Skip to content

Commit

Permalink
[bitnami/openldap] Validate port related values
Browse files Browse the repository at this point in the history
Assert that port related values are positive int

Signed-off-by: Arano-kai <Arano-kai@users.noreply.github.com>
  • Loading branch information
Arano-kai committed Aug 16, 2024
1 parent da6ad37 commit 9ef7459
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,12 @@ ldap_validate() {
print_validation_error "Specify the same number of passwords on LDAP_PASSWORDS as the number of users on LDAP_USERS!"
fi

for var in LDAP_PORT_NUMBER LDAP_LDAPS_PORT_NUMBER LDAP_PROXYPROTO_PORT_NUMBER LDAP_PROXYPROTO_LDAPS_PORT_NUMBER; do
if ! is_positive_int "${!var}"; then
print_validation_error "The value for $var must be positive integer!"
fi
done

if [[ -n "$LDAP_PORT_NUMBER" ]] && [[ -n "$LDAP_LDAPS_PORT_NUMBER" ]]; then
if [[ "$LDAP_PORT_NUMBER" -eq "$LDAP_LDAPS_PORT_NUMBER" ]]; then
print_validation_error "LDAP_PORT_NUMBER and LDAP_LDAPS_PORT_NUMBER are bound to the same port!"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,12 @@ ldap_validate() {
print_validation_error "Specify the same number of passwords on LDAP_PASSWORDS as the number of users on LDAP_USERS!"
fi

for var in LDAP_PORT_NUMBER LDAP_LDAPS_PORT_NUMBER LDAP_PROXYPROTO_PORT_NUMBER LDAP_PROXYPROTO_LDAPS_PORT_NUMBER; do
if ! is_positive_int "${!var}"; then
print_validation_error "The value for $var must be positive integer!"
fi
done

if [[ -n "$LDAP_PORT_NUMBER" ]] && [[ -n "$LDAP_LDAPS_PORT_NUMBER" ]]; then
if [[ "$LDAP_PORT_NUMBER" -eq "$LDAP_LDAPS_PORT_NUMBER" ]]; then
print_validation_error "LDAP_PORT_NUMBER and LDAP_LDAPS_PORT_NUMBER are bound to the same port!"
Expand Down

0 comments on commit 9ef7459

Please sign in to comment.