summaryrefslogtreecommitdiffstats
path: root/src/sysusers (follow)
Commit message (Collapse)AuthorAgeFilesLines
* various: check meson feature flag earlyMike Yuan2024-11-131-2/+4
| | | | Prompted by https://github.com/systemd/systemd/pull/35110#discussion_r1835885340
* sysusers: add new ! line flag for creating fully locked accountsLennart Poettering2024-10-291-5/+27
| | | | Fixes: #13522
* tree-wide: drop unnecessary utmp includesLennart Poettering2024-09-061-1/+0
|
* sysusers: check if requested group name matches user name in queueNick Rosbrook2024-08-061-1/+7
| | | | | | | | | | | | | | When creating a user, check if the requested group name matches a user name in the queue. If that matched user name is also going to be a group name, then use it for the new user too. In other words, allow the following: u foo - u bar -:foo when both foo and bar are new users. Fixes #33547
* Merge pull request #33599 from keszybz/link-executor-staticallyZbigniew Jędrzejewski-Szmek2024-07-081-1/+1
|\ | | | | Link executor statically
| * meson: rename libbasic to libbasic_staticZbigniew Jędrzejewski-Szmek2024-07-031-1/+1
| | | | | | | | | | | | | | Our variables for internal libraries are named 'libfoo' for the shared lib variant, and 'libfoo_static' for the static lib variant. The only exception was libbasic, because we didn't have a shared variant for it. But let's rename it for consitency. This makes the build config easier to understand.
* | sysusers: handle NSS errors gracefullyLuca Boccassi2024-07-041-6/+6
|/ | | | | | | | | | | | | If the io.systemd.DynamicUser or io.systemd.Machine files exist, but nothing is listening on them, the nss-systemd module returns ECONNREFUSED and systemd-sysusers fails to creat the user/group. This is problematic when ran by packaging scripts, as the package assumes that after this has run, the user/group exist and can be used. adduser does not fail in the same situation. Change sysusers to print a loud warning but otherwise continue when NSS returns an error.
* Drop support for nscdZbigniew Jędrzejewski-Szmek2024-06-281-7/+0
| | | | | | | | | | | | | nscd is known to be racy [1] and it was already deprecated and later dropped in Fedora a while back [1,2]. We don't need to support obsolete stuff in systemd, and the cache in systemd-resolved provides a better solution anyway. We announced the plan to drop nscd in d44934f3785ad9ca4aab757beb80a9b11ba4bc04. [1] https://fedoraproject.org/wiki/Changes/DeprecateNSCD [2] https://fedoraproject.org/wiki/Changes/RemoveNSCD The option is kept as a stub without any effect to make the transition easier.
* tree-wide: replace strv_sort() + strv_uniq() -> strv_sort_uniq()Yu Watanabe2024-06-171-4/+2
|
* gcrypt: dlopenify for libsystemdLuca Boccassi2024-04-031-1/+0
| | | | | | | | | gcrypt is used only for journal sealing operations in libsystemd, so it can be made into a dlopen dependency that is used only on demand. This allows to reduce the footprint of libsystemd in the most common cases. Keep systemd-pull and systemd-resolved with normal linking, as they are executables, and usually built with OpenSSL support anyway.
* Drop unnecessary path_equal_ptr() wrapperZbigniew Jędrzejewski-Szmek2024-03-231-1/+1
| | | | path_equal already works with NULL pointers.
* extract-word: modernize extract_many_wordsMike Yuan2024-03-031-1/+1
|
* Merge pull request #31531 from poettering/verity-userspace-optionalLennart Poettering2024-02-281-1/+2
|\ | | | | dissect: make use of userspace verity keyring optional
| * dissect-image: add flag for explicitly enabling userspace verity signature ↵Lennart Poettering2024-02-281-1/+2
| | | | | | | | | | | | | | | | | | | | checking let's make userspace verity signature checking optional. This adds a dissection flag to enable the logic and patches through all our users to enable it by default, thus effectively not changing anything from the status quo ante. However, know we have a knob to turn this off in certain scenarios.
* | env-util: also rename getenv_uint64_secure() → secure_getenv_uint64()Lennart Poettering2024-02-281-1/+1
|/ | | | | As in the previous commit, let's not change the order of the words compared to the underlying glibc API.
* format-utils: Expose FORMAT_UID and FORMAT_GIDAdrian Vovk2024-02-141-10/+4
| | | | | | This pulls this generally useful helper out of sysusers and into the util lib, and updates the places throughout the codebase where it makes sense to use it.
* sysusers: convert to conf_file_read()Zbigniew Jędrzejewski-Szmek2024-02-091-55/+14
| | | | | | | | | | | | | | I was annoyed that systemd-sysusers doesn't print any info when it opens a config file. Its read_config_file() started out the same as the one in tmpfiles, and then they diverged. The one in tmpfiles has that logging, hence the rework to use it here too and get better logging. The two programs should provide similar functionality, so using a common helper will make it easier to extend them in tandem later. No functional change apart from the log info. The userdata argument (Context) is moved to the last position as requested in the review.
* sysusers,tmpfiles: clarify error message for --replaceZbigniew Jędrzejewski-Szmek2024-02-091-3/+5
| | | | | | I was trying to run sysusers --replace, but the input file didn't have the right suffix, and the message was very confusing. Let's split the message in two to make it clearer that we care about the extension.
* user-util: add get{pw,gr}{uid,gid,name}_malloc() helpersLennart Poettering2024-01-221-42/+30
| | | | | | | | | | | | | | | | | | | These are wrappers around getpwuid_r() and friends, and will allocate the right-sized buffer for this call. We so far had multiple implementations of a buffer allocation loop around getpwuid_r() and friends, and they all suck in some way. Let's clean this up and add a common implementation, and use it everywhere. Also, be more careful with error numbers, in particular systematically turn ENOENT into ENOSRCH (the former is what is returned if /etc/passwd is absent, which we want to consider identical to user not existing, which is ENOSRCH). We so far did this at some invocations, but not all. There are some invocations of getpwuid() left in the codebase. We really should fix those too, and have a single unified implementation of the logic, but those are not as trivial to convert, so left for another time.
* tree-wide: propagate the error we got from strv_extend_xyz() to the callerLennart Poettering2024-01-171-6/+8
| | | | | | It's a bit sloppy to return -ENOMEM rather than the actual error we already returned in the first place (even though it's always going to be ENOMEM)
* src/basic: rename uid-alloc-range.[ch] to uid-classification.[ch]Zbigniew Jędrzejewski-Szmek2024-01-091-1/+1
| | | | | | | | | We had both uid-range.h and uid-alloc-range.h. The latter now contains helpers like {uid,gid}_is_{system,dynamic,container}(), uid_for_system_journal(), so the existing name is outdated. I think the uid-range.[ch] should stay separate because it has a bunch of helpers for parsing and printing of uid ranges. So let's rename as in $subject to better reflect the contents of the file and make the two sets of files harder to confuse.
* src/basic: "UidRange" → "UIDRange"Zbigniew Jędrzejewski-Szmek2024-01-091-1/+1
| | | | | | We don't "uncapitalize" parts of an already-capitalized name when concatenating words. In particular, we had UidRange in basic/uid-range.h and UGIDAllocationRange in basic/uid-alloc-range.h, which is annoying.
* Merge pull request #29553 from keszybz/analyze-cat-config-tldrLuca Boccassi2023-10-251-8/+16
|\ | | | | analyze/cat-config: add switch to print only "interesting" parts of conffiles
| * sysusers: add --tldrZbigniew Jędrzejewski-Szmek2023-10-241-8/+16
| |
| * analyze/cat-config: add switch to print only "interesting" parts of config filesZbigniew Jędrzejewski-Szmek2023-10-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When looking at configuration, often a user wants to suppress the comments and just look at the parts that actually configure something, roughly equivalent to systemd-analyze cat-config … | rg -v '^(#|;|$) This switch implements this natively, skipping lines that start with a comment character or only contain whitespace. For formats that have section headers, section headers are skipped, if only followed by stuff that would be skipped. (The last section header is printed when we're about to print some actual output.) Note that the caller doesn't know if the format has headers or not. We do format type detection in pretty-print.c. So the caller only specifies tldr=true|false, and conf_files_cat() figures out if the format has headers and whether those should be handled specially. The comments that show the file name are always printed, even if all of the file is suppressed. This is a partial answer to the discussions in https://github.com/systemd/systemd/pull/28919, https://github.com/systemd/systemd/pull/29248. If the default config is shown in config files, the user can conveniently use '--tldr' to show the relevant parts.
* | tree-wide: port various parsers over to read_stripped_line()Lennart Poettering2023-10-171-5/+3
|/
* tree-wide: drop "static inline" use in .c filesLennart Poettering2023-08-211-1/+1
| | | | | | | | | "static inline" makes sense in .h files. But in .c files it's useless decoration, the compiler should just make its own decisions there, and it can do that. hence, replace all remaining uses of "static line" by a simple" static" in all .c files (but keep them in .h files, where they make sense)
* sysusers: move global variables into a Context objectLennart Poettering2023-08-091-176/+269
| | | | | | | | | | | | | | | | | Our coding style says static variables suck except for very special cases, i.e. things like the log level or very per-process stuff, such as parsed version of cmdline args and such. sysusers departed from that as one of the very few exceptions in our codebases: it keeps its operational state in global variables. Address that. Introduce a Context object that carries the fields that so far have been global, and pass it around as needed. This has the nice effect that state and configuration is clearly separated in code, and we can very clearly see which functions mangle state and which ones do not. No actual codeflow changes, just refactoring.
* meson: move declarations of hwdb, sysusers, and tmpfilesYu Watanabe2023-08-011-0/+25
|
* Merge pull request #28359 from keszybz/ret-gatherDaan De Meyer2023-07-281-33/+42
|\ | | | | Add RET_GATHER macro to make continue-but-remember-first-error functions easier
| * sysusers: add comments and simplify how set with names is createdZbigniew Jędrzejewski-Szmek2023-07-131-33/+42
| | | | | | | | | | | | | | | | | | | | The code was correct, but rather confusing: it used two sets with strings with trivial_hash_ops to store strings used in other hashmaps. Let's add a bunch of comments to explain what is happening. We also don't need two sets, using just one saves a bit of memory. While at it, let's add some debug messages if duplicate user/group names or uids/gids are present.
* | sysusers: reduce duplication in param list definitionZbigniew Jędrzejewski-Szmek2023-07-171-5/+5
|/
* label: Introduce LabelOps to do pre/post labelling operationsDaan De Meyer2023-05-311-1/+1
| | | | | | | | | By default, label_ops is initialized with a NULL pointer which translates to noop labelling operations. In mac_selinux_init() and the new mac_smack_init(), we initialize label_ops with a MAC specific LabelOps pointer. We also introduce mac_init() to initialize any configured MACs and replace all usages of mac_selinux_init() with mac_init().
* firstboot: process the root account after sysusers created itZbigniew Jędrzejewski-Szmek2023-05-231-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We would create root account from sysusers or from firstboot, depending on which one ran earlier. Since firstboot offers more options, in particular can set the root password, we needed to order it earlier. This created an ugly ordering requirement: systemd-sysusers.service > systemd-firstboot.service > ... > systemd-remount-fs.service > systemd-tmpfiles-setup-dev.service > systemd-sysusers.service We want sysusers.service to create basic users, so we can create nodes in dev, so we can operate on block devices and such, so that we can resize and remount things. But at the same time, systemd-firstboot.service can only work if it is run early, before systemd-sysusers.service has created /etc/passwd. We can't have it both ways: the units that want to have a fully writable root file system cannot be ordered before units which are required to do file system preparation. Instead of trying to order firstboot very early, let's let it do its thing even if it is started later. Instead of refusing to create to the root account if /etc/passwd and /etc/shadow exist, actually check if the account is configured. Now sysusers writes root account with password PASSWORD_UNPROVISIONED ("!unprovisioned"), and then firstboot checks for this, and will configure root in this case. This allows sysusers to be executed earlier (or accounts to be set up earlier in another way). This effectively reverts b825ab1a99b69956057c79838faaf7b44afee474.
* sysusers: fix argument confusion in error messageZbigniew Jędrzejewski-Szmek2023-05-231-2/+2
| | | | | Bug introduced in 335f6ab4f13abcd8073fe84f2a3c70c67271126e. pw/sp are totally wrong in this context, most likely NULL.
* sysusers: add usual "ret_" prefix, fix messagesZbigniew Jędrzejewski-Szmek2023-05-231-16/+16
| | | | | We had 'make backup x'. 'make backup of x' would be correct, but 'backup x' is shorter and to the point.
* 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-201-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
|