Skip to content

Commit

Permalink
Use setuid root instead of adding a sudoers exception
Browse files Browse the repository at this point in the history
* Thanks to reddit.com/u/Foxboron for pointing out using `install -D` over
  `mkdir` explicitly.
  • Loading branch information
Hendrikto committed Jan 2, 2018
1 parent bfc1adc commit 7ab620e
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ CFLAGS += -Wall -Wextra -O3 -march=native
prefix = /usr/local
backlight_dir = /sys/class/backlight/intel_backlight/
max_brightness = $(shell cat $(backlight_dir)max_brightness)
backlight_rule = ALL ALL=NOPASSWD: $(prefix)/bin/backlight_control

DEFINES += -D BACKLIGHT_DIR=\"$(backlight_dir)\"
DEFINES += -D MAX_BRIGHTNESS=$(max_brightness)
Expand All @@ -18,9 +17,7 @@ clean:
rm -f backlight_control

install: backlight_control
mv $< $(DESTDIR)$(prefix)/bin
tee $(DESTDIR)/etc/sudoers.d/backlight_control <<< "$(backlight_rule)"
install -D -m 4755 -o root -g root $< $(DESTDIR)$(prefix)/bin/$<

uninstall:
rm -f $(DESTDIR)$(prefix)/bin/backlight_control
rm -f $(DESTDIR)/etc/sudoers.d/backlight_control

0 comments on commit 7ab620e

Please sign in to comment.