Commit Graph
390 Commits
Author SHA1 Message Date
Lennart Poettering 1af53c0fa8 homed: when using id mapping on the home dirs, also do an identity mapping for the container UID ranges
Apparently people really want to put high UIDs in their homedirs. Let's
add some minimal support for that.

Further discussion: https://github.com/systemd/systemd/pull/22239#issuecomment-1040421552

Inspired by, based on, and replacing #22239 by Christian Brauner.
2022-02-16 13:37:01 +01:00
Zbigniew Jędrzejewski-Szmek 073c0e20ef homework: avoid runtime formatting of a fixed string
Follow-up for fe9bd5ad36.
I checked that the formatted string has the same dashes as
before fe9bd5ad36.
2022-02-15 10:50:43 +01:00
Lennart Poettering fe9bd5ad36 homed: use SD_ID128_TO_UUID_STRING() at one more place 2022-02-14 15:14:14 +01:00
Lennart Poettering e46433bb92 tree-wide: use id128_equal_string() at various places 2022-02-14 15:14:11 +01:00
Lennart Poettering b74163607b sd128: export sd_id128_to_uuid_string()
We expose various other forms of UUID helpers already, i.e.
SD_ID128_UUID_FORMAT_STR and SD_ID128_MAKE_UUID_STR(), and we parse
UUIDs, hence add a high-level helper for formatting UUIDs too.

This doesn't add any new code, it just moves some helpers
id128-util.[ch] → sd-id128.[ch], to make them public.
2022-02-14 15:13:23 +01:00
Anita Zhang 1d3b68f6e1 tree-wide: don't use strjoina() on getenv() values
Avoid doing stack allocations on environment variables.
2022-01-27 13:45:00 +09:00
Zbigniew Jędrzejewski-Szmek d6e2c1ab71 policy files: adjust landing page link 2022-01-12 16:05:59 +01:00
Yu Watanabe 367649ee66 home: update log message
The ratelimit hits even when the all previous attempts are successfull.
2021-12-22 17:29:30 +09:00
Nishal Kulkarni 9a8141662e homed: Use new SD_BUS_METHOD_WITH_ARGS macro
Migrate homed to use the new macros to declare a D-Bus method.
Replaced `SD_BUS_METHOD_WITH_NAMES` with `SD_BUS_METHOD_WITH_ARGS`
2021-12-18 11:57:57 +09:00
Yu Watanabe d9338387d9 Merge pull request #21786 from keszybz/dirent-work
Make FOREACH_DIRENT and FOREACH_DIRENT_ALL declare the iterator variables
2021-12-17 04:07:35 +09:00
Zbigniew Jędrzejewski-Szmek af3b864d76 Define FOREACH_DIRENT through FOREACH_DIRENT_ALL
As in the previous commit, 'de' is used as the iterator variable name.
2021-12-15 22:50:00 +01:00
Yu Watanabe 2ff457720b home: fix heap-use-after-free
`bus_home_emit_remove()` may be called from manager_free() -> home_free().
In that case, manager->bus is already unref()ed.

