]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
chattr-util: set O_NOCTTY when reopening O_PATH fd
authorMike Yuan <me@yhndnzj.com>
Sat, 7 Sep 2024 00:32:01 +0000 (02:32 +0200)
committerMike Yuan <me@yhndnzj.com>
Sat, 7 Sep 2024 12:46:18 +0000 (14:46 +0200)
Follow-up for 07862c9fc2becdc4bbe112b023591d2ab2dd032b

src/basic/chattr-util.c

index 13d46f26aaafdf94e3cadff89d5779d2116176aa..02d2cc2e526253dca36b8cb1088ee52435ead815 100644 (file)
@@ -138,6 +138,7 @@ int read_attr_fd(int fd, unsigned *ret) {
         struct stat st;
 
         assert(fd >= 0);
+        assert(ret);
 
         if (fstat(fd, &st) < 0)
                 return -errno;
@@ -156,7 +157,7 @@ int read_attr_at(int dir_fd, const char *path, unsigned *ret) {
         assert(ret);
 
         if (isempty(path)) {
-                fd = fd_reopen_condition(dir_fd, O_RDONLY|O_CLOEXEC, O_PATH, &fd_close); /* drop O_PATH if it is set */
+                fd = fd_reopen_condition(dir_fd, O_RDONLY|O_CLOEXEC|O_NOCTTY, O_PATH, &fd_close); /* drop O_PATH if it is set */
                 if (fd < 0)
                         return fd;
         } else {