summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2020-11-26 09:47:02 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2020-11-26 09:47:02 +0000
commit26cd94b2a8f6da396058b6c5d6446e237ec9d78f (patch)
tree13706df3bc9657d911a26133625044ae1e1acb30
parent51a612c34446e10a086947c410aa206fa978d169 (diff)
downloads6-networking-26cd94b2a8f6da396058b6c5d6446e237ec9d78f.tar.xz
Convert to new exec.h syntax
-rw-r--r--src/conn-tools/s6-tcpclient.c30
-rw-r--r--src/conn-tools/s6-tcpserver-access.c15
-rw-r--r--src/conn-tools/s6-tcpserver.c9
-rw-r--r--src/conn-tools/s6-tcpserver4-socketbinder.c7
-rw-r--r--src/conn-tools/s6-tcpserver4.c9
-rw-r--r--src/conn-tools/s6-tcpserver4d.c30
-rw-r--r--src/conn-tools/s6-tcpserver6-socketbinder.c7
-rw-r--r--src/conn-tools/s6-tcpserver6.c9
-rw-r--r--src/conn-tools/s6-tcpserver6d.c30
-rw-r--r--src/sbearssl/sbearssl_run.c2
-rw-r--r--src/tls/s6-tlsclient.c12
-rw-r--r--src/tls/s6-tlsserver.c7
-rw-r--r--src/tls/s6tls_exec_tlscio.c5
-rw-r--r--src/tls/s6tls_exec_tlsdio.c5
-rw-r--r--src/tls/s6tls_sync_and_exec_app.c6
-rw-r--r--src/tls/s6tls_ucspi_exec_app.c6
16 files changed, 106 insertions, 83 deletions
diff --git a/src/conn-tools/s6-tcpclient.c b/src/conn-tools/s6-tcpclient.c
index e2ba32b..c439812 100644
--- a/src/conn-tools/s6-tcpclient.c
+++ b/src/conn-tools/s6-tcpclient.c
@@ -3,6 +3,7 @@
#include <string.h>
#include <stdint.h>
#include <errno.h>
+
#include <skalibs/types.h>
#include <skalibs/sgetopt.h>
#include <skalibs/fmtscan.h>
@@ -14,7 +15,10 @@
#include <skalibs/skamisc.h>
#include <skalibs/socket.h>
#include <skalibs/ip46.h>
+#include <skalibs/exec.h>
+
#include <s6-dns/s6dns.h>
+
#include <s6-networking/ident.h>
#ifdef SKALIBS_IPV6_ENABLED
@@ -267,18 +271,18 @@ int main (int argc, char const *const *argv)
fmtport[uint16_fmt(fmtport, remoteport)] = 0 ;
if (flags.verbosity >= 2)
strerr_warni4x("connected to ", fmtip, " port ", fmtport) ;
- if (!pathexec_env("PROTO", "TCP")
- || !pathexec_env("TCPREMOTEIP", fmtip)
- || !pathexec_env("TCPREMOTEPORT", fmtport)) dienomem() ;
+ if (!env_mexec("PROTO", "TCP")
+ || !env_mexec("TCPREMOTEIP", fmtip)
+ || !env_mexec("TCPREMOTEPORT", fmtport)) dienomem() ;
fmtip[ip46_fmt(fmtip, &flags.localip)] = 0 ;
fmtport[uint16_fmt(fmtport, flags.localport)] = 0 ;
- if (!pathexec_env("TCPLOCALIP", fmtip)
- || !pathexec_env("TCPLOCALPORT", fmtport)) dienomem() ;
+ if (!env_mexec("TCPLOCALIP", fmtip)
+ || !env_mexec("TCPLOCALPORT", fmtport)) dienomem() ;
if (flags.localname)
{
- if (!pathexec_env("TCPLOCALHOST", flags.localname)) dienomem() ;
+ if (!env_mexec("TCPLOCALHOST", flags.localname)) dienomem() ;
}
/* DNS resolution for TCPLOCALHOST and TCPREMOTEHOST */
@@ -318,7 +322,7 @@ int main (int argc, char const *const *argv)
{
if (blob[0].status)
{
- if (!pathexec_env("TCPLOCALHOST", 0)) dienomem() ;
+ if (!env_mexec("TCPLOCALHOST", 0)) dienomem() ;
}
else
{
@@ -328,14 +332,14 @@ int main (int argc, char const *const *argv)
len = s6dns_domain_tostring(s, 255, genalloc_s(s6dns_domain_t, &data[0].ds)) ;
genalloc_free(s6dns_domain_t, &data[0].ds) ;
s[len] = 0 ;
- if (!pathexec_env("TCPLOCALHOST", s)) dienomem() ;
+ if (!env_mexec("TCPLOCALHOST", s)) dienomem() ;
}
}
if (flags.remotehost)
{
if (blob[1].status)
{
- if (!pathexec_env("TCPREMOTEHOST", 0)) dienomem() ;
+ if (!env_mexec("TCPREMOTEHOST", 0)) dienomem() ;
}
else
{
@@ -345,7 +349,7 @@ int main (int argc, char const *const *argv)
len = s6dns_domain_tostring(s, 255, genalloc_s(s6dns_domain_t, &data[1].ds)) ;
genalloc_free(s6dns_domain_t, &data[1].ds) ;
s[len] = 0 ;
- if (!pathexec_env("TCPREMOTEHOST", s)) dienomem() ;
+ if (!env_mexec("TCPREMOTEHOST", s)) dienomem() ;
}
}
}
@@ -369,14 +373,14 @@ int main (int argc, char const *const *argv)
if (r < 0) strerr_warnwu1sys("s6net_ident_client") ;
else strerr_warnw2x("ident server replied: ", s6net_ident_error_str(errno)) ;
}
- if (!pathexec_env("TCPREMOTEINFO", "")) dienomem() ;
+ if (!env_mexec("TCPREMOTEINFO", "")) dienomem() ;
}
- else if (!pathexec_env("TCPREMOTEINFO", idbuf)) dienomem() ;
+ else if (!env_mexec("TCPREMOTEINFO", idbuf)) dienomem() ;
}
}
}
if (fd_move(6, s) < 0) strerr_diefu2sys(111, "set up fd ", "6") ;
if (fd_copy(7, 6) < 0) strerr_diefu2sys(111, "set up fd ", "7") ;
- xpathexec(argv+2) ;
+ xmexec(argv+2) ;
}
diff --git a/src/conn-tools/s6-tcpserver-access.c b/src/conn-tools/s6-tcpserver-access.c
index ec2ac63..4dc6a5b 100644
--- a/src/conn-tools/s6-tcpserver-access.c
+++ b/src/conn-tools/s6-tcpserver-access.c
@@ -4,6 +4,7 @@
#include <stdint.h>
#include <unistd.h>
#include <errno.h>
+#include <stdlib.h>
#include <skalibs/gccattributes.h>
#include <skalibs/types.h>
@@ -18,9 +19,11 @@
#include <skalibs/djbunix.h>
#include <skalibs/socket.h>
#include <skalibs/ip46.h>
+#include <skalibs/exec.h>
#include <skalibs/unix-timed.h>
#include <s6/accessrules.h>
+
#include <s6-dns/s6dns.h>
#include <s6-networking/config.h>
@@ -57,7 +60,7 @@ static inline void log_deny (pid_t pid, ip46_t const *ip)
}
-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 ;
stralloc modifs = STRALLOC_ZERO ;
@@ -118,7 +121,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) ;
{
@@ -126,11 +129,11 @@ int main (int argc, char const *const *argv, char const *const *envp)
char tmp[protolen + 11] ;
memcpy(tmp, proto, protolen) ;
memcpy(tmp + protolen, "REMOTEIP", 9) ;
- x = env_get2(envp, tmp) ;
+ x = getenv(tmp) ;
if (!x) strerr_dienotset(100, tmp) ;
if (!ip46_scan(x, &remoteip)) strerr_dieinvalid(100, tmp) ;
memcpy(tmp + protolen + 6, "PORT", 5) ;
- x = env_get2(envp, tmp) ;
+ x = getenv(tmp) ;
if (!x) strerr_dienotset(100, tmp) ;
if (!uint160_scan(x, &remoteport)) strerr_dieinvalid(100, tmp) ;
}
@@ -388,13 +391,13 @@ int main (int argc, char const *const *argv, char const *const *envp)
#ifdef S6_NETWORKING_USE_EXECLINE
{
char *specialargv[4] = { EXECLINE_EXTBINPREFIX "execlineb", "-c", 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-networking 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) ;
reject:
if (verbosity >= 2)
diff --git a/src/conn-tools/s6-tcpserver.c b/src/conn-tools/s6-tcpserver.c
index 1143af7..ed874b6 100644
--- a/src/conn-tools/s6-tcpserver.c
+++ b/src/conn-tools/s6-tcpserver.c
@@ -2,18 +2,21 @@
#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/ip46.h>
+#include <skalibs/exec.h>
+
#include <s6/config.h>
+
#include <s6-networking/config.h>
#define USAGE "s6-tcpserver [ -q | -Q | -v ] [ -4 | -6 ] [ -d | -D ] [ -1 ] [ -c maxconn ] [ -C localmaxconn ] [ -b backlog ] [ -G gid,gid,... ] [ -g gid ] [ -u uid ] [ -U ] ip port 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 ;
@@ -130,6 +133,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-tcpserver4-socketbinder.c b/src/conn-tools/s6-tcpserver4-socketbinder.c
index bcd9ee1..a37fae1 100644
--- a/src/conn-tools/s6-tcpserver4-socketbinder.c
+++ b/src/conn-tools/s6-tcpserver4-socketbinder.c
@@ -1,19 +1,22 @@
/* ISC license. */
+#include <skalibs/nonposix.h>
#include <stdint.h>
#include <unistd.h>
#include <sys/socket.h>
+
#include <skalibs/types.h>
#include <skalibs/sgetopt.h>
#include <skalibs/fmtscan.h>
#include <skalibs/strerr2.h>
#include <skalibs/djbunix.h>
#include <skalibs/socket.h>
+#include <skalibs/exec.h>
#define USAGE "s6-tcpserver4-socketbinder [ -d | -D ] [ -b backlog ] [ -M | -m ] [ -B ] ip4 port 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 ;
@@ -51,5 +54,5 @@ int main (int argc, char const *const *argv, char const *const *envp)
if (backlog && socket_listen(0, backlog) < 0)
strerr_diefu5sys(111, "listen to ", argv[0], ":", argv[1], " ") ;
- xpathexec_run(argv[2], argv + 2, envp) ;
+ xexec(argv+2) ;
}
diff --git a/src/conn-tools/s6-tcpserver4.c b/src/conn-tools/s6-tcpserver4.c
index f97d307..144e16a 100644
--- a/src/conn-tools/s6-tcpserver4.c
+++ b/src/conn-tools/s6-tcpserver4.c
@@ -2,17 +2,20 @@
#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>
+
#include <s6-networking/config.h>
#define USAGE "s6-tcpserver4 [ -v verbosity ] [ -d | -D ] [ -1 ] [ -c maxconn ] [ -C localmaxconn ] [ -b backlog ] [ -G gid,gid,... ] [ -g gid ] [ -u uid ] [ -U ] ip port 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 ;
@@ -123,6 +126,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-tcpserver4d.c b/src/conn-tools/s6-tcpserver4d.c
index 7f8f27a..851058d 100644
--- a/src/conn-tools/s6-tcpserver4d.c
+++ b/src/conn-tools/s6-tcpserver4d.c
@@ -8,9 +8,9 @@
#include <unistd.h>
#include <fcntl.h>
#include <signal.h>
+
#include <skalibs/gccattributes.h>
#include <skalibs/allreadwrite.h>
-#include <skalibs/uint16.h>
#include <skalibs/types.h>
#include <skalibs/sgetopt.h>
#include <skalibs/strerr2.h>
@@ -22,6 +22,7 @@
#include <skalibs/selfpipe.h>
#include <skalibs/iopause.h>
#include <skalibs/socket.h>
+#include <skalibs/exec.h>
#define ABSOLUTE_MAXCONN 1000
@@ -79,7 +80,7 @@ static inline unsigned int lookup_ip (uint32_t ip)
/* Logging */
-static void log_start (void)
+static inline void log_start (void)
{
strerr_warni1x("starting") ;
}
@@ -96,7 +97,7 @@ static void log_status (void)
strerr_warni3x("status: ", fmt, fmtmaxconn) ;
}
-static void log_deny (uint32_t ip, uint16_t port, unsigned int num)
+static inline void log_deny (uint32_t ip, uint16_t port, unsigned int num)
{
char fmtip[UINT32_FMT] ;
char fmtport[UINT16_FMT] ;
@@ -107,7 +108,7 @@ static void log_deny (uint32_t ip, uint16_t port, unsigned int num)
strerr_warni7sys("deny ", fmtip, ":", fmtport, " count ", fmtnum, fmtlocalmaxconn) ;
}
-static void log_accept (pid_t pid, uint32_t ip, uint16_t port, unsigned int num)
+static inline void log_accept (pid_t pid, uint32_t ip, uint16_t port, unsigned int num)
{
char fmtipport[IP4_FMT + UINT16_FMT + 1] ;
char fmtpid[PID_FMT] ;
@@ -122,7 +123,7 @@ static void log_accept (pid_t pid, uint32_t ip, uint16_t port, unsigned int num)
strerr_warni7x("allow ", fmtipport, " pid ", fmtpid, " count ", fmtnum, fmtlocalmaxconn) ;
}
-static void log_close (pid_t pid, uint32_t ip, int w)
+static inline void log_close (pid_t pid, uint32_t ip, int w)
{
char fmtpid[PID_FMT] ;
char fmtip[IP4_FMT] = "?" ;
@@ -142,7 +143,7 @@ static void killthem (int sig)
for (; i < numconn ; i++) kill(pidip[i].left, sig) ;
}
-static void wait_children (void)
+static inline void wait_children (void)
{
for (;;)
{
@@ -170,7 +171,7 @@ static void wait_children (void)
}
}
-static void handle_signals (void)
+static inline void handle_signals (void)
{
for (;;) switch (selfpipe_read())
{
@@ -216,8 +217,8 @@ static void handle_signals (void)
/* New connection handling */
-static void run_child (int, uint32_t, uint16_t, unsigned int, char const *const *, char const *const *) gccattr_noreturn ;
-static void run_child (int s, uint32_t ip, uint16_t port, unsigned int num, char const *const *argv, char const *const *envp)
+static inline void run_child (int, uint32_t, uint16_t, unsigned int, char const *const *) gccattr_noreturn ;
+static inline void run_child (int s, uint32_t ip, uint16_t port, unsigned int num, char const *const *argv)
{
char fmt[74] ;
size_t n = 0 ;
@@ -230,11 +231,10 @@ static void run_child (int s, uint32_t ip, uint16_t port, unsigned int num, char
n += uint16_fmt(fmt+n, port) ; fmt[n++] = 0 ;
memcpy(fmt+n, "TCPCONNNUM=", 11) ; n += 11 ;
n += uint_fmt(fmt+n, num) ; fmt[n++] = 0 ;
- pathexec_r(argv, envp, env_len(envp), fmt, n) ;
- strerr_dieexec(111, argv[0]) ;
+ xmexec_n(argv, fmt, n, 4) ;
}
-static void new_connection (int s, uint32_t ip, uint16_t port, char const *const *argv, char const *const *envp)
+static inline void new_connection (int s, uint32_t ip, uint16_t port, char const *const *argv)
{
unsigned int i = lookup_ip(ip) ;
unsigned int num = (i < iplen) ? ipnum[i].right : 0 ;
@@ -253,7 +253,7 @@ static void new_connection (int s, uint32_t ip, uint16_t port, char const *const
else if (!pid)
{
selfpipe_finish() ;
- run_child(s, ip, port, num+1, argv, envp) ;
+ run_child(s, ip, port, num+1, argv) ;
}
if (i < iplen) ipnum[i].right = num + 1 ;
@@ -274,7 +274,7 @@ static void new_connection (int s, uint32_t ip, uint16_t port, char const *const
/* And the main */
-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-tcpserver4d" ;
@@ -374,7 +374,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
{
uint32_t ip ;
uint32_unpack_big(packedip, &ip) ;
- new_connection(fd, ip, port, argv, envp) ;
+ new_connection(fd, ip, port, argv) ;
fd_close(fd) ;
}
}
diff --git a/src/conn-tools/s6-tcpserver6-socketbinder.c b/src/conn-tools/s6-tcpserver6-socketbinder.c
index 1c4835b..683dc7c 100644
--- a/src/conn-tools/s6-tcpserver6-socketbinder.c
+++ b/src/conn-tools/s6-tcpserver6-socketbinder.c
@@ -1,19 +1,22 @@
/* ISC license. */
+#include <skalibs/nonposix.h>
#include <stdint.h>
#include <unistd.h>
#include <sys/socket.h>
+
#include <skalibs/types.h>
#include <skalibs/sgetopt.h>
#include <skalibs/fmtscan.h>
#include <skalibs/strerr2.h>
#include <skalibs/djbunix.h>
#include <skalibs/socket.h>
+#include <skalibs/exec.h>
#define USAGE "s6-tcpserver6-socketbinder [ -d | -D ] [ -b backlog ] [ -M | -m ] [ -B ] ip6 port 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 ;
@@ -51,5 +54,5 @@ int main (int argc, char const *const *argv, char const *const *envp)
if (backlog && socket_listen(0, backlog) < 0)
strerr_diefu5sys(111, "listen to ", argv[0], ":", argv[1], " ") ;
- xpathexec_run(argv[2], argv + 2, envp) ;
+ xexec(argv+2) ;
}
diff --git a/src/conn-tools/s6-tcpserver6.c b/src/conn-tools/s6-tcpserver6.c
index f96d45b..51ad4a1 100644
--- a/src/conn-tools/s6-tcpserver6.c
+++ b/src/conn-tools/s6-tcpserver6.c
@@ -2,17 +2,20 @@
#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>
+
#include <s6-networking/config.h>
#define USAGE "s6-tcpserver6 [ -v verbosity ] [ -d | -D ] [ -1 ] [ -c maxconn ] [ -C localmaxconn ] [ -b backlog ] [ -G gid,gid,... ] [ -g gid ] [ -u uid ] [ -U ] ip port 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 ;
@@ -123,6 +126,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-tcpserver6d.c b/src/conn-tools/s6-tcpserver6d.c
index 65e9133..e769ab1 100644
--- a/src/conn-tools/s6-tcpserver6d.c
+++ b/src/conn-tools/s6-tcpserver6d.c
@@ -8,9 +8,9 @@
#include <unistd.h>
#include <fcntl.h>
#include <signal.h>
+
#include <skalibs/gccattributes.h>
#include <skalibs/allreadwrite.h>
-#include <skalibs/uint16.h>
#include <skalibs/types.h>
#include <skalibs/sgetopt.h>
#include <skalibs/strerr2.h>
@@ -21,6 +21,7 @@
#include <skalibs/selfpipe.h>
#include <skalibs/iopause.h>
#include <skalibs/socket.h>
+#include <skalibs/exec.h>
#define ABSOLUTE_MAXCONN 1000
@@ -85,7 +86,7 @@ static inline unsigned int lookup_ip (char const *ip)
/* Logging */
-static void log_start (void)
+static inline void log_start (void)
{
strerr_warni1x("starting") ;
}
@@ -102,7 +103,7 @@ static void log_status (void)
strerr_warni3x("status: ", fmt, fmtmaxconn) ;
}
-static void log_deny (char const *ip, uint16_t port, unsigned int num)
+static inline void log_deny (char const *ip, uint16_t port, unsigned int num)
{
char fmtip[IP6_FMT] ;
char fmtport[UINT16_FMT] ;
@@ -113,7 +114,7 @@ static void log_deny (char const *ip, uint16_t port, unsigned int num)
strerr_warni7sys("deny ", fmtip, " port ", fmtport, " count ", fmtnum, fmtlocalmaxconn) ;
}
-static void log_accept (pid_t pid, char const *ip, uint16_t port, unsigned int num)
+static inline void log_accept (pid_t pid, char const *ip, uint16_t port, unsigned int num)
{
char fmtipport[IP6_FMT + UINT16_FMT + 6] ;
char fmtpid[PID_FMT] ;
@@ -128,7 +129,7 @@ static void log_accept (pid_t pid, char const *ip, uint16_t port, unsigned int n
strerr_warni7x("allow ", fmtipport, " pid ", fmtpid, " count ", fmtnum, fmtlocalmaxconn) ;
}
-static void log_close (pid_t pid, char const *ip, int w)
+static inline void log_close (pid_t pid, char const *ip, int w)
{
char fmtpid[PID_FMT] ;
char fmtip[IP6_FMT] = "?" ;
@@ -148,7 +149,7 @@ static void killthem (int sig)
for (; i < numconn ; i++) kill(pidip[i].pid, sig) ;
}
-static void wait_children (void)
+static inline void wait_children (void)
{
for (;;)
{
@@ -176,7 +177,7 @@ static void wait_children (void)
}
}
-static void handle_signals (void)
+static inline void handle_signals (void)
{
for (;;) switch (selfpipe_read())
{
@@ -222,8 +223,8 @@ static void handle_signals (void)
/* New connection handling */
-static void run_child (int, char const *, uint16_t, unsigned int, char const *const *, char const *const *) gccattr_noreturn ;
-static void run_child (int s, char const *ip, uint16_t port, unsigned int num, char const *const *argv, char const *const *envp)
+static inline void run_child (int, char const *, uint16_t, unsigned int, char const *const *) gccattr_noreturn ;
+static inline void run_child (int s, char const *ip, uint16_t port, unsigned int num, char const *const *argv)
{
char fmt[98] ;
size_t n = 0 ;
@@ -236,11 +237,10 @@ static void run_child (int s, char const *ip, uint16_t port, unsigned int num, c
n += uint16_fmt(fmt+n, port) ; fmt[n++] = 0 ;
memcpy(fmt+n, "TCPCONNNUM=", 11) ; n += 11 ;
n += uint_fmt(fmt+n, num) ; fmt[n++] = 0 ;
- pathexec_r(argv, envp, env_len(envp), fmt, n) ;
- strerr_dieexec(111, argv[0]) ;
+ xmexec_n(argv, fmt, n, 4) ;
}
-static void new_connection (int s, char const *ip, uint16_t port, char const *const *argv, char const *const *envp)
+static inline void new_connection (int s, char const *ip, uint16_t port, char const *const *argv)
{
unsigned int i = lookup_ip(ip) ;
unsigned int num = (i < iplen) ? ipnum[i].num : 0 ;
@@ -259,7 +259,7 @@ static void new_connection (int s, char const *ip, uint16_t port, char const *co
else if (!pid)
{
selfpipe_finish() ;
- run_child(s, ip, port, num+1, argv, envp) ;
+ run_child(s, ip, port, num+1, argv) ;
}
if (i < iplen) ipnum[i].num = num + 1 ;
@@ -278,7 +278,7 @@ static void new_connection (int s, char const *ip, uint16_t port, char const *co
}
-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-tcpserver6d" ;
@@ -379,7 +379,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
}
else
{
- new_connection(fd, ip, port, argv, envp) ;
+ new_connection(fd, ip, port, argv) ;
fd_close(fd) ;
}
}
diff --git a/src/sbearssl/sbearssl_run.c b/src/sbearssl/sbearssl_run.c
index af58a04..6a350a9 100644
--- a/src/sbearssl/sbearssl_run.c
+++ b/src/sbearssl/sbearssl_run.c
@@ -76,7 +76,7 @@ void sbearssl_run (br_ssl_engine_context *ctx, int *fds, tain_t const *tto, uint
}
else xindex[3] = 4 ;
- if (xindex[0] == 4 && xindex[1] == 4 && xindex[3] == 4 && handshake_done || !j) break ;
+ if ((xindex[0] == 4 && xindex[1] == 4 && xindex[3] == 4 && handshake_done) || !j) break ;
tain_add_g(&deadline, fds[0] >= 0 && fds[2] >= 0 && state & (BR_SSL_SENDAPP | BR_SSL_RECVREC) ? tto : &tain_infinite_relative) ;
r = iopause_g(x, j, &deadline) ;
diff --git a/src/tls/s6-tlsclient.c b/src/tls/s6-tlsclient.c
index 267f457..06ef4da 100644
--- a/src/tls/s6-tlsclient.c
+++ b/src/tls/s6-tlsclient.c
@@ -1,12 +1,14 @@
/* ISC license. */
-#include <string.h>
#include <stdint.h>
+#include <string.h>
+
#include <skalibs/types.h>
#include <skalibs/sgetopt.h>
#include <skalibs/strerr2.h>
-#include <skalibs/djbunix.h>
#include <skalibs/ip46.h>
+#include <skalibs/exec.h>
+
#include <s6-networking/config.h>
#define USAGE "s6-tlsclient [ options ] host port prog...\n" \
@@ -24,8 +26,8 @@ struct options_s
unsigned int ximeout ;
unsigned int yimeout ;
unsigned int kimeout ;
- uint16_t localport ;
ip46full_t localip ;
+ uint16_t localport ;
unsigned int verbosity : 2 ;
unsigned int flag4 : 1 ;
unsigned int flag6 : 1 ;
@@ -62,7 +64,7 @@ struct options_s
.doxy = 0 \
}
-int main (int argc, char const *const *argv, char const *const *envp)
+int main (int argc, char const *const *argv)
{
options_t o = OPTIONS_ZERO ;
PROG = "s6-tlsclient" ;
@@ -197,6 +199,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/tls/s6-tlsserver.c b/src/tls/s6-tlsserver.c
index fb899eb..fe493ad 100644
--- a/src/tls/s6-tlsserver.c
+++ b/src/tls/s6-tlsserver.c
@@ -2,11 +2,14 @@
#include <sys/types.h>
#include <limits.h>
+
#include <skalibs/types.h>
#include <skalibs/sgetopt.h>
#include <skalibs/strerr2.h>
#include <skalibs/djbunix.h>
+
#include <s6/config.h>
+
#include <s6-networking/config.h>
#define USAGE "s6-tlsserver [ -e ] [ options ] ip port prog...\n" \
@@ -80,7 +83,7 @@ struct options_s
.doapply = 0 \
}
-int main (int argc, char const *const *argv, char const *const *envp)
+int main (int argc, char const *const *argv)
{
options_t o = OPTIONS_ZERO ;
PROG = "s6-tlsserver" ;
@@ -250,6 +253,6 @@ int main (int argc, char const *const *argv, char const *const *envp)
}
while (*argv) newargv[m++] = *argv++ ;
newargv[m++] = 0 ;
- xpathexec_run(newargv[0], newargv, envp) ;
+ xexec(newargv) ;
}
}
diff --git a/src/tls/s6tls_exec_tlscio.c b/src/tls/s6tls_exec_tlscio.c
index ad00ecd..e4e84f9 100644
--- a/src/tls/s6tls_exec_tlscio.c
+++ b/src/tls/s6tls_exec_tlscio.c
@@ -1,8 +1,7 @@
/* ISC license. */
-#include <skalibs/posixplz.h>
#include <skalibs/types.h>
-#include <skalibs/djbunix.h>
+#include <skalibs/exec.h>
#include <s6-networking/config.h>
#include "s6tls-internal.h"
@@ -49,5 +48,5 @@ void s6tls_exec_tlscio (int const *fds, uint32_t options, unsigned int verbosity
newargv[m++] = fmtw ;
fmtw[uint_fmt(fmtw, fds[1])] = 0 ;
newargv[m++] = 0 ;
- xpathexec_run(newargv[0], newargv, (char const *const *)environ) ;
+ xexec(newargv) ;
}
diff --git a/src/tls/s6tls_exec_tlsdio.c b/src/tls/s6tls_exec_tlsdio.c
index b00adb2..3007cf0 100644
--- a/src/tls/s6tls_exec_tlsdio.c
+++ b/src/tls/s6tls_exec_tlsdio.c
@@ -1,8 +1,7 @@
/* ISC license. */
-#include <skalibs/posixplz.h>
#include <skalibs/types.h>
-#include <skalibs/djbunix.h>
+#include <skalibs/exec.h>
#include <s6-networking/config.h>
#include "s6tls-internal.h"
@@ -45,5 +44,5 @@ void s6tls_exec_tlsdio (int const *fds, uint32_t options, unsigned int verbosity
newargv[m++] = fmtw ;
fmtw[uint_fmt(fmtw, fds[1])] = 0 ;
newargv[m++] = 0 ;
- xpathexec_run(newargv[0], newargv, (char const *const *)environ) ;
+ xexec(newargv) ;
}
diff --git a/src/tls/s6tls_sync_and_exec_app.c b/src/tls/s6tls_sync_and_exec_app.c
index 4ae63fa..ff42d73 100644
--- a/src/tls/s6tls_sync_and_exec_app.c
+++ b/src/tls/s6tls_sync_and_exec_app.c
@@ -1,12 +1,12 @@
/* ISC license. */
#include <stdint.h>
+#include <string.h>
#include <unistd.h>
-#include <skalibs/posixplz.h>
#include <skalibs/strerr2.h>
-#include <skalibs/env.h>
#include <skalibs/djbunix.h>
+#include <skalibs/exec.h>
#include "s6tls-internal.h"
@@ -39,5 +39,5 @@ void s6tls_sync_and_exec_app (char const *const *argv, int const p[4][2], pid_t
if (r >= MAXENVSIZE)
strerr_dief1x(100, "SSL data too large") ;
m += r - 1 ;
- xpathexec_r(argv, (char const *const *)environ, env_len((char const *const *)environ), buf, m) ;
+ xmexec_m(argv, buf, m) ;
}
diff --git a/src/tls/s6tls_ucspi_exec_app.c b/src/tls/s6tls_ucspi_exec_app.c
index f4b52ef..34c05e2 100644
--- a/src/tls/s6tls_ucspi_exec_app.c
+++ b/src/tls/s6tls_ucspi_exec_app.c
@@ -4,10 +4,8 @@
#include <string.h>
#include <unistd.h>
-#include <skalibs/posixplz.h>
#include <skalibs/types.h>
-#include <skalibs/env.h>
-#include <skalibs/djbunix.h>
+#include <skalibs/exec.h>
#include "s6tls-internal.h"
@@ -32,5 +30,5 @@ void s6tls_ucspi_exec_app (char const *const *argv, int const p[4][2], uint32_t
memcpy(modif + m, "SSLWRITEFD=", 11) ; m += 11 ;
m += uint_fmt(modif + m, p[0][1]) ;
modif[m++] = 0 ;
- xpathexec_r(argv, (char const *const *)environ, env_len((char const* const *)environ), modif, m) ;
+ xmexec_m(argv, modif, m) ;
}