From e38fa6a29a90a514ad7dfa8fa873d5fd49bc9ca1 Mon Sep 17 00:00:00 2001 From: "David F. Skoll" Date: Mon, 14 Jan 2002 14:25:10 +0000 Subject: [PATCH] Made multilink and tdb code compile-time options. By default, they are included, so the default build is unchanged. --- pppd/Makefile.linux | 34 +++++++++++++++++++++++++++++----- pppd/main.c | 41 +++++++++++++++++++++++++++++++++++++++-- 2 files changed, 68 insertions(+), 7 deletions(-) diff --git a/pppd/Makefile.linux b/pppd/Makefile.linux index 64218a4..fab5ee4 100644 --- a/pppd/Makefile.linux +++ b/pppd/Makefile.linux @@ -1,6 +1,6 @@ # # pppd makefile for Linux -# $Id: Makefile.linux,v 1.42 2001/05/23 03:39:50 paulus Exp $ +# $Id: Makefile.linux,v 1.43 2002/01/14 14:25:09 dfs Exp $ # # Default installation locations @@ -9,13 +9,12 @@ MANDIR = /usr/man PPPDSRCS = main.c magic.c fsm.c lcp.c ipcp.c upap.c chap.c md5.c ccp.c \ ipxcp.c auth.c options.c sys-linux.c md4.c chap_ms.c cbcp.c \ - demand.c utils.c multilink.c tdb.c tty.c + demand.c utils.c tty.c HEADERS = callout.h pathnames.h patchlevel.h chap.h md5.h chap_ms.h md4.h \ ipxcp.h cbcp.h tdb.h MANPAGES = pppd.8 PPPDOBJS = main.o magic.o fsm.o lcp.o ipcp.o upap.o chap.o md5.o ccp.o \ - auth.o options.o demand.o utils.o sys-linux.o ipxcp.o multilink.o \ - tdb.o tty.o + auth.o options.o demand.o utils.o sys-linux.o ipxcp.o tty.o all: pppd @@ -48,6 +47,16 @@ endif # doesn't yet. #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 + +# 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 + HAS_SHADOW=y #USE_PAM=y #HAVE_INET6=y @@ -56,7 +65,7 @@ PLUGIN=y INCLUDE_DIRS= -I../include -COMPILE_FLAGS= -D_linux_=1 -DHAVE_PATHS_H -DIPX_CHANGE -DHAVE_MULTILINK -DHAVE_MMAP +COMPILE_FLAGS= -D_linux_=1 -DHAVE_PATHS_H -DIPX_CHANGE -DHAVE_MMAP CFLAGS= $(COPTS) $(COMPILE_FLAGS) $(INCLUDE_DIRS) @@ -87,6 +96,21 @@ CFLAGS += -DUSE_PAM LIBS := -lpam -ldl $(LIBS) endif +# Multi-linnk +ifdef HAVE_MULTILINK + USE_TDB=y + CFLAGS += -DHAVE_MULTILINK + PPPDSRCS += multilink.c + PPPDOBJS += multilink.o +endif + +# TDB +ifdef USE_TDB + CFLAGS += -DUSE_TDB=1 + PPPDSRCS += tdb.c + PPPDOBJS += tdb.o +endif + # Lock library binary for Linux is included in 'linux' subdirectory. ifdef LOCKLIB LIBS := -llock $(LIBS) diff --git a/pppd/main.c b/pppd/main.c index 6541a3b..a80b0a5 100644 --- a/pppd/main.c +++ b/pppd/main.c @@ -17,7 +17,7 @@ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ -#define RCSID "$Id: main.c,v 1.109 2002/01/11 18:10:16 etbe Exp $" +#define RCSID "$Id: main.c,v 1.110 2002/01/14 14:25:10 dfs Exp $" #include #include @@ -54,7 +54,10 @@ #include "chap.h" #include "ccp.h" #include "pathnames.h" + +#ifdef USE_TDB #include "tdb.h" +#endif #ifdef CBCP_SUPPORT #include "cbcp.h" @@ -94,7 +97,11 @@ volatile int status; /* exit status for pppd */ int unsuccess; /* # unsuccessful connection attempts */ int do_callback; /* != 0 if we should do callback next */ int doing_callback; /* != 0 if we are doing callback */ + +#ifdef USE_TDB TDB_CONTEXT *pppdb; /* database for storing status etc. */ +#endif + char db_key[32]; int (*holdoff_hook) __P((void)) = NULL; @@ -170,10 +177,14 @@ static void open_ccp __P((int)); static void bad_signal __P((int)); static void holdoff_end __P((void *)); static int reap_kids __P((int waitfor)); + +#ifdef USE_TDB static void update_db_entry __P((void)); static void add_db_key __P((const char *)); static void delete_db_key __P((const char *)); static void cleanup_db __P((void)); +#endif + static void handle_events __P((void)); static void print_link_stats __P((void)); @@ -353,6 +364,7 @@ main(argc, argv) */ sys_init(); +#ifdef USE_TDB pppdb = tdb_open(_PATH_PPPDB, 0, 0, O_RDWR|O_CREAT, 0644); if (pppdb != NULL) { slprintf(db_key, sizeof(db_key), "pppd%d", getpid()); @@ -364,6 +376,7 @@ main(argc, argv) multilink = 0; } } +#endif /* * Detach ourselves from the terminal, if required, @@ -400,11 +413,14 @@ main(argc, argv) /* * Open the loopback channel and set it up to be the ppp interface. */ +#ifdef USE_TDB tdb_writelock(pppdb); +#endif fd_loop = open_ppp_loopback(); set_ifunit(1); +#ifdef USE_TDB tdb_writeunlock(pppdb); - +#endif /* * Configure the interface and mark it up, etc. */ @@ -454,17 +470,23 @@ main(argc, argv) goto fail; /* set up the serial device as a ppp interface */ +#ifdef USE_TDB tdb_writelock(pppdb); +#endif fd_ppp = the_channel->establish_ppp(devfd); if (fd_ppp < 0) { +#ifdef USE_TDB tdb_writeunlock(pppdb); +#endif status = EXIT_FATAL_ERROR; goto disconnect; } if (!demand && ifunit >= 0) set_ifunit(1); +#ifdef USE_TDB tdb_writeunlock(pppdb); +#endif /* * Start opening the connection and wait for @@ -1042,8 +1064,11 @@ cleanup() warn("unable to delete pid file %s: %m", linkpidfile); linkpidfile[0] = 0; +#ifdef USE_TDB if (pppdb != NULL) cleanup_db(); +#endif + } void @@ -1690,13 +1715,17 @@ script_setenv(var, value, iskey) if (script_env != 0) { for (i = 0; (p = script_env[i]) != 0; ++i) { if (strncmp(p, var, varl) == 0 && p[varl] == '=') { +#ifdef USE_TDB if (p[-1] && pppdb != NULL) delete_db_key(p); +#endif free(p-1); script_env[i] = newstring; +#ifdef USE_TDB if (iskey && pppdb != NULL) add_db_key(newstring); update_db_entry(); +#endif return; } } @@ -1723,11 +1752,13 @@ script_setenv(var, value, iskey) script_env[i] = newstring; script_env[i+1] = 0; +#ifdef USE_TDB if (pppdb != NULL) { if (iskey) add_db_key(newstring); update_db_entry(); } +#endif } /* @@ -1746,18 +1777,23 @@ script_unsetenv(var) return; for (i = 0; (p = script_env[i]) != 0; ++i) { if (strncmp(p, var, vl) == 0 && p[vl] == '=') { +#ifdef USE_TDB if (p[-1] && pppdb != NULL) delete_db_key(p); +#endif free(p-1); while ((script_env[i] = script_env[i+1]) != 0) ++i; break; } } +#ifdef USE_TDB if (pppdb != NULL) update_db_entry(); +#endif } +#ifdef USE_TDB /* * update_db_entry - update our entry in the database. */ @@ -1840,3 +1876,4 @@ cleanup_db() if (p[-1]) delete_db_key(p); } +#endif /* USE_TDB */ -- 2.39.2