pppdump: Fix printfs with insufficient arguments

Reported-by: Dan Wallis <mrdanwallis@gmail.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
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.

Reported by Stanislav Litvinenko.

Signed-off-by: Paul Mackerras <paulus@samba.org>
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.

Signed-off-by: Paul Mackerras <paulus@samba.org>
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.

Signed-off-by: Paul Mackerras <paulus@samba.org>
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.

Signed-off-by: Paul Mackerras <paulus@samba.org>
rp-pppoe plugin: Print leading zeros in MAC address

The rp-pppoe pppd plugin prints MAC addresses without the leading 0.
That looks odd, so this adds the leading 0.

Signed-off-by: Benjamin LaHaise <bcrl@kvack.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
pppd: Notify IPv6 up/down as we do for IPv4

This adds support for notification of IPv6 up/down, mainly for the sake of
NetworkManager.

Signed-off-by: Paul Mackerras <paulus@samba.org>
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]

Signed-off-by: Paul Mackerras <paulus@samba.org>
contrib: Fix pppgetpass.gtk compilation

We need to use pkg-config not gtk-config these days.

Signed-off-by: Paul Mackerras <paulus@samba.org>
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>
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]

Signed-off-by: Paul Mackerras <paulus@samba.org>
rp-pppoe plugin: Import some fixes from rp-pppoe-3.10

* Make timeout for PADO/PADS be the total time we wait for, not the
  time that each individual select call waits for.

* Open the discovery socket in PPPOEConnectDevice() rather than
  discovery().

* Open the session socket earlier in PPPOEConnectDevice() to avoid
  missing session packets sent by the server just after the PADS
  packet.

Signed-off-by: Paul Mackerras <paulus@samba.org>
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>
ppp: ignore unrecognised radiusclient configuration directives

New versions of freeradius occasionally add configuration keywords.
There's no reason that the pppd plugin should fail when that occurs.

Signed-off-by:  Charlie Brady <charlieb@budge.apana.org.au>
Signed-off-by: Paul Mackerras <paulus@samba.org>
pppd: Take out unused %r conversion completely

This just removes some code surrounded by #if 0/#endif, which Fedora
apparently feels the need to patch...

Signed-off-by: Paul Mackerras <paulus@samba.org>
pppd: Arrange to use logwtmp from libutil on Linux

Idea stolen from Fedora ppp patches.

Signed-off-by: Paul Mackerras <paulus@samba.org>
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.

Signed-off-by: Paul Mackerras <paulus@samba.org>
chat: Correct spelling errors in the man page

From Fedora patch.

Signed-off-by: Paul Mackerras <paulus@samba.org>
pppd: Fix spelling errors in man page

From Fedora patch.

Signed-off-by: Paul Mackerras <paulus@samba.org>
plugins/passprompt: Fix potential out-of-bounds array reference

From Debian BTS, fix suggested by Timo Weingärtner.

Signed-off-by: Paul Mackerras <paulus@samba.org>