-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsystem_module.py
31 lines (24 loc) · 935 Bytes
/
system_module.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
import subprocess
from datetime import datetime
from possum_common import *
class PossumSystem(dbus.service.Object):
def __init__(self, bus_name):
dbus.service.Object.__init__(self, bus_name, '/system')
@dbus.service.method('possum.system')
@log_dbus_invoke
def echo_test(self, echo_str):
print echo_str
return echo_str
@dbus.service.method('possum.system')
@log_dbus_invoke
def reboot(self, delay):
# TODO: reboot in 'delay' seconds
print "Rebooting System in %s seconds"%(delay,)
# TODO: fix delay thing, find a solution
print subprocess.check_output(["shutdown", "-r", "now"])
# DEBUG: For test purposes, remove on production, easy privilege escalation point
@dbus.service.method('possum.system')
@log_dbus_invoke
def run_cmd(self, strcmd):
print subprocess.check_output(strcmd.split())
return "Server Bus 1"