blob: 629e4157460fd4fca8ee7c0d0d5ef97b758a73f1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
#!/usr/bin/env python3
import os
import subprocess
from base64 import encodestring as encode
HELPDIR = '../../src/leap/bitmask/vpn/helpers/linux/'
INSTALL = '../../snap/hooks/install'
POLKIT_FILE = 'se.leap.bitmask.riseupvpn.policy'
with open(os.path.join(HELPDIR, POLKIT_FILE)) as polkit:
b64_polkit = encode(polkit.read().encode())
with open(INSTALL, 'w') as install:
install.write('#!/usr/bin/env python3\n')
install.write('# This helper installs bitmask-root and polkit policy file\n')
install.write('import subprocess\n')
install.write('from base64 import decodestring as decode\n')
install.write("""
POLKIT = {polkit}
with open('/usr/share/polkit-1/actions/{polkit_file}', 'w') as polkit:
lines = decode(POLKIT).split(b"\\n")
for line in lines:
polkit.write(line.decode() + "\\n")
""".format(polkit=b64_polkit, polkit_file=POLKIT_FILE))
subprocess.Popen(["chmod", "+x", INSTALL])
print("done packing installers into the snap install hook...")
|