mirror of
https://github.com/ansible/awx.git
synced 2026-03-07 19:51:08 -03:30
escape certain log aggregator settings when generating rsyslog config
see: https://github.com/ansible/awx/issues/6760
This commit is contained in:
@@ -23,6 +23,10 @@ def construct_rsyslog_conf_template(settings=settings):
|
|||||||
'input(type="imuxsock" Socket="' + settings.LOGGING['handlers']['external_logger']['address'] + '" unlink="on")',
|
'input(type="imuxsock" Socket="' + settings.LOGGING['handlers']['external_logger']['address'] + '" unlink="on")',
|
||||||
'template(name="awx" type="string" string="%rawmsg-after-pri%")',
|
'template(name="awx" type="string" string="%rawmsg-after-pri%")',
|
||||||
])
|
])
|
||||||
|
|
||||||
|
def escape_quotes(x):
|
||||||
|
return x.replace('"', '\\"')
|
||||||
|
|
||||||
if not enabled:
|
if not enabled:
|
||||||
parts.append('action(type="omfile" file="/dev/null")') # rsyslog needs *at least* one valid action to start
|
parts.append('action(type="omfile" file="/dev/null")') # rsyslog needs *at least* one valid action to start
|
||||||
tmpl = '\n'.join(parts)
|
tmpl = '\n'.join(parts)
|
||||||
@@ -36,7 +40,7 @@ def construct_rsyslog_conf_template(settings=settings):
|
|||||||
host = '%s://%s' % (scheme, host) if scheme else '//%s' % host
|
host = '%s://%s' % (scheme, host) if scheme else '//%s' % host
|
||||||
parsed = urlparse.urlsplit(host)
|
parsed = urlparse.urlsplit(host)
|
||||||
|
|
||||||
host = parsed.hostname
|
host = escape_quotes(parsed.hostname)
|
||||||
try:
|
try:
|
||||||
if parsed.port:
|
if parsed.port:
|
||||||
port = parsed.port
|
port = parsed.port
|
||||||
@@ -65,8 +69,8 @@ def construct_rsyslog_conf_template(settings=settings):
|
|||||||
if parsed.query:
|
if parsed.query:
|
||||||
path = f'{path}?{urlparse.quote(parsed.query)}'
|
path = f'{path}?{urlparse.quote(parsed.query)}'
|
||||||
params.append(f'restpath="{path}"')
|
params.append(f'restpath="{path}"')
|
||||||
username = getattr(settings, 'LOG_AGGREGATOR_USERNAME', '')
|
username = escape_quotes(getattr(settings, 'LOG_AGGREGATOR_USERNAME', ''))
|
||||||
password = getattr(settings, 'LOG_AGGREGATOR_PASSWORD', '')
|
password = escape_quotes(getattr(settings, 'LOG_AGGREGATOR_PASSWORD', ''))
|
||||||
if getattr(settings, 'LOG_AGGREGATOR_TYPE', None) == 'splunk':
|
if getattr(settings, 'LOG_AGGREGATOR_TYPE', None) == 'splunk':
|
||||||
# splunk has a weird authorization header <shrug>
|
# splunk has a weird authorization header <shrug>
|
||||||
if password:
|
if password:
|
||||||
|
|||||||
Reference in New Issue
Block a user