mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-29 00:53:57 +00:00
4f0dadbf38
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
69 lines
2.3 KiB
Nix
69 lines
2.3 KiB
Nix
import ./make-test-python.nix (
|
|
{ lib, ... }:
|
|
{
|
|
name = "please";
|
|
meta.maintainers = with lib.maintainers; [ azahi ];
|
|
|
|
nodes.machine =
|
|
{ ... }:
|
|
{
|
|
users.users = lib.mkMerge [
|
|
(lib.listToAttrs (
|
|
map (n: lib.nameValuePair n { isNormalUser = true; }) (lib.genList (x: "user${toString x}") 6)
|
|
))
|
|
{
|
|
user0.extraGroups = [ "wheel" ];
|
|
}
|
|
];
|
|
|
|
security.please = {
|
|
enable = true;
|
|
wheelNeedsPassword = false;
|
|
settings = {
|
|
user2_run_true_as_root = {
|
|
name = "user2";
|
|
target = "root";
|
|
rule = "/run/current-system/sw/bin/true";
|
|
require_pass = false;
|
|
};
|
|
user4_edit_etc_hosts_as_root = {
|
|
name = "user4";
|
|
type = "edit";
|
|
target = "root";
|
|
rule = "/etc/hosts";
|
|
editmode = 644;
|
|
require_pass = false;
|
|
};
|
|
};
|
|
};
|
|
};
|
|
|
|
testScript = ''
|
|
with subtest("root: can run anything by default"):
|
|
machine.succeed('please true')
|
|
with subtest("root: can edit anything by default"):
|
|
machine.succeed('EDITOR=cat pleaseedit /etc/hosts')
|
|
|
|
with subtest("user0: can run as root because it's in the wheel group"):
|
|
machine.succeed('su - user0 -c "please -u root true"')
|
|
with subtest("user1: cannot run as root because it's not in the wheel group"):
|
|
machine.fail('su - user1 -c "please -u root true"')
|
|
|
|
with subtest("user0: can edit as root"):
|
|
machine.succeed('su - user0 -c "EDITOR=cat pleaseedit /etc/hosts"')
|
|
with subtest("user1: cannot edit as root"):
|
|
machine.fail('su - user1 -c "EDITOR=cat pleaseedit /etc/hosts"')
|
|
|
|
with subtest("user2: can run 'true' as root"):
|
|
machine.succeed('su - user2 -c "please -u root true"')
|
|
with subtest("user3: cannot run 'true' as root"):
|
|
machine.fail('su - user3 -c "please -u root true"')
|
|
|
|
with subtest("user4: can edit /etc/hosts"):
|
|
machine.succeed('su - user4 -c "EDITOR=cat pleaseedit /etc/hosts"')
|
|
with subtest("user5: cannot edit /etc/hosts"):
|
|
machine.fail('su - user5 -c "EDITOR=cat pleaseedit /etc/hosts"')
|
|
'';
|
|
}
|
|
)
|