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).
This commit is contained in:
lotherk committed 2026-11-18 12:28:02 +00:00
1 parent ef5f4457c6
commit f5a42ab966
3 files changed
+16 -3

No files matched your search

+11
View File
@@ -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)
+3 -1
View File
@@ -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'
+2 -2
View File
@@ -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'