mirror of
https://github.com/systemd/systemd.git
synced 2025-01-10 05:18:17 +03:00
homework: don't try to shift uidmap for already activated home areas
When we want to operate on an already activated home area we so far tried to reapply the uidmapping logic. We shouldn't do that, it's already applied after all. We only want to apply this for newly activated home areas. Hence check for the right HomeSetupFlags flag for it HOME_SETUP_ALREADY_ACTIVATED. The patch is actually in theory a two-liner. Except that so far we don#t pass the HomeSetupFlags flags down all necessary functions where the uidmap stuff will eventually run. Hence this larger than intended commit.
This commit is contained in:
parent
eae3a68144
commit
6f2c813667
@ -145,6 +145,7 @@ int home_setup_cifs(
|
||||
|
||||
int home_activate_cifs(
|
||||
UserRecord *h,
|
||||
HomeSetupFlags flags,
|
||||
HomeSetup *setup,
|
||||
PasswordCache *cache,
|
||||
UserRecord **ret_home) {
|
||||
@ -165,7 +166,7 @@ int home_activate_cifs(
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = home_refresh(h, setup, header_home, cache, NULL, &new_home);
|
||||
r = home_refresh(h, flags, setup, header_home, cache, NULL, &new_home);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
|
@ -6,6 +6,6 @@
|
||||
|
||||
int home_setup_cifs(UserRecord *h, HomeSetupFlags flags, HomeSetup *setup);
|
||||
|
||||
int home_activate_cifs(UserRecord *h, HomeSetup *setup, PasswordCache *cache, UserRecord **ret_home);
|
||||
int home_activate_cifs(UserRecord *h, HomeSetupFlags flags, HomeSetup *setup, PasswordCache *cache, UserRecord **ret_home);
|
||||
|
||||
int home_create_cifs(UserRecord *h, HomeSetup *setup, UserRecord **ret_home);
|
||||
|
@ -58,6 +58,7 @@ int home_setup_directory(UserRecord *h, HomeSetup *setup) {
|
||||
|
||||
int home_activate_directory(
|
||||
UserRecord *h,
|
||||
HomeSetupFlags flags,
|
||||
HomeSetup *setup,
|
||||
PasswordCache *cache,
|
||||
UserRecord **ret_home) {
|
||||
@ -74,11 +75,11 @@ int home_activate_directory(
|
||||
assert_se(hdo = user_record_home_directory(h));
|
||||
hd = strdupa_safe(hdo);
|
||||
|
||||
r = home_setup(h, 0, setup, cache, &header_home);
|
||||
r = home_setup(h, flags, setup, cache, &header_home);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = home_refresh(h, setup, header_home, cache, NULL, &new_home);
|
||||
r = home_refresh(h, flags, setup, header_home, cache, NULL, &new_home);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@ -279,7 +280,7 @@ int home_resize_directory(
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = home_maybe_shift_uid(h, setup);
|
||||
r = home_maybe_shift_uid(h, flags, setup);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
|
@ -5,6 +5,6 @@
|
||||
#include "user-record.h"
|
||||
|
||||
int home_setup_directory(UserRecord *h, HomeSetup *setup);
|
||||
int home_activate_directory(UserRecord *h, HomeSetup *setup, PasswordCache *cache, UserRecord **ret_home);
|
||||
int home_activate_directory(UserRecord *h, HomeSetupFlags flags, HomeSetup *setup, PasswordCache *cache, UserRecord **ret_home);
|
||||
int home_create_directory_or_subvolume(UserRecord *h, HomeSetup *setup, UserRecord **ret_home);
|
||||
int home_resize_directory(UserRecord *h, HomeSetupFlags flags, HomeSetup *setup, PasswordCache *cache, UserRecord **ret_home);
|
||||
|
@ -1511,6 +1511,7 @@ static int home_auto_grow_luks(
|
||||
|
||||
int home_activate_luks(
|
||||
UserRecord *h,
|
||||
HomeSetupFlags flags,
|
||||
HomeSetup *setup,
|
||||
PasswordCache *cache,
|
||||
UserRecord **ret_home) {
|
||||
@ -1563,6 +1564,7 @@ int home_activate_luks(
|
||||
|
||||
r = home_refresh(
|
||||
h,
|
||||
flags,
|
||||
setup,
|
||||
luks_home_record,
|
||||
cache,
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
int home_setup_luks(UserRecord *h, HomeSetupFlags flags, const char *force_image_path, HomeSetup *setup, PasswordCache *cache, UserRecord **ret_luks_home);
|
||||
|
||||
int home_activate_luks(UserRecord *h, HomeSetup *setup, PasswordCache *cache, UserRecord **ret_home);
|
||||
int home_activate_luks(UserRecord *h, HomeSetupFlags flags, HomeSetup *setup, PasswordCache *cache, UserRecord **ret_home);
|
||||
int home_deactivate_luks(UserRecord *h, HomeSetup *setup);
|
||||
int home_trim_luks(UserRecord *h, HomeSetup *setup);
|
||||
|
||||
|
@ -788,6 +788,7 @@ static int chown_recursive_directory(int root_fd, uid_t uid) {
|
||||
|
||||
int home_maybe_shift_uid(
|
||||
UserRecord *h,
|
||||
HomeSetupFlags flags,
|
||||
HomeSetup *setup) {
|
||||
|
||||
_cleanup_close_ int mount_fd = -1;
|
||||
@ -797,6 +798,10 @@ int home_maybe_shift_uid(
|
||||
assert(setup);
|
||||
assert(setup->root_fd >= 0);
|
||||
|
||||
/* If the home dir is already activated, then the UID shift is already applied. */
|
||||
if (FLAGS_SET(flags, HOME_SETUP_ALREADY_ACTIVATED))
|
||||
return 0;
|
||||
|
||||
if (fstat(setup->root_fd, &st) < 0)
|
||||
return log_error_errno(errno, "Failed to stat() home directory: %m");
|
||||
|
||||
@ -820,6 +825,7 @@ int home_maybe_shift_uid(
|
||||
|
||||
int home_refresh(
|
||||
UserRecord *h,
|
||||
HomeSetupFlags flags,
|
||||
HomeSetup *setup,
|
||||
UserRecord *header_home,
|
||||
PasswordCache *cache,
|
||||
@ -840,7 +846,7 @@ int home_refresh(
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = home_maybe_shift_uid(h, setup);
|
||||
r = home_maybe_shift_uid(h, flags, setup);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@ -868,6 +874,7 @@ static int home_activate(UserRecord *h, UserRecord **ret_home) {
|
||||
_cleanup_(home_setup_done) HomeSetup setup = HOME_SETUP_INIT;
|
||||
_cleanup_(user_record_unrefp) UserRecord *new_home = NULL;
|
||||
_cleanup_(password_cache_free) PasswordCache cache = {};
|
||||
HomeSetupFlags flags = 0;
|
||||
int r;
|
||||
|
||||
assert(h);
|
||||
@ -898,7 +905,7 @@ static int home_activate(UserRecord *h, UserRecord **ret_home) {
|
||||
switch (user_record_storage(h)) {
|
||||
|
||||
case USER_LUKS:
|
||||
r = home_activate_luks(h, &setup, &cache, &new_home);
|
||||
r = home_activate_luks(h, flags, &setup, &cache, &new_home);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@ -907,14 +914,14 @@ static int home_activate(UserRecord *h, UserRecord **ret_home) {
|
||||
case USER_SUBVOLUME:
|
||||
case USER_DIRECTORY:
|
||||
case USER_FSCRYPT:
|
||||
r = home_activate_directory(h, &setup, &cache, &new_home);
|
||||
r = home_activate_directory(h, flags, &setup, &cache, &new_home);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
break;
|
||||
|
||||
case USER_CIFS:
|
||||
r = home_activate_cifs(h, &setup, &cache, &new_home);
|
||||
r = home_activate_cifs(h, flags, &setup, &cache, &new_home);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
|
@ -80,9 +80,9 @@ int keyring_unlink(key_serial_t k);
|
||||
|
||||
int home_setup(UserRecord *h, HomeSetupFlags flags, HomeSetup *setup, PasswordCache *cache, UserRecord **ret_header_home);
|
||||
|
||||
int home_refresh(UserRecord *h, HomeSetup *setup, UserRecord *header_home, PasswordCache *cache, struct statfs *ret_statfs, UserRecord **ret_new_home);
|
||||
int home_refresh(UserRecord *h, HomeSetupFlags flags, HomeSetup *setup, UserRecord *header_home, PasswordCache *cache, struct statfs *ret_statfs, UserRecord **ret_new_home);
|
||||
|
||||
int home_maybe_shift_uid(UserRecord *h, HomeSetup *setup);
|
||||
int home_maybe_shift_uid(UserRecord *h, HomeSetupFlags flags, HomeSetup *setup);
|
||||
int home_populate(UserRecord *h, int dir_fd);
|
||||
|
||||
int home_load_embedded_identity(UserRecord *h, int root_fd, UserRecord *header_home, UserReconcileMode mode, PasswordCache *cache, UserRecord **ret_embedded_home, UserRecord **ret_new_home);
|
||||
|
Loading…
Reference in New Issue
Block a user