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