]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
lldpcli: root is privileged
authorVincent Bernat <bernat@luffy.cx>
Thu, 20 Feb 2014 20:37:22 +0000 (21:37 +0100)
committerVincent Bernat <bernat@luffy.cx>
Thu, 20 Feb 2014 20:39:14 +0000 (21:39 +0100)
For some reason, this bug was not catched before. It was expected that
`lldpcli` can be installed as suid `_lldpd` to give user read access to
the neighbor information. However, to avoid write access, we checked if
the user was privileged by checking equality of effective and real user
uid. However, even for root, they don't have to match. Maybe they
matched in the past?

Therefore, directly check for UID == 0 too.

This should fix #56

src/client/lldpcli.c

index 7a82c724c870bf3c3c30c2ab33e4c16c4cb4197c..0049a87fc5124c7c424cdf3d39c87ff8c4a295d2 100644 (file)
@@ -80,7 +80,8 @@ usage()
 static int
 is_privileged()
 {
-       return (!(getuid() != geteuid() || getgid() != getegid()));
+       return (getuid() == geteuid() && getgid() == getegid()) ||
+           getuid() == 0;
 }
 
 static char*