[systemd-commits] 6 commits - fixme Makefile.am man/systemd.special.xml.in src/manager.c src/manager.h src/service.c units/mail-transfer-agent.target units/session

Lennart Poettering lennart at kemper.freedesktop.org
Mon May 24 13:33:19 PDT 2010


 Makefile.am                      |   15 ++++-
 fixme                            |    2 
 man/systemd.special.xml.in       |  105 +++++++++++++++++++++++++++++++++++++++
 src/manager.c                    |   21 +++++--
 src/manager.h                    |    4 +
 src/service.c                    |   21 +++++++
 units/mail-transfer-agent.target |   11 ++++
 units/session/.gitignore         |    1 
 units/session/exit.service.in    |    8 ++
 9 files changed, 174 insertions(+), 14 deletions(-)

New commits:
commit 723c83fd051e2c3a195251cc0bd1313cb6bcf729
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon May 24 22:32:09 2010 +0200

    service: interpret Debian-style X-Interactive LSB header field

diff --git a/src/service.c b/src/service.c
index 3fbc0ac..8ff7b73 100644
--- a/src/service.c
+++ b/src/service.c
@@ -599,6 +599,19 @@ static int service_load_sysv_path(Service *s, const char *path) {
 
                                 u->meta.description = d;
 
+                        } else if (startswith_no_case(t, "X-Interactive:")) {
+                                int b;
+
+                                if ((b = parse_boolean(strstrip(t+14))) < 0) {
+                                        log_warning("[%s:%u] Couldn't parse interactive flag. Ignoring.", path, line);
+                                        continue;
+                                }
+
+                                if (b)
+                                        s->exec_context.std_input = EXEC_INPUT_TTY;
+                                else
+                                        s->exec_context.std_input = EXEC_INPUT_NULL;
+
                         } else if (state == LSB_DESCRIPTION) {
 
                                 if (startswith(l, "#\t") || startswith(l, "#  ")) {
commit eeb7229cba8ef6445a9fc5ca2b0da06453d616af
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon May 24 22:31:50 2010 +0200

    man: document syslog and dbus services

diff --git a/man/systemd.special.xml.in b/man/systemd.special.xml.in
index 1c9e88c..1d9c132 100644
--- a/man/systemd.special.xml.in
+++ b/man/systemd.special.xml.in
@@ -50,6 +50,7 @@
         <refsynopsisdiv>
                 <para><filename>basic.target</filename>,
                 <filename>ctrl-alt-del.target</filename>,
+                <filename>@SPECIAL_DBUS_SERVICE@</filename>,
                 <filename>default.target</filename>,
                 <filename>display-manager.service</filename>,
                 <filename>emergency.service</filename>,
@@ -80,6 +81,7 @@
                 <filename>sockets.target</filename>,
                 <filename>swap.target</filename>,
                 <filename>syslog.target</filename>,
+                <filename>@SPECIAL_SYSLOG_SERVICE@</filename>,
                 <filename>systemd-initctl.service</filename>,
                 <filename>systemd-initctl.socket</filename>,
                 <filename>systemd-logger.service</filename>,
@@ -134,6 +136,17 @@
                                 </listitem>
                         </varlistentry>
                         <varlistentry>
+                                <term><filename>@SPECIAL_DBUS_SERVICE@</filename></term>
+                                <listitem>
+                                        <para>A special unit for the
+                                        D-Bus system bus. As soon as
+                                        this service is fully started
+                                        up systemd will connect to it
+                                        and register its
+                                        service.</para>
+                                </listitem>
+                        </varlistentry>
+                        <varlistentry>
                                 <term><filename>default.target</filename></term>
                                 <listitem>
                                         <para>The default unit systemd
@@ -574,6 +587,23 @@
                                 </listitem>
                         </varlistentry>
                         <varlistentry>
+                                <term><filename>@SPECIAL_SYSLOG_SERVICE@</filename></term>
+                                <listitem>
+                                        <para>A special unit for the
+                                        syslog daemon. As soon as
+                                        this service is fully started
+                                        up systemd will connect to it
+                                        and use it for logging if it
+                                        has been configured for
+                                        that.</para>
+                                        <para>Applications should
+                                        generally not depend on this
+                                        service, and depend on
+                                        <filename>syslog.target</filename>
+                                        instead.</para>
+                                </listitem>
+                        </varlistentry>
+                        <varlistentry>
                                 <term><filename>systemd-initctl.service</filename></term>
                                 <listitem>
                                         <para>This provides
commit a1b256b0b562481404bda8304e04dee7d7d5e7c9
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon May 24 22:31:38 2010 +0200

    unit: introduce exit.service for exiting from session instances

diff --git a/Makefile.am b/Makefile.am
index a96b89d..bd25239 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -128,7 +128,8 @@ dist_sessionunit_DATA = \
 	units/session/default.target
 
 sessionunit_DATA = \
-	units/session/remote-fs.target
+	units/session/remote-fs.target \
+	units/session/exit.service
 
 EXTRA_DIST = \
 	units/basic.target.m4 \
@@ -139,6 +140,7 @@ EXTRA_DIST = \
 	units/systemd-initctl.service.in \
 	units/systemd-logger.service.in \
 	units/syslog.target.in \
+	units/session/exit.service.in \
 	LICENSE \
 	README \
 	DISTRO_PORTING
@@ -359,6 +361,8 @@ SED_PROCESS = \
 	$(SED)  -e 's, at libexecdir\@,$(libexecdir),g' \
 		-e 's, at pkglibexecdir\@,$(pkglibexecdir),g' \
 		-e 's, at SPECIAL_SYSLOG_SERVICE\@,$(SPECIAL_SYSLOG_SERVICE),g' \
+		-e 's, at SPECIAL_DBUS_SERVICE\@,$(SPECIAL_DBUS_SERVICE),g' \
+		-e 's, at SYSTEMCTL\@,$(bindir)/systemctl,g' \
 		< $< > $@
 
 units/%: units/%.in Makefile
@@ -391,6 +395,7 @@ CLEANFILES = \
 	units/multi-user.target \
 	units/remote-fs.target \
 	units/session/remote-fs.target \
+	units/session/exit.service \
 	man/systemd.special.7 \
 	man/systemd.special.html
 
diff --git a/fixme b/fixme
index 6b6f7f7..b6752d9 100644
--- a/fixme
+++ b/fixme
@@ -64,8 +64,6 @@
 
 * tcpwrap
 
-* introduce exit.target for session instances
-
 Regularly:
 
 * look for close() vs. close_nointr() vs. close_nointr_nofail()
diff --git a/man/systemd.special.xml.in b/man/systemd.special.xml.in
index 0af9c6e..1c9e88c 100644
--- a/man/systemd.special.xml.in
+++ b/man/systemd.special.xml.in
@@ -53,6 +53,7 @@
                 <filename>default.target</filename>,
                 <filename>display-manager.service</filename>,
                 <filename>emergency.service</filename>,
+                <filename>exit.service</filename>,
                 <filename>graphical.target</filename>,
                 <filename>halt.target</filename>,
                 <filename>kbrequest.target</filename>,
@@ -635,6 +636,35 @@
                 <filename>shutdown.target</filename>,
                 <filename>sockets.target</filename>,
                 <filename>swap.target</filename>.</para>
+
+                <para>In addition the following special unit is
+                understood only when systemd runs as service instance:</para>
+
+                <variablelist>
+                        <varlistentry>
+                                <term><filename>exit.service</filename></term>
+                                <listitem>
+                                        <para>A special service unit
+                                        for shutting down the
+                                        session.</para>
+
+                                        <para>Applications wanting to
+                                        terminate the session should
+                                        start this unit. If systemd
+                                        receives SIGTERM or SIGINT
+                                        when running as session daemon
+                                        it will start this
+                                        unit.</para>
+
+                                        <para>Normally, this pulls in
+                                        <filename>shutdown.target</filename>
+                                        which in turn should be
+                                        conflicted by all units that
+                                        want to be shut down on
+                                        session exit.</para>
+                                </listitem>
+                        </varlistentry>
+                </variablelist>
         </refsect1>
 
         <refsect1>
diff --git a/src/manager.c b/src/manager.c
index 2a773c6..933dd50 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -1791,11 +1791,13 @@ static int manager_dispatch_sigchld(Manager *m) {
         return 0;
 }
 
-static void manager_start_target(Manager *m, const char *name) {
+static int manager_start_target(Manager *m, const char *name) {
         int r;
 
         if ((r = manager_add_job_by_name(m, JOB_START, name, JOB_REPLACE, true, NULL)) < 0)
                 log_error("Failed to enqueue %s job: %s", name, strerror(-r));
+
+        return r;
 }
 
 static int manager_process_signal_fd(Manager *m) {
@@ -1824,14 +1826,14 @@ static int manager_process_signal_fd(Manager *m) {
                         break;
 
                 case SIGTERM:
-                        if (m->running_as == MANAGER_INIT)
+                        if (m->running_as == MANAGER_INIT) {
                                 /* This is for compatibility with the
                                  * original sysvinit */
                                 m->exit_code = MANAGER_REEXECUTE;
-                        else
-                                m->exit_code = MANAGER_EXIT;
+                                break;
+                        }
 
-                        return 0;
+                        /* Fall through */
 
                 case SIGINT:
                         if (m->running_as == MANAGER_INIT) {
@@ -1839,8 +1841,13 @@ static int manager_process_signal_fd(Manager *m) {
                                 break;
                         }
 
-                        m->exit_code = MANAGER_EXIT;
-                        return 0;
+                        /* Run the exit target if there is one, if not, just exit. */
+                        if (manager_start_target(m, SPECIAL_EXIT_SERVICE) < 0) {
+                                m->exit_code = MANAGER_EXIT;
+                                return 0;
+                        }
+
+                        break;
 
                 case SIGWINCH:
                         if (m->running_as == MANAGER_INIT)
diff --git a/src/manager.h b/src/manager.h
index 22ba04f..210e660 100644
--- a/src/manager.h
+++ b/src/manager.h
@@ -109,6 +109,7 @@ struct Watch {
 #define SPECIAL_MAIL_TRANSFER_AGENT_TARGET "mail-transfer-agent.target" /* Debian's $mail-{transport|transfer-agent */
 #define SPECIAL_BASIC_TARGET "basic.target"
 #define SPECIAL_RESCUE_TARGET "rescue.target"
+#define SPECIAL_EXIT_SERVICE "exit.service"
 
 #ifndef SPECIAL_DBUS_SERVICE
 #define SPECIAL_DBUS_SERVICE "dbus.service"
diff --git a/units/session/.gitignore b/units/session/.gitignore
new file mode 100644
index 0000000..eeb62b3
--- /dev/null
+++ b/units/session/.gitignore
@@ -0,0 +1 @@
+exit.service
diff --git a/units/session/exit.service.in b/units/session/exit.service.in
new file mode 100644
index 0000000..86c8bbc
--- /dev/null
+++ b/units/session/exit.service.in
@@ -0,0 +1,8 @@
+[Unit]
+Description=Exit
+Requires=shutdown.target
+After=shutdown.target
+
+[Service]
+Type=finish
+ExecStart=@SYSTEMCTL@ --session daemon-exit
commit 683f468c54a81fd4084a2ba1082025959cd3c7d1
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon May 24 22:30:54 2010 +0200

    unit: ship a mail-transfer-agent.target unit by default

diff --git a/Makefile.am b/Makefile.am
index f1f9da7..a96b89d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -87,6 +87,7 @@ dist_systemunit_DATA = \
 	units/local-fs.target \
 	units/network.target \
 	units/nss-lookup.target \
+	units/mail-transfer-agent.target \
 	units/poweroff.target \
 	units/reboot.target \
 	units/remote-fs.target \
diff --git a/man/systemd.special.xml.in b/man/systemd.special.xml.in
index 1c647e9..0af9c6e 100644
--- a/man/systemd.special.xml.in
+++ b/man/systemd.special.xml.in
@@ -57,6 +57,7 @@
                 <filename>halt.target</filename>,
                 <filename>kbrequest.target</filename>,
                 <filename>local-fs.target</filename>,
+                <filename>mail-transfer-agent.target</filename>,
                 <filename>multi-user.target</filename>,
                 <filename>network.target</filename>,
                 <filename>nss-lookup.target</filename>,
@@ -249,6 +250,29 @@
                                 </listitem>
                         </varlistentry>
                         <varlistentry>
+                                <term><filename>mail-transfer-agent.target</filename></term>
+                                <listitem>
+                                        <para>The mail transfer agent
+                                        (MTA) service. Usually this
+                                        should pull in all units
+                                        necessary for
+                                        sending/receiving mails on the
+                                        local host.</para>
+
+                                        <para>systemd automatically
+                                        adds dependencies of type
+                                        After for this target unit to
+                                        all SysV init script service
+                                        units with an LSB header
+                                        referring to the
+                                        <literal>$mail-transfer-argent</literal>
+                                        or
+                                        <literal>$mail-transport-agent</literal>
+                                        facilities, for compatibility
+                                        with Debian.</para>
+                                </listitem>
+                        </varlistentry>
+                        <varlistentry>
                                 <term><filename>multi-user.target</filename></term>
                                 <listitem>
                                         <para>A special target unit
diff --git a/units/mail-transfer-agent.target b/units/mail-transfer-agent.target
new file mode 100644
index 0000000..2640076
--- /dev/null
+++ b/units/mail-transfer-agent.target
@@ -0,0 +1,11 @@
+#  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.
+
+# See systemd.special(7) for details
+
+[Unit]
+Description=Mail Transfer Agent
commit 1e287fe32fd15b1691cbb966feef5fc2f9f6cf7b
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon May 24 22:29:59 2010 +0200

    unit: turn display-manager.target into a service

diff --git a/Makefile.am b/Makefile.am
index 9b0e04f..f1f9da7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -517,9 +517,12 @@ install-data-hook:
 		$(LN_S) ../sys-kernel-security.automount sys-kernel-security.automount && \
 		$(LN_S) ../sys-fs-fuse-connections.automount sys-fs-fuse-connections.automount )
 if TARGET_FEDORA
+	( cd $(DESTDIR)$(pkgsysconfdir)/system && \
+		rm -f display-manager.service && \
+		$(LN_S) $(systemunitdir)/prefdm.service display-manager.service )
 	( cd $(DESTDIR)$(pkgsysconfdir)/system/graphical.target.wants && \
-		rm -f prefdm.service && \
-		$(LN_S) $(systemunitdir)/prefdm.service prefdm.service )
+		rm -f display-manager.service && \
+		$(LN_S) ../display-manager.service display-manager.service )
 	( cd $(DESTDIR)$(pkgsysconfdir)/system/multi-user.target.wants && \
 		rm -f rc-local.service && \
 		$(LN_S) $(systemunitdir)/rc-local.service rc-local.service )
diff --git a/man/systemd.special.xml.in b/man/systemd.special.xml.in
index daa9358..1c647e9 100644
--- a/man/systemd.special.xml.in
+++ b/man/systemd.special.xml.in
@@ -51,6 +51,7 @@
                 <para><filename>basic.target</filename>,
                 <filename>ctrl-alt-del.target</filename>,
                 <filename>default.target</filename>,
+                <filename>display-manager.service</filename>,
                 <filename>emergency.service</filename>,
                 <filename>graphical.target</filename>,
                 <filename>halt.target</filename>,
@@ -148,6 +149,26 @@
                                 </listitem>
                         </varlistentry>
                         <varlistentry>
+                                <term><filename>display-manager.service</filename></term>
+                                <listitem>
+                                        <para>The display manager
+                                        service. Usually this should
+                                        be aliased (symlinked) to
+                                        <filename>gdm.service</filename>
+                                        or a similar display manager
+                                        service.</para>
+                                        <para>systemd automatically
+                                        adds dependencies of type
+                                        After for this target unit to
+                                        all SysV init script service
+                                        units with an LSB header
+                                        referring to the
+                                        <literal>$x-display-manager</literal>
+                                        facility, for compatibility
+                                        with Debian.</para>
+                                </listitem>
+                        </varlistentry>
+                        <varlistentry>
                                 <term><filename>emergency.service</filename></term>
                                 <listitem>
                                         <para>A special service unit
diff --git a/src/manager.h b/src/manager.h
index e2f9cf6..22ba04f 100644
--- a/src/manager.h
+++ b/src/manager.h
@@ -105,7 +105,7 @@ struct Watch {
 #define SPECIAL_RPCBIND_TARGET "rpcbind.target"           /* LSB's $portmap */
 #define SPECIAL_SYSLOG_TARGET "syslog.target"             /* LSB's $syslog; Should pull in syslog.socket or syslog.service */
 #define SPECIAL_RTC_SET_TARGET "rtc-set.target"           /* LSB's $time */
-#define SPECIAL_DISPLAY_MANAGER_TARGET "display-manager.target"         /* Debian's $x-display-manager */
+#define SPECIAL_DISPLAY_MANAGER_SERVICE "display-manager.service"       /* Debian's $x-display-manager */
 #define SPECIAL_MAIL_TRANSFER_AGENT_TARGET "mail-transfer-agent.target" /* Debian's $mail-{transport|transfer-agent */
 #define SPECIAL_BASIC_TARGET "basic.target"
 #define SPECIAL_RESCUE_TARGET "rescue.target"
diff --git a/src/service.c b/src/service.c
index d4b874d..3fbc0ac 100644
--- a/src/service.c
+++ b/src/service.c
@@ -203,7 +203,7 @@ static int sysv_translate_facility(const char *name, char **_r) {
                 /* Debian extensions */
                 "$mail-transport-agent", SPECIAL_MAIL_TRANSFER_AGENT_TARGET,
                 "$mail-transfer-agent",  SPECIAL_MAIL_TRANSFER_AGENT_TARGET,
-                "$x-display-manager",    SPECIAL_DISPLAY_MANAGER_TARGET,
+                "$x-display-manager",    SPECIAL_DISPLAY_MANAGER_SERVICE
         };
 
         unsigned i;
commit 6464aa0890dd21bf0b3e3acfc2b24a425b252c51
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon May 24 19:56:25 2010 +0200

    service: add extended debian facilities

diff --git a/src/manager.h b/src/manager.h
index 9548b0f..e2f9cf6 100644
--- a/src/manager.h
+++ b/src/manager.h
@@ -105,7 +105,8 @@ struct Watch {
 #define SPECIAL_RPCBIND_TARGET "rpcbind.target"           /* LSB's $portmap */
 #define SPECIAL_SYSLOG_TARGET "syslog.target"             /* LSB's $syslog; Should pull in syslog.socket or syslog.service */
 #define SPECIAL_RTC_SET_TARGET "rtc-set.target"           /* LSB's $time */
-
+#define SPECIAL_DISPLAY_MANAGER_TARGET "display-manager.target"         /* Debian's $x-display-manager */
+#define SPECIAL_MAIL_TRANSFER_AGENT_TARGET "mail-transfer-agent.target" /* Debian's $mail-{transport|transfer-agent */
 #define SPECIAL_BASIC_TARGET "basic.target"
 #define SPECIAL_RESCUE_TARGET "rescue.target"
 
diff --git a/src/service.c b/src/service.c
index 1379d14..d4b874d 100644
--- a/src/service.c
+++ b/src/service.c
@@ -191,13 +191,19 @@ static char *sysv_translate_name(const char *name) {
 static int sysv_translate_facility(const char *name, char **_r) {
 
         static const char * const table[] = {
+                /* LSB defined facilities */
                 "$local_fs",  SPECIAL_LOCAL_FS_TARGET,
                 "$network",   SPECIAL_NETWORK_TARGET,
                 "$named",     SPECIAL_NSS_LOOKUP_TARGET,
                 "$portmap",   SPECIAL_RPCBIND_TARGET,
                 "$remote_fs", SPECIAL_REMOTE_FS_TARGET,
                 "$syslog",    SPECIAL_SYSLOG_TARGET,
-                "$time",      SPECIAL_RTC_SET_TARGET
+                "$time",      SPECIAL_RTC_SET_TARGET,
+
+                /* Debian extensions */
+                "$mail-transport-agent", SPECIAL_MAIL_TRANSFER_AGENT_TARGET,
+                "$mail-transfer-agent",  SPECIAL_MAIL_TRANSFER_AGENT_TARGET,
+                "$x-display-manager",    SPECIAL_DISPLAY_MANAGER_TARGET,
         };
 
         unsigned i;


More information about the systemd-commits mailing list