summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorkcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-03-14 04:19:23 +0800
committerkcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-03-14 04:19:23 +0800
commit2c8f74d4a35c2b10579320ef6b4723597d642179 (patch)
tree273819d875205c25f23ecc26a8c4324c18d0eb7f /util
parent5f68d7e1a724af13aa4ead16da72bc91bd564e4d (diff)
downloadpttbbs-2c8f74d4a35c2b10579320ef6b4723597d642179.tar
pttbbs-2c8f74d4a35c2b10579320ef6b4723597d642179.tar.gz
pttbbs-2c8f74d4a35c2b10579320ef6b4723597d642179.tar.bz2
pttbbs-2c8f74d4a35c2b10579320ef6b4723597d642179.tar.lz
pttbbs-2c8f74d4a35c2b10579320ef6b4723597d642179.tar.xz
pttbbs-2c8f74d4a35c2b10579320ef6b4723597d642179.tar.zst
pttbbs-2c8f74d4a35c2b10579320ef6b4723597d642179.zip
kick guest who idle more then 15 minutes
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2621 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'util')
-rw-r--r--util/shmctl.c33
1 files changed, 16 insertions, 17 deletions
diff --git a/util/shmctl.c b/util/shmctl.c
index 0bd7e01a..fefa3e63 100644
--- a/util/shmctl.c
+++ b/util/shmctl.c
@@ -69,7 +69,7 @@ int utmpfix(int argc, char **argv)
char *clean, buf[1024];
IDLE_t idle[USHM_SIZE];
char changeflag = 0;
- time_t timeout = -1;
+ time_t idletimeout = IDLE_TIMEOUT;
int lowerbound = 100, upperbound = 0;
char ch;
@@ -85,7 +85,7 @@ int utmpfix(int argc, char **argv)
fast = 1;
break;
case 't':
- timeout = atoi(optarg);
+ idletimeout = atoi(optarg);
break;
case 'l':
lowerbound = atoi(optarg);
@@ -205,21 +205,20 @@ int utmpfix(int argc, char **argv)
purge_utmp(&SHM->uinfo[which]);
}
#ifdef DOTIMEOUT
- else if( !fast ){
- if( nownum > lowerbound &&
- idle[i].idle >
- (timeout == -1 ? IDLE_TIMEOUT : timeout) ){
- sprintf(buf, "timeout(%s",
- ctime4(&SHM->uinfo[which].lastact));
- buf[strlen(buf) - 1] = 0;
- strcat(buf, ")");
- clean = buf;
- addkilllist(which);
- purge_utmp(&SHM->uinfo[which]);
- printf("%s\n", buf);
- --nownum;
- continue;
- }
+ else if( (strcasecmp(SHM->uinfo[which].userid, STR_GUEST)==0 &&
+ idle[i].idle > 60*15) ||
+ (!fast && nownum > lowerbound &&
+ idle[i].idle > idletimeout ) ) {
+ sprintf(buf, "timeout(%s",
+ ctime4(&SHM->uinfo[which].lastact));
+ buf[strlen(buf) - 1] = 0;
+ strcat(buf, ")");
+ clean = buf;
+ addkilllist(which);
+ purge_utmp(&SHM->uinfo[which]);
+ printf("%s\n", buf);
+ --nownum;
+ continue;
}
#endif