mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2026-02-17 20:16:48 +01:00
29 lines
715 B
Plaintext
29 lines
715 B
Plaintext
|
|
#!/usr/bin/env python3
|
||
|
|
"""Helper script for CyberPanel File Manager: delete a file/dir by base64-encoded path.
|
||
|
|
Invoked by lscpd as root. Exits 0 on success, 1 on failure."""
|
||
|
|
import sys
|
||
|
|
import os
|
||
|
|
import base64
|
||
|
|
import shutil
|
||
|
|
|
||
|
|
def main():
|
||
|
|
if len(sys.argv) < 2:
|
||
|
|
sys.exit(1)
|
||
|
|
try:
|
||
|
|
p_b64 = sys.argv[1]
|
||
|
|
path = base64.b64decode(p_b64).decode('utf-8')
|
||
|
|
if not path or not os.path.isabs(path):
|
||
|
|
sys.exit(1)
|
||
|
|
if os.path.isfile(path):
|
||
|
|
os.remove(path)
|
||
|
|
elif os.path.isdir(path):
|
||
|
|
shutil.rmtree(path)
|
||
|
|
else:
|
||
|
|
sys.exit(1)
|
||
|
|
sys.exit(0)
|
||
|
|
except Exception:
|
||
|
|
sys.exit(1)
|
||
|
|
|
||
|
|
if __name__ == '__main__':
|
||
|
|
main()
|