blob: d9bda82be91752ee7b61575faa665fc718cb2ee3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
/* Copyright (c) 2010-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "execv-const.h"
#include <unistd.h>
static char **argv_drop_const(const char *const argv[])
{
char **ret;
unsigned int i, count;
for (count = 0; argv[count] != NULL; count++) ;
ret = t_new(char *, count + 1);
for (i = 0; i < count; i++)
ret[i] = t_strdup_noconst(argv[i]);
return ret;
}
void execv_const(const char *path, const char *const argv[])
{
(void)execv(path, argv_drop_const(argv));
i_fatal_status(errno == ENOMEM ? FATAL_OUTOFMEM : FATAL_EXEC,
"execv(%s) failed: %m", path);
}
void execvp_const(const char *file, const char *const argv[])
{
(void)execvp(file, argv_drop_const(argv));
i_fatal_status(errno == ENOMEM ? FATAL_OUTOFMEM : FATAL_EXEC,
"execvp(%s) failed: %m", file);
}
|