Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

USER_GROUP_API: typo fixes #1

Open
wants to merge 109 commits into
base: homed
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
7062ae5
ordered-set: add ordered_set_first() helper
poettering Aug 19, 2019
f39bbe7
errno: add new ERRNO_IS_NOT_SUPPORTED() and ERRNO_IS_DISK_SPACE() hel…
poettering Jul 15, 2019
2fcfeea
errno-util: add ERRNO_IS_PRIVILEGE() helper
poettering Aug 9, 2019
e94058b
memory-util: introduce erase_and_free() helper
poettering Aug 8, 2019
d4b1045
string-util: readd string_erase()
poettering Jul 11, 2019
b0dfc2a
loop-util: accept loopback flags when creating loopback device
poettering Dec 23, 2018
682b899
loop-util: add API to refresh loopback device size and opening existi…
poettering Dec 31, 2018
260101e
loop-util: allow creating loopback block devices with offset/length
poettering Jul 4, 2019
9a7923a
loop-util: allow refreshing offset
poettering May 20, 2019
5210ce8
loop-util: add api for locking the block device with flock()
poettering May 21, 2019
d38e8aa
loop-util: optionally also resize partitions
poettering May 21, 2019
b1d7789
loop-util: fill in the loopback number, even a posteriori
poettering Jul 4, 2019
62777db
loop-util: if we fail to fully set up a loop device, detach it again
poettering Jul 4, 2019
614bc3c
chown-recursive: move src/core/chown-recursive.[ch] → src/shared/
poettering Dec 23, 2018
37eb258
chown-recursive: add fd based API
poettering Apr 16, 2019
07631a8
missing: add XFS magic
poettering Dec 28, 2018
40df083
shared: add new wrapper for online fs resizing ioctls
poettering Dec 27, 2018
a464b10
fileio: add an openat() flavour for fopen()
poettering Jan 8, 2019
2130f80
fileio: add 'dir_fd' parameter to read_full_file_full()
poettering Jan 8, 2019
00d9ce3
fileio: add WRITE_STRING_FILE_MODE_0600 flag for writing files
poettering May 17, 2019
e9a4da9
json: beef up strv parser to also accept a single string instead of a…
poettering Jan 3, 2019
7f84dbd
json: add new json_variant_is_blank_object() helper
poettering Jul 4, 2019
b5eeeb6
json: add new API json_variant_filter() for dropping fields from objects
poettering Jan 3, 2019
9fd1d12
json: add new json_variant_set_field() helper
poettering Jan 4, 2019
0e416fa
json: add a new "sensitive" flags for JsonVariant objects
poettering Jan 8, 2019
1224506
json: add json_parse_file_at() helper
poettering Jan 8, 2019
2a36786
json: add flags parameter to json_parse_file(), for parsing "sensitiv…
poettering Jan 8, 2019
6d42301
json: optionally, make string checks stricter when dispatching strings
poettering Apr 23, 2019
886dda4
json: add json_variant_strv() helper that converts a json variant to …
poettering Apr 23, 2019
b3c05e5
nspawn-oci: use new json_variant_strv() helper
poettering Apr 25, 2019
4b388c2
json: add json_variant_set_field_string() and json_variant_set_field_…
poettering Jul 4, 2019
90123fc
json: add json_variant_merge() helper
poettering Jul 4, 2019
90f7a5f
json: add concept of normalization
poettering May 15, 2019
db42e52
json: add new helper json_variant_new_base64()
poettering Jul 4, 2019
3f44959
json: add new helper json_variant_append_array()
poettering Jul 4, 2019
d8b214e
json: allow putting together base64 fields with json_build()
poettering Jul 4, 2019
a9ba9ca
json: add ability to generate empty arrays/objects in json builder
poettering May 23, 2019
ae561bb
json: permit 'null' as a way to reset tri-states to default
poettering May 24, 2019
bce7c7a
json: add explicit log call for ENOMEM
poettering May 28, 2019
f8a6c47
json: add new flag for forcing a flush after dumping json data to file
poettering May 29, 2019
243dc10
json: add json_variant_unbase64() helper
poettering Jun 28, 2019
31efe31
json: add json_variant_set_field_integer() and json_variant_set_field…
poettering Jul 4, 2019
fbcef7e
json: add more dispatch helpers
poettering Jul 4, 2019
abcc2df
json: teach json_build() to build arrays from C arrays of JsonVariant
poettering Jul 29, 2019
7323d0e
json: add const string dispatcher
poettering Aug 7, 2019
dedc45d
json: add new output flag JSON_PRETTY_AUTO
poettering Aug 15, 2019
c3ca000
sd-bus: add new call sd_bus_message_sensitive() and SD_BUS_VTABLE_SEN…
poettering Aug 19, 2019
a65e6da
sd-bus: don't include properties maked as "emit-invalidation" in Inte…
poettering Aug 20, 2019
7052223
nss-util: add macros for generating getpwent()/getgrent() prototypes
poettering Aug 7, 2019
bb42c64
user-util: export is_nologin_shell() so that we can use it elsewhere
poettering Aug 7, 2019
2c6bb5d
user-util: add uid_is_container() for checking whether UID is in cont…
poettering Aug 7, 2019
b7c9c9b
user-util: add helper to check whether UNIX hashed password is valid
poettering Aug 9, 2019
c22c28e
tmpfile-util: if no path is passed to fopen_temporary() make one up
poettering Apr 23, 2019
4ab7bae
tmpfile-util: modernize mkostemp_safe() a bit
poettering Jul 4, 2019
1cfd6b4
process-util: add new safe_fork() flag for connecting stdout to stderr
poettering May 6, 2019
375068e
main-func: send main exit code to parent via sd_notify() on exit
poettering May 17, 2019
a4ad8ef
varlink: add correct support for more/continues method calls
poettering Aug 7, 2019
e34088c
varlink: add varlink_close_unref() helper
poettering May 28, 2019
4b6af2d
varlink: move connection fds > fd2
poettering Aug 15, 2019
4090e16
varlink: port varlink code over to use getdtablesize() for sizing num…
poettering Aug 20, 2019
60a652b
format-table: add UID/GID output support to format-table.h
poettering Aug 7, 2019
167ef06
login: port tables over to use TABLE_UID/TABLE_GID
poettering Aug 7, 2019
663c065
mkosi: add fdisk-devel, openssl-devel, libpwquality-devel and efsck t…
poettering Jul 3, 2019
fd97a2c
shared: add generic user/group record structures and JSON parsers
poettering Aug 7, 2019
4c95d0e
shared: add helpers for converting NSS passwd/group structures to new…
poettering Aug 5, 2019
4060e8d
shared: add internal API for querying JSON user records via varlink
poettering Aug 7, 2019
f9f1fb8
shared: add helpers for displaying new-style user/group records to users
poettering Aug 5, 2019
50ac473
userdbd: add new service that can merge userdb queries from multiple …
poettering Jul 4, 2019
a976651
userdbd: add userdbctl tool as client for userdbd
poettering Aug 5, 2019
01259c1
core: make return parameter of dynamic_user_lookup_name() optional
poettering Aug 7, 2019
40274d7
core: add user/group resolution varlink interface to PID 1
poettering Aug 7, 2019
0740e5c
nss: hook up nss-systemd with userdb varlink bits
poettering Jul 4, 2019
ab11443
homed: add new systemd-homed service that can manage LUKS homes
poettering Jul 4, 2019
fa30c4c
home: add homectl client tool
poettering Jul 4, 2019
8e69203
home: add pam_systemd_home.so PAM hookup
poettering Jul 4, 2019
cdc6153
test: add test case for homed
poettering Jul 7, 2019
50a2d98
logind: port to UserRecord object
poettering Aug 7, 2019
78c8c7a
logind: enforce user record resource settings when user logs in
poettering Aug 8, 2019
c7bef7b
logind: honour killProcesses field of user record
poettering Aug 9, 2019
07ea937
logind: honour per-user stopDelayUSec property
poettering Aug 9, 2019
1b22da6
logind: switch to short copyright header in polkit policy file
poettering Aug 9, 2019
c337c0c
pam-systemd: include PAM error code in all our log messages where tha…
poettering Aug 12, 2019
65509fb
pam-systemd: port to pam_bus_log_{create|parse}_error() and pam_log_o…
poettering Aug 12, 2019
0fee194
pam-systemd: remove duplicate error logging
poettering Aug 12, 2019
4be6bb8
pam-systemd: voidify pam_get_item() calls
poettering Aug 12, 2019
aac37f8
pam-systemd: share bus connection with pam_systemd_home if we can
poettering Aug 12, 2019
d4120d7
pam-systemd: port over to use a UserRecord structure
poettering Aug 12, 2019
e179e91
pam-systemd: normalize return values of append_session_xyz()
poettering Aug 13, 2019
7c5bb1a
pam-systemd: apply user record properties to session
poettering Aug 13, 2019
ba49efd
pam_systemd: add one more assert
poettering Aug 13, 2019
dc28f48
pam_systemd: don't use PAM_SYSTEM_ERR for something that isn't precis…
poettering Aug 13, 2019
df1d498
pam_systemd: prolong method call timeout when allocating session
poettering Aug 19, 2019
723c954
sleep: automatically lock all home directories when suspending
poettering Aug 19, 2019
2eb8a9c
cryptsetup: minor coding style clean-ups
poettering Aug 21, 2019
bc43b2e
cryptsetup: use STR_IN_SET() where appropriate
poettering Aug 21, 2019
d044558
cryptsetup: add native pkcs#11 support to cryptsetup
poettering Aug 22, 2019
1660e79
man: add homectl(1) man page
poettering Aug 23, 2019
4dc65ee
man: add systemd-homed man page
poettering Aug 26, 2019
5c9eb17
man: add man page for sd_bus_message_sensitive()
poettering Aug 26, 2019
ae298b0
man: document pam_systemd_home
poettering Aug 26, 2019
7b50b61
man: document userdbctl(1)
poettering Aug 28, 2019
8ccd348
man: document systemd-userdbd.service
poettering Aug 28, 2019
b16d05a
docs: document homed UID range
poettering Aug 26, 2019
2df59ec
docs: document the home directory format
poettering Aug 26, 2019
137187c
docs: add documentation for JSON user records
poettering Aug 27, 2019
dbdf681
docs: add documentation for JSON group records, too
poettering Aug 27, 2019
c2004b3
docs: add documentation for the varlink user/group APIs
poettering Aug 28, 2019
749f6a7
TODO-HOME
poettering Jul 4, 2019
2955089
USER_GROUP_API: typo fixes
phomes Sep 15, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .mkosi/mkosi.fedora
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ BuildPackages=
libblkid-devel
libcap-devel
libcurl-devel
libfdisk-devel
libgcrypt-devel
libidn2-devel
libmicrohttpd-devel
libmount-devel
libpwquality-devel
libseccomp-devel
libselinux-devel
libtool
Expand All @@ -51,6 +53,7 @@ BuildPackages=
lz4-devel
m4
meson
openssl-devel
pam-devel
pcre2-devel
pkgconfig
Expand All @@ -61,6 +64,7 @@ BuildPackages=
xz-devel

