deluge: allow deluged to be run as different user

Close: #31690
This commit is contained in:
Đoàn Trần Công Danh 2021-08-06 09:45:27 +07:00
parent de0ef28e2a
commit 0b4351b8e1
3 changed files with 42 additions and 2 deletions

View File

@ -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

View File

@ -0,0 +1,40 @@
From d08c3f72e94a3a2b440b5a1a36dd8f7f8641d4fa Mon Sep 17 00:00:00 2001
From: Jack O'Sullivan <jackos1998@gmail.com>
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

View File

@ -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"