mirror of
https://github.com/systemd/systemd.git
synced 2024-10-31 07:51:21 +03:00
homework: rework home_setup_cifs() to store "mounted" variable in HomeSetup
We already have a field for that, let's use it. Let's also reduce the indentation level a bit. No change in behaviour.
This commit is contained in:
parent
de7df6c3a6
commit
812e587696
@ -18,17 +18,23 @@ int home_setup_cifs(
|
||||
HomeSetupFlags flags,
|
||||
HomeSetup *setup) {
|
||||
|
||||
assert(h);
|
||||
assert(setup);
|
||||
assert(user_record_storage(h) == USER_CIFS);
|
||||
|
||||
if (FLAGS_SET(flags, HOME_SETUP_ALREADY_ACTIVATED))
|
||||
setup->root_fd = open(user_record_home_directory(h), O_RDONLY|O_CLOEXEC|O_DIRECTORY|O_NOFOLLOW);
|
||||
else {
|
||||
bool mounted = false;
|
||||
char **pw;
|
||||
int r;
|
||||
|
||||
assert(h);
|
||||
assert(user_record_storage(h) == USER_CIFS);
|
||||
assert(setup);
|
||||
assert(!setup->undo_mount);
|
||||
assert(setup->root_fd < 0);
|
||||
|
||||
if (FLAGS_SET(flags, HOME_SETUP_ALREADY_ACTIVATED)) {
|
||||
setup->root_fd = open(user_record_home_directory(h), O_RDONLY|O_CLOEXEC|O_DIRECTORY|O_NOFOLLOW);
|
||||
if (setup->root_fd < 0)
|
||||
return log_error_errno(errno, "Failed to open home directory: %m");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
r = home_unshare_and_mkdir();
|
||||
if (r < 0)
|
||||
return r;
|
||||
@ -82,16 +88,15 @@ int home_setup_cifs(
|
||||
if (exit_status != EXIT_SUCCESS)
|
||||
return -EPROTO;
|
||||
|
||||
mounted = true;
|
||||
setup->undo_mount = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!mounted)
|
||||
if (!setup->undo_mount)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(ENOKEY),
|
||||
"Failed to mount home directory with supplied password.");
|
||||
|
||||
setup->root_fd = open(HOME_RUNTIME_WORK_DIR, O_RDONLY|O_CLOEXEC|O_DIRECTORY|O_NOFOLLOW);
|
||||
}
|
||||
if (setup->root_fd < 0)
|
||||
return log_error_errno(errno, "Failed to open home directory: %m");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user