summaryrefslogtreecommitdiff
path: root/src/creds
Commit message (Collapse)AuthorAgeFilesLines
* creds: make --pretty behave in a slightly more expected mannerFrantisek Sumsal2023-04-251-7/+8
|
* various: simplify calls to parse_boolean_argument()Zbigniew Jędrzejewski-Szmek2023-04-051-4/+2
| | | | | parse_boolean_argument() returns the same information via both the output argument and normal return.
* string-util: add common implementation of function that converts sized ↵Lennart Poettering2023-01-211-7/+3
| | | | character buffers to NUL terminated C strings
* creds: use empty_or_dash() where appropriateLennart Poettering2022-12-211-1/+1
|
* tree-wide: use -EBADF for fd initializationZbigniew Jędrzejewski-Szmek2022-12-191-1/+1
| | | | | | | | | | | | | | | | -1 was used everywhere, but -EBADF or -EBADFD started being used in various places. Let's make things consistent in the new style. Note that there are two candidates: EBADF 9 Bad file descriptor EBADFD 77 File descriptor in bad state Since we're initializating the fd, we're just assigning a value that means "no fd yet", so it's just a bad file descriptor, and the first errno fits better. If instead we had a valid file descriptor that became invalid because of some operation or state change, the other errno would fit better. In some places, initialization is dropped if unnecessary.
* basic: move version() to build.h+cZbigniew Jędrzejewski-Szmek2022-11-081-0/+1
|
* condition: Check that subsystem is enabled in ConditionSecurity=tpm2Daan De Meyer2022-11-011-2/+4
| | | | | | | | | Instead of succeeding when either the firmware reports a TPM device or we find a TPM device, let's check that the firmware reports a TPM device and the TPM subsystem is enabled in the kernel. To check whether the subsystem enabled, we check if the relevant subdirectory in /sys exists at all.
* creds-tool: expose new signed PCR policies in creds tool, tooLennart Poettering2022-09-081-22/+68
|
* creds-util: hook up new signed PCR policiesLennart Poettering2022-09-081-0/+4
|
* tpm2-util: introduce tpm2_parse_pcr_argument() helperLennart Poettering2022-08-191-15/+2
| | | | | | Add a new tpm2_parse_pcr_argument() helper that unifies how we merge PCR masks in a single function, we can use all over the place. Previously we had basically the same code for this at 4 places.
* creds-tool: don't declare variable in switch bodyLennart Poettering2022-08-161-2/+4
| | | | | | The lifetime of variables decalred in the main switch/case body is just weird. Let's not rely on it, but just open a new {} block, like everywhere else in similar cases.
* creds: trivial coding style fixesLennart Poettering2022-05-021-5/+5
| | | | | | As per: https://github.com/systemd/systemd/pull/23170#pullrequestreview-959233817
* creds-tool: properly search for both encrypted + unencrypted credsLennart Poettering2022-04-281-52/+137
| | | | | Also, properly hook up things with the new fixed paths for system credentials.
* tree-wide: Fix typoYu Watanabe2022-04-251-1/+1
|
* Merge pull request #23122 from poettering/creds-has-tpm2Lennart Poettering2022-04-201-7/+44
|\ | | | | tpm2: beef up tpm2 support checks
| * creds-tool: add new "has-tpm2" verbLennart Poettering2022-04-201-7/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Sometimes it's useful from shell scripts to check if we have a working TPM2 chip around. For example, when putting together encrypted credentials for the initrd (after all: it might be wise to place the root pw in a credential for the initrd to consume, but do so only if we can lock it to the TPM2, and not otherwise, so that we risk nothing). Hence, let's add a new "systemd-creds has-tpm2" verb: it returns zero if we have a working TPM2 (which means: supported by kernel + firmware + us), or non-zero otherwise. Also show which parts are available. Use-case: in future the 'kernel-install' script should use this when deciding whether to augment kernels with security sensitive credentials.
* | creds-util: permit credentials encrypted/signed by fixed zero length keys as ↵Lennart Poettering2022-04-201-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | fallback for systems lacking TPM2 This is supposed to be useful when generating credentials for immutable initrd environments, where it is is relevant to support credentials even on systems lacking a TPM2 chip. With this, if `systemd-creds encrypt --with-key=auto-initrd` is used a credential will be encrypted/signed with the TPM2 if it is available and recognized by the firmware. Otherwise it will be encrypted/signed with the fixed empty key, thus providing no confidentiality or authenticity. The idea is that distributions use this mode to generically create credentials that are as locked down as possible on the specific platform.
* | creds-util: add an explicit 128bit ID for identifying "automatic" key ↵Lennart Poettering2022-04-201-2/+2
|/ | | | | | | | | | | | | | | | | determination Previously, when encrypting creds you could pick which key to use for this via a 128bit ID identifying the key type, and use an all zero ID for rquesting automatic mode. Let's change this to use an explicitly picked 128bit ID for automatic mode, i.e. something other than all zeros. This is in preparation for adding one further automatic mode with slightly different semantics. no change in behaviour. Note that the new 128bit id is never written to disk but only used internally to indicate a specific case.
* systemd-creds: fix name of env varLennart Poettering2022-04-081-1/+1
| | | | | The env var is called $CREDENTIALS_DIRECTORY, not $CREDENTIALS_PATH. Fix message about it accordingly.
* strv: make iterator in STRV_FOREACH() declaread in the loopYu Watanabe2022-03-191-1/+0
| | | | This also avoids multiple evaluations in STRV_FOREACH_BACKWARDS()
* variuos: add missing includesZbigniew Jędrzejewski-Szmek2021-09-221-0/+1
|
* Drop the text argument from assert_not_reached()Zbigniew Jędrzejewski-Szmek2021-08-031-2/+2
| | | | | | | | | | | | | | | | | In general we almost never hit those asserts in production code, so users see them very rarely, if ever. But either way, we just need something that users can pass to the developers. We have quite a few of those asserts, and some have fairly nice messages, but many are like "WTF?" or "???" or "unexpected something". The error that is printed includes the file location, and function name. In almost all functions there's at most one assert, so the function name alone is enough to identify the failure for a developer. So we don't get much extra from the message, and we might just as well drop them. Dropping them makes our code a tiny bit smaller, and most importantly, improves development experience by making it easy to insert such an assert in the code without thinking how to phrase the argument.
* Merge pull request #20186 from keszybz/coverity-fixesLuca Boccassi2021-07-091-16/+5
|\ | | | | Coverity fixes
| * creds: fix leak of arg_tpm2_deviceZbigniew Jędrzejewski-Szmek2021-07-091-15/+4
| | | | | | | | | | | | IIUC, "auto" is the same as NULL. There is no need to strdup() anything. Coverity CID#1458113.
| * creds: drop unnecessary initializationZbigniew Jędrzejewski-Szmek2021-07-091-1/+1
| | | | | | | | | | Coverity also thinks a leak happens here, CID #1458112. This seems wrong, but let's add an assert, maybe that'll help.
* | tree-wide: coccinelle fixesFrantisek Sumsal2021-07-091-3/+3
|/ | | | Yet another batch of Coccinelle fixes.
* creds: add a new tool for listing/showing/encrypting/decrypting credentialsLennart Poettering2021-07-081-0/+812