aboutsummaryrefslogtreecommitdiffstats
path: root/nonworking/ppp/ppp
diff options
context:
space:
mode:
Diffstat (limited to 'nonworking/ppp/ppp')
-rw-r--r--nonworking/ppp/ppp/008_pathnames.h.diff11
-rw-r--r--nonworking/ppp/ppp/011_scripts_redialer.diff152
-rw-r--r--nonworking/ppp/ppp/018_ip-up_option.diff98
-rw-r--r--nonworking/ppp/ppp/057_pppoe-interface-change78
-rw-r--r--nonworking/ppp/ppp/auth_hook_segfault33
-rw-r--r--nonworking/ppp/ppp/cifdefroute.dif283
-rw-r--r--nonworking/ppp/ppp/close_devfd17
-rw-r--r--nonworking/ppp/ppp/fix_closed_fds34
-rw-r--r--nonworking/ppp/ppp/install_and_cc.patch219
-rw-r--r--nonworking/ppp/ppp/makefilenew.patch55
-rw-r--r--nonworking/ppp/ppp/no_crypt_hack45
-rw-r--r--nonworking/ppp/ppp/ppp-2.3.11-oedod.dif172
-rw-r--r--nonworking/ppp/ppp/ppp-2.4.2-stripMSdomain35
-rw-r--r--nonworking/ppp/ppp/pppdump-no-deflate12
-rw-r--r--nonworking/ppp/ppp/pppoe_discovery150
-rw-r--r--nonworking/ppp/ppp/setevn_call_file24
-rw-r--r--nonworking/ppp/ppp/syslog_local212
-rw-r--r--nonworking/ppp/ppp/use_openssl150
18 files changed, 1580 insertions, 0 deletions
diff --git a/nonworking/ppp/ppp/008_pathnames.h.diff b/nonworking/ppp/ppp/008_pathnames.h.diff
index e69de29bb2..dee0a8db29 100644
--- a/nonworking/ppp/ppp/008_pathnames.h.diff
+++ b/nonworking/ppp/ppp/008_pathnames.h.diff
@@ -0,0 +1,11 @@
+--- ppp-2.4.0b4.orig/pppd/pathnames.h
++++ ppp-2.4.0b4/pppd/pathnames.h
+@@ -26,7 +26,7 @@
+ #define _PATH_AUTHUP _ROOT_PATH "/etc/ppp/auth-up"
+ #define _PATH_AUTHDOWN _ROOT_PATH "/etc/ppp/auth-down"
+ #define _PATH_TTYOPT _ROOT_PATH "/etc/ppp/options."
+-#define _PATH_CONNERRS _ROOT_PATH "/etc/ppp/connect-errors"
++#define _PATH_CONNERRS _ROOT_PATH "/var/log/ppp-connect-errors"
+ #define _PATH_PEERFILES _ROOT_PATH "/etc/ppp/peers/"
+ #define _PATH_RESOLV _ROOT_PATH "/etc/ppp/resolv.conf"
+
diff --git a/nonworking/ppp/ppp/011_scripts_redialer.diff b/nonworking/ppp/ppp/011_scripts_redialer.diff
index e69de29bb2..657f566c9d 100644
--- a/nonworking/ppp/ppp/011_scripts_redialer.diff
+++ b/nonworking/ppp/ppp/011_scripts_redialer.diff
@@ -0,0 +1,152 @@
+--- ppp-2.4.0b4.orig/scripts/redialer
++++ ppp-2.4.0b4/scripts/redialer
+@@ -1,96 +1,69 @@
+ #!/bin/sh
+-###################################################################
+ #
+-# These parameters control the attack dialing sequence.
++# A chatscript that will attempt to dial multiple numbers in sequence, until
++# you get connected.
+ #
+-# Maximum number of attempts to reach the telephone number(s)
+-MAX_ATTEMPTS=10
+-
+-# Delay between each of the attempts. This is a parameter to sleep
+-# so use "15s" for 15 seconds, "1m" for 1 minute, etc.
+-SLEEP_DELAY=15s
+-
+-###################################################################
++# To use: edit /etc/peers/provider, and change the connect line to read:
++# connect "/usr/local/bin/redialer"
+ #
+-# This is a list of telephone numbers. Add new numbers if you wish
+-# and see the function 'callall' below for the dial process.
+-PHONE1=555-1212
+-PHONE2=411
++# See below for configuration.
+
+-###################################################################
++# This is a list of chatscripts to use to get connected, and (optional)
++# telephone numbers to call for each of those chatscripts.
+ #
+-# If you use the ppp-on script, then these are passed to this routine
+-# automatically. There is no need to define them here. If not, then
+-# you will need to set the values.
+-#
+-ACCOUNT=my_account_name
+-PASSWORD=my_password
++# Note that in the chatscripts, you may use #NUMBER#, this will be replaced
++# with the number it is calling. You might want to use this to only have one
++# chatscript that is used for all numbers, or you might need multiple
++# chatscripts.
+
+-###################################################################
+-#
+-# Function to initialize the modem and ensure that it is in command
+-# state. This may not be needed, but it doesn't hurt.
+-#
+-function initialize
+-{
+- chat -v TIMEOUT 3 '' AT 'OK-+++\c-OK'
+- return
+-}
++PHONE1=123456789
++CHAT1=/etc/chatscripts/provider
+
+-###################################################################
+-#
+-# Script to dial a telephone
+-#
+-function callnumber
+-{
+-chat -v \
+- ABORT '\nBUSY\r' \
+- ABORT '\nNO ANSWER\r' \
+- ABORT '\nRINGING\r\n\r\nRINGING\r' \
+- '' ATDT$1 \
+- CONNECT '' \
+- ogin:--ogin: $ACCOUNT \
+- assword: $PASSWORD
+-#
+-# If the connection was successful then end the whole script with a
+-# success.
+-#
+- if [ "$?" = "0" ]; then
+- exit 0
+- fi
++PHONE2=912345678
++CHAT2=/etc/chatscripts/provider
+
+- return
+-}
++PHONE3=891234567
++CHAT3=/etc/chatscripts/provider
+
+-###################################################################
+-#
+-# Script to dial any telephone number
+-#
+-function callall
+-{
+-# echo "dialing attempt number: $1" >/dev/console
+- callnumber $PHONE1
+-# callnumber $PHONE2
+-}
++PHONE4=789123456
++CHAT4=/etc/chatscripts/provider
+
+-###################################################################
+-#
+-# Initialize the modem to ensure that it is in the command state
+-#
+-initialize
+-if [ ! "$?" = "0" ]; then
+- exit 1
+-fi
++PHONE5=001234567
++CHAT5=/etc/chatscripts/provider
+
++# How long to sleep between retries:
+ #
+-# Dial telephone numbers until one answers
+-#
++# Note that this is a parameter to sleep so use "15s" for 15 seconds,
++# "1m" for 1 minute, etc
++SLEEP_DELAY=1s
++
++# The code below does the dialing.
++
+ attempt=0
+ while : ; do
+- attempt=`expr $attempt + 1`
+- callall $attempt
+- if [ "$attempt" = "$MAX_ATTEMPTS" ]; then
+- exit 1
+- fi
+- sleep "$SLEEP_DELAY"
++ attempt=`expr $attempt + 1`
++ NUMBER=`eval echo '$PHONE'$attempt`
++ CHAT=`eval echo '$CHAT'$attempt`
++ if [ ! "$CHAT" ]; then
++ attempt=0
++ else
++ logger "Dialing attempt number: $attempt"
++ sed s/#NUMBER#/$NUMBER/ $CHAT >/etc/chatscripts/tmpchat
++ /usr/sbin/chat -v -f /etc/chatscripts/tmpchat
++ rm -f /etc/chatscripts/tmpchat
++ case $? in
++ 0) logger Connection established ; exit 0;;
++ 1) logger chat: exit 1, see manpage for details. ; exit 1;;
++ 2) logger chat: exit 2, see manpage for details. ; exit 2;;
++ 3) logger chat: exit 3, see manpage for details. ;;
++ 4) logger Line busy. ;;
++ 5) logger No Carrier. ;;
++ 6) logger A call is coming. Exiting! ; exit 1;;
++ 7) logger No dialtone. ;;
++ 8) logger An error occured. Exiting! ; exit 1;;
++ *) logger chat: exit $?, see manpage for details. ;;
++ esac
++ logger "Waiting $SLEEP_DELAY seconds before next try."
++ sleep $SLEEP_DELAY
++ fi
+ done
diff --git a/nonworking/ppp/ppp/018_ip-up_option.diff b/nonworking/ppp/ppp/018_ip-up_option.diff
index e69de29bb2..0dee9248e8 100644
--- a/nonworking/ppp/ppp/018_ip-up_option.diff
+++ b/nonworking/ppp/ppp/018_ip-up_option.diff
@@ -0,0 +1,98 @@
+--- ppp-2.4.1/pppd/ipcp.c Thu Mar 8 06:11:12 2001
++++ ppp-2.4.1-new/pppd/ipcp.c Tue Jun 19 15:35:36 2001
+@@ -1734,7 +1734,7 @@
+ */
+ if (ipcp_script_state == s_down && ipcp_script_pid == 0) {
+ ipcp_script_state = s_up;
+- ipcp_script(_PATH_IPUP);
++ ipcp_script(path_ipup);
+ }
+ }
+
+@@ -1777,7 +1777,7 @@
+ /* Execute the ip-down script */
+ if (ipcp_script_state == s_up && ipcp_script_pid == 0) {
+ ipcp_script_state = s_down;
+- ipcp_script(_PATH_IPDOWN);
++ ipcp_script(path_ipdown);
+ }
+ }
+
+@@ -1828,13 +1828,13 @@
+ case s_up:
+ if (ipcp_fsm[0].state != OPENED) {
+ ipcp_script_state = s_down;
+- ipcp_script(_PATH_IPDOWN);
++ ipcp_script(path_ipdown);
+ }
+ break;
+ case s_down:
+ if (ipcp_fsm[0].state == OPENED) {
+ ipcp_script_state = s_up;
+- ipcp_script(_PATH_IPUP);
++ ipcp_script(path_ipup);
+ }
+ break;
+ }
+
+--- ppp-2.4.1/pppd/main.c Tue Mar 13 06:56:19 2001
++++ ppp-2.4.1-new/pppd/main.c Tue Jun 19 15:35:36 2001
+@@ -233,6 +233,9 @@
+ struct protent *protp;
+ char numbuf[16];
+
++ strlcpy(path_ipup, "/etc/ppp/ip-up", sizeof(path_ipup));
++ strlcpy(path_ipdown, "/etc/ppp/ip-down", sizeof(path_ipdown));
++
+ link_stats_valid = 0;
+ new_phase(PHASE_INITIALIZE);
+
+
+--- ppp-2.4.1/pppd/options.c Tue Mar 13 06:56:19 2001
++++ ppp-2.4.1-new/pppd/options.c Tue Jun 19 15:38:32 2001
+@@ -85,6 +85,8 @@
+ bool dump_options; /* print out option values */
+ bool dryrun; /* print out option values and exit */
+ char *domain; /* domain name set by domain option */
++char path_ipup[MAXPATHLEN]; /* pathname of ip-up script */
++char path_ipdown[MAXPATHLEN];/* pathname of ip-down script */
+
+ extern option_t auth_options[];
+ extern struct stat devstat;
+@@ -231,6 +233,12 @@
+ "Print out option values after parsing all options", 1 },
+ { "dryrun", o_bool, &dryrun,
+ "Stop after parsing, printing, and checking options", 1 },
++ { "ip-up-script", o_string, path_ipup,
++ "Set pathname of ip-up script",
++ OPT_PRIV|OPT_STATIC, NULL, MAXPATHLEN },
++ { "ip-down-script", o_string, path_ipdown,
++ "Set pathname of ip-down script",
++ OPT_PRIV|OPT_STATIC, NULL, MAXPATHLEN },
+
+ #ifdef HAVE_MULTILINK
+ { "multilink", o_bool, &multilink,
+
+--- ppp-2.4.1/pppd/pathnames.h Thu Mar 8 06:15:37 2001
++++ ppp-2.4.1-new/pppd/pathnames.h Tue Jun 19 15:35:36 2001
+@@ -21,8 +21,6 @@
+ #define _PATH_UPAPFILE _ROOT_PATH "/etc/ppp/pap-secrets"
+ #define _PATH_CHAPFILE _ROOT_PATH "/etc/ppp/chap-secrets"
+ #define _PATH_SYSOPTIONS _ROOT_PATH "/etc/ppp/options"
+-#define _PATH_IPUP _ROOT_PATH "/etc/ppp/ip-up"
+-#define _PATH_IPDOWN _ROOT_PATH "/etc/ppp/ip-down"
+ #define _PATH_AUTHUP _ROOT_PATH "/etc/ppp/auth-up"
+ #define _PATH_AUTHDOWN _ROOT_PATH "/etc/ppp/auth-down"
+ #define _PATH_TTYOPT _ROOT_PATH "/etc/ppp/options."
+
+--- ppp-2.4.1/pppd/pppd.h Tue Mar 13 06:54:37 2001
++++ ppp-2.4.1-new/pppd/pppd.h Tue Jun 19 15:39:39 2001
+@@ -272,6 +272,8 @@
+ extern char *bundle_name; /* bundle name for multilink */
+ extern bool dump_options; /* print out option values */
+ extern bool dryrun; /* check everything, print options, exit */
++extern char path_ipup[MAXPATHLEN]; /* pathname of ip-up script */
++extern char path_ipdown[MAXPATHLEN]; /* pathname of ip-down script */
+
+ #ifdef PPP_FILTER
+ extern struct bpf_program pass_filter; /* Filter for pkts to pass */
diff --git a/nonworking/ppp/ppp/057_pppoe-interface-change b/nonworking/ppp/ppp/057_pppoe-interface-change
index e69de29bb2..cca5a0e67e 100644
--- a/nonworking/ppp/ppp/057_pppoe-interface-change
+++ b/nonworking/ppp/ppp/057_pppoe-interface-change
@@ -0,0 +1,78 @@
+--- ppp/pppd/plugins/rp-pppoe/plugin.c.orig 2003-04-07 02:09:05.000000000 +0200
++++ ppp/pppd/plugins/rp-pppoe/plugin.c 2003-12-03 22:15:07.000000000 +0100
+@@ -114,6 +114,57 @@
+ return 1;
+ }
+
++/* from <linux/if.h> */
++#define IFF_UP 0x1
++#define IFF_RUNNING 0x40
++
++static short ifrflags_old;
++
++static int interface_change(const char* ifname, int up)
++{
++ int fd;
++ struct ifreq ifr;
++
++ if (!up && ifrflags_old != 0) {
++ return 0;
++ }
++
++ fd = socket(AF_INET, SOCK_DGRAM, 0);
++ if (fd < 0) {
++ warn("socket(AF_INET, SOCK_DGRAM, 0): %s", strerror(errno));
++ return -1;
++ }
++
++ strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
++ if (ioctl(fd, SIOCGIFFLAGS, &ifr) < 0) {
++ warn("%s: unknown interface: %s", ifname, strerror(errno));
++ return -1;
++ }
++ strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
++ if (up) {
++ ifrflags_old = ifr.ifr_flags & (IFF_UP | IFF_RUNNING);
++ ifr.ifr_flags |= (IFF_UP | IFF_RUNNING);
++ } else {
++ ifr.ifr_flags &= ~(IFF_UP | IFF_RUNNING);
++ }
++ if (ioctl(fd, SIOCSIFFLAGS, &ifr) < 0) {
++ warn("SIOCSIFFLAGS: %s", strerror(errno));
++ return -1;
++ }
++ close(fd);
++ return 0;
++}
++
++static int interface_up (const char *ifname)
++{
++ return interface_change(ifname,1);
++}
++
++static int interface_down (const char* ifname)
++{
++ return interface_change(ifname,0);
++}
++
+ /**********************************************************************
+ * %FUNCTION: PPPOEConnectDevice
+ * %ARGUMENTS:
+@@ -142,6 +193,8 @@
+ conn->peerEth[i] = (unsigned char) mac[i];
+ }
+ } else {
++ if (interface_up(conn->ifName) < 0)
++ return -1;
+ discovery(conn);
+ if (conn->discoveryState != STATE_SESSION) {
+ fatal("Unable to complete PPPoE Discovery");
+@@ -243,6 +296,8 @@
+ return;
+ }
+ close(conn->sessionSocket);
++ if (interface_down(conn->ifName) < 0)
++ warn("We brought %s up but failed to take it down",conn->ifName);
+ }
+
+ static void
diff --git a/nonworking/ppp/ppp/auth_hook_segfault b/nonworking/ppp/ppp/auth_hook_segfault
index e69de29bb2..59007efafd 100644
--- a/nonworking/ppp/ppp/auth_hook_segfault
+++ b/nonworking/ppp/ppp/auth_hook_segfault
@@ -0,0 +1,33 @@
+To: md@linux.it, mjt@corpit.ru
+Subject: pppd-auth-hook.patch
+Message-Id: <20040604231517.3E9AD11DC4@paltus.tls.msk.ru>
+Date: Sat, 5 Jun 2004 03:15:17 +0400 (MSD)
+From: mjt@corpit.ru (Michael Tokarev)
+
+The patch below fixes pppd segfault when using auth_hook that sets
+options for the user (use-after-free problem).
+
+/mjt
+
+--- ppp/pppd/auth.c.orig Mon Jun 23 18:12:04 2003
++++ ppp/pppd/auth.c Sat Jun 5 03:11:36 2004
+@@ -1251,14 +1251,14 @@
+ if (pap_auth_hook) {
+ ret = (*pap_auth_hook)(user, passwd, msg, &addrs, &opts);
+ if (ret >= 0) {
++ /* note: set_allowed_addrs() saves opts (but not addrs): don't free it! */
+ if (ret)
+ set_allowed_addrs(unit, addrs, opts);
+- BZERO(passwd, sizeof(passwd));
++ else if (opts != 0)
++ free_wordlist(opts);
+ if (addrs != 0)
+ free_wordlist(addrs);
+- if (opts != 0) {
+- free_wordlist(opts);
+- }
++ BZERO(passwd, sizeof(passwd));
+ return ret? UPAP_AUTHACK: UPAP_AUTHNAK;
+ }
+ }
+
diff --git a/nonworking/ppp/ppp/cifdefroute.dif b/nonworking/ppp/ppp/cifdefroute.dif
index e69de29bb2..263b674f99 100644
--- a/nonworking/ppp/ppp/cifdefroute.dif
+++ b/nonworking/ppp/ppp/cifdefroute.dif
@@ -0,0 +1,283 @@
+--- ppp/pppd/ipcp.c Wed May 31 17:20:41 2000
++++ ppp/pppd/ipcp.c Wed May 31 17:27:19 2000
+@@ -145,7 +145,17 @@
+ { "-defaultroute", o_bool, &ipcp_allowoptions[0].default_route,
+ "disable defaultroute option", OPT_A2COPY,
+ &ipcp_wantoptions[0].default_route },
+
++#ifdef __linux__
++ { "replacedefaultroute", o_bool,
++ &ipcp_wantoptions[0].replace_default_route,
++ "Replace default route", 1
++ },
++ { "noreplacedefaultroute", o_bool,
++ &ipcp_allowoptions[0].replace_default_route,
++ "Never replace default route", OPT_A2COPY,
++ &ipcp_wantoptions[0].replace_default_route },
++#endif
+ { "proxyarp", o_bool, &ipcp_wantoptions[0].proxy_arp,
+ "Add proxy ARP entry", OPT_ENABLE|1, &ipcp_allowoptions[0].proxy_arp },
+ { "noproxyarp", o_bool, &ipcp_allowoptions[0].proxy_arp,
+@@ -195,7 +205,7 @@
+ ip_active_pkt
+ };
+
+-static void ipcp_clear_addrs __P((int, u_int32_t, u_int32_t));
++static void ipcp_clear_addrs __P((int, u_int32_t, u_int32_t, bool));
+ static void ipcp_script __P((char *)); /* Run an up/down script */
+ static void ipcp_script_done __P((void *));
+
+@@ -1344,7 +1354,12 @@
+ if (!sifnpmode(u, PPP_IP, NPMODE_QUEUE))
+ return 0;
+ if (wo->default_route)
++#ifndef __linux__
+ if (sifdefaultroute(u, wo->ouraddr, wo->hisaddr))
++#else
++ if (sifdefaultroute(u, wo->ouraddr, wo->hisaddr,
++ wo->replace_default_route))
++#endif
+ default_route_set[u] = 1;
+ if (wo->proxy_arp)
+ if (sifproxyarp(u, wo->hisaddr))
+@@ -1420,7 +1435,8 @@
+ */
+ if (demand) {
+ if (go->ouraddr != wo->ouraddr || ho->hisaddr != wo->hisaddr) {
+- ipcp_clear_addrs(f->unit, wo->ouraddr, wo->hisaddr);
++ ipcp_clear_addrs(f->unit, wo->ouraddr, wo->hisaddr,
++ wo->replace_default_route);
+ if (go->ouraddr != wo->ouraddr) {
+ warn("Local IP address changed to %I", go->ouraddr);
+ script_setenv("OLDIPLOCAL", ip_ntoa(wo->ouraddr));
+@@ -1445,7 +1461,12 @@
+
+ /* assign a default route through the interface if required */
+ if (ipcp_wantoptions[f->unit].default_route)
++#ifndef __linux__
+ if (sifdefaultroute(f->unit, go->ouraddr, ho->hisaddr))
++#else
++ if (sifdefaultroute(f->unit, go->ouraddr, ho->hisaddr,
++ wo->replace_default_route))
++#endif
+ default_route_set[f->unit] = 1;
+
+ /* Make a proxy ARP entry if requested. */
+@@ -1492,7 +1513,12 @@
+
+ /* assign a default route through the interface if required */
+ if (ipcp_wantoptions[f->unit].default_route)
++#ifndef __linux__
+ if (sifdefaultroute(f->unit, go->ouraddr, ho->hisaddr))
++#else
++ if (sifdefaultroute(f->unit, go->ouraddr, ho->hisaddr,
++ wo->replace_default_route))
++#endif
+ default_route_set[f->unit] = 1;
+
+ /* Make a proxy ARP entry if requested. */
+@@ -1559,7 +1585,7 @@
+ sifnpmode(f->unit, PPP_IP, NPMODE_DROP);
+ sifdown(f->unit);
+ ipcp_clear_addrs(f->unit, ipcp_gotoptions[f->unit].ouraddr,
+- ipcp_hisoptions[f->unit].hisaddr);
++ ipcp_hisoptions[f->unit].hisaddr, 0);
+ }
+
+ /* Execute the ip-down script */
+@@ -1575,16 +1601,25 @@
+ * proxy arp entries, etc.
+ */
+ static void
+-ipcp_clear_addrs(unit, ouraddr, hisaddr)
++ipcp_clear_addrs(unit, ouraddr, hisaddr, replacedefaultroute)
+ int unit;
+ u_int32_t ouraddr; /* local address */
+ u_int32_t hisaddr; /* remote address */
++ bool replacedefaultroute;
+ {
+ if (proxy_arp_set[unit]) {
+ cifproxyarp(unit, hisaddr);
+ proxy_arp_set[unit] = 0;
+ }
+- if (default_route_set[unit]) {
++ /* If replacedefaultroute, sifdefaultroute will be called soon
++ * with replacedefaultroute set and that will overwrite the current
++ * default route. This is the case only when doing demand, otherwise
++ * during demand, this cifdefaultroute would restore the old default
++ * route which is not what we want in this case. In the non-demand
++ * case, we'll delete the default route and restore the old if there
++ * is one saved by an sifdefaultroute with replacedefaultroute.
++ */
++ if (!replacedefaultroute && default_route_set[unit]) {
+ cifdefaultroute(unit, ouraddr, hisaddr);
+ default_route_set[unit] = 0;
+ }
+--- ppp/pppd/ipcp.h Wed May 31 17:20:41 2000
++++ ppp/pppd/ipcp.h Wed May 31 15:56:17 2000
+@@ -47,6 +47,7 @@
+ bool old_addrs; /* Use old (IP-Addresses) option? */
+ bool req_addr; /* Ask peer to send IP address? */
+ bool default_route; /* Assign default route through interface? */
++ bool replace_default_route; /* Replace default route through interface? */
+ bool proxy_arp; /* Make proxy ARP entry for peer? */
+ bool neg_vj; /* Van Jacobson Compression? */
+ bool old_vj; /* use old (short) form of VJ option? */
+--- ppp/pppd/pppd.8 Wed May 31 17:20:41 2000
++++ ppp/pppd/pppd.8 Wed May 31 15:56:17 2000
+@@ -99,6 +99,13 @@
+ This entry is removed when the PPP connection is broken. This option
+ is privileged if the \fInodefaultroute\fR option has been specified.
+ .TP
++.B replacedefaultroute
++This option is a flag to the defaultroute option. If defaultroute is
++set and this flag is also set, pppd replaces an existing default route
++with the new default route.
++
++
++.TP
+ .B disconnect \fIscript
+ Run the executable or shell command specified by \fIscript\fR after
+ pppd has terminated the link. This script could, for example, issue
+@@ -589,7 +596,12 @@
+ .TP
+ .B nodefaultroute
+ Disable the \fIdefaultroute\fR option. The system administrator who
+-wishes to prevent users from creating default routes with pppd
++wishes to prevent users from adding a default route with pppd
++can do so by placing this option in the /etc/ppp/options file.
++.TP
++.B noreplacedefaultroute
++Disable the \fIreplacedefaultroute\fR option. The system administrator who
++wishes to prevent users from replacing a default route with pppd
+ can do so by placing this option in the /etc/ppp/options file.
+ .TP
+ .B nodeflate
+--- ppp/pppd/pppd.h Wed May 31 17:20:41 2000
++++ ppp/pppd/pppd.h Wed May 31 15:56:17 2000
+@@ -416,7 +416,11 @@
+ int cif6addr __P((int, eui64_t, eui64_t));
+ /* Remove an IPv6 address from i/f */
+ #endif
++#ifndef __linux__
+ int sifdefaultroute __P((int, u_int32_t, u_int32_t));
++#else
++int sifdefaultroute __P((int, u_int32_t, u_int32_t, bool replace_default_rt));
++#endif
+ /* Create default route through i/f */
+ int cifdefaultroute __P((int, u_int32_t, u_int32_t));
+ /* Delete default route through i/f */
+--- ppp/pppd/sys-linux.c Wed May 31 17:20:41 2000
++++ ppp/pppd/sys-linux.c Wed May 31 17:37:23 2000
+@@ -143,6 +143,8 @@
+
+ static int if_is_up; /* Interface has been marked up */
+ static u_int32_t default_route_gateway; /* Gateway for default route added */
++static struct rtentry old_def_rt; /* Old default route */
++static int default_rt_repl_rest; /* replace and restore old default rt */
+ static u_int32_t proxy_arp_addr; /* Addr for proxy arp entry added */
+ static char proxy_arp_dev[16]; /* Device for proxy arp entry */
+ static u_int32_t our_old_addr; /* for detecting address changes */
+@@ -1209,6 +1211,9 @@
+ p = NULL;
+ }
+
++ SET_SA_FAMILY (rt->rt_dst, AF_INET);
++ SET_SA_FAMILY (rt->rt_gateway, AF_INET);
++
+ SIN_ADDR(rt->rt_dst) = strtoul(cols[route_dest_col], NULL, 16);
+ SIN_ADDR(rt->rt_gateway) = strtoul(cols[route_gw_col], NULL, 16);
+ SIN_ADDR(rt->rt_genmask) = strtoul(cols[route_mask_col], NULL, 16);
+@@ -1278,19 +1283,53 @@
+ /********************************************************************
+ *
+ * sifdefaultroute - assign a default route through the address given.
++ *
++ * If the global default_rt_repl_rest flag is set, then this function
++ * already replaced the original system defaultroute with some other
++ * route and it should just replace the current defaultroute with
++ * another one, without saving the current route. Use: demand mode,
++ * when pppd sets first a defaultroute it it's temporary ppp0 addresses
++ * and then changes the temporary addresses to the addresses for the real
++ * ppp connection when it has come up.
+ */
+
+-int sifdefaultroute (int unit, u_int32_t ouraddr, u_int32_t gateway)
++int sifdefaultroute (int unit, u_int32_t ouraddr, u_int32_t gateway, bool replace)
+ {
+- struct rtentry rt;
+-
+- if (defaultroute_exists(&rt) && strcmp(rt.rt_dev, ifname) != 0) {
+- u_int32_t old_gateway = SIN_ADDR(rt.rt_gateway);
++ struct rtentry rt, tmp_rt;
++ struct rtentry *del_rt = NULL;
+
+- if (old_gateway != gateway)
+- error("not replacing existing default route to %s [%I]",
+- rt.rt_dev, old_gateway);
+- return 0;
++
++ if (default_rt_repl_rest) {
++ /* We have already reclaced the original defaultroute, if we
++ * are called again, we will delete the current default route
++ * and set the new default route in this function.
++ * - this is normally only the case the doing demand: */
++ if (defaultroute_exists( &tmp_rt ))
++ del_rt = &tmp_rt;
++ } else if ( defaultroute_exists( &old_def_rt ) &&
++ strcmp( old_def_rt.rt_dev, ifname ) != 0) {
++ /* We did not yet replace an existing default route, let's
++ * check if we should save and replace a default route:
++ */
++ u_int32_t old_gateway = SIN_ADDR(old_def_rt.rt_gateway);
++
++ if (old_gateway != gateway) {
++ if (!replace) {
++ error("not replacing default route to %s [%I]",
++ old_def_rt.rt_dev, old_gateway);
++ return 0;
++ } else {
++ // we need to copy rt_dev because we need it permanent too:
++ char * tmp_dev = malloc(strlen(old_def_rt.rt_dev)+1);
++ strcpy(tmp_dev, old_def_rt.rt_dev);
++ old_def_rt.rt_dev = tmp_dev;
++
++ notice("replacing old default route to %s [%I]",
++ old_def_rt.rt_dev, old_gateway);
++ default_rt_repl_rest = 1;
++ del_rt = &old_def_rt;
++ }
++ }
+ }
+
+ memset (&rt, '\0', sizeof (rt));
+@@ -1310,6 +1349,12 @@
+ error("default route ioctl(SIOCADDRT): %m(%d)", errno);
+ return 0;
+ }
++ if (default_rt_repl_rest && del_rt)
++ if (ioctl(sock_fd, SIOCDELRT, del_rt) < 0) {
++ if ( ! ok_error ( errno ))
++ error("del old default route ioctl(SIOCDELRT): %m(%d)", errno);
++ return 0;
++ }
+
+ default_route_gateway = gateway;
+ return 1;
+@@ -1344,6 +1389,16 @@
+ error("default route ioctl(SIOCDELRT): %m (%d)", errno);
+ return 0;
+ }
++ }
++ if (default_rt_repl_rest) {
++ notice("restoring old default route to %s [%I]",
++ old_def_rt.rt_dev, SIN_ADDR(old_def_rt.rt_gateway));
++ if (ioctl(sock_fd, SIOCADDRT, &old_def_rt) < 0) {
++ if ( ! ok_error ( errno ))
++ error("restore default route ioctl(SIOCADDRT): %m(%d)", errno);
++ return 0;
++ }
++ default_rt_repl_rest = 0;
+ }
+
+ return 1;
diff --git a/nonworking/ppp/ppp/close_devfd b/nonworking/ppp/ppp/close_devfd
index e69de29bb2..987d964aae 100644
--- a/nonworking/ppp/ppp/close_devfd
+++ b/nonworking/ppp/ppp/close_devfd
@@ -0,0 +1,17 @@
+Ensure that the fd returned by the connect method is closed before
+running external programs.
+
+http://article.gmane.org/gmane.linux.ppp/1371
+
+diff -ruNp ppp.orig/pppd/main.c ppp/pppd/main.c
+--- ppp.orig/pppd/main.c 2004-07-12 12:55:30.000000000 +0200
++++ ppp/pppd/main.c 2004-07-12 12:55:25.000000000 +0200
+@@ -1662,6 +1662,8 @@ run_program(prog, args, must_exist, done
+ closelog();
+ if (the_channel->close)
+ (*the_channel->close)();
++ else
++ close(devfd);
+
+ /* Don't pass handles to the PPP device, even by accident. */
+ dup2(fd_devnull, 0);
diff --git a/nonworking/ppp/ppp/fix_closed_fds b/nonworking/ppp/ppp/fix_closed_fds
index e69de29bb2..39208ab4db 100644
--- a/nonworking/ppp/ppp/fix_closed_fds
+++ b/nonworking/ppp/ppp/fix_closed_fds
@@ -0,0 +1,34 @@
+sys_init() will open a socket and keep it open for the whole like of the
+process. If pppd is started without all standard fds open then the socket
+will get one of their numbers, which will be clobbered later by the
+/dev/null fd duplicated by main().
+
+See Debian bug #235192.
+
+diff -ruN ppp.orig/pppd/main.c ppp/pppd/main.c
+--- ppp.orig/pppd/main.c 2004-02-29 18:50:12.000000000 +0100
++++ ppp/pppd/main.c 2004-02-29 18:48:56.000000000 +0100
+@@ -385,11 +385,6 @@
+ if (dryrun)
+ die(0);
+
+- /*
+- * Initialize system-dependent stuff.
+- */
+- sys_init();
+-
+ /* Make sure fds 0, 1, 2 are open to somewhere. */
+ fd_devnull = open(_PATH_DEVNULL, O_RDWR);
+ if (fd_devnull < 0)
+@@ -401,6 +396,11 @@
+ fd_devnull = i;
+ }
+
++ /*
++ * Initialize system-dependent stuff.
++ */
++ sys_init();
++
+ #ifdef USE_TDB
+ pppdb = tdb_open(_PATH_PPPDB, 0, 0, O_RDWR|O_CREAT, 0644);
+ if (pppdb != NULL) {
diff --git a/nonworking/ppp/ppp/install_and_cc.patch b/nonworking/ppp/ppp/install_and_cc.patch
index e69de29bb2..b521e8593c 100644
--- a/nonworking/ppp/ppp/install_and_cc.patch
+++ b/nonworking/ppp/ppp/install_and_cc.patch
@@ -0,0 +1,219 @@
+diff -ur ppp.old/chat/Makefile.linux ppp/chat/Makefile.linux
+--- ppp.old/chat/Makefile.linux 2004-01-13 05:00:17.000000000 +0100
++++ ppp/chat/Makefile.linux 2004-08-22 00:46:05.000000000 +0200
+@@ -21,7 +21,7 @@
+
+ install: chat
+ mkdir -p $(BINDIR)
+- $(INSTALL) -s -c chat $(BINDIR)
++ $(INSTALL) -c chat $(BINDIR)
+ $(INSTALL) -c -m 644 chat.8 $(MANDIR)/man8
+
+ clean:
+diff -ur ppp.old/linux/Makefile.top ppp/linux/Makefile.top
+--- ppp.old/linux/Makefile.top 2002-06-10 15:56:02.000000000 +0200
++++ ppp/linux/Makefile.top 2004-08-22 00:46:05.000000000 +0200
+@@ -3,7 +3,7 @@
+
+ BINDIR = $(DESTDIR)/usr/sbin
+ INCDIR = $(DESTDIR)/usr/include
+-MANDIR = $(DESTDIR)/usr/man
++MANDIR = $(DESTDIR)/usr/share/man
+ ETCDIR = $(DESTDIR)/etc/ppp
+
+ # uid 0 = root
+diff -ur ppp.old/pppd/plugins/Makefile.linux ppp/pppd/plugins/Makefile.linux
+--- ppp.old/pppd/plugins/Makefile.linux 2004-01-13 05:00:17.000000000 +0100
++++ ppp/pppd/plugins/Makefile.linux 2004-08-22 00:46:05.000000000 +0200
+@@ -1,8 +1,8 @@
+-CC = gcc
++# CC = gcc
+ COPTS = -O2 -g
+ CFLAGS = $(COPTS) -I.. -I../../include -fPIC
+ LDFLAGS = -shared
+-INSTALL = install -o root
++INSTALL = install
+
+ SUBDIRS := rp-pppoe
+ # Uncomment the next line to include the radius authentication plugin
+diff -ur ppp.old/pppd/plugins/radius/Makefile.linux ppp/pppd/plugins/radius/Makefile.linux
+--- ppp.old/pppd/plugins/radius/Makefile.linux 2002-10-05 06:40:14.000000000 +0200
++++ ppp/pppd/plugins/radius/Makefile.linux 2004-08-22 00:46:05.000000000 +0200
+@@ -30,29 +30,29 @@
+ install: all
+ $(MAKE) $(MFLAGS) -C radiusclient install
+ $(INSTALL) -d -m 755 $(LIBDIR)
+- $(INSTALL) -s -c -m 755 radius.so $(LIBDIR)
+- $(INSTALL) -s -c -m 755 radattr.so $(LIBDIR)
+- $(INSTALL) -s -c -m 755 radrealms.so $(LIBDIR)
++ $(INSTALL) -c -m 755 radius.so $(LIBDIR)
++ $(INSTALL) -c -m 755 radattr.so $(LIBDIR)
++ $(INSTALL) -c -m 755 radrealms.so $(LIBDIR)
+ $(INSTALL) -c -m 444 pppd-radius.8 $(MANDIR)/man8
+ $(INSTALL) -c -m 444 pppd-radattr.8 $(MANDIR)/man8
+
+ radius.so: radiusclient/lib/.libs/libradiusclient.a radius.o
+- gcc -o radius.so -shared radius.o radiusclient/lib/.libs/libradiusclient.a
++ $(CC) -o radius.so -shared radius.o radiusclient/lib/.libs/libradiusclient.a
+
+ radattr.so: radattr.o
+- gcc -o radattr.so -shared radattr.o
++ $(CC) -o radattr.so -shared radattr.o
+
+ radrealms.so: radrealms.o
+- gcc -o radrealms.so -shared radrealms.o
++ $(CC) -o radrealms.so -shared radrealms.o
+
+ radius.o: radius.c
+- gcc $(CFLAGS) -c -o radius.o -fPIC radius.c
++ $(CC) $(CFLAGS) -c -o radius.o -fPIC radius.c
+
+ radattr.o: radattr.c
+- gcc $(CFLAGS) -c -o radattr.o -fPIC radattr.c
++ $(CC) $(CFLAGS) -c -o radattr.o -fPIC radattr.c
+
+ radrealms.o: radrealms.c
+- gcc $(CFLAGS) -c -o radrealms.o -fPIC radrealms.c
++ $(CC) $(CFLAGS) -c -o radrealms.o -fPIC radrealms.c
+
+ radiusclient/lib/.libs/libradiusclient.a:
+ test -r radiusclient/Makefile || \
+diff -ur ppp.old/pppd/plugins/rp-pppoe/Makefile.linux ppp/pppd/plugins/rp-pppoe/Makefile.linux
+--- ppp.old/pppd/plugins/rp-pppoe/Makefile.linux 2004-08-22 00:17:31.000000000 +0200
++++ ppp/pppd/plugins/rp-pppoe/Makefile.linux 2004-08-22 00:58:13.000000000 +0200
+@@ -21,38 +21,38 @@
+ all: rp-pppoe.so pppoe-discovery
+
+ pppoe-discovery: libplugin.a pppoe-discovery.o
+- gcc -o pppoe-discovery pppoe-discovery.o libplugin.a
++ $(CC) -o pppoe-discovery pppoe-discovery.o libplugin.a
+
+ pppoe-discovery.o: pppoe-discovery.c
+- gcc $(CFLAGS) '-DVERSION="$(VERSION)"' -c -o pppoe-discovery.o pppoe-discovery.c
++ $(CC) $(CFLAGS) '-DVERSION="$(VERSION)"' -c -o pppoe-discovery.o pppoe-discovery.c
+
+ rp-pppoe.so: libplugin.a plugin.o
+- gcc -o rp-pppoe.so -shared plugin.o libplugin.a
++ $(CC) -o rp-pppoe.so -shared plugin.o libplugin.a
+
+ install: all
+ $(INSTALL) -d -m 755 $(LIBDIR)
+- $(INSTALL) -s -c -m 4550 rp-pppoe.so $(LIBDIR)
++ $(INSTALL) -c -m 4750 rp-pppoe.so $(LIBDIR)
+ $(INSTALL) -d -m 755 $(BINDIR)
+- $(INSTALL) -s -c -m 555 pppoe-discovery $(BINDIR)/pppoe-discovery
++ $(INSTALL) -c -m 755 pppoe-discovery $(BINDIR)/pppoe-discovery
+
+ clean:
+ rm -f *.o *.so
+
+ plugin.o: plugin.c
+- gcc '-DRP_VERSION="$(VERSION)"' $(CFLAGS) -I../../.. -c -o plugin.o -fPIC plugin.c
++ $(CC) '-DRP_VERSION="$(VERSION)"' $(CFLAGS) -I../../.. -c -o plugin.o -fPIC plugin.c
+
+ libplugin.a: discovery.o if.o common.o debug.o
+- ar -rc $@ $^
++ $(AR) -rc $@ $^
+
+ discovery.o: discovery.c
+- gcc $(CFLAGS) '-DVERSION="$(VERSION)"' -c -o discovery.o -fPIC discovery.c
++ $(CC) $(CFLAGS) '-DVERSION="$(VERSION)"' -c -o discovery.o -fPIC discovery.c
+
+ if.o: if.c
+- gcc $(CFLAGS) '-DVERSION="$(VERSION)"' -c -o if.o -fPIC if.c
++ $(CC) $(CFLAGS) '-DVERSION="$(VERSION)"' -c -o if.o -fPIC if.c
+
+ debug.o: debug.c
+- gcc $(CFLAGS) '-DVERSION="$(VERSION)"' -c -o debug.o -fPIC debug.c
++ $(CC) $(CFLAGS) '-DVERSION="$(VERSION)"' -c -o debug.o -fPIC debug.c
+
+ common.o: common.c
+- gcc $(CFLAGS) '-DVERSION="$(VERSION)"' -c -o common.o -fPIC common.c
++ $(CC) $(CFLAGS) '-DVERSION="$(VERSION)"' -c -o common.o -fPIC common.c
+
+diff -ur ppp.old/pppdump/Makefile.linux ppp/pppdump/Makefile.linux
+--- ppp.old/pppdump/Makefile.linux 1999-08-12 06:39:07.000000000 +0200
++++ ppp/pppdump/Makefile.linux 2004-08-22 00:46:05.000000000 +0200
+@@ -13,5 +13,5 @@
+
+ install:
+ mkdir -p $(BINDIR) $(MANDIR)/man8
+- $(INSTALL) -s -c pppdump $(BINDIR)
++ $(INSTALL) -c pppdump $(BINDIR)
+ $(INSTALL) -c -m 444 pppdump.8 $(MANDIR)/man8
+diff -ur ppp.old/pppstats/Makefile.linux ppp/pppstats/Makefile.linux
+--- ppp.old/pppstats/Makefile.linux 2002-10-27 14:00:08.000000000 +0100
++++ ppp/pppstats/Makefile.linux 2004-08-22 00:46:05.000000000 +0200
+@@ -11,7 +11,7 @@
+ COMPILE_FLAGS = -I../include
+ LIBS =
+
+-INSTALL= install -o root -g daemon
++INSTALL= install
+
+ CFLAGS = $(COPTS) $(COMPILE_FLAGS)
+
+@@ -19,7 +19,7 @@
+
+ install: pppstats
+ -mkdir -p $(MANDIR)/man8
+- $(INSTALL) -s -c pppstats $(BINDIR)/pppstats
++ $(INSTALL) -c pppstats $(BINDIR)/pppstats
+ $(INSTALL) -c -m 444 pppstats.8 $(MANDIR)/man8/pppstats.8
+
+ pppstats: $(PPPSTATSRCS)
+--- ppp.old/pppd/Makefile.linux 2004-08-22 00:17:31.000000000 +0200
++++ ppp/pppd/Makefile.linux 2004-08-22 01:07:20.000000000 +0200
+@@ -5,7 +5,7 @@
+
+ # Default installation locations
+ BINDIR = $(DESTDIR)/usr/sbin
+-MANDIR = $(DESTDIR)/usr/man
++MANDIR = $(DESTDIR)/usr/share/man
+ INCDIR = $(DESTDIR)/usr/include
+
+ TARGETS = pppd
+@@ -76,7 +76,7 @@
+
+ INCLUDE_DIRS= -I../include
+
+-COMPILE_FLAGS= -DHAVE_PATHS_H -DIPX_CHANGE -DHAVE_MMAP
++COMPILE_FLAGS= -DHAVE_PATHS_H -DIPX_CHANGE
+
+ CFLAGS= $(COPTS) $(COMPILE_FLAGS) $(INCLUDE_DIRS)
+
+@@ -103,7 +103,7 @@
+ ifdef USE_SRP
+ CFLAGS += -DUSE_SRP
+ TARGETS += srp-entry
+-EXTRAINSTALL = $(INSTALL) -s -c -m 555 srp-entry $(BINDIR)/srp-entry
++EXTRAINSTALL = $(INSTALL) -c -m 755 srp-entry $(BINDIR)/srp-entry
+ MANPAGES += srp-entry.8
+ EXTRACLEAN += srp-entry.o
+ NEEDDES=y
+@@ -197,7 +197,7 @@
+
+ ifdef FILTER
+ LIBS += -lpcap
+-CFLAGS += -DPPP_FILTER -I/usr/include/pcap
++CFLAGS += -DPPP_FILTER
+ endif
+
+ ifdef HAVE_INET6
+@@ -218,14 +218,14 @@
+ CFLAGS += -DMAXOCTETS
+ endif
+
+-INSTALL= install -o root
++INSTALL= install
+
+ all: $(TARGETS)
+
+ install: pppd
+ mkdir -p $(BINDIR) $(MANDIR)
+ $(EXTRAINSTALL)
+- $(INSTALL) -s -c -m 555 pppd $(BINDIR)/pppd
++ $(INSTALL) -c -m 755 pppd $(BINDIR)/pppd
+ if chgrp pppusers $(BINDIR)/pppd 2>/dev/null; then \
+ chmod o-rx,u+s $(BINDIR)/pppd; fi
+ $(INSTALL) -c -m 444 pppd.8 $(MANDIR)/man8
diff --git a/nonworking/ppp/ppp/makefilenew.patch b/nonworking/ppp/ppp/makefilenew.patch
index e69de29bb2..60b9885087 100644
--- a/nonworking/ppp/ppp/makefilenew.patch
+++ b/nonworking/ppp/ppp/makefilenew.patch
@@ -0,0 +1,55 @@
+--- ppp.old/pppd/Makefile.linux 2004-08-22 00:17:31.000000000 +0200
++++ ppp/pppd/Makefile.linux 2004-08-22 01:07:20.000000000 +0200
+@@ -5,7 +5,7 @@
+
+ # Default installation locations
+ BINDIR = $(DESTDIR)/usr/sbin
+-MANDIR = $(DESTDIR)/usr/man
++MANDIR = $(DESTDIR)/usr/share/man
+ INCDIR = $(DESTDIR)/usr/include
+
+ TARGETS = pppd
+@@ -76,7 +76,7 @@
+
+ INCLUDE_DIRS= -I../include
+
+-COMPILE_FLAGS= -DHAVE_PATHS_H -DIPX_CHANGE -DHAVE_MMAP
++COMPILE_FLAGS= -DHAVE_PATHS_H -DIPX_CHANGE
+
+ CFLAGS= $(COPTS) $(COMPILE_FLAGS) $(INCLUDE_DIRS)
+
+@@ -103,7 +103,7 @@
+ ifdef USE_SRP
+ CFLAGS += -DUSE_SRP
+ TARGETS += srp-entry
+-EXTRAINSTALL = $(INSTALL) -s -c -m 555 srp-entry $(BINDIR)/srp-entry
++EXTRAINSTALL = $(INSTALL) -c -m 755 srp-entry $(BINDIR)/srp-entry
+ MANPAGES += srp-entry.8
+ EXTRACLEAN += srp-entry.o
+ NEEDDES=y
+@@ -197,7 +197,7 @@
+
+ ifdef FILTER
+ LIBS += -lpcap
+-CFLAGS += -DPPP_FILTER -I/usr/include/pcap
++CFLAGS += -DPPP_FILTER
+ endif
+
+ ifdef HAVE_INET6
+@@ -218,14 +218,14 @@
+ CFLAGS += -DMAXOCTETS
+ endif
+
+-INSTALL= install -o root
++INSTALL= install
+
+ all: $(TARGETS)
+
+ install: pppd
+ mkdir -p $(BINDIR) $(MANDIR)
+ $(EXTRAINSTALL)
+- $(INSTALL) -s -c -m 555 pppd $(BINDIR)/pppd
++ $(INSTALL) -c -m 755 pppd $(BINDIR)/pppd
+ if chgrp pppusers $(BINDIR)/pppd 2>/dev/null; then \
+ chmod o-rx,u+s $(BINDIR)/pppd; fi
+ $(INSTALL) -c -m 444 pppd.8 $(MANDIR)/man8
diff --git a/nonworking/ppp/ppp/no_crypt_hack b/nonworking/ppp/ppp/no_crypt_hack
index e69de29bb2..501409ea9b 100644
--- a/nonworking/ppp/ppp/no_crypt_hack
+++ b/nonworking/ppp/ppp/no_crypt_hack
@@ -0,0 +1,45 @@
+diff -ruN ppp.orig/pppd/auth.c ppp/pppd/auth.c
+--- ppp.orig/pppd/auth.c 2003-06-12 02:01:21.000000000 +0200
++++ ppp/pppd/auth.c 2003-12-02 14:48:40.000000000 +0100
+@@ -1292,8 +1292,10 @@
+ }
+ if (secret[0] != 0 && !login_secret) {
+ /* password given in pap-secrets - must match */
++#ifndef NO_CRYPT_HACK
+ if ((cryptpap || strcmp(passwd, secret) != 0)
+ && strcmp(crypt(passwd, secret), secret) != 0)
++#endif
+ ret = UPAP_AUTHNAK;
+ }
+ }
+@@ -1495,8 +1497,10 @@
+ /*
+ * If no passwd, don't let them login.
+ */
++#ifndef NO_CRYPT_HACK
+ if (pw->pw_passwd == NULL || strlen(pw->pw_passwd) < 2
+ || strcmp(crypt(passwd, pw->pw_passwd), pw->pw_passwd) != 0)
++#endif
+ return (UPAP_AUTHNAK);
+
+ #endif /* #ifdef USE_PAM */
+diff -ruN ppp.orig/pppd/Makefile.linux ppp/pppd/Makefile.linux
+--- ppp.orig/pppd/Makefile.linux 2003-11-27 23:00:22.000000000 +0100
++++ ppp/pppd/Makefile.linux 2003-12-02 14:47:53.000000000 +0100
+@@ -116,12 +116,16 @@
+ #LIBS += -lshadow $(LIBS)
+ endif
+
++ifdef NO_CRYPT_HACK
++CFLAGS += -DNO_CRYPT_HACK
++else
+ ifneq ($(wildcard /usr/include/crypt.h),)
+ CFLAGS += -DHAVE_CRYPT_H=1
+ endif
+ ifneq ($(wildcard /usr/lib/libcrypt.*),)
+ LIBS += -lcrypt
+ endif
++endif
+
+ ifdef NEEDDES
+ ifndef USE_CRYPT
diff --git a/nonworking/ppp/ppp/ppp-2.3.11-oedod.dif b/nonworking/ppp/ppp/ppp-2.3.11-oedod.dif
index e69de29bb2..e024696697 100644
--- a/nonworking/ppp/ppp/ppp-2.3.11-oedod.dif
+++ b/nonworking/ppp/ppp/ppp-2.3.11-oedod.dif
@@ -0,0 +1,172 @@
+--- ppp/pppd/demand.c
++++ ppp/pppd/demand.c 2000/06/28 14:54:04
+@@ -25,6 +25,8 @@
+ #include <errno.h>
+ #include <fcntl.h>
+ #include <netdb.h>
++#include <unistd.h>
++#include <syslog.h>
+ #include <sys/param.h>
+ #include <sys/types.h>
+ #include <sys/wait.h>
+@@ -32,6 +34,8 @@
+ #include <sys/resource.h>
+ #include <sys/stat.h>
+ #include <sys/socket.h>
++#include <netinet/in.h>
++#include <arpa/inet.h>
+ #ifdef PPP_FILTER
+ #include <net/if.h>
+ #include <net/bpf.h>
+@@ -210,6 +214,14 @@
+ int c, rv;
+
+ rv = 0;
++
++/* check for synchronous connection... */
++
++ if ( (p[0] == 0xFF) && (p[1] == 0x03) ) {
++ rv = loop_frame(p,n);
++ return rv;
++ }
++
+ for (; n > 0; --n) {
+ c = *p++;
+ if (c == PPP_FLAG) {
+@@ -288,17 +300,102 @@
+ * loopback, now that the real serial link is up.
+ */
+ void
+-demand_rexmit(proto)
++demand_rexmit(proto, newip)
+ int proto;
++ u_int32_t newip;
+ {
+ struct packet *pkt, *prev, *nextpkt;
++ unsigned short checksum;
++ unsigned short pkt_checksum = 0;
++ unsigned iphdr;
++ struct timeval tv;
++ char cv = 0;
++ char ipstr[16];
+
+ prev = NULL;
+ pkt = pend_q;
+ pend_q = NULL;
++ tv.tv_sec = 1;
++ tv.tv_usec = 0;
++ select(0,NULL,NULL,NULL,&tv); /* Sleep for 1 Seconds */
+ for (; pkt != NULL; pkt = nextpkt) {
+ nextpkt = pkt->next;
+ if (PPP_PROTOCOL(pkt->data) == proto) {
++ if ( (proto == PPP_IP) && newip ) {
++ /* Get old checksum */
++
++ iphdr = (pkt->data[4] & 15) << 2;
++ checksum = *((unsigned short *) (pkt->data+14));
++ if (checksum == 0xFFFF) {
++ checksum = 0;
++ }
++
++
++ if (pkt->data[13] == 17) {
++ pkt_checksum = *((unsigned short *) (pkt->data+10+iphdr));
++ if (pkt_checksum) {
++ cv = 1;
++ if (pkt_checksum == 0xFFFF) {
++ pkt_checksum = 0;
++ }
++ }
++ else {
++ cv = 0;
++ }
++ }
++
++ if (pkt->data[13] == 6) {
++ pkt_checksum = *((unsigned short *) (pkt->data+20+iphdr));
++ cv = 1;
++ if (pkt_checksum == 0xFFFF) {
++ pkt_checksum = 0;
++ }
++ }
++
++ /* Delete old Source-IP-Address */
++ checksum -= *((unsigned short *) (pkt->data+16)) ^ 0xFFFF;
++ checksum -= *((unsigned short *) (pkt->data+18)) ^ 0xFFFF;
++
++ pkt_checksum -= *((unsigned short *) (pkt->data+16)) ^ 0xFFFF;
++ pkt_checksum -= *((unsigned short *) (pkt->data+18)) ^ 0xFFFF;
++
++ /* Change Source-IP-Address */
++ * ((u_int32_t *) (pkt->data + 16)) = newip;
++
++ /* Add new Source-IP-Address */
++ checksum += *((unsigned short *) (pkt->data+16)) ^ 0xFFFF;
++ checksum += *((unsigned short *) (pkt->data+18)) ^ 0xFFFF;
++
++ pkt_checksum += *((unsigned short *) (pkt->data+16)) ^ 0xFFFF;
++ pkt_checksum += *((unsigned short *) (pkt->data+18)) ^ 0xFFFF;
++
++ /* Write new checksum */
++ if (!checksum) {
++ checksum = 0xFFFF;
++ }
++ *((unsigned short *) (pkt->data+14)) = checksum;
++ if (pkt->data[13] == 6) {
++ *((unsigned short *) (pkt->data+20+iphdr)) = pkt_checksum;
++ }
++ if (cv && (pkt->data[13] == 17) ) {
++ *((unsigned short *) (pkt->data+10+iphdr)) = pkt_checksum;
++ }
++
++ /* Log Packet */
++ strcpy(ipstr,inet_ntoa(*( (struct in_addr *) (pkt->data+16))));
++ if (pkt->data[13] == 1) {
++ syslog(LOG_INFO,"Open ICMP %s -> %s\n",
++ ipstr,
++ inet_ntoa(*( (struct in_addr *) (pkt->data+20))));
++ } else {
++ syslog(LOG_INFO,"Open %s %s:%d -> %s:%d\n",
++ pkt->data[13] == 6 ? "TCP" : "UDP",
++ ipstr,
++ ntohs(*( (short *) (pkt->data+iphdr+4))),
++ inet_ntoa(*( (struct in_addr *) (pkt->data+20))),
++ ntohs(*( (short *) (pkt->data+iphdr+6))));
++ }
++ }
+ output(0, pkt->data, pkt->length);
+ free(pkt);
+ } else {
+--- ppp/pppd/ipcp.c
++++ ppp/pppd/ipcp.c 2000/06/28 12:32:05
+@@ -1454,7 +1454,7 @@
+ proxy_arp_set[f->unit] = 1;
+
+ }
+- demand_rexmit(PPP_IP);
++ demand_rexmit(PPP_IP,go->ouraddr);
+ sifnpmode(f->unit, PPP_IP, NPMODE_PASS);
+
+ } else {
+--- ppp/pppd/ipv6cp.c
++++ ppp/pppd/ipv6cp.c 2000/06/28 12:32:06
+@@ -1153,7 +1153,7 @@
+ }
+
+ }
+- demand_rexmit(PPP_IPV6);
++ demand_rexmit(PPP_IPV6,0);
+ sifnpmode(f->unit, PPP_IPV6, NPMODE_PASS);
+
+ } else {
+--- ppp/pppd/pppd.h
++++ ppp/pppd/pppd.h 2000/06/28 12:32:06
+@@ -359,7 +359,7 @@
+ void demand_block __P((void)); /* set all NPs to queue up packets */
+ void demand_unblock __P((void)); /* set all NPs to pass packets */
+ void demand_discard __P((void)); /* set all NPs to discard packets */
+-void demand_rexmit __P((int)); /* retransmit saved frames for an NP */
++void demand_rexmit __P((int, u_int32_t)); /* retransmit saved frames for an NP*/
+ int loop_chars __P((unsigned char *, int)); /* process chars from loopback */
+ int loop_frame __P((unsigned char *, int)); /* should we bring link up? */
+
diff --git a/nonworking/ppp/ppp/ppp-2.4.2-stripMSdomain b/nonworking/ppp/ppp/ppp-2.4.2-stripMSdomain
index e69de29bb2..d52e38645d 100644
--- a/nonworking/ppp/ppp/ppp-2.4.2-stripMSdomain
+++ b/nonworking/ppp/ppp/ppp-2.4.2-stripMSdomain
@@ -0,0 +1,35 @@
+diff -ruN ppp.orig/pppd/chap-new.c ppp/pppd/chap-new.c
+--- ppp.orig/pppd/chap-new.c 2003-11-27 23:25:17.000000000 +0100
++++ ppp/pppd/chap-new.c 2003-12-02 12:26:21.000000000 +0100
+@@ -57,6 +57,7 @@
+ int chap_timeout_time = 3;
+ int chap_max_transmits = 10;
+ int chap_rechallenge_time = 0;
++int chapms_strip_domain = 0;
+
+ /*
+ * Command-line options.
+@@ -68,6 +69,8 @@
+ "Set max #xmits for challenge", OPT_PRIO },
+ { "chap-interval", o_int, &chap_rechallenge_time,
+ "Set interval for rechallenge", OPT_PRIO },
++ { "chapms-strip-domain", o_bool, &chapms_strip_domain,
++ "Strip the domain prefix before the Username", 1 },
+ { NULL }
+ };
+
+@@ -338,6 +341,14 @@
+ /* Null terminate and clean remote name. */
+ slprintf(rname, sizeof(rname), "%.*v", len, name);
+ name = rname;
++
++ /* strip the MS domain name */
++ if (chapms_strip_domain && strrchr(rname, '\\')) {
++ char tmp[MAXNAMELEN+1];
++
++ strcpy(tmp, strrchr(rname, '\\') + 1);
++ strcpy(rname, tmp);
++ }
+ }
+
+ if (chap_verify_hook)
diff --git a/nonworking/ppp/ppp/pppdump-no-deflate b/nonworking/ppp/ppp/pppdump-no-deflate
index e69de29bb2..b76b84911c 100644
--- a/nonworking/ppp/ppp/pppdump-no-deflate
+++ b/nonworking/ppp/ppp/pppdump-no-deflate
@@ -0,0 +1,12 @@
+diff -ruN ppp-2.4.1.uus.orig/pppdump/ppp-comp.h ppp-2.4.1.uus/pppdump/ppp-comp.h
+--- ppp-2.4.1.uus.orig/pppdump/ppp-comp.h 1999-03-23 04:21:01.000000000 +0100
++++ ppp-2.4.1.uus/pppdump/ppp-comp.h 2003-08-09 23:54:49.000000000 +0200
+@@ -37,6 +37,8 @@
+ #ifndef DO_BSD_COMPRESS
+ #define DO_BSD_COMPRESS 1 /* by default, include BSD-Compress */
+ #endif
++#undef DO_DEFLATE
++#define DO_DEFLATE 0
+ #ifndef DO_DEFLATE
+ #define DO_DEFLATE 1 /* by default, include Deflate */
+ #endif
diff --git a/nonworking/ppp/ppp/pppoe_discovery b/nonworking/ppp/ppp/pppoe_discovery
index e69de29bb2..0f84cf1709 100644
--- a/nonworking/ppp/ppp/pppoe_discovery
+++ b/nonworking/ppp/ppp/pppoe_discovery
@@ -0,0 +1,150 @@
+diff -ruNp ppp.orig/pppd/plugins/rp-pppoe/Makefile.linux ppp/pppd/plugins/rp-pppoe/Makefile.linux
+--- ppp.orig/pppd/plugins/rp-pppoe/Makefile.linux 2004-01-13 05:00:17.000000000 +0100
++++ ppp/pppd/plugins/rp-pppoe/Makefile.linux 2004-07-16 19:27:40.000000000 +0200
+@@ -18,7 +18,13 @@ VERSION=3.3
+
+ COPTS=-O2 -g
+ CFLAGS=$(COPTS) -I../../../include/linux
+-all: rp-pppoe.so
++all: rp-pppoe.so pppoe-discovery
++
++pppoe-discovery: libplugin.a pppoe-discovery.o
++ gcc -o pppoe-discovery pppoe-discovery.o libplugin.a
++
++pppoe-discovery.o: pppoe-discovery.c
++ gcc $(CFLAGS) '-DVERSION="$(VERSION)"' -c -o pppoe-discovery.o pppoe-discovery.c
+
+ rp-pppoe.so: libplugin.a plugin.o
+ gcc -o rp-pppoe.so -shared plugin.o libplugin.a
+@@ -26,6 +32,8 @@ rp-pppoe.so: libplugin.a plugin.o
+ install: all
+ $(INSTALL) -d -m 755 $(LIBDIR)
+ $(INSTALL) -s -c -m 4550 rp-pppoe.so $(LIBDIR)
++ $(INSTALL) -d -m 755 $(BINDIR)
++ $(INSTALL) -s -c -m 555 pppoe-discovery $(BINDIR)/pppoe-discovery
+
+ clean:
+ rm -f *.o *.so
+diff -ruNp ppp.orig/pppd/plugins/rp-pppoe/pppoe-discovery.c ppp/pppd/plugins/rp-pppoe/pppoe-discovery.c
+--- ppp.orig/pppd/plugins/rp-pppoe/pppoe-discovery.c 1970-01-01 01:00:00.000000000 +0100
++++ ppp/pppd/plugins/rp-pppoe/pppoe-discovery.c 2004-07-16 19:26:20.000000000 +0200
+@@ -0,0 +1,119 @@
++/*
++ * Perform PPPoE discovery
++ *
++ * Copyright (C) 2000-2001 by Roaring Penguin Software Inc.
++ * Copyright (C) 2004 Marco d'Itri <md@linux.it>
++ *
++ * This program may be distributed according to the terms of the GNU
++ * General Public License, version 2 or (at your option) any later version.
++ *
++ */
++
++#include <stdio.h>
++#include <stdlib.h>
++#include <unistd.h>
++#include <errno.h>
++#include <string.h>
++
++#include "pppoe.h"
++
++char *xstrdup(const char *s);
++void usage(void);
++
++int main(int argc, char *argv[])
++{
++ int opt;
++ PPPoEConnection *conn;
++
++ conn = malloc(sizeof(PPPoEConnection));
++ if (!conn)
++ fatalSys("malloc");
++
++ memset(conn, 0, sizeof(PPPoEConnection));
++
++ while ((opt = getopt(argc, argv, "I:D:VUAS:C:h")) > 0) {
++ switch(opt) {
++ case 'S':
++ conn->serviceName = xstrdup(optarg);
++ break;
++ case 'C':
++ conn->acName = xstrdup(optarg);
++ break;
++ case 'U':
++ conn->useHostUniq = 1;
++ break;
++ case 'D':
++ conn->debugFile = fopen(optarg, "w");
++ if (!conn->debugFile) {
++ fprintf(stderr, "Could not open %s: %s\n",
++ optarg, strerror(errno));
++ exit(1);
++ }
++ fprintf(conn->debugFile, "pppoe-discovery %s\n", VERSION);
++ break;
++ case 'I':
++ conn->ifName = xstrdup(optarg);
++ break;
++ case 'A':
++ /* this is the default */
++ break;
++ case 'V':
++ case 'h':
++ usage();
++ exit(0);
++ default:
++ usage();
++ exit(1);
++ }
++ }
++
++ /* default interface name */
++ if (!conn->ifName)
++ conn->ifName = strdup("eth0");
++
++ conn->discoverySocket = -1;
++ conn->sessionSocket = -1;
++ conn->printACNames = 1;
++
++ discovery(conn);
++ exit(0);
++}
++
++void rp_fatal(char const *str)
++{
++ char buf[1024];
++
++ printErr(str);
++ sprintf(buf, "pppoe-discovery: %.256s", str);
++ exit(1);
++}
++
++void fatalSys(char const *str)
++{
++ char buf[1024];
++ int i = errno;
++
++ sprintf(buf, "%.256s: %.256s", str, strerror(i));
++ printErr(buf);
++ sprintf(buf, "pppoe-discovery: %.256s: %.256s", str, strerror(i));
++ exit(1);
++}
++
++void sysErr(char const *str)
++{
++ rp_fatal(str);
++}
++
++char *xstrdup(const char *s)
++{
++ register char *ret = strdup(s);
++ if (!ret)
++ sysErr("strdup");
++ return ret;
++}
++
++void usage(void)
++{
++ fprintf(stderr, "Usage: pppoe-discovery [options]\n");
++ fprintf(stderr, "\nVersion " VERSION "\n");
++}
diff --git a/nonworking/ppp/ppp/setevn_call_file b/nonworking/ppp/ppp/setevn_call_file
index e69de29bb2..256b703f79 100644
--- a/nonworking/ppp/ppp/setevn_call_file
+++ b/nonworking/ppp/ppp/setevn_call_file
@@ -0,0 +1,24 @@
+diff -ruN ppp.orig/pppd/options.c ppp/pppd/options.c
+--- ppp.orig/pppd/options.c 2004-02-27 19:45:18.000000000 +0100
++++ ppp/pppd/options.c 2004-02-27 19:44:48.000000000 +0100
+@@ -1448,6 +1448,7 @@
+ if ((fname = (char *) malloc(l)) == NULL)
+ novm("call file name");
+ slprintf(fname, l, "%s%s", _PATH_PEERFILES, arg);
++ script_setenv("CALL_FILE", arg, 0);
+
+ ok = options_from_file(fname, 1, 1, 1);
+
+diff -ruN ppp.orig/pppd/pppd.8 ppp/pppd/pppd.8
+--- ppp.orig/pppd/pppd.8 2004-02-27 19:45:18.000000000 +0100
++++ ppp/pppd/pppd.8 2004-02-27 19:45:13.000000000 +0100
+@@ -1569,6 +1569,9 @@
+ .B LINKNAME
+ The logical name of the link, set with the \fIlinkname\fR option.
+ .TP
++.B CALL_FILE
++The value of the \fIcall\fR option.
++.TP
+ .B DNS1
+ If the peer supplies DNS server addresses, this variable is set to the
+ first DNS server address supplied.
diff --git a/nonworking/ppp/ppp/syslog_local2 b/nonworking/ppp/ppp/syslog_local2
index e69de29bb2..32a8cead9e 100644
--- a/nonworking/ppp/ppp/syslog_local2
+++ b/nonworking/ppp/ppp/syslog_local2
@@ -0,0 +1,12 @@
+diff -ruN ppp.orig/pppd/pppd.h ppp/pppd/pppd.h
+--- ppp.orig/pppd/pppd.h 2003-11-28 00:30:27.000000000 +0100
++++ ppp/pppd/pppd.h 2003-11-28 00:30:20.000000000 +0100
+@@ -812,7 +812,7 @@
+ || defined(DEBUGCHAP) || defined(DEBUG) || defined(DEBUGIPV6CP)
+ #define LOG_PPP LOG_LOCAL2
+ #else
+-#define LOG_PPP LOG_DAEMON
++#define LOG_PPP LOG_LOCAL2
+ #endif
+ #endif /* LOG_PPP */
+
diff --git a/nonworking/ppp/ppp/use_openssl b/nonworking/ppp/ppp/use_openssl
index e69de29bb2..5f111d1eaf 100644
--- a/nonworking/ppp/ppp/use_openssl
+++ b/nonworking/ppp/ppp/use_openssl
@@ -0,0 +1,150 @@
+The built-in SHA1 code is broken on 64 bit systems.
+Using a system library may be considered a good idea anyway.
+
+
+diff -ruNp ppp.orig/pppd/chap-md5.c ppp/pppd/chap-md5.c
+--- ppp.orig/pppd/chap-md5.c 2003-11-27 23:25:17.000000000 +0100
++++ ppp/pppd/chap-md5.c 2004-07-14 16:45:46.000000000 +0200
+@@ -41,7 +41,14 @@
+ #include "chap-new.h"
+ #include "chap-md5.h"
+ #include "magic.h"
++#ifdef USE_OPENSSL
++#include <openssl/md5.h>
++#define MD5Init MD5_Init
++#define MD5Update MD5_Update
++#define MD5Final MD5_Final
++#else
+ #include "md5.h"
++#endif
+
+ #define MD5_HASH_SIZE 16
+ #define MD5_MIN_CHALLENGE 16
+diff -ruNp ppp.orig/pppd/chap_ms.c ppp/pppd/chap_ms.c
+--- ppp.orig/pppd/chap_ms.c 2004-04-14 04:40:21.000000000 +0200
++++ ppp/pppd/chap_ms.c 2004-07-14 16:46:03.000000000 +0200
+@@ -89,8 +89,21 @@
+ #include "pppd.h"
+ #include "chap-new.h"
+ #include "chap_ms.h"
++#ifdef USE_OPENSSL
++#include <openssl/md4.h>
++#define MD4Init MD4_Init
++#define MD4Update MD4_Update
++#define MD4Final MD4_Final
++#else
+ #include "md4.h"
++#endif
++#ifdef USE_OPENSSL
++#include <openssl/sha.h>
++#define SHA1_SIGNATURE_SIZE SHA_DIGEST_LENGTH
++#define SHA1_CTX SHA_CTX
++#else
+ #include "sha1.h"
++#endif
+ #include "pppcrypt.h"
+ #include "magic.h"
+
+@@ -513,7 +526,7 @@ ascii2unicode(char ascii[], int ascii_le
+ static void
+ NTPasswordHash(char *secret, int secret_len, u_char hash[MD4_SIGNATURE_SIZE])
+ {
+-#ifdef __NetBSD__
++#if defined __NetBSD__ || defined USE_OPENSSL
+ /* NetBSD uses the libc md4 routines which take bytes instead of bits */
+ int mdlen = secret_len;
+ #else
+diff -ruNp ppp.orig/pppd/eap.c ppp/pppd/eap.c
+--- ppp.orig/pppd/eap.c 2003-06-12 02:01:21.000000000 +0200
++++ ppp/pppd/eap.c 2004-07-14 16:45:46.000000000 +0200
+@@ -62,7 +62,14 @@
+
+ #include "pppd.h"
+ #include "pathnames.h"
++#ifdef USE_OPENSSL
++#include <openssl/md5.h>
++#define MD5Init MD5_Init
++#define MD5Update MD5_Update
++#define MD5Final MD5_Final
++#else
+ #include "md5.h"
++#endif
+ #include "eap.h"
+
+ #ifdef USE_SRP
+diff -ruNp ppp.orig/pppd/Makefile.linux ppp/pppd/Makefile.linux
+--- ppp.orig/pppd/Makefile.linux 2004-07-14 16:46:44.000000000 +0200
++++ ppp/pppd/Makefile.linux 2004-07-14 16:45:46.000000000 +0200
+@@ -10,7 +10,7 @@ INCDIR = $(DESTDIR)/usr/include
+
+ TARGETS = pppd
+
+-PPPDSRCS = main.c magic.c fsm.c lcp.c ipcp.c upap.c chap-new.c md5.c ccp.c \
++PPPDSRCS = main.c magic.c fsm.c lcp.c ipcp.c upap.c chap-new.c ccp.c \
+ ecp.c ipxcp.c auth.c options.c sys-linux.c md4.c chap_ms.c \
+ demand.c utils.c tty.c eap.c chap-md5.c
+
+@@ -19,7 +19,7 @@ HEADERS = ccp.h chap-new.h ecp.h fsm.h i
+ upap.h eap.h
+
+ MANPAGES = pppd.8
+-PPPDOBJS = main.o magic.o fsm.o lcp.o ipcp.o upap.o chap-new.o md5.o ccp.o \
++PPPDOBJS = main.o magic.o fsm.o lcp.o ipcp.o upap.o chap-new.o ccp.o \
+ ecp.o auth.o options.o demand.o utils.o sys-linux.o ipxcp.o tty.o \
+ eap.o chap-md5.o
+
+@@ -83,8 +83,14 @@ CFLAGS= $(COPTS) $(COMPILE_FLAGS) $(INCL
+ ifdef CHAPMS
+ CFLAGS += -DCHAPMS=1
+ NEEDDES=y
++ifdef USE_BUILTIN_CRYPTO
+ PPPDOBJS += md4.o chap_ms.o
+-HEADERS += md4.h chap_ms.h
++HEADERS += md4.h chap_ms.h
++else
++PPPDOBJS += chap_ms.o
++HEADERS += chap_ms.h
++NEED_OPENSSL=y
++endif
+ ifdef MSLANMAN
+ CFLAGS += -DMSLANMAN=1
+ endif
+@@ -95,20 +101,36 @@ endif
+
+ # EAP SRP-SHA1
+ ifdef USE_SRP
+-CFLAGS += -DUSE_SRP -DOPENSSL -I/usr/local/ssl/include
+-LIBS += -lsrp -L/usr/local/ssl/lib -lcrypto
++CFLAGS += -DUSE_SRP
+ TARGETS += srp-entry
+ EXTRAINSTALL = $(INSTALL) -s -c -m 555 srp-entry $(BINDIR)/srp-entry
+ MANPAGES += srp-entry.8
+ EXTRACLEAN += srp-entry.o
+ NEEDDES=y
++NEED_OPENSSL=y
+ else
+ # OpenSSL has an integrated version of SHA-1, and its implementation
+ # is incompatible with this local SHA-1 implementation. We must use
+ # one or the other, not both.
++ifdef USE_BUILTIN_CRYPTO
+ PPPDSRCS += sha1.c
+ HEADERS += sha1.h
+ PPPDOBJS += sha1.o
++else
++NEED_OPENSSL=y
++endif
++endif
++
++ifdef USE_BUILTIN_CRYPTO
++PPPDSRCS += md5.c
++PPPDOBJS += md5.o
++else
++NEED_OPENSSL=y
++endif
++
++ifdef NEED_OPENSSL
++CFLAGS += -DUSE_OPENSSL
++LIBS += -lcrypto
+ endif
+
+ ifdef HAS_SHADOW