massive changes - sstrip cleanup from mjn3 - various patches from nico and others: http://openwrt.org/forum/viewtopic.php?t=368

SVN-Revision: 145
This commit is contained in:
Mike Baker 2004-08-24 23:50:14 +00:00
parent f0dfe4b88a
commit 5e346b8f70
69 changed files with 8363 additions and 289 deletions

View File

@ -0,0 +1,3 @@
## missing variables that should be declared somewhere
LINUX_VERSION := 2.4.20

View File

@ -4,7 +4,9 @@
#
#############################################################
CHILLISPOT_VERSION:=0.95
CHILLISPOT_VERSION:=0.96
CHILLISPOT_RELEASE:=1
CHILLISPOT_SOURCE:=chillispot-$(CHILLISPOT_VERSION).tar.gz
CHILLISPOT_SITE:=http://www.chillispot.org/download/
CHILLISPOT_CAT:=zcat
@ -12,20 +14,27 @@ CHILLISPOT_DIR:=$(BUILD_DIR)/chillispot-$(CHILLISPOT_VERSION)
CHILLISPOT_BINARY:=src/chilli
CHILLISPOT_TARGET_BINARY:=usr/sbin/chilli
CHILLISPOT_BUILD_DIR := $(BUILD_DIR)/chillispot_$(CHILLISPOT_VERSION)-$(CHILLISPOT_RELEASE)
CHILLISPOT_IPK_DIR := $(OPENWRT_IPK_DIR)/chillispot
CHILLISPOT_IPK := $(CHILLISPOT_BUILD_DIR)_$(ARCH).ipk
$(DL_DIR)/$(CHILLISPOT_SOURCE):
$(WGET) -P $(DL_DIR) $(CHILLISPOT_SITE)/$(CHILLISPOT_SOURCE)
chillispot-source: $(DL_DIR)/$(CHILLISPOT_SOURCE)
$(CHILLISPOT_DIR)/.unpacked: $(DL_DIR)/$(CHILLISPOT_SOURCE)
$(CHILLISPOT_DIR)/.stamp-unpacked: $(DL_DIR)/$(CHILLISPOT_SOURCE)
$(CHILLISPOT_CAT) $(DL_DIR)/$(CHILLISPOT_SOURCE) | tar -C $(BUILD_DIR) -xvf -
sed -i -e s:"-ggdb"::g $(CHILLISPOT_DIR)/src/Makefile.in
touch $(CHILLISPOT_DIR)/.unpacked
$(CHILLISPOT_DIR)/.configured: $(CHILLISPOT_DIR)/.unpacked
touch $(CHILLISPOT_DIR)/.stamp-unpacked
$(CHILLISPOT_DIR)/.stamp-configured: $(CHILLISPOT_DIR)/.stamp-unpacked
(cd $(CHILLISPOT_DIR); rm -rf config.cache; \
$(TARGET_CONFIGURE_OPTS) \
CFLAGS="$(TARGET_CFLAGS)" \
ac_cv_func_malloc_0_nonnull=yes \
ac_cv_func_memcmp_working=yes \
ac_cv_func_setvbuf_reversed=no \
./configure \
--target=$(GNU_TARGET_NAME) \
@ -44,35 +53,42 @@ $(CHILLISPOT_DIR)/.configured: $(CHILLISPOT_DIR)/.unpacked
$(DISABLE_NLS) \
$(DISABLE_LARGEFILE) \
);
sed -i -e s:"#define HAVE_MALLOC 0":"#define HAVE_MALLOC 1":g \
-e s:"#define malloc rpl_malloc"::g \
$(CHILLISPOT_DIR)/config.h
touch $(CHILLISPOT_DIR)/.configured
touch $(CHILLISPOT_DIR)/.stamp-configured
$(CHILLISPOT_DIR)/$(CHILLISPOT_BINARY): $(CHILLISPOT_DIR)/.configured
$(CHILLISPOT_DIR)/.stamp-built: $(CHILLISPOT_DIR)/.stamp-configured
$(MAKE) CC=$(TARGET_CC) $(TARGET_CONFIGURE_OPTS) -C $(CHILLISPOT_DIR)
touch $(CHILLISPOT_DIR)/.stamp-built
# This stuff is needed to work around GNU make deficiencies
chillispot-target_binary: $(CHILLISPOT_DIR)/$(CHILLISPOT_BINARY)
@if [ -L $(TARGET_DIR)/$(CHILLISPOT_TARGET_BINARY) ] ; then \
rm -f $(TARGET_DIR)/$(CHILLISPOT_TARGET_BINARY); fi;
@if [ ! -f $(CHILLISPOT_DIR)/$(CHILLISPOT_BINARY) -o $(TARGET_DIR)/$(CHILLISPOT_TARGET_BINARY) \
-ot $(CHILLISPOT_DIR)/$(CHILLISPOT_BINARY) ] ; then \
set -x; \
$(MAKE) DESTDIR=$(TARGET_DIR) CC=$(TARGET_CC) -C $(CHILLISPOT_DIR) install; \
$(STRIP) $(TARGET_DIR)/$(CHILLISPOT_TARGET_BINARY)
rm -rf $(TARGET_DIR)/usr/man; fi;
$(CHILLISPOT_BUILD_DIR)/CONTROL/control: $(CHILLISPOT_DIR)/.stamp-built
rm -rf $(CHILLISPOT_BUILD_DIR)
mkdir -p $(CHILLISPOT_BUILD_DIR)/usr/sbin
cp -a $(CHILLISPOT_DIR)/src/chilli $(CHILLISPOT_BUILD_DIR)/usr/sbin/
$(STRIP) $(CHILLISPOT_BUILD_DIR)/usr/sbin/*
mkdir -p $(CHILLISPOT_BUILD_DIR)/etc
cp -a $(CHILLISPOT_DIR)/doc/chilli.conf $(CHILLISPOT_BUILD_DIR)/etc
cp -a $(CHILLISPOT_IPK_DIR)/root/* $(CHILLISPOT_BUILD_DIR)/
chmod 0755 $(CHILLISPOT_BUILD_DIR)/etc
chmod 0600 $(CHILLISPOT_BUILD_DIR)/etc/chilli.conf
chmod 0755 $(CHILLISPOT_BUILD_DIR)/etc/init.d
chmod 0755 $(CHILLISPOT_BUILD_DIR)/etc/init.d/*
chmod 0755 $(CHILLISPOT_BUILD_DIR)/usr
chmod 0755 $(CHILLISPOT_BUILD_DIR)/usr/sbin
chmod 0755 $(CHILLISPOT_BUILD_DIR)/usr/sbin/*
cp -a $(CHILLISPOT_IPK_DIR)/CONTROL $(CHILLISPOT_BUILD_DIR)/
perl -pi -e "s/^Vers.*:.*$$/Version: $(CHILLISPOT_VERSION)-$(CHILLISPOT_RELEASE)/" $(CHILLISPOT_BUILD_DIR)/CONTROL/control
perl -pi -e "s/^Arch.*:.*$$/Architecture: $(ARCH)/" $(CHILLISPOT_BUILD_DIR)/CONTROL/control
chillispot: $(CHILLISPOT_DIR)/$(CHILLISPOT_BINARY)
#chillispot-target_binary
$(MAKE) DESTDIR=$(TARGET_DIR) CC=$(TARGET_CC) -C $(CHILLISPOT_DIR) install
$(MAKE) DESTDIR=$(TARGET_DIR) CC=$(TARGET_CC) -C $(CHILLISPOT_DIR)/doc install
$(STRIP) $(TARGET_DIR)/$(CHILLISPOT_TARGET_BINARY)
touch $(CHILLISPOT_BUILD_DIR)/CONTROL/control
$(CHILLISPOT_IPK): $(CHILLISPOT_BUILD_DIR)/CONTROL/control
cd $(BUILD_DIR); $(IPKG_BUILD) $(CHILLISPOT_BUILD_DIR)
chillispot-ipk: ipkg-utils $(CHILLISPOT_IPK)
chillispot-clean:
$(MAKE) DESTDIR=$(TARGET_DIR) CC=$(TARGET_CC) -C $(CHILLISPOT_DIR) uninstall
-$(MAKE) -C $(CHILLISPOT_DIR) clean
$(MAKE) -C $(CHILLISPOT_DIR) clean
chillispot-dirclean:
rm -rf $(CHILLISPOT_DIR)

View File

@ -0,0 +1,92 @@
## dhcp-fwd
DHCP_FWD_VERSION := 0.7
DHCP_FWD_RELEASE := 1
DHCP_FWD_SOURCE := dhcp-forwarder-$(DHCP_FWD_VERSION).tar.bz2
DHCP_FWD_SITE := http://www-user.tu-chemnitz.de/~ensc/dhcp-fwd/files/
DHCP_FWD_DIR := $(BUILD_DIR)/dhcp-forwarder-$(DHCP_FWD_VERSION)
DHCP_FWD_CAT := bzcat
DHCP_FWD_BUILD_DIR := $(BUILD_DIR)/dhcp-fwd_$(DHCP_FWD_VERSION)-$(DHCP_FWD_RELEASE)
DHCP_FWD_IPK_DIR := $(OPENWRT_IPK_DIR)/dhcp-fwd
DHCP_FWD_IPK := $(DHCP_FWD_BUILD_DIR)_$(ARCH).ipk
$(DL_DIR)/$(DHCP_FWD_SOURCE):
$(WGET) -P $(DL_DIR) $(DHCP_FWD_SITE)/$(DHCP_FWD_SOURCE)
$(DHCP_FWD_DIR)/.stamp-unpacked: $(DL_DIR)/$(DHCP_FWD_SOURCE)
$(DHCP_FWD_CAT) $(DL_DIR)/$(DHCP_FWD_SOURCE) | tar -C $(BUILD_DIR) -xvf -
touch $(DHCP_FWD_DIR)/.stamp-unpacked
$(DHCP_FWD_DIR)/.stamp-configured: $(DHCP_FWD_DIR)/.stamp-unpacked
cd $(DHCP_FWD_DIR) ; \
rm -rf config.cache ; \
$(TARGET_CONFIGURE_OPTS) \
CFLAGS="$(TARGET_CFLAGS)" \
ac_cv_func_malloc_0_nonnull="yes" \
./configure \
--target=$(GNU_TARGET_NAME) \
--host=$(GNU_TARGET_NAME) \
--build=$(GNU_HOST_NAME) \
--prefix=/usr \
--exec-prefix=/usr \
--bindir=/usr/bin \
--sbindir=/usr/sbin \
--libexecdir=/usr/lib \
--datadir=/usr/share \
--infodir=/usr/share/info \
--mandir=/usr/share/man \
--localstatedir=/var \
--sysconfdir=/etc \
$(DISABLE_NLS) \
touch $(DHCP_FWD_DIR)/.stamp-configured
$(DHCP_FWD_DIR)/.stamp-built: $(DHCP_FWD_DIR)/.stamp-configured
cd $(DHCP_FWD_DIR) ; \
touch config.guess ; \
touch config.sub ; \
$(MAKE) \
CC=$(TARGET_CC) \
cfg_filename="/etc/dhcp-fwd.conf" \
all \
touch $(DHCP_FWD_DIR)/.stamp-built
$(DHCP_FWD_BUILD_DIR)/CONTROL/control: $(DHCP_FWD_DIR)/.stamp-built
rm -rf $(DHCP_FWD_BUILD_DIR)
mkdir -p $(DHCP_FWD_BUILD_DIR)/usr/sbin
cp -a $(DHCP_FWD_DIR)/dhcp-fwd $(DHCP_FWD_BUILD_DIR)/usr/sbin/
$(STRIP) $(DHCP_FWD_BUILD_DIR)/usr/sbin/*
cp -a $(DHCP_FWD_IPK_DIR)/root/* $(DHCP_FWD_BUILD_DIR)/
chmod 0755 $(DHCP_FWD_BUILD_DIR)/etc
chmod 0755 $(DHCP_FWD_BUILD_DIR)/etc/init.d
chmod 0755 $(DHCP_FWD_BUILD_DIR)/etc/init.d/*
chmod 0644 $(DHCP_FWD_BUILD_DIR)/etc/dhcp-fwd.conf
chmod 0755 $(DHCP_FWD_BUILD_DIR)/usr
chmod 0755 $(DHCP_FWD_BUILD_DIR)/usr/sbin
chmod 0755 $(DHCP_FWD_BUILD_DIR)/usr/sbin/*
cp -a $(DHCP_FWD_IPK_DIR)/CONTROL $(DHCP_FWD_BUILD_DIR)/
perl -pi -e "s/^Vers.*:.*$$/Version: $(DHCP_FWD_VERSION)-$(DHCP_FWD_RELEASE)/" $(DHCP_FWD_BUILD_DIR)/CONTROL/control
perl -pi -e "s/^Arch.*:.*$$/Architecture: $(ARCH)/" $(DHCP_FWD_BUILD_DIR)/CONTROL/control
touch $(DHCP_FWD_BUILD_DIR)/CONTROL/control
$(DHCP_FWD_IPK): $(DHCP_FWD_BUILD_DIR)/CONTROL/control
cd $(BUILD_DIR); $(IPKG_BUILD) $(DHCP_FWD_BUILD_DIR)
dhcp-fwd-ipk: ipkg-utils $(DHCP_FWD_IPK)
dhcp-fwd-clean:
rm -rf $(DHCP_FWD_IPK)
rm -rf $(DHCP_FWD_BUILD_DIR)
rm -rf $(DHCP_FWD_DIR)

View File

@ -10,6 +10,7 @@ IPKG_UTILS_SOURCE:=ipkg-utils-$(IPKG_UTILS_VERSION).tar.gz
IPKG_UTILS_DIR:=$(TOOL_BUILD_DIR)/ipkg-utils-$(IPKG_UTILS_VERSION)
IPKG_UTILS_PATCHES += ipkg-utils-1.7-ipkg_buildpackage.patch
IPKG_UTILS_PATCHES += ipkg-utils-1.7-ipkg_build_clean.patch
$(DL_DIR)/$(IPKG_UTILS_SOURCE):
$(WGET) -P $(DL_DIR) $(IPKG_UTILS_SITE)/$(IPKG_UTILS_SOURCE)
@ -30,7 +31,7 @@ $(STAGING_DIR)/bin/ipkg-build: $(IPKG_UTILS_DIR)/.unpacked
ipkg-utils: $(STAGING_DIR)/bin/ipkg-build
ipkg-utils-clean:
rm -f $(STAGING_DIR)/bin/ipkg-build*
rm -f $(STAGING_DIR)/bin/ipkg*
ipkg-utils-dirclean:
rm -rf $(IPKG_UTILS_DIR)

View File

@ -13,7 +13,7 @@ IPROUTE2_DIR=$(BUILD_DIR)/iproute2
IPROUTE2_SOURCE_URL=http://ftp.debian.org/debian/pool/main/i/iproute/
IPROUTE2_SOURCE=iproute_20010824.orig.tar.gz
IPROUTE2_PATCH:=iproute_20010824-8.diff.gz
IPROUTE2_PATCH_2:=iproute2-cross-ar-20010824.patch
IPROUTE2_PATCH_2:=iproute2-*.patch
IPROUTE2_IPKTARGET=iproute.ipk
IPROUTE2_IPKSRC:=iproute-pkg.tgz
@ -36,7 +36,7 @@ $(IPROUTE2_DIR)/.unpacked: $(DL_DIR)/$(IPROUTE2_SOURCE) #$(DL_DIR)/$(IPROUTE2_PA
rm -rf $(IPROUTE2_DIR).orig $(IPROUTE2_DIR)
zcat $(DL_DIR)/$(IPROUTE2_SOURCE) | tar -C $(BUILD_DIR) -xvf -
#zcat $(DL_DIR)/$(IPROUTE2_PATCH) | patch -p1 -d $(IPROUTE2_DIR)
cat $(SOURCE_DIR)/$(IPROUTE2_PATCH_2) | patch -p1 -d $(IPROUTE2_DIR)
$(SOURCE_DIR)/patch-kernel.sh $(IPROUTE2_DIR) $(SOURCE_DIR) $(IPROUTE2_PATCH_2)
# fun sed hacks.
$(SED) "s:-O2:${TARGET_CFLAGS}:g" $(IPROUTE2_DIR)/Makefile
ifeq ($(ARCH),i386)

View File

@ -6,6 +6,8 @@
IPTABLES_SOURCE_URL=http://www.netfilter.org/files
IPTABLES_SOURCE=iptables-1.2.9.tar.bz2
IPTABLES_BUILD_DIR=$(BUILD_DIR)/iptables-1.2.9
IP6TABLES_IPK=$(BUILD_DIR)/ip6tables_1.2.9-1_mipsel.ipk
IP6TABLES_IPK_DIR:=$(BUILD_DIR)/ip6tables-1.2.9-ipk
$(DL_DIR)/$(IPTABLES_SOURCE):
$(WGET) -P $(DL_DIR) $(IPTABLES_SOURCE_URL)/$(IPTABLES_SOURCE)
@ -35,11 +37,25 @@ $(TARGET_DIR)/sbin/iptables: $(IPTABLES_BUILD_DIR)/iptables
CC=$(TARGET_CC) COPT_FLAGS="$(TARGET_CFLAGS)" \
DESTDIR=$(TARGET_DIR) install
$(STRIP) $(TARGET_DIR)/usr/sbin/iptables*
$(STRIP) $(TARGET_DIR)/usr/sbin/ip6tables*
$(STRIP) $(TARGET_DIR)/usr/lib/iptables/*.so
rm -rf $(TARGET_DIR)/usr/man
iptables: $(TARGET_DIR)/sbin/iptables
$(IP6TABLES_IPK):
mkdir -p $(IP6TABLES_IPK_DIR)/CONTROL
mkdir -p $(IP6TABLES_IPK_DIR)/usr/lib/iptables
mkdir -p $(IP6TABLES_IPK_DIR)/usr/sbin
install -m 644 $(OPENWRT_IPK_DIR)/ip6tables/ip6tables.control $(IP6TABLES_IPK_DIR)/CONTROL/control
install -m 755 $(IPTABLES_BUILD_DIR)/ip6tables $(IP6TABLES_IPK_DIR)/usr/sbin
install -m 755 $(IPTABLES_BUILD_DIR)/extensions/libip6t_*.so $(IP6TABLES_IPK_DIR)/usr/lib/iptables/
$(STRIP) $(IP6TABLES_IPK_DIR)/usr/sbin/ip6tables*
$(STRIP) $(IP6TABLES_IPK_DIR)/usr/lib/iptables/*.so
cd $(BUILD_DIR); $(STAGING_DIR)/bin/ipkg-build -c -o root -g root $(IP6TABLES_IPK_DIR)
ip6tables-ipk: iptables $(IP6TABLES_IPK)
iptables-source: $(DL_DIR)/$(IPTABLES_SOURCE)
iptables-clean:

View File

@ -0,0 +1,15 @@
KMOD-IPT6:=kmod-ipt6
KMOD-IPT6_IPK:=$(KMOD-IPT6)_2.4.20-1_mipsel.ipk
KMOD-IPT6_IPK_DIR:=$(BUILD_DIR)/$(KMOD-IPT6)-2.4.20-ipk
$(BUILD_DIR)/$(KMOD-IPT6_IPK):
mkdir -p $(KMOD-IPT6_IPK_DIR)/CONTROL
mkdir -p $(KMOD-IPT6_IPK_DIR)/lib/modules/2.4.20/kernel/net/ipv6/netfilter
install -m 644 $(OPENWRT_IPK_DIR)/$(KMOD-IPT6)/$(KMOD-IPT6).control $(KMOD-IPT6_IPK_DIR)/CONTROL/control
install -m 644 $(BUILD_DIR)/linux/modules/lib/modules/2.4.20/kernel/net/ipv6/netfilter/* $(KMOD-IPT6_IPK_DIR)/lib/modules/2.4.20/kernel/net/ipv6/netfilter/
cd $(BUILD_DIR); $(STAGING_DIR)/bin/ipkg-build -c -o root -g root $(KMOD-IPT6_IPK_DIR)
kmod-ipt6-ipk: $(BUILD_DIR)/$(KMOD-IPT6_IPK)
kmod-ipt6-distclean:
rm -rf $(KMOD-IPT6_IPK_DIR)

View File

@ -0,0 +1,15 @@
KMOD-IPV6:=kmod-ipv6
KMOD-IPV6_IPK:=$(KMOD-IPV6)_2.4.20-1_mipsel.ipk
KMOD-IPV6_IPK_DIR:=$(BUILD_DIR)/$(KMOD-IPV6)-2.4.20-ipk
$(BUILD_DIR)/$(KMOD-IPV6_IPK):
mkdir -p $(KMOD-IPV6_IPK_DIR)/CONTROL
mkdir -p $(KMOD-IPV6_IPK_DIR)/lib/modules/2.4.20/kernel/net/ipv6
install -m 644 $(OPENWRT_IPK_DIR)/$(KMOD-IPV6)/$(KMOD-IPV6).control $(KMOD-IPV6_IPK_DIR)/CONTROL/control
install -m 644 $(BUILD_DIR)/linux/modules/lib/modules/2.4.20/kernel/net/ipv6/ipv6.o $(KMOD-IPV6_IPK_DIR)/lib/modules/2.4.20/kernel/net/ipv6
cd $(BUILD_DIR); $(STAGING_DIR)/bin/ipkg-build -c -o root -g root $(KMOD-IPV6_IPK_DIR)
kmod-ipv6-ipk: $(BUILD_DIR)/$(KMOD-IPV6_IPK)
kmod-ipv6-distclean:
rm -rf $(KMOD-IPV6_IPK_DIR)

View File

@ -0,0 +1,49 @@
## nfs-modules
NFS_MODULES_VERSION := $(SNAPSHOT)
NFS_MODULES_RELEASE := 1
NFS_MODULES_BUILD_DIR := $(BUILD_DIR)/nfs-modules_$(NFS_MODULES_VERSION)-$(NFS_MODULES_RELEASE)
NFS_MODULES_IPK_DIR := $(OPENWRT_IPK_DIR)/nfs-modules
NFS_MODULES_IPK := $(NFS_MODULES_BUILD_DIR)_$(ARCH).ipk
$(NFS_MODULES_BUILD_DIR)/CONTROL/control: $(BASE_DIR)/openwrt-kmodules.tar.bz2
rm -rf $(NFS_MODULES_BUILD_DIR)
mkdir -p $(NFS_MODULES_BUILD_DIR)/lib/
bzcat $(BASE_DIR)/openwrt-kmodules.tar.bz2 | tar -C $(NFS_MODULES_BUILD_DIR)/lib/ -xvf - \
modules/$(LINUX_VERSION)/kernel/fs/lockd/lockd.o \
modules/$(LINUX_VERSION)/kernel/fs/nfs/nfs.o \
modules/$(LINUX_VERSION)/kernel/net/sunrpc/sunrpc.o
mv -f \
$(NFS_MODULES_BUILD_DIR)/lib/modules/$(LINUX_VERSION)/kernel/fs/lockd/*.o \
$(NFS_MODULES_BUILD_DIR)/lib/modules/$(LINUX_VERSION)/
mv -f \
$(NFS_MODULES_BUILD_DIR)/lib/modules/$(LINUX_VERSION)/kernel/fs/nfs/*.o \
$(NFS_MODULES_BUILD_DIR)/lib/modules/$(LINUX_VERSION)/
mv -f \
$(NFS_MODULES_BUILD_DIR)/lib/modules/$(LINUX_VERSION)/kernel/net/sunrpc/*.o \
$(NFS_MODULES_BUILD_DIR)/lib/modules/$(LINUX_VERSION)/
rm -rf \
$(NFS_MODULES_BUILD_DIR)/lib/modules/$(LINUX_VERSION)/kernel
chmod 0755 $(NFS_MODULES_BUILD_DIR)/lib
chmod 0755 $(NFS_MODULES_BUILD_DIR)/lib/modules
chmod 0755 $(NFS_MODULES_BUILD_DIR)/lib/modules/$(LINUX_VERSION)
chmod 0755 $(NFS_MODULES_BUILD_DIR)/lib/modules/$(LINUX_VERSION)/*
cp -a $(NFS_MODULES_IPK_DIR)/CONTROL $(NFS_MODULES_BUILD_DIR)/
perl -pi -e "s/^Vers.*:.*$$/Version: $(NFS_MODULES_VERSION)-$(NFS_MODULES_RELEASE)/" $(NFS_MODULES_BUILD_DIR)/CONTROL/control
perl -pi -e "s/^Arch.*:.*$$/Architecture: $(ARCH)/" $(NFS_MODULES_BUILD_DIR)/CONTROL/control
touch $(NFS_MODULES_BUILD_DIR)/CONTROL/control
$(NFS_MODULES_IPK): $(NFS_MODULES_BUILD_DIR)/CONTROL/control
cd $(BUILD_DIR); $(IPKG_BUILD) $(NFS_MODULES_BUILD_DIR)
nfs-modules-ipk: ipkg-utils $(NFS_MODULES_IPK)
nfs-modules-clean:
rm -rf $(NFS_MODULES_IPK)
rm -rf $(NFS_MODULES_BUILD_DIR)

View File

@ -213,12 +213,13 @@ openwrt-prune: openwrt-base $(STAGING_DIR)/bin/sstrip
rm -f $(TARGET_DIR)/usr/sbin/iptables-save
rm -f $(TARGET_DIR)/usr/sbin/iptables-restore
rm -f $(TARGET_DIR)/usr/sbin/ip6tables
rm -f $(TARGET_DIR)/usr/lib/iptables/libip6*
-@find $(TARGET_DIR) -type f -perm +111 | xargs $(STAGING_DIR)/bin/sstrip 2>/dev/null || true;
######################################################################
$(STAGING_DIR)/bin/sstrip:
$(CC) -o $(STAGING_DIR)/bin/sstrip -I$(STAGING_DIR)/mipsel-linux-uclibc/include $(SOURCE_DIR)/openwrt/tools/sstrip.c
$(CC) -o $(STAGING_DIR)/bin/sstrip $(SOURCE_DIR)/openwrt/tools/sstrip.c
wrt-tools:
$(CC) -o $(WRT54G_DIR)/release/tools/trx $(SOURCE_DIR)/openwrt/tools/trx.c

View File

@ -0,0 +1,41 @@
## ppp-async-module
PPP_ASYNC_MODULE_VERSION := $(SNAPSHOT)
PPP_ASYNC_MODULE_RELEASE := 1
PPP_ASYNC_MODULE_BUILD_DIR := $(BUILD_DIR)/ppp-async-module_$(PPP_ASYNC_MODULE_VERSION)-$(PPP_ASYNC_MODULE_RELEASE)
PPP_ASYNC_MODULE_IPK_DIR := $(OPENWRT_IPK_DIR)/ppp-async-module
PPP_ASYNC_MODULE_IPK := $(PPP_ASYNC_MODULE_BUILD_DIR)_$(ARCH).ipk
$(PPP_ASYNC_MODULE_BUILD_DIR)/CONTROL/control: $(BASE_DIR)/openwrt-kmodules.tar.bz2
rm -rf $(PPP_ASYNC_MODULE_BUILD_DIR)
mkdir -p $(PPP_ASYNC_MODULE_BUILD_DIR)/lib/
bzcat $(BASE_DIR)/openwrt-kmodules.tar.bz2 | tar -C $(PPP_ASYNC_MODULE_BUILD_DIR)/lib/ -xvf - \
modules/$(LINUX_VERSION)/kernel/drivers/net/ppp_async.o
mv -f \
$(PPP_ASYNC_MODULE_BUILD_DIR)/lib/modules/$(LINUX_VERSION)/kernel/drivers/net/ppp_async.o \
$(PPP_ASYNC_MODULE_BUILD_DIR)/lib/modules/$(LINUX_VERSION)/
rm -rf \
$(PPP_ASYNC_MODULE_BUILD_DIR)/lib/modules/$(LINUX_VERSION)/kernel
chmod 0755 $(PPP_ASYNC_MODULE_BUILD_DIR)/lib
chmod 0755 $(PPP_ASYNC_MODULE_BUILD_DIR)/lib/modules
chmod 0755 $(PPP_ASYNC_MODULE_BUILD_DIR)/lib/modules/$(LINUX_VERSION)
chmod 0755 $(PPP_ASYNC_MODULE_BUILD_DIR)/lib/modules/$(LINUX_VERSION)/*
cp -a $(PPP_ASYNC_MODULE_IPK_DIR)/CONTROL $(PPP_ASYNC_MODULE_BUILD_DIR)/
perl -pi -e "s/^Vers.*:.*$$/Version: $(PPP_ASYNC_MODULE_VERSION)-$(PPP_ASYNC_MODULE_RELEASE)/" $(PPP_ASYNC_MODULE_BUILD_DIR)/CONTROL/control
perl -pi -e "s/^Arch.*:.*$$/Architecture: $(ARCH)/" $(PPP_ASYNC_MODULE_BUILD_DIR)/CONTROL/control
touch $(PPP_ASYNC_MODULE_BUILD_DIR)/CONTROL/control
$(PPP_ASYNC_MODULE_IPK): $(PPP_ASYNC_MODULE_BUILD_DIR)/CONTROL/control
cd $(BUILD_DIR); $(IPKG_BUILD) $(PPP_ASYNC_MODULE_BUILD_DIR)
ppp-async-module-ipk: ipkg-utils $(PPP_ASYNC_MODULE_IPK)
ppp-async-module-clean:
rm -rf $(PPP_ASYNC_MODULE_IPK)
rm -rf $(PPP_ASYNC_MODULE_BUILD_DIR)

View File

@ -0,0 +1,41 @@
## ppp-mppe-module
PPP_MPPE_MODULE_VERSION := $(SNAPSHOT)
PPP_MPPE_MODULE_RELEASE := 1
PPP_MPPE_MODULE_BUILD_DIR := $(BUILD_DIR)/ppp-mppe-module_$(PPP_MPPE_MODULE_VERSION)-$(PPP_MPPE_MODULE_RELEASE)
PPP_MPPE_MODULE_IPK_DIR := $(OPENWRT_IPK_DIR)/ppp-mppe-module
PPP_MPPE_MODULE_IPK := $(PPP_MPPE_MODULE_BUILD_DIR)_$(ARCH).ipk
$(PPP_MPPE_MODULE_BUILD_DIR)/CONTROL/control: $(BASE_DIR)/openwrt-kmodules.tar.bz2
rm -rf $(PPP_MPPE_MODULE_BUILD_DIR)
mkdir -p $(PPP_MPPE_MODULE_BUILD_DIR)/lib/
bzcat $(BASE_DIR)/openwrt-kmodules.tar.bz2 | tar -C $(PPP_MPPE_MODULE_BUILD_DIR)/lib/ -xvf - \
modules/$(LINUX_VERSION)/kernel/drivers/net/ppp_mppe_mppc.o
mv -f \
$(PPP_MPPE_MODULE_BUILD_DIR)/lib/modules/$(LINUX_VERSION)/kernel/drivers/net/ppp_mppe_mppc.o \
$(PPP_MPPE_MODULE_BUILD_DIR)/lib/modules/$(LINUX_VERSION)/
rm -rf \
$(PPP_MPPE_MODULE_BUILD_DIR)/lib/modules/$(LINUX_VERSION)/kernel
chmod 0755 $(PPP_MPPE_MODULE_BUILD_DIR)/lib
chmod 0755 $(PPP_MPPE_MODULE_BUILD_DIR)/lib/modules
chmod 0755 $(PPP_MPPE_MODULE_BUILD_DIR)/lib/modules/$(LINUX_VERSION)
chmod 0755 $(PPP_MPPE_MODULE_BUILD_DIR)/lib/modules/$(LINUX_VERSION)/*
cp -a $(PPP_MPPE_MODULE_IPK_DIR)/CONTROL $(PPP_MPPE_MODULE_BUILD_DIR)/
perl -pi -e "s/^Vers.*:.*$$/Version: $(PPP_MPPE_MODULE_VERSION)-$(PPP_MPPE_MODULE_RELEASE)/" $(PPP_MPPE_MODULE_BUILD_DIR)/CONTROL/control
perl -pi -e "s/^Arch.*:.*$$/Architecture: $(ARCH)/" $(PPP_MPPE_MODULE_BUILD_DIR)/CONTROL/control
touch $(PPP_MPPE_MODULE_BUILD_DIR)/CONTROL/control
$(PPP_MPPE_MODULE_IPK): $(PPP_MPPE_MODULE_BUILD_DIR)/CONTROL/control
cd $(BUILD_DIR); $(IPKG_BUILD) $(PPP_MPPE_MODULE_BUILD_DIR)
ppp-mppe-module-ipk: ipkg-utils $(PPP_MPPE_MODULE_IPK)
ppp-mppe-module-clean:
rm -rf $(PPP_MPPE_MODULE_IPK)
rm -rf $(PPP_MPPE_MODULE_BUILD_DIR)

View File

@ -0,0 +1,160 @@
## ppp & ppp-radius-plugin
PPP_VERSION := 2.4.2
PPP_RELEASE := 1
PPP_SOURCE:=ppp-$(PPP_VERSION).tar.gz
PPP_SITE:=ftp://ftp.samba.org/pub/ppp
PPP_DIR:=$(BUILD_DIR)/ppp-$(PPP_VERSION)
PPP_CAT:=zcat
PPP_PATCH_DIR := $(SOURCE_DIR)/openwrt/patches/ppp
PPP_BUILD_DIR := $(BUILD_DIR)/ppp_$(PPP_VERSION)-$(PPP_RELEASE)
PPP_IPK_DIR := $(OPENWRT_IPK_DIR)/ppp
PPP_IPK := $(PPP_BUILD_DIR)_$(ARCH).ipk
PPP_RADIUS_PLUGIN_BUILD_DIR := $(BUILD_DIR)/ppp-radius-plugin_$(PPP_VERSION)-$(PPP_RELEASE)
PPP_RADIUS_PLUGIN_IPK_DIR := $(OPENWRT_IPK_DIR)/ppp-radius-plugin
PPP_RADIUS_PLUGIN_IPK := $(PPP_RADIUS_PLUGIN_BUILD_DIR)_$(ARCH).ipk
$(DL_DIR)/$(PPP_SOURCE):
$(WGET) -P $(DL_DIR) $(PPP_SITE)/$(PPP_SOURCE)
$(PPP_DIR)/.stamp-unpacked: $(DL_DIR)/$(PPP_SOURCE)
$(PPP_CAT) $(DL_DIR)/$(PPP_SOURCE) | tar -C $(BUILD_DIR) -xvf -
touch $(PPP_DIR)/.stamp-unpacked
$(PPP_DIR)/.stamp-patched: $(PPP_DIR)/.stamp-unpacked
$(SOURCE_DIR)/patch-kernel.sh $(PPP_DIR) $(PPP_PATCH_DIR)
touch $(PPP_DIR)/.stamp-patched
$(PPP_DIR)/.stamp-configured: $(PPP_DIR)/.stamp-patched
cd $(PPP_DIR)/pppd/plugins/radius/radiusclient ; \
rm -rf config.cache ; \
$(TARGET_CONFIGURE_OPTS) \
ac_cv_func_setvbuf_reversed=no \
ac_cv_func_uname=no \
./configure \
--target=$(GNU_TARGET_NAME) \
--host=$(GNU_TARGET_NAME) \
--build=$(GNU_HOST_NAME) \
--prefix=/usr \
--exec-prefix=/usr \
--bindir=/usr/bin \
--sbindir=/usr/sbin \
--libexecdir=/usr/lib \
--sysconfdir=/etc \
--datadir=/usr/share \
--localstatedir=/var \
--mandir=/usr/share/man \
--infodir=/usr/share/info \
$(DISABLE_NLS) \
--disable-shared \
--enable-static \
cd $(PPP_DIR) ; \
rm -rf config.cache ; \
$(TARGET_CONFIGURE_OPTS) \
CFLAGS="$(TARGET_CFLAGS)" \
./configure \
--target=$(GNU_TARGET_NAME) \
--host=$(GNU_TARGET_NAME) \
--build=$(GNU_HOST_NAME) \
--prefix=/usr \
--exec-prefix=/usr \
--bindir=/usr/bin \
--sbindir=/usr/sbin \
--libexecdir=/usr/lib \
--datadir=/usr/share \
--localstatedir=/var \
--mandir=/usr/share/man \
--infodir=/usr/share/info \
--sysconfdir=/etc \
$(DISABLE_NLS) \
touch $(PPP_DIR)/.stamp-configured
$(PPP_DIR)/.stamp-built: $(PPP_DIR)/.stamp-configured
cd $(PPP_DIR) ; \
$(MAKE) \
CC=$(TARGET_CC) \
COPTS="$(TARGET_CFLAGS)" \
all
touch $(PPP_DIR)/.stamp-built
$(PPP_BUILD_DIR)/CONTROL/control: $(PPP_DIR)/.stamp-built
rm -rf $(PPP_BUILD_DIR)
mkdir -p $(PPP_BUILD_DIR)/usr/sbin
cp -a $(PPP_DIR)/pppd/pppd $(PPP_BUILD_DIR)/usr/sbin/
$(STRIP) $(PPP_BUILD_DIR)/usr/sbin/*
cp -a $(PPP_IPK_DIR)/root/* $(PPP_BUILD_DIR)/
chmod 0755 $(PPP_BUILD_DIR)/etc
chmod 0755 $(PPP_BUILD_DIR)/etc/ppp
chmod 0600 $(PPP_BUILD_DIR)/etc/ppp/chap-secrets
chmod 0644 $(PPP_BUILD_DIR)/etc/ppp/options
chmod 0755 $(PPP_BUILD_DIR)/etc/ppp/peers
chmod 0755 $(PPP_BUILD_DIR)/usr
chmod 0755 $(PPP_BUILD_DIR)/usr/sbin
chmod 0755 $(PPP_BUILD_DIR)/usr/sbin/*
cp -a $(PPP_IPK_DIR)/CONTROL $(PPP_BUILD_DIR)/
perl -pi -e "s/^Vers.*:.*$$/Version: $(PPP_VERSION)-$(PPP_RELEASE)/" $(PPP_BUILD_DIR)/CONTROL/control
perl -pi -e "s/^Arch.*:.*$$/Architecture: $(ARCH)/" $(PPP_BUILD_DIR)/CONTROL/control
touch $(PPP_BUILD_DIR)/CONTROL/control
$(PPP_IPK): $(PPP_BUILD_DIR)/CONTROL/control
cd $(BUILD_DIR); $(IPKG_BUILD) $(PPP_BUILD_DIR)
$(PPP_RADIUS_PLUGIN_BUILD_DIR)/CONTROL/control: $(PPP_DIR)/.stamp-built
rm -rf $(PPP_RADIUS_PLUGIN_BUILD_DIR)
mkdir -p $(PPP_RADIUS_PLUGIN_BUILD_DIR)/usr/lib/pppd/$(PPP_VERSION)
cp -a $(PPP_DIR)/pppd/plugins/radius/radius.so $(PPP_RADIUS_PLUGIN_BUILD_DIR)/usr/lib/pppd/$(PPP_VERSION)/
$(STRIP) $(PPP_RADIUS_PLUGIN_BUILD_DIR)/usr/lib/pppd/$(PPP_VERSION)/*
cp -a $(PPP_RADIUS_PLUGIN_IPK_DIR)/root/* $(PPP_RADIUS_PLUGIN_BUILD_DIR)/
chmod 0755 $(PPP_RADIUS_PLUGIN_BUILD_DIR)/etc
chmod 0755 $(PPP_RADIUS_PLUGIN_BUILD_DIR)/etc/ppp
chmod 0644 $(PPP_RADIUS_PLUGIN_BUILD_DIR)/etc/ppp/radius.conf
chmod 0755 $(PPP_RADIUS_PLUGIN_BUILD_DIR)/etc/ppp/radius
chmod 0644 $(PPP_RADIUS_PLUGIN_BUILD_DIR)/etc/ppp/radius/dict*
chmod 0600 $(PPP_RADIUS_PLUGIN_BUILD_DIR)/etc/ppp/radius/servers
chmod 0755 $(PPP_RADIUS_PLUGIN_BUILD_DIR)/usr
chmod 0755 $(PPP_RADIUS_PLUGIN_BUILD_DIR)/usr/lib
chmod 0755 $(PPP_RADIUS_PLUGIN_BUILD_DIR)/usr/lib/pppd
chmod 0755 $(PPP_RADIUS_PLUGIN_BUILD_DIR)/usr/lib/pppd/$(PPP_VERSION)
cp -a $(PPP_RADIUS_PLUGIN_IPK_DIR)/CONTROL $(PPP_RADIUS_PLUGIN_BUILD_DIR)/
perl -pi -e "s/^Vers.*:.*$$/Version: $(PPP_VERSION)-$(PPP_RELEASE)/" $(PPP_RADIUS_PLUGIN_BUILD_DIR)/CONTROL/control
perl -pi -e "s/^Arch.*:.*$$/Architecture: $(ARCH)/" $(PPP_RADIUS_PLUGIN_BUILD_DIR)/CONTROL/control
touch $(PPP_RADIUS_PLUGIN_BUILD_DIR)/CONTROL/control
$(PPP_RADIUS_PLUGIN_IPK): $(PPP_RADIUS_PLUGIN_BUILD_DIR)/CONTROL/control
cd $(BUILD_DIR); $(IPKG_BUILD) $(PPP_RADIUS_PLUGIN_BUILD_DIR)
ppp-ipk: ipkg-utils $(PPP_IPK) $(PPP_RADIUS_PLUGIN_IPK)
ppp-ipk-clean:
rm -rf $(PPP_IPK) $(PPP_RADIUS_PLUGIN_IPK)
rm -rf $(PPP_BUILD_DIR) $(PPP_RADIUS_PLUGIN_BUILD_DIR)
ppp-clean:
cd $(PPP_DIR) ; \
$(MAKE) clean
ppp-dirclean:
rm -rf $(PPP_DIR)

View File

@ -0,0 +1,105 @@
## pptp-server
PPTPD_VERSION := 1.1.3
PPTPD_RELEASE := 1
PPTPD_SOURCE := pptpd-1.1.3-20030409.tar.gz
PPTPD_SITE := http://unc.dl.sourceforge.net/sourceforge/poptop/
PPTPD_DIR := $(BUILD_DIR)/poptop
PPTPD_CAT := zcat
PPTPD_PATCH_DIR := $(SOURCE_DIR)/openwrt/patches/pptp-server
PPTPD_BUILD_DIR := $(BUILD_DIR)/pptp-server_$(PPTPD_VERSION)-$(PPTPD_RELEASE)
PPTPD_IPK_DIR := $(OPENWRT_IPK_DIR)/pptp-server
PPTPD_IPK := $(PPTPD_BUILD_DIR)_$(ARCH).ipk
$(DL_DIR)/$(PPTPD_SOURCE):
$(WGET) -P $(DL_DIR) $(PPTPD_SITE)/$(PPTPD_SOURCE)
$(PPTPD_DIR)/.stamp-unpacked: $(DL_DIR)/$(PPTPD_SOURCE)
$(PPTPD_CAT) $(DL_DIR)/$(PPTPD_SOURCE) | tar -C $(BUILD_DIR) -xvf -
touch $(PPTPD_DIR)/.stamp-unpacked
$(PPTPD_DIR)/.stamp-patched: $(PPTPD_DIR)/.stamp-unpacked
$(SOURCE_DIR)/patch-kernel.sh $(PPTPD_DIR) $(PPTPD_PATCH_DIR)
touch $(PPTPD_DIR)/.stamp-patched
$(PPTPD_DIR)/.stamp-configured: $(PPTPD_DIR)/.stamp-patched
cd $(PPTPD_DIR) ; \
rm -rf config.cache ; \
aclocal ; \
autoconf ; \
$(TARGET_CONFIGURE_OPTS) \
CFLAGS="$(TARGET_CFLAGS)" \
./configure \
--target=$(GNU_TARGET_NAME) \
--host=$(GNU_TARGET_NAME) \
--build=$(GNU_HOST_NAME) \
--prefix=/usr \
--exec-prefix=/usr \
--bindir=/usr/bin \
--sbindir=/usr/sbin \
--libexecdir=/usr/lib \
--datadir=/usr/share \
--infodir=/usr/share/info \
--mandir=/usr/share/man \
--localstatedir=/var \
--sysconfdir=/etc \
$(DISABLE_NLS) \
--with-pppd-ip-alloc \
touch $(PPTPD_DIR)/.stamp-configured
$(PPTPD_DIR)/.stamp-built: $(PPTPD_DIR)/.stamp-configured
cd $(PPTPD_DIR) ; \
touch config.guess ; \
touch config.sub ; \
$(MAKE) \
CC=$(TARGET_CC) \
COPTS="$(TARGET_CFLAGS)" \
all
touch $(PPTPD_DIR)/.stamp-built
$(PPTPD_BUILD_DIR)/CONTROL/control: $(PPTPD_DIR)/.stamp-built
rm -rf $(PPTPD_BUILD_DIR)
mkdir -p $(PPTPD_BUILD_DIR)/usr/sbin
cp -a $(PPTPD_DIR)/pptpctrl $(PPTPD_BUILD_DIR)/usr/sbin/
cp -a $(PPTPD_DIR)/pptpd $(PPTPD_BUILD_DIR)/usr/sbin/
$(STRIP) $(PPTPD_BUILD_DIR)/usr/sbin/*
cp -a $(PPTPD_IPK_DIR)/root/* $(PPTPD_BUILD_DIR)/
chmod 0755 $(PPTPD_BUILD_DIR)/etc
chmod 0755 $(PPTPD_BUILD_DIR)/etc/init.d
chmod 0755 $(PPTPD_BUILD_DIR)/etc/init.d/*
chmod 0755 $(PPTPD_BUILD_DIR)/etc/ppp
chmod 0644 $(PPTPD_BUILD_DIR)/etc/ppp/pptp-server-options
chmod 0644 $(PPTPD_BUILD_DIR)/etc/pptpd.conf
chmod 0755 $(PPTPD_BUILD_DIR)/usr
chmod 0755 $(PPTPD_BUILD_DIR)/usr/sbin
chmod 0755 $(PPTPD_BUILD_DIR)/usr/sbin/*
cp -a $(PPTPD_IPK_DIR)/CONTROL $(PPTPD_BUILD_DIR)/
perl -pi -e "s/^Vers.*:.*$$/Version: $(PPTPD_VERSION)-$(PPTPD_RELEASE)/" $(PPTPD_BUILD_DIR)/CONTROL/control
perl -pi -e "s/^Arch.*:.*$$/Architecture: $(ARCH)/" $(PPTPD_BUILD_DIR)/CONTROL/control
touch $(PPTPD_BUILD_DIR)/CONTROL/control
$(PPTPD_IPK): $(PPTPD_BUILD_DIR)/CONTROL/control
cd $(BUILD_DIR); $(IPKG_BUILD) $(PPTPD_BUILD_DIR)
pptp-server-ipk: ipkg-utils $(PPTPD_IPK)
pptp-server-clean:
rm -rf $(PPTPD_IPK)
rm -rf $(PPTPD_BUILD_DIR)
rm -rf $(PPTPD_DIR)

View File

@ -0,0 +1,41 @@
## tun-module
TUN_MODULE_VERSION := $(SNAPSHOT)
TUN_MODULE_RELEASE := 1
TUN_MODULE_BUILD_DIR := $(BUILD_DIR)/tun-module_$(TUN_MODULE_VERSION)-$(TUN_MODULE_RELEASE)
TUN_MODULE_IPK_DIR := $(OPENWRT_IPK_DIR)/tun-module
TUN_MODULE_IPK := $(TUN_MODULE_BUILD_DIR)_$(ARCH).ipk
$(TUN_MODULE_BUILD_DIR)/CONTROL/control: $(BASE_DIR)/openwrt-kmodules.tar.bz2
rm -rf $(TUN_MODULE_BUILD_DIR)
mkdir -p $(TUN_MODULE_BUILD_DIR)/lib/
bzcat $(BASE_DIR)/openwrt-kmodules.tar.bz2 | tar -C $(TUN_MODULE_BUILD_DIR)/lib/ -xvf - \
modules/$(LINUX_VERSION)/kernel/drivers/net/tun.o
mv -f \
$(TUN_MODULE_BUILD_DIR)/lib/modules/$(LINUX_VERSION)/kernel/drivers/net/tun.o \
$(TUN_MODULE_BUILD_DIR)/lib/modules/$(LINUX_VERSION)/
rm -rf \
$(TUN_MODULE_BUILD_DIR)/lib/modules/$(LINUX_VERSION)/kernel
chmod 0755 $(TUN_MODULE_BUILD_DIR)/lib
chmod 0755 $(TUN_MODULE_BUILD_DIR)/lib/modules
chmod 0755 $(TUN_MODULE_BUILD_DIR)/lib/modules/$(LINUX_VERSION)
chmod 0755 $(TUN_MODULE_BUILD_DIR)/lib/modules/$(LINUX_VERSION)/*
cp -a $(TUN_MODULE_IPK_DIR)/CONTROL $(TUN_MODULE_BUILD_DIR)/
perl -pi -e "s/^Vers.*:.*$$/Version: $(TUN_MODULE_VERSION)-$(TUN_MODULE_RELEASE)/" $(TUN_MODULE_BUILD_DIR)/CONTROL/control
perl -pi -e "s/^Arch.*:.*$$/Architecture: $(ARCH)/" $(TUN_MODULE_BUILD_DIR)/CONTROL/control
touch $(TUN_MODULE_BUILD_DIR)/CONTROL/control
$(TUN_MODULE_IPK): $(TUN_MODULE_BUILD_DIR)/CONTROL/control
cd $(BUILD_DIR); $(IPKG_BUILD) $(TUN_MODULE_BUILD_DIR)
tun-module-ipk: ipkg-utils $(TUN_MODULE_IPK)
tun-module-clean:
rm -rf $(TUN_MODULE_IPK)
rm -rf $(TUN_MODULE_BUILD_DIR)

View File

@ -0,0 +1,36 @@
diff -ruN ipkg-utils-1.7-old/ipkg-build ipkg-utils-1.7-new/ipkg-build
--- ipkg-utils-1.7-old/ipkg-build 2004-08-24 04:56:12.000000000 +0200
+++ ipkg-utils-1.7-new/ipkg-build 2004-08-24 04:55:49.000000000 +0200
@@ -47,6 +47,19 @@
PKG_ERROR=0
+ cvs_dirs=`find . -name 'CVS'`
+ if [ -n "$cvs_dirs" ]; then
+ if [ "$noclean" = "1" ]; then
+ echo "*** Warning: The following CVS directories where found.
+You probably want to remove them: " >&2
+ ls -ld $cvs_dirs
+ echo >&2
+ else
+ echo "*** Removing the following files: $cvs_dirs"
+ rm -rf "$cvs_dirs"
+ fi
+ fi
+
tilde_files=`find . -name '*~'`
if [ -n "$tilde_files" ]; then
if [ "$noclean" = "1" ]; then
@@ -134,8 +147,12 @@
for script in $CONTROL/preinst $CONTROL/postinst $CONTROL/prerm $CONTROL/postrm; do
if [ -f $script -a ! -x $script ]; then
+ if [ "$noclean" = "1" ]; then
echo "*** Error: package script $script is not executable" >&2
PKG_ERROR=1
+ else
+ chmod a+x $script
+ fi
fi
done

View File

@ -0,0 +1,319 @@
--- iproute2/tc/q_htb.c Sun Oct 21 22:07:29 2001
+++ iproute2new/tc/q_htb.c Sun May 12 22:18:27 2002
@@ -0,0 +1,306 @@
+/*
+ * q_htb.c HTB.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ *
+ * Authors: Martin Devera, devik@cdi.cz
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <syslog.h>
+#include <fcntl.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <string.h>
+
+#include "utils.h"
+#include "tc_util.h"
+
+#define HTB_TC_VER 0x30003
+#if HTB_TC_VER >> 16 != TC_HTB_PROTOVER
+#error "Different kernel and TC HTB versions"
+#endif
+
+static void explain(void)
+{
+ fprintf(stderr, "Usage: ... qdisc add ... htb [default N] [r2q N]\n"
+ " default minor id of class to which unclassified packets are sent {0}\n"
+ " r2q DRR quantums are computed as rate in Bps/r2q {10}\n"
+ " debug string of 16 numbers each 0-3 {0}\n\n"
+ "... class add ... htb rate R1 burst B1 [prio P] [slot S] [pslot PS]\n"
+ " [ceil R2] [cburst B2] [mtu MTU] [quantum Q]\n"
+ " rate rate allocated to this class (class can still borrow)\n"
+ " burst max bytes burst which can be accumulated during idle period {computed}\n"
+ " ceil definite upper class rate (no borrows) {rate}\n"
+ " cburst burst but for ceil {computed}\n"
+ " mtu max packet size we create rate map for {1600}\n"
+ " prio priority of leaf; lower are served first {0}\n"
+ " quantum how much bytes to serve from leaf at once {use r2q}\n"
+ "\nTC HTB version %d.%d\n",HTB_TC_VER>>16,HTB_TC_VER&0xffff
+ );
+}
+
+static void explain1(char *arg)
+{
+ fprintf(stderr, "Illegal \"%s\"\n", arg);
+ explain();
+}
+
+
+#define usage() return(-1)
+
+static int htb_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n)
+{
+ struct tc_htb_glob opt;
+ struct rtattr *tail;
+ unsigned i; char *p;
+ memset(&opt,0,sizeof(opt));
+ opt.rate2quantum = 10;
+ opt.version = 3;
+
+ while (argc > 0) {
+ if (matches(*argv, "r2q") == 0) {
+ NEXT_ARG();
+ if (get_u32(&opt.rate2quantum, *argv, 10)) {
+ explain1("r2q"); return -1;
+ }
+ } else if (matches(*argv, "default") == 0) {
+ NEXT_ARG();
+ if (get_u32(&opt.defcls, *argv, 16)) {
+ explain1("default"); return -1;
+ }
+ } else if (matches(*argv, "debug") == 0) {
+ NEXT_ARG(); p = *argv;
+ for (i=0; i<16; i++,p++) {
+ if (*p<'0' || *p>'3') break;
+ opt.debug |= (*p-'0')<<(2*i);
+ }
+ } else {
+ fprintf(stderr, "What is \"%s\"?\n", *argv);
+ explain();
+ return -1;
+ }
+ argc--; argv++;
+ }
+ tail = (struct rtattr*)(((void*)n)+NLMSG_ALIGN(n->nlmsg_len));
+ addattr_l(n, 1024, TCA_OPTIONS, NULL, 0);
+ addattr_l(n, 2024, TCA_HTB_INIT, &opt, NLMSG_ALIGN(sizeof(opt)));
+ tail->rta_len = (((void*)n)+NLMSG_ALIGN(n->nlmsg_len)) - (void*)tail;
+ return 0;
+}
+
+static int htb_parse_class_opt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n)
+{
+ int ok=0;
+ struct tc_htb_opt opt;
+ __u32 rtab[256],ctab[256];
+ unsigned buffer=0,cbuffer=0;
+ int cell_log=-1,ccell_log = -1,mtu;
+ struct rtattr *tail;
+
+ memset(&opt, 0, sizeof(opt)); mtu = 1600; /* eth packet len */
+
+ while (argc > 0) {
+ if (matches(*argv, "prio") == 0) {
+ NEXT_ARG();
+ if (get_u32(&opt.prio, *argv, 10)) {
+ explain1("prio"); return -1;
+ }
+ ok++;
+ } else if (matches(*argv, "mtu") == 0) {
+ NEXT_ARG();
+ if (get_u32(&mtu, *argv, 10)) {
+ explain1("mtu"); return -1;
+ }
+ } else if (matches(*argv, "quantum") == 0) {
+ NEXT_ARG();
+ if (get_u32(&opt.quantum, *argv, 10)) {
+ explain1("quantum"); return -1;
+ }
+ } else if (matches(*argv, "burst") == 0 ||
+ strcmp(*argv, "buffer") == 0 ||
+ strcmp(*argv, "maxburst") == 0) {
+ NEXT_ARG();
+ if (get_size_and_cell(&buffer, &cell_log, *argv) < 0) {
+ explain1("buffer");
+ return -1;
+ }
+ ok++;
+ } else if (matches(*argv, "cburst") == 0 ||
+ strcmp(*argv, "cbuffer") == 0 ||
+ strcmp(*argv, "cmaxburst") == 0) {
+ NEXT_ARG();
+ if (get_size_and_cell(&cbuffer, &ccell_log, *argv) < 0) {
+ explain1("cbuffer");
+ return -1;
+ }
+ ok++;
+ } else if (strcmp(*argv, "ceil") == 0) {
+ NEXT_ARG();
+ if (opt.ceil.rate) {
+ fprintf(stderr, "Double \"ceil\" spec\n");
+ return -1;
+ }
+ if (get_rate(&opt.ceil.rate, *argv)) {
+ explain1("ceil");
+ return -1;
+ }
+ ok++;
+ } else if (strcmp(*argv, "rate") == 0) {
+ NEXT_ARG();
+ if (opt.rate.rate) {
+ fprintf(stderr, "Double \"rate\" spec\n");
+ return -1;
+ }
+ if (get_rate(&opt.rate.rate, *argv)) {
+ explain1("rate");
+ return -1;
+ }
+ ok++;
+ } else if (strcmp(*argv, "help") == 0) {
+ explain();
+ return -1;
+ } else {
+ fprintf(stderr, "What is \"%s\"?\n", *argv);
+ explain();
+ return -1;
+ }
+ argc--; argv++;
+ }
+
+/* if (!ok)
+ return 0;*/
+
+ if (opt.rate.rate == 0) {
+ fprintf(stderr, "\"rate\" is required.\n");
+ return -1;
+ }
+ /* if ceil params are missing, use the same as rate */
+ if (!opt.ceil.rate) opt.ceil = opt.rate;
+
+ /* compute minimal allowed burst from rate; mtu is added here to make
+ sute that buffer is larger than mtu and to have some safeguard space */
+ if (!buffer) buffer = opt.rate.rate / HZ + mtu;
+ if (!cbuffer) cbuffer = opt.ceil.rate / HZ + mtu;
+
+ if ((cell_log = tc_calc_rtable(opt.rate.rate, rtab, cell_log, mtu, 0)) < 0) {
+ fprintf(stderr, "htb: failed to calculate rate table.\n");
+ return -1;
+ }
+ opt.buffer = tc_calc_xmittime(opt.rate.rate, buffer);
+ opt.rate.cell_log = cell_log;
+
+ if ((ccell_log = tc_calc_rtable(opt.ceil.rate, ctab, cell_log, mtu, 0)) < 0) {
+ fprintf(stderr, "htb: failed to calculate ceil rate table.\n");
+ return -1;
+ }
+ opt.cbuffer = tc_calc_xmittime(opt.ceil.rate, cbuffer);
+ opt.ceil.cell_log = ccell_log;
+
+ tail = (struct rtattr*)(((void*)n)+NLMSG_ALIGN(n->nlmsg_len));
+ addattr_l(n, 1024, TCA_OPTIONS, NULL, 0);
+ addattr_l(n, 2024, TCA_HTB_PARMS, &opt, sizeof(opt));
+ addattr_l(n, 3024, TCA_HTB_RTAB, rtab, 1024);
+ addattr_l(n, 4024, TCA_HTB_CTAB, ctab, 1024);
+ tail->rta_len = (((void*)n)+NLMSG_ALIGN(n->nlmsg_len)) - (void*)tail;
+ return 0;
+}
+
+static int htb_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
+{
+ struct rtattr *tb[TCA_HTB_RTAB+1];
+ struct tc_htb_opt *hopt;
+ struct tc_htb_glob *gopt;
+ double buffer,cbuffer;
+ SPRINT_BUF(b1);
+ SPRINT_BUF(b2);
+
+ if (opt == NULL)
+ return 0;
+
+ memset(tb, 0, sizeof(tb));
+ parse_rtattr(tb, TCA_HTB_RTAB, RTA_DATA(opt), RTA_PAYLOAD(opt));
+
+ if (tb[TCA_HTB_PARMS]) {
+
+ hopt = RTA_DATA(tb[TCA_HTB_PARMS]);
+ if (RTA_PAYLOAD(tb[TCA_HTB_PARMS]) < sizeof(*hopt)) return -1;
+
+ if (!hopt->level) {
+ fprintf(f, "prio %d ", (int)hopt->prio);
+ if (show_details)
+ fprintf(f, "quantum %d ", (int)hopt->quantum);
+ }
+ fprintf(f, "rate %s ", sprint_rate(hopt->rate.rate, b1));
+ buffer = ((double)hopt->rate.rate*tc_core_tick2usec(hopt->buffer))/1000000;
+ fprintf(f, "ceil %s ", sprint_rate(hopt->ceil.rate, b1));
+ cbuffer = ((double)hopt->ceil.rate*tc_core_tick2usec(hopt->cbuffer))/1000000;
+ if (show_details) {
+ fprintf(f, "burst %s/%u mpu %s ", sprint_size(buffer, b1),
+ 1<<hopt->rate.cell_log, sprint_size(hopt->rate.mpu, b2));
+ fprintf(f, "cburst %s/%u mpu %s ", sprint_size(cbuffer, b1),
+ 1<<hopt->ceil.cell_log, sprint_size(hopt->ceil.mpu, b2));
+ fprintf(f, "level %d ", (int)hopt->level);
+ } else {
+ fprintf(f, "burst %s ", sprint_size(buffer, b1));
+ fprintf(f, "cburst %s ", sprint_size(cbuffer, b1));
+ }
+ if (show_raw)
+ fprintf(f, "buffer [%08x] cbuffer [%08x] ",
+ hopt->buffer,hopt->cbuffer);
+ }
+ if (tb[TCA_HTB_INIT]) {
+ gopt = RTA_DATA(tb[TCA_HTB_INIT]);
+ if (RTA_PAYLOAD(tb[TCA_HTB_INIT]) < sizeof(*gopt)) return -1;
+
+ fprintf(f, "r2q %d default %x direct_packets_stat %u",
+ gopt->rate2quantum,gopt->defcls,gopt->direct_pkts);
+ if (show_details)
+ fprintf(f," ver %d.%d",gopt->version >> 16,gopt->version & 0xffff);
+ }
+ return 0;
+}
+
+static int htb_print_xstats(struct qdisc_util *qu, FILE *f, struct rtattr *xstats)
+{
+ struct tc_htb_xstats *st;
+ if (xstats == NULL)
+ return 0;
+
+ if (RTA_PAYLOAD(xstats) < sizeof(*st))
+ return -1;
+
+ st = RTA_DATA(xstats);
+ fprintf(f, " lended: %u borrowed: %u giants: %u\n",
+ st->lends,st->borrows,st->giants);
+ fprintf(f, " tokens: %d ctokens: %d\n", st->tokens,st->ctokens);
+ return 0;
+}
+
+struct qdisc_util htb_util = {
+ NULL,
+ "htb",
+ htb_parse_opt,
+ htb_print_opt,
+ htb_print_xstats,
+ htb_parse_class_opt,
+ htb_print_opt,
+};
+
+/* for testing of old one */
+struct qdisc_util htb2_util = {
+ NULL,
+ "htb2",
+ htb_parse_opt,
+ htb_print_opt,
+ htb_print_xstats,
+ htb_parse_class_opt,
+ htb_print_opt,
+};
--- iproute2/tc/Makefile Tue Jul 6 18:13:07 1999
+++ iproute2new/tc/Makefile Thu May 9 12:34:19 2002
@@ -21,6 +21,7 @@ ifeq ($(TC_CONFIG_DIFFSERV),y)
endif
#TCMODULES += q_csz.o
+TCMODULES += q_htb.o
#TCMODULES += q_hpfq.o
#TCMODULES += q_hfsc.o

View File

@ -9,7 +9,7 @@
+#PF_EXT_SLIB:=ah connlimit connmark conntrack dscp ecn esp helper icmp iprange length limit mac mark multiport owner physdev pkttype realm rpc standard state tcp tcpmss tos ttl udp unclean CLASSIFY CONNMARK DNAT DSCP ECN LOG MARK MASQUERADE MIRROR NETMAP NOTRACK REDIRECT REJECT SAME SNAT TARPIT TCPMSS TOS TRACE TTL ULOG
+PF_EXT_SLIB:=icmp iprange mark multiport standard state tcp udp DNAT LOG MARK MASQUERADE REDIRECT REJECT SNAT TCPMSS
+#PF6_EXT_SLIB:=eui64 hl icmpv6 length limit mac mark multiport owner standard tcp udp HL LOG MARK TRACE
+#PF6_EXT_SLIB:=eui64 icmpv6 mark standard tcp udp LOG
+PF6_EXT_SLIB:=eui64 icmpv6 mark standard tcp udp LOG
# Optionals
-PF_EXT_SLIB_OPTS:=$(foreach T,$(wildcard extensions/.*-test),$(shell KERNEL_DIR=$(KERNEL_DIR) $(T)))

View File

@ -0,0 +1 @@
/etc/chilli.conf

