[systemd-commits] 3 commits - src/libsystemd src/libsystemd-network src/tmpfiles
Lennart Poettering
lennart at kemper.freedesktop.org
Fri Apr 10 10:05:56 PDT 2015
src/libsystemd-network/sd-dhcp-client.c | 11 +++-------
src/libsystemd/sd-event/sd-event.c | 22 ++++++++------------
src/tmpfiles/tmpfiles.c | 35 +++++++++++++++++++++-----------
3 files changed, 37 insertions(+), 31 deletions(-)
New commits:
commit 3dc055541c570e93c817e42f451f7d3519629cbc
Author: Lennart Poettering <lennart at poettering.net>
Date: Fri Apr 10 19:04:43 2015 +0200
Revert "sd-dhcp-client: fix strict aliasing issue"
This reverts commit 6ec8e7c763b7dfa82e25e31f6938122748d1608f.
This doesn't fix any issues, just makes the code harder to read.
diff --git a/src/libsystemd-network/sd-dhcp-client.c b/src/libsystemd-network/sd-dhcp-client.c
index a477ccc..4224e01 100644
--- a/src/libsystemd-network/sd-dhcp-client.c
+++ b/src/libsystemd-network/sd-dhcp-client.c
@@ -1469,7 +1469,7 @@ static int client_receive_message_udp(sd_event_source *s, int fd,
_cleanup_free_ DHCPMessage *message = NULL;
int buflen = 0, len, r;
const struct ether_addr zero_mac = { { 0, 0, 0, 0, 0, 0 } };
- bool expect_chaddr;
+ const struct ether_addr *expected_chaddr = NULL;
uint8_t expected_hlen = 0;
assert(s);
@@ -1514,11 +1514,11 @@ static int client_receive_message_udp(sd_event_source *s, int fd,
if (client->arp_type == ARPHRD_ETHER) {
expected_hlen = ETH_ALEN;
- expect_chaddr = true;
+ expected_chaddr = (const struct ether_addr *) &client->mac_addr;
} else {
/* Non-ethernet links expect zero chaddr */
expected_hlen = 0;
- expect_chaddr = false;
+ expected_chaddr = &zero_mac;
}
if (message->hlen != expected_hlen) {
@@ -1526,10 +1526,7 @@ static int client_receive_message_udp(sd_event_source *s, int fd,
return 0;
}
- if (memcmp(&message->chaddr[0], expect_chaddr ?
- (void *)&client->mac_addr :
- (void *)&zero_mac,
- ETH_ALEN)) {
+ if (memcmp(&message->chaddr[0], expected_chaddr, ETH_ALEN)) {
log_dhcp_client(client, "received chaddr does not match "
"expected: ignoring");
return 0;
commit 53bac4e0e32b017e7a5c1fd1181c740a1583e3fd
Author: Lennart Poettering <lennart at poettering.net>
Date: Fri Apr 10 18:45:39 2015 +0200
sd-event: simplify sd_event_run()
diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c
index 376477f..0dc4680 100644
--- a/src/libsystemd/sd-event/sd-event.c
+++ b/src/libsystemd/sd-event/sd-event.c
@@ -2490,24 +2490,20 @@ _public_ int sd_event_run(sd_event *e, uint64_t timeout) {
assert_return(e->state == SD_EVENT_INITIAL, -EBUSY);
r = sd_event_prepare(e);
- if (r > 0) {
- r = sd_event_dispatch(e);
- if (r < 0)
- return r;
- else
- return 1;
- } else if (r < 0)
- return r;
+ if (r == 0)
+ /* There was nothing? Then wait... */
+ r = sd_event_wait(e, timeout);
- r = sd_event_wait(e, timeout);
if (r > 0) {
+ /* There's something now, then let's dispatch it */
r = sd_event_dispatch(e);
if (r < 0)
return r;
- else
- return 1;
- } else
- return r;
+
+ return 1;
+ }
+
+ return r;
}
_public_ int sd_event_loop(sd_event *e) {
commit 5c5ccf12b623a1e77684c58bb0d06e1d4fd73e21
Author: Lennart Poettering <lennart at poettering.net>
Date: Fri Apr 10 18:07:04 2015 +0200
tmpfiles: add specifier expansion for L and C lines, too
diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
index 1603ab2..3ca9b4a 100644
--- a/src/tmpfiles/tmpfiles.c
+++ b/src/tmpfiles/tmpfiles.c
@@ -1105,17 +1105,23 @@ static int create_item(Item *i) {
return r;
break;
- case COPY_FILES:
- log_debug("Copying tree \"%s\" to \"%s\".", i->argument, i->path);
- r = copy_tree(i->argument, i->path, false);
+ case COPY_FILES: {
+ _cleanup_free_ char *resolved = NULL;
+
+ r = specifier_printf(i->argument, specifier_table, NULL, &resolved);
+ if (r < 0)
+ return log_error_errno(r, "Failed to substitute specifiers in copy source %s: %m", i->argument);
+
+ log_debug("Copying tree \"%s\" to \"%s\".", resolved, i->path);
+ r = copy_tree(resolved, i->path, false);
if (r < 0) {
struct stat a, b;
if (r != -EEXIST)
return log_error_errno(r, "Failed to copy files to %s: %m", i->path);
- if (stat(i->argument, &a) < 0)
- return log_error_errno(errno, "stat(%s) failed: %m", i->argument);
+ if (stat(resolved, &a) < 0)
+ return log_error_errno(errno, "stat(%s) failed: %m", resolved);
if (stat(i->path, &b) < 0)
return log_error_errno(errno, "stat(%s) failed: %m", i->path);
@@ -1224,29 +1230,35 @@ static int create_item(Item *i) {
return r;
break;
+ }
- case CREATE_SYMLINK:
+ case CREATE_SYMLINK: {
+ _cleanup_free_ char *resolved = NULL;
+
+ r = specifier_printf(i->argument, specifier_table, NULL, &resolved);
+ if (r < 0)
+ return log_error_errno(r, "Failed to substitute specifiers in symlink target %s: %m", i->argument);
mac_selinux_create_file_prepare(i->path, S_IFLNK);
- r = symlink(i->argument, i->path);
+ r = symlink(resolved, i->path);
mac_selinux_create_file_clear();
if (r < 0) {
_cleanup_free_ char *x = NULL;
if (errno != EEXIST)
- return log_error_errno(errno, "symlink(%s, %s) failed: %m", i->argument, i->path);
+ return log_error_errno(errno, "symlink(%s, %s) failed: %m", resolved, i->path);
r = readlink_malloc(i->path, &x);
- if (r < 0 || !streq(i->argument, x)) {
+ if (r < 0 || !streq(resolved, x)) {
if (i->force) {
mac_selinux_create_file_prepare(i->path, S_IFLNK);
- r = symlink_atomic(i->argument, i->path);
+ r = symlink_atomic(resolved, i->path);
mac_selinux_create_file_clear();
if (r < 0)
- return log_error_errno(r, "symlink(%s, %s) failed: %m", i->argument, i->path);
+ return log_error_errno(r, "symlink(%s, %s) failed: %m", resolved, i->path);
creation = CREATION_FORCE;
} else {
log_debug("\"%s\" is not a symlink or does not point to the correct path.", i->path);
@@ -1259,6 +1271,7 @@ static int create_item(Item *i) {
log_debug("%s symlink \"%s\".", creation_mode_verb_to_string(creation), i->path);
break;
+ }
case CREATE_BLOCK_DEVICE:
case CREATE_CHAR_DEVICE: {
More information about the systemd-commits
mailing list