Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make /var/empty immutable (with chattr +i) #18365

Merged
merged 2 commits into from
Sep 7, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions nixos/modules/system/activation/activation-script.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ let
'';
});

path = map getBin
[ pkgs.coreutils pkgs.gnugrep pkgs.findutils
pkgs.glibc # needed for getent
pkgs.shadow
pkgs.nettools # needed for hostname
path = with pkgs; map getBin
[ coreutils
gnugrep
findutils
glibc # needed for getent
shadow
nettools # needed for hostname
e2fsprogs # needed for chattr
];

in
Expand Down Expand Up @@ -137,8 +140,13 @@ in

mkdir -m 1777 -p /var/tmp

# Make sure it's really empty
chattr -i /var/empty
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be ${e2fsprogs}/bin/chattr to prevent polluting the path with e2fsprogs.

rm -rf /var/empty
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This introduces a race during activation where /var/empty doesn't exist. So for example, if it gets interrupted at that point, you won't be able to log in via ssh anymore.


# Empty, read-only home directory of many system accounts.
mkdir -m 0555 -p /var/empty
chattr +i /var/empty
'';

system.activationScripts.usrbinenv = if config.environment.usrbinenv != null
Expand Down