diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2021-04-19 11:26:23 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2021-04-19 11:26:23 +0000 |
commit | 9969d7437fa6786782e6c780fbadd6561220ccfe (patch) | |
tree | 0be0d73689929500cab25d32695d6074d41c9c90 | |
parent | eaeee8195f3347b3fa762a7ddbb0c7eb0ef15133 (diff) | |
download | s6-linux-init-9969d7437fa6786782e6c780fbadd6561220ccfe.tar.xz |
Clean up the wtmp mess
-rw-r--r-- | doc/overview.html | 4 | ||||
-rw-r--r-- | doc/s6-linux-init-maker.html | 25 | ||||
-rw-r--r-- | src/init/s6-linux-init-maker.c | 17 | ||||
-rw-r--r-- | src/shutdown/s6-linux-init-hpr.c | 6 |
4 files changed, 29 insertions, 23 deletions
diff --git a/doc/overview.html b/doc/overview.html index 71b852d..ef01e1e 100644 --- a/doc/overview.html +++ b/doc/overview.html @@ -129,8 +129,8 @@ command is executed. </li> utmp record cleanup duty for patched <tt>login</tt> programs. </li> <li> <tt>s6-linux-init-early-getty</tt>: the early getty, allowing the user to login even if <em>rc.init</em> fails early. </li> - <li> <tt>utmpd</tt> and <tt>wtmpd</tt>: the services performing -utmp and wtmp access when <a href="//skarnet.org/software/utmps/">utmps</a> is + <li> <tt>utmpd</tt>: a service performing +utmp access when <a href="//skarnet.org/software/utmps/">utmps</a> is used. </li> </ul> </li> </ul> diff --git a/doc/s6-linux-init-maker.html b/doc/s6-linux-init-maker.html index f8ef940..9bf44ac 100644 --- a/doc/s6-linux-init-maker.html +++ b/doc/s6-linux-init-maker.html @@ -320,9 +320,15 @@ files in a staging directory. </li> <br /> available when the s6-linux-init package has been built with the <tt>--enable-utmps</tt> configure option, that enables support for the <a href="//skarnet.org/software/utmps/">utmps</a> package. The option -defines the user that the <tt>utmpd</tt> and <tt>wtmpd</tt> services -will run as, and activates these services. Default is <strong>no -utmpd or wtmpd services</strong>. </li> <br /> +defines the user that the <tt>utmpd</tt> service +will run as, and activates this service. (Note that you will still +have to create a <tt>wtmpd</tt> service yourself and activate it +later in the boot sequence, after a writable filesystem is mounted, +because the wtmp database is supposed to be persistent and should live +on a real filesystem. +s6-linux-init cannot do that for you, because it only handles the +early part of the boot sequence, before filesystems are mounted.) +Default is <strong>no utmpd service</strong>. </li> <br /> <li> <tt>-C</tt> : create a set of scripts that is suitable for running <em>in a container</em>. This modifies some behaviours: @@ -457,11 +463,14 @@ directories may exist: <ul> <li> A directory somewhere under <tt>run-image</tt>, by default <tt>utmps</tt>, -that is the location where the utmp and wtmp files will be created. </li> - <li> Two additional early services named <tt>utmpd</tt> and <tt>wtmpd</tt>, -that are the <a href="//skarnet.org/software/utmps/">utmps</a> way of -providing secure utmp functionality. </li> -</ul> +that is the location where the utmp files will be created. </li> + <li> An additional early service named <tt>utmpd</tt>, which is +a part of the <a href="//skarnet.org/software/utmps/">utmps</a> way of +providing secure utmp functionality. A similar <tt>wtmpd</tt> service +should also be created and run later in the boot sequence by the +service manager; it is not s6-linux-init's job to do it because +<tt>wtmp</tt> requires a real, writable filesystem. </li> +</ul>1 <h2> Notes </h2> diff --git a/src/init/s6-linux-init-maker.c b/src/init/s6-linux-init-maker.c index 6d86ff9..c505e04 100644 --- a/src/init/s6-linux-init-maker.c +++ b/src/init/s6-linux-init-maker.c @@ -499,7 +499,7 @@ static inline void auto_basedir (char const *base, char const *dir, uid_t uid, g } } -static int utmpd_script (buffer *b, char const *uw) +static int utmpd_script (buffer *b, char const *aux) { size_t sabase = satmp.len ; if (!put_shebang(b) @@ -512,12 +512,9 @@ static int utmpd_script (buffer *b, char const *uw) if (buffer_puts(b, "\n" EXECLINE_EXTBINPREFIX "cd " S6_LINUX_INIT_TMPFS "/" UTMPS_DIR "\n" EXECLINE_EXTBINPREFIX "fdmove 1 3\n" - S6_EXTBINPREFIX "s6-ipcserver -1 -c 1000 -- ") < 0) return 0 ; - if (buffer_puts(b, uw[0] == 'u' ? UTMPS_UTMPD_PATH : UTMPS_WTMPD_PATH) < 0 - || buffer_puts(b, "\n" - UTMPS_EXTBINPREFIX "utmps-") < 0 - || buffer_puts(b, uw) < 0 - || buffer_puts(b, "tmpd\n") < 0) return 0 ; + S6_EXTBINPREFIX "s6-ipcserver -1 -c 1000 -- " UTMPS_UTMPD_PATH "\n" + UTMPS_EXTBINPREFIX "utmps-utmpd") < 0) return 0 ; + (void)aux ; return 1 ; err: @@ -529,17 +526,13 @@ static inline void make_utmps (char const *base) { auto_dir(base, "run-image/" SCANDIR "/utmpd", 0, 0, 0755) ; auto_file(base, "run-image/" SCANDIR "/utmpd/notification-fd", "3\n", 2) ; - auto_script(base, "run-image/" SCANDIR "/utmpd/run", &utmpd_script, "u") ; - auto_dir(base, "run-image/" SCANDIR "/wtmpd", 0, 0, 0755) ; - auto_file(base, "run-image/" SCANDIR "/wtmpd/notification-fd", "3\n", 2) ; - auto_script(base, "run-image/" SCANDIR "/wtmpd/run", &utmpd_script, "w") ; + auto_script(base, "run-image/" SCANDIR "/utmpd/run", &utmpd_script, 0) ; { uid_t uid ; gid_t gid ; getug(base, utmp_user, &uid, &gid) ; auto_dir(base, "run-image/" UTMPS_DIR, uid, gid, 0755) ; auto_basedir(base, "run-image/" S6_LINUX_INIT_UTMPD_PATH, uid, gid, 0755) ; - auto_basedir(base, "run-image/" S6_LINUX_INIT_WTMPD_PATH, uid, gid, 0755) ; } } diff --git a/src/shutdown/s6-linux-init-hpr.c b/src/shutdown/s6-linux-init-hpr.c index 8ebe2d5..a874ac3 100644 --- a/src/shutdown/s6-linux-init-hpr.c +++ b/src/shutdown/s6-linux-init-hpr.c @@ -26,7 +26,11 @@ #endif #ifndef _PATH_WTMP -#define _PATH_WTMP "/dev/null/wtmp" +# ifdef WTMPX_FILE +# define _PATH_WTMP WTMPX_FILE +# else +# define _PATH_WTMP "/var/log/wtmp" +# endif #endif #define USAGE "s6-linux-init-hpr [ -h | -p | -r ] [ -n ] [ -d | -w ] [ -W ] [ -f ] [ -i ]" |