Skip to content

Commit c290712

Browse files
committed
add -f passfile option (SOFTWARE-4751)
1 parent 42d4e86 commit c290712

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

osg-comanage-project-usermap.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@
1717
OPTIONS:
1818
-u USER[:PASS] specify USER and optionally PASS on command line
1919
-d passfd specify open fd to read PASS
20+
-f passfile specify path to file to open and read PASS
2021
-e ENDPOINT specify REST endpoint
2122
2223
PASS for USER is taken from the first of:
2324
1. -u USER:PASS
2425
2. -d passfd (read from fd)
25-
3. read from $PASS env var
26+
3. -f passfile (read from file)
27+
4. read from $PASS env var
2628
2729
ENDPOINT defaults to {ENDPOINT}
2830
"""
@@ -45,11 +47,13 @@ class Options:
4547
options = Options()
4648

4749

48-
def getpw(user, passfd=None):
50+
def getpw(user, passfd, passfile):
4951
if ':' in user:
5052
user, pw = user.split(':', 1)
5153
elif passfd is not None:
5254
pw = os.fdopen(passfd).readline().rstrip('\n')
55+
elif passfile is not None:
56+
pw = open(passfile).readline().rstrip('\n')
5357
elif 'PASS' in os.environ:
5458
pw = os.environ['PASS']
5559
else:
@@ -140,13 +144,15 @@ def parse_options(args):
140144
usage("Extra arguments: %s" % repr(args))
141145

142146
passfd = None
147+
passfile = None
143148

144149
for op, arg in ops:
145150
if op == '-u': options.user = arg
146151
if op == '-d': passfd = int(arg)
152+
if op == '-f': passfile = arg
147153
if op == '-e': options.endpoint = arg
148154

149-
options.user, passwd = getpw(options.user, passfd)
155+
options.user, passwd = getpw(options.user, passfd, passfile)
150156
options.authstr = mkauthstr(options.user, passwd)
151157

152158

0 commit comments

Comments
 (0)