summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>1996-02-02 01:12:19 +0000
committerMiles Bader <miles@gnu.org>1996-02-02 01:12:19 +0000
commitf813b59cdcee8c3d2939b4d0d428cb7a93b99a23 (patch)
treea700fb03bb8074399a6b4b3df303520499699dc2
parent88c9a9b2ea6f5932168d6f7e6914367795ca4c20 (diff)
(main): Get the ttyname to chown.
-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 (),