mirror of
https://github.com/rwinkhart/sshyp.git
synced 2026-08-28 04:46:34 -04:00
Fix installed extension ownership on FreeBSD
This commit is contained in:
+6
-1
@@ -718,7 +718,12 @@ def wrapped_entry(_gm_device_type, _gm_top_message='configuration options:'):
|
||||
# install with privilege escalation (outside of curses)
|
||||
from tempfile import gettempdir
|
||||
_exe_dir, _ini_dir = f"{gettempdir()}/sshyp_exe", f"{gettempdir()}/sshyp_ini"
|
||||
run((_escalator, 'chown', 'root:root', _exe_dir, _ini_dir))
|
||||
# PORT START TWEAK-EXT-CHOWN
|
||||
if uname()[0] == 'FreeBSD':
|
||||
run((_escalator, 'chown', 'root:wheel', _exe_dir, _ini_dir))
|
||||
else:
|
||||
run((_escalator, 'chown', 'root:root', _exe_dir, _ini_dir))
|
||||
# PORT END TWEAK-EXT-CHOWN
|
||||
run((_escalator, 'mv', _exe_dir, f"/usr/lib/sshyp/{_ext_name}"))
|
||||
run((_escalator, 'mv', _ini_dir, f"/usr/lib/sshyp/extensions/{_ext_name}.ini"))
|
||||
else:
|
||||
|
||||
Executable
+28
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env python3
|
||||
import re
|
||||
from sys import argv
|
||||
|
||||
# read arguments
|
||||
arguments = argv[1:]
|
||||
|
||||
# define PORT target
|
||||
string1 = '# PORT START TWEAK-EXT-CHOWN'
|
||||
string2 = '# PORT END TWEAK-EXT-CHOWN'
|
||||
|
||||
# define replacement text depending on arguments
|
||||
if len(arguments) > 0 and arguments[0] == 'BSD':
|
||||
replacement = "run((_escalator, 'chown', 'root:wheel', _exe_dir, _ini_dir))"
|
||||
else:
|
||||
replacement = "run((_escalator, 'chown', 'root:root', _exe_dir, _ini_dir))"
|
||||
|
||||
# read input file
|
||||
text = open('working/stweak.py', 'r').read()
|
||||
|
||||
# compile regex and modify text
|
||||
regex = re.compile(f"{string1}.*?{string2}", re.DOTALL)
|
||||
|
||||
# find and replace the defined PORT target
|
||||
new_text = re.sub(regex, replacement, text)
|
||||
|
||||
# write updated text
|
||||
open('working/stweak.py', 'w').write(new_text)
|
||||
Reference in New Issue
Block a user