]> git.ozlabs.org Git - ppp.git/log
ppp.git
2 years agoSetting version to 2.4.10-dev per request of Neustradamus
Eivind Næss [Wed, 21 Jul 2021 15:54:41 +0000 (08:54 -0700)]
Setting version to 2.4.10-dev per request of Neustradamus

Signed-off-by: Eivind Næss <eivnaes@yahoo.com>
2 years agoUpdating .gitignore files
Eivind Næss [Tue, 20 Jul 2021 16:21:10 +0000 (09:21 -0700)]
Updating .gitignore files

Signed-off-by: Eivind Næss <eivnaes@yahoo.com>
2 years agoRemove obsolete Makefile(s) and configure scripts
Eivind Næss [Tue, 20 Jul 2021 16:20:04 +0000 (09:20 -0700)]
Remove obsolete Makefile(s) and configure scripts

Signed-off-by: Eivind Næss <eivnaes@yahoo.com>
2 years agoRemoving dead code per review by James Carlson
Eivind Næss [Tue, 20 Jul 2021 08:19:39 +0000 (01:19 -0700)]
Removing dead code per review by James Carlson

Signed-off-by: Eivind Næss <eivnaes@yahoo.com>
2 years agoFixing up libpcap configure option on SunOS
Eivind Næss [Tue, 20 Jul 2021 08:18:23 +0000 (01:18 -0700)]
Fixing up libpcap configure option on SunOS

Re-introducing the Automake WITH_FILTER to separate the detection
of libpcap. SunOS has a viable libpcap, but does not support the
filter feature.

Signed-off-by: Eivind Næss <eivnaes@yahoo.com>
2 years agoIncorporating review feedback from David Seifert.
Eivind Næss [Sat, 17 Jul 2021 20:35:58 +0000 (13:35 -0700)]
Incorporating review feedback from David Seifert.

Signed-off-by: Eivind Næss <eivnaes@yahoo.com>
2 years agoUpdated Buildroot CI to make it work with autotools.
RICCIARDI-Adrien [Sat, 17 Jul 2021 07:19:55 +0000 (09:19 +0200)]
Updated Buildroot CI to make it work with autotools.

2 years agoCompiling with clang encounters an error in eap-tls.c
Eivind Næss [Sun, 11 Jul 2021 21:36:44 +0000 (14:36 -0700)]
Compiling with clang encounters an error in eap-tls.c

This moves the inline functions to outside the function and declares them static.

Signed-off-by: Eivind Næss <eivnaes@yahoo.com>
2 years agoUse autoconf/automake to configure and make ppp
Eivind Næss [Thu, 24 Jun 2021 23:07:26 +0000 (16:07 -0700)]
Use autoconf/automake to configure and make ppp

This change brings in autoconf/automake scripts to configure the ppp project. Current change doesn't eliminate the previous build system, but the new script autogen.sh will overwrite configure, and generate the basic Makefile.in and Makefile files.

Features can now be enabled by command line:

  * Microsoft Extensions,
    - MSCHAP
    - MPPE
    - MS LAN Manager support
  * IPXCP protocol
  * CBCP protocol
  * PAM support
  * EAP-TLS support
  * EAP-SRP support
  * Max session lifetime by byte count
  * Plugins
  * Packet activity filter support
  * Multilink
  * IPv6 support

Control linkage with
  * OpenSSL (-lssl -lcrypto)
  * systemd (-lsystemd)
  * libatm (-latm)
  * libsrp (-lsrp)
  * pam (-lpam)

Also, the configure script is made sensitive to features of OpenSSL. Like the presence or absence of DES, SHA, MD4 and MD5 crypto support. In the cases where either of these are missing, the support will be directly compiled into pppd and plugins.

In addition, package maintainers can now control the installation paths with standard --prefix=, or --localstatedir=, or --sysconfdir= to configure. On top of that, they can now control the following directories:
  * runtime directory w/--with-runtime-dir
  * logfile directory w/--with-logfile-dir
  * plugin directory w/--with-plugin-dir

In the case where automake isn't the right solution, namely: SunOS kernel module build, the original Makefile infrastructure is preserved and reused.

Care was taken to only cosmetically touchup the source files in this change. This means:
  * Insert HAVE_CONFIG_H and include config.h in all .c files.
  * Change HAS_SHADOW to HAVE_SHADOW_H
  * Change HAVE_LOGWTMP to HAVE_UTMP_H
  * Introduce HAVE_CRYPT_H into the source code where appropriate
  * Added ifdef MPPE where appropriate
  * USE_SRP required a few changes as it didn't compile
  * Touchup some compile warning in pppstats directory on SunOS

Introduced a new pppdconf.h file that exports the appropriate defines to a module that wants to provide a module that pppd can dynamically load. This will define/undef features like MPPE, CHAPMS such that the project doesn't have to guess what features pppd is compiled with.

Signed-off-by: Eivind Næss <eivnaes@yahoo.com>
2 years agochat: Clean up usage of clean() function
Paul Mackerras [Mon, 19 Jul 2021 07:41:09 +0000 (17:41 +1000)]
chat: Clean up usage of clean() function

In a couple of places, we were calling clean(), which does environment
variable substitution among other things, but then using the original
string not the "cleaned" string when logging a message about what
we're doing.

Also, this removes a couple of checks that the "cleaned" string is not
longer than the original string, which date back to the first version
of the code checked into CVS.  Those checks were appropriate before
environment variable substitution was added in commit eaca954c2d4a
("add -E option to use environment variables, from Andreas Arens") and
dynamic reallocation of the result buffer was added in commit
86dd2eec100d ("clean(): Fix buffer overflow.") but are no longer
necessary.

