From: watanaby Date: Thu, 11 Jul 2013 07:18:49 +0000 (+0900) Subject: Ver.1.5.32 fixed error to ignore duration in extra set X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=5b00554607b8f9d2d0b5ec53925348a5def28fea;p=opengate%2Fopengate.git Ver.1.5.32 fixed error to ignore duration in extra set --- diff --git a/opengate/doc/Changes.html b/opengate/doc/Changes.html index 8cf10b0..6918805 100644 --- a/opengate/doc/Changes.html +++ b/opengate/doc/Changes.html @@ -766,6 +766,11 @@ Opengate History
Modified code for authentication recheck when extraset exists.
+
+ Ver.1.5.32 at 2013.7.11 +
+ Fixed error to ingore duration value in extra set. +

Please see CVS on SourceForge.net to check the differences between diff --git a/opengate/opengatesrv/Makefile b/opengate/opengatesrv/Makefile index 48f3a2a..6a49302 100644 --- a/opengate/opengatesrv/Makefile +++ b/opengate/opengatesrv/Makefile @@ -38,7 +38,7 @@ FWDPROG = opengatefwd LIBOPT = ezxml TESTPROGS = test-get-param test-comm-auth test-comm-ipfw test-watch-client test-cgi test-comm-userdb -CLEANFILES = *.o *~ *.core +CLEANFILES = *.o *~ *.core all: ${MAINPROG} ${AUTHPROG} ${FWDPROG} ${TESTPROGS} ${LIBOPT} diff --git a/opengate/opengatesrv/comm-cgi.c b/opengate/opengatesrv/comm-cgi.c index 2f43970..79ae81c 100644 --- a/opengate/opengatesrv/comm-cgi.c +++ b/opengate/opengatesrv/comm-cgi.c @@ -148,17 +148,9 @@ int getPostData(char *userid, char *password, char *clientAddr4, int *durationPt /* convert duration string to interger and minutes to seconds */ *durationPtr = atoi(durationStr)*60; - *durationEntered = TRUE; - - /* usage duration is restricted to permitted range */ - if(*durationPtr <= 0){ - *durationEntered = FALSE; - *durationPtr= atoi(GetConfValue("Duration/Default")); - }else{ - int durmax=atoi(GetConfValue("Duration/Max")); - if(*durationPtr > durmax) *durationPtr=durmax; - } - + if(*durationPtr > 0) *durationEntered = TRUE; + else *durationEntered = FALSE; + /* encoded address starting as "0-0-0" means no addr info */ /* it indicates needless to get dual stack addresses */ /* and only use getenv("REMOTE_ADDR") address */ @@ -490,12 +482,12 @@ void putClientAccept(char *userid, char *sessionId, int port, int pid, char *cli break; } - /* split id to display short format of userid */ - SplitId(userid, useridshort, extraId); - /* if positive value is set in duration, TIME watch mode is selected */ if(durationEntered) pAcceptDoc=GetConfValue("AcceptDocTime"); + /* split id to display short format of userid */ + SplitId(userid, useridshort, extraId); + /* create path to acceptdoc */ snprintf(acceptDocPath, BUFFMAXLN, "%s%s/%s/%s",GetConfValue("DocumentRoot"), GetConfValue("OpengateDir"),language,pAcceptDoc); @@ -519,7 +511,8 @@ void putClientAccept(char *userid, char *sessionId, int port, int pid, char *cli snprintf(portStr, WORDMAXLN, "%d", port); /* create duration string (duration=sec, display value=min) */ - snprintf(durationStr, WORDMAXLN, "%d", duration/60); + if(duration<60) snprintf(durationStr, WORDMAXLN, "%.2f", duration/60.); + else snprintf(durationStr, WORDMAXLN, "%d", duration/60); /* open acceptdoc */ if((fp=fopen(acceptDocPath, "r"))==NULL){ @@ -669,6 +662,21 @@ int checkReferer(void) return TRUE; } +/***************************************************/ +/* trim duration value between zero to max in conf */ +/***************************************************/ +int trimDuration(int duration, int durationEntered){ + + /* if no entry, set default. if huge value, set upper-limit */ + if(!durationEntered){ + duration = atoi(GetConfValue("Duration/Default")); + }else{ + int durmax=atoi(GetConfValue("Duration/Max")); + if(duration > durmax) duration=durmax; + } + return duration; +} + /*******************************/ /*******************************/ void GetClientAddr(char *clientAddr) @@ -753,3 +761,13 @@ int GetCookieData(char *userid, char *clientAddr4, int *duration, int *durationE if(debug>1) err_msg("DEBUG:%d<=getCookieData(%s,passwd,%s,%d,%d,%s,%s)",ret,userid,clientAddr4,*duration,*durationEntered,language,closeTime); return ret; } + +int TrimDuration(int duration, int durationEntered){ + int ret; + + if(debug>1) err_msg("DEBUG:=>trimDuration(%d,%d)", + duration,durationEntered); + ret=trimDuration(duration,durationEntered); + if(debug>1) err_msg("DEBUG:%d<=trimDuration( )",ret); + return ret; +} diff --git a/opengate/opengatesrv/main.c b/opengate/opengatesrv/main.c index 28fd865..26eeaa2 100644 --- a/opengate/opengatesrv/main.c +++ b/opengate/opengatesrv/main.c @@ -135,6 +135,9 @@ int main(int argc, char **argv) /* setup pointer to ExtraSet in config file */ SetupConfExtra(useridshort, extraId); + /* trim duration values between zero to max value in conf */ + duration = TrimDuration(duration, durationEntered); + /* setup static variable value for SqLite3_busy_timeout from conf */ SetupSqliteBusyTimeoutValue(); diff --git a/opengate/opengatesrv/opengatesrv.h b/opengate/opengatesrv/opengatesrv.h index 4329099..74ca3e8 100644 --- a/opengate/opengatesrv/opengatesrv.h +++ b/opengate/opengatesrv/opengatesrv.h @@ -155,6 +155,7 @@ void PutClientMsg(char *message); void PutClientAccept(char *userid, char *sessionId, int port, int pid, char *clientAddr4, char *clientAddr6, int ipStatus, int duration, int durationEntered, char *language, char *cookie, int cookieAuth, char *redirectedUrl); void split(char content[], char *name[], char *value[], char *next[]); int GetUserIdFromEnv(char *userid); +int TrimDuration(int duration, int durationEntered); /* comm-userdb.c */ int SetupSqliteBusyTimeoutValue(void);