Skip to content

Commit

Permalink
nixos/geoip-updater: run as user 'geoip' instead of 'nobody'
Browse files Browse the repository at this point in the history
That way 'nobody' is prevented from messing with the databases.
  • Loading branch information
bjornfor committed Feb 15, 2017
1 parent 900fc49 commit d4e5bb3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 2 additions & 0 deletions nixos/modules/misc/ids.nix
Expand Up @@ -287,6 +287,7 @@
pdns-recursor = 269;
kresd = 270;
rpc = 271;
geoip = 272;

# When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399!

Expand Down Expand Up @@ -543,6 +544,7 @@
gogs = 268;
kresd = 270;
#rpc = 271; # unused
#geoip = 272; # unused

# When adding a gid, make sure it doesn't match an existing
# uid. Users and groups with the same name should have equal
Expand Down
14 changes: 10 additions & 4 deletions nixos/modules/services/misc/geoip-updater.nix
Expand Up @@ -251,6 +251,12 @@ in
}
];

users.extraUsers.geoip = {
group = "root";
description = "GeoIP database updater";
uid = config.ids.uids.geoip;
};

systemd.timers.geoip-updater =
{ description = "GeoIP Updater Timer";
partOf = [ "geoip-updater.service" ];
Expand All @@ -267,11 +273,11 @@ in
preStart = ''
mkdir -p "${cfg.databaseDir}"
chmod 755 "${cfg.databaseDir}"
chown nobody:root "${cfg.databaseDir}"
chown geoip:root "${cfg.databaseDir}"
'';
serviceConfig = {
ExecStart = "${geoip-updater}/bin/geoip-updater";
User = "nobody";
User = "geoip";
PermissionsStartOnly = true;
};
};
Expand All @@ -285,11 +291,11 @@ in
preStart = ''
mkdir -p "${cfg.databaseDir}"
chmod 755 "${cfg.databaseDir}"
chown nobody:root "${cfg.databaseDir}"
chown geoip:root "${cfg.databaseDir}"
'';
serviceConfig = {
ExecStart = "${geoip-updater}/bin/geoip-updater --skip-existing";
User = "nobody";
User = "geoip";
PermissionsStartOnly = true;
# So it won't be (needlessly) restarted:
RemainAfterExit = true;
Expand Down

0 comments on commit d4e5bb3

Please sign in to comment.