summaryrefslogtreecommitdiff
path: root/src/login/logind-dbus.c
Commit message (Collapse)AuthorAge
...
* Reverted accidential renaming of /run/systemd to /run/elogind. Applications ↵Sven Eden2018-04-23
| | | | using elogind as a drop-in replacement expect the first.
* Prep v236 : Add missing SPDX-License-Identifier (5/9) src/loginSven Eden2018-03-26
|
* logind: fix sysfs change trigger codeLennart Poettering2017-11-22
| | | | | We can't create files in sysfs, hence don't bother. Also if we ignore the return value, do so explicitly by casting to void.
* logind: make sure we don't acces m->action_what if it's not initialized (#7475)Lennart Poettering2017-11-27
| | | | Fixes: #7466
* logind: fix SetLinger to authorize by client's effective User IDAlan Jenkins2017-09-15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | SetLinger is authorized by the PolicyKit action "set-self-linger", if it is not passed an explicit UID. According to comments we were determining the default UID from the client's session. However, user processes e.g. which are run from a terminal emulator do not necessarily belong to a session scope unit. They may equally be started from the elogind user manager [1][2]. Actually the comment was wrong, and it would also have worked for processes started from the elogind user manager. Nevertheless it seems to involve fetching "augmented credentials" i.e. it's using a racy method, so we shouldn't have been authenticating based on it. We could change the default UID, but that raises issues especially for consistency between the methods. Instead we can just use the clients effective UID for authorization. This commit also fixes `loginctl enable-linger $USER` to match the docs that say it was equivalent to `loginctl enable-linger` (given that $USER matches the callers user and owner_uid). Previously, the former would not have suceeded for unpriviliged users in the default configuration. [1] It seems the main meaning of per-session scopes is tracking the PAM login process. Killing that provokes logind to revoke device access. Less circularly, killing it provokes getty to hangup the TTY. [2] User units may be started with an environment which includes XDG_SESSION_ID (presuambly GNOME does this?). Or not.
* Apply missing updates from upstreamSven Eden2017-12-08
|
* logind: don's change dry-run boolean before we actually enqueue the operationLennart Poettering2017-10-02
| | | | Let's not affect change before the PK check.
* logind: reorder things a bitLennart Poettering2017-12-08
| | | | Let's keep the three sleep method implementations close to each other.
* logind: add Halt() and CanHalt() APIsLennart Poettering2017-12-08
| | | | | | | | | | | | | | | | | | | | | This adds new method calls Halt() and CanHalt() to the logind bus APIs. They aren't overly useful (as the whole concept of halting isn't really too useful), however they clean up one major asymmetry: currently, using the "shutdown" legacy commands it is possibly to enqueue a "halt" operation through logind, while logind officially doesn't actually support this. Moreover, the path through "shutdown" currently ultimately fails, since the referenced "halt" action isn't actually defined in PolicyKit. Finally, the current logic results in an unexpected asymmetry in systemctl: "systemctl poweroff", "systemctl reboot" are currently asynchronous (due to the logind involvement) while "systemctl halt" isnt. Let's clean this up, and make all three APIs implemented by logind natively, and all three hence asynchronous in "systemctl". Moreover, let's add the missing PK action. Fixes: #6957
* 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
* Revert "tree-wide: use pid_is_valid() at more places"Alan Jenkins2017-10-03
| | | | | | | | | | | This reverts commit ee043777be58251e7441b4f04594e9e3792d7fb2. It broke almost everywhere it touched. The places that handn't been converted, were mostly followed by special handling for the invalid PID `0`. That explains why they tested for `pid < 0` instead of `pid <= 0`. I think that one was the first commit I reviewed, heh.
* v235: Added missing updatesSven Eden2017-11-19
|
* tree-wide: use pid_is_valid() at more placesLennart Poettering2017-08-31
|
* logind: tighten assertion in execute_shutdown_or_sleep()Alan Jenkins2017-08-24
| | | | | | | Following commit b498d6ea, I belated realized we should tighten the assertions as well, to make sure that we're setting `m->action_what` to represent an action in progress. (The check for an action in progress is to compare `m->action_what` to zero)
* logind: add missing resume signal when we fail to initiate sleep/shutdownAlan Jenkins2017-09-25
| | | | | | | | | | | | | | | | | | | | This fixed https://bugzilla.redhat.com/show_bug.cgi?id=1476313 as much as I was able to reproduce it in a VM, at least. E.g. this signal might wake the screen back up, providing a more visible indicator of suspend failure. In my VM testing, it was also required in order to unblock keyboard input in gnome-shell after the failed suspend. At the same time, fix the error handling for scheduled shutdowns. This now mirrors the behaviour of when you use `shutdown -k` - it sends all the scary messages about shutting down, "but you'll have to do it [shut down the system] yourself". It also avoids the risk of locking out the admin (nologin file), in case they logged out for some reason (and they use `sudo` instead of root). Not that I have any idea why you'd want to use `shutdown -k`, but the code is easier to analyze if it rolls back on error (in the absence of any code comment as to why that's not wanted).
* logind: respect "delay" inhibitors in scheduled shutdownsAlan Jenkins2017-09-25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There is no justification not to wait an extra (default) 5 seconds, for a more graceful shutdown of user programs. Again, you don't get to ignore delay inhibitors for unscheduled shutdowns, short of `systemctl poweroff -f`. It is simplest if we move the test for `m->shutdown_dry_run` into manager_scheduled_shutdown_handler(). However we need to not add such delays during a "dry run". Otherwise, we would still have to be considered "in progress" for some seconds after our admin has seen the final wall message. If they go to `poweroff`, we would have blocked them with a misleading error message. Note this `poweroff` will still process delay inhibitors as needed. If the admin planned to use a more forceful method... eh. It's their responsibility to assess whether that's safe. There is an argument that the alternative behaviour could be used (racily!) to kludge around them not being able to shutdown to "single user mode". If we cared about that case, we would have easily preserved non-racy support for it in `shutdown`. Additionally, though I think this code does read more easily by reducing inconsistencies, we didn't come up with any use case for delay inhibitors v.s. shutdown.[1] The SIGTERM v.s. SIGKILL delay is more general, and we allow a whole 90 seconds for it, not just 5. So I don't think keeping this approach bears a risk of significant damage. [1] https://www.freedesktop.org/wiki/Software/elogind/inhibit/
* logind: add missing check for conflicting operation v.s. scheduled shutdownAlan Jenkins2017-08-21
| | | | | | | | | | | | | | | | | | | | | | | | > We don't want to shutdown while a suspend is running, and vice versa. > This would be confusing and could lead to data loss in the worst case. https://bugs.launchpad.net/ubuntu/+source/elogind/+bug/1441253/comments/4 According to the above comment, if the conflicting operation is hung, we don't want to force things when the admin has not passed a force option. Similarly if you're not an admin, you probably shouldn't get to sneak around this check by using a scheduled shutdown instead of an unscheduled one. (And no-one so far thought it necessary to add such a permission in PolKit). Note that if the conflicting operation was _not_ hung, and we lost the race with suspend, the system might not have shut down at the scheduled time anyway. Which is no good if you were scheduling a power outage. And scheduling a shutdown for an arbitrary time when the system is resumed, does not seem a very useful semantic. More likely, scheduled shutdowns are useful on systems which do not use suspend, such as multi-user servers. (In which case even PolKit defaults likely don't let the users trigger suspend).
* logind: method_schedule_shutdown() already rejects empty `type`Alan Jenkins2017-09-25
| | | | | Don't test for an empty `type` afterwards. This is not how you cancel scheduled shutdowns - there's a separate method for that.
* Prep v235: Apply upstream fixes (6/10) [src/login]Sven Eden2017-08-14
|
* core, sd-bus, logind: make use of uid_is_valid() in more placesLennart Poettering2017-07-14
|
* logind: nicer error message when we cannot guess the caller's sessionZbigniew Jędrzejewski-Szmek2017-07-25
| | | | Partial fix for #6032.
* Prep v233.3: Moved four functions, that did not need adaptation in ↵Sven Eden2017-07-20
| | | | elogind-dbus.c, back to logind-dbus.c.
* Prep v233: Add missing updates from upstream in src/loginSven Eden2017-07-17
|
* logind: trivial simplificationZbigniew Jędrzejewski-Szmek2017-07-17
| | | | free_and_strdup() handles NULL arg, so make use of that.
* tree-wide: replace all readdir cycles with FOREACH_DIRENT{,_ALL} (#4853)Reverend Homer2017-07-17
|
* Rename formats-util.h to format-util.hZbigniew Jędrzejewski-Szmek2017-07-17
| | | | | | We don't have plural in the name of any other -util files and this inconsistency trips me up every time I try to type this file name from memory. "formats-util" is even hard to pronounce.
* tree-wide: add SD_ID128_MAKE_STR, remove LOG_MESSAGE_IDZbigniew Jędrzejewski-Szmek2017-07-17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Embedding sd_id128_t's in constant strings was rather cumbersome. We had SD_ID128_CONST_STR which returned a const char[], but it had two problems: - it wasn't possible to statically concatanate this array with a normal string - gcc wasn't really able to optimize this, and generated code to perform the "conversion" at runtime. Because of this, even our own code in coredumpctl wasn't using SD_ID128_CONST_STR. Add a new macro to generate a constant string: SD_ID128_MAKE_STR. It is not as elegant as SD_ID128_CONST_STR, because it requires a repetition of the numbers, but in practice it is more convenient to use, and allows gcc to generate smarter code: $ size .libs/elogind{,-logind,-journald}{.old,} text data bss dec hex filename 1265204 149564 4808 1419576 15a938 .libs/elogind.old 1260268 149564 4808 1414640 1595f0 .libs/elogind 246805 13852 209 260866 3fb02 .libs/elogind-logind.old 240973 13852 209 255034 3e43a .libs/elogind-logind 146839 4984 34 151857 25131 .libs/elogind-journald.old 146391 4984 34 151409 24f71 .libs/elogind-journald It is also much easier to check if a certain binary uses a certain MESSAGE_ID: $ strings .libs/elogind.old|grep MESSAGE_ID MESSAGE_ID=%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x MESSAGE_ID=%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x MESSAGE_ID=%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x MESSAGE_ID=%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x $ strings .libs/elogind|grep MESSAGE_ID MESSAGE_ID=c7a787079b354eaaa9e77b371893cd27 MESSAGE_ID=b07a249cd024414a82dd00cd181378ff MESSAGE_ID=641257651c1b4ec9a8624d7a40a9e1e7 MESSAGE_ID=de5b426a63be47a7b6ac3eaac82e2f6f MESSAGE_ID=d34d037fff1847e6ae669a370e694725 MESSAGE_ID=7d4958e842da4a758f6c1cdc7b36dcc5 MESSAGE_ID=1dee0369c7fc4736b7099b38ecb46ee7 MESSAGE_ID=39f53479d3a045ac8e11786248231fbf MESSAGE_ID=be02cf6855d2428ba40df7e9d022f03d MESSAGE_ID=7b05ebc668384222baa8881179cfda54 MESSAGE_ID=9d1aaa27d60140bd96365438aad20286
* Prep v231.3: No authorization for setting the wall message.Sven Eden2017-06-29
| | | | | | elogind only calls this when shutting down, rebooting or cancelling a pending shutdown/reboot. Authorization is already needed there, so do not question the user twice, just because they forgot to sudo.
* Prep v231.2: Move elogind specific code in logind-dbus.c to elogind-dbus.cSven Eden2017-06-28
|
* Prep v231.2: elogind is a stand-alone daemon, so do not exit if suspending ↵Sven Eden2017-06-27
| | | | the system fails.
* Prep v231.2: Send processes the wakeup signal, even if suspending the system ↵Sven Eden2017-06-27
| | | | failed.
* Prep v231.2: Add mor debug messages to find out, why 'loginctl suspend' ↵Sven Eden2017-06-26
| | | | isn't working.
* Prep v231.2: Really set an extra wall message (if any) and display it when ↵Sven Eden2017-06-26
| | | | cancelling a pending shutdown/reboot
* Prep v229.6: Send wakeup call to suspended processes.Sven Eden2017-06-16
| | | | | | | | | | Somewhere in the update stream from 227.x to 228.x the sending of the wakeup signal to sleeping processes got lost. Re-add the sending of the wakeup signal. Fixes issue 17 ( https://github.com/elogind/elogind/issues/17 )
* Prep v231: Move can_sleep() back to src/shared/sleep-config.cSven Eden2017-06-16
|
* Prep v230: Add utmp support to make wall message to work properly.Sven Eden2017-06-16
|
* Prep v230: Return 'no' when asked whether we can reboot into firmware setup. ↵Sven Eden2017-06-16
| | | | elogind does not support EFI.
* Prep v230: Apply missing upstream fixes and updates (6/8) src/login.Sven Eden2017-06-16
|
* logind: enforce a limit on inhibitors we hand outLennart Poettering2017-06-16
| | | | | | | | For similar reasons as the recent addition of a limit on sessions. Note that we don't enforce a limit on inhibitors per-user currently, but there's an implicit one, since each inhibitor takes up one fd, and fds are limited via RLIMIT_NOFILE, and the limit on the number of processes per user.
* logind: expose more configuration settings as bus propertiesLennart Poettering2017-06-16
|
* logind: enforce a limit on current user sessionsLennart Poettering2017-06-16
| | | | | | | | | | | We really should put limits on all resources we manage, hence add one to the number of concurrent sessions, too. This was previously unbounded, hence set a relatively high limit of 8K by default. Note that most PAM setups will actually invoke pam_elogind prefixed with "-", so that the return code of pam_elogind is ignored, and the login attempt succeeds anyway. On systems like this the session will be created but is not tracked by elogind.
* logind: allow any user to request lingeringZbigniew Jędrzejewski-Szmek2017-06-16
| | | | | | We enable lingering for anyone who wants this. It is still disabled by default to avoid keeping long-running processes accidentally. Admins might want to customize this policy on multi-user sites.
* Prep v229: Consolidate system sleep functions.Sven Eden2017-05-22
| | | | | | Move sleep relevant functions from shared/sleep-config.* and login/logind-action.* into login/logind-sleep.* - they aren't used outside of elogind anyway.
* Prep v229: Add missing fixes from upstream [4/6] src/loginSven Eden2017-05-17
|
* logind: load SELinux labelling systemNicolas Iooss2017-05-17
| | | | | | | | | | | elogind-logind uses mkdir_label and label_fix functions without calling first mac_selinux_init. This makes /run/user/$UID/ directories not labelled correctly on an Arch Linux system using SELinux. Fix this by calling mac_selinux_init("/run") early in elogind-logind. This makes files created in /etc/udev/rules.d and /var/lib/elogind to be labelled through transitions in the SELinux policy instead of using setfscreatecon (with mac_selinux_create_file_prepare).
* tree-wide: check if errno is greater then zeroZbigniew Jędrzejewski-Szmek2017-05-17
| | | | | | | | | | | | | | gcc is confused by the common idiom of return errno ? -errno : -ESOMETHING and thinks a positive value may be returned. Replace this condition with errno > 0 to help gcc and avoid many spurious warnings. I filed a gcc rfe a long time ago, but it hard to say if it will ever be implemented [1]. Both conventions were used in the codebase, this change makes things more consistent. This is a follow up to bcb161b0230f. [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61846
* Fix typo on logind-dbus.cJoost Bremmer2017-05-17
| | | | | | | | | method_schedule_shutdown referenced org.freedesktop.login1.poweroff* which is never registered in polkit. Now refers to org.freedesktop.login1.power-off* Signed-off-by: Joost Bremmer <toost.b@gmail.com>
* login: make sure /run/nologin has correct SELinux labelMichal Sekletar2017-05-17
|
* Reset pending actions after returning from possible suspend/sleep actions.Sven Eden2017-05-17
| | | | This should fix any "suspension loops".