arpwatch/SOURCES/arpwatch-2.1a15-dropgroup.p...

13 lines
607 B
Diff

diff -up arpwatch-2.1a15/arpwatch.c.dropgroup arpwatch-2.1a15/arpwatch.c
--- arpwatch-2.1a15/arpwatch.c.dropgroup 2012-05-31 11:47:13.327901902 +0200
+++ arpwatch-2.1a15/arpwatch.c 2012-05-31 11:48:04.859900061 +0200
@@ -147,7 +147,7 @@ void dropprivileges(const char* user)
struct passwd* pw;
pw = getpwnam( user );
if ( pw ) {
- if ( initgroups(pw->pw_name, NULL) != 0 || setgid(pw->pw_gid) != 0 ||
+ if ( setgid(pw->pw_gid) != 0 || setgroups(0, NULL) != 0 ||
setuid(pw->pw_uid) != 0 ) {
syslog(LOG_ERR, "Couldn't change to '%.32s' uid=%d gid=%d", user,
pw->pw_uid, pw->pw_gid);