nspawn,pty: port over to new ptsname_malloc() helper

This commit is contained in:
Lennart Poettering 2014-12-23 02:02:08 +01:00
parent ee451d766a
commit 611b312b7d
2 changed files with 6 additions and 7 deletions

View file

@ -2931,13 +2931,12 @@ static int determine_names(void) {
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
_cleanup_free_ char *device_path = NULL, *root_device = NULL, *home_device = NULL, *srv_device = NULL; _cleanup_free_ char *device_path = NULL, *root_device = NULL, *home_device = NULL, *srv_device = NULL, *console = NULL;
bool root_device_rw = true, home_device_rw = true, srv_device_rw = true; bool root_device_rw = true, home_device_rw = true, srv_device_rw = true;
_cleanup_close_ int master = -1, image_fd = -1; _cleanup_close_ int master = -1, image_fd = -1;
_cleanup_close_pair_ int kmsg_socket_pair[2] = { -1, -1 }; _cleanup_close_pair_ int kmsg_socket_pair[2] = { -1, -1 };
_cleanup_fdset_free_ FDSet *fds = NULL; _cleanup_fdset_free_ FDSet *fds = NULL;
int r, n_fd_passed, loop_nr = -1; int r, n_fd_passed, loop_nr = -1;
const char *console = NULL;
char veth_name[IFNAMSIZ]; char veth_name[IFNAMSIZ];
bool secondary = false, remove_subvol = false; bool secondary = false, remove_subvol = false;
sigset_t mask, mask_chld; sigset_t mask, mask_chld;
@ -3094,9 +3093,9 @@ int main(int argc, char *argv[]) {
goto finish; goto finish;
} }
console = ptsname(master); r = ptsname_malloc(master, &console);
if (!console) { if (r < 0) {
r = log_error_errno(errno, "Failed to determine tty name: %m"); r = log_error_errno(r, "Failed to determine tty name: %m");
goto finish; goto finish;
} }

View file

@ -194,13 +194,13 @@ int pty_get_fd(Pty *pty) {
} }
int pty_make_child(Pty *pty) { int pty_make_child(Pty *pty) {
char slave_name[1024]; _cleanup_free_ char *slave_name = NULL;
int r, fd; int r, fd;
assert_return(pty, -EINVAL); assert_return(pty, -EINVAL);
assert_return(pty_is_unknown(pty), -EALREADY); assert_return(pty_is_unknown(pty), -EALREADY);
r = ptsname_r(pty->fd, slave_name, sizeof(slave_name)); r = ptsname_malloc(pty->fd, &slave_name);
if (r < 0) if (r < 0)
return -errno; return -errno;