OSAC-1381: Fix htpasswd generation failure with special characters in password#468
Conversation
|
Warning Review limit reached
More reviews will be available in 51 minutes and 45 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThe PR modifies the Ironic credential hashing task in the deployment playbook, changing the execution method from argv-based ChangesIronic Htpasswd Generation Method
Estimated Code Review Effort🎯 2 (Simple) | ⏱️ ~8 minutes Security Risk Assessment: Poem
🚥 Pre-merge checks | ✅ 11✅ Passed checks (11 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
… password The htpasswd generation task fails when the randomly-generated password contains certain special characters (e.g., #, @, \, }, /, ~, =). This causes Ironic API authentication to fail with 401 Unauthorized errors. Root cause: Commit 0eb46d5 switched from the command module to argv form to fix trailing backslash issues, but the argv form does not properly handle complex special characters, causing htpasswd to receive mangled input and generate an incorrect hash that doesn't match the password. Fix: Use shell module with Ansible's quote filter, which uses shlex.quote() to properly escape ALL special characters including: - Trailing backslashes (the original issue from 0eb46d5) - Complex special characters like #@\#}/~= (the current issue) - Spaces, quotes, and other edge cases The quote filter wraps arguments in single quotes and properly escapes any embedded single quotes, ensuring htpasswd receives the password exactly as generated. Fixes: gori-project/GoRI#915 Assisted-by: Claude Code <noreply@anthropic.com>
0410e75 to
2048eb9
Compare
|
e2e connected failure related to #469 |
|
Claude Code - How this fix aligns with Bob's diagnosis: Bob's testing proved that the htpasswd hash stored in This mismatch proves the htpasswd generation is broken - it's receiving mangled input. Root cause: The This fix: Using Verification: With this fix, regenerating htpasswd from the stored password will produce the same hash every time, eliminating the auth mismatch Bob identified. |
Summary
Fixes Ironic API authentication failures (401 Unauthorized) caused by incorrect htpasswd generation when passwords contain special characters.
Problem
Bootstrap deployment fails at the "Check if baremetal node already exists" task when the randomly-generated Metal3 Ironic password contains certain special characters (e.g.,
#,@,\,},/,~,=).Error:
Root Cause
Commit 0eb46d5 (April 19, 2026) switched from
commandmodule toargvform to fix trailing backslash issues. However, theargvform does not properly handle complex special characters, causing htpasswd to receive mangled input and generate an incorrect hash that doesn't match the stored password.Timeline:
Solution
Use
shellmodule with Ansible'squotefilter instead ofargvform. Thequotefilter usesshlex.quote()to properly escape ALL special characters:Before:
After:
This properly handles:
#@\#}/~=(the current issue)Testing
Validated that
shlex.quote()(which backs Ansible'squotefilter) correctly handles the problematic password from the failing deployment:#@Ny.MGr76\#}YPvm3W1Y/~=GdjQ0MQVRelated Issues
Checklist
Summary by CodeRabbit