]> The Tcpdump Group git mirrors - tcpdump/blobdiff - tcpdump.c
Make the port arguments to udpipaddr_print() ints so that there can be
[tcpdump] / tcpdump.c
index 1d81af14e36a7f5228996af98125acc0e5c8314b..a83be5deb1b2537747502ff78ea2f907d99d547b 100644 (file)
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -30,7 +30,7 @@ static const char copyright[] =
     "@(#) 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";
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.208 2003-05-25 16:26:57 hannes Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.211 2003-07-31 22:36:43 fenner Exp $ (LBL)";
 #endif
 
 /*
@@ -69,7 +69,6 @@ extern int SIZE_BUF;
 #include "gmt2local.h"
 #include "pcap-missing.h"
 
-int aflag;                     /* translate network and broadcast addresses */
 int dflag;                     /* print filter code */
 int eflag;                     /* print ethernet header */
 int fflag;                     /* don't translate "foreign" IP address */
@@ -352,7 +351,7 @@ main(int argc, char **argv)
                switch (op) {
 
                case 'a':
-                       ++aflag;
+                       /* compatibility for old -a */
                        break;
 
                case 'A':
@@ -601,28 +600,28 @@ main(int argc, char **argv)
                        /* NOTREACHED */
                }
 
-       if (aflag && nflag)
-               error("-a and -n options are incompatible");
-
        if (tflag > 0)
                thiszone = gmt2local(0);
 
        if (RFileName != NULL) {
+#ifndef WIN32
                /*
-                * We don't need network access, so set it back to the user id.
-                * Also, this prevents the user from reading anyone's
-                * trace file.
+                * We don't need network access, so relinquish any set-UID
+                * or set-GID privileges we have (if any).
+                *
+                * We do *not* want set-UID privileges when opening a
+                * trace file, as that might let the user read other
+                * people's trace files (especially if we're set-UID
+                * root).
                 */
-#ifndef WIN32
                setuid(getuid());
 #endif /* WIN32 */
-
                pd = pcap_open_offline(RFileName, ebuf);
+               if (pd == NULL)
+                       error("%s", ebuf);
                 printf("reading from file %s, link-type %u\n",
                       RFileName,
                       pcap_datalink(pd));
-               if (pd == NULL)
-                       error("%s", ebuf);
                localnet = 0;
                netmask = 0;
                if (fflag != 0)
@@ -700,6 +699,9 @@ main(int argc, char **argv)
        }
        init_addrtoname(localnet, netmask);
 
+#ifndef WIN32  
+       (void)setsignal(SIGPIPE, cleanup);
+#endif /* WIN32 */
        (void)setsignal(SIGTERM, cleanup);
        (void)setsignal(SIGINT, cleanup);
        /* Cooperate with nohup(1) */