summaryrefslogtreecommitdiff
path: root/src/sysusers/sysusers.c
Commit message (Collapse)AuthorAgeFilesLines
* dissect-image: port mount_image_privately_interactively() to use ↵Lennart Poettering2023-05-161-3/+3
| | | | | | | | | | /run/systemd/mount-rootfs/ too Let's use the same common directory as the unit logic uses. This means we have less to clean up, and opens the door to eventually allow unprivileged operation of the mount_image_privately_interactively() logic.
* image-policy: introduce parse_image_policy_argument() helperYu Watanabe2023-04-131-13/+8
| | | | | | | | | Addresses https://github.com/systemd/systemd/pull/25608/commits/84be0c710d9d562f6d2cf986cc2a8ff4c98a138b#r1060130312, https://github.com/systemd/systemd/pull/25608/commits/84be0c710d9d562f6d2cf986cc2a8ff4c98a138b#r1067927293, and https://github.com/systemd/systemd/pull/25608/commits/84be0c710d9d562f6d2cf986cc2a8ff4c98a138b#r1067926416. Follow-up for 84be0c710d9d562f6d2cf986cc2a8ff4c98a138b.
* tree-wide: hook up image dissection policy logic everywhereLennart Poettering2023-04-051-9/+26
|
* chase-symlinks: Rename chase_symlinks() to chase()Daan De Meyer2023-03-241-3/+3
| | | | | | | | | Chasing symlinks is a core function that's used in a lot of places so it deservers a less verbose names so let's rename it to chase() and chaseat(). We also slightly change the pattern used for the chaseat() helpers so we get chase_and_openat() and similar.
* dissect-image: Return mount point fd if requestedDaan De Meyer2023-02-171-0/+1
|
* sysusers: when comparing items, log debug the differenceZbigniew Jędrzejewski-Szmek2023-02-011-16/+55
|
* sysusers: add helper to create new ItemZbigniew Jędrzejewski-Szmek2023-02-011-34/+50
|
* pid1,sysusers: drop unused SYNTHETIC_ERRNOZbigniew Jędrzejewski-Szmek2023-01-311-1/+1
| | | | | The only function of SYNTHETIC_ERRNO is to set the return value. If we're ignoring the return value, it shouldn't be used.
* sysusers: drop counterproductive bitfield annotationsZbigniew Jędrzejewski-Szmek2023-01-311-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | The usual story: $ diff -u <(pahole build/systemd-sysusers.0) <(pahole build/systemd-sysusers) /* size: 80, cachelines: 2, members: 15 */ - /* sum members: 68, holes: 1, sum holes: 4 */ - /* sum bitfield members: 5 bits (0 bytes) */ - /* padding: 7 */ - /* bit_padding: 3 bits */ + /* sum members: 73, holes: 1, sum holes: 4 */ + /* padding: 3 */ /* last cacheline: 16 bytes */ Effectively, because of padding, we were not saving anything. We're not putting struct Item in arrays, but when allocating on the heap, we're going to round up to normal alignment too. The code becomes shorter (and quicker): $ size build/systemd-sysusers{,.0} text data bss dec hex filename 79967 2040 264 82271 1415f build/systemd-sysusers.0 79726 2040 264 82030 1406e build/systemd-sysusers (In case you're wondering, I wrote this long commit message for a very simple change on purpose: I want to deflate the bitfield cargo cult a bit.)
* tree-wide: use -EBADF moreYu Watanabe2022-12-211-2/+2
|
* Rename def.h to constants.hZbigniew Jędrzejewski-Szmek2022-11-081-1/+1
| | | | | | The name "def.h" originates from before the rule of "no needless abbreviations" was established. Let's rename the file to clarify that it contains a collection of various semi-related constants.
* basic: move version() to build.h+cZbigniew Jędrzejewski-Szmek2022-11-081-1/+1
|
* sysusers: cross-check user and group names tooLuca BRUNO2022-11-031-9/+19
| | | | | | | | | | This adds an additional name check when cross-matching new group entries against existing users, which allows coalescing entries matching both ID and name. It provides a small idempotence enhancement when creating groups in cases where matching user entries are in place. By fine-tuning the conflict detection logic, this avoids picking up new random IDs and correctly prefers configuration values instead.
* tree-wide: drop unused reference to DecryptedImageYu Watanabe2022-09-181-3/+1
|
* uid-range: tie up number and array of uid range entriesYu Watanabe2022-09-161-8/+7
| | | | | | This renames UidRange -> UidRangeEntry, and reintroduces UidRange which contains the array of UidRangeEntry and its size. No fucntional changes, just refactoring.
* sysusers: make sp_lstchg shadow field reproducibleJohannes Schauer Marin Rodrigues2022-09-021-1/+14
| | | | | If the environment variable SOURCE_DATE_EPOCH is set, use its value instead of the current time.
* tree-wide: Fix a some remaining format warnings by castingJan Janssen2022-08-301-2/+2
|
* tree-wide: Use correct format specifiersJan Janssen2022-08-301-1/+1
| | | | gcc will complain about all these with -Wformat-signedness.
* sysusers: report the original error when writing failsZbigniew Jędrzejewski-Szmek2022-08-241-30/+26
| | | | | | | | | | | | | We have fairly nice error messages for specific operations, but only at debug level. Instead, we'd print a fairly useless generic message: Before: Failed to write files: Invalid argument After: Failed to add existing group "users" to temporary group file: Invalid argument Fixes #10241.
* various: try to use DEFAULT_USER_SHELL for root tooZbigniew Jędrzejewski-Szmek2022-08-241-1/+1
| | | | | | | | | | | | | | | | | | | /bin/sh as a shell is punishing. There is no good reason to make the occasional root login unpleasant. Since /bin/sh is usually /bin/bash in compat mode, i.e. if one is available, the other will be too, /bin/bash is almost as good as a default. But to avoid a regression in the situation where /bin/bash (or DEFAULT_USER_SHELL) is not installed, we check with access() and fall back to /bin/sh. This should make this change in behaviour less risky. (FWIW, e.g. Fedora/RHEL use /bin/bash as default for root.) This is a follow-up of sorts for 53350c7bbade8c5f357aa3d1029ef9b2208ea675, which added the default-user-shell option, but most likely with the idea of using /bin/bash less ;) Fixes #24369.
* sysusers: do not warn about values that equivalentZbigniew Jędrzejewski-Szmek2022-08-241-8/+52
| | | | | | | | | | | | | | | | | | | We'd warn that "-" and "/sbin/nologin" are different, even even though "/sbin/nologin" is the default we'd use. So let's stop warning in all cases where the config would lead to the same file, also under different paths, or when both shells are nologin shells. The general idea is to avoid warnings when sysusers config is moved between packages (and not exactly the same), or when it is generated from some template and the details change in an unimportant way. We try to chase symlinks. This means that on unmerged-usr systems we'll find that e.g. /usr/bin/bash and /bin/bash are equivalent if the basic fs structure is already in place (bash doesn't actually have to be installed, enough that the /bin symlink exists). I think this is a good result: after all, /bin/bash and /usr/bin/bash *may* be different things on an unmerged-usr system. Fixes #24215.
* sysusers: do not reject non-simplified paths for shell/homeZbigniew Jędrzejewski-Szmek2022-08-221-0/+4
| | | | | | | | /home/zbyszek/src/systemd-work/testcase.conf:3: '//sbin//nologin' is not a valid login shell field. This isn't very useful. The usual argument holds: people use templates to construct config, so paths may have doubled slashes and similar. Let's simplify paths so that the value that is pushed to /etc/passwd is nice and clean.
* sysusers: use log_syntax (changes prefix from '[%s:%u]' to '%s:%u:')Zbigniew Jędrzejewski-Szmek2022-08-221-71/+63
| | | | | This makes the sysusers use the same message convention as other tools. Also adds the prefix in a few places.
* sysusers: rename output params with 'ret'Zbigniew Jędrzejewski-Szmek2022-08-191-9/+9
|
* sysusers: add fsync for passwd (#24324)Avram Lubkin2022-08-161-1/+1
| | | | | | | https://github.com/systemd/systemd/pull/6636 added `fsync()` when temporary shadow, group, and gshadow files are created, but it was not added for passwd. As far as I can tell, this seems to have been an oversight. I'm seeing real world issues where a blank /etc/passwd file is being created if a machine loses power early in the boot process.
* creds: refactor reading user passwordLudwig Nussel2022-08-111-23/+9
| | | | Share code between firstboot and sysusers
* sysusers: properly process user entries with an explicit GIDLuca BRUNO2022-08-091-2/+4
| | | | | | | | This tweaks user creation logic to properly take into consideration an explicitly requested GID. It fixes a bug where the creation flow would mistakenly fall back to use the username instead, resulting in wrong lookups in case of users and groups using the same name.
* sysusers: only check whether the requested GID is availableLuca BRUNO2022-08-091-13/+15
| | | | | | | This relaxes the availability check when creating a group, if an explicit GID has been requested. It avoids mixing up users and groups entries with valid and unique UIDs/GIDs, but each having the same ID number.
* sysusers: allow defining additional sysusers lines via credentialsLennart Poettering2022-07-161-13/+34
|
* tree-wide: allow ASCII fallback for … in logsDavid Tardon2022-06-281-6/+6
|
* uid-range: use size_t for array sizeLennart Poettering2022-04-011-1/+1
|
* strv: make iterator in STRV_FOREACH() declaread in the loopYu Watanabe2022-03-191-6/+0
| | | | This also avoids multiple evaluations in STRV_FOREACH_BACKWARDS()
* tree-wide: use strv_contains() in more placesZbigniew Jędrzejewski-Szmek2022-03-181-2/+2
|
* sysusers: use filename if /proc is not mountedYu Watanabe2021-12-311-1/+1
| | | | | | During system install, /proc may not be mounted yet. Fixes RHBZ#2036217 (https://bugzilla.redhat.com/show_bug.cgi?id=2036217).
* bootctl: write KERNEL_INSTALL_LAYOUT=bls and KERNEL_INSTALL_MACHINE_ID=…Zbigniew Jędrzejewski-Szmek2021-12-171-3/+3
| | | | | | | | | | | | | | | | This is a natural extension of d6bce6e224: if we are installing sd-boot, we want to use the sd-boot layout, so let's write the appropriate KERNEL_INSTALL_LAYOUT setting. Effectively, if we do 'booctl install', kernel-install will not autodetect the layout anymore. And 357376d0bb added support for KERNEL_INSTALL_MACHINE_ID. We need to support it here too. We both read it, so that we create the right directories, and also write it if it wasn't written yet and we created some directories using it, so that kernel-install that is executed later knows the machine-id that matches the directories we crated. The code is changed in some places to fail if we can't figure out the current status. When installing the boot loader it's probably better not to guess.
* sysusers: raise level of message about UID/GID being already usedZbigniew Jędrzejewski-Szmek2021-12-081-2/+2
| | | | | It can be quite important that a different value was used, so let's log this by default.
* sysusers: improve message about conflicting entriesZbigniew Jędrzejewski-Szmek2021-12-081-7/+23
| | | | | | | | | | | Without any markup, the sentence could be quite confusing: g user 55 g user 56 → "Two or more conflicting lines for user configured" It also wasn't clear which line is ignored. Inspired by https://github.com/systemd/systemd/pull/21156.
* sysusers: add --dry-runZbigniew Jędrzejewski-Szmek2021-12-081-4/+34
|
* sysusers: use ordered_hashmap_isempty()Zbigniew Jędrzejewski-Szmek2021-12-081-4/+4
|
* sysusers: use uppercase UID/GID consistently in messagesZbigniew Jędrzejewski-Szmek2021-12-081-26/+26
|
* tree-wide: use new RET_NERRNO() helper at various placesLennart Poettering2021-11-161-4/+1
|
* shared: split out UID allocation range stuff from user-record.hLennart Poettering2021-11-131-1/+1
| | | | | | | | user-record.[ch] are about the UserRecord JSON stuff, and the UID allocation range stuff (i.e. login.defs handling) is a very different thing, and complex enough on its own, let's give it its own c/h files. No code changes, just some splitting out of code.
* Make pager_open() return voidZbigniew Jędrzejewski-Szmek2021-11-031-1/+1
|
* Avoid passing NULL to underlying fprintf() in sysusers (#20974)(GalaxyMaster)2021-10-111-1/+1
|
* basic: split out sync() family of calls from fs-util.[ch] into new c/h fileLennart Poettering2021-10-051-0/+1
| | | | No changes in code, just some splitting out.
* 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.
* tree-wide: "a" -> "an"Yu Watanabe2021-06-301-1/+1
|
* tree-wide: make specifier expansion --root= awareLennart Poettering2021-06-241-5/+5
| | | | | | | | | | | | | | | | | | | | | | This fixes repart's, systemctl's, sysusers' and tmpfiles' specifier expansion to honour the root dir specified with --root=. This is relevant for specifiers such as %m, %o, … which are directly sourced from files on disk. This doesn't try to be overly smart: specifiers referring to runtime concepts (i.e. boot ID, architecture, hostname) rather than files on the medium are left as is. There's certainly a point to be made that they should fail in case --root= is specified, but I am not entirely convinced about that, and it's certainly something we can look into later if there's reason to. I wondered for a while how to hook this up best, but given that quite a large number of specifiers resolve to data from files on disks, and most of our tools needs this, I ultimately decided to make the root dir a first class parameter to specifier_printf(). Replaces: #16187 Fixes: #16183
* tree-wide: add missing whitespace at the end of commentsYu Watanabe2021-06-151-1/+1
|
* tree-wide: always drop unnecessary dot in pathYu Watanabe2021-05-281-2/+2
|