From a73bd66ef3a94515a01a5921b5352366e20b4166 Mon Sep 17 00:00:00 2001 From: Jonatan Steuernagel Date: Tue, 18 Apr 2023 16:46:45 +0200 Subject: [PATCH 1/2] Change all write paths to /var/run/python-validity This is to ensure functionality of the python-validity on systems who restrict write access to the /usr directory, like Fedora Silverblue. --- bin/validity-sensors-firmware | 2 +- dbus_service/dbus-service | 2 +- validitysensor/sensor.py | 2 +- validitysensor/upload_fwext.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/validity-sensors-firmware b/bin/validity-sensors-firmware index e585f1c..9c9e7b9 100755 --- a/bin/validity-sensors-firmware +++ b/bin/validity-sensors-firmware @@ -32,7 +32,7 @@ from usb import core as usb_core from validitysensor.firmware_tables import FIRMWARE_NAMES, FIRMWARE_URIS from validitysensor.usb import SupportedDevices -python_validity_data = '/usr/share/python-validity/' +python_validity_data = '/var/run/python-validity/' def download_and_extract_fw(dev_type, fwdir, fwuri=None): diff --git a/dbus_service/dbus-service b/dbus_service/dbus-service index 31e10b7..8159a1a 100755 --- a/dbus_service/dbus-service +++ b/dbus_service/dbus-service @@ -191,7 +191,7 @@ class Device(dbus.service.Object): return hexlify(tls.app(unhexlify(cmd))).decode() -backoff_file = '/usr/share/python-validity/backoff' +backoff_file = '/var/run/python-validity/backoff' # I don't know how to tell systemd to backoff in case of multiple instance of the same template service, help! diff --git a/validitysensor/sensor.py b/validitysensor/sensor.py index a135641..31a31e9 100644 --- a/validitysensor/sensor.py +++ b/validitysensor/sensor.py @@ -20,7 +20,7 @@ from .usb import usb, CancelledException from .util import assert_status, unhex # TODO: this should be specific to an individual device (system may have more than one sensor) -calib_data_path = '/usr/share/python-validity/calib-data.bin' +calib_data_path = '/var/run/python-validity/calib-data.bin' line_update_type1_devices = [ 0xB5, 0x885, 0xB3, 0x143B, 0x1055, 0xE1, 0x8B1, 0xEA, 0xE4, 0xED, 0x1825, 0x1FF5, 0x199 diff --git a/validitysensor/upload_fwext.py b/validitysensor/upload_fwext.py index cfe3132..695bf0f 100644 --- a/validitysensor/upload_fwext.py +++ b/validitysensor/upload_fwext.py @@ -8,7 +8,7 @@ from .flash import write_flash_all, write_fw_signature, get_fw_info from .sensor import reboot, write_hw_reg32, read_hw_reg32, identify_sensor from .usb import usb, SupportedDevices -firmware_home = '/usr/share/python-validity' +firmware_home = '/var/run/python-validity' def default_fwext_name(): From 4846362e50a207d3a7a239afb36f7eb6171cb86b Mon Sep 17 00:00:00 2001 From: Jonatan Steuernagel Date: Tue, 18 Apr 2023 16:53:06 +0200 Subject: [PATCH 2/2] Create /var/run/python-validity in Debian postinstall --- debian/python3-validity.postinst | 1 + 1 file changed, 1 insertion(+) diff --git a/debian/python3-validity.postinst b/debian/python3-validity.postinst index ca62874..4a9f48a 100644 --- a/debian/python3-validity.postinst +++ b/debian/python3-validity.postinst @@ -4,6 +4,7 @@ set -e #DEBHELPER# if [ "$1" = "configure" ]; then + mkdir -p /var/run/python-validity || true validity-sensors-firmware || true systemctl daemon-reload || true udevadm control --reload-rules || true