summaryrefslogtreecommitdiff
path: root/src/login/logind-core.c
Commit message (Collapse)AuthorAgeFilesLines
...
* logind: replace udev_device by sd_deviceYu Watanabe2018-08-231-47/+54
|
* Merge pull request #9783 from poettering/get-user-creds-flagsZbigniew Jędrzejewski-Szmek2018-08-211-1/+1
|\ | | | | beef up get_user_creds() a bit and other improvements
| * user-util: rework get_user_creds()Lennart Poettering2018-08-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Let's fold get_user_creds_clean() into get_user_creds(), and introduce a flags argument for it to select "clean" behaviour. This flags parameter also learns to other new flags: - USER_CREDS_SYNTHESIZE_FALLBACK: in this mode the user records for root/nobody are only synthesized as fallback. Normally, the synthesized records take precedence over what is in the user database. With this flag set this is reversed, and the user database takes precedence, and the synthesized records are only used if they are missing there. This flag should be set in cases where doing NSS is deemed safe, and where there's interest in knowing the correct shell, for example if the admin changed root's shell to zsh or suchlike. - USER_CREDS_ALLOW_MISSING: if set, and a UID/GID is specified by numeric value, and there's no user/group record for it accept it anyway. This allows us to fix #9767 This then also ports all users to set the most appropriate flags. Fixes: #9767 [zj: remove one isempty() call]
* | tree-wide: shorten error logging a bitYu Watanabe2018-08-071-2/+2
|/ | | | Continuation of 4027f96aa08c73f109aa46b89842ca0e25c9c0e9.
* tree-wide: remove Lennart's copyright linesLennart Poettering2018-06-141-3/+0
| | | | | | | | | | | These lines are generally out-of-date, incomplete and unnecessary. With SPDX and git repository much more accurate and fine grained information about licensing and authorship is available, hence let's drop the per-file copyright notice. Of course, removing copyright lines of others is problematic, hence this commit only removes my own lines and leaves all others untouched. It might be nicer if sooner or later those could go away too, making git the only and accurate source of authorship information.
* 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.
* logind: modernize Manager object allocation and freeingLennart Poettering2018-04-271-0/+2
| | | | | | Let's propagate errors correctly, and stick to the usual naming and behaviour of these functions. Or in other words, make this closer to the matching code in machined.
* Merge pull request #7599 from keszybz/slice-templatesLennart Poettering2018-04-261-0/+43
|\ | | | | Make user@.service independent of logind
| * logind: move two functions to logind_core utility libZbigniew Jędrzejewski-Szmek2018-04-241-0/+43
| | | | | | | | In preparation to reusing them later in other places...
* | tree-wide: drop redundant _cleanup_ macros (#8810)Lennart Poettering2018-04-251-2/+2
|/ | | | | | | | | | | | | | | | | | | | | | | | | | This drops a good number of type-specific _cleanup_ macros, and patches all users to just use the generic ones. In most recent code we abstained from defining type-specific macros, and this basically removes all those added already, with the exception of the really low-level ones. Having explicit macros for this is not too useful, as the expression without the extra macro is generally just 2ch wider. We should generally emphesize generic code, unless there are really good reasons for specific code, hence let's follow this in this case too. Note that _cleanup_free_ and similar really low-level, libc'ish, Linux API'ish macros continue to be defined, only the really high-level OO ones are dropped. From now on this should really be the rule: for really low-level stuff, such as memory allocation, fd handling and so one, go ahead and define explicit per-type macros, but for high-level, specific program code, just use the generic _cleanup_() macro directly, in order to keep things simple and as readable as possible for the uninitiated. Note that before this patch some of the APIs (notable libudev ones) were already used with the high-level macros at some places and with the generic _cleanup_ macro at others. With this patch we hence unify on the latter.
* 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.
* logind: rework manager_get_{user|session}_by_pid() a bitLennart Poettering2018-03-211-10/+23
| | | | | | | | Let's make sure we always initialize the return value if we return non-negative. Just a matter of coding style: we should always initialize our return values when we return >= 0, and leave them unclobbered if we return < 0.
* logind: trivial improvementsLennart Poettering2018-02-261-0/+3
| | | | | Just some addition whitespace, some additional assert()s, and removal of redundant variables.
* Suspend on lid close based on power status. (#8016)Simon Fowler2018-02-091-0/+31
| | | | | | | This change adds support for controlling the suspend-on-lid-close behaviour based on the power status as well as whether the machine is docked or has an external monitor. For backwards compatibility the new configuration file variable is ignored completely by default, and must be set explicitly before being considered in any decisions.
* log: minimize includes in log.hLennart Poettering2018-01-111-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | log.h really should only include the bare minimum of other headers, as it is really pulled into pretty much everything else and already in itself one of the most basic pieces of code we have. Let's hence drop inclusion of: 1. sd-id128.h because it's entirely unneeded in current log.h 2. errno.h, dito. 3. sys/signalfd.h which we can replace by a simple struct forward declaration 4. process-util.h which was needed for getpid_cached() which we now hide in a funciton log_emergency_level() instead, which nicely abstracts the details away. 5. sys/socket.h which was needed for struct iovec, but a simple struct forward declaration suffices for that too. Ultimately this actually makes our source tree larger (since users of the functionality above must now include it themselves, log.h won't do that for them), but I think it helps to untangle our web of includes a tiny bit. (Background: I'd like to isolate the generic bits of src/basic/ enough so that we can do a git submodule import into casync for it)
* 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: use pid_is_valid() where appropriateAlan Jenkins2017-10-041-2/+2
| | | | | | | These two sites _do_ match the definition of pid_is_valid(); they don't provide any special handling for the invalid PID value 0. (They're used by dbus methods, so the PID value 0 is handled with reference to the dbus client creds, outside of these functions).
* logind: VT_GETSTATE "cannot return state for more than 16 VTs" (#6625)Alan Jenkins2017-08-301-0/+40
| | | | `vt_is_busy(16)` would always return FALSE. So we could have started autovt@16.service even when VT 16 was already being used for something.
* logind: filter out input devices that have none of the keys/switche we care ↵Lennart Poettering2017-06-271-1/+5
| | | | | | | about Let's check what keys are there, before we actually hang on to the opened devices.
* treewide: fix typosTorstein Husebø2016-07-041-1/+1
|
* logind: make KillOnlyUsers override KillUserProcessesZbigniew Jędrzejewski-Szmek2016-04-211-6/+3
| | | | | | | Instead of KillOnlyUsers being a filter for KillUserProcesses, it can now be used to specify users to kill, independently of the KillUserProcesses setting. Having the settings orthogonal seems to make more sense. It also makes KillOnlyUsers symmetrical to KillExcludeUsers.
* logind: reload config on SIGHUPZbigniew Jędrzejewski-Szmek2016-04-211-0/+3
| | | | | | v2: - fix setting of kill_user_processes and *_ignore_inhibited settings
* 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: check if errno is greater then zeroZbigniew Jędrzejewski-Szmek2016-01-131-1/+1
| | | | | | | | | | | | | | 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
* 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.
* tree-wide: sort includesThomas Hindoe Paaboel Andersen2015-11-161-2/+2
| | | | Sort the includes accoding to the new coding style.
* login: make user_new() and user_free() follow coding-styleDavid Herrmann2015-11-161-3/+4
| | | | | | | | | | Few changes to user_new() and user_free(): - Use _cleanup_(user_freep) in constructor - return 'int' from user_new() - make user_free() deal with partially initialized objects - keep reverse-order in user_free() compared to user_new() - make user_free() return NULL - make user_free() accept NULL as no-op
* util-lib: split out allocation calls into alloc-util.[ch]Lennart Poettering2015-10-271-0/+1
|
* util-lib: split out user/group/uid/gid calls into user-util.[ch]Lennart Poettering2015-10-261-0/+1
|
* util-lib: split out fd-related operations into fd-util.[ch]Lennart Poettering2015-10-251-4/+5
| | | | | There are more than enough to deserve their own .c file, hence move them over.
* logind: switch to sd_bus_track helperDaniel Mack2015-08-051-38/+0
| | | | | | | | | Let logind use the sd_bus_track helper object to track the controllers of sessions. This does not only remove quite some code but also kills the unconditional matches for all NameOwnerChanged signals. The latter is something we should never ever do, as it wakes up the daemon every time a client connects, which doesn't scale.
* logind: fail on CreateSession if already in sessionDavid Herrmann2015-07-071-2/+2
| | | | | | | | | | | Right now, if you're already in a session and call CreateSession, we return information about the current session of yours. This is highy confusing and a nasty hack. Avoid that, and instead return a commonly known error, so the caller can detect that. This has the side-effect, that we no longer override XDG_VTNR and XDG_SEAT in pam_systemd, if you're already in a session. But this sounds like the right thing to do, anyway.
* logind: rework display counting when detecting whether the system is dockedLennart Poettering2015-06-171-7/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | Previously, we'd just count connected displays, and if there was 2 or more we assumed a "docked" state. With this change we now: - Only count external displays, ignore internal ones (which we detect by checking the connector name against a whitelist of known external plug types) - We ignore connectors which are explicitly disabled - We then compare the count with >= 1 rather than >= 2 as before This new logic has the benefit that systems that disconnect the internal display when the lid is closed are better supported. Also, explicitly disabled ports do not confuse the algorithm anymore. This new algorithm has been suggested here: http://lists.freedesktop.org/archives/intel-gfx/2015-June/068821.html This also makes two functions static, that are not used outside of their .c files.
* everywhere: actually make use of DUAL_TIMESTAMP_NULL macroLennart Poettering2015-06-161-1/+1
| | | | Let's use it as initializer where appropriate.
* shared: add terminal-util.[ch]Ronny Chevalier2015-04-111-0/+1
|
* remove unused includesThomas Hindoe Paaboel Andersen2015-02-231-3/+0
| | | | | | This patch removes includes that are not used. The removals were found with include-what-you-use which checks if any of the symbols from a header is in use.
* logind: unify how we cast between uid_t and pointers for hashmap keysLennart Poettering2015-01-091-1/+1
|
* treewide: no need to negate errno for log_*_errno()Michal Schmidt2014-11-281-1/+1
| | | | It corrrectly handles both positive and negative errno values.
* treewide: auto-convert the simple cases to log_*_errno()Michal Schmidt2014-11-281-1/+1
| | | | | | | | | | | | | As a followup to 086891e5c1 "log: add an "error" parameter to all low-level logging calls and intrdouce log_error_errno() as log calls that take error numbers", use sed to convert the simple cases to use the new macros: find . -name '*.[ch]' | xargs sed -r -i -e \ 's/log_(debug|info|notice|warning|error|emergency)\("(.*)%s"(.*), strerror\(-([a-zA-Z_]+)\)\);/log_\1_errno(-\4, "\2%m"\3);/' Multi-line log_*() invocations are not covered. And we also should add log_unit_*_errno().
* logind: add HandleLidSwitchDocked= option to logind.conf + documentationBen Wolsieffer2014-08-261-0/+22
| | | | https://bugs.freedesktop.org/show_bug.cgi?id=82485
* logind: Do not fail display count if a device has no parentMantas Mikulėnas2014-03-111-1/+1
| | | | | | | udev_device_get_parent() may return NULL when the device doesn't have a parent, as is the case with (for example) /sys/devices/virtual/drm/ttm. Also, log an actual error message instead of "-12 displays connected".
* logind: small simplificationsZbigniew Jędrzejewski-Szmek2014-03-041-53/+25
|
* logind: ignore lid switch if more than 1 display is connectedLennart Poettering2014-03-031-2/+53
| | | | | | | | | | Previously we expected the desktop environment to take an inhibitor lock, but this opened a race on boot-up where logind might already be running but no DE is active. Hence, let's move checking for additional displays into logind. This also opens up this logic for other DEs, given that only GNOME implemented the inhibitor logic so far.
* logind: detect whether the system is docked, and if it is inhibit lid switch ↵Lennart Poettering2014-02-241-0/+11
| | | | | | | processing This should make operation nicer with docking stations, but will not cover anything that does not implement SW_DOCK.
* logind: make VT numbers unsignedDavid Herrmann2013-11-281-6/+6
| | | | | | | | | | Fix the whole code to use "unsigned int" for vtnr. 0 is an invalid vtnr so we don't need negative numbers at all. Note that most code already assumes it's unsigned so in case there's a negative vtnr, our code may, under special circumstances, silently break. So this patch makes sure all sources of vtnrs verify the validity. Also note that the dbus api already uses unsigned ints.
* logind: log which process is delaying suspend and not closing locksLennart Poettering2013-11-271-1/+1
|
* machined: keep track of the initial leader PID of a machineLennart Poettering2013-11-061-2/+2
| | | | | | | This way we can without races always determine the machine for a leader PID. This allows machine managers to query the machine for a forked off container/VM without a race where the child might already have died before we could read the cgroup information from /proc/$PID/cgroup.
* logind: port logind to libsystemd-busLennart Poettering2013-11-051-26/+17
|
* Move part of logind.c into a separate fileZbigniew Jędrzejewski-Szmek2013-09-261-0/+514
liblogind-core.la was underlinked, missing a few functions defined in logind.c. They are moved to a new file, logind-core.c, and this file is linked into liblogind-core.la. In addition, logind-acl.c is attached to the liblogind-core.la, instead of systemd-logind directly.