ongrep

A cleaned up fork of ngrep for OpenBSD
git clone git://git.sgregoratto.me/ongrep
Log | Files | Refs | README | LICENSE

commit 069c87669f76166e279952240f9e4e2556b8fc98
parent 248878761d14fdc6d07fe4b6f865e374374027c2
Author: Jordan Ritter <jpr5@darkridge.com>
Date:   Sun, 10 Aug 2003 02:03:56 +0000

changed drop_privs code

Diffstat:
Mngrep.c | 10+++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/ngrep.c b/ngrep.c @@ -847,11 +847,11 @@ void update_windowsize(int e) { void drop_privs(void) { struct passwd *pw = getpwnam(SAFE_USER); - seteuid(pw->pw_uid); - setegid(pw->pw_gid); - - setuid(pw->pw_uid); - setgid(pw->pw_gid); + if (setregid(pw->pw_gid, pw->pw_gid) == -1 || + setreuid(pw->pw_uid, pw->pw_uid) == -1) { + perror("attempt to drop privileges failed"); + clean_exit(-1); + } } void usage(int e) {