Skip to content

RANGER-5631: Fix setup passwords containing percent and backslash - #1159

Open
arnabnandy7 wants to merge 1 commit into
apache:masterfrom
arnabnandy7:fix/setup-password-special-characters
Open

RANGER-5631: Fix setup passwords containing percent and backslash#1159
arnabnandy7 wants to merge 1 commit into
apache:masterfrom
arnabnandy7:fix/setup-password-special-characters

Conversation

@arnabnandy7

@arnabnandy7 arnabnandy7 commented Aug 15, 2026

Copy link
Copy Markdown

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:

  • 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.

Signed-off-by: Arnab Nandy <arnab_nandy7@yahoo.com>
@arnabnandy7
arnabnandy7 force-pushed the fix/setup-password-special-characters branch from decc6fa to 40de0a3 Compare August 15, 2026 08:03
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

Successfully merging this pull request may close these issues.

1 participant