diff --git a/Makefile b/Makefile index 7772420..307c4ee 100644 --- a/Makefile +++ b/Makefile @@ -36,6 +36,8 @@ install: $(PROGRAMS) cd configs && find . -type f -exec install -D -m 0644 "{}" "$(DESTDIR)$(PREFIX)/share/sxmo/{}" \; && cd .. # Configs + install -D -m 0755 -t $(DESTDIR)/etc/init.d configs/openrc/sxmo-pinephone + install -D -m 0644 -t $(DESTDIR)/etc/alsa/conf.d/ configs/alsa/alsa_sxmo_enable_dmix.conf install -D -m 0644 -t $(DESTDIR)/etc/polkit-1/rules.d/ configs/polkit/*.rules @@ -51,11 +53,12 @@ install: $(PROGRAMS) # Bin install -D -t $(DESTDIR)$(PREFIX)/bin scripts/*/* - install -D -o root -m 4755 programs/sxmo_setpineled $(DESTDIR)$(PREFIX)/bin/ + install -D -m 0755 programs/sxmo_setpineled $(DESTDIR)$(PREFIX)/bin/ - install -D -o root -m 4755 programs/sxmo_setpinebacklight $(DESTDIR)$(PREFIX)/bin/ + install -D -m 0755 programs/sxmo_setpinebacklight $(DESTDIR)$(PREFIX)/bin/ - install -D -o root -m 4755 programs/sxmo_screenlock $(DESTDIR)$(PREFIX)/bin/ + install -D -m 0755 programs/sxmo_screenlock $(DESTDIR)$(PREFIX)/bin/ install -D programs/sxmo_megiaudioroute $(DESTDIR)$(PREFIX)/bin/ install -D programs/sxmo_vibratepine $(DESTDIR)$(PREFIX)/bin/ + diff --git a/configs/openrc/sxmo-pinephone b/configs/openrc/sxmo-pinephone new file mode 100644 index 0000000..b6b93e6 --- /dev/null +++ b/configs/openrc/sxmo-pinephone @@ -0,0 +1,6 @@ +#!/sbin/openrc-run + +description="Enable user access to pinephone hardware kernel interface" + +command="chmod" +command_args="a+rw /sys/module/8723cs/parameters/rtw_scan_interval_thr /sys/devices/platform/backlight/backlight/backlight/brightness /sys/power/state /sys/devices/platform/soc/1f00000.rtc/power/wakeup /sys/power/mem_sleep /sys/bus/usb/drivers/usb/unbind /sys/bus/usb/drivers/usb/bind /sys/class/leds/red:indicator/brightness /sys/class/leds/blue:indicator/brightness /sys/class/leds/green:indicator/brightness /sys/class/leds/white:flash/brightness /dev/rtc0" diff --git a/programs/sxmo_screenlock.c b/programs/sxmo_screenlock.c index af465ab..a087763 100644 --- a/programs/sxmo_screenlock.c +++ b/programs/sxmo_screenlock.c @@ -431,7 +431,7 @@ writefile(char *filepath, char *str) } void usage() { - fprintf(stderr, "Usage: sxmo_screenlock [--screen-off] [--suspend] [--wake-interval n]\n"); + fprintf(stderr, "Usage: sxmo_screenlock [--screen-off] [--suspend] [--wake-interval n] [--setuid]\n"); } @@ -474,14 +474,15 @@ main(int argc, char **argv) { target = StateSuspend; } else if(!strcmp(argv[i], "--wake-interval")) { wakeinterval = (time_t) atoi(argv[++i]); + } else if(!strcmp(argv[i], "--setuid")) { + if (setuid(0)) + die("setuid(0) failed\n"); } else { fprintf(stderr, "Invalid argument: %s\n", argv[i]); return 2; } } - if (setuid(0)) - die("setuid(0) failed\n"); if (!(dpy = XOpenDisplay(NULL))) die("Cannot open display\n"); diff --git a/programs/sxmo_setpinebacklight.c b/programs/sxmo_setpinebacklight.c index 0352c82..ea5a7a9 100644 --- a/programs/sxmo_setpinebacklight.c +++ b/programs/sxmo_setpinebacklight.c @@ -28,11 +28,6 @@ int main(int argc, char *argv[]) { argc--; brightness = atoi(argv[argc--]); - if (setuid(0)) { - fprintf(stderr, "setuid(0) failed\n"); - return 1; - } - if (access(pbpScreen, F_OK) != -1) { writeFile(pbpScreen, brightness); fprintf(stderr, "Set PBP brightness to %d\n", brightness); diff --git a/programs/sxmo_setpineled.c b/programs/sxmo_setpineled.c index 97a05a9..b86bd54 100644 --- a/programs/sxmo_setpineled.c +++ b/programs/sxmo_setpineled.c @@ -48,9 +48,5 @@ int main(int argc, char *argv[]) { "sh -c 'echo %d > /sys/class/leds/%s:%s/brightness'", brightness, color, type ); - if (setuid(0)) { - fprintf(stderr, "setuid(0) failed\n"); - } else { - return system(command); - } + return system(command); }