mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 01:00:29 +08:00
chown only if needed
This commit is contained in:
parent
3a7278b0f7
commit
880f24dfbc
@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
import pwd
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
@ -74,11 +75,12 @@ def _move(src: str, dest: str) -> None:
|
|||||||
|
|
||||||
|
|
||||||
def _chown(path: str, user: str) -> None:
|
def _chown(path: str, user: str) -> None:
|
||||||
_log(f"CHOWN --- {user} - {path}")
|
if pwd.getpwuid(os.stat(path).st_uid).pw_name != user:
|
||||||
try:
|
_log(f"CHOWN --- {user} - {path}")
|
||||||
shutil.chown(path, user)
|
try:
|
||||||
except Exception as err:
|
shutil.chown(path, user)
|
||||||
raise SystemExit(f"Can't change ownership: {err}")
|
except Exception as err:
|
||||||
|
raise SystemExit(f"Can't change ownership: {err}")
|
||||||
|
|
||||||
|
|
||||||
# =====
|
# =====
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user