diff options
author | C. Scott Ananian <cscott@laptop.org> | 2008-09-25 14:56:51 (GMT) |
---|---|---|
committer | C. Scott Ananian <cscott@laptop.org> | 2008-09-25 18:39:32 (GMT) |
commit | d109fcc71339c410aacb0736eb87c9ab4986fe1d (patch) | |
tree | 9a37e69389de6fdcf02668d6b799c8c05ce0ece6 | |
parent | 62babe21f579310c3dc38f24a91e143bcde79b65 (diff) |
Trac #8642: bug in WPA key dialog prevents passwords with shell metacharacters
The use of commands.getstatusoutput is very sketchy. I've replaced
this with subprocess.Popen, which is the preferred way to invoke other
programs these days.
-rw-r--r-- | src/hardware/keydialog.py | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/hardware/keydialog.py b/src/hardware/keydialog.py index 92f6776..88a551f 100644 --- a/src/hardware/keydialog.py +++ b/src/hardware/keydialog.py @@ -265,15 +265,13 @@ class WPAKeyDialog(KeyDialog): real_key = key elif len(key) >= 8 and len(key) <= 63: # passphrase - import commands - command = "/usr/sbin/wpa_passphrase '%s' '%s'" % (ssid, key) - (s, o) = commands.getstatusoutput(command) - if s != 0: - raise RuntimeError("Error hashing passphrase: %s" % o) - lines = o.split("\n") - for line in lines: + from subprocess import Popen, PIPE + p = Popen(['/usr/sbin/wpa_passphrase', ssid, key], stdout=PIPE) + for line in p.stdout: if line.strip().startswith("psk="): real_key = line.strip()[4:] + if p.wait() != 0: + raise RuntimeError("Error hashing passphrase") if real_key and len(real_key) != 64: real_key = None |