|
From: <di...@us...> - 2007-01-26 04:27:06
|
Revision: 297
http://safekeep.svn.sourceforge.net/safekeep/?rev=297&view=rev
Author: dimi
Date: 2007-01-25 20:27:04 -0800 (Thu, 25 Jan 2007)
Log Message:
-----------
Make the keys options more like options rather then
mode selectors. This means that any combination of them
is now valid as input on the command line.
Addition documentation work to match these changes.
Modified Paths:
--------------
safekeep/trunk/doc/safekeep.txt
safekeep/trunk/safekeep
Modified: safekeep/trunk/doc/safekeep.txt
===================================================================
--- safekeep/trunk/doc/safekeep.txt 2007-01-26 04:09:05 UTC (rev 296)
+++ safekeep/trunk/doc/safekeep.txt 2007-01-26 04:27:04 UTC (rev 297)
@@ -11,7 +11,7 @@
'safekeep' --client
-'safekeep' --keys [-q] [-v] [--status|--print|--deploy] <clientid>*
+'safekeep' --keys [-q] [-v] [--status] [--print] [--deploy] <clientid>*
'safekeep' -h | -V
@@ -43,8 +43,8 @@
Each mode accepts a few options as described below.
-OPTIONS
--------
+OPERATION MODE
+--------------
--server::
Selects the server mode (default)
@@ -56,6 +56,9 @@
--keys::
Selects the SSH key management mode
+
+GENERAL OPTIONS
+---------------
-h, --help::
Selects the help mode, in which safekeep prints out the
online help and exits.
@@ -72,6 +75,8 @@
Increases the verbosity level. Can be specified more than
once.
+SERVER OPTIONS
+--------------
-C, --cfg=FILE|DIR::
Specifies the configuration file location.
This can be a single file (for a single client configuration)
@@ -88,14 +93,20 @@
Specifies the SMTP server used for sending
mails when `-e` is used. Defaults to `localhost`.
+KEYS OPTIONS
+------------
--status::
- (key mode only) Display the key status for the clients.
+ Display the key status for the clients. It is implied if no other
+ option is specified. In effect this option prints the steps that
+ will be taken when the keys are deployed to the client.
--print::
- (key mode only) Display the authorization keys for the clients.
+ Display the authorization keys for the clients. This is useful in
+ case you want to manually copy it into the client's
+ `~/.ssh/authorized_keys` file. This option is seldom useful.
--deploy::
- (key mode only) Deploy the authorization keys on the clients.
+ Deploy the authorization keys on the clients.
Configuration file
------------------
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2007-01-26 04:09:05 UTC (rev 296)
+++ safekeep/trunk/safekeep 2007-01-26 04:27:04 UTC (rev 297)
@@ -588,7 +588,7 @@
debug('Server backup done')
-def do_keys(cfgs, ids, action):
+def do_keys(cfgs, ids, status, dump, deploy):
matches = []
for cfg in cfgs:
id = cfg['id']
@@ -608,13 +608,13 @@
if os.path.isfile(publickeyfile):
error('%s: Public key exists %s, but private key is missing. Skipping client.' % (id, publickeyfile))
break
- if action is 'print':
- print '%s: Key do not exist: %s.' % (id, privatekeyfile)
+ if dump:
+ print '%s: Key does not exist: %s.' % (id, privatekeyfile)
break
- if action is 'status':
- print '%s: Key do not exist: %s. Will be generated.' % (id, privatekeyfile)
+ if status:
+ print '%s: Key does not exist: %s. Will be generated.' % (id, privatekeyfile)
break
- elif action is 'deploy':
+ if deploy:
info('%s: Key do not exist, generating it now: %s' % (id, privatekeyfile))
gencmd = 'ssh-keygen -q -b 1024 -t dsa -N "" -C "SafeKeep auto generated key at %s@%s" -f %s' % \
(os.environ['LOGNAME'], os.uname()[1], privatekeyfile)
@@ -637,9 +637,9 @@
continue
output = '\n'.join(lines)
- if action is 'print':
+ if dump:
print output
- elif action in ('status', 'deploy'):
+ if status or deploy:
cmd = 'ssh %s@%s "if test -f .ssh/authorized_keys; then cat .ssh/authorized_keys; fi"' % (cfg['user'], cfg['host'])
debug(cmd)
out = os.popen(cmd, 'r')
@@ -655,21 +655,19 @@
else:
new_keys.append(this_key)
if not new_keys:
- if action is 'status':
+ if status:
print '%s: Client is up to date.' % id
continue
- if action is 'deploy':
+ if status:
+ print '%s: Keys will be deployed on the client.' % id
+ if deploy:
cmd = 'ssh %s@%s "umask 077; test -d .ssh || mkdir .ssh; cat >> .ssh/authorized_keys"' % (cfg['user'], cfg['host'])
debug(cmd)
pipe = os.popen(cmd, 'w')
pipe.write('\n'.join([key[4] for key in new_keys]))
if pipe.close():
error('Failed to deliver the keys to the client')
- elif action is 'status':
- print '%s: Keys will be deployed on the client.' % id
- else:
- assert False, 'Unknown action: %s' % action
for id in ids:
if id not in matches:
@@ -776,7 +774,9 @@
cfglocs = []
verbosity = 0
clientid = None
- action = None
+ keys_status = None
+ keys_print = None
+ keys_deploy = None
for o, a in opts:
if o in ('-C', '--cfg'):
cfglocs.append(a)
@@ -794,11 +794,11 @@
elif o in ('--keys', ):
mode = 'keys'
elif o in ('--status', ):
- action = 'status'
+ keys_status = True
elif o in ('--print', ):
- action = 'print'
+ keys_print = True
elif o in ('--deploy', ):
- action = 'deploy'
+ keys_deploy = True
elif o in ('-q', '--quiet'):
verbosity -= 1
elif o in ('-v', '--verbose'):
@@ -824,8 +824,9 @@
elif mode == 'keys':
is_client = False
verbosity_level = 1 + verbosity
- if not action: action = 'status'
- do_keys(cfgs, args, action)
+ if not keys_status and not keys_print and not keys_deploy:
+ keys_status = True
+ do_keys(cfgs, args, keys_status, keys_print, keys_deploy)
else:
assert False, 'Unkown mode: ' + mode
except Exception, ex:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|