From d436e257b5666163e02608c4afeada60e231fa88 Mon Sep 17 00:00:00 2001
From: Mal Graty <mal.graty@googlemail.com>
Date: Wed, 16 May 2018 19:06:30 +0100
Subject: Fix systemd_unit user property usage

Use Etc.getpwnam rather than Etc.getpwuid, since getpwuid expects a UID
and the resource provides a string.

Signed-off-by: Mal Graty <mal.graty@googlemail.com>
---
 lib/chef/provider/service/systemd.rb | 2 +-
 lib/chef/provider/systemd_unit.rb    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

(limited to 'lib')

diff --git a/lib/chef/provider/service/systemd.rb b/lib/chef/provider/service/systemd.rb
index 1bcc2f3a00..704f94a7ff 100644
--- a/lib/chef/provider/service/systemd.rb
+++ b/lib/chef/provider/service/systemd.rb
@@ -77,7 +77,7 @@ class Chef::Provider::Service::Systemd < Chef::Provider::Service::Simple
 
   def get_systemctl_options_args
     if new_resource.user
-      uid = Etc.getpwuid(new_resource.user).uid
+      uid = Etc.getpwnam(new_resource.user).uid
       options = {
         :environment => {
           "DBUS_SESSION_BUS_ADDRESS" => "unix:path=/run/user/#{uid}/bus",
diff --git a/lib/chef/provider/systemd_unit.rb b/lib/chef/provider/systemd_unit.rb
index d8c83d2b4b..124f255c3a 100644
--- a/lib/chef/provider/systemd_unit.rb
+++ b/lib/chef/provider/systemd_unit.rb
@@ -245,7 +245,7 @@ class Chef
       def systemctl_opts
         @systemctl_opts ||=
           if new_resource.user
-            uid = Etc.getpwuid(new_resource.user).uid
+            uid = Etc.getpwnam(new_resource.user).uid
             {
               :user => new_resource.user,
               :environment => {
-- 
cgit v1.2.1


From 3071b022ccb88a0c3298ebf613c0109f97ff4b55 Mon Sep 17 00:00:00 2001
From: Mal Graty <mal.graty@googlemail.com>
Date: Wed, 16 May 2018 19:07:11 +0100
Subject: Contextualise daemon-reload calls

Ensure daemon-reload is called in the correct context for user units.

Signed-off-by: Mal Graty <mal.graty@googlemail.com>
---
 lib/chef/provider/systemd_unit.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'lib')

diff --git a/lib/chef/provider/systemd_unit.rb b/lib/chef/provider/systemd_unit.rb
index 124f255c3a..0c02b4491c 100644
--- a/lib/chef/provider/systemd_unit.rb
+++ b/lib/chef/provider/systemd_unit.rb
@@ -219,7 +219,7 @@ class Chef
       end
 
       def daemon_reload
-        shell_out_with_systems_locale!("#{systemctl_path} daemon-reload")
+        shell_out_with_systems_locale!("#{systemctl_cmd} daemon-reload", systemctl_opts)
       end
 
       def systemctl_execute!(action, unit)
-- 
cgit v1.2.1