-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathaddPolicy.py
executable file
·34 lines (27 loc) · 1.22 KB
/
addPolicy.py
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
28
29
30
31
32
33
34
#!/usr/bin/env python3
import sys, os
path = sys.argv[1]
policyData = """<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE policyconfig PUBLIC
"-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
"http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd">
<policyconfig>
<action id="it.binbash.pkexec.salt">
<message>Tranparent authentication for SALT</message>
<defaults>
<allow_any>yes</allow_any>
<allow_inactive>yes</allow_inactive>
<allow_active>yes</allow_active>
</defaults>
<annotate key="org.freedesktop.policykit.exec.path">{}</annotate>
<annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
</action>
</policyconfig>"""
if not os.path.isdir('/usr/share/polkit-1/actions'):
print("The polkit directory does not exist/is not in the expected location. Please add the policy manually")
exit()
if os.path.isfile('/usr/share/polkit-1/actions/it.binbash.pkexec.salt.policy'):
# Possibly an outdated version so we will remove it to be safe
os.remove('/usr/share/polkit-1/actions/it.binbash.pkexec.salt.policy')
with open('/usr/share/polkit-1/actions/it.binbash.pkexec.salt.policy','w') as policyFile:
policyFile.write(policyData.format(path))