De-couple ppp from libalias. If libalias isn't there, the

alias commands simply won't work.  Only root may specify the
location of the alias lib (otherwise, it's hard-coded).

Make logprintf silently fail if LogOpen hasn't been called.

Suggested by:	eivind
This commit is contained in:
Brian Somers 1997-05-26 00:44:10 +00:00
parent dcb1c20021
commit 6ed9fb2fc9
25 changed files with 259 additions and 119 deletions

View File

@ -1,14 +1,14 @@
# $Id: Makefile,v 1.18 1997/03/31 22:50:59 brian Exp $
# $Id: Makefile,v 1.19 1997/05/23 04:53:49 brian Exp $
PROG= ppp
SRCS= alias_cmd.c arp.c async.c auth.c ccp.c chap.c chat.c command.c \
filter.c fsm.c hdlc.c ip.c ipcp.c lcp.c log.c lqr.c main.c mbuf.c \
modem.c os.c pap.c passwdauth.c pred.c route.c sig.c slcompress.c \
systems.c timer.c vars.c vjcomp.c
filter.c fsm.c hdlc.c ip.c ipcp.c lcp.c loadalias.c log.c lqr.c \
main.c mbuf.c modem.c os.c pap.c passwdauth.c pred.c route.c sig.c \
slcompress.c systems.c timer.c vars.c vjcomp.c
#CFLAGS+= -DHAVE_SHELL_CMD_WITH_ANY_MODE
CFLAGS += -Wall -DMSEXT -DPASSWDAUTH
LDADD += -lmd -lcrypt -lutil -lalias
DPADD += ${LIBMD} ${LIBCRYPT} ${LIBUTIL} ${LIBALIAS}
LDADD += -lmd -lcrypt -lutil
DPADD += ${LIBMD} ${LIBCRYPT} ${LIBUTIL}
MAN8= ppp.8
BINMODE=4555
BINOWN= root

View File

@ -8,9 +8,10 @@
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <alias.h>
#include "defs.h"
#include "command.h"
#include "loadalias.h"
#include "vars.h"
static int
@ -29,8 +30,9 @@ AliasRedirectPort (struct cmdtab *list,
char **argv,
void *param)
{
if (argc == 3)
{
if (!(mode & MODE_ALIAS))
printf("alias not enabled\n");
else if (argc == 3) {
char proto_constant;
char *proto;
u_short local_port;
@ -41,32 +43,25 @@ AliasRedirectPort (struct cmdtab *list,
struct alias_link *link;
proto = argv[0];
if (strcmp(proto, "tcp") == 0)
{
if (strcmp(proto, "tcp") == 0) {
proto_constant = IPPROTO_TCP;
}
else if (strcmp(proto, "udp") == 0)
{
} else if (strcmp(proto, "udp") == 0) {
proto_constant = IPPROTO_UDP;
}
else
{
} else {
printf("port redirect: protocol must be tcp or udp\n");
printf("Usage: alias %s %s\n", list->name, list->syntax);
return 1;
}
error = StrToAddrAndPort(argv[1], &local_addr, &local_port, proto);
if (error)
{
if (error) {
printf("port redirect: error reading local addr:port\n");
printf("Usage: alias %s %s\n", list->name, list->syntax);
return 1;
}
error = StrToPort(argv[2], &alias_port, proto);
if (error)
{
if (error) {
printf("port redirect: error reading alias port\n");
printf("Usage: alias %s %s\n", list->name, list->syntax);
return 1;
@ -74,7 +69,7 @@ AliasRedirectPort (struct cmdtab *list,
null_addr.s_addr = 0;
link = PacketAliasRedirectPort(local_addr, local_port,
link = VarPacketAliasRedirectPort(local_addr, local_port,
null_addr, 0,
null_addr, alias_port,
proto_constant);
@ -82,11 +77,9 @@ AliasRedirectPort (struct cmdtab *list,
if (link == NULL)
printf("port redirect: error returned by packed aliasing engine"
"(code=%d)\n", error);
} else
printf("Usage: alias %s %s\n", list->name, list->syntax);
return 1;
}
printf("Usage: alias %s %s\n", list->name, list->syntax);
return 1;
}
@ -97,39 +90,36 @@ AliasRedirectAddr(struct cmdtab *list,
char **argv,
void *param)
{
if (argc == 2)
{
if (!(mode & MODE_ALIAS))
printf("alias not enabled\n");
else if (argc == 2) {
int error;
struct in_addr local_addr;
struct in_addr alias_addr;
struct alias_link *link;
error = StrToAddr(argv[0], &local_addr);
if (error)
{
if (error) {
printf("address redirect: invalid local address\n");
return 1;
}
error = StrToAddr(argv[1], &alias_addr);
if (error)
{
if (error) {
printf("address redirect: invalid alias address\n");
printf("Usage: alias %s %s\n", list->name, list->syntax);
return 1;
}
link = PacketAliasRedirectAddr(local_addr, alias_addr);
if (link == NULL)
{
link = VarPacketAliasRedirectAddr(local_addr, alias_addr);
if (link == NULL) {
printf("address redirect: packet aliasing engine error\n");
printf("Usage: alias %s %s\n", list->name, list->syntax);
}
return 1;
}
} else
printf("Usage: alias %s %s\n", list->name, list->syntax);
printf("Usage: alias %s %s\n", list->name, list->syntax);
return 1;
}

View File

@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id$
* $Id: async.c,v 1.7 1997/02/22 16:09:59 peter Exp $
*
*/
#include "fsm.h"
@ -25,6 +25,7 @@
#include "lcp.h"
#include "lcpproto.h"
#include "modem.h"
#include "loadalias.h"
#include "vars.h"
#include "os.h"

View File

@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: auth.c,v 1.11 1997/05/07 23:01:21 brian Exp $
* $Id: auth.c,v 1.12 1997/05/10 01:22:05 brian Exp $
*
* TODO:
* o Implement check against with registered IP addresses.
@ -25,6 +25,7 @@
#include "fsm.h"
#include "lcpproto.h"
#include "ipcp.h"
#include "loadalias.h"
#include "vars.h"
#include "filter.h"
#include "auth.h"

View File

@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: ccp.c,v 1.10 1997/02/22 16:10:03 peter Exp $
* $Id: ccp.c,v 1.11 1997/05/10 01:22:06 brian Exp $
*
* TODO:
* o Support other compression protocols
@ -27,6 +27,7 @@
#include "lcp.h"
#include "ccp.h"
#include "phase.h"
#include "loadalias.h"
#include "vars.h"
#include "pred.h"
#include "cdefs.h"

View File

@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: chap.c,v 1.15 1997/05/19 01:59:57 brian Exp $
* $Id: chap.c,v 1.16 1997/05/24 17:32:32 brian Exp $
*
* TODO:
*/
@ -29,6 +29,7 @@
#include "lcp.h"
#include "hdlc.h"
#include "phase.h"
#include "loadalias.h"
#include "vars.h"
#include "auth.h"

View File

@ -18,7 +18,7 @@
* Columbus, OH 43221
* (614)451-1883
*
* $Id: chat.c,v 1.23 1997/05/07 23:01:23 brian Exp $
* $Id: chat.c,v 1.24 1997/05/10 01:22:07 brian Exp $
*
* TODO:
* o Support more UUCP compatible control sequences.
@ -36,7 +36,12 @@
#include <errno.h>
#include <signal.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/param.h>
#include <netinet/in.h>
#include "timeout.h"
#include "loadalias.h"
#include "vars.h"
#include "chat.h"
#include "sig.h"

View File

@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: command.c,v 1.48 1997/05/23 04:54:01 brian Exp $
* $Id: command.c,v 1.49 1997/05/24 17:32:33 brian Exp $
*
*/
#include <sys/types.h>
@ -41,11 +41,11 @@
#include "command.h"
#include "alias_cmd.h"
#include "hdlc.h"
#include "loadalias.h"
#include "vars.h"
#include "systems.h"
#include "chat.h"
#include "os.h"
#include "chat.h"
extern void Cleanup(), TtyTermMode(), PacketMode();
extern int EnableCommand(), DisableCommand(), DisplayCommand();
@ -79,7 +79,6 @@ struct cmdtab *plist;
{
struct cmdtab *cmd;
int n;
char c;
if (argc > 0) {
for (cmd = plist; cmd->name; cmd++) {
@ -95,8 +94,7 @@ struct cmdtab *plist;
n = 0;
for (cmd = plist; cmd->func; cmd++) {
if (cmd->name && (cmd->lauth & VarLocalAuth)) {
c = (n & 1)? '\n' : '\t';
printf(" %-8s: %-20s%c", cmd->name, cmd->helpmes, c);
printf(" %-8s: %-20s\n", cmd->name, cmd->helpmes);
n++;
}
}
@ -1272,14 +1270,21 @@ struct cmdtab *list;
int argc;
char **argv;
{
if (argc == 1 && strcmp(argv[0], "yes") == 0) {
mode |= MODE_ALIAS;
} else if (argc == 1 && strcmp(argv[0], "no") == 0) {
mode &= ~MODE_ALIAS;
} else {
printf("Usage: alias %s %s\n", list->name, list->syntax);
}
return(1);
if (argc == 1 && strcmp(argv[0], "yes") == 0) {
if (!(mode & MODE_ALIAS))
if (loadAliasHandlers(&VarAliasHandlers) == 0)
mode |= MODE_ALIAS;
else
printf("Cannot load alias library\n");
} else if (argc == 1 && strcmp(argv[0], "no") == 0) {
if (mode & MODE_ALIAS) {
unloadAliasHandlers();
mode &= ~MODE_ALIAS;
}
} else {
printf("Usage: alias %s %s\n", list->name, list->syntax);
}
return(1);
}
@ -1291,9 +1296,15 @@ char **argv;
void* param;
{
if (argc == 1 && strcmp(argv[0], "yes") == 0) {
SetPacketAliasMode((unsigned)param, (unsigned)param);
if (mode & MODE_ALIAS)
VarSetPacketAliasMode((unsigned)param, (unsigned)param);
else
printf("alias not enabled\n");
} else if (argc == 1 && strcmp(argv[0], "no") == 0) {
SetPacketAliasMode(0, (unsigned)param);
if (mode & MODE_ALIAS)
VarSetPacketAliasMode(0, (unsigned)param);
else
printf("alias not enabled\n");
} else {
printf("Usage: alias %s %s\n", list->name, list->syntax);
}

View File

@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: hdlc.c,v 1.13 1997/04/19 11:31:38 ache Exp $
* $Id: hdlc.c,v 1.14 1997/05/10 01:22:10 brian Exp $
*
* TODO:
*/
@ -26,6 +26,7 @@
#include "lcpproto.h"
#include "lcp.h"
#include "lqr.h"
#include "loadalias.h"
#include "vars.h"
#include "pred.h"
#include "modem.h"

View File

@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: ip.c,v 1.18 1997/05/23 04:54:02 brian Exp $
* $Id: ip.c,v 1.19 1997/05/24 17:32:35 brian Exp $
*
* TODO:
* o Return ICMP message for filterd packet
@ -33,6 +33,7 @@
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <alias.h>
#include "loadalias.h"
#include "vars.h"
#include "filter.h"
@ -337,7 +338,7 @@ struct mbuf *bp; /* IN: Pointer to IP pakcet */
int iresult;
char *fptr;
iresult = PacketAliasIn(tunbuff, sizeof tunbuff);
iresult = VarPacketAliasIn(tunbuff, sizeof tunbuff);
nb = ntohs(((struct ip *) tunbuff)->ip_len);
if (nb > MAX_MRU) {
@ -361,8 +362,8 @@ struct mbuf *bp; /* IN: Pointer to IP pakcet */
fprintf(stderr, "wrote %d, got %d\r\n", nb, nw);
if (iresult == PKT_ALIAS_FOUND_HEADER_FRAGMENT) {
while ((fptr = GetNextFragmentPtr(tunbuff)) != NULL) {
FragmentAliasIn(tunbuff, fptr);
while ((fptr = VarGetNextFragmentPtr(tunbuff)) != NULL) {
VarFragmentAliasIn(tunbuff, fptr);
nb = ntohs(((struct ip *) fptr)->ip_len);
nw = write(tun_out, fptr, nb);
if (nw != nb)
@ -379,7 +380,7 @@ struct mbuf *bp; /* IN: Pointer to IP pakcet */
}
else {
memcpy(fptr, tunbuff, nb);
SaveFragmentPtr(fptr);
VarSaveFragmentPtr(fptr);
}
}
}

View File

@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: ipcp.c,v 1.18 1997/05/23 04:54:02 brian Exp $
* $Id: ipcp.c,v 1.19 1997/05/24 17:32:35 brian Exp $
*
* TODO:
* o More RFC1772 backwoard compatibility
@ -31,10 +31,10 @@
#include <netinet/ip.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <alias.h>
#include "slcompress.h"
#include "os.h"
#include "phase.h"
#include "loadalias.h"
#include "vars.h"
extern void PutConfValue();
@ -282,7 +282,7 @@ struct fsm *fp;
IpcpStartReport();
StartIdleTimer();
if (mode & MODE_ALIAS)
SetPacketAliasAddress(IpcpInfo.want_ipaddr);
VarSetPacketAliasAddress(IpcpInfo.want_ipaddr);
}
void

View File

@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: lcp.c,v 1.19 1997/05/19 02:00:04 brian Exp $
* $Id: lcp.c,v 1.20 1997/05/24 17:32:38 brian Exp $
*
* TODO:
* o Validate magic number received from peer.
@ -33,6 +33,7 @@
#include "ccp.h"
#include "lqr.h"
#include "phase.h"
#include "loadalias.h"
#include "vars.h"
#include "auth.h"
#include <arpa/inet.h>

88
usr.sbin/ppp/loadalias.c Normal file
View File

@ -0,0 +1,88 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/param.h>
#include <netinet/in.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <dlfcn.h>
#include "systems.h"
#include "mbuf.h"
#include "log.h"
#include "loadalias.h"
#include "vars.h"
#define _PATH_ALIAS "/usr/lib/libalias.so.2.1"
#define off(item) ((int)&(((struct aliasHandlers *)0)->item))
#define entry(a) { off(a), "_" #a }
static struct {
int offset;
char *name;
} map[] = {
entry(GetNextFragmentPtr),
entry(GetNextFragmentPtr),
entry(InitPacketAlias),
entry(PacketAliasIn),
entry(PacketAliasOut),
entry(PacketAliasRedirectAddr),
entry(PacketAliasRedirectPort),
entry(SaveFragmentPtr),
entry(SetPacketAliasAddress),
entry(SetPacketAliasMode),
entry(FragmentAliasIn),
{ 0, 0 }
};
static void *dl;
int loadAliasHandlers(struct aliasHandlers *h)
{
char *path;
char *env;
char *err;
int i;
path = _PATH_ALIAS;
env = getenv("_PATH_ALIAS");
if (env)
if (OrigUid() == 0)
path = env;
else {
logprintf("Ignoring environment _PATH_ALIAS value (%s)\n", env);
printf("Ignoring environment _PATH_ALIAS value (%s)\n", env);
}
dl = dlopen(path, RTLD_LAZY);
if (dl == (void *)0) {
err = dlerror();
logprintf("_PATH_ALIAS (%s): Invalid lib: %s\n", path, err);
printf("_PATH_ALIAS (%s): Invalid lib: %s\n", path, err);
return -1;
}
for (i = 0; map[i].name; i++) {
*(void **)((char *)h + map[i].offset) = dlsym(dl, map[i].name);
if (*(void **)((char *)h + map[i].offset) == (void *)0) {
err = dlerror();
logprintf("_PATH_ALIAS (%s): %s: %s\n", path, map[i].name, err);
printf("_PATH_ALIAS (%s): %s: %s\n", path, map[i].name, err);
(void)dlclose(dl);
dl = (void *)0;
return -1;
}
}
VarInitPacketAlias();
return 0;
}
void unloadAliasHandlers()
{
if (dl) {
dlclose(dl);
dl = (void *)0;
}
}

18
usr.sbin/ppp/loadalias.h Normal file
View File

@ -0,0 +1,18 @@
struct aliasHandlers {
char *(*GetNextFragmentPtr)(char *);
void (*InitPacketAlias)();
int (*PacketAliasIn)(char *,int);
int (*PacketAliasOut)(char *,int);
struct alias_link *(*PacketAliasRedirectAddr)
(struct in_addr, struct in_addr);
struct alias_link *(*PacketAliasRedirectPort)
(struct in_addr, u_short, struct in_addr, u_short,
struct in_addr, u_short, u_char);
int (*SaveFragmentPtr)(char *);
void (*SetPacketAliasAddress)(struct in_addr);
unsigned (*SetPacketAliasMode)(unsigned, unsigned);
void (*FragmentAliasIn)(char *, char *);
};
extern int loadAliasHandlers(struct aliasHandlers *);
extern void unloadAliasHandlers();

View File

@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: log.c,v 1.9 1997/05/04 02:39:03 ache Exp $
* $Id: log.c,v 1.10 1997/05/07 23:30:48 brian Exp $
*
*/
#include "defs.h"
@ -151,9 +151,11 @@ vlogprintf(format, ap)
char *format;
va_list ap;
{
vsnprintf(logptr, sizeof(logbuff)-(logptr-logbuff), format, ap);
logptr += strlen(logptr);
LogFlush();
if (logptr) {
vsnprintf(logptr, sizeof(logbuff)-(logptr-logbuff), format, ap);
logptr += strlen(logptr);
LogFlush();
}
}
void

View File

@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: lqr.c,v 1.12 1997/05/19 02:00:05 brian Exp $
* $Id: lqr.c,v 1.13 1997/05/24 17:32:39 brian Exp $
*
* o LQR based on RFC1333
*
@ -30,6 +30,7 @@
#include "lqr.h"
#include "hdlc.h"
#include "lcp.h"
#include "loadalias.h"
#include "vars.h"
#include "main.h"

View File

@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: main.c,v 1.55 1997/05/23 05:22:48 brian Exp $
* $Id: main.c,v 1.56 1997/05/24 17:32:40 brian Exp $
*
* TODO:
* o Add commands for traffic summary, version display, etc.
@ -37,13 +37,13 @@
#include <arpa/inet.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <alias.h>
#include "modem.h"
#include "os.h"
#include "hdlc.h"
#include "ccp.h"
#include "lcp.h"
#include "ipcp.h"
#include "loadalias.h"
#include "vars.h"
#include "auth.h"
#include "filter.h"
@ -289,7 +289,10 @@ ProcessArgs(int argc, char **argv)
else if (strcmp(cp, "ddial") == 0)
mode |= MODE_DDIAL|MODE_AUTO;
else if (strcmp(cp, "alias") == 0) {
mode |= MODE_ALIAS;
if (loadAliasHandlers(&VarAliasHandlers) == 0)
mode |= MODE_ALIAS;
else
printf("Cannot load alias library\n");
optc--; /* this option isn't exclusive */
}
else
@ -330,7 +333,6 @@ char **argv;
Greetings();
GetUid();
IpcpDefAddress();
InitPacketAlias();
if (SelectSystem("default", CONFFILE) < 0) {
fprintf(stderr, "Warning: No default entry is given in config file.\n");
@ -1026,7 +1028,7 @@ DoLoop()
pri = PacketCheck(rbuff, n, FL_DIAL);
if (pri >= 0) {
if (mode & MODE_ALIAS) {
PacketAliasOut(rbuff, sizeof rbuff);
VarPacketAliasOut(rbuff, sizeof rbuff);
n = ntohs(((struct ip *)rbuff)->ip_len);
}
IpEnqueue(pri, rbuff, n);
@ -1037,7 +1039,7 @@ DoLoop()
pri = PacketCheck(rbuff, n, FL_OUT);
if (pri >= 0) {
if (mode & MODE_ALIAS) {
PacketAliasOut(rbuff, sizeof rbuff);
VarPacketAliasOut(rbuff, sizeof rbuff);
n = ntohs(((struct ip *)rbuff)->ip_len);
}
IpEnqueue(pri, rbuff, n);

View File

@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: modem.c,v 1.38 1997/05/19 02:00:08 brian Exp $
* $Id: modem.c,v 1.39 1997/05/24 17:32:41 brian Exp $
*
* TODO:
*/
@ -33,6 +33,7 @@
#include "lcp.h"
#include "ip.h"
#include "modem.h"
#include "loadalias.h"
#include "vars.h"
#ifndef O_NONBLOCK

View File

@ -8,9 +8,10 @@
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <alias.h>
#include "defs.h"
#include "command.h"
#include "loadalias.h"
#include "vars.h"
static int
@ -29,8 +30,9 @@ AliasRedirectPort (struct cmdtab *list,
char **argv,
void *param)
{
if (argc == 3)
{
if (!(mode & MODE_ALIAS))
printf("alias not enabled\n");
else if (argc == 3) {
char proto_constant;
char *proto;
u_short local_port;
@ -41,32 +43,25 @@ AliasRedirectPort (struct cmdtab *list,
struct alias_link *link;
proto = argv[0];
if (strcmp(proto, "tcp") == 0)
{
if (strcmp(proto, "tcp") == 0) {
proto_constant = IPPROTO_TCP;
}
else if (strcmp(proto, "udp") == 0)
{
} else if (strcmp(proto, "udp") == 0) {
proto_constant = IPPROTO_UDP;
}
else
{
} else {
printf("port redirect: protocol must be tcp or udp\n");
printf("Usage: alias %s %s\n", list->name, list->syntax);
return 1;
}
error = StrToAddrAndPort(argv[1], &local_addr, &local_port, proto);
if (error)
{
if (error) {
printf("port redirect: error reading local addr:port\n");
printf("Usage: alias %s %s\n", list->name, list->syntax);
return 1;
}
error = StrToPort(argv[2], &alias_port, proto);
if (error)
{
if (error) {
printf("port redirect: error reading alias port\n");
printf("Usage: alias %s %s\n", list->name, list->syntax);
return 1;
@ -74,7 +69,7 @@ AliasRedirectPort (struct cmdtab *list,
null_addr.s_addr = 0;
link = PacketAliasRedirectPort(local_addr, local_port,
link = VarPacketAliasRedirectPort(local_addr, local_port,
null_addr, 0,
null_addr, alias_port,
proto_constant);
@ -82,11 +77,9 @@ AliasRedirectPort (struct cmdtab *list,
if (link == NULL)
printf("port redirect: error returned by packed aliasing engine"
"(code=%d)\n", error);
} else
printf("Usage: alias %s %s\n", list->name, list->syntax);
return 1;
}
printf("Usage: alias %s %s\n", list->name, list->syntax);
return 1;
}
@ -97,39 +90,36 @@ AliasRedirectAddr(struct cmdtab *list,
char **argv,
void *param)
{
if (argc == 2)
{
if (!(mode & MODE_ALIAS))
printf("alias not enabled\n");
else if (argc == 2) {
int error;
struct in_addr local_addr;
struct in_addr alias_addr;
struct alias_link *link;
error = StrToAddr(argv[0], &local_addr);
if (error)
{
if (error) {
printf("address redirect: invalid local address\n");
return 1;
}
error = StrToAddr(argv[1], &alias_addr);
if (error)
{
if (error) {
printf("address redirect: invalid alias address\n");
printf("Usage: alias %s %s\n", list->name, list->syntax);
return 1;
}
link = PacketAliasRedirectAddr(local_addr, alias_addr);
if (link == NULL)
{
link = VarPacketAliasRedirectAddr(local_addr, alias_addr);
if (link == NULL) {
printf("address redirect: packet aliasing engine error\n");
printf("Usage: alias %s %s\n", list->name, list->syntax);
}
return 1;
}
} else
printf("Usage: alias %s %s\n", list->name, list->syntax);
printf("Usage: alias %s %s\n", list->name, list->syntax);
return 1;
}

View File

@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: os.c,v 1.17 1997/05/19 02:00:10 brian Exp $
* $Id: os.c,v 1.18 1997/05/24 17:32:41 brian Exp $
*
*/
#include "fsm.h"
@ -40,6 +40,7 @@
#include "ipcp.h"
#include "os.h"
#include "loadalias.h"
#include "vars.h"
#include "arp.h"
#include "systems.h"

View File

@ -18,13 +18,14 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: pap.c,v 1.10 1997/05/19 02:00:12 brian Exp $
* $Id: pap.c,v 1.11 1997/05/24 17:32:42 brian Exp $
*
* TODO:
*/
#include "fsm.h"
#include "lcp.h"
#include "pap.h"
#include "loadalias.h"
#include "vars.h"
#include "hdlc.h"
#include "lcpproto.h"

View File

@ -17,11 +17,12 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: systems.c,v 1.9 1997/02/22 16:10:56 peter Exp $
* $Id: systems.c,v 1.10 1997/05/10 01:22:19 brian Exp $
*
* TODO:
*/
#include "fsm.h"
#include "loadalias.h"
#include "vars.h"
#include "ipcp.h"
#include "pathnames.h"
@ -33,6 +34,12 @@ static int uid, gid;
static int euid, egid;
static int usermode;
int
OrigUid()
{
return uid;
}
void
GetUid()
{

View File

@ -17,12 +17,13 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id$
* $Id: systems.h,v 1.3 1997/02/22 16:10:57 peter Exp $
*
*/
#ifndef _SYSTEMS_H_
#define _SYSTEMS_H_
extern int OrigUid __P((void));
extern void GetUid __P((void));
extern int SelectSystem __P((char *, char*));
#endif

View File

@ -17,19 +17,20 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: vars.c,v 1.15 1997/05/10 03:39:55 brian Exp $
* $Id: vars.c,v 1.16 1997/05/17 16:08:48 brian Exp $
*
*/
#include "fsm.h"
#include "command.h"
#include "hdlc.h"
#include "termios.h"
#include "loadalias.h"
#include "vars.h"
#include "auth.h"
#include "defs.h"
char VarVersion[] = "Version 0.94";
char VarLocalVersion[] = "$Date: 1997/05/10 03:39:55 $";
char VarLocalVersion[] = "$Date: 1997/05/17 16:08:48 $";
/*
* Order of conf option is important. See vars.h.

View File

@ -15,7 +15,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: vars.h,v 1.14 1997/05/19 02:00:16 brian Exp $
* $Id: vars.h,v 1.15 1997/05/24 17:32:42 brian Exp $
*
* TODO:
*/
@ -83,6 +83,7 @@ struct pppvars {
char phone_copy[200]; /* copy for strsep() */
char *next_phone; /* Next phone from the list */
char shostname[MAXHOSTNAMELEN];/* Local short Host Name */
struct aliasHandlers handler; /* Alias function pointers */
};
#define VarAccmap pppVars.var_accmap
@ -111,6 +112,19 @@ struct pppvars {
#define VarRedialNextTimeout pppVars.redial_next_timeout
#define VarDialTries pppVars.dial_tries
#define VarAliasHandlers pppVars.handler
#define VarGetNextFragmentPtr (*pppVars.handler.GetNextFragmentPtr)
#define VarGetNextFragmentPtr (*pppVars.handler.GetNextFragmentPtr)
#define VarInitPacketAlias (*pppVars.handler.InitPacketAlias)
#define VarPacketAliasIn (*pppVars.handler.PacketAliasIn)
#define VarPacketAliasOut (*pppVars.handler.PacketAliasOut)
#define VarPacketAliasRedirectAddr (*pppVars.handler.PacketAliasRedirectAddr)
#define VarPacketAliasRedirectPort (*pppVars.handler.PacketAliasRedirectPort)
#define VarSaveFragmentPtr (*pppVars.handler.SaveFragmentPtr)
#define VarSetPacketAliasAddress (*pppVars.handler.SetPacketAliasAddress)
#define VarSetPacketAliasMode (*pppVars.handler.SetPacketAliasMode)
#define VarFragmentAliasIn (*pppVars.handler.FragmentAliasIn)
#define DEV_IS_SYNC (VarSpeed == 0)
extern struct pppvars pppVars;