summaryrefslogtreecommitdiff
path: root/utils/login.c
diff options
context:
space:
mode:
Diffstat (limited to 'utils/login.c')
-rw-r--r--utils/login.c16
1 files changed, 10 insertions, 6 deletions
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 (),