1
0
mirror of https://github.com/systemd/systemd synced 2026-04-24 07:55:12 +02:00

Compare commits

...

6 Commits

Author SHA1 Message Date
Yu Watanabe
5674b74c4f hwdb: fix parsing options
Fixes #22976.
2022-04-06 04:03:32 +09:00
Lennart Poettering
80b7f7118e
Merge pull request #22975 from poettering/logind-longpress-followup
logind: "long press" follow-up
2022-04-05 18:42:17 +02:00
Yu Watanabe
58dd4999dc core: command argument can be longer than PATH_MAX
Fixes a bug introduced by 065364920281e1cf59cab989e17aff21790505c4.

Fixes #22957.
2022-04-06 00:39:06 +09:00
Lennart Poettering
30e0343b1c man: split an overly long paragraph in two 2022-04-05 16:10:26 +02:00
Lennart Poettering
acc63800bc logind: also show long press settings in default logind.conf
The configuration options where added back in
a520bb665417af7aa98dcb983f3583659bbab807 but this was never actually
added to the default logind.conf.

Follow-up-for: a520bb665417af7aa98dcb983f3583659bbab807
Follow-up-for: #19917
2022-04-05 16:10:21 +02:00
Lennart Poettering
c4db78fce6 logind: expose long press actions on D-Bus
The settings and internal varables were added, but this was never
exposed on the bus. Add that.

Follow-up-for: a520bb665417af7aa98dcb983f3583659bbab807
Follow-up-for: #19917
2022-04-05 16:09:52 +02:00
7 changed files with 86 additions and 45 deletions

View File

@ -205,47 +205,34 @@
<term><varname>HandleLidSwitchExternalPower=</varname></term>
<term><varname>HandleLidSwitchDocked=</varname></term>
<listitem><para>Controls how logind shall handle the
system power, reboot and sleep keys and the lid switch to trigger
actions such as system power-off, reboot or suspend. Can be one of
<literal>ignore</literal>,
<literal>poweroff</literal>,
<literal>reboot</literal>,
<literal>halt</literal>,
<literal>kexec</literal>,
<literal>suspend</literal>,
<literal>hibernate</literal>,
<literal>hybrid-sleep</literal>,
<literal>suspend-then-hibernate</literal>,
<literal>lock</literal>, and
<literal>factory-reset</literal>.
If <literal>ignore</literal>, logind will never handle these
keys. If <literal>lock</literal>, all running sessions will be
screen-locked; otherwise, the specified action will be taken
in the respective event. Only input devices with the
<literal>power-switch</literal> udev tag will be watched for
key/lid switch events. <varname>HandlePowerKey=</varname>
defaults to <literal>poweroff</literal>, <varname>HandleRebootKey=</varname>
defaults to <literal>reboot</literal>, <varname>HandleSuspendKey=</varname>
defaults to <literal>suspend</literal>, <varname>HandleHibernateKey=</varname>
defaults to <literal>hibernate</literal>, <varname>HandlePowerKeyLongPress=</varname>
defaults to <literal>ignore</literal>, <varname>HandleRebootKeyLongPress=</varname>
defaults to <literal>poweroff</literal>, <varname>HandleSuspendKeyLongPress=</varname>
defaults to <literal>hibernate</literal>, <varname>HandleHibernateKeyLongPress=</varname>
defaults to <literal>ignore</literal>.
<varname>HandleLidSwitch=</varname> defaults to
<literal>suspend</literal>.
<varname>HandleLidSwitchExternalPower=</varname> is completely
ignored by default (for backwards compatibility) — an explicit
value must be set before it will be used to determine
behaviour. <varname>HandleLidSwitchDocked=</varname> defaults
to <literal>ignore</literal>. If the system is inserted in a
docking station, or if more than one display is connected, the
action specified by <varname>HandleLidSwitchDocked=</varname>
occurs; if the system is on external power the action (if any)
specified by <varname>HandleLidSwitchExternalPower=</varname>
occurs; otherwise the <varname>HandleLidSwitch=</varname>
action occurs.</para>
<listitem><para>Controls how logind shall handle the system power, reboot and sleep keys and the lid
switch to trigger actions such as system power-off, reboot or suspend. Can be one of
<literal>ignore</literal>, <literal>poweroff</literal>, <literal>reboot</literal>,
<literal>halt</literal>, <literal>kexec</literal>, <literal>suspend</literal>,
<literal>hibernate</literal>, <literal>hybrid-sleep</literal>,
<literal>suspend-then-hibernate</literal>, <literal>lock</literal>, and
<literal>factory-reset</literal>. If <literal>ignore</literal>, <command>systemd-logind</command>
will never handle these keys. If <literal>lock</literal>, all running sessions will be screen-locked;
otherwise, the specified action will be taken in the respective event. Only input devices with the
<literal>power-switch</literal> udev tag will be watched for key/lid switch
events.</para>
<para><varname>HandlePowerKey=</varname> defaults to <literal>poweroff</literal>,
<varname>HandleRebootKey=</varname> defaults to <literal>reboot</literal>,
<varname>HandleSuspendKey=</varname> defaults to <literal>suspend</literal>,
<varname>HandleHibernateKey=</varname> defaults to <literal>hibernate</literal>,
<varname>HandlePowerKeyLongPress=</varname> defaults to <literal>ignore</literal>,
<varname>HandleRebootKeyLongPress=</varname> defaults to <literal>poweroff</literal>,
<varname>HandleSuspendKeyLongPress=</varname> defaults to <literal>hibernate</literal>,
<varname>HandleHibernateKeyLongPress=</varname> defaults to <literal>ignore</literal>.
<varname>HandleLidSwitch=</varname> defaults to <literal>suspend</literal>.
<varname>HandleLidSwitchExternalPower=</varname> is completely ignored by default (for backwards
compatibility) — an explicit value must be set before it will be used to determine
behaviour. <varname>HandleLidSwitchDocked=</varname> defaults to <literal>ignore</literal>. If the
system is inserted in a docking station, or if more than one display is connected, the action
specified by <varname>HandleLidSwitchDocked=</varname> occurs; if the system is on external power the
action (if any) specified by <varname>HandleLidSwitchExternalPower=</varname> occurs; otherwise the
<varname>HandleLidSwitch=</varname> action occurs.</para>
<para>A different application may disable logind's handling of system power and
sleep keys and the lid switch by taking a low-level inhibitor lock

