Преглед изворни кода

Reject purely numeric usernames

Unix utility getent confuse numbers-as-usernames with unix-ids. Easiest fix is to prohibit numerical usernames.
See  https://github.com/hestiacp/hestiacp/issues/5124 for more info.
divinity76 пре 5 месеци
родитељ
комит
6a279eeb8b
1 измењених фајлова са 5 додато и 0 уклоњено
  1. 5 0
      func/main.sh

+ 5 - 0
func/main.sh

@@ -738,6 +738,11 @@ is_localpart_format_valid() {
 
 # Username / ftp username format validator
 is_user_format_valid() {
+	# Reject purely numeric names like "123"
+	if [[ "$1" =~ ^[0-9]+$ ]]; then
+		check_result "$E_INVALID" "invalid $2 format :: $1"
+	fi
+
 	if [ ${#1} -eq 1 ]; then
 		if ! [[ "$1" =~ ^^[[:alnum:]]$ ]]; then
 			check_result "$E_INVALID" "invalid $2 format :: $1"