[systemd-commits] 4 commits - fixme Makefile.am src/dbus-job.c src/dbus-job.h src/dbus-manager.c src/dbus-unit.c src/execute.c src/execute.h src/job.c src/job.h src/main.c src/systemadm.vala src/systemctl.vala src/systemd-interfaces.vala units/sys-fs-fuse-connections.automount units/sys-fs-fuse-connections.mount units/sys-kernel-security.automount units/sys-kernel-security.mount units/var-lock.mount

Lennart Poettering lennart at kemper.freedesktop.org
Sat May 22 16:57:08 PDT 2010


 Makefile.am                             |   16 ++++
 fixme                                   |    9 +-
 src/dbus-job.c                          |    9 ++
 src/dbus-job.h                          |    2 
 src/dbus-manager.c                      |    1 
 src/dbus-unit.c                         |    5 +
 src/execute.c                           |   10 +-
 src/execute.h                           |    2 
 src/job.c                               |    3 
 src/job.h                               |    1 
 src/main.c                              |    2 
 src/systemadm.vala                      |    2 
 src/systemctl.vala                      |  107 +++++++++++++++++++++++---------
 src/systemd-interfaces.vala             |    2 
 units/sys-fs-fuse-connections.automount |   13 +++
 units/sys-fs-fuse-connections.mount     |   14 ++++
 units/sys-kernel-security.automount     |   13 +++
 units/sys-kernel-security.mount         |   14 ++++
 units/var-lock.mount                    |   15 ++++
 19 files changed, 194 insertions(+), 46 deletions(-)

New commits:
commit 6d526de26737a0f1e8d1cf422da364d29489022e
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sun May 23 01:56:54 2010 +0200

    unit: add automount units for a number of API filesystems

diff --git a/Makefile.am b/Makefile.am
index 194e373..ffa9ad9 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -89,8 +89,13 @@ dist_systemunit_DATA = \
 	units/dev-mqueue.mount \
 	units/proc-sys-fs-binfmt_misc.automount \
 	units/proc-sys-fs-binfmt_misc.mount \
+	units/sys-fs-fuse-connections.automount \
+	units/sys-fs-fuse-connections.mount \
 	units/sys-kernel-debug.automount \
 	units/sys-kernel-debug.mount \
+	units/sys-kernel-security.automount \
+	units/sys-kernel-security.mount \
+	units/var-lock.mount \
 	units/var-run.mount
 
 systemunit_DATA = \
