[systemd-commits] 2 commits - Makefile.am src/core units/user
Kay Sievers
kay at kemper.freedesktop.org
Mon Jan 6 10:15:58 PST 2014
Makefile.am | 1 +
src/core/manager.c | 20 ++++++++++++++++++++
src/core/service.c | 26 ++++----------------------
units/user/basic.target | 13 +++++++++++++
units/user/default.target | 2 ++
5 files changed, 40 insertions(+), 22 deletions(-)
New commits:
commit fccd44ec3a7abd305b558d39f54b5ef223f00b68
Author: Kay Sievers <kay at vrfy.org>
Date: Mon Jan 6 07:52:17 2014 +0400
core: --user -- add basic.target an sort against it like --system does
diff --git a/Makefile.am b/Makefile.am
index 069583c..aed8c32 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -460,6 +460,7 @@ nodist_systemunit_DATA = \
units/systemd-nspawn at .service
dist_userunit_DATA = \
+ units/user/basic.target \
units/user/default.target \
units/user/exit.target
diff --git a/src/core/service.c b/src/core/service.c
index 6fbde2b..23810b3 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -1138,28 +1138,10 @@ static int service_add_default_dependencies(Service *s) {
* majority of services. */
/* First, pull in base system */
- if (UNIT(s)->manager->running_as == SYSTEMD_SYSTEM) {
- r = unit_add_two_dependencies_by_name(UNIT(s), UNIT_AFTER, UNIT_REQUIRES,
- SPECIAL_BASIC_TARGET, NULL, true);
- if (r < 0)
- return r;
-
- } else if (UNIT(s)->manager->running_as == SYSTEMD_USER) {
- r = unit_add_two_dependencies_by_name(UNIT(s), UNIT_AFTER, UNIT_REQUIRES,
- SPECIAL_SOCKETS_TARGET, NULL, true);
- if (r < 0)
- return r;
-
- r = unit_add_two_dependencies_by_name(UNIT(s), UNIT_AFTER, UNIT_REQUIRES,
- SPECIAL_TIMERS_TARGET, NULL, true);
- if (r < 0)
- return r;
-
- r = unit_add_two_dependencies_by_name(UNIT(s), UNIT_AFTER, UNIT_REQUIRES,
- SPECIAL_PATHS_TARGET, NULL, true);
- if (r < 0)
- return r;
- }
+ r = unit_add_two_dependencies_by_name(UNIT(s), UNIT_AFTER, UNIT_REQUIRES,
+ SPECIAL_BASIC_TARGET, NULL, true);
+ if (r < 0)
+ return r;
/* Second, activate normal shutdown */
r = unit_add_two_dependencies_by_name(UNIT(s), UNIT_BEFORE, UNIT_CONFLICTS,
diff --git a/units/user/basic.target b/units/user/basic.target
new file mode 100644
index 0000000..b74d13c
--- /dev/null
+++ b/units/user/basic.target
@@ -0,0 +1,13 @@
+# This file is part of systemd.
+#
+# systemd is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation; either version 2.1 of the License, or
+# (at your option) any later version.
+
+[Unit]
+Description=Basic System
+Documentation=man:systemd.special(7)
+Wants=sockets.target timers.target paths.target
+After=sockets.target timers.target paths.target
+RefuseManualStart=yes
diff --git a/units/user/default.target b/units/user/default.target
index 71eed51..9853c33 100644
--- a/units/user/default.target
+++ b/units/user/default.target
@@ -8,4 +8,6 @@
[Unit]
Description=Default
Documentation=man:systemd.special(7)
+Requires=basic.target
+After=basic.target
AllowIsolate=yes
commit fcc81ea3616b1108a23c0997331923d052539124
Author: Kay Sievers <kay at vrfy.org>
Date: Mon Jan 6 07:50:26 2014 +0400
core: --user -- move generator directories from /tmp to $XDG_RUNTIME_DIR
diff --git a/src/core/manager.c b/src/core/manager.c
index bbe5efa..0e35ba5 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -2507,6 +2507,7 @@ static int create_generator_dir(Manager *m, char **generator, const char *name)
return 0;
if (m->running_as == SYSTEMD_SYSTEM && getpid() == 1) {
+ /* systemd --system, not running --test */
p = strappend("/run/systemd/", name);
if (!p)
@@ -2519,7 +2520,26 @@ static int create_generator_dir(Manager *m, char **generator, const char *name)
free(p);
return r;
}
+ } else if (m->running_as == SYSTEMD_USER) {
+ const char *s = NULL;
+
+ s = getenv("XDG_RUNTIME_DIR");
+ if (!s)
+ return -EINVAL;
+ p = strjoin(s, "/systemd/", name, NULL);
+ if (!p)
+ return log_oom();
+
+ r = mkdir_p_label(p, 0755);
+ if (r < 0) {
+ log_error("Failed to create generator directory %s: %s",
+ p, strerror(-r));
+ free(p);
+ return r;
+ }
} else {
+ /* systemd --system --test */
+
p = strjoin("/tmp/systemd-", name, ".XXXXXX", NULL);
if (!p)
return log_oom();
More information about the systemd-commits
mailing list