diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2002-03-16 18:40:01 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2002-03-16 18:40:01 +0000 |
commit | ae4ab6f021abf999cafe2d94fb55ef68d9dca5f2 (patch) | |
tree | e5446b5c23c4bc7c993f1177880f7f99a364eaad /libexec/atrun | |
parent | 514233f1901c9df60ca55bd73df68eeb82a85ab6 (diff) |
Avoid potential corruption of passwd pointer auth_approval().
Similar to my recent rshd change.
Diffstat (limited to 'libexec/atrun')
-rw-r--r-- | libexec/atrun/atrun.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/libexec/atrun/atrun.c b/libexec/atrun/atrun.c index c36563913e0..face2bd2a4a 100644 --- a/libexec/atrun/atrun.c +++ b/libexec/atrun/atrun.c @@ -1,4 +1,4 @@ -/* $OpenBSD: atrun.c,v 1.15 2001/08/27 16:18:58 deraadt Exp $ */ +/* $OpenBSD: atrun.c,v 1.16 2002/03/16 18:40:00 millert Exp $ */ /* * atrun.c - run jobs queued by at; run with root privileges. @@ -71,7 +71,7 @@ /* File scope variables */ static char *namep; -static char rcsid[] = "$OpenBSD: atrun.c,v 1.15 2001/08/27 16:18:58 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: atrun.c,v 1.16 2002/03/16 18:40:00 millert Exp $"; static int debug = 0; /* Local functions */ @@ -134,6 +134,7 @@ run_file(filename, uid, gid) uid_t nuid; gid_t ngid; login_cap_t *lc; + auth_session_t *as; PRIV_START @@ -160,6 +161,13 @@ run_file(filename, uid, gid) uid, filename); exit(EXIT_FAILURE); } + + as = auth_open(); + if (as == NULL || auth_setpwd(as, pw) != 0) { + syslog(LOG_ERR,"Unable to allocate memory - aborting job %s", + filename); + exit(EXIT_FAILURE); + } PRIV_START stream = fopen(filename, "r"); @@ -307,9 +315,10 @@ run_file(filename, uid, gid) if (setusercontext(lc, pw, pw->pw_uid, LOGIN_SETALL) < 0) perr("Cannot set user context"); - if (auth_approval(NULL, lc, pw->pw_name, "at") <= 0) + if (auth_approval(as, lc, pw->pw_name, "at") <= 0) perr2("Approval failure for ", pw->pw_name); + auth_close(as); login_close(lc); if (chdir(pw->pw_dir) < 0) |