From f51d44e622135915665fb3526f64e15c175af75b Mon Sep 17 00:00:00 2001 From: brian Date: Fri, 3 Sep 1999 10:31:34 +0000 Subject: When sending radius authentication requests: Supply RAD_NAS_IDENTIFIER if we have a `hostname` and RAD_IP_ADDRESS if that hostname resolves. Supply RAD_NAS_PORT using the ttyslot() of the tty that we're authenticating on if it's a tty device. Partially submitted by: Andriy I Pilipenko PR: 12225 --- usr.sbin/ppp/radius.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) (limited to 'usr.sbin/ppp') diff --git a/usr.sbin/ppp/radius.c b/usr.sbin/ppp/radius.c index 1348207..366baec 100644 --- a/usr.sbin/ppp/radius.c +++ b/usr.sbin/ppp/radius.c @@ -41,6 +41,9 @@ #include #include #include +#include +#include +#include #include "layer.h" #include "defs.h" @@ -336,8 +339,12 @@ void radius_Authenticate(struct radius *r, struct authinfo *authp, const char *name, const char *key, const char *challenge) { + struct ttyent *ttyp; struct timeval tv; - int got; + int got, slot; + char hostname[MAXHOSTNAMELEN]; + struct hostent *hp; + struct in_addr hostaddr; if (!*r->cfg.file) return; @@ -392,6 +399,44 @@ radius_Authenticate(struct radius *r, struct authinfo *authp, const char *name, return; } + if (gethostname(hostname, sizeof hostname) != 0) + log_Printf(LogERROR, "rad_put: gethostname(): %s\n", strerror(errno)); + else { + if ((hp = gethostbyname(hostname)) != NULL) { + hostaddr.s_addr = *(u_long *)hp->h_addr; + if (rad_put_addr(r->cx.rad, RAD_NAS_IP_ADDRESS, hostaddr) != 0) { + log_Printf(LogERROR, "rad_put: rad_put_string: %s\n", + rad_strerror(r->cx.rad)); + rad_close(r->cx.rad); + return; + } + } + if (rad_put_string(r->cx.rad, RAD_NAS_IDENTIFIER, hostname) != 0) { + log_Printf(LogERROR, "rad_put: rad_put_string: %s\n", + rad_strerror(r->cx.rad)); + rad_close(r->cx.rad); + return; + } + } + + if (authp->physical->handler && + authp->physical->handler->type == TTY_DEVICE) { + setttyent(); + for (slot = 1; (ttyp = getttyent()); ++slot) + if (!strcmp(ttyp->ty_name, authp->physical->name.base)) { + if(rad_put_int(r->cx.rad, RAD_NAS_PORT, slot) != 0) { + log_Printf(LogERROR, "rad_put: rad_put_string: %s\n", + rad_strerror(r->cx.rad)); + rad_close(r->cx.rad); + endttyent(); + return; + } + break; + } + endttyent(); + } + + if ((got = rad_init_send_request(r->cx.rad, &r->cx.fd, &tv))) radius_Process(r, got); else { -- cgit v1.1