diff options
author | Jason Kincl <kincljc@ornl.gov> | 2012-11-19 10:37:34 -0500 |
---|---|---|
committer | Jason Kincl <kincljc@ornl.gov> | 2012-11-19 10:37:34 -0500 |
commit | 894299b01b6138c54a99fd41f166554d175d6106 (patch) | |
tree | 88e11cb8c49d3f933cf5f622a93dfa123922960f /src/sbin | |
parent | de0ae51b6dc635a3acd2491d4ca3fd021aa55873 (diff) | |
parent | f4da37aa0a360add3f5c40f37cd3cc010ef8788f (diff) | |
download | bcfg2-894299b01b6138c54a99fd41f166554d175d6106.tar.gz bcfg2-894299b01b6138c54a99fd41f166554d175d6106.tar.bz2 bcfg2-894299b01b6138c54a99fd41f166554d175d6106.zip |
Merge remote branch 'upstream/master' into jasons-hacking
Diffstat (limited to 'src/sbin')
-rwxr-xr-x | src/sbin/bcfg2-crypt | 19 | ||||
-rwxr-xr-x | src/sbin/bcfg2-info | 7 |
2 files changed, 15 insertions, 11 deletions
diff --git a/src/sbin/bcfg2-crypt b/src/sbin/bcfg2-crypt index 0693b430c..961a8dc58 100755 --- a/src/sbin/bcfg2-crypt +++ b/src/sbin/bcfg2-crypt @@ -4,6 +4,7 @@ import os import sys import copy +import select import logging import lxml.etree import Bcfg2.Logger @@ -31,7 +32,7 @@ class Encryptor(object): self.passphrase = None self.pname = None self.logger = logging.getLogger(self.__class__.__name__) - + def get_encrypted_filename(self, plaintext_filename): """ get the name of the file encrypted data should be written to """ return plaintext_filename @@ -67,7 +68,7 @@ class Encryptor(object): if self.setup['passphrase']: self.pname = self.setup['passphrase'] - + if self.pname: if self.setup.cfp.has_option("encryption", self.pname): self.passphrase = self.setup.cfp.get("encryption", @@ -182,7 +183,7 @@ class Encryptor(object): self.logger.error("Error getting encrypted data from %s: %s" % (fname, err)) return False - + try: return self.unchunk(plaintext, crypted) except EncryptionChunkingError: @@ -317,10 +318,14 @@ class PropertiesEncryptor(Encryptor): print(lxml.etree.tostring( elt, xml_declaration=False).decode("UTF-8").strip()) + # flush input buffer + while len(select.select([sys.stdin.fileno()], [], [], + 0.0)[0]) > 0: + os.read(sys.stdin.fileno(), 4096) ans = input("Encrypt this element? [y/N] ") if not ans.lower().startswith("y"): elements.remove(element) - + # this is not a good use of a generator, but we need to # generate the full list of elements in order to ensure that # some exist before we know what to return @@ -386,11 +391,11 @@ def main(): # pylint: disable=R0912,R0915 elif setup['interactive']: logger.error("Cannot decrypt interactively") setup['interactive'] = False - + if setup['cfg']: if setup['properties']: logger.error("You cannot specify both --cfg and --properties") - raise SystemExit(1) + raise SystemExit(1) if setup['xpath']: logger.error("Specifying --xpath with --cfg is nonsensical, " "ignoring --xpath") @@ -411,7 +416,7 @@ def main(): # pylint: disable=R0912,R0915 if not os.path.exists(fname): logger.error("%s does not exist, skipping" % fname) continue - + # figure out if we need to encrypt this as a Properties file # or as a Cfg file props = False diff --git a/src/sbin/bcfg2-info b/src/sbin/bcfg2-info index 7277fa765..acb9e4f44 100755 --- a/src/sbin/bcfg2-info +++ b/src/sbin/bcfg2-info @@ -94,7 +94,7 @@ def load_interpreters(): best = "bpython" except ImportError: pass - + try: # whether ipython is actually better than bpython is # up for debate, but this is the behavior that existed @@ -454,7 +454,7 @@ Bcfg2 client itself.""") print(lxml.etree.tostring(pfile.XMLMatch(metadata), xml_declaration=False, pretty_print=True).decode('UTF-8')) - + def do_bundles(self, _): """ bundles - Print out group/bundle info """ data = [('Group', 'Bundles')] @@ -503,7 +503,6 @@ Bcfg2 client itself.""") pretty = True alist.remove('-p') if len(alist) != 1: - print 'alist=%s' % alist print(self._get_usage(self.do_probes)) return hostname = alist[0] @@ -736,7 +735,7 @@ Bcfg2 client itself.""") def _block(self): pass - + def build_usage(): |