]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tmpfiles: fix borked assert
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 6 Jul 2021 14:41:28 +0000 (16:41 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 20 Jul 2021 16:00:38 +0000 (18:00 +0200)
It seems that fd_set_perms() is always called after checking that
fd >= 0 (also when called as action() in glob_item_recursively()),
so it seems that the assertion really came from fd==0.

Fixes #20140.

Also three other similar cases are updated.

(cherry picked from commit b4b0f87c6275dde32769c2e75231caa1d4c21f9b)
(cherry picked from commit 1dcecfc50b6c4db3b76b81765403f84c06ecf225)

src/tmpfiles/tmpfiles.c

index a1f421392376d1418af0d56b522b038e31f0df1d..341f83fd5af16804d6af70f271926281968f4e93 100644 (file)
@@ -837,7 +837,7 @@ static int fd_set_perms(Item *i, int fd, const char *path, const struct stat *st
         int r;
 
         assert(i);
-        assert(fd);
+        assert(fd >= 0);
         assert(path);
 
         if (!i->mode_set && !i->uid_set && !i->gid_set)
@@ -1021,7 +1021,7 @@ static int fd_set_xattrs(Item *i, int fd, const char *path, const struct stat *s
         char **name, **value;
 
         assert(i);
-        assert(fd);
+        assert(fd >= 0);
         assert(path);
 
         xsprintf(procfs_path, "/proc/self/fd/%i", fd);
@@ -1124,7 +1124,7 @@ static int fd_set_acls(Item *item, int fd, const char *path, const struct stat *
         struct stat stbuf;
 
         assert(item);
-        assert(fd);
+        assert(fd >= 0);
         assert(path);
 
         if (!st) {
@@ -1278,7 +1278,7 @@ static int fd_set_attribute(Item *item, int fd, const char *path, const struct s
         int r;
 
         assert(item);
-        assert(fd);
+        assert(fd >= 0);
         assert(path);
 
         if (!item->attribute_set || item->attribute_mask == 0)