diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2015-03-07 19:51:21 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2015-03-07 19:51:21 +0000 |
commit | f8f42124ba675de10e4085b67c84871f55993941 (patch) | |
tree | 3ba4d9b7d81b5ae04ef1ba339cd5ed70e9278257 /src/daemontools-extras | |
parent | e3f57fb9a99f7d54efe15bf3301d252f8e323be3 (diff) | |
download | s6-f8f42124ba675de10e4085b67c84871f55993941.tar.xz |
Bugfix: s6-setuidgid uid:gid prog syntax wasn't honored
Diffstat (limited to 'src/daemontools-extras')
-rw-r--r-- | src/daemontools-extras/s6-setuidgid.c | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/src/daemontools-extras/s6-setuidgid.c b/src/daemontools-extras/s6-setuidgid.c index cc7f21a..30cce8c 100644 --- a/src/daemontools-extras/s6-setuidgid.c +++ b/src/daemontools-extras/s6-setuidgid.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include <skalibs/bytestr.h> #include <skalibs/strerr2.h> #include <skalibs/djbunix.h> #include <s6/config.h> @@ -7,18 +8,35 @@ #define USAGE "s6-setuidgid username 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 *argv, char const *const *envp) { - char const *newargv[argc + 4] ; - unsigned int m = 5 ; + char const *newargv[argc + 7] ; + unsigned int m = 0 ; + unsigned int pos ; PROG = "s6-setuidgid" ; if (argc < 3) dieusage() ; argv++ ; - newargv[0] = S6_BINPREFIX "s6-envuidgid" ; - newargv[1] = *argv++ ; - newargv[2] = S6_BINPREFIX "s6-applyuidgid" ; - newargv[3] = "-Uz" ; - newargv[4] = "--" ; + pos = str_chr(argv[0], ':') ; + if (argv[0][pos]) + { + argv[0][pos] = 0 ; + newargv[m++] = S6_BINPREFIX "s6-applyuidgid" ; + newargv[m++] = "-u" ; + newargv[m++] = argv[0] ; + newargv[m++] = "-g" ; + newargv[m++] = argv[0] + pos + 1 ; + newargv[m++] = "-G" ; + newargv[m++] = "" ; + argv++ ; + } + else + { + newargv[m++] = S6_BINPREFIX "s6-envuidgid" ; + newargv[m++] = *argv++ ; + newargv[m++] = S6_BINPREFIX "s6-applyuidgid" ; + newargv[m++] = "-Uz" ; + } + newargv[m++] = "--" ; while (*argv) newargv[m++] = *argv++ ; newargv[m++] = 0 ; pathexec_run(newargv[0], newargv, envp) ; |