ryantimwilson / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone
65878a
From 426a65ac5d56264b1890539eff96a1fa1d460217 Mon Sep 17 00:00:00 2001
65878a
From: Kay Sievers <kay@vrfy.org>
65878a
Date: Wed, 14 May 2014 00:34:49 +0200
65878a
Subject: [PATCH] udev: do not skip the execution of RUN when renaming a
65878a
 network device fails
65878a
65878a
(cherry picked from commit 1ea972174baba40dbc80c51cbfc4edc49764b59b)
65878a
65878a
Resolves: #1102135
65878a
---
65878a
 src/test/test-udev.c    |  5 ++---
65878a
 src/udev/udev-event.c   |  9 ++++-----
65878a
 src/udev/udev.h         |  2 +-
65878a
 src/udev/udevadm-test.c | 13 +++++--------
65878a
 src/udev/udevd.c        | 13 ++++++-------
65878a
 5 files changed, 18 insertions(+), 24 deletions(-)
65878a
65878a
diff --git a/src/test/test-udev.c b/src/test/test-udev.c
65878a
index 17825f1..3fcf728 100644
65878a
--- a/src/test/test-udev.c
65878a
+++ b/src/test/test-udev.c
65878a
@@ -156,9 +156,8 @@ int main(int argc, char *argv[])
65878a
                 }
65878a
         }
65878a
 
65878a
-        err = udev_event_execute_rules(event, rules, &sigmask_orig);
65878a
-        if (err == 0)
65878a
-                udev_event_execute_run(event, NULL);
65878a
+        udev_event_execute_rules(event, rules, &sigmask_orig);
65878a
+        udev_event_execute_run(event, NULL);
65878a
 out:
65878a
         if (event != NULL && event->fd_signal >= 0)
65878a
                 close(event->fd_signal);
65878a
diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c
65878a
index 3db2cb7..d69d7ba 100644
65878a
--- a/src/udev/udev-event.c
65878a
+++ b/src/udev/udev-event.c
65878a
@@ -776,13 +776,12 @@ static int rename_netif(struct udev_event *event)
65878a
         return err;
65878a
 }
65878a
 
