2009-08-16 23:48:46 +02:00
|
|
|
{ config, pkgs, ... }:
|
|
|
|
|
|
|
|
with pkgs.lib;
|
|
|
|
|
2010-05-14 22:28:04 +02:00
|
|
|
let
|
|
|
|
pkWrapper = pkgs.stdenv.mkDerivation {
|
|
|
|
name = "polkit-wrapper";
|
2010-05-18 18:46:32 +02:00
|
|
|
helper = "libexec/polkit-1/polkit-agent-helper-1";
|
2010-05-14 22:28:04 +02:00
|
|
|
buildInputs = [ pkgs.xorg.lndir ];
|
|
|
|
|
|
|
|
builder = pkgs.writeScript "pkwrap-builder" ''
|
|
|
|
source $stdenv/setup
|
|
|
|
|
2010-05-18 18:46:32 +02:00
|
|
|
mkdir -pv $out
|
2010-05-14 22:28:04 +02:00
|
|
|
lndir ${pkgs.polkit} $out
|
|
|
|
|
2010-05-18 18:46:32 +02:00
|
|
|
rm $out/$helper
|
|
|
|
ln -sv ${config.security.wrapperDir}/polkit-agent-helper-1 $out/$helper
|
2010-05-14 22:28:04 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
in
|
|
|
|
|
2009-08-16 23:48:46 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
config = {
|
|
|
|
|
2010-05-14 22:28:04 +02:00
|
|
|
environment = {
|
|
|
|
systemPackages = [ pkWrapper ];
|
|
|
|
pathsToLink = [ "/share/polkit-1" "/etc/polkit-1" ];
|
2010-09-13 17:41:38 +02:00
|
|
|
etc = singleton
|
|
|
|
{ source = "${config.system.path}/etc/polkit-1";
|
2010-05-14 22:28:04 +02:00
|
|
|
target = "polkit-1";
|
2010-09-13 17:41:38 +02:00
|
|
|
};
|
2010-05-14 22:28:04 +02:00
|
|
|
};
|
2009-08-16 23:48:46 +02:00
|
|
|
|
2010-05-14 22:28:04 +02:00
|
|
|
services.dbus.packages = [ pkWrapper ];
|
2009-08-16 23:48:46 +02:00
|
|
|
|
2010-05-14 22:28:04 +02:00
|
|
|
security = {
|
|
|
|
pam.services = [ { name = "polkit-1"; } ];
|
|
|
|
setuidPrograms = [ "pkexec" ];
|
2009-08-16 23:48:46 +02:00
|
|
|
|
2010-09-13 17:41:38 +02:00
|
|
|
setuidOwners = singleton
|
|
|
|
{ program = "polkit-agent-helper-1";
|
2010-05-14 22:28:04 +02:00
|
|
|
owner = "root";
|
|
|
|
group = "root";
|
|
|
|
setuid = true;
|
2010-05-18 18:46:32 +02:00
|
|
|
source = pkgs.polkit + "/" + pkWrapper.helper;
|
2010-09-13 17:41:38 +02:00
|
|
|
};
|
2010-05-14 22:28:04 +02:00
|
|
|
};
|
2009-08-16 23:48:46 +02:00
|
|
|
|
2010-09-13 17:41:38 +02:00
|
|
|
system.activationScripts.polkit =
|
2009-08-16 23:48:46 +02:00
|
|
|
''
|
2010-05-18 18:46:32 +02:00
|
|
|
mkdir -p /var/lib/polkit-1/localauthority
|
|
|
|
chmod 700 /var/lib/polkit-1{/localauthority,}
|
2011-07-26 16:13:07 +02:00
|
|
|
|
|
|
|
# Force polkitd to be restarted so that it reloads its
|
|
|
|
# configuration.
|
|
|
|
pkill -INT -u root -x polkitd
|
2009-08-16 23:48:46 +02:00
|
|
|
'';
|
2011-07-26 16:13:07 +02:00
|
|
|
|
2009-08-16 23:48:46 +02:00
|
|
|
};
|
|
|
|
|
2009-08-17 03:16:38 +02:00
|
|
|
}
|