summaryrefslogtreecommitdiffstats
path: root/src/sysusers (follow)
Commit message (Collapse)AuthorAgeFilesLines
* util-lib: move take_password_lock() to user-util.[ch]Lennart Poettering2015-10-271-1/+1
| | | | | Also, rename it take_etc_passwd_lock(), in order to make it more expressive.
* util-lib: split out user/group/uid/gid calls into user-util.[ch]Lennart Poettering2015-10-261-0/+1
|
* util-lib: split out fd-related operations into fd-util.[ch]Lennart Poettering2015-10-251-0/+1
| | | | | There are more than enough to deserve their own .c file, hence move them over.
* util-lib: split our string related calls from util.[ch] into its own file ↵Lennart Poettering2015-10-241-1/+2
| | | | | | | | | | | | | | string-util.[ch] There are more than enough calls doing string manipulations to deserve its own files, hence do something about it. This patch also sorts the #include blocks of all files that needed to be updated, according to the sorting suggestions from CODING_STYLE. Since pretty much every file needs our string manipulation functions this effectively means that most files have sorted #include blocks now. Also touches a few unrelated include files.
* path-util: unify how we process paths specified on the command lineLennart Poettering2015-10-241-5/+2
| | | | | Let's introduce a common function that makes relative paths absolute and warns about any errors while doing so.
* util-lib: get_current_dir_name() can return errors other than ENOMEMLennart Poettering2015-10-241-5/+5
| | | | | | | | | get_current_dir_name() can return a variety of errors, not just ENOMEM, hence don't blindly turn its errors to ENOMEM, but return correct errors in path_make_absolute_cwd(). This trickles down into a couple of other functions, some of which receive unrelated minor fixes too with this commit.
* smack: label /etc/passwd and friends as '_' smack label when ↵Sangjung Woo2015-10-071-12/+22
| | | | | | | | | | | | | | | | --with-smack-run-label' is enabled systemd-sysusers.service unit creates system users and groups and it could update /etc/passwd, /etc/group, /etc/shadow and /etc/gshadow. Those files should have '_' smack label because of accessibility. However, if systemd has its own smack label using '--with-smack-run-label' configuration, systemd-sysusers process spawned by systemd(pid:1) has its parent smack label and eventually updated files also is set as its parent smack label. This patch fixes that bug by labeling updated files as '_' smack label when --with-smack-run-label' is enabled.
* util: introduce common version() implementation and use it everywhereLennart Poettering2015-09-291-15/+12
| | | | | | This also allows us to drop build.h from a ton of files, hence do so. Since we touched the #includes of those files, let's order them properly according to CODING_STYLE.
* tree-wide: never use the off_t unless glibc makes us use itLennart Poettering2015-09-101-1/+1
| | | | | | | | | | | off_t is a really weird type as it is usually 64bit these days (at least in sane programs), but could theoretically be 32bit. We don't support off_t as 32bit builds though, but still constantly deal with safely converting from off_t to other types and back for no point. Hence, never use the type anymore. Always use uint64_t instead. This has various benefits, including that we can expose these values directly as D-Bus properties, and also that the values parse the same in all cases.
* util: Don't interpret quotes by default in extract_first_wordRichard Maw2015-08-071-1/+1
| | | | | This adds an EXTRACT_QUOTES option to allow the previous behaviour, of not interpreting any character inside ' or " quotes as separators.
* util: change unquote_*_word to extract_*_wordRichard Maw2015-08-071-1/+1
| | | | | It now takes a separators argument, which defaults to WHITESPACE if NULL is passed.
* Convert unquote_*_word users to expect isempty(p) after the last entryRichard Maw2015-08-071-1/+1
| | | | | | | | | | | | | | | This is so that, when called in a loop, unquote_first_word can distinguish between reaching the end of a string because it has consumed all the input before the end, and consuming all the input. This is important because we later add a flag that allows char *in = ""; char *out; unquote_first_word(&in, &out, flags); To put "" in out, and set in = NULL, so the trailing empty string of the input can be consumed, and mark that the input has been consumed.
* tree-wide: introduce mfree()David Herrmann2015-07-311-24/+12
| | | | | | | | | Pretty trivial helper which wraps free() but returns NULL, so we can simplify this: free(foobar); foobar = NULL; to this: foobar = mfree(foobar);
* tree-wide: use free_and_strdup()Daniel Mack2015-07-301-5/+6
| | | | | Use free_and_strdup() where appropriate and replace equivalent, open-coded versions.
* util: add generic calls for prefixing a root directory to a pathLennart Poettering2015-05-131-9/+7
| | | | | | | | So far a number of utilities implemented their own calls for this, unify them in prefix_root() and prefix_roota(). The former uses heap memory, the latter allocates from the stack via alloca(). Port over most users of a --root= logic.
* shared: add formats-util.hRonny Chevalier2015-04-101-0/+1
|
* util: rework word parsing and c unescaping codeLennart Poettering2015-03-261-1/+1
| | | | | | | | | | | When parsing words from input files, optionally automatically unescape the passed strings, controllable via a new flags parameter. Make use of this in tmpfiles, and port everything else over, too. This improves parsing quite a bit, since we no longer have to process the same string multiple times with different calls, where an earlier call might corrupt the input for a later call.
* sysusers: do not reject users with already present /etc/shadow entriesIvan Shapovalov2015-03-071-14/+9
| | | | | | This is needed to interoperate firstboot and sysusers. The former one is started first, and it writes only /etc/shadow when it is told to set the root password. It's better to relax checks here than to duplicate functionality in firstboot.
* remove unused includesThomas Hindoe Paaboel Andersen2015-02-231-2/+0
| | | | | | This patch removes includes that are not used. The removals were found with include-what-you-use which checks if any of the symbols from a header is in use.
* util: rework strappenda(), and rename it strjoina()Lennart Poettering2015-02-031-2/+2
| | | | | | After all it is now much more like strjoin() than strappend(). At the same time, add support for NULL sentinels, even if they are normally not necessary.
* logind: unify how we cast between uid_t and pointers for hashmap keysLennart Poettering2015-01-091-6/+0
|
* tmpfiles: add new line type 'v' for creating btrfs subvolumesLennart Poettering2014-12-281-0/+1
|
* copy: use btrfs reflinking only whe we know we copy full filesLennart Poettering2014-12-121-1/+1
|
* treewide: introduce UID_INVALID (and friends) as macro for (uid_t) -1Lennart Poettering2014-11-281-1/+1
|
* treewide: another round of simplificationsMichal Schmidt2014-11-281-12/+6
| | | | | Using the same scripts as in f647962d64e "treewide: yet more log_*_errno + return simplifications".
* treewide: use log_*_errno whenever %m is in the format stringMichal Schmidt2014-11-281-7/+7
| | | | | | | | | | | If the format string contains %m, clearly errno must have a meaningful value, so we might as well use log_*_errno to have ERRNO= logged. Using: find . -name '*.[ch]' | xargs sed -r -i -e \ 's/log_(debug|info|notice|warning|error|emergency)\((".*%m.*")/log_\1_errno(errno, \2/' Plus some whitespace, linewrap, and indent adjustments.
* treewide: a few more log_*_errno + return simplificationsMichal Schmidt2014-11-281-2/+1
| | | | The one in tmpfiles.c:create_item() even looks like it fixes a bug.
* treewide: yet more log_*_errno + return simplificationsMichal Schmidt2014-11-281-32/+20
| | | | | | | | | | | | | Using: find . -name '*.[ch]' | while read f; do perl -i.mmm -e \ 'local $/; local $_=<>; s/(if\s*\([^\n]+\))\s*{\n(\s*)(log_[a-z_]*_errno\(\s*([->a-zA-Z_]+)\s*,[^;]+);\s*return\s+\g4;\s+}/\1\n\2return \3;/msg; print;' $f done And a couple of manual whitespace fixups.
* treewide: no need to negate errno for log_*_errno()Michal Schmidt2014-11-281-15/+15
| | | | It corrrectly handles both positive and negative errno values.
* treewide: auto-convert the simple cases to log_*_errno()Michal Schmidt2014-11-281-15/+15
| | | | | | | | | | | | | As a followup to 086891e5c1 "log: add an "error" parameter to all low-level logging calls and intrdouce log_error_errno() as log calls that take error numbers", use sed to convert the simple cases to use the new macros: find . -name '*.[ch]' | xargs sed -r -i -e \ 's/log_(debug|info|notice|warning|error|emergency)\("(.*)%s"(.*), strerror\(-([a-zA-Z_]+)\)\);/log_\1_errno(-\4, "\2%m"\3);/' Multi-line log_*() invocations are not covered. And we also should add log_unit_*_errno().
* Introduce CONF_DIRS_NULSTR helper to define standard conf dirsJosh Triplett2014-11-271-9/+1
| | | | | | | Several different systemd tools define a nulstr containing a standard series of configuration file directories, in /etc, /run, /usr/local/lib, /usr/lib, and (#ifdef HAVE_SPLIT_USR) /lib. Factor that logic out into a new helper macro, CONF_DIRS_NULSTR.
* sysuser: simplify access mode syncing by introducing helper function for itLennart Poettering2014-11-111-21/+23
|
* sysusers: be nice and print a warning if futimens() failsLennart Poettering2014-11-071-1/+2
| | | | CID# 1251163
* sysusers: Preserve ownership and mode on /etc/passwd and friendsColin Guthrie2014-10-301-20/+41
| | | | | | | | When running sysusers we would clobber file ownership and permissions on the files /etc/passwd, /etc/group and /etc/[g]shadow. This simply preserves the ownership and mode if existing files are found.
* mac: rename apis with mac_{selinux/smack}_ prefixWaLyong Cho2014-10-231-1/+1
|
* sysusers: Remove some gcc warnings about uninitialized variablesPhilippe De Swert2014-09-181-2/+2
| | | | | Gcc is spewing some warnings about uninitialized variables. Let's get rid of the noise.
* hashmap: introduce hash_ops to make struct Hashmap smallerMichal Schmidt2014-09-151-11/+11
| | | | | | | | | It is redundant to store 'hash' and 'compare' function pointers in struct Hashmap separately. The functions always comprise a pair. Store a single pointer to struct hash_ops instead. systemd keeps hundreds of hashmaps, so this saves a little bit of memory.
* sysusers: initialize rThomas Hindoe Paaboel Andersen2014-08-191-1/+1
| | | | | Needed for the stdin case where it could otherwise end up being used uninitialized.
* tmpfiles: add new 'r' line type to add UIDs/GIDs to the pool to allocate ↵Lennart Poettering2014-08-191-72/+135
| | | | | | | | UIDs/GIDs from This way we can guarantee a limited amount of compatibility with login.defs, by generate an appopriate "r" line out of it, on package installation.
* sysusers: add another column to sysusers files for the home directoryLennart Poettering2014-08-191-56/+118
|
* sysusers: optionally, read sysuers configuration from standard inputLennart Poettering2014-08-191-7/+14
|
* sysusers: also update /etc/shadow and /etc/gshadow when creating new system ↵Lennart Poettering2014-08-191-17/+238
| | | | | | users This should resolve problems with tools like "grpck" and suchlike.
* sysusers: isempty will never be < 0Thomas Hindoe Paaboel Andersen2014-08-041-1/+1
| | | | looks like a typo from 1b99214789101976d6bbf75c351279584b071998
* Unify parse_argv styleZbigniew Jędrzejewski-Szmek2014-08-041-9/+6
| | | | | | | | | | | | | | | | getopt is usually good at printing out a nice error message when commandline options are invalid. It distinguishes between an unknown option and a known option with a missing arg. It is better to let it do its job and not use opterr=0 unless we actually want to suppress messages. So remove opterr=0 in the few places where it wasn't really useful. When an error in options is encountered, we should not print a lengthy help() and overwhelm the user, when we know precisely what is wrong with the commandline. In addition, since help() prints to stdout, it should not be used except when requested with -h or --help. Also, simplify things here and there.
* sysusers: fix selinux context of backup filesZbigniew Jędrzejewski-Szmek2014-07-221-21/+24
| | | | | | | | | Also, fix fopen_temporary_label to set proper context. By chance, all users so far used the same context, so the error didn't matter. Also, check return value from label_init(). https://bugzilla.redhat.com/show_bug.cgi?id=1121806
* Add function to open temp files in selinux modeZbigniew Jędrzejewski-Szmek2014-07-141-11/+4
|
* sysusers: preserve label of /etc/{passwd, group}Colin Walters2014-07-141-1/+12
| | | | | These files are specially labeled on SELinux systems, and we need to preserve that label.
* sysusers: allow overrides in /etc and /runZbigniew Jędrzejewski-Szmek2014-07-111-0/+2
| | | | | | | | An administrator might want to block a certain sysusers config file from being executed, e.g. to block the creation of a certain user. Only a relatively short description is added in the man page, since overrides should be relatively rare.
* sysusers: don't allow control characters in gecos fieldsLennart Poettering2014-07-091-1/+5
|
* sysusers: don't allow user names longer than UT_NAMESIZELennart Poettering2014-07-091-0/+4
| | | | | As pointed out by Miloslav Trmač it might be a good idea to make sure that usernames stay with in the utmp-defined limits.