[systemd-commits] 3 commits - Makefile.am src/tmpfiles.c tmpfiles.d/systemd.conf tmpfiles.d/x11.conf
Lennart Poettering
lennart at kemper.freedesktop.org
Tue Sep 28 13:33:03 PDT 2010
Makefile.am | 5 +++++
src/tmpfiles.c | 48 ++++++++++++++++++++++++++++++++++--------------
tmpfiles.d/systemd.conf | 10 ++++++++++
tmpfiles.d/x11.conf | 9 +++++++++
4 files changed, 58 insertions(+), 14 deletions(-)
New commits:
commit 34c8deaae1fcfa9e7c9db49b5f3a33973e103218
Author: Lennart Poettering <lennart at poettering.net>
Date: Tue Sep 28 22:32:53 2010 +0200
tmpfiles: install default tmpfiles configuration
diff --git a/Makefile.am b/Makefile.am
index 44a2779..973d341 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -30,6 +30,7 @@ polkitpolicydir=$(datadir)/polkit-1/actions
# Our own, non-special dirs
pkgsysconfdir=$(sysconfdir)/systemd
sessionunitdir=$(pkgdatadir)/session
+tmpfilesdir=$(sysconfdir)/tmpfiles.d
# And these are the special ones for /
rootdir=@rootdir@
@@ -139,6 +140,10 @@ dbusinterface_DATA = \
org.freedesktop.systemd1.Swap.xml \
org.freedesktop.systemd1.Path.xml
+dist_tmpfiles_DATA = \
+ tmpfiles.d/systemd.conf \
+ tmpfiles.d/x11.conf
+
dist_systemunit_DATA = \
units/emergency.service \
units/emergency.target \
diff --git a/tmpfiles.d/systemd.conf b/tmpfiles.d/systemd.conf
new file mode 100644
index 0000000..ee326f0
--- /dev/null
+++ b/tmpfiles.d/systemd.conf
@@ -0,0 +1,10 @@
+# This file is part of systemd.
+#
+# systemd is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+d /var/lock/subsys 0755 root root
+d /var/run/user 0755 root root
+f /var/run/utmp 0664 root utmp
diff --git a/tmpfiles.d/x11.conf b/tmpfiles.d/x11.conf
new file mode 100644
index 0000000..d23c052
--- /dev/null
+++ b/tmpfiles.d/x11.conf
@@ -0,0 +1,9 @@
+# This file is part of systemd.
+#
+# systemd is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+d /tmp/.X11-unix 1777 root root
+d /tmp/.ICE-unix 1777 root root
commit 7fcde28044351a9d2780916b69ff67e5c4e27e01
Author: Lennart Poettering <lennart at poettering.net>
Date: Tue Sep 28 22:32:27 2010 +0200
tmpfiles: move dir to /etc/tempfiles.d/
diff --git a/src/tmpfiles.c b/src/tmpfiles.c
index 7bd5510..3a83311 100644
--- a/src/tmpfiles.c
+++ b/src/tmpfiles.c
@@ -258,12 +258,12 @@ int main(int argc, char *argv[]) {
label_init();
- if ((n = scandir("/etc/tempfiles.d/", &de, scandir_filter, alphasort)) < 0) {
+ if ((n = scandir("/etc/tmpfiles.d/", &de, scandir_filter, alphasort)) < 0) {
if (errno == ENOENT)
r = EXIT_SUCCESS;
else
- log_error("Failed to enumerate /etc/tempfiles.d/ files: %m");
+ log_error("Failed to enumerate /etc/tmpfiles.d/ files: %m");
goto finish;
}
@@ -276,7 +276,7 @@ int main(int argc, char *argv[]) {
FILE *f;
unsigned j;
- k = asprintf(&fn, "/etc/tempfiles.d/%s", de[i]->d_name);
+ k = asprintf(&fn, "/etc/tmpfiles.d/%s", de[i]->d_name);
free(de[i]);
if (k < 0) {
commit 4aa8b15b0c378eeb5773f74c27836be06da484f3
Author: Lennart Poettering <lennart at poettering.net>
Date: Tue Sep 28 22:32:05 2010 +0200
tmpfiles: return sensible error code
diff --git a/src/tmpfiles.c b/src/tmpfiles.c
index 80e424f..7bd5510 100644
--- a/src/tmpfiles.c
+++ b/src/tmpfiles.c
@@ -40,7 +40,7 @@
* /var/lock which are volatile and hence need to be recreated on
* bootup. */
-static void process_line(const char *fname, unsigned line, const char *buffer, const char *prefix) {
+static int process_line(const char *fname, unsigned line, const char *buffer, const char *prefix) {
char type;
char *path = NULL;
unsigned mode;
@@ -48,7 +48,7 @@ static void process_line(const char *fname, unsigned line, const char *buffer, c
uid_t uid;
gid_t gid;
bool uid_set = false, gid_set = false;
- int n, fd = -1;
+ int n, fd = -1, r;
assert(fname);
assert(line >= 1);
@@ -66,16 +66,20 @@ static void process_line(const char *fname, unsigned line, const char *buffer, c
&user,
&group)) < 2) {
log_error("[%s:%u] Syntax error.", fname, line);
+ r = -EIO;
goto finish;
}
if (type != 'f' && type != 'd') {
log_error("[%s:%u] Unknown file type '%c'.", fname, line, type);
+ r = -EBADMSG;
goto finish;
}
- if (prefix && !path_startswith(path, prefix))
+ if (prefix && !path_startswith(path, prefix)) {
+ r = 0;
goto finish;
+ }
if (user && !streq(user, "-")) {
unsigned long lu;
@@ -89,6 +93,7 @@ static void process_line(const char *fname, unsigned line, const char *buffer, c
uid = p->pw_uid;
else {
log_error("[%s:%u] Unknown user '%s'.", fname, line, user);
+ r = -ENOENT;
goto finish;
}
@@ -107,6 +112,7 @@ static void process_line(const char *fname, unsigned line, const char *buffer, c
gid = g->gr_gid;
else {
log_error("[%s:%u] Unknown group '%s'.", fname, line, group);
+ r = -ENOENT;
goto finish;
}
@@ -126,21 +132,25 @@ static void process_line(const char *fname, unsigned line, const char *buffer, c
if (fd < 0) {
log_error("Failed to create file %s: %m", path);
+ r = -errno;
goto finish;
}
if (fstat(fd, &st) < 0) {
log_error("stat(%s) failed: %m", path);
+ r = -errno;
goto finish;
}
if (!S_ISREG(st.st_mode)) {
log_error("%s is not a file.", path);
+ r = -EEXIST;
goto finish;
}
if (fchmod(fd, mode) < 0) {
log_error("chmod(%s) failed: %m", path);
+ r = -errno;
goto finish;
}
@@ -150,13 +160,13 @@ static void process_line(const char *fname, unsigned line, const char *buffer, c
uid_set ? uid : (uid_t) -1,
gid_set ? gid : (gid_t) -1) < 0) {
log_error("chown(%s) failed: %m", path);
+ r = -errno;
goto finish;
}
}
} else if (type == 'd') {
mode_t u;
- int r;
struct stat st;
u = umask(0);
@@ -165,21 +175,25 @@ static void process_line(const char *fname, unsigned line, const char *buffer, c
if (r < 0 && errno != EEXIST) {
log_error("Failed to create directory %s: %m", path);
+ r = -errno;
goto finish;
}
if (stat(path, &st) < 0) {
log_error("stat(%s) failed: %m", path);
+ r = -errno;
goto finish;
}
if (!S_ISDIR(st.st_mode)) {
log_error("%s is not a directory.", path);
+ r = -EEXIST;
goto finish;
}
if (chmod(path, mode) < 0) {
log_error("chmod(%s) failed: %m", path);
+ r = -errno;
goto finish;
}
@@ -189,14 +203,17 @@ static void process_line(const char *fname, unsigned line, const char *buffer, c
uid_set ? uid : (uid_t) -1,
gid_set ? gid : (gid_t) -1) < 0) {
log_error("chown(%s) failed: %m", path);
+ r = -errno;
goto finish;
}
}
}
- label_fix(path);
+ if ((r = label_fix(path)) < 0)
+ goto finish;
log_debug("%s created successfully.", path);
+ r = 0;
finish:
free(path);
@@ -205,6 +222,8 @@ finish:
if (fd >= 0)
close_nointr_nofail(fd);
+
+ return r;
}
static int scandir_filter(const struct dirent *d) {
@@ -266,11 +285,9 @@ int main(int argc, char *argv[]) {
continue;
}
- f = fopen(fn, "re");
- free(fn);
-
- if (!f) {
+ if (!(f = fopen(fn, "re"))) {
log_error("Failed to open %s: %m", fn);
+ free(fn);
r = EXIT_FAILURE;
continue;
}
@@ -288,14 +305,17 @@ int main(int argc, char *argv[]) {
if (*l == '#' || *l == 0)
continue;
- process_line(de[i]->d_name, j, l, prefix);
+ if (process_line(fn, j, l, prefix) < 0)
+ r = EXIT_FAILURE;
}
if (ferror(f)) {
r = EXIT_FAILURE;
- log_error("Failed to read from file: %m");
+ log_error("Failed to read from file %s: %m", fn);
}
+ free(fn);
+
fclose(f);
}
More information about the systemd-commits
mailing list