]>
Commit | Line | Data |
---|---|---|
db9ecf05 | 1 | /* SPDX-License-Identifier: LGPL-2.1-or-later */ |
70a5db58 LP |
2 | #pragma once |
3 | ||
572c1fe6 | 4 | #include <linux/fscrypt.h> |
543a48b6 | 5 | #include <sys/keyctl.h> |
70a5db58 LP |
6 | |
7 | #include "sd-id128.h" | |
8 | ||
572c1fe6 | 9 | #include "homework-forward.h" |
70a5db58 LP |
10 | #include "user-record-util.h" |
11 | ||
12 | typedef struct HomeSetup { | |
491347bd LP |
13 | char *dm_name; /* "home-<username>" */ |
14 | char *dm_node; /* "/dev/mapper/home-<username>" */ | |
70a5db58 LP |
15 | |
16 | LoopDevice *loop; | |
17 | struct crypt_device *crypt_device; | |
18 | int root_fd; | |
28a7f106 | 19 | int image_fd; |
70a5db58 LP |
20 | sd_id128_t found_partition_uuid; |
21 | sd_id128_t found_luks_uuid; | |
22 | sd_id128_t found_fs_uuid; | |
23 | ||
24 | uint8_t fscrypt_key_descriptor[FS_KEY_DESCRIPTOR_SIZE]; | |
25 | ||
26 | void *volume_key; | |
27 | size_t volume_key_size; | |
28 | ||
d26cdde3 LP |
29 | key_serial_t key_serial; |
30 | ||
baa41cee LP |
31 | bool undo_dm:1; |
32 | bool undo_mount:1; /* Whether to unmount /run/systemd/user-home-mount */ | |
33 | bool do_offline_fitrim:1; | |
34 | bool do_offline_fallocate:1; | |
35 | bool do_mark_clean:1; | |
36 | bool do_drop_caches:1; | |
70a5db58 LP |
37 | |
38 | uint64_t partition_offset; | |
39 | uint64_t partition_size; | |
bf15879b LP |
40 | |
41 | char *mount_suffix; /* The directory to use as home dir is this path below /run/systemd/user-home-mount */ | |
32dda527 LP |
42 | |
43 | char *temporary_image_path; | |
70a5db58 LP |
44 | } HomeSetup; |
45 | ||
46 | #define HOME_SETUP_INIT \ | |
47 | { \ | |
254d1313 ZJS |
48 | .root_fd = -EBADF, \ |
49 | .image_fd = -EBADF, \ | |
70a5db58 LP |
50 | .partition_offset = UINT64_MAX, \ |
51 | .partition_size = UINT64_MAX, \ | |
d26cdde3 | 52 | .key_serial = -1, \ |
70a5db58 LP |
53 | } |
54 | ||
e1df968b LP |
55 | /* Various flags for the operation of setting up a home directory */ |
56 | typedef enum HomeSetupFlags { | |
4e6e72f1 | 57 | HOME_SETUP_ALREADY_ACTIVATED = 1 << 0, /* Open an already activated home, rather than activate it afresh */ |
bf15879b LP |
58 | |
59 | /* CIFS backend: */ | |
4e6e72f1 LP |
60 | HOME_SETUP_CIFS_MKDIR = 1 << 1, /* Create CIFS subdir when missing */ |
61 | ||
62 | /* Applies only for resize operations */ | |
63 | HOME_SETUP_RESIZE_DONT_SYNC_IDENTITIES = 1 << 2, /* Don't sync identity records into home and LUKS header */ | |
c8caf53c LP |
64 | HOME_SETUP_RESIZE_MINIMIZE = 1 << 3, /* Shrink to minimal size */ |
65 | HOME_SETUP_RESIZE_DONT_GROW = 1 << 4, /* If the resize would grow, gracefully terminate operation */ | |
66 | HOME_SETUP_RESIZE_DONT_SHRINK = 1 << 5, /* If the resize would shrink, gracefully terminate operation */ | |
5813fca6 | 67 | HOME_SETUP_RESIZE_DONT_UNDO = 1 << 6, /* Leave loopback/DM device context open after successful operation */ |
e1df968b LP |
68 | } HomeSetupFlags; |
69 | ||
66aa51f8 | 70 | int home_setup_done(HomeSetup *setup); |
70a5db58 | 71 | |
55166094 | 72 | int home_setup_undo_mount(HomeSetup *setup, int level); |
f7800049 | 73 | int home_setup_undo_dm(HomeSetup *setup, int level); |
55166094 | 74 | |
d26cdde3 LP |
75 | int keyring_unlink(key_serial_t k); |
76 | ||
c00b2ddc | 77 | int home_setup(UserRecord *h, HomeSetupFlags flags, HomeSetup *setup, PasswordCache *cache, UserRecord **ret_header_home); |
70a5db58 | 78 | |
6f2c8136 | 79 | int home_refresh(UserRecord *h, HomeSetupFlags flags, HomeSetup *setup, UserRecord *header_home, PasswordCache *cache, struct statfs *ret_statfs, UserRecord **ret_new_home); |
70a5db58 | 80 | |
6f2c8136 | 81 | int home_maybe_shift_uid(UserRecord *h, HomeSetupFlags flags, HomeSetup *setup); |
70a5db58 LP |
82 | int home_populate(UserRecord *h, int dir_fd); |
83 | ||
7b78db28 | 84 | 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); |
285ad523 | 85 | int home_store_embedded_identity(UserRecord *h, int root_fd, UserRecord *old_home); |
70a5db58 LP |
86 | int home_extend_embedded_identity(UserRecord *h, UserRecord *used, HomeSetup *setup); |
87 | ||
7b78db28 | 88 | int user_record_authenticate(UserRecord *h, UserRecord *secret, PasswordCache *cache, bool strict_verify); |
70a5db58 LP |
89 | |
90 | int home_sync_and_statfs(int root_fd, struct statfs *ret); | |
498abadb LP |
91 | |
92 | #define HOME_RUNTIME_WORK_DIR "/run/systemd/user-home-mount" |