Skip to content

Commit

Permalink
Handle zypper operation on a different root
Browse files Browse the repository at this point in the history
If zypper is instructed to operate on a different root with the "--root"
argument the credentials are also expected to be found in this seperate
root tree. WE need to accomodate this redirection.
  • Loading branch information
rjschwei committed May 8, 2024
1 parent 79f93f9 commit b5dbdb0
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/cloudregister/registerutils.py
Expand Up @@ -159,10 +159,19 @@ def clear_rmt_as_scc_proxy_flag():
def credentials_files_are_equal(repo_credentials):
"""Compare the base credentials files the the repo header and make
sure they have the same values."""
credentials_location = '/etc/zypp/credentials.d/'

if not repo_credentials or not isinstance(repo_credentials, str):
return False

base_credentials_location = '/etc/zypp/credentials.d/'
zypper_cmd = get_zypper_command()
target_root = ''
for root_arg in ('-R', '--root'):
if root_arg in zypper_cmd:
target_root = zypper_cmd.split(root_arg)[-1].split()[0].strip()
break

credentials_location = target_root + base_credentials_location
credentials_base = os.path.join(credentials_location, 'SCCcredentials')
credentials_header = os.path.join(credentials_location, repo_credentials)
ref_user, ref_pass = get_credentials(credentials_base)
Expand Down

0 comments on commit b5dbdb0

Please sign in to comment.