Skip to content

Commit a162b38

Browse files
committed
flexible prompt msg for prc_write_irodsA.py
1 parent f02317b commit a162b38

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ Creating PAM or Native Credentials File (.irodsA)
134134

135135
Two free functions exist for creating encoded authentication files:
136136
```
137-
irods.client_init.write_native_credentials_to_secrets_file
138-
irods.client_init.write_pam_credentials_to_secrets_file
137+
irods.client_init.write_native_irodsA_file
138+
irods.client_init.write_pam_irodsA_file
139139
```
140140

141141
Each takes a cleartext password and writes an appropriately processed version of it

irods/auth/pam_password.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,15 @@ def _authenticate_pam_password(conn, req):
5454
_logger.debug('----------- %s (end)', _scheme)
5555

5656

57-
def _get_pam_password_from_stdin(file_like_object = None):
57+
def _get_pam_password_from_stdin(file_like_object = None, prompt = "Enter your current PAM password: "):
5858
try:
5959
if file_like_object:
6060
if not getattr(file_like_object,'readline',None):
6161
msg = "The file_like_object, if provided, must have a 'readline' method."
6262
raise RuntimeError(msg)
6363
sys.stdin = file_like_object
6464
if sys.stdin.isatty():
65-
return getpass.getpass("Enter your current PAM password: ")
65+
return getpass.getpass(prompt)
6666
else:
6767
return sys.stdin.readline().strip()
6868
finally:

irods/prc_write_irodsA.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
opts, args = getopt.getopt(sys.argv[1:], "hi:", ["ttl=","help"])
3131
optD = dict(opts)
3232
help_selected = {*optD} & {'-h','--help'}
33+
scheme = args[0]
3334
if len(args) != 1 or help_selected:
3435
print("{}\nUsage: {} [-i STREAM| -h | --help | --ttl HOURS] AUTH_SCHEME".format(extra_help, sys.argv[0]))
3536
print(" Choices for AUTH_SCHEME are:")
@@ -38,13 +39,13 @@
3839
print(" STREAM is the name of a file containing a password. Alternatively, a hyphen('-') is used to\n"
3940
" indicate that the password may be read from stdin.")
4041
sys.exit(0 if help_selected else 1)
41-
elif args[0] in vector:
42+
elif scheme in vector:
4243
options = {}
4344
inp_stream = optD.get('-i',None)
4445
if '--ttl' in optD:
4546
options['ttl'] = optD['--ttl']
4647
pw = get_password(sys.stdin if inp_stream in ("-",None)
47-
else open(inp_stream,"r"))
48-
vector[args[0]](pw,**options)
48+
else open(inp_stream,"r"), prompt = f"Enter current password for scheme {scheme!r}: ")
49+
vector[scheme](pw,**options)
4950
else:
5051
print("did not recognize authentication scheme argument", file=sys.stderr)

0 commit comments

Comments
 (0)