[systemd-commits] 8 commits - TODO man/systemd.unit.xml src/ac-power src/analyze src/core src/hostname src/locale src/login src/shared src/timedate units/systemd-hostnamed.service.in

Lennart Poettering lennart at kemper.freedesktop.org
Mon Dec 31 12:24:37 PST 2012


 TODO                                             |   10 --
 man/systemd.unit.xml                             |   18 +++++
 src/ac-power/ac-power.c                          |   80 -----------------------
 src/analyze/systemd-analyze                      |   71 ++++++++++++--------
 src/core/condition.c                             |   14 ++++
 src/core/condition.h                             |    1 
 src/core/load-fragment-gperf.gperf.m4            |    1 
 src/hostname/org.freedesktop.hostname1.policy.in |    1 
 src/locale/org.freedesktop.locale1.policy.in     |    1 
 src/login/org.freedesktop.login1.policy.in       |   14 ++++
 src/shared/macro.h                               |   21 ++++--
 src/shared/util.c                                |   78 ++++++++++++++++++++++
 src/shared/util.h                                |    2 
 src/timedate/org.freedesktop.timedate1.policy.in |    1 
 units/systemd-hostnamed.service.in               |    2 
 15 files changed, 195 insertions(+), 120 deletions(-)

New commits:
commit 9b41366baeb02b0e732f22f8b5d42a25ae569e20
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Dec 31 21:24:05 2012 +0100

    TODO

diff --git a/TODO b/TODO
index aa9292e..6cc673e 100644
--- a/TODO
+++ b/TODO
@@ -19,6 +19,8 @@ F18:
 
 Features:
 
+* drop the TARGET_xxx stuff as far as possible
+
 * logind: optionally, ignore idle-hint logic for autosuspend, block suspend as long as a session is around
 
 * service: when killing a service with SIGKILL always kill all processes, even if for SIGTERM we only killed the main process

commit 240dbaa44f8e5ad51775c776fc3ce9cd2f19f037
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Dec 25 16:29:51 2012 +0100

    unit: add ConditionACPower=

diff --git a/TODO b/TODO
index 3ec87c5..aa9292e 100644
--- a/TODO
+++ b/TODO
@@ -57,8 +57,6 @@ Features:
 
 * When shutdown.target is queued begin with an asynchronous sync()?
 
-* Add ConditionBatteryPower= or ConditionACPower=? (but definitely not both)
-
 * add API to close/reopen/get fd for journal client fd in libsystemd-journal.
 
 * maybe add API to send pairs of iovecs via sd_journal_send
@@ -240,8 +238,6 @@ Features:
 
 * system-wide seccomp filter
 
-* ability to pass fds into systemd
-
 * system.conf should have controls for cgroups
 
 * bind mount read-only the cgroup tree higher than nspawn
diff --git a/man/systemd.unit.xml b/man/systemd.unit.xml
index bf91b4e..8570815 100644
--- a/man/systemd.unit.xml
+++ b/man/systemd.unit.xml
@@ -790,6 +790,7 @@
                                 <term><varname>ConditionSecurity=</varname></term>
                                 <term><varname>ConditionCapability=</varname></term>
                                 <term><varname>ConditionHost=</varname></term>
+                                <term><varname>ConditionACPower=</varname></term>
                                 <term><varname>ConditionNull=</varname></term>
 
                                 <listitem><para>Before starting a unit
@@ -959,6 +960,23 @@
                                 The test may be negated by prepending
                                 an exclamation mark.</para>
 
+                                <para><varname>ConditionACPower=</varname>
+                                may may be used to check whether the
+                                system has AC power, or is exlcusively
+                                battery powered at the time of
+                                activation of the unit. This takes a
+                                boolean argument. If set to
+                                <varname>true</varname> the condition
+                                will hold only if at least one AC
+                                connector of the system is connected
+                                to a power source, or if no AC
+                                connectors are known. Conversely, if
+                                set to <varname>false</varname> the
+                                condition will hold only if there is
+                                at least one AC connector known and
+                                all AC connectors are disconnected
+                                from a power source.</para>
+
                                 <para>Finally,
                                 <varname>ConditionNull=</varname> may
                                 be used to add a constant condition
