galaxy: Handle token as dict while loading using yaml (#70911)

Malformed galaxy_token file creates stacktrace.

Fixes: #70887

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
pull/73045/head
Abhijeet Kasurde 4 years ago committed by GitHub
parent 932ba36160
commit aa56a2ff6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
minor_changes:
- galaxy - handle token as dict while loading from yaml file (https://github.com/ansible/ansible/issues/70887).

@ -120,7 +120,7 @@ class GalaxyToken(object):
def _read(self):
action = 'Opened'
if not os.path.isfile(self.b_file):
# token file not found, create and chomd u+rw
# token file not found, create and chmod u+rw
open(self.b_file, 'w').close()
os.chmod(self.b_file, S_IRUSR | S_IWUSR) # owner has +rw
action = 'Created'
@ -130,6 +130,10 @@ class GalaxyToken(object):
display.vvv('%s %s' % (action, to_text(self.b_file)))
if config and not isinstance(config, dict):
display.vvv('Galaxy token file %s malformed, unable to read it' % to_text(self.b_file))
return {}
return config or {}
def set(self, token):

Loading…
Cancel
Save