diff options
author | Guillaume Cottenceau <gc@mandriva.com> | 2001-06-11 11:44:34 +0000 |
---|---|---|
committer | Guillaume Cottenceau <gc@mandriva.com> | 2001-06-11 11:44:34 +0000 |
commit | ab5559aaabd1167a18ac882e64d97c5adc0e7d03 (patch) | |
tree | d22adafe4701e0abbccc7456fc58ae60ce75d5fb /mdk-stage1/ppp/pppd/plugins | |
parent | f35f2383eed07ff16aa76f30975817117eea6cbb (diff) | |
download | drakx-backup-do-not-use-ab5559aaabd1167a18ac882e64d97c5adc0e7d03.tar drakx-backup-do-not-use-ab5559aaabd1167a18ac882e64d97c5adc0e7d03.tar.gz drakx-backup-do-not-use-ab5559aaabd1167a18ac882e64d97c5adc0e7d03.tar.bz2 drakx-backup-do-not-use-ab5559aaabd1167a18ac882e64d97c5adc0e7d03.tar.xz drakx-backup-do-not-use-ab5559aaabd1167a18ac882e64d97c5adc0e7d03.zip |
Initial revision
Diffstat (limited to 'mdk-stage1/ppp/pppd/plugins')
-rw-r--r-- | mdk-stage1/ppp/pppd/plugins/Makefile.linux | 19 | ||||
-rw-r--r-- | mdk-stage1/ppp/pppd/plugins/Makefile.sol2 | 27 | ||||
-rw-r--r-- | mdk-stage1/ppp/pppd/plugins/minconn.c | 46 | ||||
-rw-r--r-- | mdk-stage1/ppp/pppd/plugins/passprompt.c | 108 |
4 files changed, 200 insertions, 0 deletions
diff --git a/mdk-stage1/ppp/pppd/plugins/Makefile.linux b/mdk-stage1/ppp/pppd/plugins/Makefile.linux new file mode 100644 index 000000000..a64256461 --- /dev/null +++ b/mdk-stage1/ppp/pppd/plugins/Makefile.linux @@ -0,0 +1,19 @@ +CC = gcc +CFLAGS = -g -O2 -I.. -I../../include -fPIC +LDFLAGS = -shared +INSTALL = install + +all: minconn.so passprompt.so + +minconn.so: minconn.c + $(CC) -o $@ $(LDFLAGS) $(CFLAGS) minconn.c + +passprompt.so: passprompt.c + $(CC) -o $@ $(LDFLAGS) $(CFLAGS) passprompt.c + +LIBDIR = /usr/lib/pppd + +install: minconn.so passprompt.so + version=`awk -F '"' '/VERSION/ { print $$2; }' ../patchlevel.h`; \ + $(INSTALL) -d $(LIBDIR)/$$version; \ + $(INSTALL) $? $(LIBDIR)/$$version
\ No newline at end of file diff --git a/mdk-stage1/ppp/pppd/plugins/Makefile.sol2 b/mdk-stage1/ppp/pppd/plugins/Makefile.sol2 new file mode 100644 index 000000000..8f4398258 --- /dev/null +++ b/mdk-stage1/ppp/pppd/plugins/Makefile.sol2 @@ -0,0 +1,27 @@ +# +# Makefile for plugins on Solaris 2 +# +# $Id$ +# + +include ../../svr4/Makedefs + +CFLAGS = -c -O -I.. -I../../include $(COPTS) +LDFLAGS = -G + +all: minconn.so + +minconn.so: minconn.o + ld -o $@ $(LDFLAGS) -h $@ minconn.o + +minconn.o: minconn.c + $(CC) $(CFLAGS) -c $? + +passprompt.so: passprompt.o + ld -o $@ $(LDFLAGS) -h $@ passprompt.o + +passprompt.o: passprompt.c + $(CC) $(CFLAGS) -c $? + +clean: + rm -f *.o *.so diff --git a/mdk-stage1/ppp/pppd/plugins/minconn.c b/mdk-stage1/ppp/pppd/plugins/minconn.c new file mode 100644 index 000000000..02ea34bf6 --- /dev/null +++ b/mdk-stage1/ppp/pppd/plugins/minconn.c @@ -0,0 +1,46 @@ +/* + * minconn.c - pppd plugin to implement a `minconnect' option. + * + * Copyright 1999 Paul Mackerras. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms. The name of the author + * may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ +#include <stddef.h> +#include <time.h> +#include "pppd.h" + +char pppd_version[] = VERSION; + +static int minconnect = 0; + +static option_t my_options[] = { + { "minconnect", o_int, &minconnect, + "Set minimum connect time before idle timeout applies" }, + { NULL } +}; + +static int my_get_idle(struct ppp_idle *idle) +{ + time_t t; + + if (idle == NULL) + return minconnect? minconnect: idle_time_limit; + t = idle->xmit_idle; + if (idle->recv_idle < t) + t = idle->recv_idle; + return idle_time_limit - t; +} + +void plugin_init(void) +{ + info("plugin_init"); + add_options(my_options); + idle_time_hook = my_get_idle; +} diff --git a/mdk-stage1/ppp/pppd/plugins/passprompt.c b/mdk-stage1/ppp/pppd/plugins/passprompt.c new file mode 100644 index 000000000..5e6a7f90b --- /dev/null +++ b/mdk-stage1/ppp/pppd/plugins/passprompt.c @@ -0,0 +1,108 @@ +/* + * passprompt.c - pppd plugin to invoke an external PAP password prompter + * + * Copyright 1999 Paul Mackerras, Alan Curry. + * + * 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. + */ +#include <errno.h> +#include <unistd.h> +#include <sys/wait.h> +#include <syslog.h> +#include "pppd.h" + +char pppd_version[] = VERSION; + +static char promptprog[PATH_MAX+1]; + +static option_t options[] = { + { "promptprog", o_string, promptprog, + "External PAP password prompting program", + OPT_STATIC, NULL, PATH_MAX }, + { NULL } +}; + +static int promptpass(char *user, char *passwd) +{ + int p[2]; + pid_t kid; + int readgood, wstat; + size_t red; + + if (promptprog[0] == 0 || access(promptprog, X_OK) < 0) + return -1; /* sorry, can't help */ + + if (!passwd) + return 1; + + if (pipe(p)) { + warn("Can't make a pipe for %s", promptprog); + return 0; + } + if ((kid = fork()) == (pid_t) -1) { + warn("Can't fork to run %s", promptprog); + close(p[0]); + close(p[1]); + return 0; + } + if (!kid) { + /* we are the child, exec the program */ + char *argv[4], fdstr[32]; + sys_close(); + closelog(); + close(p[0]); + seteuid(getuid()); + setegid(getgid()); + argv[0] = promptprog; + argv[1] = user; + argv[2] = remote_name; + sprintf(fdstr, "%d", p[1]); + argv[3] = fdstr; + argv[4] = 0; + execv(*argv, argv); + _exit(127); + } + + /* we are the parent, read the password from the pipe */ + close(p[1]); + readgood = 0; + do { + red = read(p[0], passwd + readgood, MAXSECRETLEN-1 - readgood); + if (red == 0) + break; + if (red < 0) { + error("Can't read secret from %s: %m", promptprog); + readgood = -1; + break; + } + readgood += red; + } while (readgood < MAXSECRETLEN - 1); + passwd[readgood] = 0; + close(p[0]); + + /* now wait for child to exit */ + while (waitpid(kid, &wstat, 0) < 0) { + if (errno != EINTR) { + warn("error waiting for %s: %m", promptprog); + break; + } + } + + if (readgood < 0) + return 0; + if (!WIFEXITED(wstat)) + warn("%s terminated abnormally", promptprog); + if (WEXITSTATUS(wstat)) + warn("%s exited with code %d", promptprog, WEXITSTATUS(status)); + + return 1; +} + +void plugin_init(void) +{ + add_options(options); + pap_passwd_hook = promptpass; +} |