OSDN Git Service

Ver.1.5.32 fixed error to ignore duration in extra set
authorwatanaby <watanaby@users.sourgeforge.net>
Thu, 11 Jul 2013 07:18:49 +0000 (16:18 +0900)
committerwatanaby <watanaby@users.sourgeforge.net>
Thu, 11 Jul 2013 07:18:49 +0000 (16:18 +0900)
opengate/doc/Changes.html
opengate/opengatesrv/Makefile
opengate/opengatesrv/comm-cgi.c
opengate/opengatesrv/main.c
opengate/opengatesrv/opengatesrv.h

index 8cf10b0..6918805 100644 (file)
@@ -766,6 +766,11 @@ Opengate History</H3>
        </DT><DD>
        Modified code for authentication recheck when extraset exists.
        </DD>
+       <DT>
+       Ver.1.5.32 at 2013.7.11
+       </DT><DD>
+       Fixed error to ingore duration value in extra set.
+       </DD>
        </DL>
 <P>
 <B>Please see CVS on SourceForge.net to check the differences between
index 48f3a2a..6a49302 100644 (file)
@@ -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}
 
index 2f43970..79ae81c 100644 (file)
@@ -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;
+}
index 28fd865..26eeaa2 100644 (file)
@@ -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();
 
index 4329099..74ca3e8 100644 (file)
@@ -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);