summaryrefslogtreecommitdiff
path: root/src/login
Commit message (Collapse)AuthorAge
* tree-wide: drop !! casts to booleansZbigniew Jędrzejewski-Szmek2018-08-24
| | | | | | | | | | | They are not needed, because anything that is non-zero is converted to true. C11: > 6.3.1.2: When any scalar value is converted to _Bool, the result is 0 if the > value compares equal to 0; otherwise, the result is 1. https://stackoverflow.com/questions/31551888/casting-int-to-bool-in-c-c
* tree-wide: drop trailing whitespaceLennart Poettering2018-08-24
|
* Remove NULL terminator from two log_struct callsZbigniew Jędrzejewski-Szmek2018-08-24
| | | | Fixup for a1230ff972. I forgot to press "save" ;(
* basic/log: add the log_struct terminator to macroZbigniew Jędrzejewski-Szmek2018-08-24
| | | | | This way all callers do not need to specify it. Exhaustively tested by running test-log under valgrind ;)
* login: log session state "closing" (as well as New/Removed)Alan Jenkins2018-08-24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Let's show a message at the time of logout i.e. entering the "closing" state, not just e.g. once the user closes `tmux` and the session can be removed completely. (At least when KillUserProcesses=no applies. My thinking was we can spare the log noise if we're killing the processes anyway). These are two independent events. I think the logout event is quite significant in the session lifecycle. It will be easier for a user who does not know logind details to understand why "Removed session" doesn't appear at logout time, if we have a specific message we can show at this time :). Tested using tmux and KillUserProcesses=no. I can also confirm the extra message doesn't show when using KillUserProcesses=yes. Maybe it looks a bit mysterious when you use KillOnlyUsers= / KillExcludeUsers=, but hopefully not alarmingly so. I was looking at systemd-logind messages on my system, because I can reproduce two separate problems with Gnome on Fedora 28 where sessions are unexpectedly in state "closing". (One where a GUI session limps along in a degraded state[1], and another where spice-vdagent is left alive after logout, keeping the session around[2]). It logged when sessions were created and removed, but it didn't log when the session entered the "closing" state. [1] https://bugzilla.redhat.com/show_bug.cgi?id=1583240#c1 [2] https://bugzilla.redhat.com/show_bug.cgi?id=1583261 Closes #9096
* Use const char* for timestamp strings which we don't plan to modifyZbigniew Jędrzejewski-Szmek2018-08-24
| | | | Makes the intent a bit clearer.
* fileio: accept FILE* in addition to path in parse_env_file()Lennart Poettering2018-08-24
| | | | | | | Most our other parsing functions do this, let's do this here too, internally we accept that anyway. Also, the closely related load_env_file() and load_env_file_pairs() also do this, so let's be systematic.
* logind: let's change the type of the runtime directory size to uint64_tLennart Poettering2018-08-24
| | | | | | | Externally it's an uint64_t anyway, and internally we most just initialize it to physical_memory() which returns uint64_t, hence there's exactly zero value in using it as size_t internally. Hence, let's fix that, and use uint64_t everywhere.
* tree-wide: remove some double newlines in headers, tooLennart Poettering2018-08-24
|
* tree-wide: port over all code to the new CONFIG_PARSER_PROTOTYPE() macroLennart Poettering2018-08-24
| | | | | | | | | | | This makes most header files easier to look at. Also Emacs gets really slow when browsing through large sections of overly long prototypes, which is much improved by this macro. We should probably not do something similar with too many other cases, as macros like this might help readability for some, but make it worse for others. But I think given the complexity of this specific prototype and how often we use it, it's worth doing.
* tree-wide: port various bits of the tree over to the new DUMP_STRING_TABLE() ↵Lennart Poettering2018-08-24
| | | | macro
* login: use BUS_DEFINE_PROPERTY_GET* macrosYu Watanabe2018-08-24
|
* inhibit: use pager for systemd-inhibit --listDavid Tardon2018-08-24
|
* logind: fix borked r checkZbigniew Jędrzejewski-Szmek2018-08-24
| | | | CID #1390947, #1390952.
* login: do not wall message on cancelling shutdown when ↵Yu Watanabe2018-08-24
| | | | | | Manager.enable_wall_messages is false Fixes #8904.
* login: change variable type of enable_wall_messages as it matches ↵Yu Watanabe2018-08-24
| | | | Manager.enable_wall_messages
* meson: generate m4 preprocessor from config.h (#8914)Yu Watanabe2018-08-24
|
* util: rename signal_from_string_try_harder() to signal_from_string()Yu Watanabe2018-08-24
| | | | | Also this makes the new `signal_from_string()` function reject e.g, `SIG3` or `SIG+5`.
* logind: (void)ify all things we knowingly ignoreLennart Poettering2018-08-24
|
* logind: terminate cleanly on SIGTERM/SIGINTLennart Poettering2018-08-24
| | | | | | | Let's properly terminate on SIGTERM or SIGINT. Previously we'd just rely on the implicit process clean-up logic on UNIX. By shutting down properly on SIGTERM/SIGINT we make it easier to track down memory leaks by employing valgrind.
* logind: modernize Manager object allocation and freeingLennart Poettering2018-08-24
| | | | | | 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.
* login: drop unnecessary headersYu Watanabe2018-08-24
|
* logind: remove manager_start_slice()Zbigniew Jędrzejewski-Szmek2018-08-24
| | | | It is now unused.
* logind: split %t directory creation to a helper unitZbigniew Jędrzejewski-Szmek2018-08-24
| | | | | | | | | | | | | | | Unfortunately this needs a new binary to do the mount because there's just too many special steps to outsource this to systemd-mount: - EPERM needs to be treated specially - UserRuntimeDir= setting must be obeyed - SELinux label must be adjusted This allows user@.service to be started independently of logind. So 'systemctl start user@nnn' will start the user manager for user nnn. Logind will start it too when the user logs in, and will stop it (unless lingering is enabled) when the user logs out. Fixes #7339.
* Use a dash-truncated drop-in for user-%j.slice configurationZbigniew Jędrzejewski-Szmek2018-08-24
| | | | | | | | | | | | | | | | | | | This removes the UserTasksMax= setting in logind.conf. Instead, the generic TasksMax= setting on the slice should be used. Instead of a transient unit we use a drop-in to tweak the default definition of a .slice. It's better to use the normal unit mechanisms instead of creating units on the fly. This will also make it easier to start user@.service independently of logind, or set additional settings like MemoryMax= for user slices. The setting in logind is removed, because otherwise we would have two sources of "truth": the slice on disk and the logind config. Instead of trying to coordinate those two sources of configuration (and maintainer overrides to both), let's just convert to the new one fully. Right now now automatic transition mechanism is provided. logind will emit a hint when it encounters the setting, but otherwise it will be ignored. Fixes #2556.
* logind: move two functions to logind_core utility libZbigniew Jędrzejewski-Szmek2018-08-24
| | | | In preparation to reusing them later in other places...
* tree-wide: drop redundant _cleanup_ macros (#8810)Lennart Poettering2018-08-24
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* login: drop an unused variableYu Watanabe2018-08-24
| | | | Follow-up for 99f1229d76da4b805f8f6c6e5e4a878d17d42f93.
* tree-wide: drop spurious newlines (#8764)Lennart Poettering2018-08-24
| | | | | | | | | Double newlines (i.e. one empty lines) are great to structure code. But let's avoid triple newlines (i.e. two empty lines), quadruple newlines, quintuple newlines, …, that's just spurious whitespace. It's an easy way to drop 121 lines of code, and keeps the coding style of our sources a bit tigther.
* loginctl: port loginctl to format-table.[ch]Lennart Poettering2018-08-24
|
* logind: enable limiting of user session scopes using pam context objects (#8397)Jan Synacek2018-08-24
|
* shared/sleep-config: return a custom message when not enough swap for ↵Zbigniew Jędrzejewski-Szmek2018-08-24
| | | | | | | | | | | hibernation $ sudo swapoff -av swapoff /dev/vda4 $ sudo systemctl hibernate Failed to hibernate system via logind: Not enough swap space for hibernation Fixes #6729.
* logind: refuse operations if the target unit is masked or unavailableZbigniew Jędrzejewski-Szmek2018-08-24
| | | | | | | | | | | | | | | | If hibernate.target is masked, and systemctl hibernate is invoked, havoc ensues. logind starts the hibernation operation, but then doesn't go through with it; gnome-shell segfaults. Let's be nice to the user and refuse doing anything in that case. $ sudo systemctl mask hibernate.target $ busctl call org.freedesktop.login1 /org/freedesktop/login1 org.freedesktop.login1.Manager CanHibernate s "no" $ sudo systemctl hibernate Failed to hibernate system via logind: Access denied Failed to start hibernate.target: Unit hibernate.target is masked. https://bugzilla.redhat.com/show_bug.cgi?id=1468003#c4
* tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek2018-08-24
| | | | | | | | | | 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.
* tree-wide: use TAKE_PTR() and TAKE_FD() macrosYu Watanabe2018-08-24
|
* tree-wide: remove unused variables (#8612)Yu Watanabe2018-08-24
|
* Rename suspend-to-hibernate to suspend-then-hibernateMario Limonciello2018-08-24
| | | | | Per some discussion with Gnome folks, they would prefer this name as it's more descriptive of what's happening.
* inhibit: make use of EXIT_SUCCESS where appropriateLennart Poettering2018-08-24
|
* bus-util: add flags for bus_map_all_properties() (#8546)Yu Watanabe2018-08-24
| | | | | | | | | | This adds flags BUS_MAP_STRDUP and BUS_MAP_BOOLEAN_AS_BOOL. If BUS_MAP_STRDUP is set, then each "s" message is duplicated. If BUS_MAP_BOOLEAN_AS_BOOL is set, then each "b" message is written to a bool pointer. Follow-up for #8488. See https://github.com/systemd/systemd/pull/8488#discussion_r175816270.
* label: rework label_fix() implementations (#8583)Lennart Poettering2018-08-24
| | | | | | | | | | | | | | | | | | | | | This reworks the SELinux and SMACK label fixing calls in a number of ways: 1. The two separate boolean arguments of these functions are converted into a flags type LabelFixFlags. 2. The operations are now implemented based on O_PATH. This should resolve TTOCTTOU races between determining the label for the file system object and applying it, as it it allows to pin the object while we are operating on it. 3. When changing a label fails we'll query the label previously set, and if matches what we want to set anyway we'll suppress the error. Also, all calls to label_fix() are now (void)ified, when we ignore the return values. Fixes: #8566
* tree-wide: warn when a directory path already exists but has bad mode/owner/typeZbigniew Jędrzejewski-Szmek2018-08-24
| | | | | | | | | | | | | | | | | | | | | When we are attempting to create directory somewhere in the bowels of /var/lib and get an error that it already exists, it can be quite hard to diagnose what is wrong (especially for a user who is not aware that the directory must have the specified owner, and permissions not looser than what was requested). Let's print a warning in most cases. A warning is appropriate, because such state is usually a sign of borked installation and needs to be resolved by the adminstrator. $ build/test-fs-util Path "/tmp/test-readlink_and_make_absolute" already exists and is not a directory, refusing. (or) Directory "/tmp/test-readlink_and_make_absolute" already exists, but has mode 0775 that is too permissive (0755 was requested), refusing. (or) Directory "/tmp/test-readlink_and_make_absolute" already exists, but is owned by 1001:1000 (1000:1000 was requested), refusing. Assertion 'mkdir_safe(tempdir, 0755, getuid(), getgid(), MKDIR_WARN_MODE) >= 0' failed at ../src/test/test-fs-util.c:320, function test_readlink_and_make_absolute(). Aborting. No functional change except for the new log lines.
* basic/mkdir: convert bool flag to enumZbigniew Jędrzejewski-Szmek2018-08-24
| | | | In preparation for subsequent changes...
* logind: drop obsolete commentLennart Poettering2018-08-24
| | | | | | The code matching this comment was removed in a50df72b37ce2a7caf7775c70d18c3f9504b9e80 in 2014, let's drop the comment too.
* logind: use manager_get_user_by_pid() where appropriateLennart Poettering2018-08-24
| | | | | The current code reimplemented something like the manager_get_user_by_pid() logic on its own, manually. Let's unify this.
* logind: rework manager_get_{user|session}_by_pid() a bitLennart Poettering2018-08-24
| | | | | | | | 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.
* macro: introduce new TAKE_FD() macroLennart Poettering2018-08-24
| | | | | | | This is similar to TAKE_PTR() but operates on file descriptors, and thus assigns -1 to the fd parameter after returning it. Removes 60 lines from our codebase. Pretty good too I think.
* macro: introduce TAKE_PTR() macroLennart Poettering2018-08-24
| | | | | | | | | | | | | | | | This macro will read a pointer of any type, return it, and set the pointer to NULL. This is useful as an explicit concept of passing ownership of a memory area between pointers. This takes inspiration from Rust: https://doc.rust-lang.org/std/option/enum.Option.html#method.take and was suggested by Alan Jenkins (@sourcejedi). It drops ~160 lines of code from our codebase, which makes me like it. Also, I think it clarifies passing of ownership, and thus helps readability a bit (at least for the initiated who know the new macro)
* Prep v238: fix forking of the poweroff programs in run_helper()Sven Eden2018-06-29
|
* Fix elogind debug mode:Sven Eden2018-06-29
| | | | | | | | | | | | | | When switched from autotools to meson, config.h changed fundamentally. Although enabled values are still #define HAVE_FOO 1 the disabled values are nolonger undef, but now #define HAVE_FOO 0 Therefore all instances of #ifdef ENABLE_DEBUG_ELOGIND have been changed to #if ENABLE_DEBUG_ELOGIND
* Prep v238: Disallow killing of lingering user processes even if forced.Sven Eden2018-06-29
|