git.iko.soy/typeable/nixpkgs
on master help sign in
namecoind nixos module: security enhancements
commit8db7c14e5632cb139ecdb0eeceaabddc9f00d7a8 authorThomas Strobel <ts468@cam.ac.uk> dateThu 10 Sep 2015, 18:04 (11 years ago) parent13e2d22
2 files changed+24−2
nixos/modules/misc/ids.nix+1−1 nixos/modules/services/networking/namecoind.nix+23−1
nixos/modules/misc/ids.nix+1−1
@@ -437,7 +437,7 @@
437437 riak = 205;
438438 #shout = 206; #unused
439439 gateone = 207;
440− #namecoin = 208; #unused
440+ namecoin = 208;
441441
442442 # When adding a gid, make sure it doesn't match an existing
443443 # uid. Users and groups with the same name should have equal
nixos/modules/services/networking/namecoind.nix+23−1
@@ -45,7 +45,8 @@ in
4545 type = types.path;
4646 example = "/etc/namecoin/wallet.dat";
4747 description = ''
48− Wallet file.
48+ Wallet file. The ownership of the file has to be
49+ namecoin:namecoin, and the permissions must be 0640.
4950 '';
5051 };
5152
@@ -61,6 +62,8 @@ in
6162 USER=namecoin
6263 PASSWORD=secret
6364 </literal>
65+ The ownership of the file has to be namecoin:namecoin,
66+ and the permissions must be 0640.
6467 '';
6568 };
6669
@@ -107,10 +110,29 @@ in
107110 createHome = true;
108111 };
109112
113+ users.extraGroups = singleton
114+ { name = "namecoin";
115+ gid = config.ids.gids.namecoin;
116+ };
117+
110118 systemd.services.namecoind = {
111119 description = "Namecoind Daemon";
112120 after = [ "network.target" ];
113121 wantedBy = [ "multi-user.target" ];
122+ preStart = ''
123+ if [ "$(stat --printf '%u' ${cfg.userFile})" != "${toString config.ids.uids.namecoin}" \
124+ -o "$(stat --printf '%g' ${cfg.userFile})" != "${toString config.ids.gids.namecoin}" \
125+ -o "$(stat --printf '%a' ${cfg.userFile})" != "640" ]; then
126+ echo "ERROR: bad ownership or rights on ${cfg.userFile}" >&2
127+ exit 1
128+ fi
129+ if [ "$(stat --printf '%u' ${cfg.wallet})" != "${toString config.ids.uids.namecoin}" \
130+ -o "$(stat --printf '%g' ${cfg.wallet})" != "${toString config.ids.gids.namecoin}" \
131+ -o "$(stat --printf '%a' ${cfg.wallet})" != "640" ]; then
132+ echo "ERROR: bad ownership or rights on ${cfg.wallet}" >&2
133+ exit 1
134+ fi
135+ '';
114136 serviceConfig = {
115137 Type = "simple";
116138 User = "namecoin";