*/
#ifndef lint
-static char rcsid[] = "$Id: auth.c,v 1.41 1999/02/26 10:38:50 paulus Exp $";
+static char rcsid[] = "$Id: auth.c,v 1.44 1999/03/08 01:47:54 paulus Exp $";
#endif
#include <stdio.h>
lcp_allowoptions[0].neg_upap = 1;
/* open user info file */
- if ((ufile = fopen(*argv, "r")) == NULL) {
+ seteuid(getuid());
+ ufile = fopen(*argv, "r");
+ seteuid(0);
+ if (ufile == NULL) {
option_error("unable to open user login data file %s", *argv);
return 0;
}
+#if 0 /* check done by setting effective UID above */
if (!readable(fileno(ufile))) {
option_error("%s: access denied", *argv);
return 0;
}
+#endif
check_access(ufile, *argv);
/* get username */
wo->neg_upap = 0;
}
+ /*
+ * If we have a default route, require the peer to authenticate
+ * unless the noauth option was given.
+ */
+ if (!auth_required && !allow_any_ip && have_route_to(0))
+ auth_required = 1;
+
/*
* Check whether we have appropriate secrets to use
* to authenticate the peer.
int unit;
u_int32_t addr;
{
+
+ if (addresses[unit] == NULL) {
+ if (auth_required)
+ return 0; /* no addresses authorized */
+ return allow_any_ip || !have_route_to(addr);
+ }
return ip_addr_check(addr, addresses[unit]);
}
if (bad_ip_adrs(addr))
return 0;
- if (addrs == NULL) {
- if (auth_required)
- return 0; /* no addresses authorized */
- return allow_any_ip || !have_route_to(addr);
- }
+ if (addrs == NULL)
+ return 0; /* no addresses authorized */
for (; addrs != NULL; addrs = addrs->next) {
/* "-" means no addresses authorized, "*" means any address allowed */