popen.c (90276) | popen.c (159142) |
---|---|
1/* 2 * Copyright (c) 1988 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * This code is derived from software written by Ken Arnold and 6 * published in UNIX Review, Vol. 6, No. 8. 7 * 8 * Redistribution and use in source and binary forms are permitted --- 14 unchanged lines hidden (view full) --- 23 * globbing stuff since we don't need it. also execvp instead of execv. 24 */ 25 26#ifndef lint 27#if 0 28static char sccsid[] = "@(#)popen.c 5.7 (Berkeley) 2/14/89"; 29#endif 30static const char rcsid[] = | 1/* 2 * Copyright (c) 1988 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * This code is derived from software written by Ken Arnold and 6 * published in UNIX Review, Vol. 6, No. 8. 7 * 8 * Redistribution and use in source and binary forms are permitted --- 14 unchanged lines hidden (view full) --- 23 * globbing stuff since we don't need it. also execvp instead of execv. 24 */ 25 26#ifndef lint 27#if 0 28static char sccsid[] = "@(#)popen.c 5.7 (Berkeley) 2/14/89"; 29#endif 30static const char rcsid[] = |
31 "$FreeBSD: head/usr.sbin/cron/cron/popen.c 90276 2002-02-06 02:00:07Z bbraun $"; | 31 "$FreeBSD: head/usr.sbin/cron/cron/popen.c 159142 2006-06-01 15:03:06Z maxim $"; |
32#endif /* not lint */ 33 34#include "cron.h" 35#include <sys/signal.h> 36#include <fcntl.h> 37#include <paths.h> 38#if defined(SYSLOG) 39# include <syslog.h> --- 130 unchanged lines hidden (view full) --- 170 (void) endpwent(); 171 else { 172 /* fall back to the old method */ 173 (void) endpwent(); 174# endif 175 /* set our directory, uid and gid. Set gid first, 176 * since once we set uid, we've lost root privledges. 177 */ | 32#endif /* not lint */ 33 34#include "cron.h" 35#include <sys/signal.h> 36#include <fcntl.h> 37#include <paths.h> 38#if defined(SYSLOG) 39# include <syslog.h> --- 130 unchanged lines hidden (view full) --- 170 (void) endpwent(); 171 else { 172 /* fall back to the old method */ 173 (void) endpwent(); 174# endif 175 /* set our directory, uid and gid. Set gid first, 176 * since once we set uid, we've lost root privledges. 177 */ |
178 setgid(e->gid); | 178 if (setgid(e->gid) != 0) 179 _exit(ERROR_EXIT); |
179# if defined(BSD) | 180# if defined(BSD) |
180 initgroups(usernm, e->gid); | 181 if (initgroups(usernm, e->gid) != 0) 182 _exit(ERROR_EXIT); |
181# endif | 183# endif |
182 setlogin(usernm); 183 setuid(e->uid); /* we aren't root after this..*/ | 184 if (setlogin(usernm) != 0) 185 _exit(ERROR_EXIT); 186 if (setuid(e->uid) != 0) 187 _exit(ERROR_EXIT); 188 /* we aren't root after this..*/ |
184#if defined(LOGIN_CAP) 185 } 186 if (lc != NULL) 187 login_close(lc); 188#endif 189 chdir(env_get("HOME", e->envp)); 190 } 191#if WANT_GLOBBING --- 49 unchanged lines hidden --- | 189#if defined(LOGIN_CAP) 190 } 191 if (lc != NULL) 192 login_close(lc); 193#endif 194 chdir(env_get("HOME", e->envp)); 195 } 196#if WANT_GLOBBING --- 49 unchanged lines hidden --- |