65878a
-int udev_event_execute_rules(struct udev_event *event, struct udev_rules *rules, const sigset_t *sigmask)
65878a
+void udev_event_execute_rules(struct udev_event *event, struct udev_rules *rules, const sigset_t *sigmask)
65878a
 {
65878a
         struct udev_device *dev = event->dev;
65878a
-        int err = 0;
65878a
 
65878a
         if (udev_device_get_subsystem(dev) == NULL)
65878a
-                return -1;
65878a
+                return;
65878a
 
65878a
         if (streq(udev_device_get_action(dev), "remove")) {
65878a
                 udev_device_read_db(dev, NULL);
65878a
@@ -816,9 +815,10 @@ int udev_event_execute_rules(struct udev_event *event, struct udev_rules *rules,
65878a
                     event->name != NULL && !streq(event->name, udev_device_get_sysname(dev))) {
65878a
                         char syspath[UTIL_PATH_SIZE];
65878a
                         char *pos;
65878a
+                        int err;
65878a
 
65878a
                         err = rename_netif(event);
65878a
-                        if (err == 0) {
65878a
+                        if (err >= 0) {
65878a
                                 log_debug("renamed netif to '%s'\n", event->name);
65878a
 
65878a
                                 /* remember old name */
65878a
@@ -881,7 +881,6 @@ int udev_event_execute_rules(struct udev_event *event, struct udev_rules *rules,
65878a
                 udev_device_unref(event->dev_db);
65878a
                 event->dev_db = NULL;
65878a
         }
65878a
-        return err;
65878a
 }
65878a
 
65878a
 void udev_event_execute_run(struct udev_event *event, const sigset_t *sigmask)
65878a
diff --git a/src/udev/udev.h b/src/udev/udev.h
65878a
index 8395926..900b1d6 100644
65878a
--- a/src/udev/udev.h
65878a
+++ b/src/udev/udev.h
65878a
@@ -83,7 +83,7 @@ int udev_event_apply_subsys_kernel(struct udev_event *event, const char *string,
65878a
 int udev_event_spawn(struct udev_event *event,
65878a
                      const char *cmd, char **envp, const sigset_t *sigmask,
65878a
                      char *result, size_t ressize);
65878a
-int udev_event_execute_rules(struct udev_event *event, struct udev_rules *rules, const sigset_t *sigset);
65878a
+void udev_event_execute_rules(struct udev_event *event, struct udev_rules *rules, const sigset_t *sigset);
65878a
 void udev_event_execute_run(struct udev_event *event, const sigset_t *sigset);
65878a
 int udev_build_argv(struct udev *udev, char *cmd, int *argc, char *argv[]);
65878a
 
65878a
diff --git a/src/udev/udevadm-test.c b/src/udev/udevadm-test.c
65878a
index df1409b..dc292c2 100644
65878a
--- a/src/udev/udevadm-test.c
65878a
+++ b/src/udev/udevadm-test.c
65878a
@@ -42,7 +42,6 @@ static int adm_test(struct udev *udev, int argc, char *argv[])
65878a
         struct udev_rules *rules = NULL;
65878a
         struct udev_list_entry *entry;
65878a
         sigset_t mask, sigmask_orig;
65878a
-        int err;
65878a
         int rc = 0;
65878a
 
65878a
         static const struct option options[] = {
65878a
@@ -141,18 +140,16 @@ static int adm_test(struct udev *udev, int argc, char *argv[])
65878a
                 goto out;
65878a
         }
65878a
 
65878a
-        err = udev_event_execute_rules(event, rules, &sigmask_orig);
65878a
+        udev_event_execute_rules(event, rules, &sigmask_orig);
65878a
 
65878a
         udev_list_entry_foreach(entry, udev_device_get_properties_list_entry(dev))
65878a
                 printf("%s=%s\n", udev_list_entry_get_name(entry), udev_list_entry_get_value(entry));
65878a
 
65878a
-        if (err == 0) {
65878a
-                udev_list_entry_foreach(entry, udev_list_get_entry(&event->run_list)) {
65878a
-                        char program[UTIL_PATH_SIZE];
65878a
+        udev_list_entry_foreach(entry, udev_list_get_entry(&event->run_list)) {
65878a
+                char program[UTIL_PATH_SIZE];
65878a
 
65878a
-                        udev_event_apply_format(event, udev_list_entry_get_name(entry), program, sizeof(program));
65878a
-                        printf("run: '%s'\n", program);
65878a
-                }
65878a
+                udev_event_apply_format(event, udev_list_entry_get_name(entry), program, sizeof(program));
65878a
+                printf("run: '%s'\n", program);
65878a
         }
65878a
 out:
65878a
         if (event != NULL && event->fd_signal >= 0)
65878a
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
65878a
index 7c6c5d6..3d5feb4 100644
65878a
--- a/src/udev/udevd.c
65878a
+++ b/src/udev/udevd.c
65878a
@@ -272,7 +272,7 @@ static void worker_new(struct event *event)
65878a
                 for (;;) {
65878a
                         struct udev_event *udev_event;
65878a
                         struct worker_message msg;
65878a
-                        int err;
65878a
+                        int err = 0;
65878a
 
65878a
                         log_debug("seq %llu running\n", udev_device_get_seqnum(dev));
65878a
                         udev_event = udev_event_new(dev);
65878a
@@ -288,13 +288,12 @@ static void worker_new(struct event *event)
65878a
                                 udev_event->exec_delay = exec_delay;
65878a
 
65878a
                         /* apply rules, create node, symlinks */
65878a
-                        err = udev_event_execute_rules(udev_event, rules, &sigmask_orig);
65878a
+                        udev_event_execute_rules(udev_event, rules, &sigmask_orig);
65878a
 
65878a
-                        if (err == 0)
65878a
-                                udev_event_execute_run(udev_event, &sigmask_orig);
65878a
+                        udev_event_execute_run(udev_event, &sigmask_orig);
65878a
 
65878a
                         /* apply/restore inotify watch */
65878a
-                        if (err == 0 && udev_event->inotify_watch) {
65878a
+                        if (udev_event->inotify_watch) {
65878a
                                 udev_watch_begin(udev, dev);
65878a
                                 udev_device_update_db(dev);
65878a
                         }
65878a
@@ -304,8 +303,8 @@ static void worker_new(struct event *event)
65878a
 
65878a
                         /* send udevd the result of the event execution */
65878a
                         memset(&msg, 0, sizeof(struct worker_message));
65878a
-                        if (err != 0)
65878a
-                                msg.exitcode = err;
65878a
+
65878a
+                        msg.exitcode = err;
65878a
                         msg.pid = getpid();
65878a
                         send(worker_watch[WRITE_END], &msg, sizeof(struct worker_message), 0);
65878a