mirror of
https://github.com/flatcar/scripts.git
synced 2025-10-02 19:11:20 +02:00
fix(sys-apps/systemd) pick in upstream systemd bugfixes
Also add the --root= files from @marineam and me so that our initramfs scripts will work properly in the near future.
This commit is contained in:
parent
b977fa3559
commit
2cc64031dc
@ -0,0 +1,25 @@
|
||||
From d6201d7653de28af38f7c84b7280302b512f4ef9 Mon Sep 17 00:00:00 2001
|
||||
From: Tomasz Torcz <tomek@pipebreaker.pl>
|
||||
Date: Wed, 12 Mar 2014 19:25:11 +0100
|
||||
Subject: 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(-)
|
||||
|
||||
diff --git a/src/gpt-auto-generator/gpt-auto-generator.c b/src/gpt-auto-generator/gpt-auto-generator.c
|
||||
index e487f6438689..19c5eea9de2f 100644
|
||||
--- a/src/gpt-auto-generator/gpt-auto-generator.c
|
||||
+++ b/src/gpt-auto-generator/gpt-auto-generator.c
|
||||
@@ -395,7 +395,7 @@ static int enumerate_partitions(dev_t devnum) {
|
||||
|
||||
parent = udev_device_get_parent(d);
|
||||
if (!parent)
|
||||
- return log_oom();
|
||||
+ return 0;
|
||||
|
||||
/* Does it have a devtype? */
|
||||
devtype = udev_device_get_devtype(parent);
|
||||
--
|
||||
1.9.0
|
||||
|
@ -0,0 +1,26 @@
|
||||
From d21c038833f621fc4328fdd75decaacdb147c396 Mon Sep 17 00:00:00 2001
|
||||
From: Lennart Poettering <lennart@poettering.net>
|
||||
Date: Thu, 13 Mar 2014 20:00:50 +0100
|
||||
Subject: 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 a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c
|
||||
index ffa3369feb37..ca7c428a3162 100644
|
||||
--- a/src/libsystemd/sd-bus/sd-bus.c
|
||||
+++ b/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.9.0
|
||||
|
@ -0,0 +1,181 @@
|
||||
From 53776069023eb1ae33acb0ae9ae1a27e8b172c25 Mon Sep 17 00:00:00 2001
|
||||
From: Lennart Poettering <lennart@poettering.net>
|
||||
Date: Thu, 13 Mar 2014 20:33:22 +0100
|
||||
Subject: 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 a/src/libsystemd/sd-bus/bus-dump.c b/src/libsystemd/sd-bus/bus-dump.c
|
||||
index 0e4154973775..ea81644d46bc 100644
|
||||
--- a/src/libsystemd/sd-bus/bus-dump.c
|
||||
+++ b/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 a/src/libsystemd/sd-bus/bus-kernel.c b/src/libsystemd/sd-bus/bus-kernel.c
|
||||
index 8a2ca0299677..80ef15bd422b 100644
|
||||
--- a/src/libsystemd/sd-bus/bus-kernel.c
|
||||
+++ b/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 a/src/libsystemd/sd-bus/bus-message.c b/src/libsystemd/sd-bus/bus-message.c
|
||||
index fb894eff1fb4..97ab0e3beac8 100644
|
||||
--- a/src/libsystemd/sd-bus/bus-message.c
|
||||
+++ b/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 a/src/libsystemd/sd-bus/bus-message.h b/src/libsystemd/sd-bus/bus-message.h
|
||||
index 5fbe3e60307a..df792945b020 100644
|
||||
--- a/src/libsystemd/sd-bus/bus-message.h
|
||||
+++ b/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 a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c
|
||||
index ca7c428a3162..8e44e502f70c 100644
|
||||
--- a/src/libsystemd/sd-bus/sd-bus.c
|
||||
+++ b/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.9.0
|
||||
|
@ -0,0 +1,28 @@
|
||||
From 233bd18dd9144977cc3179a89e0449614c0e9557 Mon Sep 17 00:00:00 2001
|
||||
From: Brandon Philips <brandon.philips@coreos.com>
|
||||
Date: Thu, 13 Mar 2014 15:19:40 -0700
|
||||
Subject: nspawn: allow -EEXIST on mkdir_safe /home/${uid}
|
||||
|
||||
With systemd 211 nspawn attempts to create the home directory for the
|
||||
given uid. However, if the home directory already exists then it will
|
||||
fail. Don't error out on -EEXIST.
|
||||
---
|
||||
src/nspawn/nspawn.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
|
||||
index b2c974d97016..6bf0a20ecae2 100644
|
||||
--- a/src/nspawn/nspawn.c
|
||||
+++ b/src/nspawn/nspawn.c
|
||||
@@ -2464,7 +2464,7 @@ static int change_uid_gid(char **_home) {
|
||||
}
|
||||
|
||||
r = mkdir_safe(home, 0755, uid, gid);
|
||||
- if (r < 0) {
|
||||
+ if (r < 0 && r != -EEXIST) {
|
||||
log_error("Failed to make home directory: %s", strerror(-r));
|
||||
return r;
|
||||
}
|
||||
--
|
||||
1.9.0
|
||||
|
@ -0,0 +1,88 @@
|
||||
From 3a87ae6e818f875b8bd70bc09dbc173fe90f2769 Mon Sep 17 00:00:00 2001
|
||||
From: Tom Gundersen <teg@jklm.no>
|
||||
Date: Thu, 13 Mar 2014 19:02:28 +0100
|
||||
Subject: networkd: fix creation of runtime dirs at startup
|
||||
|
||||
This allows us to drop the repeated attempted creations of the runtime dirs during runtime.
|
||||
---
|
||||
src/libsystemd-network/sd-dhcp-lease.c | 4 ----
|
||||
src/network/networkd-link.c | 4 ----
|
||||
src/network/networkd-manager.c | 4 ----
|
||||
src/network/networkd.c | 16 ++++++++++++++--
|
||||
4 files changed, 14 insertions(+), 14 deletions(-)
|
||||
|
||||
diff --git a/src/libsystemd-network/sd-dhcp-lease.c b/src/libsystemd-network/sd-dhcp-lease.c
|
||||
index f7a204af82a9..e6d80d4c665d 100644
|
||||
--- a/src/libsystemd-network/sd-dhcp-lease.c
|
||||
+++ b/src/libsystemd-network/sd-dhcp-lease.c
|
||||
@@ -297,10 +297,6 @@ int dhcp_lease_save(sd_dhcp_lease *lease, const char *lease_file) {
|
||||
assert(lease);
|
||||
assert(lease_file);
|
||||
|
||||
- r = mkdir_safe_label("/run/systemd/network/leases", 0755, 0, 0);
|
||||
- if (r < 0)
|
||||
- goto finish;
|
||||
-
|
||||
r = fopen_temporary(lease_file, &f, &temp_path);
|
||||
if (r < 0)
|
||||
goto finish;
|
||||
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
|
||||
index fdc351fed31a..5449a1246ec7 100644
|
||||
--- a/src/network/networkd-link.c
|
||||
+++ b/src/network/networkd-link.c
|
||||
@@ -1367,10 +1367,6 @@ int link_save(Link *link) {
|
||||
assert(link);
|
||||
assert(link->state_file);
|
||||
|
||||
- r = mkdir_safe_label("/run/systemd/network/links", 0755, 0, 0);
|
||||
- if (r < 0)
|
||||
- goto finish;
|
||||
-
|
||||
r = fopen_temporary(link->state_file, &f, &temp_path);
|
||||
if (r < 0)
|
||||
goto finish;
|
||||
diff --git a/src/network/networkd-manager.c b/src/network/networkd-manager.c
|
||||
index f41914f8809a..8c2f5efbd341 100644
|
||||
--- a/src/network/networkd-manager.c
|
||||
+++ b/src/network/networkd-manager.c
|
||||
@@ -407,10 +407,6 @@ int manager_update_resolv_conf(Manager *m) {
|
||||
|
||||
assert(m);
|
||||
|
||||
- r = mkdir_safe_label("/run/systemd/network", 0755, 0, 0);
|
||||
- if (r < 0)
|
||||
- return r;
|
||||
-
|
||||
r = fopen_temporary("/run/systemd/network/resolv.conf", &f, &temp_path);
|
||||
if (r < 0)
|
||||
return r;
|
||||
diff --git a/src/network/networkd.c b/src/network/networkd.c
|
||||
index 2f6a12dbccfd..f0e6ad5201a5 100644
|
||||
--- a/src/network/networkd.c
|
||||
+++ b/src/network/networkd.c
|
||||
@@ -42,8 +42,20 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
/* Always create the directories people can create inotify
|
||||
* watches in. */
|
||||
- mkdir_label("/run/systemd/network/links", 0755);
|
||||
- mkdir_label("/run/systemd/network/leases", 0755);
|
||||
+ r = mkdir_label("/run/systemd/network", 0755);
|
||||
+ if (r < 0)
|
||||
+ log_error("Could not create runtime directory: %s",
|
||||
+ strerror(-r));
|
||||
+
|
||||
+ r = mkdir_label("/run/systemd/network/links", 0755);
|
||||
+ if (r < 0)
|
||||
+ log_error("Could not create runtime directory 'links': %s",
|
||||
+ strerror(-r));
|
||||
+
|
||||
+ r = mkdir_label("/run/systemd/network/leases", 0755);
|
||||
+ if (r < 0)
|
||||
+ log_error("Could not create runtime directory 'leases': %s",
|
||||
+ strerror(-r));
|
||||
|
||||
r = manager_new(&m);
|
||||
if (r < 0) {
|
||||
--
|
||||
1.9.0
|
||||
|
@ -0,0 +1,31 @@
|
||||
From 2d8a2869f482e17982eb4748d82a5066497e07bb Mon Sep 17 00:00:00 2001
|
||||
From: Tom Gundersen <teg@jklm.no>
|
||||
Date: Thu, 13 Mar 2014 18:42:56 +0100
|
||||
Subject: networkd: lease - store (up to) one dhcp lease file per interface
|
||||
|
||||
This removes an accidentally left-over test fragment.
|
||||
---
|
||||
src/network/networkd-link.c | 7 ++++++-
|
||||
1 file changed, 6 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
|
||||
index 5449a1246ec7..2650f863575b 100644
|
||||
--- a/src/network/networkd-link.c
|
||||
+++ b/src/network/networkd-link.c
|
||||
@@ -1379,7 +1379,12 @@ int link_save(Link *link) {
|
||||
link_state_to_string(link->state));
|
||||
|
||||
if (link->dhcp_lease) {
|
||||
- const char *lease_file = "/run/systemd/network/leases/test.lease";
|
||||
+ char *lease_file;
|
||||
+
|
||||
+ r = asprintf(&lease_file, "/run/systemd/network/leases/%u",
|
||||
+ (unsigned) link->ifindex);
|
||||
+ if (r < 0)
|
||||
+ return r;
|
||||
|
||||
r = dhcp_lease_save(link->dhcp_lease, lease_file);
|
||||
if (r < 0)
|
||||
--
|
||||
1.9.0
|
||||
|
@ -0,0 +1,69 @@
|
||||
From ca37f1e43b089e721760064b93882958e3f61485 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
||||
Date: Fri, 14 Mar 2014 09:05:56 -0400
|
||||
Subject: Do not return -1 (EINVAL) on allocation error
|
||||
|
||||
---
|
||||
src/core/socket.c | 8 +++-----
|
||||
src/network/networkd-link.c | 12 ++++++------
|
||||
2 files changed, 9 insertions(+), 11 deletions(-)
|
||||
|
||||
diff --git a/src/core/socket.c b/src/core/socket.c
|
||||
index 35531edb751e..ac59ce9d6a88 100644
|
||||
--- a/src/core/socket.c
|
||||
+++ b/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;
|
||||
|
||||
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
|
||||
index 2650f863575b..275ad97a6307 100644
|
||||
--- a/src/network/networkd-link.c
|
||||
+++ b/src/network/networkd-link.c
|
||||
@@ -53,10 +53,10 @@ int link_new(Manager *manager, struct udev_device *device, Link **ret) {
|
||||
if (link->ifindex <= 0)
|
||||
return -EINVAL;
|
||||
|
||||
- r = asprintf(&link->state_file, "/run/systemd/network/links/%u",
|
||||
- (unsigned) link->ifindex);
|
||||
+ r = asprintf(&link->state_file, "/run/systemd/network/links/%"PRIu64,
|
||||
+ link->ifindex);
|
||||
if (r < 0)
|
||||
- return r;
|
||||
+ return -ENOMEM;
|
||||
|
||||
mac = udev_device_get_sysattr_value(device, "address");
|
||||
if (mac) {
|
||||
@@ -1381,10 +1381,10 @@ int link_save(Link *link) {
|
||||
if (link->dhcp_lease) {
|
||||
char *lease_file;
|
||||
|
||||
- r = asprintf(&lease_file, "/run/systemd/network/leases/%u",
|
||||
- (unsigned) link->ifindex);
|
||||
+ r = asprintf(&lease_file, "/run/systemd/network/leases/%"PRIu64,
|
||||
+ link->ifindex);
|
||||
if (r < 0)
|
||||
- return r;
|
||||
+ return -ENOMEM;
|
||||
|
||||
r = dhcp_lease_save(link->dhcp_lease, lease_file);
|
||||
if (r < 0)
|
||||
--
|
||||
1.9.0
|
||||
|
@ -0,0 +1,148 @@
|
||||
From systemd-devel-bounces@lists.freedesktop.org Fri Mar 14 04:32:58 2014
|
||||
From: Michael Marineau <michael.marineau@coreos.com>
|
||||
Date: Thu, 13 Mar 2014 21:32:12 -0700
|
||||
Subject: [systemd-devel] [PATCH 1/3] shared: add root argument to search_and_fopen
|
||||
To: systemd-devel@lists.freedesktop.org
|
||||
Message-ID: <1394771534-27529-1-git-send-email-michael.marineau@coreos.com>
|
||||
|
||||
|
||||
This adds the same root argument to search_and_fopen that
|
||||
conf_files_list already has. Tools that use those two functions as a
|
||||
pair can now be easily modified to load configuration files from an
|
||||
alternate root filesystem tree.
|
||||
---
|
||||
src/binfmt/binfmt.c | 2 +-
|
||||
src/modules-load/modules-load.c | 2 +-
|
||||
src/shared/util.c | 12 ++++++------
|
||||
src/shared/util.h | 4 ++--
|
||||
src/sysctl/sysctl.c | 2 +-
|
||||
src/tmpfiles/tmpfiles.c | 2 +-
|
||||
6 files changed, 12 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git a/src/binfmt/binfmt.c b/src/binfmt/binfmt.c
|
||||
index a1877c4..9fc5d4e 100644
|
||||
--- a/src/binfmt/binfmt.c
|
||||
+++ b/src/binfmt/binfmt.c
|
||||
@@ -86,7 +86,7 @@ static int apply_file(const char *path, bool ignore_enoent) {
|
||||
|
||||
assert(path);
|
||||
|
||||
- r = search_and_fopen_nulstr(path, "re", conf_file_dirs, &f);
|
||||
+ r = search_and_fopen_nulstr(path, "re", NULL, conf_file_dirs, &f);
|
||||
if (r < 0) {
|
||||
if (ignore_enoent && r == -ENOENT)
|
||||
return 0;
|
||||
diff --git a/src/modules-load/modules-load.c b/src/modules-load/modules-load.c
|
||||
index 49b153d..ecb84da 100644
|
||||
--- a/src/modules-load/modules-load.c
|
||||
+++ b/src/modules-load/modules-load.c
|
||||
@@ -145,7 +145,7 @@ static int apply_file(struct kmod_ctx *ctx, const char *path, bool ignore_enoent
|
||||
assert(ctx);
|
||||
assert(path);
|
||||
|
||||
- r = search_and_fopen_nulstr(path, "re", conf_file_dirs, &f);
|
||||
+ r = search_and_fopen_nulstr(path, "re", NULL, conf_file_dirs, &f);
|
||||
if (r < 0) {
|
||||
if (ignore_enoent && r == -ENOENT)
|
||||
return 0;
|
||||
diff --git a/src/shared/util.c b/src/shared/util.c
|
||||
index 9e8cd54..8b8d2fb 100644
|
||||
--- a/src/shared/util.c
|
||||
+++ b/src/shared/util.c
|
||||
@@ -5668,14 +5668,14 @@ int on_ac_power(void) {
|
||||
return found_online || !found_offline;
|
||||
}
|
||||
|
||||
-static int search_and_fopen_internal(const char *path, const char *mode, char **search, FILE **_f) {
|
||||
+static int search_and_fopen_internal(const char *path, const char *mode, const char *root, char **search, FILE **_f) {
|
||||
char **i;
|
||||
|
||||
assert(path);
|
||||
assert(mode);
|
||||
assert(_f);
|
||||
|
||||
- if (!path_strv_canonicalize_absolute_uniq(search, NULL))
|
||||
+ if (!path_strv_canonicalize_absolute_uniq(search, root))
|
||||
return -ENOMEM;
|
||||
|
||||
STRV_FOREACH(i, search) {
|
||||
@@ -5699,7 +5699,7 @@ static int search_and_fopen_internal(const char *path, const char *mode, char **
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
-int search_and_fopen(const char *path, const char *mode, const char **search, FILE **_f) {
|
||||
+int search_and_fopen(const char *path, const char *mode, const char *root, const char **search, FILE **_f) {
|
||||
_cleanup_strv_free_ char **copy = NULL;
|
||||
|
||||
assert(path);
|
||||
@@ -5722,10 +5722,10 @@ int search_and_fopen(const char *path, const char *mode, const char **search, FI
|
||||
if (!copy)
|
||||
return -ENOMEM;
|
||||
|
||||
- return search_and_fopen_internal(path, mode, copy, _f);
|
||||
+ return search_and_fopen_internal(path, mode, root, copy, _f);
|
||||
}
|
||||
|
||||
-int search_and_fopen_nulstr(const char *path, const char *mode, const char *search, FILE **_f) {
|
||||
+int search_and_fopen_nulstr(const char *path, const char *mode, const char *root, const char *search, FILE **_f) {
|
||||
_cleanup_strv_free_ char **s = NULL;
|
||||
|
||||
if (path_is_absolute(path)) {
|
||||
@@ -5744,7 +5744,7 @@ int search_and_fopen_nulstr(const char *path, const char *mode, const char *sear
|
||||
if (!s)
|
||||
return -ENOMEM;
|
||||
|
||||
- return search_and_fopen_internal(path, mode, s, _f);
|
||||
+ return search_and_fopen_internal(path, mode, root, s, _f);
|
||||
}
|
||||
|
||||
char *strextend(char **x, ...) {
|
||||
diff --git a/src/shared/util.h b/src/shared/util.h
|
||||
index 81831e2..e99f8d1 100644
|
||||
--- a/src/shared/util.h
|
||||
+++ b/src/shared/util.h
|
||||
@@ -696,8 +696,8 @@ char *strip_tab_ansi(char **p, size_t *l);
|
||||
|
||||
int on_ac_power(void);
|
||||
|
||||
-int search_and_fopen(const char *path, const char *mode, const char **search, FILE **_f);
|
||||
-int search_and_fopen_nulstr(const char *path, const char *mode, const char *search, FILE **_f);
|
||||
+int search_and_fopen(const char *path, const char *mode, const char *root, const char **search, FILE **_f);
|
||||
+int search_and_fopen_nulstr(const char *path, const char *mode, const char *root, const char *search, FILE **_f);
|
||||
|
||||
#define FOREACH_LINE(line, f, on_error) \
|
||||
for (;;) \
|
||||
diff --git a/src/sysctl/sysctl.c b/src/sysctl/sysctl.c
|
||||
index 76efacb..8868732 100644
|
||||
--- a/src/sysctl/sysctl.c
|
||||
+++ b/src/sysctl/sysctl.c
|
||||
@@ -123,7 +123,7 @@ static int parse_file(Hashmap *sysctl_options, const char *path, bool ignore_eno
|
||||
|
||||
assert(path);
|
||||
|
||||
- r = search_and_fopen_nulstr(path, "re", conf_file_dirs, &f);
|
||||
+ r = search_and_fopen_nulstr(path, "re", NULL, conf_file_dirs, &f);
|
||||
if (r < 0) {
|
||||
if (ignore_enoent && r == -ENOENT)
|
||||
return 0;
|
||||
diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
|
||||
index 6e36dc7..3684289 100644
|
||||
--- a/src/tmpfiles/tmpfiles.c
|
||||
+++ b/src/tmpfiles/tmpfiles.c
|
||||
@@ -1376,7 +1376,7 @@ static int read_config_file(const char *fn, bool ignore_enoent) {
|
||||
|
||||
assert(fn);
|
||||
|
||||
- r = search_and_fopen_nulstr(fn, "re", conf_file_dirs, &f);
|
||||
+ r = search_and_fopen_nulstr(fn, "re", NULL, conf_file_dirs, &f);
|
||||
if (r < 0) {
|
||||
if (ignore_enoent && r == -ENOENT)
|
||||
return 0;
|
||||
--
|
||||
1.8.3.2
|
||||
|
||||
_______________________________________________
|
||||
systemd-devel mailing list
|
||||
systemd-devel@lists.freedesktop.org
|
||||
http://lists.freedesktop.org/mailman/listinfo/systemd-devel
|
||||
|
@ -0,0 +1,116 @@
|
||||
From systemd-devel-bounces@lists.freedesktop.org Fri Mar 14 04:33:04 2014
|
||||
From: Michael Marineau <michael.marineau@coreos.com>
|
||||
Date: Thu, 13 Mar 2014 21:32:13 -0700
|
||||
Subject: [systemd-devel] [PATCH 2/3] tmpfiles: Add --root option to operate on an alternate fs tree.
|
||||
To: systemd-devel@lists.freedesktop.org
|
||||
Message-ID: <1394771534-27529-2-git-send-email-michael.marineau@coreos.com>
|
||||
|
||||
|
||||
This makes it possible to initialize or cleanup an arbitrary filesystem
|
||||
hierarchy in the same way that it would be during system boot.
|
||||
---
|
||||
src/tmpfiles/tmpfiles.c | 27 ++++++++++++++++++++++++---
|
||||
1 file changed, 24 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
|
||||
index 3684289..4ce35b5 100644
|
||||
--- a/src/tmpfiles/tmpfiles.c
|
||||
+++ b/src/tmpfiles/tmpfiles.c
|
||||
@@ -111,6 +111,7 @@ static bool arg_boot = false;
|
||||
|
||||
static char **include_prefixes = NULL;
|
||||
static char **exclude_prefixes = NULL;
|
||||
+static char *arg_root = NULL;
|
||||
|
||||
static const char conf_file_dirs[] =
|
||||
"/etc/tmpfiles.d\0"
|
||||
@@ -1188,6 +1189,15 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) {
|
||||
if (!should_include_path(i->path))
|
||||
return 0;
|
||||
|
||||
+ if (arg_root) {
|
||||
+ char *p = strjoin(arg_root, i->path, NULL);
|
||||
+ if (!p)
|
||||
+ return log_oom();
|
||||
+
|
||||
+ free(i->path);
|
||||
+ i->path = p;
|
||||
+ }
|
||||
+
|
||||
if (user && !streq(user, "-")) {
|
||||
const char *u = user;
|
||||
|
||||
@@ -1277,7 +1287,8 @@ static int help(void) {
|
||||
" --remove Remove marked files/directories\n"
|
||||
" --boot Execute actions only safe at boot\n"
|
||||
" --prefix=PATH Only apply rules that apply to paths with the specified prefix\n"
|
||||
- " --exclude-prefix=PATH Ignore rules that apply to paths with the specified prefix\n",
|
||||
+ " --exclude-prefix=PATH Ignore rules that apply to paths with the specified prefix\n"
|
||||
+ " --root=PATH Operate on an alternate filesystem root\n",
|
||||
program_invocation_short_name);
|
||||
|
||||
return 0;
|
||||
@@ -1293,6 +1304,7 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
ARG_BOOT,
|
||||
ARG_PREFIX,
|
||||
ARG_EXCLUDE_PREFIX,
|
||||
+ ARG_ROOT,
|
||||
};
|
||||
|
||||
static const struct option options[] = {
|
||||
@@ -1304,6 +1316,7 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
{ "boot", no_argument, NULL, ARG_BOOT },
|
||||
{ "prefix", required_argument, NULL, ARG_PREFIX },
|
||||
{ "exclude-prefix", required_argument, NULL, ARG_EXCLUDE_PREFIX },
|
||||
+ { "root", required_argument, NULL, ARG_ROOT },
|
||||
{}
|
||||
};
|
||||
|
||||
@@ -1350,6 +1363,13 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
return log_oom();
|
||||
break;
|
||||
|
||||
+ case ARG_ROOT:
|
||||
+ arg_root = path_make_absolute_cwd(optarg);
|
||||
+ if (!arg_root)
|
||||
+ return log_oom();
|
||||
+ path_kill_slashes(arg_root);
|
||||
+ break;
|
||||
+
|
||||
case '?':
|
||||
return -EINVAL;
|
||||
|
||||
@@ -1376,7 +1396,7 @@ static int read_config_file(const char *fn, bool ignore_enoent) {
|
||||
|
||||
assert(fn);
|
||||
|
||||
- r = search_and_fopen_nulstr(fn, "re", NULL, conf_file_dirs, &f);
|
||||
+ r = search_and_fopen_nulstr(fn, "re", arg_root, conf_file_dirs, &f);
|
||||
if (r < 0) {
|
||||
if (ignore_enoent && r == -ENOENT)
|
||||
return 0;
|
||||
@@ -1477,7 +1497,7 @@ int main(int argc, char *argv[]) {
|
||||
_cleanup_strv_free_ char **files = NULL;
|
||||
char **f;
|
||||
|
||||
- r = conf_files_list_nulstr(&files, ".conf", NULL, conf_file_dirs);
|
||||
+ r = conf_files_list_nulstr(&files, ".conf", arg_root, conf_file_dirs);
|
||||
if (r < 0) {
|
||||
log_error("Failed to enumerate tmpfiles.d files: %s", strerror(-r));
|
||||
goto finish;
|
||||
@@ -1508,6 +1528,7 @@ finish:
|
||||
|
||||
free(include_prefixes);
|
||||
free(exclude_prefixes);
|
||||
+ free(arg_root);
|
||||
|
||||
set_free_free(unix_sockets);
|
||||
|
||||
--
|
||||
1.8.3.2
|
||||
|
||||
_______________________________________________
|
||||
systemd-devel mailing list
|
||||
systemd-devel@lists.freedesktop.org
|
||||
http://lists.freedesktop.org/mailman/listinfo/systemd-devel
|
||||
|
@ -0,0 +1,39 @@
|
||||
From systemd-devel-bounces@lists.freedesktop.org Fri Mar 14 04:33:02 2014
|
||||
From: Michael Marineau <michael.marineau@coreos.com>
|
||||
Date: Thu, 13 Mar 2014 21:32:14 -0700
|
||||
Subject: [systemd-devel] [PATCH 3/3] tmpfiles: Add --root to the man page.
|
||||
To: systemd-devel@lists.freedesktop.org
|
||||
Message-ID: <1394771534-27529-3-git-send-email-michael.marineau@coreos.com>
|
||||
|
||||
|
||||
---
|
||||
man/systemd-tmpfiles.xml | 8 ++++++++
|
||||
1 file changed, 8 insertions(+)
|
||||
|
||||
diff --git a/man/systemd-tmpfiles.xml b/man/systemd-tmpfiles.xml
|
||||
index 0b62640..193acb7 100644
|
||||
--- a/man/systemd-tmpfiles.xml
|
||||
+++ b/man/systemd-tmpfiles.xml
|
||||
@@ -152,6 +152,14 @@
|
||||
prefix. This option can be specified
|
||||
multiple times.</para></listitem>
|
||||
</varlistentry>
|
||||
+ <varlistentry>
|
||||
+ <term><option>--root=ROOT</option></term>
|
||||
+ <listitem><para>Takes a directory path
|
||||
+ as an argument. All paths will be
|
||||
+ prefixed with the given alternate ROOT
|
||||
+ path, including config search paths.
|
||||
+ </para></listitem>
|
||||
+ </varlistentry>
|
||||
|
||||
<xi:include href="standard-options.xml" xpointer="help" />
|
||||
<xi:include href="standard-options.xml" xpointer="version" />
|
||||
--
|
||||
1.8.3.2
|
||||
|
||||
_______________________________________________
|
||||
systemd-devel mailing list
|
||||
systemd-devel@lists.freedesktop.org
|
||||
http://lists.freedesktop.org/mailman/listinfo/systemd-devel
|
||||
|
@ -0,0 +1,315 @@
|
||||
From systemd-devel-bounces@lists.freedesktop.org Fri Mar 14 04:42:13 2014
|
||||
From: Greg KH <gregkh@linuxfoundation.org>
|
||||
Date: Fri, 14 Mar 2014 04:43:04 +0000
|
||||
Subject: [systemd-devel] [PATCH] machine-id: add --root option to operate on an alternate fs tree
|
||||
To: systemd Mailing List <systemd-devel@lists.freedesktop.org>
|
||||
Message-ID: <20140314044304.GA24528@kroah.com>
|
||||
Content-Disposition: inline
|
||||
|
||||
|
||||
This makes it possible to initialize the /etc/machine-id file on an
|
||||
arbitrary filesystem hierarchy. This helps systems that wish to run
|
||||
this at image creation time in a subdirectory, or from initramfs before
|
||||
pivot-root is called.
|
||||
|
||||
diff --git a/man/systemd-machine-id-setup.xml b/man/systemd-machine-id-setup.xml
|
||||
index 5c34b345d012..b879b40b997d 100644
|
||||
--- a/man/systemd-machine-id-setup.xml
|
||||
+++ b/man/systemd-machine-id-setup.xml
|
||||
@@ -96,6 +96,14 @@
|
||||
<para>The following options are understood:</para>
|
||||
|
||||
<variablelist>
|
||||
+ <varlistentry>
|
||||
+ <term><option>--root=ROOT</option></term>
|
||||
+ <listitem><para>Takes a directory path
|
||||
+ as an argument. All paths will be
|
||||
+ prefixed with the given alternate ROOT
|
||||
+ path, including config search paths.
|
||||
+ </para></listitem>
|
||||
+ </varlistentry>
|
||||
<xi:include href="standard-options.xml" xpointer="help" />
|
||||
<xi:include href="standard-options.xml" xpointer="version" />
|
||||
</variablelist>
|
||||
diff --git a/src/core/machine-id-setup.c b/src/core/machine-id-setup.c
|
||||
index 1b55da7e56b8..7d52b468a11a 100644
|
||||
--- a/src/core/machine-id-setup.c
|
||||
+++ b/src/core/machine-id-setup.c
|
||||
@@ -59,18 +59,22 @@ static int shorten_uuid(char destination[36], const char *source) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
-static int generate(char id[34]) {
|
||||
- int fd, r;
|
||||
+static int generate(char id[34], const char *root) {
|
||||
+ int fd, r = 0;
|
||||
unsigned char *p;
|
||||
sd_id128_t buf;
|
||||
char *q;
|
||||
ssize_t k;
|
||||
const char *vm_id;
|
||||
+ char *dbus_machine_id;
|
||||
|
||||
assert(id);
|
||||
|
||||
+ if (asprintf(&dbus_machine_id, "%s/var/lib/dbus/machine-id", root) < 0)
|
||||
+ return log_oom();
|
||||
+
|
||||
/* First, try reading the D-Bus machine id, unless it is a symlink */
|
||||
- fd = open("/var/lib/dbus/machine-id", O_RDONLY|O_CLOEXEC|O_NOCTTY|O_NOFOLLOW);
|
||||
+ fd = open(dbus_machine_id, O_RDONLY|O_CLOEXEC|O_NOCTTY|O_NOFOLLOW);
|
||||
if (fd >= 0) {
|
||||
k = loop_read(fd, id, 33, false);
|
||||
close_nointr_nofail(fd);
|
||||
@@ -83,7 +87,7 @@ static int generate(char id[34]) {
|
||||
id[33] = 0;
|
||||
|
||||
log_info("Initializing machine ID from D-Bus machine ID.");
|
||||
- return 0;
|
||||
+ goto finish;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -105,7 +109,8 @@ static int generate(char id[34]) {
|
||||
r = shorten_uuid(id, uuid);
|
||||
if (r >= 0) {
|
||||
log_info("Initializing machine ID from KVM UUID.");
|
||||
- return 0;
|
||||
+ r = 0;
|
||||
+ goto finish;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -124,7 +129,8 @@ static int generate(char id[34]) {
|
||||
r = shorten_uuid(id, e);
|
||||
if (r >= 0) {
|
||||
log_info("Initializing machine ID from container UUID.");
|
||||
- return 0;
|
||||
+ r = 0;
|
||||
+ goto finish;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -134,7 +140,7 @@ static int generate(char id[34]) {
|
||||
r = sd_id128_randomize(&buf);
|
||||
if (r < 0) {
|
||||
log_error("Failed to open /dev/urandom: %s", strerror(-r));
|
||||
- return r;
|
||||
+ goto finish;
|
||||
}
|
||||
|
||||
for (p = buf.bytes, q = id; p < buf.bytes + sizeof(buf); p++, q += 2) {
|
||||
@@ -147,15 +153,27 @@ static int generate(char id[34]) {
|
||||
|
||||
log_info("Initializing machine ID from random generator.");
|
||||
|
||||
- return 0;
|
||||
+finish:
|
||||
+ free(dbus_machine_id);
|
||||
+ return r;
|
||||
}
|
||||
|
||||
-int machine_id_setup(void) {
|
||||
+int machine_id_setup(const char *root) {
|
||||
_cleanup_close_ int fd = -1;
|
||||
- int r;
|
||||
+ int r = 0;
|
||||
bool writable = false;
|
||||
struct stat st;
|
||||
char id[34]; /* 32 + \n + \0 */
|
||||
+ char *etc_machine_id = NULL;
|
||||
+ char *run_machine_id = NULL;
|
||||
+
|
||||
+ if (asprintf(&etc_machine_id, "%s/etc/machine-id", root) < 0)
|
||||
+ return log_oom();
|
||||
+
|
||||
+ if (asprintf(&run_machine_id, "%s/run/machine-id", root) < 0) {
|
||||
+ r = log_oom();
|
||||
+ goto finish;
|
||||
+ }
|
||||
|
||||
RUN_WITH_UMASK(0000) {
|
||||
/* We create this 0444, to indicate that this isn't really
|
||||
@@ -163,14 +181,15 @@ int machine_id_setup(void) {
|
||||
* will be owned by root it doesn't matter much, but maybe
|
||||
* people look. */
|
||||
|
||||
- fd = open("/etc/machine-id", O_RDWR|O_CREAT|O_CLOEXEC|O_NOCTTY, 0444);
|
||||
+ fd = open(etc_machine_id, O_RDWR|O_CREAT|O_CLOEXEC|O_NOCTTY, 0444);
|
||||
if (fd >= 0)
|
||||
writable = true;
|
||||
else {
|
||||
- fd = open("/etc/machine-id", O_RDONLY|O_CLOEXEC|O_NOCTTY);
|
||||
+ fd = open(etc_machine_id, O_RDONLY|O_CLOEXEC|O_NOCTTY);
|
||||
if (fd < 0) {
|
||||
- log_error("Cannot open /etc/machine-id: %m");
|
||||
- return -errno;
|
||||
+ log_error("Cannot open %s: %m", etc_machine_id);
|
||||
+ r = -errno;
|
||||
+ goto finish;
|
||||
}
|
||||
|
||||
writable = false;
|
||||
@@ -179,7 +198,8 @@ int machine_id_setup(void) {
|
||||
|
||||
if (fstat(fd, &st) < 0) {
|
||||
log_error("fstat() failed: %m");
|
||||
- return -errno;
|
||||
+ r = -errno;
|
||||
+ goto finish;
|
||||
}
|
||||
|
||||
if (S_ISREG(st.st_mode))
|
||||
@@ -187,21 +207,21 @@ int machine_id_setup(void) {
|
||||
id[32] = 0;
|
||||
|
||||
if (id128_is_valid(id))
|
||||
- return 0;
|
||||
+ goto finish;
|
||||
}
|
||||
|
||||
/* Hmm, so, the id currently stored is not useful, then let's
|
||||
* generate one */
|
||||
|
||||
- r = generate(id);
|
||||
+ r = generate(id, root);
|
||||
if (r < 0)
|
||||
- return r;
|
||||
+ goto finish;
|
||||
|
||||
if (S_ISREG(st.st_mode) && writable) {
|
||||
lseek(fd, 0, SEEK_SET);
|
||||
|
||||
if (loop_write(fd, id, 33, false) == 33)
|
||||
- return 0;
|
||||
+ goto finish;
|
||||
}
|
||||
|
||||
close_nointr_nofail(fd);
|
||||
@@ -211,27 +231,31 @@ int machine_id_setup(void) {
|
||||
* /run/machine-id as a replacement */
|
||||
|
||||
RUN_WITH_UMASK(0022) {
|
||||
- r = write_string_file("/run/machine-id", id);
|
||||
+ r = write_string_file(run_machine_id, id);
|
||||
}
|
||||
if (r < 0) {
|
||||
- log_error("Cannot write /run/machine-id: %s", strerror(-r));
|
||||
- unlink("/run/machine-id");
|
||||
- return r;
|
||||
+ log_error("Cannot write %s: %s", run_machine_id, strerror(-r));
|
||||
+ unlink(run_machine_id);
|
||||
+ goto finish;
|
||||
}
|
||||
|
||||
/* And now, let's mount it over */
|
||||
- r = mount("/run/machine-id", "/etc/machine-id", NULL, MS_BIND, NULL);
|
||||
+ r = mount(run_machine_id, etc_machine_id, NULL, MS_BIND, NULL);
|
||||
if (r < 0) {
|
||||
- log_error("Failed to mount /etc/machine-id: %m");
|
||||
- unlink_noerrno("/run/machine-id");
|
||||
- return -errno;
|
||||
+ log_error("Failed to mount %s: %m", etc_machine_id);
|
||||
+ unlink_noerrno(run_machine_id);
|
||||
+ r = -errno;
|
||||
+ goto finish;
|
||||
}
|
||||
|
||||
- log_info("Installed transient /etc/machine-id file.");
|
||||
+ log_info("Installed transient %s file.", etc_machine_id);
|
||||
|
||||
/* Mark the mount read-only */
|
||||
- if (mount(NULL, "/etc/machine-id", NULL, MS_BIND|MS_RDONLY|MS_REMOUNT, NULL) < 0)
|
||||
- log_warning("Failed to make transient /etc/machine-id read-only: %m");
|
||||
+ if (mount(NULL, etc_machine_id, NULL, MS_BIND|MS_RDONLY|MS_REMOUNT, NULL) < 0)
|
||||
+ log_warning("Failed to make transient %s read-only: %m", etc_machine_id);
|
||||
|
||||
- return 0;
|
||||
+finish:
|
||||
+ free(etc_machine_id);
|
||||
+ free(run_machine_id);
|
||||
+ return r;
|
||||
}
|
||||
diff --git a/src/core/machine-id-setup.h b/src/core/machine-id-setup.h
|
||||
index b9e6b4d674a6..b0583eefc8fe 100644
|
||||
--- a/src/core/machine-id-setup.h
|
||||
+++ b/src/core/machine-id-setup.h
|
||||
@@ -21,4 +21,4 @@
|
||||
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
-int machine_id_setup(void);
|
||||
+int machine_id_setup(const char *root);
|
||||
diff --git a/src/core/main.c b/src/core/main.c
|
||||
index f1b06d88803e..cc876efa9c2c 100644
|
||||
--- a/src/core/main.c
|
||||
+++ b/src/core/main.c
|
||||
@@ -1582,7 +1582,7 @@ int main(int argc, char *argv[]) {
|
||||
kmod_setup();
|
||||
#endif
|
||||
hostname_setup();
|
||||
- machine_id_setup();
|
||||
+ machine_id_setup("");
|
||||
loopback_setup();
|
||||
|
||||
test_mtab();
|
||||
diff --git a/src/machine-id-setup/machine-id-setup-main.c b/src/machine-id-setup/machine-id-setup-main.c
|
||||
index 84af925f517e..a67d436dbd7c 100644
|
||||
--- a/src/machine-id-setup/machine-id-setup-main.c
|
||||
+++ b/src/machine-id-setup/machine-id-setup-main.c
|
||||
@@ -29,12 +29,15 @@
|
||||
#include "log.h"
|
||||
#include "build.h"
|
||||
|
||||
+static const char *arg_root = "";
|
||||
+
|
||||
static int help(void) {
|
||||
|
||||
printf("%s [OPTIONS...]\n\n"
|
||||
"Initialize /etc/machine-id from a random source.\n\n"
|
||||
" -h --help Show this help\n"
|
||||
- " --version Show package version\n",
|
||||
+ " --version Show package version\n"
|
||||
+ " --root Filesystem root\n",
|
||||
program_invocation_short_name);
|
||||
|
||||
return 0;
|
||||
@@ -43,12 +46,14 @@ static int help(void) {
|
||||
static int parse_argv(int argc, char *argv[]) {
|
||||
|
||||
enum {
|
||||
- ARG_VERSION = 0x100
|
||||
+ ARG_VERSION = 0x100,
|
||||
+ ARG_ROOT,
|
||||
};
|
||||
|
||||
static const struct option options[] = {
|
||||
{ "help", no_argument, NULL, 'h' },
|
||||
{ "version", no_argument, NULL, ARG_VERSION },
|
||||
+ { "root", required_argument, NULL, ARG_ROOT },
|
||||
{}
|
||||
};
|
||||
|
||||
@@ -69,6 +74,10 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
puts(SYSTEMD_FEATURES);
|
||||
return 0;
|
||||
|
||||
+ case ARG_ROOT:
|
||||
+ arg_root = optarg;
|
||||
+ break;
|
||||
+
|
||||
case '?':
|
||||
return -EINVAL;
|
||||
|
||||
@@ -95,5 +104,5 @@ int main(int argc, char *argv[]) {
|
||||
if (r <= 0)
|
||||
return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
|
||||
|
||||
- return machine_id_setup() < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
|
||||
+ return machine_id_setup(arg_root) < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
|
||||
}
|
||||
_______________________________________________
|
||||
systemd-devel mailing list
|
||||
systemd-devel@lists.freedesktop.org
|
||||
http://lists.freedesktop.org/mailman/listinfo/systemd-devel
|
||||
|
@ -109,8 +109,22 @@ src_prepare() {
|
||||
epatch "${FILESDIR}"/211-handle-empty-etc-os-release.patch
|
||||
|
||||
# upstream fixes not yet in the release
|
||||
epatch "${FILESDIR}"/211-0001-gpt-auto-generator-don-t-return-OOM-on-parentless-de.patch
|
||||
epatch "${FILESDIR}"/211-0002-bus-fix-memory-leak-when-kdbus-is-not-enabled.patch
|
||||
epatch "${FILESDIR}"/211-0003-sd-bus-don-t-look-for-a-64bit-value-when-we-only-hav.patch
|
||||
epatch "${FILESDIR}"/211-0004-nspawn-allow-EEXIST-on-mkdir_safe-home-uid.patch
|
||||
epatch "${FILESDIR}"/211-0005-networkd-fix-creation-of-runtime-dirs-at-startup.patch
|
||||
epatch "${FILESDIR}"/211-0006-networkd-lease-store-up-to-one-dhcp-lease-file-per-i.patch
|
||||
epatch "${FILESDIR}"/211-0007-Do-not-return-1-EINVAL-on-allocation-error.patch
|
||||
|
||||
# patch to make journald work at first boot
|
||||
epatch "${FILESDIR}"/211-tmpfiles.patch
|
||||
epatch "${FILESDIR}"/211-0001-nspawn-allow-EEXIST-on-mkdir_safe-home-uid.patch
|
||||
|
||||
# --root= options to some utilities needed by initramfs
|
||||
epatch "${FILESDIR}"/211-001-shared-add-root-argument-to-search_and_fopen.patch
|
||||
epatch "${FILESDIR}"/211-002-tmpfiles-add-root-option-to-operate-on-an-alternate-fs-tree.patch
|
||||
epatch "${FILESDIR}"/211-003-tmpfiles-add-root-to-the-man-page.patch
|
||||
epatch "${FILESDIR}"/211-004-machine-id-add-root-option-to-operate-on-an-alternate-fs-tree.patch
|
||||
|
||||
if [[ ${PV} == *9999 ]]; then
|
||||
if use doc; then
|
Loading…
x
Reference in New Issue
Block a user