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

sshd fails to start on 16.09: /var/emtpy must be owned by root and not group or world-writable #18358

Closed
domenkozar opened this issue Sep 6, 2016 · 17 comments
Labels
1.severity: blocker This is preventing another PR or issue from being completed
Milestone

Comments

@domenkozar
Copy link
Member

domenkozar commented Sep 6, 2016

Possible cause 4f8f1c3 /cc @rickynils

@domenkozar domenkozar added the 1.severity: blocker This is preventing another PR or issue from being completed label Sep 6, 2016
@domenkozar domenkozar added this to the 16.09 milestone Sep 6, 2016
@domenkozar
Copy link
Member Author

Following didn't help:

  • chmod 400 /var/emtpy

Following did help:

  • rm -f /var/empty & mkdir /var/empty

@domenkozar
Copy link
Member Author

Deploying fresh 16.03 and 16.09 on top with sshd running doesn't yield this problem.

Maybe something created files in /var/emtpy?

@domenkozar
Copy link
Member Author

Aha, here's what I have on my system:

$ ls /var/empty/ -la
total 4
dr-xr-xr-x 1 root root    8 Oct 31  2015 .
drwxr-xr-x 1 root root  136 Sep  4 18:58 ..
-rw------- 1 root root 1024 Oct 31  2015 .rnd

@domenkozar
Copy link
Member Author

domenkozar commented Sep 6, 2016

http://manpages.ubuntu.com/manpages/precise/en/man1/rand.1ssl.html:

 The rand command outputs num pseudo-random bytes after seeding the
       random number generator once.  As in other openssl command line tools,
       PRNG seeding uses the file $HOME/.rnd or .rnd in addition to the files
       given in the -rand option.  A new $HOME/.rnd or .rnd file will be
       written back if enough seeding was obtained from these sources.

Maybe some service has HOME=/var/empty set when it runs rand?

@edolstra
Copy link
Member

edolstra commented Sep 6, 2016

We could make /var/empty immutable to prevent this kind of problem.

@grahamc
Copy link
Member

grahamc commented Sep 6, 2016

Making it immutable seems like a good long-term permanent solution.

@domenkozar
Copy link
Member Author

Not sure it was /var/empty/.rnd fault, I've tested on my machine and sshd starts regardless if I have /var/empty/a file.

@obadz
Copy link
Contributor

obadz commented Sep 6, 2016

Can't repro with

nix-build -E 'with import <nixpkgs/nixos> {
    configuration = {
      services.openssh.enable = true;
      users.extraUsers.root.initialHashedPassword = "";
      virtualisation.graphics = false;
    }
  }; vm' &&
./result/bin/run-nixos-vm

sshd starts fine in there. Am on 7c377f8.

@obadz
Copy link
Contributor

obadz commented Sep 6, 2016

Also starting the VM on release-16.03 on a clean filesystem, and then starting it again on 7c377f8 on the same filesystem doesn't seem to be a problem either.

@domenkozar
Copy link
Member Author

I assume some service changed /var/empty, since it's the default directory for users.

This machine has been upgraded for a few NixOS stable releases, so it must be that it was writable at one time or changed by root.

@domenkozar
Copy link
Member Author

I think making /var/empty immutable sounds correct, since this will pop up again.

@domenkozar
Copy link
Member Author

Hmm, could this be a duplicate of #14910 ?

@obadz
Copy link
Contributor

obadz commented Sep 6, 2016

Only if createHome = true I guess?

@domenkozar
Copy link
Member Author

Writting an assertion now to get cases when createHome = true and home = /var/empty.

@domenkozar
Copy link
Member Author

Nothing sets that as of today, but let's make /var/empty immutable so this won't be able to happen in future.

@domenkozar
Copy link
Member Author

#18365

domenkozar added a commit that referenced this issue Sep 6, 2016
Fixes #14910 and #18358

Deployed to an existing server, restarted sshd and polkit to verify
they don't fail.
domenkozar added a commit that referenced this issue Sep 7, 2016
Fixes #14910 and #18358

Deployed to an existing server, restarted sshd and polkit to verify
they don't fail.'

(cherry picked from commit 8f95e6f)
Signed-off-by: Domen Kožar <domen@dev.si>
@kvz
Copy link
Contributor

kvz commented Sep 22, 2016

There may very well be a million things I'm doing wrong, but this is just a friendly hint to let you know I had this break on me in the Riak package. Riak wants a user which does not specify a homedir, so /var/empty is used from what I understand. Riak's Erlang backend sets a ~/.erlang.cookie file, which location is impossible to change (I googled hard).

Rolling back won't fix my issue, as the old version does not contain code to revert this (e.g. chattr -i /var/empty). So instead I now added some Bash to revert this on my servers until I can think of a better way to fix this.

As said, just to let you know. I'm a newcomer to this, and very thankful for NixOS' existence and the hard work you're putting in. I'm also not contesting this particular change, it seems sounds.

adrianpk added a commit to adrianpk/nixpkgs that referenced this issue May 31, 2024
Fixes NixOS#14910 and NixOS#18358

Deployed to an existing server, restarted sshd and polkit to verify
they don't fail.'

(cherry picked from commit 8f95e6f)
Signed-off-by: Domen Kožar <domen@dev.si>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.severity: blocker This is preventing another PR or issue from being completed
Projects
None yet
Development

No branches or pull requests

5 participants