PolicyKit: Branch 'master' - 2 commits

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Apr 22 14:03:20 UTC 2021


 meson_post_install.py |   15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

New commits:
commit cd18b017a57b1fbed0542d4f9719f979a98d3f35
Merge: 6ac355e f986ebc
Author: Jan Rybar <jrybar at redhat.com>
Date:   Thu Apr 22 14:03:18 2021 +0000

    Merge branch 'master' into 'master'
    
    Avoid calling external processes
    
    See merge request polkit/polkit!73

commit f986ebcb6c1fa7d37c52af35207eaf2d1214ac22
Author: Hendrikto <hendrik.to at gmail.com>
Date:   Sun Jan 31 16:08:48 2021 +0100

    avoid calling external processes
    
    Python already offers functions for chowning and chmodding files in its
    standard library. The os module is even already imported. This commit removes
    external process calls in favor of using these built-in Python functions.

diff --git a/meson_post_install.py b/meson_post_install.py
index 784d491..0a0fccf 100644
--- a/meson_post_install.py
+++ b/meson_post_install.py
@@ -2,7 +2,7 @@
 
 import getpass
 import os
-import subprocess
+import pwd
 import sys
 
 prefix = os.environ['MESON_INSTALL_DESTDIR_PREFIX']
@@ -12,9 +12,9 @@ pkgdatadir = os.path.join(prefix, sys.argv[2])
 pkglibdir = os.path.join(prefix, sys.argv[3])
 pkgsysconfdir = os.path.join(prefix, sys.argv[4])
 
-polkitd_user = sys.argv[5]
+polkitd_uid = pwd.getpwnam(sys.argv[5]).pw_uid
 
-subprocess.check_call(['chmod', '4755', os.path.join(bindir, 'pkexec')])
+os.chmod(os.path.join(bindir, 'pkexec'), 0o4775)
 
 dst_dirs = [
     os.path.join(pkgsysconfdir, 'rules.d'),
@@ -23,15 +23,14 @@ dst_dirs = [
 
 for dst in dst_dirs:
     if not os.path.exists(dst):
-        os.makedirs(dst)
-        subprocess.check_call(['chmod', '700', dst])
+        os.makedirs(dst, mode=0o700)
         if getpass.getuser() == "root":
-            subprocess.check_call(['chown', polkitd_user, dst])
+            os.chown(dst, polkitd_uid, -1)
 
 # polkit-agent-helper-1 need to be setuid root because it's used to
 # authenticate not only the invoking user, but possibly also root
 # and/or other users.
 dst = os.path.join(pkglibdir, 'polkit-agent-helper-1')
-subprocess.check_call(['chmod', '4755', dst])
+os.chmod(dst, 0o4755)
 if getpass.getuser() == "root":
-    subprocess.check_call(['chown', 'root', dst])
+    os.chown(dst, 0, -1)


More information about the hal-commit mailing list