anitazha / rpms / systemd

Forked from rpms/systemd 3 years ago
Clone

Blame SOURCES/0276-udev-do-not-skip-the-execution-of-RUN-when-renaming-.patch

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