diff options
author | brian <brian@FreeBSD.org> | 1999-09-03 10:31:34 +0000 |
---|---|---|
committer | brian <brian@FreeBSD.org> | 1999-09-03 10:31:34 +0000 |
commit | f51d44e622135915665fb3526f64e15c175af75b (patch) | |
tree | edb2e1805a2caf2fb45733457ab6910702524af7 | |
parent | f56c58792745f748b24761ec0f23c864cd0c9583 (diff) | |
download | FreeBSD-src-f51d44e622135915665fb3526f64e15c175af75b.zip FreeBSD-src-f51d44e622135915665fb3526f64e15c175af75b.tar.gz |
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 <bamby@marka.net.ua>
PR: 12225
-rw-r--r-- | usr.sbin/ppp/radius.c | 47 |
1 files changed, 46 insertions, 1 deletions
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 <string.h> #include <sys/time.h> #include <termios.h> +#include <ttyent.h> +#include <unistd.h> +#include <netdb.h> #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 { |