diff options
author | Miles Bader <miles@gnu.org> | 1996-05-28 23:01:19 +0000 |
---|---|---|
committer | Miles Bader <miles@gnu.org> | 1996-05-28 23:01:19 +0000 |
commit | 7ed6e4be0ada170342193bf23ee2c4250daa731e (patch) | |
tree | e756f76bec1d21e40fb2ff716f2d279f2e2266c8 /utils/login.c | |
parent | 61893578d2543d5c37290d8fb60bd0d0e42613da (diff) |
(main): Fetch the parent uids before checking their number.
(dog): Don't kill session if the user logged in! Print newline before message.
Diffstat (limited to 'utils/login.c')
-rw-r--r-- | utils/login.c | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/utils/login.c b/utils/login.c index b09dbc69..01f05bc4 100644 --- a/utils/login.c +++ b/utils/login.c @@ -336,10 +336,13 @@ dog (time_t timeout, pid_t pid) exit (0); /* Give up, luser wins. */ /* None are owned. Kill session after emitting cryptic, yet stupid, message. */ + putc ('\n', stderr); error (0, 0, "Beware of dog."); } else if (err) exit (1); /* Impossible error.... XXX */ + else if (owned) + exit (0); /* Use logged in. */ else /* Give normal you-forgot-to-login message. */ { @@ -347,6 +350,8 @@ dog (time_t timeout, pid_t pid) struct timeval tv = { timeout, 0 }; fmt_named_interval (&tv, 0, interval, sizeof interval); + + putc ('\n', stderr); error (0, 0, "Timed out after %s.", interval); } @@ -489,13 +494,24 @@ main(int argc, char *argv[]) need_parent_ids (); return idvec_contains (parent_uids, uid); } - /* Returns true if the *caller* of this login program has GID. */ int parent_has_gid (gid_t gid) { need_parent_ids (); return idvec_contains (parent_gids, gid); } + /* Returns the number of parent uids. */ + int count_parent_uids () + { + need_parent_ids (); + return parent_uids->num; + } + /* Returns the number of parent gids. */ + int count_parent_gids () + { + need_parent_ids (); + return parent_gids->num; + } /* Make sure the user should be allowed to do this. */ void verify_passwd (const char *name, const char *password, @@ -597,8 +613,8 @@ main(int argc, char *argv[]) /* True if this is the user arg and there were no user options. */ int only_user = (key == ARGP_KEY_ARG - && eff_uids->num == 0 && avail_uids->num <= parent_uids->num - && eff_gids->num == 0 && avail_gids->num <= parent_gids->num); + && eff_uids->num == 0 && avail_uids->num <= count_parent_uids () + && eff_gids->num == 0 && avail_gids->num <= count_parent_gids ()); if (! pw) if (! arg) @@ -759,7 +775,7 @@ main(int argc, char *argv[]) if (err) fail (3, err, "Authentication failure", 0); - if (!no_login && parent_uids->num > 0) + if (!no_login && count_parent_uids () != 0) /* Make a new login collection (but only for real users). */ { char *user = envz_get (args, args_len, "USER"); @@ -768,7 +784,7 @@ main(int argc, char *argv[]) proc_make_login_coll (proc_server); } - if (eff_uids->num + avail_uids->num == 0 && parent_uids->num != 0) + if (eff_uids->num + avail_uids->num == 0 && count_parent_uids () != 0) /* We're transiting from having some uids to having none, which means this is probably a new login session. Unless specified otherwise, set a timer to kill this session if it hasn't aquired any ids by then. |