From 6134896d95da8f968b0ae5ac4180c6a518a187e2 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Fri, 6 Jan 2017 10:10:49 +0000 Subject: [PATCH] Add x-systemd-unit and x-dbus-service MIME types These cover all types of systemd unit file, and D-Bus services, matching by filename and magic string. They are added together as both use the .service extension, and hence can be confused if only matched by name. Matching by content sniffing disambiguates them, as they use different group headers. https://bugs.freedesktop.org/show_bug.cgi?id=99297 --- freedesktop.org.xml.in | 53 ++++++++++++++++++++++++++++++++++++++++++++++ tests/dbus-comment.service | 9 ++++++++ tests/dbus.service | 5 +++++ tests/list | 18 ++++++++++++++++ tests/systemd.automount | 7 ++++++ tests/systemd.device | 14 ++++++++++++ tests/systemd.mount | 14 ++++++++++++ tests/systemd.path | 6 ++++++ tests/systemd.scope | 13 ++++++++++++ tests/systemd.service | 11 ++++++++++ tests/systemd.slice | 3 +++ tests/systemd.socket | 5 +++++ tests/systemd.swap | 9 ++++++++ tests/systemd.target | 4 ++++ tests/systemd.timer | 10 +++++++++ 15 files changed, 181 insertions(+) create mode 100644 tests/dbus-comment.service create mode 100644 tests/dbus.service create mode 100644 tests/systemd.automount create mode 100644 tests/systemd.device create mode 100644 tests/systemd.mount create mode 100644 tests/systemd.path create mode 100644 tests/systemd.scope create mode 100644 tests/systemd.service create mode 100644 tests/systemd.slice create mode 100644 tests/systemd.socket create mode 100644 tests/systemd.swap create mode 100644 tests/systemd.target create mode 100644 tests/systemd.timer diff --git a/freedesktop.org.xml.in b/freedesktop.org.xml.in index 44900e6..acc24eb 100644 --- a/freedesktop.org.xml.in +++ b/freedesktop.org.xml.in @@ -6185,6 +6185,59 @@ command to generate the output files. + + <_comment>D-Bus service file + + + + + + + + + <_comment>systemd unit file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_comment>XSLT stylesheet XSLT diff --git a/tests/dbus-comment.service b/tests/dbus-comment.service new file mode 100644 index 0000000..cc0f478 --- /dev/null +++ b/tests/dbus-comment.service @@ -0,0 +1,9 @@ +# This is a D-Bus service with a comment at the top, which +# would typically be some kind of licencing header; but +# here it’s just designed to take up space, annoyingly. + +[D-BUS Service] +Name=org.freedesktop.someservice +Exec=/bin/false +User=root +SystemdService=dbus-org.freedesktop.someservice.service diff --git a/tests/dbus.service b/tests/dbus.service new file mode 100644 index 0000000..f31f2e9 --- /dev/null +++ b/tests/dbus.service @@ -0,0 +1,5 @@ +[D-BUS Service] +Name=org.freedesktop.someservice +Exec=/bin/false +User=root +SystemdService=dbus-org.freedesktop.someservice.service diff --git a/tests/list b/tests/list index 1deab33..50e82ec 100644 --- a/tests/list +++ b/tests/list @@ -607,3 +607,21 @@ SConscript text/x-scons oxo # copied from https://raw.githubusercontent.com/mongodb/mongo/master/SConscript.buildinfo SConscript.buildinfo text/x-scons oxo +# systemd units +systemd.automount text/x-systemd-unit +systemd.device text/x-systemd-unit +systemd.mount text/x-systemd-unit +systemd.path text/x-systemd-unit +systemd.scope text/x-systemd-unit +systemd.service text/x-systemd-unit xoo +systemd.slice text/x-systemd-unit +systemd.socket text/x-systemd-unit +systemd.swap text/x-systemd-unit +systemd.target text/x-systemd-unit +systemd.timer text/x-systemd-unit +dbus.service text/x-systemd-unit xxx +dbus-comment.service text/x-systemd-unit xxx + +# D-Bus services +dbus.service text/x-dbus-service +dbus-comment.service text/x-dbus-service diff --git a/tests/systemd.automount b/tests/systemd.automount new file mode 100644 index 0000000..ceba2f9 --- /dev/null +++ b/tests/systemd.automount @@ -0,0 +1,7 @@ +[Unit] +Description=Test Automount Point +Before=sysinit.target +ConditionPathExists=/some/mountpoint/ + +[Automount] +Where=/some/mountpoint diff --git a/tests/systemd.device b/tests/systemd.device new file mode 100644 index 0000000..8a9b46f --- /dev/null +++ b/tests/systemd.device @@ -0,0 +1,14 @@ +[Install] +Wants=something.service + +# Here is some long exposition so that the Unit section is a lot further +# down the file than the Install section, so we are only relying on the +# Install section for the magic string comparison. +# +# It is interesting to note that there is no Device section because we +# cannot really set per-device options in files which are automatically +# generated, or in ones which are shipped with applications. You learn +# something new each day, right? + +[Unit] +Description=Some random description diff --git a/tests/systemd.mount b/tests/systemd.mount new file mode 100644 index 0000000..ffc2f43 --- /dev/null +++ b/tests/systemd.mount @@ -0,0 +1,14 @@ +# This file has a deliberately quite long introductory comment, which is +# designed to emulate the long license and copyright headers which some +# systemd files include. This might throw off simplistic magic string +# sniffing. +[Unit] +Description=Some Fancy Mount +DefaultDependencies=no +Before=sysinit.target +ConditionPathExists=/proc/sys/fs/mqueue + +[Mount] +What=mqueue +Where=/dev/mqueue +Type=mqueue diff --git a/tests/systemd.path b/tests/systemd.path new file mode 100644 index 0000000..a4a7f92 --- /dev/null +++ b/tests/systemd.path @@ -0,0 +1,6 @@ +[Unit] +Description=Some Kind of Path + +[Path] +DirectoryNotEmpty=/run/systemd/some-path +MakeDirectory=yes diff --git a/tests/systemd.scope b/tests/systemd.scope new file mode 100644 index 0000000..e00752d --- /dev/null +++ b/tests/systemd.scope @@ -0,0 +1,13 @@ +# This is a transient unit file, created programmatically via the systemd API. Do not edit. +[Scope] +Slice=user-1000.slice +[Unit] +Description=Session 2 of user philip +[Unit] +After=systemd-logind.service +[Unit] +After=systemd-user-sessions.service +[Scope] +SendSIGHUP=yes +[Scope] +TasksMax=infinity diff --git a/tests/systemd.service b/tests/systemd.service new file mode 100644 index 0000000..194c48d --- /dev/null +++ b/tests/systemd.service @@ -0,0 +1,11 @@ +[Unit] +Description=Pseudo-Emergency Shell +Conflicts=shutdown.target +Conflicts=rescue.service +Conflicts=syslog.socket +Before=shutdown.target + +[Service] +Environment=HOME=/root +WorkingDirectory=-/root +Type=idle diff --git a/tests/systemd.slice b/tests/systemd.slice new file mode 100644 index 0000000..98bacf1 --- /dev/null +++ b/tests/systemd.slice @@ -0,0 +1,3 @@ +[Unit] +Description=Cake Slice +Before=desserts.target diff --git a/tests/systemd.socket b/tests/systemd.socket new file mode 100644 index 0000000..d3f5902 --- /dev/null +++ b/tests/systemd.socket @@ -0,0 +1,5 @@ +[Unit] +Description=Another Bus Messaging Socket + +[Socket] +ListenStream=/run/another/system_bus_socket diff --git a/tests/systemd.swap b/tests/systemd.swap new file mode 100644 index 0000000..b668206 --- /dev/null +++ b/tests/systemd.swap @@ -0,0 +1,9 @@ +# Automatically generated by systemd-fstab-generator + +[Unit] +SourcePath=/etc/fstab +Documentation=man:fstab(5) man:systemd-fstab-generator(8) + +[Swap] +What=/dev/mapper/fedora-swap +Options=defaults,x-systemd.device-timeout=0 diff --git a/tests/systemd.target b/tests/systemd.target new file mode 100644 index 0000000..3e0eee9 --- /dev/null +++ b/tests/systemd.target @@ -0,0 +1,4 @@ +[Unit] +Description=Final Target +RefuseManualStart=yes +After=shutdown.target umount.target diff --git a/tests/systemd.timer b/tests/systemd.timer new file mode 100644 index 0000000..8ed865f --- /dev/null +++ b/tests/systemd.timer @@ -0,0 +1,10 @@ +[Unit] +Description=Do something once a week + +[Timer] +OnCalendar=weekly +AccuracySec=1h +Persistent=true + +[Install] +WantedBy=something.target -- 2.9.3