Compare commits
3 Commits
trigger_re
...
prepare_re
| Author | SHA1 | Date | |
|---|---|---|---|
| 8b1d9a81a1 | |||
| 6eb3f5a210 | |||
|
|
9a64bef661 |
@@ -244,7 +244,7 @@ def move_to_trash(path: Path, interactive: bool, force: bool, recursive: bool, p
|
|||||||
print(f"Failed permanent delete: {e}")
|
print(f"Failed permanent delete: {e}")
|
||||||
return
|
return
|
||||||
|
|
||||||
# 🚫 Prevent non-root user deleting root-owned files
|
# Prevent non-root user deleting root-owned files
|
||||||
try:
|
try:
|
||||||
st = path.stat()
|
st = path.stat()
|
||||||
if st.st_uid == 0 and os.geteuid() != 0:
|
if st.st_uid == 0 and os.geteuid() != 0:
|
||||||
@@ -253,7 +253,7 @@ def move_to_trash(path: Path, interactive: bool, force: bool, recursive: bool, p
|
|||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# 🧭 Detect which trash to use (based on file owner)
|
# Detect which trash to use (based on file owner)
|
||||||
try:
|
try:
|
||||||
import pwd
|
import pwd
|
||||||
owner_uid = path.stat().st_uid
|
owner_uid = path.stat().st_uid
|
||||||
@@ -344,4 +344,4 @@ def main(argv: Optional[List[str]] = None):
|
|||||||
continue
|
continue
|
||||||
print(f"resrm: cannot remove '{pth}': Is a directory")
|
print(f"resrm: cannot remove '{pth}': Is a directory")
|
||||||
continue
|
continue
|
||||||
move_to_trash(pth, interactive=args.i, force=args.f, recursive=args.r, perma=args.perma)
|
move_to_trash(pth, interactive=args.i, force=args.f, recursive=args.r, perma=args.perma)
|
||||||
Reference in New Issue
Block a user