Blame SOURCES/0001-Allow-running-on-an-older-systemd.patch

b01a52
From 246ba5fed9f67047179f11a85c5fa4c869b62840 Mon Sep 17 00:00:00 2001
b01a52
From: Mario Limonciello <mario.limonciello@dell.com>
b01a52
Date: Mon, 9 Jul 2018 17:09:41 -0500
b01a52
Subject: [PATCH] Allow running on an older systemd
b01a52
b01a52
Build the path list dynamically based on enabled plugins and use options
b01a52
that are compatible with older systemd when appropriate
b01a52
---
b01a52
 data/fwupd.service.in |  6 +----
b01a52
 data/meson.build      | 61 ++++++++++++++++++++++++++++---------------
b01a52
 meson.build           |  2 +-
b01a52
 3 files changed, 42 insertions(+), 27 deletions(-)
b01a52
b01a52
diff --git a/data/fwupd.service.in b/data/fwupd.service.in
b01a52
index 7785439f..996ff4cf 100644
b01a52
--- a/data/fwupd.service.in
b01a52
+++ b/data/fwupd.service.in
b01a52
@@ -8,13 +8,9 @@ Before=gdm.service
b01a52
 Type=dbus
b01a52
 BusName=org.freedesktop.fwupd
b01a52
 ExecStart=@libexecdir@/fwupd/fwupd
b01a52
-MemoryDenyWriteExecute=yes
b01a52
 PrivateTmp=yes
b01a52
-ProtectControlGroups=yes
b01a52
 ProtectHome=yes
b01a52
-ProtectKernelModules=yes
b01a52
 ProtectSystem=full
b01a52
 RestrictAddressFamilies=AF_NETLINK AF_UNIX
b01a52
-RestrictRealtime=yes
b01a52
-ReadWritePaths=@localstatedir@/lib/fwupd @sysconfdir@/fwupd/remotes.d -@bootdir@
b01a52
 SystemCallFilter=~@mount
b01a52
+@dynamic_options@
b01a52
diff --git a/data/meson.build b/data/meson.build
b01a52
index 7adc0c05..c40b132b 100644
b01a52
--- a/data/meson.build
b01a52
+++ b/data/meson.build
b01a52
@@ -30,26 +30,47 @@ if get_option('daemon')
b01a52
   )
b01a52
 endif
b01a52
 
b01a52
-con2 = configuration_data()
b01a52
-con2.set('libexecdir', libexecdir)
b01a52
-con2.set('bindir', bindir)
b01a52
-con2.set('localstatedir', localstatedir)
b01a52
-con2.set('datadir', datadir)
b01a52
-con2.set('bootdir', get_option('bootdir'))
b01a52
-con2.set('sysconfdir', default_sysconfdir)
b01a52
+if get_option('systemd')
b01a52
+  con2 = configuration_data()
b01a52
+  con2.set('libexecdir', libexecdir)
b01a52
+  con2.set('bindir', bindir)
b01a52
+  con2.set('localstatedir', localstatedir)
b01a52
+  con2.set('datadir', datadir)
b01a52
+  con2.set('bootdir', get_option('bootdir'))
b01a52
+  con2.set('sysconfdir', default_sysconfdir)
b01a52
 
b01a52
-# replace @libexecdir@
b01a52
-configure_file(
b01a52
-  input : 'org.freedesktop.fwupd.service.in',
b01a52
-  output : 'org.freedesktop.fwupd.service',
b01a52
-  configuration : con2,
b01a52
-  install: true,
b01a52
-  install_dir: join_paths(datadir,
b01a52
-                          'dbus-1',
b01a52
-                          'system-services'),
b01a52
-)
b01a52
+  rw_directories = []
b01a52
+  rw_directories += join_paths (localstatedir, 'lib', 'fwupd')
b01a52
+  rw_directories += join_paths (default_sysconfdir, 'fwupd', 'remotes.d')
b01a52
+  rw_directories += ['-/boot/efi', '-/boot', '-/efi']
b01a52
+
b01a52
+
b01a52
+
b01a52
+  dynamic_options = []
b01a52
+  if systemd.version().version_compare('>= 232')
b01a52
+    dynamic_options += 'ProtectControlGroups=yes'
b01a52
+    dynamic_options += 'ProtectKernelModules=yes'
b01a52
+  endif
b01a52
+  if systemd.version().version_compare('>= 231')
b01a52
+    dynamic_options += 'RestrictRealtime=yes'
b01a52
+    dynamic_options += 'MemoryDenyWriteExecute=yes'
b01a52
+    dynamic_options += ['ReadWritePaths=' + ' '.join(rw_directories)]
b01a52
+  else
b01a52
+    dynamic_options += ['ReadWriteDirectories=' + ' '.join(rw_directories)]
b01a52
+  endif
b01a52
+  con2.set('dynamic_options', '\n'.join(dynamic_options))
b01a52
+
b01a52
+  # replace @libexecdir@
b01a52
+  configure_file(
b01a52
+    input : 'org.freedesktop.fwupd.service.in',
b01a52
+    output : 'org.freedesktop.fwupd.service',
b01a52
+    configuration : con2,
b01a52
+    install: true,
b01a52
+    install_dir: join_paths(datadir,
b01a52
+                            'dbus-1',
b01a52
+                            'system-services'),
b01a52
+  )
b01a52
 
b01a52
-if get_option('systemd')
b01a52
   # replace @bindir@
b01a52
   configure_file(
b01a52
     input : 'fwupd-offline-update.service.in',
b01a52
@@ -58,10 +79,8 @@ if get_option('systemd')
b01a52
     install: true,
b01a52
     install_dir: systemdunitdir,
b01a52
   )
b01a52
-endif
b01a52
 
b01a52
-if get_option('systemd')
b01a52
-  # replace @localstatedir@, @sysconfdir@ and @bootdir@
b01a52
+  # replace @dynamic_options@
b01a52
   configure_file(
b01a52
     input : 'fwupd.service.in',
b01a52
     output : 'fwupd.service',
b01a52
diff --git a/meson.build b/meson.build
b01a52
index 2f2710c2..fecdfca5 100644
b01a52
--- a/meson.build
b01a52
+++ b/meson.build
b01a52
@@ -225,7 +225,7 @@ if get_option('plugin_thunderbolt')
b01a52
 endif
b01a52
 
b01a52
 if get_option('systemd')
b01a52
-  systemd = dependency('systemd', version : '>= 231')
b01a52
+  systemd = dependency('systemd', version : '>= 211')
b01a52
   conf.set('HAVE_SYSTEMD' , '1')
b01a52
 endif
b01a52
 
b01a52
-- 
b01a52
2.17.1
b01a52