Ejemplo n.º 1
0
 def load_user(self):
     """This sets the user attribute, based on the RPM Fusion SSL cert."""
     try:
         self._user = rpmfusion_cert.read_user_cert()
     except Exception as e:
         self.log.debug('Could not read RPM Fusion cert, falling back to '
                        'default method: %s' % e)
         super(Commands, self).load_user()
Ejemplo n.º 2
0
def main(opts):
    # lets read in the existing cert if it exists.
    # gets us existing acc info
    if not opts.username:
        try:
            username = rpmfusion_cert.read_user_cert()
        except:
            print("Can't determine fas name, lets get a new cert")
            try:
                rpmfusion_cert.create_user_cert(None)
            except rpmfusion_cert.rpmfusion_cert_error as e:
                print(e)
                sys.exit(1)
            sys.exit(0)
    else:
        username = opts.username

    if opts.confkrb:
        with open(os.path.expanduser('~/.rpmfusion.upn'), 'w') as f:
            f.write(username)
        print('Kerberos username configured. Run kinit %[email protected]' %
              username)
        sys.exit(0)

    #has cert expired? do we force a new cert? get a new one
    if opts.newcert:
        print("Getting a new User Certificate")
        try:
            rpmfusion_cert.create_user_cert(username)
        except rpmfusion_cert.rpmfusion_cert_error as e:
            print(e)
            sys.exit(1)
        sys.exit(0)
    if rpmfusion_cert.certificate_expired():
        print("Certificate has expired, getting a new one")
        try:
            rpmfusion_cert.create_user_cert(username)
        except rpmfusion_cert.rpmfusion_cert_error as e:
            print(e)
            sys.exit(1)
        sys.exit(0)
    if opts.verifycert:
        print("Verifying Certificate")
        try:
            rpmfusion_cert.verify_cert()
        except rpmfusion_cert.rpmfusion_cert_error as e:
            print(e)
            sys.exit(1)

        import OpenSSL.crypto
        if not hasattr(OpenSSL.crypto, 'load_crl'):
            print("CRL Checking not available in this version of pyOpenSSL")
Ejemplo n.º 3
0
def ask_password(username=None, bad_password=False):
    """ Example login_callback to ask username/password from user
    :kwarg username: Username
    :type username: str
    :kwarg bad_password: Whether there was a previous failed login attempt
    :type bad_password: bool
    :return: username, password
    :rtype: tuple
    """
    if bad_password:
        print("Bad password, please retry")
    if not username:
        try:
            username = rpmfusion_cert.read_user_cert()
        except rpmfusion_cert.rpmfusion_cert_error:
            LOG.debug('Could not read Rpmfusion cert, asking for username')
            username = input("Username: "******"FAS password for user {0}: ".format(username))
    return username, password
Ejemplo n.º 4
0
import os
import tempfile

import datetime

import requests
import rpmfusion_cert
import xmlrpclib

from bugzilla import Bugzilla
from fedora.client import AccountSystem, AuthError

import rfpkgdb2client

try:
    USERNAME = rpmfusion_cert.read_user_cert()
except rpmfusion_cert.rpmfusion_cert_error:
    rfpkgdb2client.LOG.debug(
        'Could not read Rpmfusion cert, asking for username')
    USERNAME = None

BZCLIENT = None
FASCLIENT = None


def _get_bz(url=rfpkgdb2client.BZ_URL, insecure=False):
    ''' Return a bugzilla object. '''
    global BZCLIENT
    if not BZCLIENT or BZCLIENT.url != url:
        BZCLIENT = Bugzilla(url=url)