mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 04:40:22 -07:00
fix yum proxy username/password handling (#46291)
Fixes #46249 Signed-off-by: Adam Miller <admiller@redhat.com>
This commit is contained in:
parent
712ad9ed64
commit
fd97c8e56c
3 changed files with 111 additions and 6 deletions
|
@ -701,20 +701,27 @@ class YumModule(YumDnf):
|
|||
# setting system proxy environment and saving old, if exists
|
||||
my = self.yum_base()
|
||||
namepass = ""
|
||||
proxy_url = ""
|
||||
scheme = ["http", "https"]
|
||||
old_proxy_env = [os.getenv("http_proxy"), os.getenv("https_proxy")]
|
||||
try:
|
||||
if my.conf.proxy:
|
||||
if my.conf.proxy_username:
|
||||
namepass = namepass + my.conf.proxy_username
|
||||
proxy_url = my.conf.proxy
|
||||
if my.conf.proxy_password:
|
||||
namepass = namepass + ":" + my.conf.proxy_password
|
||||
namepass = namepass + '@'
|
||||
for item in scheme:
|
||||
os.environ[item + "_proxy"] = re.sub(
|
||||
r"(http://)",
|
||||
r"\1" + namepass, my.conf.proxy
|
||||
)
|
||||
elif '@' in my.conf.proxy:
|
||||
namepass = my.conf.proxy.split('@')[0].split('//')[-1]
|
||||
proxy_url = my.conf.proxy.replace("{0}@".format(namepass), "")
|
||||
|
||||
if namepass:
|
||||
namepass = namepass + '@'
|
||||
for item in scheme:
|
||||
os.environ[item + "_proxy"] = re.sub(
|
||||
r"(http://)",
|
||||
r"\1" + namepass, proxy_url
|
||||
)
|
||||
yield
|
||||
except yum.Errors.YumBaseError:
|
||||
raise
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue