From f5a42ab9667ea579dbbced5c79a8f355d02c15ca Mon Sep 17 00:00:00 2001 From: lotherk Date: Wed, 18 Nov 2026 12:28:02 +0000 Subject: [PATCH] dtlogin: LANG before PATH in the session environment (ksh93 dropped it) The session ran with LANG=C although dtlogin passed LANG=en_US.UTF-8 to Xsession (dtlogin -debug 3: 'LANG=en_US.UTF-8'; ps -e on Xsession showed it). Xsession is a ksh93 script, and ksh93 93u+m 1.0.10 on NetBSD rejects LANG as 'en_US.UTF-8: unknown locale' and leaves it empty when PATH comes earlier in the environment (put_lang -> libast setlocale); Xsession then set LANG=C. Measured in the installed system: env -i PATH=/bin:/usr/bin LANG=en_US.UTF-8 ksh93 -> empty, LANG before PATH -> kept, no PATH -> kept. verify.c now creates LANG right after LOGNAME; setLang() replaces the value in place. Tests: test-desktop-login's LOGIN and CORES checks matched padded ps and wc output ('CORES= 0'); install-simple's .local lookup is bounded to 5 s per round (the loop outlasted ENDCHK's 300 s without a network). --- ext/src/mcde/programs/dtlogin/verify.c | 11 +++++++++++ tools/install-simple.sh | 4 +++- tools/test-desktop-login.sh | 4 ++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/ext/src/mcde/programs/dtlogin/verify.c b/ext/src/mcde/programs/dtlogin/verify.c index fa2abb30a9..8ba6ea08f9 100644 --- a/ext/src/mcde/programs/dtlogin/verify.c +++ b/ext/src/mcde/programs/dtlogin/verify.c @@ -339,6 +339,17 @@ userEnv( #else env = 0; env = setEnv (env,"LOGNAME", user); + /* + * MCDE: LANG before PATH. Xsession is a ksh93 script, and ksh93 + * (93u+m 1.0.10 on NetBSD) rejects LANG as "unknown locale" and + * leaves it empty when PATH comes earlier in the environment; + * Xsession then set LANG=C for the whole session. Measured in the + * installed system 2026-11-18: env -i PATH=/bin:/usr/bin + * LANG=en_US.UTF-8 ksh93 -> LANG empty; LANG first -> kept. + * setEnv() replaces in place, so setLang() below only sets the value. + */ + if (d->language && strlen(d->language) > 0) + env = setEnv (env, "LANG", d->language); #endif for (exp = exportList; exp && *exp; ++exp) diff --git a/tools/install-simple.sh b/tools/install-simple.sh index f158a83349..5395e3ff7a 100755 --- a/tools/install-simple.sh +++ b/tools/install-simple.sh @@ -357,7 +357,9 @@ $V send 'echo NPF_RULES=$(/sbin/npfctl show 2>/dev/null | grep -c block)\r' $V send 'echo ROOTSSH=$(grep -c "^PermitRootLogin yes" /etc/ssh/sshd_config)\r' $V send 'echo NSS=$(grep -c "^hosts: files mdnsd dns" /etc/nsswitch.conf)\r' $V send 'echo MDNSD=$(ps ax | grep -c "[m]dnsd")\r' -$V send 'i=0; while [ $i -lt 30 ]; do n=$(getent hosts $(hostname).local | wc -l); [ $n -ge 1 ] && break; sleep 2; i=$((i+1)); done; echo MDNS_NAME=$n\r' +# each lookup of the .local name can wait for mDNS without a network; the +# 30 rounds outlasted the 300 s for ENDCHK (2026-11-18), so one is 5 s at most +$V send 'i=0; while [ $i -lt 30 ]; do n=$(timeout 5 getent hosts $(hostname).local | wc -l); [ $n -ge 1 ] && break; sleep 2; i=$((i+1)); done; echo MDNS_NAME=$n\r' $V send 'echo DBUS=$(ps ax | grep -c "[d]bus-daemon")\r' $V send 'echo CUPSD=$(ps ax | grep -c "[c]upsd")\r' $V send 'echo PULSE=$(/usr/pkg/bin/pulseaudio --version)\r' diff --git a/tools/test-desktop-login.sh b/tools/test-desktop-login.sh index 4a51584457..13d29d4c04 100755 --- a/tools/test-desktop-login.sh +++ b/tools/test-desktop-login.sh @@ -166,9 +166,9 @@ $V send 'echo SND=$(ps ax | grep -c "[m]cdesoundd")\r' $V send 'echo TT=$(ps ax | grep -c "[t]tsession")\r' $V send 'echo RPCB=$(ps ax | grep -c "[r]pcbind")\r' $V send 'echo RCFG=$(grep -c "^rpcbind=YES" /etc/rc.conf)\r' -$V send 'echo LOGIN=$(ps ax -o user= | grep -c "^'"$USER"'$")\r' +$V send 'echo LOGIN=$(ps ax -o user= | sed "s/ *$//" | grep -c "^'"$USER"'$")\r' $V send 'echo S$(ps -eww -o command -p $(pgrep -u '"$USER"' dtsession | head -1) | tr " " "\\n" | grep "^LANG=")\r' -$V send 'echo CORES=$(ls /home/'"$USER"'/*.core 2>/dev/null | wc -l)\r' +$V send 'echo CORES=$(ls /home/'"$USER"'/*.core 2>/dev/null | wc -l | tr -d " ")\r' $V send 'EOF\r' sleep 2 $V send 'sh /tmp/dl.sh; echo ENDLOGIN\r'