View File

@ -0,0 +1,9 @@
Package: chillispot
Priority: optional
Section: net
Version: TBDL
Architecture: TBDL
Maintainer: Nico <nthill@free.fr>
Source: http://openwrt.org/cgi-bin/viewcvs.cgi/buildroot/
Description: a wireless access point controller
Depends: tun-module

View File

@ -0,0 +1,17 @@
#!/bin/sh
case $1 in
start)
insmod tun >/dev/null 2>&1
[ -d /var/run ] || mkdir -p /var/run
/usr/sbin/chilli
;;
stop)
[ -f /var/run/chilli.pid ] && kill $(cat /var/run/chilli.pid) >/dev/null 2>&1
;;
*)
echo "usage: $0 (start|stop)"
exit 1
esac
exit $?

View File

@ -0,0 +1 @@
/etc/dhcp-fwd.conf

View File

@ -0,0 +1,8 @@
Package: dhcp-fwd
Priority: optional
Section: net
Version: TBDL
Architecture: TBDL
Maintainer: Nico <nthill@free.fr>
Source: http://openwrt.org/cgi-bin/viewcvs.cgi/buildroot/
Description: a DHCP relay agent

View File

@ -0,0 +1,114 @@
## $Id$
## This file contains a sample configuration for the network shown
## below:
##
## -------------- ---------- -------------
## | DHCP Server | | | | |
## | 192.168.8.66 |------<eth1>| dhcp-fwd |<eth2>------| Clients |
## | | | | | |
## -------------- ---------- -------------
##
## By default, the dhcp-fwd agent looks at /etc/dhcp-fwd.conf
## for this file. By using the '-c' option when calling dhcp-fwd, this
## path can be changed.
######### ENVIRONMENT SETTINGS #########
####
###
## The server will drop its privileges and goes into a chroot-jail
## after doing its initialization. The following parameters are
## defining the needed parameters:
## User and group names/ids. It can be a numeric id or a resolvable
## alphanumeric-name.
##
## WARNING: when compiled with dietlibc the user-/group-names must be
## resolvable by files-NSS. LDAP or NIS NSS will not work so
## the numeric ids must be used
user daemon
group daemon
## chroot() path
chroot /var/run/dhcp-fwd
## Logfile and loglevel. The logfile-location is relatively to the
## directory where dhcp-fwd was started and not to the chroot-directory.
##
## The loglevel option is not supported yet.
logfile /var/log/dhcp-fwd.log
loglevel 1
## SysV pidfile; contains the PID of the daemon-process and will be
## written with root-privileges
pidfile /var/run/dhcp-fwd.pid
## Set limit for resources. When using much interfaces or servers
## below you will need to increase some values. Same holds when not
## using dietlibc. Use '-1' as the value to disable the upper limit
## for the given resource.
##
## Look into /proc/<pid>/status to find out the real usage of the
## resources.
ulimit core 0
ulimit stack 64K
ulimit data 32K
ulimit rss 200K
ulimit nproc 0
ulimit nofile 0
ulimit as 0
######### INTERFACE SETTINGS #########
####
###
## The interface where the forwarder listens for messages. There must
## be specified BOTH the server-side and client-side interfaces!
##
## Each interface will be identified by its system-wide name
## (e.g. eth0). After this it must be told whether there are
## clients and servers, and if it is allowed to send broadcast
## messages to clients. The bcast flags will be IGNORED when
## forwarding messages to servers.
# IFNAME clients servers bcast
if eth2 true false true
if eth1 false true true
## Each interface can be given an RFC 3046 agent ID. The 'name' config
## option sets this value; if an interface is not specified here, the
## IFNAME will be assumed.
# IFNAME agent-id
name eth2 ws-c
## Each interface can be given an specific IP to be filled into the
## 'giaddr' field.
##
## BEWARE: because the outgoing DHCP message will contain the "normal" IP
## address of the outgoing-interface in its IP-header, some additional
## work in the system must be done. You can e.g. add an iptables rule to
## the 'nat' table similarly to this:
##
## | Chain POSTROUTING (policy ACCEPT)
## | target prot opt source destination
## | SNAT udp -- 192.168.0.6 192.168.8.66 udp spt:68 dpt:67 to:192.168.2.255
# ip eth0 192.168.2.255
######### SERVER SETTINGS #########
####
###
## Definitions of the servers. There must be told the type ('ip' or
## 'bcast') and the address. When using 'ip', the address is a non-bcast
## IPv4 address (dotted, DNS-names are NOT supported); and when using
## 'bcast' servers, the address is an IFNAME.
# TYPE address
server ip 192.168.8.66
#server bcast eth1

