fix yum proxy regex (closes #47797) (#47800)

* Modify yum/tasks/proxy.yml to usernames that expose regex bug

* Fix bad regex backref/interpolation w/yum proxy username

A yum proxy username that begins with a number was being
interpolated as part of the backref, resulting in an error:
"sre_constants.error: invalid group reference"

Closes #47797
pull/47865/head
Paul Harvey 6 years ago committed by Martin Krizek
parent 4b8f2c99d2
commit cd75074fc5

@ -710,7 +710,7 @@ class YumModule(YumDnf):
for item in scheme: for item in scheme:
os.environ[item + "_proxy"] = re.sub( os.environ[item + "_proxy"] = re.sub(
r"(http://)", r"(http://)",
r"\1" + namepass, proxy_url r"\g<1>" + namepass, proxy_url
) )
yield yield
except yum.Errors.YumBaseError: except yum.Errors.YumBaseError:

@ -6,7 +6,7 @@
- lineinfile: - lineinfile:
path: /etc/tinyproxy/tinyproxy.conf path: /etc/tinyproxy/tinyproxy.conf
line: "BasicAuth testuser testpassword" line: "BasicAuth 1testuser 1testpassword"
state: present state: present
# systemd doesn't play nice with this in a container for some reason # systemd doesn't play nice with this in a container for some reason
@ -15,7 +15,7 @@
- lineinfile: - lineinfile:
path: /etc/yum.conf path: /etc/yum.conf
line: "proxy=http://testuser:testpassword@127.0.0.1:8888" line: "proxy=http://1testuser:1testpassword@127.0.0.1:8888"
state: present state: present
- yum: - yum:
@ -35,7 +35,7 @@
- lineinfile: - lineinfile:
path: /etc/yum.conf path: /etc/yum.conf
line: "proxy=http://testuser:testpassword@127.0.0.1:8888" line: "proxy=http://1testuser:1testpassword@127.0.0.1:8888"
state: absent state: absent
- lineinfile: - lineinfile:
@ -45,12 +45,12 @@
- lineinfile: - lineinfile:
path: /etc/yum.conf path: /etc/yum.conf
line: "proxy_username=testuser" line: "proxy_username=1testuser"
state: present state: present
- lineinfile: - lineinfile:
path: /etc/yum.conf path: /etc/yum.conf
line: "proxy_password=testpassword" line: "proxy_password=1testpassword"
state: present state: present
- yum: - yum:
@ -75,7 +75,7 @@
- lineinfile: - lineinfile:
path: /etc/yum.conf path: /etc/yum.conf
line: "proxy=http://testuser:testpassword@127.0.0.1:8888" line: "proxy=http://1testuser:1testpassword@127.0.0.1:8888"
state: absent state: absent
- lineinfile: - lineinfile:
@ -85,12 +85,12 @@
- lineinfile: - lineinfile:
path: /etc/yum.conf path: /etc/yum.conf
line: "proxy_username=testuser" line: "proxy_username=1testuser"
state: absent state: absent
- lineinfile: - lineinfile:
path: /etc/yum.conf path: /etc/yum.conf
line: "proxy_password=testpassword" line: "proxy_password=1testpassword"
state: absent state: absent
when: when:
- (ansible_distribution in ['RedHat', 'CentOS', 'ScientificLinux'] and ansible_distribution_major_version|int == 7) - (ansible_distribution in ['RedHat', 'CentOS', 'ScientificLinux'] and ansible_distribution_major_version|int == 7)

Loading…
Cancel
Save