From 3800d603adcf963c40c38bdc2fae24f6dacdf25d Mon Sep 17 00:00:00 2001 From: elijah Date: Tue, 2 Jul 2013 13:53:59 -0700 Subject: prevent compile from happening before adding at least one user ssh key. --- lib/leap_cli/commands/user.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/leap_cli/commands/user.rb b/lib/leap_cli/commands/user.rb index d0146b6..f96d527 100644 --- a/lib/leap_cli/commands/user.rb +++ b/lib/leap_cli/commands/user.rb @@ -14,11 +14,11 @@ require 'gpgme' module LeapCli module Commands - desc 'Adds a new trusted sysadmin' + desc 'Adds a new trusted sysadmin by adding public keys to the "users" directory.' arg_name 'USERNAME' #, :optional => false, :multiple => false command :'add-user' do |c| - c.switch 'self', :desc => 'lets you choose among your public keys', :negatable => false + c.switch 'self', :desc => 'Add yourself as a trusted sysadin by choosing among the public keys available for the current user.', :negatable => false c.flag 'ssh-pub-key', :desc => 'SSH public key file for this new user' c.flag 'pgp-pub-key', :desc => 'OpenPGP public key file for this new user' @@ -120,7 +120,11 @@ module LeapCli def update_authorized_keys buffer = StringIO.new - Dir.glob(path([:user_ssh, '*'])).sort.each do |keyfile| + keys = Dir.glob(path([:user_ssh, '*'])) + if keys.empty? + bail! "You must have at least one public SSH user key configured in order to proceed. See `leap help add-user`." + end + keys.sort.each do |keyfile| ssh_type, ssh_key = File.read(keyfile).strip.split(" ") buffer << ssh_type buffer << " " -- cgit v1.2.3