Packages=
e2fsprogs
libidn2

BuildDirectory=mkosi.builddir
Expand Down
63 changes: 63 additions & 0 deletions CRYPTSETUP
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Using a Yubikey for unlocking arbitrary LUKS devices.
#
# A few notes on the used parameters:
#
# → We use RSA (and not ECC), since Yubikeys support PKCS#11 Decrypt() only for
# RSA keys (ECC keys can only be used for signing?)
# → We use RSA2048, which is the longest key size current Yubikeys support for
# RSA
# → LUKS key size must be << 2048bit due to RSA padding, hence we use 128 bytes
# → We use Yubikey key slot 9d, since that's apparently the keyslot to use for
# decryption purposes, see:
# https://developers.yubico.com/PIV/Introduction/Certificate_slots.html

# Make sure noone can read the files we generate, but us
umask 077

# Clear the Yubikey from any old keys
ykman piv reset

# Generate a new private/public key pair on th device, store the public key in
# 'pubkey.pem'.
ykman piv generate-key -a RSA2048 9d pubkey.pem

# Create a self-signed certificate from this public key, and store it on the
# device.
ykman piv generate-certificate --subject "Knobelei" 9d pubkey.pem

# Check if the newly create key on the Yubikey shows up as token in
# PKCS#11. Have a look at the output, and copy the resulting token URI to the
# clipboard.
p11tool --list-tokens

