various: clean up isatty() handling

As per https://github.com/systemd/systemd/pull/30547#discussion_r1434371627
This commit is contained in:
Mike Yuan
2023-12-22 23:06:49 +08:00
parent 76270f5c09
commit dd9c8da865
12 changed files with 26 additions and 29 deletions
+2 -6
View File
@@ -670,12 +670,8 @@ static int chown_terminal(int fd, uid_t uid) {
assert(fd >= 0);
/* Before we chown/chmod the TTY, let's ensure this is actually a tty */
if (isatty(fd) < 1) {
if (IN_SET(errno, EINVAL, ENOTTY))
return 0; /* not a tty */
return -errno;
}
if (!isatty_safe(fd))
return 0;
/* This might fail. What matters are the results. */
r = fchmod_and_chown(fd, TTY_MODE, uid, GID_INVALID);