1
0
mirror of https://github.com/altlinux/gpupdate.git synced 2025-03-20 18:50:17 +03:00

Fix polkit rule and replace it's template to datadir

This commit is contained in:
Evgeny Sinelnikov 2019-11-28 22:06:32 +04:00
parent def7b1ae79
commit eb7832507b
3 changed files with 10 additions and 19 deletions

View File

@ -6,7 +6,7 @@ import logging
logging.basicConfig(level=logging.DEBUG)
class polkit:
__template_path = '/usr/lib/python3/site-packages/gpoa/templates'
__template_path = '/usr/share/gpupdate/templates'
__policy_dir = '/etc/polkit-1/rules.d'
__template_loader = jinja2.FileSystemLoader(searchpath=__template_path)
__template_environment = jinja2.Environment(loader=__template_loader)

View File

@ -1,23 +1,9 @@
{% if Deny_All == 1 %}
polkit.addAdminRule(function (action, subject) {
if (action.id == "org.freedesktop.udisks2.filesystem-mount-other-seat") {
return polkit.Result.NO;
}
return ["unix-group:wheel"];
});
{% else %}
polkit.addAdminRule(function (action, subject) {
return ["unix-group:wheel"];
});
polkit.addRule(function (action, subject) {
if (action.id == "org.freedesktop.udisks2.filesystem-mount-other-seat" && subject.isInGroup("users")) {
polkit.log("Mount action from user: " + subject.user + ", pid: " + subject.id + ": allowed");
return polkit.Result.YES;
if (action.id == "org.freedesktop.udisks2.filesystem-mount" ||
action.id == "org.freedesktop.udisks2.filesystem-mount-system" ||
action.id == "org.freedesktop.udisks2.filesystem-mount-other-seat") {
return polkit.Result.NO;
}
polkit.log("Mount action from user: " + subject.user + ", pid: " + subject.id + ": denied");
return polkit.Result.NO;
});
{% endif %}

View File

@ -37,6 +37,10 @@ mkdir -p \
ln -s %python3_sitelibdir/gpoa/main.py \
%buildroot%_sbindir/gpoa
mkdir -p %buildroot%_datadir/%name
mv %buildroot%python3_sitelibdir/gpoa/templates \
%buildroot%_datadir/%name/
install -Dm0644 %name.service %buildroot%_unitdir/%name.service
%preun
@ -50,6 +54,7 @@ install -Dm0644 %name.service %buildroot%_unitdir/%name.service
%_bindir/gpupdate
%attr(755,root,root) %python3_sitelibdir/gpoa/main.py
%python3_sitelibdir/gpoa
%_datadir/%name
%_unitdir/%name.service
%changelog