Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IO plugins for libpcap #823

Closed

Conversation

raybellis
Copy link

This replaces #578 which I messed up when performing a second rebase.

With this patch deployed, libpcap checks the environment variables PCAP_IOPLUGIN_READ and PCAP_IOPLUGIN_WRITE for dynamically-loadable plugins that replace the file I/O routines, e.g. for automatic decompression or compression of pcap files.

Plugins use fopencookie or funopen (O/S dependent) to create a virtual FILE* handle which is then returned to existing libpcap functions. A sample plugin with gzip support is at https://github.com/raybellis/libpcap-gzip

If the plugin is not found or does not initialise properly the system falls back to generic stdio-based functions that are provided in pcap-ioplugin.c and which now handle the use of - to indicate stdin or stdout there instead of in savefile.c (simplifying the code in the latter).

@mcr
Copy link
Member

mcr commented Jun 10, 2019 via email

@raybellis
Copy link
Author

raybellis commented Jun 10, 2019

With the plugin model in this (much) later version of the patch the dependencies end up in the plugin, not the main library, so (for example) libpcap-plugin-gzip.rpm could be the package that pulls in the zlib dependency.

(this differs from my first attempt at this where I didn't use dynamically loadable modules and just hooked zlib into the main library).

The setuid concern is valid, though, and we should certainly talk about that further. Would it be sufficient (and appropriate) to disable the mechanism if getuid() != geteuid() ?

@guyharris
Copy link
Member

The setuid concern is valid, though, and we should certainly talk about that further. Would it be sufficient (and appropriate) to disable the mechanism if getuid() != geteuid() ?

Ideally, it should be disabled if the program is running with special privileges or was started with them, has relinquished them, but could reclaim them, or was started with them but relinquished them in favor of privileges other than those of the user running the program.

OpenBSD introduced an issetugid() call that indicates whether "the process was made setuid or setgid as the result of the last or other previous execve() system calls". Somebody's complained that other OSes that have picked it up have changed it so in ways that are inappropriate; from a quick read of his document, I infer that it would mean we'd disallow plugins when not necessary on those OSes.

That document also mentions another mechanism that Linux provides.

@mcr
Copy link
Member

mcr commented Jun 12, 2019 via email

@mcr
Copy link
Member

mcr commented Mar 2, 2020

Replaced with #914.

@mcr mcr closed this Mar 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants