mirror of
https://github.com/systemd/systemd.git
synced 2025-01-10 05:18:17 +03:00
chattr-util: set O_NOCTTY when reopening O_PATH fd
Follow-up for 07862c9fc2
This commit is contained in:
parent
517e892210
commit
26f5897767
@ -138,6 +138,7 @@ int read_attr_fd(int fd, unsigned *ret) {
|
|||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
assert(fd >= 0);
|
assert(fd >= 0);
|
||||||
|
assert(ret);
|
||||||
|
|
||||||
if (fstat(fd, &st) < 0)
|
if (fstat(fd, &st) < 0)
|
||||||
return -errno;
|
return -errno;
|
||||||
@ -156,7 +157,7 @@ int read_attr_at(int dir_fd, const char *path, unsigned *ret) {
|
|||||||
assert(ret);
|
assert(ret);
|
||||||
|
|
||||||
if (isempty(path)) {
|
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)
|
if (fd < 0)
|
||||||
return fd;
|
return fd;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user