polkit: cleaning up

This commit is contained in:
Tim Biermann 2022-05-27 10:31:00 +02:00
parent 8e4bcb7b35
commit 9e93874d89
Signed by: tb
GPG Key ID: 42F8B4E30B673606
3 changed files with 4 additions and 193 deletions

View File

@ -1,6 +1,6 @@
untrusted comment: verify with /etc/ports/opt.pub
RWSE3ohX2g5d/V8l9iBDcPY09Je8xzkpyInqswb+VSyU6oV2Ysyhhp5EPQnUwnJuSi+ajKS5lXvvyHIMPtTVggBgb+h9CX5dUwQ=
SHA256 (Pkgfile) = 728a668cb1422d14793379687a58314c10fffffc70bd920c1d328f402a78843c
RWSE3ohX2g5d/Rm3KWRKWhvDEihzOhmEnh2Hxg9DdsByqqBPhRJDNW86nOQ/xZqDpMLSK9V6peSvXzllj62Ftrf9vVl+P9pCFQ8=
SHA256 (Pkgfile) = c789bc857217e3ce0fb53c84b6208763ae87e6a228bb50abec0997dfd525c7c6
SHA256 (.footprint) = 7ae3e87d2e0379db60e118c5b79938e87319b3460d1907ef73524cbdad79db15
SHA256 (polkit-0.120.tar.gz) = ee7a599a853117bf273548725719fa92fabd2f136915c7a4906cee98567aee03
SHA256 (polkit-1) = 9045eb2a1e2e403b0144d14a5cfe903dc97cfef979c956815a56777c0eb1bf1a

View File

