diff options
author | Robin H. Johnson <robbat2@gentoo.org> | 2007-12-24 03:42:37 -0800 |
---|---|---|
committer | Robin H. Johnson <robbat2@gentoo.org> | 2007-12-24 03:42:37 -0800 |
commit | be82f264fe8f3670c76cb5e172c1d659cfa5f823 (patch) | |
tree | 2fbe26589d6a4089b368f138f1c7630f40eac01d | |
parent | Exclude spaces from valid chars in username in command. (diff) | |
download | gitosis-dakkar-be82f264fe8f3670c76cb5e172c1d659cfa5f823.tar.gz gitosis-dakkar-be82f264fe8f3670c76cb5e172c1d659cfa5f823.tar.bz2 gitosis-dakkar-be82f264fe8f3670c76cb5e172c1d659cfa5f823.zip |
Allow passing in a file for the admin key, and overriding the default key name.
-rw-r--r-- | gitosis/init.py | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/gitosis/init.py b/gitosis/init.py index ffc0215..cb21cbd 100644 --- a/gitosis/init.py +++ b/gitosis/init.py @@ -21,7 +21,7 @@ from gitosis import app log = logging.getLogger('gitosis.init') def read_ssh_pubkey(fp=None): #pragma: no cover - """Read an SSH public key from stdin.""" + """Read an SSH public key from stdin or file.""" if fp is None: fp = sys.stdin line = fp.readline() @@ -92,7 +92,20 @@ class Main(app.App): parser = super(Main, self).create_parser() parser.set_usage('%prog [OPTS]') parser.set_description( - 'Initialize a user account for use with gitosis') + 'Initialize a user account for use with gitosis' + ) + parser.set_defaults( + adminkey=None, + adminname=None, + ) + parser.add_option('--adminkey', + metavar='FILE', + help='Admin SSH public key FILE location', + ) + parser.add_option('--adminname', + metavar='STRING', + help='Name for administrator public key file', + ) return parser def read_config(self, options, cfg): @@ -111,8 +124,11 @@ class Main(app.App): os.umask(0022) log.info('Reading SSH public key...') - pubkey = read_ssh_pubkey() - user = sshkey.extract_user(pubkey) + pubkey = read_ssh_pubkey(options.adminkey) + if options.adminname is None: + user = sshkey.extract_user(pubkey) + else: + user = options.adminname if user is None: log.error('Cannot parse user from SSH public key.') sys.exit(1) |