]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
util-lib: make sure fd_check_fstype() opens files with O_CLOEXEC
authorLennart Poettering <lennart@poettering.net>
Thu, 8 Dec 2016 18:35:05 +0000 (19:35 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 20 Dec 2016 19:00:09 +0000 (20:00 +0100)
Also, O_NOCTTY is a safer bet, let's add that too.

src/basic/stat-util.c

index 5663a29cd65b5b5a67ba4673928964f01da2c393..848572687e2201802e3466a30a289b10976e5d2a 100644 (file)
@@ -204,7 +204,7 @@ int fd_check_fstype(int fd, statfs_f_type_t magic_value) {
 int path_check_fstype(const char *path, statfs_f_type_t magic_value) {
         _cleanup_close_ int fd = -1;
 
-        fd = open(path, O_RDONLY);
+        fd = open(path, O_RDONLY|O_CLOEXEC|O_NOCTTY);
         if (fd < 0)
                 return -errno;