1
0
mirror of https://github.com/Yubico/yubiadmin.git synced 2025-02-20 14:54:30 +01:00

Added yubiadmin-config tool.

This commit is contained in:
Dain Nilsson 2013-05-16 11:19:45 +02:00
parent 73f955c0a6
commit 5e0dcebf8c
4 changed files with 197 additions and 5 deletions

View File

@ -1,4 +1,30 @@
#!/usr/bin/python
# Copyright (c) 2013 Yubico AB
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or
# without modification, are permitted provided that the following
# conditions are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided
# with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
import os
import base64

100
bin/yubiadmin-config Executable file
View File

@ -0,0 +1,100 @@
#!/usr/bin/python
# Copyright (c) 2013 Yubico AB
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or
# without modification, are permitted provided that the following
# conditions are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided
# with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
import sys
import argparse
from yubiadmin.apps.admin import admin_config
def get_interactive(config):
print 'Specify which interface to listen to.'
print '127.0.0.1 will only be accessible from the local machine.'
print '0.0.0.0 will be accessible from any interface.'
print 'Press enter to keep the current settings.'
interface = raw_input('Interface [%s]: ' % config['interface'])
if interface:
config['interface'] = interface
port = raw_input('Port [%s]: ' % config['port'])
if port:
config['port'] = int(port)
print 'Set the credentials required for accessing YubiAdmin via the web ' \
'interface.'
print 'Press enter to keep the current settings.'
username = raw_input('Username [%s]: ' % config['username'])
if username:
config['username'] = username
password = raw_input('Password [%s]: ' % ('*' * len(config['password'])))
if password:
password2 = raw_input('Repeat password: ')
if password == password2:
config['password'] = password
else:
print 'ERROR: Passwords did not match!'
sys.exit(1)
def get_args(config):
parser = argparse.ArgumentParser(
description='Configure YubiAdmin\n'
'Interactively configures YubiAdmin when run with no arguments,\n'
'or sets the arguments given via the arguments passed to the program',
add_help=True,
# formatter_class=argparse.ArgumentDefaultsHelpFormatter
)
parser.add_argument('-i', '--interface', nargs='?',
default=config['interface'],
help='Listening interface')
parser.add_argument('-p', '--port', type=int, nargs='?',
default=config['port'], help='Listening port')
parser.add_argument('-U', '--username', nargs='?',
default=config['username'],
help='Username for authentication')
parser.add_argument('-P', '--password', nargs='?',
default=config['password'],
help='Password for authentication')
args = parser.parse_args()
config.update(vars(args))
if __name__ == '__main__':
admin_config.read()
if len(sys.argv) > 1:
get_args(admin_config)
else:
get_interactive(admin_config)
admin_config.commit()
print '\n%s written!' % admin_config.filename
print 'YubiAdmin needs to be restarted for these settings to take effect.'
print '\n service yubiadmin restart'

66
bin/yubiadmin-config.1 Normal file
View File

@ -0,0 +1,66 @@
.\" Copyright (c) 2013 Yubico AB
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions are
.\" met:
.\"
.\" * Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\"
.\" * Redistributions in binary form must reproduce the above
.\" copyright notice, this list of conditions and the following
.\" disclaimer in the documentation and/or other materials provided
.\" with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
.\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
.\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
.\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
.\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.\" The following commands are required for all man pages.
.de URL
\\$2 \(laURL: \\$1 \(ra\\$3
..
.if \n[.g] .mso www.tmac
.TH yubiadmin-config "1" "May 2013" "yubiadmin"
.SH NAME
yubiadmin-config - Command-line tool for configuring YubiAdmin.
.SH SYNOPSIS
.B yubiadmin-config
[\fI--help\fR] [\fI--interface INTERFACE\fR] [\fI--port PORT\fR] [\fI--username USERNAME] [\fI--password PASSWORD]
.SH DESCRIPTION
Edits the YubiAdmin configuration file. Run either without arguments to
interactively set the available options, or with one or more of the
command-line arguments set to set specific options.
.HP
\fB\-\-help, \-h\fR Usage help.
.HP
\fB\-\-interface \-i\fR Network interface to listen to.
.HP
\fB\-\-port \-p\fR TCP port to listen to.
.HP
\fB\-\-username \-U\fR Username to use for authentication.
.HP
\fB\-\-password \-P\fR Password to use for authentication.
.PP
Configuration is written to /etc/yubico/admin/yubiadmin.conf
.SH BUGS
Report yubiadmin-config bugs in
.URL "https://github.com/Yubico/yubiadmin/issues" "the issue tracker"
.SH "SEE ALSO"
The
.URL "https://github.com/Yubico/yubiadmin" "yubiadmin home page"
.PP
YubiKeys can be obtained from
.URL "http://www.yubico.com/" "Yubico" "."

View File

@ -46,15 +46,15 @@ using the username: "yubiadmin" and the password: "yubiadmin". These settings
and many more are available by editing the configuration file, or by using the
program arguments.
.HP
\fB\-\-help\fR Usage help.
\fB\-\-help, \-h\fR Usage help.
.HP
\fB\-\-interface\fR Network interface to listen to.
\fB\-\-interface \-i\fR Network interface to listen to.
.HP
\fB\-\-port\fR IP port to listen to.
\fB\-\-port \-p\fR TCP port to listen to.
.HP
\fB\-\-username\fR Username to use for authentication.
\fB\-\-username \-U\fR Username to use for authentication.
.HP
\fB\-\-password\fR Password to use for authentication.
\fB\-\-password \-P\fR Password to use for authentication.
.PP
Configuration is read from /etc/yubico/admin/yubiadmin.conf
.SH BUGS