Commit Graph

44 Commits

Author SHA1 Message Date
Lennart Poettering 6a01ea4a2f json: port various tools to the new JSON_FORMAT_OFF flag
These are the obvious cases.
2021-01-09 17:36:24 +01:00
Lennart Poettering fb2d839c06 homed: move fido2 device enumeration logic to shared code 2020-12-17 19:59:50 +01:00
Lennart Poettering f240cbb645 homed: move code to list and resolve "auto" pkcs#11 URL into common code
That way we can reuse it from systemd-cryptenroll.
2020-12-17 19:58:39 +01:00
Zbigniew Jędrzejewski-Szmek 44ee03d111 tree-wide: unsetenv cannot fail
... when called with a valid environment variable name. This means that
any time we call it with a fixed string, it is guaranteed to return 0.
(Also when the variable is not present in the environment block.)
2020-11-10 15:52:32 +01:00
Yu Watanabe db9ecf0501 license: LGPL-2.1+ -> LGPL-2.1-or-later 2020-11-09 13:23:58 +09:00
Zbigniew Jędrzejewski-Szmek ab4a88eb92 sd-bus: add custom return code when $XDG_RUNTIME_DIR is not set
We would return ENOENT, which is extremely confusing. Strace is not helpful because
no *file* is actually missing. So let's add some logs at debug level and also use
a custom return code. Let all user-facing utilities print a custom error message
in that case.
2020-10-14 18:28:30 +02:00
Lennart Poettering d1f6e01e47 homed: explicitly deactivate all home directories on shutdown
Let's explicitly deactivate all home dirs on shutdown, in order to
properly synchronizing unmounting and avoiding blocking devices.

Previously, we'd rely on automatic deactivation when home directories
become unused. However, that scheme is asynchronous, and ongoing
deactviations might conflicts with attempts to unmount /home. Let's fix
that by providing an explicit service systemd-homed-activate.service
whose only job is to have a ExecStop= line that explicitly deactivates
all home directories on shutdown. This service can the be ordered after
home.mount and similar, ensuring that we'll first deactivate all homes
before deactivating /home itself during shutdown.

This is kept separate from systemd-homed.service so that it is possible
to restart systemd-homed.service without deactivating all home
directories.

Fixes: #16842
2020-09-30 14:37:52 +02:00
Lennart Poettering cc9886bc20 homed: make it easier to run multiple instances of homed
When debugging homed while being logged into a user account manged by
homed it is a good idea to be able to run a second copy of homed. In
order to not collide with its AF_UNIX socket and bus name use, let's add
a new env var $SYSTEMD_HOME_DEBUG_SUFFIX, when set the busnames/socket
names are suffixed by it. When setting this while debugging one can
invoke an additional copy without interfering with the host one.
2020-09-18 22:35:36 +02:00
Lennart Poettering 80c41552a8 homectl: teach homectl to generate recovery keys 2020-08-25 18:14:55 +02:00
Lennart Poettering caf6bd166f homed: default to "btrfs" as fs type in the LUKS backend
Apparently both Fedora and suse default to btrfs now, it should hence be
good enough for us too.

This enables a bunch of really nice things for us, most importanly we
can resize home directories freely (i.e. both grow *and* shrink) while
online. It also allows us to add nice subvolume based home directory
snapshotting later on.

Also, whenever we mention the three supported types, alaways mention
them in alphabetical order, which is also our new order of preference.
2020-08-19 15:46:07 +02:00
Lennart Poettering 679badd7ba home: make libpwquality dep a runtime dlopen() one
Also, let's move the glue for this to src/shared/ so that we later can
reuse this in sysemd-firstboot.

