]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
Make lldpctl refuse attempts to change anything when running setuid.
authorAndreas Hofmeister <andi@collax.com>
Sat, 27 Feb 2010 18:58:46 +0000 (19:58 +0100)
committerVincent <bernat@luffy.cx>
Sun, 28 Feb 2010 11:58:10 +0000 (12:58 +0100)
When running setuid, lldpctl now refuses to set location data. This should
make it save to run the program setuid root by normal users including a
web-server f.e.

src/lldpctl.c

index f4ec58ca8d1fe406d910d28f4054ee714c1ee088..12d1bc1593184718014bb19fd97cbb545f25e1b0 100644 (file)
@@ -1176,9 +1176,13 @@ main(int argc, char *argv[])
                default:
                        usage();
                }
-       }               
-       
+       }
+
        log_init(debug, __progname);
+
+       if ( ( action != 0 ) && ( getuid() != geteuid() ) ) {
+               fatalx("mere mortals may not do that, 'root' privileges are required.");
+       }
        
        if ((s = ctl_connect(LLDPD_CTL_SOCKET)) == -1)
                fatalx("unable to connect to socket " LLDPD_CTL_SOCKET);