diff --git a/src/ac-power/ac-power.c b/src/ac-power/ac-power.c
index 37313cf..bd1b6ec 100644
--- a/src/ac-power/ac-power.c
+++ b/src/ac-power/ac-power.c
@@ -19,93 +19,19 @@
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
-#include <stdlib.h>
-#include <stdbool.h>
-#include <errno.h>
-#include <string.h>
-#include <libudev.h>
-
 #include "util.h"
 
-static int on_ac_power(void) {
-        int r;
-
-        struct udev *udev;
-        struct udev_enumerate *e = NULL;
-        struct udev_list_entry *item = NULL, *first = NULL;
-        bool found_offline = false, found_online = false;
-
-        if (!(udev = udev_new())) {
-                r = -ENOMEM;
-                goto finish;
-        }
-
-        if (!(e = udev_enumerate_new(udev))) {
-                r = -ENOMEM;
-                goto finish;
-        }
-
-        if (udev_enumerate_add_match_subsystem(e, "power_supply") < 0) {
-                r = -EIO;
-                goto finish;
-        }
-
-        if (udev_enumerate_scan_devices(e) < 0) {
-                r = -EIO;
-                goto finish;
-        }
-
-        first = udev_enumerate_get_list_entry(e);
-        udev_list_entry_foreach(item, first) {
-                struct udev_device *d;
-                const char *type, *online;
-
-                if (!(d = udev_device_new_from_syspath(udev, udev_list_entry_get_name(item)))) {
-                        r = -ENOMEM;
-                        goto finish;
-                }
-
-                if (!(type = udev_device_get_sysattr_value(d, "type")))
-                        goto next;
-
-                if (!streq(type, "Mains"))
-                        goto next;
-
-                if (!(online = udev_device_get_sysattr_value(d, "online")))
-                        goto next;
-
-                if (streq(online, "1")) {
-                        found_online = true;
-                        break;
-                } else if (streq(online, "0"))
-                        found_offline = true;
-
-        next:
-                udev_device_unref(d);
-        }
-
-        r = found_online || !found_offline;
-
-finish:
-        if (e)
-                udev_enumerate_unref(e);
-
-        if (udev)
-                udev_unref(udev);
-
-        return r;
-}
-
 int main(int argc, char *argv[]) {
         int r;
 
         /* This is mostly intended to be used for scripts which want
          * to detect whether AC power is plugged in or not. */
 
-        if ((r = on_ac_power()) < 0) {
+        r = on_ac_power();
+        if (r < 0) {
                 log_error("Failed to read AC status: %s", strerror(-r));
                 return EXIT_FAILURE;
         }
 
-        return r == 0;
+        return r != 0 ? EXIT_SUCCESS : EXIT_FAILURE;
 }
diff --git a/src/core/condition.c b/src/core/condition.c
index 32a37cc..b318492 100644
--- a/src/core/condition.c
+++ b/src/core/condition.c
@@ -221,6 +221,16 @@ static bool test_host(const char *parameter) {
         return b;
 }
 
+static bool test_ac_power(const char *parameter) {
+        int r;
+
+        r = parse_boolean(parameter);
+        if (r < 0)
+                return true;
+
+        return (on_ac_power() != 0) == !!r;
+}
+
 bool condition_test(Condition *c) {
         assert(c);
 
@@ -294,6 +304,9 @@ bool condition_test(Condition *c) {
         case CONDITION_HOST:
                 return test_host(c->parameter) == !c->negate;
 
+        case CONDITION_AC_POWER:
+                return test_ac_power(c->parameter) == !c->negate;
+
         case CONDITION_NULL:
                 return !c->negate;
 
@@ -364,6 +377,7 @@ static const char* const condition_type_table[_CONDITION_TYPE_MAX] = {
         [CONDITION_VIRTUALIZATION] = "ConditionVirtualization",
         [CONDITION_SECURITY] = "ConditionSecurity",
         [CONDITION_HOST] = "ConditionHost",
+        [CONDITION_AC_POWER] = "ConditionACPower",
         [CONDITION_NULL] = "ConditionNull"
 };
 
diff --git a/src/core/condition.h b/src/core/condition.h
index 03954e4..1797385 100644
--- a/src/core/condition.h
+++ b/src/core/condition.h
@@ -40,6 +40,7 @@ typedef enum ConditionType {
         CONDITION_SECURITY,
         CONDITION_CAPABILITY,
         CONDITION_HOST,
+        CONDITION_AC_POWER,
         CONDITION_NULL,
         _CONDITION_TYPE_MAX,
         _CONDITION_TYPE_INVALID = -1
diff --git a/src/core/load-fragment-gperf.gperf.m4 b/src/core/load-fragment-gperf.gperf.m4
index 7212053..7fba0cf 100644
--- a/src/core/load-fragment-gperf.gperf.m4
+++ b/src/core/load-fragment-gperf.gperf.m4
@@ -137,6 +137,7 @@ Unit.ConditionVirtualization,    config_parse_unit_condition_string, CONDITION_V
 Unit.ConditionSecurity,          config_parse_unit_condition_string, CONDITION_SECURITY,            0
 Unit.ConditionCapability,        config_parse_unit_condition_string, CONDITION_CAPABILITY,          0
 Unit.ConditionHost,              config_parse_unit_condition_string, CONDITION_HOST,                0
+Unit.ConditionACPower,           config_parse_unit_condition_string, CONDITION_AC_POWER,            0
 Unit.ConditionNull,              config_parse_unit_condition_null,   0,                             0
 m4_dnl
 Service.PIDFile,                 config_parse_unit_path_printf,      0,                             offsetof(Service, pid_file)
diff --git a/src/shared/util.c b/src/shared/util.c
index 1779625..3f00db7 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -5763,3 +5763,81 @@ char *strip_tab_ansi(char **ibuf, size_t *_isz) {
 
         return obuf;
 }
+
+int on_ac_power(void) {
+        bool found_offline = false, found_online = false;
+        _cleanup_closedir_ DIR *d = NULL;
+
+        d = opendir("/sys/class/power_supply");
+        if (!d)
+                return -errno;
+
+        for (;;) {
+                struct dirent *de;
+                union dirent_storage buf;
+                _cleanup_free_ char *p = NULL;
+                _cleanup_close_ int fd = -1, device = -1;
+                char contents[6];
+                ssize_t n;
+                int k;
+
+                k = readdir_r(d, &buf.de, &de);
+                if (k != 0)
+                        return -k;
+
+                if (!de)
+                        break;
+
+                if (ignore_file(de->d_name))
+                        continue;
+
+                device = openat(dirfd(d), de->d_name, O_DIRECTORY|O_RDONLY|O_CLOEXEC|O_NOCTTY);
+                if (device < 0) {
+                        if (errno == ENOENT || errno == ENOTDIR)
+                                continue;
+
+                        return -errno;
+                }
+
+                fd = openat(device, "type", O_RDONLY|O_CLOEXEC|O_NOCTTY);
+                if (fd < 0) {
+                        if (errno == ENOENT)
+                                continue;
+
+                        return -errno;
+                }
+
+                n = read(fd, contents, sizeof(contents));
+                if (n < 0)
+                        return -errno;
+
+                if (n != 6 || memcmp(contents, "Mains\n", 6))
+                        continue;
+
+                close_nointr_nofail(fd);
+                fd = openat(device, "online", O_RDONLY|O_CLOEXEC|O_NOCTTY);
+                if (fd < 0) {
+                        if (errno == ENOENT)
+                                continue;
+
+                        return -errno;
+                }
+
+                n = read(fd, contents, sizeof(contents));
+                if (n < 0)
+                        return -errno;
+
+                if (n != 2 || contents[1] != '\n')
+                        return -EIO;
+
+                if (contents[0] == '1') {
+                        found_online = true;
+                        break;
+                } else if (contents[0] == '0')
+                        found_offline = true;
+                else
+                        return -EIO;
+        }
+
+        return found_online || !found_offline;
+}
diff --git a/src/shared/util.h b/src/shared/util.h
index 25b349a..bb6602f 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -561,3 +561,5 @@ const char *draw_special_char(DrawSpecialChar ch);
 char *strreplace(const char *text, const char *old_string, const char *new_string);
 
 char *strip_tab_ansi(char **p, size_t *l);
+
+int on_ac_power(void);

commit 3ec90c030081111900597ec5475d880893f10a76
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Dec 25 12:58:54 2012 +0100

    analyze: properly parse firmware/loader time and handle times for container boots correctly

diff --git a/src/analyze/systemd-analyze b/src/analyze/systemd-analyze
index 88699d6..1512b16 100755
--- a/src/analyze/systemd-analyze
+++ b/src/analyze/systemd-analyze
@@ -35,6 +35,17 @@ def acquire_start_time():
         properties = Gio.DBusProxy.new_for_bus_sync(bus, Gio.DBusProxyFlags.NONE,
                 None, 'org.freedesktop.systemd1', '/org/freedesktop/systemd1', 'org.freedesktop.DBus.Properties', None)
 
+        # Note that the firmware/loader times are returned as positive
+        # values but are atcually considered negative from the point
+        # in time of kernel initialization. Also, the monotonic kernel
+        # time will always be 0 since that's where the epoch of the
+        # monotonic clock ist. Since we want to know whether the
+        # kernel time stamp is set at all, we will thus ask for the
+        # realtime clock for this timestamp, instead.
+
+        firmware_time = properties.Get('(ss)', 'org.freedesktop.systemd1.Manager', 'FirmwareTimestampMonotonic')
+        loader_time = properties.Get('(ss)', 'org.freedesktop.systemd1.Manager', 'LoaderTimestampMonotonic')
+        kernel_time = properties.Get('(ss)', 'org.freedesktop.systemd1.Manager', 'KernelTimestamp')
         initrd_time = properties.Get('(ss)', 'org.freedesktop.systemd1.Manager', 'InitRDTimestampMonotonic')
         userspace_time = properties.Get('(ss)', 'org.freedesktop.systemd1.Manager', 'UserspaceTimestampMonotonic')
         finish_time = properties.Get('(ss)', 'org.freedesktop.systemd1.Manager', 'FinishTimestampMonotonic')
@@ -43,10 +54,11 @@ def acquire_start_time():
                 sys.stderr.write("Bootup is not yet finished. Please try again later.\n")
                 sys.exit(1)
 
+        assert firmware_time >= loader_time
         assert initrd_time <= userspace_time
         assert userspace_time <= finish_time
 
-        return initrd_time, userspace_time, finish_time
+        return firmware_time, loader_time, kernel_time, initrd_time, userspace_time, finish_time
 
 def draw_box(context, j, k, l, m, r = 0, g = 0, b = 0):
         context.save()
@@ -78,20 +90,25 @@ def draw_text(context, x, y, text, size = 12, r = 0, g = 0, b = 0, vcenter = 0.5
 
 def time():
 
-        initrd_time, start_time, finish_time = acquire_start_time()
+        firmware_time, loader_time, kernel_time, initrd_time, userspace_time, finish_time = acquire_start_time()
 
+        sys.stdout.write("Startup finished in ")
+
+        if firmware_time > 0:
+                sys.stdout.write("%lums (firmware) + " % ((firmware_time - loader_time) / 1000))
+        if loader_time > 0:
+                sys.stdout.write("%lums (loader) + " % (loader_time / 1000))
         if initrd_time > 0:
-                sys.stdout.write("Startup finished in %lums (kernel) + %lums (initramfs) + %lums (userspace) = %lums\n" % ( \
-                        initrd_time/1000, \
-                        (start_time - initrd_time)/1000, \
-                        (finish_time - start_time)/1000, \
-                        finish_time/1000))
-        else:
-                sys.stdout.write("Startup finished in %lums (kernel) + %lums (userspace) = %lums\n" % ( \
-                        start_time/1000, \
-                        (finish_time - start_time)/1000, \
-                        finish_time/1000))
+                sys.stdout.write("%lums (kernel) + %lums (initrd) + " % (initrd_time / 1000, (userspace_time - initrd_time) / 1000))
+        elif kernel_time > 0:
+                sys.stdout.write("%lums (kernel) + " % (userspace_time  / 1000))
 
+        sys.stdout.write("%lums (userspace) " % ((finish_time - userspace_time) / 1000))
+
+        if kernel_time > 0:
+                sys.stdout.write("= %lums\n" % ((firmware_time + finish_time) / 1000))
+        else:
+                sys.stdout.write("= %lums\n" % ((finish_time - userspace_time) / 1000))
 
 def blame():
 
@@ -112,7 +129,7 @@ def plot():
         if cairo is None:
                 sys.stderr.write("Failed to initilize python-cairo required for 'plot' verb.\n")
                 sys.exit(1)
-        initrd_time, start_time, finish_time = acquire_start_time()
+        firmware_time, loader_time, kernel_time, initrd_time, userspace_time, finish_time = acquire_start_time()
         data = acquire_time_data()
         s = sorted(data, key = lambda i: i[1])
 
@@ -124,9 +141,9 @@ def plot():
 
         for name, ixt, aet, axt, iet in s:
 
-                if (ixt >= start_time and ixt <= finish_time) or \
-                                (aet >= start_time and aet <= finish_time) or \
-                                (axt >= start_time and axt <= finish_time):
+                if (ixt >= userspace_time and ixt <= finish_time) or \
+                                (aet >= userspace_time and aet <= finish_time) or \
+                                (axt >= userspace_time and axt <= finish_time):
                         count += 1
 
         border = 100
@@ -186,17 +203,17 @@ def plot():
                 draw_text(context, 10, y + bar_height/2, "kernel", hcenter = 0)
                 y += bar_height + bar_space
 
-                draw_box(context, initrd_time/10000, y, start_time/10000-initrd_time/10000, bar_height, 0.7, 0.7, 0.7)
+                draw_box(context, initrd_time/10000, y, userspace_time/10000-initrd_time/10000, bar_height, 0.7, 0.7, 0.7)
                 draw_text(context, initrd_time/10000 + 10, y + bar_height/2, "initramfs", hcenter = 0)
                 y += bar_height + bar_space
 
         else:
-                draw_box(context, 0, y, start_time/10000, bar_height, 0.6, 0.6, 0.6)
+                draw_box(context, 0, y, userspace_time/10000, bar_height, 0.6, 0.6, 0.6)
                 draw_text(context, 10, y + bar_height/2, "kernel", hcenter = 0)
                 y += bar_height + bar_space
 
-        draw_box(context, start_time/10000, y, finish_time/10000-start_time/10000, bar_height, 0.7, 0.7, 0.7)
-        draw_text(context, start_time/10000 + 10, y + bar_height/2, "userspace", hcenter = 0)
+        draw_box(context, userspace_time/10000, y, finish_time/10000-userspace_time/10000, bar_height, 0.7, 0.7, 0.7)
+        draw_text(context, userspace_time/10000 + 10, y + bar_height/2, "userspace", hcenter = 0)
         y += bar_height + bar_space
 
         for name, ixt, aet, axt, iet in s:
@@ -204,7 +221,7 @@ def plot():
                 drawn = False
                 left = -1
 
-                if ixt >= start_time and ixt <= finish_time:
+                if ixt >= userspace_time and ixt <= finish_time:
 
                         # Activating
                         a = ixt
@@ -216,7 +233,7 @@ def plot():
                         if left < 0:
                                 left = a
 
-                if aet >= start_time and aet <= finish_time:
+                if aet >= userspace_time and aet <= finish_time:
 
                         # Active
                         a = aet
@@ -228,7 +245,7 @@ def plot():
                         if left < 0:
                                 left = a
 
-                if axt >= start_time and axt <= finish_time:
+                if axt >= userspace_time and axt <= finish_time:
 
                         # Deactivating
                         a = axt
@@ -255,13 +272,13 @@ def plot():
         if initrd_time > 0:
                 draw_text(context, 0, height-border*2 + bar_height, "Startup finished in %lums (kernel) + %lums (initramfs) + %lums (userspace) = %lums" % ( \
                         initrd_time/1000, \
-                        (start_time - initrd_time)/1000, \
-                        (finish_time - start_time)/1000, \
+                        (userspace_time - initrd_time)/1000, \
+                        (finish_time - userspace_time)/1000, \
                         finish_time/1000), hcenter = 0, vcenter = -1)
         else:
                 draw_text(context, 0, height-border*2 + bar_height, "Startup finished in %lums (kernel) + %lums (userspace) = %lums" % ( \
-                        start_time/1000, \
-                        (finish_time - start_time)/1000, \
+                        userspace_time/1000, \
+                        (finish_time - userspace_time)/1000, \
                         finish_time/1000), hcenter = 0, vcenter = -1)
 
         surface.finish()

commit 2a2784badc1abf0d984eaa7d790df4af82db0adc
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Dec 25 12:22:15 2012 +0100

    TODO

diff --git a/TODO b/TODO
index bcf6fe1..3ec87c5 100644
--- a/TODO
+++ b/TODO
@@ -39,8 +39,6 @@ Features:
   "dropped %u messages" not only when we are about to print the next
   message that works, but alraedy after a short tiemout
 
-* use C11 static_assert() where we currently use assert_cc()
-
 * journald: also get thread ID from client, plus thread name
 
 * check if we can make journalctl by default use --follow mode inside of less if called without args?

commit 22ffd25ba538bc04b22b778e0b5ecea830ba239f
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Dec 25 12:16:48 2012 +0100

    units: add CAP_DAC_OVERRIDE+CAP_SYS_PTRACE to hostnamed so that detection of virtualization works

diff --git a/units/systemd-hostnamed.service.in b/units/systemd-hostnamed.service.in
index be22a3a..874f6c2 100644
--- a/units/systemd-hostnamed.service.in
+++ b/units/systemd-hostnamed.service.in
@@ -13,4 +13,4 @@ Documentation=http://www.freedesktop.org/wiki/Software/systemd/hostnamed
 [Service]
 ExecStart=@rootlibexecdir@/systemd-hostnamed
 BusName=org.freedesktop.hostname1
-CapabilityBoundingSet=CAP_SYS_ADMIN
+CapabilityBoundingSet=CAP_SYS_ADMIN CAP_DAC_OVERRIDE CAP_SYS_PTRACE

commit f791c684a3d248baa83a3167086826ba6238d7f5
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Dec 25 11:52:14 2012 +0100

    macro: use C11 static_assert() macro for static assertions

diff --git a/src/shared/macro.h b/src/shared/macro.h
index e930fda..700171b 100644
--- a/src/shared/macro.h
+++ b/src/shared/macro.h
@@ -119,14 +119,21 @@ static inline size_t ALIGN_TO(size_t l, size_t ali) {
                 log_assert_failed_unreachable(t, __FILE__, __LINE__, __PRETTY_FUNCTION__); \
         } while (false)
 
-#define assert_cc(expr)                            \
-        do {                                       \
-                switch (0) {                       \
-                        case 0:                    \
-                        case !!(expr):             \
-                                ;                  \
-                }                                  \
+#if defined(static_assert)
+#define assert_cc(expr)                         \
+        do {                                    \
+                static_assert(expr, #expr);     \
         } while (false)
+#else
+#define assert_cc(expr)                         \
+        do {                                    \
+                switch (0) {                    \
+                case 0:                         \
+                case !!(expr):                  \
+                        ;                       \
+                }                               \
+        } while (false)
+#endif
 
 #define PTR_TO_UINT(p) ((unsigned int) ((uintptr_t) (p)))
 #define UINT_TO_PTR(u) ((void*) ((uintptr_t) (u)))

commit 31c15e20ceda62997e84c7e048f65a6dabc5d597
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Dec 25 11:37:06 2012 +0100

    TODO

diff --git a/TODO b/TODO
index bb4a7d3..bcf6fe1 100644
--- a/TODO
+++ b/TODO
@@ -55,8 +55,6 @@ Features:
   include _SYSTEMD_UNIT= fields so that "systemctl status" can show
   them along with the unit
 
-* use polkit "imply" for binding hostname actions together
-
 * journal: when waiting for journal additions in the client always sleep at least 1s or so, in order to minimize wakeups
 
 * When shutdown.target is queued begin with an asynchronous sync()?

commit 3960015566b506b234596a4f726cb47fb9a0da51
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Dec 25 11:36:37 2012 +0100

    polkit: add "imply" rules to a number of polkit actions

diff --git a/src/hostname/org.freedesktop.hostname1.policy.in b/src/hostname/org.freedesktop.hostname1.policy.in
index df082d8..c32c1d4 100644
--- a/src/hostname/org.freedesktop.hostname1.policy.in
+++ b/src/hostname/org.freedesktop.hostname1.policy.in
@@ -34,6 +34,7 @@
                         <allow_inactive>auth_admin_keep</allow_inactive>
                         <allow_active>auth_admin_keep</allow_active>
                 </defaults>
+                <annotate key="org.freedesktop.policykit.imply">org.freedesktop.hostname1.set-hostname org.freedesktop.hostname1.set-machine-info</annotate>
         </action>
 
         <action id="org.freedesktop.hostname1.set-machine-info">
diff --git a/src/locale/org.freedesktop.locale1.policy.in b/src/locale/org.freedesktop.locale1.policy.in
index 91296c2..df63845 100644
--- a/src/locale/org.freedesktop.locale1.policy.in
+++ b/src/locale/org.freedesktop.locale1.policy.in
@@ -24,6 +24,7 @@
                         <allow_inactive>auth_admin_keep</allow_inactive>
                         <allow_active>auth_admin_keep</allow_active>
                 </defaults>
+                <annotate key="org.freedesktop.policykit.imply">org.freedesktop.locale1.set-keyboard</annotate>
         </action>
 
         <action id="org.freedesktop.locale1.set-keyboard">
diff --git a/src/login/org.freedesktop.login1.policy.in b/src/login/org.freedesktop.login1.policy.in
index 57dfb2a..b5f5db4 100644
--- a/src/login/org.freedesktop.login1.policy.in
+++ b/src/login/org.freedesktop.login1.policy.in
@@ -24,6 +24,7 @@
                         <allow_inactive>yes</allow_inactive>
                         <allow_active>yes</allow_active>
                 </defaults>
+                <annotate key="org.freedesktop.policykit.imply">org.freedesktop.login1.inhibit-delay-shutdown org.freedesktop.login1.inhibit-block-sleep org.freedesktop.login1.inhibit-delay-sleep org.freedesktop.login1.inhibit-block-idle</annotate>
         </action>
 
         <action id="org.freedesktop.login1.inhibit-delay-shutdown">
@@ -34,6 +35,7 @@
                         <allow_inactive>yes</allow_inactive>
                         <allow_active>yes</allow_active>
                 </defaults>
+                <annotate key="org.freedesktop.policykit.imply">org.freedesktop.login1.inhibit-delay-sleep</annotate>
         </action>
 
         <action id="org.freedesktop.login1.inhibit-block-sleep">
@@ -44,6 +46,7 @@
                         <allow_inactive>yes</allow_inactive>
                         <allow_active>yes</allow_active>
                 </defaults>
+                <annotate key="org.freedesktop.policykit.imply">org.freedesktop.login1.inhibit-delay-sleep org.freedesktop.login1.inhibit-block-idle</annotate>
         </action>
 
         <action id="org.freedesktop.login1.inhibit-delay-sleep">
@@ -74,6 +77,7 @@
                         <allow_inactive>yes</allow_inactive>
                         <allow_active>yes</allow_active>
                 </defaults>
+                <annotate key="org.freedesktop.policykit.imply">org.freedesktop.login1.inhibit-handle-suspend-key org.freedesktop.login1.inhibit-handle-hibernate-key org.freedesktop.login1.inhibit-handle-lid-switch</annotate>
         </action>
 
         <action id="org.freedesktop.login1.inhibit-handle-suspend-key">
@@ -84,6 +88,7 @@
                         <allow_inactive>yes</allow_inactive>
                         <allow_active>yes</allow_active>
                 </defaults>
+                <annotate key="org.freedesktop.policykit.imply">org.freedesktop.login1.inhibit-handle-hibernate-key org.freedesktop.login1.inhibit-handle-lid-switch</annotate>
         </action>
 
         <action id="org.freedesktop.login1.inhibit-handle-hibernate-key">
@@ -124,6 +129,7 @@
                         <allow_inactive>auth_admin_keep</allow_inactive>
                         <allow_active>auth_admin_keep</allow_active>
                 </defaults>
+                <annotate key="org.freedesktop.policykit.imply">org.freedesktop.login1.flush-devices</annotate>
         </action>
 
         <action id="org.freedesktop.login1.flush-devices">
@@ -154,6 +160,7 @@
                         <allow_inactive>auth_admin_keep</allow_inactive>
                         <allow_active>auth_admin_keep</allow_active>
                 </defaults>
+                <annotate key="org.freedesktop.policykit.imply">org.freedesktop.login1.power-off</annotate>
         </action>
 
         <action id="org.freedesktop.login1.power-off-ignore-inhibit">
@@ -164,6 +171,7 @@
                         <allow_inactive>auth_admin_keep</allow_inactive>
                         <allow_active>auth_admin_keep</allow_active>
                 </defaults>
+                <annotate key="org.freedesktop.policykit.imply">org.freedesktop.login1.power-off</annotate>
         </action>
 
         <action id="org.freedesktop.login1.reboot">
@@ -184,6 +192,7 @@
                         <allow_inactive>auth_admin_keep</allow_inactive>
                         <allow_active>auth_admin_keep</allow_active>
                 </defaults>
+                <annotate key="org.freedesktop.policykit.imply">org.freedesktop.login1.reboot</annotate>
         </action>
 
         <action id="org.freedesktop.login1.reboot-ignore-inhibit">
@@ -194,6 +203,7 @@
                         <allow_inactive>auth_admin_keep</allow_inactive>
                         <allow_active>auth_admin_keep</allow_active>
                 </defaults>
+                <annotate key="org.freedesktop.policykit.imply">org.freedesktop.login1.reboot</annotate>
         </action>
 
         <action id="org.freedesktop.login1.suspend">
@@ -214,6 +224,7 @@
                         <allow_inactive>auth_admin_keep</allow_inactive>
                         <allow_active>yes</allow_active>
                 </defaults>
+                <annotate key="org.freedesktop.policykit.imply">org.freedesktop.login1.suspend</annotate>
         </action>
 
         <action id="org.freedesktop.login1.suspend-ignore-inhibit">
@@ -224,6 +235,7 @@
                         <allow_inactive>auth_admin_keep</allow_inactive>
                         <allow_active>auth_admin_keep</allow_active>
                 </defaults>
+                <annotate key="org.freedesktop.policykit.imply">org.freedesktop.login1.suspend</annotate>
         </action>
 
         <action id="org.freedesktop.login1.hibernate">
@@ -244,6 +256,7 @@
                         <allow_inactive>auth_admin_keep</allow_inactive>
                         <allow_active>auth_admin_keep</allow_active>
                 </defaults>
+                <annotate key="org.freedesktop.policykit.imply">org.freedesktop.login1.hibernate</annotate>
         </action>
 
         <action id="org.freedesktop.login1.hibernate-ignore-inhibit">
@@ -254,6 +267,7 @@
                         <allow_inactive>auth_admin_keep</allow_inactive>
                         <allow_active>auth_admin_keep</allow_active>
                 </defaults>
+                <annotate key="org.freedesktop.policykit.imply">org.freedesktop.login1.hibernate</annotate>
         </action>
 
 </policyconfig>
diff --git a/src/timedate/org.freedesktop.timedate1.policy.in b/src/timedate/org.freedesktop.timedate1.policy.in
index dd0a54d..aa30b70 100644
--- a/src/timedate/org.freedesktop.timedate1.policy.in
+++ b/src/timedate/org.freedesktop.timedate1.policy.in
@@ -24,6 +24,7 @@
                         <allow_inactive>auth_admin_keep</allow_inactive>
                         <allow_active>auth_admin_keep</allow_active>
                 </defaults>
+                <annotate key="org.freedesktop.policykit.imply">org.freedesktop.timedate1.set-timezone org.freedesktop.timedate1.set-ntp</annotate>
         </action>
 
         <action id="org.freedesktop.timedate1.set-timezone">



More information about the systemd-commits mailing list