[systemd-commits] 3 commits - Makefile.am configure.ac man/systemd.service.xml man/systemd.xml src/core units/user
Lennart Poettering
lennart at kemper.freedesktop.org
Wed Oct 17 16:20:45 PDT 2012
Makefile.am | 1 +
configure.ac | 8 +++++---
man/systemd.service.xml | 19 +++++++++++++------
man/systemd.xml | 8 ++++++++
src/core/manager.c | 10 ++++++++++
src/core/service.c | 15 ++++++++++-----
units/user/systemd-exit.service.in | 2 +-
7 files changed, 48 insertions(+), 15 deletions(-)
New commits:
commit 86b2e20a5e5abf222fb81edcb5d58d012e35cbaa
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Oct 18 01:20:03 2012 +0200
units: rework systemd-exit.service to terminate systemd via signal rather than bus
This should make session termination more reliable, as D-Bus doesn't
have to be around anymore for this to succeed.
diff --git a/Makefile.am b/Makefile.am
index 8e88c42..e1eb034 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -3613,6 +3613,7 @@ SED_PROCESS = \
-e 's, at rootprefix\@,$(rootprefix),g' \
-e 's, at udevlibexecdir\@,$(udevlibexecdir),g' \
-e 's, at sushell\@,$(sushell),g' \
+ -e 's, at KILL\@,$(KILL),g' \
-e 's, at QUOTAON\@,$(QUOTAON),g' \
-e 's, at QUOTACHECK\@,$(QUOTACHECK),g' \
-e 's, at SYSTEM_SYSVINIT_PATH\@,$(sysvinitdir),g' \
diff --git a/configure.ac b/configure.ac
index 62e83be..a16e7ea 100644
--- a/configure.ac
+++ b/configure.ac
@@ -64,10 +64,12 @@ AC_PROG_GCC_TRADITIONAL
AC_PATH_PROG([M4], [m4])
AC_PATH_PROG([XSLTPROC], [xsltproc])
-AC_PATH_PROG([QUOTAON], [quotaon], [/sbin/quotaon])
-AC_PATH_PROG([QUOTACHECK], [quotacheck], [/sbin/quotacheck])
+AC_PATH_PROG([QUOTAON], [quotaon], [/usr/sbin/quotaon])
+AC_PATH_PROG([QUOTACHECK], [quotacheck], [/usr/sbin/quotacheck])
-AC_PATH_PROG([SETCAP], [setcap], [/sbin/setcap])
+AC_PATH_PROG([SETCAP], [setcap], [/usr/sbin/setcap])
+
+AC_PATH_PROG([KILL], [kill], [/usr/bin/cap])
# gtkdocize greps for '^GTK_DOC_CHECK', so it needs to be on its own line
m4_ifdef([GTK_DOC_CHECK], [
diff --git a/units/user/systemd-exit.service.in b/units/user/systemd-exit.service.in
index a114f6c..95bd6b1 100644
--- a/units/user/systemd-exit.service.in
+++ b/units/user/systemd-exit.service.in
@@ -14,4 +14,4 @@ After=shutdown.target
[Service]
Type=oneshot
-ExecStart=@SYSTEMCTL@ --user --force exit
+ExecStart=@KILL@ -s RTMAX-6 $MANAGERPID
commit 600b704eb0fe4b4fd2901017082254634823f02d
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Oct 18 01:19:35 2012 +0200
manager: connect SIGRTMIN+24 to terminating --user instances
diff --git a/man/systemd.xml b/man/systemd.xml
index f14e3eb..7758524 100644
--- a/man/systemd.xml
+++ b/man/systemd.xml
@@ -838,6 +838,14 @@
</varlistentry>
<varlistentry>
+ <term>SIGRTMIN+24</term>
+
+ <listitem><para>Immediately exits the
+ manager (only available for --user
+ instances).</para></listitem>
+ </varlistentry>
+
+ <varlistentry>
<term>SIGRTMIN+26</term>
<term>SIGRTMIN+27</term>
<term>SIGRTMIN+28</term>
diff --git a/src/core/manager.c b/src/core/manager.c
index b19fc3d..f932c79 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -199,6 +199,7 @@ static int manager_setup_signals(Manager *m) {
SIGRTMIN+21, /* systemd: disable status messages */
SIGRTMIN+22, /* systemd: set log level to LOG_DEBUG */
SIGRTMIN+23, /* systemd: set log level to LOG_INFO */
+ SIGRTMIN+24, /* systemd: Immediate exit (--user only) */
SIGRTMIN+26, /* systemd: set log target to journal-or-kmsg */
SIGRTMIN+27, /* systemd: set log target to console */
SIGRTMIN+28, /* systemd: set log target to kmsg */
@@ -1272,6 +1273,15 @@ static int manager_process_signal_fd(Manager *m) {
log_notice("Setting log level to info.");
break;
+ case 24:
+ if (m->running_as == SYSTEMD_USER) {
+ m->exit_code = MANAGER_EXIT;
+ return 0;
+ }
+
+ /* This is a nop on init */
+ break;
+
case 26:
log_set_target(LOG_TARGET_JOURNAL_OR_KMSG);
log_notice("Setting log target to journal-or-kmsg.");
commit 97ae63e2a9c07ee64ab9f226b9b6121114f1d732
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Oct 18 01:18:50 2012 +0200
service: when invoking service processes in --user mode set MANAGERPID to PID of systemd
diff --git a/man/systemd.service.xml b/man/systemd.service.xml
index 11f6006..59ecf81 100644
--- a/man/systemd.service.xml
+++ b/man/systemd.service.xml
@@ -365,6 +365,13 @@
explicitly to a shell implementation
of some kind. Example:
<literal>ExecStart=/bin/sh -c 'dmesg | tac'</literal></para>
+
+ <para>For services run by a user
+ instance of systemd the special
+ environment variable
+ <literal>MANAGERPID</literal> is set
+ to the PID of the systemd
+ instance.</para>
</listitem>
</varlistentry>
@@ -407,12 +414,12 @@
variable substitution is supported
here following the same scheme as for
<varname>ExecStart=</varname>. One
- special environment variable is set:
- if known <literal>$MAINPID</literal> is
- set to the main process of the
- daemon, and may be used for command
- lines like the following:
- <command>/bin/kill -HUP
+ additional special environment
+ variables is set: if known
+ <literal>$MAINPID</literal> is set to
+ the main process of the daemon, and
+ may be used for command lines like the
+ following: <command>/bin/kill -HUP
$MAINPID</command>.</para></listitem>
</varlistentry>
diff --git a/src/core/service.c b/src/core/service.c
index 7f9a53a..5742968 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -1801,7 +1801,8 @@ static int service_spawn(
goto fail;
}
- if (!(our_env = new0(char*, 4))) {
+ our_env = new0(char*, 5);
+ if (!our_env) {
r = -ENOMEM;
goto fail;
}
@@ -1824,10 +1825,14 @@ static int service_spawn(
goto fail;
}
- if (!(final_env = strv_env_merge(2,
- UNIT(s)->manager->environment,
- our_env,
- NULL))) {
+ if (s->meta.manager->running_as != SYSTEMD_SYSTEM)
+ if (asprintf(our_env + n_env++, "MANAGERPID=%lu", (unsigned long) getpid()) < 0) {
+ r = -ENOMEM;
+ goto fail;
+ }
+
+ final_env = strv_env_merge(2, UNIT(s)->manager->environment, our_env, NULL);
+ if (!final_env) {
r = -ENOMEM;
goto fail;
}
More information about the systemd-commits
mailing list