Skip to content

Commit

Permalink
Allow users in group "keys" to access /run/keys.
Browse files Browse the repository at this point in the history
This makes it at least possible to access the keys directory if a
particular service is in the keys group, which has been introduced by
NixOS/nixpkgs@4ab5646.

However, to let specific users access a particular key, you still need
to work around it by adding an additional systemd service that sets the
right permissions. But at least with this we should have some
consistency with what is actually done in <nixpkgs>.

Signed-off-by: aszlig <[email protected]>
  • Loading branch information
aszlig committed Jun 24, 2014
1 parent 58cdd27 commit 51cafce
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions nix/keys.nix
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ with pkgs.lib;
Thus, <literal>{ password = "foobar"; }</literal> causes a
file <filename>/run/keys/password</filename> to be created
with contents <literal>foobar</literal>. The directory
<filename>/run/keys</filename> is only accessible to root.
<filename>/run/keys</filename> is only accessible to root and
the <literal>keys</literal> group.
'';
};

Expand All @@ -47,7 +48,8 @@ with pkgs.lib;

system.activationScripts.nixops-keys =
''
mkdir -p /run/keys -m 0700
mkdir -p /run/keys -m 0750
chown root:keys /run/keys
${optionalString config.deployment.storeKeysOnMachine
(concatStrings (mapAttrsToList (name: value:
Expand Down
3 changes: 2 additions & 1 deletion nixops/backends/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ def reboot_rescue(self, hard=False):

def send_keys(self):
if self.store_keys_on_machine: return
self.run_command("mkdir -m 0700 -p /run/keys")
self.run_command("mkdir -m 0750 -p /run/keys"
" && chown root:keys /run/keys")
for k, v in self.get_keys().items():
self.log("uploading key ‘{0}’...".format(k))
tmp = self.depl.tempdir + "/key-" + self.name
Expand Down

0 comments on commit 51cafce

Please sign in to comment.