Given that libpwquality is a more a leaf dependency, let's make it
runtime optional, so that downstream distros can downgrade their package
deps from Required to Recommended.
2020-08-19 10:03:24 +02:00
fangxiuning 4b6607d949 table use table_log_print_error() instead of table_log_show_error 2020-07-08 15:16:52 +08:00
fangxiuning df83eb546b table add table_log_sort_error() 2020-07-08 10:53:57 +08:00
fangxiuning d836018a73 table add table_log_show_error() 2020-07-08 10:50:59 +08:00
fangxiuning f987a261b4 userdbctl homectl use table_log_add_error()
Signed-off-by: fangxiuning <fangxiuning123@126.com>
2020-07-06 21:32:22 +08:00
Lennart Poettering 0eb3be4644 homectl: add --pkcs11-uri=auto and --pkcs-11-uri=list support
We have the same for FIDO2 devices, for listing suitable devices, or
picking the right one automatically, let's add that for PKCS11 too.
2020-07-01 11:20:26 +02:00
Lennart Poettering 93295a2501 homectl: split out pkcs#11 related code bits into own .c/.h file
There's some highly specific PKCS#11 code in homectl.c. Let's split that
out, since it is easily isolatable, to make homectl.c a bit more
readable.

No funcional changes, just some moving around and renaming two functions
to make them more suitably named when exported.
2020-07-01 11:20:25 +02:00
Lennart Poettering c98811d837 homectl: rework how we log when doing a home directory update
When updating a home directory we might update the record first, then
resize the image and finally synchronize the passwords to the storage
layers. These are three individually authenticated operations. Since
each might require touching a FIDO2 or PKCS#11 key we should say what we
are doing. Hence do so.

Usually we are pretty quiet with what we do, and let's stick to that.
Hence show this information only if we actually do more than one thing.
If we only update (and do not resize/sync passwords) then let's be quiet
as usual, as the command line then sufficiently clarifies what we are
doing.
2020-07-01 11:17:28 +02:00
Lennart Poettering 8e62dfb12a homectl: do generic error handling/retry also when creating a home directory
After all, when creating we might need interaction with the security
token too, and our initial attempt to create the user will fail, since
we do not allow interactive auth on the security token, so that we then
can print a log message and retry with interactive auth then enabled.
2020-07-01 11:17:28 +02:00
Lennart Poettering f737186ab1 homectl: show touch emoji when asking for PKCS#11 protected auth path 2020-07-01 11:17:28 +02:00
Lennart Poettering 7b78db28e5 homed: add support for authenticating with fido2 hmac-secret tokens 2020-07-01 11:17:28 +02:00
Lennart Poettering 1c0c4a43c6 homectl: add support for enrolling FIDO2 HMAC-SECRET tokens 2020-07-01 11:17:28 +02:00
Lennart Poettering c0bde0d240 user-record: rename JSON field "pkcs11Pin" to "tokenPin"
We'd like to use it for FIDO2 tokens too, and the concept is entirely
generic, hence let's just reuse the field, but rename it. Read the old
name for compatibility, and treat the old name and the new name as
identical for most purposes.
2020-07-01 11:17:28 +02:00
Lennart Poettering 7b8d55b72c homectl: add missing log messages when json_variant_format() fails 2020-07-01 11:17:28 +02:00
Lennart Poettering 9b71e4ab90 shared: actually move all BusLocator related calls to bus-locator.c 2020-06-30 15:09:19 +02:00
Frantisek Sumsal cb713f1696 tree-wide: spellcheck fixes
Most of them were reported by Fossies.org
2020-06-26 22:33:56 +02:00
Filipe Brandenburger 41d1f469cf log: introduce log_parse_environment_cli() and log_setup_cli()
Presently, CLI utilities such as systemctl will check whether they have a tty
attached or not to decide whether to parse /proc/cmdline or EFI variable
SystemdOptions looking for systemd.log_* entries.

But this check will be misleading if these tools are being launched by a
daemon, such as a monitoring daemon or automation service that runs in
background.

Make log handling of CLI tools uniform by never checking /proc/cmdline or EFI
variables to determine the logging level.

