🔧 Entrée passwd pour PUID: MakeMKV résout sa conf via getpwuid, pas $HOME

This commit is contained in:
Orionis312050 committed 2026-10-13 15:18:08 +00:00
1 parent acc1609b4d
commit 87fd6b39fd
1 file changed
+13
+13
View File
@@ -25,6 +25,19 @@ if os.geteuid() == 0 and puid:
subprocess.run( subprocess.run(
["chown", "-R", f"{puid}:{pgid or puid}", config_dir], check=False ["chown", "-R", f"{puid}:{pgid or puid}", config_dir], check=False
) )
# Entree passwd pour PUID: certains binaires (MakeMKV) resolvent le
# repertoire utilisateur via getpwuid et non via $HOME. Sans entree,
# makemkvcon ne trouve pas sa configuration (/config/.MakeMKV).
try:
with open("/etc/passwd", encoding="utf-8") as handle:
known_uids = {line.split(":")[2] for line in handle if ":" in line}
if str(puid) not in known_uids:
with open("/etc/passwd", "a", encoding="utf-8") as handle:
handle.write(
f"mkvtool:x:{puid}:{pgid or puid}::{config_dir}:/usr/sbin/nologin\n"
)
except OSError:
pass
os.setgroups([pgid] if pgid else []) os.setgroups([pgid] if pgid else [])
if pgid: if pgid:
os.setgid(pgid) os.setgid(pgid)