From 0b4351b8e1d6f3e9c5d28b094685bad7f66bb501 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?= Date: Fri, 6 Aug 2021 09:45:27 +0700 Subject: [PATCH] deluge: allow deluged to be run as different user Close: #31690 --- srcpkgs/deluge/files/deluged/run | 2 +- srcpkgs/deluge/patches/drop-priv.patch | 40 ++++++++++++++++++++++++++ srcpkgs/deluge/template | 2 +- 3 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 srcpkgs/deluge/patches/drop-priv.patch diff --git a/srcpkgs/deluge/files/deluged/run b/srcpkgs/deluge/files/deluged/run index ac0e7983faf..48cc18df5b7 100644 --- a/srcpkgs/deluge/files/deluged/run +++ b/srcpkgs/deluge/files/deluged/run @@ -1,3 +1,3 @@ #!/bin/sh [ -r ./conf ] && . ./conf -exec chpst -u deluge:deluge deluged -d ${OPTS} 2>&1 +exec deluged -d -U deluge -g deluge -c /var/lib/deluge/.config ${OPTS} 2>&1 diff --git a/srcpkgs/deluge/patches/drop-priv.patch b/srcpkgs/deluge/patches/drop-priv.patch new file mode 100644 index 00000000000..cb356dbe018 --- /dev/null +++ b/srcpkgs/deluge/patches/drop-priv.patch @@ -0,0 +1,40 @@ +From d08c3f72e94a3a2b440b5a1a36dd8f7f8641d4fa Mon Sep 17 00:00:00 2001 +From: Jack O'Sullivan +Date: Tue, 24 Sep 2019 11:32:18 +0100 +Subject: [PATCH] Fix privilege dropping when setting process ownership + +`os.setgid()` should be called to set the GID, and it should be called +before `os.setuid()` to prevent reinstatement of privileges. +--- + deluge/argparserbase.py | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +diff --git a/deluge/argparserbase.py b/deluge/argparserbase.py +index af9d568fa4..77866a3ed6 100644 +--- a/deluge/argparserbase.py ++++ b/deluge/argparserbase.py +@@ -329,18 +329,18 @@ def _handle_ui_options(self, options): + _file.write('%d\n' % os.getpid()) + + if not common.windows_check(): ++ if options.group: ++ if not options.group.isdigit(): ++ import grp ++ ++ options.group = grp.getgrnam(options.group)[2] ++ os.setgid(options.group) + if options.user: + if not options.user.isdigit(): + import pwd + + options.user = pwd.getpwnam(options.user)[2] + os.setuid(options.user) +- if options.group: +- if not options.group.isdigit(): +- import grp +- +- options.group = grp.getgrnam(options.group)[2] +- os.setuid(options.group) + + return options + diff --git a/srcpkgs/deluge/template b/srcpkgs/deluge/template index ce2523384e4..622e8a4d484 100644 --- a/srcpkgs/deluge/template +++ b/srcpkgs/deluge/template @@ -1,7 +1,7 @@ # Template file for 'deluge' pkgname=deluge version=2.0.3 -revision=11 +revision=12 build_style=python3-module # TODO package python3-slimit to minify javascript hostmakedepends="intltool python3-setuptools python3-wheel"