@ -1,190 +0,0 @@
From 0b59685e8f3729852a175777bceeccbe34870460 Mon Sep 17 00:00:00 2001
From: Simon McVittie <smcv@debian.org>
Date: Thu, 3 Jun 2021 17:11:46 +0100
Subject: [PATCH 1/8] meson_post_install: Use geteuid instead of getpass
Signed-off-by: Simon McVittie <smcv@debian.org>
---
meson_post_install.py | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/meson_post_install.py b/meson_post_install.py
index 0a0fccf..a87b711 100644
--- a/meson_post_install.py
+++ b/meson_post_install.py
@@ -1,6 +1,5 @@
#!/usr/bin/env python3
-import getpass
import os
import pwd
import sys
@@ -24,7 +23,7 @@ dst_dirs = [
for dst in dst_dirs:
if not os.path.exists(dst):
os.makedirs(dst, mode=0o700)
- if getpass.getuser() == "root":
+ if os.geteuid() == 0:
os.chown(dst, polkitd_uid, -1)
# polkit-agent-helper-1 need to be setuid root because it's used to
@@ -32,5 +31,5 @@ for dst in dst_dirs:
# and/or other users.
dst = os.path.join(pkglibdir, 'polkit-agent-helper-1')
os.chmod(dst, 0o4755)
-if getpass.getuser() == "root":
+if os.geteuid() == 0:
os.chown(dst, 0, -1)
diff --git a/meson_post_install.py b/meson_post_install.py
index a87b711..ef69bb2 100644
--- a/meson_post_install.py
+++ b/meson_post_install.py
@@ -11,7 +11,10 @@ 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_uid = pwd.getpwnam(sys.argv[5]).pw_uid
+try:
+ polkitd_uid = pwd.getpwnam(sys.argv[5]).pw_uid
+except KeyError:
+ polkitd_uid = None
os.chmod(os.path.join(bindir, 'pkexec'), 0o4775)
@@ -23,7 +26,7 @@ dst_dirs = [
for dst in dst_dirs:
if not os.path.exists(dst):
os.makedirs(dst, mode=0o700)
- if os.geteuid() == 0:
+ if os.geteuid() == 0 and polkitd_uid is not None:
os.chown(dst, polkitd_uid, -1)
# polkit-agent-helper-1 need to be setuid root because it's used to
diff --git a/meson_post_install.py b/meson_post_install.py
index ef69bb2..de42531 100644
--- a/meson_post_install.py
+++ b/meson_post_install.py
@@ -10,9 +10,10 @@ bindir = os.path.join(prefix, sys.argv[1])
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]
try:
- polkitd_uid = pwd.getpwnam(sys.argv[5]).pw_uid
+ polkitd_uid = pwd.getpwnam(polkitd_user).pw_uid
except KeyError:
polkitd_uid = None
@@ -28,6 +29,12 @@ for dst in dst_dirs:
os.makedirs(dst, mode=0o700)
if os.geteuid() == 0 and polkitd_uid is not None:
os.chown(dst, polkitd_uid, -1)
+ else:
+ print(
+ 'Owner of {} needs to be set to {} after installation'.format(
+ dst, polkitd_user,
+ )
+ )
# polkit-agent-helper-1 need to be setuid root because it's used to
# authenticate not only the invoking user, but possibly also root
@@ -36,3 +43,7 @@ dst = os.path.join(pkglibdir, 'polkit-agent-helper-1')
os.chmod(dst, 0o4755)
if os.geteuid() == 0:
os.chown(dst, 0, -1)
+else:
+ print(
+ 'Owner of {} needs to be set to root after installation'.format(dst)
+ )
diff --git a/meson_post_install.py b/meson_post_install.py
index de42531..94ffa57 100644
--- a/meson_post_install.py
+++ b/meson_post_install.py
@@ -17,7 +17,7 @@ try:
except KeyError:
polkitd_uid = None
-os.chmod(os.path.join(bindir, 'pkexec'), 0o4775)
+os.chmod(os.path.join(bindir, 'pkexec'), 0o4755)
dst_dirs = [
os.path.join(pkgsysconfdir, 'rules.d'),
diff --git a/meson_post_install.py b/meson_post_install.py
index 94ffa57..85cd0ea 100644
--- a/meson_post_install.py
+++ b/meson_post_install.py
@@ -17,7 +17,18 @@ try:
except KeyError:
polkitd_uid = None
-os.chmod(os.path.join(bindir, 'pkexec'), 0o4755)
+dst = os.path.join(bindir, 'pkexec')
+
+if os.geteuid() == 0:
+ os.chmod(dst, 0o4755)
+ os.chown(dst, 0, -1)
+else:
+ print(
+ 'Owner and mode of {} need to be setuid root (04755) after '
+ 'installation'.format(
+ dst,
+ )
+ )
dst_dirs = [
os.path.join(pkgsysconfdir, 'rules.d'),
@@ -40,10 +51,14 @@ for dst in dst_dirs:
# authenticate not only the invoking user, but possibly also root
# and/or other users.
dst = os.path.join(pkglibdir, 'polkit-agent-helper-1')
-os.chmod(dst, 0o4755)
+
if os.geteuid() == 0:
+ os.chmod(dst, 0o4755)
os.chown(dst, 0, -1)
else:
print(
- 'Owner of {} needs to be set to root after installation'.format(dst)
+ 'Owner and mode of {} need to be setuid root (04755) after '
+ 'installation'.format(
+ dst,
+ )
)
diff --git a/meson_post_install.py b/meson_post_install.py
index 85cd0ea..0ab7469 100644
--- a/meson_post_install.py
+++ b/meson_post_install.py
@@ -4,12 +4,22 @@ import os
import pwd
import sys
+destdir = os.environ.get('DESTDIR')
prefix = os.environ['MESON_INSTALL_DESTDIR_PREFIX']
-bindir = os.path.join(prefix, sys.argv[1])
-pkgdatadir = os.path.join(prefix, sys.argv[2])
-pkglibdir = os.path.join(prefix, sys.argv[3])
-pkgsysconfdir = os.path.join(prefix, sys.argv[4])
+def destdir_path(p):
+ if os.path.isabs(p):
+ if destdir is None:
+ return p
+ else:
+ return os.path.join(destdir, os.path.relpath(p, '/'))
+ else:
+ return os.path.join(prefix, p)
+
+bindir = destdir_path(sys.argv[1])
+pkgdatadir = destdir_path(sys.argv[2])
+pkglibdir = destdir_path(sys.argv[3])
+pkgsysconfdir = destdir_path(sys.argv[4])
polkitd_user = sys.argv[5]
try:

View File

@ -8,7 +8,8 @@ version=0.120
release=3
source=(https://freedesktop.org/software/polkit/releases/$name-$version.tar.gz
polkit-1
CVE-2021-4034.patch 99.patch)
CVE-2021-4034.patch
99.patch)
build() {
patch -Np1 -d $name-$version -i $SRC/99.patch