Commit graph

1231 commits

Author SHA1 Message Date
Lennart Poettering b910cc72c0 tree-wide: get rid of strappend()
It's a special case of strjoin(), so no need to keep both. In particular
as typing strjoin() is even shoert than strappend().
2019-07-12 14:31:12 +09:00
Lennart Poettering 66855de739 tree-wide: make use of errno_or_else() everywhere 2019-07-11 23:20:31 +02:00
Lennart Poettering ba40f0399e
Merge pull request #12939 from yuwata/lgtm-fixes
make LGTM quiet
2019-07-10 14:57:14 +02:00
Lennart Poettering 1ccbb359a1 login: move file definitions outside of the conditionalization 2019-07-05 17:55:49 +02:00
Yu Watanabe 4bbccb02ea tree-wide: introduce strerror_safe() 2019-07-05 02:43:56 +09:00
Lennart Poettering 54130b3622 logind: drop old-style header from .sym file in favour of SPDX 2019-07-04 12:35:14 +09:00
Zbigniew Jędrzejewski-Szmek b81b40d4c4 logind: log operation details when starting actions
For some reason, systemd-logind is trying to handle idle action in one of my containers:

Jun 07 10:28:08 rawhide systemd-logind[42]: System idle. Taking action.
Jun 07 10:28:08 rawhide systemd-logind[42]: Requested operation not supported, ignoring.

But we didn't log what exactly was being done. Let's put the name of the action in messages.
2019-06-24 17:26:13 +02:00
Zbigniew Jędrzejewski-Szmek f2330acda4 logind: remove unused check
All callers pass either a fixed action, or HANDLE_IGNORE is explicitly filtered
out. Let's remove this case here, because we cannot properly log what opreation
we are ignoring.
2019-06-24 17:26:13 +02:00
Zbigniew Jędrzejewski-Szmek 58cf79c224
Merge pull request #12424 from poettering/logind-brightness
logind: add SetBrightness() bus call as minimal API for setting "leds" and "backlight" kernel class device brightness
2019-06-12 14:28:09 +02:00
Philip Withnall de5e9096e2 pam_systemd: Fix some option names in error messages
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-06-12 10:39:50 +01:00
Lennart Poettering 6ecda0fbef logind: split out dbus header files into their own
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.
2019-05-24 15:05:27 +02:00
Lennart Poettering 77c45ce336 logind: convert ENXIO into 0, to signal 'not found' cleanly 2019-05-24 15:05:27 +02:00
Lennart Poettering ed179418ae logind: support self/auto seats for AttachDevice(), too 2019-05-24 15:05:27 +02:00
Lennart Poettering bda0613072 logind: validate /sys fs path a bit more strictly 2019-05-24 15:05:27 +02:00
Lennart Poettering b0bd159f67 logind: prefer hashmap_contains() over hashmap_get() 2019-05-24 15:05:27 +02:00
Lennart Poettering 544c4e1eda loginctl: drop $XDG_SESSION_ID env var magic
The server side can do something similar, but better on its own, let's
hence rely on that.
2019-05-24 15:05:27 +02:00
Lennart Poettering 3b92c086a8 logind: make "self" and "auto" magic strings when operating on seats + sessions
Most of the operations one can do on sessions so far accepted an empty
session name as a shortcut for the caller's session. This is quite
useful traditionally, but much less useful than it used to be, since
most user code now (rightfully) runs in --user context, not in a
session.

With this change we tweak the logic a bit: we introduce the two special
session and seat names "self" and "auto". The former refers to the
session/seat the client is in, and is hence mostly equivalent to te
empty string "" as before. However, the latter refers to the
session/seat the client is in if that exists, with a fallback of the
user's display session if not. Clients can hence reference "auto"
instead of the empty string if they really don't want to think much
about sessions.

Why "self" btw? Previously, we'd already expose a special dbus object
with the path /org/freedesktop/login1/session/self (and similar for the
seat), matching what the empty string did for bus calls that took a
session name. With this scheme we reuse this identifier and introduce
"auto" in a similar way.

Of course this means real-life seats and sessions can never be named
"self" or "auto", but they aren't anyway: valid seat names have to start
with "seat" anyway, and sessions are generated server-side as either a
numeric value or "c" suffixed with a counter ID.

