PR/50248: re-apply src/external/bsd/tcpdump/dist/tcpdump.c rev.1.8.

> 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:
nonaka 2015-09-17 14:03:10 +00:00
parent a9a1ce9deb
commit de17d00067
1 changed files with 6 additions and 2 deletions

View File

@ -30,7 +30,7 @@
static const char copyright[] _U_ =
"@(#) Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000\n\
The Regents of the University of California. All rights reserved.\n";
__RCSID("$NetBSD: tcpdump.c,v 1.11 2015/03/31 21:59:35 christos Exp $");
__RCSID("$NetBSD: tcpdump.c,v 1.12 2015/09/17 14:03:10 nonaka Exp $");
#endif
/*
@ -1856,8 +1856,12 @@ main(int argc, char **argv)
}
capng_apply(CAPNG_SELECT_BOTH);
#endif /* HAVE_LIBCAP_NG */
if (username || chroot_dir)
if (username || chroot_dir) {
#ifndef HAVE_LIBCAP_NG
if (!WFileName)
#endif
droproot(username, chroot_dir);
}
}
#endif /* WIN32 */