View File

@ -0,0 +1,17 @@
#!/bin/sh
case $1 in
start)
[ -d /var/log ] || mkdir -p /var/log
[ -d /var/run/dhcp-wfd ] || mkdir -p /var/run/dhcp-fwd
dhcp-fwd
;;
stop)
[ -f /var/run/dhcpd-fwd.pid ] && kill $(cat /var/run/dhcpd-fwd.pid) 2>/dev/null
;;
*)
echo "usage: $0 (start|stop)"
exit 1
esac
exit $?

View File

@ -0,0 +1,9 @@
Package: ip6tables
Architecture: mipsel
Version: 1.2.9-1
Section: net
Priority: optional
Maintainer: Sebastien NOEL <me@twolife.org>
Source: Embedded in the main OpenWrt buildroot
Depends: kmod-ipv6, kmod-ipt6
Description: Linux kernel 2.4+ IPv6 packet filter administration tools

View File

@ -0,0 +1,9 @@
Package: kmod-ipt6
Architecture: mipsel
Version: 2.4.20-1
Section: kernel
Priority: optional
Maintainer: Sebastien NOEL <me@twolife.org>
Source: Embedded in the main OpenWrt buildroot
Depends: kmod-ipv6, ip6tables
Description: ip6tables kernel modules

View File

