fix: root actions in tui/gui & userControl
This commit is contained in:
32 files changed
+665
-317
No files matched your search
@@ -1,26 +1,35 @@
|
||||
# Polkit rules granting proxy-suite group members passwordless control over services.
|
||||
{
|
||||
lib,
|
||||
cfg,
|
||||
userControlCfg,
|
||||
}:
|
||||
# Polkit rule body granting userControl group members passwordless control over the
|
||||
# units of their scopes.
|
||||
{ userControlCfg }:
|
||||
|
||||
let
|
||||
userControlEnabled = userControlCfg.allow != [ ];
|
||||
|
||||
userControlPolkitRules =
|
||||
lib.optionalString (builtins.elem "perApp" userControlCfg.allow) ''
|
||||
if (unit.indexOf("proxy-suite-per-app-") === 0) {
|
||||
return polkit.Result.YES;
|
||||
}
|
||||
''
|
||||
+ lib.optionalString (builtins.elem "global" userControlCfg.allow) ''
|
||||
if (unit.indexOf("proxy-suite-") === 0 &&
|
||||
unit.indexOf("proxy-suite-per-app-") !== 0) {
|
||||
return polkit.Result.YES;
|
||||
}
|
||||
'';
|
||||
# Units a narrower scope starts; every other proxy-suite unit is "services".
|
||||
scopeByUnitPrefix = {
|
||||
"proxy-suite-per-app-" = "perApp";
|
||||
"proxy-suite-outbound-pin@" = "routing";
|
||||
"proxy-suite-outbound-unpin." = "routing";
|
||||
"proxy-suite-route-mode@" = "routing";
|
||||
"proxy-suite-outbound-reload." = "outbounds";
|
||||
"proxy-suite-subscription-update." = "outbounds";
|
||||
"proxy-suite-autoproxy-learn." = "autoProxy";
|
||||
"proxy-suite-zapret2-cutoff." = "zapret";
|
||||
"proxy-suite-inbound-stats." = "stats";
|
||||
};
|
||||
in
|
||||
{
|
||||
inherit userControlEnabled userControlPolkitRules;
|
||||
userControlPolkitRules = ''
|
||||
var scopeByUnitPrefix = ${builtins.toJSON scopeByUnitPrefix};
|
||||
var scope = unit.indexOf("proxy-suite-") === 0 ? "services" : null;
|
||||
for (var prefix in scopeByUnitPrefix) {
|
||||
if (unit.indexOf(prefix) === 0) {
|
||||
scope = scopeByUnitPrefix[prefix];
|
||||
break;
|
||||
}
|
||||
}
|
||||
// No scopes listed means all of them.
|
||||
var scopes = ${builtins.toJSON userControlCfg.scopes};
|
||||
if (scope !== null && (scopes.length === 0 || scopes.indexOf(scope) !== -1)) {
|
||||
return polkit.Result.YES;
|
||||
}
|
||||
'';
|
||||
}
|
||||
Reference in new issue
Block a user