summaryrefslogtreecommitdiffstats
path: root/core/modules/pam-bwidm
diff options
context:
space:
mode:
authorSimon Rettberg2022-07-18 11:58:39 +0200
committerSimon Rettberg2022-07-18 11:58:39 +0200
commit50dfaf6e1e98caa0c39570f83b2eeaff53bf52ab (patch)
tree3c98c427b3a9963e70c098d75f59e83f09b00005 /core/modules/pam-bwidm
parent[pam-bwidm] Add marker to username (diff)
downloadmltk-50dfaf6e1e98caa0c39570f83b2eeaff53bf52ab.tar.gz
mltk-50dfaf6e1e98caa0c39570f83b2eeaff53bf52ab.tar.xz
mltk-50dfaf6e1e98caa0c39570f83b2eeaff53bf52ab.zip
[pam-bwidm] Try UID gen 10 times, invert counting to simplify check
Diffstat (limited to 'core/modules/pam-bwidm')
-rwxr-xr-xcore/modules/pam-bwidm/data/opt/openslx/scripts/pam_bwidm10
1 files changed, 5 insertions, 5 deletions
diff --git a/core/modules/pam-bwidm/data/opt/openslx/scripts/pam_bwidm b/core/modules/pam-bwidm/data/opt/openslx/scripts/pam_bwidm
index 5215eccc..41ac2636 100755
--- a/core/modules/pam-bwidm/data/opt/openslx/scripts/pam_bwidm
+++ b/core/modules/pam-bwidm/data/opt/openslx/scripts/pam_bwidm
@@ -243,14 +243,14 @@ write_user_data() {
gexp="$( printf "%s" "${PAM_USER}" | sed 's/[][$^\.*]/\\&/g' )" # Basic regexp
if ! grep -q "^${gexp}:" /etc/passwd; then
# create a random 6digit UID
- LOOPS=0
- while [ "$LOOPS" -lt 5 ]; do
+ LOOPS=10
+ while [ "$LOOPS" -gt 0 ]; do
USER_UID="$(( 100000 + RANDOM % 100000 ))"
- # check existence of this UID, if its free, use it
+ # check existence of this UID, if it's free, use it
getent passwd "$USER_UID" || break
- let LOOPS++
+ let LOOPS--
done
- if [ "$LOOPS" -eq 5 ]; then
+ if [ "$LOOPS" -eq 0 ]; then
# could not find an empty random 6-digit UID, so we will use demo's UID...
USER_UID="$(id -u demo)"
[ -z "$USER_UID" ] && echo "Could not use UID of 'demo' as a fallback, aborting..." && exit 1