# Generate a (secret) random key to use as LUKS decryption key.
dd if=/dev/urandom of=plaintext.bin bs=128 count=1

# Encrypt this newly generated LUKS decryption key using the public key whose
# private key is on the Yubikey, store the result in
# /etc/encrypted-luks-key.bin, where we'll look for it during boot.
openssl rsautl -encrypt -pubin -inkey pubkey.pem -in plaintext.bin -out /etc/encrypted-luks-key.bin

# Configure the LUKS decryption key on the LUKS device. We use very low pbkdf
# settings since the key already has quite a high quality (it comes directly
# from /dev/urandom after all), and thus we don't need to do much key
# derivation.
cryptsetup luksAddKey /dev/sda1 plaintext.bin --pbkdf-memory=32 --pbkdf-parallel=1 --pbkdf-force-iterations=4

# Now securely delete the plain text LUKS key, we don't need it anymore, and
# since it contains secret key material it should be removed from disk
# thoroughly.
shred -u plaintext.bin

# We don't need the public key anymore either, let's remove it too. Since this
# one is not security sensitive we just do a regular "rm" here.
rm pubkey.pem

# Test: Let's run systemd-cryptsetup to test if this all worked. The option
# string should contain the full PKCS#11 URI we have in the clipboard, it tells
# the tool how to decypher the encrypted LUKS key.
systemd-cryptsetup attach mytest /dev/sda1 /etc/encrypted-luks-key.bin 'pkcs11-uri=pkcs11:…'

