Skip to content

Commit 4a1b04d

Browse files
committed
tmpfiles: refactor into separate executable
The tmpfiles.d spec has proven useful in systemd, enough so that some developers are starting to ship tmpfiles.d configuration files with their software. By splitting the tmpfiles functionality in finit out into a separate executable we are providing a useful piece of software that package managers can hook into.
1 parent d318aa0 commit 4a1b04d

File tree

5 files changed

+25
-49
lines changed

5 files changed

+25
-49
lines changed

plugins/bootmisc.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
#include "finit.h"
3939
#include "helpers.h"
4040
#include "plugin.h"
41-
#include "tmpfiles.h"
4241
#include "util.h"
4342
#include "utmp-api.h"
4443

@@ -163,7 +162,7 @@ static void setup(void *arg)
163162
kernel_links();
164163

165164
/* Create all system tmpfiles.d(5) */
166-
tmpfilesd();
165+
execl(_PATH_TMPFILES, _PATH_TMPFILES, NULL);
167166

168167
/* Set BOOT_TIME UTMP entry */
169168
utmp_set_boot();

src/Makefile.am

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ AM_LDFLAGS = -export-dynamic
88
endif
99

1010
sbin_PROGRAMS = finit initctl
11-
pkglibexec_PROGRAMS = getty logit runparts
11+
pkglibexec_PROGRAMS = getty logit runparts tmpfiles
1212
if SULOGIN
1313
pkglibexec_PROGRAMS += sulogin
1414
endif
@@ -43,6 +43,11 @@ sulogin_SOURCES = sulogin.c
4343
sulogin_CFLAGS = -W -Wall -Wextra -std=gnu99
4444
sulogin_LDADD = -lcrypt
4545

46+
tmpfiles_SOURCES = tmpfiles.c
47+
tmpfiles_CFLAGS = -W -Wall -Wextra -std=gnu99
48+
tmpfiles_CFLAGS += $(lite_CFLAGS)
49+
tmpfiles_LDADD = $(lite_LIBS)
50+
4651
logit_SOURCES = logit.c logrotate.c
4752
logit_CFLAGS = -W -Wall -Wextra -Wno-unused-parameter -std=gnu99
4853
logit_CFLAGS += $(lite_CFLAGS)
@@ -66,7 +71,6 @@ finit_SOURCES = api.c cgroup.c cgroup.h \
6671
sig.c sig.h \
6772
sm.c sm.h \
6873
svc.c svc.h \
69-
tmpfiles.c tmpfiles.h \
7074
tty.c tty.h \
7175
util.c util.h \
7276
utmp-api.c utmp-api.h

src/finit.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
#define _PATH_RUNPARTS FINIT_EXECPATH_ "/runparts"
6060
#define _PATH_SULOGIN FINIT_EXECPATH_ "/sulogin"
6161
#define _PATH_GETTY FINIT_EXECPATH_ "/getty"
62+
#define _PATH_TMPFILES FINIT_EXECPATH_ "/tmpfiles"
6263

6364
#define CMD_SIZE 1024
6465
#define LINE_SIZE 1024

src/tmpfiles.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,24 @@
2323

2424
#include "config.h" /* Generated by configure script */
2525

26+
#include <dirent.h>
27+
#include <ftw.h>
28+
#include <glob.h>
29+
#include <libgen.h>
30+
#include <grp.h>
31+
#include <pwd.h>
2632
#include <sys/sysmacros.h>
27-
#include "finit.h"
33+
34+
#include <stdlib.h>
35+
#include <string.h>
36+
#ifdef _LIBITE_LITE
37+
# include <libite/lite.h>
38+
#else
39+
# include <lite/lite.h>
40+
#endif
41+
2842
#include "helpers.h"
29-
#include "tmpfiles.h"
43+
#include "log.h"
3044
#include "util.h"
3145

3246
static int glob_do(const char *path, int (*cb)(const char *))
@@ -470,7 +484,7 @@ static void tmpfiles(char *line)
470484
* before that to have Finit specific ones sorted first, and
471485
* a configure prefix specific one after that for user needs.
472486
*/
473-
void tmpfilesd(void)
487+
int main(int argc, char *argv[])
474488
{
475489
/* in priority order */
476490
char *dir[] = {

src/tmpfiles.h

Lines changed: 0 additions & 42 deletions
This file was deleted.

0 commit comments

Comments
 (0)