From a0fc21eda38427f300cabb834d3ec6259196c18d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Tue, 1 Apr 2008 10:16:35 +0000 Subject: [PATCH] Add `atd' Upstart job. svn path=/nixos/trunk/; revision=11435 --- etc/default.nix | 1 + etc/pam.d/atd | 4 +++ system/ids.nix | 3 ++ system/options.nix | 9 ++++++ system/system.nix | 4 ++- upstart-jobs/atd.nix | 64 ++++++++++++++++++++++++++++++++++++++++ upstart-jobs/default.nix | 6 ++++ 7 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 etc/pam.d/atd create mode 100644 upstart-jobs/atd.nix diff --git a/etc/default.nix b/etc/default.nix index e8b44f553b9..1e924e0f7f4 100644 --- a/etc/default.nix +++ b/etc/default.nix @@ -233,6 +233,7 @@ import ../helpers/make-etc.nix { } ) [ + "atd" "login" "slim" "su" diff --git a/etc/pam.d/atd b/etc/pam.d/atd new file mode 100644 index 00000000000..50f3cc5ce60 --- /dev/null +++ b/etc/pam.d/atd @@ -0,0 +1,4 @@ +auth include common +account include common +password include common +session include common diff --git a/system/ids.nix b/system/ids.nix index b0ce6e28591..6c6df24dd90 100644 --- a/system/ids.nix +++ b/system/ids.nix @@ -13,6 +13,7 @@ bitlbee = 9; avahi = 10; portmap = 11; + atd = 12; nixbld = 30000; # start of range of uids nobody = 65534; @@ -27,6 +28,8 @@ bitlbee = 9; avahi = 10; portmap = 11; + atd = 12; + audio = 17; users = 100; diff --git a/system/options.nix b/system/options.nix index f8d3e302e72..44b40dc5683 100644 --- a/system/options.nix +++ b/system/options.nix @@ -611,6 +611,15 @@ }; + atd = { + + enable = mkOption { + default = true; + description = '' + Whether to enable the `at' daemon, a command scheduler. + ''; + }; + }; locate = { diff --git a/system/system.nix b/system/system.nix index 9d733d804d0..03142fde25c 100644 --- a/system/system.nix +++ b/system/system.nix @@ -257,6 +257,7 @@ rec { pkgs.wirelesstools ] ++ pkgs.lib.optional config.security.sudo.enable pkgs.sudo + ++ pkgs.lib.optional config.services.atd.enable pkgs.at ++ pkgs.lib.optional config.services.bitlbee.enable pkgs.bitlbee ++ pkgs.lib.optional config.services.avahi.enable pkgs.avahi ++ pkgs.lib.optional config.networking.defaultMailServer.directDelivery pkgs.ssmtp @@ -304,7 +305,8 @@ rec { setuidPrograms = config.security.setuidPrograms ++ config.security.extraSetuidPrograms ++ - pkgs.lib.optional (config.security.sudo.enable) "sudo"; + pkgs.lib.optional (config.security.sudo.enable) "sudo" ++ + (if (config.services.atd.enable) then [ "at" "atq" "atrm" ] else []); inherit (usersGroups) createUsersGroups usersList groupsList; diff --git a/upstart-jobs/atd.nix b/upstart-jobs/atd.nix new file mode 100644 index 00000000000..260c3001c35 --- /dev/null +++ b/upstart-jobs/atd.nix @@ -0,0 +1,64 @@ +{ at }: + +let uid = (import ../system/ids.nix).uids.atd; + gid = (import ../system/ids.nix).gids.atd; +in +{ + name = "atd"; + + users = [ + { name = "atd"; + inherit uid; + description = "atd user"; + home = "/var/empty"; + } + ]; + + groups = [ + { name = "atd"; + inherit gid; + } + ]; + + 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" + if [ ! -f "$etcdir"/at.deny ] + then + touch "$etcdir"/at.deny && \ + chown root:root "$etcdir"/at.deny && \ + 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 +''; + +} diff --git a/upstart-jobs/default.nix b/upstart-jobs/default.nix index 23339a570ae..5ccb79f663a 100644 --- a/upstart-jobs/default.nix +++ b/upstart-jobs/default.nix @@ -167,6 +167,12 @@ let ]) + # At daemon. + ++ optional config.services.atd.enable + (import ../upstart-jobs/atd.nix { + at = pkgs.at; + }) + # DHCP client. ++ optional config.networking.useDHCP (import ../upstart-jobs/dhclient.nix {