Subject: pkg/32275: The program l2tpd from the net/rp-l2tp package does not run on NetBSD-2.0/i386
To: None <,,>
From: None <>
List: pkgsrc-bugs
Date: 12/10/2005 23:25:00
>Number:         32275
>Category:       pkg
>Synopsis:       The program l2tpd from the net/rp-l2tp package does not run on NetBSD-2.0/i386
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Dec 10 23:25:00 +0000 2005
>Originator:     Charles Zmudzinski
>Release:        NetBSD 2.0.2_STABLE - source code as of May 27, 2005
System: NetBSD ave 2.0.2_STABLE NetBSD 2.0.2_STABLE (GENERIC.IPSEC) #0: Thu Nov 24 01:13:26 EST 2005 chuckz@ave:/home/chuckz/obj/home/chuckz/netbsd-2.0/src/sys/arch/i386/compil
The program builds and installs fine either from pkgsrc or from the pre-compiled binary for NetBSD-2.0. I tried the pre-compiled binary from pkgsrc-2005Q3 and also building and installing from pkgsrc checked out on December 5, 2005 using the tag pkgsrc-2005Q3. In both cases, I got the following error when running l2tpd:

Error: Could not dload Undefined PLT symbol "l2tp_option_set" (symnum = 23)
FATAL: Could not dload /usr/pkg/lib/l2tp/plugins/ Undefined PLT symbol "l2tp_option_set" (symnum = 23)

Assuming the rp-l2tp package is installed: l2tpd
I fixed it by adding the -Wl,-E option to the rule for building l2tpd in the Makefile that was generated by pkgsrc in the process of building the package. After that, it still did not work (I got another undefined PLT symbol error) until I added the -lutil option to the rule for building the handler in the Makefile of the handlers directory. These changes can be integrated into pkgsrc by replacing patch-ab with the patch-ab listed below, and by adding patch-ah as listed below to the patches directory:

Replace patch-ab with this to add the -Wl,-E option for building l2tpd on NetBSD:

---------------Beginning of File patches/patch-ab---------------------
---	2002-09-30 16:33:55.000000000 -0400
+++	2005-12-10 09:16:01.000000000 -0500
@@ -26,11 +26,21 @@
 install_dir=@INSTALL@ -d
+OPSYS= $(shell uname -s)
 OBJS=auth.o debug.o dgram.o main.o md5.o network.o options.o peer.o session.o tunnel.o utils.o
+ifeq (${OPSYS}, Linux)
+DYNAMIC_FLAGS= -rdynamic
+ifeq (${OPSYS}, NetBSD)
-CFLAGS=-g -I.. -I@LIBEVENT@ -Wall -Wstrict-prototypes -ansi -pedantic -D_GNU_SOURCE -DVERSION=\"$(VERSION)\" -DPREFIX=\"$(prefix)\"
+CFLAGS=-g -I.. -I@LIBEVENT@ -Wall -Wstrict-prototypes -ansi -pedantic -D_GNU_SOURCE -DVERSION=\"$(VERSION)\" -DPREFIX=\"$(prefix)\" -DSYSCONFDIR=\""@sysconfdir@"\"
 TARGETS=l2tpd libl2tp.a handlers
@@ -43,7 +53,7 @@
 l2tpd: libl2tp.a libevent/libevent.a
 	$(MAKE) -C handlers
-	@CC@ -o l2tpd -rdynamic $(OBJS) $(EXTRA_LIBS)
 	test -d libevent || ln -s ../libevent .
@@ -82,8 +92,7 @@
 install: all
 	-mkdir -p $(RPM_INSTALL_ROOT)$(sbindir)
 	$(install) -m 755 -s l2tpd $(RPM_INSTALL_ROOT)$(sbindir)
-	-mkdir -p $(RPM_INSTALL_ROOT)/etc/l2tp
-	$(install) -m 644 l2tp.conf $(RPM_INSTALL_ROOT)/etc/l2tp/l2tp.conf.example
+	$(install) -m 644 l2tp.conf $(RPM_INSTALL_ROOT)${PREFIX}/share/examples/l2tp.conf
 	-mkdir -p $(RPM_INSTALL_ROOT)$(mandir)/man8
 	-mkdir -p $(RPM_INSTALL_ROOT)$(mandir)/man5
 	$(install) -m 644 man/l2tpd.8 $(RPM_INSTALL_ROOT)$(mandir)/man8
--------------------------End of File----------------------------------

Add this file (patch-ah) to the patches directory to add the -lutil option for
-------------------Beginning of File patches/patch-ah-----------------
--- handlers/	2002-09-30 15:45:00.000000000 -0400
+++ handlers/	2005-12-10 09:28:31.000000000 -0500
@@ -15,6 +15,7 @@
 OBJS=pty.o sync-pppd.o dstring.o
 CFLAGS=-g -O2 -I.. -I../libevent -I../../libevent -Wall
 all: $(HANDLERS) l2tp-control
@@ -28,7 +29,7 @@
 	gcc $(CFLAGS) -fPIC -c -o $@ $< pty.o sync-pppd.o
-	gcc -shared -o $@ $^
+	gcc -shared $(LDFLAGS) -o $@ $^ cmd.o dstring.o
 	gcc -shared -o $@ $^
---------------------------End of File--------------------------------