microsoft / microsoft/WSL

Start user shells in proper PAM sessions

Open
#9,213 7 comments 12 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature
Dominant language
C++
Stars
33.7k
Forks
1.8k
Avg merge
3d 17h
Merged PRs (30d)
116

Description

**Is your feature request related to a problem? Please describe.**
In NixOS, we rely on PAM to set up some important environment variables, including some related to locales, via `pam_env.so`. Right now WSL starts a single non-interactive shell with `login -f` to trigger the user systemd instance, but all the interactive shells are spawned bypassing PAM, and therefore not importing the environment variables.

**Describe the solution you'd like**
WSL starts every interactive shell instance via `login` or a similar mechanism that runs PAM modules.

**Describe alternatives you've considered**
Right now we're considering wrapping the user-selected shell in a script that updates the environment manually, but this will not be correct if any other PAM modules are involved.

**Additional context**
The specific issue that led me to notice this was zsh failing to discover locales when spawned through WSL, as we require the LOCALE_ARCHIVE environment variable to be set for locale archives to be discovered.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing WSL's interactive-shell launch path and compare it with the existing non-interactive `login -f` path. Check how PAM sessions, including `pam_env.so`, are invoked before launching the user-selected shell, and verify that locale variables such as `LOCALE_ARCHIVE` are available in zsh.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, linux, zsh
Domain
cli, operating-systems
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.