@ -0,0 +1,9 @@
Package: kmod-ipv6
Architecture: mipsel
Version: 2.4.20-1
Section: kernel
Priority: optional
Maintainer: Sebastien NOEL <me@twolife.org>
Source: Embedded in the main OpenWrt buildroot
Depends:
Description: Kernel modules for the IPv6 protocol

View File

@ -0,0 +1,8 @@
Package: nfs-modules
Priority: optional
Section: kernel
Version: TBDL
Architecture: TBDL
Maintainer: Nico <nthill@free.fr>
Source: http://openwrt.org/cgi-bin/viewcvs.cgi/buildroot/
Description: the NFS kernel modules

View File

@ -0,0 +1,8 @@
Package: ppp-async-module
Priority: optional
Section: net
Version: TBDL
Architecture: TBDL
Maintainer: Nico <nthill@free.fr>
Source: http://openwrt.org/cgi-bin/viewcvs.cgi/buildroot/
Description: a PPP async serial channel driver kernel module

View File

@ -0,0 +1,8 @@
Package: ppp-mppe-module
Priority: optional
Section: net
Version: TBDL
Architecture: TBDL
Maintainer: Nico <nthill@free.fr>
Source: http://openwrt.org/cgi-bin/viewcvs.cgi/buildroot/
Description: a Microsoft PPP compression/encryption (MPPC/MPPE) kernel module

View File

@ -0,0 +1,2 @@
/etc/ppp/radius.conf
/etc/ppp/radius/servers

View File

@ -0,0 +1,9 @@
Package: ppp-radius-plugin
Priority: optional
Section: net
Version: TBDL
Architecture: TBDL
Maintainer: Nico
Source: http://openwrt.org/cgi-bin/viewcvs.cgi/buildroot/
Description: a RADIUS plugin for the PPP daemon
Depends: ppp

View File

@ -0,0 +1,2 @@
plugin radius.so
radius-config-file /etc/ppp/radius.conf

View File

@ -0,0 +1,8 @@
authserver localhost:1812
acctserver localhost:1813
dictionary /etc/ppp/radius/dictionary
servers /etc/ppp/radius/servers
seqfile /var/tmp/radius.seq
radius_timeout 10
radius_retries 3
mapfile /dev/null

View File

