commit 04b699857c141a93fc981b83ba02b452ce3a2ddc parent a4deb6285e4a3d4aa10fe1913e0be400ec4be25e Author: Laurent Bercot <ska-skaware@skarnet.org> Date: Mon, 28 Aug 2017 13:59:16 +0000 Switch to xpathexec_* Diffstat:
29 files changed, 39 insertions(+), 69 deletions(-)
diff --git a/doc/index.html b/doc/index.html @@ -130,10 +130,11 @@ the previous versions of s6 and the current one. </li> <h3> Commands </h3> <p> - All these commands exit 111 if they encounter a temporary error or -hardware error, and -100 if they encounter a permanent error - such as a misuse. Short-lived -commands exit 0 on success. + All these commands exit 111 if they encounter a temporary error, and +100 if they encounter a permanent error - such as a misuse. They exit +127 if they're trying to execute into a program and cannot find it, and +126 if they fail to execute into a program for another reason. +Short-lived commands exit 0 on success. </p> <h4> Supervision system </h4> diff --git a/src/conn-tools/s6-connlimit.c b/src/conn-tools/s6-connlimit.c @@ -33,7 +33,6 @@ int main (int argc, char const *const *argv, char const *const *envp) strerr_dief2x(1, "number of connections from this client limited to ", x) ; } } - pathexec0_run(argv+1, envp) ; (void)argc ; - strerr_dieexec(111, argv[1]) ; + xpathexec0_run(argv+1, envp) ; } diff --git a/src/conn-tools/s6-ipcclient.c b/src/conn-tools/s6-ipcclient.c @@ -61,7 +61,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") ; - pathexec_r(argv+1, envp, env_len(envp), modif, i) ; + xpathexec_r(argv+1, envp, env_len(envp), modif, i) ; } - strerr_dieexec(111, argv[1]) ; } diff --git a/src/conn-tools/s6-ipcserver-access.c b/src/conn-tools/s6-ipcserver-access.c @@ -206,10 +206,7 @@ int main (int argc, char const *const *argv, char const *const *envp) if (params.exec.len) { char *specialargv[4] = { EXECLINE_EXTBINPREFIX "execlineb", "-c", params.exec.s, 0 } ; - pathexec_r((char const *const *)specialargv, envp, env_len(envp), params.env.s, params.env.len) ; - strerr_dieexec(111, specialargv[0]) ; + xpathexec_r((char const *const *)specialargv, envp, env_len(envp), params.env.s, params.env.len) ; } - - pathexec_r(argv, envp, env_len(envp), params.env.s, params.env.len) ; - strerr_dieexec(111, argv[0]) ; + else xpathexec_r(argv, envp, env_len(envp), params.env.s, params.env.len) ; } diff --git a/src/conn-tools/s6-ipcserver-socketbinder.c b/src/conn-tools/s6-ipcserver-socketbinder.c @@ -48,6 +48,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]) ; - pathexec_run(argv[1], argv + 1, envp) ; - strerr_dieexec(111, argv[1]) ; + xpathexec_run(argv[1], argv + 1, envp) ; } diff --git a/src/conn-tools/s6-ipcserver.c b/src/conn-tools/s6-ipcserver.c @@ -122,7 +122,6 @@ int main (int argc, char const *const *argv, char const *const *envp) newargv[m++] = "--" ; while (*argv) newargv[m++] = *argv++ ; newargv[m++] = 0 ; - pathexec_run(newargv[0], newargv, envp) ; - strerr_dieexec(111, newargv[0]) ; + xpathexec_run(newargv[0], newargv, envp) ; } } diff --git a/src/conn-tools/s6-ipcserverd.c b/src/conn-tools/s6-ipcserverd.c @@ -255,8 +255,7 @@ 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 ; - pathexec_r(argv, envp, env_len(envp), fmt, n) ; - strerr_dieexec(111, argv[0]) ; + xpathexec_r(argv, envp, env_len(envp), fmt, n) ; } static void new_connection (int s, char const *remotepath, char const *const *argv, char const *const *envp) diff --git a/src/conn-tools/s6-sudo.c b/src/conn-tools/s6-sudo.c @@ -61,7 +61,6 @@ int main (int argc, char const *const *argv, char const *const *envp) eargv[n++] = "--" ; while (argc--) eargv[n++] = *argv++ ; eargv[n++] = 0 ; - pathexec_run(eargv[0], eargv, envp) ; + xpathexec_run(eargv[0], eargv, envp) ; } - strerr_dieexec(111, S6_BINPREFIX "s6-ipcclient") ; } diff --git a/src/conn-tools/s6-sudod.c b/src/conn-tools/s6-sudod.c @@ -145,6 +145,7 @@ int main (int argc, char const *const *argv, char const *const *envp) 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) @@ -157,11 +158,9 @@ int main (int argc, char const *const *argv, char const *const *envp) } selfpipe_finish() ; pathexec0_run(targv, tenvp) ; - { - char c = errno ; - fd_write(p[1], &c, 1) ; - } - strerr_dieexec(111, targv[0]) ; + c = errno ; + fd_write(p[1], &c, 1) ; + strerr_dieexec(c == ENOENT ? 127 : 126, targv[0]) ; } fd_close(p[1]) ; { diff --git a/src/daemontools-extras/s6-applyuidgid.c b/src/daemontools-extras/s6-applyuidgid.c @@ -61,7 +61,6 @@ int main (int argc, char const *const *argv, char const *const *envp) if (uid && setuid(uid) < 0) strerr_diefu1sys(111, "setuid") ; - if (unexport) pathexec_r(argv, envp, env_len(envp), "UID\0GID\0GIDLIST", 16) ; - else pathexec_run(argv[0], argv, envp) ; - strerr_dieexec(111, argv[0]) ; + if (unexport) xpathexec_r(argv, envp, env_len(envp), "UID\0GID\0GIDLIST", 16) ; + else xpathexec_run(argv[0], argv, envp) ; } diff --git a/src/daemontools-extras/s6-envdir.c b/src/daemontools-extras/s6-envdir.c @@ -35,6 +35,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") ; - pathexec_r(argv, envp, env_len(envp), modifs.s, modifs.len) ; - strerr_dieexec(111, argv[0]) ; + xpathexec_r(argv, envp, env_len(envp), modifs.s, modifs.len) ; } diff --git a/src/daemontools-extras/s6-envuidgid.c b/src/daemontools-extras/s6-envuidgid.c @@ -153,7 +153,6 @@ int main (int argc, char *const *argv, char const *const *envp) pos += gid_fmtlist(fmt + pos, tab, n) ; fmt[pos++] = 0 ; } - pathexec_r((char const *const *)argv + 1, envp, env_len(envp), fmt, pos) ; + xpathexec_r((char const *const *)argv + 1, envp, env_len(envp), fmt, pos) ; } - strerr_dieexec(111, argv[1]) ; } diff --git a/src/daemontools-extras/s6-log.c b/src/daemontools-extras/s6-log.c @@ -323,8 +323,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) ; - pathexec_run(cargv[0], cargv, (char const *const *)environ) ; - strerr_dieexec(111, cargv[0]) ; + xpathexec_run(cargv[0], cargv, (char const *const *)environ) ; } static int rotator (logdir_t *ldp) diff --git a/src/daemontools-extras/s6-setlock.c b/src/daemontools-extras/s6-setlock.c @@ -35,8 +35,7 @@ int main (int argc, char const *const *argv, char const *const *envp) case 'N' : nb = 0 ; break ; case 'r' : ex = 0 ; break ; case 'w' : ex = 1 ; break ; - case 't' : if (!uint0_scan(subgetopt_here.arg, &timeout)) dieusage() ; - nb = 2 ; break ; + case 't' : if (!uint0_scan(subgetopt_here.arg, &timeout)) dieusage() ; nb = 2 ; break ; default : dieusage() ; } } @@ -83,6 +82,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") ; } - pathexec_run(argv[1], argv+1, envp) ; - strerr_dieexec(111, argv[1]) ; + xpathexec_run(argv[1], argv+1, envp) ; } diff --git a/src/daemontools-extras/s6-setsid.c b/src/daemontools-extras/s6-setsid.c @@ -66,6 +66,5 @@ int main (int argc, char const *const *argv, char const *const *envp) default : break ; } - pathexec_run(argv[0], argv, envp) ; - strerr_dieexec(111, argv[0]) ; + xpathexec_run(argv[0], argv, envp) ; } diff --git a/src/daemontools-extras/s6-setuidgid.c b/src/daemontools-extras/s6-setuidgid.c @@ -39,6 +39,5 @@ int main (int argc, char *const *argv, char const *const *envp) newargv[m++] = "--" ; while (*argv) newargv[m++] = *argv++ ; newargv[m++] = 0 ; - pathexec_run(newargv[0], newargv, envp) ; - strerr_dieexec(111, newargv[0]) ; + xpathexec_run(newargv[0], newargv, envp) ; } diff --git a/src/daemontools-extras/s6-softlimit.c b/src/daemontools-extras/s6-softlimit.c @@ -111,6 +111,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) ; - pathexec_run(argv[0], argv, envp) ; - strerr_dieexec(111, argv[0]) ; + xpathexec_run(argv[0], argv, envp) ; } diff --git a/src/fdholder/s6-fdholder-daemon.c b/src/fdholder/s6-fdholder-daemon.c @@ -150,7 +150,6 @@ int main (int argc, char const *const *argv, char const *const *envp) newargv[m++] = rulesfile ; } newargv[m++] = 0 ; - pathexec_run(newargv[0], newargv, envp) ; - strerr_dieexec(111, newargv[0]) ; + xpathexec_run(newargv[0], newargv, envp) ; } } diff --git a/src/fdholder/s6-fdholder-delete.c b/src/fdholder/s6-fdholder-delete.c @@ -46,6 +46,5 @@ int main (int argc, char const *const *argv, char const *const *envp) newargv[m++] = "--" ; newargv[m++] = argv[1] ; newargv[m++] = 0 ; - pathexec_run(newargv[0], newargv, envp) ; - strerr_dieexec(111, newargv[0]) ; + xpathexec_run(newargv[0], newargv, envp) ; } diff --git a/src/fdholder/s6-fdholder-getdump.c b/src/fdholder/s6-fdholder-getdump.c @@ -52,7 +52,6 @@ int main (int argc, char const *const *argv, char const *const *envp) newargv[m++] = "7" ; while (*argv) newargv[m++] = *argv++ ; newargv[m++] = 0 ; - pathexec_run(newargv[0], newargv, envp) ; - strerr_dieexec(111, newargv[0]) ; + xpathexec_run(newargv[0], newargv, envp) ; } } diff --git a/src/fdholder/s6-fdholder-getdumpc.c b/src/fdholder/s6-fdholder-getdumpc.c @@ -79,7 +79,6 @@ int main (int argc, char const *const *argv, char const *const *envp) } modifs[pos++] = 0 ; } - pathexec_r(argv, envp, env_len(envp), modifs, pos) ; + xpathexec_r(argv, envp, env_len(envp), modifs, pos) ; } - strerr_dieexec(111, argv[0]) ; } diff --git a/src/fdholder/s6-fdholder-list.c b/src/fdholder/s6-fdholder-list.c @@ -47,6 +47,5 @@ int main (int argc, char const *const *argv, char const *const *envp) newargv[m++] = fmtt ; } newargv[m++] = 0 ; - pathexec_run(newargv[0], newargv, envp) ; - strerr_dieexec(111, newargv[0]) ; + xpathexec_run(newargv[0], newargv, envp) ; } diff --git a/src/fdholder/s6-fdholder-retrieve.c b/src/fdholder/s6-fdholder-retrieve.c @@ -56,7 +56,6 @@ int main (int argc, char const *const *argv, char const *const *envp) newargv[m++] = "7" ; while (*argv) newargv[m++] = *argv++ ; newargv[m++] = 0 ; - pathexec_run(newargv[0], newargv, envp) ; - strerr_dieexec(111, newargv[0]) ; + xpathexec_run(newargv[0], newargv, envp) ; } } diff --git a/src/fdholder/s6-fdholder-retrievec.c b/src/fdholder/s6-fdholder-retrievec.c @@ -47,6 +47,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") ; - pathexec_run(argv[1], argv+1, envp) ; - strerr_dieexec(111, argv[1]) ; + xpathexec_run(argv[1], argv+1, envp) ; } diff --git a/src/fdholder/s6-fdholder-setdump.c b/src/fdholder/s6-fdholder-setdump.c @@ -44,6 +44,5 @@ int main (int argc, char const *const *argv, char const *const *envp) newargv[m++] = fmtt ; } newargv[m++] = 0 ; - pathexec_run(newargv[0], newargv, envp) ; - strerr_dieexec(111, newargv[0]) ; + xpathexec_run(newargv[0], newargv, envp) ; } diff --git a/src/fdholder/s6-fdholder-store.c b/src/fdholder/s6-fdholder-store.c @@ -58,6 +58,5 @@ int main (int argc, char const *const *argv, char const *const *envp) newargv[m++] = "--" ; newargv[m++] = argv[1] ; newargv[m++] = 0 ; - pathexec_run(newargv[0], newargv, envp) ; - strerr_dieexec(111, newargv[0]) ; + xpathexec_run(newargv[0], newargv, envp) ; } diff --git a/src/fdholder/s6-fdholder-transferdump.c b/src/fdholder/s6-fdholder-transferdump.c @@ -84,6 +84,5 @@ int main (int argc, char const *const *argv, char const *const *envp) newargv[m++] = fmtto ; } newargv[m++] = 0 ; - pathexec_run(newargv[0], newargv, envp) ; - strerr_dieexec(111, newargv[0]) ; + xpathexec_run(newargv[0], newargv, envp) ; } diff --git a/src/supervision/s6-svc.c b/src/supervision/s6-svc.c @@ -103,8 +103,7 @@ int main (int argc, char const *const *argv, char const *const *envp) newargv[m++] = "--" ; newargv[m++] = argv[0] ; newargv[m++] = 0 ; - pathexec_run(newargv[0], newargv, envp) ; - strerr_dieexec(111, newargv[0]) ; + xpathexec_run(newargv[0], newargv, envp) ; } else { diff --git a/src/supervision/s6-svscan.c b/src/supervision/s6-svscan.c @@ -296,8 +296,7 @@ static void trystart (unsigned int i, char const *name, int islog) if (services[i].flaglog) if (fd_move(!islog, services[i].p[!islog]) == -1) strerr_diefu2sys(111, "set fds for ", name) ; - pathexec_run(S6_BINPREFIX "s6-supervise", cargv, (char const **)environ) ; - strerr_dieexec(111, S6_BINPREFIX "s6-supervise") ; + xpathexec_run(S6_BINPREFIX "s6-supervise", cargv, (char const **)environ) ; } } services[i].pid[islog] = pid ;