View File

@ -194,10 +194,20 @@ node /org/freedesktop/login1 {
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly s HandlePowerKey = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly s HandlePowerKeyLongPress = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly s HandleRebootKey = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly s HandleRebootKeyLongPress = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly s HandleSuspendKey = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly s HandleSuspendKeyLongPress = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly s HandleHibernateKey = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly s HandleHibernateKeyLongPress = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly s HandleLidSwitch = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly s HandleLidSwitchExternalPower = '...';
@ -242,6 +252,16 @@ node /org/freedesktop/login1 {
};
</programlisting>
<!--property HandlePowerKeyLongPress is not documented!-->
<!--property HandleRebootKey is not documented!-->
<!--property HandleRebootKeyLongPress is not documented!-->
<!--property HandleSuspendKeyLongPress is not documented!-->
<!--property HandleHibernateKeyLongPress is not documented!-->
<!--Autogenerated cross-references for systemd.directives, do not edit-->
<variablelist class="dbus-interface" generated="True" extra-ref="org.freedesktop.login1.Manager"/>
@ -418,10 +438,20 @@ node /org/freedesktop/login1 {
<variablelist class="dbus-property" generated="True" extra-ref="HandlePowerKey"/>
<variablelist class="dbus-property" generated="True" extra-ref="HandlePowerKeyLongPress"/>
<variablelist class="dbus-property" generated="True" extra-ref="HandleRebootKey"/>
<variablelist class="dbus-property" generated="True" extra-ref="HandleRebootKeyLongPress"/>
<variablelist class="dbus-property" generated="True" extra-ref="HandleSuspendKey"/>
<variablelist class="dbus-property" generated="True" extra-ref="HandleSuspendKeyLongPress"/>
<variablelist class="dbus-property" generated="True" extra-ref="HandleHibernateKey"/>
<variablelist class="dbus-property" generated="True" extra-ref="HandleHibernateKeyLongPress"/>
<variablelist class="dbus-property" generated="True" extra-ref="HandleLidSwitch"/>
<variablelist class="dbus-property" generated="True" extra-ref="HandleLidSwitchExternalPower"/>

View File

@ -1000,7 +1000,7 @@ int config_parse_exec(
if (r < 0)
return ignore ? 0 : -ENOEXEC;
r = unit_path_printf(u, word, &resolved);
r = unit_full_printf(u, word, &resolved);
if (r < 0) {
log_syntax(unit, ignore ? LOG_WARNING : LOG_ERR, filename, line, r,
"Failed to resolve unit specifiers in %s%s: %m",

View File

@ -73,7 +73,7 @@ static int parse_argv(int argc, char *argv[]) {
assert(argc >= 0);
assert(argv);
while ((c = getopt_long(argc, argv, "ust:r:h", options, NULL)) >= 0)
while ((c = getopt_long(argc, argv, "sr:h", options, NULL)) >= 0)
switch (c) {
case 'h':

View File

@ -3378,8 +3378,13 @@ static const sd_bus_vtable manager_vtable[] = {
SD_BUS_PROPERTY("InhibitDelayMaxUSec", "t", NULL, offsetof(Manager, inhibit_delay_max), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("UserStopDelayUSec", "t", NULL, offsetof(Manager, user_stop_delay), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("HandlePowerKey", "s", property_get_handle_action, offsetof(Manager, handle_power_key), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("HandlePowerKeyLongPress", "s", property_get_handle_action, offsetof(Manager, handle_power_key_long_press), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("HandleRebootKey", "s", property_get_handle_action, offsetof(Manager, handle_reboot_key), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("HandleRebootKeyLongPress", "s", property_get_handle_action, offsetof(Manager, handle_reboot_key_long_press), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("HandleSuspendKey", "s", property_get_handle_action, offsetof(Manager, handle_suspend_key), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("HandleSuspendKeyLongPress", "s", property_get_handle_action, offsetof(Manager, handle_suspend_key_long_press), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("HandleHibernateKey", "s", property_get_handle_action, offsetof(Manager, handle_hibernate_key), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("HandleHibernateKeyLongPress", "s", property_get_handle_action, offsetof(Manager, handle_hibernate_key_long_press), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("HandleLidSwitch", "s", property_get_handle_action, offsetof(Manager, handle_lid_switch), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("HandleLidSwitchExternalPower", "s", property_get_handle_action, offsetof(Manager, handle_lid_switch_ep), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("HandleLidSwitchDocked", "s", property_get_handle_action, offsetof(Manager, handle_lid_switch_docked), SD_BUS_VTABLE_PROPERTY_CONST),

View File

@ -23,13 +23,16 @@
#InhibitDelayMaxSec=5
#UserStopDelaySec=10
#HandlePowerKey=poweroff
#HandlePowerKeyLongPress=ignore
#HandleRebootKey=reboot
#HandleRebootKeyLongPress=poweroff
#HandleSuspendKey=suspend
#HandleSuspendKeyLongPress=hibernate
#HandleHibernateKey=hibernate
#HandleHibernateKeyLongPress=ignore
#HandleLidSwitch=suspend
#HandleLidSwitchExternalPower=suspend
#HandleLidSwitchDocked=ignore
#HandleRebootKey=reboot
#HandleRebootKeyLongPress=poweroff
#PowerKeyIgnoreInhibited=no
#SuspendKeyIgnoreInhibited=no
#HibernateKeyIgnoreInhibited=no

View File

@ -10,6 +10,7 @@
#include "capability-util.h"
#include "conf-parser.h"
#include "fd-util.h"
#include "fileio.h"
#include "format-util.h"
#include "fs-util.h"
#include "hashmap.h"
@ -416,6 +417,21 @@ TEST(config_parse_exec) {
assert_se(r == 0);
assert_se(c1->command_next == NULL);
log_info("/* long arg */"); /* See issue #22957. */
char x[LONG_LINE_MAX-100], *y;
y = mempcpy(x, "/bin/echo ", STRLEN("/bin/echo "));
memset(y, 'x', sizeof(x) - STRLEN("/bin/echo ") - 1);
x[sizeof(x) - 1] = '\0';
r = config_parse_exec(NULL, "fake", 5, "section", 1,
"LValue", 0, x,
&c, u);
assert_se(r >= 0);
c1 = c1->command_next;
check_execcommand(c1,
"/bin/echo", NULL, y, NULL, false);
log_info("/* empty argument, reset */");
r = config_parse_exec(NULL, "fake", 4, "section", 1,
"LValue", 0, "",