porting tools to kerberos auth #6565

Merged
jnsamyak merged 5 commits from krb into master 2026-06-08 03:12:45 +00:00
4 changed files with 44 additions and 14 deletions

View file

@ -21,6 +21,8 @@ import argparse
# get architecture, tag/target and build from command line
parser = argparse.ArgumentParser(description='Build srpm from primary koji in secondary koji.')
parser.add_argument("--keytab", help="specify a Kerberos keytab to use")
parser.add_argument("--principal", help="specify a Kerberos principal to use")
parser.add_argument('--scratch', action='store_true', help='scratch build')
parser.add_argument('--verbose', action='store_true', help='enables additional output, overrides --quiet')
parser.add_argument('--quiet', action='store_true', help='suppresses non error related output')
@ -38,6 +40,10 @@ SERVERCA = os.path.expanduser('~/.fedora-server-ca.cert')
CLIENTCA = os.path.expanduser('~/.fedora-upload-ca.cert')
CLIENTCERT = os.path.expanduser('~/.fedora.cert')
session_opts = {}
session_opts['krbservice'] = 'host'
session_opts['krb_rdns'] = False
if args.verbose:
loglevel = logging.DEBUG
elif args.quiet:
@ -62,9 +68,15 @@ def _unique_path(prefix):
# setup the koji session
logging.info('Setting up koji session')
localkojisession = koji.ClientSession(LOCALKOJIHUB)
localkojisession = koji.ClientSession(LOCALKOJIHUB, session_opts)
remotekojisession = koji.ClientSession(REMOTEKOJIHUB)
localkojisession.ssl_login(CLIENTCERT, CLIENTCA, SERVERCA)
if os.path.isfile(CLIENTCERT):
localckojisession.ssl_login(CLIENTCERT, CLIENTCA, SERVERCA)
else:
if args.keytab and args.principal:
localkojisession.krb_login(principal=args.principal, keytab=args.keytab)
else:
localkojisession.krb_login()
pg = progress.TextMeter()

View file

@ -30,13 +30,8 @@ else:
exit(0)
LOCALKOJIHUB = 'http://%s.koji.fedoraproject.org/kojihub' % (SECONDARY_ARCH)
REMOTEKOJIHUB = 'http://koji.fedoraproject.org/kojihub'
# Should probably set these from a koji config file
SERVERCA = os.path.expanduser('~/.fedora-server-ca.cert')
CLIENTCA = os.path.expanduser('~/.fedora-upload-ca.cert')
CLIENTCERT = os.path.expanduser('~/.fedora.cert')
LOCALKOJIHUB = 'https://%s.koji.fedoraproject.org/kojihub' % (SECONDARY_ARCH)
REMOTEKOJIHUB = 'https://koji.fedoraproject.org/kojihub'
def _rpmvercmp ((e1, v1, r1), (e2, v2, r2)):
"""find out which build is newer"""
@ -76,7 +71,6 @@ def _countMissing (build):
return cnt
localkojisession = koji.ClientSession(LOCALKOJIHUB)
remotekojisession = koji.ClientSession(REMOTEKOJIHUB)
# package indexes

View file

@ -20,6 +20,8 @@ import tempfile
# get parameters from command line
parser = argparse.ArgumentParser()
parser.add_argument("--keytab", help="specify a Kerberos keytab to use")
parser.add_argument("--principal", help="specify a Kerberos principal to use")
parser.add_argument("--force", help="reimport a failed build", action="store_true")
parser.add_argument("--verbose", help="be verbose during processing", action="store_true")
parser.add_argument("arch", help="secondary arch koji where to import the builds")
@ -36,6 +38,10 @@ SERVERCA = os.path.expanduser('~/.fedora-server-ca.cert')
CLIENTCA = os.path.expanduser('~/.fedora-upload-ca.cert')
CLIENTCERT = os.path.expanduser('~/.fedora.cert')
session_opts = {}
session_opts['krbservice'] = 'host'
session_opts['krb_rdns'] = False
workpath = tempfile.mkdtemp(prefix="koji-import.")
loglevel = logging.DEBUG
@ -141,9 +147,15 @@ def importBuild(rpms, buildinfo, tag=None):
# setup the koji session
logging.info('Setting up koji session')
localkojisession = koji.ClientSession(LOCALKOJIHUB)
localkojisession = koji.ClientSession(LOCALKOJIHUB, session_opts)
remotekojisession = koji.ClientSession(REMOTEKOJIHUB)
localkojisession.ssl_login(CLIENTCERT, CLIENTCA, SERVERCA)
if os.path.isfile(CLIENTCERT):
localckojisession.ssl_login(CLIENTCERT, CLIENTCA, SERVERCA)
else:
if args.keytab and args.principal:
localkojisession.krb_login(principal=args.principal, keytab=args.keytab)
else:
localkojisession.krb_login()
for build in args.build:
buildinfo = remotekojisession.getBuild(build)

View file

@ -21,6 +21,8 @@ import argparse
# get architecture and tags from command line
parser = argparse.ArgumentParser()
parser.add_argument("--keytab", help="specify a Kerberos keytab to use")
parser.add_argument("--principal", help="specify a Kerberos principal to use")
parser.add_argument("--dry-run", help="no changes will be made", action="store_true")
parser.add_argument("arch", help="secondary arch to sync")
parser.add_argument("tag", nargs="+", help="tag to sync")
@ -31,6 +33,10 @@ SERVERCA = os.path.expanduser('~/.fedora-server-ca.cert')
CLIENTCA = os.path.expanduser('~/.fedora-upload-ca.cert')
CLIENTCERT = os.path.expanduser('~/.fedora.cert')
session_opts = {}
session_opts['krbservice'] = 'host'
session_opts['krb_rdns'] = False
def getTagged(kojisession, tag):
tagged = [] # holding for blocked pkgs
pkgs = kojisession.listTagged(tag, latest=True)
@ -58,8 +64,14 @@ def rpmvercmp ((e1, v1, r1), (e2, v2, r2)):
print "=== Working on arch: %s ====" % args.arch
# Create a koji session
kojisession = koji.ClientSession('https://koji.fedoraproject.org/kojihub')
seckojisession = koji.ClientSession('https://%s.koji.fedoraproject.org/kojihub' % args.arch)
seckojisession.ssl_login(CLIENTCERT, CLIENTCA, SERVERCA)
seckojisession = koji.ClientSession('https://%s.koji.fedoraproject.org/kojihub' % args.arch, session_opts)
if os.path.isfile(CLIENTCERT):
seckojisession.ssl_login(CLIENTCERT, CLIENTCA, SERVERCA)
else:
if args.keytab and args.principal:
seckojisession.krb_login(principal=args.principal, keytab=args.keytab)
else:
seckojisession.krb_login()
for tag in args.tag:
print "=== Working on tag: %s ====" % tag