[PATCH pycryptsetup] Updated the fillins.py

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



subprocess.Popen() does not work with arguments containing spaces,
have to use params.extend(["something", "something"])
instead of params.append("something something").

"cryptsetup luksRemoveKey" asks for the phrase we want to delete first,
so it must be written to the pipe prior to the verification phrase.
---
 pycryptsetup/fillins.py |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/pycryptsetup/fillins.py b/pycryptsetup/fillins.py
index e752d6b..0542f8d 100644
--- a/pycryptsetup/fillins.py
+++ b/pycryptsetup/fillins.py
@@ -90,7 +90,7 @@ def luks_add_key(device,
     if passphrase:
         os.write(p[1], "%s\n" % passphrase)
     elif key_file and os.path.isfile(key_file):
-        params.append("--key-file %s" % key_file)
+        params.extend(["--key-file", key_file])
     else:
         raise ValueError(_("luks_add_key requires either a passphrase or a key file"))
 
@@ -119,20 +119,26 @@ def luks_remove_key(device,
                     del_passphrase=None, del_key_file=None,
                     passphrase=None, key_file=None):
 
-    params = ["-q"]
+    # segfaults with -q, not needed
+    params = []
 
     p = os.pipe()
+
+    # this is the first cryptsetup question
+    if del_passphrase:
+        os.write(p[1], "%s\n" % del_passphrase)
+    
     if passphrase:
         os.write(p[1], "%s\n" % passphrase)
     elif key_file and os.path.isfile(key_file):
-        params.append("--key-file %s" % key_file)
+        params.extend(["--key-file", key_file])
     else:
         raise ValueError(_("luks_remove_key requires either a passphrase or a key file"))
 
     params.extend(["luksRemoveKey", device])
 
     if del_passphrase:
-        os.write(p[1], "%s\n" % del_passphrase)
+        pass
     elif del_key_file and os.path.isfile(del_key_file):
         params.append("%s" % del_key_file)
     else:
-- 
1.6.0.6

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux