]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/home/home-util.h
homed: add automatic grow/shrink ("rebalancing")
[thirdparty/systemd.git] / src / home / home-util.h
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3
4 #include <stdbool.h>
5
6 #include "sd-bus.h"
7
8 #include "time-util.h"
9 #include "user-record.h"
10
11 /* See https://systemd.io/UIDS-GIDS for details how this range fits into the rest of the world */
12 #define HOME_UID_MIN 60001
13 #define HOME_UID_MAX 60513
14
15 /* Put some limits on disk sizes: not less than 5M, not more than 5T */
16 #define USER_DISK_SIZE_MIN (UINT64_C(5)*1024*1024)
17 #define USER_DISK_SIZE_MAX (UINT64_C(5)*1024*1024*1024*1024)
18
19 /* The default disk size to use when nothing else is specified, relative to free disk space. We calculate
20 * this from the default rebalancing weights, so that what we create initially doesn't immediately require
21 * rebalancing. */
22 #define USER_DISK_SIZE_DEFAULT_PERCENT ((unsigned) ((100 * REBALANCE_WEIGHT_DEFAULT) / (REBALANCE_WEIGHT_DEFAULT + REBALANCE_WEIGHT_BACKING)))
23
24 /* This should be 83% right now, i.e. 100 of (100 + 20). Let's protect us against accidental changes. */
25 assert_cc(USER_DISK_SIZE_DEFAULT_PERCENT == 83U);
26
27 bool suitable_user_name(const char *name);
28 int suitable_realm(const char *realm);
29 int suitable_image_path(const char *path);
30
31 bool supported_fstype(const char *fstype);
32
33 int split_user_name_realm(const char *t, char **ret_user_name, char **ret_realm);
34
35 int bus_message_append_secret(sd_bus_message *m, UserRecord *secret);
36
37 /* Many of our operations might be slow due to crypto, fsck, recursive chown() and so on. For these
38 * operations permit a *very* long timeout */
39 #define HOME_SLOW_BUS_CALL_TIMEOUT_USEC (2*USEC_PER_MINUTE)
40
41 const char *home_record_dir(void);