]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tmpfiles: improve warning message and use O_NOCTTY
authorChristian Göttsche <cgzones@googlemail.com>
Mon, 27 May 2024 13:38:18 +0000 (15:38 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 28 May 2024 19:58:30 +0000 (21:58 +0200)
Mention in the warning message for a failed open on a to be removed file
why systemd-tmpfiles tried to open it.

Also open the file with the O_NOCTTY flag, since it should never become
the controlling terminal.

src/tmpfiles/tmpfiles.c

index 3ade4ee32e165ec1dbaa2086f0846e3c61897812..807925f199d4eb631d8415825437fe57b7172c51 100644 (file)
@@ -892,9 +892,9 @@ static int dir_cleanup(
                                 continue;
 
                         if (!arg_dry_run) {
-                                fd = xopenat(dirfd(d), de->d_name, O_RDONLY|O_CLOEXEC|O_NOFOLLOW|O_NOATIME|O_NONBLOCK);
+                                fd = xopenat(dirfd(d), de->d_name, O_RDONLY|O_CLOEXEC|O_NOFOLLOW|O_NOATIME|O_NONBLOCK|O_NOCTTY);
                                 if (fd < 0 && !IN_SET(fd, -ENOENT, -ELOOP))
-                                        log_warning_errno(fd, "Opening file \"%s\" failed, ignoring: %m", sub_path);
+                                        log_warning_errno(fd, "Opening file \"%s\" failed, proceeding without lock: %m", sub_path);
                                 if (fd >= 0 && flock(fd, LOCK_EX|LOCK_NB) < 0 && errno == EAGAIN) {
                                         log_debug_errno(errno, "Couldn't acquire shared BSD lock on file \"%s\", skipping: %m", sub_path);
                                         continue;