From 8e62dfb12aff85cc894ff7eef39fb21623335566 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 15 Apr 2020 19:35:07 +0200 Subject: [PATCH] homectl: do generic error handling/retry also when creating a home directory After all, when creating we might need interaction with the security token too, and our initial attempt to create the user will fail, since we do not allow interactive auth on the security token, so that we then can print a log message and retry with interactive auth then enabled. --- src/home/homectl.c | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/src/home/homectl.c b/src/home/homectl.c index 41531735de..943f526676 100644 --- a/src/home/homectl.c +++ b/src/home/homectl.c @@ -1459,25 +1459,28 @@ static int create_home(int argc, char *argv[], void *userdata) { r = sd_bus_call(bus, m, HOME_SLOW_BUS_CALL_TIMEOUT_USEC, &error, NULL); if (r < 0) { - if (!sd_bus_error_has_name(&error, BUS_ERROR_LOW_PASSWORD_QUALITY)) - return log_error_errno(r, "Failed to create user home: %s", bus_error_message(&error, r)); - - log_error_errno(r, "%s", bus_error_message(&error, r)); - log_info("(Use --enforce-password-policy=no to turn off password quality checks for this account.)"); - } else - break; /* done */ + if (sd_bus_error_has_name(&error, BUS_ERROR_LOW_PASSWORD_QUALITY)) { + log_error_errno(r, "%s", bus_error_message(&error, r)); + log_info("(Use --enforce-password-policy=no to turn off password quality checks for this account.)"); - r = user_record_set_hashed_password(hr, original_hashed_passwords); - if (r < 0) - return r; + r = user_record_set_hashed_password(hr, original_hashed_passwords); + if (r < 0) + return r; - r = acquire_new_password(hr->user_name, hr, /* suggest = */ false); - if (r < 0) - return r; + r = acquire_new_password(hr->user_name, hr, /* suggest = */ false); + if (r < 0) + return r; - r = user_record_make_hashed_password(hr, hr->password, /* extend = */ true); - if (r < 0) - return log_error_errno(r, "Failed to hash passwords: %m"); + r = user_record_make_hashed_password(hr, hr->password, /* extend = */ true); + if (r < 0) + return log_error_errno(r, "Failed to hash passwords: %m"); + } else { + r = handle_generic_user_record_error(hr->user_name, hr, &error, r, false); + if (r < 0) + return r; + } + } else + break; /* done */ } return 0; -- 2.25.1