]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
terminal-util: drop unused open_terminal_in_namespace() 36027/head
authorMike Yuan <me@yhndnzj.com>
Wed, 15 Jan 2025 16:34:11 +0000 (17:34 +0100)
committerMike Yuan <me@yhndnzj.com>
Wed, 15 Jan 2025 16:46:10 +0000 (17:46 +0100)
With our baseline including TIOCGPTPEER we now systematically
open pty peer through ioctl(), i.e. this sits unused
since 1d522f1a866f911980b5eaad87182bf58c58fa32. Kill it!

src/basic/terminal-util.c
src/basic/terminal-util.h
src/machine/machine.c
src/machine/machine.h

index f1967a15c072473f4177452a4fc4197de4d0e6b7..eeeb6576239747aac7f47accc0cdd439e168eb32 100644 (file)
@@ -1413,56 +1413,6 @@ int openpt_allocate_in_namespace(
         return TAKE_FD(fd);
 }
 
-int open_terminal_in_namespace(
-                const PidRef *pidref,
-                const char *name,
-                int mode) {
-
-        _cleanup_close_ int pidnsfd = -EBADF, mntnsfd = -EBADF, usernsfd = -EBADF, rootfd = -EBADF;
-        _cleanup_close_pair_ int pair[2] = EBADF_PAIR;
-        int r;
-
-        assert(name);
-
-        r = pidref_namespace_open(pidref, &pidnsfd, &mntnsfd, /* ret_netns_fd= */ NULL, &usernsfd, &rootfd);
-        if (r < 0)
-                return r;
-
-        if (socketpair(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0, pair) < 0)
-                return -errno;
-
-        r = namespace_fork(
-                        "(sd-terminalns)",
-                        "(sd-terminal)",
-                        /* except_fds= */ NULL,
-                        /* n_except_fds= */ 0,
-                        FORK_RESET_SIGNALS|FORK_DEATHSIG_SIGKILL|FORK_WAIT,
-                        pidnsfd,
-                        mntnsfd,
-                        /* netnsd_fd= */ -EBADF,
-                        usernsfd,
-                        rootfd,
-                        /* ret_pid= */ NULL);
-        if (r < 0)
-                return r;
-        if (r == 0) {
-                pair[0] = safe_close(pair[0]);
-
-                int pty_fd = open_terminal(name, mode|O_NOCTTY|O_CLOEXEC);
-                if (pty_fd < 0)
-                        _exit(EXIT_FAILURE);
-
-                if (send_one_fd(pair[1], pty_fd, 0) < 0)
-                        _exit(EXIT_FAILURE);
-
-                _exit(EXIT_SUCCESS);
-        }
-
-        pair[1] = safe_close(pair[1]);
-
-        return receive_one_fd(pair[0], 0);
-}
-
 static bool on_dev_null(void) {
         struct stat dst, ost, est;
 
index a9c8ba7789d7e2abeb1a168131d34c68dcab2492..d6dd394bcf466e021db3805fa9d3a33a4d0f9dde 100644 (file)
@@ -145,7 +145,6 @@ int ptsname_malloc(int fd, char **ret);
 
 int openpt_allocate(int flags, char **ret_peer);
 int openpt_allocate_in_namespace(const PidRef *pidref, int flags, char **ret_peer);
-int open_terminal_in_namespace(const PidRef *pidref, const char *name, int mode);
 
 int vt_restore(int fd);
 int vt_release(int fd, bool restore_vt);
index 3bb7a94ddd455c812b39a767ab27c1847c8a99b3..76467f1bf6c390c6eba12c24f32f811a89660375 100644 (file)
@@ -688,25 +688,6 @@ int machine_openpt(Machine *m, int flags, char **ret_peer) {
         }
 }
 
-int machine_open_terminal(Machine *m, const char *path, int mode) {
-        assert(m);
-
-        switch (m->class) {
-
-        case MACHINE_HOST:
-                return open_terminal(path, mode);
-
-        case MACHINE_CONTAINER:
-                if (!pidref_is_set(&m->leader))
-                        return -EINVAL;
-
-                return open_terminal_in_namespace(&m->leader, path, mode);
-
-        default:
-                return -EOPNOTSUPP;
-        }
-}
-
 static int machine_bus_new(Machine *m, sd_bus_error *error, sd_bus **ret) {
         int r;
 
index 614d295bcab1628306a99cb06c1d28a13fffe3e2..6d972c15337606a0b6130c9d183c3914cc72ca1f 100644 (file)
@@ -102,7 +102,6 @@ const char* kill_whom_to_string(KillWhom k) _const_;
 KillWhom kill_whom_from_string(const char *s) _pure_;
 
 int machine_openpt(Machine *m, int flags, char **ret_peer);
-int machine_open_terminal(Machine *m, const char *path, int mode);
 int machine_start_getty(Machine *m, const char *ptmx_name, sd_bus_error *error);
 int machine_start_shell(Machine *m, int ptmx_fd, const char *ptmx_name, const char *user, const char *path, char **args, char **env, sd_bus_error *error);
 #define machine_default_shell_path() ("/bin/sh")