wiringPi: Fix non-root user who has gpiomem cannot use gpio binary properly
Signed-off-by: Yang Deokgyu <secugyu@gmail.com>
diff --git a/gpio/gpio.c b/gpio/gpio.c
index 4da2688..e96b003 100755
--- a/gpio/gpio.c
+++ b/gpio/gpio.c
@@ -1051,6 +1051,7 @@
int main (int argc, char *argv [])
{
int i ;
+ struct stat statBuf ;
if (getenv ("WIRINGPI_DEBUG") != NULL) {
printf ("gpio: wiringPi debug mode enabled\n") ;
@@ -1101,7 +1102,7 @@
return 0 ;
}
- if (geteuid () != 0) {
+ if (geteuid () != 0 && stat("/dev/gpiomem", &statBuf) != 0) {
fprintf (stderr, "%s: Must be root to run. Program should be suid root. This is an error.\n", argv [0]) ;
return 1 ;
}