#1125 Ignore non-existing option when activate a session
Merged 5 years ago by mikem. Opened 5 years ago by cqi.
cqi/koji fix-krb-auth  into  master

file modified
+2 -2
@@ -578,7 +578,7 @@ 

          session.login()

      elif options.authtype == "kerberos" or has_krb_creds() and options.authtype is None:

          try:

-             if options.keytab and options.principal:

+             if getattr(options, 'keytab', None) and getattr(options, 'principal', None):

                  session.krb_login(principal=options.principal, keytab=options.keytab, proxyuser=runas)

              else:

                  session.krb_login(proxyuser=runas)
@@ -592,7 +592,7 @@ 

      if not noauth and not session.logged_in:

          error(_("Unable to log in, no authentication methods available"))

      ensure_connection(session)

-     if options.debug:

+     if getattr(options, 'debug', None):

          print("successfully connected to hub")

  

  

For kerberos auth, if not login with a keytab and principal, those two
options may not be present in the incoming options.

Similarly, debug is also an optional option that could not exist.

Signed-off-by: Chenxiong Qi cqi@redhat.com

All of these options have default values in read_config(). In what situation are they not set?

@mikem I encountered this issue during running rpkg tests after replacing code with activate_session. rpkg logs into a session via gssapi, so test just uses a fake koji config dict without setting keytab and principal, then test fails at line if options.keytab and options.principal:.

Yes, read_config returns a mapping containing keytab and principal with proper values, and I can also set them in the fake config dict in test to workaround. I made this PR and just thought it could be convenient in some cases where those two configs are not necessary.

Fair enough. I just wanted to make sure we weren't missing a problem elsewhere in Koji.

Commit dc9e0dd fixes this pull-request

Pull-Request has been merged by mikem

5 years ago