summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rules/60-block.rules2
-rw-r--r--rules/60-persistent-storage.rules2
-rw-r--r--src/cryptsetup/cryptsetup.c90
-rw-r--r--src/libsystemd/libsystemd.sym.m41
-rw-r--r--src/libsystemd/sd-bus/bus-convenience.c37
-rw-r--r--src/network/networkd-dhcp4.c2
-rw-r--r--src/network/networkd-ipv4ll.c2
-rw-r--r--src/network/networkd-link.c12
-rw-r--r--src/shared/util.c17
-rw-r--r--src/systemd/sd-bus.h1
10 files changed, 113 insertions, 53 deletions
diff --git a/rules/60-block.rules b/rules/60-block.rules
index a69d648023..c74caca49f 100644
--- a/rules/60-block.rules
+++ b/rules/60-block.rules
@@ -8,4 +8,4 @@ ACTION=="add", SUBSYSTEM=="module", KERNEL=="block", ATTR{parameters/events_dfl_
ACTION=="change", SUBSYSTEM=="scsi", ENV{DEVTYPE}=="scsi_device", TEST=="block", ATTR{block/*/uevent}="change"
# watch metadata changes, caused by tools closing the device node which was opened for writing
-ACTION!="remove", SUBSYSTEM=="block", KERNEL=="loop*|nvme*|sd*|vd*", OPTIONS+="watch"
+ACTION!="remove", SUBSYSTEM=="block", KERNEL=="loop*|nvme*|sd*|vd*|xvd*", OPTIONS+="watch"
diff --git a/rules/60-persistent-storage.rules b/rules/60-persistent-storage.rules
index 64c5f1cfdd..2daeb6db42 100644
--- a/rules/60-persistent-storage.rules
+++ b/rules/60-persistent-storage.rules
@@ -6,7 +6,7 @@
ACTION=="remove", GOTO="persistent_storage_end"
SUBSYSTEM!="block", GOTO="persistent_storage_end"
-KERNEL!="loop*|mmcblk*[0-9]|msblk*[0-9]|mspblk*[0-9]|nvme*|sd*|sr*|vd*|bcache*|xvd*", GOTO="persistent_storage_end"
+KERNEL!="loop*|mmcblk*[0-9]|msblk*[0-9]|mspblk*[0-9]|nvme*|sd*|sr*|vd*|xvd*|bcache*", GOTO="persistent_storage_end"
# ignore partitions that span the entire disk
TEST=="whole_disk", GOTO="persistent_storage_end"
diff --git a/src/cryptsetup/cryptsetup.c b/src/cryptsetup/cryptsetup.c
index a5018f13ed..5c6c7c0ed8 100644
--- a/src/cryptsetup/cryptsetup.c
+++ b/src/cryptsetup/cryptsetup.c
@@ -238,6 +238,23 @@ static void log_glue(int level, const char *msg, void *usrptr) {
log_debug("%s", msg);
}
+static int disk_major_minor(const char *path, char **ret) {
+ struct stat st;
+
+ assert(path);
+
+ if (stat(path, &st) < 0)
+ return -errno;
+
+ if (!S_ISBLK(st.st_mode))
+ return -EINVAL;
+
+ if (asprintf(ret, "/dev/block/%d:%d", major(st.st_rdev), minor(st.st_rdev)) < 0)
+ return -errno;
+
+ return 0;
+}
+
static char* disk_description(const char *path) {
static const char name_fields[] =
@@ -295,20 +312,55 @@ static char *disk_mount_point(const char *label) {
return NULL;
}
-static int get_password(const char *name, usec_t until, bool accept_cached, char ***passwords) {
- int r;
+static int get_password(const char *vol, const char *src, usec_t until, bool accept_cached, char ***passwords) {
+ int r = 0;
char **p;
_cleanup_free_ char *text = NULL;
_cleanup_free_ char *escaped_name = NULL;
char *id;
+ const char *name = NULL;
+ _cleanup_free_ char *description = NULL, *name_buffer = NULL,
+ *mount_point = NULL, *maj_min = NULL;
- assert(name);
+ assert(vol);
+ assert(src);
assert(passwords);
+ description = disk_description(src);
+ mount_point = disk_mount_point(vol);
+
+ if (description && streq(vol, description)) {
+ /* If the description string is simply the
+ * volume name, then let's not show this
+ * twice */
+ free(description);
+ description = NULL;
+ }
+
+ if (mount_point && description)
+ r = asprintf(&name_buffer, "%s (%s) on %s", description, vol, mount_point);
+ else if (mount_point)
+ r = asprintf(&name_buffer, "%s on %s", vol, mount_point);
+ else if (description)
+ r = asprintf(&name_buffer, "%s (%s)", description, vol);
+
+ if (r < 0)
+ return log_oom();
+
+ name = name_buffer ? name_buffer : vol;
+
if (asprintf(&text, "Please enter passphrase for disk %s!", name) < 0)
return log_oom();
- escaped_name = cescape(name);
+ if (src)
+ (void) disk_major_minor(src, &maj_min);
+
+ if (maj_min) {
+ escaped_name = maj_min;
+ maj_min = NULL;
+ } else
+ escaped_name = cescape(name);
+
if (!escaped_name)
return log_oom();
@@ -552,8 +604,7 @@ int main(int argc, char *argv[]) {
unsigned tries;
usec_t until;
crypt_status_info status;
- const char *key_file = NULL, *name = NULL;
- _cleanup_free_ char *description = NULL, *name_buffer = NULL, *mount_point = NULL;
+ const char *key_file = NULL;
/* Arguments: systemd-cryptsetup attach VOLUME SOURCE-DEVICE [PASSWORD] [OPTIONS] */
@@ -581,31 +632,6 @@ int main(int argc, char *argv[]) {
/* A delicious drop of snake oil */
mlockall(MCL_FUTURE);
- description = disk_description(argv[3]);
- mount_point = disk_mount_point(argv[2]);
-
- if (description && streq(argv[2], description)) {
- /* If the description string is simply the
- * volume name, then let's not show this
- * twice */
- free(description);
- description = NULL;
- }
-
- k = 0;
- if (mount_point && description)
- k = asprintf(&name_buffer, "%s (%s) on %s", description, argv[2], mount_point);
- else if (mount_point)
- k = asprintf(&name_buffer, "%s on %s", argv[2], mount_point);
- else if (description)
- k = asprintf(&name_buffer, "%s (%s)", description, argv[2]);
-
- if (k < 0) {
- log_oom();
- goto finish;
- }
- name = name_buffer ? name_buffer : argv[2];
-
if (arg_header) {
log_debug("LUKS header: %s", arg_header);
k = crypt_init(&cd, arg_header);
@@ -652,7 +678,7 @@ int main(int argc, char *argv[]) {
_cleanup_strv_free_ char **passwords = NULL;
if (!key_file) {
- k = get_password(name, until, tries == 0 && !arg_verify, &passwords);
+ k = get_password(argv[2], argv[3], until, tries == 0 && !arg_verify, &passwords);
if (k == -EAGAIN)
continue;
else if (k < 0)
diff --git a/src/libsystemd/libsystemd.sym.m4 b/src/libsystemd/libsystemd.sym.m4
index 0b94a87dd6..3121e71282 100644
--- a/src/libsystemd/libsystemd.sym.m4
+++ b/src/libsystemd/libsystemd.sym.m4
@@ -320,6 +320,7 @@ global:
sd_bus_get_name_creds;
sd_bus_get_name_machine_id;
sd_bus_call_method;
+ sd_bus_call_method_async;
sd_bus_get_property;
sd_bus_get_property_trivial;
sd_bus_get_property_string;
diff --git a/src/libsystemd/sd-bus/bus-convenience.c b/src/libsystemd/sd-bus/bus-convenience.c
index 28bc8d2818..dfd82e746d 100644
--- a/src/libsystemd/sd-bus/bus-convenience.c
+++ b/src/libsystemd/sd-bus/bus-convenience.c
@@ -58,6 +58,43 @@ _public_ int sd_bus_emit_signal(
return sd_bus_send(bus, m, NULL);
}
+_public_ int sd_bus_call_method_async(
+ sd_bus *bus,
+ sd_bus_slot **slot,
+ const char *destination,
+ const char *path,
+ const char *interface,
+ const char *member,
+ sd_bus_message_handler_t callback,
+ void *userdata,
+ const char *types, ...) {
+
+ _cleanup_bus_message_unref_ sd_bus_message *m = NULL;
+ int r;
+
+ assert_return(bus, -EINVAL);
+ assert_return(!bus_pid_changed(bus), -ECHILD);
+
+ if (!BUS_IS_OPEN(bus->state))
+ return -ENOTCONN;
+
+ r = sd_bus_message_new_method_call(bus, &m, destination, path, interface, member);
+ if (r < 0)
+ return r;
+
+ if (!isempty(types)) {
+ va_list ap;
+
+ va_start(ap, types);
+ r = bus_message_append_ap(m, types, ap);
+ va_end(ap);
+ if (r < 0)
+ return r;
+ }
+
+ return sd_bus_call_async(bus, slot, m, callback, userdata, 0);
+}
+
_public_ int sd_bus_call_method(
sd_bus *bus,
const char *destination,
diff --git a/src/network/networkd-dhcp4.c b/src/network/networkd-dhcp4.c
index 20aee53d6e..71cc722bcc 100644
--- a/src/network/networkd-dhcp4.c
+++ b/src/network/networkd-dhcp4.c
@@ -561,7 +561,7 @@ int dhcp4_configure(Link *link) {
assert(link);
assert(link->network);
- assert(IN_SET(link->network->dhcp, ADDRESS_FAMILY_YES, ADDRESS_FAMILY_IPV4));
+ assert(link->network->dhcp & ADDRESS_FAMILY_IPV4);
r = sd_dhcp_client_new(&link->dhcp_client);
if (r < 0)
diff --git a/src/network/networkd-ipv4ll.c b/src/network/networkd-ipv4ll.c
index 74b3dea235..14b8770429 100644
--- a/src/network/networkd-ipv4ll.c
+++ b/src/network/networkd-ipv4ll.c
@@ -209,7 +209,7 @@ int ipv4ll_configure(Link *link) {
assert(link);
assert(link->network);
- assert(IN_SET(link->network->link_local, ADDRESS_FAMILY_IPV4, ADDRESS_FAMILY_YES));
+ assert(link->network->link_local & ADDRESS_FAMILY_IPV4);
r = sd_ipv4ll_new(&link->ipv4ll);
if (r < 0)
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index f039a2d687..127bc1249a 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -40,7 +40,7 @@ bool link_dhcp6_enabled(Link *link) {
if (!link->network)
return false;
- return IN_SET(link->network->dhcp, ADDRESS_FAMILY_IPV6, ADDRESS_FAMILY_YES);
+ return link->network->dhcp & ADDRESS_FAMILY_IPV6;
}
bool link_dhcp4_enabled(Link *link) {
@@ -50,7 +50,7 @@ bool link_dhcp4_enabled(Link *link) {
if (!link->network)
return false;
- return IN_SET(link->network->dhcp, ADDRESS_FAMILY_IPV4, ADDRESS_FAMILY_YES);
+ return link->network->dhcp & ADDRESS_FAMILY_IPV4;
}
bool link_dhcp4_server_enabled(Link *link) {
@@ -70,7 +70,7 @@ bool link_ipv4ll_enabled(Link *link) {
if (!link->network)
return false;
- return IN_SET(link->network->link_local, ADDRESS_FAMILY_IPV4, ADDRESS_FAMILY_YES);
+ return link->network->link_local & ADDRESS_FAMILY_IPV4;
}
bool link_ipv6ll_enabled(Link *link) {
@@ -80,7 +80,7 @@ bool link_ipv6ll_enabled(Link *link) {
if (!link->network)
return false;
- return IN_SET(link->network->link_local, ADDRESS_FAMILY_IPV6, ADDRESS_FAMILY_YES);
+ return link->network->link_local & ADDRESS_FAMILY_IPV6;
}
bool link_lldp_enabled(Link *link) {
@@ -103,7 +103,7 @@ static bool link_ipv4_forward_enabled(Link *link) {
if (!link->network)
return false;
- return IN_SET(link->network->ip_forward, ADDRESS_FAMILY_IPV4, ADDRESS_FAMILY_YES);
+ return link->network->ip_forward & ADDRESS_FAMILY_IPV4;
}
static bool link_ipv6_forward_enabled(Link *link) {
@@ -113,7 +113,7 @@ static bool link_ipv6_forward_enabled(Link *link) {
if (!link->network)
return false;
- return IN_SET(link->network->ip_forward, ADDRESS_FAMILY_IPV6, ADDRESS_FAMILY_YES);
+ return link->network->ip_forward & ADDRESS_FAMILY_IPV6;
}
#define FLAG_STRING(string, flag, old, new) \
diff --git a/src/shared/util.c b/src/shared/util.c
index 1442301cd7..dc5e938796 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -4931,15 +4931,11 @@ int bind_remount_recursive(const char *prefix, bool ro) {
while ((x = set_steal_first(todo))) {
- r = set_put(done, x);
- if (r == -EEXIST) {
- free(x);
+ r = set_consume(done, x);
+ if (r == -EEXIST || r == 0)
continue;
- }
- if (r < 0) {
- free(x);
+ if (r < 0)
return r;
- }
/* Try to reuse the original flag set, but
* don't care for errors, in case of
@@ -4949,15 +4945,14 @@ int bind_remount_recursive(const char *prefix, bool ro) {
orig_flags &= ~MS_RDONLY;
if (mount(NULL, x, NULL, orig_flags|MS_BIND|MS_REMOUNT|(ro ? MS_RDONLY : 0), NULL) < 0) {
+
/* Deal with mount points that are
* obstructed by a later mount */
- if (errno != ENOENT) {
- free(x);
+ if (errno != ENOENT)
return -errno;
- }
}
- free(x);
+
}
}
}
diff --git a/src/systemd/sd-bus.h b/src/systemd/sd-bus.h
index e6e2ecd0b7..57e46ced8e 100644
--- a/src/systemd/sd-bus.h
+++ b/src/systemd/sd-bus.h
@@ -299,6 +299,7 @@ int sd_bus_get_name_machine_id(sd_bus *bus, const char *name, sd_id128_t *machin
/* Convenience calls */
int sd_bus_call_method(sd_bus *bus, const char *destination, const char *path, const char *interface, const char *member, sd_bus_error *ret_error, sd_bus_message **reply, const char *types, ...);
+int sd_bus_call_method_async(sd_bus *bus, sd_bus_slot **slot, const char *destination, const char *path, const char *interface, const char *member, sd_bus_message_handler_t callback, void *userdata, const char *types, ...);
int sd_bus_get_property(sd_bus *bus, const char *destination, const char *path, const char *interface, const char *member, sd_bus_error *ret_error, sd_bus_message **reply, const char *type);
int sd_bus_get_property_trivial(sd_bus *bus, const char *destination, const char *path, const char *interface, const char *member, sd_bus_error *ret_error, char type, void *ret_ptr);
int sd_bus_get_property_string(sd_bus *bus, const char *destination, const char *path, const char *interface, const char *member, sd_bus_error *ret_error, char **ret); /* free the result! */