When running as root and wanting to write a file and not having CAPNG, don't

drop privs, because we cannot open the file if we drop privs.
This commit is contained in:
christos 2014-05-13 20:29:59 +00:00
parent 02160989ff
commit 21314e18fb

View File

@ -34,7 +34,7 @@ The Regents of the University of California. All rights reserved.\n";
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.283 2008-09-25 21:45:50 guy Exp (LBL)";
#else
__RCSID("$NetBSD: tcpdump.c,v 1.7 2013/12/31 17:33:31 christos Exp $");
__RCSID("$NetBSD: tcpdump.c,v 1.8 2014/05/13 20:29:59 christos Exp $");
#endif
#endif
@ -1482,8 +1482,12 @@ main(int argc, char **argv)
#endif /* HAVE_CAP_NG_H */
if (getuid() == 0 || geteuid() == 0) {
if (username || chroot_dir)
if (username || chroot_dir) {
#ifndef HAVE_CAP_NG_H
if (!WFileName)
#endif
droproot(username, chroot_dir);
}
}
#endif /* WIN32 */