Cleanup SXMO_SYS_FILES

Drop completly this way of giving access to system resources.
Rely on doas to privilage escalate. This ensure the user is in wheel
group.
This commit is contained in:
Willow Barraco
2023-09-09 15:46:53 +02:00
parent 7a77851c9a
commit c1b2803fcf
13 changed files with 8 additions and 43 deletions

View File

@@ -66,11 +66,6 @@ install-scripts: $(PROGRAMS)
cd resources && find . -type f -exec install -D -m 0644 "{}" "$(DESTDIR)$(PREFIX)/share/sxmo/{}" \; && cd ..
# Configs
if [ "$(OPENRC)" = "1" ]; then \
install -D -m 0755 -t $(DESTDIR)$(SYSCONFDIR)/init.d configs/openrc/sxmo-setpermissions; \
fi
install -D -m 0644 -t $(DESTDIR)$(PREFIX)/lib/udev/rules.d/ configs/udev/*.rules
install -D -m 0644 -t $(DESTDIR)$(PREFIX)/share/applications/ configs/xdg/mimeapps.list

View File

@@ -69,7 +69,8 @@ esac
sxmo_state_switch.sh set unlock
# Turn on auto-suspend
if [ -w "/sys/power/wakeup_count" ] && [ -f "/sys/power/wake_lock" ]; then
if [ -f "/sys/power/wakeup_count" ]; then
sxmo_wakelock.sh lock sxmo_not_screenoff infinite
superctl start sxmo_autosuspend
fi

View File

@@ -16,5 +16,7 @@ permit nopass :wheel as root cmd systemctl args start eg25-manager
permit nopass :wheel as root cmd systemctl args stop eg25-manager
permit nopass :wheel as root cmd systemctl args start ModemManager
permit nopass :wheel as root cmd systemctl args stop ModemManager
permit nopass :wheel as root cmd rtcwake
permit nopass :wheel as root cmd tee args -a /sys/power/wake_lock
permit nopass :wheel as root cmd tee args -a /sys/power/wake_unlock
permit nopass :wheel as root cmd tee args /sys/power/wakeup_count

View File

@@ -1,5 +0,0 @@
#!/sbin/openrc-run
description="Set user permissions to aspects of the hardware kernel interface"
command="/usr/bin/sxmo_setpermissions.sh"

View File

@@ -31,7 +31,9 @@ while true; do
# If the wakeup count has changed since we read it, this will fail so we
# know to try again. If something takes a wake_lock after we do this, it
# will cause the kernel to abort suspend.
echo "$wakeup_count" > /sys/power/wakeup_count || continue
if ! echo "$wakeup_count" | doas tee /sys/power/wakeup_count > /dev/null; then
continue
fi
# If sxmo_suspend failed then we didn't enter suspend, it should be safe
# to retry immediately. There's a delay so we don't eat up all the

View File

@@ -1,23 +0,0 @@
#!/bin/sh
# SPDX-License-Identifier: AGPL-3.0-only
# Copyright 2022 Sxmo Contributors
# This script is executed as root
# from the init process and sets
# some device-specific permissions
if [ -e /proc/device-tree/compatible ]; then
device="$(tr -c '\0[:alnum:].,-' '_' < /proc/device-tree/compatible |
tr '\0' '\n' | head -n1)"
deviceprofile="$(command -v "sxmo_deviceprofile_$device.sh")"
# shellcheck disable=SC1090
[ -f "$deviceprofile" ] && . "$deviceprofile"
fi
# the defaults are best guesses
# users can override this in sxmo_deviceprofile_mydevice.sh
files="${SXMO_SYS_FILES:-"/sys/power/state /sys/power/mem_sleep /dev/rtc0"}"
for file in $files /sys/power/wakeup_count; do
[ -e "$file" ] && chmod a+rw "$file"
done

View File

@@ -24,7 +24,7 @@ fi
sxmo_log "calling suspend with suspend_time <$suspend_time>"
start="$(date "+%s")"
rtcwake -m mem -s "$suspend_time" || exit 1
doas rtcwake -m mem -s "$suspend_time" || exit 1
#We woke up again
time_spent="$(( $(date "+%s") - start ))"

View File

@@ -74,7 +74,5 @@ SXMO_DISABLE_KEYBINDS | Disable most custom Sxmo binds on volume keys if set.
SXMO_MONITOR | Display "Output" from `swaymsg -t get_outputs`. Should be the same as the output from the `xrandr` command when running dwm.
### General / Misc.
SXMO_SYS_FILES | String of files for sxmo_setpermissions.sh to make +rw (see sxmo_setpermissions.sh)
SXMO_VIBRATE_DEV | Path to vibration device (see sxmo_vibrate.c and clickclack.c) [default: /dev/input/by-path/platform-vibrator-event]
SXMO_VIBRATE_STRENGTH | Strength parameter to pass to sxmo_vibrate [default: 1]

View File

@@ -8,5 +8,4 @@ export SXMO_POWER_BUTTON="0:0:pm8941_pwrkey"
export SXMO_VOLUME_BUTTON="1:1:GPIO_Buttons 0:0:pm8941_resin"
export SXMO_ROTATION_GRAVITY="500"
export SXMO_ROTATION_THRESHOLD="60"
export SXMO_SYS_FILES="/sys/power/state /sys/power/mem_sleep /dev/rtc0"
export SXMO_SWAY_SCALE="2"

View File

@@ -12,7 +12,6 @@ export SXMO_TOUCHSCREEN_ID="10"
export SXMO_STYLUS_ID="12"
export SXMO_DISABLE_LEDS="1"
export SXMO_MIN_BRIGHTNESS="0" # we can set brightness all the way down
export SXMO_SYS_FILES="/sys/power/state /sys/power/mem_sleep /dev/rtc0"
export SXMO_BMENU_LANDSCAPE_LINES="15"
export SXMO_MONITOR="Unknown-1"
export SXMO_POWER_BUTTON="0:0:rk805_pwrkey"

View File

@@ -2,7 +2,6 @@
# SPDX-License-Identifier: AGPL-3.0-only
# Copyright 2022 Sxmo Contributors
export SXMO_SYS_FILES="/sys/power/state /sys/devices/platform/soc/1f00000.rtc/power/wakeup /sys/power/mem_sleep /dev/rtc0 /sys/devices/platform/soc/1f03400.rsb/sunxi-rsb-3a3/axp221-pek/power/wakeup"
export SXMO_TOUCHSCREEN_ID=8
export SXMO_MONITOR="DSI-1"
export SXMO_SWAY_SCALE="2"

View File

@@ -2,7 +2,6 @@
# SPDX-License-Identifier: AGPL-3.0-only
# Copyright 2022 Sxmo Contributors
export SXMO_SYS_FILES="/sys/power/state /sys/power/mem_sleep /dev/rtc0"
export SXMO_TOUCHSCREEN_ID=7
export SXMO_MONITOR="DSI-1"
export SXMO_POWER_BUTTON="1:1:gpio-keys"

View File

@@ -5,7 +5,6 @@
export SXMO_SPEAKER="Speaker"
export SXMO_HEADPHONE="Headphone"
export SXMO_EARPIECE="Earpiece"
export SXMO_SYS_FILES="/sys/power/state /sys/power/mem_sleep /dev/rtc0"
export SXMO_POWER_BUTTON="0:0:30370000.snvs:snvs-powerkey"
export SXMO_VOLUME_BUTTON="1:1:gpio-keys"
export SXMO_SWAY_SCALE="2"