# If that worked, let's now add the same line persistently to /etc/crypttab,
# for the future.
echo "mytest /dev/sda1 /etc/encrypted-luks-key 'pkcs11-uri=pkcs11:…' >> /etc/crypttab
17 changes: 8 additions & 9 deletions TODO
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ Janitorial Clean-ups:

Features:

* socket units: allow creating a udev monitor socket with ListenDevices= or so,
with matches, then actviate app thorugh that passing socket oveer

* cryptsetup: allow encoding key directly in /etc/crypttab, maybe with a
"base64:" prefix. Useful in particular for pkcs11 mode.

* cryptsetup: add logic to wait for pkcs11 token

* coredump: maybe when coredumping read a new xattr from /proc/$PID/exe that
may be used to mark a whole binary as non-coredumpable. Would fix:
https://bugs.freedesktop.org/show_bug.cgi?id=69447
Expand Down Expand Up @@ -395,15 +403,6 @@ Features:

* maybe introduce gpt auto discovery for /var/tmp?

* maybe add gpt-partition-based user management: each user gets his own
LUKS-encrypted GPT partition with a new GPT type. A small nss module
enumerates users via udev partition enumeration. UIDs are assigned in a fixed
way: the partition index is added as offset to some fixed base uid. User name
is stored in GPT partition name. A PAM module authenticates the user via the
LUKS partition password. Benefits: strong per-user security, compatibility
with stateless/read-only/verity-enabled root. (other idea: do this based on
loopback files in /home, without GPT involvement)

