Skip to content

Commit

Permalink
Merge pull request #77 from jjh74/nopromiscv2
Browse files Browse the repository at this point in the history
-N option to set interface(pcap_open_live) to non promisc. mode
  • Loading branch information
gamelinux committed Feb 5, 2016
2 parents 76ca909 + 1e71c4c commit 9fb5b70
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/passivedns.c
Expand Up @@ -1093,6 +1093,7 @@ void usage()
olog(" -C <sec> Seconds to cache DNS objects in memory (default: %u).\n", DNSCACHETIMEOUT);
olog(" -P <sec> Seconds between printing duplicate DNS info (default %u).\n", DNSPRINTTIME);
olog(" -X <flags> Manually set DNS RR Types to care about (default: -X 46CDNPRS).\n");
olog(" -N Set interface to non promisc. mode.\n");
olog(" -u <uid> User ID to drop privileges to.\n");
olog(" -g <gid> Group ID to drop privileges to.\n");
olog(" -T <dir> Directory to chroot into.\n");
Expand Down Expand Up @@ -1164,6 +1165,7 @@ int main(int argc, char *argv[])
config.logfile = "/var/log/passivedns.log";
config.logfile_nxd = "/var/log/passivedns.log";
config.pidfile = "/var/run/passivedns.pid";
config.promisc = 1;
config.output_log = 0;
config.output_log_nxd = 0;
config.output_syslog = 0;
Expand Down Expand Up @@ -1205,7 +1207,7 @@ int main(int argc, char *argv[])
signal(SIGUSR1, print_pdns_stats);
signal(SIGUSR2, expire_all_dns_records);

#define ARGS "i:r:c:nyYjJl:L:d:hb:Dp:C:P:S:f:X:u:g:T:V"
#define ARGS "i:r:c:nyYNjJl:L:d:hb:Dp:C:P:S:f:X:u:g:T:V"

while ((ch = getopt(argc, argv, ARGS)) != -1)
switch (ch) {
Expand Down Expand Up @@ -1276,6 +1278,9 @@ int main(int argc, char *argv[])
config.group_name = optarg;
config.drop_privs_flag = 1;
break;
case 'N':
config.promisc = 0;
break;
#ifdef HAVE_PFRING
case 'n':
config.use_pfring = 1;
Expand Down Expand Up @@ -1434,7 +1439,7 @@ int main(int argc, char *argv[])
config.dev = pcap_lookupdev(config.errbuf);
olog("[*] Device: %s\n", config.dev);

if ((config.handle = pcap_open_live(config.dev, SNAPLENGTH, 1, 500,
if ((config.handle = pcap_open_live(config.dev, SNAPLENGTH, config.promisc, 500,
config.errbuf)) == NULL) {
olog("[*] Error pcap_open_live: %s \n", config.errbuf);
exit(1);
Expand Down
1 change: 1 addition & 0 deletions src/passivedns.h
Expand Up @@ -497,6 +497,7 @@ typedef struct _globalconfig {
uint8_t use_json_nxd; /* Use JSON as output in NXDOMAIN log */
#endif /* HAVE_JSON */
uint8_t setfilter;
uint8_t promisc; /* set interface promisc mode */
uint8_t drop_privs_flag; /* Flag marking to drop privs */
uint8_t chroot_flag; /* Flag for going chroot */
uint8_t daemon_flag; /* Flag for going daemon */
Expand Down

0 comments on commit 9fb5b70

Please sign in to comment.