diff options
| author | Maxim Konovalov <maxim@FreeBSD.org> | 2006-07-01 07:18:16 +0000 |
|---|---|---|
| committer | Maxim Konovalov <maxim@FreeBSD.org> | 2006-07-01 07:18:16 +0000 |
| commit | dbd61bdf4e78d64ba0e2f4d98b83eb046bc311b2 (patch) | |
| tree | b08ae03b16728362a966a77dc80c1010c4cde8f5 /usr.sbin/cron | |
| parent | 41f97ccf7318e93dc1f8b10bcc310f231eaa69dd (diff) | |
Notes
Diffstat (limited to 'usr.sbin/cron')
| -rw-r--r-- | usr.sbin/cron/cron/do_command.c | 25 | ||||
| -rw-r--r-- | usr.sbin/cron/cron/popen.c | 13 |
2 files changed, 30 insertions, 8 deletions
diff --git a/usr.sbin/cron/cron/do_command.c b/usr.sbin/cron/cron/do_command.c index 258e4a2b6e3c..1e6fe05502e3 100644 --- a/usr.sbin/cron/cron/do_command.c +++ b/usr.sbin/cron/cron/do_command.c @@ -245,12 +245,29 @@ child_process(e, u) /* set our directory, uid and gid. Set gid first, * since once we set uid, we've lost root privledges. */ - setgid(e->gid); + if (setgid(e->gid) != 0) { + log_it(usernm, getpid(), + "error", "setgid failed"); + exit(ERROR_EXIT); + } # if defined(BSD) - initgroups(usernm, e->gid); + if (initgroups(usernm, e->gid) != 0) { + log_it(usernm, getpid(), + "error", "initgroups failed"); + exit(ERROR_EXIT); + } # endif - setlogin(usernm); - setuid(e->uid); /* we aren't root after this..*/ + if (setlogin(usernm) != 0) { + log_it(usernm, getpid(), + "error", "setlogin failed"); + exit(ERROR_EXIT); + } + if (setuid(e->uid) != 0) { + log_it(usernm, getpid(), + "error", "setuid failed"); + exit(ERROR_EXIT); + } + /* we aren't root after this..*/ #if defined(LOGIN_CAP) } if (lc != NULL) diff --git a/usr.sbin/cron/cron/popen.c b/usr.sbin/cron/cron/popen.c index 806676da4429..06e8c1c75b3b 100644 --- a/usr.sbin/cron/cron/popen.c +++ b/usr.sbin/cron/cron/popen.c @@ -175,12 +175,17 @@ cron_popen(program, type, e) /* set our directory, uid and gid. Set gid first, * since once we set uid, we've lost root privledges. */ - setgid(e->gid); + if (setgid(e->gid) != 0) + _exit(ERROR_EXIT); # if defined(BSD) - initgroups(usernm, e->gid); + if (initgroups(usernm, e->gid) != 0) + _exit(ERROR_EXIT); # endif - setlogin(usernm); - setuid(e->uid); /* we aren't root after this..*/ + if (setlogin(usernm) != 0) + _exit(ERROR_EXIT); + if (setuid(e->uid) != 0) + _exit(ERROR_EXIT); + /* we aren't root after this..*/ #if defined(LOGIN_CAP) } if (lc != NULL) |
