| @@ -1,41 +1,41 @@ | | | @@ -1,41 +1,41 @@ |
1 | /* $NetBSD: do_command.c,v 1.13 2018/06/14 22:04:28 christos Exp $ */ | | 1 | /* $NetBSD: do_command.c,v 1.14 2019/08/03 07:06:47 christos Exp $ */ |
2 | | | 2 | |
3 | /* Copyright 1988,1990,1993,1994 by Paul Vixie | | 3 | /* Copyright 1988,1990,1993,1994 by Paul Vixie |
4 | * All rights reserved | | 4 | * All rights reserved |
5 | */ | | 5 | */ |
6 | | | 6 | |
7 | /* | | 7 | /* |
8 | * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") | | 8 | * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") |
9 | * Copyright (c) 1997,2000 by Internet Software Consortium, Inc. | | 9 | * Copyright (c) 1997,2000 by Internet Software Consortium, Inc. |
10 | * | | 10 | * |
11 | * Permission to use, copy, modify, and distribute this software for any | | 11 | * Permission to use, copy, modify, and distribute this software for any |
12 | * purpose with or without fee is hereby granted, provided that the above | | 12 | * purpose with or without fee is hereby granted, provided that the above |
13 | * copyright notice and this permission notice appear in all copies. | | 13 | * copyright notice and this permission notice appear in all copies. |
14 | * | | 14 | * |
15 | * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES | | 15 | * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES |
16 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | | 16 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
17 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR | | 17 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR |
18 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | | 18 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
19 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | | 19 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
20 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT | | 20 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT |
21 | * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | | 21 | * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
22 | */ | | 22 | */ |
23 | #include <sys/cdefs.h> | | 23 | #include <sys/cdefs.h> |
24 | #if !defined(lint) && !defined(LINT) | | 24 | #if !defined(lint) && !defined(LINT) |
25 | #if 0 | | 25 | #if 0 |
26 | static char rcsid[] = "Id: do_command.c,v 1.9 2004/01/23 18:56:42 vixie Exp"; | | 26 | static char rcsid[] = "Id: do_command.c,v 1.9 2004/01/23 18:56:42 vixie Exp"; |
27 | #else | | 27 | #else |
28 | __RCSID("$NetBSD: do_command.c,v 1.13 2018/06/14 22:04:28 christos Exp $"); | | 28 | __RCSID("$NetBSD: do_command.c,v 1.14 2019/08/03 07:06:47 christos Exp $"); |
29 | #endif | | 29 | #endif |
30 | #endif | | 30 | #endif |
31 | | | 31 | |
32 | #include "cron.h" | | 32 | #include "cron.h" |
33 | #include <unistd.h> | | 33 | #include <unistd.h> |
34 | | | 34 | |
35 | static int child_process(entry *); | | 35 | static int child_process(entry *); |
36 | static int safe_p(const char *, const char *); | | 36 | static int safe_p(const char *, const char *); |
37 | | | 37 | |
38 | void | | 38 | void |
39 | do_command(entry *e, user *u) { | | 39 | do_command(entry *e, user *u) { |
40 | int retval; | | 40 | int retval; |
41 | | | 41 | |
| @@ -172,27 +172,27 @@ read_data(entry *e, const char *mailto, | | | @@ -172,27 +172,27 @@ read_data(entry *e, const char *mailto, |
172 | /* ... but it's empty. set to NULL | | 172 | /* ... but it's empty. set to NULL |
173 | */ | | 173 | */ |
174 | mailto = NULL; | | 174 | mailto = NULL; |
175 | } | | 175 | } |
176 | } else { | | 176 | } else { |
177 | /* MAILTO not present, set to USER. | | 177 | /* MAILTO not present, set to USER. |
178 | */ | | 178 | */ |
179 | mailto = usernm; | | 179 | mailto = usernm; |
180 | } | | 180 | } |
181 | | | 181 | |
182 | /* | | 182 | /* |
183 | * Unsafe, disable mailing. | | 183 | * Unsafe, disable mailing. |
184 | */ | | 184 | */ |
185 | if (!safe_p(usernm, mailto)) | | 185 | if (mailto && !safe_p(usernm, mailto)) |
186 | mailto = NULL; | | 186 | mailto = NULL; |
187 | | | 187 | |
188 | /* if we are supposed to be mailing, MAILTO will | | 188 | /* if we are supposed to be mailing, MAILTO will |
189 | * be non-NULL. only in this case should we set | | 189 | * be non-NULL. only in this case should we set |
190 | * up the mail command and subjects and stuff... | | 190 | * up the mail command and subjects and stuff... |
191 | */ | | 191 | */ |
192 | | | 192 | |
193 | if (mailto) { | | 193 | if (mailto) { |
194 | char **env; | | 194 | char **env; |
195 | char mailcmd[MAX_COMMAND]; | | 195 | char mailcmd[MAX_COMMAND]; |
196 | char hostname[MAXHOSTNAMELEN + 1]; | | 196 | char hostname[MAXHOSTNAMELEN + 1]; |
197 | | | 197 | |
198 | (void)gethostname(hostname, MAXHOSTNAMELEN); | | 198 | (void)gethostname(hostname, MAXHOSTNAMELEN); |