From f813b59cdcee8c3d2939b4d0d428cb7a93b99a23 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Fri, 2 Feb 1996 01:12:19 +0000 Subject: (main): Get the ttyname to chown. --- utils/login.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'utils') diff --git a/utils/login.c b/utils/login.c index ba69429f..05d94920 100644 --- a/utils/login.c +++ b/utils/login.c @@ -850,12 +850,16 @@ main(int argc, char *argv[]) if (eff_uids->num | eff_gids->num) { - /* Change the terminal to be owned by the user. */ - err = chown (tty, - eff_uids->num ? eff_uids->ids[0] : -1, - eff_gids->num ? eff_gids->ids[0] : -1); - if (err) - error (0, err, "chown: %s", tty); + char *tty = ttyname (0); + if (tty) + { + /* Change the terminal to be owned by the user. */ + err = chown (tty, + eff_uids->num ? eff_uids->ids[0] : -1, + eff_gids->num ? eff_gids->ids[0] : -1); + if (err) + error (0, err, "chown: %s", tty); + } } err = file_exec (exec, mach_task_self (), -- cgit v1.2.3