Commit Graph

78 Commits

Author SHA1 Message Date
Tudor Roman 6a220cdb0b home: respect user record mount flags 2020-05-24 22:48:50 +02:00
Lennart Poettering c8f145adbb homed: don't insist on authentication against host-copy user record
homed maintains two or three copies of the user's identity record per
home directory: one on the host, one inside the LUKS header, and one
embedded in the home directory.

Previously we'd insist that if a user logs in they have to authenticate
against all three, as a safety feature. This broke logging into
unfixated records however, since in that case the host version is
synthetic and thus does not carry any authentication data.

Let's hence losen the strictness here: accept authentication against
host records that carry no auth data. This should be safe as we know
after all that the second/third record will catch invalid accesses.

Fixes: #15178
2020-05-21 23:39:30 +02:00
Lennart Poettering 1a53adb3ab homed: include error string when in log message if quota doesn't work 2020-05-21 23:39:30 +02:00
Lennart Poettering fa3709c5fb homed: also fsync private/public key pair when storing it 2020-05-21 23:39:30 +02:00
Lennart Poettering e8dd54ab3c homed: fix typo 2020-05-21 23:39:30 +02:00
Lennart Poettering b847192699 homed: make sure we log about invalid user records we load 2020-05-21 23:39:30 +02:00
Lennart Poettering 20f4a308bf homed: automatically clean up empty user record files
See: #15178
2020-05-21 23:39:30 +02:00
Lennart Poettering e4005ffe00 homed: when updating local copy of user record, sync to disk
Apparently xfs needs us to sync explicitly, see #15178.
2020-05-21 23:28:49 +02:00
Lennart Poettering cbffdcecae homed: return a better error when a home has no authentication information defined
We can't log into home entries that have no password or PKCS#11 token.
Return a proper, useful error in that case.

See: #15178
2020-05-21 23:28:48 +02:00
Lennart Poettering a60416f319 homed: fix return value mix-up
We generally return > 1 if any of the actions we are doing is instantly
complete and == 0 when we started doing it asynchronously (by forking
off homework), in our functions that execute operations on homes.

Fix a mix-up where the test for this was reversed in
home_dispatch_release() and home_dispatch_lock_all().

Fixes: #15684
2020-05-21 08:10:13 +02:00
Anita Zhang 30ed6e2250
Merge pull request #15864 from poettering/pam-sudo-fixes-part3
two more pam_systemd fixes, split out of #15742
2020-05-20 15:01:52 -07:00
Zbigniew Jędrzejewski-Szmek 6b8664cb5b tree-wide: fix bad errno checks 2020-05-20 18:10:58 +02:00
Lennart Poettering 764ae4dd51 man_systemd_home: intrdouce SYSTEMD_HOME_SUSPEND env var
This variable is read by the module and can be used instead of the
suspend= PAM module parameter.

It is also set for the session itself to make debugging easy.
2020-05-20 00:47:37 +02:00
Zbigniew Jędrzejewski-Szmek 5e375a1ef2
Merge pull request #15794 from poettering/pam-sudo-fixes-part2
pam_systemd/pam_systemd_home: fix caching
2020-05-19 10:09:14 +02:00
Lennart Poettering c5dc0a298e homed: use right config section in example config
We really should get this right, otherwise it's a pretty useless vendor
default example configuration file.

Follow-up for: c76dd733af
2020-05-19 09:26:49 +02:00
Lennart Poettering 6c8428bb8b pam_systemd_home: also store acquirement fd per user
We might pin a home through authentication and a different one through a
session, all from the same PAM context, like sudo does. Hence also store
the referencing fd keyed by the user name.
2020-05-12 17:38:32 +02:00
Lennart Poettering dbe7fff476 pam_systemd/pam_systemd_home: rework how we cache user records
Since acquiring user records involves plenty of IPC we try to cache user
records in the PAM context between our various hooks. Previously we'd
just cache whatever we acquired, and use it from the on, forever until
the context is destroyed.