Fixes #21767.
2021-12-14 20:00:56 +09:00
Yu Watanabe 76fc157702 home: clear Manager::bus, ::event, ::homes_by_xxx and so on
`home_free()` may try to call some dbus or event related functions.
To prevent that, set those variables NULL.
2021-12-14 20:00:24 +09:00
Yu Watanabe 8add30a03c tree-wide: use ERRNO_IS_TRANSIENT() 2021-11-30 23:06:43 +09:00
Yu Watanabe a6f44d610c tree-wide: fix typo 2021-11-30 12:30:07 +00:00
Luca Boccassi 485c9e19e7 Merge pull request #21253 from poettering/homed-auto-grow-shrink
homed: automatic grow/shrink of LUKS home dirs
2021-11-25 22:14:17 +00:00
Zbigniew Jędrzejewski-Szmek f1da1e7b5f Merge pull request #21522 from yuwata/home-fix-memleak
home: fix memleak
2021-11-25 20:22:23 +01:00
Lennart Poettering 6d6d4459ab homectl: add new "homectl rebalance" command
Let's add an explicit, synchronous command to request immediate rebalancing and
wait for it.
2021-11-25 18:28:44 +01:00
Lennart Poettering 4950591627 homed: add explicit API for requesting rebalancing too 2021-11-25 18:28:44 +01:00
Lennart Poettering d357b80d33 homed: add automatic grow/shrink ("rebalancing") 2021-11-25 18:28:44 +01:00
Lennart Poettering 21505c937c homectl: expose new rebalanceWeight JSON use record field 2021-11-25 18:28:44 +01:00
Lennart Poettering c42234abf2 homed: support LogControl1 D-Bus API too, and make use of it
All our D-Bus services support the LogControl1 API, but homed didn't so
far. Fix that, and make use of it in the test case, to make debugging it
easier.
2021-11-25 18:18:42 +01:00
Yu Watanabe 5601a9b910 homework: fix memleak
Fixes #21521.
2021-11-26 00:14:32 +09:00
Yu Watanabe 47398ea705 homework: drop unnecessary initialization 2021-11-26 00:09:30 +09:00
Lennart Poettering 0cdf6b14a5 json: add new JSON_BUILD_CONST_STRING() macro
This macro is like JSON_BUILD_STRING() but uses our json library's
ability to use literal strings directly as JsonVariant objects.

The changes all our codebase to use this new macro whenever we build
JSON objects from literal strings.

