diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/condition.c | 9 | ||||
-rw-r--r-- | src/condition.h | 1 | ||||
-rw-r--r-- | src/load-fragment.c | 1 |
3 files changed, 11 insertions, 0 deletions
diff --git a/src/condition.c b/src/condition.c index 76ee0370d2..f9202f6850 100644 --- a/src/condition.c +++ b/src/condition.c @@ -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 (lstat(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; diff --git a/src/condition.h b/src/condition.h index ff896a793a..672996e836 100644 --- a/src/condition.h +++ b/src/condition.h @@ -31,6 +31,7 @@ typedef enum ConditionType { CONDITION_PATH_EXISTS_GLOB, CONDITION_PATH_IS_DIRECTORY, CONDITION_DIRECTORY_NOT_EMPTY, + CONDITION_FILE_IS_EXECUTABLE, CONDITION_KERNEL_COMMAND_LINE, CONDITION_VIRTUALIZATION, CONDITION_SECURITY, diff --git a/src/load-fragment.c b/src/load-fragment.c index 05e60bf8fd..5c1dff60b8 100644 --- a/src/load-fragment.c +++ b/src/load-fragment.c @@ -2003,6 +2003,7 @@ static int load_from_path(Unit *u, const char *path) { { "ConditionPathExistsGlob", config_parse_condition_path, CONDITION_PATH_EXISTS_GLOB, u, "Unit" }, { "ConditionPathIsDirectory", config_parse_condition_path, CONDITION_PATH_IS_DIRECTORY, u, "Unit" }, { "ConditionDirectoryNotEmpty", config_parse_condition_path, CONDITION_DIRECTORY_NOT_EMPTY, u, "Unit" }, + { "ConditionFileIsExecutable", config_parse_condition_path, CONDITION_FILE_IS_EXECUTABLE, u, "Unit" }, { "ConditionKernelCommandLine", config_parse_condition_string, CONDITION_KERNEL_COMMAND_LINE, u, "Unit" }, { "ConditionVirtualization", config_parse_condition_string, CONDITION_VIRTUALIZATION, u, "Unit" }, { "ConditionSecurity", config_parse_condition_string, CONDITION_SECURITY, u, "Unit" }, |