These changes were prompted by github issue #294 and redhat bugzilla
https://bugzilla.redhat.com/show_bug.cgi?id=1650539

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
2 years agoplugins/radius: Add RFC8044 dictionary compatibility for IPv4 address (#291)
Adrian [Fri, 16 Jul 2021 09:24:13 +0000 (12:24 +0300)]
plugins/radius: Add RFC8044 dictionary compatibility for IPv4 address (#291)

This patch adds ipv4addr RADIUS data type compatible with RFC8044.
New dictionaries from RADIUS is using ipv4addr instead of old
ipaddr data type. This patch is avoiding modification of RADIUS
dictionaries to be compatible with PPP.

Signed-off-by: Adrian Ban <devel@easynet.dev>
2 years agoAdd option to ask peer for WINS address
Mike Frysinger [Fri, 3 Jan 2020 16:19:40 +0000 (17:19 +0100)]
Add option to ask peer for WINS address

Signed-off-by: Michael Everitt <gentoo@veremit.xyz>
Signed-off-by: Lars Wendler <polynomial-c@gentoo.org>
2 years agoplugins/radius: Use snprintf in rc_mksid
Paul Mackerras [Sat, 10 Jul 2021 00:29:55 +0000 (10:29 +1000)]
plugins/radius: Use snprintf in rc_mksid

Commit 858976b1fc31 ("radius: Prevent buffer overflow in rc_mksid()")
changed sprintf to slprintf to avoid a possible buffer overflow.
However, this introduced a bug because slprintf does not currently
handle the %lX and %hX formats.  Use snprintf instead, which does, as
we are not using any of the custom formats that slprintf handles in
this instance.

Reported-by: Adrian Ban <devel@easynet.dev>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
2 years agoipv6cp: Fix enforcing local and peer non-random IPv6 interface identifiers (#283)
pali [Sat, 19 Jun 2021 01:03:14 +0000 (03:03 +0200)]
ipv6cp: Fix enforcing local and peer non-random IPv6 interface identifiers (#283)

In some cases peer may reject our local IPv6 identifier or may send to us
IPV6CP request without any IPv6 identifier or send empty IPv6 identifier
(asking as to generate some identifier for him).

In these special cases pppd always generated some new random IPv6
identifier and completely ignored the fact that user may already specified
IPv6 link local address (used for IPv6 identifier) either at command line
or in config file.

So properly check pppd options and generate new random IPv6 identifier only
in case user did not supply any IPv6 link local address.

If pppd was configured to not allow random identifiers and peer rejected
our enforced identifiers then pppd connection should be terminated.

Signed-off-by: Pali Rohár <pali@kernel.org>
2 years agoipv6cp: Fix ipv6cp-accept-local and ipv6cp-accept-remote options (#282)
pali [Sat, 19 Jun 2021 01:02:37 +0000 (03:02 +0200)]
ipv6cp: Fix ipv6cp-accept-local and ipv6cp-accept-remote options (#282)

These options are completely broken and ignored because pppd reflects these
options in the incorrect struct ipv6cp_allowoptions. Instead pppd expects
that these options are reflected in struct ipv6cp_wantoptions. Same applies
also for IPv4 code where these options are reflected in struct wantoptions.

This issue can be tested and verified by following command:

    ./pppd noauth asyncmap 0 default-asyncmap novj noaccomp nopcomp nodeflate nobsdcomp nomagic  local nolock nodetach  noip  ipv6 ::2,::1 ipv6cp-accept-local ipv6cp-accept-remote  debug pty "./pppd noauth asyncmap 0 default-asyncmap novj noaccomp nopcomp nodeflate nobsdcomp nomagic  local nolock nodetach  noip  ipv6 ::1:1,::1:2  notty"

First pppd prefer to use IPv6 addresses ::2 and ::1 but accept also any
address suggested by second pppd. Second pppd allows usage only of IPv6
addresses ::1:1 and ::1:2 and does not accept any suggestion by first pppd.

Without this patch first pppd show this output:

    sent [IPV6CP ConfReq id=0x1 <addr fe80::0000:0000:0000:0002>]
    rcvd [IPV6CP ConfReq id=0x1 <addr fe80::0000:0000:0001:0001>]
    sent [IPV6CP ConfNak id=0x1 <addr fe80::0000:0000:0000:0001>]
    rcvd [IPV6CP ConfNak id=0x1 <addr fe80::0000:0000:0001:0002>]
    sent [IPV6CP ConfReq id=0x2 <addr fe80::0000:0000:0000:0002>]
    rcvd [IPV6CP ConfReq id=0x2 <addr fe80::0000:0000:0001:0001>]
    sent [IPV6CP ConfAck id=0x2 <addr fe80::0000:0000:0001:0001>]
    rcvd [IPV6CP ConfAck id=0x2 <addr fe80::0000:0000:0000:0002>]
    local  LL address fe80::0000:0000:0000:0002
    remote LL address fe80::0000:0000:0001:0001

Which means that second pppd did not forced its IPv6 address assignment.

With applying this patch first pppd show output:

    sent [IPV6CP ConfReq id=0x1 <addr fe80::0000:0000:0000:0002>]
    rcvd [IPV6CP ConfReq id=0x1 <addr fe80::0000:0000:0001:0001>]
    sent [IPV6CP ConfAck id=0x1 <addr fe80::0000:0000:0001:0001>]
    rcvd [IPV6CP ConfNak id=0x1 <addr fe80::0000:0000:0001:0002>]
    sent [IPV6CP ConfReq id=0x2 <addr fe80::0000:0000:0001:0002>]
    rcvd [IPV6CP ConfAck id=0x2 <addr fe80::0000:0000:0001:0002>]
    local  LL address fe80::0000:0000:0001:0002
    remote LL address fe80::0000:0000:0001:0001

And now first pppd accepted offer from second pppd, meaning that both
ipv6cp-accept-local and ipv6cp-accept-remote are working.

Signed-off-by: Pali Rohár <pali@kernel.org>
2 years agoipv6cp: Fix enforcing peer IPv6 interface identifier (#281)
pali [Sat, 19 Jun 2021 01:01:58 +0000 (03:01 +0200)]
ipv6cp: Fix enforcing peer IPv6 interface identifier (#281)

Enforcing peer IPv6 interface identifier is broken in the same way as it
was broken for peer IPv4 address prior commit 9fe8923419a9 ("pppd: Fix
enforcing peer IP address").

IPv6 test case:

    ./pppd noauth asyncmap 0 default-asyncmap novj noaccomp nopcomp nodeflate nobsdcomp nomagic  local nolock nodetach  noip  ipv6 ::2,::1  debug pty "./pppd noauth asyncmap 0 default-asyncmap novj noaccomp nopcomp nodeflate nobsdcomp nomagic  local nolock nodetach  noip  ipv6 ::1:1,::1:2  notty"

Without this patch output from first pppd is:

    sent [IPV6CP ConfReq id=0x5 <addr fe80::0000:0000:0000:0002>]
    rcvd [IPV6CP ConfReq id=0x5 <addr fe80::0000:0000:0001:0001>]
    sent [IPV6CP ConfNak id=0x5 <addr fe80::0000:0000:0000:0001>]
    rcvd [IPV6CP ConfNak id=0x5 <addr fe80::0000:0000:0001:0002>]
    sent [IPV6CP ConfReq id=0x6]
    rcvd [IPV6CP ConfReq id=0x6]
    sent [IPV6CP ConfAck id=0x6]
    rcvd [IPV6CP ConfAck id=0x6]
    local  LL address fe80::0000:0000:0000:0002
    remote LL address fe80::0000:0000:0000:0001

And system configured IPv6 addresses as:

    124: ppp0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 3
        link/ppp
        inet6 fe80::2 peer fe80::1/128 scope link nodad
           valid_lft forever preferred_lft forever
    125: ppp1: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 3
        link/ppp
        inet6 fe80::1:1 peer fe80::1:2/128 scope link nodad
           valid_lft forever preferred_lft forever

So both pppd use different IPv6 LL addresses and therefore IPv6 connection
is totally broken between these pppd instances.

With this patch output from first pppd is:

    sent [IPV6CP ConfReq id=0x5 <addr fe80::0000:0000:0000:0002>]
    rcvd [IPV6CP ConfReq id=0x5 <addr fe80::0000:0000:0001:0001>]
    sent [IPV6CP ConfNak id=0x5 <addr fe80::0000:0000:0000:0001>]
    rcvd [IPV6CP ConfNak id=0x5 <addr fe80::0000:0000:0001:0002>]
    sent [IPV6CP ConfReq id=0x6]
    rcvd [IPV6CP ConfReq id=0x6]
    sent [IPV6CP ConfAck id=0x6]
    rcvd [IPV6CP ConfAck id=0x6]
    Peer refused to agree to his interface identifier
    sent [IPV6CP TermReq id=0x7 "Refused his interface identifier"]
    rcvd [IPV6CP TermReq id=0x7 "Refused his interface identifier"]
    sent [IPV6CP TermAck id=0x7]
    rcvd [IPV6CP TermAck id=0x7]
    sent [LCP TermReq id=0x2 "No network protocols running"]
    rcvd [LCP TermAck id=0x2]
    Connection terminated.
    Connect time 0.0 minutes.
    Sent 148 bytes, received 148 bytes.

Now pppd correctly detected that IPv6 interface identifiers negotiation
failed and closed IPv6 connection.

Signed-off-by: Pali Rohár <pali@kernel.org>
2 years agopppd: Allow users to use Engine and ID strings unmodified to the OpenSSL engine ...
Eivind Næss [Sat, 19 Jun 2021 01:01:34 +0000 (18:01 -0700)]
pppd: Allow users to use Engine and ID strings unmodified to the OpenSSL engine (#280)

This change allows users to specify "cert" and "key" arguments where the prefix
leading up to the ':' indicates the engine e.g. pkcs11, the entire string is
passed down to the engine library which does the parsing. In the case of
pkcs11.so (OpenSC project's libp11) engine for OpenSSL, it will now correctly
parse the PKCS11 URI string (See RFC7512).

Signed-off-by: Eivind Næss <eivnaes@yahoo.com>
2 years agopppd: Fix vslprintf %ld for negative values (#279)
Maks Naumov [Mon, 7 Jun 2021 11:13:42 +0000 (14:13 +0300)]
pppd: Fix vslprintf %ld for negative values (#279)

'val' is unsigned so condition 'val < 0' is always false
fix it by adding signed long variable.

Signed-off-by: Maks Naumov <maksqwe1@ukr.net>
2 years agopppd: Set restore_term at correct place (#284)
pali [Mon, 7 Jun 2021 11:11:43 +0000 (13:11 +0200)]
pppd: Set restore_term at correct place (#284)

After successful call to tcsetattr/TCSAFLUSH it is needed to restore
terminal at the end. So set restore_term variable at correct place. Fixes
issue that fatal() call after tcsetattr/TCSAFLUSH does not restore terminal
settings.

Signed-off-by: Pali Rohár <pali@kernel.org>
2 years agopppd: Add support for arbitrary baud rates via BOTHER on Linux (#278)
pali [Sat, 5 Jun 2021 01:43:24 +0000 (03:43 +0200)]
pppd: Add support for arbitrary baud rates via BOTHER on Linux (#278)

Most Linux architectures and drivers support arbitrary baud rate BOTHER
values via TCGETS2 and TCSETS2 ioctls in struct termios2.

This patch implements support for BOTHER and struct termios2 which allows
pppd to use any baud rate on Linux systems where architecture and drivers
have support for it.

By default standard values are used.

Support for BOTHER is enabled during compilation when header files have
appropriate definitions of TCGETS2 and TCSETS2 ioctls.

Because there is no glibc support for BOTHER and struct termios2 yet, pppd
defines own BOTHER macro and struct termios2.

Signed-off-by: Pali Rohár <pali@kernel.org>
2 years agopppd: Support for use of PKCS12 certificates (#264)
Eivind Næss [Sat, 5 Jun 2021 01:30:16 +0000 (18:30 -0700)]
pppd: Support for use of PKCS12 certificates (#264)

This implements the ability to specify the option 'pkcs12' to allow
users to provide a PKCS12 formatted file as user credentials.

Signed-off-by: Eivind Naess <eivnaes@yahoo.com>
3 years agopppd: Expose the MPPE keys generated through an API (#267)
Eivind Næss [Sat, 24 Apr 2021 10:00:34 +0000 (03:00 -0700)]
pppd: Expose the MPPE keys generated through an API (#267)

The lengthy part of this fix is to refactor the handling of MPPE keys
by moving it into mppe.c and thus reducing the clutter in chap_ms.c.
It does so by renaming the mppe_set_keys/2 to the corresponding
mppe_set_chapv1/mppe_set_chapv2 versions and updates callers of these
functions.

Having done so, it conveniently allows the name "mppe_set_keys" to be
re-used for this new purpose which will copy the key material up to
its size and then clear the input parameters (avoids leaving the MPPE
keys on the stack).

Additional functiions added to the MPPE code allow plugins et al. to
access the MPPE keys, clear the keys, and check if they are set. All
plugin and CCP code has been updated to use this API.

This fixes GitHub Issue #258

Signed-off-by: Eivind Naess <eivnaes@yahoo.com>
3 years agoAdd pkgconfig support to PPP project (#270)
Eivind Næss [Sat, 24 Apr 2021 05:26:06 +0000 (22:26 -0700)]
Add pkgconfig support to PPP project (#270)

This adds pppd.pc into $(INSTROOT)/$(LIBDIR)/pkgconfig. On some distributions
this would be /lib/pkgconfig, or /usr/lib/pkgconfig, but other distributions
may consider specifying --libdir=/usr/lib/x86_x64-linux-gnu/ and the pkgconfig
directory would be under that. Allowing --libdir to be specified at configure
time fixes #223, providing pkgconfig support fixes #19 and allows third party
packages pickup the plugin directory.

Manually cherry picking parts of two commits by @lkundrak from:
    https://github.com/NetworkManager/ppp/tree/lr/pkgconfig

Mainly, the difference between the original commit is not to replace DESTDIR
with "prefix". Leave DESTDIR alone, and add needed pkgconfig (pppd.pc.in)
as a part of the linux distribution (previously in pppd/plugin directory).

This fixes GitHub issues: #19 #47 and #223

Signed-off-by: Eivind Naess <eivnaes@yahoo.com>
3 years agopppd: Allow building of EAP-TLS code when OPENSSL_NO_ENGINE is set. (#273)
jjkeijser [Thu, 22 Apr 2021 22:31:19 +0000 (00:31 +0200)]
pppd: Allow building of EAP-TLS code when OPENSSL_NO_ENGINE is set. (#273)

Signed-off-by: Jan Just Keijser <jan.just.keijser@gmail.com>
3 years agopppd: Fix SIGSEGV in EAP-TLS code when TLS verify method is not specified
Eivind Næss [Sun, 11 Apr 2021 23:31:02 +0000 (16:31 -0700)]
pppd: Fix SIGSEGV in EAP-TLS code when TLS verify method is not specified

Make sure the tls_verify_method variable has a default value. Also, fix up the
README.eap-tls documentation for the new options.

Fixes github issue #268.

Signed-off-by: Eivind Naess <eivnaes@yahoo.com>
3 years agopppd: Fix logical error in comparing valid encryption policies (#262)
Eivind Næss [Sun, 14 Mar 2021 23:20:29 +0000 (16:20 -0700)]
pppd: Fix logical error in comparing valid encryption policies (#262)

RFC2548 describes the proper values of the MS-MPPE-Encryption-Policy attribute.
and it can only hold 2 values: 1 (encryption allowed) and 2 (encryption required).

See
   https://tools.ietf.org/html/rfc2548, section 2.4.4

The correct comparison should be made with an && and not a ||.

This fixes github issue #218

Signed-off-by: Eivind Naess <eivnaes@yahoo.com>
3 years agopppd: EAP-TLS: Verify Subject or CommonName by suffix (#261)
Eivind Næss [Sun, 14 Mar 2021 23:17:41 +0000 (16:17 -0700)]
pppd: EAP-TLS: Verify Subject or CommonName by suffix (#261)

This feature matches closely what OpenVPN and the network-manager-openvpn plugin do for
certificate verification. It allows the end user to configure the certificate to be matched by
its common name (entire string), its subject name, or the suffix of a subject name.
The latter is especially useful if you are trying to match against a random server in a RADIUS
pool. Lastly, it also allows you to turn off the certificate matching altogether.

tls-verify-method can have the following parameter values:
- none
- subject   - The entire subject, e.g. /CN=some.server.org
- name      - The entire common name, e.g. some.server.org
- suffix    - The latter part of a name, e.g. servers.org

Secondly, it also introduces a new parameter 'tls-verify-key-usage' which permits checking
of the 'server' or 'client' side attributes of nsCertType and X509 extended key attributes.
For example, in client mode, it will verify that received certificate has the 'server' side
attributes enabled.

Signed-off-by: Eivind Naess <eivnaes@yahoo.com>
3 years agopppd: Fix cross-compilation using Clang (#253)
10ne1 [Sun, 14 Mar 2021 23:11:35 +0000 (01:11 +0200)]
pppd: Fix cross-compilation using Clang (#253)

Clang does not have the --print-sysroot option so the shell
snippet silently fails leading to "-I/usr/include/openssl".
Thankfully systems like Gentoo/portage or Yocto/bitbake enable
sysroot poisoning precisely to catch these kinds of bugs.

There is only one user of this non-standard CFLAG include in
pppcrypt.h, so make it consistent with the rest of the sources
(eg. see eap-tls.[h|c] openssl/* includes) and drop the fragile
sysroot hackery.

Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
3 years agoMerge pull request #254 from pali/ipv6-rtnetlink
Paul Mackerras [Fri, 26 Feb 2021 04:58:01 +0000 (15:58 +1100)]
Merge pull request #254 from pali/ipv6-rtnetlink

pppd: Fix and clean up code for setting Linux IPv6 addresses

3 years agopppd: defaultroute6 is not frequent option and should not be used (#257)
pali [Fri, 26 Feb 2021 04:44:19 +0000 (05:44 +0100)]
pppd: defaultroute6 is not frequent option and should not be used (#257)

In pppd.8 manpage, move defaultroute6 option from FREQUENTLY USED OPTIONS
into OPTIONS, and add a warning that this option should not be needed or
used on IPv6 networks. Option defaultroute6 is needed only for broken IPv6
networks. Also add nodefaultroute6 into sample options file.

Signed-off-by: Pali Rohár <pali@kernel.org>
3 years agopppd: Define request and response rtnetlink IPv6 structures
Pali Rohár [Sat, 16 Jan 2021 21:50:27 +0000 (22:50 +0100)]
pppd: Define request and response rtnetlink IPv6 structures

This simplify understanding of rtnetlink IPv6 API. Also it simplify
code for filling rtnetlink IPv6 address request message and reading
rtnetlink response message as it avoids usage of pointer arithmetic.

Signed-off-by: Pali Rohár <pali@kernel.org>
3 years agopppd: Set local and remote IPv6 addresses by one call
Pali Rohár [Sun, 10 Jan 2021 18:46:07 +0000 (19:46 +0100)]
pppd: Set local and remote IPv6 addresses by one call

Currently local IPv6 address is set by SIOCSIFADDR ioctl and remote peer
address is appended by rtnetlink RTM_NEWADDR/NLM_F_REPLACE call. For
RTM_NEWADDR/NLM_F_REPLACE call it is needed to specify both local + remote
addresses as local address is used for matching to which address needs to
be remote peer address appended. When issuing this call kernel first
removes currently configured local address and then inserts a new pair of
local + remote addresses.

Simplify whole setup by just one rtnetlink RTM_NEWADDR/NLM_F_CREATE call by
inserting pair of local + remote addresses atomically. Therefore calling
SIOCSIFADDR ioctl for local IPv6 address is not used or needed anymore.

Signed-off-by: Pali Rohár <pali@kernel.org>
3 years agopppd: Disable Duplicate Address Detection for IPv6 peer address
Pali Rohár [Sun, 10 Jan 2021 18:09:25 +0000 (19:09 +0100)]
pppd: Disable Duplicate Address Detection for IPv6 peer address

IPv6 link-local addresses are negotiated via IPV6CP and therefore are
unique and not duplicate. Doing additional Duplicate Address Detection
is redundant and not needed, so disable it.

Signed-off-by: Pali Rohár <pali@kernel.org>
3 years agopppd: Fix setting flags of IPv6 peer address
Pali Rohár [Sun, 10 Jan 2021 17:51:23 +0000 (18:51 +0100)]
pppd: Fix setting flags of IPv6 peer address

Address is link-local (not globaly routable) and is permanent (not dynamic
from stateless address configuration).

Signed-off-by: Pali Rohár <pali@kernel.org>
3 years agopppd: Fix compilation with older glibc or kernel headers (#248)
pali [Mon, 15 Feb 2021 06:54:01 +0000 (07:54 +0100)]
pppd: Fix compilation with older glibc or kernel headers (#248)

glibc versions prior to 2.24 do not define SOL_NETLINK and linux kernel
versions prior to 4.3 do not define NETLINK_CAP_ACK. So add fallback
definitions for these macros into pppd/sys-linux.c file.

Also extend description why we call SOL_NETLINK/NETLINK_CAP_ACK option.

Signed-off-by: Pali Rohár <pali@kernel.org>
3 years agoMerge pull request #230 from tisj/eap-mschapv2-refactor
Paul Mackerras [Tue, 26 Jan 2021 03:14:42 +0000 (14:14 +1100)]
Merge pull request #230 from tisj/eap-mschapv2-refactor

EAP mschapv2 refactoring

3 years agoipv6cp: Fix ipv6cp-use-persistent option when remote address is specified (#246)
pali [Tue, 26 Jan 2021 02:58:45 +0000 (03:58 +0100)]
ipv6cp: Fix ipv6cp-use-persistent option when remote address is specified (#246)

Option ipv6cp-use-persistent affects only local interface identifier (local
link-local address). It does not affects remote peer interface identifier
(and remote link-local address) therefore ipv6cp-use-persistent option
should not depend on remote address.

Signed-off-by: Pali Rohár <pali@kernel.org>
3 years agopppd: Document LLLOCAL and LLREMOTE environment variables (#240)
pali [Tue, 26 Jan 2021 02:58:07 +0000 (03:58 +0100)]
pppd: Document LLLOCAL and LLREMOTE environment variables (#240)

Signed-off-by: Pali Rohár <pali@kernel.org>
3 years agoipv6cp: Fix ipv6cp-use-persistent option (#239)
pali [Tue, 26 Jan 2021 02:57:38 +0000 (03:57 +0100)]
ipv6cp: Fix ipv6cp-use-persistent option (#239)

There is incorrect logic in ether_to_eui64() function. Persistent id cannot
be found when both sources of persistent id fails, not just one.

This fixes ipv6cp-use-persistent option for non-ethernet PPP connections.

Fixes: 952cfa5acc41ad4ceee160420a188a388bb340cf
Signed-off-by: Pali Rohár <pali@kernel.org>
3 years agoMerge pull request #238 from pali/ipv6cp-demand
Paul Mackerras [Tue, 26 Jan 2021 02:57:00 +0000 (13:57 +1100)]
Merge pull request #238 from pali/ipv6cp-demand

ipv6cp: Fix demand mode for IPv6

3 years agopppd: Negotiate IP address when only peer addresses are provided (#236)
pali [Tue, 26 Jan 2021 02:55:25 +0000 (03:55 +0100)]
pppd: Negotiate IP address when only peer addresses are provided (#236)

This fixes special case when both ppp ends are configured to send only IP
address of other side and do not send its own IP address. Such setup is
correct because both ends can exchange its IP addresses and therefore they
have full information, they known both local and remote address.

This issue can be triggered by calling pppd with arguments:

    ./pppd debug local noauth nolock nodetach asyncmap 0 default-asyncmap novj noaccomp nopcomp nodeflate nobsdcomp nomagic noipv6 noipdefault nosendip :10.0.0.1 pty "./pppd debug local noauth nolock nodetach asyncmap 0 default-asyncmap novj noaccomp nopcomp nodeflate nobsdcomp nomagic noipv6 nosendip nodefaultroute :10.0.0.2 notty"

Without this patch IP addresses are not exchanges at all and pppd fails:

    rcvd [LCP ConfReq id=0x1]
    sent [LCP ConfReq id=0x1]
    sent [LCP ConfAck id=0x1]
    rcvd [LCP ConfAck id=0x1]
    sent [LCP EchoReq id=0x0 magic=0x0]
    sent [IPCP ConfReq id=0x1]
    rcvd [LCP EchoReq id=0x0 magic=0x0]
    sent [LCP EchoRep id=0x0 magic=0x0]
    rcvd [IPCP ConfReq id=0x1]
    sent [IPCP ConfAck id=0x1]
    rcvd [LCP EchoRep id=0x0 magic=0x0]
    rcvd [IPCP ConfAck id=0x1]
    Could not determine local IP address

After applying this patch exchanging of IP addresses is working fine:

    rcvd [LCP ConfReq id=0x1]
    sent [LCP ConfReq id=0x1]
    sent [LCP ConfAck id=0x1]
    rcvd [LCP ConfAck id=0x1]
    sent [LCP EchoReq id=0x0 magic=0x0]
    sent [IPCP ConfReq id=0x1]
    rcvd [LCP EchoReq id=0x0 magic=0x0]
    sent [LCP EchoRep id=0x0 magic=0x0]
    rcvd [IPCP ConfReq id=0x1]
    sent [IPCP ConfNak id=0x1 <addr 10.0.0.1>]
    rcvd [LCP EchoRep id=0x0 magic=0x0]
    rcvd [IPCP ConfNak id=0x1 <addr 10.0.0.2>]
    sent [IPCP ConfReq id=0x2 <addr 10.0.0.2>]
    rcvd [IPCP ConfReq id=0x2 <addr 10.0.0.1>]
    sent [IPCP ConfAck id=0x2 <addr 10.0.0.1>]
    rcvd [IPCP ConfAck id=0x2 <addr 10.0.0.2>]
    local  IP address 10.0.0.2
    remote IP address 10.0.0.1

Signed-off-by: Pali Rohár <pali@kernel.org>
3 years agopppd: Fix enforcing peer IP address (#235)
pali [Tue, 26 Jan 2021 02:53:59 +0000 (03:53 +0100)]
pppd: Fix enforcing peer IP address (#235)

If peer address is specified and ipcp-accept-remote is not set then peer
address is enforced.

But there is bug in pppd which allows peer to not use supplied address when
it reply with empty IPCP ConfReq. In this case pppd thinks that peer
accepted its idea of remote/peer address even it is not truth.

This issue can be reproduced by running pppd with arguments:

    ./pppd debug local noauth nolock nodetach asyncmap 0 default-asyncmap novj noaccomp nopcomp nodeflate nobsdcomp nomagic noipv6 noipdefault :10.1.0.1 pty "./pppd debug local noauth nolock nodetach asyncmap 0 default-asyncmap novj noaccomp nopcomp nodeflate nobsdcomp nomagic noipv6 nosendip nodefaultroute 10.0.0.1:10.0.0.2 notty"

Which means that first pppd force usage of address 10.1.0.1 for peer and
second pppd (peer) wants to use only address 10.0.0.1 for itself.

First pppd see this communication

    rcvd [IPCP ConfReq id=0x64 <addr 10.0.0.1>]
    sent [IPCP ConfNak id=0x64 <addr 10.1.0.1>]
    rcvd [IPCP ConfReq id=0x65]
    sent [IPCP ConfAck id=0x65]
    local  IP address 10.0.0.2
    remote IP address 10.1.0.1

and thinks that peer (second pppd) accepted its idea of remote/peer
address.

After applying this patch first pppd correctly detects that peer refused
its proposed peer address and therefore close connection.

    rcvd [IPCP ConfReq id=0x64 <addr 10.0.0.1>]
    sent [IPCP ConfNak id=0x64 <addr 10.1.0.1>]
    rcvd [IPCP ConfReq id=0x65]
    sent [IPCP ConfAck id=0x65]
    Peer refused to agree to his IP address
    Connect time 0.0 minutes.
    Sent 1024 bytes, received 1018 bytes.
    sent [IPCP TermReq id=0x3 "Refused his IP address"]

Signed-off-by: Pali Rohár <pali@kernel.org>
3 years agopppd: Fix demand mode with noremoteip option (#232)
pali [Tue, 26 Jan 2021 02:52:22 +0000 (03:52 +0100)]
pppd: Fix demand mode with noremoteip option (#232)

When noremoteip is set then initial hisaddr (peer address) is zero. So to
handle setting correct peer address after establishing connection it is
needed to change logic around 'wo->hisaddr != 0' condition. wo->hisaddr
needs to be updated from initial zero address to correct peer address.

Signed-off-by: Pali Rohár <pali@kernel.org>
3 years agopppd: Document ipcp-no-address, ipcp-no-addresses and nosendip options (#231)
pali [Tue, 26 Jan 2021 02:49:57 +0000 (03:49 +0100)]
pppd: Document ipcp-no-address, ipcp-no-addresses and nosendip options (#231)

Signed-off-by: Pali Rohár <pali@kernel.org>
3 years agopppd: Fix nosendip option (#229)
pali [Tue, 26 Jan 2021 02:49:09 +0000 (03:49 +0100)]
pppd: Fix nosendip option (#229)

Respect nosendip option and do not send our IP address to peer even when
peer send to us IPCP ConfNak packet with address 0.0.0.0.

Without this patch pppd sends own local IP address to remote peer and it
can be reproduced with following command:

    $ ./pppd/pppd debug local noauth nolock nodetach asyncmap 0 default-asyncmap novj noaccomp nopcomp nodeflate nobsdcomp noipv6 nodefaultroute noipdefault pty "./pppd/pppd debug local noauth nolock nodetach asyncmap 0 default-asyncmap novj noaccomp nopcomp nodeflate nobsdcomp noipv6 nodefaultroute nosendip 10.0.0.1:10.0.0.2 notty"

Without this patch first pppd receives 10.0.0.1 address from second pppd
even second pppd is configured to not send its IP address.

    rcvd [LCP ConfReq id=0x1 <magic 0x7cf29fab>]
    sent [LCP ConfReq id=0x1 <magic 0x4550b00c>]
    sent [LCP ConfAck id=0x1 <magic 0x7cf29fab>]
    rcvd [LCP ConfAck id=0x1 <magic 0x4550b00c>]
    sent [LCP EchoReq id=0x0 magic=0x4550b00c]
    sent [IPCP ConfReq id=0x1 <addr 0.0.0.0>]
    rcvd [LCP EchoReq id=0x0 magic=0x7cf29fab]
    sent [LCP EchoRep id=0x0 magic=0x4550b00c]
    rcvd [IPCP ConfReq id=0x1]
    sent [IPCP ConfNak id=0x1 <addr 0.0.0.0>]
    rcvd [LCP EchoRep id=0x0 magic=0x7cf29fab]
    rcvd [IPCP ConfNak id=0x1 <addr 10.0.0.2>]
    sent [IPCP ConfReq id=0x2 <addr 10.0.0.2>]
    rcvd [IPCP ConfReq id=0x2 <addr 10.0.0.1>]
    sent [IPCP ConfAck id=0x2 <addr 10.0.0.1>]
    rcvd [IPCP ConfAck id=0x2 <addr 10.0.0.2>]
    local  IP address 10.0.0.2
    remote IP address 10.0.0.1

After applying this patch first pppd does not receive remote 10.0.0.1
address anymore which can be seen by the fact that first pppd cannot
determinate remote IP address and defaulting to 10.64.64.64.

    rcvd [LCP ConfReq id=0x1 <magic 0x1da305a6>]
    sent [LCP ConfReq id=0x1 <magic 0x2d76359>]
    sent [LCP ConfAck id=0x1 <magic 0x1da305a6>]
    rcvd [LCP ConfAck id=0x1 <magic 0x2d76359>]
    sent [LCP EchoReq id=0x0 magic=0x2d76359]
    sent [IPCP ConfReq id=0x1 <addr 0.0.0.0>]
    rcvd [LCP EchoReq id=0x0 magic=0x1da305a6]
    sent [LCP EchoRep id=0x0 magic=0x2d76359]
    rcvd [IPCP ConfReq id=0x1]
    sent [IPCP ConfNak id=0x1 <addr 0.0.0.0>]
    rcvd [LCP EchoRep id=0x0 magic=0x1da305a6]
    rcvd [IPCP ConfNak id=0x1 <addr 10.0.0.2>]
    sent [IPCP ConfReq id=0x2 <addr 10.0.0.2>]
    rcvd [IPCP ConfReq id=0x2]
    sent [IPCP ConfAck id=0x2]
    rcvd [IPCP ConfAck id=0x2 <addr 10.0.0.2>]
    Could not determine remote IP address: defaulting to 10.64.64.64
    local  IP address 10.0.0.2
    remote IP address 10.64.64.64

Signed-off-by: Pali Rohár <pali@kernel.org>
3 years agopppd/Makefile.linux: Fix copy/paste typo (#237)
Richard Purdie [Fri, 22 Jan 2021 05:02:58 +0000 (05:02 +0000)]
pppd/Makefile.linux: Fix copy/paste typo (#237)

A previous commit to fix a make issue had a copy/paste error, fix it
to refer to the correct header.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
3 years agoipv6cp: Remove demand debug notice
Pali Rohár [Sat, 9 Jan 2021 13:41:00 +0000 (14:41 +0100)]
ipv6cp: Remove demand debug notice

Signed-off-by: Pali Rohár <pali@kernel.org>
3 years agoipv6cp: Fix clearing previous IPv6 LL address in demand mode
Pali Rohár [Sat, 9 Jan 2021 13:40:12 +0000 (14:40 +0100)]
ipv6cp: Fix clearing previous IPv6 LL address in demand mode

Previous old IPv6 LL address is stored in the 'wo' structure. In 'go'/'ho'
is stored new address which needs to be assigned on interface.

Without this patch pppd in demand IPv6 mode always let previous IPv6 LL
address on interface and failed on error:

cif6addr: ioctl(SIOCDIFADDR): No such address

Because it tried to remove new address from interface which obviously was
not set.

Signed-off-by: Pali Rohár <pali@kernel.org>
3 years agoipv6cp: Allow to use demand mode without specifying IPv6 address/identifier
Pali Rohár [Sat, 9 Jan 2021 13:37:00 +0000 (14:37 +0100)]
ipv6cp: Allow to use demand mode without specifying IPv6 address/identifier

Support is similar as in IPv4, pppd generates random temporary identifier
for LL address and after connection is established then LL address is
changed to the real one.

Signed-off-by: Pali Rohár <pali@kernel.org>
3 years agoplugins/pppoe: Add manual page for pppoe-discovery
Jaroslav Škarvada [Tue, 5 Jan 2021 23:03:38 +0000 (00:03 +0100)]
plugins/pppoe: Add manual page for pppoe-discovery

Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
3 years agoAdd some configuration samples (#225)
Jaroslav Škarvada [Fri, 8 Jan 2021 02:52:41 +0000 (03:52 +0100)]
Add some configuration samples (#225)

Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
3 years agoInstall with standard permissions (#221)
Jaroslav Škarvada [Fri, 8 Jan 2021 01:45:24 +0000 (02:45 +0100)]
Install with standard permissions (#221)

In Fedora it's installed with standard permissions for years.

Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
3 years agoconfigure: Allow commas in the CFLAGS (#220)
Jaroslav Škarvada [Fri, 8 Jan 2021 01:43:46 +0000 (02:43 +0100)]
configure: Allow commas in the CFLAGS (#220)

It allows e.g. the following:
./configure --cflags='-Wp,-D_FORTIFY_SOURCE=2'

Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
3 years agopppd/Makefile.linux: Fix reproducibility issue with differing make versions (#234)
Richard Purdie [Fri, 8 Jan 2021 01:41:42 +0000 (01:41 +0000)]
pppd/Makefile.linux: Fix reproducibility issue with differing make versions (#234)

We were seeing reproducibility issues where one host would use the internal
logwtmp wrapper, another would use the one in libutil. The issue was that in
some cases the "\#include" was making it to CC, in others, "#include". The
issue seems to be related to shell escaping.

The root cause looks to be:
http://git.savannah.gnu.org/cgit/make.git/commit/?id=c6966b323811c37acedff05b576b907b06aea5f4

Instead of relying on shell quoting, use make to indirect the variable
and avoid the problem.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
3 years agopppd: Support strip MS domain name for EAP MSCHAPv2
Tijs Van Buggenhout [Wed, 6 Jan 2021 13:59:04 +0000 (14:59 +0100)]
pppd: Support strip MS domain name for EAP MSCHAPv2

Missing feature in preparation for validating the MSCHAPv2 response, as
it was introduced in [1] later on.

1. https://github.com/paulusmack/ppp/commit/7f7ea8967e3b02234811a4b9bb893fc21544319c

Signed-off-by: Tijs Van Buggenhout <tvbuggen@gmail.com>
3 years agopppd: Refactor eap MSCHAPv2 using chap_find_digest
Tijs Van Buggenhout [Mon, 4 Jan 2021 22:59:57 +0000 (23:59 +0100)]
pppd: Refactor eap MSCHAPv2 using chap_find_digest

Remove code duplication from eap.c related to eap MSCHAPv2 (server)
implementation.

The chap_find_digest function - introduced in [1] - exposes the
registered CHAP digests type definitions, providing functions to
generate a challenge and verify a response, among others.

1. https://github.com/paulusmack/ppp/commit/14c1a77816e837852138e87a4adccfd66030b2c3

Signed-off-by: Tijs Van Buggenhout <tvbuggen@gmail.com>
3 years agopppd: (Re)use chap_find_digest in chap_auth_peer
Tijs Van Buggenhout [Mon, 4 Jan 2021 22:57:13 +0000 (23:57 +0100)]
pppd: (Re)use chap_find_digest in chap_auth_peer

Code duplication.

Signed-off-by: Tijs Van Buggenhout <tvbuggen@gmail.com>
3 years agopppd: Fix indentation/whitespace in chap_find_digest
Tijs Van Buggenhout [Mon, 4 Jan 2021 22:54:40 +0000 (23:54 +0100)]
pppd: Fix indentation/whitespace in chap_find_digest

Signed-off-by: Tijs Van Buggenhout <tvbuggen@gmail.com>
3 years agopppoe-discovery: Remove unused file debug.c
Pali Rohár [Fri, 1 Jan 2021 15:57:43 +0000 (16:57 +0100)]
pppoe-discovery: Remove unused file debug.c

Signed-off-by: Pali Rohár <pali@kernel.org>
3 years agopppoe-discovery: Use pppoe plugin discovery1() function and remove duplicate implemen...
Pali Rohár [Fri, 1 Jan 2021 15:57:00 +0000 (16:57 +0100)]
pppoe-discovery: Use pppoe plugin discovery1() function and remove duplicate implementation

Signed-off-by: Pali Rohár <pali@kernel.org>
3 years agopppoe-discovery: Define function and variables which are used by pppoe plugin code
Pali Rohár [Fri, 1 Jan 2021 15:51:08 +0000 (16:51 +0100)]
pppoe-discovery: Define function and variables which are used by pppoe plugin code

Signed-off-by: Pali Rohár <pali@kernel.org>
3 years agopppoe: Do not use %.*v and %.*B formats which are unsupported by C printf()
Pali Rohár [Fri, 1 Jan 2021 15:39:52 +0000 (16:39 +0100)]
pppoe: Do not use %.*v and %.*B formats which are unsupported by C printf()

Signed-off-by: Pali Rohár <pali@kernel.org>
3 years agopppoe: Dump discovery packets when pppoe-verbose option is set to >= 2
Pali Rohár [Fri, 1 Jan 2021 15:38:03 +0000 (16:38 +0100)]
pppoe: Dump discovery packets when pppoe-verbose option is set to >= 2

Signed-off-by: Pali Rohár <pali@kernel.org>
3 years agopppoe: Show verbose information about all concentrator when pppoe-verbose option...
Pali Rohár [Fri, 1 Jan 2021 15:33:23 +0000 (16:33 +0100)]
pppoe: Show verbose information about all concentrator when pppoe-verbose option is set

Signed-off-by: Pali Rohár <pali@kernel.org>
3 years agopppoe: Do not use lcp_allowoptions[] and lcp_wantoptions[] in discovery.c code
Pali Rohár [Fri, 1 Jan 2021 15:30:19 +0000 (16:30 +0100)]
pppoe: Do not use lcp_allowoptions[] and lcp_wantoptions[] in discovery.c code

Signed-off-by: Pali Rohár <pali@kernel.org>
3 years agopppoe: Split function discovery() into phases discovery1() and discovery2()
Pali Rohár [Fri, 1 Jan 2021 15:28:22 +0000 (16:28 +0100)]
pppoe: Split function discovery() into phases discovery1() and discovery2()

pppoe-discovery.c needs to call only the first phase of discovery.

Signed-off-by: Pali Rohár <pali@kernel.org>
3 years agopppoe: Rename variable printACNames to pppoe_verbose to match cmdline option
Pali Rohár [Fri, 1 Jan 2021 15:24:57 +0000 (16:24 +0100)]
pppoe: Rename variable printACNames to pppoe_verbose to match cmdline option

Signed-off-by: Pali Rohár <pali@kernel.org>
3 years agoUpdate README and patchlevel.h for 2.4.9 release 2.4.9 ppp-2.4.9
Paul Mackerras [Mon, 4 Jan 2021 03:20:47 +0000 (14:20 +1100)]
Update README and patchlevel.h for 2.4.9 release

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
3 years agopppd: Send nak suggesting eap-mschapv2 when using eap-tls (#217)
Eivind Næss [Mon, 4 Jan 2021 22:41:11 +0000 (14:41 -0800)]
pppd: Send nak suggesting eap-mschapv2 when using eap-tls (#217)

Signed-off-by: Eivind Naess <eivnaes@yahoo.com>
3 years agopppd: Call auth-up-notifier even if 'noauth' is specified (#216)
Eivind Næss [Mon, 4 Jan 2021 06:53:40 +0000 (22:53 -0800)]
pppd: Call auth-up-notifier even if 'noauth' is specified (#216)

This will allow client side plug-ins like for SSTP to use the auth-up-notifier hook to
process the authentication complete step.

Signed-off-by: Eivind Naess <eivnaes@yahoo.com>
3 years agoplugins/radius: Eliminate some potential buffer overruns
Paul Mackerras [Mon, 4 Jan 2021 03:20:10 +0000 (14:20 +1100)]
plugins/radius: Eliminate some potential buffer overruns

Increase AUTH_STRING_LEN and add extra checks in rc_avpair_gen()
to make sure that we can not overflow pair->strvalue.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
3 years agopppd: Add support for EAP-MSCHAPv2 (client side) (#211)
Eivind Næss [Mon, 4 Jan 2021 01:34:34 +0000 (17:34 -0800)]
pppd: Add support for EAP-MSCHAPv2 (client side) (#211)

* Adding EAP-MSCHAPv2 support #175

Implementation based on the RFC: draft-kamath-pppext-eap-mschapv2-02.
Adding support for MSCHAPv2 inside extensible authentication protocol (EAP).

Signed-off-by: Thomas Omerzu <thomas@omerzu.de>
* Removing empty "TODO" in comment section

Signed-off-by: Eivind Naess <eivnaes@yahoo.com>
* Add support for EAP-MSCHAPv2 #138

Rewrote the original patch to use the chap-new.c API for caching request/responses. Also incorporate feedback from @paulusmack for input validation and function signatures.

Signed-off-by: Eivind Naess <eivnaes@yahoo.com>
* Adding length checks per Paul's request

Signed-off-by: Eivind Naess, eivnaes@yahoo.com
Co-authored-by: Thomas Omerzu <thomas@omerzu.de>
3 years agopppd: Fix setting IPv6 peer address (#212)
pali [Sun, 3 Jan 2021 23:01:44 +0000 (00:01 +0100)]
pppd: Fix setting IPv6 peer address (#212)

On Linux IPv6 peer address cannot be set via SIOCSIFDSTADDR ioctl like it
is for IPv4 peer address. Linux kernel does not support SIOCSIFDSTADDR for
AF_INET6 PPP interfaces.

The only way how to set IPv6 peer address on Linux is via kernel netlink
interface which is just a little bit complicated compared to one ioctl
call.

Linux kernel for a long time automatically adds IPv6 peer address from
interface into route table so it is not needed to explicitly set routing
for remote peer address. pppd already does not do it for kernel versions
newer than 2.1.16. So the same check is used also for IPv6 peer route
address.

Prior this patch ppp interface was configured as:

    $ ip -6 address show dev ppp0
    2: ppp0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 state UNKNOWN qlen 3
        inet6 fe80::2/128 scope link
           valid_lft forever preferred_lft forever

    $ ip -6 route show dev ppp0
    fe80::1 metric 1 pref medium
    fe80::2 proto kernel metric 256 pref medium

And after applying this patch as:

    $ ip -6 address show dev ppp0
    2: ppp0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 state UNKNOWN qlen 3
        inet6 fe80::2 peer fe80::1/128 scope link
           valid_lft forever preferred_lft forever

    $ ip -6 route show dev ppp0
    fe80::1 proto kernel metric 256 pref medium
    fe80::2 proto kernel metric 256 pref medium

As can be seen IPv6 peer address is now correctly set on the interface and
also kernel correctly fill route table for IPv6 peer address.

Please note that old ifconfig utility cannot show nor change IPv6 peer
address. Peer address is supported only for IPv4 addresses as opposite of
the local addresses where both IPv4 and IPv6 are supported. It is because
old ifconfig utility is also using ioctl interface which cannot handle it.
Therefore for any testing it is really required ip utility or other utility
with netlink interface (and not ioctl interface).

Signed-off-by: Pali Rohár <pali@kernel.org>
3 years agopppoe: Check if PPPoE discovery socket was created
Pali Rohár [Fri, 1 Jan 2021 15:23:26 +0000 (16:23 +0100)]
pppoe: Check if PPPoE discovery socket was created

Signed-off-by: Pali Rohár <pali@kernel.org>
3 years agoEnabled Buildroot CI test builds on pull request. (#214)
Adrien RICCIARDI [Sun, 3 Jan 2021 22:58:30 +0000 (23:58 +0100)]
Enabled Buildroot CI test builds on pull request. (#214)

Signed-off-by: RICCIARDI-Adrien <adrien.ricciardi@hotmail.fr>
3 years agoSolaris automated CI build. (#215)
Adrien RICCIARDI [Sun, 3 Jan 2021 22:57:37 +0000 (23:57 +0100)]
Solaris automated CI build. (#215)

* Started Solaris CI test. Retrieved PPP source code and started a Solaris virtual machine.

Signed-off-by: RICCIARDI-Adrien <adrien.ricciardi@hotmail.fr>
* Added PPP build step to Solaris CI.

Signed-off-by: RICCIARDI-Adrien <adrien.ricciardi@hotmail.fr>
3 years agoRepair compilation issues on Solaris
James Carlson [Wed, 30 Dec 2020 14:55:12 +0000 (09:55 -0500)]
Repair compilation issues on Solaris

There's no "ifr_mtu" on the legacy BSD interface; it's "ifr_metric"
and old K&R style implied 'int' can't be used with modern function
declarations.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
3 years agopppd: Combine get_first_ethernet() and get_if_hwaddr() into one function (#207)
pali [Sat, 2 Jan 2021 03:27:13 +0000 (04:27 +0100)]
pppd: Combine get_first_ethernet() and get_if_hwaddr() into one function (#207)

On all places is just needed hardware address for the first ethernet-style
interface. So provide it by new get_first_ether_hwaddr() function.

Signed-off-by: Pali Rohár <pali@kernel.org>
3 years agopppd: Document chapms-strip-domain option in pppd(8) (#203)
Samuel Thibault [Sat, 2 Jan 2021 03:26:43 +0000 (04:26 +0100)]
pppd: Document chapms-strip-domain option in pppd(8) (#203)

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
3 years agopppd: Add replacedefaultroute option (#200)
Samuel Thibault [Sat, 2 Jan 2021 03:25:48 +0000 (04:25 +0100)]
pppd: Add replacedefaultroute option (#200)

Adds an option to pppd to control whether to replace existing default routes
when using the 'defaultroute' option.

If defaultroute and replacedefaultroute are both set, pppd replaces an existing
default route with the new default route. The old default route is restored when
the connection is taken down.

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Co-authored-by: Chris Boot <bootc@debian.org>
3 years agoMerge pull request #208 from RICCIARDI-Adrien/automated_build
Paul Mackerras [Sat, 2 Jan 2021 03:13:06 +0000 (14:13 +1100)]
Merge pull request #208 from RICCIARDI-Adrien/automated_build

Automated build (multiple architectures and C libraries using Buildroot).

3 years agoAdded ARM, PPC and MIPS targets to Buildroot CI tests.
RICCIARDI-Adrien [Fri, 1 Jan 2021 14:17:51 +0000 (15:17 +0100)]
Added ARM, PPC and MIPS targets to Buildroot CI tests.

Signed-off-by: RICCIARDI-Adrien <adrien.ricciardi@hotmail.fr>
3 years agoAdded Buildroot C library selection.
RICCIARDI-Adrien [Thu, 31 Dec 2020 22:06:27 +0000 (23:06 +0100)]
Added Buildroot C library selection.

Signed-off-by: RICCIARDI-Adrien <adrien.ricciardi@hotmail.fr>
3 years agoAdded Buildroot configuration and build steps.
RICCIARDI-Adrien [Thu, 31 Dec 2020 15:21:04 +0000 (16:21 +0100)]
Added Buildroot configuration and build steps.

Signed-off-by: RICCIARDI-Adrien <adrien.ricciardi@hotmail.fr>
3 years agoEnabled PPPD package in Buildroot defconfig.
RICCIARDI-Adrien [Thu, 31 Dec 2020 13:08:10 +0000 (14:08 +0100)]
Enabled PPPD package in Buildroot defconfig.

Signed-off-by: RICCIARDI-Adrien <adrien.ricciardi@hotmail.fr>
3 years agoModified Buildroot PPPD package to use GitHub master branch.
RICCIARDI-Adrien [Thu, 31 Dec 2020 12:56:57 +0000 (13:56 +0100)]
Modified Buildroot PPPD package to use GitHub master branch.

Signed-off-by: RICCIARDI-Adrien <adrien.ricciardi@hotmail.fr>
3 years agoStarted Buildroot GitHub action. It can currently only retrieve latest stable Buildro...
RICCIARDI-Adrien [Thu, 31 Dec 2020 11:18:43 +0000 (12:18 +0100)]
Started Buildroot GitHub action. It can currently only retrieve latest stable Buildroot sources.

Signed-off-by: RICCIARDI-Adrien <adrien.ricciardi@hotmail.fr>
3 years agopppd: Fix ether_to_eui64() to prefer devnam ether interface (#206)
pali [Fri, 1 Jan 2021 08:58:02 +0000 (09:58 +0100)]
pppd: Fix ether_to_eui64() to prefer devnam ether interface (#206)

In case of PPPoE connection, devnam is ethernet interface. So in this case
calculate EUI-64 IPV6CP identifier from the PPPoE ethernet interface
instead from the first ethernet interface in the system.

This would ensure that each PPPoE connection would have unique IPv6 link
local address calculated from the interface MAC address on which is PPPoE
going to be established.

Currently IPv6 link local address is always calculated from the MAC address
of the first ethernet interface and therefore all active PPPoE connections
have by default same (non unique) IPv6 link local address.

Signed-off-by: Pali Rohár <pali@kernel.org>
3 years agoAdd cross-compilation support on Linux
Paul Mackerras [Fri, 1 Jan 2021 08:44:07 +0000 (19:44 +1100)]
Add cross-compilation support on Linux

This adds three new command-line options to the configure script:

--cross_compile=<prefix> (default "")
--cc=<compiler>          (default cc)
--cflags=<compile flags> (default -g -O2 -pipe)

These get propagated to the Makefiles in the subdirectories.  The
cross-compile prefix is prepended to the CC value, so for example
if you do "./configure --cross_compile=powerpc64le-linux-" then
everything gets compiled and linked using powerpc64le-linux-cc.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
3 years agopppd: Use a run-time test to detect libutil availability on Linux
Paul Mackerras [Fri, 1 Jan 2021 00:26:48 +0000 (11:26 +1100)]
pppd: Use a run-time test to detect libutil availability on Linux

This tests whether logwtmp is declared in <utmp.h>, and if not we
assume we need to include our own logwtmp implementation.  We assume
that if logwtmp is provided by the system then we need -lutil to get
it (as is the case for glibc).

This fixes compilation with musl libc and other libcs that don't
provide logwtmp.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
3 years agoMerge pull request #205 from pali/pppoe-rename
Paul Mackerras [Fri, 1 Jan 2021 08:52:59 +0000 (19:52 +1100)]
Merge pull request #205 from pali/pppoe-rename

Rename rp-pppoe.so plugin to pppoe.so

3 years agoCleanup pppoe-discovery fatal functions
Pali Rohár [Thu, 31 Dec 2020 17:52:50 +0000 (18:52 +0100)]
Cleanup pppoe-discovery fatal functions

Implement fatal() function as defined in pppd/pppd.h and use it instead of
rp_fatal() and sysErr() functions.

Signed-off-by: Pali Rohár <pali@kernel.org>
3 years agoMake a consistency in pppoe options
Pali Rohár [Thu, 31 Dec 2020 17:49:27 +0000 (18:49 +0100)]
Make a consistency in pppoe options

Remove 'rp_' prefix from all pppoe options and ensure that pppoe options
have 'pppoe-' prefix. Also change underlines to dashes to be consistent
with other pppd options.

To not break a backward compatibility ensure that old option names still
work via (legacy) aliases.

Also document everything in pppd manual page.

Signed-off-by: Pali Rohár <pali@kernel.org>
3 years agoDeduplicate ether_to_eui64() implementation (#204)
pali [Thu, 31 Dec 2020 22:54:37 +0000 (23:54 +0100)]
Deduplicate ether_to_eui64() implementation (#204)

Now when get_first_ethernet() is implemented for both Linux and Solaris,
implementation of ether_to_eui64() function can use this function
get_first_ethernet() and therefore be system independent.

So change implementation of ether_to_eui64() to use get_first_ethernet()
function and move it from Linux and Solaris files to common ipv6cp.c file
where it is used.

Signed-off-by: Pali Rohár <pali@kernel.org>
3 years agopppd/Makefile.linux: do not check for bpf header presence on the host (#201)
Alexander Kanavin [Thu, 31 Dec 2020 22:44:08 +0000 (23:44 +0100)]
pppd/Makefile.linux: do not check for bpf header presence on the host (#201)

This makes builds non-deterministic, and doesn't work
when building in sysroot environments (such as yocto).

Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
3 years agoRename rp-pppoe.so plugin to pppoe.so
Pali Rohár [Thu, 31 Dec 2020 17:46:01 +0000 (18:46 +0100)]
Rename rp-pppoe.so plugin to pppoe.so

Original out-of-tree rp-pppoe plugin for pppd software is still available
at website https://dianne.skoll.ca/projects/rp-pppoe/ and receives new
releases. The last update is from the June 2020.

Currently it is ambiguous if user is using original out-of-tree rp-pppoe
plugin or in-tree pppd's rp-pppoe plugin. These two plugins are different,
come from different sources but share same name.

Some users want to use original rp-pppoe plugin and not pppd's in-tree
rp-pppoe plugin. Also some distribution want to package both plugins,
pppd's in-tree and original rp-pppoe.

So for this reason and also because all other PPP over <something> plugins
have just pppo prefix, rename in-tree rp-pppoe.so plugin to just pppoe.so.

This will allow to distinguish and make it clear what is the original
rp-pppoe plugin and what is pppd's in-tree pppoe plugin.

When installing pppd create a compatibility symlink from pppoe.so to
rp-pppoe.so so nothing would be broken. This compatibility symlink may be
removed by Linux distribution which do not want to have compatibility with
the old name as before and rather use rp-pppoe.so name for original
rp-pppoe software.

Signed-off-by: Pali Rohár <pali@kernel.org>
3 years agopppd: Use a compile test to detect crypt.h (#198)
Samuel Thibault [Thu, 31 Dec 2020 05:35:24 +0000 (06:35 +0100)]
pppd: Use a compile test to detect crypt.h (#198)

ppp checks header for existence of crypt.h looking it up in /usr/include.
That's incompatible with non-glibcs or a glibc with multiarch headers
(https://bugs.debian.org/798955). This patch replaces the file existence
test with a compile test.

Reviewed-by: Chris Boot <bootc@debian.org>
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Co-authored-by: Helmut Grohne <helmut@subdivi.de>
3 years agoAllow overriding the optimization level with CFLAGS (#197)
Samuel Thibault [Thu, 31 Dec 2020 05:34:09 +0000 (06:34 +0100)]
Allow overriding the optimization level with CFLAGS (#197)

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Co-authored-by: Marco d'Itri <md@linux.it>
3 years agoRevert "pppdump: support building with the system zlib (#189)"
Paul Mackerras [Thu, 31 Dec 2020 05:00:37 +0000 (16:00 +1100)]
Revert "pppdump: support building with the system zlib (#189)"

This reverts commit c98cc28f128dffc456488c74b600640057da6994
because of compile errors in pppdump:

cc  -o pppdump pppdump.o deflate.o bsd-comp.o  -lz
/usr/bin/ld: deflate.o: in function `z_incomp':
deflate.c:(.text+0x99): undefined reference to `inflateIncomp'
/usr/bin/ld: deflate.o: in function `z_decomp_alloc':
deflate.c:(.text+0x355): undefined reference to `inflateInit2'
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:38: pppdump] Error 1

The copy of zlib here is not the same as the standard upstream zlib;
this version has some extra functions added.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
3 years agopppd: Export $CALL_FILE to the link scripts (#196)
Samuel Thibault [Thu, 31 Dec 2020 04:50:46 +0000 (05:50 +0100)]
pppd: Export $CALL_FILE to the link scripts (#196)

From https://bugs.debian.org/51880


This would make it much easier for me, and cleaner too, to handle
multiple, mutually exclusive, dialout internet service providers.


Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Co-authored-by: Marco d'Itri <md@linux.it>