Deleted Added
full compact
do_command.c (10660) do_command.c (20573)
1/* Copyright 1988,1990,1993,1994 by Paul Vixie
2 * All rights reserved
3 *
4 * Distribute freely, except: don't remove my name from the source or
5 * documentation (don't take credit for my work), mark your changes (don't
6 * get me blamed for your possible bugs), don't alter or remove this
7 * notice. May be sold if buildable source is provided to buyer. No
8 * warrantee of any kind, express or implied, is included with this
9 * software; use at your own risk, responsibility for damages (if any) to
10 * anyone resulting from the use of this software rests entirely with the
11 * user.
12 *
13 * Send bug reports, bug fixes, enhancements, requests, flames, etc., and
14 * I'll try to keep a version up to date. I can be reached as follows:
15 * Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
16 */
17
18#if !defined(lint) && !defined(LINT)
1/* Copyright 1988,1990,1993,1994 by Paul Vixie
2 * All rights reserved
3 *
4 * Distribute freely, except: don't remove my name from the source or
5 * documentation (don't take credit for my work), mark your changes (don't
6 * get me blamed for your possible bugs), don't alter or remove this
7 * notice. May be sold if buildable source is provided to buyer. No
8 * warrantee of any kind, express or implied, is included with this
9 * software; use at your own risk, responsibility for damages (if any) to
10 * anyone resulting from the use of this software rests entirely with the
11 * user.
12 *
13 * Send bug reports, bug fixes, enhancements, requests, flames, etc., and
14 * I'll try to keep a version up to date. I can be reached as follows:
15 * Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
16 */
17
18#if !defined(lint) && !defined(LINT)
19static char rcsid[] = "$Id: do_command.c,v 1.5 1995/05/30 03:47:00 rgrimes Exp $";
19static char rcsid[] = "$Id: do_command.c,v 1.6 1995/09/10 13:02:56 joerg Exp $";
20#endif
21
22
23#include "cron.h"
24#include <sys/signal.h>
25#if defined(sequent)
26# include <sys/universe.h>
27#endif

--- 182 unchanged lines hidden (view full) ---

210 * so that the child can invoke /usr/lib/sendmail
211 * without surprises.
212 */
213 do_univ(u);
214
215 /* set our directory, uid and gid. Set gid first, since once
216 * we set uid, we've lost root privledges.
217 */
20#endif
21
22
23#include "cron.h"
24#include <sys/signal.h>
25#if defined(sequent)
26# include <sys/universe.h>
27#endif

--- 182 unchanged lines hidden (view full) ---

210 * so that the child can invoke /usr/lib/sendmail
211 * without surprises.
212 */
213 do_univ(u);
214
215 /* set our directory, uid and gid. Set gid first, since once
216 * we set uid, we've lost root privledges.
217 */
218 chdir(env_get("HOME", e->envp));
218 setgid(e->gid);
219# if defined(BSD)
220 initgroups(env_get("LOGNAME", e->envp), e->gid);
221# endif
219# if defined(BSD)
220 initgroups(env_get("LOGNAME", e->envp), e->gid);
221# endif
222 setgid(e->gid);
222 setlogin(usernm);
223 setuid(e->uid); /* we aren't root after this... */
223 setuid(e->uid); /* we aren't root after this... */
224 chdir(env_get("HOME", e->envp));
224
225 /* exec the command.
226 */
227 {
228 char *shell = env_get("SHELL", e->envp);
229
230# if DEBUGGING
231 if (DebugFlags & DTEST) {

--- 138 unchanged lines hidden (view full) ---

370 */
371
372 if (mailto) {
373 register char **env;
374 auto char mailcmd[MAX_COMMAND];
375 auto char hostname[MAXHOSTNAMELEN];
376
377 (void) gethostname(hostname, MAXHOSTNAMELEN);
225
226 /* exec the command.
227 */
228 {
229 char *shell = env_get("SHELL", e->envp);
230
231# if DEBUGGING
232 if (DebugFlags & DTEST) {

--- 138 unchanged lines hidden (view full) ---

371 */
372
373 if (mailto) {
374 register char **env;
375 auto char mailcmd[MAX_COMMAND];
376 auto char hostname[MAXHOSTNAMELEN];
377
378 (void) gethostname(hostname, MAXHOSTNAMELEN);
378 (void) sprintf(mailcmd, MAILARGS,
379 MAILCMD);
379 (void) snprintf(mailcmd, sizeof(mailcmd),
380 MAILARGS, MAILCMD);
380 if (!(mail = cron_popen(mailcmd, "w"))) {
381 perror(MAILCMD);
382 (void) _exit(ERROR_EXIT);
383 }
384 fprintf(mail, "From: root (Cron Daemon)\n");
385 fprintf(mail, "To: %s\n", mailto);
386 fprintf(mail, "Subject: Cron <%s@%s> %s\n",
387 usernm, first_word(hostname, "."),

--- 41 unchanged lines hidden (view full) ---

429
430 /* if there was output and we could not mail it,
431 * log the facts so the poor user can figure out
432 * what's going on.
433 */
434 if (mailto && status) {
435 char buf[MAX_TEMPSTR];
436
381 if (!(mail = cron_popen(mailcmd, "w"))) {
382 perror(MAILCMD);
383 (void) _exit(ERROR_EXIT);
384 }
385 fprintf(mail, "From: root (Cron Daemon)\n");
386 fprintf(mail, "To: %s\n", mailto);
387 fprintf(mail, "Subject: Cron <%s@%s> %s\n",
388 usernm, first_word(hostname, "."),

--- 41 unchanged lines hidden (view full) ---

430
431 /* if there was output and we could not mail it,
432 * log the facts so the poor user can figure out
433 * what's going on.
434 */
435 if (mailto && status) {
436 char buf[MAX_TEMPSTR];
437
437 sprintf(buf,
438 snprintf(buf, sizeof(buf),
438 "mailed %d byte%s of output but got status 0x%04x\n",
439 bytes, (bytes==1)?"":"s",
440 status);
441 log_it(usernm, getpid(), "MAIL", buf);
442 }
443
444 } /*if data from grandchild*/
445

--- 65 unchanged lines hidden ---
439 "mailed %d byte%s of output but got status 0x%04x\n",
440 bytes, (bytes==1)?"":"s",
441 status);
442 log_it(usernm, getpid(), "MAIL", buf);
443 }
444
445 } /*if data from grandchild*/
446

--- 65 unchanged lines hidden ---