]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/home/homework.h
home: add new systemd-homed service that can manage LUKS homes
[thirdparty/systemd.git] / src / home / homework.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 #include <linux/fs.h>
5 #include <sys/vfs.h>
6
7 #include "sd-id128.h"
8
9 #include "loop-util.h"
10 #include "user-record.h"
11 #include "user-record-util.h"
12
13 typedef struct HomeSetup {
14 char *dm_name;
15 char *dm_node;
16
17 LoopDevice *loop;
18 struct crypt_device *crypt_device;
19 int root_fd;
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
29 bool undo_dm;
30 bool undo_mount;
31
32 uint64_t partition_offset;
33 uint64_t partition_size;
34 } HomeSetup;
35
36 #define HOME_SETUP_INIT \
37 { \
38 .root_fd = -1, \
39 .partition_offset = UINT64_MAX, \
40 .partition_size = UINT64_MAX, \
41 }
42
43 int home_setup_undo(HomeSetup *setup);
44
45 int home_prepare(UserRecord *h, bool already_activated, char ***pkcs11_decrypted_passwords, HomeSetup *setup, UserRecord **ret_header_home);
46
47 int home_refresh(UserRecord *h, HomeSetup *setup, UserRecord *header_home, char ***pkcs11_decrypted_passwords, struct statfs *ret_statfs, UserRecord **ret_new_home);
48
49 int home_populate(UserRecord *h, int dir_fd);
50
51 int home_load_embedded_identity(UserRecord *h, int root_fd, UserRecord *header_home, UserReconcileMode mode, char ***pkcs11_decrypted_passwords, UserRecord **ret_embedded_home, UserRecord **ret_new_home);
52 int home_store_embedded_identity(UserRecord *h, int root_fd, uid_t uid, UserRecord *old_home);
53 int home_extend_embedded_identity(UserRecord *h, UserRecord *used, HomeSetup *setup);
54
55 int user_record_authenticate(UserRecord *h, UserRecord *secret, char ***pkcs11_decrypted_passwords);
56
57 int home_sync_and_statfs(int root_fd, struct statfs *ret);