Adrian Ban [Wed, 3 Apr 2013 20:19:52 +0000 (23:19 +0300)]
plugins/radius: Handle bindaddr keyword in radiusclient.conf
This adds code to the radius plugin to handle the bindaddr keyword in
/etc/radiusclient/radiusclient.conf, thus allowing the administrator
to specify which local IP address to use when sending packets to the
radius server.
This is very common for setups where the router has multiple
interfaces for upstream and you don't know which connection is active.
In this case sometimes the packet uses the IP of interface 1 and
sometimes uses the IP of interface 2. With this patch (adapted from
radiusclient-ng) you can specify the IP of the loopback address, and
the plugin will bind to that IP and send the packet with a fixed IP
every time.
Slimmed a little bit at James Carlson's suggestion.
Paul Mackerras [Mon, 11 Mar 2013 08:30:21 +0000 (19:30 +1100)]
pppd: Default exit status to EXIT_CONNECT_FAILED during connection phase
The rp-pppoe plugin doesn't set the exit status in its connect
function, resulting in pppd exiting with a status of EXIT_OK (0)
if rp-pppoe fails to connect. This fixes the problem for rp-pppoe
and any other plugins that don't set the exit status explicitly
by making the status default to EXIT_CONNECT_FAILED if the channel's
connect function fails.
Reported-by: Peter Warasin <peter@endian.com> Signed-off-by: Paul Mackerras <paulus@samba.org>
Paul Mackerras [Sat, 2 Mar 2013 09:25:28 +0000 (20:25 +1100)]
pppd: Add master_detach option
This adds a new option, master_detach, to allow pppd to detach from
the controlling terminal when it is the multilink bundle master but
its own link has terminated, even if the nodetach option has been
given.
Requested-by: Stephen Marron <sfm@boxfusion.net> Signed-off-by: Paul Mackerras <paulus@samba.org>
Paul Mackerras [Sun, 3 Feb 2013 10:53:28 +0000 (21:53 +1100)]
chat: Fix *roff errors in the man page
Fixes these errors:
$ nroff -man -ww chat/chat.8
chat/chat.8:227: warning: number register `"' not defined
chat/chat.8:291: warning: macro `'' not defined
chat/chat.8:368: warning: macro `PR' not defined
Patch partly from Debian BTS by Bjarni Ingi Gislason.
Paul Mackerras [Sun, 3 Feb 2013 06:51:12 +0000 (17:51 +1100)]
pppdump: Eliminate some compiler warnings
gcc lacks the -fyes-actually-I-do-know-the-C-operator-precedence-rules
option, so add some parentheses to shut it up. Also remove some unused
variables.
Paul Mackerras [Wed, 23 Jan 2013 11:59:45 +0000 (22:59 +1100)]
pppd: Clarify circumstances where DNS1/DNS2 environment variables are set
Make it clear that the DNS1 and DNS2 environment variables being set
for scripts doesn't depend on whether the usepeerdns option was given,
only on whether the peer provided DNS server addresses.
Reported-by: William McCall Signed-off-by: Paul Mackerras <paulus@samba.org>
Paul Mackerras [Sun, 20 May 2012 07:09:16 +0000 (17:09 +1000)]
pppd: Eliminate some warnings
auth.c: In function ‘start_link’:
auth.c:556:11: warning: variable ‘msg’ set but not used [-Wunused-but-set-variable]
utils.c: In function ‘logit’:
utils.c:655:9: warning: variable ‘n’ set but not used [-Wunused-but-set-variable]
sys-linux.c: In function ‘ether_to_eui64’:
sys-linux.c:2881:9: warning: pointer targets in assignment differ in signedness [-Wpointer-sign]
Paul Mackerras [Sun, 20 May 2012 04:14:55 +0000 (14:14 +1000)]
pppd: Don't crash if crypt() returns NULL
It is possible for crypt() to return NULL under some circumstances,
so we need to check the return value before passing it to strcmp().
If we do get NULL from crypt(), treat it as an authentication failure.
Reported-by: Paul Wouters <pwouters@redhat.com> Signed-off-by: Paul Mackerras <paulus@samba.org>
Paul Mackerras [Sun, 20 May 2012 02:01:48 +0000 (12:01 +1000)]
pppd: Enable IPV6 by default and fix some warnings
Fixes these warnings:
ipv6cp.c: In function ‘ipv6_check_options’:
ipv6cp.c:1106:2: warning: implicit declaration of function ‘ether_to_eui64’ [-Wimplicit-function-declaration]
ipv6cp.c:1133:2: warning: implicit declaration of function ‘exit’ [-Wimplicit-function-declaration]
ipv6cp.c:1133:2: warning: incompatible implicit declaration of built-in function ‘exit’ [enabled by default]
Jason St. John [Fri, 14 Oct 2011 04:08:14 +0000 (00:08 -0400)]
scripts: Make poff ignore extra arguments to pppd
This allows /usr/bin/poff to properly end a /usr/sbin/pppd process
that was started with additional arguments.
The problem with the current poff script is on line 93 where the
output of `ps axw` is piped into grep. The current regular expression
that grep searches for prevents the PID of the specified pppd process
from being found, which results in the script failing to terminate the
pppd process. The output of poff in that case would be the following:
/usr/bin/poff: I could not find a pppd process for provider 'cit-vpn'.
None stopped.
The reason for this is that the " *\$" at the end of the regular
expression does not match the output of the following example from `ps
axw`:
11846 ? Ss 0:00 /usr/sbin/pppd call cit-vpn updetach persist
To resolve this issue, I removed the troublesome part of the regular
expression (" *\$") and now grep can properly match the example output
provided above.
I have tested this using ppp 2.4.5-2 in conjunction with
pptpclient-1.7.2-3 on Arch Linux x86_64.
Deomid Ryabkov [Sat, 31 Mar 2012 04:14:23 +0000 (05:14 +0100)]
pppd: Make MSCHAP-v2 cope better with packet loss
This implements response caching for MSCHAP-v2. It caches our
responses and the responses we expect from the peer. MSCHAP-v2 is
unusual in that the authenticatee's CHAP-Response contains what is
effectively a challenge to the authenticator, and the authenticator's
CHAP-Success packet contains a response to that challenge. Having
the response cache lets us (a) answer challenges consistently and
(b) cope with a CHAP-Success packet that corresponds to one of our
CHAP-Responses that wasn't the last one we sent.
This solves a problem where MSCHAP-v2 does not handle replay/retry
properly. Here's what a typical normal session looks like:
Mar 31 02:47:40 nbm pppd[12895]: rcvd [CHAP Challenge id=0x37 <7ac9de47e66fc440e4b142e28c1a2064>, name = "jeeves"]
Mar 31 02:47:40 nbm pppd[12895]: sent [CHAP Response id=0x37 <12986c68266e0d60e7e0de9c8326073200000000000000005da37272ed71b6743f65bc00f7ae2ca148db9210627b646500>, name = "murka"]
Mar 31 02:47:40 nbm pppd[12895]: rcvd [CHAP Success id=0x37 "S=ED8FB5829C8049C331AAE0C570F63F8B558DEA2C M=Access granted"]
Mar 31 02:47:40 nbm pppd[12895]: CHAP authentication succeeded
however, this breaks down if, for whatever reason - packet loss,
reordering or whatnot - server sends a second challenge that arrives
before the response - it changes client's expectation and the
authentication fails. Here's how it looks in the logs:
Mar 31 02:47:47 nbm pppd[13014]: rcvd [CHAP Challenge id=0x8a <5070251e94455e2155d2cf4d698d23c9>, name = "jeeves"]
Mar 31 02:47:47 nbm pppd[13014]: sent [CHAP Response id=0x8a <14d788f835add58b60d2aff362c183160000000000000000d780f3849076e9e013272f67bcb8c8cfa0e9b51c0fe3ee2100>, name = "murka"]
Mar 31 02:47:48 nbm pppd[13014]: rcvd [CHAP Challenge id=0x8a <5070251e94455e2155d2cf4d698d23c9>, name = "jeeves"]
Mar 31 02:47:48 nbm pppd[13014]: sent [CHAP Response id=0x8a <df950da43b90e235048810469d3283dd0000000000000000ace042b145f5eb9f118349b5672d4829eb5038192050a90b00>, name = "murka"]
Mar 31 02:47:48 nbm pppd[13014]: rcvd [CHAP Success id=0x8a "S=ABAEA4DF5601FADF25F8729455D39BF6D971D501 M=Access granted"]
Mar 31 02:47:48 nbm pppd[13014]: MS-CHAPv2 mutual authentication failed.
Paul Mackerras [Sun, 20 May 2012 06:48:17 +0000 (16:48 +1000)]
Remove old version of Linux if_pppol2tp.h
This has been in the Linux kernel source now for long enough that we
can rely on getting a usable version from /usr/include on all
distributions that we care about. The version we have here had started
to lag behind what is in the Linux kernel, causing compilation errors
due to struct pppol2tpv3_addr being undefined. Removing our local
version means we will use what is in /usr/include instead.
Paul Mackerras [Sun, 6 May 2012 07:32:26 +0000 (17:32 +1000)]
pppd: Don't unconditionally disable VJ compression under Linux
We were always clearing vjcomp if it was set, so VJ header compression
was never getting enabled. This adds a pair of braces so it only gets
disabled if there was an error.
Simon Arlott [Tue, 4 May 2010 19:06:06 +0000 (20:06 +0100)]
rp-pppoe: allow MTU to be increased up to 1500
The ethernet data limit on rp-pppoe has been increased to 1508 to
allow an MTU of 1500 to be used. To prevent problems the interface
MTU is checked and used to lower the configured MTU/MRU.
If MIN(MTU/MRU) is > 1492, PPP-Max-Payload is added to PADI and
PADR. If PPP-Max-Payload is received in PADO or PADS, it will be
used to lower the configured MTU/MRU as required.
The MTU/MRU settings are stored and reloaded whenever a connection
is made, to allow for the peer or interface MTU/MRU to increase if
used with persist option.
Conforming to RFC4638, if no PPP-Max-Payload is received, the
negotiated MRU will be limited to 1492.
James Carlson [Mon, 23 Aug 2010 14:03:07 +0000 (10:03 -0400)]
Fix quote handling in configuration files to be more like shell quoting.
The specific case that confused a user was:
ROUTES="216.220.192.0/20 10.0.100.0/24"
which was interpreted as two separate words, merely because the first quote
mark was in the middle of a word.
Paul Mackerras [Sun, 7 Mar 2010 05:54:00 +0000 (16:54 +1100)]
rp_pppoe: Copy acName and pppd_pppoe_service after option parsing
At present, the access concentrator name (acName) and service name
(pppd_pppoe_service) are set by option parsing, but are used at the
point of PPPOEInitDevice(), which gets called when the ethernet
device name is seen. So if the rp_pppoe_service or rp_pppoe_ac
options appear after the device name, they are ignored.
This fixes it by using acName and pppd_pppoe_service in
PPPOEConnectDevice, which gets called after all options have been
parsed.
Paul Mackerras [Sun, 7 Mar 2010 04:21:38 +0000 (15:21 +1100)]
pppd: Terminate correctly if lcp_lowerup delayed calling fsm_lowerup
Cameron Hutchison noticed that if pppd gets asked to terminate the
link in the period between when lcp_lowerup() is called and when
fsm_lowerup() is called from lcp_delayed_up() (i.e. when listen_time
is non-zero), pppd never exits.
The reason is that lcp_close() doesn't handle the delayed-up case
properly. Since the FSM is still in STOPPED state, we don't call
lcp_finished() and therefore never exit the main event loop.
This fixes it by handling the delayed-up case in lcp_close() as if
we had done the lowerup but the OPT_SILENT bit was set. We use the
silent case because we don't want to actually send a configure-request
at this point.
Paul Mackerras [Sun, 15 Nov 2009 06:08:20 +0000 (17:08 +1100)]
Specify the device name on the default route deletion
Some users have reported that pppd will delete a default route
through another device, for example if they bring up a ppp connection
with default route, then bring up an ethernet interface and set a
default route through that, then take down the ppp connection.
This fixes it, for Linux at least, by specifying the device name on
the default route deletion ioctl, which means that the kernel will
only delete default routes through that device.
Paul Mackerras [Fri, 23 Oct 2009 01:17:11 +0000 (12:17 +1100)]
Increase default IPCP Conf-Nak limit
Some 3G modems use IPCP Conf-Naks with the same values as we requested
as a way to delay the negotiation until they have contacted a server
over their radio network. This increases the default value for the
ipcp-max-failure option from 5 to 100 so that we don't give up too
easily when this is happening.
Marcus Better [Wed, 21 Oct 2009 01:52:59 +0000 (12:52 +1100)]
Accept ms-wins settings provided by server
The PPP servers of some UMTS/HSPA modems, including the Huawei E220
and E620, will send WINS server settings and insist that the client
accepts these. If the client does not do so, the modem will sometimes
provide bogus DNS server addresses like 10.11.12.13 and 10.11.12.14.
If we receive ms-wins settings from the server, save and include them
in our ConfReqs.
[paulus@samba.org: In fact what seems to happen is that the modem naks
IPCP conf-reqs with bogus values until it manages to communicate on the
network. It's not clear that asking for the ms-wins stuff is essential
but it seems that sometimes it helps.]
Signed-off-by: Marcus Better <marcus@better.se> Signed-off-by: Paul Mackerras <paulus@samba.org>
Paul Mackerras [Wed, 26 Nov 2008 10:02:29 +0000 (21:02 +1100)]
Fix authentication on second time around with multilink and persist
Frédéric Brière reported that when using multilink and persist, pppd
would fail to authenticate itself on the second and subsequent times
of bringing up a bundle. The reason was that the doing_multilink and
multilink_master flags never got reset when the first bundle was
destroyed. This adds lines to mp_bundle_terminated to do that.
Paul Mackerras [Sat, 6 Sep 2008 08:51:08 +0000 (18:51 +1000)]
Update ppp_available and the no_ppp_msg message
These days almost all Linux systems are going to be using the "new"
driver, i.e. the one that's been in the kernel since before 2.4.0.
This updates the message we print if the kernel doesn't seem to
support ppp to be more appropriate for the new driver.
Paul Mackerras [Sat, 6 Sep 2008 08:48:54 +0000 (18:48 +1000)]
Enable printing of MS-CHAP and MS-CHAPv2 auth options always
There's no need to have lcp_printpkt be ignorant of the MS-CHAP and
MS-CHAPV2 options. Even if pppd doesn't support those protocols,
it's still useful if lcp_printpkt can tell us that the peer is
asking for them. And it's one less ifdef this way.
Paul Mackerras [Tue, 19 Aug 2008 11:25:58 +0000 (21:25 +1000)]
Remove various warnings, fix pppol2tp install
This fixes a collection of minor things that were resulting in
harmless warnings (accidental trigraphs, missing prototypes,
signed/unsigned char being used interchangeably) and corrects
an error in the pppol2tp makefile, which meant that it wasn't
installing anything.
Paul Mackerras [Mon, 18 Aug 2008 12:21:18 +0000 (22:21 +1000)]
Remove more stuff that we don't need to distribute
This removes some files from include/linux that any halfway-modern
distro will have under /usr/include, and removes the stuff from the
linux/ directory that we haven't included in the tarballs for ages.
This also moves some MPPE macros from include/{linux,net}/ppp-comp.h
to a new pppd/mppe.h.
Paul Mackerras [Tue, 1 Jul 2008 12:27:56 +0000 (12:27 +0000)]
Clear hungup in start_link() instead of connect_tty()
Since hungup gets set in get_input(), which is generic, but only
cleared in connect_tty(), which is specific to the tty channel type,
other channel types were showing various problems on the second and
subsequent connections when the persist option was used. This fixes
it by clearing hungup in start_link() rather than connect_tty().
Paul Mackerras [Mon, 23 Jun 2008 12:27:39 +0000 (12:27 +0000)]
Remove send/recv_config_pppoa
Plugins have no business to be setting the ppp interface mtu.
The send/recv_config functions are only meant to set the channel
mtu/mru, not the ppp interface mtu/mru.
Paul Mackerras [Mon, 23 Jun 2008 11:47:18 +0000 (11:47 +0000)]
Only kill the whole process group if we have detached
Previously we always sent a signal to the whole of our current process
group when we got a signal such as SIGINT or SIGTERM. That's OK if
we have detached, because then we have our own process group, but not
if we haven't, because there might be other processes in our process
group that we don't know about. In the latter case we now just send
the signal individually to the child processes that we have forked off
to run things like the connect script, charshunt or pty command.
Paul Mackerras [Mon, 23 Jun 2008 11:44:06 +0000 (11:44 +0000)]
Flush the tty when welcomer or connector fails
This avoids having the tcsetsf and the close of the tty device block
for long periods waiting for output to drain, as can happen if for
instance the serial port is in CRTSCTS mode and CTS is negated.
Paul Mackerras [Sun, 15 Jun 2008 07:08:49 +0000 (07:08 +0000)]
Add L2TP support.
Patch from James Chapman.
This patch adds support for L2TP. It allows pppd to interface with the
pppol2tp driver in the Linux kernel. All data packets are handled by
the Linux kernel in order that the datapath be as efficient as
possible, while a userspace daemon implements the L2TP control
protocol, handling tunnel/session setup and teardown. The
implementation uses the PPPoX infrastructure; the architecture is
similar to PPPoE/PPPoATM in that a userspace daemon spawns a pppd
process per PPP session and uses a protocol-specific plugin to connect
pppd with the kernel.
The pppol2tp Linux kernel driver was integrated in the Linux kernel
from 2.6.23. For earlier kernels, an out of tree driver is available
from the pppol2tp-kmod package on the OpenL2TP project site at
http://sourceforge.net/projects/openl2tp.
Signed-off-by: James Chapman <jchapman@katalix.com>
Paul Mackerras [Sun, 15 Jun 2008 06:53:06 +0000 (06:53 +0000)]
Make pppd use blank username/password when explicitly specified
Patch from Jon Dubovsky.
Previously pppd would use its default strategies for working out a
username and password/secret to use if the user gave the empty string
to the user and/or password options. Now we set a flag when an
explicit username is given, and don't do the default username
calculation if the flag is set. Similarly for the password.
Paul Mackerras [Sun, 15 Jun 2008 04:35:50 +0000 (04:35 +0000)]
Add pppoe-mac option to rp-pppoe plugin
This allows the user to specify the MAC address of the pppoe
server that s/he wishes to use. With this option, pppd will
ignore PADO packets from any other MAC address.
Paul Mackerras [Mon, 9 Jun 2008 08:34:23 +0000 (08:34 +0000)]
Updates and fixes for the rp-pppoe plugin
1) Imported the good bits from the rp-pppoe-3.8 release. This plugin
was previously based on the 3.3 release.
2) Split apart the plugin from the pppoe-discovery program so that the
plugin could use pppd functions such as error() rather than things
like fprintf() and syslog().
3) Removed the stuff relating to DLPI and BPF, which isn't used on
Linux; this plugin only works on Linux, and Solaris uses something
quite different.
4) Added a PPPoE packet printer.
5) Removed several unused functions.
6) Instead of using bitfields for the 4-bit version and type fields
in PPPoE packet headers, use a single 8-bit field and define macros
to get the version and type fields out. This eliminates any
dependency on how the compiler lays out bitfields.
7) Sundry cleanups, such as removing unnecessary casts.
8) Last but by no means least, removed calls to exit() and die() so
that the plugin doesn't exit, but returns an error where appropriate,
so that the main pppd code can make the decisions about whether to
exit or not. (The plugin still exits if the specified interface is
not a suitable sort of interface.)
Paul Mackerras [Tue, 3 Jun 2008 12:06:37 +0000 (12:06 +0000)]
Minor tweaks to utils.c
Add a const qualifier to the prefix arg for init_pr_log, and
use OUTCHAR in a couple of places in vslprintf instead of
explicitly putting things in the buffer.
This fixes a bug where we didn't cancel a timeout in the radius code
when the link goes down, leaving us with duplicate timeouts if it
comes back up again. Bug report and patch from Richard Kojedzinszky.
Paul Mackerras [Mon, 26 May 2008 08:33:22 +0000 (08:33 +0000)]
Fix bug 1732 - using un-acked DNS settings
This fixes a bug where we could end up using DNS settings that
were requested but nacked or rejected. The problem was that ipcp_up
was only looking at go->dnsaddr, not at go->req_dns{1,2}.
Paul Mackerras [Wed, 26 Mar 2008 11:34:23 +0000 (11:34 +0000)]
Allow operation without an IP address for the peer
Under Linux, a point-to-point interface can operate without having
a destination IP address assigned to it, because routes can be
directed to the device rather than to a gateway IP address. Some
peers expect us to operate in this manner and refuse to give us
an IP address for them, so this adds a new `noremoteip' option that
tells pppd not to ask for the peer's IP address if the peer doesn't
supply it. There is also a `nosendip' option which tells pppd not
to supply its IP address -- mostly intended for testing.
Solaris requires a destination IP address, so the noremoteip option
is not included on Solaris.
Paul Mackerras [Wed, 26 Mar 2008 10:57:11 +0000 (10:57 +0000)]
Some MS-DNS changes: if the peer sends a conf-nak prompting us
to ask for MS-DNS1 or MS-DNS2, do so; and also fix the code that
prints packets - it was printing "ms-dns3" rather than "ms-dns2".
James Carlson [Wed, 30 Jan 2008 14:26:53 +0000 (14:26 +0000)]
Fixed uninitialized 'pw' variable in HAS_SHADOW logic in session.c due
to flaw in initial integration. Enabled HAS_SHADOW for Solaris, which
always has shadow password files. Fixed all of pppd to compile with gcc
-Wall on Solaris. (Still need fixes for kernel modules; blocking
Makedefs.gcc update.) Tested with and without PAM, with gcc and Sun's
cc.
James Carlson [Tue, 19 Jun 2007 02:08:35 +0000 (02:08 +0000)]
Added new "enable-session" option to enable session accounting and
logging without system-based authentication (works with all PPP
authentication types, including CHAP, unlike the "login" option), and
repaired misuse of wtmpx data in Solaris port.
Contributed by Diego Rivera <diego@rivera.net>.
Paul Mackerras [Tue, 19 Dec 2006 08:38:14 +0000 (08:38 +0000)]
Fix bug in CHAP MS v2 handling where we didn't zero enough.
Changing the response parameter of the ChapMS2 function to an
unsigned char * meant that using sizeof(*response) in a BZERO call
was no longer correct. Instead we need to use MS_CHAP2_RESPONSE_LEN.
Patch from Guillaume Knispel.
Paul Mackerras [Tue, 19 Dec 2006 07:48:19 +0000 (07:48 +0000)]
Fix problem with fd 0 getting closed unintentionally by closelog.
Patch from Alan Curry in
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=298582.
Basically, openlog was getting fd 0 for the log in some circumstances,
and safe_fork() was doing closelog after getting the desired stdin
dup'd to fd 0. This fixes it by doing the closelog a little earlier.
Paul Mackerras [Sun, 18 Jun 2006 11:26:00 +0000 (11:26 +0000)]
Restore original EUID rather than 0 during option processing.
When dropping and regaining privileges during option processing,
the seteuid to regain privileges is now the original EUID rather
than a constant zero. This means that `pppd --version' run without
root privilege prints the version number and exits rather than
giving an "unable to regain privileges" error.
Paul Mackerras [Sun, 4 Jun 2006 05:07:46 +0000 (05:07 +0000)]
Add $(INSTDIR) to installation paths in Linux makefiles.
Patch from Robert Vogelgesang.
This patch re-introduces the possibility for package maintainers to
install into a different filesystem tree. This is done by adding
$(INSTROOT) at various places; the package maintainers can then
issue a
make install INSTROOT=/some/where/else
when they package pppd for their distribution. In previous versions
of the ppp package this was possible using the variable DESTDIR, but
this variable is now used for a different purpose and cannot be
changed via additional parameters of the make command.
Paul Mackerras [Sun, 4 Jun 2006 03:52:50 +0000 (03:52 +0000)]
Fix snafu in run_program(). Patch from Robert Vogelgesang.
This patch splits out the major part of reap_kids() into a new
function, forget_child(), and calls this new function instead of
reap_kids() in run_program(), after having waitpid()'ed for a child.
Rationale:
The waitpid() at the start of reap_kids() has no chance to get the
PID of the child already waited for in run_program().
As a consequence, the PID of that child will stay in the list of all
children until the end of the pppd process, which is bad, because
pppd will then try to kill -TERM that PID (and might kill some
innocent third party at this point).
Paul Mackerras [Mon, 29 May 2006 23:29:16 +0000 (23:29 +0000)]
Remove name checks in the rp-pppoe plugin PPPoEDevnameHook function.
Based on a patch from Alin Nastac. I also made the function only
set the device name and initialize the channel if `doit' is set.