mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-22 14:49:24 +01:00
test: Avoid input() in simple-agent.py.
That function reads a string of python code and immediately executes it. This required passphrases to be input as python literals, we can just use a string as passphrase instead.
This commit is contained in:
parent
99cdb860c0
commit
4bf109a7ce
@ -20,42 +20,20 @@ class Agent(dbus.service.Object):
|
|||||||
print("Release")
|
print("Release")
|
||||||
mainloop.quit()
|
mainloop.quit()
|
||||||
|
|
||||||
def input_passphrase(self):
|
|
||||||
response = {}
|
|
||||||
|
|
||||||
if not self.passphrase:
|
|
||||||
print("Service credentials requested, type cancel to cancel")
|
|
||||||
args = input('Answer: ')
|
|
||||||
|
|
||||||
for arg in args.split():
|
|
||||||
if arg.startswith("cancel"):
|
|
||||||
response["Error"] = arg
|
|
||||||
|
|
||||||
if arg.startswith("Passphrase="):
|
|
||||||
passphrase = arg.replace("Passphrase=", "", 1)
|
|
||||||
response["Passphrase"] = passphrase
|
|
||||||
else:
|
|
||||||
if self.passphrase:
|
|
||||||
response["Passphrase"] = self.passphrase
|
|
||||||
|
|
||||||
return response
|
|
||||||
|
|
||||||
@dbus.service.method("net.connman.iwd.Agent",
|
@dbus.service.method("net.connman.iwd.Agent",
|
||||||
in_signature='o',
|
in_signature='o',
|
||||||
out_signature='s')
|
out_signature='s')
|
||||||
def RequestPassphrase(self, path):
|
def RequestPassphrase(self, path):
|
||||||
print("RequestPassphrase (%s)" % (path))
|
print("RequestPassphrase (%s)" % (path))
|
||||||
|
|
||||||
response = {}
|
print("Service credentials requested, type cancel to cancel")
|
||||||
response.update(self.input_passphrase())
|
passphrase = raw_input('Answer: ')
|
||||||
|
|
||||||
if response.has_key("Error"):
|
if not passphrase or passphrase == 'cancel':
|
||||||
if response["Error"] == "cancel":
|
raise Canceled("canceled")
|
||||||
raise Canceled("canceled")
|
|
||||||
return
|
|
||||||
|
|
||||||
print("returning (%s)" % (response["Passphrase"]))
|
print("returning (%s)" % (passphrase))
|
||||||
return response["Passphrase"]
|
return passphrase
|
||||||
|
|
||||||
@dbus.service.method("net.connman.iwd.Agent",
|
@dbus.service.method("net.connman.iwd.Agent",
|
||||||
in_signature='', out_signature='')
|
in_signature='', out_signature='')
|
||||||
|
Loading…
Reference in New Issue
Block a user