source: TI12-security/trunk/python/bin/MyProxyAdmin.py @ 964

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI12-security/trunk/python/bin/MyProxyAdmin.py@964
Revision 964, 2.9 KB checked in by pjkersha, 16 years ago (diff)

Tests/SecurityClientTest?.py: get proxy cert from call to Session Manager WS connect call rather
than from a local file.

conf/myProxyProperties.xml: config file just for MyProxy? - contains settings copied from
sessionMgrProperties.xml. Isolate for use by new MyProxyAdmin?.py tool. Eventually MyProxy?
config settings may be removed and kept spearate from sessionMgrProperties.xml.

conf/gatekeeperProperties.xml: properties file for NDG Gatekeeper

bin/MyProxyAdmin.py: new command line tool for MyProxy? administration. It enables new users
to be added from the command line of the host running MyProxy?. This may replace the current
Session Manager WS addUser method.

NDG/AttAuthority.py: Make sure sys.path is copied by content rather than reference in init

NDG/log_services_server.py: added reposID var for recording of version from SVN.

NDG/Gatekeeper.py: added readAccess, writeAccess and executeAccess methods.

  • Property svn:executable set to *
Line 
1#!/usr/bin/env python
2
3"""NDG MyProxy admin command line interface - enables new users to be
4registered with NDG CA and added to the MyProxy repository.  This command
5must be run from the MyProxy host.
6
7NERC Data Grid Project
8
9P J Kershaw 19/05/06
10
11Copyright (C) 2006 CCLRC & NERC
12
13This software may be distributed under the terms of the Q Public License,
14version 1.0 or later.
15"""
16
17# Handle socket errors from WS
18import socket 
19
20# Command line processing
21import sys
22import os
23import optparse
24import getpass
25
26
27from NDG.MyProxy import *
28
29
30#_____________________________________________________________________________
31if __name__ == '__main__':
32
33    parser = optparse.OptionParser()
34    parser.add_option("-n", 
35                      "--add-user", 
36                      dest="newUserName",
37                      help=\
38                      "add a new user to MyProxy with the username given")
39
40    parser.add_option("-f", 
41                      "--properties-file",
42                      dest="propFilePath",
43                      help=\
44"file path for MyProxy properties file - default is ./myProxyProperties.xml")
45
46    parser.add_option("-p",
47                      "--pass-phrase-from-stdin",
48                      action="store_true",
49                      dest="bPassPhraseFromStdin",
50                      default=False,
51                      help="""\
52Take user's pass-phrase from stdin.  If this flag is omitted, pass-phrase is
53prompted for from tty""")
54
55    (options, args) = parser.parse_args()
56
57
58    if not options.newUserName:
59        sys.stderr.write("No new username set.\n\n")
60        parser.print_help()
61        sys.exit(1)
62       
63       
64    if options.propFilePath is None:
65        # Check in installation area otherwise assume local directory
66        options.propFilePath = os.path.join(".", 'myProxyProperties.xml')
67
68
69    if options.bPassPhraseFromStdin:
70        # Read from standard input
71        passPhrase = sys.stdin.read().strip()           
72    else:
73        # Obtain from prompt
74        try:
75            passPhrase = getpass.getpass(prompt="New user pass-phrase: ") 
76            confirmPassPhrase = \
77                            getpass.getpass(prompt="Confirm pass-phrase: ")
78           
79            if confirmPassPhrase != passPhrase:
80                sys.stderr.write("Pass-phrases are not the same - exiting.\n")
81                sys.exit(1)
82               
83        except KeyboardInterrupt:
84            sys.exit(1)
85
86
87    # Create server instance at start up
88    try:
89        myPx = MyProxy(propFilePath=options.propFilePath)
90
91    except Exception, e:
92        sys.stderr.write("Initialising MyProxy client: %s\n\n" % str(e))
93        parser.print_help()
94        sys.exit(1)
95   
96    try:
97         myPx.addUser(options.newUserName, passPhrase)
98
99    except Exception, e:
100        sys.stderr.write("MyProxy client: %s\n\n" % str(e))
101        parser.print_help()
102        sys.exit(1)
103       
104    sys.exit(0)
Note: See TracBrowser for help on using the repository browser.