View Issue Details

IDProjectCategoryView StatusLast Update
0009794Kali LinuxKali Package Bugpublic2026-07-20 08:23
Reporterjulienraptor01 Assigned Toarnaudr  
PrioritynormalSeverityminorReproducibilityhave not tried
Status assignedResolutionopen 
Summary0009794: Kali WSL isn't loading /etc/environment
Description

kali-defaults inject this in /etc/environment

# START KALI-DEFAULTS CONFIG
# Everything from here and until STOP KALI-DEFAULTS CONFIG
# was installed by the kali-defaults package, and it will
# be removed if ever the kali-defaults package is removed.
# If you want to disable a line, please do NOT remove it,
# as it would be added back when kali-defaults is upgraded.
# Instead, comment the line out, and your change will be
# preserved across upgrades.
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games
COMMAND_NOT_FOUND_INSTALL_PROMPT=1
POWERSHELL_UPDATECHECK=Off
POWERSHELL_TELEMETRY_OPTOUT=1
DOTNET_CLI_TELEMETRY_OPTOUT=1
# STOP KALI-DEFAULTS CONFIG

however in Kali used via WSL /etc/environment isn't loaded due to pam not being used and pam having the role of loading that
this means that all those don't take effects
i currently patched it by emulating pam like this

diff --git a/etc/profile.bak b/etc/profile
index ca27ab2..34c2b2d 100644
--- a/etc/profile.bak
+++ b/etc/profile
@@ -1,38 +1,49 @@
 # /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
 # and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).

 # WSL already sets PATH, shouldn't be overridden
 IS_WSL=$( grep -i microsoft /proc/version )
 if test "${IS_WSL}" = ""; then
   if [ "$( id -u )" -eq 0 ]; then
     PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
   else
     PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games"
   fi
+else
+  # In WSL, PAM is bypassed so /etc/environment is never loaded.
+  # We emulate PAM here, but prevent PATH from being overridden
+  if [ -f /etc/environment ]; then
+    _WSL_SAVED_PATH="$PATH"
+    set -a
+    . /etc/environment
+    set +a
+    PATH="$_WSL_SAVED_PATH"
+    unset _WSL_SAVED_PATH
+  fi
 fi
 export PATH

 if [ "$\{PS1-}" ]; then
   if [ "${BASH-}" ] && [ "${BASH}" != "/bin/sh" ]; then
     # The file bash.bashrc already sets the default PS1.
     # PS1='\h:\w$ '
     if [ -f /etc/bash.bashrc ]; then
       . /etc/bash.bashrc
     fi
   else
     if [ "$( id -u )" -eq 0 ]; then
       PS1='# '
     else
       PS1='$ '
     fi
   fi
 fi

 if [ -d /etc/profile.d ]; then
   for i in /etc/profile.d/*.sh; do
     if [ -r $i ]; then
       . $i
     fi
   done
   unset i
 fi

i don't know if this patch, basically emulating pam on WSL is the good way, maybe instead those variables should be somewhere else ?

Activities

There are no notes attached to this issue.

Issue History

Date Modified Username Field Change
2026-07-19 22:03 julienraptor01 New Issue
2026-07-20 08:23 daniruiz Assigned To => daniruiz
2026-07-20 08:23 daniruiz Status new => assigned
2026-07-20 08:23 daniruiz Assigned To daniruiz => arnaudr