From 367649ee669b77793bdaf3d50effcc03f0ae9706 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 22 Dec 2021 17:11:31 +0900 Subject: [PATCH 1/3] home: update log message The ratelimit hits even when the all previous attempts are successfull. --- src/home/homectl.c | 2 +- src/home/pam_systemd_home.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/home/homectl.c b/src/home/homectl.c index 6057c04bae..1e3c96f5ad 100644 --- a/src/home/homectl.c +++ b/src/home/homectl.c @@ -383,7 +383,7 @@ static int handle_generic_user_record_error( else if (sd_bus_error_has_name(error, BUS_ERROR_AUTHENTICATION_LIMIT_HIT)) return log_error_errno(SYNTHETIC_ERRNO(ETOOMANYREFS), - "Too frequent unsuccessful login attempts for user %s, try again later.", user_name); + "Too frequent login attempts for user %s, try again later.", user_name); else if (sd_bus_error_has_name(error, BUS_ERROR_BAD_PASSWORD)) { diff --git a/src/home/pam_systemd_home.c b/src/home/pam_systemd_home.c index 3835efd608..35195c2ef0 100644 --- a/src/home/pam_systemd_home.c +++ b/src/home/pam_systemd_home.c @@ -293,7 +293,7 @@ static int handle_generic_user_record_error( return PAM_PERM_DENIED; } else if (sd_bus_error_has_name(error, BUS_ERROR_AUTHENTICATION_LIMIT_HIT)) { - (void) pam_prompt(handle, PAM_ERROR_MSG, NULL, "Too frequent unsuccessful login attempts for user %s, try again later.", user_name); + (void) pam_prompt(handle, PAM_ERROR_MSG, NULL, "Too frequent login attempts for user %s, try again later.", user_name); pam_syslog(handle, LOG_ERR, "Failed to acquire home for user %s: %s", user_name, bus_error_message(error, ret)); return PAM_MAXTRIES; From a75a4148a8d8d682fd93127e5828d64d70f12c8f Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 22 Dec 2021 15:43:05 +0900 Subject: [PATCH 2/3] test: remove test-user2 Otherwise, we cannot run the test multiple times. --- test/units/testsuite-46.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/units/testsuite-46.sh b/test/units/testsuite-46.sh index 3313c18167..d0bedc63d5 100755 --- a/test/units/testsuite-46.sh +++ b/test/units/testsuite-46.sh @@ -26,6 +26,13 @@ inspect() { homectl inspect --json=pretty "$USERNAME" } +wait_for_state() { + for ((i=0;i<10;i++)) ; do + homectl inspect "$1" | grep -qF "State: $2" && break + sleep .5 + done +} + systemd-analyze log-level debug systemd-analyze log-target console systemctl service-log-level systemd-homed debug @@ -156,8 +163,16 @@ PASSWORD=xEhErW0ndafV4s homectl with test-user -- test ! -f /home/test-user/xyz PASSWORD=xEhErW0ndafV4s homectl with test-user -- test -f /home/test-user/xyz \ && { echo 'unexpected success'; exit 1; } +wait_for_state test-user inactive homectl remove test-user +if ! systemd-detect-virt -cq ; then + wait_for_state test-user2 active + homectl deactivate test-user2 + wait_for_state test-user2 inactive + homectl remove test-user2 +fi + systemd-analyze log-level info echo OK >/testok From de27f4c8b8dd230a936f1b467a1da275f6fe024b Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 22 Dec 2021 16:52:47 +0900 Subject: [PATCH 3/3] test: wait for user inactive The user may be busy when auto-rebalancing the user's home device. Workaround for #21589. --- Dec 01 15:03:15 H systemd-homework[1078]: Provided password unlocks user record. Dec 01 15:03:15 H systemd-homework[1078]: Image file '/home/test-user.home' already locked, can't use. Dec 01 15:03:15 H systemd-homed[240]: Worker reported error code EADDRINUSE. Dec 01 15:03:15 H systemd-homed[240]: Activation failed: Address already in use --- --- test/units/testsuite-46.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/units/testsuite-46.sh b/test/units/testsuite-46.sh index d0bedc63d5..c3e57cec95 100755 --- a/test/units/testsuite-46.sh +++ b/test/units/testsuite-46.sh @@ -153,13 +153,20 @@ if ! systemd-detect-virt -cq ; then inspect test-user2 fi +wait_for_state test-user inactive PASSWORD=xEhErW0ndafV4s homectl with test-user -- test ! -f /home/test-user/xyz +wait_for_state test-user inactive PASSWORD=xEhErW0ndafV4s homectl with test-user -- test -f /home/test-user/xyz \ && { echo 'unexpected success'; exit 1; } +wait_for_state test-user inactive PASSWORD=xEhErW0ndafV4s homectl with test-user -- touch /home/test-user/xyz +wait_for_state test-user inactive PASSWORD=xEhErW0ndafV4s homectl with test-user -- test -f /home/test-user/xyz +wait_for_state test-user inactive PASSWORD=xEhErW0ndafV4s homectl with test-user -- rm /home/test-user/xyz +wait_for_state test-user inactive PASSWORD=xEhErW0ndafV4s homectl with test-user -- test ! -f /home/test-user/xyz +wait_for_state test-user inactive PASSWORD=xEhErW0ndafV4s homectl with test-user -- test -f /home/test-user/xyz \ && { echo 'unexpected success'; exit 1; }