summaryrefslogtreecommitdiff
path: root/net/ngrep/patches/patch-ac
diff options
context:
space:
mode:
authorhubertf <hubertf@pkgsrc.org>2004-07-05 21:42:46 +0000
committerhubertf <hubertf@pkgsrc.org>2004-07-05 21:42:46 +0000
commit2f6fd86193aaecef408491446d7510e468811c19 (patch)
tree21cf5806b497aec22acbb94c882afe46f6346039 /net/ngrep/patches/patch-ac
parent892e09d9641663e82b837772a3a8f0d9680f5212 (diff)
downloadpkgsrc-2f6fd86193aaecef408491446d7510e468811c19.tar.gz
Add a patch to fix privilege handling.
Contributed by Steve Rumble in private mail, and mailed back to the ngrep author by him. Bump the pkg to nb2.
Diffstat (limited to 'net/ngrep/patches/patch-ac')
-rw-r--r--net/ngrep/patches/patch-ac63
1 files changed, 63 insertions, 0 deletions
diff --git a/net/ngrep/patches/patch-ac b/net/ngrep/patches/patch-ac
new file mode 100644
index 00000000000..18d503b0466
--- /dev/null
+++ b/net/ngrep/patches/patch-ac
@@ -0,0 +1,63 @@
+--- ngrep.c.orig 2004-03-28 21:15:59.000000000 -0500
++++ ngrep.c 2004-07-04 19:21:18.000000000 -0400
+@@ -999,40 +999,29 @@
+
+ {
+ struct passwd *pw = getpwnam(DROPPRIVS_USER);
+- gid_t newgid = pw->pw_uid, oldgid = getegid();
+- uid_t newuid = pw->pw_gid, olduid = geteuid();
+-
+- if (!olduid)
+- setgroups(1, &newgid);
+-
+- if (newgid != oldgid) {
+-#if !defined(LINUX)
+- setegid(newgid);
+- if (setgid(newgid) == -1)
+-#else
+- if (setregid(newgid, newgid) == -1)
+-#endif
+- {
+- perror("attempt to drop privileges failed");
+- clean_exit(-1);
+- }
++ gid_t newgid = pw->pw_gid, oldgid = getegid();
++ uid_t newuid = pw->pw_uid, olduid = geteuid();
++ gid_t groups[2];
++
++ groups[0] = groups[1] = newgid;
++ if (setgroups(1, groups) == -1)
++ {
++ perror("attempt to set groups failed");
++ clean_exit(-1);
+ }
+
+- if (newuid != olduid) {
+-#if !defined(LINUX)
+-#if !defined(MACOSX)
+- seteuid(newuid);
+-#endif
+- if (setuid(newuid) == -1)
+-#else
+- if (setreuid(newuid, newuid) == -1)
+-#endif
+- {
+- perror("attempt to drop privileges failed");
+- clean_exit(-1);
+- }
++ if (setgid(newgid) == -1)
++ {
++ perror("attempt to drop group privileges failed");
++ clean_exit(-1);
+ }
+-
++
++ if (setuid(newuid) == -1)
++ {
++ perror("attempt to drop user privileges failed");
++ clean_exit(-1);
++ }
++
+ if ((newgid != oldgid && (setegid(oldgid) != -1 || getegid() != newgid)) ||
+ (newuid != olduid && (seteuid(olduid) != -1 || geteuid() != newuid))) {
+ perror("attempt to drop privileges failed");