SVN-Revision: 3588master
parent
e4b534024d
commit
ee27e41337
@ -1,31 +0,0 @@ |
||||
# |
||||
|
||||
menu "Runtime Configuration" |
||||
choice |
||||
bool "Telnet access" |
||||
default BR2_SYSCONF_TELNET_FAILSAFE_ONLY |
||||
|
||||
config BR2_SYSCONF_TELNET_FAILSAFE_ONLY |
||||
bool "open, failsafe only" |
||||
|
||||
config BR2_SYSCONF_TELNET_OPEN |
||||
bool "open" |
||||
|
||||
endchoice |
||||
|
||||
menu "Failsafe configuration" |
||||
|
||||
config BR2_SYSCONF_FAILSAFE_IP |
||||
string "IP Address" |
||||
default "192.168.1.1" |
||||
|
||||
config BR2_SYSCONF_FAILSAFE_NETMASK |
||||
string "Netmask" |
||||
default "255.255.255.0" |
||||
|
||||
config BR2_SYSCONF_FAILSAFE_MAC |
||||
string "MAC Address" |
||||
default "00:00:BA:DC:0D:ED" |
||||
|
||||
endmenu |
||||
endmenu |
@ -1,62 +1,88 @@ |
||||
#!/bin/sh |
||||
# $Id$ |
||||
|
||||
mount | grep squashfs >&- || { |
||||
echo "You do not have a squashfs partition; aborting" |
||||
echo "(firstboot cannot be run on jffs2 based firmwares)" |
||||
return |
||||
rom=$(awk '/squashfs/ {print $2}' /proc/mounts) |
||||
jffs=$(awk '/jffs2/ {print $2}' /proc/mounts) |
||||
|
||||
dupe() { # <new_root> <old_root> |
||||
cd $1 |
||||
echo -n "creating directories... " |
||||
{ |
||||
cd $2 |
||||
find . -xdev -type d |
||||
echo "./dev ./jffs ./mnt ./proc ./tmp ./sys" |
||||
# xdev skips mounted directories |
||||
cd $1 |
||||
} | xargs mkdir -p |
||||
echo "done" |
||||
|
||||
echo -n "setting up symlinks... " |
||||
for file in $(cd $2; find . -xdev -type f;); do |
||||
case "$file" in |
||||
"./rom/note") ;; #nothing |
||||
"./etc/config"|\ |
||||
"./etc/resolv.conf"|\ |
||||
"./usr/lib/ipkg/info") cp -af $2/$file $file;; |
||||
*) ln -sf /rom/${file#./*} $file;; |
||||
esac |
||||
done |
||||
for file in $(cd $2; find . -xdev -type l;); do |
||||
cp -af $2/${file#./*} $file |
||||
done |
||||
echo "done" |
||||
} |
||||
|
||||
[ -f "/tmp/.firstboot" ] && { |
||||
echo "firstboot is already running" |
||||
return |
||||
pivot() { # <new_root> <old_root> |
||||
mount -o move /proc $1/proc && \ |
||||
pivot_root $1 $1$2 && { |
||||
mount -o move $2/dev /dev |
||||
mount -o move $2/tmp /tmp |
||||
} |
||||
} |
||||
touch /tmp/.firstboot |
||||
|
||||
jdev=$(mount | awk '/jffs2/ {print $3}') |
||||
mountdp() { # <device> <mount_point> <ignored> <fs> |
||||
dev=$1; mnt=$2; shift 2; opt=$* |
||||
mount $dev $mnt $opt |
||||
dupe $mnt $rom |
||||
pivot $mnt /rom |
||||
} |
||||
|
||||
if [ -z "$jdev" ]; then |
||||
echo -n "Creating jffs2 partition... " |
||||
mtd erase OpenWrt >&- 2>&- |
||||
mount -t jffs2 /dev/mtdblock/4 /jffs |
||||
echo "done" |
||||
cd /jffs |
||||
else |
||||
echo "firstboot has already been run" |
||||
echo "jffs2 partition is mounted, only resetting files" |
||||
cd $jdev |
||||
fi |
||||
|
||||
exec 2>/dev/null |
||||
|
||||
mount /dev/mtdblock/2 /rom -o ro |
||||
|
||||
echo -n "creating directories... " |
||||
{ |
||||
cd /rom |
||||
find . -type d |
||||
cd - |
||||
} | xargs mkdir |
||||
echo "done" |
||||
|
||||
echo -n "setting up symlinks... " |
||||
for file in $(cd /rom; find * -type f; find * -type l;) |
||||
do { |
||||
case "${file%/*}" in |
||||
"usr/lib/ipkg/info"|"etc/config") cp -f /rom/$file $file;; |
||||
*) ln -sf /rom/$file $file;; |
||||
esac |
||||
} done |
||||
echo "done" |
||||
|
||||
touch /tmp/resolv.conf |
||||
ln -s /tmp/resolv.conf /etc/resolv.conf |
||||
|
||||
umount /rom |
||||
mount none /jffs/proc -t proc |
||||
pivot_root /jffs /jffs/rom |
||||
mount none /dev -t devfs |
||||
mount none /tmp -t ramfs |
||||
umount /rom/proc |
||||
umount /rom/tmp |
||||
umount /rom/dev |
||||
ramoverlay() { |
||||
mkdir -p /tmp/root |
||||
mountdp /tmp/root /mnt -o bind |
||||
} |
||||
|
||||
[ "${0##*/}" = "firstboot" ] && { |
||||
[ -z "$rom" ] && { |
||||
echo "You do not have a squashfs partition; aborting" |
||||
echo "(firstboot cannot be run on jffs2 based firmwares)" |
||||
exit 1 |
||||
} |
||||
|
||||
[ "$1" = "switch2jffs" ] && { |
||||
mtd erase OpenWrt |
||||
mount -o remount,ro none / # try to avoid fs changing while copying |
||||
mount -o bind / /mnt |
||||
mount /dev/mtdblock/4 /rom/jffs -t jffs2 |
||||
echo -n "copying files ... " |
||||
cp -a /mnt/* /rom/jffs |
||||
umount /mnt |
||||
echo "done" |
||||
pivot /rom /mnt |
||||
mount -o move /mnt /tmp/root |
||||
pivot /jffs /rom |
||||
jffs2root --clean |
||||
exit 0 |
||||
} |
||||
|
||||
# script run manually |
||||
[ \! -z "$jffs" ] && { |
||||
echo "firstboot has already been run" |
||||
echo "jffs2 partition is mounted, only resetting files" |
||||
dupe $jffs $rom |
||||
exit 0 |
||||
} |
||||
|
||||
mtd erase OpenWrt |
||||
mountdp /dev/mtdblock/4 /jffs -t jffs2 |
||||
} |
||||
|
@ -0,0 +1,32 @@ |
||||
#!/bin/sh |
||||
|
||||
awk -f /usr/lib/common.awk -f - $* <<EOF |
||||
BEGIN { |
||||
ipaddr=ip2int(ARGV[1]) |
||||
netmask=ip2int(ARGV[2]) |
||||
network=and(ipaddr,netmask) |
||||
broadcast=or(network,compl(netmask)) |
||||
|
||||
start=or(network,and(ip2int(ARGV[3]),compl(netmask))) |
||||
limit=network+1 |
||||
if (start<limit) start=limit |
||||
|
||||
end=start+ARGV[4] |
||||
limit=or(network,compl(netmask))-1 |
||||
if (end>limit) end=limit |
||||
|
||||
print "IP="int2ip(ipaddr) |
||||
print "NETMASK="int2ip(netmask) |
||||
print "BROADCAST="int2ip(broadcast) |
||||
print "NETWORK="int2ip(network) |
||||
print "PREFIX="32-bitcount(compl(netmask)) |
||||
|
||||
# range calculations: |
||||
# ipcalc <ip> <netmask> <start> <num> |
||||
|
||||
if (ARGC > 3) { |
||||
print "START="int2ip(start) |
||||
print "END="int2ip(end) |
||||
} |
||||
} |
||||
EOF |
@ -1,20 +1,16 @@ |
||||
#!/bin/sh |
||||
. /etc/sysconf 2>&- |
||||
|
||||
[ "$FAILSAFE" != "true" ] && |
||||
[ "$BR2_SYSCONF_TELNET_FAILSAFE_ONLY" = "y" ] && |
||||
grep '^root:[^!]' /etc/passwd >&- 2>&- |
||||
[ "$?" = "0" -a -z "$FAILSAFE" ] && |
||||
{ |
||||
grep '^root:[^!]' /etc/passwd >&- 2>&- && |
||||
{ |
||||
echo "Login failed." |
||||
exit 0 |
||||
} || { |
||||
} || { |
||||
cat << EOF |
||||
=== IMPORTANT ============================ |
||||
Use 'passwd' to set your login password |
||||
this will disable telnet and enable SSH |
||||
------------------------------------------ |
||||
EOF |
||||
} |
||||
} |
||||
|
||||
exec /bin/ash --login |
||||
|
@ -1,29 +0,0 @@ |
||||
#!/bin/sh |
||||
. /etc/functions.sh |
||||
. /etc/network.overrides |
||||
[ "$FAILSAFE" != "true" -a -e /etc/config/network ] && . /etc/config/network |
||||
|
||||
WAN=$(nvram get wan_ifname) |
||||
LAN=$(nvram get lan_ifname) |
||||
|
||||
iptables -F input_rule |
||||
iptables -F output_rule |
||||
iptables -F forwarding_rule |
||||
iptables -t nat -F prerouting_rule |
||||
iptables -t nat -F postrouting_rule |
||||
|
||||
### BIG FAT DISCLAIMER |
||||
### The "-i $WAN" literally means packets that came in over the $WAN interface; |
||||
### this WILL NOT MATCH packets sent from the LAN to the WAN address. |
||||
|
||||
### Allow SSH on the WAN interface |
||||
# iptables -t nat -A prerouting_rule -i $WAN -p tcp --dport 22 -j ACCEPT |
||||
# iptables -A input_rule -i $WAN -p tcp --dport 22 -j ACCEPT |
||||
|
||||
### Port forwarding |
||||
# iptables -t nat -A prerouting_rule -i $WAN -p tcp --dport 22 -j DNAT --to 192.168.1.2 |
||||
# iptables -A forwarding_rule -i $WAN -p tcp --dport 22 -d 192.168.1.2 -j ACCEPT |
||||
|
||||
### DMZ (should be placed after port forwarding / accept rules) |
||||
# iptables -t nat -A prerouting_rule -i $WAN -j DNAT --to 192.168.1.2 |
||||
# iptables -A forwarding_rule -i $WAN -d 192.168.1.2 -j ACCEPT |
@ -1,16 +0,0 @@ |
||||
#!/bin/sh |
||||
. /etc/functions.sh |
||||
[ "$FAILSAFE" != "true" -a -e /etc/config/network ] && . /etc/config/network |
||||
case "$1" in |
||||
start|restart) |
||||
# ifup lan |
||||
# ifup wan |
||||
# ifup wifi |
||||
# wifi up |
||||
|
||||
for route in $(nvram get static_route); do { |
||||
eval "set $(echo $route | sed 's/:/ /g')" |
||||
$DEBUG route add -net $1 netmask $2 gw $3 metric $4 dev $5 |
||||
} done |
||||
;; |
||||
esac |
@ -1,2 +1,2 @@ |
||||
#!/bin/sh |
||||
if awk -F: '/^root:/ && $2 !~ /\!/ {exit 1}' /etc/passwd 2>/dev/null || test $FAILSAFE; then telnetd -l /bin/login; fi |
||||
if awk -F: '/^root:/ && $2 !~ /\!/ {exit 1}' /etc/passwd 2>/dev/null; then telnetd -l /bin/login; fi |
||||
|
@ -1,6 +1,4 @@ |
||||
#!/bin/sh |
||||
[ -d /etc/crontabs ] || mkdir -p /etc/crontabs |
||||
[ -e /var/spool/cron/crontabs ] || { |
||||
mkdir -p /var/spool/cron |
||||
ln -s /etc/crontabs /var/spool/cron/crontabs |
||||
} && crond -c /etc/crontabs |
||||
mkdir -p /var/spool/cron |
||||
ln -s /etc/crontabs /var/spool/cron/crontabs |
||||
crond -c /etc/crontabs |
||||
|
@ -0,0 +1,9 @@ |
||||
#!/bin/sh |
||||
sysctl -p >&- |
||||
|
||||
# automagically run firstboot |
||||
{ mount|grep "on / type tmpfs" 1>&-; } && { |
||||
lock /tmp/.switch2jffs |
||||
firstboot switch2jffs |
||||
lock -u /tmp/.switch2jffs |
||||
} |
@ -1,4 +0,0 @@ |
||||
#!/bin/sh |
||||
# set leds to normal state |
||||
[ -f /proc/sys/diag ] && echo "0x00" > /proc/sys/diag |
||||
sysctl -p >&- |
@ -1,4 +1,3 @@ |
||||
::sysinit:/etc/init.d/rcS |
||||
::shutdown:/sbin/halt |
||||
tts/0::askfirst:/bin/ash --login |
||||
#tts/1::askfirst:/bin/ash --login |
||||
|
@ -1,24 +1,11 @@ |
||||
#!/bin/sh |
||||
. /etc/nvram.sh |
||||
export PATH=/bin:/sbin:/usr/bin:/usr/sbin |
||||
mount none /proc -t proc |
||||
insmod diag |
||||
[ -f /proc/sys/diag ] && echo 0x01 > /proc/sys/diag |
||||
sleep 1 |
||||
if [ -f /proc/sys/reset ] && [ $(cat /proc/sys/reset) = 1 -o "$(nvram get failsafe)" = 1 ]; then |
||||
export FAILSAFE=true |
||||
[ -x /usr/sbin/nvram -a "$(nvram get boot_wait)" != "on" ] && { |
||||
nvram set boot_wait=on |
||||
nvram commit |
||||
} |
||||
while :; do { echo $(((X=(X+1)%8)%2)) > /proc/sys/diag; sleep $((X==0)); } done & |
||||
fi |
||||
|
||||
mount_root ${FAILSAFE:+failsafe} |
||||
|
||||
# automagically run firstboot |
||||
[ -z "$FAILSAFE" -a -z "$(nvram get no_root_swap)" ] && { |
||||
{ mount|grep "on / type jffs2" 1>&-; } || firstboot |
||||
[ -f /etc/preinit.arch ] && . /etc/preinit.arch |
||||
[ -z "$FAILSAFE" ] || { |
||||
echo /bin/true > /proc/sys/kernel/hotplug |
||||
telnetd -l /bin/login <> /dev/null 2>&1 |
||||
} |
||||
|
||||
mount_root ${FAILSAFE:+failsafe} |
||||
exec /sbin/init |
||||
|
@ -1,3 +0,0 @@ |
||||
#!/bin/sh |
||||
/usr/bin/killall5 -9 |
||||
#umount -ar |
@ -1,26 +1,18 @@ |
||||
#!/bin/sh |
||||
[ $# = 0 ] && { echo " $0 <group>"; exit; } |
||||
. /etc/functions.sh |
||||
. /etc/network.overrides |
||||
[ "$FAILSAFE" != "true" -a -e /etc/config/network ] && . /etc/config/network |
||||
. /etc/config/network |
||||
|
||||
debug "### ifdown $type ###" |
||||
type=$1 |
||||
|
||||
if_proto=$(nvram get ${type}_proto) |
||||
if=$(nvram get ${type}_ifname) |
||||
eval "if_proto=\"\${${type}_proto}\"" |
||||
eval "if=\"\${${type}_ifname}\"" |
||||
[ "${if%%[0-9]}" = "ppp" ] && eval "if=\"\${${type}_device}\"" |
||||
|
||||
case "$if_proto" in |
||||
pppoa) hotplug_dev unregister atm0; exit 0 ;; |
||||
""|none) exit 0;; |
||||
esac |
||||
|
||||
[ "${if%%[0-9]*}" = "ppp" ] && if="$(nvram get ${type}_device)" |
||||
|
||||
if [ "${if%%[0-9]}" = "br" ]; then |
||||
for sif in $(nvram get ${type}_ifnames); do |
||||
hotplug_dev unregister "$sif" |
||||
done |
||||
fi |
||||
|
||||
hotplug_dev unregister "$if" |
||||
|
@ -1,40 +1,34 @@ |
||||
#!/bin/sh |
||||
. /etc/nvram.sh |
||||
is_clean() { |
||||
grep Broadcom /proc/cpuinfo 2>&- >&- || return 0 |
||||
OFFSET="$((0x$(dd if=/dev/mtdblock/1 bs=1 skip=$((0x14)) count=2 2>&- | hexdump | grep 0000000 | cut -d ' ' -f 2) - 1))" |
||||
dd if=/dev/mtdblock/1 bs=1 skip=$OFFSET count=1 2>&- | hexdump -v | grep ' 0000' > /dev/null && return 255 || return 0 |
||||
is_dirty() { |
||||
grep Broadcom /proc/cpuinfo >&- || return 1 |
||||
OFFSET="$(($(hexdump -v /dev/mtdblock/1 -s 20 -n 2 -e '"%d"')-1))" |
||||
return $(hexdump -v /dev/mtdblock/1 -s $OFFSET -n 1 -e '"%d"') |
||||
} |
||||
|
||||
size=$(awk '/Mem:/ {l=5242880;print((s=$2/2)<l)?$2-l:s}' /proc/meminfo) |
||||
mount none /tmp -t tmpfs -o size=$size |
||||
|
||||
if [ "$1" != "failsafe" ]; then |
||||
mtd unlock linux |
||||
mount | grep jffs2 >&- |
||||
if [ $? = 0 ] ; then |
||||
if [ $(cat /proc/mtd | wc -l) = 6 ]; then |
||||
echo 5 > /proc/sys/diag |
||||
mtd unlock linux |
||||
mtd erase OpenWrt |
||||
jffs2root --move |
||||
else |
||||
mtd unlock rootfs |
||||
mount -o remount,rw /dev/root / |
||||
fi |
||||
else |
||||
if [ -z "$(nvram get no_root_swap)" ]; then |
||||
is_clean || { |
||||
mtd erase OpenWrt |
||||
mtd unlock linux |
||||
jffs2root --clean |
||||
} |
||||
mtd unlock OpenWrt |
||||
mount -t jffs2 /dev/mtdblock/4 /jffs |
||||
pivot_root /jffs /jffs/rom |
||||
mount none /proc -t proc |
||||
mount none /dev -t devfs |
||||
umount /rom/proc /rom/dev >&- |
||||
fi |
||||
. /bin/firstboot |
||||
is_dirty |
||||
[ $? != 0 ] && { |
||||
mount /dev/mtdblock/4 /jffs |
||||
pivot /jffs /rom |
||||
} || ramoverlay |
||||
fi |
||||
fi |
||||
mount none /tmp -t tmpfs -o nosuid,nodev,mode=1777,size=50% |
||||
|
||||
mount none /tmp -t tmpfs -o remount,nosuid,nodev,mode=1777 |
||||
mkdir -p /dev/pts |
||||
mount none /dev/pts -t devpts |
||||
grep sysfs /proc/filesystems >&- && mount -t sysfs none /sys |
||||
mount -t sysfs none /sys 2>&- |
||||
|
@ -0,0 +1,66 @@ |
||||
function portstr(type, str) { |
||||
gsub(/-/, ":", str) |
||||
if (insmod_mport != 1) { |
||||
print "insmod ipt_multiport >&- 2>&-" |
||||
insmod_mport = 1 |
||||
} |
||||
if (type == "src") return " -m multiport --sports " str |
||||
else return " -m multiport --dports " str |
||||
} |
||||
|
||||
function str2ipt(str) { |
||||
str2data(str) |
||||
_cmd = "" |
||||
if (_l["src"] != "") _cmd = _cmd " -s " _l["src"] |
||||
if (_l["dest"] != "") _cmd = _cmd " -d " _l["dest"] |
||||
if (_l["proto"] != "") { |
||||
_cmd = _cmd " -p " _l["proto"] |
||||
} |
||||
# scripts need to check for proto="" and emit two rules in that case |
||||
if ((_l["proto"] == "") || (_l["proto"] == "tcp") || (_l["proto"] == "udp")) { |
||||
if (_l["sport"] != "") _cmd = _cmd portstr("src", _l["sport"]) |
||||
if (_l["dport"] != "") _cmd = _cmd portstr("dest", _l["dport"]) |
||||
} |
||||
if (_l["layer7"] != "") { |
||||
if (insmod_l7 != 1) { |
||||
print "insmod ipt_layer7 >&- 2>&-" |
||||
insmod_l7 = 1 |
||||
} |
||||
_cmd = _cmd " -m layer7 --l7proto " _l["layer7"] |
||||
} |
||||
return _cmd |
||||
} |
||||
|
||||
function str2data(str) { |
||||
delete _l |
||||
_n = split(str, _o, "[\t ]") |
||||
for (_i = 1; _i <= _n; _i++) { |
||||
_n2 = split(_o[_i], _c, "=") |
||||
if (_n2 == 2) _l[_c[1]] = _c[2] |
||||
} |
||||
} |
||||
|
||||
function bitcount(c) { |
||||
c=and(rshift(c, 1),0x55555555)+and(c,0x55555555) |
||||
c=and(rshift(c, 2),0x33333333)+and(c,0x33333333) |
||||
c=and(rshift(c, 4),0x0f0f0f0f)+and(c,0x0f0f0f0f) |
||||
c=and(rshift(c, 8),0x00ff00ff)+and(c,0x00ff00ff) |
||||
c=and(rshift(c,16),0x0000ffff)+and(c,0x0000ffff) |
||||
return c |
||||
} |
||||
|
||||
function validate_netmask(nm) { |
||||
return and(-nm,compl(nm)) |
||||
} |
||||
|
||||
function ip2int(ip) { |
||||
for (ret=0,n=split(ip,a,"\."),x=1;x<=n;x++) ret=or(lshift(ret,8),a[x]) |
||||
return ret |
||||
} |
||||
|
||||
function int2ip(ip,ret,x) { |
||||
ret=and(ip,255) |
||||
ip=rshift(ip,8) |
||||
for(;x<3;ret=and(ip,255)"."ret,ip=rshift(ip,8),x++); |
||||
return ret |
||||
} |
@ -0,0 +1,40 @@ |
||||
{ |
||||
line=$0 |
||||
gsub(/^[ \t]*/, "") |
||||
gsub(/[ \t]*$/, "") |
||||
} |
||||
|
||||
$1 == "@define" { |
||||
v[$2] = $3 |
||||
} |
||||
|
||||
$1 == "@ifdef" { |
||||
if_open = 1 |
||||
if (v[$2] != "") noprint = 0 |
||||
else noprint = 1 |
||||
} |
||||
|
||||
$1 == "@ifndef" { |
||||
if_open = 1 |
||||
if (v[$2] != "") noprint = 1 |
||||
else noprint = 0 |
||||
} |
||||
|
||||
$1 == "@else" { |
||||
if (noprint == 1) noprint = 0 |
||||
else noprint = 1 |
||||
} |
||||
|
||||
($1 !~ /^@/) && (noprint != 1) { |
||||
n=split(line "@@", a, /@@/) |
||||
for (i=1; i<=n; i++) { |
||||
if ((i % 2) == 1) printf a[i] |
||||
else printf v[a[i]] |
||||
} |
||||
print "" |
||||
} |
||||
|
||||
$1 == "@endif" { |
||||
if_open = 0 |
||||
noprint = 0 |
||||
} |
@ -0,0 +1,61 @@ |
||||
--- busybox-1.00/editors/awk.c.orig 2004-09-24 05:24:27 -04:00
|
||||
+++ busybox-1.00/editors/awk.c 2006-03-08 02:16:52 -05:00
|
||||
@@ -271,7 +271,8 @@
|
||||
/* builtins */
|
||||
enum {
|
||||
B_a2=0, B_ix, B_ma, B_sp, B_ss, B_ti, B_lo, B_up,
|
||||
- B_ge, B_gs, B_su
|
||||
+ B_ge, B_gs, B_su,
|
||||
+ B_an, B_co, B_ls, B_or, B_rs, B_xo,
|
||||
};
|
||||
|
||||
/* tokens and their corresponding info values */
|
||||
@@ -311,6 +312,8 @@
|
||||
"\5while" NTC
|
||||
"\4else" NTC
|
||||
|
||||
+ "\3and" "\5compl" "\6lshift" "\2or"
|
||||
+ "\6rshift" "\3xor"
|
||||
"\5close" "\6system" "\6fflush" "\5atan2" /* BUILTIN */
|
||||
"\3cos" "\3exp" "\3int" "\3log"
|
||||
"\4rand" "\3sin" "\4sqrt" "\5srand"
|
||||
@@ -364,6 +367,8 @@
|
||||
ST_WHILE,
|
||||
0,
|
||||
|
||||
+ OC_B|B_an|P(0x83), OC_B|B_co|P(0x41), OC_B|B_ls|P(0x83), OC_B|B_or|P(0x83),
|
||||
+ OC_B|B_rs|P(0x83), OC_B|B_xo|P(0x83),
|
||||
OC_FBLTIN|Sx|F_cl, OC_FBLTIN|Sx|F_sy, OC_FBLTIN|Sx|F_ff, OC_B|B_a2|P(0x83),
|
||||
OC_FBLTIN|Nx|F_co, OC_FBLTIN|Nx|F_ex, OC_FBLTIN|Nx|F_in, OC_FBLTIN|Nx|F_lg,
|
||||
OC_FBLTIN|F_rn, OC_FBLTIN|Nx|F_si, OC_FBLTIN|Nx|F_sq, OC_FBLTIN|Nx|F_sr,
|
||||
@@ -1942,6 +1947,30 @@
|
||||
strncpy(s, as[0]+i, n);
|
||||
s[n] = '\0';
|
||||
setvar_p(res, s);
|
||||
+ break;
|
||||
+
|
||||
+ case B_an:
|
||||
+ setvar_i(res, (long)getvar_i(av[0]) & (long)getvar_i(av[1]));
|
||||
+ break;
|
||||
+
|
||||
+ case B_co:
|
||||
+ setvar_i(res, ~(long)getvar_i(av[0]));
|
||||
+ break;
|
||||
+
|
||||
+ case B_ls:
|
||||
+ setvar_i(res, (long)getvar_i(av[0]) << (long)getvar_i(av[1]));
|
||||
+ break;
|
||||
+
|
||||
+ case B_or:
|
||||
+ setvar_i(res, (long)getvar_i(av[0]) | (long)getvar_i(av[1]));
|
||||
+ break;
|
||||
+
|
||||
+ case B_rs:
|
||||
+ setvar_i(res, (long)((unsigned long)getvar_i(av[0]) >> (unsigned long)getvar_i(av[1])));
|
||||
+ break;
|
||||
+
|
||||
+ case B_xo:
|
||||
+ setvar_i(res, (long)getvar_i(av[0]) ^ (long)getvar_i(av[1]));
|
||||
break;
|
||||
|
||||
case B_lo:
|
@ -0,0 +1,13 @@ |
||||
--- busybox-1.00/loginutils/passwd.c 2006-03-26 06:07:37 -05:00
|
||||
+++ busybox-1.00/loginutils/passwd.c 2006-03-26 06:09:03 -05:00
|
||||
@@ -386,7 +386,9 @@
|
||||
bzero(orig, sizeof(orig));
|
||||
|
||||
if (algo == 1) {
|
||||
- cp = pw_encrypt(pass, "$1$");
|
||||
+ char salt[6]="$1$\0\0\0";
|
||||
+ memcpy(salt+3,crypt_make_salt(),3);
|
||||
+ cp = pw_encrypt(pass, salt);
|
||||
} else
|
||||
cp = pw_encrypt(pass, crypt_make_salt());
|
||||
bzero(pass, sizeof pass);
|
@ -0,0 +1,167 @@ |
||||
diff -urN busybox.old/include/applets.h busybox.dev/include/applets.h
|
||||
--- busybox.old/include/applets.h 2006-04-05 01:06:29.000000000 +0200
|
||||
+++ busybox.dev/include/applets.h 2006-04-05 01:19:09.000000000 +0200
|
||||
@@ -167,6 +167,7 @@
|
||||
USE_LN(APPLET(ln, ln_main, _BB_DIR_BIN, _BB_SUID_NEVER))
|
||||
USE_LOADFONT(APPLET(loadfont, loadfont_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
|
||||
USE_LOADKMAP(APPLET(loadkmap, loadkmap_main, _BB_DIR_SBIN, _BB_SUID_NEVER))
|
||||
+USE_LOCK(APPLET_NOUSAGE(lock, lock_main, _BB_DIR_BIN, _BB_SUID_NEVER))
|
||||
USE_LOGGER(APPLET(logger, logger_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
|
||||
USE_LOGIN(APPLET(login, login_main, _BB_DIR_BIN, _BB_SUID_ALWAYS))
|
||||
USE_LOGNAME(APPLET(logname, logname_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
|
||||
diff -urN busybox.old/miscutils/Config.in busybox.dev/miscutils/Config.in
|
||||
--- busybox.old/miscutils/Config.in 2006-03-22 22:16:24.000000000 +0100
|
||||
+++ busybox.dev/miscutils/Config.in 2006-04-05 01:07:12.000000000 +0200
|
||||
@@ -209,6 +209,12 @@
|
||||
Enables the 'hdparm -d' option to get/set using_dma flag.
|
||||
This is dangerous stuff, so you should probably say N.
|
||||
|
||||
+config CONFIG_LOCK
|
||||
+ bool "lock"
|
||||
+ default y
|
||||
+ help
|
||||
+ Small utility for using locks in scripts
|
||||
+
|
||||
config CONFIG_MAKEDEVS
|
||||
bool "makedevs"
|
||||
default n
|
||||
diff -urN busybox.old/miscutils/Makefile.in busybox.dev/miscutils/Makefile.in
|
||||
--- busybox.old/miscutils/Makefile.in 2006-03-22 22:16:24.000000000 +0100
|
||||
+++ busybox.dev/miscutils/Makefile.in 2006-04-05 01:10:50.000000000 +0200
|
||||
@@ -20,6 +20,7 @@
|
||||
MISCUTILS-$(CONFIG_EJECT) += eject.o
|
||||
MISCUTILS-$(CONFIG_HDPARM) += hdparm.o
|
||||
MISCUTILS-$(CONFIG_LAST) += last.o
|
||||
+MISCUTILS-$(CONFIG_LOCK) += lock.o
|
||||
MISCUTILS-${CONFIG_LESS} += less.o
|
||||
MISCUTILS-$(CONFIG_MAKEDEVS) += makedevs.o
|
||||
MISCUTILS-$(CONFIG_MOUNTPOINT) += mountpoint.o
|
||||
diff -urN busybox.old/miscutils/lock.c busybox.dev/miscutils/lock.c
|
||||
--- busybox.old/miscutils/lock.c 1970-01-01 01:00:00.000000000 +0100
|
||||
+++ busybox.dev/miscutils/lock.c 2006-04-05 01:07:12.000000000 +0200
|
||||
@@ -0,0 +1,125 @@
|
||||
+#include <sys/types.h>
|
||||
+#include <sys/file.h>
|
||||
+#include <sys/stat.h>
|
||||
+#include <signal.h>
|
||||
+#include <fcntl.h>
|
||||
+#include <unistd.h>
|
||||
+#include <stdio.h>
|
||||
+#include "busybox.h"
|
||||
+
|
||||
+static int unlock = 0;
|
||||
+static int shared = 0;
|
||||
+static int waitonly = 0;
|
||||
+static int fd;
|
||||
+static char *file;
|
||||
+
|
||||
+static void usage(char *name)
|
||||
+{
|
||||
+ fprintf(stderr, "Usage: %s [-suw] <filename>\n"
|
||||
+ " -s Use shared locking\n"
|
||||
+ " -u Unlock\n"
|
||||
+ " -w Wait for the lock to become free, don't acquire lock\n"
|
||||
+ "\n", name);
|
||||
+ exit(1);
|
||||
+}
|
||||
+
|
||||
+static void exit_unlock(int sig)
|
||||
+{
|
||||
+ flock(fd, LOCK_UN);
|
||||
+ unlink(file);
|
||||
+ exit(0);
|
||||
+}
|
||||
+
|
||||
+static int do_unlock(void)
|
||||
+{
|
||||
+ FILE *f;
|
||||
+ int i;
|
||||
+
|
||||
+ f = fopen(file, "r");
|
||||
+ fscanf(f, "%d", &i);
|
||||
+ if (i > 0)
|
||||
+ kill(i, SIGTERM);
|
||||
+ fclose(f);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int do_lock(void)
|
||||
+{
|
||||
+ int pid;
|
||||
+ char pidstr[8];
|
||||
+
|
||||
+ if ((fd = open(file, O_RDWR | O_CREAT, 0700)) < 0) {
|
||||
+ fprintf(stderr, "Can't open %s\n", file);
|
||||
+ return 1;
|
||||
+ }
|
||||
+
|
||||
+ if (flock(fd, (shared ? LOCK_SH : LOCK_EX)) < 0) {
|
||||
+ fprintf(stderr, "Can't lock %s\n", file);
|
||||
+ return 1;
|
||||
+ }
|
||||
+
|
||||
+ pid = fork();
|
||||
+
|
||||
+ if (pid < 0)
|
||||
+ return -1;
|
||||
+
|
||||
+ if (pid == 0) {
|
||||
+ signal(SIGKILL, exit_unlock);
|
||||
+ signal(SIGTERM, exit_unlock);
|
||||
+ signal(SIGINT, exit_unlock);
|
||||
+ if (waitonly)
|
||||
+ exit_unlock(0);
|
||||
+ else
|
||||
+ while (1)
|
||||
+ sleep(1);
|
||||
+ } else {
|
||||
+ if (!waitonly) {
|
||||
+ lseek(fd, 0, SEEK_SET);
|
||||
+ ftruncate(fd, 0);
|
||||
+ sprintf(pidstr, "%d\n", pid);
|
||||
+ write(fd, pidstr, strlen(pidstr));
|
||||
+ close(fd);
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+#ifndef CONFIG_LOCK
|
||||
+int main(int argc, char **argv)
|
||||
+#else
|
||||
+int lock_main(int argc, char **argv)
|
||||
+#endif
|
||||
+{
|
||||
+ char **args = &argv[1];
|
||||
+ int c = argc - 1;
|
||||
+
|
||||
+ while ((*args != NULL) && (*args)[0] == '-') {
|
||||
+ char *ch = *args;
|
||||
+ while (*(++ch) > 0) {
|
||||
+ switch(*ch) {
|
||||
+ case 'w':
|
||||
+ waitonly = 1;
|
||||
+ break;
|
||||
+ case 's':
|
||||
+ shared = 1;
|
||||
+ break;
|
||||
+ case 'u':
|
||||
+ unlock = 1;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ c--;
|
||||
+ args++;
|
||||
+ }
|
||||
+
|
||||
+ if (c != 1)
|
||||
+ usage(argv[0]);
|
||||
+
|
||||
+ file = *args;
|
||||
+ if (unlock)
|
||||
+ return do_unlock();
|
||||
+ else
|
||||
+ return do_lock();
|
||||
+}
|
@ -1,30 +0,0 @@ |
||||
#!/bin/sh |
||||
. /etc/functions.sh |
||||
. /etc/network.overrides |
||||
[ "$FAILSAFE" != "true" -a -e /etc/config/network ] && . /etc/config/network |
||||
|
||||
# interface to use for DHCP |
||||
iface=lan |
||||
|
||||
ifname=$(nvram get ${iface}_ifname) |
||||
ipaddr=$(nvram get ${iface}_ipaddr) |
||||
netmask=$(nvram get ${iface}_netmask) |
||||
|
||||
# check for existing DHCP server |
||||
udhcpc -n -q -R -s /bin/true -i $ifname >&- || { |
||||
|
||||
ipaddr=$(ip2int $ipaddr) |
||||
netmask=$(ip2int ${netmask:-255.255.255.0}) |
||||
network=$((ipaddr&netmask)) |
||||
|
||||
start=$(nvram get dhcp_start) |
||||
start=$((network+${start:-100})) |
||||
end=$(nvram get dhcp_num) |
||||
end=$((start+${end:-150})) |
||||
|
||||
wanproto=$(nvram get wan_proto) |
||||
[ -z "$wanproto" -o "$wanproto" = "none" ] || wanif=$(nvram get wan_ifname) |
||||
|
||||
args="-K -F $(int2ip $start),$(int2ip $end),$(int2ip $netmask),12h ${wanif:+-I ${wanif} }" |
||||
} |
||||
dnsmasq ${args} |
@ -0,0 +1,45 @@ |
||||
#!/bin/sh |
||||
. /etc/config/network |
||||
|
||||
# The following is to automatically configure the DHCP settings |
||||
# based on config settings. Feel free to replace all this crap |
||||
# with a simple "dnsmasq" and manage everything via the |
||||
# /etc/dnsmasq.conf config file |
||||
|
||||
[ -f /etc/dnsmasq.conf ] || exit |
||||
|
||||
args="" |
||||
iface=lan |
||||
eval "ifname=\${${iface}_ifname}" |
||||
|
||||
dhcp_enable="${dhcp_enable:-1}" |
||||
dhcp_start="${dhcp_start:-100}" |
||||
dhcp_num="${dhcp_num:-50}" |
||||
dhcp_lease="${dhcp_lease:-12h}" |
||||
|
||||
# if dhcp_enable is unset and there is a dhcp server on the network already, default to dhcp_enable=0 |
||||
[ -z "$dhcp_enable" ] && udhcpc -n -q -R -s /bin/true -i $ifname >&- && dhcp_enable="${dhcp_enable:-0}" |
||||
|
||||
# dhcp_enable=0 disables the dhcp server |
||||
( |
||||
[ -z "$dhcp_enable" -o "$dhcp_enable" -eq 1 ] && { |
||||
# no existing DHCP server? |
||||
|
||||
# calculate settings |
||||
eval "ipaddr=\${${iface}_ipaddr}" |
||||
eval "netmask=\${${iface}_netmask}" |
||||
eval $(ipcalc $ipaddr $netmask ${dhcp_start:-100} ${dhcp_num:-150}) |
||||
|
||||
# and pass the args via config parser defines |
||||
echo "@define dhcp_enable 1" |
||||
echo "@define netmask $NETMASK" |
||||
echo "@define start $START" |
||||
echo "@define end $END" |
||||
echo "@define lease ${dhcp_lease:-12h}" |
||||
} |
||||
|
||||
# ignore requests from wan interface |
||||
[ -z "$wan_proto" -o "$wan_proto" = "none" ] || echo "@define wan_ifname $wan_ifname" |
||||
|
||||
cat /etc/dnsmasq.conf |
||||
) | awk -f /usr/lib/parse-config.awk | dnsmasq -C /proc/self/fd/0 |
@ -1,10 +1,10 @@ |
||||
. /etc/functions.sh |
||||
NAME=ez-ipupdate |
||||
CONFIG=/etc/$NAME.conf |
||||
COMMAND=/usr/sbin/$NAME |
||||
|
||||
[ "$ACTION" = "ifup" -a "$INTERFACE" = "wan" ] && { |
||||
[ -x $COMMAND ] && [ -r $CONFIG ] && { |
||||
IFNAME=$(nvram get ${INTERFACE}_ifname) |
||||
$COMMAND -c $CONFIG -i $IFNAME 2>&1 | logger -t $NAME |
||||
eval "ifname=\"\${${INTERFACE}_ifname}\"" |
||||
$COMMAND -c $CONFIG -i $ifname 2>&1 | logger -t $NAME |
||||
} & |
||||
} |
||||
|
@ -0,0 +1,64 @@ |
||||
BEGIN { |
||||
print "proto=\"$wan_proto\"" |
||||
print "[ -z \"$proto\" -o \"$proto\" = \"none\" ] && exit" |
||||
print "ifname=\"$wan_ifname\"" |
||||
print "[ -z \"$ifname\" ] && exit" |
||||
print "" |
||||
print "iptables -X input_$ifname 2>&- >&-" |
||||
print "iptables -N input_$ifname" |
||||
print "iptables -X forward_$ifname 2>&- >&-" |
||||
print "iptables -N forward_$ifname" |
||||
print "iptables -t nat -X prerouting_$ifname 2>&- >&-" |
||||
print "iptables -t nat -N prerouting_$ifname" |
||||
print "" |
||||
print "iptables -A input_rule -i \"$ifname\" -j input_$ifname" |
||||
print "iptables -A forwarding_rule -i \"$ifname\" -j forward_$ifname" |
||||
print "iptables -t nat -A prerouting_rule -i \"$ifname\" -j prerouting_$ifname" |
||||
print "" |
||||
FS=":" |
||||
} |
||||
|
||||
($1 == "accept") || ($1 == "drop") || ($1 == "forward") { |
||||
delete _opt |
||||
str2data($2) |
||||
if ((_l["proto"] == "") && (_l["sport"] _l["dport"] != "")) { |
||||
_opt[0] = " -p tcp" |
||||
_opt[1] = " -p udp" |
||||
} else { |
||||
_opt[0] = "" |
||||
} |
||||
} |
||||
|
||||
($1 == "accept") { |
||||
target = " -j ACCEPT" |
||||
for (o in _opt) { |
||||
print "iptables -t nat -A prerouting_$ifname" _opt[o] str2ipt($2) target |
||||
print "iptables -A input_$ifname " _opt[o] str2ipt($2) target |
||||
print "" |
||||
} |
||||
} |
||||
|
||||
($1 == "drop") { |
||||
for (o in _opt) { |
||||
print "iptables -t nat -A prerouting_$ifname" _opt[o] str2ipt($2) " -j DROP" |
||||
print "" |
||||
} |
||||
} |
||||
|
||||
($1 == "forward") { |
||||
target = " -j DNAT --to " $3 |
||||
fwopts = "" |
||||
if ($4 != "") { |
||||
if ((_l["proto"] == "tcp") || (_l["proto"] == "udp") || (_l["proto"] == "")) { |
||||
if (_l["proto"] != "") fwopts = " -p " _l["proto"] |
||||
fwopts = fwopts " --dport " $4 |
||||
target = target ":" $4 |
||||
} |
||||
else fwopts = "" |
||||
} |
||||
for (o in _opt) { |
||||
print "iptables -t nat -A prerouting_$ifname" _opt[o] str2ipt($2) target |
||||
print "iptables -A forward_$ifname " _opt[o] " -d " $3 fwopts " -j ACCEPT" |
||||
print "" |
||||
} |
||||
} |
@ -0,0 +1,46 @@ |
||||
# RULE SYNTAX: |
||||
# |
||||
# forward:<match>:<target>[:<port>] |
||||
# - forwards all packets matched by <match> to <target>, |
||||
# optionally changing the port to <port> |
||||
# |
||||
# accept:<match> |
||||
# - accepts all traffic matched by <match> |
||||
# |
||||
# drop:<match> |
||||
# - drops all traffic matched by <match> |
||||
# |
||||
# |
||||
# MATCHING OPTIONS: |
||||
# |
||||
# src=<ip> |
||||
# - match the source ip <ip> |
||||
# |
||||
# dest=<ip> |
||||
# - match the destination ip <ip> |
||||
# |
||||
# proto=<proto> |
||||
# - match the protocol by name or number |
||||
# |
||||
# sport=<port(s)> |
||||
# - match the source port(s), see below for syntax |
||||
# |
||||
# dport=<port(s)> |
||||
# - match the destination port(s), see below for syntax |
||||
# |
||||
# |
||||
# |
||||
# PORT SYNTAX: |
||||
# |
||||
# You can enter an arbitrary list of ports and port ranges in the following format: |
||||
# - 22,53,993,1000-1024 |
||||
# |
||||
# If you don't set the protocol to tcp or udp, it will apply to both |
||||
# |
||||
# |
||||
# |
||||
# EXAMPLES: |
||||
# |
||||
# drop:dport=22 src=1.3.3.7 |
||||
# accept:proto=tcp dport=22 |
||||
# forward:dport=60168:192.168.1.2:60169 |
@ -0,0 +1,31 @@ |
||||
#!/bin/sh |
||||
. /etc/config/network |
||||
|
||||
WAN="$wan_ifname" |
||||
LAN="$lan_ifname" |
||||
|
||||
iptables -F input_rule |
||||
iptables -F output_rule |
||||
iptables -F forwarding_rule |
||||
iptables -t nat -F prerouting_rule |
||||
iptables -t nat -F postrouting_rule |
||||
|
||||
### BIG FAT DISCLAIMER |
||||
## The "-i $WAN" is used to match packets that come in via the $WAN interface. |
||||
## it WILL NOT MATCH packets sent from the $WAN ip address -- you won't be able |
||||
## to see the effects from within the LAN. |
||||
|
||||
### Open port to WAN |
||||
## -- This allows port 22 to be answered by (dropbear on) the router |
||||
# iptables -t nat -A prerouting_rule -i $WAN -p tcp --dport 22 -j ACCEPT |
||||
# iptables -A input_rule -i $WAN -p tcp --dport 22 -j ACCEPT |
||||
|
||||
### Port forwarding |
||||
## -- This forwards port 8080 on the WAN to port 80 on 192.168.1.2 |
||||
# iptables -t nat -A prerouting_rule -i $WAN -p tcp --dport 8080 -j DNAT --to 192.168.1.2:80 |
||||
# iptables -A forwarding_rule -i $WAN -p tcp --dport 80 -d 192.168.1.2 -j ACCEPT |
||||
|
||||
### DMZ |
||||
## -- Connections to ports not handled above will be forwarded to 192.168.1.2 |
||||
# iptables -t nat -A prerouting_rule -i $WAN -j DNAT --to 192.168.1.2 |
||||
# iptables -A forwarding_rule -i $WAN -d 192.168.1.2 -j ACCEPT |
@ -1,3 +1 @@ |
||||
LAN_IF=$(nvram get lan_ifname) |
||||
WIFI_IF=$(nvram get wifi_ifname) |
||||
OPTIONS="$LAN_IF $WIFI_IF" |
||||
OPTIONS="$lan_ifname $wifi_ifname" |
||||
|
@ -1,28 +0,0 @@ |
||||
# NVRAM overrides |
||||
# |
||||
# This file handles the NVRAM quirks of various hardware. |
||||
# THIS FILE IS NOT A REPLACEMENT FOR NVRAM |
||||
|
||||
# Load sysconf defaults |
||||
[ -f /etc/sysconf ] && . /etc/sysconf |
||||
|
||||
DEFAULT_lan_proto="static" |
||||
DEFAULT_lan_ifname="br0" |
||||
DEFAULT_lan_ifnames="eth0" |
||||
DEFAULT_lan_ipaddr=${BR2_SYSCONF_FAILSAFE_IP:-"192.168.1.1"} |
||||
DEFAULT_lan_netmask=${BR2_SYSCONF_FAILSAFE_NETMASK:-"255.255.255.0"} |
||||
DEFAULT_lan_hwaddr=`echo $(strings /dev/mtdblock/3 | grep -A1 maca | grep :)` |
||||
DEFAULT_lan_hwaddr=${DEFAULT_lan_hwaddr##* } |
||||
DEFAULT_lan_hwaddr=${DEFAULT_lan_hwaddr:-${BR2_SYSCONF_FAILSAFE_MAC:-"00:0B:AD:0A:DD:00"}} |
||||
|
||||
# failsafe if reset is held |
||||
[ "$FAILSAFE" = "true" ] && { |
||||
echo "### YOU ARE IN FAILSAFE MODE ####" |
||||
lan_ifname=${DEFAULT_lan_proto} |
||||
lan_ifnames=${FAILSAFE_ifnames:-${DEFAULT_lan_ifnames}} |
||||
lan_ipaddr=$DEFAULT_lan_ipaddr |
||||
lan_netmask=$DEFAULT_lan_netmask |
||||
lan_hwaddr=$DEFAULT_lan_hwaddr |
||||
wan_ifname="none" |
||||
wifi_ifname="none" |
||||
} |
@ -1,26 +0,0 @@ |
||||
# NVRAM overrides |
||||
# |
||||
# This file handles the NVRAM quirks of various hardware. |
||||
# THIS FILE IS NOT A REPLACEMENT FOR NVRAM |
||||
|
||||
# Load sysconf defaults |
||||
[ -f /etc/sysconf ] && . /etc/sysconf |
||||
|
||||
DEFAULT_lan_proto="static" |
||||
DEFAULT_lan_ifname="br0" |
||||
DEFAULT_lan_ifnames="eth0" |
||||
DEFAULT_lan_ipaddr=${BR2_SYSCONF_FAILSAFE_IP:-"192.168.1.1"} |
||||
DEFAULT_lan_netmask=${BR2_SYSCONF_FAILSAFE_NETMASK:-"255.255.255.0"} |
||||
# DEFAULT_lan_hwaddr=${BR2_SYSCONF_FAILSAFE_MAC:-"00:0B:AD:0A:DD:00"} |
||||
|
||||
# failsafe if reset is held |
||||
[ "$FAILSAFE" = "true" ] && { |
||||
echo "### YOU ARE IN FAILSAFE MODE ####" |
||||
lan_ifname=${DEFAULT_lan_proto} |
||||
lan_ifnames=${FAILSAFE_ifnames:-${DEFAULT_lan_ifnames}} |
||||
lan_ipaddr=$DEFAULT_lan_ipaddr |
||||
lan_netmask=$DEFAULT_lan_netmask |
||||
lan_hwaddr=$DEFAULT_lan_hwaddr |
||||
wan_ifname="none" |
||||
wifi_ifname="none" |
||||
} |
@ -0,0 +1,66 @@ |
||||
#!/bin/sh |
||||
# NVRAM setup |
||||
# |
||||
# This file handles the NVRAM quirks of various hardware. |
||||
|
||||
# WGT634u |
||||
grep 'mtd0: 00060000' /proc/mtd 2>&- >&- && exit |
||||
|
||||
alias debug=${DEBUG:-:} |
||||
|
||||
nvram_default() { |
||||
[ -z "$(nvram get $1)" ] && nvram set "$1=$2" |
||||
} |
||||
|
||||
nvram_set() { # for the linksys fixup part |
||||
[ "$(nvram get "$1")" = "$2" -a "$2" != "" ] || { |
||||
COMMIT=1 |
||||
/usr/sbin/nvram set "$1=$2" |
||||
} |
||||
} |
||||
|
||||
# work around braindead CFE defaults in linksys routers |
||||
boardtype=$(nvram get boardtype) |
||||
boardnum=$(nvram get boardnum) |
||||
boardflags=$(($(nvram get boardflags))) |
||||
adm_switch="$(( ($boardflags & 0x80) >> 7 ))" |
||||
|
||||
case "$(( $boardtype ))" in |
||||
"1800") #0x708 |
||||
if [ "$adm_switch" = 0 ]; then |
||||
nvram_set sdram_init "$(printf 0x%04x $(( $(/usr/sbin/nvram get sdram_init) | 0x0100 )))" |
||||
[ "$COMMIT" = 1 ] && { |
||||
nvram_set sdram_config 0x0062 |
||||
nvram_set clkfreq 216 |
||||
nvram_set sdram_ncdl 0x0 |
||||
nvram_set pa0itssit 62 |
||||
nvram_set pa0b0 0x15eb |
||||
nvram_set pa0b1 0xfa82 |
||||
nvram_set pa0b2 0xfe66 |
||||
nvram_set pa0maxpwr 0x4e |
||||
} |
||||
fi |
||||
;; |
||||
"1127") #0x467 |
||||
nvram_set sdram_init "$(printf 0x%04x $(( $(/usr/sbin/nvram get sdram_init) | 0x0100 )))" |
||||
[ "$COMMIT" = 1 ] && { |
||||
nvram_set sdram_config 0x0062 |
||||
nvram_set sdram_ncdl 0x0 |
||||
nvram_set pa0itssit 62 |
||||
nvram_set pa0b0 0x168b |
||||
nvram_set pa0b1 0xfabf |
||||
nvram_set pa0b2 0xfeaf |
||||
nvram_set pa0maxpwr 0x4e |
||||
} |
||||
;; |
||||
esac |
||||
[ "$COMMIT" = "1" ] && nvram commit |
||||
|
||||
# hack for some motorola routers |
||||
nvram unset wl0gpio0 |
||||
|
||||
[ "$(nvram get il0macaddr)" = "00:90:4c:5f:00:2a" ] && { |
||||
# if default wifi mac, set two higher than the lan mac |
||||
nvram set il0macaddr=$(nvram get et0macaddr| |
||||
awk '{OFS=FS=":";for(x=7,y=2;--x;){$x=sprintf("%02x",(y+="0x"$x)%256);y/=256}print}') |
||||
} |
@ -1,166 +0,0 @@ |
||||
#!/bin/sh |
||||
# NVRAM setup |
||||
# |
||||
# This file handles the NVRAM quirks of various hardware. |
||||
|
||||
. /etc/network.overrides |
||||
alias debug=${DEBUG:-:} |
||||
|
||||
# WGT634u |
||||
grep 'mtd0: 00060000' /proc/mtd 2>&- >&- && exit |
||||
|
||||
remap () { |
||||
for type in lan wifi wan pppoe |
||||
do |
||||
for s in '' s |
||||
do |
||||
eval nvram set ${type}_ifname$s=\"$(nvram get ${type}_ifname$s|sed s/$1/$2/g)\" |
||||
done |
||||
done |
||||
} |
||||
|
||||
nvram_default() { |
||||
[ -z "$(nvram get $1)" ] && nvram set "$1=$2" |
||||
} |
||||
|
||||
nvram_set() { # for the linksys fixup part |
||||
[ "$(nvram get "$1")" = "$2" -a "$2" != "" ] || { |
||||
COMMIT=1 |
||||
/usr/sbin/nvram set "$1=$2" |
||||
} |
||||
} |
||||
|
||||
# work around braindead CFE defaults in linksys routers |
||||
boardtype=$(nvram get boardtype) |
||||
boardflags=$(($(nvram get boardflags))) |
||||
[ "$boardtype" = "bcm94710dev" ] && boardtype="0xdeadbeef" |
||||
adm_switch="$(( ($boardflags & 0x80) >> 7 ))" |
||||
case "$(( $boardtype ))" in |
||||
"$((0x708))") |
||||
if [ "$adm_switch" = 0 ]; then |
||||
nvram_set sdram_init "$(printf 0x%04x $(( $(/usr/sbin/nvram get sdram_init) | 0x0100 )))" |
||||
[ "$COMMIT" = 1 ] && { |
||||
nvram_set sdram_config 0x0062 |
||||
nvram_set clkfreq 216 |
||||
nvram_set sdram_ncdl 0x0 |
||||
nvram_set pa0itssit 62 |
||||
nvram_set pa0b0 0x15eb |
||||
nvram_set pa0b1 0xfa82 |
||||
nvram_set pa0b2 0xfe66 |
||||
nvram_set pa0maxpwr 0x4e |
||||
} |
||||
fi |
||||
;; |
||||
"$((0x467))") |
||||
nvram_set sdram_init "$(printf 0x%04x $(( $(/usr/sbin/nvram get sdram_init) | 0x0100 )))" |
||||
[ "$COMMIT" = 1 ] && { |
||||
nvram_set sdram_config 0x0062 |
||||
nvram_set sdram_ncdl 0x0 |
||||
nvram_set pa0itssit 62 |
||||
nvram_set pa0b0 0x168b |
||||
nvram_set pa0b1 0xfabf |
||||
nvram_set pa0b2 0xfeaf |
||||
nvram_set pa0maxpwr 0x4e |
||||
} |
||||
;; |
||||
esac |
||||
[ "$COMMIT" = "1" ] && nvram commit |
||||
|
||||
|
||||
# linksys bug; remove when not using static configuration for lan |
||||
nvram set lan_proto="static" |
||||
|
||||
# hacks for wrt54g 1.x hardware |
||||
[ "$(nvram get boardnum)" = "42" \ |
||||
-a "$(nvram get boardtype)" = "bcm94710dev" ] && { |
||||
debug "### wrt54g 1.x hack ###" |
||||
nvram set vlan1hwname="et0" |
||||
nvram set vlan2hwname="et0" |
||||
remap eth0 vlan2 |
||||
remap eth1 vlan1 |
||||
} |
||||
|
||||
# hacks for asus wl-500g deluxe |
||||
[ "$(nvram get boardtype)" = "bcm95365r" \ |
||||
-a "$(nvram get boardnum)" = "45" ] && { |
||||
debug "### wl-500g deluxe hacks ###" |
||||
nvram set vlan0hwname="et0" |
||||
nvram set vlan1hwname="et0" |
||||
remap eth0.1 vlan0 |
||||
remap eth0 vlan1 |
||||
|
||||
# set up the vlan*ports variables for the asus wl-500g deluxe |
||||
# if they don't already exist |
||||
nvram_default vlan0ports "1 2 3 4 5*" |
||||
nvram_default vlan1ports "0 5" |
||||
} |
||||
|
||||
# hacks for asus |
||||
case "$(nvram get productid)" in |
||||
WL300g) |
||||
debug "### wl-300g hacks ###" |
||||
nvram set lan_ifnames="eth0 eth2" |
||||
nvram set wan_ifname="none" |
||||
;; |
||||
WLHDD) |
||||
debug "### wl-hdd hacks ###" |
||||
nvram set lan_ifnames="eth1 eth2" |
||||
nvram set wan_ifname="none" |
||||
;; |
||||
*) |
||||
# wl-500g defaults. these are placed here, because WL-HDD and WL-300g |
||||
# might have the same nvram settings. |
||||
[ "$(nvram get boardnum)" = "asusX" \ |
||||
-a "$(nvram get boardtype)" = "bcm94710dev" ] && { |
||||
nvram_default wan_device "eth1" |
||||
} |
||||
;; |
||||
esac |
||||
|
||||
# hacks for wap54g hardware |
||||
[ "$(nvram get boardnum)" = "2" \ |
||||
-o "$(nvram get boardnum)" = "1024" ] && { |
||||
debug "### wap54g hack ###" |
||||
nvram set wan_ifname="none" |
||||
} |
||||
|
||||
# hacks for buffalo wla2-g54l |
||||
[ "$(nvram get boardnum)" = "00" \ |
||||
-a "$(nvram get product_name)" = "Product_name" \ |
||||
-o "$(nvram get product_name)" = "WLA2-G54L" ] && { |
||||
debug "### wla2-g54l hacks ###" |
||||
nvram set wan_ifname="none" |
||||
nvram set lan_ifnames="vlan0" |
||||
} |
||||
|
||||
# needed at least for wrt54gs v1.1 and wrt54g v2.0, v2.2 |
||||
[ \! -z "$(nvram get boardrev)" ] && { |
||||
nvram_default wl0id 0x4320 |
||||
} |
||||
|
||||
# defaults |
||||
nvram_default lan_ifname "br0" |
||||
nvram_default lan_ifnames "$FAILSAFE_ifnames" |
||||
|
||||
nvram_default wan_ifname "vlan1" |
||||
nvram_default wan_device "vlan1" |
||||
nvram_default wan_proto "dhcp" |
||||
|
||||
nvram_default wl0_ssid OpenWrt |
||||
nvram_default wl0_mode ap |
||||
nvram_default wl0_infra 1 |
||||
nvram_default wl0_radio 1 |
||||
|
||||
WAN_PROTO="$(nvram get wan_proto)" |
||||
WAN_IFNAME="$(nvram get wan_ifname)" |
||||
case "$WAN_PROTO" in |
||||
pp*) [ "${WAN_IFNAME%%[0-9]*}" = "ppp" ] || nvram set wan_ifname=ppp0;; |
||||
*) [ "${WAN_IFNAME%%[0-9]*}" = "ppp" ] && nvram set wan_ifname="$(nvram get wan_device)";; |
||||
esac |
||||
|
||||
[ "$(nvram get il0macaddr)" = "00:90:4c:5f:00:2a" ] && { |
||||
# if default wifi mac, set two higher than the lan mac |
||||
nvram set il0macaddr=$(nvram get et0macaddr| |
||||
awk '{OFS=FS=":";for(x=7,y=2;--x;){$x=sprintf("%02x",(y+="0x"$x)%256);y/=256}print}') |
||||
} |
||||
|
@ -1,41 +0,0 @@ |
||||
# NVRAM overrides |
||||
# |
||||
# This file handles the NVRAM quirks of various hardware. |
||||
# THIS FILE IS NOT A REPLACEMENT FOR NVRAM |
||||
|
||||
# Load sysconf defaults |
||||
[ -f /etc/sysconf ] && . /etc/sysconf |
||||
|
||||
# hacks for wrt54g 1.x hardware |
||||
[ "$(nvram get boardnum)" = "42" \ |
||||
-a "$(nvram get boardtype)" = "bcm94710dev" ] && FAILSAFE_ifnames="vlan0 vlan2 eth2" |
||||
|
||||
# hacks for asus wl-500g deluxe |
||||
[ "$(nvram get boardtype)" = "bcm95365r" \ |
||||
-a "$(nvram get boardnum)" = "45" ] && FAILSAFE_ifnames="vlan0 eth1" |
||||
|
||||
# hacks for wap54g hardware |
||||
[ "$(nvram get boardnum)" = "2" \ |
||||
-o "$(nvram get boardnum)" = "1024" ] && FAILSAFE_ifnames="eth0 eth1" |
||||
|
||||
# hack for asus wl-500g hardware |
||||
[ "$(nvram get boardnum)" = "asusX" \ |
||||
-a "$(nvram get boardtype)" = "bcm94710dev" ] && FAILSAFE_ifnames="eth0 eth1 eth2" |
||||
|
||||
FAILSAFE_ifnames=${FAILSAFE_ifnames:-"vlan0 eth1 eth2"} |
||||
|
||||
DEFAULT_lan_ipaddr=${BR2_SYSCONF_FAILSAFE_IP:-"192.168.1.1"} |
||||
DEFAULT_lan_netmask=${BR2_SYSCONF_FAILSAFE_NETMASK:-"255.255.255.0"} |
||||
DEFAULT_lan_hwaddr=${BR2_SYSCONF_FAILSAFE_MAC:-"00:0B:AD:0A:DD:00"} |
||||
|
||||
# failsafe if reset is held |
||||
[ "$FAILSAFE" = "true" ] && { |
||||
echo "### YOU ARE IN FAILSAFE MODE ####" |
||||
lan_ifname="br0" |
||||
lan_ifnames=$FAILSAFE_ifnames |
||||
lan_ipaddr=$DEFAULT_lan_ipaddr |
||||
lan_netmask=$DEFAULT_lan_netmask |
||||
lan_hwaddr=$DEFAULT_lan_hwaddr |
||||
wan_ifname="none" |
||||
wifi_ifname="none" |
||||
} |
@ -1,31 +0,0 @@ |
||||
# NVRAM overrides |
||||
# |
||||
# This file handles the NVRAM quirks of various hardware. |
||||
# THIS FILE IS NOT A REPLACEMENT FOR NVRAM |
||||
|
||||
# Load sysconf defaults |
||||
[ -f /etc/sysconf ] && . /etc/sysconf |
||||
|
||||
DEFAULT_lan_proto="static" |
||||
DEFAULT_lan_ifname="br0" |
||||
DEFAULT_lan_ifnames="vlan0 ath0" |
||||
DEFAULT_lan_ipaddr=${BR2_SYSCONF_FAILSAFE_IP:-"192.168.1.1"} |
||||
DEFAULT_lan_netmask=${BR2_SYSCONF_FAILSAFE_NETMASK:-"255.255.255.0"} |
||||
DEFAULT_lan_hwaddr=${DEFAULT_lan_hwaddr:-${BR2_SYSCONF_FAILSAFE_MAC:-"00:0B:AD:0A:DD:00"}} |
||||
DEFAULT_vlan0hwname="et0" |
||||
DEFAULT_vlan1hwname="et0" |
||||
DEFAULT_et0macaddr=$(ifconfig eth0| awk '/eth0/ {print $5 }') |
||||
DEFAULT_wan_proto="dhcp" |
||||
DEFAULT_wan_ifname="vlan1" |
||||
|
||||
# failsafe if reset is held |
||||
[ "$FAILSAFE" = "true" ] && { |
||||
echo "### YOU ARE IN FAILSAFE MODE ####" |
||||
lan_ifname=${DEFAULT_lan_proto} |
||||
lan_ifnames=${FAILSAFE_ifnames:-${DEFAULT_lan_ifnames}} |
||||
lan_ipaddr=$DEFAULT_lan_ipaddr |
||||
lan_netmask=$DEFAULT_lan_netmask |
||||
lan_hwaddr=$DEFAULT_lan_hwaddr |
||||
wan_ifname="none" |
||||
wifi_ifname="none" |
||||
} |
@ -1,26 +0,0 @@ |
||||
# NVRAM overrides |
||||
# |
||||
# This file handles the NVRAM quirks of various hardware. |
||||
# THIS FILE IS NOT A REPLACEMENT FOR NVRAM |
||||
|
||||
# Load sysconf defaults |
||||
[ -f /etc/sysconf ] && . /etc/sysconf |
||||
|
||||
DEFAULT_lan_proto="static" |
||||
DEFAULT_lan_ifname="br0" |
||||
DEFAULT_lan_ifnames="eth0" |
||||
DEFAULT_lan_ipaddr=${BR2_SYSCONF_FAILSAFE_IP:-"192.168.1.1"} |
||||
DEFAULT_lan_netmask=${BR2_SYSCONF_FAILSAFE_NETMASK:-"255.255.255.0"} |
||||
DEFAULT_lan_hwaddr=${BR2_SYSCONF_FAILSAFE_MAC:-"00:0B:AD:0A:DD:00"} |
||||
|
||||
# failsafe if reset is held |
||||
[ "$FAILSAFE" = "true" ] && { |
||||
echo "### YOU ARE IN FAILSAFE MODE ####" |
||||
lan_ifname=${DEFAULT_lan_proto} |
||||
lan_ifnames=${FAILSAFE_ifnames:-${DEFAULT_lan_ifnames}} |
||||
lan_ipaddr=$DEFAULT_lan_ipaddr |
||||
lan_netmask=$DEFAULT_lan_netmask |
||||
lan_hwaddr=$DEFAULT_lan_hwaddr |
||||
wan_ifname="none" |
||||
wifi_ifname="none" |
||||
} |
@ -1,26 +0,0 @@ |
||||
# NVRAM overrides |
||||
# |
||||
# This file handles the NVRAM quirks of various hardware. |
||||
# THIS FILE IS NOT A REPLACEMENT FOR NVRAM |
||||
|
||||
# Load sysconf defaults |
||||
[ -f /etc/sysconf ] && . /etc/sysconf |
||||
|
||||
DEFAULT_lan_proto="static" |
||||
DEFAULT_lan_ifname="br0" |
||||
DEFAULT_lan_ifnames="eth0" |
||||
DEFAULT_lan_ipaddr=${BR2_SYSCONF_FAILSAFE_IP:-"192.168.1.1"} |
||||
DEFAULT_lan_netmask=${BR2_SYSCONF_FAILSAFE_NETMASK:-"255.255.255.0"} |
||||
DEFAULT_lan_hwaddr=${BR2_SYSCONF_FAILSAFE_MAC:-"00:0B:AD:0A:DD:00"} |
||||
|
||||
# failsafe if reset is held |
||||
[ "$FAILSAFE" = "true" ] && { |
||||
echo "### YOU ARE IN FAILSAFE MODE ####" |
||||
lan_ifname=${DEFAULT_lan_proto} |
||||
lan_ifnames=${FAILSAFE_ifnames:-${DEFAULT_lan_ifnames}} |
||||
lan_ipaddr=$DEFAULT_lan_ipaddr |
||||
lan_netmask=$DEFAULT_lan_netmask |
||||
lan_hwaddr=$DEFAULT_lan_hwaddr |
||||
wan_ifname="none" |
||||
wifi_ifname="none" |
||||
} |
Loading…
Reference in new issue