summaryrefslogtreecommitdiff
path: root/src/login/logind-session-device.c
Commit message (Collapse)AuthorAgeFilesLines
* logind-session-device: modernize session_device_free()David Tardon2023-04-281-3/+5
|
* tree-wide: use -EBADF for fd initializationZbigniew Jędrzejewski-Szmek2022-12-191-1/+1
| | | | | | | | | | | | | | | | -1 was used everywhere, but -EBADF or -EBADFD started being used in various places. Let's make things consistent in the new style. Note that there are two candidates: EBADF 9 Bad file descriptor EBADFD 77 File descriptor in bad state Since we're initializating the fd, we're just assigning a value that means "no fd yet", so it's just a bad file descriptor, and the first errno fits better. If instead we had a valid file descriptor that became invalid because of some operation or state change, the other errno would fit better. In some places, initialization is dropped if unnecessary.
* basic: rename util.h to logarithm.hZbigniew Jędrzejewski-Szmek2022-11-081-1/+0
| | | | | util.h is now about logarithms only, so we can rename it. Many files included util.h for no apparent reason… Those includes are dropped.
* tree-wide: drop () around the first argument of a ternary opZbigniew Jędrzejewski-Szmek2022-10-111-1/+1
| | | | https://github.com/systemd/systemd/pull/24933#discussion_r991242789
* fd-util: rename CLOSE_AND_REPLACE() -> close_and_replace()Yu Watanabe2022-09-171-1/+1
| | | | | | | | We have free_and_replace() and friends, they are all named with lower letters, even they are macros, not functions. For consistency, let's rename CLOSE_AND_REPLACE() with lower letters. This also mekes the macro used more places.
* login: use helper functions for fd storeYu Watanabe2022-08-161-18/+4
|
* Minor wording fixesZbigniew Jędrzejewski-Szmek2022-05-241-1/+1
| | | | | | | Some NEWS entries are tweaked a bit to address complaints about readability from users. "udev" is pronounced as /ˈjuːdɛv/, like in "user", hence "a" not "an".
* tree-wide: use new RET_NERRNO() helper at various placesLennart Poettering2021-11-161-10/+2
|
* tree-wide: warn when sd_notify fails with READY=1 or FDSTOREREMOVE=1Zbigniew Jędrzejewski-Szmek2021-11-031-5/+10
| | | | | | | | Most sd_notify() calls are like log_info() — the result is only informative and if they fail, it's best ignore this. But if a call with READY=1 fails, the unit may enter a failed state, so we should warn about this. Similarly for FSTOREREMOVE=1: the manager may be left with a stale fd, at least wasting resources.
* tree-wide: voidify unchecked close_nointr callsLuca Boccassi2021-08-031-1/+1
| | | | | | | | | | These have ignored the return value forever. Two are public APIs so we can't really change what they return anyway, and the other one is a cleanup path and the existing error code is more important. CID#1461274 CID#1461275 CID#1461276
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-091-1/+1
|
* Add CLOSE_AND_REPLACE helperZbigniew Jędrzejewski-Szmek2020-09-181-2/+1
| | | | | | Similar to free_and_replace. I think this should be uppercase to make it clear that this is a macro. free_and_replace should probably be uppercased too.
* tree-wide: define iterator inside of the macroZbigniew Jędrzejewski-Szmek2020-09-081-8/+4
|
* tree-wide: drop input.h when missing_input.h is includedYu Watanabe2019-11-041-1/+0
|
* tree-wide: drop missing.hYu Watanabe2019-10-311-1/+2
|
* logind: split out dbus header files into their ownLennart Poettering2019-05-241-1/+2
| | | | | | | | | Previously, logind's logind-session.h would define prototypes for logind-session.c and logind-session-dbus.c. Split that out, so that there's a separate logind-session-dbus.h for that. Similar for seats and users as well as the manager itself. This changes no code, just rearranges where protoypes are located.
* codespell: fix spelling errorsBen Boeckel2019-04-291-1/+1
|
* logind: simplify removal of device fdsLennart Poettering2019-04-021-15/+5
| | | | | | let's use sd_notifyf(). Let's also stop validating the session ID here. This is the destructor. if it contains a dash, we are already too late here anyway.
* missing: re-add drm related entriesYu Watanabe2018-12-071-4/+0
| | | | | | This effectively reverts dab28f09051445fe370466e767e31652e0804a0f. Fixes #11075.
* missing: drop old drm related definitionsYu Watanabe2018-12-061-0/+4
| | | | | These values are exposed earlier than linux-3.11. Let's use drm/drm.h.
* coccinelle: make use of SYNTHETIC_ERRNOZbigniew Jędrzejewski-Szmek2018-11-221-4/+3
| | | | | | | | | | | Ideally, coccinelle would strip unnecessary braces too. But I do not see any option in coccinelle for this, so instead, I edited the patch text using search&replace to remove the braces. Unfortunately this is not fully automatic, in particular it didn't deal well with if-else-if-else blocks and ifdefs, so there is an increased likelikehood be some bugs in such spots. I also removed part of the patch that coccinelle generated for udev, where we returns -1 for failure. This should be fixed independently.
* tree-wide: replace 'unsigned int' with 'unsigned'Yu Watanabe2018-10-191-1/+1
|
* tree-wide: drop unnecessary initializationsYu Watanabe2018-09-231-5/+6
|
* tree-wide: use streq() instead of streq_ptr()Yu Watanabe2018-09-231-2/+2
|
* logind: replace udev_device by sd_deviceYu Watanabe2018-08-231-48/+34
|
* tree-wide: drop copyright headers from frequent contributorsZbigniew Jędrzejewski-Szmek2018-06-201-3/+0
| | | | | | | | Fixes #9320. for p in Shapovalov Chevalier Rozhkov Sievers Mack Herrmann Schmidt Rudenberg Sahani Landden Andersen Watanabe; do git grep -e 'Copyright.*'$p -l|xargs perl -i -0pe 's|/([*][*])?[*]\s+([*#]\s+)?Copyright[^\n]*'$p'[^\n]*\s*[*]([*][*])?/\n*|\n|gms; s|\s+([*#]\s+)?Copyright[^\n]*'$p'[^\n]*\n*|\n|gms' done
* tree-wide: beautify remaining copyright statementsLennart Poettering2018-06-141-1/+1
| | | | | | Let's unify an beautify our remaining copyright statements, with a unicode ©. This means our copyright statements are now always formatted the same way. Yay.
* tree-wide: drop 'This file is part of systemd' blurbLennart Poettering2018-06-141-2/+0
| | | | | | | | | | | | | | | | This part of the copyright blurb stems from the GPL use recommendations: https://www.gnu.org/licenses/gpl-howto.en.html The concept appears to originate in times where version control was per file, instead of per tree, and was a way to glue the files together. Ultimately, we nowadays don't live in that world anymore, and this information is entirely useless anyway, as people are very welcome to copy these files into any projects they like, and they shouldn't have to change bits that are part of our copyright header for that. hence, let's just get rid of this old cruft, and shorten our codebase a bit.
* tree-wide: drop trailing whitespaceLennart Poettering2018-06-121-1/+1
|
* tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek2018-04-061-13/+0
| | | | | | | | | | Files which are installed as-is (any .service and other unit files, .conf files, .policy files, etc), are left as is. My assumption is that SPDX identifiers are not yet that well known, so it's better to retain the extended header to avoid any doubt. I also kept any copyright lines. We can probably remove them, but it'd nice to obtain explicit acks from all involved authors before doing that.
* login: effectively revert "open device if needed"Alan Jenkins2018-03-101-11/+13
| | | | | | | | | | | | | This replaces commit 4d3900f1b7ccce03366f9a57d259d0735c1cfbcf. The underlying cause of issue #8291 has been fixed, so there is no reason to paper over it any more. But it might still be useful not to crash in the face of bad restart data. That can cause several restarts, or maybe at some point an infinite loop of restarts. Fail the start (or stop!) request, and write an error to the system log. Each time reflects a user request where we fail to resume the display server's access (or revoke it), and it can be useful if the log shows the most recent one.
* login: don't remove all devices from PID1 when only one was removedAlan Jenkins2018-03-101-12/+26
| | | | | | | | | | | | | | | | FDSTOREREMOVE=1 removes all fds with the specified name. And we had named the fds after the session. Better fix that. Closes #8344. AFAICT there's no point providing compatibility code for this transition. No-one would be restarting logind on a system with a GUI (where the session devices are used), because doing so has been killing the GUI, and even causing startup of the GUI to fail leading to a restart loop. Upgrading logind on a running system with a GUI might start being possible after this commit (and after also fixing the display server of your choice).
* login: correct comment in session_device_free()Alan Jenkins2018-03-081-1/+1
| | | | | | We're not removing the pushed fd "again"; this is the only place logind removes it from PID1. (And stopping the fd doesn't always cause PID1 to remove the fd itself; it depends on the device type).
* login: remember that fds received from PID1 need to be removed eventuallyAlan Jenkins2018-03-031-0/+1
| | | | | Remember to set sd->pushed_fd when we receive an fd from PID1 on startup, the same as we set it when we send an fd to PID1.
* login: fix FDNAME in call to sd_pid_notify_with_fds()Alan Jenkins2018-03-031-1/+1
| | | | | | | | | | | | | | | $ git grep FDNAME logind-session-device.c: ... "FDNAME=session-", sd->session->id); logind-session-device.c: ... "FDNAME=session", sd->session->id); Oops. Fixes #8343. Or at least a more minimal reproducer. Xorg still dies when logind is restarted, but the Xorg message says this is entirely deliberate. (This could also be the reason I hit #8035, instead of the race condition I originally suggested).
* logind: fix typo in commentLennart Poettering2018-03-021-1/+5
|
* logind: open device if neededLennart Poettering2018-03-021-5/+13
| | | | Fixes: #8291
* logind: cast away return value we don't care aboutLennart Poettering2018-03-021-1/+1
|
* logind: voidify a function we never check the return value ofLennart Poettering2018-03-021-3/+1
|
* logind: make sure we don't trip up on half-initialized session devicesLennart Poettering2018-02-261-1/+1
| | | | Fixes: #8035
* logind: fd 0 is a valid fdLennart Poettering2018-02-261-1/+1
|
* logind: let's reduce one level of indentationLennart Poettering2018-02-261-16/+19
|
* logind: propagate the right error, don't make up ENOMEMLennart Poettering2018-02-261-3/+1
|
* logind: rework sd_eviocrevoke()Lennart Poettering2018-02-261-7/+5
| | | | | Let's initialize static variables properly and get rid of redundant variables.
* logind: trivial improvementsLennart Poettering2018-02-261-25/+26
| | | | | Just some addition whitespace, some additional assert()s, and removal of redundant variables.
* logind: use the new FDSTOREREMOVE=1 sd_notify() messageLennart Poettering2017-11-271-13/+28
| | | | | | | Let's explicitly tell PID 1 that we don't need an fd anymore, instead of relying exclusively on POLLERR/POLLHUP for it to be removed. Fixes: #6908
* Add SPDX license identifiers to source files under the LGPLZbigniew Jędrzejewski-Szmek2017-11-191-0/+1
| | | | | This follows what the kernel is doing, c.f. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
* logind: save/restore session devices and their respective file descriptorsFranck Bui2017-06-081-20/+61
| | | | | | | | | | | | | | | | | | | This patch ensures that session devices are saved for each session. In order to make the revokation logic work when logind is restarted, the session devices are now saved in the session state files and their respective file descriptors sent to PID1's fdstore in order to keep them open accross restart. This is mandatory in order to keep the revokation logic working. Indeed in case of input-devices, the same file descriptors must be shared by logind and a given session controller in order EVIOCREVOKE to work otherwise multiple sessions can have device access in parallel. This should be the only remaining and missing piece for making logind fully restartable. Fixes: #1163
* tree-wide: remove Emacs lines from all filesDaniel Mack2016-02-101-2/+0
| | | | | This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
* tree-wide: expose "p"-suffix unref calls in public APIs to make gcc cleanup easyLennart Poettering2015-11-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GLIB has recently started to officially support the gcc cleanup attribute in its public API, hence let's do the same for our APIs. With this patch we'll define an xyz_unrefp() call for each public xyz_unref() call, to make it easy to use inside a __attribute__((cleanup())) expression. Then, all code is ported over to make use of this. The new calls are also documented in the man pages, with examples how to use them (well, I only added docs where the _unref() call itself already had docs, and the examples, only cover sd_bus_unrefp() and sd_event_unrefp()). This also renames sd_lldp_free() to sd_lldp_unref(), since that's how we tend to call our destructors these days. Note that this defines no public macro that wraps gcc's attribute and makes it easier to use. While I think it's our duty in the library to make our stuff easy to use, I figure it's not our duty to make gcc's own features easy to use on its own. Most likely, client code which wants to make use of this should define its own: #define _cleanup_(function) __attribute__((cleanup(function))) Or similar, to make the gcc feature easier to use. Making this logic public has the benefit that we can remove three header files whose only purpose was to define these functions internally. See #2008.