summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2021-10-13 22:40:11 +0200
committerLennart Poettering <lennart@poettering.net>2021-10-16 10:13:02 +0200
commite1ab663575b205b4a9e7363fff3215d87f7d992f (patch)
treeecb67597f1648827634764aa9d7b31bb87cfb675
parentc8e2a76807adabd9b960925ae599c3b8b66a11ff (diff)
downloadsystemd-e1ab663575b205b4a9e7363fff3215d87f7d992f.tar.gz
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.
-rw-r--r--src/home/homework-luks.c11
-rw-r--r--src/home/homework-luks.h2
-rw-r--r--src/home/homework.c2
3 files changed, 5 insertions, 10 deletions
diff --git a/src/home/homework-luks.c b/src/home/homework-luks.c
index 43174f311b..90a49559f1 100644
--- a/src/home/homework-luks.c
+++ b/src/home/homework-luks.c
@@ -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;
diff --git a/src/home/homework-luks.h b/src/home/homework-luks.h
index 8764862bd2..eac8f0761b 100644
--- a/src/home/homework-luks.h
+++ b/src/home/homework-luks.h
@@ -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);
diff --git a/src/home/homework.c b/src/home/homework.c
index 0c77b492e8..48ff77213b 100644
--- a/src/home/homework.c
+++ b/src/home/homework.c
@@ -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)