summaryrefslogtreecommitdiff
path: root/src/basic
Commit message (Collapse)AuthorAge
* tree-wide: drop assert.h includesZbigniew Jędrzejewski-Szmek2017-07-25
| | | | | We provide an independent reimplementation in macro.h, and that's the one we want to use. Including the system header is unnecessary and confusing.
* tree-wide: when %m is used in log_*, always specify errno explicitlyZbigniew Jędrzejewski-Szmek2017-07-25
| | | | | | | | All those uses were correct, but I think it's better to be explicit. Using implicit errno is too error prone, and with this change we can require (in the sense of a style guideline) that the code is always specified. Helpful query: git grep -n -P 'log_[^s][a-z]+\(.*%m'
* basic/fileio: extend atomic file writing with timestamp settingZbigniew Jędrzejewski-Szmek2017-07-25
| | | | There should be no functional change.
* Revert "selinux: split up mac_selinux_have() from mac_selinux_use()"Gary Tierney2017-07-25
| | | | | | | | | | | | | | | This reverts commit 6355e75610a8d47fc3ba5ab8bd442172a2cfe574. The previously mentioned commit inadvertently broke a lot of SELinux related functionality for both unprivileged users and elogind instances running as MANAGER_USER. In particular, setting the correct SELinux context after a User= directive is used would fail to work since we attempt to set the security context after changing UID. Additionally, it causes activated socket units to be mislabeled for elogind --user processes since setsockcreatecon() would never be called. Reverting this fixes the issues with labeling outlined above, and reinstates SELinux access checks on unprivileged user services.
* core: introduce cg_mask_from_string()/cg_mask_to_string()Franck Bui2017-07-25
|
* parse-util: introduce parse_dev() helperFranck Bui2017-07-25
|
* tmpfiles: use safe_glob()Zbigniew Jędrzejewski-Szmek2017-07-25
| | | | | | | | | | | | This filters out "." and ".." from glob results. Fixes #5655 and #5644. Any judgements on whether the path is "safe" are removed. We will not remove "/" under any name (including "/../" and such), but we will remove stuff that is specified using paths that include "//", "/./" and "/../". Such paths can be created when joining strings automatically, or for other reasons, and people generally know what ".." and "." is. Tests are added to make sure that the helper functions behave as expected.
* basic: add readdir_no_dot and safe_glob functionsZbigniew Jędrzejewski-Szmek2017-07-25
| | | | | | safe_glob filters out "." and "..". This converts all users of glob_extend() and glob_exists() to safe_glob.
* Add Geneve netlink properties to missing.hSusant Sahani2017-07-25
|
* shared/extract-word: replace enum with unsigned int to avoid undefined behaviourZbigniew Jędrzejewski-Szmek2017-07-25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ../src/basic/extract-word.c:255:22: warning: passing an object that undergoes default argument promotion to 'va_start' has undefined behavior [-Wvarargs] va_start(ap, flags); ^ ../src/basic/extract-word.c:244:77: note: parameter of type 'ExtractFlags' (aka 'enum ExtractFlags') is declared here int extract_many_words(const char **p, const char *separators, ExtractFlags flags, ...) { ^ ../src/basic/extract-word.c:286:22: warning: passing an object that undergoes default argument promotion to 'va_start' has undefined behavior [-Wvarargs] va_start(ap, flags); ^ ../src/basic/extract-word.c:244:77: note: parameter of type 'ExtractFlags' (aka 'enum ExtractFlags') is declared here int extract_many_words(const char **p, const char *separators, ExtractFlags flags, ...) { ^ 2 warnings generated. I think the relevant part of C99 is 6.7.2.2 Enumeration specifiers: Each enumerated type shall be compatible with char, a signed integer type, or an unsigned integer type. The choice of type is implementation-defined, but shall be capable of representing the values of all the members of the enumeration. and 7.16.1.4: The parameter parmN is the identifier of the rightmost parameter in the variable parameter list in the function definition (the one just before the ...). If the parameter parmN is declared with the register storage class, with a function or array type, or with a type that is not compatible with the type that results after application of the default argument promotions, the behavior is undefined. This might cause a real issue if the compiler chooses something that is not an integer for ExtractFlags. Rework the code to avoid the warning, but add an assert_cc in a large-valued ExtractFlags element is ever defined and the type is bumped to something wider than an int.
* basic/log: expose log_dispatchZbigniew Jędrzejewski-Szmek2017-07-25
| | | | | | | | | | This is useful when we want to avoid printf formatting on the message. It's nicer than using log_struct with "%s" as the format, because printf is slow and with a large message (like from a backtrace) this would require extra unnecessary memory. I'm not exposing all the fields in the wrapper: only level and errno. Those are the most likely to be useful.
* tree-wide: mark log_struct with _printf_ and fix falloutZbigniew Jędrzejewski-Szmek2017-07-25
| | | | | | | | | | | | | | log_struct takes multiple format strings, each one followed by arguments. The _printf_ annotation is not sufficiently flexible to express this, but we can still annotate the first format string, though not its arguments (because their number is unknown). With the annotation, the places which specified the message id or similar as the first pattern cause a warning from -Wformat-nonliteral. This can be trivially fixed by putting the MESSAGE= first. This change will help find issues where a non-literal is erroneously used as the pattern.
* basic/log: fix _printf_ annotation on log_object_internalvZbigniew Jędrzejewski-Szmek2017-07-25
| | | | | | | | | | | | Fixup for 4b58153dd22172d817055d2a09a0cdf3f4bd9db3. I saw this because of a clang warning. With gcc the -Wformat-nonliteral warning doesn't seem to work as expected. In two places, a string constructed with strjoina is used as the pattern. This is safe, because we're taking a pattern which was already marked with _printf_ and prepending a known value to it. Those places are marked with #pragma to silence the warning.
* basic/random-util: add new header for getrandom()Zbigniew Jędrzejewski-Szmek2017-07-25
| | | | | | | There's some confusion: older man pages specify that linux/random.h contains getrandom, but newer glibc has it in sys/random.h. Detect if the newer header is available and include it. We still need the older header for the flags.
* basic/missing.h: drop inclusion of macro.hZbigniew Jędrzejewski-Szmek2017-07-25
| | | | It's not necessary for anything.
* basic/def.h: drop TTY_GID definitionZbigniew Jędrzejewski-Szmek2017-07-25
| | | | | We already provide a definition through the configuration system, this one is duplicate.
* basic: forbid rm_rf() to remove paths ending with ".." (#5653)Jan Synacek2017-07-25
| | | | Fixes: #5644
* fix includesMatija Skala2017-07-25
| | | | | | | linux/sockios.h is needed for the SIOCGSTAMPNS macro xlocale.h is included indirectly in glibc and doesn't even exist in other libcs
* missing.h: add vxlan netlink propertiesSusant Sahani2017-07-25
|
* basic/log: split max log level into multiple "realms"Zbigniew Jędrzejewski-Szmek2017-07-25
| | | | | | | | | | | | | | The single log level is split into an array of log levels. Which index in the array is used can be determined for each compilation unit separately by setting a macro before including log.h. All compilation units use the same index (LOG_REALM_SYSTEMD), so there should be no functional change. v2: - the "realm" is squished into the level (upper bits that are not used by priority or facility), and unsquished later in functions in log.c. v3: - rename REALM_PLUS_LEVEL to LOG_REALM_PLUS_LEVEL and REALM to LOG_REALM_REMOVE_LEVEL.
* Prep v233.3: Add HAVE_UTMP information to basic/build.hSven Eden2017-07-21
|
* Prep v233.3: Remove stray character.Sven Eden2017-07-21
|
* Prep v233.3: Unmask various functions for future coverage tests.Sven Eden2017-07-19
| | | | | These functions, although not used by elogind itself, are mostly tiny and crucial for important tests to work.
* Prep v233.2: Mask unneeded functions and definitions in src/basicSven Eden2017-07-18
|
* Prep v233: Add missing updates from upstream in src/basicSven Eden2017-07-17
|
* Prep v233: Add missing includes in src/basicSven Eden2017-07-17
|
* Prep v233: Unmask now needed functions in src/basicSven Eden2017-07-17
|
* Prep v233: Add missing files from upstream and rename formats-util.[hc]Sven Eden2017-07-17
| | | | | | | | | | | | | | | | Some functionality has been exported to the following files: - src/basic/env-util.[hc] - src/basic/exec-util.[hc] - src/shared/nsflags.[hc] The content of these files is now needed in elogind, and the files have been added as-is. Cleanup is done later. Further the header src/basic/formats-util.h has been renamed to src/basic/format-util.h
* Revert "util: Fine tune running_in_chroot() a bit" (#5506)Lennart Poettering2017-07-17
| | | | | | | | | | | This reverts commit 295ee9845c801300298d01256eb5a9e3ff117ae0. Let'd revert this for now, see #5446 for discussions. We want elogind-detect-virt --chroot to return true for all chroot-like stuff, for example mock environments which have use a mount namespace. The downside of this revert that systemctl will not work from our own namespaced services, anything with RootDirectory=/RootImage= set.
* mount-util: accept that name_to_handle_at() might fail with EPERM (#5499)Lennart Poettering2017-07-17
| | | | | | | | | | | | | Container managers frequently block name_to_handle_at(), returning EACCES or EPERM when this is issued. Accept that, and simply fall back to to fdinfo-based checks. Note that we accept either EACCES or EPERM here, as container managers can choose the error code and aren't very good on agreeing on just one. (note that this is a non-issue with nspawn, as we permit name_to_handle_at() there, only block open_by_handle_at(), which should be sufficiently safe).
* socket-util: introduce address_label_validSusant Sahani2017-07-17
|
* Fix missing space in comments (#5439)AsciiWolf2017-07-17
|
* cgroup: rework cg_all_unified()Lennart Poettering2017-07-17
| | | | | | | | Let's just check the unified level, directly. There's really no value in wrapping cg_unified_controllers() with this, i.e. potentially do string comparison when there's no reason to. Also, this makes the clal more alike cg_hybrid_unified().
* cgroup: rename cg_update_unified() → cg_unified_update()Lennart Poettering2017-07-17
| | | | | We usually put the noun first, the verb (i.e. method) secont, for example in cg_unified_flush(), let's follow the logic here...
* cgroup: rename cg_unified() → cg_unified_controller()Lennart Poettering2017-07-17
| | | | | cg_unified() is a bit generic a name, let's make clear that it checks whether a specified controller is in unified mode.
* cgroup: change cg_unified() to possibly return errors againLennart Poettering2017-07-17
| | | | | | | | | We use our cgroup APIs in various contexts, including from our libraries sd-login, sd-bus. As we don#t control those environments we can't rely that the unified cgroup setup logic succeeds, and hence really shouldn't assert on it. This more or less reverts 415fc41ceaeada2e32639f24f134b1c248b9e43f.
* cgroup-util: check unified_cache before invoking streq()Lennart Poettering2017-07-17
| | | | Just a minor optimization.
* cgroup-util: fix the case of default=unified, unified-cgroup-hierarchy=0Zbigniew Jędrzejewski-Szmek2017-07-17
| | | | | We should mount the hybrid hierarchy if the user disabled the unified hierarchy on the kernel command line.
* cgroup-util: cache all cg_is_*_wanted answers, disable ↵Zbigniew Jędrzejewski-Szmek2017-07-17
| | | | | | | | | | | | | /sys/fs/cgroups/unified on unified If we encounter an error in proc cmdline parsing, just treat that as permanent, i.e. the same as if the option was not specified. Realistically, it is better to use the same condition for all related mounts, then to have e.g. /sys/fs/cgroup mounted and /sys/fs/cgroup/unified not. If we find something is mounted and base our answer on that, cache that result too. Fix the conditions so that if "unified" is used, make sure any "hybrid" mounts are not mounted.
* Fix check for signal in set (#5416)stuart-mclaren2017-07-17
| | | | | | | IN_SET(SIGCONT, SIGKILL) will always evaluate to false. The signal needs to be included as the first argument. Fixup for 26f417d3e8dd2522adfdc4c8fed4c36fa40f48fc.
* Revert "basic/strv: allow NULLs to be inserted into strv"Lennart Poettering2017-07-17
| | | | | | | | This reverts commit 18f71a3c8174774c5386c4aba94d54f3b5c36a84. According to @keszybz we don't need this anymore, hence drop it: https://github.com/elogind/elogind/pull/5131/commits/18f71a3c8174774c5386c4aba94d54f3b5c36a84#r102232368
* log: never log into foreign fd #2 in PID 1 or its pre-execve() childrenLennart Poettering2017-07-17
| | | | Fixes: #5401
* bootctl: create loader.conf only if it doesn't exist yetLennart Poettering2017-07-17
| | | | | | | | | If the snippet aleady exists, don't do anything, as the file was already installed then. (This also reworks the code to create the file atomically) Fixes: #5396
* basic/fileio: use IN_SETZbigniew Jędrzejewski-Szmek2017-07-17
|
* basic/fileio: fix memleak when discarding an invalid variableZbigniew Jędrzejewski-Szmek2017-07-17
| | | | Fixes #5405.
* copy: a plain unlink() works here tooLennart Poettering2017-07-17
|
* cgroup-util: fix the reversed return value of ↵Zbigniew Jędrzejewski-Szmek2017-07-17
| | | | | | | | cg_is_unified_elogind_contoller_wanted 1d84ad944520fc3e062ef518c4db4e1 reversed the meaning of the option. The kernel command line option has the opposite meaning to the function, i.e. specifying "legacy=yes" means "unifed elogind controller=no".
* core/mount-setup: if unified hierarchy is not supported, fall back to legacyZbigniew Jędrzejewski-Szmek2017-07-17
| | | | | | | | | | | We need this to gracefully support older or strangely configured kernels. v2: - do not install a callback handler, just embed the right conditions into cg_is_*_wanted() v3: - fix bug in cg_is_legacy_wanted()
* Rename cg_is_unified_elogind_controller_wanted to cg_is_hybrid_wantedZbigniew Jędrzejewski-Szmek2017-07-17
| | | | Less typing and doesn't make the table so incredibly wide.
* build.h: include default cgroup hierarchy setting in --version outputZbigniew Jędrzejewski-Szmek2017-07-17
| | | | | | | | | | | | This is pretty important, and we print this string during startup, so putting the default hierarchy information might help with diagnosis if things go awry. $ ./systemctl --version elogind 232 +PAM +AUDIT +SELINUX +IMA -APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD +IDN default-hierarchy=legacy v2: make the message nicer by including the ./configure option argument directly in output