@ -0,0 +1,253 @@
#
# Updated 97/06/13 to livingston-radius-2.01 miquels@cistron.nl
#
# This file contains dictionary translations for parsing
# requests and generating responses. All transactions are
# composed of Attribute/Value Pairs. The value of each attribute
# is specified as one of 4 data types. Valid data types are:
#
# string - 0-253 octets
# ipaddr - 4 octets in network byte order
# integer - 32 bit value in big endian order (high byte first)
# date - 32 bit value in big endian order - seconds since
# 00:00:00 GMT, Jan. 1, 1970
#
# Enumerated values are stored in the user file with dictionary
# VALUE translations for easy administration.
#
# Example:
#
# ATTRIBUTE VALUE
# --------------- -----
# Framed-Protocol = PPP
# 7 = 1 (integer encoding)
#
# The dictionary format now supports vendor-specific attributes.
# Vendors are introduced like this:
#
# VENDOR vendor_name vendor_number
#
# For example:
#
# VENDOR RoaringPenguin 10055
#
# Vendor-specific attributes have a fifth field with the name of the
# vendor. For example:
#
# ATTRIBUTE RP-Upstream-Speed-Limit 1 integer RoaringPenguin
#
# introduces a Roaring Penguin vendor-specific attribbute with name
# RP-Upstream-Speed-Limit, number 1, type integer and vendor RoaringPenguin.
#
# Following are the proper new names. Use these.
#
ATTRIBUTE User-Name 1 string
ATTRIBUTE Password 2 string
ATTRIBUTE CHAP-Password 3 string
ATTRIBUTE NAS-IP-Address 4 ipaddr
ATTRIBUTE NAS-Port-Id 5 integer
ATTRIBUTE Service-Type 6 integer
ATTRIBUTE Framed-Protocol 7 integer
ATTRIBUTE Framed-IP-Address 8 ipaddr
ATTRIBUTE Framed-IP-Netmask 9 ipaddr
ATTRIBUTE Framed-Routing 10 integer
ATTRIBUTE Filter-Id 11 string
ATTRIBUTE Framed-MTU 12 integer
ATTRIBUTE Framed-Compression 13 integer
ATTRIBUTE Login-IP-Host 14 ipaddr
ATTRIBUTE Login-Service 15 integer
ATTRIBUTE Login-TCP-Port 16 integer
ATTRIBUTE Reply-Message 18 string
ATTRIBUTE Callback-Number 19 string
ATTRIBUTE Callback-Id 20 string
ATTRIBUTE Framed-Route 22 string
ATTRIBUTE Framed-IPX-Network 23 ipaddr
ATTRIBUTE State 24 string
ATTRIBUTE Class 25 string
ATTRIBUTE Session-Timeout 27 integer
ATTRIBUTE Idle-Timeout 28 integer
ATTRIBUTE Termination-Action 29 integer
ATTRIBUTE Called-Station-Id 30 string
ATTRIBUTE Calling-Station-Id 31 string
ATTRIBUTE NAS-Identifier 32 string
ATTRIBUTE Acct-Status-Type 40 integer
ATTRIBUTE Acct-Delay-Time 41 integer
ATTRIBUTE Acct-Input-Octets 42 integer
ATTRIBUTE Acct-Output-Octets 43 integer
ATTRIBUTE Acct-Session-Id 44 string
ATTRIBUTE Acct-Authentic 45 integer
ATTRIBUTE Acct-Session-Time 46 integer
ATTRIBUTE Acct-Input-Packets 47 integer
ATTRIBUTE Acct-Output-Packets 48 integer
ATTRIBUTE Acct-Terminate-Cause 49 integer
ATTRIBUTE Chap-Challenge 60 string
ATTRIBUTE NAS-Port-Type 61 integer
ATTRIBUTE Port-Limit 62 integer
ATTRIBUTE Connect-Info 77 string
# RFC 2869
ATTRIBUTE Acct-Interim-Interval 85 integer
#
# Experimental Non Protocol Attributes used by Cistron-Radiusd
#
ATTRIBUTE Huntgroup-Name 221 string
ATTRIBUTE User-Category 1029 string
ATTRIBUTE Group-Name 1030 string
ATTRIBUTE Simultaneous-Use 1034 integer
ATTRIBUTE Strip-User-Name 1035 integer
ATTRIBUTE Fall-Through 1036 integer
ATTRIBUTE Add-Port-To-IP-Address 1037 integer
ATTRIBUTE Exec-Program 1038 string
ATTRIBUTE Exec-Program-Wait 1039 string
ATTRIBUTE Hint 1040 string
#
# Non-Protocol Attributes
# These attributes are used internally by the server
#
ATTRIBUTE Expiration 21 date
ATTRIBUTE Auth-Type 1000 integer
ATTRIBUTE Menu 1001 string
ATTRIBUTE Termination-Menu 1002 string
ATTRIBUTE Prefix 1003 string
ATTRIBUTE Suffix 1004 string
ATTRIBUTE Group 1005 string
ATTRIBUTE Crypt-Password 1006 string
ATTRIBUTE Connect-Rate 1007 integer
#
# Experimental, implementation specific attributes
#
# Limit session traffic
ATTRIBUTE Session-Octets-Limit 227 integer
# What to assume as limit - 0 in+out, 1 in, 2 out, 3 max(in,out)
ATTRIBUTE Octets-Direction 228 integer
#
# Integer Translations
#
# User Types
VALUE Service-Type Login-User 1
VALUE Service-Type Framed-User 2
VALUE Service-Type Callback-Login-User 3
VALUE Service-Type Callback-Framed-User 4
VALUE Service-Type Outbound-User 5
VALUE Service-Type Administrative-User 6
VALUE Service-Type NAS-Prompt-User 7
# Framed Protocols
VALUE Framed-Protocol PPP 1
VALUE Framed-Protocol SLIP 2
# Framed Routing Values
VALUE Framed-Routing None 0
VALUE Framed-Routing Broadcast 1
VALUE Framed-Routing Listen 2
VALUE Framed-Routing Broadcast-Listen 3
# Framed Compression Types
VALUE Framed-Compression None 0
VALUE Framed-Compression Van-Jacobson-TCP-IP 1
# Login Services
VALUE Login-Service Telnet 0
VALUE Login-Service Rlogin 1
VALUE Login-Service TCP-Clear 2
VALUE Login-Service PortMaster 3
# Status Types
VALUE Acct-Status-Type Start 1
VALUE Acct-Status-Type Stop 2
VALUE Acct-Status-Type Accounting-On 7
VALUE Acct-Status-Type Accounting-Off 8
# Authentication Types
VALUE Acct-Authentic RADIUS 1
VALUE Acct-Authentic Local 2
VALUE Acct-Authentic PowerLink128 100
# Termination Options
VALUE Termination-Action Default 0
VALUE Termination-Action RADIUS-Request 1
# NAS Port Types, available in 3.3.1 and later
VALUE NAS-Port-Type Async 0
VALUE NAS-Port-Type Sync 1
VALUE NAS-Port-Type ISDN 2
VALUE NAS-Port-Type ISDN-V120 3
VALUE NAS-Port-Type ISDN-V110 4
# Acct Terminate Causes, available in 3.3.2 and later
VALUE Acct-Terminate-Cause User-Request 1
VALUE Acct-Terminate-Cause Lost-Carrier 2
VALUE Acct-Terminate-Cause Lost-Service 3
VALUE Acct-Terminate-Cause Idle-Timeout 4
VALUE Acct-Terminate-Cause Session-Timeout 5
VALUE Acct-Terminate-Cause Admin-Reset 6
VALUE Acct-Terminate-Cause Admin-Reboot 7
VALUE Acct-Terminate-Cause Port-Error 8
VALUE Acct-Terminate-Cause NAS-Error 9
VALUE Acct-Terminate-Cause NAS-Request 10
VALUE Acct-Terminate-Cause NAS-Reboot 11
VALUE Acct-Terminate-Cause Port-Unneeded 12
VALUE Acct-Terminate-Cause Port-Preempted 13
VALUE Acct-Terminate-Cause Port-Suspended 14
VALUE Acct-Terminate-Cause Service-Unavailable 15
VALUE Acct-Terminate-Cause Callback 16
VALUE Acct-Terminate-Cause User-Error 17
VALUE Acct-Terminate-Cause Host-Request 18
#
# Non-Protocol Integer Translations
#
VALUE Auth-Type Local 0
VALUE Auth-Type System 1
VALUE Auth-Type SecurID 2
VALUE Auth-Type Crypt-Local 3
VALUE Auth-Type Reject 4
#
# Cistron extensions
#
VALUE Auth-Type Pam 253
VALUE Auth-Type None 254
#
# Experimental Non-Protocol Integer Translations for Cistron-Radiusd
#
VALUE Fall-Through No 0
VALUE Fall-Through Yes 1
VALUE Add-Port-To-IP-Address No 0
VALUE Add-Port-To-IP-Address Yes 1
#
# Configuration Values
# uncomment these two lines to turn account expiration on
#
#VALUE Server-Config Password-Expiration 30
#VALUE Server-Config Password-Warning 5
# Octets-Direction
VALUE Octets-Direction Sum 0
VALUE Octets-Direction Input 1
VALUE Octets-Direction Output 2
VALUE Octets-Direction MaxOveral 3
VALUE Octets-Direction MaxSession 4
INCLUDE /etc/ppp/radius/dictionary.microsoft

View File

@ -0,0 +1,81 @@
#
# Microsoft's VSA's, from RFC 2548
#
# $Id$
#
VENDOR Microsoft 311 Microsoft
ATTRIBUTE MS-CHAP-Response 1 string Microsoft
ATTRIBUTE MS-CHAP-Error 2 string Microsoft
ATTRIBUTE MS-CHAP-CPW-1 3 string Microsoft
ATTRIBUTE MS-CHAP-CPW-2 4 string Microsoft
ATTRIBUTE MS-CHAP-LM-Enc-PW 5 string Microsoft
ATTRIBUTE MS-CHAP-NT-Enc-PW 6 string Microsoft
ATTRIBUTE MS-MPPE-Encryption-Policy 7 string Microsoft
# This is referred to as both singular and plural in the RFC.
# Plural seems to make more sense.
ATTRIBUTE MS-MPPE-Encryption-Type 8 string Microsoft
ATTRIBUTE MS-MPPE-Encryption-Types 8 string Microsoft
ATTRIBUTE MS-RAS-Vendor 9 integer Microsoft
ATTRIBUTE MS-CHAP-Domain 10 string Microsoft
ATTRIBUTE MS-CHAP-Challenge 11 string Microsoft
ATTRIBUTE MS-CHAP-MPPE-Keys 12 string Microsoft
ATTRIBUTE MS-BAP-Usage 13 integer Microsoft
ATTRIBUTE MS-Link-Utilization-Threshold 14 integer Microsoft
ATTRIBUTE MS-Link-Drop-Time-Limit 15 integer Microsoft
ATTRIBUTE MS-MPPE-Send-Key 16 string Microsoft
ATTRIBUTE MS-MPPE-Recv-Key 17 string Microsoft
ATTRIBUTE MS-RAS-Version 18 string Microsoft
ATTRIBUTE MS-Old-ARAP-Password 19 string Microsoft
ATTRIBUTE MS-New-ARAP-Password 20 string Microsoft
ATTRIBUTE MS-ARAP-PW-Change-Reason 21 integer Microsoft
ATTRIBUTE MS-Filter 22 string Microsoft
ATTRIBUTE MS-Acct-Auth-Type 23 integer Microsoft
ATTRIBUTE MS-Acct-EAP-Type 24 integer Microsoft
ATTRIBUTE MS-CHAP2-Response 25 string Microsoft
ATTRIBUTE MS-CHAP2-Success 26 string Microsoft
ATTRIBUTE MS-CHAP2-CPW 27 string Microsoft
ATTRIBUTE MS-Primary-DNS-Server 28 ipaddr Microsoft
ATTRIBUTE MS-Secondary-DNS-Server 29 ipaddr Microsoft
ATTRIBUTE MS-Primary-NBNS-Server 30 ipaddr Microsoft
ATTRIBUTE MS-Secondary-NBNS-Server 31 ipaddr Microsoft
#ATTRIBUTE MS-ARAP-Challenge 33 string Microsoft
#
# Integer Translations
#
# MS-BAP-Usage Values
VALUE MS-BAP-Usage Not-Allowed 0
VALUE MS-BAP-Usage Allowed 1
VALUE MS-BAP-Usage Required 2
# MS-ARAP-Password-Change-Reason Values
VALUE MS-ARAP-PW-Change-Reason Just-Change-Password 1
VALUE MS-ARAP-PW-Change-Reason Expired-Password 2
VALUE MS-ARAP-PW-Change-Reason Admin-Requires-Password-Change 3
VALUE MS-ARAP-PW-Change-Reason Password-Too-Short 4
# MS-Acct-Auth-Type Values
VALUE MS-Acct-Auth-Type PAP 1
VALUE MS-Acct-Auth-Type CHAP 2
VALUE MS-Acct-Auth-Type MS-CHAP-1 3
VALUE MS-Acct-Auth-Type MS-CHAP-2 4
VALUE MS-Acct-Auth-Type EAP 5
# MS-Acct-EAP-Type Values
VALUE MS-Acct-EAP-Type MD5 4
VALUE MS-Acct-EAP-Type OTP 5
VALUE MS-Acct-EAP-Type Generic-Token-Card 6
VALUE MS-Acct-EAP-Type TLS 13

View File

@ -0,0 +1 @@
localhost secret

View File

@ -0,0 +1,2 @@
/etc/ppp/chap-secrets
/etc/ppp/options

View File

@ -0,0 +1,8 @@
Package: ppp
Priority: optional
Section: net
Version: TBDL
Architecture: TBDL
Maintainer: Nico <nthill@free.fr>
Source: http://openwrt.org/cgi-bin/viewcvs.cgi/buildroot/
Description: a Point-to-Point Protocol (PPP) daemon

View File

@ -0,0 +1 @@
nico pptp-server secret 172.16.1.101

View File

@ -0,0 +1 @@
#debug

View File

@ -0,0 +1,2 @@
/etc/ppp/pptp-server-options
/etc/pptpd.conf

View File

@ -0,0 +1,9 @@
Package: pptp-server
Priority: optional
Section: net
Version: TBDL
Architecture: TBDL
Maintainer: Nico <nthill@free.fr>
Source: http://openwrt.org/cgi-bin/viewcvs.cgi/buildroot/
Description: a Point-to-Point Tunneling Protocol (PPTP) server
Depends: ppp

View File

@ -0,0 +1,18 @@
#!/bin/sh
case $1 in
start)
insmod ppp_async >/dev/null 2>&1
insmod ppp_mppe_mppc >/dev/null 2>&1
[ -d /var/run ] || mkdir -p /var/run
/usr/sbin/pptpd
;;
stop)
[ -f /var/run/pptpd.pid ] && kill $(cat /var/run/pptpd.pid) >/dev/null 2>&1
;;
*)
echo "usage: $0 (start|stop)"
exit 1
esac
exit $?

View File

@ -0,0 +1,27 @@
#debug
#logfile /tmp/pptp-server.log
172.16.1.1:
auth
name "pptp-server"
lcp-echo-failure 3
lcp-echo-interval 60
default-asyncmap
mtu 1482
mru 1482
nobsdcomp
nodeflate
#noproxyarp
#nomppc
nomppe-40
nomppe-56
nomppe-stateful
require-mppe
require-mppe-128
require-mschap-v2
refuse-chap
refuse-mschap
refuse-eap
refuse-pap
#ms-dns 172.16.1.1
#plugin radius.so
#radius-config-file /etc/radius.conf

View File

@ -0,0 +1,5 @@
#debug
option /etc/ppp/pptp-server-options
speed 115200
stimeout 10
#localip & remoteip are not needed, ip management is done by pppd

View File

@ -0,0 +1,8 @@
Package: tun-module
Priority: optional
Section: kernel
Version: TBDL
Architecture: TBDL
Maintainer: Nico <nthill@free.fr>
Source: http://openwrt.org/cgi-bin/viewcvs.cgi/buildroot/
Description: the Universal TUN/TAP device driver

View File

@ -0,0 +1,24 @@
diff -Nur linux/net/ipv6/netfilter/ip6_tables.c linux.fixed/net/ipv6/netfilter/ip6_tables.c
--- linux/net/ipv6/netfilter/ip6_tables.c Sat Aug 3 02:39:46 2002
+++ linux.fixed/net/ipv6/netfilter/ip6_tables.c Thu Sep 26 17:12:07 2002
@@ -98,10 +98,8 @@
unsigned int hook_entry[NF_IP6_NUMHOOKS];
unsigned int underflow[NF_IP6_NUMHOOKS];
- char padding[SMP_ALIGN((NF_IP6_NUMHOOKS*2+2)*sizeof(unsigned int))];
-
/* ip6t_entry tables: one per CPU */
- char entries[0];
+ char entries[0] ____cacheline_aligned;
};
static LIST_HEAD(ip6t_target);
@@ -1425,7 +1423,7 @@
int ret;
struct ip6t_table_info *newinfo;
static struct ip6t_table_info bootstrap
- = { 0, 0, 0, { 0 }, { 0 }, { }, { } };
+ = { 0, 0, 0, { 0 }, { 0 }, { } };
MOD_INC_USE_COUNT;
newinfo = vmalloc(sizeof(struct ip6t_table_info)

File diff suppressed because it is too large Load Diff

View File

@ -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"

View File

@ -0,0 +1,20 @@
--- ppp-2.4.0b4.orig/scripts/README
+++ ppp-2.4.0b4/scripts/README
@@ -141,3 +141,17 @@
are escaped. This may need to be modified depending on the ssh (or
pseudo-tty) implementation which may differ across platforms, for further
optimizations.
+
+------------------------------------------------------------------------
+
+12. pon, poff and ip-up
+
+These are modified version of the pon/poff/ip-up scripts contributed by Yann
+Dirson <dirson@debian.org>. They allow you to call "pon quick" respectively
+"pon quick my-isp" to just call the provider for running you ip-up scripts in
+/etc/ppp/ip-up.d. This can be useful to check for incoming/flush outgoing
+mail, without the necessary delay before hangup introduced by diald or such.
+
+These scripts break the possibility to connect to multiple ISPs at once, so
+they are included only here.
+

View File

@ -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

View File

@ -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 */

View File

@ -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

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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);

View File

@ -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) {

View File

@ -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

View File

@ -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? */

View File

@ -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)

View File

@ -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

View 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.

View File

@ -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 */

View File

