Skip to content

Commit

Permalink
Revert "Merge pull request NixOS#70137 from michaelpj/fix-pam-variabl…
Browse files Browse the repository at this point in the history
…e-subst"

This reverts commit 08e03bf.
  • Loading branch information
dtzWill committed Oct 5, 2019
1 parent 78dafc7 commit 9f9fea1
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions nixos/modules/config/system-environment.nix
Expand Up @@ -8,6 +8,11 @@ let

cfg = config.environment;

pamProfiles =
map
(replaceStrings ["$HOME" "$USER"] ["@{HOME}" "@{PAM_USER}"])
cfg.profiles;

in

{
Expand Down Expand Up @@ -70,20 +75,13 @@ in
let
suffixedVariables =
flip mapAttrs cfg.profileRelativeSessionVariables (envVar: suffixes:
flip concatMap cfg.profiles (profile:
flip concatMap pamProfiles (profile:
map (suffix: "${profile}${suffix}") suffixes
)
);

# We're trying to use the same syntax for PAM variables and env variables.
# That means we need to map the env variables that people might use to their
# equivalent PAM variable.
# Note: PAM_USER is a PAM_ITEM, HOME is an environment variable, they have
# different syntax.
replaceEnvVars = replaceStrings ["$HOME" "$USER"] ["\${HOME}" "@{PAM_USER}"];

pamVariable = n: v:
''${n} DEFAULT="${concatStringsSep ":" (map replaceEnvVars (toList v))}"'';
''${n} DEFAULT="${concatStringsSep ":" (toList v)}"'';

pamVariables =
concatStringsSep "\n"
Expand Down

0 comments on commit 9f9fea1

Please sign in to comment.