From 320cdee53ad9f2252403402fb0b41764cdc001fd Mon Sep 17 00:00:00 2001
From: Laurent Bercot
Date: Wed, 4 Nov 2015 21:19:25 +0000
Subject: - add -g option to s6-envuidgid - set s6-log processor wd to the
logdir
---
INSTALL | 4 +--
doc/index.html | 6 ++--
doc/s6-envuidgid.html | 5 ++-
doc/s6-log.html | 3 +-
doc/upgrade.html | 9 ++++++
package/info | 2 +-
src/daemontools-extras/s6-envuidgid.c | 58 ++++++++++++++++++++++-------------
src/daemontools-extras/s6-log.c | 32 ++++++++-----------
8 files changed, 71 insertions(+), 48 deletions(-)
diff --git a/INSTALL b/INSTALL
index 049db1d..3161cee 100644
--- a/INSTALL
+++ b/INSTALL
@@ -6,8 +6,8 @@ Build Instructions
- A POSIX-compliant C development environment
- GNU make version 3.81 or later
- - skalibs version 2.3.8.0 or later: http://skarnet.org/software/skalibs/
- - execline version 2.1.4.2 or later: http://skarnet.org/software/execline/
+ - skalibs version 2.3.8.2 or later: http://skarnet.org/software/skalibs/
+ - execline version 2.1.4.4 or later: http://skarnet.org/software/execline/
This software will run on any operating system that implements
POSIX.1-2008, available at:
diff --git a/doc/index.html b/doc/index.html
index 99dd520..21880b8 100644
--- a/doc/index.html
+++ b/doc/index.html
@@ -83,11 +83,11 @@ with s6
A POSIX-compliant system with a standard C development environment
GNU make, version 3.81 or later
skalibs version
-2.3.8.0 or later. It's a build-time requirement. It's also a run-time
+2.3.8.2 or later. It's a build-time requirement. It's also a run-time
requirement if you link against the shared version of the skalibs
library.
execline version
-2.1.4.2 or later. It's a build-time and run-time requirement.
+2.1.4.4 or later. It's a build-time and run-time requirement.
Licensing
@@ -100,7 +100,7 @@ library.
Download
diff --git a/doc/upgrade.html b/doc/upgrade.html
index 08303b2..38fc0e7 100644
--- a/doc/upgrade.html
+++ b/doc/upgrade.html
@@ -18,6 +18,15 @@
What has changed in s6
+ in 2.2.3.0
+
+
+ - Processor scripts for s6-log
+now switch their working directory to the logdir they process.
+ - skalibs dependency bumped to 2.3.8.2.
+ - execline dependency bumped to 2.1.4.4.
+
+
in 2.2.2.2
diff --git a/package/info b/package/info
index 3539339..1d3b7fa 100644
--- a/package/info
+++ b/package/info
@@ -1,4 +1,4 @@
package=s6
-version=2.2.2.2
+version=2.2.3.0
category=admin
package_macro_name=S6
diff --git a/src/daemontools-extras/s6-envuidgid.c b/src/daemontools-extras/s6-envuidgid.c
index 3712411..c0aaac2 100644
--- a/src/daemontools-extras/s6-envuidgid.c
+++ b/src/daemontools-extras/s6-envuidgid.c
@@ -2,6 +2,7 @@
#include
#include
+#include
#include
#include
#include
@@ -12,26 +13,27 @@
#include
#include
-#define USAGE "s6-envuidgid [ -i | -D defaultuid:defaultgid ] username prog..."
+#define USAGE "s6-envuidgid [ -i | -D defaultuid:defaultgid ] [ -g ] username prog..."
#define dieusage() strerr_dieusage(100, USAGE)
int main (int argc, char const *const *argv, char const *const *envp)
{
- struct passwd *pw ;
uint64 uid ;
gid_t gid ;
gid_t tab[NGROUPS_MAX] ;
int n = 0 ;
+ int dogroup = 0 ;
int insist = 1 ;
PROG = "s6-envuidgid" ;
{
subgetopt_t l = SUBGETOPT_ZERO ;
for (;;)
{
- register int opt = subgetopt_r(argc, argv, "iD:", &l) ;
+ register int opt = subgetopt_r(argc, argv, "giD:", &l) ;
if (opt == -1) break ;
switch (opt)
{
+ case 'g' : dogroup = 1 ; break ;
case 'i' : insist = 1 ; break ;
case 'D' :
{
@@ -58,28 +60,42 @@ int main (int argc, char const *const *argv, char const *const *envp)
}
if (argc < 2) dieusage() ;
- pw = getpwnam(argv[0]) ;
- if (pw)
+ if (dogroup)
{
- uid = pw->pw_uid ;
- gid = pw->pw_gid ;
- n = prot_readgroups(argv[0], tab, NGROUPS_MAX) ;
- if (n < 0)
- strerr_diefu2sys(111, "get supplementary groups for ", argv[0]) ;
- }
- else if (insist) strerr_dief2x(1, "unknown user: ", argv[0]) ;
-
- {
- unsigned int pos = 0 ;
- char fmt[19 + UINT64_FMT + (n+1) * GID_FMT] ;
- byte_copy(fmt + pos, 4, "UID=") ; pos += 4 ;
- pos += uint64_fmt(fmt + pos, uid) ;
- byte_copy(fmt + pos, 5, "\0GID=") ; pos += 5 ;
+ struct group *gr = getgrnam(argv[0]) ;
+ unsigned int pos = 4 ;
+ char fmt[4 + GID_FMT] = "GID=" ;
+ if (gr) gid = gr->gr_gid ;
+ else if (insist) strerr_dief2x(1, "unknown group: ", argv[0]) ;
pos += gid_fmt(fmt + pos, gid) ;
- byte_copy(fmt + pos, 9, "\0GIDLIST=") ; pos += 9 ;
- pos += gid_fmtlist(fmt + pos, tab, n) ;
fmt[pos++] = 0 ;
pathexec_r(argv+1, envp, env_len(envp), fmt, pos) ;
}
+ else
+ {
+ struct passwd *pw = getpwnam(argv[0]) ;
+ if (pw)
+ {
+ uid = pw->pw_uid ;
+ gid = pw->pw_gid ;
+ n = prot_readgroups(argv[0], tab, NGROUPS_MAX) ;
+ if (n < 0)
+ strerr_diefu2sys(111, "get supplementary groups for ", argv[0]) ;
+ }
+ else if (insist) strerr_dief2x(1, "unknown user: ", argv[0]) ;
+
+ {
+ unsigned int pos = 0 ;
+ char fmt[19 + UINT64_FMT + (n+1) * GID_FMT] ;
+ byte_copy(fmt + pos, 4, "UID=") ; pos += 4 ;
+ pos += uint64_fmt(fmt + pos, uid) ;
+ byte_copy(fmt + pos, 5, "\0GID=") ; pos += 5 ;
+ pos += gid_fmt(fmt + pos, gid) ;
+ byte_copy(fmt + pos, 9, "\0GIDLIST=") ; pos += 9 ;
+ pos += gid_fmtlist(fmt + pos, tab, n) ;
+ fmt[pos++] = 0 ;
+ pathexec_r(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
index bbb92b1..c3aec9c 100644
--- a/src/daemontools-extras/s6-log.c
+++ b/src/daemontools-extras/s6-log.c
@@ -306,27 +306,21 @@ static int finish (logdir_t *ldp, char const *name, char suffix)
static inline void exec_processor (logdir_t *ldp)
{
char const *cargv[4] = { EXECLINE_EXTBINPREFIX "execlineb", "-Pc", ldp->processor, 0 } ;
- unsigned int dirlen = str_len(ldp->dir) ;
int fd ;
- char x[dirlen + 10] ;
PROG = "s6-log (processor child)" ;
- byte_copy(x, dirlen, ldp->dir) ;
- byte_copy(x + dirlen, 10, "/previous") ;
- fd = open_readb(x) ;
- if (fd < 0) strerr_diefu2sys(111, "open_readb ", x) ;
- if (fd_move(0, fd) < 0) strerr_diefu2sys(111, "fd_move ", x) ;
- byte_copy(x + dirlen + 1, 10, "processed") ;
- fd = open_trunc(x) ;
- if (fd < 0) strerr_diefu2sys(111, "open_trunc ", x) ;
- if (fd_move(1, fd) < 0) strerr_diefu2sys(111, "fd_move ", x) ;
- byte_copy(x + dirlen + 1, 6, "state") ;
- fd = open_readb(x) ;
- if (fd < 0) strerr_diefu2sys(111, "open_readb ", x) ;
- if (fd_move(4, fd) < 0) strerr_diefu2sys(111, "fd_move ", x) ;
- byte_copy(x + dirlen + 1, 9, "newstate") ;
- fd = open_trunc(x) ;
- if (fd < 0) strerr_diefu2sys(111, "open_trunc ", x) ;
- if (fd_move(5, fd) < 0) strerr_diefu2sys(111, "fd_move ", x) ;
+ if (chdir(ldp->dir) < 0) strerr_diefu2sys(111, "chdir to ", ldp->dir) ;
+ fd = open_readb("previous") ;
+ if (fd < 0) strerr_diefu3sys(111, "open_readb ", ldp->dir, "/previous") ;
+ if (fd_move(0, fd) < 0) strerr_diefu3sys(111, "fd_move ", ldp->dir, "/previous") ;
+ fd = open_trunc("processed") ;
+ if (fd < 0) strerr_diefu3sys(111, "open_trunc ", ldp->dir, "/processed") ;
+ if (fd_move(1, fd) < 0) strerr_diefu3sys(111, "fd_move ", ldp->dir, "/processed") ;
+ fd = open_readb("state") ;
+ if (fd < 0) strerr_diefu3sys(111, "open_readb ", ldp->dir, "/state") ;
+ if (fd_move(4, fd) < 0) strerr_diefu3sys(111, "fd_move ", ldp->dir, "/state") ;
+ fd = open_trunc("newstate") ;
+ if (fd < 0) strerr_diefu3sys(111, "open_trunc ", ldp->dir, "/newstate") ;
+ 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) ;
--
cgit v1.3.1