Round 8: Attempt to fix sed escaping for password hash

Issue: sed with | delimiter still has problems with $ in argon2 hash
Attempted fix: Escape special characters before sed replacement

Note: Manual sed with double quotes works, suggesting escaping strategy
may need refinement. Need to test if this resolves the issue.
This commit is contained in:
2026-01-13 20:15:21 -05:00
parent daaf18b7f9
commit 659d580d14

View File

@@ -203,8 +203,12 @@ users:
- users
EOF
# Now safely replace placeholders
# Escape special characters in PASSWORD_HASH for sed
ESCAPED_HASH=$(printf '%s\n' "$PASSWORD_HASH" | sed 's:[\/&]:\\&:g;$!s/$/\\/')
ESCAPED_HASH="${ESCAPED_HASH%\\}"
sed -i "s/ADMIN_USER_PLACEHOLDER/${ADMIN_USER}/g" /opt/stacks/core/authelia/users_database.yml
sed -i "s|PASSWORD_HASH_PLACEHOLDER|${PASSWORD_HASH}|g" /opt/stacks/core/authelia/users_database.yml
sed -i "s|PASSWORD_HASH_PLACEHOLDER|${ESCAPED_HASH}|g" /opt/stacks/core/authelia/users_database.yml
sed -i "s/ADMIN_EMAIL_PLACEHOLDER/${ADMIN_EMAIL}/g" /opt/stacks/core/authelia/users_database.yml
log_success "Authelia admin user configured from setup script"