From 91f9dcaf9270fe465525638cc08bd94590273349 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 17 Jun 2011 00:15:02 +0200 Subject: [PATCH] dbus: add dbus introspection extraction --- Makefile.am | 34 +++++++++++++++++++++++++----- org.freedesktop.hostname1.xml | 26 +++++++++++++++++++++++ org.freedesktop.locale1.xml | 11 ++++++++++ org.freedesktop.timedate1.xml | 22 +++++++++++++++++++ src/hostnamed.c | 21 ++++++++++++++---- src/localed.c | 21 ++++++++++++++---- src/logind.h | 1 + src/org.freedesktop.login1.policy | 29 +++++++++++++++++++++++++ src/org.freedesktop.login1.service | 12 +++++++++++ src/timedated.c | 23 +++++++++++++++----- units/.gitignore | 1 + units/systemd-logind.service.in | 17 +++++++++++++++ 12 files changed, 200 insertions(+), 18 deletions(-) create mode 100644 org.freedesktop.hostname1.xml create mode 100644 org.freedesktop.locale1.xml create mode 100644 org.freedesktop.timedate1.xml create mode 100644 src/org.freedesktop.login1.policy create mode 100644 src/org.freedesktop.login1.service create mode 100644 units/systemd-logind.service.in diff --git a/Makefile.am b/Makefile.am index 0439957e..a2d73975 100644 --- a/Makefile.am +++ b/Makefile.am @@ -203,13 +203,15 @@ dist_dbuspolicy_DATA = \ src/org.freedesktop.systemd1.conf \ src/org.freedesktop.hostname1.conf \ src/org.freedesktop.locale1.conf \ - src/org.freedesktop.timedate1.conf + src/org.freedesktop.timedate1.conf \ + src/org.freedesktop.login1.conf dist_dbussystemservice_DATA = \ src/org.freedesktop.systemd1.service \ src/org.freedesktop.hostname1.service \ src/org.freedesktop.locale1.service \ - src/org.freedesktop.timedate1.service + src/org.freedesktop.timedate1.service \ + src/org.freedesktop.login1.service dist_udevrules_DATA = \ src/99-systemd.rules @@ -227,7 +229,10 @@ dbusinterface_DATA = \ org.freedesktop.systemd1.Automount.xml \ org.freedesktop.systemd1.Snapshot.xml \ org.freedesktop.systemd1.Swap.xml \ - org.freedesktop.systemd1.Path.xml + org.freedesktop.systemd1.Path.xml \ + org.freedesktop.hostname1.xml \ + org.freedesktop.locale1.xml \ + org.freedesktop.timedate1.xml dist_bashcompletion_DATA = \ src/systemctl-bash-completion.sh @@ -316,6 +321,7 @@ nodist_systemunit_DATA = \ units/systemd-hostnamed.service \ units/systemd-localed.service \ units/systemd-timedated.service \ + units/systemd-logind.service \ units/systemd-kmsg-syslogd.service \ units/systemd-modules-load.service \ units/systemd-vconsole-setup.service \ @@ -365,6 +371,7 @@ EXTRA_DIST = \ units/systemd-hostnamed.service.in \ units/systemd-localed.service.in \ units/systemd-timedated.service.in \ + units/systemd-logind.service.in \ units/systemd-kmsg-syslogd.service.in \ units/systemd-modules-load.service.in \ units/systemd-vconsole-setup.service.in \ @@ -455,7 +462,8 @@ nodist_polkitpolicy_DATA = \ dist_polkitpolicy_DATA = \ src/org.freedesktop.hostname1.policy \ src/org.freedesktop.locale1.policy \ - src/org.freedesktop.timedate1.policy + src/org.freedesktop.timedate1.policy \ + src/org.freedesktop.login1.policy noinst_LTLIBRARIES = \ libsystemd-basic.la \ @@ -1388,6 +1396,21 @@ org.freedesktop.systemd1.%.xml: systemd $(STRINGS) $@.tmp | $(AWK) -f $(srcdir)/introspect.awk | \ $(DBUS_PREPROCESS) -o $@ - && rm $@.tmp +org.freedesktop.hostname1.xml: systemd-hostnamed + $(AM_V_GEN)$(OBJCOPY) -O binary -j introspect.hostname1 $< $@.tmp && \ + $(STRINGS) $@.tmp | $(AWK) -f $(srcdir)/introspect.awk | \ + $(DBUS_PREPROCESS) -o $@ - && rm $@.tmp + +org.freedesktop.locale1.xml: systemd-localed + $(AM_V_GEN)$(OBJCOPY) -O binary -j introspect.locale1 $< $@.tmp && \ + $(STRINGS) $@.tmp | $(AWK) -f $(srcdir)/introspect.awk | \ + $(DBUS_PREPROCESS) -o $@ - && rm $@.tmp + +org.freedesktop.timedate1.xml: systemd-timedated + $(AM_V_GEN)$(OBJCOPY) -O binary -j introspect.timedate1 $< $@.tmp && \ + $(STRINGS) $@.tmp | $(AWK) -f $(srcdir)/introspect.awk | \ + $(DBUS_PREPROCESS) -o $@ - && rm $@.tmp + CLEANFILES += \ $(dbusinterface_DATA) @@ -1492,7 +1515,8 @@ endif $(LN_S) reboot.target ctrl-alt-del.target && \ $(LN_S) systemd-hostnamed.service dbus-org.freedesktop.hostname1.service && \ $(LN_S) systemd-localed.service dbus-org.freedesktop.locale1.service && \ - $(LN_S) systemd-timedate.service dbus-org.freedesktop.timedate1.service ) + $(LN_S) systemd-timedated.service dbus-org.freedesktop.timedate1.service && \ + $(LN_S) systemd-logind.service dbus-org.freedesktop.login1.service ) ( cd $(DESTDIR)$(systemunitdir)/multi-user.target.wants && \ rm -f getty.target systemd-user-sessions.service systemd-ask-password-wall.path && \ $(LN_S) ../getty.target getty.target && \ diff --git a/org.freedesktop.hostname1.xml b/org.freedesktop.hostname1.xml new file mode 100644 index 00000000..e2d81a35 --- /dev/null +++ b/org.freedesktop.hostname1.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/org.freedesktop.locale1.xml b/org.freedesktop.locale1.xml new file mode 100644 index 00000000..ca24e840 --- /dev/null +++ b/org.freedesktop.locale1.xml @@ -0,0 +1,11 @@ + + + + + + + + + + diff --git a/org.freedesktop.timedate1.xml b/org.freedesktop.timedate1.xml new file mode 100644 index 00000000..3799a656 --- /dev/null +++ b/org.freedesktop.timedate1.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/src/hostnamed.c b/src/hostnamed.c index f579e112..d05c9023 100644 --- a/src/hostnamed.c +++ b/src/hostnamed.c @@ -31,9 +31,7 @@ #include "dbus-common.h" #include "polkit.h" -#define INTROSPECTION \ - DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE \ - "\n" \ +#define INTERFACE \ " \n" \ " \n" \ " \n" \ @@ -55,7 +53,12 @@ " \n" \ " \n" \ " \n" \ - " \n" \ + " \n" + +#define INTROSPECTION \ + DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE \ + "\n" \ + INTERFACE \ BUS_PROPERTIES_INTERFACE \ BUS_INTROSPECTABLE_INTERFACE \ BUS_PEER_INTERFACE \ @@ -65,6 +68,8 @@ BUS_GENERIC_INTERFACES_LIST \ "org.freedesktop.hostname1\0" +const char hostname_interface[] _introspect_("hostname1") = INTERFACE; + enum { PROP_HOSTNAME, PROP_STATIC_HOSTNAME, @@ -547,6 +552,14 @@ int main(int argc, char *argv[]) { log_parse_environment(); log_open(); + if (argc == 2 && streq(argv[1], "--introspect")) { + fputs(DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE + "\n", stdout); + fputs(hostname_interface, stdout); + fputs("\n", stdout); + return 0; + } + if (argc != 1) { log_error("This program takes no arguments."); r = -EINVAL; diff --git a/src/localed.c b/src/localed.c index 0fbe7478..353e88ef 100644 --- a/src/localed.c +++ b/src/localed.c @@ -30,16 +30,19 @@ #include "dbus-common.h" #include "polkit.h" -#define INTROSPECTION \ - DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE \ - "\n" \ +#define INTERFACE \ " \n" \ " \n" \ " \n" \ " \n" \ " \n" \ " \n" \ - " \n" \ + " \n" + +#define INTROSPECTION \ + DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE \ + "\n" \ + INTERFACE \ BUS_PROPERTIES_INTERFACE \ BUS_INTROSPECTABLE_INTERFACE \ BUS_PEER_INTERFACE \ @@ -49,6 +52,8 @@ BUS_GENERIC_INTERFACES_LIST \ "org.freedesktop.locale1\0" +const char locale_interface[] _introspect_("locale1") = INTERFACE; + enum { /* We don't list LC_ALL here on purpose. People should be * using LANG instead. */ @@ -563,6 +568,14 @@ int main(int argc, char *argv[]) { log_parse_environment(); log_open(); + if (argc == 2 && streq(argv[1], "--introspect")) { + fputs(DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE + "\n", stdout); + fputs(locale_interface, stdout); + fputs("\n", stdout); + return 0; + } + if (argc != 1) { log_error("This program takes no arguments."); r = -EINVAL; diff --git a/src/logind.h b/src/logind.h index 95db35dd..fdc780fe 100644 --- a/src/logind.h +++ b/src/logind.h @@ -38,6 +38,7 @@ * PAM rewrite * spawn user systemd * dbus API + * direct client API * * non-local X11 server * reboot/shutdown halt management diff --git a/src/org.freedesktop.login1.policy b/src/org.freedesktop.login1.policy new file mode 100644 index 00000000..b81e4888 --- /dev/null +++ b/src/org.freedesktop.login1.policy @@ -0,0 +1,29 @@ + + + + + + + + The systemd Project + http://www.freedesktop.org/wiki/Software/systemd + + + Allow non-logged-in users to run programs + Authentication is required to allow a non-logged-in user to run programs + + auth_admin_keep + auth_admin_keep + auth_admin_keep + + + + diff --git a/src/org.freedesktop.login1.service b/src/org.freedesktop.login1.service new file mode 100644 index 00000000..4a64177e --- /dev/null +++ b/src/org.freedesktop.login1.service @@ -0,0 +1,12 @@ +# This file is part of systemd. +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +[D-BUS Service] +Name=org.freedesktop.login1 +Exec=/bin/false +User=root +SystemdService=dbus-org.freedesktop.login1.service diff --git a/src/timedated.c b/src/timedated.c index daa3d9c8..a6ec2627 100644 --- a/src/timedated.c +++ b/src/timedated.c @@ -33,9 +33,7 @@ #define NULL_ADJTIME_UTC "0.0 0 0\n0\nUTC\n" #define NULL_ADJTIME_LOCAL "0.0 0 0\n0\nLOCAL\n" -#define INTROSPECTION \ - DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE \ - "\n" \ +#define INTERFACE \ " \n" \ " \n" \ " \n" \ @@ -50,10 +48,15 @@ " \n" \ " \n" \ " \n" \ - " \n" \ + " \n" \ " \n" \ " \n" \ - " \n" \ + " \n" + +#define INTROSPECTION \ + DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE \ + "\n" \ + INTERFACE \ BUS_PROPERTIES_INTERFACE \ BUS_INTROSPECTABLE_INTERFACE \ BUS_PEER_INTERFACE \ @@ -63,6 +66,8 @@ BUS_GENERIC_INTERFACES_LIST \ "org.freedesktop.locale1\0" +const char timedate_interface[] _introspect_("timedate1") = INTERFACE; + static char *zone = NULL; static bool local_rtc = false; @@ -566,6 +571,14 @@ int main(int argc, char *argv[]) { log_parse_environment(); log_open(); + if (argc == 2 && streq(argv[1], "--introspect")) { + fputs(DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE + "\n", stdout); + fputs(timedate_interface, stdout); + fputs("\n", stdout); + return 0; + } + if (argc != 1) { log_error("This program takes no arguments."); r = -EINVAL; diff --git a/units/.gitignore b/units/.gitignore index 96344409..8da3804e 100644 --- a/units/.gitignore +++ b/units/.gitignore @@ -1,3 +1,4 @@ +systemd-logind.service systemd-localed.service systemd-timedated.service systemd-hostnamed.service diff --git a/units/systemd-logind.service.in b/units/systemd-logind.service.in new file mode 100644 index 00000000..52c4acfe --- /dev/null +++ b/units/systemd-logind.service.in @@ -0,0 +1,17 @@ +# This file is part of systemd. +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# See systemd.special(7) for details + +[Unit] +Description=Login Service + +[Service] +ExecStart=@rootlibexecdir@/systemd-logind +Type=dbus +BusName=org.freedesktop.login1 +CapabilityBoundingSet= -- 2.39.5