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";
|
|
|
|
helper = "polkit-agent-helper-1";
|
|
|
|
buildInputs = [ pkgs.xorg.lndir ];
|
|
|
|
|
|
|
|
builder = pkgs.writeScript "pkwrap-builder" ''
|
|
|
|
source $stdenv/setup
|
|
|
|
|
|
|
|
mkdir -p $out
|
|
|
|
lndir ${pkgs.polkit} $out
|
|
|
|
new=$out/libexec/$helper
|
|
|
|
|
|
|
|
mv $new $out/libexec/.$helper.orig
|
|
|
|
echo "exec ${config.security.wrapperDir}/$helper \"\$@\"" > $new
|
|
|
|
chmod +x $new
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
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" ];
|
|
|
|
etc = [
|
|
|
|
{
|
|
|
|
source = "${config.system.path}/etc/polkit-1";
|
|
|
|
target = "polkit-1";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
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-05-14 21:28:04 +01:00
|
|
|
setuidOwners = [
|
|
|
|
{
|
|
|
|
program = pkWrapper.helper;
|
|
|
|
owner = "root";
|
|
|
|
group = "root";
|
|
|
|
setuid = true;
|
|
|
|
source = pkWrapper + "/libexec/." + pkWrapper.helper + ".orig";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
2009-08-16 22:48:46 +01:00
|
|
|
|
|
|
|
system.activationScripts.policyKit = pkgs.stringsWithDeps.noDepEntry
|
|
|
|
''
|
|
|
|
mkdir -p /var/lib/polkit-1
|
2010-05-14 21:28:04 +01:00
|
|
|
chmod 700 /var/lib/polkit-1
|
2009-08-16 22:48:46 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2009-08-17 02:16:38 +01:00
|
|
|
}
|