(I tried to make this automatic, i.e. to detect in JSON_BUILD_STRING()
whether something is a literal string nicely and thus do this stuff
automatically, but I couldn't find a way.)

This should reduce memory usage of our JSON code a bit. Constant strings
we use very often will now be shared and mapped directly from the ELF
image.
2021-11-25 14:22:31 +01:00
Lennart Poettering 4dc07c3a9a repart,homed: split out disk cleanup macros into generic header 2021-11-25 12:10:34 +01:00
Lennart Poettering 6c68d5ad73 homework: add debug log message whenever we applied a uidmap to a mount 2021-11-24 18:42:08 +01:00
Lennart Poettering b05f4495bd homework: fix a bad error propagation 2021-11-24 18:42:08 +01:00
Lennart Poettering a8be098403 homework: also apply uid shifting when changing passwords/resizing/updating home areas
This adds uidmap shifting also when resizing/updating/changing
passwords. Prviously I thought we didn't have to, because the user is
not going to access the uidmap if we only quickly activate the home
area. But this thinking is wrong, because the three operations will
result in an update ~/.identity fie to be written, and we should do that
with uidmap applied, so that its ownership maps down to nobody below as
intended.

Fixes: #21441
2021-11-24 18:41:54 +01:00
Lennart Poettering 6f2c813667 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.
2021-11-24 18:31:51 +01:00
Lennart Poettering eae3a68144 homework: fix message typo 2021-11-24 18:29:52 +01:00
Lennart Poettering 6b356f4498 homectl: also acquire "cheap" passwords for homectl update/passwd
In 57bb9bcba5 support was added to read
"cheap" passwords from env vars and stuff before issuing the first
operation, instead of waiting for it until the first operation failed.

This was added for most verbs of "homectl", but two were left out:
update + passwd. Add it there too.
2021-11-24 18:26:28 +01:00
Lennart Poettering 5c682b7881 Merge pull request #21440 from poettering/homed-initial-fs-size
homed: also support minimizing/maximizing home dirs when creating them
2021-11-23 16:44:26 +01:00
Lennart Poettering 31ea1bfec1 homework: correct initial minimal fs size calculations by LUKS2/GPT overhead
So far we assumed we ignore the LUKS2/GPT header overhead when
determining what the lower bound for images sizes is. Let's correct
this.
2021-11-23 10:02:56 +01:00
Lennart Poettering 716bc20034 homework: when creating home dir also treat specified size as hint
The resize logic is now able to handle resize requests that cannot be
fulfilled in full gracefully. Let's do the same when allocating new home
directories.

This means "homectl create foo --disk-size=min" and "homectl create foo
--disk-size=max" may now be used to create the smallest or largest home
directory we support.
2021-11-23 10:02:35 +01:00
Lennart Poettering d26cdde3d4 homework: upload home password into kernel keyring if needed
If we do automatic disk space rebalancing, we must be able to unlock the
encrypted volume for that in the background, thus we need to decryption
key around in userspace. Let's do this via the kernel keyring. This
allows us to do this in a relatively secure way, so that it sticks
around between homework invocations, but still is destroyed
automatically when homed goes down.
2021-11-23 08:07:21 +01:00
Lennart Poettering 2619100038 homework: add auto-shrink/auto-grow 2021-11-23 08:04:10 +01:00
Lennart Poettering ab3b6fcb40 homectl: expose new autoResizeMode JSON user record property 2021-11-23 08:04:10 +01:00
Lennart Poettering 9f5827e01c homectl: parse "min" and "max" as special disk size values 2021-11-19 00:05:53 +01:00
Lennart Poettering 2b02eb0591 homework: also add logic for "maximizing" size of home 2021-11-19 00:05:53 +01:00
Lennart Poettering 34081f6be7 homework: make it safe to invoke home_setup_luks() twice in a row
Being able to invoke the call twice on the same HomeSetup object will
simplify auto-growing/auto-shrinking since we can issue a resize
operatio directly from activate/deactivate
2021-11-19 00:05:53 +01:00
Lennart Poettering 5813fca61f homework: make destroying of HomeSetup optional when resizing
This will be useful when we want to issue a resize operation right when
activating, where the HomeSetup object should be destroyed only after
both activation is done.
2021-11-19 00:05:53 +01:00
Luca Boccassi 26b2832992 Merge pull request #21424 from keszybz/json-double
Use double and int64_t types in json
2021-11-18 13:37:20 +00:00
Lennart Poettering 3510cef8fa Merge pull request #21401 from poettering/open-mkdir-at
add open_mkdir_at() helper and use it
2021-11-18 10:13:26 +01:00
Zbigniew Jędrzejewski-Szmek 718ca77232 shared/json: use int64_t instead of intmax_t
We were already asserting that the intmax_t and uintmax_t types
are the same as int64_t and uint64_t. Pretty much everywhere in
the code base we use the latter types. In principle intmax_t could
be something different on some new architecture, and then the code would
fail to compile or behave differently. We actually do not want the code
to behave differently on those architectures, because that'd break
interoperability. So let's just use int64_t/uint64_t since that's what
we indend to use.
2021-11-18 01:34:31 +01:00
Lennart Poettering 96603ea076 tree-wide: port various places over to open_mkdir_at() 2021-11-17 21:48:29 +01:00
Lennart Poettering edde3a35b4 pam_systemd_home: prompt user for recovery key if homed asks for it
For accoutns that have no passwords but only a recovery key homed might
ask explicitly for that. Honour the request and ask the user for it.
2021-11-17 17:45:21 +01:00
Lennart Poettering c7b6051f16 homectl: if homed asks for the recovery key to be supplied, query the user for it
Fixes: #21103
2021-11-17 17:42:12 +01:00
Lennart Poettering c8caf53ca2 homework: beef up luks resize logic to allow "minimizing" homes 2021-11-16 17:28:26 +01:00
Lennart Poettering 71bf7ba193 user-record: relax rules on diskSize user record field
Let's not refuse low or high disk sizes unnecessarily early. They disk
sizes are subject fs limits anyway, hence there's no point in adding
another limit.

Relaxing thhe rules here as the advantage that we can later allow
"homectl resize lennart 0" as a generic way to minimize disk space.
2021-11-16 17:18:07 +01:00