Ethereal-dev: [ethereal-dev] Trouble with plugins

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Gilbert Ramirez <gram@xxxxxxxxxx>
Date: Sun, 12 Dec 1999 00:00:04 -0600
Olivier: I'm trying your plugin code for the first time. I'm using the
sample gryphon plugin that your provided. I compile the loadable module,
install it in ~/.ethereal/plugins, but then ethereal doesn't recognize
the plugin when I open the plugins dialogue.

I put the in a debug line (see the attached diff) to get the dlerror()
error message.

My system is Debian, Linux 2.3.31, i586, glibc 2.1.2. The number of
libdl libraries on my system is interesting:

$ ls -l /lib/libdl*
-rw-r--r--    1 root     root        10224 Nov  8 12:55 /lib/libdl-2.1.2.so
lrwxrwxrwx    1 root     root           15 Nov 23 02:39 /lib/libdl.so.1 -> libdl.so.1.9.11
-rwxr-xr-x    1 root     root         6124 Oct 25 11:14 /lib/libdl.so.1.9.11
lrwxrwxrwx    1 root     root           14 Nov 20 08:41 /lib/libdl.so.2 -> libdl-2.1.2.so

However, 'ldd ethereal' shows me linking against the correct libdl:

	libsnmp.so.4.0 => /usr/lib/libsnmp.so.4.0 (0x40019000)
	libz.so.1 => /usr/lib/libz.so.1 (0x40052000)
	libgtk-1.2.so.0 => /usr/debug/lib/libgtk-1.2.so.0 (0x40061000)
	libgdk-1.2.so.0 => /usr/debug/lib/libgdk-1.2.so.0 (0x4019a000)
	libgmodule-1.2.so.0 => /usr/debug/lib/libgmodule-1.2.so.0 (0x401ce000)
	libglib-1.2.so.0 => /usr/debug/lib/libglib-1.2.so.0 (0x401d1000)
	libdl.so.2 => /lib/libdl.so.2 (0x401fd000)
	libXext.so.6 => /usr/X11R6/lib/libXext.so.6 (0x40201000)
	libX11.so.6 => /usr/X11R6/lib/libX11.so.6 (0x4020d000)
	libm.so.6 => /lib/libm.so.6 (0x402ac000)
	libc.so.6 => /lib/libc.so.6 (0x402c9000)
	/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)

Here's when I made the loadable module, and the output from ethereal (with my debug code)
First you'll see that the code doesn't try to avoid loading "." and ".."
files; we should probably avoid that. But the interesting line is
what appears to be an improper file format.

Any ideas?

$ make
gcc -DHAVE_CONFIG_H -I. -I. -I. -I../..  -I/usr/debug/include  -Wall -g -O2 -I/usr/debug/lib/glib/include -I/usr/debug/include -c packet-gryphon.c
ld -shared -o gryphon packet-gryphon.o

$ file packet-gryphon.o
packet-gryphon.o: ELF 32-bit LSB relocatable, Intel 80386, version 1, not stripped

$ cp packet-gryphon.o ~/.ethereal/plugins/

$ cd ../..

$ ./ethereal -n -r ~/prj/sniff/gryphon-capture.eth 
Not opening /home/gram/.ethereal/plugins/.: /home/gram/.ethereal/plugins/.: cannot read file data: Is a directory
Not opening /home/gram/.ethereal/plugins/..: /home/gram/.ethereal/plugins/..: cannot read file data: Is a directory
Not opening /home/gram/.ethereal/plugins/packet-gryphon.o: /home/gram/.ethereal/plugins/packet-gryphon.o: ELF file's phentsize not the expected size

--gilbert
Index: plugins_dlg.c
===================================================================
RCS file: /usr/local/cvsroot/ethereal/gtk/plugins_dlg.c,v
retrieving revision 1.2
diff -u -r1.2 plugins_dlg.c
--- plugins_dlg.c	1999/12/09 20:55:49	1.2
+++ plugins_dlg.c	1999/12/12 05:56:38
@@ -210,8 +210,10 @@
 	while ((file = readdir(dir)) != NULL)
 	{
 	    sprintf(filename, "%s/%s", dirname, file->d_name);
-
-	    if ((handle = dlopen(filename, RTLD_LAZY)) == NULL) continue;
+	    if ((handle = dlopen(filename, RTLD_LAZY)) == NULL) {
+		    printf("Not opening %s: %s\n", filename, dlerror());
+		    continue;
+	    }
 	    name = (gchar *)file->d_name;
 	    if ((version = (gchar *)dlsym(handle, "version")) == NULL)
 	    {