@@ -475,11 +480,18 @@ install-data-hook:
 		rm -f getty.target && \
 		$(LN_S) $(systemunitdir)/getty.target getty.target )
 	( cd $(DESTDIR)$(systemunitdir)/basic.target.wants && \
-		rm -f dev-hugepages.automount dev-mqueue.automount proc-sys-fs-binfmt_misc.automount sys-kernel-debug.automount && \
+		rm -f dev-hugepages.automount \
+			dev-mqueue.automount \
+			proc-sys-fs-binfmt_misc.automount \
+			sys-kernel-debug.automount \
+			sys-fs-fuse-connections.automount \
+			sys-kernel-security.automount && \
 		$(LN_S) ../dev-hugepages.automount dev-hugepages.automount && \
 		$(LN_S) ../dev-mqueue.automount dev-mqueue.automount && \
 		$(LN_S) ../proc-sys-fs-binfmt_misc.automount proc-sys-fs-binfmt_misc.automount && \
-		$(LN_S) ../sys-kernel-debug.automount sys-kernel-debug.automount )
+		$(LN_S) ../sys-kernel-debug.automount sys-kernel-debug.automount && \
+		$(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/graphical.target.wants && \
 		rm -f prefdm.service && \
diff --git a/fixme b/fixme
index 0585d1d..b6752d9 100644
--- a/fixme
+++ b/fixme
@@ -56,6 +56,14 @@
 
 * teach dbus to talk to systemd when autospawning services
 
+* regnerate unit/sysv search paths on daemon reload
+
+* write utmp record a la upstart for processes
+
+* run PAM session stuff
+
+* tcpwrap
+
 Regularly:
 
 * look for close() vs. close_nointr() vs. close_nointr_nofail()
diff --git a/units/sys-fs-fuse-connections.automount b/units/sys-fs-fuse-connections.automount
new file mode 100644
index 0000000..db13162
--- /dev/null
+++ b/units/sys-fs-fuse-connections.automount
@@ -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 General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or
+#  (at your option) any later version.
+
+[Unit]
+Description=FUSE Control File System Automount Point
+Before=basic.target
+
+[Automount]
+Where=/sys/fs/fuse/connections
diff --git a/units/sys-fs-fuse-connections.mount b/units/sys-fs-fuse-connections.mount
new file mode 100644
index 0000000..0a0a4e8
--- /dev/null
+++ b/units/sys-fs-fuse-connections.mount
@@ -0,0 +1,14 @@
+#  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.
+
+[Unit]
+Description=FUSE Control File System
+
+[Mount]
+What=fusectl
+Where=/sys/fs/fuse/connections
+Type=fusectl
diff --git a/units/sys-kernel-security.automount b/units/sys-kernel-security.automount
new file mode 100644
index 0000000..061a5a2
--- /dev/null
+++ b/units/sys-kernel-security.automount
@@ -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 General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or
+#  (at your option) any later version.
+
+[Unit]
+Description=Security File System Automount Point
+Before=basic.target
+
+[Automount]
+Where=/sys/kernel/security
diff --git a/units/sys-kernel-security.mount b/units/sys-kernel-security.mount
new file mode 100644
index 0000000..db9d672
--- /dev/null
+++ b/units/sys-kernel-security.mount
@@ -0,0 +1,14 @@
+#  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.
+
+[Unit]
+Description=Security File System
+
+[Mount]
+What=securityfs
+Where=/sys/kernel/security
+Type=securityfs
diff --git a/units/var-lock.mount b/units/var-lock.mount
new file mode 100644
index 0000000..dbfee59
--- /dev/null
+++ b/units/var-lock.mount
@@ -0,0 +1,15 @@
+#  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.
+
+[Unit]
+Description=Lock Directory
+Before=local-fs.target
+
+[Mount]
+What=tmpfs
+Where=/var/lock
+Type=tmpfs
commit 9a57a1fdd6491bb319d5ae59b505fa224b873ccf
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sat May 22 04:39:37 2010 +0200

    systemctl: subscribe to changes of existing units/jobs

diff --git a/src/systemctl.vala b/src/systemctl.vala
index e1e8a0c..e3e675f 100644
--- a/src/systemctl.vala
+++ b/src/systemctl.vala
@@ -128,16 +128,17 @@ int main (string[] args) {
                         "  clear-jobs                      Cancel all jobs\n" +
                         "  load [NAME...]                  Load one or more units\n" +
                         "  cancel [JOB...]                 Cancel one or more jobs\n" +
-                        "  start [NAME...]                 Start on or more units\n" +
-                        "  stop [NAME...]                  Stop on or more units\n" +
-                        "  enter [NAME]                    Start one unit and stop all others\n" +
-                        "  restart [NAME...]               Restart on or more units\n" +
-                        "  reload [NAME...]                Reload on or more units\n" +
+                        "  start [NAME...]                 Start one or more units\n" +
+                        "  stop [NAME...]                  Stop one or more units\n" +
+                        "  restart [NAME...]               Restart one or more units\n" +
+                        "  reload [NAME...]                Reload one or more units\n" +
+                        "  isolate [NAME]                  Start one unit and stop all others\n" +
                         "  monitor                         Monitor unit/job changes\n" +
                         "  dump                            Dump server status\n" +
                         "  snapshot [NAME]                 Create a snapshot\n" +
                         "  daemon-reload                   Reload daemon configuration\n" +
                         "  daemon-reexecute                Reexecute daemon\n" +
+                        "  daemon-exit                     Ask the daemon to quit\n" +
                         "  show-environment                Dump environment\n" +
                         "  set-environment [NAME=VALUE...] Set one or more environment variables\n" +
                         "  unset-environment [NAME...]     Unset one or more environment variables\n");
@@ -300,6 +301,15 @@ int main (string[] args) {
 
                         manager.subscribe();
 
+                        var unit_list = manager.list_units();
+
+                        foreach (var i in unit_list) {
+                                monitor_on_unit_new(i.id, i.unit_path);
+
+                                if (i.job_id != 0)
+                                        monitor_on_job_new(i.job_id, i.job_path);
+                        }
+
                         manager.unit_new += monitor_on_unit_new;
                         manager.unit_removed += monitor_on_unit_removed;
                         manager.job_new += monitor_on_job_new;
commit 1b91d3e8f402829f336daa5f768e768aede373da
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sat May 22 04:39:16 2010 +0200

    execute: fix typo

diff --git a/src/execute.c b/src/execute.c
index ead6c0f..1b37f2e 100644
--- a/src/execute.c
+++ b/src/execute.c
@@ -783,10 +783,12 @@ int exec_spawn(ExecCommand *command,
 
                 /* child */
 
-                /* We reset exactly these two signals, since they are
-                 * the only ones we set to SIG_IGN in the main
-                 * daemon. All others */
-                default_signals(SIGNALS_CRASH_HANLDER,
+                /* We reset exactly these signals, since they are the
+                 * only ones we set to SIG_IGN in the main daemon. All
+                 * others we leave untouched because we set them to
+                 * SIG_DFL or a valid handler initially, both of which
+                 * will be demoted to SIG_DFL. */
+                default_signals(SIGNALS_CRASH_HANDLER,
                                 SIGNALS_IGNORE, -1);
 
                 if (sigemptyset(&ss) < 0 ||
diff --git a/src/execute.h b/src/execute.h
index 045d462..4585fe4 100644
--- a/src/execute.h
+++ b/src/execute.h
@@ -42,7 +42,7 @@ struct CGroupBonding;
 #define LOGGER_SOCKET "/org/freedesktop/systemd1/logger"
 
 /* This doesn't really belong here, but I couldn't find a better place to put this. */
-#define SIGNALS_CRASH_HANLDER SIGSEGV,SIGILL,SIGFPE,SIGBUS,SIGQUIT,SIGABRT
+#define SIGNALS_CRASH_HANDLER SIGSEGV,SIGILL,SIGFPE,SIGBUS,SIGQUIT,SIGABRT
 #define SIGNALS_IGNORE SIGKILL,SIGPIPE
 
 typedef enum ExecInput {
diff --git a/src/main.c b/src/main.c
index 5c2af04..3b9719f 100644
--- a/src/main.c
+++ b/src/main.c
@@ -165,7 +165,7 @@ static void install_crash_handler(void) {
         sa.sa_handler = crash;
         sa.sa_flags = SA_NODEFER;
 
-        sigaction_many(&sa, SIGNALS_CRASH_HANLDER, -1);
+        sigaction_many(&sa, SIGNALS_CRASH_HANDLER, -1);
 }
 
 static int make_null_stdio(void) {
commit 7535cc788e37afaf9904d0ee8e2b98f1cb3a4cbd
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sat May 22 04:27:24 2010 +0200

    systemctl: add --block switch for synchronous starting of units

diff --git a/fixme b/fixme
index 513c32b..0585d1d 100644
--- a/fixme
+++ b/fixme
@@ -56,11 +56,6 @@
 
 * teach dbus to talk to systemd when autospawning services
 
-* Figure out which signal handlers we actually have to reset in the
-  forked off child
-
-* Add code to systemctl to wait for an operation to finish
-
 Regularly:
 
 * look for close() vs. close_nointr() vs. close_nointr_nofail()
diff --git a/src/dbus-job.c b/src/dbus-job.c
index 3a6e715..34e64fc 100644
--- a/src/dbus-job.c
+++ b/src/dbus-job.c
@@ -197,15 +197,19 @@ oom:
         log_error("Failed to allocate job change signal.");
 }
 
-void bus_job_send_removed_signal(Job *j) {
+void bus_job_send_removed_signal(Job *j, bool success) {
         char *p = NULL;
         DBusMessage *m = NULL;
+        dbus_bool_t b = success;
 
         assert(j);
 
-        if (set_isempty(j->manager->subscribed) || !j->sent_dbus_new_signal)
+        if (set_isempty(j->manager->subscribed))
                 return;
 
+        if (!j->sent_dbus_new_signal)
+                bus_job_send_change_signal(j);
+
         if (!(p = job_dbus_path(j)))
                 goto oom;
 
@@ -215,6 +219,7 @@ void bus_job_send_removed_signal(Job *j) {
         if (!dbus_message_append_args(m,
                                       DBUS_TYPE_UINT32, &j->id,
                                       DBUS_TYPE_OBJECT_PATH, &p,
+                                      DBUS_TYPE_BOOLEAN, &b,
                                       DBUS_TYPE_INVALID))
                 goto oom;
 
diff --git a/src/dbus-job.h b/src/dbus-job.h
index cf91760..4602358 100644
--- a/src/dbus-job.h
+++ b/src/dbus-job.h
@@ -25,7 +25,7 @@
 #include <dbus/dbus.h>
 
 void bus_job_send_change_signal(Job *j);
-void bus_job_send_removed_signal(Job *j);
+void bus_job_send_removed_signal(Job *j, bool success);
 
 extern const DBusObjectPathVTable bus_job_vtable;
 
diff --git a/src/dbus-manager.c b/src/dbus-manager.c
index 90ab8d1..9833b6c 100644
--- a/src/dbus-manager.c
+++ b/src/dbus-manager.c
@@ -81,6 +81,7 @@
         "  <signal name=\"JobRemoved\">"                                \
         "   <arg name=\"id\" type=\"u\"/>"                              \
         "   <arg name=\"job\" type=\"o\"/>"                             \
+        "   <arg name=\"success\" type=\"b\"/>"                         \
         "  </signal>"                                                   \
         "  <property name=\"Version\" type=\"s\" access=\"read\"/>"     \
         "  <property name=\"RunningAs\" type=\"s\" access=\"read\"/>"   \
diff --git a/src/dbus-unit.c b/src/dbus-unit.c
index 5c474c0..ba428a8 100644
--- a/src/dbus-unit.c
+++ b/src/dbus-unit.c
@@ -421,9 +421,12 @@ void bus_unit_send_removed_signal(Unit *u) {
 
         assert(u);
 
-        if (set_isempty(u->meta.manager->subscribed) || !u->meta.sent_dbus_new_signal)
+        if (set_isempty(u->meta.manager->subscribed))
                 return;
 
+        if (!u->meta.sent_dbus_new_signal)
+                bus_unit_send_change_signal(u);
+
         if (!(p = unit_dbus_path(u)))
                 goto oom;
 
diff --git a/src/job.c b/src/job.c
index 9937ed7..78fe136 100644
--- a/src/job.c
+++ b/src/job.c
@@ -56,7 +56,7 @@ void job_free(Job *j) {
 
         /* Detach from next 'bigger' objects */
         if (j->installed) {
-                bus_job_send_removed_signal(j);
+                bus_job_send_removed_signal(j, !j->failed);
 
                 if (j->unit->meta.job == j) {
                         j->unit->meta.job = NULL;
@@ -476,6 +476,7 @@ int job_finish_and_invalidate(Job *j, bool success) {
                 return 0;
         }
 
+        j->failed = !success;
         u = j->unit;
         t = j->type;
         job_free(j);
diff --git a/src/job.h b/src/job.h
index 1ae97b7..054aa53 100644
--- a/src/job.h
+++ b/src/job.h
@@ -108,6 +108,7 @@ struct Job {
         bool override:1;
         bool in_dbus_queue:1;
         bool sent_dbus_new_signal:1;
+        bool failed:1;
 };
 
 Job* job_new(Manager *m, JobType type, Unit *unit);
diff --git a/src/systemadm.vala b/src/systemadm.vala
index b28759a..9e4a2a2 100644
--- a/src/systemadm.vala
+++ b/src/systemadm.vala
@@ -728,7 +728,7 @@ public class MainWindow : Window {
                 } while (unit_model.iter_next(ref iter));
         }
 
-        public void on_job_removed(uint32 id, ObjectPath path) {
+        public void on_job_removed(uint32 id, ObjectPath path, bool success) {
                 TreeIter iter;
                 if (!(job_model.get_iter_first(out iter)))
                         return;
diff --git a/src/systemctl.vala b/src/systemctl.vala
index 821be5a..e1e8a0c 100644
--- a/src/systemctl.vala
+++ b/src/systemctl.vala
@@ -24,7 +24,11 @@ static string type = null;
 static bool all = false;
 static bool replace = false;
 static bool session = false;
-static Connection bus = null;
+static bool block = false;
+static Connection? bus = null;
+static List<ObjectPath> jobs = null;
+static MainLoop main_loop = null;
+static int exit_code = 0;
 
 public static int job_info_compare(void* key1, void* key2) {
         Manager.JobInfo *j1 = (Manager.JobInfo*) key1;
@@ -44,11 +48,11 @@ public static int unit_info_compare(void* key1, void* key2) {
         return Posix.strcmp(u1->id, u2->id);
 }
 
-public void on_unit_changed(Unit u) {
+public void monitor_on_unit_changed(Unit u) {
         stdout.printf("Unit %s changed.\n", u.id);
 }
 
-public void on_unit_new(string id, ObjectPath path) {
+public void monitor_on_unit_new(string id, ObjectPath path) {
         stdout.printf("Unit %s added.\n", id);
 
         Unit u = bus.get_object(
@@ -56,17 +60,17 @@ public void on_unit_new(string id, ObjectPath path) {
                         path,
                         "org.freedesktop.systemd1.Unit") as Unit;
 
-        u.changed += on_unit_changed;
+        u.changed += monitor_on_unit_changed;
 
         /* FIXME: We leak memory here */
         u.ref();
 }
 
-public void on_job_changed(Job j) {
+public void monitor_on_job_changed(Job j) {
         stdout.printf("Job %u changed.\n", j.id);
 }
 
-public void on_job_new(uint32 id, ObjectPath path) {
+public void monitor_on_job_new(uint32 id, ObjectPath path) {
         stdout.printf("Job %u added.\n", id);
 
         Job j = bus.get_object(
@@ -74,18 +78,34 @@ public void on_job_new(uint32 id, ObjectPath path) {
                         path,
                         "org.freedesktop.systemd1.Job") as Job;
 
-        j.changed += on_job_changed;
+        j.changed += monitor_on_job_changed;
 
         /* FIXME: We leak memory here */
         j.ref();
 }
 
-public void on_unit_removed(string id, ObjectPath path) {
+public void monitor_on_unit_removed(string id, ObjectPath path) {
         stdout.printf("Unit %s removed.\n", id);
 }
 
-public void on_job_removed(uint32 id, ObjectPath path) {
-        stdout.printf("Job %u removed.\n", id);
+public void monitor_on_job_removed(uint32 id, ObjectPath path, bool success) {
+        stdout.printf("Job %u removed (success=%i).\n", id, (int) success);
+}
+
+public void block_on_job_removed(uint32 id, ObjectPath path, bool success) {
+
+        for (unowned List<ObjectPath> i = jobs; i != null; i = i.next)
+                if (i.data == path) {
+                        jobs.remove_link(i);
+                        break;
+                }
+
+        if (jobs == null) {
+                if (!success)
+                        exit_code = 1;
+
+                main_loop.quit();
+        }
 }
 
 static const OptionEntry entries[] = {
@@ -94,11 +114,11 @@ static const OptionEntry entries[] = {
         { "replace", 0,   0,                   OptionArg.NONE,   out replace, "When installing a new job, replace existing conflicting ones", null },
         { "session", 0,   0,                   OptionArg.NONE,   out session, "Connect to session bus", null },
         { "system",  0,   OptionFlags.REVERSE, OptionArg.NONE,   out session, "Connect to system bus", null },
+        { "block",   0,   0,                   OptionArg.NONE,   out block,   "Wait until the operation finished", null },
         { null }
 };
 
 int main (string[] args) {
-
         OptionContext context = new OptionContext("[COMMAND [ARGUMENT...]]");
         context.add_main_entries(entries, null);
         context.set_description(
@@ -226,6 +246,9 @@ int main (string[] args) {
                                 return 1;
                         }
 
+                        if (block)
+                                manager.subscribe();
+
                         for (int i = 2; i < args.length; i++) {
 
                                 ObjectPath p = manager.load_unit(args[i]);
@@ -237,14 +260,19 @@ int main (string[] args) {
 
                                 string mode = replace ? "replace" : "fail";
 
+                                ObjectPath j = null;
+
                                 if (args[1] == "start")
-                                        u.start(mode);
+                                        j = u.start(mode);
                                 else if (args[1] == "stop")
-                                        u.stop(mode);
+                                        j = u.stop(mode);
                                 else if (args[1] == "restart")
-                                        u.restart(mode);
+                                        j = u.restart(mode);
                                 else if (args[1] == "reload")
-                                        u.reload(mode);
+                                        j = u.reload(mode);
+
+                                if (block)
+                                        jobs.append(j);
                         }
 
                 } else if (args[1] == "isolate") {
@@ -261,19 +289,24 @@ int main (string[] args) {
                                         p,
                                         "org.freedesktop.systemd1.Unit") as Unit;
 
-                        u.start("isolate");
+                        ObjectPath j = u.start("isolate");
+
+                        if (block) {
+                                manager.subscribe();
+                                jobs.append(j);
+                        }
 
                 } else if (args[1] == "monitor") {
 
                         manager.subscribe();
 
-                        manager.unit_new += on_unit_new;
-                        manager.unit_removed += on_unit_removed;
-                        manager.job_new += on_job_new;
-                        manager.job_removed += on_job_removed;
+                        manager.unit_new += monitor_on_unit_new;
+                        manager.unit_removed += monitor_on_unit_removed;
+                        manager.job_new += monitor_on_job_new;
+                        manager.job_removed += monitor_on_job_removed;
 
-                        MainLoop l = new MainLoop();
-                        l.run();
+                        main_loop = new MainLoop();
+                        main_loop.run();
 
                 } else if (args[1] == "dump")
                         stdout.puts(manager.dump());
@@ -313,9 +346,17 @@ int main (string[] args) {
                         return 1;
                 }
 
+                if (jobs != null && block) {
+                        manager.job_removed += block_on_job_removed;
+
+                        main_loop = new MainLoop();
+                        main_loop.run();
+                }
+
         } catch (DBus.Error e) {
                 stderr.printf("%s\n".printf(e.message));
+                return 1;
         }
 
-        return 0;
+        return exit_code;
 }
diff --git a/src/systemd-interfaces.vala b/src/systemd-interfaces.vala
index 7282bf3..a8aeb75 100644
--- a/src/systemd-interfaces.vala
+++ b/src/systemd-interfaces.vala
@@ -71,7 +71,7 @@ public interface Manager : DBus.Object {
         public abstract signal void unit_new(string id, ObjectPath path);
         public abstract signal void unit_removed(string id, ObjectPath path);
         public abstract signal void job_new(uint32 id, ObjectPath path);
-        public abstract signal void job_removed(uint32 id, ObjectPath path);
+        public abstract signal void job_removed(uint32 id, ObjectPath path, bool success);
 }
 
 [DBus (name = "org.freedesktop.systemd1.Unit")]


More information about the systemd-commits mailing list