summaryrefslogtreecommitdiff
path: root/src/libelogind
Commit message (Collapse)AuthorAge
* tree-wide: use IN_SET macro (#6977)Yu Watanabe2017-12-08
|
* Apply updates from upstreamSven Eden2017-12-07
|
* build-sys: use #if Y instead of #ifdef Y everywhereZbigniew Jędrzejewski-Szmek2017-11-23
| | | | | | | | | | | | | | | The advantage is that is the name is mispellt, cpp will warn us. $ git grep -Ee "conf.set\('(HAVE|ENABLE)_" -l|xargs sed -r -i "s/conf.set\('(HAVE|ENABLE)_/conf.set10('\1_/" $ git grep -Ee '#ifn?def (HAVE|ENABLE)' -l|xargs sed -r -i 's/#ifdef (HAVE|ENABLE)/#if \1/; s/#ifndef (HAVE|ENABLE)/#if ! \1/;' $ git grep -Ee 'if.*defined\(HAVE' -l|xargs sed -i -r 's/defined\((HAVE_[A-Z0-9_]*)\)/\1/g' $ git grep -Ee 'if.*defined\(ENABLE' -l|xargs sed -i -r 's/defined\((ENABLE_[A-Z0-9_]*)\)/\1/g' + manual changes to meson.build squash! build-sys: use #if Y instead of #ifdef Y everywhere v2: - fix incorrect setting of HAVE_LIBIDN2
* sd-bus: drop bloom fieldsLennart Poettering2017-09-29
| | | | These fields are unused since kdbus support has been removed.
* sd-bus: drop match cookie conceptLennart Poettering2017-09-29
| | | | | | THe match cookie was used by kdbus to identify matches we install uniquely. But given that kdbus is gone, the cookie serves no process anymore, let's kill it.
* sd-bus: when showing brief message info show error name in debug out put tooLennart Poettering2017-09-29
| | | | | | | When debug logging is enabled we show brief information about every bus message we send or receieve. Pretty much all information is shown, except for the error name if a message is an error (interestingly we do print the error text however). Fix that, and add the error name as well.
* libelogind: use IN_SET macroYu Watanabe2017-11-22
|
* fileio: return 0 from read_one_line_file on successZbigniew Jędrzejewski-Szmek2017-11-22
| | | | Fixup for f4b51a2d09. Suggested by Evgeny Vereshchagin.
* cgroup, unit, fragment parser: make use of new firewall functionsDaniel Mack2017-11-21
|
* Add abstraction model for BPF programsDaniel Mack2017-11-20
| | | | | This object takes a number of bpf_insn members and wraps them together with the in-kernel reference id. Will be needed by the firewall code.
* v235: Added missing updatesSven Eden2017-11-19
|
* tests: change dbus tests to use user bus (#6845)Michael Biebl2017-09-19
| | | | | | This makes it possible to run more dbus tests in a build environment/chroot where no system bus is available. To run the dbus test one then can use dbus-run-session.
* sd-bus: style nitpick node_vtable_get_userdata()Alan Jenkins2017-09-16
| | | | | | | | | It's confusing to use a single void* to store data with two different types, i.e. a userdata value which is safe to pass to ->find(), and a userdata value which identifies the found object. Name the latter `found_u`. This naming treats (!c->find) as a degenerate case. (I.e. at that point, we know the object has already been found :).
* sd-bus: fix response for GetAll on non-existent objectsAlan Jenkins2017-09-16
| | | | | | | | | | | | | | | | | | | | Before this commit, if you run `loginctl user-status` from debug-shell.service (and you have no login sessions for root), you always see this output: 0 Linger: no because Properties.GetAll is returning success but without any properties, when the only find() callback had returned 0 to mean "no object found". After: Could not get properties: Unknown object: '/org/freedesktop/login1/user/self' BTW I have a fix for more user-friendly messages from logind in this case. It is pending in my local branch for #6829 "fix `loginctl enable-linger`".
* sd-bus: extend D-Bus authentication timeout considerably (#6813)Lennart Poettering2017-09-13
| | | | | | | | | | | | | | As it turns out the authentication phase times out too often than is good, mostly due to PRNG pools not being populated during boot. Hence, let's increase the authentication timeout from 25s to 90s, to cover for that. (Note that we leave the D-Bus method call timeout at 25s, matching the reference implementation's value. And if the auth phase managed to complete then the pools should be populated enough and mehtod calls shouldn't take needlessly long anymore). Fixes: #6418
* sd-bus: use -- when passing arguments to ssh (#6706)Evgeny Vereshchagin2017-09-25
| | | | | | | | This prevents `systemctl` from runnning /bin/touch when the following command is used: ``` systemctl -H '-oProxyCommand=/bin/touch i-shouldnt-be-here' show-environment ```
* sd-bus: socket - only transmit auxillary FDs once (#6603)Tom Gundersen2017-08-30
| | | | | | | | | | | | | | If a message is too large to fit into the output buffer, it will be transmitted to the kernel in several chunks. However, the FDs must only ever be transmitted once or they will bereceived by the remote end repeatedly. The D-Bus specification disallows several sets of FDs attached to one message, however, the reference implementation of D-Bus will not reject such a message, rather it will reassign the duplicate FDs to subsequent FD-carrying messages. This attaches the FD array only to the first byte of the message.
* Prep v235: Update test-login.cshwsh2017-09-07
| | | | * Merge pull request #29 from shwsh/master
* Prep 235: add missing libshared.sym and remove obsolete kdbus.hSven Eden2017-08-30
|
* Prep v235: Fix pkgconfig/libelogind.pcSven Eden2017-08-22
|
* Prep v235: Add missing includes and dependencies.Sven Eden2017-08-14
|
* Prep v235: Apply upstream fixes (5/10) [src/libelogind]Sven Eden2017-08-14
|
* Prep v235: Remove superfluous .gitignore filesSven Eden2017-08-14
|
* sd-login: test - fix failure when run from non-graphical seatAlan Jenkins2017-08-10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Observed when running from the console of a elogind nspawn container (see failure below). The value of r was tested, when r was last set by sd_session_can_graphical(). This did not correspond to the value expected. Fix the code, so we compare relevant values now. Hopefully :). Test failure ------------ /* Information printed is from the live system */ sd_pid_get_unit(0, …) → "session-13.scope" sd_pid_get_user_unit(0, …) → "n/a" sd_pid_get_slice(0, …) → "user-1000.slice" sd_pid_get_session(0, …) → "13" sd_pid_get_owner_uid(0, …) → 1000 sd_pid_get_cgroup(0, …) → "/user.slice/user-1000.slice/session-13.scope" sd_uid_get_display(1000, …) → "13" sd_uid_get_sessions(1000, …) → [2] "15 13" sd_uid_get_seats(1000, …) → [1] "seat0" sd_session_is_active("13") → yes sd_session_is_remote("13") → no sd_session_get_state("13") → "active" sd_session_get_uid("13") → 1000 sd_session_get_type("13") → "tty" sd_session_get_class("13") → "user" sd_session_get_display("13") → "n/a" sd_session_get_remote_user("13") → "n/a" sd_session_get_remote_host("13") → "n/a" sd_session_get_seat("13") → "seat0" sd_session_can_multi_seat("seat0") → no sd_session_can_tty("seat0") → no sd_session_can_graphical("seat0") → no sd_uid_get_state(1000, …) → active Assertion '!!k == !!r' failed at ../src/libelogind/sd-login/test-login.c:191, function test_login(). Aborting.
* sd-login: test - fix function name in outputAlan Jenkins2017-08-10
|
* sd-bus: free everything when bus_set_address_user fails (#6552)Evgeny Vereshchagin2017-08-10
| | | | | | | | | | | | | | | | | | Fixes: ``` $ env -i valgrind --leak-check=full ./build/test-bus-chat ... ==7763== 1,888 (1,824 direct, 64 indirect) bytes in 1 blocks are definitely lost in loss record 2 of 2 ==7763== at 0x4C2FA50: calloc (vg_replace_malloc.c:711) ==7763== by 0x4F8FF9A: sd_bus_new (sd-bus.c:175) ==7763== by 0x4F938BF: sd_bus_open_user (sd-bus.c:1138) ==7763== by 0x109ACD: server_init (test-bus-chat.c:70) ==7763== by 0x10BCF8: main (test-bus-chat.c:526) ==7763== ``` Closes #6481
* core, sd-bus, logind: make use of uid_is_valid() in more placesLennart Poettering2017-07-14
|
* General: Update build system to upstream support of meson+ninja.Sven Eden2017-08-04
| | | | | | | | Upstream thinks, that the auto tools are too 'legacy', or that they are at least no longer fitting. We follow, as the classic auto tools files have been removed, so no other choice here...
* Prep v234: Apply missing upstream fixes in src/libelogind (2/6)Sven Eden2017-07-25
|
* Prep v234: Remove now obsolete text files from src/libelogind/sd-busSven Eden2017-07-25
|
* Prep v234: Update root build files to upstream.Sven Eden2017-07-25
|
* 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
|
* 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
* 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
* 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).
* 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
* 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.
* 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
|
* Fix includes (#5980)Matija Skala2017-07-25
| | | | Needed on musl.
* sd-login: fix querying machines when machined is not runningZbigniew Jędrzejewski-Szmek2017-07-25
| | | | | We should not leak the internal error from missing directory and treat that case the same as no machines.
* sd-login,test-login: return -ENODATA from sd_pid_get_unit tooZbigniew Jędrzejewski-Szmek2017-07-25
| | | | After all, we might be running on a non-elogind system.
* sd-login: fix return value of sd_pid_get_user_unitZbigniew Jędrzejewski-Szmek2017-07-25
| | | | | E.g. "/user.slice/user-1000.slice/session-15.scope" would cause -ENXIO to be returned.
* sd-login: fix return value of sd_pid_get_sessionZbigniew Jędrzejewski-Szmek2017-07-25
| | | | We'd return -ENXIO, even thoug -ENODATA is documented.
* sd-login: read list of uids of sessions from UIDS not ACTIVE_SESSIONSZbigniew Jędrzejewski-Szmek2017-07-25
| | | | | | | | | | | | | | As described by Luke Shumaker: sd_seat_get_sessions looks at /run/elogind/seats/${seat_name}:SESSIONS to get the list of sessions (which I believe is correct), and at /run/elogind/seats/${seat_name}:ACTIVE_SESSIONS for the list of users (which I believe is incorrect); I believe that it should look at the UIDS field for the list of users. As far as I can tell, the ACTIVE_SESSIONS field is never even present in the seats file. I also believe that this has been broken since the function was first committed almost 6 years ago. Fixes #5743.
* sd-login: always return two arrays of same length from sd_seat_get_sessionsZbigniew Jędrzejewski-Szmek2017-07-25
| | | | | | | | sd_seat_get_sessions returns two arrays, that in principle should always match: the session names and corresponding uids. The second array could be shorter only if parsing or uid conversion fails. But in that case there is no way to tell *which* uid is wrong, so they are *all* useless. It's better to simplify things and just return an error if parsing fails.