]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tmpfiles: shortcut path_set_perms() if there's nothing to do
authorLennart Poettering <lennart@poettering.net>
Mon, 22 Jan 2018 20:10:27 +0000 (21:10 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 23 Jan 2018 20:19:00 +0000 (21:19 +0100)
No need to open() anything in that case, hence don't.

src/tmpfiles/tmpfiles.c

index 3fdbfca9a2773e31ad807eeef7a9312bb7e53fb9..c11a649c2f96da389471915e2c3367f4a5e386e8 100644 (file)
@@ -761,6 +761,9 @@ static int path_set_perms(Item *i, const char *path) {
         assert(i);
         assert(path);
 
+        if (!i->mode_set && !i->uid_set && !i->gid_set)
+                goto shortcut;
+
         /* We open the file with O_PATH here, to make the operation
          * somewhat atomic. Also there's unfortunately no fchmodat()
          * with AT_SYMLINK_NOFOLLOW, hence we emulate it here via
@@ -778,7 +781,6 @@ static int path_set_perms(Item *i, const char *path) {
                 }
 
                 log_full_errno(level, errno, "Adjusting owner and mode for %s failed: %m", path);
-
                 return r;
         }
 
@@ -830,6 +832,7 @@ static int path_set_perms(Item *i, const char *path) {
 
         fd = safe_close(fd);
 
+shortcut:
         return label_fix(path, false, false);
 }