chiark / gitweb /
kmsg-syslogd: pass facility value into kmsg
[elogind.git] / src / condition.c
index 1dce276c00575004f48ecde1ff40de576a8ed771..b404b49c925eba8c92a6a97420d0829c148c6c3a 100644 (file)
@@ -30,7 +30,9 @@
 Condition* condition_new(ConditionType type, const char *parameter, bool trigger, bool negate) {
         Condition *c;
 
-        c = new0(Condition, 1);
+        if (!(c = new0(Condition, 1)))
+                return NULL;
+
         c->type = type;
         c->trigger = trigger;
         c->negate = negate;
@@ -134,6 +136,14 @@ bool condition_test(Condition *c) {
         case CONDITION_PATH_EXISTS:
                 return (access(c->parameter, F_OK) >= 0) == !c->negate;
 
+        case CONDITION_PATH_IS_DIRECTORY: {
+                struct stat st;
+
+                if (lstat(c->parameter, &st) < 0)
+                        return !c->negate;
+                return S_ISDIR(st.st_mode) == !c->negate;
+        }
+
         case CONDITION_DIRECTORY_NOT_EMPTY: {
                 int k;