util-lib: make sure fd_check_fstype() opens files with O_CLOEXEC

Also, O_NOCTTY is a safer bet, let's add that too.
This commit is contained in:
Lennart Poettering
2016-12-08 19:35:05 +01:00
parent eee8b7ab2e
commit 08cea7dfc0

View 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;