valeriyvdovin / rpms / systemd

Forked from rpms/systemd 4 years ago
Clone

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

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