tacacs: convert script to python3
This commit is contained in:
parent
e03efff4a9
commit
0d6389c236
|
@ -0,0 +1,98 @@
|
|||
--- a/do_auth.py
|
||||
+++ b/do_auth.py
|
||||
@@ -211,7 +211,7 @@
|
||||
Written by Dan Schmidt - Please visit tacacs.org to check for updates.
|
||||
'''
|
||||
|
||||
-import sys,re,getopt,ConfigParser
|
||||
+import sys,re,getopt,configparser
|
||||
from time import strftime
|
||||
|
||||
# I really don't want to deal with these exceptions more than once
|
||||
@@ -230,23 +230,23 @@
|
||||
#Should not have any exceptions - BUT, just in case
|
||||
try:
|
||||
attributes = config.get(the_section, the_option)
|
||||
- except ConfigParser.NoSectionError:
|
||||
+ except configparser.NoSectionError:
|
||||
log_file.write(strftime("%Y-%m-%d %H:%M:%S: ")
|
||||
+ "Error: Section '%s' Doesn't Exist!\n"
|
||||
% (the_section))
|
||||
sys.exit(1)
|
||||
- except ConfigParser.DuplicateSectionError:
|
||||
+ except configparser.DuplicateSectionError:
|
||||
log_file.write(strftime("%Y-%m-%d %H:%M:%S: ")
|
||||
+ "Error: Duplicate section '%s'\n"
|
||||
% (the_section))
|
||||
sys.exit(1)
|
||||
- except ConfigParser.NoOptionError:
|
||||
+ except configparser.NoOptionError:
|
||||
log_file.write(strftime("%Y-%m-%d %H:%M:%S: ")
|
||||
+ "Error: '%s' not found in section '%s\n'"
|
||||
% (the_option, the_section))
|
||||
sys.exit(1)
|
||||
#To do: finish exceptions.
|
||||
- except ConfigParser.ParsingError:
|
||||
+ except configparser.ParsingError:
|
||||
log_file.write(strftime("%Y-%m-%d %H:%M:%S: ")
|
||||
+ "Error: Can't parse file '%s'! (You got me)\n"
|
||||
% (filename))
|
||||
@@ -298,9 +298,9 @@
|
||||
argv = sys.argv
|
||||
try:
|
||||
optlist, args = getopt.getopt(sys.argv[1:], 'i:u:f:l:d:?:D', ['fix_crs_bug','?', '-?', 'help', 'Help'])
|
||||
- except getopt.GetoptError, err:
|
||||
- print str(err)
|
||||
- print __doc__
|
||||
+ except getopt.GetoptError as err:
|
||||
+ print(str(err))
|
||||
+ print(__doc__)
|
||||
sys.exit(1)
|
||||
for (i, j) in optlist:
|
||||
if i == '-i':
|
||||
@@ -314,15 +314,15 @@
|
||||
elif i == '-d':
|
||||
device = j
|
||||
elif i in ('?', '-?', 'help', 'Help'):
|
||||
- print __doc__
|
||||
+ print(__doc__)
|
||||
sys.exit(1)
|
||||
elif i == '-D':
|
||||
is_debug = True
|
||||
else:
|
||||
- print 'Unknown option:', i
|
||||
+ print('Unknown option:', i)
|
||||
sys.exit(1)
|
||||
if len(argv) < 7:
|
||||
- print __doc__
|
||||
+ print(__doc__)
|
||||
sys.exit(1)
|
||||
log_file = open (log_name, "a")
|
||||
#DEBUG! We at least got CALLED
|
||||
@@ -384,7 +384,7 @@
|
||||
log_file.write(strftime("%Y-%m-%d %H:%M:%S: ")
|
||||
+ "Error: No username entered!\n")
|
||||
sys.exit(1)
|
||||
- config = ConfigParser.SafeConfigParser()
|
||||
+ config = configparser.SafeConfigParser()
|
||||
if not (filename in config.read(filename)):
|
||||
log_file.write(strftime("%Y-%m-%d %H:%M:%S: ")
|
||||
+ "Error: Can't open/parse '%s'\n"
|
||||
@@ -491,7 +491,7 @@
|
||||
for item in return_pairs:
|
||||
#DEBUG
|
||||
# log_file.write("Returning:%s\n" % item.strip())
|
||||
- print item.strip('\n')
|
||||
+ print(item.strip('\n'))
|
||||
if want_tac_pairs:
|
||||
#DEBUG
|
||||
# log_file.write("Exiting status 2\n")
|
||||
@@ -507,7 +507,7 @@
|
||||
for item in return_pairs:
|
||||
#DEBUG
|
||||
# log_file.write("Returning:%s\n" % item.strip())
|
||||
- print item.strip('\n')
|
||||
+ print(item.strip('\n'))
|
||||
log_file.write(strftime("%Y-%m-%d %H:%M:%S: ")
|
||||
+ "User '%s' granted access to device '%s' in group '%s' from '%s'\n"
|
||||
% (user_name, device, this_group, ip_addr))
|
|
@ -1,7 +1,7 @@
|
|||
# Template file for 'tacacs'
|
||||
pkgname=tacacs
|
||||
version=4.0.4.28
|
||||
revision=2
|
||||
revision=3
|
||||
build_style=gnu-configure
|
||||
configure_args="--with-libwrap=no"
|
||||
hostmakedepends="flex perl"
|
||||
|
@ -10,9 +10,9 @@ short_desc="Modified version of Cisco's tacacs+ (tac_plus) developer's kit"
|
|||
maintainer="Orphaned <orphan@voidlinux.org>"
|
||||
license="custom:Cisco"
|
||||
homepage="http://www.shrubbery.net/tac_plus/"
|
||||
distfiles="ftp://ftp.shrubbery.net/pub/tac_plus/$pkgname-F$version.tar.gz"
|
||||
distfiles="ftp://ftp.shrubbery.net/pub/tac_plus/tacacs-F$version.tar.gz"
|
||||
checksum=147f2dc98d26d2f93f0aba76c988ced196ffe1c001dc2e91f788a1a2c747219e
|
||||
python_version=2
|
||||
python_version=3
|
||||
disable_parallel_build=yes
|
||||
|
||||
pre_configure() {
|
||||
|
|
Loading…
Reference in New Issue