Furthermore, introduce a new log_setup_cli() shortcut to set up common options
used by most command-line utilities.
2020-06-24 16:49:26 +02:00
layderv a07e962549 homed help --uid short option 2020-06-07 12:38:46 +02:00
Zbigniew Jędrzejewski-Szmek 0328d672f3
Merge pull request #15651 from poettering/newlocale-check
check if locales are installed before using them
2020-05-08 11:31:34 +02:00
Lennart Poettering 7c5137329d
Merge pull request #15713 from poettering/home-discard-when-offline
homed: optionally, issue FITRIM ioctl when logging out
2020-05-07 19:17:48 +02:00
Vito Caputo 8a1596aab5 home: switch to shared bus_home_mgr
Largely mechanical change; s/&home_mgr/bus_home_mgr/g
2020-05-07 08:46:43 -07:00
Lennart Poettering a00a78b84e tree-wide: port various bits over to locale_is_installed() 2020-05-07 17:24:22 +02:00
Lennart Poettering cba116991d homectl: add option for controlling new luksOfflineDiscard user record field 2020-05-07 16:13:07 +02:00
Lennart Poettering 2ffee2c9b0 home: mark various bus messages we write user records to as sensitive
let's make sure that when we append potentially sensitive data to a bus
message we set the sensitive flag on the message object.
2020-04-29 16:32:46 +02:00
Zbigniew Jędrzejewski-Szmek c11428adf9 homectl: say "home area" in more places
Follow-up for b5947b5b10.
2020-04-28 09:56:24 +02:00
Zbigniew Jędrzejewski-Szmek 162392b75a tree-wide: spellcheck using codespell
Fixes #15436.
2020-04-16 18:00:40 +02:00
Zbigniew Jędrzejewski-Szmek 38cd55b007 Remove unneded {}s
$ perl -i -0pe 's|\s+{\n([^\n]*;)\n\s+}\n|\n\1\n|gms' **/*.c

Inspired by ea7cbf5bdd.
2020-04-13 09:31:49 +02:00
Vito Caputo ea7cbf5bdd home: switch to BusLocator-oriented helpers
Remove some unnecessary verbosity, largely mechanical change with
no functional difference.
2020-04-12 17:24:00 +02:00
Lennart Poettering 7a8867abfa user-util: rework how we validate user names
This reworks the user validation infrastructure. There are now two
modes. In regular mode we are strict and test against a strict set of
valid chars. And in "relaxed" mode we just filter out some really
obvious, dangerous stuff. i.e. strict is whitelisting what is OK, but
"relaxed" is blacklisting what is really not OK.

The idea is that we use strict mode whenver we allocate a new user
(i.e. in sysusers.d or homed), while "relaxed" mode is when we process
users registered elsewhere, (i.e. userdb, logind, …)

The requirements on user name validity vary wildly. SSSD thinks its fine
to embedd "@" for example, while the suggested NAME_REGEX field on
Debian does not even allow uppercase chars…

This effectively liberaralizes a lot what we expect from usernames.

The code that warns about questionnable user names is now optional and
only used at places such as unit file parsing, so that it doesn't show
up on every userdb query, but only when processing configuration files
that know better.

Fixes: #15149 #15090
2020-04-08 17:11:20 +02:00
Vito Caputo 80ace4f25e home: fix several typos 2020-03-31 15:16:36 +02:00
Piero La Terza 36e4a8f22a homectl: fix a typo
stroage -> storage
2020-03-31 09:24:38 +02:00
Zbigniew Jędrzejewski-Szmek 18143cd767 tree-wide: s/home/home area/g
"home" is okay-ish in English, but rather awkward in many other languages.
For example, even before this change, in fr.po we had "un espace personnel"
as the translation everywhere. Let's use a less overloaded term.

Fixes #14789.
2020-02-26 11:11:57 +01:00
Chris Murphy d900701eea fix typo in object field
# homectl create hack --fs-type=btrfs
Unexpected object field 'fileSytemType'.
2020-02-10 19:47:42 +09:00
Lennart Poettering 4aa0a8ac3e home: add homectl client tool 2020-01-28 22:36:30 +01:00