[systemd/f17] fix 3 BZs
Michal Schmidt
michich at fedoraproject.org
Thu Jun 14 22:09:37 UTC 2012
commit cc232e9d26a95ea288cd490a76e8dfaaabdfab1e
Author: Michal Schmidt <mschmidt at redhat.com>
Date: Thu Jun 14 23:59:49 2012 +0200
fix 3 BZs
- tmpfiles: correct SELinux context for char devices (#824059)
- systemctl: warn when stopping a triggerable unit (#714525)
- systemctl: clearer error message for missing [Install] (#817033)
...ctl-will-print-warning-when-stopping-unit.patch | 263 +++++++++++++++++
...temctl-style-fixes-for-the-previous-patch.patch | 286 ++++++++++++++++++
0414-systemctl-remove-is_socket_listening.patch | 305 ++++++++++++++++++++
...-fix-iteration-in-check_listening_sockets.patch | 25 ++
...arn-about-all-active-triggers-not-just-so.patch | 62 ++++
...t-name-introduce-unit_dbus_path_from_name.patch | 180 ++++++++++++
...eate-char-devices-with-correct-SELinux-co.patch | 38 +++
...learer-error-message-for-missing-install-.patch | 31 ++
systemd.spec | 15 +-
9 files changed, 1204 insertions(+), 1 deletions(-)
---
diff --git a/0412-systemctl-will-print-warning-when-stopping-unit.patch b/0412-systemctl-will-print-warning-when-stopping-unit.patch
new file mode 100644
index 0000000..9d05109
--- /dev/null
+++ b/0412-systemctl-will-print-warning-when-stopping-unit.patch
@@ -0,0 +1,263 @@
+From c45e0321f16a6d13ab510d1594c2a90639dcb96a Mon Sep 17 00:00:00 2001
+From: Michal Sekletar <msekleta at redhat.com>
+Date: Wed, 13 Jun 2012 14:14:13 +0200
+Subject: [PATCH] systemctl will print warning when stopping unit
+
+systemctl now prints warning and list of sockets in listenning state which can
+trigger start of service which is about to be stopped
+(cherry picked from commit 701cdcb9ee846b3d1629b55a11c61a3343af4874)
+---
+ src/systemctl/systemctl.c | 233 +++++++++++++++++++++++++++++++++++++++++++++
+ 1 file changed, 233 insertions(+)
+
+diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
+index ed3dbab..a38d799 100644
+--- a/src/systemctl/systemctl.c
++++ b/src/systemctl/systemctl.c
+@@ -1480,6 +1480,234 @@ finish:
+ return r;
+ }
+
++static int get_unit_path(
++ DBusConnection *bus,
++ DBusError *error,
++ const char *name,
++ char **unit_path) {
++
++ DBusMessage *m = NULL, *reply = NULL;
++ int r = 0;
++
++ assert(bus);
++ assert(error);
++ assert(name);
++ assert(unit_path);
++
++ *unit_path = NULL;
++
++
++ m = dbus_message_new_method_call("org.freedesktop.systemd1",
++ "/org/freedesktop/systemd1",
++ "org.freedesktop.systemd1.Manager",
++ "GetUnit");
++ if (!m) {
++ log_error("Could not allocate message.");
++ r = -ENOMEM;
++ goto finish;
++ }
++
++ if (!dbus_message_append_args(m,
++ DBUS_TYPE_STRING, &name,
++ DBUS_TYPE_INVALID)) {
++ log_error("Could not append arguments to message.");
++ r = -ENOMEM;
++ goto finish;
++ }
++
++ reply = dbus_connection_send_with_reply_and_block(bus, m, -1, error);
++ if (!reply) {
++ if (streq(error->name, BUS_ERROR_NO_SUCH_UNIT)) {
++ dbus_error_free(error);
++ r = -EINVAL;
++ } else {
++ log_error("Failed to issue method call: %s", bus_error_message(error));
++ r = -EIO;
++ }
++ goto finish;
++ }
++
++ if (!dbus_message_get_args(reply, error,
++ DBUS_TYPE_OBJECT_PATH, unit_path,
++ DBUS_TYPE_INVALID)) {
++ log_error("Failed to parse reply: %s", bus_error_message(error));
++ r = -EIO;
++ goto finish;
++ }
++
++ *unit_path = strdup(*unit_path);
++ if (!(*unit_path)) {
++ log_error("Failed to duplicate unit path");
++ r = -ENOMEM;
++ }
++finish:
++ if (m)
++ dbus_message_unref(m);
++ if (reply)
++ dbus_message_unref(reply);
++ return r;
++}
++
++static int is_socket_listening(
++ DBusConnection *bus,
++ DBusError *error,
++ const char *socket_name) {
++
++ DBusMessage *m = NULL, *reply = NULL;
++ DBusMessageIter iter, sub;
++ char *socket_object_path = NULL;
++ const char *sub_state = NULL,
++ *interface = "org.freedesktop.systemd1.Unit",
++ *property = "SubState";
++ int r = 0;
++
++ assert(bus);
++ assert(error);
++ assert(socket_name);
++
++ if ((r = get_unit_path(bus, error, socket_name, &socket_object_path)) < 0) {
++ goto finish;
++ }
++ m = dbus_message_new_method_call("org.freedesktop.systemd1",
++ socket_object_path,
++ "org.freedesktop.DBus.Properties",
++ "Get");
++ if (!m) {
++ log_error("Could not allocate message.");
++ r = -ENOMEM;
++ goto finish;
++ }
++
++ if (!dbus_message_append_args(m,
++ DBUS_TYPE_STRING, &interface,
++ DBUS_TYPE_STRING, &property,
++ DBUS_TYPE_INVALID)) {
++ log_error("Could not append arguments to message.");
++ r = -ENOMEM;
++ goto finish;
++ }
++
++ reply = dbus_connection_send_with_reply_and_block(bus, m, -1, error);
++ if (!reply) {
++ log_error("Failed to issue method call: %s", bus_error_message(error));
++ r = -EIO;
++ goto finish;
++ }
++
++ dbus_message_iter_init(reply, &iter);
++ dbus_message_iter_recurse(&iter, &sub);
++
++ if (dbus_message_iter_get_arg_type(&sub) != DBUS_TYPE_STRING) {
++ log_error("Failed to parse reply: %s", bus_error_message(error));
++ r = -EIO;
++ goto finish;
++ }
++ dbus_message_iter_get_basic(&sub, &sub_state);
++ r = streq(sub_state, "listening");
++finish:
++ if (m)
++ dbus_message_unref(m);
++
++ if (reply)
++ dbus_message_unref(reply);
++
++ free(socket_object_path);
++ return r;
++}
++
++static void check_listening_sockets(
++ DBusConnection *bus,
++ DBusError *error,
++ const char *unit_name) {
++
++ DBusMessage *m = NULL, *reply = NULL;
++ DBusMessageIter iter, sub;
++ const char *service_trigger = NULL,
++ *interface = "org.freedesktop.systemd1.Unit",
++ *triggered_by_property = "TriggeredBy";
++
++ char *unit_path = NULL;
++ int print_warning_label = 1;
++
++ if ((get_unit_path(bus, error, unit_name, &unit_path) < 0)) {
++ goto finish;
++ }
++
++ m = dbus_message_new_method_call("org.freedesktop.systemd1",
++ unit_path,
++ "org.freedesktop.DBus.Properties",
++ "Get");
++ if (!m) {
++ log_error("Could not allocate message.");
++ goto finish;
++ }
++
++ if (!dbus_message_append_args(m,
++ DBUS_TYPE_STRING, &interface,
++ DBUS_TYPE_STRING, &triggered_by_property,
++ DBUS_TYPE_INVALID)) {
++ log_error("Could not append arguments to message.");
++ goto finish;
++ }
++
++ reply = dbus_connection_send_with_reply_and_block(bus, m, -1, error);
++ if (!reply) {
++ log_error("Failed to issue method call: %s", bus_error_message(error));
++ goto finish;
++ }
++
++ if (!dbus_message_iter_init(reply, &iter) ||
++ dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_VARIANT) {
++ log_error("Failed to parse reply: %s", bus_error_message(error));
++ goto finish;
++
++ }
++
++ dbus_message_iter_recurse(&iter, &sub);
++ dbus_message_iter_recurse(&sub, &iter);
++ sub = iter;
++
++ while (dbus_message_iter_get_arg_type(&sub) != DBUS_TYPE_INVALID) {
++ int r = 0;
++
++ if (dbus_message_iter_get_arg_type(&sub) != DBUS_TYPE_STRING) {
++ log_error("Failed to parse reply: %s", bus_error_message(error));
++ goto finish;
++ }
++
++ dbus_message_iter_get_basic(&sub, &service_trigger);
++
++ if (endswith(service_trigger, ".socket")) {
++ r = is_socket_listening(bus, error, service_trigger);
++ } else {
++ dbus_message_iter_recurse(&iter, &sub);
++ iter = sub;
++ continue;
++ }
++
++ if (r == 1) {
++ if (print_warning_label) {
++ log_warning("There are listening sockets associated with %s :", unit_name);
++ print_warning_label = 0;
++ }
++ log_warning("%s",service_trigger);
++ } else if (r < 0) {
++ log_error("Failed to issue function call: %s", bus_error_message(error));
++ goto finish;
++ }
++ dbus_message_iter_recurse(&iter, &sub);
++ iter = sub;
++ }
++finish:
++ if (m)
++ dbus_message_unref(m);
++
++ if (reply)
++ dbus_message_unref(reply);
++
++ free(unit_path);
++}
++
+ static int start_unit_one(
+ DBusConnection *bus,
+ const char *method,
+@@ -1560,6 +1788,11 @@ static int start_unit_one(
+ }
+ }
+
++ /* When stopping unit check if we have some listening sockets active */
++ if (streq(method, "StopUnit") && !arg_quiet) {
++ check_listening_sockets(bus, error, name);
++ }
++
+ r = 0;
+
+ finish:
diff --git a/0413-systemctl-style-fixes-for-the-previous-patch.patch b/0413-systemctl-style-fixes-for-the-previous-patch.patch
new file mode 100644
index 0000000..aebdd88
--- /dev/null
+++ b/0413-systemctl-style-fixes-for-the-previous-patch.patch
@@ -0,0 +1,286 @@
+From 82cdde0db9a470c2c129e4377bc45ccda349b535 Mon Sep 17 00:00:00 2001
+From: Michal Schmidt <mschmidt at redhat.com>
+Date: Wed, 13 Jun 2012 15:52:27 +0200
+Subject: [PATCH] systemctl: style fixes for the previous patch
+
+Use the usual indentation, bracketing style, and no assignments in ifs.
+Since check_listening_sockets provides just optional hints for the user,
+don't pass its DBusErrors to the caller.
+(cherry picked from commit e61a3135e99f349af949520e85d06e7fab4b5d9e)
+---
+ src/systemctl/systemctl.c | 111 +++++++++++++++++++++++----------------------
+ 1 file changed, 57 insertions(+), 54 deletions(-)
+
+diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
+index a38d799..2e3cc11 100644
+--- a/src/systemctl/systemctl.c
++++ b/src/systemctl/systemctl.c
+@@ -1482,20 +1482,19 @@ finish:
+
+ static int get_unit_path(
+ DBusConnection *bus,
+- DBusError *error,
+ const char *name,
+ char **unit_path) {
+
++ DBusError error;
+ DBusMessage *m = NULL, *reply = NULL;
++ char *path;
+ int r = 0;
+
+ assert(bus);
+- assert(error);
+ assert(name);
+ assert(unit_path);
+
+- *unit_path = NULL;
+-
++ dbus_error_init(&error);
+
+ m = dbus_message_new_method_call("org.freedesktop.systemd1",
+ "/org/freedesktop/systemd1",
+@@ -1508,34 +1507,33 @@ static int get_unit_path(
+ }
+
+ if (!dbus_message_append_args(m,
+- DBUS_TYPE_STRING, &name,
+- DBUS_TYPE_INVALID)) {
++ DBUS_TYPE_STRING, &name,
++ DBUS_TYPE_INVALID)) {
+ log_error("Could not append arguments to message.");
+ r = -ENOMEM;
+ goto finish;
+ }
+
+- reply = dbus_connection_send_with_reply_and_block(bus, m, -1, error);
++ reply = dbus_connection_send_with_reply_and_block(bus, m, -1, &error);
+ if (!reply) {
+- if (streq(error->name, BUS_ERROR_NO_SUCH_UNIT)) {
+- dbus_error_free(error);
++ if (streq(error.name, BUS_ERROR_NO_SUCH_UNIT))
+ r = -EINVAL;
+- } else {
+- log_error("Failed to issue method call: %s", bus_error_message(error));
++ else {
++ log_error("Failed to issue method call: %s", bus_error_message(&error));
+ r = -EIO;
+ }
+ goto finish;
+ }
+
+- if (!dbus_message_get_args(reply, error,
+- DBUS_TYPE_OBJECT_PATH, unit_path,
+- DBUS_TYPE_INVALID)) {
+- log_error("Failed to parse reply: %s", bus_error_message(error));
++ if (!dbus_message_get_args(reply, &error,
++ DBUS_TYPE_OBJECT_PATH, &path,
++ DBUS_TYPE_INVALID)) {
++ log_error("Failed to parse reply: %s", bus_error_message(&error));
+ r = -EIO;
+ goto finish;
+ }
+
+- *unit_path = strdup(*unit_path);
++ *unit_path = strdup(path);
+ if (!(*unit_path)) {
+ log_error("Failed to duplicate unit path");
+ r = -ENOMEM;
+@@ -1545,14 +1543,17 @@ finish:
+ dbus_message_unref(m);
+ if (reply)
+ dbus_message_unref(reply);
++
++ dbus_error_free(&error);
++
+ return r;
+ }
+
+ static int is_socket_listening(
+ DBusConnection *bus,
+- DBusError *error,
+ const char *socket_name) {
+
++ DBusError error;
+ DBusMessage *m = NULL, *reply = NULL;
+ DBusMessageIter iter, sub;
+ char *socket_object_path = NULL;
+@@ -1562,12 +1563,14 @@ static int is_socket_listening(
+ int r = 0;
+
+ assert(bus);
+- assert(error);
+ assert(socket_name);
+
+- if ((r = get_unit_path(bus, error, socket_name, &socket_object_path)) < 0) {
++ dbus_error_init(&error);
++
++ r = get_unit_path(bus, socket_name, &socket_object_path);
++ if (r < 0)
+ goto finish;
+- }
++
+ m = dbus_message_new_method_call("org.freedesktop.systemd1",
+ socket_object_path,
+ "org.freedesktop.DBus.Properties",
+@@ -1579,17 +1582,17 @@ static int is_socket_listening(
+ }
+
+ if (!dbus_message_append_args(m,
+- DBUS_TYPE_STRING, &interface,
+- DBUS_TYPE_STRING, &property,
+- DBUS_TYPE_INVALID)) {
++ DBUS_TYPE_STRING, &interface,
++ DBUS_TYPE_STRING, &property,
++ DBUS_TYPE_INVALID)) {
+ log_error("Could not append arguments to message.");
+ r = -ENOMEM;
+ goto finish;
+ }
+
+- reply = dbus_connection_send_with_reply_and_block(bus, m, -1, error);
++ reply = dbus_connection_send_with_reply_and_block(bus, m, -1, &error);
+ if (!reply) {
+- log_error("Failed to issue method call: %s", bus_error_message(error));
++ log_error("Failed to issue method call: %s", bus_error_message(&error));
+ r = -EIO;
+ goto finish;
+ }
+@@ -1598,7 +1601,7 @@ static int is_socket_listening(
+ dbus_message_iter_recurse(&iter, &sub);
+
+ if (dbus_message_iter_get_arg_type(&sub) != DBUS_TYPE_STRING) {
+- log_error("Failed to parse reply: %s", bus_error_message(error));
++ log_error("Failed to parse reply: %s", bus_error_message(&error));
+ r = -EIO;
+ goto finish;
+ }
+@@ -1611,15 +1614,17 @@ finish:
+ if (reply)
+ dbus_message_unref(reply);
+
++ dbus_error_free(&error);
++
+ free(socket_object_path);
+ return r;
+ }
+
+ static void check_listening_sockets(
+ DBusConnection *bus,
+- DBusError *error,
+ const char *unit_name) {
+
++ DBusError error;
+ DBusMessage *m = NULL, *reply = NULL;
+ DBusMessageIter iter, sub;
+ const char *service_trigger = NULL,
+@@ -1627,11 +1632,12 @@ static void check_listening_sockets(
+ *triggered_by_property = "TriggeredBy";
+
+ char *unit_path = NULL;
+- int print_warning_label = 1;
++ bool print_warning_label = true;
++
++ dbus_error_init(&error);
+
+- if ((get_unit_path(bus, error, unit_name, &unit_path) < 0)) {
++ if (get_unit_path(bus, unit_name, &unit_path) < 0)
+ goto finish;
+- }
+
+ m = dbus_message_new_method_call("org.freedesktop.systemd1",
+ unit_path,
+@@ -1643,22 +1649,22 @@ static void check_listening_sockets(
+ }
+
+ if (!dbus_message_append_args(m,
+- DBUS_TYPE_STRING, &interface,
+- DBUS_TYPE_STRING, &triggered_by_property,
+- DBUS_TYPE_INVALID)) {
++ DBUS_TYPE_STRING, &interface,
++ DBUS_TYPE_STRING, &triggered_by_property,
++ DBUS_TYPE_INVALID)) {
+ log_error("Could not append arguments to message.");
+ goto finish;
+ }
+
+- reply = dbus_connection_send_with_reply_and_block(bus, m, -1, error);
++ reply = dbus_connection_send_with_reply_and_block(bus, m, -1, &error);
+ if (!reply) {
+- log_error("Failed to issue method call: %s", bus_error_message(error));
++ log_error("Failed to issue method call: %s", bus_error_message(&error));
+ goto finish;
+ }
+
+ if (!dbus_message_iter_init(reply, &iter) ||
+- dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_VARIANT) {
+- log_error("Failed to parse reply: %s", bus_error_message(error));
++ dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_VARIANT) {
++ log_error("Failed to parse reply: %s", bus_error_message(&error));
+ goto finish;
+
+ }
+@@ -1668,33 +1674,29 @@ static void check_listening_sockets(
+ sub = iter;
+
+ while (dbus_message_iter_get_arg_type(&sub) != DBUS_TYPE_INVALID) {
+- int r = 0;
++ int r;
+
+ if (dbus_message_iter_get_arg_type(&sub) != DBUS_TYPE_STRING) {
+- log_error("Failed to parse reply: %s", bus_error_message(error));
++ log_error("Failed to parse reply: %s", bus_error_message(&error));
+ goto finish;
+ }
+
+ dbus_message_iter_get_basic(&sub, &service_trigger);
+
+- if (endswith(service_trigger, ".socket")) {
+- r = is_socket_listening(bus, error, service_trigger);
+- } else {
+- dbus_message_iter_recurse(&iter, &sub);
+- iter = sub;
+- continue;
+- }
++ if (!endswith(service_trigger, ".socket"))
++ goto next;
+
++ r = is_socket_listening(bus, service_trigger);
++ if (r < 0)
++ goto finish;
+ if (r == 1) {
+ if (print_warning_label) {
+ log_warning("There are listening sockets associated with %s :", unit_name);
+- print_warning_label = 0;
++ print_warning_label = false;
+ }
+- log_warning("%s",service_trigger);
+- } else if (r < 0) {
+- log_error("Failed to issue function call: %s", bus_error_message(error));
+- goto finish;
++ log_warning("%s", service_trigger);
+ }
++next:
+ dbus_message_iter_recurse(&iter, &sub);
+ iter = sub;
+ }
+@@ -1705,6 +1707,8 @@ finish:
+ if (reply)
+ dbus_message_unref(reply);
+
++ dbus_error_free(&error);
++
+ free(unit_path);
+ }
+
+@@ -1789,9 +1793,8 @@ static int start_unit_one(
+ }
+
+ /* When stopping unit check if we have some listening sockets active */
+- if (streq(method, "StopUnit") && !arg_quiet) {
+- check_listening_sockets(bus, error, name);
+- }
++ if (streq(method, "StopUnit") && !arg_quiet)
++ check_listening_sockets(bus, name);
+
+ r = 0;
+
diff --git a/0414-systemctl-remove-is_socket_listening.patch b/0414-systemctl-remove-is_socket_listening.patch
new file mode 100644
index 0000000..64cbb52
--- /dev/null
+++ b/0414-systemctl-remove-is_socket_listening.patch
@@ -0,0 +1,305 @@
+From 5320b2e6837e014bb6a424963cd58f1e446b49f4 Mon Sep 17 00:00:00 2001
+From: Michal Schmidt <mschmidt at redhat.com>
+Date: Wed, 13 Jun 2012 17:29:11 +0200
+Subject: [PATCH] systemctl: remove is_socket_listening
+
+We can use the functionality of check_unit(). Factor out
+check_one_unit().
+(cherry picked from commit 31be1221a13a13fa1d5e82a44f07e2abfb8344c5)
+---
+ src/systemctl/systemctl.c | 215 ++++++++++++++++-----------------------------
+ 1 file changed, 77 insertions(+), 138 deletions(-)
+
+diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
+index 2e3cc11..9dbcba9 100644
+--- a/src/systemctl/systemctl.c
++++ b/src/systemctl/systemctl.c
+@@ -1549,32 +1549,64 @@ finish:
+ return r;
+ }
+
+-static int is_socket_listening(
+- DBusConnection *bus,
+- const char *socket_name) {
+-
+- DBusError error;
++static int check_one_unit(DBusConnection *bus, char *name, bool quiet) {
+ DBusMessage *m = NULL, *reply = NULL;
++ DBusError error;
+ DBusMessageIter iter, sub;
+- char *socket_object_path = NULL;
+- const char *sub_state = NULL,
+- *interface = "org.freedesktop.systemd1.Unit",
+- *property = "SubState";
+- int r = 0;
++ const char
++ *interface = "org.freedesktop.systemd1.Unit",
++ *property = "ActiveState";
++ const char *path = NULL;
++ const char *state;
++ int r = 3; /* According to LSB: "program is not running" */
+
+ assert(bus);
+- assert(socket_name);
++ assert(name);
+
+ dbus_error_init(&error);
+
+- r = get_unit_path(bus, socket_name, &socket_object_path);
+- if (r < 0)
++ m = dbus_message_new_method_call(
++ "org.freedesktop.systemd1",
++ "/org/freedesktop/systemd1",
++ "org.freedesktop.systemd1.Manager",
++ "GetUnit");
++ if (!m) {
++ log_error("Could not allocate message.");
++ r = -ENOMEM;
+ goto finish;
++ }
+
+- m = dbus_message_new_method_call("org.freedesktop.systemd1",
+- socket_object_path,
+- "org.freedesktop.DBus.Properties",
+- "Get");
++ if (!dbus_message_append_args(m,
++ DBUS_TYPE_STRING, &name,
++ DBUS_TYPE_INVALID)) {
++ log_error("Could not append arguments to message.");
++ r = -ENOMEM;
++ goto finish;
++ }
++
++ reply = dbus_connection_send_with_reply_and_block(bus, m, -1, &error);
++ if (!reply) {
++ /* Hmm, cannot figure out anything about this unit... */
++ if (!quiet)
++ puts("unknown");
++
++ goto finish;
++ }
++
++ if (!dbus_message_get_args(reply, &error,
++ DBUS_TYPE_OBJECT_PATH, &path,
++ DBUS_TYPE_INVALID)) {
++ log_error("Failed to parse reply: %s", bus_error_message(&error));
++ r = -EIO;
++ goto finish;
++ }
++
++ dbus_message_unref(m);
++ m = dbus_message_new_method_call(
++ "org.freedesktop.systemd1",
++ path,
++ "org.freedesktop.DBus.Properties",
++ "Get");
+ if (!m) {
+ log_error("Could not allocate message.");
+ r = -ENOMEM;
+@@ -1590,6 +1622,7 @@ static int is_socket_listening(
+ goto finish;
+ }
+
++ dbus_message_unref(reply);
+ reply = dbus_connection_send_with_reply_and_block(bus, m, -1, &error);
+ if (!reply) {
+ log_error("Failed to issue method call: %s", bus_error_message(&error));
+@@ -1597,16 +1630,29 @@ static int is_socket_listening(
+ goto finish;
+ }
+
+- dbus_message_iter_init(reply, &iter);
++ if (!dbus_message_iter_init(reply, &iter) ||
++ dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_VARIANT) {
++ log_error("Failed to parse reply.");
++ r = -EIO;
++ goto finish;
++ }
++
+ dbus_message_iter_recurse(&iter, &sub);
+
+- if (dbus_message_iter_get_arg_type(&sub) != DBUS_TYPE_STRING) {
+- log_error("Failed to parse reply: %s", bus_error_message(&error));
++ if (dbus_message_iter_get_arg_type(&sub) != DBUS_TYPE_STRING) {
++ log_error("Failed to parse reply.");
+ r = -EIO;
+ goto finish;
+ }
+- dbus_message_iter_get_basic(&sub, &sub_state);
+- r = streq(sub_state, "listening");
++
++ dbus_message_iter_get_basic(&sub, &state);
++
++ if (!quiet)
++ puts(state);
++
++ if (streq(state, "active") || streq(state, "reloading"))
++ r = 0;
++
+ finish:
+ if (m)
+ dbus_message_unref(m);
+@@ -1616,7 +1662,6 @@ finish:
+
+ dbus_error_free(&error);
+
+- free(socket_object_path);
+ return r;
+ }
+
+@@ -1627,8 +1672,8 @@ static void check_listening_sockets(
+ DBusError error;
+ DBusMessage *m = NULL, *reply = NULL;
+ DBusMessageIter iter, sub;
+- const char *service_trigger = NULL,
+- *interface = "org.freedesktop.systemd1.Unit",
++ char *service_trigger = NULL;
++ const char *interface = "org.freedesktop.systemd1.Unit",
+ *triggered_by_property = "TriggeredBy";
+
+ char *unit_path = NULL;
+@@ -1686,10 +1731,10 @@ static void check_listening_sockets(
+ if (!endswith(service_trigger, ".socket"))
+ goto next;
+
+- r = is_socket_listening(bus, service_trigger);
++ r = check_one_unit(bus, service_trigger, true);
+ if (r < 0)
+ goto finish;
+- if (r == 1) {
++ if (r == 0) {
+ if (print_warning_label) {
+ log_warning("There are listening sockets associated with %s :", unit_name);
+ print_warning_label = false;
+@@ -2081,126 +2126,20 @@ static int start_special(DBusConnection *bus, char **args) {
+ }
+
+ static int check_unit(DBusConnection *bus, char **args) {
+- DBusMessage *m = NULL, *reply = NULL;
+- const char
+- *interface = "org.freedesktop.systemd1.Unit",
+- *property = "ActiveState";
+- int r = 3; /* According to LSB: "program is not running" */
+- DBusError error;
+ char **name;
++ int r = 3; /* According to LSB: "program is not running" */
+
+ assert(bus);
+ assert(args);
+
+- dbus_error_init(&error);
+-
+ STRV_FOREACH(name, args+1) {
+- const char *path = NULL;
+- const char *state;
+- DBusMessageIter iter, sub;
+-
+- if (!(m = dbus_message_new_method_call(
+- "org.freedesktop.systemd1",
+- "/org/freedesktop/systemd1",
+- "org.freedesktop.systemd1.Manager",
+- "GetUnit"))) {
+- log_error("Could not allocate message.");
+- r = -ENOMEM;
+- goto finish;
+- }
+-
+- if (!dbus_message_append_args(m,
+- DBUS_TYPE_STRING, name,
+- DBUS_TYPE_INVALID)) {
+- log_error("Could not append arguments to message.");
+- r = -ENOMEM;
+- goto finish;
+- }
+-
+- if (!(reply = dbus_connection_send_with_reply_and_block(bus, m, -1, &error))) {
+-
+- /* Hmm, cannot figure out anything about this unit... */
+- if (!arg_quiet)
+- puts("unknown");
+-
+- dbus_error_free(&error);
+- dbus_message_unref(m);
+- m = NULL;
+- continue;
+- }
+-
+- if (!dbus_message_get_args(reply, &error,
+- DBUS_TYPE_OBJECT_PATH, &path,
+- DBUS_TYPE_INVALID)) {
+- log_error("Failed to parse reply: %s", bus_error_message(&error));
+- r = -EIO;
+- goto finish;
+- }
+-
+- dbus_message_unref(m);
+- if (!(m = dbus_message_new_method_call(
+- "org.freedesktop.systemd1",
+- path,
+- "org.freedesktop.DBus.Properties",
+- "Get"))) {
+- log_error("Could not allocate message.");
+- r = -ENOMEM;
+- goto finish;
+- }
+-
+- if (!dbus_message_append_args(m,
+- DBUS_TYPE_STRING, &interface,
+- DBUS_TYPE_STRING, &property,
+- DBUS_TYPE_INVALID)) {
+- log_error("Could not append arguments to message.");
+- r = -ENOMEM;
+- goto finish;
+- }
+-
+- dbus_message_unref(reply);
+- if (!(reply = dbus_connection_send_with_reply_and_block(bus, m, -1, &error))) {
+- log_error("Failed to issue method call: %s", bus_error_message(&error));
+- r = -EIO;
+- goto finish;
+- }
+-
+- if (!dbus_message_iter_init(reply, &iter) ||
+- dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_VARIANT) {
+- log_error("Failed to parse reply.");
+- r = -EIO;
+- goto finish;
+- }
+-
+- dbus_message_iter_recurse(&iter, &sub);
+-
+- if (dbus_message_iter_get_arg_type(&sub) != DBUS_TYPE_STRING) {
+- log_error("Failed to parse reply.");
+- r = -EIO;
+- goto finish;
+- }
+-
+- dbus_message_iter_get_basic(&sub, &state);
+-
+- if (!arg_quiet)
+- puts(state);
+-
+- if (streq(state, "active") || streq(state, "reloading"))
++ int state = check_one_unit(bus, *name, arg_quiet);
++ if (state < 0)
++ return state;
++ if (state == 0)
+ r = 0;
+-
+- dbus_message_unref(m);
+- dbus_message_unref(reply);
+- m = reply = NULL;
+ }
+
+-finish:
+- if (m)
+- dbus_message_unref(m);
+-
+- if (reply)
+- dbus_message_unref(reply);
+-
+- dbus_error_free(&error);
+-
+ return r;
+ }
+
diff --git a/0415-systemctl-fix-iteration-in-check_listening_sockets.patch b/0415-systemctl-fix-iteration-in-check_listening_sockets.patch
new file mode 100644
index 0000000..153c9aa
--- /dev/null
+++ b/0415-systemctl-fix-iteration-in-check_listening_sockets.patch
@@ -0,0 +1,25 @@
+From 5f938ced62c7ca01607ea89b53564cf7243037a4 Mon Sep 17 00:00:00 2001
+From: Michal Schmidt <mschmidt at redhat.com>
+Date: Wed, 13 Jun 2012 17:47:51 +0200
+Subject: [PATCH] systemctl: fix iteration in check_listening_sockets()
+ (cherry picked from commit
+ 222d0348f97aa132cc24ed3a38f18463e9b0e8c9)
+
+---
+ src/systemctl/systemctl.c | 3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
+index 9dbcba9..92753e9 100644
+--- a/src/systemctl/systemctl.c
++++ b/src/systemctl/systemctl.c
+@@ -1742,8 +1742,7 @@ static void check_listening_sockets(
+ log_warning("%s", service_trigger);
+ }
+ next:
+- dbus_message_iter_recurse(&iter, &sub);
+- iter = sub;
++ dbus_message_iter_next(&sub);
+ }
+ finish:
+ if (m)
diff --git a/0416-systemctl-warn-about-all-active-triggers-not-just-so.patch b/0416-systemctl-warn-about-all-active-triggers-not-just-so.patch
new file mode 100644
index 0000000..93ff26e
--- /dev/null
+++ b/0416-systemctl-warn-about-all-active-triggers-not-just-so.patch
@@ -0,0 +1,62 @@
+From ac4548ac765bdfa8741ae9de10fa6ba263cc1f10 Mon Sep 17 00:00:00 2001
+From: Michal Schmidt <mschmidt at redhat.com>
+Date: Wed, 13 Jun 2012 18:27:41 +0200
+Subject: [PATCH] systemctl: warn about all active triggers, not just sockets
+ (cherry picked from commit
+ 1c291cf34cb22c8ca5ec0db122bd5e8bfabe9ac5)
+
+---
+ src/systemctl/systemctl.c | 18 ++++++++----------
+ 1 file changed, 8 insertions(+), 10 deletions(-)
+
+diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
+index 92753e9..7426647 100644
+--- a/src/systemctl/systemctl.c
++++ b/src/systemctl/systemctl.c
+@@ -1665,7 +1665,7 @@ finish:
+ return r;
+ }
+
+-static void check_listening_sockets(
++static void check_triggering_units(
+ DBusConnection *bus,
+ const char *unit_name) {
+
+@@ -1728,20 +1728,17 @@ static void check_listening_sockets(
+
+ dbus_message_iter_get_basic(&sub, &service_trigger);
+
+- if (!endswith(service_trigger, ".socket"))
+- goto next;
+-
+ r = check_one_unit(bus, service_trigger, true);
+ if (r < 0)
+ goto finish;
+ if (r == 0) {
+ if (print_warning_label) {
+- log_warning("There are listening sockets associated with %s :", unit_name);
++ log_warning("Warning: Stopping %s, but it can still be activated by:", unit_name);
+ print_warning_label = false;
+ }
+- log_warning("%s", service_trigger);
++ log_warning(" %s", service_trigger);
+ }
+-next:
++
+ dbus_message_iter_next(&sub);
+ }
+ finish:
+@@ -1836,9 +1833,10 @@ static int start_unit_one(
+ }
+ }
+
+- /* When stopping unit check if we have some listening sockets active */
+- if (streq(method, "StopUnit") && !arg_quiet)
+- check_listening_sockets(bus, name);
++ /* When stopping a unit warn if it can still be triggered by
++ * another active unit (socket, path, timer) */
++ if (!arg_quiet && streq(method, "StopUnit"))
++ check_triggering_units(bus, name);
+
+ r = 0;
+
diff --git a/0417-unit-name-introduce-unit_dbus_path_from_name.patch b/0417-unit-name-introduce-unit_dbus_path_from_name.patch
new file mode 100644
index 0000000..47d85db
--- /dev/null
+++ b/0417-unit-name-introduce-unit_dbus_path_from_name.patch
@@ -0,0 +1,180 @@
+From ca021b4c51c42a324124a5c99c94a95a4103feaa Mon Sep 17 00:00:00 2001
+From: Michal Schmidt <mschmidt at redhat.com>
+Date: Wed, 13 Jun 2012 18:22:08 +0200
+Subject: [PATCH] unit-name: introduce unit_dbus_path_from_name()
+
+Use the same function in core and in systemctl.
+get_unit_path() in systemctl becomes unnecessary.
+(cherry picked from commit 48899192a7b28b6a338cc8ec18aa35ccd8867acb)
+---
+ src/core/unit.c | 10 +-----
+ src/shared/unit-name.c | 13 ++++++++
+ src/shared/unit-name.h | 2 ++
+ src/systemctl/systemctl.c | 81 +++------------------------------------------
+ 4 files changed, 21 insertions(+), 85 deletions(-)
+
+diff --git a/src/core/unit.c b/src/core/unit.c
+index 15e86e9..b52ed42 100644
+--- a/src/core/unit.c
++++ b/src/core/unit.c
+@@ -1831,20 +1831,12 @@ int set_unit_path(const char *p) {
+ }
+
+ char *unit_dbus_path(Unit *u) {
+- char *p, *e;
+-
+ assert(u);
+
+ if (!u->id)
+ return NULL;
+
+- if (!(e = bus_path_escape(u->id)))
+- return NULL;
+-
+- p = strappend("/org/freedesktop/systemd1/unit/", e);
+- free(e);
+-
+- return p;
++ return unit_dbus_path_from_name(u->id);
+ }
+
+ int unit_add_cgroup(Unit *u, CGroupBonding *b) {
+diff --git a/src/shared/unit-name.c b/src/shared/unit-name.c
+index b74ab29..cbc9fc5 100644
+--- a/src/shared/unit-name.c
++++ b/src/shared/unit-name.c
+@@ -458,3 +458,16 @@ char *unit_name_path_unescape(const char *f) {
+
+ return e;
+ }
++
++char *unit_dbus_path_from_name(const char *name) {
++ char *e, *p;
++
++ e = bus_path_escape(name);
++ if (!e)
++ return NULL;
++
++ p = strappend("/org/freedesktop/systemd1/unit/", e);
++ free(e);
++
++ return p;
++}
+diff --git a/src/shared/unit-name.h b/src/shared/unit-name.h
+index e369910..116da11 100644
+--- a/src/shared/unit-name.h
++++ b/src/shared/unit-name.h
+@@ -54,4 +54,6 @@ char *unit_name_from_path(const char *path, const char *suffix);
+ char *unit_name_from_path_instance(const char *prefix, const char *path, const char *suffix);
+ char *unit_name_to_path(const char *name);
+
++char *unit_dbus_path_from_name(const char *name);
++
+ #endif
+diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
+index 7426647..a3c3141 100644
+--- a/src/systemctl/systemctl.c
++++ b/src/systemctl/systemctl.c
+@@ -1480,75 +1480,6 @@ finish:
+ return r;
+ }
+
+-static int get_unit_path(
+- DBusConnection *bus,
+- const char *name,
+- char **unit_path) {
+-
+- DBusError error;
+- DBusMessage *m = NULL, *reply = NULL;
+- char *path;
+- int r = 0;
+-
+- assert(bus);
+- assert(name);
+- assert(unit_path);
+-
+- dbus_error_init(&error);
+-
+- m = dbus_message_new_method_call("org.freedesktop.systemd1",
+- "/org/freedesktop/systemd1",
+- "org.freedesktop.systemd1.Manager",
+- "GetUnit");
+- if (!m) {
+- log_error("Could not allocate message.");
+- r = -ENOMEM;
+- goto finish;
+- }
+-
+- if (!dbus_message_append_args(m,
+- DBUS_TYPE_STRING, &name,
+- DBUS_TYPE_INVALID)) {
+- log_error("Could not append arguments to message.");
+- r = -ENOMEM;
+- goto finish;
+- }
+-
+- reply = dbus_connection_send_with_reply_and_block(bus, m, -1, &error);
+- if (!reply) {
+- if (streq(error.name, BUS_ERROR_NO_SUCH_UNIT))
+- r = -EINVAL;
+- else {
+- log_error("Failed to issue method call: %s", bus_error_message(&error));
+- r = -EIO;
+- }
+- goto finish;
+- }
+-
+- if (!dbus_message_get_args(reply, &error,
+- DBUS_TYPE_OBJECT_PATH, &path,
+- DBUS_TYPE_INVALID)) {
+- log_error("Failed to parse reply: %s", bus_error_message(&error));
+- r = -EIO;
+- goto finish;
+- }
+-
+- *unit_path = strdup(path);
+- if (!(*unit_path)) {
+- log_error("Failed to duplicate unit path");
+- r = -ENOMEM;
+- }
+-finish:
+- if (m)
+- dbus_message_unref(m);
+- if (reply)
+- dbus_message_unref(reply);
+-
+- dbus_error_free(&error);
+-
+- return r;
+-}
+-
+ static int check_one_unit(DBusConnection *bus, char *name, bool quiet) {
+ DBusMessage *m = NULL, *reply = NULL;
+ DBusError error;
+@@ -1681,8 +1612,11 @@ static void check_triggering_units(
+
+ dbus_error_init(&error);
+
+- if (get_unit_path(bus, unit_name, &unit_path) < 0)
++ unit_path = unit_dbus_path_from_name(unit_name);
++ if (!unit_path) {
++ log_error("Could not allocate dbus path.");
+ goto finish;
++ }
+
+ m = dbus_message_new_method_call("org.freedesktop.systemd1",
+ unit_path,
+@@ -3301,12 +3235,7 @@ static int show(DBusConnection *bus, char **args) {
+
+ /* Interpret as unit name */
+
+- char *e, *p;
+- e = bus_path_escape(*name);
+- if (!e)
+- return -ENOMEM;
+- p = strappend("/org/freedesktop/systemd1/unit/", e);
+- free(e);
++ char *p = unit_dbus_path_from_name(*name);
+ if (!p)
+ return -ENOMEM;
+
diff --git a/0418-tmpfiles-create-char-devices-with-correct-SELinux-co.patch b/0418-tmpfiles-create-char-devices-with-correct-SELinux-co.patch
new file mode 100644
index 0000000..790fb5e
--- /dev/null
+++ b/0418-tmpfiles-create-char-devices-with-correct-SELinux-co.patch
@@ -0,0 +1,38 @@
+From 91ddddcc97fc5e3bf3702a55531a9a2c91232954 Mon Sep 17 00:00:00 2001
+From: Michal Schmidt <mschmidt at redhat.com>
+Date: Thu, 14 Jun 2012 16:01:19 +0200
+Subject: [PATCH] tmpfiles: create char devices with correct SELinux context
+
+https://bugzilla.redhat.com/show_bug.cgi?id=824059
+(cherry picked from commit e7aee75932e8a5bee54eefcc77f4702a3ea79db2)
+---
+ src/tmpfiles/tmpfiles.c | 7 ++++---
+ 1 file changed, 4 insertions(+), 3 deletions(-)
+
+diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
+index dd9f159..23b1ef8 100644
+--- a/src/tmpfiles/tmpfiles.c
++++ b/src/tmpfiles/tmpfiles.c
+@@ -744,10 +744,11 @@ static int create_item(Item *i) {
+
+ case CREATE_BLOCK_DEVICE:
+ case CREATE_CHAR_DEVICE: {
++ mode_t file_type = (i->type == CREATE_BLOCK_DEVICE ? S_IFBLK : S_IFCHR);
+
+ u = umask(0);
+- label_context_set(i->path, CREATE_BLOCK_DEVICE ? S_IFBLK : S_IFCHR);
+- r = mknod(i->path, i->mode | (i->type == CREATE_BLOCK_DEVICE ? S_IFBLK : S_IFCHR), i->major_minor);
++ label_context_set(i->path, file_type);
++ r = mknod(i->path, i->mode | file_type, i->major_minor);
+ e = errno;
+ label_context_clear();
+ umask(u);
+@@ -763,7 +764,7 @@ static int create_item(Item *i) {
+ return -errno;
+ }
+
+- if (i->type == CREATE_BLOCK_DEVICE ? !S_ISBLK(st.st_mode) : !S_ISCHR(st.st_mode)) {
++ if ((st.st_mode & S_IFMT) != file_type) {
+ log_error("%s is not a device node.", i->path);
+ return -EEXIST;
+ }
diff --git a/0419-systemctl-clearer-error-message-for-missing-install-.patch b/0419-systemctl-clearer-error-message-for-missing-install-.patch
new file mode 100644
index 0000000..6a8312b
--- /dev/null
+++ b/0419-systemctl-clearer-error-message-for-missing-install-.patch
@@ -0,0 +1,31 @@
+From 496de7bd58f3078086c1008a496dc0d25a0ac6bb Mon Sep 17 00:00:00 2001
+From: Michal Schmidt <mschmidt at redhat.com>
+Date: Thu, 14 Jun 2012 23:16:07 +0200
+Subject: [PATCH] systemctl: clearer error message for missing install
+ information
+
+Some users found it difficult to understand what systemctl was telling
+them.
+Instead of "install information" talk about "[Install] section", which
+is more likely to ring a bell. And suggest that it is intentional, so
+that users do not attempt to "correct" the unit files.
+
+https://bugzilla.redhat.com/show_bug.cgi?id=817033
+(cherry picked from commit 34cdc274edd870ffc27d21cf82655a0114948748)
+---
+ src/systemctl/systemctl.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
+index a3c3141..4d26398 100644
+--- a/src/systemctl/systemctl.c
++++ b/src/systemctl/systemctl.c
+@@ -4205,7 +4205,7 @@ static int enable_unit(DBusConnection *bus, char **args) {
+ }
+
+ if (carries_install_info == 0)
+- log_warning("Warning: unit files do not carry install information. No operation executed.");
++ log_warning("The unit files have no [Install] section. They are not meant to be enabled using systemctl.");
+
+ finish:
+ if (m)
diff --git a/systemd.spec b/systemd.spec
index 214960a..d0198fc 100644
--- a/systemd.spec
+++ b/systemd.spec
@@ -3,7 +3,7 @@
Name: systemd
Url: http://www.freedesktop.org/wiki/Software/systemd
Version: 44
-Release: 13%{?gitcommit:.git%{gitcommit}}%{?dist}
+Release: 14%{?gitcommit:.git%{gitcommit}}%{?dist}
License: GPLv2+
Group: System Environment/Base
Summary: A System and Service Manager
@@ -471,6 +471,14 @@ Patch0408: 0408-logind-fix-check-for-multiple-sessions.patch
Patch0409: 0409-journal-file-fix-mmap-leak.patch
Patch0410: 0410-man-fix-sysytemd-typos.patch
Patch0411: 0411-F17-fix-manpage-name-typo.patch
+Patch0412: 0412-systemctl-will-print-warning-when-stopping-unit.patch
+Patch0413: 0413-systemctl-style-fixes-for-the-previous-patch.patch
+Patch0414: 0414-systemctl-remove-is_socket_listening.patch
+Patch0415: 0415-systemctl-fix-iteration-in-check_listening_sockets.patch
+Patch0416: 0416-systemctl-warn-about-all-active-triggers-not-just-so.patch
+Patch0417: 0417-unit-name-introduce-unit_dbus_path_from_name.patch
+Patch0418: 0418-tmpfiles-create-char-devices-with-correct-SELinux-co.patch
+Patch0419: 0419-systemctl-clearer-error-message-for-missing-install-.patch
# For sysvinit tools
Obsoletes: SysVinit < 2.86-24, sysvinit < 2.86-24
@@ -848,6 +856,11 @@ mv /etc/systemd/system/default.target.save /etc/systemd/system/default.target >/
%{_bindir}/systemd-analyze
%changelog
+* Thu Jun 14 2012 Michal Schmidt <mschmidt at redhat.com> - 44-14
+- tmpfiles: correct SELinux context for char devices (#824059)
+- systemctl: warn when stopping a triggerable unit (#714525)
+- systemctl: clearer error message for missing [Install] (#817033)
+
* Wed Jun 13 2012 Michal Schmidt <mschmidt at redhat.com> - 44-13
- Patches from upstream
- Fixes to journald, logind, tmpfiles
More information about the scm-commits
mailing list