• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javaandroidc++linuxc#objective-c誰得cocoaqtpythonrubywindowsphpgameguibathyscaphec翻訳omegat計画中(planning stage)frameworktwitterdombtronvb.nettestarduinodirectxpreviewerゲームエンジン

OpengateM Source Repository


Commit MetaInfo

Revisão58e834ab25ec26ee89066574c5b82c46d2546179 (tree)
Hora2016-06-26 11:31:34
Autorwatanaby <watanaby@user...>
Commiterwatanaby

Mensagem de Log

removed flag for log option

Mudança Sumário

Diff

--- a/conf/opengatemd.conf.sample
+++ b/conf/opengatemd.conf.sample
@@ -92,9 +92,6 @@
9292 <!-- SQLite busy timeout (milli-seconds) -->
9393 <SqliteBusyTimeout>100</SqliteBusyTimeout>
9494
95- <!-- Save Log of session to Management DB (1:YES/0:NO) -->
96- <SaveLogToMngDb>1</SaveLogToMngDb>
97-
9895 <!-- SQLite database file -->
9996 <!-- for opengatemd work -->
10097 <SqliteDbMd>/tmp/opengatemd.db</SqliteDbMd>
--- a/conf/opengatemmng.conf.sample
+++ b/conf/opengatemmng.conf.sample
@@ -23,16 +23,17 @@
2323 <Device>fxp0</Device>
2424
2525 <!-- ### MUST BE MODIFIED ## -->
26- <!-- auth server setting for administrators(watanaby,admin1,admin2) -->
26+ <!-- auth server setting for Aadministrators(user1 user2) -->
2727 <AuthServer>
2828 <UserType>admin</UserType>
2929 <Protocol>pop3s</Protocol>
3030 <Address>192.168.0.2</Address>
31- <AcceptUsers>watanaby admin1 admin2</AcceptUsers>
31+ <MailDomain>opengate.example.com</MailDomain>
32+ <AcceptUsers>user1 user2</AcceptUsers>
3233 </AuthServer>
3334
3435 <!-- ### MUST BE MODIFIED ## -->
35- <!-- auth server setting for normal(not admin) users -->
36+ <!-- auth server setting for Normal(not admin) users -->
3637 <AuthServer>
3738 <Protocol>shibboleth</Protocol>
3839 <UidAttribute>uid</UidAttribute>
--- /dev/null
+++ b/html/en/macauthadmin.html
@@ -0,0 +1,55 @@
1+<html>
2+<head>
3+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
4+<title></title>
5+</head>
6+<body bgcolor="#EEFFEE">
7+<center>
8+
9+<h2>Management of MAC Address Registration</h2>
10+
11+<p><a href="%%CGINAME%%?lang=ja&redirectedurl=%%REDIRECTEDURL%%">Japanese Page</a></p>
12+
13+<P><font size=+1>This is the page to manage MAC address of your
14+terminals. If you register this terminal, you can use the network
15+without password entry.</font></P>
16+
17+<P><font size=+1>To proceed, you are requested to be authenticated.
18+</font></P>
19+
20+<P><font size=+1>You will be authenticated with your user ID and
21+password. If you do not know your user ID and/or password, please consult CNC.
22+</font></P>
23+
24+<P>
25+Please enter <font color=red>Administrator's user ID and password</font> in the box below, then press SEND.
26+</P>
27+
28+<p><font color="red">
29+%%ERRORLIST%%
30+</font></p>
31+
32+<P>
33+<form method="POST" action="%%CGINAME%%?lang=en&redirectedurl=%%REDIRECTEDURL%%">
34+<INPUT TYPE="HIDDEN" NAME="redirected_url" VALUE="%%REDIRECTEDURL%%">
35+
36+<TABLE BORDER=0>
37+<TR NOWRAP>
38+<TD><strong>Administrator's User ID: </strong></TD><TD><INPUT TYPE="TEXT" SIZE=20 NAME="userid"></TD>
39+</TR><TR NOWRAP>
40+<TD><strong>Password: </strong></TD><TD><INPUT TYPE="PASSWORD" SIZE=20 NAME="password"></TD>
41+</TR><TR NOWRAP>
42+<TD></TD><TD><INPUT TYPE="SUBMIT" VALUE=" SEND "></TD>
43+</TR>
44+</TABLE>
45+</form>
46+</P>
47+
48+<p><font size=+1>If you have any questions,
49+please contact network administrator.
50+</center>
51+
52+<div align=right>Saga University</div>
53+</body>
54+</html>
55+
--- a/html/en/macchk.html
+++ b/html/en/macchk.html
@@ -58,7 +58,7 @@
5858 try network access to confirm that the network for the terminal is closed.
5959 </p></li>
6060 <li><p>
61- Load this page. If you already loaded, reload it.
61+ Reload this page.
6262 </p></li>
6363 <li><p>
6464 The above is the list of addresses using this access point recently.
--- /dev/null
+++ b/html/ja/macauthadmin.html
@@ -0,0 +1,55 @@
1+<html>
2+<head>
3+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
4+<title></title>
5+</head>
6+<body bgcolor="#EEFFEE">
7+<center>
8+
9+<h2>利用者端末MACアドレス登録管理</h2>
10+
11+<p><a href="%%CGINAME%%?lang=en&redirectedurl=%%REDIRECTEDURL%%">English Page</a></p>
12+
13+
14+<P><font size=+1>ここは利用者端末のMACアドレスを登録管理するページです。
15+端末を登録するとパスワード入力なしでネットワークを利用できます。
16+</font></P>
17+
18+<P><font size=+1>登録管理に進むために利用資格の確認を行ってください。</font></P>
19+
20+<P><font size=+1>利用資格の確認には、ユーザ名とパスワードが必要です。自分のユーザ名やパスワードが解らない場合は、総合情報基盤センターに尋ねてください。</font></P>
21+
22+<P>
23+下の入力欄に、<font color=red>管理担当者のユーザIDとパスワード</font>を入力して、「送信」ボタンを押して下さい。
24+</P>
25+
26+
27+<p><font color="red">
28+%%ERRORLIST%%
29+</font></p>
30+
31+<P>
32+<form method="POST" action="%%CGINAME%%?lang=ja&redirectedurl=%%REDIRECTEDURL%%">
33+<INPUT TYPE="HIDDEN" NAME="redirected_url" VALUE="%%REDIRECTEDURL%%">
34+
35+<TABLE BORDER=0>
36+<TR NOWRAP>
37+ <TD><strong>管理ユーザID:</strong></TD><TD><INPUT TYPE="TEXT" SIZE=20 NAME="userid"></TD>
38+</TR><TR NOWRAP>
39+<TD><strong>パスワード:</strong></TD><TD><INPUT TYPE="PASSWORD" SIZE=20 NAME="password"></TD>
40+</TR><TR NOWRAP>
41+<TD></TD><TD><INPUT TYPE="SUBMIT" VALUE=" 送 信 "></TD>
42+</TR>
43+</TABLE>
44+</form>
45+</P>
46+<p>
47+<font size=+1>不明な点などがありましたら、ネットワーク管理者にお尋ねく
48+ださい。</font></p>
49+</center>
50+
51+
52+<div align=right>佐賀大学</div>
53+
54+</body>
55+</html>
--- a/html/ja/macchk.html
+++ b/html/ja/macchk.html
@@ -57,7 +57,7 @@
5757 登録を希望する端末で、この端末と同じアクセスポイントに接続して、ネットワークアクセスを試み、ネットワークが閉鎖していることを確認する。
5858 </p></li>
5959 <li><p>
60- このページを表示する。確認前に表示しているときはリロードを行う。
60+ このページをリロードする。
6161 </p></li>
6262 <li><p>
6363 上記の表は、同一アクセスポイントを最近利用した端末のアドレス一覧である。リストの先頭が最も最近に検出した端末である。
--- a/mdsrc/managementdb.c
+++ b/mdsrc/managementdb.c
@@ -29,7 +29,7 @@ Email: watanaby@is.saga-u.ac.jp
2929 #include <mysql.h>
3030
3131 static MYSQL mysql;
32-static int saveLogToMngDb=0;
32+static int isSessionTableFoundInMngDb=TRUE;
3333
3434 /******************************************
3535 initialize management db
@@ -42,7 +42,6 @@ int initMngDb(void){
4242 char *password = GetConfValue("MySqlDb/Password");
4343 char *database = GetConfValue("MySqlDb/Database");
4444 my_bool reconnect;
45- char *confStr;
4645
4746 /* initialize mysql */
4847 mysql_library_init(-1,NULL,NULL);
@@ -64,13 +63,9 @@ int initMngDb(void){
6463 reconnect = TRUE;
6564 mysql_options(&mysql, MYSQL_OPT_RECONNECT, &reconnect);
6665
67- /* read logmode flag from conf file and hold in a variable */
68- confStr = GetConfValue("SaveLogToMngDb");
69- if(isNull(confStr)) saveLogToMngDb = 0; /* no conf means no-log */
70- else saveLogToMngDb = strtol(confStr, NULL, 2);
71-
72- /* adjust relation of logmode in conf and logtable in mngdb */
73- AdjustLogModeAndLogTable();
66+ /* check existence of session table in management db(not work db) */
67+ /* if it is FALSE, writing/reading log is skipped */
68+ isSessionTableFoundInMngDb = IsTableFoundInMngDb("sessionmd");
7469
7570 return TRUE;
7671 }
@@ -137,8 +132,8 @@ int putOpenToMngDb(char* macAddress){
137132 char queryStr[BUFFMAXLN];
138133 struct utsname uts;
139134
140- /* if session log table is not used, return */
141- if(!saveLogToMngDb) return FALSE;
135+ /* if session log table is not found, return */
136+ if(!isSessionTableFoundInMngDb) return FALSE;
142137
143138 /* get domain name */
144139 uname(&uts);
@@ -167,8 +162,8 @@ int putCloseToMngDb(char* macAddress){
167162
168163 char queryStr[BUFFMAXLN];
169164
170- /* if session log table is not used, return */
171- if(!saveLogToMngDb) return FALSE;
165+ /* if session log table is not found, return */
166+ if(!isSessionTableFoundInMngDb) return FALSE;
172167
173168 /* prepare query string */
174169 snprintf(queryStr, BUFFMAXLN,
@@ -193,8 +188,8 @@ int delOldSessionLogInMngDb(void){
193188
194189 char* queryStr="delete from sessionmd where closeTime>0 and closeTime<adddate(now(),interval -1 month)";
195190
196- /* if session log table is not used, return */
197- if(!saveLogToMngDb) return FALSE;
191+ /* if session log table is not found, return */
192+ if(!isSessionTableFoundInMngDb) return FALSE;
198193
199194 /* send SQL query */
200195 if (mysql_query(&mysql, queryStr)){
@@ -330,45 +325,6 @@ int isTableFoundInMngDb(char* table){
330325 return found;
331326 }
332327
333-/******************************************
334-set closeTime to unclosed sessions in mngdb
335-return value: 1=success, 0=error
336-******************************************/
337-int updateCloseTimeToUnclosedSessionInMngDb(void){
338-
339- char* queryStr="update sessionmd set closeTime=now() where closeTime=0";
340-
341- /* send SQL query */
342- if (mysql_query(&mysql, queryStr)){
343- err_msg("ERR at %s#%d: mysql query: %s",__FILE__,__LINE__,
344- mysql_error(&mysql));
345- return FALSE;
346- }
347-
348- return TRUE;
349-}
350-
351-/**********************************************************
352-adjust the relation of logmode(SaveLogToMngDb) in conf file
353-and logtable(sessionmd) in management db
354-***********************************************************/
355-void adjustLogModeAndLogTable(void){
356-
357- /* check the existence of table sessionmd in management.db */
358- int isSessionTableFoundInMngDb = IsTableFoundInMngDb("sessionmd");
359-
360- /* if logmode=off and session table exists, cleanup all sessions */
361- if(!saveLogToMngDb && isSessionTableFoundInMngDb){
362- UpdateCloseTimeToUnclosedSessionInMngDb();
363- }
364-
365- /* if logmode=on and session table does not exist, write error */
366- if(saveLogToMngDb && !isSessionTableFoundInMngDb){
367- err_msg("ERR at %s#%d: please create mysql table. sample script is found in archive",
368- __FILE__,__LINE__);
369- }
370-}
371-
372328
373329 /********************************************
374330 routines for debugging
@@ -444,16 +400,3 @@ int IsTableFoundInMngDb(char* table){
444400 return ret;
445401 }
446402
447-int UpdateCloseTimeToUnclosedSessionInMngDb(void){
448- int ret;
449- if(debug>1) err_msg("DEBUG:=>updateCloseTimeToUnclosedSessionInMngDb()");
450- ret = updateCloseTimeToUnclosedSessionInMngDb();
451- if(debug>1) err_msg("DEBUG:(%d)<=updateCloseTimeToUnclosedSessionInMngDb()", ret);
452- return ret;
453-}
454-
455-void AdjustLogModeAndLogTable(void){
456- if(debug>1) err_msg("DEBUG:=>adjustLogModeAndLogTable()");
457- adjustLogModeAndLogTable();
458- if(debug>1) err_msg("DEBUG:<=adjustLogModeAndLogTable()");
459-}
--- a/mdsrc/opengatemd.h
+++ b/mdsrc/opengatemd.h
@@ -179,8 +179,6 @@ int GetNextRecordFromWatchlistTableInMngDb(char* macAddress);
179179 int IsAllFoundInWatchlistTable(void);
180180 int DelOldSessionLogInMngDb(void);
181181 int IsTableFoundInMngDb(char* table);
182-int UpdateCloseTimeToUnclosedSessionInMngDb(void);
183-void AdjustLogModeAndLogTable(void);
184182
185183 /* workdb.c */
186184 int SetupSqliteBusyTimeoutValue(void);
--- a/mngsrc/auth.c
+++ b/mngsrc/auth.c
@@ -184,7 +184,8 @@ int getUserId(char* requestStr, char* userId, char* extraId, char* language, int
184184
185185 /* if all check is failed, put error */
186186 if(authResult==DENY){
187- SetMessage(NoInfoInDb);
187+ SetMessage(NoInfoInDb);
188+ if(userType==ADMINUSER) SetMessage(RequestAdminAuth);
188189 PutDenyToClient(language);
189190 err_msg("DENY: user %s", useridfull);
190191 }
--- a/mngsrc/managementdb.c
+++ b/mngsrc/managementdb.c
@@ -491,7 +491,10 @@ int getNextUsageLogFromMngDb(char* userId, char* extraId, char* macAddr, char* d
491491 /* set default values */
492492 macAddr[0]=deviceName[0]=openTime[0]=gatewayName[0]='\0';
493493
494- /* if do not get result yet */
494+ /* if session table is not found in management db, return */
495+ if(!IsTableFoundInMngDb("sessionmd")) return FALSE;
496+
497+ /* if do not get result yet (if first call) */
495498 if(res==NULL){
496499
497500 /* prepare query string */
@@ -511,7 +514,8 @@ int getNextUsageLogFromMngDb(char* userId, char* extraId, char* macAddr, char* d
511514 if (mysql_query(&mysql, queryStr)){
512515
513516 /* query error */
514- /* might be caused by <SaveLogToMngDb> setting in opengatemd.conf */
517+ err_msg("ERR at %s#%d: mysql query: %s",__FILE__,__LINE__,
518+ mysql_error(&mysql));
515519 return FALSE;
516520 }
517521
@@ -815,6 +819,44 @@ int doesMacAddrBelongToUser(char* macAddr, char* userId, char* extraId){
815819 return exists;
816820 }
817821
822+/******************************************
823+is found table in management db
824+input=table name
825+return value: 1=found,0=not found or error
826+******************************************/
827+int isTableFoundInMngDb(char* table){
828+ MYSQL_RES *res;
829+ MYSQL_ROW row;
830+ int found=FALSE;
831+ char queryStr[BUFFMAXLN];
832+
833+ /* if no table, return false */
834+ if(isNull(table)) return FALSE;
835+
836+ /* prepare query string */
837+ snprintf(queryStr, BUFFMAXLN,
838+ "show tables like '%s'", table);
839+
840+ /* send SQL query */
841+ if (mysql_query(&mysql, queryStr)){
842+ err_msg("ERR at %s#%d: mysql query: %s",__FILE__,__LINE__,
843+ mysql_error(&mysql));
844+ return ERROR;
845+ }
846+ res = mysql_use_result(&mysql);
847+
848+ /* output table row */
849+ row = mysql_fetch_row(res);
850+
851+ /* row==NULL means getting no record */
852+ if(row==NULL) found=FALSE;
853+ else found=TRUE;
854+
855+ mysql_free_result(res);
856+ return found;
857+}
858+
859+
818860 /********************************************
819861 routines for debugging output
820862 ********************************************/
@@ -990,3 +1032,12 @@ int DoesMacAddrBelongToUser(char* macAddr, char* userId, char* extraId){
9901032 if(debug>1) err_msg("DEBUG:(%d)<=doesMacAddrBelongToUser( )",ret);
9911033 return ret;
9921034 }
1035+
1036+int IsTableFoundInMngDb(char* table){
1037+ int ret;
1038+ if(debug>1) err_msg("DEBUG:=>isTableFoundInMngDb(%s)", table);
1039+ ret = isTableFoundInMngDb(table);
1040+ if(debug>1) err_msg("DEBUG:(%d)<=isTableFoundInMngDb()", ret);
1041+ return ret;
1042+}
1043+
--- a/mngsrc/opengatemmng.h
+++ b/mngsrc/opengatemmng.h
@@ -197,6 +197,7 @@ int RenameMailAddressInMngDb(char* macAddr, char* mailStr);
197197 int RegOrUpNobodyMacAddr(char* macAddress);
198198 int IsMacAddrStatusInactiveInMngDb(char* macAddress);
199199 int DoesMacAddrBelongToUser(char* macAddr, char* userId, char* extraId);
200+int IsTableFoundInMngDb(char* table);
200201
201202 /* workdb.c */
202203 int SetupSqliteBusyTimeoutValue(void);