@ -0,0 +1,225 @@
diff -ruN ppp-2.4.2-old/chat/Makefile.linux ppp-2.4.2-new/chat/Makefile.linux
--- ppp-2.4.2-old/chat/Makefile.linux 2004-01-13 04:57:55.000000000 +0100
+++ ppp-2.4.2-new/chat/Makefile.linux 2004-08-23 12:48:50.000000000 +0200
@@ -6,8 +6,9 @@
CDEF4= -DFNDELAY=O_NDELAY # Old name value
CDEFS= $(CDEF1) $(CDEF2) $(CDEF3) $(CDEF4)
-COPTS= -O2 -g -pipe $(CDEFS)
-CFLAGS= $(COPTS) $(CDEFS)
+COPTS = -O2
+COMPILE_FLAGS = $(CDEFS)
+CFLAGS = $(COPTS) $(COMPILE_FLAGS)
INSTALL= install
diff -ruN ppp-2.4.2-old/pppd/Makefile.linux ppp-2.4.2-new/pppd/Makefile.linux
--- ppp-2.4.2-old/pppd/Makefile.linux 2003-11-27 22:55:19.000000000 +0100
+++ ppp-2.4.2-new/pppd/Makefile.linux 2004-08-23 12:48:50.000000000 +0200
@@ -47,19 +47,19 @@
# Uncomment the next line to include support for PPP packet filtering.
# This requires that the libpcap library and headers be installed
# and that the kernel driver support PPP packet filtering.
-FILTER=y
+#FILTER=y
# Uncomment the next line to enable multilink PPP (enabled by default)
# Linux distributions: Please leave multilink ENABLED in your builds
# of pppd!
-HAVE_MULTILINK=y
+#HAVE_MULTILINK=y
# Uncomment the next line to enable the TDB database (enabled by default.)
# If you enable multilink, then TDB is automatically enabled also.
# Linux distributions: Please leave TDB ENABLED in your builds.
-USE_TDB=y
+#USE_TDB=y
-HAS_SHADOW=y
+#HAS_SHADOW=y
#USE_PAM=y
#HAVE_INET6=y
@@ -76,7 +76,7 @@
INCLUDE_DIRS= -I../include
-COMPILE_FLAGS= -DHAVE_PATHS_H -DIPX_CHANGE -DHAVE_MMAP
+COMPILE_FLAGS= -DHAVE_PATHS_H
CFLAGS= $(COPTS) $(COMPILE_FLAGS) $(INCLUDE_DIRS)
@@ -192,7 +192,7 @@
CFLAGS += -DMAXOCTETS
endif
-INSTALL= install -o root
+INSTALL= install
all: $(TARGETS)
diff -ruN ppp-2.4.2-old/pppd/plugins/Makefile.linux ppp-2.4.2-new/pppd/plugins/Makefile.linux
--- ppp-2.4.2-old/pppd/plugins/Makefile.linux 2004-01-13 04:56:24.000000000 +0100
+++ ppp-2.4.2-new/pppd/plugins/Makefile.linux 2004-08-23 12:48:50.000000000 +0200
@@ -1,12 +1,16 @@
-CC = gcc
-COPTS = -O2 -g
-CFLAGS = $(COPTS) -I.. -I../../include -fPIC
-LDFLAGS = -shared
-INSTALL = install -o root
+#CC = gcc
+COPTS = -O2
+COMPILE_FLAGS = -I.. -I../../include -fPIC
+LIBS =
+
+INSTALL = install
+
+CFLAGS = $(COPTS) $(COMPILE_FLAGS)
+LDFLAGS = -shared
SUBDIRS := rp-pppoe
# Uncomment the next line to include the radius authentication plugin
-# SUBDIRS += radius
+SUBDIRS += radius
PLUGINS := minconn.so passprompt.so passwordfd.so
# include dependencies if present
diff -ruN ppp-2.4.2-old/pppd/plugins/radius/Makefile.linux ppp-2.4.2-new/pppd/plugins/radius/Makefile.linux
--- ppp-2.4.2-old/pppd/plugins/radius/Makefile.linux 2002-11-09 12:24:42.000000000 +0100
+++ ppp-2.4.2-new/pppd/plugins/radius/Makefile.linux 2004-08-23 12:57:38.000000000 +0200
@@ -5,7 +5,12 @@
MANDIR=/usr/man
PLUGIN=radius.so radattr.so radrealms.so
-CFLAGS=-I../.. -I../../../include -Iradiusclient/include -O2
+COPTS = -O2
+COMPILE_FLAGS = -I../.. -I../../../include -Iradiusclient/include -fPIC
+LIBS=
+
+CFLAGS=$(COPTS) $(COMPILE_FLAGS)
+LDFLAGS=-lradiusclient
# Uncomment the next line to include support for Microsoft's
# MS-CHAP authentication protocol.
@@ -37,29 +42,34 @@
$(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) -c $(CFLAGS) radius.c -o radius.o
radattr.o: radattr.c
- gcc $(CFLAGS) -c -o radattr.o -fPIC radattr.c
+ $(CC) -c $(CFLAGS) radattr.c -o radattr.o
radrealms.o: radrealms.c
- gcc $(CFLAGS) -c -o radrealms.o -fPIC radrealms.c
+ $(CC) -c $(CFLAGS) radrealms.c -o radrealms.o
radiusclient/lib/.libs/libradiusclient.a:
test -r radiusclient/Makefile || \
(cd radiusclient; \
+ rm -f config.cache ; \
+ aclocal ; \
+ autoconf ; \
+ ac_cv_func_setvbuf_reversed=no \
+ ac_cv_func_uname=no \
./configure --prefix=/usr \
--sysconfdir=/etc \
- --enable-shared \
+ --disable-shared \
--enable-static)
$(MAKE) -C radiusclient
diff -ruN ppp-2.4.2-old/pppd/plugins/rp-pppoe/Makefile.linux ppp-2.4.2-new/pppd/plugins/rp-pppoe/Makefile.linux
--- ppp-2.4.2-old/pppd/plugins/rp-pppoe/Makefile.linux 2004-01-13 04:57:55.000000000 +0100
+++ ppp-2.4.2-new/pppd/plugins/rp-pppoe/Makefile.linux 2004-08-23 12:48:50.000000000 +0200
@@ -16,12 +16,16 @@
# Version is set ONLY IN THE MAKEFILE! Don't delete this!
VERSION=3.3
-COPTS=-O2 -g
-CFLAGS=$(COPTS) -I../../../include/linux
+#CC = gcc
+COPTS = -O2
+COMPILE_FLAGS = -I../../../include/linux -fPIC
+
+CFLAGS = $(COPTS) $(COMPILE_FLAGS)
+
all: rp-pppoe.so
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)
@@ -31,20 +35,20 @@
rm -f *.o *.so
plugin.o: plugin.c
- gcc '-DRP_VERSION="$(VERSION)"' $(CFLAGS) -I../../.. -c -o plugin.o -fPIC plugin.c
+ $(CC) -c $(CFLAGS) plugin.c '-DRP_VERSION="$(VERSION)"' -I../../.. -o plugin.o
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) -c $(CFLAGS) discovery.c '-DVERSION="$(VERSION)"' -o discovery.o
if.o: if.c
- gcc $(CFLAGS) '-DVERSION="$(VERSION)"' -c -o if.o -fPIC if.c
+ $(CC) -c $(CFLAGS) if.c '-DVERSION="$(VERSION)"' -o if.o
debug.o: debug.c
- gcc $(CFLAGS) '-DVERSION="$(VERSION)"' -c -o debug.o -fPIC debug.c
+ $(CC) -c $(CFLAGS) debug.c '-DVERSION="$(VERSION)"' -o debug.o
common.o: common.c
- gcc $(CFLAGS) '-DVERSION="$(VERSION)"' -c -o common.o -fPIC common.c
+ $(CC) -c $(CFLAGS) common.c '-DVERSION="$(VERSION)"' -o common.o
diff -ruN ppp-2.4.2-old/pppdump/Makefile.linux ppp-2.4.2-new/pppdump/Makefile.linux
--- ppp-2.4.2-old/pppdump/Makefile.linux 1999-07-26 13:09:29.000000000 +0200
+++ ppp-2.4.2-new/pppdump/Makefile.linux 2004-08-23 12:48:50.000000000 +0200
@@ -1,4 +1,8 @@
-CFLAGS= -O -I../include/net
+#CC = gcc
+COPTS = -O
+COMPILE_FLAGS = -I../include/net
+CFLAGS= $(COPTS) $(COMPILE_FLAGS)
+
OBJS = pppdump.o bsd-comp.o deflate.o zlib.o
INSTALL= install
diff -ruN ppp-2.4.2-old/pppstats/Makefile.linux ppp-2.4.2-new/pppstats/Makefile.linux
--- ppp-2.4.2-old/pppstats/Makefile.linux 2002-11-09 12:24:43.000000000 +0100
+++ ppp-2.4.2-new/pppstats/Makefile.linux 2004-08-23 12:48:50.000000000 +0200
@@ -7,11 +7,11 @@
PPPSTATOBJS = pppstats.o
#CC = gcc
-COPTS = -O
+COPTS = -O2
COMPILE_FLAGS = -I../include
LIBS =
-INSTALL= install -o root -g daemon
+INSTALL= install
CFLAGS = $(COPTS) $(COMPILE_FLAGS)

View File

@ -0,0 +1,15 @@
diff -ruN poptop-old/Makefile.in poptop-new/Makefile.in
--- poptop-old/Makefile.in 2003-02-06 17:39:45.000000000 +0100
+++ poptop-new/Makefile.in 2004-04-04 15:50:17.000000000 +0200
@@ -74,8 +74,9 @@
AUTOMAKE_OPTIONS = no-dependencies foreign
INCLUDES = -I.
-CFLAGS = -O2 -fno-builtin -Wall -ansi -DSBINDIR='"$(sbindir)"'
-#CFLAGS = -O2 -fno-builtin -Wall -ansi -pedantic -Wmissing-prototypes -Werror -DSBINDIR='"$(sbindir)"'
+CCOPTS = -O2 -fno-builtin
+CFLAGS = $(CCOPTS) -Wall -ansi -DSBINDIR='"$(sbindir)"'
+#CFLAGS = $(CCOPTS) -Wall -ansi -pedantic -Wmissing-prototypes -Werror -DSBINDIR='"$(sbindir)"'
man_MANS = pptpctrl.8 pptpd.8 pptpd.conf.5

View File

