terminal-util: drop support for pre-TIOCGPTPEER kernels
Our minimum baseline is now far beyond 4.13, hence let's drop these fallback paths.
This commit is contained in:
@@ -2324,7 +2324,7 @@ int terminal_is_pty_fd(int fd) {
|
||||
return true;
|
||||
}
|
||||
|
||||
int pty_open_peer_racefree(int fd, int mode) {
|
||||
int pty_open_peer(int fd, int mode) {
|
||||
assert(fd >= 0);
|
||||
|
||||
/* Opens the peer PTY using the new race-free TIOCGPTPEER ioctl() (kernel 4.13).
|
||||
@@ -2339,9 +2339,6 @@ int pty_open_peer_racefree(int fd, int mode) {
|
||||
if (peer_fd >= 0)
|
||||
return peer_fd;
|
||||
|
||||
if (ERRNO_IS_IOCTL_NOT_SUPPORTED(errno)) /* new ioctl() is not supported, return a clear error */
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
if (errno != EIO)
|
||||
return -errno;
|
||||
|
||||
@@ -2352,31 +2349,3 @@ int pty_open_peer_racefree(int fd, int mode) {
|
||||
(void) usleep_safe(50 * USEC_PER_MSEC);
|
||||
}
|
||||
}
|
||||
|
||||
int pty_open_peer(int fd, int mode) {
|
||||
int r;
|
||||
|
||||
assert(fd >= 0);
|
||||
|
||||
/* Opens the peer PTY using the new race-free TIOCGPTPEER ioctl() (kernel 4.13) if it is
|
||||
* available. Otherwise falls back to the POSIX ptsname() + open() logic.
|
||||
*
|
||||
* Because of the fallback path this is not safe to be called on PTYs from other namespaces. (Because
|
||||
* we open the peer PTY name there via a path in the file system.) */
|
||||
|
||||
// TODO: Remove fallback path once baseline is updated to >= 4.13, i.e. systemd v258
|
||||
|
||||
int peer_fd = pty_open_peer_racefree(fd, mode);
|
||||
if (peer_fd >= 0)
|
||||
return peer_fd;
|
||||
if (!ERRNO_IS_NEG_NOT_SUPPORTED(peer_fd))
|
||||
return peer_fd;
|
||||
|
||||
/* The racy fallback path */
|
||||
_cleanup_free_ char *peer_path = NULL;
|
||||
r = ptsname_malloc(fd, &peer_path);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return open_terminal(peer_path, mode);
|
||||
}
|
||||
|
||||
@@ -165,7 +165,6 @@ int terminal_fix_size(int input_fd, int output_fd);
|
||||
|
||||
int terminal_is_pty_fd(int fd);
|
||||
|
||||
int pty_open_peer_racefree(int fd, int mode);
|
||||
int pty_open_peer(int fd, int mode);
|
||||
|
||||
static inline bool osc_char_is_valid(char c) {
|
||||
|
||||
Reference in New Issue
Block a user