>Is there a way that we can control a user connecting to a max based on >time ie he can only connect to the max from 9:00am to 3:30pm, With radius it is possible. The following mail was posted on the list a month ago. According to the headers you got a cc, maybe you missed it. Date: Sat, 1 Nov 1997 17:58:31 +0100 (MET) From: Olivier PRENANT <ohp@pyrenet.fr> X-Sender: ohp@server To: Alex Bligh <amb@gxn.net> cc: gdornan@atlantic.co.za, ascend-users@bungi.com Subject: Re: (ASCEND) Time of DAy In-Reply-To: <199710311627.QAA07737@diamond.xara.net> Message-ID: <Pine.UW2.3.96.971101174816.26223A-100000@server> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-ascend-users@max.bungi.com Precedence: bulk Status: RO Content-Length: 5145 Lines: 238 On Fri, 31 Oct 1997, Alex Bligh wrote: > Date: Fri, 31 Oct 1997 16:27:36 +0000 > From: Alex Bligh <amb@gxn.net> > To: gdornan@atlantic.co.za > Cc: ascend-users@bungi.com > Subject: Re: (ASCEND) Time of DAy > > > Is it possible to have a time of day connectivity, ie A user can only > > log on to the max during 9:00am and 4:00pm otherwise he is declined? > > > crontab entry to mv your users file? Or better recreate it using > awk or similar? Simple hack, but effective. > > > -- > Alex Bligh > GX Networks (formerly Xara Networks) What I did was to create the following function : #include <stdio.h> #include <fcntl.h> #include <string.h> #include <sys/types.h> #include <time.h> #include "conf.h" #include "radius.h" extern int debug_flag; #define TIMEFILE "/etc/raddb/users.times" struct week_time { char wkd[3]; int time_min, time_max; }; rad_check_time(char *authname) { time_t cur_time; struct tm *tm; FILE *fp; char *buf, buffer[255],login[10]; int result= -1; time(&cur_time); tm=localtime(&cur_time); fp=fopen(TIMEFILE,"r"); if (fp == 0) return 0; result=0; while (!feof(fp)) { char *p, *p2=login; buf=fgets(buffer,255,fp); p=buf; if (*p == '#') /* skip comment lines */ continue; while (*p && *p != '\t' && *p != '\n') *p2++ = *p++; *p2=NULL; while (*p == '\t') p++; if (strcmp(login,authname) == 0) { result= (*p=='\n' ? -1 : get_times(login,p,tm)); break; } } fclose(fp); return result; } int get_times(login,times,tm) char *login, *times; struct tm *tm; { char *p=times, day[3], day1[3], day2[3]; int ind, intervalle=0; struct week_time week_time[8]= { {"su",-1,-1}, {"mo",-1,-1}, {"tu",-1,-1}, {"we",-1,-1}, {"th",-1,-1}, {"fr",-1,-1}, {"sa",-1,-1}, {"",-2,-2} }; while (*p && *p != '\n') { if (isalpha(*p)) /* we found a day name */ { day1[0]=*p++; day1[1]=*p++; day1[2]='\0'; for (ind=0;ind<8;ind++) if (!strcmp(day1,week_time[ind].wkd)) { week_time[ind].time_min= week_time[ind].time_max=0; break; } if (ind == 8) { debugf("%s: %s bad day name\n",login,day1); return 0; } } else if (*p == '-') /* day interval */ { int ind2, i; intervalle=1; p++; day2[0]=*p++; day2[1]=*p++; day2[2]='\0'; for (ind2=0;ind2<8;ind2++) if (!strcmp(day2,week_time[ind2].wkd)) { week_time[ind2].time_min= week_time[ind2].time_max=0; break; } if (ind2 == 8) { debugf("%s: %s bad day name\n",login,day2); return 0; } for (i=ind+1;i<ind2;i++) week_time[i].time_min=week_time[i].time_max=0; } else if (isalpha(*p)) /* day list */ continue; else if (isdigit(*p)) /* Hours Minutes */ { int i, h_min, h_max; char time[5]="", *p2=time; for (i=0;i<4;i++) { if (!isdigit(*p)) { debugf("%s: %s l'heure doit etre sur 4 caracteres\n",login,time); exit(1); } *p2++=*p++; } h_min=atoi(time); if (*p++ != ':') { debugf("%s: Erreur ':' attendu apres %s\n",login,time); return 0; } p2=time; for (i=0;i<4;i++) { if (!isdigit(*p)) { debugf("%s: %s l'heure doit etre sur 4 caracteres\n",login,time); return 0; } *p2++=*p++; } h_max=atoi(time); for (i=0;i<8;i++) if (week_time[i].time_min == 0) { week_time[i].time_min = h_min; week_time[i].time_max = h_max; } } } if (week_time[tm->tm_wday].time_min <= tm->tm_hour * 100 + tm->tm_min && week_time[tm->tm_wday].time_max >= tm->tm_hour * 100 +tm->tm_min) return 0; else return -1; } ------------ and call it from function rad_authenticate in radiusd.c after the comment 'Look for the remaining matching items' ,add : user_msg = (char *) NULL; check_item=checklist; result=rad_check_time(authName->strvalue); if (result == -1) user_msg="Connexion refused blah blah blah..."; ------------- The ascii file with login you want check is like this: # # login hours for certain users: # structure: #login day1-day2time1:time2... #login day1day2...time1:time2... #login #the days are Sunday: su # Monday: mo # Tuesday: tu # Wedsday: we # Thursday: th # Friday: fr # Saturday: sa # #times must be four digit long # terdis mo-sa0900:1930 mammouth mo-sa0900:2230 inter mo-sa0900:2000 --------- Good luck, hope it helps! -- Olivier PRENANT Tel: +33-5-61-50-97-00 (Work) Quartier d'Harraud Turrou +33-5-61-50-97-01 (Fax) 31190 AUTERIVE +33-6-07-63-80-64 (GSM) FRANCE Email: ohp@pyrenet.fr ------------------------------------------------------------------------------ Make your life a dream, make your dream a reality. (St Exupery) ++ Ascend Users Mailing List ++ To unsubscribe: send unsubscribe to ascend-users-request@bungi.com To get FAQ'd: <<A HREF="http://www.nealis.net/ascend/faq">http://www.nealis.net/ascend/faq</A>> -- Oliver J. Albrecht <olli@allcon.net> AllCon GmbH Lise Meitner Str. 2 D-24941 Flensburg EMail: allcon@allcon.net Tel: +49 461 9992-162 Fax: -165 ++ Ascend Users Mailing List ++ To unsubscribe: send unsubscribe to ascend-users-request@bungi.com To get FAQ'd: <<A HREF="http://www.nealis.net/ascend/faq">http://www.nealis.net/ascend/faq</A>> </PRE> <!--X-MsgBody-End--> <!--X-Follow-Ups--> <!--X-Follow-Ups-End--> <!--X-References--> <HR> <STRONG>References</STRONG>: <UL> <LI><STRONG><A HREF="msg11215.html">(ASCEND) Time of day connectivity</A></STRONG></LI> <UL> <LI><EM>From</EM>: Geoff Dornan <gdornan@atlantic.co.za></LI> </UL> </UL> <!--X-References-End--> <!--X-BotPNI--> <HR> <UL> <LI>Prev by Date: <STRONG><A HREF="msg11216.html">Re: (ASCEND)56K</A></STRONG> </LI> <LI>Next by Date: <STRONG><A HREF="msg11224.html">Re: (ASCEND) AMI to B8ZS conversion?</A></STRONG> </LI> <LI>Prev by thread: <STRONG><A HREF="msg11215.html">(ASCEND) Time of day connectivity</A></STRONG> </LI> <LI>Next by thread: <STRONG><A HREF="msg10290.html">(ASCEND) Quake through a Max 4000</A></STRONG> </LI> <LI>Index(es): <UL> <LI><A HREF="maillist.html#11226"><STRONG>Main</STRONG></A></LI> <LI><A HREF="thrd225.html#11226"><STRONG>Thread</STRONG></A></LI> </UL> </LI> </UL> <!--X-BotPNI-End--> <!--X-User-Footer--> <!--X-User-Footer-End--> </BODY> </HTML>