Revert "printer: add pwm tool count to init"
This reverts commit 6aad7880180366d6a1b91ea0f48fed2aadeb2722.
This commit is contained in:
parent
6aad788018
commit
9889f551cc
@ -18,7 +18,6 @@ class Printer:
|
||||
self.tempdevcount = 0
|
||||
self.fancount = 0
|
||||
self.ledcount = 0
|
||||
self.pwm_tools_count = 0
|
||||
self.output_pin_count = 0
|
||||
self.store_timeout = None
|
||||
self.tempstore = {}
|
||||
|
@ -17,10 +17,7 @@ from sdbus_block.networkmanager import (
|
||||
enums,
|
||||
exceptions,
|
||||
)
|
||||
from sdbus import (
|
||||
sd_bus_open_system,
|
||||
set_default_bus,
|
||||
)
|
||||
from sdbus import sd_bus_open_system, set_default_bus
|
||||
from gi.repository import GLib
|
||||
from uuid import uuid4
|
||||
|
||||
@ -194,7 +191,7 @@ class SdbusNm:
|
||||
return sorted(networks, key=lambda i: i['signal_level'], reverse=True)
|
||||
return networks
|
||||
|
||||
def get_bssid_from_ssid(selsd_busf, ssid):
|
||||
def get_bssid_from_ssid(self, ssid):
|
||||
return next(net['BSSID'] for net in self.get_networks() if ssid == net['SSID'])
|
||||
|
||||
def get_connected_ap(self):
|
||||
@ -216,7 +213,6 @@ class SdbusNm:
|
||||
)
|
||||
|
||||
def add_network(self, ssid, psk):
|
||||
|
||||
security_type = self.get_security_type(ssid)
|
||||
if security_type is None:
|
||||
return {"error": "network_not_found", "message": _("Network not found")}
|
||||
@ -258,11 +254,6 @@ class SdbusNm:
|
||||
return {"error": "unknown_security_type", "message": _("Unknown security type")}
|
||||
|
||||
try:
|
||||
if not self.request_polkit_auth(
|
||||
'org.example.NetworkManager.AddNetwork'
|
||||
):
|
||||
return {"error": "insufficient_privileges", "message": _("Authorization failed")}
|
||||
|
||||
NetworkManagerSettings().add_connection(properties)
|
||||
return {"status": "success"}
|
||||
except exceptions.NmSettingsPermissionDeniedError:
|
||||
@ -275,9 +266,6 @@ class SdbusNm:
|
||||
logging.exception("Couldn't add network")
|
||||
return {"error": "unknown", "message": _("Couldn't add network") + f"\n{e}"}
|
||||
|
||||
def request_polkit_auth(self, action_id):
|
||||
return True
|
||||
|
||||
def disconnect_network(self):
|
||||
self.wlan_device.disconnect()
|
||||
|
||||
|
@ -174,9 +174,9 @@ create_policy()
|
||||
|
||||
echo_text "Installing KlipperScreen PolicyKit Rules"
|
||||
sudo groupadd -f klipperscreen
|
||||
sudo adduser "$USER" klipperscreen
|
||||
sudo adduser "$USER" netdev
|
||||
if [ ! -x "$(command -v pkaction)" ]; then
|
||||
echo_error "PolicyKit not installed"
|
||||
echo "PolicyKit not installed"
|
||||
return
|
||||
fi
|
||||
|
||||
@ -194,14 +194,20 @@ create_policy()
|
||||
elif [ -d $POLKIT_DIR ]; then
|
||||
RULE_FILE="${POLKIT_DIR}/KlipperScreen.rules"
|
||||
else
|
||||
echo_error "PolicyKit rules folder not detected"
|
||||
echo "PolicyKit rules folder not detected"
|
||||
exit 1
|
||||
fi
|
||||
echo_text "Installing PolicyKit Rules to ${RULE_FILE}..."
|
||||
sudo rm ${RULE_FILE}
|
||||
|
||||
KS_GID=$( getent group klipperscreen | awk -F: '{printf "%d", $3}' )
|
||||
sudo tee ${RULE_FILE} > /dev/null << EOF
|
||||
// subject.isInGroup("klipperscreen")
|
||||
// subject.user == "$USER")
|
||||
// Allow KlipperScreen to reboot, shutdown, etc
|
||||
polkit.addRule(function(action, subject) {
|
||||
if (action.id == "org.freedesktop.NetworkManager.settings.modify.system" &&
|
||||
subject.isInGroup("network")) {
|
||||
return polkit.Result.YES;
|
||||
}
|
||||
});
|
||||
polkit.addRule(function(action, subject) {
|
||||
if ((action.id == "org.freedesktop.login1.power-off" ||
|
||||
action.id == "org.freedesktop.login1.power-off-multiple-sessions" ||
|
||||
@ -211,6 +217,10 @@ polkit.addRule(function(action, subject) {
|
||||
action.id == "org.freedesktop.login1.halt-multiple-sessions" ||
|
||||
action.id.startsWith("org.freedesktop.NetworkManager.")) &&
|
||||
subject.user == "$USER") {
|
||||
// Only allow processes with the "klipperscreen" supplementary group
|
||||
// access
|
||||
var regex = "^Groups:.+?\\\s$KS_GID[\\\s\\\0]";
|
||||
var cmdpath = "/proc/" + subject.pid.toString() + "/status";
|
||||
try {
|
||||
polkit.spawn(["grep", "-Po", regex, cmdpath]);
|
||||
return polkit.Result.YES;
|
||||
|
Loading…
x
Reference in New Issue
Block a user