* gpt-auto logic: introduce support for discovering /var matching an image. For
that, use a partition type UUID that is hashed from the OS name (as encoded
in /etc/os-release), the architecture, and 4 new bits from the gpt flags
Expand Down
51 changes: 51 additions & 0 deletions TODO-HOME
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
PRIMARILY:

- pkcs11 smart card support: pin certificate in record, then for auth, generate random data, ask smartcard to sign it, then verify signature. For LUKS key store encrypted key in record, decrypt it with smartcard.
- write fscrypt key into client's keyring
- don't use argon2 with pkcs#11 cryptsetup mode
- move the ssh authorized keys stuff from homectl to userdbctl
- honour passwordChangeNow, and unset it in homectl passwd
- fix borked yubikey cryptsetup stuff?

Before first release:
- unit file lockdown (caps, …)
- extend test case to cover more
- man pages:
cryptsetup pkcs11
pam_systemd update
nss-systemd update
- blog story
- fix userwork and homework paths
- drop LOG_DEBUG being forced in userdbd and homed
- drop debug=true being forced in pam_systemd_home
- performance data

Later:
- when user tries to log into record signed by unrecognized key, automatically add key to our chain after polkit auth
- hook up machined/nspawn users with a varlink user query interface
- rollback when resize fails mid-operation
- forget key on suspend (requires gnome rework so that lock screen runs outside of uid)
- resize on login?
- update LUKS password on login if we find there's a password that unlocks the JSON record but not the LUKS device.
- always fstrim on logout?
- compare with accounts daemon
- create on activate?
- properties: icon url?, preferred session type?, administrator bool (which translates to 'wheel' membership)?, address?, telephone?, vcard?, samba stuff?, parental controls?
- communicate clearly when usb stick is safe to remove. probably involves
beefing up logind to make pam session close hook synchronous and wait until
systemd --user is shut down.
- logind: maybe keep a "busy fd" as long as there's a non-released session around or the [email protected]
- fscrypt key mgmt (maybe in xattr?)
- shrink fs on logout?
- maybe make automatic, read-only, time-based reflink-copies of LUKS disk images (think: time machine)
- distuingish destroy / remove (i.e. currently we can unregister a user, unregister+remove their home directory, but not just remove their home directory)
- in systemd's PAMName= logic: query passwords with ssh-askpassword, so that we can make "loginctl set-linger" mode work
- fingerprint authentication, pattern authentication, …
- make sure "classic" user records can also be managed by homed
- description field for groups
- make size of $XDG_RUNTIME_DIR configurable in user record
- reuse pwquality magic in firstboot
- query password from kernel keyring first
- update in absence
- add a "access mode" + "fstype" field to the "status" section of json identity records reflecting the actually used access mode and fstype, even on non-luks backends
- move acct mgmt stuff from pam_systemd_home to pam_systemd?
156 changes: 156 additions & 0 deletions docs/GROUP_RECORD.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
---
title: JSON Group Records
---

# JSON Group Records

