]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tmpfiles: use CHASE_WARN in addition to CHASE_SAFE
authorFranck Bui <fbui@suse.com>
Wed, 28 Nov 2018 15:09:16 +0000 (16:09 +0100)
committerFranck Bui <fbui@suse.com>
Mon, 10 Dec 2018 08:19:14 +0000 (09:19 +0100)
and let's emit a more comprehensive warning when an unsafe transition is
encountered.

Before this patch:

 Unsafe symlinks encountered in /run/nrpe, refusing.

After:

 Detected unsafe path transition / → /run during canonicalization of /run/nrpe.

src/tmpfiles/tmpfiles.c

index 1f2caf5f7384fc2d8ef55b4a05091a33844976ca..d4e4f0c53565c40bd4b6bf9215c2c112d8d0e4d0 100644 (file)
@@ -861,10 +861,8 @@ static int path_open_parent_safe(const char *path) {
         if (!dn)
                 return log_oom();
 
-        fd = chase_symlinks(dn, NULL, CHASE_OPEN|CHASE_SAFE, NULL);
-        if (fd == -ENOLINK)
-                return log_error_errno(fd, "Unsafe symlinks encountered in %s, refusing.", path);
-        if (fd < 0)
+        fd = chase_symlinks(dn, NULL, CHASE_OPEN|CHASE_SAFE|CHASE_WARN, NULL);
+        if (fd < 0 && fd != -ENOLINK)
                 return log_error_errno(fd, "Failed to validate path %s: %m", path);
 
         return fd;
@@ -884,10 +882,8 @@ static int path_open_safe(const char *path) {
                                        "Failed to open invalid path '%s'.",
                                        path);
 
-        fd = chase_symlinks(path, NULL, CHASE_OPEN|CHASE_SAFE|CHASE_NOFOLLOW, NULL);
-        if (fd == -ENOLINK)
-                return log_error_errno(fd, "Unsafe symlinks encountered in %s, refusing.", path);
-        if (fd < 0)
+        fd = chase_symlinks(path, NULL, CHASE_OPEN|CHASE_SAFE|CHASE_WARN|CHASE_NOFOLLOW, NULL);
+        if (fd < 0 && fd != -ENOLINK)
                 return log_error_errno(fd, "Failed to validate path %s: %m", path);
 
         return fd;