Subject: bin/20065: pppd is unable to load plugins
To: None <gnats-bugs@gnats.netbsd.org>
From: John F. Woods <jfw@jfwhome.funhouse.com>
List: netbsd-bugs
Date: 01/26/2003 09:08:37
>Number:         20065
>Category:       bin
>Synopsis:       pppd is unable to load plugins
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sun Jan 26 06:09:01 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:     John F. Woods
>Release:        NetBSD 1.6F
>Organization:
Misanthropes-R-Us
>Environment:
System: NetBSD jfwhome.funhouse.com 1.6F NetBSD 1.6F (JFW) #6: Sun Aug 18 12:28:13 EDT 2002 jfw@jfwhome.funhouse.com:/usr/src/sys/arch/i386/compile/JFW i386
Architecture: i386
Machine: i386
>Description:
The pppd code has the ability to dynamically load "plugins" (shared libraries)
which can be used to extend pppd's functionality.  As compiled on NetBSD, this
capability is disabled, yet it is trivial to enable it.
>How-To-Repeat:
Read the pppd docs.  Try it.  Read the Makefile to find out why it didn't work.
>Fix:
Patching the Makefile as shown below appears to be sufficient to enable plugin
functionality in pppd under NetBSD.  Three things are required:  the symbol
PLUGIN must be defined in the compilation, the linker must be told to export
dynamic symbols (so that loaded plugins can have symbols resolved), and the
object must not be stripped when installed.

In addition to changing the Makefile, pppd (as shipped) expects to load the
shared library plugins from /usr/lib/pppd/2.4.1; if there is a more appropriate
place, pathnames.h should be editted accordingly.

Index: Makefile
===================================================================
RCS file: /cvsroot/src/usr.sbin/pppd/pppd/Makefile,v
retrieving revision 1.30
diff -u -d -b -w -r1.30 Makefile
--- Makefile	2002/09/18 03:54:35	1.30
+++ Makefile	2003/01/26 13:58:35
@@ -14,9 +14,11 @@
 BINMODE=4555
 BINOWN=	root
 
-LDADD=	-lpcap -lcrypt -lutil
+# don't strip object so that it can load plugins
+STRIPFLAG=
+LDADD=	-lpcap -lcrypt -lutil -Wl,--export-dynamic
 DPADD=	${LIBPCAP} ${LIBCRYPT} ${LIBUTIL}
-CPPFLAGS+= -I. -DHAVE_PATHS_H -DSUPPORT_UTMP -DSUPPORT_UTMPX
+CPPFLAGS+= -I. -DHAVE_PATHS_H -DSUPPORT_UTMP -DSUPPORT_UTMPX -DPLUGIN
 CPPFLAGS+= -I${PCAPDIR} -DPPP_FILTER
 CPPFLAGS+= -DCBCP_SUPPORT -DCHAPMS -DUSE_CRYPT -DMSLANMAN
 CPPFLAGS+= -DINET6

>Release-Note:
>Audit-Trail:
>Unformatted:
 Sun Jan 26 09:01:34 EST 2003