From af21e602b1dad1b7fd2c00f570d1d5605b9bb277 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Mon, 20 May 2019 13:30:47 +0000 Subject: Improve UX following IRC feedback, prepare for 1.0.1.0 --- AUTHORS | 1 + NEWS | 11 +++++++++++ doc/index.html | 2 +- doc/s6-linux-init-maker.html | 11 ++++++++++- doc/upgrade.html | 12 +++++++++++ package/info | 2 +- package/modes | 16 +++++++-------- skel/runlevel | 3 +++ src/init/s6-linux-init-maker.c | 45 ++++++++++++++++++++++++------------------ 9 files changed, 73 insertions(+), 30 deletions(-) diff --git a/AUTHORS b/AUTHORS index f0bd677..1fa6deb 100644 --- a/AUTHORS +++ b/AUTHORS @@ -5,3 +5,4 @@ Thanks to: Colin Booth multiplexd Luis Ressel + Samuel Holland diff --git a/NEWS b/NEWS index 547eebe..c01907c 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,16 @@ Changelog for s6-linux-init. +In 1.0.1.0 +---------- + + - New -f option to s6-linux-init-maker, for use +in distribution packaging scripts with a staging directory. + - Better permissions on the binaries. + - The skeleton runlevel script now includes a guard to +avoid calling the service manager without an argument. + - /run/uncaught-logs directory permissions changed to 02750. + + In 1.0.0.0 ---------- diff --git a/doc/index.html b/doc/index.html index 4cffd46..cb9cd58 100644 --- a/doc/index.html +++ b/doc/index.html @@ -110,7 +110,7 @@ all the other packages against the static version of libskarnet.
  • The current released version of s6-linux-init is -1.0.0.0.
  • +1.0.1.0.
  • Alternatively, you can checkout a copy of the s6-linux-init git repository: diff --git a/doc/s6-linux-init-maker.html b/doc/s6-linux-init-maker.html index 34fa829..218af02 100644 --- a/doc/s6-linux-init-maker.html +++ b/doc/s6-linux-init-maker.html @@ -59,7 +59,8 @@ machine. If it is not the case, the system will fail to boot. [ -e initial_envvar ] ... \ [ -q finalsleeptime ] \ [ -D initdefault ] \ - [ -n | -N ] + [ -n | -N ] \ + [ -f skeldir ] \ [ -U utmp_user ] \ dir @@ -295,6 +296,14 @@ option if your rootfs is read-only: failure to write to /run will cause init to die and the kernel to panic. This option is incompatible with the -n option.
  • +

  • -f skeldir : copy the skeleton +scripts from directory skeldir. By default, skeldir +is /etc/s6-linux-init/skel, or the directory that has been +given as an argument to the --skeldir configure option at +build time. This option is typically useful when distributions run +s6-linux-init-maker in packaging scripts, when preparing +files in a staging directory.
  • +

  • -U utmp_user : this option is only available when the s6-linux-init package has been built with the --enable-utmps configure option, that enables support for the diff --git a/doc/upgrade.html b/doc/upgrade.html index 7c27f49..3804ac6 100644 --- a/doc/upgrade.html +++ b/doc/upgrade.html @@ -18,6 +18,18 @@

    What has changed in s6-linux-init

    +

    in 1.0.1.0

    + +
      +
    • -f option added to +s6-linux-init-maker for use +in distribution packaging scripts with a staging directory.
    • +
    • Permissions on the binaries have been adjusted.
    • +
    • The skeleton runlevel script now includes a guard to +avoid calling the service manager without an argument.
    • +
    • The permissions of the /run/uncaught-logs directory +in the generated image have been changed to 02750.
    • +

    in 1.0.0.0

    diff --git a/package/info b/package/info index d58a5f1..f5264c0 100644 --- a/package/info +++ b/package/info @@ -1,4 +1,4 @@ package=s6-linux-init -version=1.0.0.0 +version=1.0.1.0 category=admin package_macro_name=S6_LINUX_INIT diff --git a/package/modes b/package/modes index ab52a84..f2c9b24 100644 --- a/package/modes +++ b/package/modes @@ -1,9 +1,9 @@ -s6-linux-init 0700 -s6-linux-init-hpr 0750 -s6-linux-init-shutdown 0755 -s6-linux-init-shutdownd 0700 -s6-linux-init-telinit 0750 -s6-linux-init-logouthookd 0700 +s6-linux-init 0744 +s6-linux-init-hpr 0744 +s6-linux-init-shutdown 0744 +s6-linux-init-shutdownd 0744 +s6-linux-init-telinit 0744 +s6-linux-init-logouthookd 0744 s6-linux-init-echo 0755 -s6-linux-init-umountall 0750 -s6-linux-init-maker 0700 +s6-linux-init-umountall 0744 +s6-linux-init-maker 0744 diff --git a/skel/runlevel b/skel/runlevel index 51789f3..8ca2fd1 100755 --- a/skel/runlevel +++ b/skel/runlevel @@ -5,6 +5,9 @@ ### requests a machine state change via telinit. ### Ideally, it should just be a call to the service manager. +test "$#" -gt 0 || { echo 'runlevel: fatal: too few arguments' 1>&2 ; exit 100 ; } + + ### If your services are managed by sysv-rc: # exec /etc/init.d/rc "$1" diff --git a/src/init/s6-linux-init-maker.c b/src/init/s6-linux-init-maker.c index 1005811..8de17fe 100644 --- a/src/init/s6-linux-init-maker.c +++ b/src/init/s6-linux-init-maker.c @@ -28,12 +28,12 @@ #ifdef S6_LINUX_INIT_UTMPD_PATH # include -# define USAGE "s6-linux-init-maker [ -c basedir ] [ -u log_user ] [ -G early_getty_cmd ] [ -1 ] [ -L ] [ -p initial_path ] [ -m initial_umask ] [ -t timestamp_style ] [ -d slashdev ] [ -s env_store ] [ -e initial_envvar ... ] [ -q default_grace_time ] [ -D initdefault ] [ -n | -N ] [ -U utmp_user ] dir" -# define OPTION_STRING "c:u:G:1Lp:m:t:d:s:e:E:q:D:nNU:" +# define USAGE "s6-linux-init-maker [ -c basedir ] [ -u log_user ] [ -G early_getty_cmd ] [ -1 ] [ -L ] [ -p initial_path ] [ -m initial_umask ] [ -t timestamp_style ] [ -d slashdev ] [ -s env_store ] [ -e initial_envvar ... ] [ -q default_grace_time ] [ -D initdefault ] [ -n | -N ] [ -f skeldir ] [ -U utmp_user ] dir" +# define OPTION_STRING "c:u:G:1Lp:m:t:d:s:e:E:q:D:nNf:U:" # define UTMPS_DIR "utmps" #else -# define USAGE "s6-linux-init-maker [ -c basedir ] [ -u log_user ] [ -G early_getty_cmd ] [ -1 ] [ -L ] [ -p initial_path ] [ -m initial_umask ] [ -t timestamp_style ] [ -d slashdev ] [ -s env_store ] [ -e initial_envvar ... ] [ -q default_grace_time ] [ -D initdefault ] [ -n | -N ] dir" -# define OPTION_STRING "c:u:G:1Lp:m:t:d:s:e:E:q:D:nN" +# define USAGE "s6-linux-init-maker [ -c basedir ] [ -u log_user ] [ -G early_getty_cmd ] [ -1 ] [ -L ] [ -p initial_path ] [ -m initial_umask ] [ -t timestamp_style ] [ -d slashdev ] [ -s env_store ] [ -e initial_envvar ... ] [ -q default_grace_time ] [ -D initdefault ] [ -n | -N ] [ -f skeldir ] dir" +# define OPTION_STRING "c:u:G:1Lp:m:t:d:s:e:E:q:D:nNf:" #endif #define dieusage() strerr_dieusage(100, USAGE) @@ -48,6 +48,7 @@ static char const *early_getty = 0 ; static char const *slashdev = 0 ; static char const *log_user = "root" ; static char const *initdefault = 0 ; +static char const *skeldir = S6_LINUX_INIT_SKELDIR ; static unsigned int initial_umask = 0022 ; static unsigned int timestamp_style = 1 ; static unsigned int finalsleep = 3000 ; @@ -272,10 +273,10 @@ static void auto_dir_internal (char const *base, char const *dir, uid_t uid, gid { if (errno != EEXIST || strict) goto err ; } - else if (uid || gid) + else { - if (chown(fn, uid, gid) < 0 - || chmod(fn, mode) < 0) goto err ; + if ((uid || gid) && chown(fn, uid, gid) < 0) goto err ; + if (mode & 07000 && chmod(fn, mode) < 0) goto err ; } return ; @@ -358,18 +359,23 @@ static void auto_script (char const *base, char const *file, writetobuf_func_t_r fd_close(fd) ; } -static void copy_script (char const *base, char const *src, char const *dst) +static void copy_script (char const *base, char const *name) { size_t baselen = strlen(base) ; - size_t dstlen = strlen(dst) ; - char fn[baselen + dstlen + 2] ; - memcpy(fn, base, baselen) ; - fn[baselen] = '/' ; - memcpy(fn + baselen + 1, dst, dstlen + 1) ; - if (!filecopy_unsafe(src, fn, 0755)) + size_t namelen = strlen(name) ; + size_t skellen = strlen(skeldir) ; + char dst[baselen + sizeof("/scripts/") + namelen] ; + char src[skellen + namelen + 2] ; + memcpy(dst, base, baselen) ; + memcpy(dst + baselen, "/scripts/", sizeof("/scripts/") - 1) ; + memcpy(dst + baselen + sizeof("/scripts/") - 1, name, namelen + 1) ; + memcpy(src, skeldir, skellen) ; + src[skellen] = '/' ; + memcpy(src + skellen + 1, name, namelen + 1) ; + if (!filecopy_unsafe(src, dst, 0755)) { cleanup(base) ; - strerr_diefu4sys(111, "copy ", src, " to ", fn) ; + strerr_diefu4sys(111, "copy ", src, " to ", dst) ; } } @@ -498,7 +504,7 @@ static inline void make_image (char const *base) uid_t uid ; gid_t gid ; getug(base, log_user, &uid, &gid) ; - auto_dir(base, "run-image/" UNCAUGHT_DIR, uid, gid, 02700) ; + auto_dir(base, "run-image/" UNCAUGHT_DIR, uid, gid, 02750) ; } auto_dir(base, "run-image/" SCANDIR, 0, 0, 0755) ; auto_dir(base, "run-image/" SCANDIR "/.s6-svscan", 0, 0, 0755) ; @@ -545,9 +551,9 @@ static inline void make_image (char const *base) static inline void make_scripts (char const *base) { auto_dir(base, "scripts", 0, 0, 0755) ; - copy_script(base, S6_LINUX_INIT_SKELDIR "/runlevel", "scripts/runlevel") ; - copy_script(base, S6_LINUX_INIT_SKELDIR "/" STAGE2, "scripts/" STAGE2) ; - copy_script(base, S6_LINUX_INIT_SKELDIR "/" STAGE3, "scripts/" STAGE3) ; + copy_script(base, "runlevel") ; + copy_script(base, STAGE2) ; + copy_script(base, STAGE3) ; } static inline void make_bins (char const *base) @@ -587,6 +593,7 @@ int main (int argc, char const *const *argv, char const *const *envp) case 'D' : initdefault = l.arg ; break ; case 'n' : mounttype = 2 ; break ; case 'N' : mounttype = 0 ; break ; + case 'f' : skeldir = l.arg ; break ; #ifdef S6_LINUX_INIT_UTMPD_PATH case 'U' : utmp_user = l.arg ; break ; #endif -- cgit v1.2.3