From 3288c22e64440ae93eb28190a70621d68045fb14 Mon Sep 17 00:00:00 2001 From: Laurent Indermuehle Date: Thu, 14 Sep 2023 14:50:57 +0200 Subject: [PATCH] fix quote around special priv Proxy for root on ``@`%` --- plugins/modules/mysql_info.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plugins/modules/mysql_info.py b/plugins/modules/mysql_info.py index 80a7de4..2f246b7 100644 --- a/plugins/modules/mysql_info.py +++ b/plugins/modules/mysql_info.py @@ -538,7 +538,14 @@ class MySQL_Info(object): if db_table == '*.*' and priv == 'USAGE': continue - priv_string.append("'%s': '%s'" % (db_table, ','.join(priv))) + # privileges_get returns "'''@''': 'PROXY,GRANT'". The % is missing + # and there is too many quotes. So we rewrite this. + if priv == ['PROXY', 'GRANT'] and u == 'root': + priv_string.append("'``@`%`: 'PROXY,GRANT'") + continue + + unquote_db_table = db_table.replace('`', '').replace("'", '') + priv_string.append("'%s': '%s'" % (unquote_db_table, ','.join(priv))) self.info['users_privs'][key] = { 'user': u, 'host': h, 'privs': '/'.join(priv_string)}