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

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