]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
homework: actually try all supplied passwords
authorLennart Poettering <lennart@poettering.net>
Tue, 26 Oct 2021 14:41:31 +0000 (16:41 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 27 Oct 2021 20:46:46 +0000 (22:46 +0200)
Unfortunately mount.cifs doesn't really let us know much about the
reason for the failure. Hence, assume it's caused by a bad password, and
retry on any failure with additional passwords that we might have.

A loop to do this was always in place, but none of the possible
codepaths actually allowed to iterate more than once. Fix that.

src/home/homework-cifs.c

index 55b8c2588d684a946e078961ebe0fec0893d21bd..6184d7c30e1e8be79e8a7411be406497c0fee27d 100644 (file)
@@ -99,16 +99,18 @@ int home_setup_cifs(
                 exit_status = wait_for_terminate_and_check("mount", mount_pid, WAIT_LOG_ABNORMAL|WAIT_LOG_NON_ZERO_EXIT_STATUS);
                 if (exit_status < 0)
                         return exit_status;
-                if (exit_status != EXIT_SUCCESS)
-                        return -EPROTO;
+                if (exit_status == EXIT_SUCCESS) {
+                        setup->undo_mount = true;
+                        break;
+                }
 
-                setup->undo_mount = true;
-                break;
+                if (pw[1])
+                        log_info("CIFS mount failed with password #%zu, trying next password.", (size_t) (pw - h->password) + 1);
         }
 
         if (!setup->undo_mount)
                 return log_error_errno(SYNTHETIC_ERRNO(ENOKEY),
-                                       "Failed to mount home directory with supplied password.");
+                                       "Failed to mount home directory, supplied password(s) possibly wrong.");
 
         /* Adjust MS_SUID and similar flags */
         r = mount_nofollow_verbose(LOG_ERR, NULL, HOME_RUNTIME_WORK_DIR, NULL, MS_BIND|MS_REMOUNT|user_record_mount_flags(h), NULL);