]> err.no Git - systemd/commitdiff
condition: add ConditionPathIsSymbolicLink
authorMichal Schmidt <mschmidt@redhat.com>
Tue, 20 Sep 2011 23:29:38 +0000 (01:29 +0200)
committerMichal Schmidt <mschmidt@redhat.com>
Tue, 20 Sep 2011 23:42:02 +0000 (01:42 +0200)
man/systemd.unit.xml
src/condition.c
src/condition.h
src/load-fragment-gperf.gperf.m4
units/var-lock.mount
units/var-run.mount

index 4437510df7c08fcba821aba97416df3e50ee5ff7..f4764f95579960208ff3f165ef3b709fa3223a55 100644 (file)
                                 <term><varname>ConditionPathExists=</varname></term>
                                 <term><varname>ConditionPathExistsGlob=</varname></term>
                                 <term><varname>ConditionPathIsDirectory=</varname></term>
+                                <term><varname>ConditionPathIsSymbolicLink=</varname></term>
                                 <term><varname>ConditionPathIsMountPoint=</varname></term>
                                 <term><varname>ConditionDirectoryNotEmpty=</varname></term>
                                 <term><varname>ConditionFileIsExecutable=</varname></term>
                                 <varname>ConditionPathExists=</varname>
                                 but verifies whether a certain path
                                 exists and is a
-                                directory. <varname>ConditionPathIsMountPoint=</varname>
+                                directory. <varname>ConditionPathIsSymbolicLink=</varname>
+                                is similar to
+                                <varname>ConditionPathExists=</varname>
+                                but verifies whether a certain path
+                                exists and is a
+                                symbolic link. <varname>ConditionPathIsMountPoint=</varname>
                                 is similar to
                                 <varname>ConditionPathExists=</varname>
                                 but verifies whether a certain path
                                 prefix an argument with the pipe
                                 symbol and an exclamation mark the
                                 pipe symbol must be passed first, the
-                                exclamation second. All path checks
-                                follow symlinks.</para></listitem>
+                                exclamation second. Except for
+                                <varname>ConditionPathIsSymbolicLink=</varname>,
+                                all path checks follow symlinks.</para></listitem>
                         </varlistentry>
 
                         <varlistentry>
index 7f8564966a22cdc39dcce79eaa693c445da9d2f3..f84c81bd811cd48d2b8abbbf5424bd697a6f7db2 100644 (file)
@@ -167,6 +167,14 @@ bool condition_test(Condition *c) {
                 return S_ISDIR(st.st_mode) == !c->negate;
         }
 
+        case CONDITION_PATH_IS_SYMBOLIC_LINK: {
+                struct stat st;
+
+                if (lstat(c->parameter, &st) < 0)
+                        return !c->negate;
+                return S_ISLNK(st.st_mode) == !c->negate;
+        }
+
         case CONDITION_PATH_IS_MOUNT_POINT:
                 return (path_is_mount_point(c->parameter, true) > 0) == !c->negate;
 
@@ -256,6 +264,7 @@ static const char* const condition_type_table[_CONDITION_TYPE_MAX] = {
         [CONDITION_PATH_EXISTS] = "ConditionPathExists",
         [CONDITION_PATH_EXISTS_GLOB] = "ConditionPathExistsGlob",
         [CONDITION_PATH_IS_DIRECTORY] = "ConditionPathIsDirectory",
+        [CONDITION_PATH_IS_SYMBOLIC_LINK] = "ConditionPathIsSymbolicLink",
         [CONDITION_PATH_IS_MOUNT_POINT] = "ConditionPathIsMountPoint",
         [CONDITION_DIRECTORY_NOT_EMPTY] = "ConditionDirectoryNotEmpty",
         [CONDITION_KERNEL_COMMAND_LINE] = "ConditionKernelCommandLine",
index 66b020fc8c6040c28f9d8401d21eac547e7395b3..dd65aa60543895ce327475a8dfb7fb3afdb766e7 100644 (file)
@@ -30,6 +30,7 @@ typedef enum ConditionType {
         CONDITION_PATH_EXISTS,
         CONDITION_PATH_EXISTS_GLOB,
         CONDITION_PATH_IS_DIRECTORY,
+        CONDITION_PATH_IS_SYMBOLIC_LINK,
         CONDITION_PATH_IS_MOUNT_POINT,
         CONDITION_DIRECTORY_NOT_EMPTY,
         CONDITION_FILE_IS_EXECUTABLE,
index 370a7a7eb64988143fc8b689ed26253164024cea..7749b88dfb2c4ae2bcc36d596a1e763cbf8c7775 100644 (file)
@@ -112,6 +112,7 @@ Unit.JobTimeoutSec,              config_parse_usec,                  0,
 Unit.ConditionPathExists,        config_parse_unit_condition_path,   CONDITION_PATH_EXISTS,         0
 Unit.ConditionPathExistsGlob,    config_parse_unit_condition_path,   CONDITION_PATH_EXISTS_GLOB,    0
 Unit.ConditionPathIsDirectory,   config_parse_unit_condition_path,   CONDITION_PATH_IS_DIRECTORY,   0
+Unit.ConditionPathIsSymbolicLink,config_parse_unit_condition_path,   CONDITION_PATH_IS_SYMBOLIC_LINK,0
 Unit.ConditionPathIsMountPoint,  config_parse_unit_condition_path,   CONDITION_PATH_IS_MOUNT_POINT, 0
 Unit.ConditionDirectoryNotEmpty, config_parse_unit_condition_path,   CONDITION_DIRECTORY_NOT_EMPTY, 0
 Unit.ConditionFileIsExecutable,  config_parse_unit_condition_path,   CONDITION_FILE_IS_EXECUTABLE,  0
index 80e1bab2618fe62872d51c7c47c8016b10813fd2..07277adac3a299cd80e30272daf437908b8effd4 100644 (file)
@@ -10,6 +10,7 @@ Description=Lock Directory
 Before=local-fs.target
 # skip mounting if the directory does not exist or is a symlink
 ConditionPathIsDirectory=/var/lock
+ConditionPathIsSymbolicLink=!/var/lock
 
 [Mount]
 What=/run/lock
index c513dfecd23a8cdafc10f33efd6a5350d76bcee7..ab4da424c966e99a6ee521f36c1c7b0d44cc6e47 100644 (file)
@@ -10,6 +10,7 @@ Description=Runtime Directory
 Before=local-fs.target
 # skip mounting if the directory does not exist or is a symlink
 ConditionPathIsDirectory=/var/run
+ConditionPathIsSymbolicLink=!/var/run
 
 [Mount]
 What=/run