summaryrefslogtreecommitdiff
path: root/src/daemontools-extras
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2020-11-28 12:38:56 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2020-11-28 12:38:56 +0000
commit1f7a397ea589f31ab8e8eed72ebc2933ddb229a9 (patch)
treecb4e418146839514fbca2f805a7a4e4ee3918324 /src/daemontools-extras
parentbdef68e12278ddfc5080732bd3b28dd5135c9d3a (diff)
downloads6-1f7a397ea589f31ab8e8eed72ebc2933ddb229a9.tar.xz
Adapt to new exec.h
Diffstat (limited to 'src/daemontools-extras')
-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
9 files changed, 45 insertions, 32 deletions
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) ;
}