]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
homed: return the correct error if an image file is not present when we try to activa...
authorLennart Poettering <lennart@poettering.net>
Thu, 20 Feb 2025 14:09:25 +0000 (15:09 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 20 Feb 2025 16:34:02 +0000 (17:34 +0100)
We already return BUS_ERROR_HOME_ABSENT when we detect the image being
absent before we fork off the homework worker. Let's also return the
same error if the homework process notices the same condition while
actually doing something.

This mostly fixes a race, that the same condition seen at different
points in time results in the same errors.

src/home/homed-home.c
src/home/homework.c

index 96477b3061afb363c024044cc8266ab97831df71..a2c28337f496069aadf45f88e6ba997018a5eae1 100644 (file)
@@ -689,6 +689,8 @@ static int convert_worker_errno(Home *h, int e, sd_bus_error *error) {
                 return sd_bus_error_setf(error, BUS_ERROR_HOME_CANT_AUTHENTICATE, "Home %s has no password or other authentication mechanism defined.", h->user_name);
         case -EADDRINUSE:
                 return sd_bus_error_setf(error, BUS_ERROR_HOME_IN_USE, "Home %s is currently being used elsewhere.", h->user_name);
+        case -ENETUNREACH:
+                return sd_bus_error_setf(error, BUS_ERROR_HOME_ABSENT, "Backing storage for %s currently absent.", h->user_name);
         }
 
         return 0;
index 00e74894b32849e4dc78a308131961b0fe5b4c52..9d3eb94ab2b6a608b858a090fa810bf6f8f89d2f 100644 (file)
@@ -926,7 +926,7 @@ static int home_activate(UserRecord *h, UserRecord **ret_home) {
         if (r < 0)
                 return r;
         if (r == USER_TEST_ABSENT)
-                return log_error_errno(SYNTHETIC_ERRNO(ENOENT), "Image path %s is missing, refusing.", user_record_image_path(h));
+                return log_error_errno(SYNTHETIC_ERRNO(ENETUNREACH), "Image path %s is missing, refusing.", user_record_image_path(h));
 
         switch (user_record_storage(h)) {
 
@@ -1596,7 +1596,7 @@ static int home_validate_update(UserRecord *h, HomeSetup *setup, HomeSetupFlags
         if (r < 0)
                 return r;
         if (r == USER_TEST_ABSENT)
-                return log_error_errno(SYNTHETIC_ERRNO(ENOENT), "Image path %s does not exist", user_record_image_path(h));
+                return log_error_errno(SYNTHETIC_ERRNO(ENETUNREACH), "Image path %s does not exist", user_record_image_path(h));
 
         switch (user_record_storage(h)) {
 
@@ -2092,6 +2092,7 @@ static int run(int argc, char *argv[]) {
          * ENOSPC          → not enough disk space for operation
          * EKEYREVOKED     → user record has not suitable hashed password or pkcs#11 entry, we cannot authenticate
          * EADDRINUSE      → home image is already used elsewhere (lock taken)
+         * ENETUNREACH     → backing storage is currently not (image is ENOENT, or AF_UNIX socket to connect to is ENOENT)
          */
 
         if (streq(argv[1], "activate"))