# l2tpd calling pppd with -detach instead of nodetach

## Moriah

I have just rebuilt my gateway firewall on a newer box using 2.6.14-gentoo-r5 kernel and net-dialup/l2tpd varsion 0.70_pre20031121; the old box was running redhat-9 and a version of l2tpd that was a little over 2 years old.  The old box worked; the new one doesn't.    :Sad: 

I tracked the problem down to the fact that the newer version of l2tpd is calling pppd as follows:

```

12/29/05 02:18:28 l2tpd: control_finish: Call established with 204.255.233.225, Local: 52763, Remote: 8, Serial: 1

12/29/05 02:18:28 l2tpd: start_pppd: I'm running:  "/usr/sbin/pppd" "passive" "-detach" ":" "/dev/ttyp0" 

12/29/05 02:18:28 l2tpd: check_control: control, cid = 0, Ns = 2, Nr = 4

12/29/05 02:18:30 l2tpd: child_handler : pppd exited for call 8 with code 1

12/29/05 02:18:30 l2tpd: call_close: Call 52763 to 204.255.233.225 disconnected

```

But the old version is calling it like this:

```

12/29/05 02:54:30 l2tpd: control_finish: Call established with 204.255.233.225, Local: 62733, Remote: 29, Serial: 2

12/29/05 02:54:30 l2tpd: start_pppd: I'm running:  "/usr/sbin/pppd" "passive" "nodetach" ":" 

12/29/05 02:54:30 l2tpd: check_control: control, cid = 0, Ns = 4, Nr = 6

12/29/05 02:55:19 l2tpd: check_control: control, cid = 0, Ns = 4, Nr = 7

12/29/05 02:56:19 l2tpd: check_control: control, cid = 0, Ns = 4, Nr = 8

```

This log excerpt from the old box continues these checks every minute, as the tunnel is connected and working, but the new box has pppd exiting with a code 1.  If I look into /var/log/messages, I find:

```

Dec 29 02:18:28 shadrach l2tpd[5655]: control_finish: Connection established to 204.255.233.225, 1701.  Local: 54788, Remote: 3.

Dec 29 02:18:28 shadrach l2tpd[5655]: ourcid = 52763, entropy_buf = ce1b

Dec 29 02:18:28 shadrach l2tpd[5655]: lac_call: Calling on tunnel 54788

Dec 29 02:18:28 shadrach l2tpd[5655]: check_control: control, cid = 0, Ns = 1, Nr = 2

Dec 29 02:18:28 shadrach l2tpd[5655]: check_control: control, cid = 0, Ns = 1, Nr = 3

Dec 29 02:18:28 shadrach l2tpd[5655]: handle_avps: handling avp's for tunnel 54788, call 52763

Dec 29 02:18:28 shadrach l2tpd[5655]: message_type_avp: message type 11 (Incoming-Call-Reply)

Dec 29 02:18:28 shadrach l2tpd[5655]: assigned_session_avp: assigned session id: 8

Dec 29 02:18:28 shadrach l2tpd[5655]: control_finish: Call established with 204.255.233.225, Local: 52763, Remote: 8, Serial: 1

Dec 29 02:18:28 shadrach l2tpd[5655]: start_pppd: I'm running:  

Dec 29 02:18:28 shadrach l2tpd[5655]: "/usr/sbin/pppd" 

Dec 29 02:18:28 shadrach l2tpd[5655]: "passive" 

Dec 29 02:18:28 shadrach l2tpd[5655]: "-detach" 

Dec 29 02:18:28 shadrach l2tpd[5655]: ":" 

Dec 29 02:18:28 shadrach l2tpd[5655]: "/dev/ttyp0" 

Dec 29 02:18:28 shadrach l2tpd[5655]: 

Dec 29 02:18:28 shadrach l2tpd[5655]: check_control: control, cid = 0, Ns = 2, Nr = 4

Dec 29 02:18:28 shadrach CSLIP: code copyright 1989 Regents of the University of California

Dec 29 02:18:28 shadrach PPP generic driver version 2.4.2

Dec 29 02:18:28 shadrach pppd[5658]: pppd 2.4.2 started by root, uid 0

Dec 29 02:18:28 shadrach pppd[5658]: Couldn't set tty to PPP discipline: Invalid argument

Dec 29 02:18:28 shadrach pppd[5658]: Exit.

Dec 29 02:18:30 shadrach l2tpd[5655]: child_handler : pppd exited for call 8 with code 1

Dec 29 02:18:30 shadrach l2tpd[5655]: call_close: Call 52763 to 204.255.233.225 disconnected

```

Looking at the man page for pppd, I find:

```

       nodetach

              Don't  detach  from  the  controlling terminal.  Without this option, if a serial device other than the

              terminal on the standard input is specified, pppd will fork to become a background process.

```

But there is no "-detach" option.  It appears that either l2tpd has a buggy invocation of pppd, or at the very least, the version of l2tpd is not compatible with the version of pppd.   

BTW I am running pppd version 2.4.2 on the new box, and pppd version 2.4.1 on the old box.

I expect that a simple change to the source code of the new l2tpd to change the "-detach" to "nodetach" would do the trick, but I do not know how to get the source files for l2tpd using the emerge mechanism.   :Mad: 

I seem to remember having to edit this in the old l2tpd, but I seem to have misplaced the source file tarball I used to build it over 2 years ago.  :Embarassed: 

So either how do I fetch the sources and then build l2tpd from my edited version, or even better, how do I get this fixed properly in the current distribution?

Thanks for any help with this!    :Very Happy: 

----------

