2009-01-02 16:07:10 +00:00
|
|
|
{pkgs, config, ...}:
|
2008-04-01 11:16:35 +01:00
|
|
|
|
2009-01-02 16:07:10 +00:00
|
|
|
###### interface
|
|
|
|
let
|
|
|
|
inherit (pkgs.lib) mkOption;
|
|
|
|
|
|
|
|
options = {
|
|
|
|
services = {
|
|
|
|
atd = {
|
|
|
|
|
|
|
|
enable = mkOption {
|
|
|
|
default = true;
|
|
|
|
description = ''
|
|
|
|
Whether to enable the `at' daemon, a command scheduler.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
allowEveryone = mkOption {
|
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
Whether to make /var/spool/at{jobs,spool} writeable
|
2009-01-02 19:41:39 +00:00
|
|
|
by everyone (and sticky). This is normally not needed since
|
|
|
|
the `at' commands are setuid/setgid `atd'.
|
2009-01-02 16:07:10 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
2008-04-01 11:16:35 +01:00
|
|
|
in
|
|
|
|
|
2009-01-02 16:07:10 +00:00
|
|
|
###### implementation
|
|
|
|
let
|
|
|
|
cfg = config.services.atd;
|
|
|
|
inherit (pkgs.lib) mkIf;
|
|
|
|
inherit (pkgs) at;
|
|
|
|
|
|
|
|
user = {
|
|
|
|
name = "atd";
|
|
|
|
uid = (import ../system/ids.nix).uids.atd;
|
|
|
|
description = "atd user";
|
|
|
|
home = "/var/empty";
|
|
|
|
};
|
|
|
|
|
|
|
|
group = {
|
|
|
|
name = "atd";
|
|
|
|
gid = (import ../system/ids.nix).gids.atd;
|
|
|
|
};
|
2008-04-01 11:16:35 +01:00
|
|
|
|
|
|
|
job = ''
|
|
|
|
description "at daemon (atd)"
|
|
|
|
|
|
|
|
start on startup
|
|
|
|
stop on shutdown
|
|
|
|
|
|
|
|
start script
|
|
|
|
# Snippets taken and adapted from the original `install' rule of
|
|
|
|
# the makefile.
|
|
|
|
|
|
|
|
# We assume these values are those actually used in Nixpkgs for
|
|
|
|
# `at'.
|
|
|
|
spooldir=/var/spool/atspool
|
|
|
|
jobdir=/var/spool/atjobs
|
|
|
|
etcdir=/etc/at
|
|
|
|
|
|
|
|
for dir in "$spooldir" "$jobdir" "$etcdir"
|
|
|
|
do
|
|
|
|
if [ ! -d "$dir" ]
|
|
|
|
then
|
|
|
|
mkdir "$dir" && chown atd:atd "$dir"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
chmod 1770 "$spooldir" "$jobdir"
|
2009-01-02 16:07:10 +00:00
|
|
|
${if cfg.allowEveryone then ''chmod a+rwxt "$spooldir" "$jobdir" '' else ""}
|
2008-04-01 11:16:35 +01:00
|
|
|
if [ ! -f "$etcdir"/at.deny ]
|
|
|
|
then
|
|
|
|
touch "$etcdir"/at.deny && \
|
2009-01-02 19:41:39 +00:00
|
|
|
chown root:atd "$etcdir"/at.deny && \
|
2008-04-01 11:16:35 +01:00
|
|
|
chmod 640 "$etcdir"/at.deny
|
|
|
|
fi
|
|
|
|
if [ ! -f "$jobdir"/.SEQ ]
|
|
|
|
then
|
|
|
|
touch "$jobdir"/.SEQ && \
|
|
|
|
chown atd:atd "$jobdir"/.SEQ && \
|
|
|
|
chmod 600 "$jobdir"/.SEQ
|
|
|
|
fi
|
|
|
|
end script
|
|
|
|
|
|
|
|
respawn ${at}/sbin/atd
|
|
|
|
'';
|
2009-01-02 16:07:10 +00:00
|
|
|
in
|
|
|
|
|
|
|
|
mkIf cfg.enable {
|
|
|
|
require = [
|
|
|
|
options
|
|
|
|
|
|
|
|
# config.services.extraJobs
|
|
|
|
(import ../upstart-jobs/default.nix)
|
|
|
|
|
|
|
|
# config.environment.etc
|
|
|
|
(import ../etc/default.nix)
|
|
|
|
|
|
|
|
# users.*
|
|
|
|
(import ../system/users-groups.nix)
|
|
|
|
|
|
|
|
# (import ?) # config.environment.extraPackages
|
|
|
|
# (import ?) # config.security.extraSetuidPrograms
|
|
|
|
];
|
|
|
|
|
|
|
|
security = {
|
2009-01-02 19:41:39 +00:00
|
|
|
setuidOwners = map (program: {
|
|
|
|
inherit program;
|
|
|
|
owner = "atd";
|
|
|
|
group = "atd";
|
|
|
|
setuid = true;
|
|
|
|
setgid = true;
|
|
|
|
}) [ "at" "atq" "atrm" ];
|
2009-01-02 16:07:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
environment = {
|
|
|
|
extraPackages = [ at ];
|
|
|
|
|
|
|
|
etc = [{
|
|
|
|
source = ../etc/pam.d/atd;
|
|
|
|
target = "pam.d/atd";
|
|
|
|
}];
|
|
|
|
};
|
|
|
|
|
|
|
|
users = {
|
|
|
|
extraUsers = [user];
|
|
|
|
extraGroups = [group];
|
|
|
|
};
|
|
|
|
|
|
|
|
services = {
|
|
|
|
extraJobs = [{
|
|
|
|
name = "atd";
|
|
|
|
inherit job;
|
|
|
|
}];
|
|
|
|
};
|
2008-04-01 11:16:35 +01:00
|
|
|
}
|