[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freeradius-users
Subject:    about radlast
From:       george torwell <bpmcontrol () gmail ! com>
Date:       2013-05-31 16:31:33
Message-ID: 51AA21AA.7090205 () gmail ! com
[Download RAW message or body]

Hello everyone, we had issues with radlast on freeBSD and linux.
It seems that the format for the utmp and wtmp that last reads isnt
consistent, on freeBSD its not even the same file...

So we wrote the attached file to read the file radutmp written by
freeRadius.
If its useful to anyone, you can have it under any license you want.

You will probably want to change a couple of things:
- the path on line 32.
- #include the struct instead of declaring it.

If you want me to do it, just ask.
If im on the wrong list for this, sorry.
If you want me to read your reply, cc me. I will unsubscribe soon. 

Version 2.2.0
Tested on debian and freeBSD. both 64 bit.
Have a great weekend.





["spoofedRadLast.c" (text/x-csrc)]

/*
 * spoofedRadLast.c
 *
 *  Created on: May 30, 2013
 *      Author: sharondvir
 *      license: do whatever you want.
 */
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

struct radutmp {
	char login[32];		/* Loginname */
	/* FIXME: extend to 48 or 64 bytes */
	unsigned int nas_port;	/* Port on the terminal server (32 bits). */
	char session_id[8];		/* Radius session ID (first 8 bytes at least)*/
	/* FIXME: extend to 16 or 32 bytes */
	unsigned int nas_address;	/* IP of portmaster. */
	unsigned int framed_address;	/* SLIP/PPP address or login-host. */
	int proto;			/* Protocol. */
	time_t time;			/* Time entry was last updated. */
	time_t delay;			/* Delay time of request */
	int type;			/* Type of entry (login/logout) */
	char porttype;		/* Porttype (I=ISDN A=Async T=Async-ISDN */
	char res1,res2,res3;		/* Fills up to one int */
	char caller_id[16];		/* Calling-Station-ID */
	char reserved[12];		/* 3 ints reserved */
};

int main()
{
	struct radutmp st;
	char path[]="/var/log/radutmp";
	FILE *fp = fopen(path, "rb");
	if (fp==NULL)
	{
		printf("cant open %s\n",path);
		return -1;
	}
	while(fread(&st,sizeof(struct radutmp),1,fp)==1)
	{
		printf("%s %s %u %u ",st.login,st.type==0?"connect":"disconnect",st.nas_address,st.nas_port);
		int i=0;
		for (i=0;i<sizeof(st.session_id);i++)
		{
			printf("%c",st.session_id[i]);
		}
		printf(" %s",ctime(&st.time));
	}
	printf("reminder - output format is:\nlogin connect/disconnect nas_addr nas_port session_id time\n");
	return 0;
}





-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic