File no-suid.patch of Package wiringpi
Author: Dave Jones <dave.jones@canonical.com>
Description: Removed check for root on execution of gpio.
The wiringPi library already has the ability to use the unprivileged
/dev/gpiomem device if it can't open /dev/mem so there's no need to require
root access for the gpio command, and hence no need to set the gpio command
to have suid root privileges.
Index: b/gpio/gpio.c
===================================================================
--- a/gpio/gpio.c 2020-08-27 10:38:41.019466888 +0200
+++ b/gpio/gpio.c 2020-08-27 10:40:02.110609029 +0200
@@ -1371,12 +1371,6 @@ int main (int argc, char *argv [])
exit (EXIT_SUCCESS) ;
}
- if (geteuid () != 0)
- {
- fprintf (stderr, "%s: Must be root to run. Program should be suid root. This is an error.\n", argv [0]) ;
- exit (EXIT_FAILURE) ;
- }
-
// Initial test for /sys/class/gpio operations:
/**/ if (strcasecmp (argv [1], "exports" ) == 0) { doExports (argc, argv) ; return 0 ; }