diff options
author | Daniel Borkmann <dborkman@redhat.com> | 2013-04-09 09:51:26 +0200 |
---|---|---|
committer | Daniel Borkmann <dborkman@redhat.com> | 2013-04-09 09:51:26 +0200 |
commit | a4703f2a060a81397da497b85bc135187f0f89e9 (patch) | |
tree | dbae97c2ec9e0b74fa85e06ccdc18e3f6197b515 /pcap_rw.c | |
parent | 5be3139e456d85b18e166643ce1636b0ecdbccc3 (diff) |
pcap_io: introduce init_once helper that is called with priviledges
When using netsniff-ng with dropping priviledges, we have to introduce
another pcap helper function that is called once before we drop the
priviledges. In this function we have to invoke the disc I/O scheduler
policy, because it needs priviledges. Otherwise netsniff-ng will fail
with "Failed to set io prio for pid" on startup, since we're not root
anymore.
Reported-by: Doug Burks <doug.burks@gmail.com>
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Diffstat (limited to 'pcap_rw.c')
-rw-r--r-- | pcap_rw.c | 6 |
1 files changed, 2 insertions, 4 deletions
@@ -57,11 +57,9 @@ static ssize_t pcap_rw_read(int fd, pcap_pkthdr_t *phdr, enum pcap_type type, return hdrsize + hdrlen; } -static int pcap_rw_prepare_access(int fd, enum pcap_mode mode, bool jumbo) +static void pcap_rw_init_once(void) { set_ioprio_rt(); - - return 0; } static void pcap_rw_fsync(int fd) @@ -70,9 +68,9 @@ static void pcap_rw_fsync(int fd) } const struct pcap_file_ops pcap_rw_ops = { + .init_once_pcap = pcap_rw_init_once, .pull_fhdr_pcap = pcap_generic_pull_fhdr, .push_fhdr_pcap = pcap_generic_push_fhdr, - .prepare_access_pcap = pcap_rw_prepare_access, .read_pcap = pcap_rw_read, .write_pcap = pcap_rw_write, .fsync_pcap = pcap_rw_fsync, |