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
This commit is contained in:
Paul Harvey 2018-10-31 02:35:37 +11:00 committed by Martin Krizek
parent 4b8f2c99d2
commit cd75074fc5
2 changed files with 9 additions and 9 deletions

View file

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

View file

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