Proposed patch for auth.c
Alain cocconi
cocconi at net-outremer.nc
Sat Nov 19 01:09:33 CET 2005
Le 04:09 19/11/2005,Alan DeKok écrit:
>Alain cocconi <cocconi at net-outremer.nc> wrote:
> > I've mad a small patch to the rad_authlog function in auth.c
> > The purpose of this patch is to make a pair with the auth log message
> in it
> > (Auth: login Ok ....). For this I use the Reply-Message attribute. What do
> > you think, is it safe to use this one ? Or should I define a new one ?
>
> Ok... why is trhis necessary, or even useful?
It is usefull to be used in postauth to store it in a database for helpdesk
.... without parsing a log file
> > Here is the new function :
>
> Don't send the new function. Send the patch.
ok:
--- auth.c.orig 2005-08-25 11:10:28.000000000 +1100
+++ auth.c 2005-11-18 12:04:41.694075060 +1100
@@ -116,7 +116,10 @@
char clean_password[1024];
char clean_username[1024];
char buf[1024];
+ char msg_log[1024];
VALUE_PAIR *username = NULL;
+ VALUE_PAIR *log_pair = NULL;
+
if (!mainconfig.log_auth) {
return 0;
@@ -157,21 +160,32 @@
}
}
+
if (goodpass) {
- radlog(L_AUTH, "%s: [%s%s%s] (%s)",
+ sprintf(msg_log, "%s: [%s%s%s] (%s)",
msg,
clean_username,
mainconfig.log_auth_goodpass ? "/" : "",
mainconfig.log_auth_goodpass ?
clean_password : "",
auth_name(buf, sizeof(buf), request, 1));
} else {
- radlog(L_AUTH, "%s: [%s%s%s] (%s)",
+ sprintf(msg_log, "%s: [%s%s%s] (%s)",
msg,
clean_username,
mainconfig.log_auth_badpass ? "/" : "",
mainconfig.log_auth_badpass ?
clean_password : "",
auth_name(buf, sizeof(buf), request, 1));
}
+ radlog(L_AUTH, msg_log);
+
+ log_pair = paircreate(PW_REPLY_MESSAGE, PW_TYPE_STRING);
+ if (log_pair == NULL) {
+ radlog(L_ERR|L_CONS, "no memory");
+ exit(1);
+ }
+ sprintf((char *)log_pair->strvalue, "%s", msg_log);
+ log_pair->length = strlen((char *)log_pair->strvalue);
+ pairadd(&request->reply->vps, log_pair);
return 0;
}
> Alan DeKok.
>-
>List info/subscribe/unsubscribe? See
>http://www.freeradius.org/list/users.html
More information about the Freeradius-Users
mailing list