1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-11-12 23:56:13 +01:00

Remove deprecated 'GnomeKeyringCredentialsManager' and related code

This commit is contained in:
Daniel Mach 2022-08-25 10:29:50 +02:00
parent ed49664d3e
commit 41ceb4b5f8
6 changed files with 9 additions and 109 deletions

View File

@ -93,8 +93,6 @@ class Osc(cmdln.Cmdln):
help='specify alternate configuration file')
optparser.add_argument('--no-keyring', action='store_true',
help='disable usage of desktop keyring system')
optparser.add_argument('--no-gnome-keyring', action='store_true',
help='disable usage of GNOME Keyring')
verbose_group = optparser.add_mutually_exclusive_group()
verbose_group.add_argument('-v', '--verbose', action='store_true',
help='increase verbosity')
@ -121,7 +119,6 @@ class Osc(cmdln.Cmdln):
override_traceback = self.options.traceback,
override_post_mortem = self.options.post_mortem,
override_no_keyring = self.options.no_keyring,
override_no_gnome_keyring = self.options.no_gnome_keyring,
override_verbose = self.options.verbose)
except oscerr.NoConfigfile as e:
print(e.msg, file=sys.stderr)

View File

@ -52,19 +52,12 @@ from .util.helper import raw_input
GENERIC_KEYRING = False
GNOME_KEYRING = False
try:
import keyring
GENERIC_KEYRING = True
except:
try:
import gobject
gobject.set_application_name('osc')
import gnomekeyring
GNOME_KEYRING = gnomekeyring.is_available()
except:
pass
pass
def _get_processors():
@ -133,7 +126,6 @@ DEFAULTS = {'apiurl': 'https://api.opensuse.org',
'traceback': '0',
'post_mortem': '0',
'use_keyring': '0',
'gnome_keyring': '0',
'cookiejar': _identify_osccookiejar(),
# fallback for osc build option --no-verify
'no_verify': '0',
@ -198,7 +190,7 @@ if not os.path.isfile('/usr/lib/build/vc') and os.path.isfile('/usr/lib/obs-buil
boolean_opts = ['debug', 'do_package_tracking', 'http_debug', 'post_mortem', 'traceback', 'check_filelist', 'plaintext_passwd',
'checkout_no_colon', 'checkout_rooted', 'check_for_request_on_action', 'linkcontrol', 'show_download_progress', 'request_show_interactive',
'request_show_source_buildstatus', 'review_inherit_group', 'use_keyring', 'gnome_keyring', 'no_verify', 'builtin_signature_check',
'request_show_source_buildstatus', 'review_inherit_group', 'use_keyring', 'no_verify', 'builtin_signature_check',
'http_full_debug', 'include_request_from_project', 'local_service_run', 'buildlog_strip_time', 'no_preinstallimage',
'status_mtime_heuristic', 'print_web_links', 'ccache', 'sccache', 'build-shell-after-fail']
integer_opts = ['build-jobs']
@ -635,9 +627,10 @@ def config_set_option(section, opt, val=None, delete=False, update=True, creds_m
write_config(config['conffile'], cp)
run = True
if run and update:
kw = {'override_conffile': config['conffile'],
'override_no_keyring': config['use_keyring'],
'override_no_gnome_keyring': config['gnome_keyring']}
kw = {
'override_conffile': config['conffile'],
'override_no_keyring': config['use_keyring'],
}
kw.update(kwargs)
get_config(**kw)
if cp.has_option(section, opt):
@ -707,9 +700,6 @@ def _get_credentials_manager(url, cp):
return creds_mgr
if config['use_keyring'] and GENERIC_KEYRING:
return credentials.get_keyring_credentials_manager(cp)
elif config['gnome_keyring'] and GNOME_KEYRING:
protocol, host, path = parse_apisrv_url(None, url)
return credentials.GnomeKeyringCredentialsManager(cp, None)
elif cp.get(url, 'passx') is not None:
return credentials.ObfuscatedConfigFileCredentialsManager(cp, None)
return credentials.PlaintextConfigFileCredentialsManager(cp, None)
@ -733,7 +723,6 @@ def get_config(override_conffile=None,
override_traceback=None,
override_post_mortem=None,
override_no_keyring=None,
override_no_gnome_keyring=None,
override_verbose=None):
"""do the actual work (see module documentation)"""
global config
@ -794,8 +783,6 @@ def get_config(override_conffile=None,
# This needs to be done before processing API sections as it might be already used there
if override_no_keyring:
config['use_keyring'] = False
if override_no_gnome_keyring:
config['gnome_keyring'] = False
aliases = {}
for url in [x for x in cp.sections() if x != 'general']:

View File

@ -15,16 +15,6 @@ except BaseException as e:
print(msg, e, file=sys.stderr)
keyring = None
try:
import gnomekeyring
except ImportError:
gnomekeyring = None
except BaseException as e:
# catch and report any exceptions raised in the 'gnomekeyring' module
msg = "Warning: Unable to load the 'gnomekeyring' module due to an internal error:"
print(msg, e, file=sys.stderr)
gnomekeyring = None
from . import conf
from . import oscerr
@ -283,77 +273,6 @@ class KeyringCredentialsDescriptor(AbstractCredentialsManagerDescriptor):
return KeyringCredentialsManager(cp, qualified_backend_name)
class GnomeKeyringCredentialsManager(AbstractCredentialsManager):
@classmethod
def create(cls, cp, options):
if gnomekeyring is None:
return None
return super(cls, cls).create(cp, options)
def _get_password(self, url, user):
gk_data = self._keyring_data(url, user)
if gk_data is None:
return None
return gk_data['password']
def set_password(self, url, user, password):
scheme, host, path = self._urlsplit(url)
gnomekeyring.set_network_password_sync(
user=user,
password=password,
protocol=scheme,
server=host,
object=path)
self._cp.set(url, self.config_entry, self._qualified_name())
def delete_password(self, url, user):
gk_data = self._keyring_data(url, user)
if gk_data is None:
return
gnomekeyring.item_delete_sync(gk_data['keyring'], gk_data['item_id'])
def get_user(self, url):
gk_data = self._keyring_data(url, None)
if gk_data is None:
return None
return gk_data['user']
def _keyring_data(self, url, user):
scheme, host, path = self._urlsplit(url)
try:
entries = gnomekeyring.find_network_password_sync(protocol=scheme,
server=host,
object=path)
except gnomekeyring.NoMatchError:
return None
for entry in entries:
if 'user' not in entry or 'password' not in entry:
continue
if user is None or entry['user'] == user:
return entry
return None
def _urlsplit(self, url):
splitted_url = urlsplit(url)
return splitted_url.scheme, splitted_url.netloc, splitted_url.path
class GnomeKeyringCredentialsDescriptor(AbstractCredentialsManagerDescriptor):
def name(self):
return 'GNOME Keyring Manager (deprecated)'
def description(self):
return 'Deprecated GNOME Keyring Manager. If you use \
this we will send you a Dial-In modem'
def priority(self):
return 0
def create(self, cp):
return GnomeKeyringCredentialsManager(cp, None)
# we're supporting only selected python-keyring backends in osc
SUPPORTED_KEYRING_BACKENDS = {
"keyutils.osc.OscKernelKeyringBackend": {
@ -390,8 +309,6 @@ def get_credentials_manager_descriptors():
data["priority"]
)
descriptors.append(descriptor)
if gnomekeyring:
descriptors.append(GnomeKeyringCredentialsDescriptor())
descriptors.append(PlaintextConfigFileDescriptor())
descriptors.append(ObfuscatedConfigFileDescriptor())
descriptors.append(TransientDescriptor())

View File

@ -202,8 +202,7 @@ class OscTestCase(unittest.TestCase):
EXPECTED_REQUESTS = []
os.chdir(os.path.dirname(__file__))
oscrc = os.path.join(self._get_fixtures_dir(), 'oscrc')
osc.conf.get_config(override_conffile=oscrc,
override_no_keyring=True, override_no_gnome_keyring=True)
osc.conf.get_config(override_conffile=oscrc, override_no_keyring=True)
os.environ['OSC_CONFIG'] = oscrc
self.tmpdir = tempfile.mkdtemp(prefix='osc_test')

View File

@ -56,7 +56,7 @@ class TestProjectDiff(OscTestCase):
def _run_prdiff(self, *args):
"""Runs osc prdiff, returning captured STDOUT as a string."""
cli = osc.commandline.Osc()
argv = ['osc', '--no-keyring', '--no-gnome-keyring', 'prdiff']
argv = ['osc', '--no-keyring', 'prdiff']
argv.extend(args)
cli.main(argv=argv)
return sys.stdout.getvalue()

View File

@ -23,7 +23,7 @@ class TestResults(OscTestCase):
def _run_osc(self, *args):
"""Runs osc, returning captured STDOUT as a string."""
cli = osc.commandline.Osc()
argv = ['osc', '--no-keyring', '--no-gnome-keyring']
argv = ['osc', '--no-keyring']
argv.extend(args)
cli.main(argv=argv)
return sys.stdout.getvalue()