@ -2,10 +2,55 @@
/* sstrip: Copyright (C) 1999-2001 by Brian Raiter, under the GNU
* General Public License. No warranty. See COPYING for details.
*
* Aug 23, 2004 Hacked by Manuel Novoa III <mjn3@codepoet.org> to
* handle targets of different endianness and/or elf class, making
* it more useful in a cross-devel environment.
*/
#define __MIPSEL__ 1
#define _MIPS_SZLONG 32
/* ============== original README ===================
*
* sstrip is a small utility that removes the contents at the end of an
* ELF file that are not part of the program's memory image.
*
* Most ELF executables are built with both a program header table and a
* section header table. However, only the former is required in order
* for the OS to load, link and execute a program. sstrip attempts to
* extract the ELF header, the program header table, and its contents,
* leaving everything else in the bit bucket. It can only remove parts of
* the file that occur at the end, after the parts to be saved. However,
* this almost always includes the section header table, and occasionally
* a few random sections that are not used when running a program.
*
* It should be noted that the GNU bfd library is (understandably)
* dependent on the section header table as an index to the file's
* contents. Thus, an executable file that has no section header table
* cannot be used with gdb, objdump, or any other program based upon the
* bfd library, at all. In fact, the program will not even recognize the
* file as a valid executable. (This limitation is noted in the source
* code comments for bfd, and is marked "FIXME", so this may change at
* some future date. However, I would imagine that it is a pretty
* low-priority item, as executables without a section header table are
* rare in the extreme.) This probably also explains why strip doesn't
* offer the option to do this.
*
* Shared library files may also have their section header table removed.
* Such a library will still function; however, it will no longer be
* possible for a compiler to link a new program against it.
*
* As an added bonus, sstrip also tries to removes trailing zero bytes
* from the end of the file. (This normally cannot be done with an
* executable that has a section header table.)
*
* sstrip is a very simplistic program. It depends upon the common
* practice of putting the parts of the file that contribute to the
* memory image at the front, and the remaining material at the end. This
* permits it to discard the latter material without affecting file
* offsets and memory addresses in what remains. Of course, the ELF
* standard permits files to be organized in almost any order, so if a
* pathological linker decided to put its section headers at the top,
* sstrip would be useless on such executables.
*/
#include <stdio.h>
#include <stdlib.h>
@ -14,35 +59,14 @@
#include <unistd.h>
#include <fcntl.h>
#include <elf.h>
#include <linux/bitops.h>
typedef signed char s8;
typedef unsigned char u8;
typedef signed short s16;
typedef unsigned short u16;
typedef signed int s32;
typedef unsigned int u32;
typedef signed long long s64;
typedef unsigned long long u64;
#include <asm/elf.h>
#include <endian.h>
#include <byteswap.h>
#ifndef TRUE
#define TRUE 1
#define FALSE 0
#endif
#if ELF_CLASS == ELFCLASS32
#define Elf_Ehdr Elf32_Ehdr
#define Elf_Phdr Elf32_Phdr
#else
#define Elf_Ehdr Elf64_Ehdr
#define Elf_Phdr Elf64_Phdr
#endif
/* The name of the program.
*/
static char const *progname;
@ -61,19 +85,237 @@ static int err(char const *errmsg)
return FALSE;
}
/* A flag to signal the need for endian reversal.
*/
static int do_reverse_endian;
/* Get a value from the elf header, compensating for endianness.
*/
#define EGET(X) \
(__extension__ ({ \
uint64_t __res; \
if (!do_reverse_endian) { \
__res = (X); \
} else if (sizeof(X) == 1) { \
__res = (X); \
} else if (sizeof(X) == 2) { \
__res = bswap_16((X)); \
} else if (sizeof(X) == 4) { \
__res = bswap_32((X)); \
} else if (sizeof(X) == 8) { \
__res = bswap_64((X)); \
} else { \
fprintf(stderr, "%s: %s: EGET failed for size %d\n", \
progname, filename, sizeof(X)); \
exit(EXIT_FAILURE); \
} \
__res; \
}))
/* Set a value 'Y' in the elf header to 'X', compensating for endianness.
*/
#define ESET(Y,X) \
do if (!do_reverse_endian) { \
Y = (X); \
} else if (sizeof(Y) == 1) { \
Y = (X); \
} else if (sizeof(Y) == 2) { \
Y = bswap_16((uint16_t)(X)); \
} else if (sizeof(Y) == 4) { \
Y = bswap_32((uint32_t)(X)); \
} else if (sizeof(Y) == 8) { \
Y = bswap_64((uint64_t)(X)); \
} else { \
fprintf(stderr, "%s: %s: ESET failed for size %d\n", \
progname, filename, sizeof(Y)); \
exit(EXIT_FAILURE); \
} while (0)
/* A macro for I/O errors: The given error message is used only when
* errno is not set.
*/
#define ferr(msg) (err(errno ? strerror(errno) : (msg)))
/* readelfheader() reads the ELF header into our global variable, and
* checks to make sure that this is in fact a file that we should be
* munging.
#define HEADER_FUNCTIONS(CLASS) \
\
/* readelfheader() reads the ELF header into our global variable, and \
* checks to make sure that this is in fact a file that we should be \
* munging. \
*/ \
static int readelfheader ## CLASS (int fd, Elf ## CLASS ## _Ehdr *ehdr) \
{ \
if (read(fd, ((char *)ehdr)+EI_NIDENT, sizeof(*ehdr) - EI_NIDENT) \
!= sizeof(*ehdr) - EI_NIDENT) \
return ferr("missing or incomplete ELF header."); \
\
/* Verify the sizes of the ELF header and the program segment \
* header table entries. \
*/ \
if (EGET(ehdr->e_ehsize) != sizeof(Elf ## CLASS ## _Ehdr)) \
return err("unrecognized ELF header size."); \
if (EGET(ehdr->e_phentsize) != sizeof(Elf ## CLASS ## _Phdr)) \
return err("unrecognized program segment header size."); \
\
/* Finally, check the file type. \
*/ \
if (EGET(ehdr->e_type) != ET_EXEC && EGET(ehdr->e_type) != ET_DYN) \
return err("not an executable or shared-object library."); \
\
return TRUE; \
} \
\
/* readphdrtable() loads the program segment header table into memory. \
*/ \
static int readphdrtable ## CLASS (int fd, Elf ## CLASS ## _Ehdr const *ehdr, \
Elf ## CLASS ## _Phdr **phdrs) \
{ \
size_t size; \
\
if (!EGET(ehdr->e_phoff) || !EGET(ehdr->e_phnum) \
) return err("ELF file has no program header table."); \
\
size = EGET(ehdr->e_phnum) * sizeof **phdrs; \
if (!(*phdrs = malloc(size))) \
return err("Out of memory!"); \
\
errno = 0; \
if (read(fd, *phdrs, size) != (ssize_t)size) \
return ferr("missing or incomplete program segment header table."); \
\
return TRUE; \
} \
\
/* getmemorysize() determines the offset of the last byte of the file \
* that is referenced by an entry in the program segment header table. \
* (Anything in the file after that point is not used when the program \
* is executing, and thus can be safely discarded.) \
*/ \
static int getmemorysize ## CLASS (Elf ## CLASS ## _Ehdr const *ehdr, \
Elf ## CLASS ## _Phdr const *phdrs, \
unsigned long *newsize) \
{ \
Elf ## CLASS ## _Phdr const *phdr; \
unsigned long size, n; \
int i; \
\
/* Start by setting the size to include the ELF header and the \
* complete program segment header table. \
*/ \
size = EGET(ehdr->e_phoff) + EGET(ehdr->e_phnum) * sizeof *phdrs; \
if (size < sizeof *ehdr) \
size = sizeof *ehdr; \
\
/* Then keep extending the size to include whatever data the \
* program segment header table references. \
*/ \
for (i = 0, phdr = phdrs ; i < EGET(ehdr->e_phnum) ; ++i, ++phdr) { \
if (EGET(phdr->p_type) != PT_NULL) { \
n = EGET(phdr->p_offset) + EGET(phdr->p_filesz); \
if (n > size) \
size = n; \
} \
} \
\
*newsize = size; \
return TRUE; \
} \
\
/* modifyheaders() removes references to the section header table if \
* it was stripped, and reduces program header table entries that \
* included truncated bytes at the end of the file. \
*/ \
static int modifyheaders ## CLASS (Elf ## CLASS ## _Ehdr *ehdr, \
Elf ## CLASS ## _Phdr *phdrs, \
unsigned long newsize) \
{ \
Elf ## CLASS ## _Phdr *phdr; \
int i; \
\
/* If the section header table is gone, then remove all references \
* to it in the ELF header. \
*/ \
if (EGET(ehdr->e_shoff) >= newsize) { \
ESET(ehdr->e_shoff,0); \
ESET(ehdr->e_shnum,0); \
ESET(ehdr->e_shentsize,0); \
ESET(ehdr->e_shstrndx,0); \
} \
\
/* The program adjusts the file size of any segment that was \
* truncated. The case of a segment being completely stripped out \
* is handled separately. \
*/ \
for (i = 0, phdr = phdrs ; i < EGET(ehdr->e_phnum) ; ++i, ++phdr) { \
if (EGET(phdr->p_offset) >= newsize) { \
ESET(phdr->p_offset,newsize); \
ESET(phdr->p_filesz,0); \
} else if (EGET(phdr->p_offset) + EGET(phdr->p_filesz) > newsize) { \
newsize -= EGET(phdr->p_offset); \
ESET(phdr->p_filesz, newsize); \
} \
} \
\
return TRUE; \
} \
\
/* commitchanges() writes the new headers back to the original file \
* and sets the file to its new size. \
*/ \
static int commitchanges ## CLASS (int fd, Elf ## CLASS ## _Ehdr const *ehdr, \
Elf ## CLASS ## _Phdr *phdrs, \
unsigned long newsize) \
{ \
size_t n; \
\
/* Save the changes to the ELF header, if any. \
*/ \
if (lseek(fd, 0, SEEK_SET)) \
return ferr("could not rewind file"); \
errno = 0; \
if (write(fd, ehdr, sizeof *ehdr) != sizeof *ehdr) \
return err("could not modify file"); \
\
/* Save the changes to the program segment header table, if any. \
*/ \
if (lseek(fd, EGET(ehdr->e_phoff), SEEK_SET) == (off_t)-1) { \
err("could not seek in file."); \
goto warning; \
} \
n = EGET(ehdr->e_phnum) * sizeof *phdrs; \
if (write(fd, phdrs, n) != (ssize_t)n) { \
err("could not write to file"); \
goto warning; \
} \
\
/* Eleventh-hour sanity check: don't truncate before the end of \
* the program segment header table. \
*/ \
if (newsize < EGET(ehdr->e_phoff) + n) \
newsize = EGET(ehdr->e_phoff) + n; \
\
/* Chop off the end of the file. \
*/ \
if (ftruncate(fd, newsize)) { \
err("could not resize file"); \
goto warning; \
} \
\
return TRUE; \
\
warning: \
return err("ELF file may have been corrupted!"); \
}
/* First elements of Elf32_Ehdr and Elf64_Ehdr are common.
*/
static int readelfheader(int fd, Elf_Ehdr *ehdr)
static int readelfheaderident(int fd, Elf32_Ehdr *ehdr)
{
errno = 0;
if (read(fd, ehdr, sizeof *ehdr) != sizeof *ehdr)
if (read(fd, ehdr, EI_NIDENT) != EI_NIDENT)
return ferr("missing or incomplete ELF header.");
/* Check the ELF signature.
@ -82,88 +324,48 @@ static int readelfheader(int fd, Elf_Ehdr *ehdr)
ehdr->e_ident[EI_MAG1] == ELFMAG1 &&
ehdr->e_ident[EI_MAG2] == ELFMAG2 &&
ehdr->e_ident[EI_MAG3] == ELFMAG3))
return err("missing ELF signature.");
{
err("missing ELF signature.");
return -1;
}
/* Compare the file's class and endianness with the program's.
*/
if (ehdr->e_ident[EI_DATA] != ELF_DATA)
return err("ELF file has different endianness.");
if (ehdr->e_ident[EI_CLASS] != ELF_CLASS)
return err("ELF file has different word size.");
#if __BYTE_ORDER == __LITTLE_ENDIAN
if (ehdr->e_ident[EI_DATA] == ELFDATA2LSB) {
do_reverse_endian = 0;
} else if (ehdr->e_ident[EI_DATA] == ELFDATA2MSB) {
/* fprintf(stderr, "ELF file has different endianness.\n"); */
do_reverse_endian = 1;
}
#elif __BYTE_ORDER == __BIG_ENDIAN
if (ehdr->e_ident[EI_DATA] == ELFDATA2LSB) {
/* fprintf(stderr, "ELF file has different endianness.\n"); */
do_reverse_endian = 1;
} else if (ehdr->e_ident[EI_DATA] == ELFDATA2MSB) {
do_reverse_endian = 0;
}
#else
#error unkown endianness
#endif
else {
err("Unsupported endianness");
return -1;
}
/* Check the target architecture.
*/
if (ehdr->e_machine != ELF_ARCH)
return err("ELF file created for different architecture.");
/* Verify the sizes of the ELF header and the program segment
* header table entries.
*/
if (ehdr->e_ehsize != sizeof(Elf_Ehdr))
return err("unrecognized ELF header size.");
if (ehdr->e_phentsize != sizeof(Elf_Phdr))
return err("unrecognized program segment header size.");
/* Finally, check the file type.
*/
if (ehdr->e_type != ET_EXEC && ehdr->e_type != ET_DYN)
return err("not an executable or shared-object library.");
return TRUE;
/* if (EGET(ehdr->e_machine) != ELF_ARCH) { */
/* /\* return err("ELF file created for different architecture."); *\/ */
/* fprintf(stderr, "ELF file created for different architecture.\n"); */
/* } */
return ehdr->e_ident[EI_CLASS];
}
/* readphdrtable() loads the program segment header table into memory.
*/
static int readphdrtable(int fd, Elf_Ehdr const *ehdr, Elf_Phdr **phdrs)
{
size_t size;
if (!ehdr->e_phoff || !ehdr->e_phnum)
return err("ELF file has no program header table.");
HEADER_FUNCTIONS(32)
size = ehdr->e_phnum * sizeof **phdrs;
if (!(*phdrs = malloc(size)))
return err("Out of memory!");
errno = 0;
if (read(fd, *phdrs, size) != (ssize_t)size)
return ferr("missing or incomplete program segment header table.");
return TRUE;
}
/* getmemorysize() determines the offset of the last byte of the file
* that is referenced by an entry in the program segment header table.
* (Anything in the file after that point is not used when the program
* is executing, and thus can be safely discarded.)
*/
static int getmemorysize(Elf_Ehdr const *ehdr, Elf_Phdr const *phdrs,
unsigned long *newsize)
{
Elf32_Phdr const *phdr;
unsigned long size, n;
int i;
/* Start by setting the size to include the ELF header and the
* complete program segment header table.
*/
size = ehdr->e_phoff + ehdr->e_phnum * sizeof *phdrs;
if (size < sizeof *ehdr)
size = sizeof *ehdr;
/* Then keep extending the size to include whatever data the
* program segment header table references.
*/
for (i = 0, phdr = phdrs ; i < ehdr->e_phnum ; ++i, ++phdr) {
if (phdr->p_type != PT_NULL) {
n = phdr->p_offset + phdr->p_filesz;
if (n > size)
size = n;
}
}
*newsize = size;
return TRUE;
}
HEADER_FUNCTIONS(64)
/* truncatezeros() examines the bytes at the end of the file's
* size-to-be, and reduces the size to exclude any trailing zero
@ -196,97 +398,20 @@ static int truncatezeros(int fd, unsigned long *newsize)
return TRUE;
}
/* modifyheaders() removes references to the section header table if
* it was stripped, and reduces program header table entries that
* included truncated bytes at the end of the file.
*/
static int modifyheaders(Elf_Ehdr *ehdr, Elf_Phdr *phdrs,
unsigned long newsize)
{
Elf32_Phdr *phdr;
int i;
/* If the section header table is gone, then remove all references
* to it in the ELF header.
*/
if (ehdr->e_shoff >= newsize) {
ehdr->e_shoff = 0;
ehdr->e_shnum = 0;
ehdr->e_shentsize = 0;
ehdr->e_shstrndx = 0;
}
/* The program adjusts the file size of any segment that was
* truncated. The case of a segment being completely stripped out
* is handled separately.
*/
for (i = 0, phdr = phdrs ; i < ehdr->e_phnum ; ++i, ++phdr) {
if (phdr->p_offset >= newsize) {
phdr->p_offset = newsize;
phdr->p_filesz = 0;
} else if (phdr->p_offset + phdr->p_filesz > newsize) {
phdr->p_filesz = newsize - phdr->p_offset;
}
}
return TRUE;
}
/* commitchanges() writes the new headers back to the original file
* and sets the file to its new size.
*/
static int commitchanges(int fd, Elf_Ehdr const *ehdr, Elf_Phdr *phdrs,
unsigned long newsize)
{
size_t n;
/* Save the changes to the ELF header, if any.
*/
if (lseek(fd, 0, SEEK_SET))
return ferr("could not rewind file");
errno = 0;
if (write(fd, ehdr, sizeof *ehdr) != sizeof *ehdr)
return err("could not modify file");
/* Save the changes to the program segment header table, if any.
*/
if (lseek(fd, ehdr->e_phoff, SEEK_SET) == (off_t)-1) {
err("could not seek in file.");
goto warning;
}
n = ehdr->e_phnum * sizeof *phdrs;
if (write(fd, phdrs, n) != (ssize_t)n) {
err("could not write to file");
goto warning;
}
/* Eleventh-hour sanity check: don't truncate before the end of
* the program segment header table.
*/
if (newsize < ehdr->e_phoff + n)
newsize = ehdr->e_phoff + n;
/* Chop off the end of the file.
*/
if (ftruncate(fd, newsize)) {
err("could not resize file");
goto warning;
}
return TRUE;
warning:
return err("ELF file may have been corrupted!");
}
/* main() loops over the cmdline arguments, leaving all the real work
* to the other functions.
*/
int main(int argc, char *argv[])
{
int fd;
Elf_Ehdr ehdr;
Elf_Phdr *phdrs;
union {
Elf32_Ehdr ehdr32;
Elf64_Ehdr ehdr64;
} e;
union {
Elf32_Phdr *phdrs32;
Elf64_Phdr *phdrs64;
} p;
unsigned long newsize;
char **arg;
int failures = 0;
@ -294,7 +419,8 @@ int main(int argc, char *argv[])
if (argc < 2 || argv[1][0] == '-') {
printf("Usage: sstrip FILE...\n"
"sstrip discards all nonessential bytes from an executable.\n\n"
"Version 2.0 Copyright (C) 2000,2001 Brian Raiter.\n"
"Version 2.0-X Copyright (C) 2000,2001 Brian Raiter.\n"
"Cross-devel hacks Copyright (C) 2004 Manuel Novoa III.\n"
"This program is free software, licensed under the GNU\n"
"General Public License. There is absolutely no warranty.\n");
return EXIT_SUCCESS;
@ -312,14 +438,29 @@ int main(int argc, char *argv[])
continue;
}
if (!(readelfheader(fd, &ehdr) &&
readphdrtable(fd, &ehdr, &phdrs) &&
getmemorysize(&ehdr, phdrs, &newsize) &&
switch (readelfheaderident(fd, &e.ehdr32)) {
case ELFCLASS32:
if (!(readelfheader32(fd, &e.ehdr32) &&
readphdrtable32(fd, &e.ehdr32, &p.phdrs32) &&
getmemorysize32(&e.ehdr32, p.phdrs32, &newsize) &&
truncatezeros(fd, &newsize) &&
modifyheaders(&ehdr, phdrs, newsize) &&
commitchanges(fd, &ehdr, phdrs, newsize)))
modifyheaders32(&e.ehdr32, p.phdrs32, newsize) &&
commitchanges32(fd, &e.ehdr32, p.phdrs32, newsize)))
++failures;
break;
case ELFCLASS64:
if (!(readelfheader64(fd, &e.ehdr64) &&
readphdrtable64(fd, &e.ehdr64, &p.phdrs64) &&
getmemorysize64(&e.ehdr64, p.phdrs64, &newsize) &&
truncatezeros(fd, &newsize) &&
modifyheaders64(&e.ehdr64, p.phdrs64, newsize) &&
commitchanges64(fd, &e.ehdr64, p.phdrs64, newsize)))
++failures;
break;
default:
++failures;
break;
}
close(fd);
}