Added logic to support including external password and group files.
1 parent 703d3d8 commit dd866ff201301667f75ba41b674d396b1799a606
@root root authored on 5 Apr 2005
Showing 1 changed file
View
58
mkapachepw.py
 
# Program Information
 
PROGNAME = "mkapachepw"
RCSID = "$Id: mkapachepw.py,v 1.110 2005/04/05 20:43:44 root Exp $"
RCSID = "$Id: mkapachepw.py,v 1.111 2005/04/05 21:44:36 root Exp $"
VERSION = RCSID.split()[2]
 
# Copyright Information
 
# Usage Prompts
#####
 
uTable = [PROGNAME + " " + VERSION + " - %s\n" % COPYRIGHT,
"usage: " + PROGNAME + " [-GUfghuv] where,\n",
" -G list of groups to include (+group) or exclude (-group) (default: none)",
" -U list of users to include (+user) or exclude (-user) (default: none)",
"usage: " + PROGNAME + " [-GUguIihv] where,\n",
" -G list of groups to include (+group | +GID) or exclude (-group | -GID) (default: none)",
" -U list of users to include (+user | + UID) or exclude (-user | -UID) (default: none)",
" -g # smallest GID to include in output (default: 100)",
" -u # smallest UID to include in output (default: 100)",
" -I file include file containing other group information (default: none)",
" -i file include file containing other user information (default: none)",
" -h print this help information",
" -u # smallest UID to include in output (default: 100)",
" -v print detailed version information",
]
 
 
else:
del master[item]
 
# End of 'ProcessEnumeratedList(()'
 
 
#####
# Read A File Into A Local List, Stripping Newlines, And
# Suppressing Blank Lines
#####
 
def ReadFile(filename):
temp = []
try:
f = open(filename)
for l in f.readlines():
if l[-1] == '\n': # Get rid of trailing newlines
l = l[:-1]
l = l.split('#')[0].strip() # Get rid of comments
 
if l: # Add any non-blank lines
name, members = l.split(':')
members = members.split()
temp.append([name, members])
f.close()
 
except:
ErrorMsg("Cannot Open File '%s'." % filename)
sys.exit(1)
 
return temp
 
# End of 'ReadFile()'
 
 
#----------------------------------------------------------#
# Program Entry Point #
if envopt:
OPTIONS = envopt.split() + OPTIONS
 
try:
opts, args = getopt.getopt(OPTIONS, '-G:U:g:hu:v')
opts, args = getopt.getopt(OPTIONS, '-G:U:g:u:I:i:hv')
except getopt.GetoptError:
Usage()
sys.exit(1)
 
STARTGID=int(val)
except:
ErrorMsg("Invalid Starting GID, '%s' - Must Be An Integer Value." % val)
sys.exit(1)
if opt == "-h":
Usage()
sys.exit(0)
if opt == "-u":
try:
STARTUID=int(val)
except:
ErrorMsg("Invalid Starting UID '%s' - Must Be An Integer Value." % val)
sys.exit(1)
if opt == "-I":
temp = ReadFile(val)
for entry in temp:
groups[entry[0]] = [65535, entry[1], False]
if opt == "-i":
temp = ReadFile(val)
for entry in temp:
users[entry[0]] = [65535, entry[1][0], False]
if opt == "-h":
Usage()
sys.exit(0)
if opt == "-v":
print RCSID
sys.exit(0)