chiark / gitweb /
condition: in ConditionPathIsExecutable follow symlinks
[elogind.git] / src / condition.c
index 76ee0370d22c398ef87bcad6331220ea16c0b8ff..933aec8485ebb5ab0ec048d8ed2a5324e45493c6 100644 (file)
@@ -75,7 +75,7 @@ static bool test_kernel_command_line(const char *parameter) {
 
         assert(parameter);
 
-        if (detect_virtualization(NULL) > 0)
+        if (detect_container(NULL) > 0)
                 return false;
 
         if ((r = read_one_line_file("/proc/cmdline", &line)) < 0) {
@@ -168,6 +168,15 @@ bool condition_test(Condition *c) {
                 return !(k == -ENOENT || k > 0) == !c->negate;
         }
 
+        case CONDITION_FILE_IS_EXECUTABLE: {
+                struct stat st;
+
+                if (stat(c->parameter, &st) < 0)
+                        return !c->negate;
+
+                return (S_ISREG(st.st_mode) && (st.st_mode & 0111)) == !c->negate;
+        }
+
         case CONDITION_KERNEL_COMMAND_LINE:
                 return test_kernel_command_line(c->parameter) == !c->negate;