Fixes: #12399
2019-05-24 15:05:27 +02:00
Lennart Poettering 469df514c7 logind: make a constant array static 2019-05-24 15:05:27 +02:00
Lennart Poettering a2dcb1d787 logind: consider "greeter" sessions suitable as "display" sessions of a user
Interestingly, elect_display_compare() already ordered "user" sessions
before "greeter" sessions, though nothing other than "user" sessions
where ever considered anyway.

Fixes: #12399
2019-05-24 15:05:27 +02:00
Lennart Poettering 2a66c2a1ed logind: add SetBrightness() bus call for setting brightness of leds/backlight devices associated with a seat
This augments the drm/input device management by adding a single method
call for setting the brightness of an "leds" or "backlight" kernel class
device.

This method call requires no privileges to call, but a caller can only
change the brightness on sessions that are currently active, and they
must own the session.

This does not do enumeration of such class devices, feature or range
probing, chnage notification; it doesn't help associating graphics or
input devices with their backlight or leds devices. For all that clients
should go directly to udev/sysfs. The SetBrightness() call is just for
executing the actual change operation, that is otherwise privileged.

Example line:

   busctl call org.freedesktop.login1 /org/freedesktop/login1/session/self org.freedesktop.login1.Session SetBrightness ssu "backlight" "intel_backlight" 200

The parameter the SetBrightness() call takes are the kernel subsystem
(i.e. "leds" or "backlight"), the device name, and the brightness
value.

On some hw setting the brightness is slow, and implementation and write
access to the sysfs knobs exposes this slowness. Due to this we'll fork
off a writer process in the background so that logind doesn't have to
block. Moreover, write requestes are coalesced: when a write request is
enqueued while one is already being executed it is queued. When another
write reques is then enqueued the earlier one is replaced by the newer
one, so that only one queued write request per device remains at any
time. Method replies are sent as soon as the first write request that
happens after the request was received is completed.

It is recommended that bus clients turn off the "expect_reply" flag on
the dbus messages they send though, that relieves logind from sending
completion notification and is particularly a good idea if clients
implement reactive UI sliders that send a quick secession of write
requests.

Replaces: #12413
2019-05-24 15:05:27 +02:00
Lennart Poettering e83b8b6bc2 logind: small simplification 2019-05-24 15:05:27 +02:00
Lennart Poettering 3841f57b87 udev: tag "leds" and "backlight" devices for association to a seat
These devices do not become user-accessible this way, but they are
logically assigned to a seat, which makes a lot of sense, since they are
human-facing output devices, and such should belong to one.
2019-05-24 15:05:27 +02:00
root 12e982425c login: fixup button_open() fd 2019-05-23 11:16:11 +09:00
Zbigniew Jędrzejewski-Szmek 92c605796d login: use _cleanup_ to simplify error handling
When logging about a device, try to include the path to it everywhere in
messages. Also fixes an invalid assert(fd).

Inspired by b2774a3ae6.
2019-05-22 15:17:24 +02:00
ven b2774a3ae6 bus_open leak sd_event_source when udevadm trigger。
On my host, when executing the udevadm trigger, I only receive the change event, which causes memleak
2019-05-22 10:44:34 +02:00
Lennart Poettering e95be7def2
Merge pull request #12411 from keszybz/pr/12394
run: when emitting the calendarspec warning, use red
2019-05-08 10:11:32 -04:00
Lennart Poettering 324d9acab7 machinectl/loginctl: show json output if requested even if zero entries 2019-05-08 06:33:36 -04:00
Zbigniew Jędrzejewski-Szmek 1a04395959 Enable log colors for most of tools in /usr/bin
When emitting the calendarspec warning we want to see some color.
Follow-up for 04220fda5c.

Exceptions:
- systemctl, because it has a lot hand-crafted coloring
- tmpfiles, sysusers, stdio-bridge, etc, because they are also used in
  services and I'm not sure if this wouldn't mess up something.
