-
Notifications
You must be signed in to change notification settings - Fork 1
/
resetPermissions.py
executable file
·48 lines (34 loc) · 1.05 KB
/
resetPermissions.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env python3
import json, requests
debug = False
port = 9092
user = 'test'
pw = 'tset'
def debugDump(label, data):
if not debug: return
print(label, json.dumps(data, sort_keys=True, indent=4))
def sendRequest(function, data = None):
url = 'http://127.0.0.1:' + str(port) + function
debugDump('POST: ' + url, data)
resp = requests.post(url=url, json=data, auth=(user, pw))
# gracefully add 401 error
if resp.status_code == 401:
return {'retval': False}
debugDump('RESP', resp.json())
return resp.json()
if __name__ == "__main__":
resp = sendRequest('/rsServiceControl/getOwnServices')
for service in resp['info']['mServiceList']:
name = service["value"]["mServiceName"]
id = service["key"]
req = {'serviceId': id}
resp = sendRequest('/rsServiceControl/getServicePermissions', req)
if not resp['retval']:
continue
p = resp['permissions']
p['mDefaultAllowed'] = True
p['mPeersDenied'].clear()
p['mPeersAllowed'].clear()
# update req
req['permissions'] = p
sendRequest('/rsServiceControl/updateServicePermissions', req)