Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

escape_for_shell double-escapes #24

Open
hholzgra opened this issue Nov 18, 2016 · 0 comments
Open

escape_for_shell double-escapes #24

hholzgra opened this issue Nov 18, 2016 · 0 comments

Comments

@hholzgra
Copy link

hholzgra commented Nov 18, 2016

escape_for_shell() function escapes characters with "special" meaning to the shell, like \ or #, and also puts the result string into single quotes. Within single quotes these special characters do not have a special meaning though, especially a \ inside single quotes is just a regular character, eg:

$ echo \\
\

$ echo '\\'
\\

So for example a password containing a #, like secr#t, becomes 'secr\#t', while the correctly shell-escaped forms would be either secr\#t (with backslash but without single qoutes) or 'secr#t' (in single quotes, but without backslash). This then breaks invocation of external scripts like master_ip_failover and master_ip_online_change

The fix for this would be simple: do not put the already backslash-escaped string into extra single quotes:

diff --git a/lib/MHA/NodeUtil.pm b/lib/MHA/NodeUtil.pm
index c0bdba5..ed8b407 100644
--- a/lib/MHA/NodeUtil.pm
+++ b/lib/MHA/NodeUtil.pm
@@ -253,7 +253,7 @@ sub escape_for_shell {
     }
     $ret .= "$x";
   }
-  $ret = "'" . $ret . "'";
+#  $ret = "'" . $ret . "'";
   return $ret;
 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant