OSDN Git Service

Ver.1.5.2: fixed mulfunctions by remained cookie and null http_host.
authorwatanaby <>
Sun, 4 Oct 2009 07:26:03 +0000 (07:26 +0000)
committerwatanaby <>
Sun, 4 Oct 2009 07:26:03 +0000 (07:26 +0000)
12 files changed:
opengate/conf/opengatesrv.conf.sample
opengate/doc/Changes.html
opengate/javahtml/en/httpkeep.html
opengate/javahtml/en/index-ssl.html
opengate/javahtml/en/index.html
opengate/javahtml/httpkeep.js
opengate/javahtml/ja/httpkeep.html
opengate/opengatesrv/comm-cgi.c
opengate/opengatesrv/main.c
opengate/opengatesrv/opengateauth.c
opengate/opengatesrv/opengatesrv.h
opengate/opengatesrv/watch-client.c

index d48c861..5706158 100644 (file)
        <HttpKeepJS>httpkeep.js</HttpKeepJS>
        <Md5JS>md5.js</Md5JS>
 
-       <!-- URL used to retry -->
+       <!-- URL used for retrying -->
        <ExternalUrl>http://www.google.com/</ExternalUrl>
 
        <!-- Url to start browsing after authentication -->
                <Url>http://www.yahoo.com/</Url>
        </StartPage>
 
+       <!-- authentication by http-cookie is allowed(1) or not(0) --> 
+       <EnableCookieAuth>1</EnableCookieAuth>
+
        <!-- Related command path -->
        <ArpPath>/usr/sbin/arp</ArpPath>
        <NdpPath>/usr/sbin/ndp</NdpPath>
index 983ae54..de64814 100644 (file)
@@ -637,6 +637,10 @@ Opengate History</H3>
        Ver.1.5.1 at 2009.9.15
        </DT><DD>
         Modified english document. Removed disabled item in conf file.
+       </DD><DT>
+       Ver.1.5.2 at 2009.10.4
+       </DT><DD>
+        Fixed mulfunctions by remained cookie and null http_host.
        </DD>
        </DL>
 <P>
index ccc8a82..5ddfc22 100644 (file)
@@ -66,8 +66,7 @@ Or, minimize this page and load other network programs.</p>
 
 
 <p>If [Error!] is shown between above two lines or 
-other malfunction has occured, 
-please access the network from your home page or another (external) site.  
+other malfunction has occured, please use another page.  
 Should your browser display any abnormal behavior, 
 please close it and try again. 
 If you enter a value in duration field of authentication page, 
@@ -77,7 +76,7 @@ the network can be used for that duration of time.</p>
 //<!--
   window.open("%%STARTURL%%","window1");
 
-  initHttpkeep("%%HTTPHELLOURL%%","%%SESSIONID%%");
+  initHttpkeep("%%HTTPHELLOURL%%","%%SESSIONID%%","%%COOKIENAME%%");
 //-->
 </script>
 
index 7c9f87e..da5449f 100644 (file)
@@ -62,7 +62,7 @@ when you want to stop using the network.
 
 </center>
 
-<p><font size=+1>If you have some questions, 
+<p><font size=+1>If you have any questions, 
 please contact the network administrator.
 
 <div align=right>Saga University</div>
index 8b61398..449981a 100644 (file)
@@ -63,7 +63,7 @@ when you want to stop using the network.
 
 </center>
 
-<p><font size=+1>If you have some questions, 
+<p><font size=+1>If you have any questions, 
 please contact network administrator.
 
 <div align=right>Saga University</div>
@@ -74,10 +74,3 @@ please contact network administrator.
 </HTML>
 
 
-
-
-
-
-
-
-
index 57e75bb..8db858c 100644 (file)
@@ -5,6 +5,8 @@ var httpObj;
 var nextKey;
 var nowKey;
 var sessionId;
+var keepConnect;
+var cookieName;
 
 function createXMLHttpRequest() {
   try { return new ActiveXObject("Msxml2.XMLHTTP");    } catch(e) {}
@@ -26,12 +28,11 @@ function sendHello(){
       rand=Math.random();
       nextKey=hex_md5(String(rand));
     }catch(e){
-      document.getElementById("watchdog").innerHTML = "Error!:1";
+       showError();
     }
   }
