summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/conn-tools/s6-connlimit.c15
-rw-r--r--src/conn-tools/s6-ipcclient.c6
-rw-r--r--src/conn-tools/s6-ipcserver-access.c16
-rw-r--r--src/conn-tools/s6-ipcserver-socketbinder.c6
-rw-r--r--src/conn-tools/s6-ipcserver.c8
-rw-r--r--src/conn-tools/s6-ipcserverd.c29
-rw-r--r--src/conn-tools/s6-sudo.c7
-rw-r--r--src/conn-tools/s6-sudod.c7
-rw-r--r--src/daemontools-extras/s6-applyuidgid.c16
-rw-r--r--src/daemontools-extras/s6-envdir.c7
-rw-r--r--src/daemontools-extras/s6-envuidgid.c7
-rw-r--r--src/daemontools-extras/s6-fghack.c14
-rw-r--r--src/daemontools-extras/s6-log.c4
-rw-r--r--src/daemontools-extras/s6-setlock.c7
-rw-r--r--src/daemontools-extras/s6-setsid.c7
-rw-r--r--src/daemontools-extras/s6-setuidgid.c8
-rw-r--r--src/daemontools-extras/s6-softlimit.c7
-rw-r--r--src/fdholder/s6-fdholder-daemon.c8
-rw-r--r--src/fdholder/s6-fdholder-getdump.c6
-rw-r--r--src/fdholder/s6-fdholder-retrieve.c6
-rw-r--r--src/supervision/s6-notifyoncheck.c9
-rw-r--r--src/supervision/s6-permafailon.c6
-rw-r--r--src/supervision/s6-svc.c10
-rw-r--r--src/supervision/s6-svscan.c30
24 files changed, 132 insertions, 114 deletions
diff --git a/src/conn-tools/s6-connlimit.c b/src/conn-tools/s6-connlimit.c
index b34d411..959c421 100644
--- a/src/conn-tools/s6-connlimit.c
+++ b/src/conn-tools/s6-connlimit.c
@@ -1,17 +1,18 @@
/* ISC license. */
#include <string.h>
+#include <stdlib.h>
+
#include <skalibs/types.h>
#include <skalibs/strerr2.h>
-#include <skalibs/env.h>
-#include <skalibs/djbunix.h>
+#include <skalibs/exec.h>
-int main (int argc, char const *const *argv, char const *const *envp)
+int main (int argc, char const *const *argv)
{
char const *x ;
size_t protolen ;
PROG = "s6-connlimit" ;
- x = env_get2(envp, "PROTO") ;
+ x = getenv("PROTO") ;
if (!x) strerr_dienotset(100, "PROTO") ;
protolen = strlen(x) ;
if (!protolen) strerr_dief1x(100, "empty PROTO") ;
@@ -20,11 +21,11 @@ int main (int argc, char const *const *argv, char const *const *envp)
char s[protolen + 8] ;
memcpy(s, x, protolen) ;
memcpy(s + protolen, "CONNNUM", 8) ;
- x = env_get2(envp, s) ;
+ x = getenv(s) ;
if (!x) strerr_dienotset(100, s) ;
if (!uint0_scan(x, &num)) strerr_dief2x(100, "invalid ", s) ;
memcpy(s + protolen + 4, "MAX", 4) ;
- x = env_get2(envp, s) ;
+ x = getenv(s) ;
if (x)
{
unsigned int max ;
@@ -34,5 +35,5 @@ int main (int argc, char const *const *argv, char const *const *envp)
}
}
(void)argc ;
- xpathexec0_run(argv+1, envp) ;
+ xexec0(argv+1) ;
}
diff --git a/src/conn-tools/s6-ipcclient.c b/src/conn-tools/s6-ipcclient.c
index 42521de..0b17853 100644
--- a/src/conn-tools/s6-ipcclient.c
+++ b/src/conn-tools/s6-ipcclient.c
@@ -4,13 +4,13 @@
#include <skalibs/sgetopt.h>
#include <skalibs/strerr2.h>
-#include <skalibs/env.h>
#include <skalibs/djbunix.h>
#include <skalibs/webipc.h>
+#include <skalibs/exec.h>
#define USAGE "s6-ipcclient [ -q | -Q | -v ] [ -p bindpath ] [ -l localname ] path prog..."
-int main (int argc, char const *const *argv, char const *const *envp)
+int main (int argc, char const *const *argv)
{
char const *bindpath = 0 ;
char const *localname = 0 ;
@@ -62,6 +62,6 @@ int main (int argc, char const *const *argv, char const *const *envp)
strerr_diefu2sys(111, "set up fd ", "6") ;
if (fd_copy(7, 6) < 0)
strerr_diefu2sys(111, "set up fd ", "7") ;
- xpathexec_r(argv+1, envp, env_len(envp), modif, i) ;
+ xmexec_n(argv+1, modif, i, 2) ;
}
}
diff --git a/src/conn-tools/s6-ipcserver-access.c b/src/conn-tools/s6-ipcserver-access.c
index e3f6ac2..752ecab 100644
--- a/src/conn-tools/s6-ipcserver-access.c
+++ b/src/conn-tools/s6-ipcserver-access.c
@@ -3,14 +3,16 @@
#include <string.h>
#include <unistd.h>
#include <errno.h>
+#include <stdlib.h>
+
#include <skalibs/gccattributes.h>
#include <skalibs/types.h>
#include <skalibs/strerr2.h>
#include <skalibs/sgetopt.h>
#include <skalibs/cdb.h>
-#include <skalibs/env.h>
#include <skalibs/djbunix.h>
#include <skalibs/webipc.h>
+#include <skalibs/exec.h>
#include <s6/config.h>
#include <s6/accessrules.h>
@@ -113,7 +115,7 @@ static inline int check (s6_accessrules_params_t *params, char const *rules, uns
}
}
-int main (int argc, char const *const *argv, char const *const *envp)
+int main (int argc, char const *const *argv)
{
s6_accessrules_params_t params = S6_ACCESSRULES_PARAMS_ZERO ;
char const *rules = 0 ;
@@ -147,7 +149,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
if (!argc) dieusage() ;
if (!*argv[0]) dieusage() ;
- proto = env_get2(envp, "PROTO") ;
+ proto = getenv("PROTO") ;
if (!proto) strerr_dienotset(100, "PROTO") ;
protolen = strlen(proto) ;
@@ -156,11 +158,11 @@ int main (int argc, char const *const *argv, char const *const *envp)
char tmp[protolen + 11] ;
memcpy(tmp, proto, protolen) ;
memcpy(tmp + protolen, "REMOTEEUID", 11) ;
- x = env_get2(envp, tmp) ;
+ x = getenv(tmp) ;
if (!x) strerr_dienotset(100, tmp) ;
if (!uid0_scan(x, &uid)) strerr_dieinvalid(100, tmp) ;
tmp[protolen + 7] = 'G' ;
- x = env_get2(envp, tmp) ;
+ x = getenv(tmp) ;
if (!x) strerr_dienotset(100, tmp) ;
if (!gid0_scan(x, &gid)) strerr_dieinvalid(100, tmp) ;
}
@@ -212,10 +214,10 @@ int main (int argc, char const *const *argv, char const *const *envp)
#ifdef S6_USE_EXECLINE
{
char *specialargv[4] = { EXECLINE_EXTBINPREFIX "execlineb", "-Pc", params.exec.s, 0 } ;
- xpathexec_r((char const *const *)specialargv, envp, env_len(envp), params.env.s, params.env.len) ;
+ xmexec_m((char const *const *)specialargv, params.env.s, params.env.len) ;
}
#else
strerr_warnw1x("exec file found but ignored because s6 was compiled without execline support!") ;
#endif
- xpathexec_r(argv, envp, env_len(envp), params.env.s, params.env.len) ;
+ xmexec_m(argv, params.env.s, params.env.len) ;
}
diff --git a/src/conn-tools/s6-ipcserver-socketbinder.c b/src/conn-tools/s6-ipcserver-socketbinder.c
index 71c1c70..f5abf67 100644
--- a/src/conn-tools/s6-ipcserver-socketbinder.c
+++ b/src/conn-tools/s6-ipcserver-socketbinder.c
@@ -3,16 +3,18 @@
#include <sys/stat.h>
#include <sys/socket.h>
#include <unistd.h>
+
#include <skalibs/types.h>
#include <skalibs/sgetopt.h>
#include <skalibs/strerr2.h>
#include <skalibs/djbunix.h>
#include <skalibs/webipc.h>
+#include <skalibs/exec.h>
#define USAGE "s6-ipcserver-socketbinder [ -d | -D ] [ -b backlog ] [ -M | -m ] [ -a perms ] [ -B ] path prog..."
#define dieusage() strerr_dieusage(100, USAGE)
-int main (int argc, char const *const *argv, char const *const *envp)
+int main (int argc, char const *const *argv)
{
unsigned int backlog = SOMAXCONN ;
int flagreuse = 1 ;
@@ -54,5 +56,5 @@ int main (int argc, char const *const *argv, char const *const *envp)
if (backlog && ipc_listen(0, backlog) < 0)
strerr_diefu2sys(111, "listen to ", argv[0]) ;
- xpathexec_run(argv[1], argv + 1, envp) ;
+ xexec(argv+1) ;
}
diff --git a/src/conn-tools/s6-ipcserver.c b/src/conn-tools/s6-ipcserver.c
index 03f6eb9..aa707fc 100644
--- a/src/conn-tools/s6-ipcserver.c
+++ b/src/conn-tools/s6-ipcserver.c
@@ -2,16 +2,18 @@
#include <sys/types.h>
#include <limits.h>
+
#include <skalibs/types.h>
#include <skalibs/sgetopt.h>
#include <skalibs/strerr2.h>
-#include <skalibs/djbunix.h>
+#include <skalibs/exec.h>
+
#include <s6/config.h>
#define USAGE "s6-ipcserver [ -q | -Q | -v ] [ -d | -D ] [ -P | -p ] [ -1 ] [ -c maxconn ] [ -C localmaxconn ] [ -b backlog ] [ -a socketperms ] [ -G gid,gid,... ] [ -g gid ] [ -u uid ] [ -U ] path prog..."
#define dieusage() strerr_dieusage(100, USAGE)
-int main (int argc, char const *const *argv, char const *const *envp)
+int main (int argc, char const *const *argv)
{
unsigned int verbosity = 1 ;
int flag1 = 0 ;
@@ -132,6 +134,6 @@ int main (int argc, char const *const *argv, char const *const *envp)
newargv[m++] = "--" ;
while (*argv) newargv[m++] = *argv++ ;
newargv[m++] = 0 ;
- xpathexec_run(newargv[0], newargv, envp) ;
+ xexec(newargv) ;
}
}
diff --git a/src/conn-tools/s6-ipcserverd.c b/src/conn-tools/s6-ipcserverd.c
index 1a63503..9edb4ad 100644
--- a/src/conn-tools/s6-ipcserverd.c
+++ b/src/conn-tools/s6-ipcserverd.c
@@ -8,18 +8,19 @@
#include <unistd.h>
#include <fcntl.h>
#include <signal.h>
+
+#include <skalibs/posixplz.h>
#include <skalibs/types.h>
#include <skalibs/gccattributes.h>
#include <skalibs/allreadwrite.h>
#include <skalibs/sgetopt.h>
#include <skalibs/strerr2.h>
-#include <skalibs/env.h>
#include <skalibs/djbunix.h>
#include <skalibs/sig.h>
#include <skalibs/selfpipe.h>
#include <skalibs/iopause.h>
-#include <skalibs/getpeereid.h>
#include <skalibs/webipc.h>
+#include <skalibs/exec.h>
#define USAGE "s6-ipcserverd [ -v verbosity ] [ -1 ] [ -P | -p ] [ -c maxconn ] [ -C localmaxconn ] prog..."
@@ -102,7 +103,7 @@ static void log_status (void)
strerr_warni3x("status: ", fmt, fmtmaxconn) ;
}
-static void log_deny (uid_t uid, gid_t gid, unsigned int num)
+static inline void log_deny (uid_t uid, gid_t gid, unsigned int num)
{
char fmtuid[UID_FMT] = "?" ;
char fmtgid[GID_FMT] = "?" ;
@@ -116,7 +117,7 @@ static void log_deny (uid_t uid, gid_t gid, unsigned int num)
strerr_warni7sys("deny ", fmtuid, ":", fmtgid, " count ", fmtnum, fmtlocalmaxconn) ;
}
-static void log_accept (pid_t pid, uid_t uid, gid_t gid, unsigned int num)
+static inline void log_accept (pid_t pid, uid_t uid, gid_t gid, unsigned int num)
{
char fmtuidgid[UID_FMT + GID_FMT + 1] = "?:?" ;
char fmtpid[UINT_FMT] ;
@@ -133,7 +134,7 @@ static void log_accept (pid_t pid, uid_t uid, gid_t gid, unsigned int num)
strerr_warni7x("allow ", fmtuidgid, " pid ", fmtpid, " count ", fmtnum, fmtlocalmaxconn) ;
}
-static void log_close (pid_t pid, uid_t uid, int w)
+static inline void log_close (pid_t pid, uid_t uid, int w)
{
char fmtpid[PID_FMT] ;
char fmtuid[UID_FMT] = "?" ;
@@ -153,7 +154,7 @@ static void killthem (int sig)
for (; i < numconn ; i++) kill(piduid[i].left, sig) ;
}
-static void wait_children (void)
+static inline void wait_children (void)
{
for (;;)
{
@@ -181,7 +182,7 @@ static void wait_children (void)
}
}
-static void handle_signals (void)
+static inline void handle_signals (void)
{
for (;;) switch (selfpipe_read())
{
@@ -227,8 +228,8 @@ static void handle_signals (void)
/* New connection handling */
-static void run_child (int, uid_t, gid_t, unsigned int, char const *, char const *const *, char const *const *) gccattr_noreturn ;
-static void run_child (int s, uid_t uid, gid_t gid, unsigned int num, char const *remotepath, char const *const *argv, char const *const *envp)
+static void run_child (int, uid_t, gid_t, unsigned int, char const *, char const *const *) gccattr_noreturn ;
+static void run_child (int s, uid_t uid, gid_t gid, unsigned int num, char const *remotepath, char const *const *argv)
{
size_t rplen = strlen(remotepath) + 1 ;
unsigned int n = 0 ;
@@ -255,10 +256,10 @@ static void run_child (int s, uid_t uid, gid_t gid, unsigned int num, char const
fmt[n++] = 0 ;
memcpy(fmt+n, "IPCREMOTEPATH=", 14) ; n += 14 ;
memcpy(fmt+n, remotepath, rplen) ; n += rplen ;
- xpathexec_r(argv, envp, env_len(envp), fmt, n) ;
+ xmexec_n(argv, fmt, n, 5) ;
}
-static void new_connection (int s, char const *remotepath, char const *const *argv, char const *const *envp)
+static void new_connection (int s, char const *remotepath, char const *const *argv)
{
uid_t uid = 0 ;
gid_t gid = 0 ;
@@ -285,7 +286,7 @@ static void new_connection (int s, char const *remotepath, char const *const *ar
else if (!pid)
{
selfpipe_finish() ;
- run_child(s, uid, gid, num+1, remotepath, argv, envp) ;
+ run_child(s, uid, gid, num+1, remotepath, argv) ;
}
if (i < uidlen) uidnum[i].right = num + 1 ;
@@ -304,7 +305,7 @@ static void new_connection (int s, char const *remotepath, char const *const *ar
}
-int main (int argc, char const *const *argv, char const *const *envp)
+int main (int argc, char const *const *argv)
{
iopause_fd x[2] = { { .events = IOPAUSE_READ }, { .fd = 0, .events = IOPAUSE_READ | IOPAUSE_EXCEPT } } ;
PROG = "s6-ipcserverd" ;
@@ -399,7 +400,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
}
else
{
- new_connection(sock, remotepath, argv, envp) ;
+ new_connection(sock, remotepath, argv) ;
fd_close(sock) ;
}
}
diff --git a/src/conn-tools/s6-sudo.c b/src/conn-tools/s6-sudo.c
index 2408927..6120004 100644
--- a/src/conn-tools/s6-sudo.c
+++ b/src/conn-tools/s6-sudo.c
@@ -3,14 +3,14 @@
#include <skalibs/types.h>
#include <skalibs/sgetopt.h>
#include <skalibs/strerr2.h>
-#include <skalibs/djbunix.h>
+#include <skalibs/exec.h>
#include <s6/config.h>
#define USAGE "s6-sudo [ -q | -Q | -v ] [ -p bindpath ] [ -l localname ] [ -e ] [ -t timeout ] [ -T timeoutrun ] path [ args... ]"
#define dieusage() strerr_dieusage(100, USAGE)
-int main (int argc, char const *const *argv, char const *const *envp)
+int main (int argc, char const *const *argv)
{
unsigned int verbosity = 1, t = 0, T = 0 ;
char const *bindpath = 0 ;
@@ -39,6 +39,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
argc -= l.ind ; argv += l.ind ;
}
if (!argc) dieusage() ;
+ if (verbosity > 4) verbosity = 4 ;
{
char const *eargv[9 + argc + ((verbosity < 2 ? 1 : verbosity-1)) + ((!!bindpath + !!localname) << 1) + nodoenv] ;
char fmt1[UINT_FMT] ;
@@ -62,6 +63,6 @@ int main (int argc, char const *const *argv, char const *const *envp)
eargv[n++] = "--" ;
while (argc--) eargv[n++] = *argv++ ;
eargv[n++] = 0 ;
- xpathexec_run(eargv[0], eargv, envp) ;
+ xexec(eargv) ;
}
}
diff --git a/src/conn-tools/s6-sudod.c b/src/conn-tools/s6-sudod.c
index 8b92532..34904ac 100644
--- a/src/conn-tools/s6-sudod.c
+++ b/src/conn-tools/s6-sudod.c
@@ -18,6 +18,7 @@
#include <skalibs/iopause.h>
#include <skalibs/selfpipe.h>
#include <skalibs/env.h>
+#include <skalibs/exec.h>
#include <skalibs/djbunix.h>
#include <skalibs/unix-timed.h>
#include <skalibs/unixmessage.h>
@@ -176,15 +177,13 @@ int main (int argc, char const *const *argv, char const *const *envp)
x[0].fd = selfpipe_init() ;
if (x[0].fd < 0) strerr_diefu1sys(111, "selfpipe_init") ;
if (selfpipe_trap(SIGCHLD) < 0) strerr_diefu1sys(111, "trap SIGCHLD") ;
- if (pipe(p) < 0) strerr_diefu1sys(111, "pipe") ;
- if (coe(p[1]) < 0) strerr_diefu1sys(111, "coe pipe") ;
+ if (pipecoe(p) < 0) strerr_diefu1sys(111, "pipe") ;
pid = fork() ;
if (pid < 0) strerr_diefu1sys(111, "fork") ;
if (!pid)
{
char c ;
PROG = "s6-sudod (child)" ;
- fd_close(p[0]) ;
if ((fd_move(2, m.fds[2]) < 0)
|| (fd_move(1, m.fds[1]) < 0)
|| (fd_move(0, m.fds[0]) < 0))
@@ -194,7 +193,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
strerr_diefu1sys(111, "move fds") ;
}
selfpipe_finish() ;
- pathexec0_run(targv, tenvp) ;
+ exec0_e(targv, tenvp) ;
c = errno ;
fd_write(p[1], &c, 1) ;
strerr_dieexec(c == ENOENT ? 127 : 126, targv[0]) ;
diff --git a/src/daemontools-extras/s6-applyuidgid.c b/src/daemontools-extras/s6-applyuidgid.c
index ba550c4..4dd0912 100644
--- a/src/daemontools-extras/s6-applyuidgid.c
+++ b/src/daemontools-extras/s6-applyuidgid.c
@@ -3,17 +3,19 @@
#include <unistd.h>
#include <grp.h>
#include <limits.h>
+#include <stdlib.h>
+
#include <skalibs/types.h>
#include <skalibs/setgroups.h>
#include <skalibs/strerr2.h>
#include <skalibs/sgetopt.h>
-#include <skalibs/env.h>
#include <skalibs/djbunix.h>
+#include <skalibs/exec.h>
#define USAGE "s6-applyuidgid [ -z ] [ -u uid ] [ -g gid ] [ -G gidlist ] [ -U ] prog..."
#define dieusage() strerr_dieusage(100, USAGE)
-int main (int argc, char const *const *argv, char const *const *envp)
+int main (int argc, char const *const *argv)
{
uid_t uid = 0 ;
gid_t gid = 0 ;
@@ -35,13 +37,13 @@ int main (int argc, char const *const *argv, char const *const *envp)
case 'G' : if (!gid_scanlist(gids, NGROUPS_MAX, l.arg, &gidn) && *l.arg) dieusage() ; break ;
case 'U' :
{
- char const *x = env_get2(envp, "UID") ;
+ char const *x = getenv("UID") ;
if (!x) strerr_dienotset(100, "UID") ;
if (!uid0_scan(x, &uid)) strerr_dieinvalid(100, "UID") ;
- x = env_get2(envp, "GID") ;
+ x = getenv("GID") ;
if (!x) strerr_dienotset(100, "GID") ;
if (!gid0_scan(x, &gid)) strerr_dieinvalid(100, "GID") ;
- x = env_get2(envp, "GIDLIST") ;
+ x = getenv("GIDLIST") ;
if (!x) strerr_dienotset(100, "GIDLIST") ;
if (!gid_scanlist(gids, NGROUPS_MAX+1, x, &gidn) && *x)
strerr_dieinvalid(100, "GIDLIST") ;
@@ -61,6 +63,6 @@ int main (int argc, char const *const *argv, char const *const *envp)
if (uid && setuid(uid) < 0)
strerr_diefu1sys(111, "setuid") ;
- if (unexport) xpathexec_r(argv, envp, env_len(envp), "UID\0GID\0GIDLIST", 16) ;
- else xpathexec_run(argv[0], argv, envp) ;
+ if (unexport) xmexec_n(argv, "UID\0GID\0GIDLIST", 16, 3) ;
+ else xexec(argv) ;
}
diff --git a/src/daemontools-extras/s6-envdir.c b/src/daemontools-extras/s6-envdir.c
index 140379d..6a6bd6f 100644
--- a/src/daemontools-extras/s6-envdir.c
+++ b/src/daemontools-extras/s6-envdir.c
@@ -1,15 +1,16 @@
/* ISC license. */
#include <errno.h>
+
#include <skalibs/sgetopt.h>
#include <skalibs/strerr2.h>
#include <skalibs/stralloc.h>
#include <skalibs/env.h>
-#include <skalibs/djbunix.h>
+#include <skalibs/exec.h>
#define USAGE "s6-envdir [ -I | -i ] [ -n ] [ -f ] [ -c nullchar ] dir prog..."
-int main (int argc, char const *const *argv, char const *const *envp)
+int main (int argc, char const *const *argv)
{
stralloc modifs = STRALLOC_ZERO ;
subgetopt_t l = SUBGETOPT_ZERO ;
@@ -35,5 +36,5 @@ int main (int argc, char const *const *argv, char const *const *envp)
if (argc < 2) strerr_dieusage(100, USAGE) ;
if ((envdir_internal(*argv++, &modifs, options, nullis) < 0) && (insist || (errno != ENOENT)))
strerr_diefu1sys(111, "envdir") ;
- xpathexec_r(argv, envp, env_len(envp), modifs.s, modifs.len) ;
+ xmexec_m(argv, modifs.s, modifs.len) ;
}
diff --git a/src/daemontools-extras/s6-envuidgid.c b/src/daemontools-extras/s6-envuidgid.c
index ec809e0..48da80a 100644
--- a/src/daemontools-extras/s6-envuidgid.c
+++ b/src/daemontools-extras/s6-envuidgid.c
@@ -5,11 +5,12 @@
#include <grp.h>
#include <errno.h>
#include <limits.h>
+
#include <skalibs/types.h>
#include <skalibs/sgetopt.h>
#include <skalibs/strerr2.h>
-#include <skalibs/env.h>
#include <skalibs/djbunix.h>
+#include <skalibs/exec.h>
#define USAGE "s6-envuidgid [ -i | -D defaultuid:defaultgid ] [ -u | -g | -B ] [ -n ] account prog..."
#define dieusage() strerr_dieusage(100, USAGE)
@@ -64,7 +65,7 @@ static int prot_readgroups (char const *name, gid_t *tab, unsigned int max)
return errno ? -1 : n ;
}
-int main (int argc, char *const *argv, char const *const *envp)
+int main (int argc, char *const *argv)
{
char const *user = 0 ;
char const *group = 0 ;
@@ -173,6 +174,6 @@ int main (int argc, char *const *argv, char const *const *envp)
pos += gid_fmtlist(fmt + pos, tab, n) ;
fmt[pos++] = 0 ;
}
- xpathexec_r((char const *const *)argv + 1, envp, env_len(envp), fmt, pos) ;
+ xmexec_m((char const *const *)argv + 1, fmt, pos) ;
}
}
diff --git a/src/daemontools-extras/s6-fghack.c b/src/daemontools-extras/s6-fghack.c
index 5981b96..a2f1f2b 100644
--- a/src/daemontools-extras/s6-fghack.c
+++ b/src/daemontools-extras/s6-fghack.c
@@ -3,13 +3,15 @@
#include <unistd.h>
#include <errno.h>
#include <sys/wait.h>
+
#include <skalibs/strerr2.h>
#include <skalibs/allreadwrite.h>
#include <skalibs/djbunix.h>
+#include <skalibs/exec.h>
#define USAGE "s6-fghack prog..."
-int main (int argc, char const *const *argv, char const *const *envp)
+int main (int argc, char const *const *argv)
{
int p[2] ;
int pcoe[2] ;
@@ -26,19 +28,19 @@ int main (int argc, char const *const *argv, char const *const *envp)
case 0 :
{
int i = 0 ;
- fd_close(p[0]) ;
- fd_close(pcoe[0]) ;
+ close(p[0]) ;
+ close(pcoe[0]) ;
if (coe(pcoe[1]) < 0) _exit(111) ;
for (; i < 30 ; i++) dup(p[1]) ; /* hack. gcc's warning is justified. */
- pathexec_run(argv[1], argv+1, envp) ;
+ exec(argv+1) ;
i = errno ;
if (fd_write(pcoe[1], "", 1) < 1) _exit(111) ;
_exit(i) ;
}
}
- fd_close(p[1]) ;
- fd_close(pcoe[1]) ;
+ close(p[1]) ;
+ close(pcoe[1]) ;
switch (fd_read(pcoe[0], &dummy, 1))
{
diff --git a/src/daemontools-extras/s6-log.c b/src/daemontools-extras/s6-log.c
index 54b945f..2f8438d 100644
--- a/src/daemontools-extras/s6-log.c
+++ b/src/daemontools-extras/s6-log.c
@@ -32,7 +32,7 @@
#include <skalibs/selfpipe.h>
#include <skalibs/siovec.h>
#include <skalibs/skamisc.h>
-#include <skalibs/environ.h>
+#include <skalibs/exec.h>
#include <s6/config.h>
@@ -330,7 +330,7 @@ static inline void exec_processor (logdir_t *ldp)
if (fd_move(5, fd) < 0) strerr_diefu3sys(111, "fd_move ", ldp->dir, "/newstate") ;
selfpipe_finish() ;
sig_restore(SIGPIPE) ;
- xpathexec_run(cargv[0], cargv, (char const *const *)environ) ;
+ xexec(cargv) ;
}
static int rotator (logdir_t *ldp)
diff --git a/src/daemontools-extras/s6-setlock.c b/src/daemontools-extras/s6-setlock.c
index 83741ac..bc50519 100644
--- a/src/daemontools-extras/s6-setlock.c
+++ b/src/daemontools-extras/s6-setlock.c
@@ -3,6 +3,7 @@
#include <unistd.h>
#include <errno.h>
#include <signal.h>
+
#include <skalibs/allreadwrite.h>
#include <skalibs/sgetopt.h>
#include <skalibs/strerr2.h>
@@ -10,6 +11,8 @@
#include <skalibs/tai.h>
#include <skalibs/iopause.h>
#include <skalibs/djbunix.h>
+#include <skalibs/exec.h>
+
#include <s6/config.h>
#define USAGE "s6-setlock [ -r | -w ] [ -n | -N | -t timeout ] lockfile prog..."
@@ -20,7 +23,7 @@ typedef lockfunc_t *lockfunc_t_ref ;
static lockfunc_t_ref f[2][2] = { { &lock_sh, &lock_shnb }, { &lock_ex, &lock_exnb } } ;
-int main (int argc, char const *const *argv, char const *const *envp)
+int main (int argc, char const *const *argv)
{
unsigned int nb = 0, ex = 1 ;
unsigned int timeout = 0 ;
@@ -82,5 +85,5 @@ int main (int argc, char const *const *argv, char const *const *envp)
fd_close(p[0]) ;
if (uncoe(p[1]) < 0) strerr_diefu1sys(111, "uncoe fd to helper") ;
}
- xpathexec_run(argv[1], argv+1, envp) ;
+ xexec(argv+1) ;
}
diff --git a/src/daemontools-extras/s6-setsid.c b/src/daemontools-extras/s6-setsid.c
index f77fb8a..69098ef 100644
--- a/src/daemontools-extras/s6-setsid.c
+++ b/src/daemontools-extras/s6-setsid.c
@@ -2,16 +2,17 @@
#include <unistd.h>
#include <signal.h>
+
#include <skalibs/types.h>
#include <skalibs/sgetopt.h>
#include <skalibs/strerr2.h>
#include <skalibs/sig.h>
-#include <skalibs/djbunix.h>
+#include <skalibs/exec.h>
#define USAGE "s6-setsid [ -s | -b | -f | -g ] [ -i | -I | -q ] [ -d ctty ] prog..."
#define dieusage() strerr_dieusage(100, USAGE)
-int main (int argc, char const *const *argv, char const *const *envp)
+int main (int argc, char const *const *argv)
{
unsigned int ctty = 0, what = 0, insist = 1 ;
PROG = "s6-setsid" ;
@@ -66,5 +67,5 @@ int main (int argc, char const *const *argv, char const *const *envp)
default : break ;
}
- xpathexec_run(argv[0], argv, envp) ;
+ xexec(argv) ;
}
diff --git a/src/daemontools-extras/s6-setuidgid.c b/src/daemontools-extras/s6-setuidgid.c
index f8ba542..f6103c1 100644
--- a/src/daemontools-extras/s6-setuidgid.c
+++ b/src/daemontools-extras/s6-setuidgid.c
@@ -1,14 +1,16 @@
/* ISC license. */
#include <string.h>
+
#include <skalibs/strerr2.h>
-#include <skalibs/djbunix.h>
+#include <skalibs/exec.h>
+
#include <s6/config.h>
#define USAGE "s6-setuidgid username prog..."
#define dieusage() strerr_dieusage(100, USAGE)
-int main (int argc, char *const *argv, char const *const *envp)
+int main (int argc, char *const *argv)
{
char const *newargv[argc + 7] ;
char *colon ;
@@ -39,5 +41,5 @@ int main (int argc, char *const *argv, char const *const *envp)
newargv[m++] = "--" ;
while (*argv) newargv[m++] = *argv++ ;
newargv[m++] = 0 ;
- xpathexec_run(newargv[0], newargv, envp) ;
+ xexec(newargv) ;
}
diff --git a/src/daemontools-extras/s6-softlimit.c b/src/daemontools-extras/s6-softlimit.c
index f12564d..608385a 100644
--- a/src/daemontools-extras/s6-softlimit.c
+++ b/src/daemontools-extras/s6-softlimit.c
@@ -2,10 +2,11 @@
#include <sys/types.h>
#include <sys/resource.h>
+
#include <skalibs/strerr2.h>
#include <skalibs/sgetopt.h>
#include <skalibs/uint64.h>
-#include <skalibs/djbunix.h>
+#include <skalibs/exec.h>
#define USAGE "s6-softlimit [ -a allbytes ] [ -c corebytes ] [ -d databytes ] [ -f filebytes ] [ -l lockbytes ] [ -m membytes ] [ -o openfiles ] [ -p processes ] [ -r residentbytes ] [ -s stackbytes ] [ -t cpusecs ] prog..."
@@ -24,7 +25,7 @@ static void doit (int res, char const *arg)
if (setrlimit(res, &r) < 0) strerr_diefu1sys(111, "setrlimit") ;
}
-int main (int argc, char const *const *argv, char const *const *envp)
+int main (int argc, char const *const *argv)
{
subgetopt_t l = SUBGETOPT_ZERO ;
PROG = "s6-softlimit" ;
@@ -111,5 +112,5 @@ int main (int argc, char const *const *argv, char const *const *envp)
}
argc -= l.ind ; argv += l.ind ;
if (!argc) strerr_dieusage(100, USAGE) ;
- xpathexec_run(argv[0], argv, envp) ;
+ xexec(argv) ;
}
diff --git a/src/fdholder/s6-fdholder-daemon.c b/src/fdholder/s6-fdholder-daemon.c
index ba057d2..a233db1 100644
--- a/src/fdholder/s6-fdholder-daemon.c
+++ b/src/fdholder/s6-fdholder-daemon.c
@@ -2,16 +2,18 @@
#include <sys/types.h>
#include <limits.h>
+
#include <skalibs/types.h>
#include <skalibs/sgetopt.h>
#include <skalibs/strerr2.h>
-#include <skalibs/djbunix.h>
+#include <skalibs/exec.h>
+
#include <s6/config.h>
#define USAGE "s6-fdholder-daemon [ -v verbosity ] [ -d | -D ] [ -1 ] [ -c maxconn ] [ -n maxfds ] [ -b backlog ] [ -G gid,gid,... ] [ -g gid ] [ -u uid ] [ -U ] [ -t timeout ] [ -T lameducktimeout ] [ -i rulesdir | -x rulesfile ] path"
#define dieusage() strerr_dieusage(100, USAGE)
-int main (int argc, char const *const *argv, char const *const *envp)
+int main (int argc, char const *const *argv)
{
unsigned int verbosity = 1 ;
int flag1 = 0 ;
@@ -150,6 +152,6 @@ int main (int argc, char const *const *argv, char const *const *envp)
newargv[m++] = rulesfile ;
}
newargv[m++] = 0 ;
- xpathexec_run(newargv[0], newargv, envp) ;
+ xexec(newargv) ;
}
}
diff --git a/src/fdholder/s6-fdholder-getdump.c b/src/fdholder/s6-fdholder-getdump.c
index 34aeeb7..da99797 100644
--- a/src/fdholder/s6-fdholder-getdump.c
+++ b/src/fdholder/s6-fdholder-getdump.c
@@ -2,13 +2,15 @@
#include <string.h>
#include <limits.h>
+
#include <skalibs/types.h>
#include <skalibs/strerr2.h>
#include <skalibs/sgetopt.h>
#include <skalibs/tai.h>
-#include <skalibs/env.h>
#include <skalibs/djbunix.h>
#include <skalibs/genalloc.h>
+#include <skalibs/exec.h>
+
#include <s6/s6-fdholder.h>
#define USAGE "s6-fdholder-getdump [ -t timeout ] socket prog..."
@@ -81,6 +83,6 @@ int main (int argc, char const *const *argv, char const *const *envp)
}
modifs[pos++] = 0 ;
}
- xpathexec_r(argv+1, envp, env_len(envp), modifs, pos) ;
+ xmexec_n(argv+1, modifs, pos, 1 + 3*n) ;
}
}
diff --git a/src/fdholder/s6-fdholder-retrieve.c b/src/fdholder/s6-fdholder-retrieve.c
index ebfd2ed..c1a0cd6 100644
--- a/src/fdholder/s6-fdholder-retrieve.c
+++ b/src/fdholder/s6-fdholder-retrieve.c
@@ -5,12 +5,14 @@
#include <skalibs/sgetopt.h>
#include <skalibs/tai.h>
#include <skalibs/djbunix.h>
+#include <skalibs/exec.h>
+
#include <s6/s6-fdholder.h>
#define USAGE "s6-fdholder-retrieve [ -D ] [ -t timeout ] socket id prog..."
#define dieusage() strerr_dieusage(100, USAGE)
-int main (int argc, char const *const *argv, char const *const *envp)
+int main (int argc, char const *const *argv)
{
s6_fdholder_t a = S6_FDHOLDER_ZERO ;
tain_t deadline ;
@@ -49,5 +51,5 @@ int main (int argc, char const *const *argv, char const *const *envp)
if (uncoe(0) < 0) strerr_diefu1sys(111, "uncoe stdin") ;
}
else if (fd_move(0, fd) < 0) strerr_diefu1sys(111, "move fd") ;
- xpathexec_run(argv[2], argv+2, envp) ;
+ xexec(argv+2) ;
}
diff --git a/src/supervision/s6-notifyoncheck.c b/src/supervision/s6-notifyoncheck.c
index b1ef96b..a1ec7ff 100644
--- a/src/supervision/s6-notifyoncheck.c
+++ b/src/supervision/s6-notifyoncheck.c
@@ -16,6 +16,7 @@
#include <skalibs/djbunix.h>
#include <skalibs/selfpipe.h>
#include <skalibs/iopause.h>
+#include <skalibs/exec.h>
#include <s6/s6.h>
@@ -176,7 +177,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
*/
- if (pipe(p) < 0) strerr_diefu1sys(111, "pipe") ;
+ if (pipecoe(p) < 0) strerr_diefu1sys(111, "pipe") ;
switch (df ? doublefork() : fork())
{
case -1: strerr_diefu1sys(111, df ? "doublefork" : "fork") ;
@@ -185,10 +186,8 @@ int main (int argc, char const *const *argv, char const *const *envp)
{
char c ;
close((int)fd) ;
- close(p[1]) ;
if (read(p[0], &c, 1) < 1) strerr_diefu1x(111, "synchronize with child") ;
- close(p[0]) ;
- xpathexec_run(argv[0], argv, envp) ;
+ xexec_e(argv, envp) ;
}
}
@@ -206,7 +205,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
x[1].fd = ftrigr_fd(&a) ;
if (fd_write(p[1], "", 1) < 1) strerr_diefu1sys(2, "synchronize with parent") ;
- fd_close(p[1]) ;
+ close(p[1]) ;
/* Loop around a sleep and a ./data/check invocation */
diff --git a/src/supervision/s6-permafailon.c b/src/supervision/s6-permafailon.c
index 1a9d68e..3912691 100644
--- a/src/supervision/s6-permafailon.c
+++ b/src/supervision/s6-permafailon.c
@@ -9,7 +9,7 @@
#include <skalibs/bitarray.h>
#include <skalibs/sig.h>
#include <skalibs/tai.h>
-#include <skalibs/djbunix.h>
+#include <skalibs/exec.h>
#include <s6/s6-supervise.h>
@@ -59,7 +59,7 @@ static inline void list_scan (char const *s, unsigned char *codes, sigset_t *sig
}
}
-int main (int argc, char const *const *argv, char const *const *envp)
+int main (int argc, char const *const *argv)
{
unsigned char codes[32] ;
sigset_t sigs ;
@@ -122,5 +122,5 @@ int main (int argc, char const *const *argv, char const *const *envp)
}
cont:
- xpathexec0_run(argv + 4, envp) ;
+ xexec0(argv+4) ;
}
diff --git a/src/supervision/s6-svc.c b/src/supervision/s6-svc.c
index 6a5d64b..3e024d6 100644
--- a/src/supervision/s6-svc.c
+++ b/src/supervision/s6-svc.c
@@ -3,10 +3,12 @@
#include <string.h>
#include <unistd.h>
#include <errno.h>
+
#include <skalibs/types.h>
#include <skalibs/sgetopt.h>
#include <skalibs/strerr2.h>
-#include <skalibs/djbunix.h>
+#include <skalibs/exec.h>
+
#include <s6/config.h>
#include <s6/s6-supervise.h>
@@ -15,7 +17,7 @@
#define DATASIZE 63
-int main (int argc, char const *const *argv, char const *const *envp)
+int main (int argc, char const *const *argv)
{
char data[DATASIZE+1] = "-" ;
unsigned int datalen = 1 ;
@@ -106,12 +108,12 @@ int main (int argc, char const *const *argv, char const *const *envp)
newargv[m++] = argv[0] ;
}
newargv[m++] = 0 ;
- xpathexec_run(newargv[0], newargv, envp) ;
+ xexec(newargv) ;
}
else switch (s6_svc_writectl(argv[0], S6_SUPERVISE_CTLDIR, data + 1, datalen - 1))
{
case -1 : strerr_diefu2sys(111, "control ", argv[0]) ;
- case -2 : strerr_dief3sys(100, "something is wrong with the ", argv[0], "/" S6_SUPERVISE_CTLDIR " directory. errno reported") ;
+ case -2 : strerr_dief3sys(100, "something is wrong with the ", argv[0], "/" S6_SUPERVISE_CTLDIR " directory") ;
case 0 : strerr_diefu3x(100, "control ", argv[0], ": supervisor not listening") ;
}
return 0 ;
diff --git a/src/supervision/s6-svscan.c b/src/supervision/s6-svscan.c
index 7016236..3f63c2d 100644
--- a/src/supervision/s6-svscan.c
+++ b/src/supervision/s6-svscan.c
@@ -8,6 +8,7 @@
#include <fcntl.h>
#include <signal.h>
+#include <skalibs/posixplz.h>
#include <skalibs/allreadwrite.h>
#include <skalibs/sgetopt.h>
#include <skalibs/types.h>
@@ -18,7 +19,7 @@
#include <skalibs/direntry.h>
#include <skalibs/sig.h>
#include <skalibs/selfpipe.h>
-#include <skalibs/environ.h>
+#include <skalibs/exec.h>
#include <s6/config.h>
#include <s6/s6-supervise.h>
@@ -331,7 +332,7 @@ static void trystart (unsigned int i, char const *name, int islog)
&& !strcmp(name, SPECIAL_LOGGER_SERVICE)
&& fd_move(2, consoleholder) < 0) /* autoclears coe */
strerr_diefu1sys(111, "restore console fd for service " SPECIAL_LOGGER_SERVICE) ;
- xpathexec_run(S6_BINPREFIX "s6-supervise", cargv, (char const **)environ) ;
+ xexec_a(S6_BINPREFIX "s6-supervise", cargv) ;
}
}
services[i].pid[islog] = pid ;
@@ -496,16 +497,8 @@ int main (int argc, char const *const *argv)
{
case 'c' : if (uint0_scan(l.arg, &max)) break ;
case 't' : if (uint0_scan(l.arg, &t)) break ;
- case 'd' :
- if (!uint0_scan(l.arg, &notif)) dieusage() ;
- if (notif < 3) strerr_dief1x(100, "notification fd must be 3 or more") ;
- if (fcntl(notif, F_GETFD) < 0) strerr_dief1sys(100, "invalid notification fd") ;
- break ;
- case 'X' :
- if (!uint0_scan(l.arg, &consoleholder)) dieusage() ;
- if (consoleholder < 3) strerr_dief1x(100, "console holder fd must be 3 or more") ;
- if (fcntl(consoleholder, F_GETFD) < 0) strerr_dief1sys(100, "invalid console holder fd") ;
- break ;
+ case 'd' : if (!uint0_scan(l.arg, &notif)) dieusage() ; break ;
+ case 'X' : if (!uint0_scan(l.arg, &consoleholder)) dieusage() ; break ;
default : dieusage() ;
}
}
@@ -515,11 +508,10 @@ int main (int argc, char const *const *argv)
if (max < 2) max = 2 ;
}
- /* Init phase.
- If something fails here, we can die, because it means that
- something is seriously wrong with the system, and we can't
- run correctly anyway.
- */
+ if (notif < 3) strerr_dief1x(100, "notification fd must be 3 or more") ;
+ if (fcntl(notif, F_GETFD) < 0) strerr_dief1sys(100, "invalid notification fd") ;
+ if (consoleholder < 3) strerr_dief1x(100, "console holder fd must be 3 or more") ;
+ if (fcntl(consoleholder, F_GETFD) < 0) strerr_dief1sys(100, "invalid console holder fd") ;
if (argc && (chdir(argv[0]) < 0)) strerr_diefu1sys(111, "chdir") ;
if (consoleholder && coe(consoleholder) < 0) strerr_diefu1sys(111, "coe console holder") ;
@@ -560,9 +552,7 @@ int main (int argc, char const *const *argv)
services = blob ;
tain_now_set_stopwatch_g() ;
-
- /* Loop phase.
- From now on, we must not die.
+ /* From now on, we must not die.
Temporize on recoverable errors, and panic on serious ones. */
while (cont)