diff options
| author | Zack Hobson | 2013-12-21 18:52:38 -0800 |
|---|---|---|
| committer | Zack Hobson | 2013-12-21 18:52:38 -0800 |
| commit | 8fa144bcc347b31f4fa661d172fdd27fd351ee5b (patch) | |
| tree | d520a9edcd72dcf9f78ac292e77b060da121ad3d /lib | |
| parent | fd426b4a0476f517e7b956de46f3d25e4e86f7b6 (diff) | |
| download | hcl-8fa144bcc347b31f4fa661d172fdd27fd351ee5b.tar.bz2 | |
app: improved check for OSX `security` command
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/hcl/app.rb | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/hcl/app.rb b/lib/hcl/app.rb index f164ff5..e58921f 100644 --- a/lib/hcl/app.rb +++ b/lib/hcl/app.rb @@ -139,7 +139,7 @@ EOM def read_config if File.exists? CONFIG_FILE config = YAML::load(File.read(CONFIG_FILE)) || {} - if has_security_command + if has_security_command? load_password config end TimesheetResource.configure config @@ -165,7 +165,7 @@ EOM def write_config config puts "Writing configuration to #{CONFIG_FILE}." - if has_security_command + if has_security_command? save_password config end File.open(CONFIG_FILE, 'w') do |f| @@ -192,9 +192,10 @@ EOM nil end - def has_security_command + def has_security_command? if @has_security.nil? - @has_security = File.exists?('/usr/bin/security') + @has_security = File.exists?('/usr/bin/security') && + (`/usr/bin/security error 1` =~ /CSSM_ERRCODE_INTERNAL_ERROR/) else @has_security end |
