From 1611bb1e20d0a131793c00c5a0d13083a74cc3037d16327b151494600053c381 Mon Sep 17 00:00:00 2001 From: "Dr. Werner Fink" Date: Wed, 19 Mar 2014 12:11:12 +0000 Subject: [PATCH] . OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd?expand=0&rev=565 --- ...or-don-t-return-OOM-on-parentless-de.patch | 20 + ...emory-leak-when-kdbus-is-not-enabled.patch | 26 ++ ...k-for-a-64bit-value-when-we-only-hav.patch | 181 ++++++++ ...-return-1-EINVAL-on-allocation-error.patch | 35 ++ 0007-networkd-fix-typo.patch | 26 ++ ...ess-invalid-memory-if-a-signal-match.patch | 27 ++ ...ke-if-somebody-sends-us-a-message-wi.patch | 47 ++ ...nstall-_sd_machines-with-_machinectl.patch | 28 ++ ...ve-stray-reset-of-error-return-value.patch | 24 ++ ...systemd-timedate-udev-spelling-fixes.patch | 118 +++++ systemctl-set-default-target.patch | 28 ++ systemd-mini.changes | 28 +- systemd-mini.spec | 30 ++ systemd.changes | 28 +- systemd.spec | 30 ++ udev-generate-peristent-rule.sh | 405 ++++++++++++++++++ 16 files changed, 1079 insertions(+), 2 deletions(-) create mode 100644 0001-gpt-auto-generator-don-t-return-OOM-on-parentless-de.patch create mode 100644 0002-bus-fix-memory-leak-when-kdbus-is-not-enabled.patch create mode 100644 0003-sd-bus-don-t-look-for-a-64bit-value-when-we-only-hav.patch create mode 100644 0006-Do-not-return-1-EINVAL-on-allocation-error.patch create mode 100644 0007-networkd-fix-typo.patch create mode 100644 0008-sd-bus-don-t-access-invalid-memory-if-a-signal-match.patch create mode 100644 0009-sd-bus-don-t-choke-if-somebody-sends-us-a-message-wi.patch create mode 100644 0010-zsh-completion-Install-_sd_machines-with-_machinectl.patch create mode 100644 0012-journald-remove-stray-reset-of-error-return-value.patch create mode 100644 0013-core-libsystemd-systemd-timedate-udev-spelling-fixes.patch create mode 100644 systemctl-set-default-target.patch create mode 100644 udev-generate-peristent-rule.sh diff --git a/0001-gpt-auto-generator-don-t-return-OOM-on-parentless-de.patch b/0001-gpt-auto-generator-don-t-return-OOM-on-parentless-de.patch new file mode 100644 index 00000000..be9add48 --- /dev/null +++ b/0001-gpt-auto-generator-don-t-return-OOM-on-parentless-de.patch @@ -0,0 +1,20 @@ +From 9c4495ca561624c2f0085507dd1288ed5f1247c5 Mon Sep 17 00:00:00 2001 +From: Tomasz Torcz +Date: Wed, 12 Mar 2014 19:25:11 +0100 +Subject: [PATCH] gpt-auto-generator: don't return OOM on parentless devices + +--- + src/gpt-auto-generator/gpt-auto-generator.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- src/gpt-auto-generator/gpt-auto-generator.c ++++ src/gpt-auto-generator/gpt-auto-generator.c 2014-03-18 13:35:11.438235125 +0000 +@@ -254,7 +254,7 @@ static int enumerate_partitions(struct u + + parent = udev_device_get_parent(d); + if (!parent) +- return log_oom(); ++ return 0; + + r = udev_enumerate_add_match_parent(e, parent); + if (r < 0) diff --git a/0002-bus-fix-memory-leak-when-kdbus-is-not-enabled.patch b/0002-bus-fix-memory-leak-when-kdbus-is-not-enabled.patch new file mode 100644 index 00000000..718f6862 --- /dev/null +++ b/0002-bus-fix-memory-leak-when-kdbus-is-not-enabled.patch @@ -0,0 +1,26 @@ +From 82923adfe5c4fa09cc91fd2a2e374c936cd4a186 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Thu, 13 Mar 2014 20:00:50 +0100 +Subject: [PATCH] bus: fix memory leak when kdbus is not enabled + +--- + src/libsystemd/sd-bus/sd-bus.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git src/libsystemd/sd-bus/sd-bus.c src/libsystemd/sd-bus/sd-bus.c +index ffa3369..ca7c428 100644 +--- src/libsystemd/sd-bus/sd-bus.c ++++ src/libsystemd/sd-bus/sd-bus.c +@@ -1189,7 +1189,8 @@ _public_ int sd_bus_open_user(sd_bus **ret) { + #ifdef ENABLE_KDBUS + asprintf(&b->address, KERNEL_USER_BUS_FMT, (unsigned long) getuid()); + #else +- return -ECONNREFUSED; ++ r = -ECONNREFUSED; ++ goto fail; + #endif + } + +-- +1.7.9.2 + diff --git a/0003-sd-bus-don-t-look-for-a-64bit-value-when-we-only-hav.patch b/0003-sd-bus-don-t-look-for-a-64bit-value-when-we-only-hav.patch new file mode 100644 index 00000000..456de40d --- /dev/null +++ b/0003-sd-bus-don-t-look-for-a-64bit-value-when-we-only-hav.patch @@ -0,0 +1,181 @@ +From 42c4ebcbd4cbd7b27667eb8081ee4dc46f9ece17 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Thu, 13 Mar 2014 20:33:22 +0100 +Subject: [PATCH] sd-bus: don't look for a 64bit value when we only have 32bit + value on reply cookie hash table access + +This broke hashtable lookups for the message cookies on s390x, which is +a 64bit BE machine where accessing 32bit values as 64bit and vice versa +will explode. + +Also, while we are at it, be a bit more careful when dealing with the +64bit cookies we expose and the 32bit serial numbers dbus uses in its +payload. + +Problem identified by Fridrich Strba. +--- + src/libsystemd/sd-bus/bus-dump.c | 4 ++-- + src/libsystemd/sd-bus/bus-kernel.c | 2 +- + src/libsystemd/sd-bus/bus-message.c | 15 ++++++++++----- + src/libsystemd/sd-bus/bus-message.h | 5 +++-- + src/libsystemd/sd-bus/sd-bus.c | 12 ++++++------ + 5 files changed, 22 insertions(+), 16 deletions(-) + +diff --git src/libsystemd/sd-bus/bus-dump.c src/libsystemd/sd-bus/bus-dump.c +index 0e41549..ea81644 100644 +--- src/libsystemd/sd-bus/bus-dump.c ++++ src/libsystemd/sd-bus/bus-dump.c +@@ -69,10 +69,10 @@ int bus_message_dump(sd_bus_message *m, FILE *f, bool with_header) { + if (BUS_MESSAGE_COOKIE(m) == 0xFFFFFFFFULL) + fprintf(f, " Cookie=-1"); + else +- fprintf(f, " Cookie=%lu", (unsigned long) BUS_MESSAGE_COOKIE(m)); ++ fprintf(f, " Cookie=%" PRIu64, BUS_MESSAGE_COOKIE(m)); + + if (m->reply_cookie != 0) +- fprintf(f, " ReplyCookie=%lu", (unsigned long) m->reply_cookie); ++ fprintf(f, " ReplyCookie=%" PRIu64, m->reply_cookie); + + fputs("\n", f); + +diff --git src/libsystemd/sd-bus/bus-kernel.c src/libsystemd/sd-bus/bus-kernel.c +index 8a2ca02..80ef15b 100644 +--- src/libsystemd/sd-bus/bus-kernel.c ++++ src/libsystemd/sd-bus/bus-kernel.c +@@ -266,7 +266,7 @@ static int bus_message_setup_kmsg(sd_bus *b, sd_bus_message *m) { + well_known ? 0 : + m->destination ? unique : KDBUS_DST_ID_BROADCAST; + m->kdbus->payload_type = KDBUS_PAYLOAD_DBUS; +- m->kdbus->cookie = m->header->serial; ++ m->kdbus->cookie = (uint64_t) m->header->serial; + m->kdbus->priority = m->priority; + + if (m->header->flags & BUS_MESSAGE_NO_REPLY_EXPECTED) +diff --git src/libsystemd/sd-bus/bus-message.c src/libsystemd/sd-bus/bus-message.c +index fb894ef..97ab0e3 100644 +--- src/libsystemd/sd-bus/bus-message.c ++++ src/libsystemd/sd-bus/bus-message.c +@@ -617,7 +617,7 @@ static int message_new_reply( + t->header->flags |= BUS_MESSAGE_NO_REPLY_EXPECTED; + t->reply_cookie = BUS_MESSAGE_COOKIE(call); + +- r = message_append_field_uint32(t, BUS_MESSAGE_HEADER_REPLY_SERIAL, t->reply_cookie); ++ r = message_append_field_uint32(t, BUS_MESSAGE_HEADER_REPLY_SERIAL, (uint32_t) t->reply_cookie); + if (r < 0) + goto fail; + +@@ -752,7 +752,7 @@ int bus_message_new_synthetic_error( + t->header->flags |= BUS_MESSAGE_NO_REPLY_EXPECTED; + t->reply_cookie = cookie; + +- r = message_append_field_uint32(t, BUS_MESSAGE_HEADER_REPLY_SERIAL, t->reply_cookie); ++ r = message_append_field_uint32(t, BUS_MESSAGE_HEADER_REPLY_SERIAL, (uint32_t) t->reply_cookie); + if (r < 0) + goto fail; + +@@ -5075,21 +5075,26 @@ int bus_message_parse_fields(sd_bus_message *m) { + break; + } + +- case BUS_MESSAGE_HEADER_REPLY_SERIAL: ++ case BUS_MESSAGE_HEADER_REPLY_SERIAL: { ++ uint32_t serial; ++ + if (m->reply_cookie != 0) + return -EBADMSG; + + if (!streq(signature, "u")) + return -EBADMSG; + +- r = message_peek_field_uint32(m, &ri, item_size, &m->reply_cookie); ++ r = message_peek_field_uint32(m, &ri, item_size, &serial); + if (r < 0) + return r; + ++ m->reply_cookie = serial; ++ + if (m->reply_cookie == 0) + return -EBADMSG; + + break; ++ } + + case BUS_MESSAGE_HEADER_UNIX_FDS: + if (unix_fds != 0) +@@ -5489,7 +5494,7 @@ int bus_message_remarshal(sd_bus *bus, sd_bus_message **m) { + return -ENOMEM; + + n->reply_cookie = (*m)->reply_cookie; +- r = message_append_field_uint32(n, BUS_MESSAGE_HEADER_REPLY_SERIAL, n->reply_cookie); ++ r = message_append_field_uint32(n, BUS_MESSAGE_HEADER_REPLY_SERIAL, (uint32_t) n->reply_cookie); + if (r < 0) + return r; + +diff --git src/libsystemd/sd-bus/bus-message.h src/libsystemd/sd-bus/bus-message.h +index 5fbe3e6..df79294 100644 +--- src/libsystemd/sd-bus/bus-message.h ++++ src/libsystemd/sd-bus/bus-message.h +@@ -84,7 +84,7 @@ struct sd_bus_message { + + sd_bus *bus; + +- uint32_t reply_cookie; ++ uint64_t reply_cookie; + + const char *path; + const char *interface; +@@ -162,7 +162,8 @@ static inline uint64_t BUS_MESSAGE_BSWAP64(sd_bus_message *m, uint64_t u) { + return BUS_MESSAGE_NEED_BSWAP(m) ? bswap_64(u) : u; + } + +-static inline uint32_t BUS_MESSAGE_COOKIE(sd_bus_message *m) { ++static inline uint64_t BUS_MESSAGE_COOKIE(sd_bus_message *m) { ++ /* Note that we return the serial converted to a 64bit value here */ + return BUS_MESSAGE_BSWAP32(m, m->header->serial); + } + +diff --git src/libsystemd/sd-bus/sd-bus.c src/libsystemd/sd-bus/sd-bus.c +index ca7c428..8e44e50 100644 +--- src/libsystemd/sd-bus/sd-bus.c ++++ src/libsystemd/sd-bus/sd-bus.c +@@ -1486,15 +1486,15 @@ static int bus_write_message(sd_bus *bus, sd_bus_message *m, bool hint_sync_call + return r; + + if (bus->is_kernel || *idx >= BUS_MESSAGE_SIZE(m)) +- log_debug("Sent message type=%s sender=%s destination=%s object=%s interface=%s member=%s cookie=%lu reply_cookie=%lu error=%s", ++ log_debug("Sent message type=%s sender=%s destination=%s object=%s interface=%s member=%s cookie=%" PRIu64 " reply_cookie=%" PRIu64 " error=%s", + bus_message_type_to_string(m->header->type), + strna(sd_bus_message_get_sender(m)), + strna(sd_bus_message_get_destination(m)), + strna(sd_bus_message_get_path(m)), + strna(sd_bus_message_get_interface(m)), + strna(sd_bus_message_get_member(m)), +- (unsigned long) BUS_MESSAGE_COOKIE(m), +- (unsigned long) m->reply_cookie, ++ BUS_MESSAGE_COOKIE(m), ++ m->reply_cookie, + strna(m->error.message)); + + return r; +@@ -2253,15 +2253,15 @@ static int process_message(sd_bus *bus, sd_bus_message *m) { + bus->current = m; + bus->iteration_counter++; + +- log_debug("Got message type=%s sender=%s destination=%s object=%s interface=%s member=%s cookie=%lu reply_cookie=%lu error=%s", ++ log_debug("Got message type=%s sender=%s destination=%s object=%s interface=%s member=%s cookie=%" PRIu64 " reply_cookie=%" PRIu64 " error=%s", + bus_message_type_to_string(m->header->type), + strna(sd_bus_message_get_sender(m)), + strna(sd_bus_message_get_destination(m)), + strna(sd_bus_message_get_path(m)), + strna(sd_bus_message_get_interface(m)), + strna(sd_bus_message_get_member(m)), +- (unsigned long) BUS_MESSAGE_COOKIE(m), +- (unsigned long) m->reply_cookie, ++ BUS_MESSAGE_COOKIE(m), ++ m->reply_cookie, + strna(m->error.message)); + + r = process_hello(bus, m); +-- +1.7.9.2 + diff --git a/0006-Do-not-return-1-EINVAL-on-allocation-error.patch b/0006-Do-not-return-1-EINVAL-on-allocation-error.patch new file mode 100644 index 00000000..bf1db2c6 --- /dev/null +++ b/0006-Do-not-return-1-EINVAL-on-allocation-error.patch @@ -0,0 +1,35 @@ +From 315db1a8aed226a51a4cf700172249cfd10ae115 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= +Date: Fri, 14 Mar 2014 09:05:56 -0400 +Subject: [PATCH] Do not return -1 (EINVAL) on allocation error + +--- + src/core/socket.c | 8 +++----- + +diff --git src/core/socket.c src/core/socket.c +index 8ecc9f9..b39bec2 100644 +--- src/core/socket.c ++++ src/core/socket.c +@@ -198,16 +198,14 @@ static int socket_instantiate_service(Socket *s) { + + assert(s->accept); + +- if (!(prefix = unit_name_to_prefix(UNIT(s)->id))) ++ prefix = unit_name_to_prefix(UNIT(s)->id); ++ if (!prefix) + return -ENOMEM; + +- r = asprintf(&name, "%s@%u.service", prefix, s->n_accepted); +- +- if (r < 0) ++ if (asprintf(&name, "%s@%u.service", prefix, s->n_accepted) < 0) + return -ENOMEM; + + r = manager_load_unit(UNIT(s)->manager, name, NULL, NULL, &u); +- + if (r < 0) + return r; + +-- +1.7.9.2 + diff --git a/0007-networkd-fix-typo.patch b/0007-networkd-fix-typo.patch new file mode 100644 index 00000000..8bd67322 --- /dev/null +++ b/0007-networkd-fix-typo.patch @@ -0,0 +1,26 @@ +From eed0eee85ac34abd81cd9e81fdb6a19f47b6c8a3 Mon Sep 17 00:00:00 2001 +From: Michael Olbrich +Date: Fri, 14 Mar 2014 18:19:29 +0100 +Subject: [PATCH] networkd: fix typo + +It's HAVE_SPLIT_USR not HAVE_SPLIT_USER +--- + src/network/networkd-manager.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git src/network/networkd-manager.c src/network/networkd-manager.c +index c730e71..ea414b1 100644 +--- src/network/networkd-manager.c ++++ src/network/networkd-manager.c +@@ -33,7 +33,7 @@ const char* const network_dirs[] = { + "/etc/systemd/network", + "/run/systemd/network", + "/usr/lib/systemd/network", +-#ifdef HAVE_SPLIT_USER ++#ifdef HAVE_SPLIT_USR + "/lib/systemd/network", + #endif + NULL}; +-- +1.7.9.2 + diff --git a/0008-sd-bus-don-t-access-invalid-memory-if-a-signal-match.patch b/0008-sd-bus-don-t-access-invalid-memory-if-a-signal-match.patch new file mode 100644 index 00000000..d2eac44b --- /dev/null +++ b/0008-sd-bus-don-t-access-invalid-memory-if-a-signal-match.patch @@ -0,0 +1,27 @@ +From bbb6ff0216a7c081a2e63e01b1f121592b0165bb Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Fri, 14 Mar 2014 21:12:36 +0100 +Subject: [PATCH] sd-bus: don't access invalid memory if a signal matcher was + freed from its own callback + +--- + src/libsystemd/sd-bus/bus-match.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git src/libsystemd/sd-bus/bus-match.c src/libsystemd/sd-bus/bus-match.c +index 8280488..c54ca8d 100644 +--- src/libsystemd/sd-bus/bus-match.c ++++ src/libsystemd/sd-bus/bus-match.c +@@ -293,6 +293,9 @@ int bus_match_run( + r = bus_maybe_reply_error(m, r, &error_buffer); + if (r != 0) + return r; ++ ++ if (bus && bus->match_callbacks_modified) ++ return 0; + } + + return bus_match_run(bus, node->next, m); +-- +1.7.9.2 + diff --git a/0009-sd-bus-don-t-choke-if-somebody-sends-us-a-message-wi.patch b/0009-sd-bus-don-t-choke-if-somebody-sends-us-a-message-wi.patch new file mode 100644 index 00000000..f9e93696 --- /dev/null +++ b/0009-sd-bus-don-t-choke-if-somebody-sends-us-a-message-wi.patch @@ -0,0 +1,47 @@ +From 5a4d665ad679a8436f1210ba67d713a8f0b91b96 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Fri, 14 Mar 2014 21:15:32 +0100 +Subject: [PATCH] sd-bus: don't choke if somebody sends us a message with a + unix fd count of 0 + +It's kinda pointless to include a unix fd header field in messages if it +carries the value 0, but let's do this anyway... +--- + src/libsystemd/sd-bus/bus-message.c | 7 +++---- + 1 file changed, 3 insertions(+), 4 deletions(-) + +diff --git src/libsystemd/sd-bus/bus-message.c src/libsystemd/sd-bus/bus-message.c +index 97ab0e3..b9d7f6d 100644 +--- src/libsystemd/sd-bus/bus-message.c ++++ src/libsystemd/sd-bus/bus-message.c +@@ -4885,6 +4885,7 @@ int bus_message_parse_fields(sd_bus_message *m) { + size_t ri; + int r; + uint32_t unix_fds = 0; ++ bool unix_fds_set = false; + void *offsets = NULL; + unsigned n_offsets = 0; + size_t sz = 0; +@@ -5097,7 +5098,7 @@ int bus_message_parse_fields(sd_bus_message *m) { + } + + case BUS_MESSAGE_HEADER_UNIX_FDS: +- if (unix_fds != 0) ++ if (unix_fds_set) + return -EBADMSG; + + if (!streq(signature, "u")) +@@ -5107,9 +5108,7 @@ int bus_message_parse_fields(sd_bus_message *m) { + if (r < 0) + return -EBADMSG; + +- if (unix_fds == 0) +- return -EBADMSG; +- ++ unix_fds_set = true; + break; + + default: +-- +1.7.9.2 + diff --git a/0010-zsh-completion-Install-_sd_machines-with-_machinectl.patch b/0010-zsh-completion-Install-_sd_machines-with-_machinectl.patch new file mode 100644 index 00000000..9093b006 --- /dev/null +++ b/0010-zsh-completion-Install-_sd_machines-with-_machinectl.patch @@ -0,0 +1,28 @@ +From d895500c478c6ad7904905bb4c08176d5a6c0763 Mon Sep 17 00:00:00 2001 +From: Wieland Hoffmann +Date: Mon, 10 Mar 2014 15:17:31 +0100 +Subject: [PATCH] zsh completion: Install _sd_machines with _machinectl + +_machinectl uses _sd_machines to provide a list of all available +machines. +--- + Makefile.am | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git Makefile.am Makefile.am +index 60cb991..9e01cd5 100644 +--- Makefile.am ++++ Makefile.am +@@ -4067,7 +4067,8 @@ dist_dbuspolicy_DATA += \ + src/machine/org.freedesktop.machine1.conf + + dist_zshcompletion_DATA += \ +- shell-completion/zsh/_machinectl ++ shell-completion/zsh/_machinectl \ ++ shell-completion/zsh/_sd_machines + + SYSTEM_UNIT_ALIASES += \ + systemd-machined.service dbus-org.freedesktop.machine1.service +-- +1.7.9.2 + diff --git a/0012-journald-remove-stray-reset-of-error-return-value.patch b/0012-journald-remove-stray-reset-of-error-return-value.patch new file mode 100644 index 00000000..f15237f7 --- /dev/null +++ b/0012-journald-remove-stray-reset-of-error-return-value.patch @@ -0,0 +1,24 @@ +From 2fc74bf4336eb7a7e40c0b355d19966cd97d4b3c Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= +Date: Mon, 10 Mar 2014 21:19:23 -0400 +Subject: [PATCH] journald: remove stray reset of error return value + +--- + src/journal/journald.c | 1 - + 1 file changed, 1 deletion(-) + +diff --git src/journal/journald.c src/journal/journald.c +index 37896d0..c8c0801 100644 +--- src/journal/journald.c ++++ src/journal/journald.c +@@ -110,7 +110,6 @@ int main(int argc, char *argv[]) { + r = sd_event_run(server.event, t); + if (r < 0) { + log_error("Failed to run event loop: %s", strerror(-r)); +- r = -errno; + goto finish; + } + +-- +1.7.9.2 + diff --git a/0013-core-libsystemd-systemd-timedate-udev-spelling-fixes.patch b/0013-core-libsystemd-systemd-timedate-udev-spelling-fixes.patch new file mode 100644 index 00000000..0343c2ad --- /dev/null +++ b/0013-core-libsystemd-systemd-timedate-udev-spelling-fixes.patch @@ -0,0 +1,118 @@ +From 6f285378aa6e4b5b23c939d1fea16f9ab0a57efb Mon Sep 17 00:00:00 2001 +From: Miklos Vajna +Date: Fri, 14 Mar 2014 21:13:38 +0100 +Subject: [PATCH] core, libsystemd, systemd, timedate, udev: spelling fixes + +--- + src/core/service.c | 2 +- + src/core/unit.c | 2 +- + src/libsystemd/sd-bus/bus-message.c | 2 +- + src/libsystemd/sd-bus/sd-bus.c | 4 ++-- + src/systemd/sd-resolve.h | 2 +- + src/timedate/timedated.c | 2 +- + src/udev/udevadm-settle.c | 2 +- + 7 files changed, 8 insertions(+), 8 deletions(-) + +diff --git src/core/service.c src/core/service.c +index 41b95ab..386692a 100644 +--- src/core/service.c ++++ src/core/service.c +@@ -3416,7 +3416,7 @@ static void service_notify_message(Unit *u, pid_t pid, char **tags) { + free(t); + } + +- /* Interpet WATCHDOG= */ ++ /* Interpret WATCHDOG= */ + if (strv_find(tags, "WATCHDOG=1")) { + log_debug_unit(u->id, "%s: got WATCHDOG=1", u->id); + service_reset_watchdog(s); +diff --git src/core/unit.c src/core/unit.c +index 5c98843..4fb0d9c 100644 +--- src/core/unit.c ++++ src/core/unit.c +@@ -1537,7 +1537,7 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_su + unit_destroy_cgroup(u); + + /* Note that this doesn't apply to RemainAfterExit services exiting +- * sucessfully, since there's no change of state in that case. Which is ++ * successfully, since there's no change of state in that case. Which is + * why it is handled in service_set_state() */ + if (UNIT_IS_INACTIVE_OR_FAILED(os) != UNIT_IS_INACTIVE_OR_FAILED(ns)) { + ExecContext *ec; +diff --git src/libsystemd/sd-bus/bus-message.c src/libsystemd/sd-bus/bus-message.c +index b9d7f6d..e32f2b8 100644 +--- src/libsystemd/sd-bus/bus-message.c ++++ src/libsystemd/sd-bus/bus-message.c +@@ -4215,7 +4215,7 @@ static int message_read_ap( + * in a single stackframe. We hence implement our own + * home-grown stack in an array. */ + +- n_array = (unsigned) -1; /* lenght of current array entries */ ++ n_array = (unsigned) -1; /* length of current array entries */ + n_struct = strlen(types); /* length of current struct contents signature */ + + for (;;) { +diff --git src/libsystemd/sd-bus/sd-bus.c src/libsystemd/sd-bus/sd-bus.c +index 8e44e50..ba8a8a2 100644 +--- src/libsystemd/sd-bus/sd-bus.c ++++ src/libsystemd/sd-bus/sd-bus.c +@@ -1447,7 +1447,7 @@ static int bus_seal_message(sd_bus *b, sd_bus_message *m, usec_t timeout) { + static int bus_remarshal_message(sd_bus *b, sd_bus_message **m) { + assert(b); + +- /* Do packet version and endianess already match? */ ++ /* Do packet version and endianness already match? */ + if ((b->message_version == 0 || b->message_version == (*m)->header->version) && + (b->message_endian == 0 || b->message_endian == (*m)->header->endian)) + return 0; +@@ -1464,7 +1464,7 @@ int bus_seal_synthetic_message(sd_bus *b, sd_bus_message *m) { + * hence let's fill something in for synthetic messages. Since + * synthetic messages might have a fake sender and we don't + * want to interfere with the real sender's serial numbers we +- * pick a fixed, artifical one. We use (uint32_t) -1 rather ++ * pick a fixed, artificial one. We use (uint32_t) -1 rather + * than (uint64_t) -1 since dbus1 only had 32bit identifiers, + * even though kdbus can do 64bit. */ + +diff --git src/systemd/sd-resolve.h src/systemd/sd-resolve.h +index df69e4b..3c1d482 100644 +--- src/systemd/sd-resolve.h ++++ src/systemd/sd-resolve.h +@@ -129,7 +129,7 @@ int sd_resolve_get_next(sd_resolve *resolve, sd_resolve_query **q); + int sd_resolve_get_n_queries(sd_resolve *resolve); + + /** Cancel a currently running query. q is is destroyed by this call +- * and may not be used any futher. */ ++ * and may not be used any further. */ + int sd_resolve_cancel(sd_resolve_query* q); + + /** Returns non-zero when the query operation specified by q has been completed */ +diff --git src/timedate/timedated.c src/timedate/timedated.c +index d85ce57..c4a797a 100644 +--- src/timedate/timedated.c ++++ src/timedate/timedated.c +@@ -468,7 +468,7 @@ static int property_get_rtc_time( + zero(tm); + r = hwclock_get_time(&tm); + if (r == -EBUSY) { +- log_warning("/dev/rtc is busy, is somebody keeping it open continously? That's not a good idea... Returning a bogus RTC timestamp."); ++ log_warning("/dev/rtc is busy, is somebody keeping it open continuously? That's not a good idea... Returning a bogus RTC timestamp."); + t = 0; + } else if (r == -ENOENT) { + log_debug("Not /dev/rtc found."); +diff --git src/udev/udevadm-settle.c src/udev/udevadm-settle.c +index b026155..927ea2a 100644 +--- src/udev/udevadm-settle.c ++++ src/udev/udevadm-settle.c +@@ -100,7 +100,7 @@ static int adm_settle(struct udev *udev, int argc, char *argv[]) + case '?': + exit(EXIT_FAILURE); + default: +- assert_not_reached("Unkown argument"); ++ assert_not_reached("Unknown argument"); + } + + if (optind < argc) { +-- +1.7.9.2 + diff --git a/systemctl-set-default-target.patch b/systemctl-set-default-target.patch new file mode 100644 index 00000000..a8f0bb89 --- /dev/null +++ b/systemctl-set-default-target.patch @@ -0,0 +1,28 @@ +Mention that --force is required to override an already existing default.target + +This solves the bug bnc#868439 + +--- + systemctl.xml | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +--- systemd-210/man/systemctl.xml ++++ systemd-210/man/systemctl.xml 2014-03-19 09:54:37.946235696 +0000 +@@ -371,7 +371,7 @@ along with systemd; If not, see + + +- When used with enable, overwrite ++ When used with enable or set-default, overwrite + any existing conflicting symlinks. + + When used with halt, +@@ -1036,6 +1036,8 @@ kobject-uevent 1 systemd-udevd-kernel.so + + Set the default target to boot into. Command links + default.target to the given unit. ++ If combined with , overwrite ++ an already existing symlink for the default target. + + + diff --git a/systemd-mini.changes b/systemd-mini.changes index 80282770..06391535 100644 --- a/systemd-mini.changes +++ b/systemd-mini.changes @@ -1,3 +1,29 @@ +------------------------------------------------------------------- +Wed Mar 19 12:09:31 UTC 2014 - werner@suse.de + +- Add patch systemctl-set-default-target.patch which explain how + to override the default.target by using --force (bnc#868439) + +------------------------------------------------------------------- +Tue Mar 18 13:23:43 UTC 2014 - werner@suse.de + +- Add Robert's udev-generate-peristent-rule shell script to + udev's tool library +- Add or port upstram bugfix patches: + 0001-gpt-auto-generator-don-t-return-OOM-on-parentless-de.patch + 0002-bus-fix-memory-leak-when-kdbus-is-not-enabled.patch + 0003-sd-bus-don-t-look-for-a-64bit-value-when-we-only-hav.patch + 0004-nspawn-allow-EEXIST-on-mkdir_safe-home-uid.patch + 0005-networkd-fix-creation-of-runtime-dirs-at-startup.patch + 0006-Do-not-return-1-EINVAL-on-allocation-error.patch + 0007-networkd-fix-typo.patch + 0008-sd-bus-don-t-access-invalid-memory-if-a-signal-match.patch + 0009-sd-bus-don-t-choke-if-somebody-sends-us-a-message-wi.patch + 0010-zsh-completion-Install-_sd_machines-with-_machinectl.patch + 0011-_sd_machines-Use-machinectl-no-legend.patch + 0012-journald-remove-stray-reset-of-error-return-value.patch + 0013-core-libsystemd-systemd-timedate-udev-spelling-fixes.patch + ------------------------------------------------------------------- Fri Mar 14 14:24:56 UTC 2014 - werner@suse.de @@ -789,7 +815,7 @@ Fri Dec 20 12:06:18 UTC 2013 - werner@suse.de - Change patch 1012-pam_systemd_do_override_XDG_RUNTIME_DIR_of_the_original_user.patch to check if XDG_RUNTIME_DIR is set before the call of pam_putenv() - may fix bnc#855160 + may fix bnc#855160 ------------------------------------------------------------------- Fri Dec 20 09:40:01 UTC 2013 - lbsousajr@gmail.com diff --git a/systemd-mini.spec b/systemd-mini.spec index c554b30a..faa9385e 100644 --- a/systemd-mini.spec +++ b/systemd-mini.spec @@ -149,6 +149,7 @@ Source11: after-local.service Source1060: boot.udev Source1061: write_dev_root_rule Source1062: systemd-udev-root-symlink +Source1063: udev-generate-peristent-rule.sh ############################################################################## # @@ -308,6 +309,22 @@ Patch151: 0005-logind-fix-policykit-checks.patch Patch152: 0006-rules-mark-loop-device-as-SYSTEMD_READY-0-if-no-file.patch # PATCH-FIX-USTREAM added at 2014/03/11 Patch153: 0008-man-multiple-sleep-modes-are-to-be-separated-by-whit.patch +# PATCH-FIX-USTREAM added at 2014/03/18 +Patch154: 0001-gpt-auto-generator-don-t-return-OOM-on-parentless-de.patch +# PATCH-FIX-USTREAM added at 2014/03/18 +Patch155: 0002-bus-fix-memory-leak-when-kdbus-is-not-enabled.patch +# PATCH-FIX-USTREAM added at 2014/03/18 +Patch157: 0006-Do-not-return-1-EINVAL-on-allocation-error.patch +# PATCH-FIX-USTREAM added at 2014/03/18 +Patch158: 0007-networkd-fix-typo.patch +# PATCH-FIX-USTREAM added at 2014/03/18 +Patch159: 0008-sd-bus-don-t-access-invalid-memory-if-a-signal-match.patch +# PATCH-FIX-USTREAM added at 2014/03/18 +Patch160: 0009-sd-bus-don-t-choke-if-somebody-sends-us-a-message-wi.patch +# PATCH-FIX-USTREAM added at 2014/03/18 +Patch161: 0012-journald-remove-stray-reset-of-error-return-value.patch +# PATCH-FIX-USTREAM added at 2014/03/18 +Patch162: 0013-core-libsystemd-systemd-timedate-udev-spelling-fixes.patch # PATCH-FIX-OPENSUSE 1009-make-xsltproc-use-correct-ROFF-links.patch -- Make ROFF links working again in manual pages (bnc#842844) Patch1009: 1009-make-xsltproc-use-correct-ROFF-links.patch # PATCH-FIX-OPENSUSE 1010-do-not-install-sulogin-unit-with-poweroff.patch -- Avoid installing console-shell.service (bnc#849071) @@ -326,6 +343,8 @@ Patch1020: 0001-add-network-device-after-NFS-mount-units.patch Patch1022: 1022-systemd-tmpfiles-ownerkeep.patch # PATCH-FIX-SUSE systemd-powerd-initctl-support.patch Patch1023: systemd-powerd-initctl-support.patch +# PATCH-FIX-SUSE systemctl-set-default-target.patch +Patch1024: systemctl-set-default-target.patch # PATCH-FIX-SUSE systemd-install-compat_pkgconfig-always.patch Patch1999: systemd-install-compat_pkgconfig-always.patch # PATCH-FIX-OPENSUSE systemd-dbus-system-bus-address.patch always use /run/dbus not /var/run @@ -657,6 +676,14 @@ cp %{SOURCE7} m4/ %patch151 -p0 %patch152 -p0 %patch153 -p0 +%patch154 -p0 +%patch155 -p0 +%patch157 -p0 +%patch158 -p0 +%patch159 -p0 +%patch160 -p0 +%patch161 -p0 +%patch162 -p0 %patch1009 -p1 %patch1010 -p1 %patch1012 -p1 @@ -668,6 +695,7 @@ cp %{SOURCE7} m4/ %endif %patch1022 -p1 %patch1023 -p1 +%patch1024 -p1 %if ! 0%{?bootstrap} %patch1999 -p1 %endif @@ -776,6 +804,7 @@ sed -ie "s|@@PREFIX@@|%{_bindir}|g" %{S:1061} install -m755 -D %{S:1061} %{buildroot}/%{_prefix}/lib/udev/write_dev_root_rule sed -ie "s|@@PREFIX@@|%{_prefix}/lib/udev|g" %{S:1062} install -m644 -D %{S:1062} %{buildroot}/%{_prefix}/lib/systemd/system/systemd-udev-root-symlink.service +install -m755 -D %{S:1063} %{buildroot}/%{_prefix}/lib/udev/udev-generate-peristent-rule mkdir -p %{buildroot}/%{_prefix}/lib/systemd/system/basic.target.wants ln -sf ../systemd-udev-root-symlink.service %{buildroot}/%{_prefix}/lib/systemd/system/basic.target.wants rm -rf %{buildroot}%{_sysconfdir}/rpm @@ -1376,6 +1405,7 @@ exit 0 %{_prefix}/lib/udev/scsi_id %{_prefix}/lib/udev/v4l_id %{_prefix}/lib/udev/write_dev_root_rule +%{_prefix}/lib/udev/udev-generate-peristent-rule %dir %{_prefix}/lib/udev/rules.d/ %exclude %{_prefix}/lib/udev/rules.d/70-uaccess.rules %exclude %{_prefix}/lib/udev/rules.d/71-seat.rules diff --git a/systemd.changes b/systemd.changes index 80282770..06391535 100644 --- a/systemd.changes +++ b/systemd.changes @@ -1,3 +1,29 @@ +------------------------------------------------------------------- +Wed Mar 19 12:09:31 UTC 2014 - werner@suse.de + +- Add patch systemctl-set-default-target.patch which explain how + to override the default.target by using --force (bnc#868439) + +------------------------------------------------------------------- +Tue Mar 18 13:23:43 UTC 2014 - werner@suse.de + +- Add Robert's udev-generate-peristent-rule shell script to + udev's tool library +- Add or port upstram bugfix patches: + 0001-gpt-auto-generator-don-t-return-OOM-on-parentless-de.patch + 0002-bus-fix-memory-leak-when-kdbus-is-not-enabled.patch + 0003-sd-bus-don-t-look-for-a-64bit-value-when-we-only-hav.patch + 0004-nspawn-allow-EEXIST-on-mkdir_safe-home-uid.patch + 0005-networkd-fix-creation-of-runtime-dirs-at-startup.patch + 0006-Do-not-return-1-EINVAL-on-allocation-error.patch + 0007-networkd-fix-typo.patch + 0008-sd-bus-don-t-access-invalid-memory-if-a-signal-match.patch + 0009-sd-bus-don-t-choke-if-somebody-sends-us-a-message-wi.patch + 0010-zsh-completion-Install-_sd_machines-with-_machinectl.patch + 0011-_sd_machines-Use-machinectl-no-legend.patch + 0012-journald-remove-stray-reset-of-error-return-value.patch + 0013-core-libsystemd-systemd-timedate-udev-spelling-fixes.patch + ------------------------------------------------------------------- Fri Mar 14 14:24:56 UTC 2014 - werner@suse.de @@ -789,7 +815,7 @@ Fri Dec 20 12:06:18 UTC 2013 - werner@suse.de - Change patch 1012-pam_systemd_do_override_XDG_RUNTIME_DIR_of_the_original_user.patch to check if XDG_RUNTIME_DIR is set before the call of pam_putenv() - may fix bnc#855160 + may fix bnc#855160 ------------------------------------------------------------------- Fri Dec 20 09:40:01 UTC 2013 - lbsousajr@gmail.com diff --git a/systemd.spec b/systemd.spec index 7be75e0f..557956bd 100644 --- a/systemd.spec +++ b/systemd.spec @@ -144,6 +144,7 @@ Source11: after-local.service Source1060: boot.udev Source1061: write_dev_root_rule Source1062: systemd-udev-root-symlink +Source1063: udev-generate-peristent-rule.sh ############################################################################## # @@ -303,6 +304,22 @@ Patch151: 0005-logind-fix-policykit-checks.patch Patch152: 0006-rules-mark-loop-device-as-SYSTEMD_READY-0-if-no-file.patch # PATCH-FIX-USTREAM added at 2014/03/11 Patch153: 0008-man-multiple-sleep-modes-are-to-be-separated-by-whit.patch +# PATCH-FIX-USTREAM added at 2014/03/18 +Patch154: 0001-gpt-auto-generator-don-t-return-OOM-on-parentless-de.patch +# PATCH-FIX-USTREAM added at 2014/03/18 +Patch155: 0002-bus-fix-memory-leak-when-kdbus-is-not-enabled.patch +# PATCH-FIX-USTREAM added at 2014/03/18 +Patch157: 0006-Do-not-return-1-EINVAL-on-allocation-error.patch +# PATCH-FIX-USTREAM added at 2014/03/18 +Patch158: 0007-networkd-fix-typo.patch +# PATCH-FIX-USTREAM added at 2014/03/18 +Patch159: 0008-sd-bus-don-t-access-invalid-memory-if-a-signal-match.patch +# PATCH-FIX-USTREAM added at 2014/03/18 +Patch160: 0009-sd-bus-don-t-choke-if-somebody-sends-us-a-message-wi.patch +# PATCH-FIX-USTREAM added at 2014/03/18 +Patch161: 0012-journald-remove-stray-reset-of-error-return-value.patch +# PATCH-FIX-USTREAM added at 2014/03/18 +Patch162: 0013-core-libsystemd-systemd-timedate-udev-spelling-fixes.patch # PATCH-FIX-OPENSUSE 1009-make-xsltproc-use-correct-ROFF-links.patch -- Make ROFF links working again in manual pages (bnc#842844) Patch1009: 1009-make-xsltproc-use-correct-ROFF-links.patch # PATCH-FIX-OPENSUSE 1010-do-not-install-sulogin-unit-with-poweroff.patch -- Avoid installing console-shell.service (bnc#849071) @@ -321,6 +338,8 @@ Patch1020: 0001-add-network-device-after-NFS-mount-units.patch Patch1022: 1022-systemd-tmpfiles-ownerkeep.patch # PATCH-FIX-SUSE systemd-powerd-initctl-support.patch Patch1023: systemd-powerd-initctl-support.patch +# PATCH-FIX-SUSE systemctl-set-default-target.patch +Patch1024: systemctl-set-default-target.patch # PATCH-FIX-SUSE systemd-install-compat_pkgconfig-always.patch Patch1999: systemd-install-compat_pkgconfig-always.patch # PATCH-FIX-OPENSUSE systemd-dbus-system-bus-address.patch always use /run/dbus not /var/run @@ -652,6 +671,14 @@ cp %{SOURCE7} m4/ %patch151 -p0 %patch152 -p0 %patch153 -p0 +%patch154 -p0 +%patch155 -p0 +%patch157 -p0 +%patch158 -p0 +%patch159 -p0 +%patch160 -p0 +%patch161 -p0 +%patch162 -p0 %patch1009 -p1 %patch1010 -p1 %patch1012 -p1 @@ -663,6 +690,7 @@ cp %{SOURCE7} m4/ %endif %patch1022 -p1 %patch1023 -p1 +%patch1024 -p1 %if ! 0%{?bootstrap} %patch1999 -p1 %endif @@ -771,6 +799,7 @@ sed -ie "s|@@PREFIX@@|%{_bindir}|g" %{S:1061} install -m755 -D %{S:1061} %{buildroot}/%{_prefix}/lib/udev/write_dev_root_rule sed -ie "s|@@PREFIX@@|%{_prefix}/lib/udev|g" %{S:1062} install -m644 -D %{S:1062} %{buildroot}/%{_prefix}/lib/systemd/system/systemd-udev-root-symlink.service +install -m755 -D %{S:1063} %{buildroot}/%{_prefix}/lib/udev/udev-generate-peristent-rule mkdir -p %{buildroot}/%{_prefix}/lib/systemd/system/basic.target.wants ln -sf ../systemd-udev-root-symlink.service %{buildroot}/%{_prefix}/lib/systemd/system/basic.target.wants rm -rf %{buildroot}%{_sysconfdir}/rpm @@ -1371,6 +1400,7 @@ exit 0 %{_prefix}/lib/udev/scsi_id %{_prefix}/lib/udev/v4l_id %{_prefix}/lib/udev/write_dev_root_rule +%{_prefix}/lib/udev/udev-generate-peristent-rule %dir %{_prefix}/lib/udev/rules.d/ %exclude %{_prefix}/lib/udev/rules.d/70-uaccess.rules %exclude %{_prefix}/lib/udev/rules.d/71-seat.rules diff --git a/udev-generate-peristent-rule.sh b/udev-generate-peristent-rule.sh new file mode 100644 index 00000000..ee6a5e65 --- /dev/null +++ b/udev-generate-peristent-rule.sh @@ -0,0 +1,405 @@ +#!/bin/bash +# +# Copyright (C) 2014 Robert Milasan +# +# This program 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 version 2 of the License. +# +# This script run manually by user, will generate a persistent rule for +# a given network interface to rename it to new interface name. +# + +prj=${0##*/} + +log_info() +{ + local msg="$1" + echo "$prj: $msg" +} + +log_error() +{ + local msg=$1 + echo "$prj: $msg" >&2 +} + +usage() +{ + set -f + cat << EOF +$prj: udev persistent rule generator + +Usage: $prj [OPTION] ... + + -h show this help + -m generate the persistent rule based on interface MAC address + -p generate the persistent rule based on interface PCI slot + -v be verbose + -c current interface name (ex: "ip a s") + -n new interface name (ex: net0) + -o where to write the new generate rule (default: /dev/stdout) + prefered location is /etc/udev/rules.d/70-persistent-net.rules + +Example: + $prj -m -c enp0s4 -n net0 -o /etc/udev/rules.d/70-persistent-net.rules + or + $prj -p -c wlp3s0 -n wlan0 -o /etc/udev/rules.d/50-mynet.rules + +EOF +} + +display_note() +{ + cat <<'EOF' + +NOTE: Using the generate persistent rule might mean you will need to do extra +work to ensure that it will work accordingly. This mean, regenerating the +initramfs/initrd image and/or using 'net.ifnames=0' option at boot time. + +In openSUSE/SUSE, the user will need to regenerate the initramfs/initrd image, +but usually there is no need for 'net.ifnames=0' option if the persistent rule +is available in initramfs/initrd image. + +EOF +} + +get_pci() +{ + local path=$1 + local pci="" + + if [ -L "$path/device" ]; then + local pci_link="$(readlink -f $path/device 2>/dev/null)" + pci="$(basename $pci_link 2>/dev/null)" + fi + echo $pci +} + +get_pci_id() +{ + local path=$1 + local pci_id="" + + if [ -r "$path/device/uevent" ]; then + local _pci_id="$(cat $path/device/uevent|grep ^PCI_ID 2>/dev/null)" + pci_id="${_pci_id#*=}" + fi + echo $pci_id +} + +get_macaddr() +{ + local path=$1 + local macaddr="" + + if [ -r "$path/address" ]; then + macaddr="$(cat $path/address 2>/dev/null)" + fi + echo $macaddr +} + +get_type() +{ + local path=$1 + local dev_type="" + + if [ -r "$path/type" ]; then + dev_type="$(cat $path/type 2>/dev/null)" + fi + echo $dev_type +} + +get_dev_id() +{ + local path=$1 + local dev_id="" + + if [ -r "$path/dev_id" ]; then + dev_id="$(cat $path/dev_id 2>/dev/null)" + fi + echo $dev_id +} + +get_devtype() +{ + local path=$1 + local devtype="" + if [ -r "$path/uevent" ]; then + local _devtype="$(cat $path/uevent|grep ^DEVTYPE 2>/dev/null)" + devtype="${_devtype#*=}" + fi + echo $devtype +} + +get_subsystem() +{ + local path=$1 + local subsystem="" + + if [ -L "$path/subsystem" ]; then + local subsystem_link="$(readlink -f $path/subsystem 2>/dev/null)" + subsystem="$(basename $subsystem_link 2>/dev/null)" + fi + echo $subsystem +} + +get_driver() +{ + local path=$1 + local driver="" + + if [ -L "$path/device/driver" ]; then + local driver_link="$(readlink -f $path/device/driver 2>/dev/null)" + driver="$(basename $driver_link 2>/dev/null)" + fi + echo $driver +} + +valid_mac() +{ + local macaddr=$1 + local valid_macaddr="" + + if [ -n "$macaddr" ]; then + valid_macaddr="$(echo $macaddr | sed -n '/^\([0-9a-z][0-9a-z]:\)\{5\}[0-9a-z][0-9a-z]$/p')" + fi + echo $valid_macaddr +} + +generate_comment() +{ + local pci_id=$1 + local driver=$2 + local output=$3 + + if [ -z "$pci_id" ]; then + log_error "\$pci_id empty." + exit 1 + elif [ -z "$driver" ]; then + log_error "\$driver empty." + exit 1 + elif [ -z "$output" ]; then + log_error "\$output empty." + exit 1 + else + echo "# PCI device $pci_id ($driver) with official udev name $interface renamed to unsupported $new_interface" >> $output + fi +} + +generate_rule() +{ + local _subsystem=$1 + local _mac=$2 + local _pci=$3 + local _dev_id=$4 + local _dev_type=$5 + local _kernel=$6 + local _interface=$7 + local output=$8 + + if [ -z "$_subsystem" ]; then + log_error "\$_subsystem empty." + exit 1 + elif [ -z "$_dev_id" ]; then + log_error "\$_dev_id empty." + exit 1 + elif [ -z "$_dev_type" ]; then + log_error "\$_dev_type empty." + exit 1 + elif [ -z "$_kernel" ]; then + log_error "\$_kernel empty." + exit 1 + elif [ -z "$_interface" ]; then + log_error "\$_interface empty." + exit 1 + elif [ -z "$output" ]; then + output="/dev/stdout" + fi + + if [ "$_mac" != "none" ]; then + echo "SUBSYSTEM==\"$_subsystem\", ACTION==\"add\", DRIVERS==\"?*\", ATTR{address}==\"$_mac\", \ +ATTR{dev_id}==\"$_dev_id\", ATTR{type}==\"$_dev_type\", KERNEL==\"$_kernel\", NAME=\"$_interface\"" >> ${output} + elif [ "$_pci" != "none" ]; then + echo "SUBSYSTEM==\"$_subsystem\", ACTION==\"add\", DRIVERS==\"?*\", KERNELS==\"$_pci\", \ +ATTR{dev_id}==\"$_dev_id\", ATTR{type}==\"$_dev_type\", KERNEL==\"$_kernel\", NAME=\"$_interface\"" >> ${output} + else + log_error "MAC address or PCI slot information missing." + exit 1 + fi +} + +if [ $# -eq 0 ]; then + usage + log_error "missing option(s)." + exit 1 +fi + +use_mac=0 +use_pci=0 +use_verbose=0 + +while getopts "hmpvc:n:o:" opt; do + case "$opt" in + h) + usage; exit 0;; + m) + use_mac=1 ;; + p) + use_pci=1 ;; + v) + use_verbose=1 ;; + c) + ifcur="$OPTARG" ;; + n) + ifnew="$OPTARG" ;; + o) + output="$OPTARG" ;; + \?) + exit 1 ;; + esac +done + +if [[ "$use_mac" -eq 1 ]] && [[ "$use_pci" -eq 1 ]]; then + log_error "generating a persistent rule can be done only using one of the option, -m or -p, not both." + exit 1 +fi + +outfile=$output +if [ -z "$output" ]; then + outfile=/dev/stdout +else + dir="$(dirname $outfile 2>/dev/null)" + tmpfile="$dir/.tmp_file" + if [ -d "$dir" ]; then + touch "$tmpfile" >/dev/null 2>&1 + if [ $? -ne 0 ]; then + log_error "no write access for $outfile. make sure you have write permissions to $dir." + exit 1 + fi + rm -f "$tmpfile" >/dev/null 2>&1 + else + log_error "$dir not a directory." + exit 1 + fi +fi + +interface=$ifcur +if [ -z "$interface" ]; then + log_error "current interface must be specified." + exit 1 +elif [ "$interface" == "lo" ]; then + log_error "loopback interface is not a valid interface." + exit 1 +fi +[ "$use_verbose" -eq 1 ] && echo "I: INTERFACE=$interface" + +new_interface=$ifnew +if [ -z "$new_interface" ]; then + log_error "new interface must be specified." + exit 1 +elif [ "$new_interface" == "lo" ]; then + log_error "new interface cant be named loopback interface." + exit +fi +[ "$use_verbose" -eq 1 ] && echo "I: INTERFACE_NEW=$new_interface" + +path="/sys/class/net/$interface" +if [ ! -d "$path" ]; then + log_error "devpath $path not a directory." + exit 1 +fi +[ "$use_verbose" -eq 1 ] && echo "I: DEVPATH=$path" + +devtype="$(get_devtype $path)" +if [ -n "$devtype" ]; then + [ "$use_verbose" -eq 1 ] && echo "I: DEVTYPE=$devtype" +fi + +subsystem="$(get_subsystem $path)" +if [ -z "$subsystem" ]; then + log_error "unable to retrieve subsystem for interface $interface." + exit 1 +fi +[ "$use_verbose" -eq 1 ] && echo "I: SUBSYSTEM=$subsystem" + +pci_id="$(get_pci_id $path)" +if [ -z "$pci_id" ]; then + log_error "unable to retrieve PCI_ID for interface $interface." + exit 1 +fi +[ "$use_verbose" -eq 1 ] && echo "I: PCI_ID=$pci_id" + +driver="$(get_driver $path)" +if [ -z "$driver" ]; then + log_error "unable to retrieve driver for interface $interface." + exit 1 +fi +[ "$use_verbose" -eq 1 ] && echo "I: DRIVER=$driver" + +if [ "$use_mac" -eq 1 ]; then + macaddr="$(get_macaddr $path)" + if [ -z "$macaddr" ]; then + log_error "unable to retrieve MAC address for interface $interface." + exit 1 + fi + if [ "$(valid_mac $macaddr)" != "$macaddr" ]; then + log_error "$macaddr invalid MAC address." + exit 1 + fi + [ "$use_verbose" -eq 1 ] && echo "I: MACADDR=$macaddr" +fi + +if [ "$use_pci" -eq 1 ]; then + pci="$(get_pci $path)" + if [ -z "$pci" ]; then + log_error "unable to retrieve PCI slot for interface $interface." + exit 1 + fi + [ "$use_verbose" -eq 1 ] && echo "I: KERNELS=$pci" +fi + +dev_id="$(get_dev_id $path)" +if [ -z "$dev_id" ]; then + log_error "unable to retrieve dev_id for interface $interface." + exit 1 +fi +[ "$use_verbose" -eq 1 ] && echo "I: DEV_ID=$dev_id" + +dev_type="$(get_type $path)" +if [ -z "$dev_type" ]; then + log_error "unable to retrieve dev_type for interface $interface." + exit 1 +fi +[ "$use_verbose" -eq 1 ] && echo "I: TYPE=$dev_type" + +if [ "$devtype" == "wlan" ]; then + kernel="wlan*" +else + kernel="eth*" +fi + +if [ -n "$output" ]; then + echo "Persistent rule saved in "$outfile"" + echo + generate_comment "$pci_id" "$driver" "$output" +fi + +set -f +if [ "$use_mac" -eq 1 ]; then + generate_rule "$subsystem" "$macaddr" "none" "$dev_id" "$dev_type" "$kernel" "$new_interface" + if [ -n "$output" ]; then + generate_rule "$subsystem" "$macaddr" "none" "$dev_id" "$dev_type" "$kernel" "$new_interface" "$output" + fi +elif [ "$use_pci" -eq 1 ]; then + generate_rule "$subsystem" "none" "$pci" "$dev_id" "$dev_type" "$kernel" "$new_interface" + if [ -n "$output" ]; then + generate_rule "$subsystem" "none" "$pci" "$dev_id" "$dev_type" "$kernel" "$new_interface" "$outfile" + fi +fi + +if [ -n "$output" ]; then + display_note +fi + +exit 0