summaryrefslogtreecommitdiff
path: root/src/home
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2020-04-15 19:35:55 +0200
committerLennart Poettering <lennart@poettering.net>2020-07-01 11:17:28 +0200
commitc98811d837c5b00370e25737766325b2ae6307fc (patch)
tree13697b8a734994d2fa2a0744da7c135533f9d24c /src/home
parent8e62dfb12aff85cc894ff7eef39fb21623335566 (diff)
downloadsystemd-c98811d837c5b00370e25737766325b2ae6307fc.tar.gz
homectl: rework how we log when doing a home directory update
When updating a home directory we might update the record first, then resize the image and finally synchronize the passwords to the storage layers. These are three individually authenticated operations. Since each might require touching a FIDO2 or PKCS#11 key we should say what we are doing. Hence do so. Usually we are pretty quiet with what we do, and let's stick to that. Hence show this information only if we actually do more than one thing. If we only update (and do not resize/sync passwords) then let's be quiet as usual, as the command line then sufficiently clarifies what we are doing.
Diffstat (limited to 'src/home')
-rw-r--r--src/home/homectl.c40
1 files changed, 36 insertions, 4 deletions
diff --git a/src/home/homectl.c b/src/home/homectl.c
index 943f526676..d47a9a6589 100644
--- a/src/home/homectl.c
+++ b/src/home/homectl.c
@@ -1623,6 +1623,26 @@ static int acquire_updated_home_record(
return 0;
}
+static int home_record_reset_human_interaction_permission(UserRecord *hr) {
+ int r;
+
+ assert(hr);
+
+ /* When we execute multiple operations one after the other, let's reset the permission to ask the
+ * user each time, so that if interaction is necessary we will be told so again and thus can print a
+ * nice message to the user, telling the user so. */
+
+ r = user_record_set_pkcs11_protected_authentication_path_permitted(hr, -1);
+ if (r < 0)
+ return log_error_errno(r, "Failed to reset PKCS#11 protected authentication path permission flag: %m");
+
+ r = user_record_set_fido2_user_presence_permitted(hr, -1);
+ if (r < 0)
+ return log_error_errno(r, "Failed to reset FIDO2 user presence permission flag: %m");
+
+ return 0;
+}
+
static int update_home(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
_cleanup_(user_record_unrefp) UserRecord *hr = NULL;
@@ -1651,6 +1671,12 @@ static int update_home(int argc, char *argv[], void *userdata) {
if (r < 0)
return r;
+ /* If we do multiple operations, let's output things more verbosely, since otherwise the repeated
+ * authentication might be confusing. */
+
+ if (arg_and_resize || arg_and_change_password)
+ log_info("Updating home directory.");
+
for (;;) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
@@ -1686,13 +1712,16 @@ static int update_home(int argc, char *argv[], void *userdata) {
break;
}
+ if (arg_and_resize)
+ log_info("Resizing home.");
+
+ (void) home_record_reset_human_interaction_permission(hr);
+
/* Also sync down disk size to underlying LUKS/fscrypt/quota */
while (arg_and_resize) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
- log_debug("Resizing");
-
r = bus_message_new_method_call(bus, &m, bus_home_mgr, "ResizeHome");
if (r < 0)
return bus_log_create_error(r);
@@ -1719,13 +1748,16 @@ static int update_home(int argc, char *argv[], void *userdata) {
break;
}
+ if (arg_and_change_password)
+ log_info("Synchronizing passwords and encryption keys.");
+
+ (void) home_record_reset_human_interaction_permission(hr);
+
/* Also sync down passwords to underlying LUKS/fscrypt */
while (arg_and_change_password) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
- log_debug("Propagating password");
-
r = bus_message_new_method_call(bus, &m, bus_home_mgr, "ChangePasswordHome");
if (r < 0)
return bus_log_create_error(r);