Let's not support loading addresses from /etc/appletalk.names.

There are two points to consider:
* tcpdump uses just one file now (/etc/pf.os) which means we can probably
    simplify priv_getlines(), but let's not right now.
* there is some lookup code left, but let's remove it later.
    removing is not as simple, as the hnametable[] array is used even
    when printing a numerical address.

Comments? OK?

Index: usr.sbin/tcpdump/print-atalk.c
===================================================================
RCS file: /cvs/src/usr.sbin/tcpdump/print-atalk.c,v
retrieving revision 1.31
diff -u -p -r1.31 print-atalk.c
--- usr.sbin/tcpdump/print-atalk.c      28 Oct 2016 12:54:05 -0000      1.31
+++ usr.sbin/tcpdump/print-atalk.c      13 Jun 2017 19:32:10 -0000
@@ -554,51 +554,13 @@ struct hnamemem {
 
 static struct hnamemem hnametable[HASHNAMESIZE];
 
-/*
- * see if there's an AppleTalk number to name map file.
- */
-static void
-init_atalk(void)
-{
-       struct hnamemem *tp;
-       char nambuf[HOST_NAME_MAX+1 + 20];
-       char line[BUFSIZ];
-       int i1, i2, i3;
-
-       priv_getlines(FTAB_APPLETALK);
-       while (priv_getline(line, sizeof(line)) > 0) {
-               if (line[0] == '\n' || line[0] == 0 || line[0] == '#')
-                       continue;
-               if (sscanf(line, "%d.%d.%d %255s", &i1, &i2, &i3, nambuf) == 4)
-                       /* got a hostname. */
-                       i3 |= ((i1 << 8) | i2) << 8;
-               else if (sscanf(line, "%d.%d %255s", &i1, &i2, nambuf) == 3)
-                       /* got a net name */
-                       i3 = (((i1 << 8) | i2) << 8) | 255;
-               else
-                       continue;
-               
-               for (tp = &hnametable[i3 & (HASHNAMESIZE-1)];
-                    tp->nxt; tp = tp->nxt)
-                       ;
-               tp->addr = i3;
-               tp->nxt = newhnamemem();
-               tp->name = savestr(nambuf);
-       }
-}
-
 static const char *
 ataddr_string(u_short atnet, u_char athost)
 {
        struct hnamemem *tp, *tp2;
        int i = (atnet << 8) | athost;
        char nambuf[HOST_NAME_MAX+1 + 20];
-       static int first = 1;
 
-       if (first) {
-               first = 0;
-               init_atalk();
-       }
        for (tp = &hnametable[i & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt)
                if (tp->addr == i)
                        return (tp->name);
Index: usr.sbin/tcpdump/privsep.c
===================================================================
RCS file: /cvs/src/usr.sbin/tcpdump/privsep.c,v
retrieving revision 1.44
diff -u -p -r1.44 privsep.c
--- usr.sbin/tcpdump/privsep.c  23 Jan 2017 04:25:05 -0000      1.44
+++ usr.sbin/tcpdump/privsep.c  13 Jun 2017 19:32:10 -0000
@@ -101,8 +101,7 @@ struct ftab {
        int count;
 };
 
-static struct ftab file_table[] = {{"/etc/appletalk.names", 1, 0},
-                                  {PF_OSFP_FILE, 1, 0}};
+static struct ftab file_table[] = {{PF_OSFP_FILE, 1, 0}};
 
 #define NUM_FILETAB (sizeof(file_table) / sizeof(struct ftab))
 
Index: usr.sbin/tcpdump/privsep.h
===================================================================
RCS file: /cvs/src/usr.sbin/tcpdump/privsep.h,v
retrieving revision 1.8
diff -u -p -r1.8 privsep.h
--- usr.sbin/tcpdump/privsep.h  14 Jul 2015 20:23:40 -0000      1.8
+++ usr.sbin/tcpdump/privsep.h  13 Jun 2017 19:32:10 -0000
@@ -22,8 +22,7 @@
 #define TCPDUMP_MAGIC 0xa1b2c3d4
 
 /* file ids used by priv_getlines */
-#define FTAB_APPLETALK 0
-#define FTAB_PFOSFP    1
+#define FTAB_PFOSFP    0
 
 enum cmd_types {
        PRIV_OPEN_BPF,          /* open a bpf descriptor */


-- 
Michal Mazurek

Reply via email to