mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-24 21:34:08 +03:00
homework: reuse home_validate_update_luks() at one more place
We have the same code at two places, let's reuse it. Given the more generic scope let's rename the function home_get_state() since it retrieve the current setup state of the LUKS logic.
This commit is contained in:
parent
c8e2a76807
commit
e1ab663575
@ -1379,15 +1379,10 @@ int home_activate_luks(
|
||||
assert_se(hdo = user_record_home_directory(h));
|
||||
hd = strdupa_safe(hdo); /* copy the string out, since it might change later in the home record object */
|
||||
|
||||
r = make_dm_names(h->user_name, &setup.dm_name, &setup.dm_node);
|
||||
r = home_get_state_luks(h, &setup);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = access(setup.dm_node, F_OK);
|
||||
if (r < 0) {
|
||||
if (errno != ENOENT)
|
||||
return log_error_errno(errno, "Failed to determine whether %s exists: %m", setup.dm_node);
|
||||
} else
|
||||
if (r > 0)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EEXIST), "Device mapper device %s already exists, refusing.", setup.dm_node);
|
||||
|
||||
r = home_prepare_luks(
|
||||
@ -2351,7 +2346,7 @@ fail:
|
||||
return r;
|
||||
}
|
||||
|
||||
int home_validate_update_luks(UserRecord *h, HomeSetup *setup) {
|
||||
int home_get_state_luks(UserRecord *h, HomeSetup *setup) {
|
||||
_cleanup_free_ char *dm_name = NULL, *dm_node = NULL;
|
||||
int r;
|
||||
|
||||
|
@ -15,7 +15,7 @@ int home_store_header_identity_luks(UserRecord *h, HomeSetup *setup, UserRecord
|
||||
|
||||
int home_create_luks(UserRecord *h, PasswordCache *cache, char **effective_passwords, UserRecord **ret_home);
|
||||
|
||||
int home_validate_update_luks(UserRecord *h, HomeSetup *setup);
|
||||
int home_get_state_luks(UserRecord *h, HomeSetup *setup);
|
||||
|
||||
int home_resize_luks(UserRecord *h, bool already_activated, PasswordCache *cache, HomeSetup *setup, UserRecord **ret_home);
|
||||
|
||||
|
@ -1408,7 +1408,7 @@ static int home_validate_update(UserRecord *h, HomeSetup *setup) {
|
||||
break;
|
||||
|
||||
case USER_LUKS: {
|
||||
r = home_validate_update_luks(h, setup);
|
||||
r = home_get_state_luks(h, setup);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if ((r > 0) != has_mount)
|
||||
|
Loading…
Reference in New Issue
Block a user