Skip to content

Commit d85455b

Browse files
authored
Merge pull request #76 from DrDaveD/v1
Fix crash with --nobearertoken and unknown credkey
2 parents dada36e + 7b62130 commit d85455b

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

htgettoken

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,7 @@ def main():
912912

913913
credkey = options.credkey
914914
configfile = None
915-
if credkey is None:
915+
if credkey is None and (not options.nobearertoken or options.showbearerurl):
916916
# Look for saved credkey, needed for figuring out the vault secretpath
917917
configfile = options.configdir + '/credkey-' + options.issuer + '-' + options.role
918918
configfile = os.path.expanduser(configfile)
@@ -933,7 +933,12 @@ def main():
933933
log("Credkey from %s: %s" % (configfile, credkey))
934934

935935
if (credkey is not None or options.nobearertoken) and not options.registerssh:
936-
fullsecretpath = secretpath.replace("%credkey", credkey)
936+
fullsecretpath = ""
937+
if credkey is None:
938+
if options.showbearerurl:
939+
fatal("cannot do --showbearerurl because credkey is not known")
940+
else:
941+
fullsecretpath = secretpath.replace("%credkey", credkey)
937942

938943
# Check to see if a valid vault token already exists and works by
939944
# attempting to read a bearer token

htgettoken.spec

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ rm -rf $RPM_BUILD_ROOT
124124

125125

126126
%changelog
127+
# - Fix crash introduced in 1.17 when using --nobearertoken while the
128+
# credkey is not known.
129+
127130
* Wed Mar 15 2023 Dave Dykstra <dwd@fnal.gov> 1.17-1
128131
- Fix the usage of getaddrinfo, which caused a fatal error on python3.9
129132
on Mac.

0 commit comments

Comments
 (0)