summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAge
* Prep v234: Update root build files to upstream.Sven Eden2017-07-25
|
* Revert "core: link user keyring to session keyring (#6275)" (#6342)Lennart Poettering2017-07-25
| | | | | | | This reverts commit 437a85112e02042b62751395b9e7225628c1b708. The outcome of this isn't that clear, let's revert this for now, see discussion on #6286.
* time-util: make parse_timestamp() return -EINVAL if the input is very old ↵Yu Watanabe2017-07-25
| | | | | | | | | date (#6327) This reverts 7635ab8e74ea4a94e81143c3077570a986df375c and makes parse_timestamp() return -EINVAL if the input is older than 1970-01-01. Fixes #6290.
* Add comments to log_functions which shouldn't be called from library code ↵Zbigniew Jędrzejewski-Szmek2017-07-25
| | | | (#6326)
* random-util: we are fine if ints are 16 bytes actuallyLennart Poettering2017-07-25
| | | | Not that it matters IRL, but let's make this less surprising to read...
* random-util: always cast from smaller to bigger type when comparingLennart Poettering2017-07-25
| | | | | | When we compare two size values, let's make sure we cast from the smaller to the bigger type first, if both types differ, rather than the reverse in order to not run into overflows.
* basic/strv: use existing qsort_safe() helperZbigniew Jędrzejewski-Szmek2017-07-25
| | | | | strv_sort() predates qsort_safe(), but we can convert it to it to save a few lines.
* sd_uid_get_state: do not return -ENOENT if state is "offline" (#6302)Yu, Li-Yu2017-07-25
|
* sd-login: fix memleak when output argument is NULLZbigniew Jędrzejewski-Szmek2017-07-25
|
* time-util: make parse_timestamp() set 0 if the input is very old date (#6297)Yu Watanabe2017-07-25
| | | | | | | | | | If the input is older than "1970-01-01 UTC", then `parse_timestamp()` fails and returns -EINVAL. However, if the input is e.g. `-100years`, then the function succeeds and sets `usec = 0`. This commit makes the function also succeed for old dates and set `usec = 0`. Fixes #6290.
* core/load-fragment: refuse units with errors in ↵Zbigniew Jędrzejewski-Szmek2017-07-25
| | | | | | | RootDirectory/RootImage/DynamicUser Behaviour of the service is completely different with the option off, so the service would probably mess up state on disk and do unexpected things.
* basic/log: use getenv instead of secure_getenvZbigniew Jędrzejewski-Szmek2017-07-25
| | | | | | | | | | | | | | | secure_getenv does not work when the process has a nonempty permitted capability set, which means that it's unduly hard to configure logging in elogind-logind, elogind-resolved, and others. secure_getenv is useful for code in libraries which might get called from a setuid application. log_parse_environment() is never called from our library code, but directly form various top-level executables. None of them are installed suid, and none are prepared to be used this way, since many additional changes would be required to make that safe. We may just as well drop the check and allow SYSTEMD_LOG_* to properly parsed. Fixes #4900.
* test-fs-util: re-order test_readlink_and_make_absolute and ↵Mike Gilbert2017-07-25
| | | | | | | | | | | | | | | | | | | test_get_files_in_directory (#6288) test_readlink_and_make_absolute switches to a temp directory, and then removes it. test_get_files_in_directory calls opendir(".") from a directory that has been removed from the filesystem. This call sequence triggers a bug in Gentoo's sandbox library. This library attempts to resolve the "." to an absolute path, and aborts when it ultimately fails to do so. Re-ordering the calls works around the issue until the sandbox library can be fixed to more gracefully deal with this. Bug: https://bugs.gentoo.org/590084
* basic: Fix build warning in random-util (#6284)Benjamin Robin2017-07-25
|
* udev: move the KEY_* defines to missing.h (#6278)Peter Hutterer2017-07-25
|
* core: link user keyring to session keyring (#6275)Christian Hesse2017-07-25
| | | | | | | | | | Commit 74dd6b515fa968c5710b396a7664cac335e25ca8 (core: run each system service with a fresh session keyring) broke adding keys to user keyring. Added keys could not be accessed with error message: keyctl_read_alloc: Permission denied So link the user keyring to our session keyring.
* Parse "timeout=0" as infinity in various generators (#6264)Zbigniew Jędrzejewski-Szmek2017-07-25
| | | | | | | | | | | | | This extends 2d79a0bbb9f651656384a0a86ed814e6306fb5dd to the kernel command line parsing. The parsing is changed a bit to only understand "0" as infinity. If units are specified, parse normally, e.g. "0s" is just 0. This makes it possible to provide a zero timeout if necessary. Simple test is added. Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1462378.
* Be slightly more verbose in error messageZbigniew Jędrzejewski-Szmek2017-07-25
| | | | | | Including the full path is always useful. Also use PID_FMT in one more place.
* bus-util: replace non-printable values with [unprintable]Zbigniew Jędrzejewski-Szmek2017-07-25
| | | | | | | | | | | | | | | Like I said in the previous commit, such values do not seem to appear in normal use, but it's pretty hard to prove that all paths to assign values properly check that they contain no spaces. So just in case some slip through, replace values with spaces (in case of single-valued properties) or spaces and newlines (in case of array proprties) with "[unprintable]". We were already doing it in case of properties which we didn't know how to print, so this fits in well. The advantage is the previous code which used escaping that a) this is easier to spot, b) does not mess up printing of properties which were properly escaped already. v2: - add comments
* Revert "bus: when dumping string property values escape the chars we use as ↵Zbigniew Jędrzejewski-Szmek2017-07-25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | end-of-line and end-of-item marks" This reverts commit 27e9c5af817147ea1c678769e45e83f2e4b4ae96. Property values already use escaping, so escaping them a second time is confusing. It also should be mostly unnecessary: we take care to make property values only contains strings which (after the initial escaping) are printable and parseable without any futher escaping. Before revert: $ systemctl list-dependencies 'dev-mapper-luks\x2d8db85dcf\x2d6230\x2d4e88\x2d940d\x2dba176d062b31.device' dev-mapper-luks\x2d8db85dcf\x2d6230\x2d4e88\x2d940d\x2dba176d062b31.device ● ├─dev-mapper-luks\x2d8db85dcf\x2d6230\x2d4e88\x2d940d\x2dba176d062b31.swap ● └─elogind-cryptsetup@luks\x2d8db85dcf\x2d6230\x2d4e88\x2d940d\x2dba176d062b31.service $ systemctl show -p Wants,Requires 'dev-mapper-luks\x2d8db85dcf\x2d6230\x2d4e88\x2d940d\x2dba176d062b31.device' Requires=elogind-cryptsetup@luks\x5cx2d8db85dcf\x5cx2d6230\x5cx2d4e88\x5cx2d940d\x5cx2dba176d062b31.service Wants=dev-mapper-luks\x5cx2d8db85dcf\x5cx2d6230\x5cx2d4e88\x5cx2d940d\x5cx2dba176d062b31.swap Difference between systemctl show before revert and now: -Slice=system-elogind\x5cx2dcryptsetup.slice +Slice=system-elogind\x2dcryptsetup.slice -Id=elogind-cryptsetup@luks\x5cx2d8db85dcf\x5cx2d6230\x5cx2d4e88\x5cx2d940d\x5cx2dba176d062b31.service +Id=elogind-cryptsetup@luks\x2d8db85dcf\x2d6230\x2d4e88\x2d940d\x2dba176d062b31.service -Names=elogind-cryptsetup@luks\x5cx2d8db85dcf\x5cx2d6230\x5cx2d4e88\x5cx2d940d\x5cx2dba176d062b31.service +Names=elogind-cryptsetup@luks\x2d8db85dcf\x2d6230\x2d4e88\x2d940d\x2dba176d062b31.service -Requires=system-elogind\x5cx2dcryptsetup.slice +Requires=system-elogind\x2dcryptsetup.slice -BindsTo=dev-mapper-luks\x5cx2d8db85dcf\x5cx2d6230\x5cx2d4e88\x5cx2d940d\x5cx2dba176d062b31.device dev-disk-by\x5cx2duuid-8db85dcf\x5cx2d6230\x5cx2d4e88\x5cx2d940d\x5cx2dba176d062b31.device +BindsTo=dev-mapper-luks\x2d8db85dcf\x2d6230\x2d4e88\x2d940d\x2dba176d062b31.device dev-disk-by\x2duuid-8db85dcf\x2d6230\x2d4e88\x2d940d\x2dba176d062b31.device -RequiredBy=dev-mapper-luks\x5cx2d8db85dcf\x5cx2d6230\x5cx2d4e88\x5cx2d940d\x5cx2dba176d062b31.device cryptsetup.target +RequiredBy=dev-mapper-luks\x2d8db85dcf\x2d6230\x2d4e88\x2d940d\x2dba176d062b31.device cryptsetup.target -WantedBy=dev-disk-by\x5cx2duuid-8db85dcf\x5cx2d6230\x5cx2d4e88\x5cx2d940d\x5cx2dba176d062b31.device +WantedBy=dev-disk-by\x2duuid-8db85dcf\x2d6230\x2d4e88\x2d940d\x2dba176d062b31.device
* sd-bus: never augment creds when we are operating on remote connections (#6217)Lennart Poettering2017-07-25
| | | | | | | It's not always clear when something is a remote connection, hence only flag the obvious cases as local. Fixes: #6207
* logind: filter out input devices that have none of the keys/switche we care ↵Lennart Poettering2017-07-25
| | | | | | | about Let's check what keys are there, before we actually hang on to the opened devices.
* logind: relax udev rules matching devices logind watches forLennart Poettering2017-07-25
| | | | | | | | | | Now that we have support for key/switch masking in logind, we can relax the rules by which logind picks the devices to watch a bit, after all we won't wake up anymore for every single event, but instead only the events we actually care about. This should make power/suspend keys on normal usb/atkbd keyboards just work.
* logind: make use of EVIOCSMASK input ioctl to mask out events we aren't ↵Lennart Poettering2017-07-25
| | | | | | | | | | | | | | | interested in This way logind will get woken up only when an actual event took place, and not for every key press on the system. The ioctl EVIOCSMASK was added by @dvdhrm already in October 2015, for the use in logind, among others, hence let's actually make use of it now. While we are at it, also fix usage of the EVIOCGSW ioctl, where we assumed a byte array, even though a unsigned long native endian array is returned.
* sd-bus: use GetConnectionCredentials() when querying credentials, if availableLennart Poettering2017-07-25
| | | | | | | | | Newer D-Bus versions implement the GetConnectionCredentials() driver call to get all connection creds in one go. Make use of that to reduce the number of bus calls we do. When only a single credential field is queried we will still use the old calls, which we'll also use if the new call isn't implemented.
* sd-bus: when credentials of the "org.freedesktop.DBus" service are queried ↵Lennart Poettering2017-07-25
| | | | | | | | | | | | return the bus owner's credentials The bus driver service is always implemented by the owner of the bus, hence let's shortcut the credential operation and use our cached data. This makes sure things simply work, given that dbus itself doesn't support GetConnectionSELinuxSecurityContext() on the bus driver name itself. Fixes: #6120
* core: make IOSchedulingClass= and IOSchedulingPriority= settable for ↵Lennart Poettering2017-07-25
| | | | | | | | | | | | transient units This patch is a bit more complex thant I hoped. In particular the single IOScheduling= property exposed on the bus is split up into IOSchedulingClass= and IOSchedulingPriority= (though compat is retained). Otherwise the asymmetry between setting props and getting them is a bit too nasty. Fixes #5613
* Copy defines for renameat2 from casync (#6181)Zbigniew Jędrzejewski-Szmek2017-07-25
|
* basic/random-util: do not fall back to /dev/urandom if getrandom() returns shortZbigniew Jędrzejewski-Szmek2017-07-25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | During early boot, we'd call getrandom(), and immediately fall back to reading from /dev/urandom unless we got the full requested number of bytes. Those two sources are the same, so the most likely result is /dev/urandom producing some pseudorandom numbers for us, complaining widely on the way. Let's change our behaviour to be more conservative: - if the numbers are only used to initialize a hash table, a short read is OK, we don't really care if we get the first part of the seed truly random and then some pseudorandom bytes. So just do that and return "success". - if getrandom() returns -EAGAIN, fall back to rand() instead of querying /dev/urandom again. The idea with those two changes is to avoid generating a warning about reading from an /dev/urandom when the kernel doesn't have enough entropy. - only in the cases where we really need to make the best effort possible (sd_id128_randomize and firstboot password hashing), fall back to /dev/urandom. When calling getrandom(), drop the checks whether the argument fits in an int — getrandom() should do that for us already, and we call it with small arguments only anyway. Note that this does not really change the (relatively high) number of random bytes we request from the kernel. On my laptop, during boot, PID 1 and all other processes using this code through libelogind request: 74780 bytes with high_quality_required == false 464 bytes with high_quality_required == true and it does not eliminate reads from /dev/urandom completely. If the kernel was short on entropy and getrandom() would fail, we would fall back to /dev/urandom for those 464 bytes. When falling back to /dev/urandom, don't lose the short read we already got, and just read the remaining bytes. If getrandom() syscall is not available, we fall back to /dev/urandom same as before. Fixes #4167 (possibly partially, let's see).
* tests: add tests for environment serializationZbigniew Jędrzejewski-Szmek2017-07-25
|
* basic/env-util: when serializing, actually use escapingZbigniew Jędrzejewski-Szmek2017-07-25
| | | | Fixes #6152.
* manager: just warn about an invalid environment entryZbigniew Jędrzejewski-Szmek2017-07-25
| | | | | | Apart from bugs (as in #6152), this can happen if we ever make our requirements for environment entries more stringent. As with the rest of deserialization, we should just warn and continue.
* time-util: add new call usec_shift_clock() for converting times between clocksLennart Poettering2017-07-25
| | | | We use that quite often, let's implement one clean version of it.
* time-util: rename usec_sub() to usec_sub_signed() and add usec_sub_unsigned()Lennart Poettering2017-07-25
| | | | | Quite often we just want to subtract two normal usec_t values, hence provide an implementation for that.
* log: pass the correct length to vsnprintf (#6168)Evgeny Vereshchagin2017-07-25
| | | | | | | This prevents log_object_internalv from corrupting the stack. Closes #6147. Many thanks to Walter Doekes for the code review.
* sd-bus: make sure propagate all errors with vtable callbacks back to clientsLennart Poettering2017-07-25
| | | | | | | | | | | | Previously we'd propagate errors returned by user callbacks configured in vtables back to the users only for method handlers and property get/set handlers. This does the same for child enumeration and when we check whether a fallback unit exists. Without this the failure will be treated as a non-recoverable connection error and result in connection termination. Fixes: #6059
* core: make NotifyAccess= and FileDescriptorStoreMax= available to transient ↵Lennart Poettering2017-07-25
| | | | | | services This is helpful for debugging/testing #5606.
* basic/rm-rf: allow a symlink to / to be removedZbigniew Jędrzejewski-Szmek2017-07-25
| | | | | | | | We open the target path with O_DIRECTORY|O_NOFOLLOW, and if that doesn't work, we call unlink() on the path. In neither case we will follow the symlink, so we can relax our check to also not follow symlinks. Fixes #5864.
* basic/path-util: allow flags for path_equal_or_files_sameZbigniew Jędrzejewski-Szmek2017-07-25
| | | | | No functional change, just a new parameters and the tests that AT_SYMLINK_NOFOLLOW works as expected.
* Make IDN support conditionalWaldemar Brodkorb2017-07-25
| | | | [zj: rename HAVE_IDN to ENABLE_IDN]
* Use "dollar-single-quotes" to escape shell-sensitive stringsZbigniew Jędrzejewski-Szmek2017-07-25
| | | | | | | | | | | | | | | | | | | | | | | | | Also called "ANSI-C Quoting" in info:(bash) ANSI-C Quoting. The escaping rules are a POSIX proposal, and are described in http://austingroupbugs.net/view.php?id=249. There's a lot of back-and-forth on the details of escaping of control characters, but we'll be only using a small subset of the syntax that is common to all proposals and is widely supported. Unfortunately dash and fish and maybe some other shells do not support it (see the man page patch for a list). This allows environment variables to be safely exported using show-environment and imported into the shell. Shells which do not support this syntax will have to do something like export $(systemctl show-environment|grep -v '=\$') or whatever is appropriate in their case. I think csh and fish do not support the A=B syntax anyway, so the change is moot for them. Fixes #5536. v2: - also escape newlines (which currently disallowed in shell values, so this doesn't really matter), and tabs (as $'\t'), and ! (as $'!'). This way quoted output can be included directly in both interactive and noninteractive bash.
* sd-bus: silence format warnings in kdbus code (#6072)Zbigniew Jędrzejewski-Szmek2017-07-25
| | | | | | | | | | | | | | | | | | | | | | | | | | The code is mostly correct, but gcc is trying to outsmart us, and emits a warning for a "llu vs lu" mismatch, even though they are the same size (on alpha): src/libelogind/sd-bus/bus-control.c: In function ‘kernel_get_list’: src/libelogind/sd-bus/bus-control.c:267:42: error: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘__u64 {aka long unsigned int}’ [-Werror=format=] if (asprintf(&n, ":1.%llu", name->id) < 0) { ^ src/libelogind/sd-bus/bus-control.c: In function ‘bus_get_name_creds_kdbus’: src/libelogind/sd-bus/bus-control.c:714:47: error: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘__u64 {aka long unsigned int}’ [-Werror=format=] if (asprintf(&c->unique_name, ":1.%llu", conn_info->id) < 0) { ^ This is hard to work around properly, because kdbus.h uses __u64 which is defined-differently-despite-being-the-same-size then uint64_t. Thus the simple solution of using %PRIu64 fails on amd64: src/libelogind/sd-bus/bus-control.c:714:47: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘__u64 {aka long long unsigned int}’ [-Werror=format=] if (asprintf(&c->unique_name, ":1.%"PRIu64, conn_info->id) < 0) { ^~~~~~ Let's just avoid the whole issue for now by silencing the warning. After the next release, we should just get rid of the kdbus code. Fixes #5561.
* loginctl: also use $XDG_SESSION_ID for session-statusZbigniew Jędrzejewski-Szmek2017-07-25
|
* loginctl: use $XDG_SESSION_ID for "our" sessionZbigniew Jędrzejewski-Szmek2017-07-25
| | | | | | | | | | | | | | | | Instead of always letting logind guess what the caller's session is, let's give it the value from $XDG_SESSION_ID when it is present in the caller's environment. Nowadays terminal emulators are often running as services under elogind --user, and not as part of an actual session, so all loginctl calls which depend on logind guessing the session will fail. I don't see a reason not to honour $XDG_SESSION_ID. This applies to LockSession, UnlockSession, TerminateSession, ActivateSession, SetUserLinger. Fixes #6032.
* logind: nicer error message when we cannot guess the caller's sessionZbigniew Jędrzejewski-Szmek2017-07-25
| | | | Partial fix for #6032.
* sd-login: sd_get_machine_names(): do not return -EINVAL when output ↵Yu Watanabe2017-07-25
| | | | | | | | parameter is NULL Other functions in sd-login generally allow the output parameter to be NULL, in which case only the number of items that would be stored in the array is returned. Be nice and do the same here.
* sd-login: treat missing /run/elogind/{seats,sessions,users} the same as emptyYu Watanabe2017-07-25
| | | | | | | C.f. 0543105b0fb13e4243b71a78f62f81fb9dde5d51. This makes if /run/elogind/{seats,sessions,users} are missing, then sd_get_seats(), sd_get_sessions() and sd_get_uids() return 0, that is, an empty list, instead of -ENOENT.
* sd-login: translate -ENOMEDIUM to -ENODATAZbigniew Jędrzejewski-Szmek2017-07-25
| | | | | | | | | | The -ENOMEDIUM return value was introduced in v232-1001-g2977724b09, ('core: make hybrid cgroup unified mode keep compat /sys/fs/cgroup/elogind hierarchy'), and would be returned by cg_pid_get_path_shifted(), but the documented and expected return value is -ENODATA. Let's just catch ENXIO/ENOMEDIUM and translate it to ENODATA in all cases. Complements 171f8f591ff27ebb5ff475b7a9d1f13a846c9331, fixes #6012.
* logn: tests - don't compare signed with unsignedTom Gundersen2017-07-25
|
* basic/time-util: make parsing of dual_timestamp more strictZbigniew Jędrzejewski-Szmek2017-07-25
| | | | | | | | | | | *scanf functions set errno on i/o error. For sscanf, this doesn't really apply, so (based on the man page), it seems that errno is unlikely to be ever set to a useful value. So just ignore errno. The error message includes the string that was parsed, so it should be always pretty clear why parsing failed. On the other hand, detect trailing characters and minus prefix that weren't converted properly. This matches what our safe_ato* functions do. Add tests to elucidate various edge cases.