summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJeremy Harris <jgh146exb@wizmail.org>2020-03-20 14:44:07 +0000
committerJeremy Harris <jgh146exb@wizmail.org>2020-03-22 20:13:21 +0000
commiteb24befc3e9ad0a36ef8f0bc3527a9bc6c923a7b (patch)
tree8bd5fee986d44f46397899e1a12d0bd82b408824 /src
parent568092148bf6ade68174fa1ccf34b8c37d9064e9 (diff)
child-open debug
Diffstat (limited to 'src')
-rw-r--r--src/src/child.c14
-rw-r--r--src/src/dns.c5
-rw-r--r--src/src/expand.c3
-rw-r--r--src/src/functions.h12
-rw-r--r--src/src/local_scan.h3
-rw-r--r--src/src/routers/queryprogram.c6
-rw-r--r--src/src/transport.c6
-rw-r--r--src/src/transports/lmtp.c6
-rw-r--r--src/src/transports/pipe.c3
9 files changed, 36 insertions, 22 deletions
diff --git a/src/src/child.c b/src/src/child.c
index 13d177c19..3aa696221 100644
--- a/src/src/child.c
+++ b/src/src/child.c
@@ -75,7 +75,7 @@ int n = 0;
int extra = pcount ? *pcount : 0;
uschar **argv;
-argv = store_get((extra + acount + MAX_CLMACROS + 19) * sizeof(char *), FALSE);
+argv = store_get((extra + acount + MAX_CLMACROS + 21) * sizeof(char *), FALSE);
/* In all case, the list starts out with the path, any macros, and a changed
config file. */
@@ -313,6 +313,7 @@ Arguments:
process is placed
wd if not NULL, a path to be handed to chdir() in the new process
make_leader if TRUE, make the new process a process group leader
+ purpose for debug: reason for running the task
Returns: the pid of the created process or -1 if anything has gone wrong
*/
@@ -320,7 +321,7 @@ Returns: the pid of the created process or -1 if anything has gone wrong
pid_t
child_open_uid(const uschar **argv, const uschar **envp, int newumask,
uid_t *newuid, gid_t *newgid, int *infdptr, int *outfdptr, uschar *wd,
- BOOL make_leader)
+ BOOL make_leader, const uschar * purpose)
{
int save_errno;
int inpfd[2], outpfd[2];
@@ -341,7 +342,7 @@ that the child process can be waited for. We sometimes get here with it set
otherwise. Save the old state for resetting on the wait. */
oldsignal = signal(SIGCHLD, SIG_DFL);
-pid = exim_fork(US"child-open");
+pid = exim_fork(purpose);
/* Handle the child process. First, set the required environment. We must do
this before messing with the pipes, in order to be able to write debugging
@@ -454,16 +455,17 @@ Arguments:
outfdptr pointer to int into which the fd of the stdout/stderr of the new
process is placed
make_leader if TRUE, make the new process a process group leader
+ purpose for debug: reason for running the task
Returns: the pid of the created process or -1 if anything has gone wrong
*/
pid_t
-child_open(uschar **argv, uschar **envp, int newumask, int *infdptr,
- int *outfdptr, BOOL make_leader)
+child_open_function(uschar **argv, uschar **envp, int newumask, int *infdptr,
+ int *outfdptr, BOOL make_leader, const uschar * purpose)
{
return child_open_uid(CUSS argv, CUSS envp, newumask, NULL, NULL,
- infdptr, outfdptr, NULL, make_leader);
+ infdptr, outfdptr, NULL, make_leader, purpose);
}
diff --git a/src/src/dns.c b/src/src/dns.c
index 6333d3cff..d036162cb 100644
--- a/src/src/dns.c
+++ b/src/src/dns.c
@@ -60,7 +60,8 @@ if (stat(CS utilname, &statbuf) >= 0)
int infd, outfd, rc;
uschar *argv[5];
- DEBUG(D_dns) debug_printf("DNS lookup of %s (%s) using fakens\n", name, dns_text_type(type));
+ DEBUG(D_dns) debug_printf("DNS lookup of %s (%s) using fakens\n",
+ name, dns_text_type(type));
argv[0] = utilname;
argv[1] = config_main_directory;
@@ -68,7 +69,7 @@ if (stat(CS utilname, &statbuf) >= 0)
argv[3] = dns_text_type(type);
argv[4] = NULL;
- pid = child_open(argv, NULL, 0000, &infd, &outfd, FALSE);
+ pid = child_open(argv, NULL, 0000, &infd, &outfd, FALSE, US"fakens-search");
if (pid < 0)
log_write(0, LOG_MAIN|LOG_PANIC_DIE, "failed to run fakens: %s",
strerror(errno));
diff --git a/src/src/expand.c b/src/src/expand.c
index 4377ea1aa..fddad3179 100644
--- a/src/src/expand.c
+++ b/src/src/expand.c
@@ -5624,7 +5624,8 @@ while (*s != 0)
/* Create the child process, making it a group leader. */
- if ((pid = child_open(USS argv, NULL, 0077, &fd_in, &fd_out, TRUE)) < 0)
+ if ((pid = child_open(USS argv, NULL, 0077, &fd_in, &fd_out, TRUE,
+ US"expand-run")) < 0)
{
expand_string_message =
string_sprintf("couldn't create child process: %s", strerror(errno));
diff --git a/src/src/functions.h b/src/src/functions.h
index a44e7a873..9e5bba9bd 100644
--- a/src/src/functions.h
+++ b/src/src/functions.h
@@ -153,8 +153,11 @@ extern uschar **child_exec_exim(int, BOOL, int *, BOOL, int, ...);
extern pid_t child_open_exim_function(int *, const uschar *);
extern pid_t child_open_exim2_function(int *, uschar *, uschar *,
const uschar *);
+extern pid_t child_open_function(uschar **argv, uschar **envp, int newumask,
+ int *infdptr, int *outfdptr, BOOL make_leader,
+ const uschar * purpose);
extern pid_t child_open_uid(const uschar **, const uschar **, int,
- uid_t *, gid_t *, int *, int *, uschar *, BOOL);
+ uid_t *, gid_t *, int *, int *, uschar *, BOOL, const uschar *);
extern BOOL cleanup_environment(void);
extern void cutthrough_data_puts(uschar *, int);
extern void cutthrough_data_put_nl(void);
@@ -1142,6 +1145,13 @@ child_open_exim2(int * fdptr, uschar * sender,
uschar * sender_auth, const uschar * purpose)
{ return child_open_exim2_function(fdptr, sender, sender_auth, purpose); }
+static inline pid_t
+child_open(uschar **argv, uschar **envp, int newumask, int *infdptr,
+ int *outfdptr, BOOL make_leader, const uschar * purpose)
+{ return child_open_function(argv, envp, newumask, infdptr,
+ outfdptr, make_leader, purpose);
+}
+
/******************************************************************************/
#endif /* !MACRO_PREDEF */
diff --git a/src/src/local_scan.h b/src/src/local_scan.h
index bb131d380..b92be5628 100644
--- a/src/src/local_scan.h
+++ b/src/src/local_scan.h
@@ -181,7 +181,6 @@ extern BOOL smtp_input; /* TRUE if input is via SMTP */
/* Functions that are documented as visible in local_scan(). */
extern int child_close(pid_t, int);
-extern pid_t child_open(uschar **, uschar **, int, int *, int *, BOOL);
extern void debug_printf(const char *, ...) PRINTF_FUNCTION(1,2);
extern uschar *expand_string(uschar *);
extern void header_add(int, const char *, ...);
@@ -225,12 +224,14 @@ with the original name. */
# define string_copy_taint(s, t) string_copy_taint_function((s), (t))
# define child_open_exim(p) child_open_exim_function((p), US"from local_scan")
# define child_open_exim2(p, s, a) child_open_exim2_function((p), (s), (a), US"from local_scan")
+# define child_open(a,e,u,i,o,l) child_open_function((a),(e),(u),(i),(o),(l),US"from local_scan")
extern uschar * string_copy_function(const uschar *);
extern uschar * string_copyn_function(const uschar *, int n);
extern uschar * string_copy_taint_function(const uschar *, BOOL tainted);
extern pid_t child_open_exim_function(int *, const uschar *);
extern pid_t child_open_exim2_function(int *, uschar *, uschar *, const uschar *);
+extern pid_t child_open_function(uschar **, uschar **, int, int *, int *, BOOL, const uschar *);
#endif
/* End of local_scan.h */
diff --git a/src/src/routers/queryprogram.c b/src/src/routers/queryprogram.c
index 107632f44..767dc7167 100644
--- a/src/src/routers/queryprogram.c
+++ b/src/src/routers/queryprogram.c
@@ -308,10 +308,8 @@ if (!transport_set_up_command(&argvptr, /* anchor for arg list */
/* Create the child process, making it a group leader. */
-pid = child_open_uid(argvptr, NULL, 0077, puid, pgid, &fd_in, &fd_out,
- current_directory, TRUE);
-
-if (pid < 0)
+if ((pid = child_open_uid(argvptr, NULL, 0077, puid, pgid, &fd_in, &fd_out,
+ current_directory, TRUE, US"queryprogram-cmd")) < 0)
{
addr->message = string_sprintf("%s router couldn't create child process: %s",
rblock->name, strerror(errno));
diff --git a/src/src/transport.c b/src/src/transport.c
index e5a7385b4..6b33a0e68 100644
--- a/src/src/transport.c
+++ b/src/src/transport.c
@@ -1234,10 +1234,10 @@ write_pid = (pid_t)(-1);
{
int bits = fcntl(tctx->u.fd, F_GETFD);
- (void)fcntl(tctx->u.fd, F_SETFD, bits | FD_CLOEXEC);
+ (void) fcntl(tctx->u.fd, F_SETFD, bits | FD_CLOEXEC);
filter_pid = child_open(USS transport_filter_argv, NULL, 077,
- &fd_write, &fd_read, FALSE);
- (void)fcntl(tctx->u.fd, F_SETFD, bits & ~FD_CLOEXEC);
+ &fd_write, &fd_read, FALSE, US"transport-filter");
+ (void) fcntl(tctx->u.fd, F_SETFD, bits & ~FD_CLOEXEC);
}
if (filter_pid < 0) goto TIDY_UP; /* errno set */
diff --git a/src/src/transports/lmtp.c b/src/src/transports/lmtp.c
index 32c57166c..517a13494 100644
--- a/src/src/transports/lmtp.c
+++ b/src/src/transports/lmtp.c
@@ -500,7 +500,8 @@ if (ob->cmd)
uid/gid and current directory. Request that the new process be a process group
leader, so we can kill it and all its children on an error. */
- if ((pid = child_open(USS argv, NULL, 0, &fd_in, &fd_out, TRUE)) < 0)
+ if ((pid = child_open(USS argv, NULL, 0, &fd_in, &fd_out, TRUE,
+ US"lmtp-tpt-cmd")) < 0)
{
addrlist->message = string_sprintf(
"Failed to create child process for %s transport: %s", tblock->name,
@@ -514,8 +515,7 @@ leader, so we can kill it and all its children on an error. */
else
{
DEBUG(D_transport) debug_printf("using socket %s\n", ob->skt);
- sockname = expand_string(ob->skt);
- if (sockname == NULL)
+ if (!(sockname = expand_string(ob->skt)))
{
addrlist->message = string_sprintf("Expansion of \"%s\" (socket setting "
"for %s transport) failed: %s", ob->skt, tblock->name,
diff --git a/src/src/transports/pipe.c b/src/src/transports/pipe.c
index 83272d80a..c1e2b26c7 100644
--- a/src/src/transports/pipe.c
+++ b/src/src/transports/pipe.c
@@ -725,7 +725,8 @@ reading of the output pipe. */
uid/gid and current directory. Request that the new process be a process group
leader, so we can kill it and all its children on a timeout. */
-if ((pid = child_open(USS argv, envp, ob->umask, &fd_in, &fd_out, TRUE)) < 0)
+if ((pid = child_open(USS argv, envp, ob->umask, &fd_in, &fd_out, TRUE,
+ US"pipe-tpt-cmd")) < 0)
{
addr->transport_return = DEFER;
addr->message = string_sprintf(