Do setlogin() before changing uid/gid, since
`at/batch' requires this. Obtained from: me && OpenBSD
This commit is contained in:
parent
dc557d030d
commit
8fad2d7e99
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=29231
@ -79,7 +79,7 @@
|
||||
/* File scope variables */
|
||||
|
||||
static char *namep;
|
||||
static char rcsid[] = "$Id: atrun.c,v 1.9 1997/03/28 15:48:03 imp Exp $";
|
||||
static char rcsid[] = "$Id: atrun.c,v 1.10 1997/04/12 01:04:50 davidn Exp $";
|
||||
static debug = 0;
|
||||
|
||||
void perr(const char *a);
|
||||
@ -283,18 +283,21 @@ run_file(const char *filename, uid_t uid, gid_t gid)
|
||||
|
||||
nice(tolower(queue) - 'a');
|
||||
|
||||
if (chdir(pentry->pw_dir))
|
||||
chdir("/");
|
||||
|
||||
if (initgroups(pentry->pw_name,pentry->pw_gid))
|
||||
perr("Cannot delete saved userids");
|
||||
|
||||
if (setgid(gid) < 0)
|
||||
if (setgid(gid) < 0 || setegid(pentry->pw_gid) < 0)
|
||||
perr("Cannot change group");
|
||||
|
||||
if (setuid(uid) < 0)
|
||||
if (setlogin(pentry->pw_name))
|
||||
perr("Cannot set login name");
|
||||
|
||||
if (setuid(uid) < 0 || seteuid(uid) < 0)
|
||||
perr("Cannot set user id");
|
||||
|
||||
if (chdir(pentry->pw_dir))
|
||||
chdir("/");
|
||||
|
||||
if(execle("/bin/sh","sh",(char *) NULL, nenvp) != 0)
|
||||
perr("Exec failed for /bin/sh");
|
||||
|
||||
@ -318,18 +321,21 @@ run_file(const char *filename, uid_t uid, gid_t gid)
|
||||
{
|
||||
PRIV_START
|
||||
|
||||
if (chdir(pentry->pw_dir))
|
||||
chdir("/");
|
||||
|
||||
if (initgroups(pentry->pw_name,pentry->pw_gid))
|
||||
perr("Cannot delete saved userids");
|
||||
|
||||
if (setgid(gid) < 0)
|
||||
if (setgid(gid) < 0 || setegid(pentry->pw_gid) < 0)
|
||||
perr("Cannot change group");
|
||||
|
||||
if (setuid(uid) < 0)
|
||||
if (setlogin(pentry->pw_name))
|
||||
perr("Cannot set login name");
|
||||
|
||||
if (setuid(uid) < 0 || seteuid(uid) < 0)
|
||||
perr("Cannot set user id");
|
||||
|
||||
if (chdir(pentry->pw_dir))
|
||||
chdir("/");
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
execl(_PATH_SENDMAIL, "sendmail", "-F", "Atrun Service",
|
||||
"-odi", "-oem",
|
||||
|
Loading…
Reference in New Issue
Block a user