summaryrefslogtreecommitdiffstats
path: root/src/sbin/bcfg2-crypt
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2012-09-11 10:38:02 -0400
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2012-09-11 10:38:02 -0400
commitd5ef5910898f601e6427c4e34b82a067268010eb (patch)
tree983f568c6f706c6e75c8ba52b466a442e7735190 /src/sbin/bcfg2-crypt
parent65ca13feeef2f5257135f884ae1433fdbb2220ee (diff)
downloadbcfg2-d5ef5910898f601e6427c4e34b82a067268010eb.tar.gz
bcfg2-d5ef5910898f601e6427c4e34b82a067268010eb.tar.bz2
bcfg2-d5ef5910898f601e6427c4e34b82a067268010eb.zip
bcfg2-crypt: added --stdout option
Diffstat (limited to 'src/sbin/bcfg2-crypt')
-rwxr-xr-xsrc/sbin/bcfg2-crypt18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/sbin/bcfg2-crypt b/src/sbin/bcfg2-crypt
index a40bab994..cb1b956fb 100755
--- a/src/sbin/bcfg2-crypt
+++ b/src/sbin/bcfg2-crypt
@@ -321,8 +321,8 @@ def main():
if not setup['args']:
print(setup.hm)
raise SystemExit(1)
- elif setup['encrypt'] and setup['decrypt']:
- print("You cannot specify both --encrypt) and --decrypt")
+ elif setup['encrypt'] and (setup['decrypt_stdout'] or setup['decrypt']):
+ print("You cannot specify both --encrypt and --decrypt or --stdout")
raise SystemExit(1)
elif setup['cfg'] and setup['properties']:
print("You cannot specify both --cfg and --properties")
@@ -375,9 +375,19 @@ def main():
if setup['encrypt']:
if not encryptor.encrypt(fname):
print("Failed to encrypt %s, skipping" % fname)
- elif setup['decrypt']:
- if not encryptor.decrypt(fname):
+ elif setup['decrypt'] or setup['decrypt_stdout']:
+ data = encryptor.decrypt(fname)
+ if not data:
print("Failed to decrypt %s, skipping" % fname)
+ continue
+ if setup['decrypt_stdout']:
+ if len(setup['args']) > 1:
+ print("----- %s -----" % fname)
+ print(data)
+ if len(setup['args']) > 1:
+ print("")
+ else:
+ encryptor.write_decrypted(fname, data=data)
else:
logger.info("Neither --encrypt nor --decrypt specified, "
"determining mode")