summaryrefslogtreecommitdiffstats
path: root/ipapython
diff options
context:
space:
mode:
authorJan Cholasta <jcholast@redhat.com>2016-11-22 15:38:43 +0100
committerMartin Basti <mbasti@redhat.com>2016-11-29 14:50:51 +0100
commit6e50fae9ec6dea35e12a65dbc46228a1e6276e07 (patch)
tree7c5900b0384ebb99ff33f463b58170920657ac63 /ipapython
parent7d5c680ace7ccea3b0f7f1471cf8dbc07b3da5a1 (diff)
downloadfreeipa-6e50fae9ec6dea35e12a65dbc46228a1e6276e07.tar.gz
freeipa-6e50fae9ec6dea35e12a65dbc46228a1e6276e07.tar.xz
freeipa-6e50fae9ec6dea35e12a65dbc46228a1e6276e07.zip
ipautil: move file encryption functions to installutils
The encrypt_file() and decrypt_file() functions depend on ipaplatform. Move them to ipaserver.install.installutils, as they are only used for the server installer. https://fedorahosted.org/freeipa/ticket/6474 Reviewed-By: Stanislav Laznicka <slaznick@redhat.com>
Diffstat (limited to 'ipapython')
-rw-r--r--ipapython/ipautil.py57
1 files changed, 0 insertions, 57 deletions
diff --git a/ipapython/ipautil.py b/ipapython/ipautil.py
index 6a2118bc8..654fdd97e 100644
--- a/ipapython/ipautil.py
+++ b/ipapython/ipautil.py
@@ -49,7 +49,6 @@ from six.moves import input
from six.moves import urllib
from ipapython.ipa_log_manager import root_logger
-from ipaplatform.paths import paths
from ipapython.dn import DN
GEN_PWD_LEN = 22
@@ -535,62 +534,6 @@ def backup_file(fname):
if file_exists(fname):
os.rename(fname, fname + ".orig")
-def _ensure_nonempty_string(string, message):
- if not isinstance(string, str) or not string:
- raise ValueError(message)
-
-# uses gpg to compress and encrypt a file
-def encrypt_file(source, dest, password, workdir = None):
- _ensure_nonempty_string(source, 'Missing Source File')
- #stat it so that we get back an exception if it does no t exist
- os.stat(source)
-
- _ensure_nonempty_string(dest, 'Missing Destination File')
- _ensure_nonempty_string(password, 'Missing Password')
-
- #create a tempdir so that we can clean up with easily
- tempdir = tempfile.mkdtemp('', 'ipa-', workdir)
- gpgdir = tempdir+"/.gnupg"
-
- try:
- try:
- #give gpg a fake dir so that we can leater remove all
- #the cruft when we clean up the tempdir
- os.mkdir(gpgdir)
- args = [paths.GPG_AGENT, '--batch', '--homedir', gpgdir, '--daemon', paths.GPG, '--batch', '--homedir', gpgdir, '--passphrase-fd', '0', '--yes', '--no-tty', '-o', dest, '-c', source]
- run(args, password, skip_output=True)
- except:
- raise
- finally:
- #job done, clean up
- shutil.rmtree(tempdir, ignore_errors=True)
-
-
-def decrypt_file(source, dest, password, workdir = None):
- _ensure_nonempty_string(source, 'Missing Source File')
- #stat it so that we get back an exception if it does no t exist
- os.stat(source)
-
- _ensure_nonempty_string(dest, 'Missing Destination File')
- _ensure_nonempty_string(password, 'Missing Password')
-
- #create a tempdir so that we can clean up with easily
- tempdir = tempfile.mkdtemp('', 'ipa-', workdir)
- gpgdir = tempdir+"/.gnupg"
-
- try:
- try:
- #give gpg a fake dir so that we can leater remove all
- #the cruft when we clean up the tempdir
- os.mkdir(gpgdir)
- args = [paths.GPG_AGENT, '--batch', '--homedir', gpgdir, '--daemon', paths.GPG, '--batch', '--homedir', gpgdir, '--passphrase-fd', '0', '--yes', '--no-tty', '-o', dest, '-d', source]
- run(args, password, skip_output=True)
- except:
- raise
- finally:
- #job done, clean up
- shutil.rmtree(tempdir, ignore_errors=True)
-
class CIDict(dict):
"""