2019-05-08 09:50:21 +02:00
Lennart Poettering 0892f3f999
Merge pull request #12420 from mrc0mmand/coccinelle-tweaks
Coccinelle improvements
2019-04-30 11:37:19 +02:00
Frantisek Sumsal ed0cb34682 tree-wide: code improvements suggested by Coccinelle 2019-04-30 09:39:07 +02:00
Ben Boeckel 5238e95759 codespell: fix spelling errors 2019-04-29 16:47:18 +02:00
Zbigniew Jędrzejewski-Szmek 41f6e627d7 Make fopen_temporary and fopen_temporary_label unlocked
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.
2019-04-12 11:44:56 +02:00
Lennart Poettering b473691d41 inhibit: fix argv[] usage
Another fix in style of ed179fd710 and
bd169c2be0fbdaf6eb2ea7951e650d5e5983fbf6..

I hope we are soon complete with these.

Fixes: #12246
2019-04-08 16:57:39 +02:00
Lennart Poettering ea505047c5
Merge pull request #12238 from keszybz/one-genuine-bugfix+lots-of-line-wrapping
One genuine bugfix and lots of line wrapping
2019-04-08 11:19:34 +02:00
Lennart Poettering 83d4ab5533 pam-systemd: use secure_getenv() rather than getenv()
And explain why in a comment.
2019-04-08 10:24:03 +02:00
Zbigniew Jędrzejewski-Szmek 124d7cb2a0 logind: linewrap some long lines and remove unnecessary conditional 2019-04-07 21:48:54 +02:00
Zbigniew Jędrzejewski-Szmek 84ce204a93
Merge pull request #12185 from poettering/login-unstore-fd
logind: remove unused fds from fdstore
2019-04-02 14:27:27 +02:00
Lennart Poettering f71611fed2 test: stop using dup() needlessly 2019-04-02 12:45:46 +02:00
Lennart Poettering efc19ee485 logind: when we cannot attach a passed fd to a device, close it
Replaces: #8532
2019-04-02 11:52:58 +02:00
Lennart Poettering 883d1b01b0 logind: simplify removal of device fds
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.
2019-04-02 11:51:50 +02:00
Lennart Poettering 6990fb6bc6 tree-wide: (void)ify a few unlink() and rmdir()
Let's be helpful to static analyzers which care about whether we
knowingly ignore return values. We do in these cases, since they are
usually part of error paths.
2019-03-27 18:09:56 +01:00
Zbigniew Jędrzejewski-Szmek 6e5dcce4b1 Voidify more mkdir_p calls 2019-03-27 11:53:12 +01:00
Zbigniew Jędrzejewski-Szmek ca78ad1de9 headers: remove unneeded includes from util.h
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.
2019-03-27 11:53:12 +01:00
Zbigniew Jędrzejewski-Szmek 83eee14f46 logind: reword the polkit prompt for reboot parameter
Let's opt for the simplest description possible so that users actually
understand what we have in mind.
2019-03-26 08:52:18 +01:00
Vesa Jääskeläinen 428b296a59 logind: Add support for RebootParameter
This adds support for user to set & get reboot parameter for reboot.

As callee would be next issuing Reboot call same policy checks are being used.

If unit file issuing the reboot action defines RebootArgument (or similar) that
setting takes precedence.
2019-03-22 20:30:33 +02:00
Vesa Jääskeläinen ce7f10707d logind: relocate function return_test_polkit()
Relocate function return_test_polkit() upper in file for easier access from other functions.
2019-03-22 17:38:54 +02:00
Topi Miettinen ebcf697685 tree-wide: fix false search hits with ppp (typos) 2019-03-18 14:25:56 +01:00
Lennart Poettering 47094ce067 util: move dbus specific definition into bus-internal.h
It shouldn't be defined globally, since it's pretty much an
implementation detail of DBus.
2019-03-14 13:25:51 +01:00
Lennart Poettering ecd5f1a9e0 util: move display_is_local() to pam_systemd.c, its only user
It's quite specific anyway, hence let's move this where it's used
2019-03-14 13:25:51 +01:00
Zbigniew Jędrzejewski-Szmek 94dfd646b3
Merge pull request #11985 from poettering/clean-dir
some rafactoring in systemctl/bus-unit-util
2019-03-14 12:21:53 +01:00