forj 0.0.42 → 0.0.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/forj-account.rb +37 -12
  3. data/lib/security.rb +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 86bafd8e907ea87422d3ffe34ee5d64030530de9
4
- data.tar.gz: d129b3a2b79f4c4217730078c135c32ca25e6c96
3
+ metadata.gz: cc168384e8283de3099794ba3fb85759286de890
4
+ data.tar.gz: 216c1d4e25503388473f88a2cce2db26674dc0d2
5
5
  SHA512:
6
- metadata.gz: 82ededa706f07e22540a5563e567ff78f0631cb3c5b5779113382d93c755880080cece6f8e2ffc367aea45b8f91147a1daf273b1dde7fa10036bffbb72b980df
7
- data.tar.gz: 48abdf7a3e8b2efdecccd488fb2a67eba44d607709d5d29899ef75f0628d28e7757178e3490b977a740f5d502f753f48eef60cb4c07d9ab8c7776cacc89fe1d7
6
+ metadata.gz: 5c5edfe564a87533f683f25137a4cca65ad6fe642c160d729d73efcf66656614ba26e53d76fda270811c5b64a59715eadd795699bfbe1854b1f6b4ac651e7fa5
7
+ data.tar.gz: e0c005a6db73411311b85cece7979536cd56709d25644d182128a63eca8355f724fea32c39a3052f41fa2559f62b39419d3e10666ccd2cfe42928bc400d15a1b
data/lib/forj-account.rb CHANGED
@@ -81,7 +81,11 @@ class ForjAccount
81
81
  key = key.to_sym if key.class == String
82
82
  section = rhGet(@oConfig.getAppDefault(:account_section_mapping, key), :section)
83
83
  yInterm = nil
84
- yInterm = rhGet(@hAccountData, section) if section
84
+ if section
85
+ yInterm = rhGet(@hAccountData, section)
86
+ else
87
+ Logging.debug("ForjAccount.get: No section found for key '%s'." % [key])
88
+ end
85
89
  @oConfig.get(key, yInterm , default )
86
90
  end
87
91
 
@@ -430,12 +434,15 @@ class ForjAccount
430
434
  q.default = forj_user if forj_user
431
435
  end
432
436
 
433
-
434
437
  # Checking key file used to encrypt/decrypt passwords
435
438
  key_file = File.join($FORJ_CREDS_PATH, '.key')
436
439
  if not File.exists?(key_file)
437
440
  # Need to create a random key.
438
- entr = { :key => rand(36**10).to_s(36), :salt => Time.now.to_i.to_s, :iv => OpenSSL::Cipher::Cipher.new('aes-256-cbc').random_iv}
441
+ entr = {
442
+ :key => rand(36**10).to_s(36),
443
+ :salt => Time.now.to_i.to_s,
444
+ :iv => Base64::strict_encode64(OpenSSL::Cipher::Cipher.new('aes-256-cbc').random_iv)
445
+ }
439
446
 
440
447
  Logging.debug("Writing '%s' key file" % key_file)
441
448
  File.open(key_file, 'w') do |out|
@@ -448,14 +455,20 @@ class ForjAccount
448
455
  end
449
456
 
450
457
  if enc_hpcloud_os_key
451
- hpcloud_os_key_hidden = '*' * Encryptor.decrypt(
452
- :value => Base64::strict_decode64(enc_hpcloud_os_key),
453
- :key => entr[:key],
454
- :iv => entr[:iv],
455
- :salt => entr[:salt]
458
+ begin
459
+ hpcloud_os_key_hidden = '*' * Encryptor.decrypt(
460
+ :value => Base64::strict_decode64(enc_hpcloud_os_key),
461
+ :key => entr[:key],
462
+ :iv => Base64::strict_decode64(entr[:iv]),
463
+ :salt => entr[:salt]
456
464
  ).length
457
- hpcloud_os_key_hidden="[%s]" % hpcloud_os_key_hidden
458
- Logging.message("A password is already set for '%s'. If you want to keep it, just press Enter" % [hpcloud_os_user])
465
+ rescue => e
466
+ Logging.error("Unable to decrypt your password. You will need to re-enter it.")
467
+ enc_hpcloud_os_key = ""
468
+ else
469
+ hpcloud_os_key_hidden="[%s]" % hpcloud_os_key_hidden
470
+ Logging.message("A password is already set for '%s'. If you want to keep it, just press Enter" % [hpcloud_os_user])
471
+ end
459
472
  else
460
473
  hpcloud_os_key_hidden = ""
461
474
  end
@@ -467,12 +480,24 @@ class ForjAccount
467
480
  q.echo = '*'
468
481
  end
469
482
  if hpcloud_os_key == "" and enc_hpcloud_os_key
470
- hpcloud_os_key = Encryptor.decrypt(:value => Base64::strict_decode64(enc_hpcloud_os_key), :key => entr[:key], :iv => entr[:iv], :salt => entr[:salt])
483
+ hpcloud_os_key = Encryptor.decrypt(
484
+ :value => Base64::strict_decode64(enc_hpcloud_os_key),
485
+ :key => entr[:key],
486
+ :iv => Base64::strict_decode64(entr[:iv]),
487
+ :salt => entr[:salt]
488
+ )
471
489
  else
472
490
  Logging.message("The password cannot be empty.") if hpcloud_os_key == ""
473
491
  end
474
492
  end
475
- enc_hpcloud_os_key = Base64::strict_encode64(Encryptor.encrypt(:value => hpcloud_os_key, :key => entr[:key], :iv => entr[:iv], :salt => entr[:salt]))
493
+ enc_hpcloud_os_key = Base64::strict_encode64(
494
+ Encryptor.encrypt(
495
+ :value => hpcloud_os_key,
496
+ :key => entr[:key],
497
+ :iv => Base64::strict_decode64(entr[:iv]),
498
+ :salt => entr[:salt]
499
+ )
500
+ )
476
501
 
477
502
  cloud_fog = File.join($FORJ_CREDS_PATH, @sAccountName+'.g64')
478
503
 
data/lib/security.rb CHANGED
@@ -173,7 +173,7 @@ module SecurityGroup
173
173
  def hpc_import_key(oForjAccount)
174
174
 
175
175
  keys = keypair_detect(oForjAccount.get('keypair_name'), oForjAccount.get('keypair_path'))
176
- account = oForjAccount.get(:name)
176
+ account = oForjAccount.getAccountData(:account, :name)
177
177
 
178
178
  Logging.fatal(1, "'keypair_path' undefined. check your config.yaml file.") if not keys[:keypair_path]
179
179
  Logging.fatal(1, "'keypair_name' undefined. check your config.yaml file.") if not keys[:keypair_name]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: forj
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.42
4
+ version: 0.0.43
5
5
  platform: ruby
6
6
  authors:
7
7
  - forj team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-12 00:00:00.000000000 Z
11
+ date: 2014-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor