summaryrefslogtreecommitdiff
path: root/lib/trocla.rb
diff options
context:
space:
mode:
authorasq <asq@asq.art.pl>2014-04-03 17:15:37 +0200
committerasq <asq@asq.art.pl>2014-04-03 17:22:18 +0200
commit4b0cd484e68a806e60a32a6d611333d41ec845aa (patch)
treebf9264582a9b30689a4b68edca4ebad96dbf5988 /lib/trocla.rb
parent9fef5b8d944946ca9ea2f37e30780d3dba1d775e (diff)
add option to generate shell-safe passwords
basically excludes characters that might be dangerous if used in shell. many passwords generated by trocla may end up in some sort of bash scripts (initscripts, sourced shell variables, etc) which may yeld problems with default trocla random generator. this can be now changed either in troclarc (with "shellsafe: true") or on (ie. "trocla create foo plain '{ length: 32, shellsafe: true}'").
Diffstat (limited to 'lib/trocla.rb')
-rw-r--r--lib/trocla.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/trocla.rb b/lib/trocla.rb
index 4e7bedb..7755149 100644
--- a/lib/trocla.rb
+++ b/lib/trocla.rb
@@ -22,7 +22,7 @@ class Trocla
plain_pwd = get_password(key,'plain')
if options['random'] && plain_pwd.nil?
- plain_pwd = Trocla::Util.random_str(options['length'])
+ plain_pwd = Trocla::Util.random_str(options['length'],options['shellsafe'])
set_password(key,'plain',plain_pwd) unless format == 'plain'
elsif !options['random'] && plain_pwd.nil?
raise "Password must be present as plaintext if you don't want a random password"