By default, xdm does not use a login shell, thus the shell does not read
/etc/profile and xdm does not use environment variable set in this file.
Most importantly the $PATH configured in /etc/profile is not used.
Instead, xdm sets $PATH to the value of DEF_USER_PATH as determined by
the configure script. On Alpine, this defaults to:

	/bin:/usr/bin:/usr/bin:/usr/ucb

This is not a sensible default for Alpine. The standard Alpine mechanism
for configuring $PATH is through /etc/profile. As such, we patch the
Xsession startup script to use a login shell, thereby forcing the shell
to read /etc/proflie.

Patch inspired by Arch Linux <https://bugs.archlinux.org/task/9167>.
Contrary to the Arch Linux patch, this patch still allows .xsession to
be a non-executable file by retaining the case distinction.

diff -upr xdm-1.1.12.orig/config/Xsession.in xdm-1.1.12/config/Xsession.in
--- xdm-1.1.12.orig/config/Xsession.in	2021-06-27 15:04:37.611614730 +0200
+++ xdm-1.1.12/config/Xsession.in	2021-06-27 15:05:27.211816165 +0200
@@ -54,9 +54,9 @@ resources=$HOME/.Xresources
 
 if [ -s "$startup" ]; then
 	if [ -x "$startup" ]; then
-		exec "$startup"
+		exec /bin/sh -ls -c "$startup"
 	else
-		exec /bin/sh "$startup"
+		exec /bin/sh -l "$startup"
 	fi
 else
 	if [ -r "$resources" ]; then
