$inf = $INET_INFNAME; $infp = XNODE_getpathbytarget("", "inf", "uid", $inf, 0); $phyinf = query($infp . "/phyinf"); $inet = query($infp . "/inet"); $inetp = XNODE_getpathbytarget("/inet", "entry", "uid", $inet, 0); $ifname = PHYINF_getifname($phyinf); $default = query($infp . "/defaultroute"); $child = query($infp . "/child"); $addrtype = query($inetp . "/addrtype"); $dial = XNODE_get_var($inf . ".DIALUP"); if ($dial == "") { $dial = query($inetp . "/ppp6/dialup/mode"); } fwrite("a", $START, 'event ' . $inf . '.PPP.AUTHFAILED add true\\n'); /* generate option file */ $optfile = pppoptions($inf, $ifname, $inetp . "/ppp6", $default, $dial, $addrtype); fwrite("a", $START, "# optfile = [" . $optfile . "]\n"); /* Files */ $sfile = "/var/run/ppp-" . $inf . ".status"; $pppd_pid = "/var/run/ppp-" . $inf . ".pid"; $dialuppid = "/var/run/ppp-" . $inf . "-dialup.pid"; $dialupsh = "/var/run/ppp-" . $inf . "-dialup.sh"; $hangupsh = "/var/run/ppp-" . $inf . "-hangup.sh"; /* Dialup/Hangup script ******************************/ fwrite(w, $dialupsh, "#!/bin/sh\n"); fwrite(w, $hangupsh, "#!/bin/sh\n"); fwrite(a, $hangupsh, '/etc/scripts/killpid.sh ' . $pppd_pid . '\\n'); fwrite(a, $dialupsh, 'if [ -f ' . $dialuppid . ' ]; then\\n' . ' echo [$0]: already dialing ...\\n' . ' exit 0\\n' . 'fi\\n' . 'xmldbc -k redial.' . $inf . '\\n' . 'event DIALINIT \\n' . 'echo $$ > ' . $dialuppid . '\\n' . 'pppd file ' . $optfile . ' > /dev/console\\n'); if ($dial != "manual") { fwrite(a, $dialupsh, 'xmldbc -t redial.' . $inf . ':5:' . $dialupsh . '\\n'); }
/* Get NAT */ $nat = query($infp . "/nat"); $natp = XNODE_getpathbytarget("/nat", "entry", "uid", $nat, 0); /* enable netsniper, must remove sw_tcpip module. Or else web access from lan will fail! */ if (query($natp . "/netsniper/enable") == 1) { fwrite("a", $START, "rmmod sw_tcpip\n"); fwrite("a", $STOP, "insmod /lib/modules/sw_tcpip.ko\n"); } } /* Adjust the dialup mode. If the dialup mode is on demand, PPPD must handle this. * If not, the INET.COMBO.XXX will handle the dialup mode. So better be manual mode here. */ if ($lower != "" && $dial != "ondemand") { $dial = "manual"; } /* generate option file */ $optfile = pppoptions($inf, $ifname, $inetp . "/ppp4", $default, $dial); fwrite("a", $START, "# optfile = [" . $optfile . "]\n"); /* Files */ $sfile = "/var/run/ppp-" . $inf . ".status"; $pppd_pid = "/var/run/ppp-" . $inf . ".pid"; $dialuppid = "/var/run/ppp-" . $inf . "-dialup.pid"; $dialupsh = "/var/run/ppp-" . $inf . "-dialup.sh"; $hangupsh = "/var/run/ppp-" . $inf . "-hangup.sh"; /* Dialup/Hangup script ****************************/ fwrite(w, $dialupsh, "#!/bin/sh\n"); fwrite(w, $hangupsh, "#!/bin/sh\n"); /* Special process for private packets leaked */ fwrite("a", $dialupsh, 'iptables -t nat -D POSTROUTING -o ppp+ -j MASQUERADE\\n' . 'iptables -t nat -A POSTROUTING -o ppp+ -j MASQUERADE\\n'); fwrite(a, $hangupsh, '/etc/scripts/killpid.sh ' . $pppd_pid . '\\n'); fwrite(a, $dialupsh, 'if [ -f ' . $dialuppid . ' ]; then\\n' . ' echo [$0]: already dialing ...\\n' . ' exit 0\\n' . 'fi\\n' . 'xmldbc -k redial.' . $inf . '\\n' . 'event DIALINIT \\n' . 'echo $$ > ' . $dialuppid . '\\n' . 'pppd file ' . $optfile . ' > /dev/console\\n'); if ($dial != "manual") {