-
   else{
-    document.getElementById("watchdog").innerHTML = "Error!:2";
+      showError();
   }
 }
 
@@ -46,28 +47,48 @@ function displayResponse()
         document.getElementById("dispmsg").innerHTML = hh+':'+mm;
         if(httpObj.responseText=="hello") sendHello();
       }else{
-        document.getElementById("dispmsg").innerHTML = "Error!:3";
+         showError();
       }
     }
   }catch(e){
-    document.getElementById("watchdog").innerHTML = "Error!:4";
+      showError();
+  }
+}
+
+function showError(){
+      document.getElementById("watchdog").innerHTML = "Error!, Close This page";
+      document.getElementById("watchdog").style.backgroundColor = "pink";
+      document.title = "Useless Page";
+      keepConnect=false;
+}
+
+function clearCookie(){
+  if(keepConnect){
+    document.cookie = cookieName+"=;";
   }
 }
 
 function endHttpkeep(){
+
+  //clear cookie
+  clearCookie(); 
+
   if(httpObj!=null){
     httpObj.abort();
   }
 }
 
-function initHttpkeep(urlArg, sid)
+function initHttpkeep(urlArg, sid, ckName)
 {
+
   // save arguments
   httpkeepUrl=urlArg;
   nowKey=hex_md5(sid);
+  cookieName=ckName;
   sessionId=sid;
   rand=Math.random();
   nextKey=hex_md5(String(rand));
+  keepConnect=true;
 
   // set timeout and send hello 
   sendHello();
index cf5ebce..9c27415 100644 (file)
@@ -65,7 +65,7 @@ Web\e$B$NMxMQ$K$O2<$N%\%?%s$r2!$7$FI=<($5$l$kJL%&%$%s%I%&$r;H$C$F$/$@$5$$!#\e(B
 </p>
 <hr />
 
-<p>\e$B>e$N\e(B2\e$BK\$N@~$N4V$K\e(B[Error!]\e$B$,I=<($5$l$k$H$-$d$=$NB>$NIT6q9g$,$"$k;~$O!"%[!<%`$d$=$NB>$N%5%$%H$+$i%"%/%;%9$7$J$*$7$F$/$@$5$$!#$=$l$G$b2~A1$7$J$$>l9g$O%V%i%&%6$r=*N;$7$F$+$i:F;n9T$7$F$/$@$5$$!#$^$?G'>Z2hLL$NMxMQ;~4V%U%#!<%k%I$KCM$r$$$l$k$H!"$=$N;~4V$@$1;HMQ$9$k$3$H$,$G$-$^$9!#\e(B
+<p>\e$B>e$N\e(B2\e$BK\$N@~$N4V$K\e(B[Error!]\e$B$,I=<($5$l$?$H$-$O!"JL$N%Z!<%8$rMxMQ$7$F$/$@$5$$!#F0:n$,$*$+$7$$;~$O%V%i%&%6$r=*N;$7$F$+$i:F;n9T$7$F$/$@$5$$!#$^$?G'>Z2hLL$NMxMQ;~4V%U%#!<%k%I$KCM$r$$$l$k$H!"$=$N;~4V$@$1;HMQ$9$k$3$H$,$G$-$^$9!#\e(B
 </p>
 
 
@@ -73,7 +73,7 @@ Web\e$B$NMxMQ$K$O2<$N%\%?%s$r2!$7$FI=<($5$l$kJL%&%$%s%I%&$r;H$C$F$/$@$5$$!#\e(B
 //<!--
   window.open("%%STARTURL%%","window1");
 
-  initHttpkeep("%%HTTPHELLOURL%%","%%SESSIONID%%");
+  initHttpkeep("%%HTTPHELLOURL%%","%%SESSIONID%%","%%COOKIENAME%%");
 //-->
 </script>
 
index 9b14c9b..a5a42e1 100644 (file)
@@ -240,7 +240,7 @@ int getAuthCookie(char *cookie, char *userid){
   while(ptr!=NULL){
     split(ptr, name, value, next);
 
-    if(strstr(name[0], "OpengateAuth")!=NULL){
+    if(strstr(name[0], COOKIENAME)!=NULL){
       strncpy(cookie, value[0], SIDMAXLN);
     }else if(strstr(name[0], "Userid")!=NULL){
       strncpy(userid, value[0], USERMAXLN);
@@ -368,6 +368,7 @@ void putClientMsg(char *message)
 
 /*********************************************/
 /* put accept message and javascript to the client */
+/*  httpkeep page is sent in watch-client.c */
 /*********************************************/
 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)
 {
@@ -380,10 +381,10 @@ void putClientAccept(char *userid, char *sessionId, int port, int pid, char *cli
   char httpkeepUrl[BUFFMAXLN];
   char portStr[WORDMAXLN];
   char durationStr[WORDMAXLN];
+  char *startPageUrl="";
   char *pAcceptDoc;
   char *opengateDir=GetConfValue("OpengateDir");
   char *opengateServerName=GetConfValue("OpengateServerName");
-  char *startPageUrl="";
   int startPageType=atoi(GetConfValue("StartPage/Type"));
 
   /* select proper accept doc */
@@ -440,6 +441,12 @@ void putClientAccept(char *userid, char *sessionId, int port, int pid, char *cli
     return;
   }
 
+  /* if redirect page is not set, use other setting */
+  if(isNull(redirectedUrl)){
+    if(isNull(GetConfValue("StartPage/Url"))) redirectedUrl=acceptDoc2Url;
+    else  redirectedUrl=GetConfValue("StartPage/Url");
+  }
+
   /* create start page url to put information */
   if(cookieAuth==1) startPageUrl=redirectedUrl;
   else if(startPageType==0) startPageUrl=acceptDoc2Url;
@@ -449,16 +456,16 @@ void putClientAccept(char *userid, char *sessionId, int port, int pid, char *cli
 
   /* write out html headers */
   printf("Content-type: text/html\r\n");
-  printf("Set-Cookie: OpengateAuth=%s&Userid=%s;\r\n\r\n", cookie, userid);
-
+  printf("Set-Cookie: %s=%s&Userid=%s;path=/;\r\n\r\n", COOKIENAME, cookie, userid);
+  
   /* read html document from file and send to web */
   while(fgets(buff, BUFFMAXLN, fp)!=NULL){
-
+    
     /* length check */
     if(strlen(buff)>=BUFFMAXLN-1){
       err_msg("ERR at %s#%d: too long line in %s",__FILE__,__LINE__,acceptDocPath);
     }
-
+    
     /* replace mark */
     htmlReplace(buff, "%%OPENGATESERVERNAME%%", opengateServerName);
     htmlReplace(buff, "%%OPENGATEDIR%%", opengateDir);
@@ -470,11 +477,11 @@ void putClientAccept(char *userid, char *sessionId, int port, int pid, char *cli
     htmlReplace(buff, "%%TERMINATEURL%%", terminateUrl);
     htmlReplace(buff, "%%HTTPKEEPURL%%", httpkeepUrl);
     htmlReplace(buff, "%%STARTURL%%", startPageUrl);
-
+    
     /* write out */
     printf("%s",buff);
   }
-
+  
   /* write end */
   fputs("\r\n\r\n",stdout);
   fclose(fp);
index 5617592..777a2b5 100644 (file)
@@ -70,7 +70,7 @@ int  main(int argc, char **argv)
   int durationEntered=0; /* the duration value is entered or not */
   int authResult=DENY;
   int authNum=1; /* present authserver number to check user */
-  int cookieAuth=FALSE; /* Auth with HTTP-Cookie is enabled */
+  int cookieAuth=FALSE; /* Auth with HTTP-Cookie is passed */
 
   /* drop root privilege */
   seteuid(getuid());
@@ -104,9 +104,12 @@ int  main(int argc, char **argv)
     return 0;
   }
 
-  /* Try to authentication with cookie data */
-  cookieAuth=GetCookieData(userid, clientAddr4,
+  /* try to authentication with cookie data, */
+  /* if cookie auth is enabled. */
+  if( (*GetConfValue("EnableCookieAuth")!='0') ){
+    cookieAuth=GetCookieData(userid, clientAddr4,
                           &duration,&durationEntered,language);
+  }
 
   /* split user@server to user and server */
   SplitId(userid, useridshort, extraId);
@@ -119,7 +122,7 @@ int  main(int argc, char **argv)
 
   /* check enable IP versions */
   if((ipStatus=CheckIpVersions(clientAddr4, clientAddr6))==0){
-      PutClientMsg("Error: Please contact to the administrator");
+      PutClientMsg("Error: Please contact the administrator(1)");
       return 0;
   }
 
@@ -167,7 +170,7 @@ int  main(int argc, char **argv)
 
   /* set terminate signal handler */
   if(Signal(SIGTERM, closeExit)==SIG_ERR){
-    PutClientMsg("Error: Please contact to the administrator");    
+    PutClientMsg("Error: Please contact the administrator(2)");    
     return 0;
   }
 
@@ -183,7 +186,7 @@ int  main(int argc, char **argv)
   port=GetListenPort();
   if(port<0){
     err_msg("ERR at %s#%d: cannot get unused listen port",__FILE__,__LINE__);
-    PutClientMsg("Error: Please contact to the administrator");
+    PutClientMsg("Error: Please contact the administrator(3)");
     closeExit(1);
   }
 
@@ -192,7 +195,7 @@ int  main(int argc, char **argv)
   /* fork */
   if((pid=Fork())==-1){
     err_msg("ERR at %s#%d: fork error",__FILE__,__LINE__);
-    PutClientMsg("Error: Please contact to the administrator");
+    PutClientMsg("Error: Please contact the administrator(4)");
     closeExit(1);
   }
 
index 9f0d091..d00a143 100644 (file)
@@ -149,8 +149,10 @@ int  main(int argc, char **argv)
          opengateDir, lang);
 
   /*** if http-cookie for opengate authentication exist */
+  /* and cookie auth is enabled, */
   /* skip authenticaion */
-  if(GetAuthCookie(cookie,userid)){
+  if( (*GetConfValue("EnableCookieAuth")!='0')
+     && GetAuthCookie(cookie,userid)){
     strncat(htmlFile, GetConfValue("SkipAuthDoc"), BUFFMAXLN);
 
     /* ssl or non-ssl protocol  */
@@ -162,7 +164,7 @@ int  main(int argc, char **argv)
     }
   }
   
-  /*** if cookie does not exist, request userid and password */
+  /*** otherwise, request userid and password */
   else{
     /* ssl or non-ssl file */
     if(!isNull(getenv("SERVER_PORT"))
index 6dd618d..a3fe745 100644 (file)
@@ -72,6 +72,8 @@ typedef       void    Sigfunc(int);   /* for signal handlers */
 #define PAMSERVICENAME "opengate"    /* default service name used in PAM */
 #define RADIUSCONF  "/etc/radius.conf" /* default path to radius.conf */
 
+#define COOKIENAME "OpengateAuth"  /* http-cookie name */
+
 #define ADDRMAXLN 128      /* maximum address string length */
 #define PASSMAXLN 128      /* maximum password string length */
 #define USERMAXLN 64       /* maximum userid string length */
index 0ebdfc6..c67ddfb 100644 (file)
@@ -795,6 +795,12 @@ void sendHttpKeepPage(char *userid, char *sessionId, char *language, int port, i
     return;
   }
 
+  /* if redirect page is not set, use other setting */
+  if(isNull(redirectedUrl)){
+    if(isNull(GetConfValue("StartPage/Url"))) redirectedUrl=acceptDoc2Url;
+    else  redirectedUrl=GetConfValue("StartPage/Url");
+  }
+
   /* create start page url to put information */
   if(cookieAuth==1) startPageUrl=redirectedUrl;
   else if(startPageType==0) startPageUrl=acceptDoc2Url;
@@ -831,6 +837,7 @@ void sendHttpKeepPage(char *userid, char *sessionId, char *language, int port, i
     htmlReplace(buff, "%%OPENGATEPORT%%", portStr);
     htmlReplace(buff, "%%LANGUAGE%%", language);
     htmlReplace(buff, "%%STARTURL%%", startPageUrl);
+    htmlReplace(buff, "%%COOKIENAME%%", COOKIENAME);
 
     /* length of chunk in hex */
     Writefmt(connfd, "%x\r\n", strlen(buff));