19
19
-d passfd specify open fd to read PASS
20
20
-f passfile specify path to file to open and read PASS
21
21
-e ENDPOINT specify REST endpoint
22
+ -o outfile specify output file (default: write to stdout)
22
23
23
24
PASS for USER is taken from the first of:
24
25
1. -u USER:PASS
@@ -41,6 +42,7 @@ def usage(msg=None):
41
42
class Options :
42
43
endpoint = ENDPOINT
43
44
user = "co_8.project_script"
45
+ outfile = None
44
46
authstr = None
45
47
46
48
@@ -151,6 +153,7 @@ def parse_options(args):
151
153
if op == '-d' : passfd = int (arg )
152
154
if op == '-f' : passfile = arg
153
155
if op == '-e' : options .endpoint = arg
156
+ if op == '-o' : options .outfile = arg
154
157
155
158
user , passwd = getpw (options .user , passfd , passfile )
156
159
options .authstr = mkauthstr (user , passwd )
@@ -179,9 +182,17 @@ def get_osguser_groups():
179
182
for pid , gids in pid_gids .items () }
180
183
181
184
182
- def print_usermap (osguser_groups ):
185
+ def print_usermap_to_file (osguser_groups , file ):
183
186
for osguser , groups in osguser_groups .items ():
184
- print ("* {} {}" .format (osguser , "," .join (groups )))
187
+ print ("* {} {}" .format (osguser , "," .join (groups )), file = file )
188
+
189
+
190
+ def print_usermap (osguser_groups ):
191
+ if options .outfile :
192
+ with open (options .outfile , "w" ) as w :
193
+ print_usermap_to_file (osguser_groups , w )
194
+ else :
195
+ print_usermap_to_file (osguser_groups , sys .stdout )
185
196
186
197
187
198
def main (args ):
0 commit comments