summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2015-11-04 21:19:25 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2015-11-04 21:19:25 +0000
commit320cdee53ad9f2252403402fb0b41764cdc001fd (patch)
treeb43bac0f373531d1f1bb5ec6e658f125f8f5aed1
parent2807442e2cff8645fc4fdb84efd257fe2b2c55a3 (diff)
downloads6-320cdee53ad9f2252403402fb0b41764cdc001fd.tar.xz
- add -g option to s6-envuidgid
- set s6-log processor wd to the logdir
-rw-r--r--INSTALL4
-rw-r--r--doc/index.html6
-rw-r--r--doc/s6-envuidgid.html5
-rw-r--r--doc/s6-log.html3
-rw-r--r--doc/upgrade.html9
-rw-r--r--package/info2
-rw-r--r--src/daemontools-extras/s6-envuidgid.c58
-rw-r--r--src/daemontools-extras/s6-log.c32
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> </li>
<li> A POSIX-compliant system with a standard C development environment </li>
<li> GNU make, version 3.81 or later </li>
<li> <a href="http://skarnet.org/software/skalibs/">skalibs</a> 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. </li>
<li> <a href="http://skarnet.org/software/execline/">execline</a> version
-2.1.4.2 or later. It's a build-time and run-time requirement. </li>
+2.1.4.4 or later. It's a build-time and run-time requirement. </li>
</ul>
<h3> Licensing </h3>
@@ -100,7 +100,7 @@ library. </li>
<h3> Download </h3>
<ul>
- <li> The current released version of s6 is <a href="s6-2.2.2.2.tar.gz">2.2.2.2</a>. </li>
+ <li> The current released version of s6 is <a href="s6-2.2.3.0.tar.gz">2.2.3.0</a>. </li>
<li> Alternatively, you can checkout a copy of the s6 git repository:
<pre> git clone git://git.skarnet.org/s6 </pre> </li>
<li> There's also a
diff --git a/doc/s6-envuidgid.html b/doc/s6-envuidgid.html
index b3fa6b3..48e9a20 100644
--- a/doc/s6-envuidgid.html
+++ b/doc/s6-envuidgid.html
@@ -26,7 +26,7 @@ then executes into another program.
<h2> Interface </h2>
<pre>
- s6-envuidgid [ -i | -D <em>uid</em>:<em>gid</em> ] <em>account</em> <em>prog...</em>
+ s6-envuidgid [ -g ] [ -i | -D <em>uid</em>:<em>gid</em> ] <em>account</em> <em>prog...</em>
</pre>
<ul>
@@ -43,6 +43,9 @@ primary group, GIDLIST is still set, but empty.) </li>
<h2> Options </h2>
<ul>
+ <li> <tt>-g</tt>&nbsp;: group. <em>account</em> will be interpreted as a
+group name instead of a user name; the GID environment variable will be set
+to its numerical value, and the UID and GIDLIST variables will not be touched. </li>
<li> <tt>-i</tt>&nbsp;: insist. If <em>account</em> is unknown, exit 1 with
an error message. This is the default. </li>
<li> <tt>-D&nbsp;<em>uid</em>:<em>gid</em></tt>&nbsp;: if <em>account</em>
diff --git a/doc/s6-log.html b/doc/s6-log.html
index e2af96e..ef85aef 100644
--- a/doc/s6-log.html
+++ b/doc/s6-log.html
@@ -128,7 +128,8 @@ occurs, <tt>current</tt> (which has then been renamed <tt>previous</tt>) is
fed to <em>processor</em>'s stdin, and <em>processor</em>'s stdout is saved
and archived. <em>processor</em> can also read the <tt>state</tt> file
on its fd 4; what it writes to its fd 5 will be saved as the next
-<tt>state</tt> file, for the next rotation.
+<tt>state</tt> file, for the next rotation. A processor script runs with
+the logdir as its working directory.
</p>
<p>
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 @@
<h1> What has changed in s6 </h1>
+<h2> in 2.2.3.0 </h2>
+
+<ul>
+ <li> Processor scripts for <a href="s6-log.html">s6-log</a>
+now switch their working directory to the logdir they process. </li>
+ <li> skalibs dependency bumped to 2.3.8.2. </li>
+ <li> execline dependency bumped to 2.1.4.4. </li>
+</ul>
+
<h2> in 2.2.2.2 </h2>
<ul>
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 <sys/types.h>
#include <pwd.h>
+#include <grp.h>
#include <limits.h>
#include <skalibs/uint64.h>
#include <skalibs/gidstuff.h>
@@ -12,26 +13,27 @@
#include <skalibs/fmtscan.h>
#include <skalibs/djbunix.h>
-#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) ;