Skip to content

fix: resolve PAM account management error for sudo in nix image#11

Merged
megheaiulian merged 2 commits intomainfrom
fix/nix-sudo-pam
Feb 10, 2026
Merged

fix: resolve PAM account management error for sudo in nix image#11
megheaiulian merged 2 commits intomainfrom
fix/nix-sudo-pam

Conversation

@megheaiulian
Copy link
Contributor

Summary

Fixes sudo: PAM account management error: Permission denied when running sudo as the coder user in the Nix Docker image.

Root Cause

Two issues combined to break sudo:

  1. Locked shadow entry — The coder user's /etc/shadow entry used ! (password locked), which causes pam_unix.so account management to return PAM_PERM_DENIED ("Permission denied").

  2. Missing /etc/pam.d/sudo — Without a dedicated PAM config for sudo, PAM fell back to /etc/pam.d/other which only had pam_rootok.so for auth (only works when the caller is already root).

Changes

  • /etc/shadow: Change !* for both root and coder entries. * means "no valid password hash" (cannot authenticate via password) but does not mark the account as locked, so pam_unix.so account management succeeds.

  • /etc/pam.d/sudo: Add a dedicated PAM config for sudo that uses pam_permit.so for auth and account checks (since actual authorisation is handled by sudoers), with pam_unix.so for session setup.

The coder user's shadow entry used '!' (locked account) which caused
pam_unix.so account management to return PAM_PERM_DENIED. Additionally,
sudo fell back to the catch-all /etc/pam.d/other config which lacked
appropriate auth rules for non-root users.

- Change shadow entries from '!' to '*' (no password, but not locked)
- Add dedicated /etc/pam.d/sudo PAM config with pam_permit.so for
  auth/account (sudoers handles actual authorisation)
The devops Dockerfile expects curl from the base image, but CI was
overriding BASE_IMAGE with ubuntu:noble (which lacks curl), causing
the build to always fail.
@megheaiulian megheaiulian merged commit a9aeaaf into main Feb 10, 2026
5 of 6 checks passed
@megheaiulian megheaiulian deleted the fix/nix-sudo-pam branch February 10, 2026 12:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant