Browse Source

Fix #45: Add --with-udev[=PATH] to configure, disables classic SUID root

This patch adds support for installing the 90-backlight.rules to gain
privileges to the kernel sysfs files.  By default the classic SUID root
mode is used and the rules file is not installed.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Joachim Nilsson 6 years ago
parent
commit
bd21ac4ded
4 changed files with 36 additions and 5 deletions
  1. 5
    0
      Makefile.am
  2. 8
    5
      README.md
  3. 21
    0
      configure.ac
  4. 2
    0
      src/Makefile.am

+ 5
- 0
Makefile.am View File

@@ -3,6 +3,11 @@ dist_man1_MANS = light.1
3 3
 doc_DATA       = README.md LICENSE CHANGELOG
4 4
 EXTRA_DIST     = README.md LICENSE CHANGELOG
5 5
 
6
+if UDEV
7
+udev_DATA      = 90-backlight.rules
8
+EXTRA_DIST    += $(top_srcdir)/90-backlight.rules
9
+endif
10
+
6 11
 #
7 12
 # Target to run when building a release
8 13
 #

+ 8
- 5
README.md View File

@@ -175,13 +175,16 @@ because they are generated at release time with `make release`.
175 175
 
176 176
 ### Permissions
177 177
 
178
-**Optional:** Instead of SUID root you can set up udev rules to manage
179
-   sysfs permissions, you may skip the `make install` step and instead
180
-   copy the file `90-backlight.rules` to `/etc/udev/rules.d/`:
178
+Optionally, instead of the classic SUID root mode of operation, udev
179
+rules can be set up to manage the kernel sysfs permissions.  Use the
180
+configure script to enable this mode of operation:
181 181
 
182
+    ./configure --with-udev && make
183
+    sudo make install
184
+
185
+This installs the file `90-backlight.rules` into `/lib/udev/rules.d/`.
186
+If your udev rules are located elsewhere, use `--with-udev=PATH`.
182 187
 
183
-    ACTION=="add", SUBSYSTEM=="backlight", RUN+="/bin/chgrp video /sys/class/backlight/%k/brightness"
184
-    ACTION=="add", SUBSYSTEM=="backlight", RUN+="/bin/chmod g+w /sys/class/backlight/%k/brightness"
185 188
 
186 189
 
187 190
 Origin & References

+ 21
- 0
configure.ac View File

@@ -10,4 +10,25 @@ AC_PROG_CC
10 10
 AC_PROG_INSTALL
11 11
 AC_HEADER_STDC
12 12
 
13
+AC_ARG_WITH([udev],
14
+	AS_HELP_STRING([--with-udev@<:@=PATH@:>@], [use udev instead of SUID root, optional rules.d path]),
15
+	[udev=$withval], [udev=no])
16
+
17
+AC_MSG_CHECKING(for udev rules.d)
18
+AS_IF([test "x$udev" != "xno"], [
19
+	AS_IF([test "x$udev" = "xyes"], [
20
+		udevdir="\${prefix}/lib/udev/rules.d"
21
+	],[
22
+		udevdir="$udev"
23
+	])
24
+	AC_SUBST(udevdir)
25
+	AC_MSG_RESULT([$udevdir])
26
+],[
27
+	AC_MSG_RESULT([disabled, classic SUID root mode])
28
+])
29
+
30
+# Allow classic SUID root behavior if udev rule is not used
31
+AM_CONDITIONAL(UDEV,    [test "x$udev" != "xno"])
32
+AM_CONDITIONAL(CLASSIC, [test "x$udev"  = "xno"])
33
+
13 34
 AC_OUTPUT

+ 2
- 0
src/Makefile.am View File

@@ -3,5 +3,7 @@ light_SOURCES  = main.c light.c light.h helpers.c helpers.h
3 3
 light_CPPFLAGS = -I../include -D_XOPEN_SOURCE=500
4 4
 light_CFLAGS   = -W -Wall -Wextra -std=gnu99 -Wno-type-limits
5 5
 
6
+if CLASSIC
6 7
 install-exec-hook:
7 8
 	chmod 4755 $(DESTDIR)$(bindir)/light
9
+endif