diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2015-07-21 01:53:07 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2015-07-21 01:53:07 +0000 |
commit | 66cdf55d28c8fc27ecdeb755c7dfb5ebe04d8cc2 (patch) | |
tree | 56bc996810ef39f13a1fb4affa84536ad5eb0465 | |
parent | 6882b1e7632d6820f8b1e3840fcdcd23bfd968a5 (diff) | |
download | s6-rc-66cdf55d28c8fc27ecdeb755c7dfb5ebe04d8cc2.tar.xz |
- fix shebang invocation
- accept symlinks to subdirs in source directories
- make oneshot down scripts optional
- execline dep bump
-rw-r--r-- | INSTALL | 2 | ||||
-rw-r--r-- | doc/index.html | 2 | ||||
-rw-r--r-- | package/modes | 6 | ||||
-rw-r--r-- | src/s6-rc/s6-rc-compile.c | 40 |
4 files changed, 28 insertions, 22 deletions
@@ -7,7 +7,7 @@ Build Instructions - A POSIX-compliant C development environment - GNU make version 4.0 or later - skalibs version 2.3.6.0 or later: http://skarnet.org/software/skalibs/ - - execline version 2.1.2.2 or later: http://skarnet.org/software/execline/ + - execline version 2.1.3.0 or later: http://skarnet.org/software/execline/ - s6 version 2.2.0.0 or later: http://skarnet.org/software/s6/ This software will run on any operating system that implements diff --git a/doc/index.html b/doc/index.html index ab997dd..c889800 100644 --- a/doc/index.html +++ b/doc/index.html @@ -49,7 +49,7 @@ scripts are also run in a controlled environment. <li> <a href="http://skarnet.org/software/skalibs/">skalibs</a> version 2.3.6.0 or later </li> <li> <a href="http://skarnet.org/software/execline/">execline</a> version -2.1.2.2 or later </li> +2.1.3.0 or later </li> <li> <a href="http://skarnet.org/software/s6/">s6</a> version 2.2.0.0 or later </li> </ul> diff --git a/package/modes b/package/modes index 0a1ebe0..7bda1d0 100644 --- a/package/modes +++ b/package/modes @@ -1,6 +1,6 @@ s6-rc-compile 0755 s6-rc-db 0755 s6-rc-dryrun 0755 -s6-rc-init 0700 -s6-rc 0700 -s6-rc-update 0700 +s6-rc-init 0755 +s6-rc 0755 +s6-rc-update 0755 diff --git a/src/s6-rc/s6-rc-compile.c b/src/s6-rc/s6-rc-compile.c index 7e4e515..3324637 100644 --- a/src/s6-rc/s6-rc-compile.c +++ b/src/s6-rc/s6-rc-compile.c @@ -30,7 +30,7 @@ #define dienomem() strerr_dief1x(111, "out of memory") ; #define S6RC_ONESHOT_RUNNER_RUNSCRIPT \ -"#!" EXECLINE_EXTBINPREFIX "execlineb -P\n" \ +"#!" EXECLINE_SHEBANGPREFIX "execlineb -P\n" \ EXECLINE_EXTBINPREFIX "fdmove -c 2 1\n" \ EXECLINE_EXTBINPREFIX "fdmove 1 3\n" \ S6_EXTBINPREFIX "s6-ipcserver-socketbinder -- s\n" \ @@ -295,23 +295,29 @@ static int add_namelist (before_t *be, int dirfd, char const *srcdir, char const return 1 ; } -static void read_script (before_t *be, int dirfd, char const *srcdir, char const *name, char const *script, unsigned int *argvindex, unsigned int *argc) +static void read_script (before_t *be, int dirfd, char const *srcdir, char const *name, char const *script, unsigned int *argvindex, unsigned int *argc, int mandatory) { - buffer b ; - int r ; - char buf[4096] ; + int r = 0 ; int fd = open_readatb(dirfd, script) ; - if (fd < 0) strerr_diefu6sys(111, "open ", srcdir, "/", name, "/", script) ; - buffer_init(&b, &fd_readsv, fd, buf, 4096) ; *argvindex = keep.len ; - r = el_parse_from_buffer(&keep, &b) ; - switch (r) + if (fd < 0) { - case -3 : strerr_dief7x(1, "syntax error in ", srcdir, "/", name, "/", script, ": missing }"); - case -2 : strerr_dief6x(1, "syntax error in ", srcdir, "/", name, "/", script) ; - case -1 : strerr_diefu6sys(111, "parse ", srcdir, "/", name, "/", script) ; + if (errno != ENOENT || mandatory) + strerr_diefu6sys(111, "open ", srcdir, "/", name, "/", script) ; + } + else + { + char buf[4096] ; + buffer b = BUFFER_INIT(&fd_readsv, fd, buf, 4096) ; + r = el_parse_from_buffer(&keep, &b) ; + switch (r) + { + case -3 : strerr_dief7x(1, "syntax error in ", srcdir, "/", name, "/", script, ": missing }"); + case -2 : strerr_dief6x(1, "syntax error in ", srcdir, "/", name, "/", script) ; + case -1 : strerr_diefu6sys(111, "parse ", srcdir, "/", name, "/", script) ; + } + close(fd) ; } - close(fd) ; *argc = r ; be->nargvs += r+1 ; } @@ -357,8 +363,8 @@ static inline void add_oneshot (before_t *be, int dirfd, char const *srcdir, cha oneshot_t service ; if (verbosity >= 3) strerr_warni3x(name, " has type ", "oneshot") ; add_common(be, dirfd, srcdir, name, &service.common, SVTYPE_ONESHOT) ; - read_script(be, dirfd, srcdir, name, "up", &service.argvindex[1], &service.argc[1]) ; - read_script(be, dirfd, srcdir, name, "down", &service.argvindex[0], &service.argc[0]) ; + read_script(be, dirfd, srcdir, name, "up", &service.argvindex[1], &service.argc[1], 1) ; + read_script(be, dirfd, srcdir, name, "down", &service.argvindex[0], &service.argc[0], 0) ; if (uint_uniq(genalloc_s(unsigned int, &be->indices) + service.common.depindex, service.common.ndeps, 0)) { if (!genalloc_append(unsigned int, &be->indices, &special_dep)) dienomem() ; @@ -494,8 +500,8 @@ static inline void add_sources (before_t *be, char const *srcdir) strerr_dief3x(2, "subdirectory of ", srcdir, " contains a newline character") ; satmp.len = cur ; if (!stralloc_catb(&satmp, d->d_name, str_len(d->d_name) + 1)) dienomem() ; - if (lstat(satmp.s + start, &st) < 0) - strerr_diefu2sys(111, "lstat ", satmp.s + start) ; + if (stat(satmp.s + start, &st) < 0) + strerr_diefu2sys(111, "stat ", satmp.s + start) ; if (!S_ISDIR(st.st_mode)) continue ; fd = open_readb(satmp.s + start) ; if (fd < 0) strerr_diefu2sys(111, "open ", satmp.s + start) ; |