Skip to content

Commit

Permalink
fix(scripts): prevent adding wireguard 'usernames' longer than 15 cha…
Browse files Browse the repository at this point in the history
…racters, fixes issue #1816
  • Loading branch information
orazioedoardo committed Apr 13, 2024
1 parent f732de2 commit 68520aa
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions scripts/wireguard/makeCONF.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ checkName() {
elif [[ "${CLIENT_NAME::1}" == "." ]]; then
err "Names cannot start with a . (dot)."
exit 1
elif [[ "${#CLIENT_NAME}" -gt 15 ]]; then
err "::: Names cannot be longer than 15 characters."
exit 1
elif [[ -z "${CLIENT_NAME}" ]]; then
err "::: You cannot leave the name blank."
exit 1
Expand Down

3 comments on commit 68520aa

@davidbeesley
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is there a “#” on line 55 as part of CLIENTNAME when none of the other elif have one?

@orazioedoardo
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

# means the length of the variable.

$ CLIENT_NAME="abcdef"
$ echo "${#CLIENT_NAME}
6

@davidbeesley
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

Please sign in to comment.