X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=pppd%2Fplugins%2Fradius%2Fradattr.c;h=8db94daaae6f19afbf3b51d0dec71900725f7510;hb=ba7f7e053daae846a54a1d08d3d133a5f1266ace;hp=1dee313bc1cb04a84b46e4f09d86ec6735a3518e;hpb=2883dd07101bf851e2ea368f0c04c91aea85cff2;p=ppp.git diff --git a/pppd/plugins/radius/radattr.c b/pppd/plugins/radius/radattr.c index 1dee313..8db94da 100644 --- a/pppd/plugins/radius/radattr.c +++ b/pppd/plugins/radius/radattr.c @@ -17,19 +17,21 @@ static char const RCSID[] = "$Id: radattr.c,v 1.2 2004/10/28 00:24:40 paulus Exp $"; -#ifdef HAVE_CONFIG_H -#include -#endif +#include +#include +#include +#include +#include +#include +#include -#include "pppd.h" #include "radiusclient.h" -#include extern void (*radius_attributes_hook)(VALUE_PAIR *); static void print_attributes(VALUE_PAIR *); static void cleanup(void *opaque, int arg); -char pppd_version[] = VERSION; +char pppd_version[] = PPPD_VERSION; /********************************************************************** * %FUNCTION: plugin_init @@ -49,11 +51,11 @@ plugin_init(void) /* calling cleanup() on link down is problematic because print_attributes() is called only after PAP or CHAP authentication, but not when the link should go up again for any other reason */ - add_notifier(&link_down_notifier, cleanup, NULL); + ppp_add_notify(NF_LINK_DOWN, cleanup, NULL); #endif /* Just in case... */ - add_notifier(&exitnotify, cleanup, NULL); + ppp_add_notify(NF_EXIT, cleanup, NULL); info("RADATTR plugin initialized."); } @@ -75,9 +77,12 @@ print_attributes(VALUE_PAIR *vp) char name[2048]; char value[2048]; int cnt = 0; + mode_t old_umask; - slprintf(fname, sizeof(fname), "/var/run/radattr.%s", ifname); + slprintf(fname, sizeof(fname), "/var/run/radattr.%s", ppp_ifname()); + old_umask = umask(077); fp = fopen(fname, "w"); + umask(old_umask); if (!fp) { warn("radattr plugin: Could not open %s for writing: %m", fname); return; @@ -109,7 +114,7 @@ cleanup(void *opaque, int arg) { char fname[512]; - slprintf(fname, sizeof(fname), "/var/run/radattr.%s", ifname); + slprintf(fname, sizeof(fname), "/var/run/radattr.%s", ppp_get_ifname(NULL,0)); (void) remove(fname); dbglog("RADATTR plugin removed file %s.", fname); }