Forráskód Böngészése

Fix Windows/Mac OS X bugs

oz123 10 éve
szülő
commit
e6cf1a79e2
2 módosított fájl, 13 hozzáadás és 10 törlés
  1. 9 7
      pwman/ui/mac.py
  2. 4 3
      pwman/ui/win.py

+ 9 - 7
pwman/ui/mac.py

@@ -20,11 +20,12 @@
 # ============================================================================
 # pylint: disable=I0011
 from __future__ import print_function
-"all mac os  related classes"
 
+import time
+# all mac os  related classes
 from pwman.ui.cli import PwmanCli
 from pwman.ui import tools
-import time
+from pwman.util.crypto_engine import CryptoEngine
 
 # pylint: disable=R0904
 
@@ -37,13 +38,14 @@ class PwmanCliMac(PwmanCli):
         ids = self._get_ids(args)
         if len(ids) > 1:
             print("Can only 1 password at a time...")
+            return None
         try:
             node = self._db.getnodes(ids)
-            node[0].get_password()
-            tools.text_to_mcclipboard(node[0].get_password())
-            print("copied password for {}@{} clipboard".format(
-                  node[0].get_username(), node[0].get_url()))
-            time.sleep(10)
+            ce = CryptoEngine.get()
+            password = ce.decrypt(node[2])
+            tools.text_to_clipboards(password)
+            print("erasing in 10 sec...")
+            time.sleep(10)  # TODO: this should be configurable!
             tools.text_to_clipboards("")
         except Exception as e:
             self.error(e)

+ 4 - 3
pwman/ui/win.py

@@ -36,6 +36,7 @@ from pwman.ui.cli import PwmanCli
 from pwman.data.nodes import Node
 from pwman.ui import tools
 from pwman.util.crypto_engine import zerome
+from pwman.util.crypto_engine import CryptoEngine
 
 
 def winGetClipboard():
@@ -171,9 +172,9 @@ class PwmanCliWin(PwmanCli):
             return None
         try:
             node = self._db.getnodes(ids)
-            winSetClipboard(node[0].password)
-            print("copied password for {}@{} clipboard".format(
-                  node[0].username, node[0].url))
+            ce = CryptoEngine.get()
+            password = ce.decrypt(node[2])
+            winSetClipboard(password)
             print("erasing in 10 sec...")
             time.sleep(10)
             winSetClipboard("")