Long story short: JSON Group Records are to `struct group` what [JSON User
Records](https://systemd.io/USER_RECORD.md) are to `struct passwd`.

Conceptually, much of what applies to JSON user records also applies to JSON
group records. They also consist of seven sections, with similar properties and
they carry some identical (or at least very similar) fields.

## Fields in the `regular` section

`groupName` → A string with the UNIX group name. Matches the `gr_name` field of
UNIX/glibc NSS `struct group`, or the shadow structure `struct sgrp`'s
`sg_namp` field.

`realm` → The "realm" the group belongs to, conceptually identical to the same
field of user records. A string in DNS domain name syntax.

`disposition` → The disposition of the group, conceptually identical to the
same field of user records. A string.

`service` → A string, an identifier for the service managing this group record
(this field is typically in reverse domain name syntax.)

`lastChangeUSec` → An unsigned 64bit integer, a timestamp (in µs since the UNIX
epoch 1970) of the last time the group record has been modified. (Covers only
the `regular`, `perMachine` and `privileged` sections).

`gid` → An unsigned integer in the range 0…4294967295: the numeric UNIX group
ID (GID) to use for the group. This corresponds to the `gr_gid` field of
`struct group`.

`members` → An array of strings, listing user names that are members of this
group. Note that JSON user records also contain a `memberOf` field, or in other
words a group membership can either be denoted in the JSON user record or in
the JSON record, or in both. The list of memberships should be determined as
the combination of both lists (plus optionally others). If a user is listed as
member of a group and doesn't exist it should be ignored. This field
corresponds to the `gr_mem` field of `struct group` and the `sg_mem` field of
`struct sgrp`.

`administrators` → Similarly, an array of strings, listing user names that
shall be considered "administrators" of this group. This field corresponds to
the `sg_adm` field of `struct sgrp`.

`privileged`/`perMachine`/`binding`/`status`/`signature`/`secret` → The
objects/arrays for the other six group record sections. These are organized the
same way as for the JSON user records, and have the same semantics.

## Fields in the `privileged` section

The following fields are defined:

`hashedPassword` → An array of strings with UNIX hashed passwords; see the
matching field for user records for details. This field corresponds to the
`sg_passwd` field of `struct sgrp` (and `gr_passwd` of `struct group` in a
way).

## Fields in the `perMachine` section

`matchMachineId`/`matchHostname` → Strings, match expressions similar as for
user records, see the user record documentation for details.

The following fields are defined for the `perMachine` section and are defined
equivalent to the fields of the same name in the `regular` section, and
override those:

`gid`, `members`, `administrators`

## Fields in the `binding` section

The following fields are defined for the `binding` section, and are equivalent
to the fields of the same name in the `regular` and `perMachine` sections:

`gid`

## Fields in the `status` section

The following fields are defined in the `status` section, and are mostly
equivalent to the fields of the same name in the `regular` section, though with
slightly different conceptual semantics, see the same fields in the user record
documentation:

`service`

## Fields in the `signature` section

The fields in this section are defined identically to those in the matching
section in the user record.

## Fields in the `secret` section

Currently no fields are defined in this section for group records.

## Mapping to `struct group` and `struct sgrp`

When mapping classic UNIX group records (i.e. `struct group` and `struct sgrp`)
to JSON group records the following mappings should be applied:

| Structure | Field | Section | Field | Condition |
|----------------|-------------|--------------|------------------|----------------------------|
| `struct group` | `gr_name` | `regular` | `groupName` | |
| `struct group` | `gr_passwd` | `privileged` | `password` | (See notes below) |
| `struct group` | `gr_gid` | `regular` | `gid` | |
| `struct group` | `gr_mem` | `regular` | `members` | |
| `struct sgrp` | `sg_namp` | `regular` | `groupName` | |
| `struct sgrp` | `sg_passwd` | `privileged` | `password` | (See notes below) |
| `struct sgrp` | `sg_adm` | `regular` | `administrators` | |
| `struct sgrp` | `sg_mem` | `regular` | `members` | |

At this time almost all Linux machines employ shadow passwords, thus the
`gr_passwd` field in `struct group` is set to `"x"`, and the actual password
is stored in the shadow entry `struct sgrp`'s field `sg_passwd`.

## Extending These Records

The same logic and recommendations apply as for JSON user records

## Examples

A reasonable group record for a system group might look like this:

```json
{
"groupName" : "systemd-resolve",
"gid" : 193,
"status" : {
"6b18704270e94aa896b003b4340978f1" : {
"service" : "io.systemd.NameServiceSwitch"
}
}
}
```

And here's a more complete one for a regular group:

```json
{
"groupName" : "grobie",
"binding" : {
"6b18704270e94aa896b003b4340978f1" : {
"gid" : 60232
}
},
"disposition" : "regular",
"status" : {
"6b18704270e94aa896b003b4340978f1" : {
"service" : "io.systemd.Home"
}
}
}
```
Loading