This pull request addresses RANGER-5631, where setup scripts fail when passwords contain % or \.
The proposed changes:
Disable ConfigParser interpolation in the UserSync, TagSync, and Ranger Admin upgrade scripts so % is treated as a literal character.
Allow backslashes in Ranger Admin database passwords while retaining restrictions on quotes and backticks, which remain unsafe in existing shell and SQL interpolation paths.
Use shlex.quote() when adding database usernames and passwords to Unix Jisql commands.
Apply the Jisql handling consistently across MySQL, Oracle, PostgreSQL, SQL Server, and SQL Anywhere paths in dba_script.py and db_setup.py.
Preserve the existing Windows command construction behavior.
How was this patch tested?
The following lightweight local tests were performed:
Parsed all modified Python files to verify syntax.
Verified that a property value containing %, such as Test%Pass1, is read literally with ConfigParser interpolation disabled.
Verified that passwords containing % and \ round-trip unchanged through the Unix shlex.quote() and shlex.split() command-building path.
Invoked the Ranger Admin password-validation entry point and confirmed that Test\Pass1 is accepted.
Ran git diff --check successfully.
Database integration tests were not run locally.
Relationship to the existing pull request
A separate pull request was opened because PR 1069 takes a broader approach that removes the complete Unix password denylist, including restrictions on single quotes, double quotes, and backticks.
Those characters are still interpolated into shell commands and database-specific SQL statements in several existing setup paths. Applying shlex.quote() to Jisql connection arguments protects command-line argument construction, but it does not escape passwords embedded in SQL literals or protect other os.system() call sites. Removing all restrictions before those paths are addressed could therefore introduce broken commands or command/SQL injection risks.
This patch takes a narrower approach:
It fixes % handling by disabling ConfigParser interpolation in all affected copied property readers.
It permits backslashes in the Ranger Admin database setup paths.
It applies shlex.quote() consistently to Unix Jisql credential arguments.
It retains the existing restrictions on quotes and backticks until every shell and database-specific SQL interpolation path can handle them safely.
It updates both dba_script.py and db_setup.py; changing only the DBA script would allow a password during database provisioning but leave the subsequent schema setup path inconsistent.
This keeps the change scoped to the failures reported in RANGER-5631 while avoiding a broader relaxation of password validation without complete downstream escaping.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
This pull request addresses RANGER-5631, where setup scripts fail when passwords contain % or \.
The proposed changes:
How was this patch tested?
The following lightweight local tests were performed:
Database integration tests were not run locally.
Relationship to the existing pull request
A separate pull request was opened because PR 1069 takes a broader approach that removes the complete Unix password denylist, including restrictions on single quotes, double quotes, and backticks.
Those characters are still interpolated into shell commands and database-specific SQL statements in several existing setup paths. Applying shlex.quote() to Jisql connection arguments protects command-line argument construction, but it does not escape passwords embedded in SQL literals or protect other os.system() call sites. Removing all restrictions before those paths are addressed could therefore introduce broken commands or command/SQL injection risks.
This patch takes a narrower approach:
This keeps the change scoped to the failures reported in RANGER-5631 while avoiding a broader relaxation of password validation without complete downstream escaping.