This is problematic however, since some programs (notably sudo) use the
same PAM context for multiple different operations. Specifically, sudo
first authenticates the originating user before creating a session for
the destination user, all with the same PAM context. Thankfully, there
was a safety check for this case in place that re-validated that the
cached user record actually matched our current idea of the user to
operate on, but this just meant the hook would fail entirely.

Let's rework this: let's key the cache by the user name, so that we do
not confused by the changing of the user name during the context's
lifecycle and always, strictly use the cached user record of the user we
operate on.

Essentially this just means we now include the user name in the PAM data
field.

Secondly, this gets rid of the extra PAM data field that indicates
whether a user record is from homed or something else. To simplify
things we instead just cache the user record twice: once for consumption
by pam_systemd_home (which only wants homed records) and once shared by
pam_systemd and pam_systemd_home (and whoever else wants it). The cache
entries simply have different field names.
2020-05-12 17:38:32 +02:00
Lennart Poettering 0289b4ec69
Merge pull request #15785 from poettering/pam-sudo-fixes-part1
some simple PAM fixes split out of #15742
2020-05-12 15:54:42 +02:00
Lennart Poettering da4340fd43 pam_systemd_home: use correct macro for converting ptr to fd 2020-05-12 11:10:10 +02:00
Lennart Poettering 55842c7326 homed: fix parameter names on D-Bus methods
These arguments contain UserRecord structures serialized to JSON,
however only the "secret" part of it, not a whole user record. We do
this since the secret part is conceptually part of the user record and
in some contexts we need a user record in full with both secret and
non-secret part, and in others just the secret and in other just the
non-secret part, but we want to keep this in memory in the same logic.

Hence, let's rename the arguments where we expect a user record
consisting only of the secret part to "secret".
2020-05-12 11:06:46 +02:00
Joel Shapiro d423294394 Fix misuse of PAM_PROMPT_ECHO_OFF in systemd-homed
Previously pam_systemd_home.so was relying on `PAM_PROMPT_ECHO_OFF` to
display error messages to the user and also display the next prompt.
`PAM_PROMPT_ECHO_OFF` was never meant as a way to convey information to
the user, and following the example set in pam_unix.so you can see that
it's meant to _only_ display the prompt. Details about why the
authentication failed should be done in a `PAM_ERROR_MSG` before
displaying a short prompt as per usual using `PAM_PROMPT_ECHO_OFF`.
2020-05-12 00:27:08 +02:00
Zbigniew Jędrzejewski-Szmek f2a8372e37
Merge pull request #15703 from poettering/homed-tweak-default-storage
homed: avoid double encryption
2020-05-08 16:57:14 +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
Zbigniew Jędrzejewski-Szmek 8acb7780df
Merge pull request #15623 from poettering/cmsg-cleanup
various CMSG_xyz clean-ups, split out of #15571
2020-05-08 11:05:06 +02:00
Lennart Poettering c76dd733af homed: make default storage/file system type configurable in homed.conf 2020-05-07 23:33:09 +02:00
Lennart Poettering c07bf7a4ed homed: move supported_fstype() to home-util.c
That way we can use it from other modules too. Just some shifting
around, no change in behaviour.
2020-05-07 23:33:04 +02:00
Lennart Poettering 1dfe5de095 homed: tweak logic for picking a default storage and file system
Let's make the logic a bit smarter: if we detect that /home is
encrypted, let's avoid double encryption and prefer plain
directory/subvolumes instead of our regular luks images.

Also, allow configuration go storage/file system via an env var passed
to homework. In a later commit, let's then change homed to initialize
that env var from a config file setting, when invoking homework.
2020-05-07 23:33:01 +02:00
Lennart Poettering 0d5e523461 home: when adding a binding for a user record, use common code for determining automatic image path
Make use of the new user_record_build_image_path() helper the previous
commit added to share some code.

Also, let's make sure we update all parsed-out fields with the new data
from the binding, so that the parsed-out fields are definitely
up-to-date.
2020-05-07 23:32:57 +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 28a7f10620 homework: run fitrim or fallocate on logout based on the new user record property 2020-05-07 16:13:07 +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 c06bcd4d68 homed: allow overriding homework path via env var
Let's make debugging a bit easier: when invoking homed from the build
tree it's now possible to make sure homed invokes the build tree's
homework binary by setting an env var.
2020-05-07 15:48:59 +02:00
Lennart Poettering fb29cdbef2 tree-wide: make sure our control buffers are properly aligned
We always need to make them unions with a "struct cmsghdr" in them, so
that things properly aligned. Otherwise we might end up at an unaligned
address and the counting goes all wrong, possibly making the kernel
refuse our buffers.

Also, let's make sure we initialize the control buffers to zero when
sending, but leave them uninitialized when reading.

Both the alignment and the initialization thing is mentioned in the
cmsg(3) man page.
2020-05-07 14:39:44 +02:00
Lennart Poettering ba876a4c8d homed: open up home dir Acquire operation to unpriv clients
Apparently unpriv clients expect to be able to auth via PAM. Kinda
sucks. But it is what it is. Hence open this up.

This shouldn't be too bad in effect since clients after all need to
provide security creds for unlocking the home dir, in order to misuse
this.

Fixes: #15072
2020-05-07 09:43:02 +02:00
Zbigniew Jędrzejewski-Szmek ba5a389d24 Merge pull request #15473 from keszybz/bus-introspection 2020-05-06 15:00:07 +02:00
Zbigniew Jędrzejewski-Szmek cfd508a9d6 homed: convert to the new scheme and add --bus-introspect 2020-05-06 09:13:42 +02:00
Lennart Poettering 560a3e5dd6 home: make sure whenever we touch the 'secret' part of a user record, we set the the sensitive flag on it 2020-04-29 16:32:46 +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
Lennart Poettering 113a51d221 home: fix strv NUL termination
Fixes: #15559
2020-04-23 21:15:02 +02:00
Lennart Poettering 3691bcf3c5 tree-wide: use recvmsg_safe() at various places
Let's be extra careful whenever we return from recvmsg() and see
MSG_CTRUNC set. This generally means we ran into a programming error, as
we didn't size the control buffer large enough. It's an error condition
we should at least log about, or propagate up. Hence do that.

This is particularly important when receiving fds, since for those the
control data can be of any size. In particular on stream sockets that's
nasty, because if we miss an fd because of control data truncation we
cannot recover, we might not even realize that we are one off.

(Also, when failing early, if there's any chance the socket might be
AF_UNIX let's close all received fds, all the time. We got this right
most of the time, but there were a few cases missing. God, UNIX is hard
to use)
2020-04-23 09:41:47 +02:00
Zbigniew Jędrzejewski-Szmek 1943d50e4e
Merge pull request #15507 from poettering/bus-log-api
add generic bus interface for setting log level that can be implemented by any daemon
2020-04-22 23:30:09 +02:00
Frantisek Sumsal 86b52a3958 tree-wide: fix spelling errors
Based on a report from Fossies.org using Codespell.

Followup to #15436
2020-04-21 23:21:08 +02:00
Frantisek Sumsal e4ff03935c tree-wide: formatting tweaks reported by Coccinelle 2020-04-21 23:21:04 +02:00
Lennart Poettering ac9f55ed40 tree-wide: implement new log control API dbus interface in all our daemons 2020-04-21 17:08:16 +02:00
Zbigniew Jędrzejewski-Szmek 162392b75a tree-wide: spellcheck using codespell
Fixes #15436.
2020-04-16 18:00:40 +02:00
Joel Shapiro 332f38d084 Fix pam_systemd_home's debug parameter to match man page description 2020-04-13 17:41:27 +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