summaryrefslogtreecommitdiff
path: root/src/login/logind-seat.c
Commit message (Collapse)AuthorAgeFilesLines
* sd-login: get rid of seat_can_multi_session()Zbigniew Jędrzejewski-Szmek2020-04-171-9/+1
| | | | | | | | | Follow-up for fa2cf64a917d31605d40d34e98ce9e2e066064fa. Backwards-compat is retained. A short note is added in docs, in case people see sd_seat_can_multi_session() mentioned somewhere and wonder what happened to it. Also see https://github.com/systemd/systemd/pull/15337#issuecomment-610369404.
* login: Fix incorrect reporting of CanMultiSession=no on non-seat0 seatsnerdopolis2020-04-101-1/+2
|
* logind: port to UserRecord objectLennart Poettering2020-01-151-4/+4
| | | | | | | This changes the user tracking of logind to use the new-style UserRecord object. In a later commit this enables us to do per-user resource management.
* tree-wide: drop string.h when string-util.h or friends are includedYu Watanabe2019-11-041-1/+0
|
* logind: don't claim we'd preallocate VTs when we shortcut itLennart Poettering2019-07-231-2/+2
|
* tree-wide: get rid of strappend()Lennart Poettering2019-07-121-1/+2
| | | | | It's a special case of strjoin(), so no need to keep both. In particular as typing strjoin() is even shoert than strappend().
* tree-wide: introduce strerror_safe()Yu Watanabe2019-07-051-1/+2
|
* logind: split out dbus header files into their ownLennart Poettering2019-05-241-0/+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.
* Make fopen_temporary and fopen_temporary_label unlockedZbigniew Jędrzejewski-Szmek2019-04-121-2/+0
| | | | | | | | This is partially a refactoring, but also makes many more places use unlocked operations implicitly, i.e. all users of fopen_temporary(). AFAICT, the uses are always for short-lived files which are not shared externally, and are just used within the same context. Locking is not necessary.
* headers: remove unneeded includes from util.hZbigniew Jędrzejewski-Szmek2019-03-271-0/+1
| | | | | This means we need to include many more headers in various files that simply included util.h before, but it seems cleaner to do it this way.
* logind: do not pass negative number to strerrorZbigniew Jędrzejewski-Szmek2019-01-101-1/+1
|
* util-lib: split out all temporary file related calls into tmpfiles-util.cLennart Poettering2018-12-021-0/+1
| | | | | | | | This splits out a bunch of functions from fileio.c that have to do with temporary files. Simply to make the header files a bit shorter, and to group things more nicely. No code changes, just some rearranging of source files.
* tree-wide: replace 'unsigned int' with 'unsigned'Yu Watanabe2018-10-191-9/+9
|
* logind: propagate session stop errorsLennart Poettering2018-10-131-2/+2
| | | | | | | | Let's propagate errors from stopping sessions via seat_stop(). This is similar to how we propagate such errors in user_stop() for all sessions associated with a user. Note that we propagate these errors, but we don't abort the function.
* logind: voidify a few callsLennart Poettering2018-10-131-2/+2
|
* logind: make better use of logging functionsLennart Poettering2018-10-131-6/+4
|
* logind: fix bad error propagationLennart Poettering2018-10-131-1/+1
|
* logind: rework Seat/Session/User object allocation and freeing a bitLennart Poettering2018-10-131-14/+24
| | | | | | | | | | | | Let's update things a bit to follow current practices: - User structure initialization rather than zero-initialized allocation - Always propagate proper errors from allocation functions - Use _cleanup_ for freeing objects when allocation fails half-way - Make destructors return NULL
* logind: make use of vtnr_from_tty() in seat_read_active_vt() (#9923)Franck Bui2018-08-241-13/+4
| | | No functional changes.
* logind: replace udev_device by sd_deviceYu Watanabe2018-08-231-2/+1
|
* 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.
* basic/log: add the log_struct terminator to macroZbigniew Jędrzejewski-Szmek2018-06-041-4/+2
| | | | | This way all callers do not need to specify it. Exhaustively tested by running test-log under valgrind ;)
* 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.
* Merge pull request #8552 from keszybz/test-improvementsLennart Poettering2018-03-231-1/+1
|\ | | | | Test and diagnostics improvements
| * tree-wide: warn when a directory path already exists but has bad mode/owner/typeZbigniew Jędrzejewski-Szmek2018-03-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-03-221-1/+1
| | | | | | | | In preparation for subsequent changes...
* | macro: introduce TAKE_PTR() macroLennart Poettering2018-03-221-2/+1
|/ | | | | | | | | | | | | | | | 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)
* logind: change check_gc to may_gc everywhereZbigniew Jędrzejewski-Szmek2018-02-151-4/+4
|
* tree-wide: use __fsetlocking() instead of fxyz_unlocked()Lennart Poettering2017-12-141-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | Let's replace usage of fputc_unlocked() and friends by __fsetlocking(f, FSETLOCKING_BYCALLER). This turns off locking for the entire FILE*, instead of doing individual per-call decision whether to use normal calls or _unlocked() calls. This has various benefits: 1. It's easier to read and easier not to forget 2. It's more comprehensive, as fprintf() and friends are covered too (as these functions have no _unlocked() counterpart) 3. Philosophically, it's a bit more correct, because it's more a property of the file handle really whether we ever pass it on to another thread, not of the operations we then apply to it. This patch reworks all pieces of codes that so far used fxyz_unlocked() calls to use __fsetlocking() instead. It also reworks all places that use open_memstream(), i.e. use stdio FILE* for string manipulations. Note that this in some way a revert of 4b61c8751135c58be043d86b9fef4c8ec7aadf18.
* 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.
* mkdir: introduce follow_symlink flag to mkdir_safe{,_label}()Yu Watanabe2017-10-061-1/+1
|
* tree-wide: use IN_SET macro (#6977)Yu Watanabe2017-10-041-2/+1
|
* tree-wide: fput[cs]() → fput[cs]_unlocked() wherever that makes sense (#6396)Lennart Poettering2017-07-211-2/+2
| | | | | | | | As a follow-up for db3f45e2d2586d78f942a43e661415bc50716d11 let's do the same for all other cases where we create a FILE* with local scope and know that no other threads hence can have access to it. For most cases this shouldn't change much really, but this should speed dbus introspection and calender time formatting up a bit.
* logind: check return value from lseekZbigniew Jędrzejewski-Szmek2017-02-201-5/+4
| | | | | | | In practice this doesn't matter much because the read that follows will likely fail, but we'll get a better error message. CID #1368233.
* tree-wide: add SD_ID128_MAKE_STR, remove LOG_MESSAGE_IDZbigniew Jędrzejewski-Szmek2017-02-151-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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/systemd{,-logind,-journald}{.old,} text data bss dec hex filename 1265204 149564 4808 1419576 15a938 .libs/systemd.old 1260268 149564 4808 1414640 1595f0 .libs/systemd 246805 13852 209 260866 3fb02 .libs/systemd-logind.old 240973 13852 209 255034 3e43a .libs/systemd-logind 146839 4984 34 151857 25131 .libs/systemd-journald.old 146391 4984 34 151409 24f71 .libs/systemd-journald It is also much easier to check if a certain binary uses a certain MESSAGE_ID: $ strings .libs/systemd.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/systemd|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
* logind: Don't try to emit a change signal for the 'Sessions' property (#5211)afrantzis2017-02-021-2/+0
| | | | | | | | The 'Sessions' property for both org.freedesktop.login1.User and org.freedesktop.login1.Seat is marked as EmitsChangedSignal(false). Trying to emit a change signal that includes the 'Sessions' property leads to the signal not being sent at all. Fixes #5210.
* Rename formats-util.h to format-util.hZbigniew Jędrzejewski-Szmek2016-11-071-1/+1
| | | | | | 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: use mfree moreZbigniew Jędrzejewski-Szmek2016-10-161-6/+3
|
* 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: use xsprintf() where applicableDaniel Mack2016-01-121-1/+2
| | | | Also add a coccinelle receipt to help with such transitions.
* util-lib: split out allocation calls into alloc-util.[ch]Lennart Poettering2015-10-271-0/+1
|
* util-lib: move more file I/O related calls into fileio.[ch]Lennart Poettering2015-10-271-0/+1
|
* util-lib: split string parsing related calls from util.[ch] into parse-util.[ch]Lennart Poettering2015-10-271-0/+1
|
* util-lib: split out fd-related operations into fd-util.[ch]Lennart Poettering2015-10-251-1/+2
| | | | | There are more than enough to deserve their own .c file, hence move them over.
* util-lib: split our string related calls from util.[ch] into its own file ↵Lennart Poettering2015-10-241-4/+6
| | | | | | | | | | | | | | string-util.[ch] There are more than enough calls doing string manipulations to deserve its own files, hence do something about it. This patch also sorts the #include blocks of all files that needed to be updated, according to the sorting suggestions from CODING_STYLE. Since pretty much every file needs our string manipulation functions this effectively means that most files have sorted #include blocks now. Also touches a few unrelated include files.
* tree-wide: port everything over to fflush_and_check()Lennart Poettering2015-07-291-10/+15
| | | | | | | | Some places invoked fflush() directly with their own manual error checking, let's unify all that by using fflush_and_check(). This also unifies the general error paths of fflush()+rename() file writers.
* logind: never select closing sessions for a VTDavid Herrmann2015-07-161-1/+1
| | | | | | | If a session is in closing state (and already got rid of its VT), then never re-select it for that VT. There is no reason why we should grant something to a session that is already going away *AND* already got rid of exactly that.
* logind: prefer new sessions over older ones on VT switchesDavid Herrmann2015-07-161-1/+1
| | | | | | | | | | | | | | | | | | Our seat->positions[] array keeps track of the 'preferred' session on a VT. The only situation this is used, is to select the session to activate when a VT is activated. In the normal case, there's only one session per VT so the selection is trivial. Older greeters, however, implement take-overs when they start sessions on the same VT that the greeter ran on. We recently limited such take-overs to VTs where a greeter is running on, to force people to never share VTs in new code that is written. For legacy reasons, we need to be compatible to old greeters, though. Hence, we allow those greeters to implement take-over. In such take-overs, however, we should really make sure that the new sessions gets preferred over the old one under all circumstances. Hence, make sure we override the previous preferred session with a new session.
* logind: rename 'pos' to 'position'David Herrmann2015-07-101-9/+9
| | | | | | | | Spell out the proper name. Use 'pos' over 'position', and also update the logind state file to do the same. Note that this breaks live updates. However, we only save 'POSITION' on non-seat0, so this shouldn't bother anyone for real. If you run multi-seat setups, you better restart a machine on updates, anyway.