mirror of
				https://github.com/9001/copyparty.git
				synced 2025-10-30 19:43:37 +00:00 
			
		
		
		
	usb-eject: support non-alphanumeric volume names
until now, volumes with whitespace and such would fail to unmount also adds a sanchk that the directory to unmount is still below the expected parent after absreal; the path was already passed to gio in a safe manner (assuming gio doesn't have any vulns) but why risk it
This commit is contained in:
		| @@ -4,6 +4,7 @@ import os | ||||
| import stat | ||||
| import subprocess as sp | ||||
| import sys | ||||
| from urllib.parse import unquote_to_bytes as unquote | ||||
|  | ||||
|  | ||||
| """ | ||||
| @@ -28,14 +29,17 @@ which does the following respectively, | ||||
| """ | ||||
|  | ||||
|  | ||||
| MOUNT_BASE = b"/run/media/egon/" | ||||
|  | ||||
|  | ||||
| def main(): | ||||
|     try: | ||||
|         label = sys.argv[1].split(":usb-eject:")[1].split(":")[0] | ||||
|         mp = "/run/media/egon/" + label | ||||
|         mp = MOUNT_BASE + unquote(label) | ||||
|         # print("ejecting [%s]... " % (mp,), end="") | ||||
|         mp = os.path.abspath(os.path.realpath(mp.encode("utf-8"))) | ||||
|         mp = os.path.abspath(os.path.realpath(mp)) | ||||
|         st = os.lstat(mp) | ||||
|         if not stat.S_ISDIR(st.st_mode): | ||||
|         if not stat.S_ISDIR(st.st_mode) or not mp.startswith(MOUNT_BASE): | ||||
|             raise Exception("not a regular directory") | ||||
|  | ||||
|         # if you're running copyparty as root (thx for the faith) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user