mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-02-09 21:53:24 +00:00
![Silvan Mosberger](/assets/img/avatar_default.png)
After final improvements to the official formatter implementation, this commit now performs the first treewide reformat of Nix files using it. This is part of the implementation of RFC 166. Only "inactive" files are reformatted, meaning only files that aren't being touched by any PR with activity in the past 2 months. This is to avoid conflicts for PRs that might soon be merged. Later we can do a full treewide reformat to get the rest, which should not cause as many conflicts. A CI check has already been running for some time to ensure that new and already-formatted files are formatted, so the files being reformatted here should also stay formatted. This commit was automatically created and can be verified using nix-builda08b3a4d19
.tar.gz \ --argstr baseRevb32a094368
result/bin/apply-formatting $NIXPKGS_PATH
84 lines
2.1 KiB
Nix
84 lines
2.1 KiB
Nix
import ../make-test-python.nix (
|
|
{ pkgs, lib, ... }:
|
|
|
|
let
|
|
testOnlySSHCredentials =
|
|
pkgs.runCommand "pam-ussh-test-ca"
|
|
{
|
|
nativeBuildInputs = [ pkgs.openssh ];
|
|
}
|
|
''
|
|
mkdir $out
|
|
ssh-keygen -t ed25519 -N "" -f $out/ca
|
|
|
|
ssh-keygen -t ed25519 -N "" -f $out/alice
|
|
ssh-keygen -s $out/ca -I "alice user key" -n "alice,root" -V 19700101:forever $out/alice.pub
|
|
|
|
ssh-keygen -t ed25519 -N "" -f $out/bob
|
|
ssh-keygen -s $out/ca -I "bob user key" -n "bob" -V 19700101:forever $out/bob.pub
|
|
'';
|
|
makeTestScript =
|
|
user:
|
|
pkgs.writeShellScript "pam-ussh-${user}-test-script" ''
|
|
set -euo pipefail
|
|
|
|
eval $(${pkgs.openssh}/bin/ssh-agent)
|
|
|
|
mkdir -p $HOME/.ssh
|
|
chmod 700 $HOME/.ssh
|
|
cp ${testOnlySSHCredentials}/${user}{,.pub,-cert.pub} $HOME/.ssh
|
|
chmod 600 $HOME/.ssh/${user}
|
|
chmod 644 $HOME/.ssh/${user}{,-cert}.pub
|
|
|
|
set -x
|
|
|
|
${pkgs.openssh}/bin/ssh-add $HOME/.ssh/${user}
|
|
${pkgs.openssh}/bin/ssh-add -l &>2
|
|
|
|
exec sudo id -u -n
|
|
'';
|
|
in
|
|
{
|
|
name = "pam-ussh";
|
|
meta.maintainers = with lib.maintainers; [ lukegb ];
|
|
|
|
machine =
|
|
{ ... }:
|
|
{
|
|
users.users.alice = {
|
|
isNormalUser = true;
|
|
extraGroups = [ "wheel" ];
|
|
};
|
|
users.users.bob = {
|
|
isNormalUser = true;
|
|
extraGroups = [ "wheel" ];
|
|
};
|
|
|
|
security.pam.ussh = {
|
|
enable = true;
|
|
authorizedPrincipals = "root";
|
|
caFile = "${testOnlySSHCredentials}/ca.pub";
|
|
};
|
|
|
|
security.sudo = {
|
|
enable = true;
|
|
extraConfig = ''
|
|
Defaults lecture="never"
|
|
'';
|
|
};
|
|
};
|
|
|
|
testScript = ''
|
|
with subtest("alice should be allowed to escalate to root"):
|
|
machine.succeed(
|
|
'su -c "${makeTestScript "alice"}" -l alice | grep root'
|
|
)
|
|
|
|
with subtest("bob should not be allowed to escalate to root"):
|
|
machine.fail(
|
|
'su -c "${makeTestScript "bob"}" -l bob | grep root'
|
|
)
|
|
'';
|
|
}
|
|
)
|