Patch #: 89 Type: operational change Priority: none Modification: add idle timeout capability to AUFS Submitted: David Hornsby Suggested: Kevin Hobson Suggested: Rakesh Patel Suggested: Chris Chaundy Suggested: RL "Bob" Morgan Archived: munnari.OZ.AU mac/cap.patches/cap60.patch089 Application: 'cd cap60; patch -p < cap60.patches/cap60.patch089' Summary: add -i flag (guests only) and -I flag (everyone) File: cap60/Configure File: cap60/applications/aufs/aufs.c File: cap60/applications/aufs/afpos.c *** Configure.orig Thu Feb 20 21:57:10 1992 --- Configure Thu Feb 20 22:01:08 1992 *************** *** 1,7 **** #!/bin/sh ! # $Author: djh $ $Date: 1992/02/16 10:32:04 $ ! # $Header: /mac/src/cap60/RCS/Configure,v 2.32 1992/02/16 10:32:04 djh Rel djh $ ! # $Revision: 2.32 $ # CAP configuration shell script. This ain't perfect, but it's a start. # Execute with /bin/sh Configure if your system won't run it (ksh is okay too) # --- 1,7 ---- #!/bin/sh ! # $Author: djh $ $Date: 1992/02/20 11:00:58 $ ! # $Header: /mac/src/cap60/RCS/Configure,v 2.33 1992/02/20 11:00:58 djh Rel djh $ ! # $Revision: 2.33 $ # CAP configuration shell script. This ain't perfect, but it's a start. # Execute with /bin/sh Configure if your system won't run it (ksh is okay too) # *************** *** 569,574 **** --- 569,577 ---- # # + ULT42PFBUG unpatched ULTRIX 4.2 packet filter workaround (also need COPYALL) # define(`specialcflags',concat(specialcflags,` -DULT42PFBUG')) + # + # + AUFS_IDLE_TIMEOUT will disconnect idle AUFS sessions (-[i|I] period) + # define(`specialcflags',concat(specialcflags,` -DAUFS_IDLE_TIMEOUT')) # # # *** applications/aufs/aufs.c.orig Mon Feb 17 21:16:04 1992 --- applications/aufs/aufs.c Thu Feb 20 21:31:21 1992 *************** *** 1,7 **** /* ! * $Author: djh $ $Date: 1992/02/17 10:15:54 $ ! * $Header: /mac/src/cap60/applications/aufs/RCS/aufs.c,v 2.9 1992/02/17 10:15:54 djh Rel djh $ ! * $Revision: 2.9 $ */ /* --- 1,7 ---- /* ! * $Author: djh $ $Date: 1992/02/20 10:31:11 $ ! * $Header: /mac/src/cap60/applications/aufs/RCS/aufs.c,v 2.10 1992/02/20 10:31:11 djh Rel djh $ ! * $Revision: 2.10 $ */ /* *************** *** 96,101 **** --- 96,106 ---- export char *aufsreadme; /* path of readme file */ export char *aufsreadmename; /* pointer into aufsreadme with just name */ #endif AUFS_README + #ifdef AUFS_IDLE_TIMEOUT + private int idletime = 0; /* allowable no traffic period */ + private int timeidle = 0; /* have been idle for this time */ + private int guestonly = 1; /* default to guest idle timeouts only */ + #endif AUFS_IDLE_TIMEOUT private int maxsess = 10; private EntityName srvr_entity_name; /* our entity name */ *************** *** 179,184 **** --- 184,192 ---- #ifdef AUFS_README fprintf(stderr,"[-r readme_path] "); #endif AUFS_README + #ifdef AUFS_IDLE_TIMEOUT + fprintf(stderr,"[-[i|I] idle_timeout] "); + #endif AUFS_IDLE_TIMEOUT fprintf(stderr,"[-u] "); fprintf(stderr,"\n\t-d for CAP debugging flags:\n"); fprintf(stderr,"\t l = lap, d = ddp, a = atp, n = nbp, p = pap,"); *************** *** 252,257 **** --- 260,268 ---- #ifdef AUFS_README strcat(optlist, "r:"); #endif AUFS_README + #ifdef AUFS_IDLE_TIMEOUT + strcat(optlist, "i:I:"); + #endif AUFS_IDLE_TIMEOUT while ((c = getopt(argc,argv,optlist)) != EOF) { switch (c) { case 'z': *************** *** 345,350 **** --- 356,369 ---- aufsreadmename = (char *)rindex(aufsreadme, '/') + 1; break; #endif AUFS_README + #ifdef AUFS_IDLE_TIMEOUT + case 'I': /* also users */ + guestonly = 0; + /* fall thro' */ + case 'i': /* guests only */ + idletime = atoi(optarg) * 6; + break; + #endif AUFS_IDLE_TIMEOUT default: usage(argv[0]); break; *************** *** 483,488 **** --- 502,512 ---- readAppList(enforcelist); } #endif APPLICATION_MANAGER + #ifdef AUFS_IDLE_TIMEOUT + if (idletime) + logit(0, "Idle timeout set to %d minutes for %s sessions", + idletime/6, (guestonly) ? "guest" : "all"); + #endif AUFS_IDLE_TIMEOUT ctp_stack_cnt = 0; { int i; for (i = 0 ; i < maxsess; i++) { *************** *** 746,752 **** for (;;) { #ifndef TREL_TIMEOUT SPGetRequest(cno,buf,mcs,&reqref,&type,&rlen,&comp); ! while (comp > 0) { abSleep(sectotick(60),TRUE); } if (comp == SessClosed || comp == ParamErr) { #else TREL_TIMEOUT if (comp1 > 0 && comp2 > 0) { --- 770,782 ---- for (;;) { #ifndef TREL_TIMEOUT SPGetRequest(cno,buf,mcs,&reqref,&type,&rlen,&comp); ! while (comp > 0) { ! abSleep(sectotick(60),TRUE); ! #ifdef AUFS_IDLE_TIMEOUT ! if (idletime) ! (void) checkIdle(cno,buf,comp); ! #endif AUFS_IDLE_TIMEOUT ! } if (comp == SessClosed || comp == ParamErr) { #else TREL_TIMEOUT if (comp1 > 0 && comp2 > 0) { *************** *** 759,765 **** if (comp1 <= 0) { SPGetRequest(cno,buf1,mcs,&reqref1,&type1,&rlen1,&comp1); ! while (comp1 > 0) { abSleep(sectotick(60),TRUE); } if (comp1 == SessClosed || comp1 == ParamErr) { #endif TREL_TIMEOUT logit(0,"Session (%d) closed",cno); --- 789,801 ---- if (comp1 <= 0) { SPGetRequest(cno,buf1,mcs,&reqref1,&type1,&rlen1,&comp1); ! while (comp1 > 0) { ! abSleep(sectotick(60),TRUE); ! #ifdef AUFS_IDLE_TIMEOUT ! if (idletime) ! (void) checkIdle(cno,buf1,comp1); ! #endif AUFS_IDLE_TIMEOUT ! } if (comp1 == SessClosed || comp1 == ParamErr) { #endif TREL_TIMEOUT logit(0,"Session (%d) closed",cno); *************** *** 822,828 **** else #ifndef TREL_TIMEOUT SPCmdReply(cno,reqref,(dword) err,rspbuf,rsplen,&comp); ! while (comp > 0) { abSleep(sectotick(60),TRUE); } if (DBSRV) printf("done\n"); #else TREL_TIMEOUT --- 858,866 ---- else #ifndef TREL_TIMEOUT SPCmdReply(cno,reqref,(dword) err,rspbuf,rsplen,&comp); ! while (comp > 0) { ! abSleep(sectotick(60),TRUE); ! } if (DBSRV) printf("done\n"); #else TREL_TIMEOUT *************** *** 867,873 **** #ifdef TREL_TIMEOUT } else { /* comp2 */ SPGetRequest(cno,buf2,mcs,&reqref2,&type2,&rlen2,&comp2); ! while (comp2 > 0) { abSleep(sectotick(60),TRUE); } if (comp2 == SessClosed || comp2 == ParamErr) { logit(0,"Session (%d) closed",cno); #ifdef LWSRV_AUFS_SECURITY --- 905,917 ---- #ifdef TREL_TIMEOUT } else { /* comp2 */ SPGetRequest(cno,buf2,mcs,&reqref2,&type2,&rlen2,&comp2); ! while (comp2 > 0) { ! abSleep(sectotick(60),TRUE); ! #ifdef AUFS_IDLE_TIMEOUT ! if (idletime) ! (void) checkIdle(cno,buf2,comp2); ! #endif AUFS_IDLE_TIMEOUT ! } if (comp2 == SessClosed || comp2 == ParamErr) { logit(0,"Session (%d) closed",cno); #ifdef LWSRV_AUFS_SECURITY *************** *** 1457,1459 **** --- 1501,1577 ---- return; } #endif APPLICATION_MANAGER + #ifdef AUFS_IDLE_TIMEOUT + /* + * If an idle time is set ('-i' for guests, '-I' for everyone) then + * check for number of minutes of no AFP activity. Give warnings + * at 5, 3 & 1 minute marks. If anything happens then we reset the + * timer and notify user that shutdown is aborted. + * + * djh@munnari.OZ.AU + * February, 1992 + * + */ + int + checkIdle(cno, buf, cmp) + int cno, cmp; + unsigned char *buf; + { + int i, comp; + extern int guestlogin; + static int sentshutdown = 0; + + if (guestonly && !guestlogin) + return; + + if (cmp == 0 && *buf != 17) { /* periodic GetVolParms AFP call */ + if (sentshutdown) { + logit(0, "Session %d: Aborting Idle Timeout", cno); + SPAttention(cno, AFPSHUTDOWNCANCEL, 1, -1, &comp); + while (comp > 0) { abSleep(30, TRUE); } /* ignore error */ + sentshutdown = 0; + } + timeidle = 0; + return; + } + + switch (cmp) { + case 0: /* noErr */ + timeidle++; + break; + case 1: /* abSleep() timeout */ + if (!sentshutdown) return; + timeidle += 6; + break; + default: /* some error */ + return; + break; + } + + if (timeidle < idletime) + return; + + switch ((i = timeidle-idletime)) { + case 0: /* shutdown in 5 min */ + case 12: /* shutdown in 3 min */ + case 24: /* shutdown in 1 min */ + logit(0, "Session %d: sending %d minute idle timeout warning",cno,5-i/6); + SPAttention(cno, AFPSHUTDOWNTIME(5-i/6), 1, -1, &comp); + while (comp > 0) { abSleep(30, TRUE); } /* ignore error */ + sentshutdown++; + return; + break; + case 30: /* shutdown now */ + logit(0, "Session %d: Idle Timeout Shutdown", cno); + SPAttention(cno, AFPSHUTDOWNNOW, 1, -1, &comp); + while (comp > 0) { abSleep(30, TRUE); } /* ignore error */ + SPCloseSession(cno, 3, 2, &comp); /* 3 times, .5 seconds */ + while (comp > 0) { abSleep(30, TRUE); } /* close down if we can */ + #ifdef LWSRV_AUFS_SECURITY + clearuserlogin(); /* gtw: delete auth-file entry for dead users */ + #endif LWSRV_AUFS_SECURITY + exit(0); + break; + } + } + #endif AUFS_IDLE_TIMEOUT *** applications/aufs/afpos.c.orig Mon Feb 17 21:16:58 1992 --- applications/aufs/afpos.c Thu Feb 20 21:32:53 1992 *************** *** 1,7 **** /* ! * $Author: djh $ $Date: 1992/02/17 10:16:43 $ ! * $Header: /mac/src/cap60/applications/aufs/RCS/afpos.c,v 2.20 1992/02/17 10:16:43 djh Rel djh $ ! * $Revision: 2.20 $ */ /* --- 1,7 ---- /* ! * $Author: djh $ $Date: 1992/02/20 10:32:42 $ ! * $Header: /mac/src/cap60/applications/aufs/RCS/afpos.c,v 2.21 1992/02/20 10:32:42 djh Rel djh $ ! * $Revision: 2.21 $ */ /* *************** *** 324,329 **** --- 324,330 ---- export sdword CurTime(); /* current time in internal form */ export char *tilde(); /* tilde expansion */ export char *logdir(); /* user login directory */ + export int guestlogin; /* session is a guest login */ private OSErr unix_rmdir(); private OSErr unix_unlink(); private OSErr unix_rename(); *************** *** 3070,3075 **** --- 3071,3078 ---- *tempbin='\0'; #endif LWSRV_AUFS_SECURITY + guestlogin = 0; + switch (uam) { case UAM_RANDNUM: if (!apasswdfile) *************** *** 3118,3123 **** --- 3121,3127 ---- usruid = p->pw_uid; usrnam = (char *) malloc(strlen(guestname)+1); strcpy(usrnam,guestname); + guestlogin = 1; usrdir = NULL; break; case UAM_CLEAR: *** README.orig Thu Feb 20 21:33:23 1992 --- README Thu Feb 20 21:33:47 1992 *************** *** 3,9 **** (For use with AppleTalk/Ethernet bridge) o RELEASE NOTES ! o CAP Distribution 6.0, Patch Level 88, February 1992 Introduction ------------ --- 3,9 ---- (For use with AppleTalk/Ethernet bridge) o RELEASE NOTES ! o CAP Distribution 6.0, Patch Level 89, February 1992 Introduction ------------