For the MariaDB and MySQL database hooks, escape quotes in passwords when the "password_transport" option is "pipe".

This commit is contained in:
Dan Helfman
2026-04-24 10:24:45 -07:00
parent 3e80056956
commit 961ff7c724
3 changed files with 22 additions and 1 deletions
@@ -64,6 +64,23 @@ def test_make_defaults_file_escapes_password_containing_backslash():
)
def test_make_defaults_file_escapes_password_containing_quote():
read_descriptor = 99
write_descriptor = flexmock()
flexmock(module.os).should_receive('pipe').and_return(read_descriptor, write_descriptor)
flexmock(module.os).should_receive('write').with_args(
write_descriptor,
b'[client]\nuser=root\n' + rb'password="trust\"some1"',
).once()
flexmock(module.os).should_receive('close')
flexmock(module.os).should_receive('set_inheritable')
assert module.make_defaults_file_options(username='root', password=r'trust"some1') == (
'--defaults-extra-file=/dev/fd/99',
)
def test_make_defaults_file_pipe_with_only_username_writes_it_to_file_descriptor():
read_descriptor = 99
write_descriptor = flexmock()