diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2020-11-28 12:38:56 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2020-11-28 12:38:56 +0000 |
commit | 1f7a397ea589f31ab8e8eed72ebc2933ddb229a9 (patch) | |
tree | cb4e418146839514fbca2f805a7a4e4ee3918324 /src/conn-tools | |
parent | bdef68e12278ddfc5080732bd3b28dd5135c9d3a (diff) | |
download | s6-1f7a397ea589f31ab8e8eed72ebc2933ddb229a9.tar.xz |
Adapt to new exec.h
Diffstat (limited to 'src/conn-tools')
-rw-r--r-- | src/conn-tools/s6-connlimit.c | 15 | ||||
-rw-r--r-- | src/conn-tools/s6-ipcclient.c | 6 | ||||
-rw-r--r-- | src/conn-tools/s6-ipcserver-access.c | 16 | ||||
-rw-r--r-- | src/conn-tools/s6-ipcserver-socketbinder.c | 6 | ||||
-rw-r--r-- | src/conn-tools/s6-ipcserver.c | 8 | ||||
-rw-r--r-- | src/conn-tools/s6-ipcserverd.c | 29 | ||||
-rw-r--r-- | src/conn-tools/s6-sudo.c | 7 | ||||
-rw-r--r-- | src/conn-tools/s6-sudod.c | 7 |
8 files changed, 51 insertions, 43 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]) ; |