<!-- #########################################################
## Opengate gateway server hostname(FQDN or IP address)## -->
- <OpengateServerName>opengate.og.saga-u.ac.jp</OpengateServerName>
+ <OpengateServerName>opengate.example.com</OpengateServerName>
<!-- Debug dump level -->
<!-- Set 0 to write only open/close and error messages to syslog -->
<HtmlLangs>ja en</HtmlLangs>
<!-- Path to Apache Contents -->
- <DocumentRoot>/usr/local/www/apache22/data</DocumentRoot>
+ <DocumentRoot>/usr/local/www/apache24/data</DocumentRoot>
<CgiDir>/cgi-bin</CgiDir>
<OpengateDir>/opengate</OpengateDir>
--- /dev/null
+From opengate@cc.saga-u.ac.jp
+Mime-Version: 1.0
+Content-Type: text/plain; charset=ISO-2022-JP
+Content-Transfer-Encoding: 7bit
+Subject: Mac Address Registration
+To: %%MAILADDRESS%%
+
+
+Your device [%%DEVICENAME%%] will reach the limit date at [%%LIMITDATE%%].
+Please update the registration in the following page.
+
+http://www.cc.saga-u.ac.jp/opengate/mup.php
</DT><DD>
Modified description of update and registration pages (opengatemup/mown/mreg).
</DD>
+ <DT>Ver.0.9.6 at 2015.6.10
+ </DT><DD>
+ Fixed CLang warning messages, Modified PHP scripts (opengatem-all).
+ </DD>
</DL>
-
</BODY>
</HTML>
-Refer http://www.cc.saga-u.ac.jp/opengate/opengatem/index-e.html
+Refer http://opengatem.osdn.jp/index.html.en
+
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-CC = gcc
+#CC = gcc
AR = ar
RM = rm -f
CFLAGS = -Wall -O2
$(CC) $(CFLAGS) -c -o $@ $<
clean:
- $(RM) $(OBJS) $(LIB) $(TEST) *~
\ No newline at end of file
+ $(RM) $(OBJS) $(LIB) $(TEST) *~
else *s = '\0'; // null terminate tag name
for (i = 0; root->attr[i] && strcmp(n, root->attr[i][0]); i++);
- while (*(n = ++s + strspn(s, EZXML_WS)) && *n != '>') {
+ while (++s, *(n = s + strspn(s, EZXML_WS)) && *n != '>') {
if (*(s = n + strcspn(n, EZXML_WS))) *s = '\0'; // attr name
else { ezxml_err(root, t, "malformed <!ATTLIST"); break; }
## This is memory leak check tool for debugging
#LIBCCMALLOC = -lccmalloc -L/usr/local/lib
-CFLAGS= -g -O4 -Wall -I/usr/local/include ${CFLAGSMYSQL}
+CFLAGS= -g -O3 -Wall -I/usr/local/include ${CFLAGSMYSQL}
LIBS = -lezxml -lpcap -L../ezxml -L/usr/local/lib ${LIBSQLITE} ${LIBMYSQL} ${LIBCCMALLOC}
strcat(buf, "\n");
if (daemon_proc) {
- syslog(level, buf);
+ syslog(level, "%s", buf);
} else {
fflush(stdout); /* in case stdout and stderr are the same */
fputs(buf, stderr);
/** setup hash value **/
/* hash value : string "<found>SPACE<unixtime>SPACE<userId>SPACE<extraId>" */
- snprintf(hashValueStr,BUFFMAXLN,"%d %d %s %s",
+ snprintf(hashValueStr,BUFFMAXLN,"%d %ld %s %s",
found,time(NULL),userId,extraId);
hashVal.data = hashValueStr;
hashVal.size = strlen(hashValueStr) + 1;
/* get is successed */
/* pick up the hash values */
- ret=sscanf(hashVal.data,"%d %d %s %s",&found,&entryTime,userId,extraId);
+ ret=sscanf(hashVal.data,"%d %ld %s %s",&found,&entryTime,userId,extraId);
/* found, entryTime should be obtained */
if(ret<=1) return ERROR;
## some other parameters exist in opengatemmng.h ########
##########################################################
CONFIGPATH = /etc/opengate ## directory of config file
-WWWTOP = /usr/local/www/apache22 ## apache directory top
+WWWTOP = /usr/local/www/apache24 ## apache directory top
DOCDIR = /data ## apache data directory(related to wwwtop)
CGIDIR = /cgi-bin ## apache cgi directory(related to wwtop)
OPENGATEDIR = /opengate ## opengate web directory(related to docdir)
## This is memory leak check tool for debugging
#LIBCCMALLOC = -lccmalloc -L/usr/local/lib
-CFLAGS= -g -O4 -Wall -I/usr/local/include ${CFLAGSMYSQL}
+CFLAGS= -g -O3 -Wall -I/usr/local/include ${CFLAGSMYSQL}
LIBS = -lezxml -lssl -lcrypto -lradius -lpam -L../ezxml -L/usr/local/lib ${LIBLDAP} ${LIBSQLITE} ${LIBMYSQL} ${LIBCCMALLOC}
.endif
cp ../conf/opengatemmng.conf.sample ${CONFIGPATH}
cp ../conf/warningmail.sample ${CONFIGPATH}
+ cp ../conf/warningmail.sample.en ${CONFIGPATH}
#
#-------------------------------------------------------#
# COPY xx.conf.sample to xx and EDIT it. #
char* port; /* auth server port */
SSL_CTX *ctx;
SSL *ssl;
- SSL_METHOD *meth;
+ const SSL_METHOD *meth;
/* get auth server address */
serverAddr=GetConfValue("AuthServer/Address");
char* port; /* auth server port */
SSL_CTX *ctx;
SSL *ssl;
- SSL_METHOD *meth;
+ const SSL_METHOD *meth;
/* get auth server address */
serverAddr=GetConfValue("AuthServer/Address");
int authResult;
SSL_CTX *ctx;
SSL *ssl;
- SSL_METHOD *meth;
+ const SSL_METHOD *meth;
/* get auth server address */
serverAddr=GetConfValue("AuthServer/Address");
strcat(buf, "\n");
if (daemon_proc) {
- syslog(level, buf);
+ syslog(level, "%s", buf);
} else {
fflush(stdout); /* in case stdout and stderr are the same */
fputs(buf, stderr);
char str[BUFFMAXLN];
/* make Http-cookie from pid&time */
- snprintf(str, BUFFMAXLN, "%d%d", getpid(),time(NULL));
+ snprintf(str, BUFFMAXLN, "%d%ld", getpid(),time(NULL));
md5hex(cookie, SIDMAXLN, str);
}
// get mail address and others from mysql db
if(!(list($device, $mailAddress)=getDataFromMysql($macAddress))){
- mysql_close($link);
+ mysqli_close($link);
return;
}
// if recent report exists, skip to send report
-if(skipReporting($macAddress, $gatewayName, $reportInterval)){
- mysql_close($link);
+if(skipReporting($link, $macAddress, $gatewayName, $reportInterval)){
+ mysqli_close($link);
return;
}
// close database
-mysql_close($link);
+mysqli_close($link);
// send mail to the user
sendMailToUser($mailSender, $mailAddress, $device, $gatewayName,
function prepareMysql($mysqlServer, $mysqlUser, $mysqlPassword){
// connect and access to MySql DB
- $link = mysql_connect($mysqlServer, $mysqlUser, $mysqlPassword);
+ $link = mysqli_connect($mysqlServer, $mysqlUser, $mysqlPassword);
if (!$link){
- syslog(LOG_INFO, 'ERR: Cannot connect DB '.mysql_error());
+ syslog(LOG_INFO, 'ERR: Cannot connect DB '.mysqli_error());
return FALSE;
}
// use opengatem database
- $db_selected = mysql_select_db('opengatem', $link);
+ $db_selected = mysqli_select_db($link, 'opengatem');
if (!$db_selected){
- syslog(LOG_INFO, 'ERR: Cannot select DB '.mysql_error());
+ syslog(LOG_INFO, 'ERR: Cannot select DB '.mysqli_error());
return FALSE;
}
- mysql_set_charset('utf8');
+ mysqli_set_charset($link, 'utf8');
return $link;
}
$mailAddress="?";
// query
- $result = mysql_query('SELECT device, mailAddress FROM macaddrs
+ $result = mysqli_query($link, 'SELECT device, mailAddress FROM macaddrs
WHERE macAddress="'.$macAddress.'" AND status!="D"');
if (!$result){
- syslog(LOG_INFO, 'ERR: Fail DB query '.mysql_error());
+ syslog(LOG_INFO, 'ERR: Fail DB query '.mysqli_error());
return FALSE;
}
// get result
- if($row = mysql_fetch_row($result)){
+ if($row = mysqli_fetch_row($result)){
$device = $row[0];
$mailAddress = $row[1];
}else{
skip if there are recent logs having same macaddress, and same gateway
PLEASE MODIFY to control the report frequency.
***/
-function skipReporting($macAddress, $gatewayName, $reportInterval){
+function skipReporting($link, $macAddress, $gatewayName, $reportInterval){
// query
- $result = mysql_query('SELECT count(*) FROM sessionmd '
+ $result = mysqli_query($link, 'SELECT count(*) FROM sessionmd '
.'WHERE EXISTS (SELECT * FROM sessionmd '
.'WHERE macAddress="'.$macAddress.'" '
.'AND gatewayName LIKE "'.$gatewayName.'.%" '
);
if (!$result){
- syslog(LOG_INFO, 'ERR: Fail query '.mysql_error());
+ syslog(LOG_INFO, 'ERR: Fail query '.mysqli_error());
return TRUE;
}
// get data
- if($row = mysql_fetch_row($result)) $count = $row[0];
+ if($row = mysqli_fetch_row($result)) $count = $row[0];
else $count = 0;
// if recent logs exist, skip is true
<?php
- // check basic auth
- if(getenv('REMOTE_USER')=='') die('Cannot get auth');
-
// set default values
$userId=$device='%';
$now=date('Y-m-d H:i:s');
print("</table></p>");
// connect and access to MySql db
- $link = mysql_connect('localhost', 'root', '');
- if (!$link) die('Cannot connet to DB'.mysql_error());
+ $link = mysqli_connect('localhost', 'root', '');
+ if (!$link) die('Cannot connet to DB'.mysqli_error());
- $db_selected = mysql_select_db('opengatem', $link);
- if (!$db_selected) die('Cannot select DB'.mysql_error());
+ $db_selected = mysqli_select_db($link, 'opengatem');
+ if (!$db_selected) die('Cannot select DB'.mysqli_error());
- mysql_set_charset('utf8');
+ mysqli_set_charset($link, 'utf8');
- $result = mysql_query('SELECT * FROM sessionview where userId like "'.$userId.'" and device like "'.$device.'" and "'.$fromTime.'"<openTime and openTime<"'.$toTime.'"');
+ $result = mysqli_query($link, 'SELECT * FROM sessionview where userId like "'.$userId.'" and device like "'.$device.'" and "'.$fromTime.'"<openTime and openTime<"'.$toTime.'"');
- if (!$result) die('Fail query'.mysql_error());
+ if (!$result) die('Fail query'.mysqli_error());
// show header line
print("<table border=1>");
print('<tr>');
$count=0;
- while ($field = mysql_fetch_field($result)) {
+ while ($field = mysqli_fetch_field($result)) {
print('<td>'.$field->name.'</td>');
$count++;
}
print('</tr>');
// show rows
- while ($row = mysql_fetch_row($result)) {
+ while ($row = mysqli_fetch_row($result)) {
print('<tr>');
for($i=0; $i<$count; $i++){
print('<td>'.$row[$i].'</td>');
}
print("</table>");
- $close_flag = mysql_close($link);
+ $close_flag = mysqli_close($link);
?>
<?php
- // check basic auth
- if(getenv('REMOTE_USER')=='') die('Cannot get auth');
-
// no table is indicated
if(!isset($_GET['table']))return;
// connect and access to MySql DB
- $link = mysql_connect('localhost', 'root', '');
- if (!$link) die('Cannot connect DB'.mysql_error());
+ $link = mysqli_connect('localhost', 'root', '');
+ if (!$link) die('Cannot connect DB'.mysqli_error());
- $db_selected = mysql_select_db('opengatem', $link);
- if (!$db_selected) die('Cannot select DB'.mysql_error());
+ $db_selected = mysqli_select_db($link, 'opengatem');
+ if (!$db_selected) die('Cannot select DB'.mysqli_error());
- mysql_set_charset('utf8');
+ mysqli_set_charset($link, 'utf8');
- $result = mysql_query('SELECT * FROM '.$_GET['table'].' limit 1000');
- if (!$result) die('Fail query'.mysql_error());
+ $result = mysqli_query($link, 'SELECT * FROM '.$_GET['table'].' limit 1000');
+ if (!$result) die('Fail query'.mysqli_error());
// print header
print("<table border=1>");
print('<tr>');
$count=0;
- while ($field = mysql_fetch_field($result)) {
+ while ($field = mysqli_fetch_field($result)) {
print('<td>'.$field->name.'</td>');
$count++;
}
print('</tr>');
// print rows
- while ($row = mysql_fetch_row($result)) {
+ while ($row = mysqli_fetch_row($result)) {
print('<tr>');
for($i=0; $i<$count; $i++){
print('<td>'.$row[$i].'</td>');
print('</tr>');
}
print("</table>");
- $close_flag = mysql_close($link);
+ $close_flag = mysqli_close($link);
?>
<?php
- // check basic auth
- if(getenv('REMOTE_USER')=='') die('Cannot get auth');
-
// if userid is not set, request input and return
if(!isset($_POST['userId'])){
- print('<form method=POST action=updatemac.php>');
+ print('<form method=POST action=updatemactable.php>');
print('UserId:<input type=text name=userId>');
print('<input type=submit value="Send">');
print('<input type=reset value="Reset">');
$userId=$_POST['userId'];
// setup MySql DB
- $link = mysql_connect('localhost', 'root', '');
- if (!$link) die('Cannot connect DB'.mysql_error());
+ $link = mysqli_connect('localhost', 'root', '');
+ if (!$link) die('Cannot connect DB'.mysqli_error());
- $db_selected = mysql_select_db('opengatem', $link);
- if (!$db_selected) die('cannot select DB'.mysql_error());
+ $db_selected = mysqli_select_db($link, 'opengatem');
+ if (!$db_selected) die('cannot select DB'.mysqli_error());
- mysql_set_charset('utf8');
+ mysqli_set_charset($link, 'utf8');
// if data is posted, update DB
$i=0;
// UPDATE macaddrs SET status="D",device="postdata",limitdate=now(),mailAddress="postdata"
// WHERE macAddress="postdata" and userId="postdata" and status!="D"
- $result = mysql_query('UPDATE macaddrs SET status="'.$_POST['status'][$i]
+ $result = mysqli_query($link, 'UPDATE macaddrs SET status="'.$_POST['status'][$i]
.'", device="'.$_POST['device'][$i].'", limitDate=now()'
.', mailAddress="'.$_POST['mailAddress'][$i].'" WHERE macAddress="'
.$_POST['macAddress'][$i].'" and userId="'.$userId.'" and status!="D"');
- if (!$result) die('Fail update query'.mysql_error());
+ if (!$result) die('Fail update query'.mysqli_error());
}else if($_POST['status'][$i]=='A'||$_POST['status'][$i]=='I'){
// other cases
// UPDATE macaddrs SET status="D",device="postdata",limitdate="postdata",mailAddress="postdata"
// WHERE macAddress="postdata" and userId="postdata" and status!="D"
- $result = mysql_query('UPDATE macaddrs SET status="'.$_POST['status'][$i]
+ $result = mysqli_query($link, 'UPDATE macaddrs SET status="'.$_POST['status'][$i]
.'", device="'.$_POST['device'][$i].'", limitDate="'.$_POST['limitDate'][$i]
.'", mailAddress="'.$_POST['mailAddress'][$i].'" WHERE macAddress="'
.$_POST['macAddress'][$i].'" and userId="'.$userId.'" and status!="D"');
- if (!$result) die('Fail update query'.mysql_error());
+ if (!$result) die('Fail update query'.mysqli_error());
}else{
print("<font color=red>Illegal status value</font>");
}
// get data from DB to show on web
- $result = mysql_query('SELECT macAddress,status,device,limitDate,mailAddress FROM macaddrs where userId="'
+ $result = mysqli_query($link, 'SELECT macAddress,status,device,limitDate,mailAddress FROM macaddrs where userId="'
.$userId.'"');
- if (!$result) die('Fail select query'.mysql_error());
+ if (!$result) die('Fail select query'.mysqli_error());
// print html form
print('<form method=POST action=updatemac.php>');
print("<table border=1>");
print('<tr>');
$count=0;
- while ($field = mysql_fetch_field($result)) {
+ while ($field = mysqli_fetch_field($result)) {
print('<td>'.$field->name.'</td>');
$fieldName[$count]=$field->name;
$count++;
print('</tr>');
// print rows
- while ($row = mysql_fetch_row($result)) {
+ while ($row = mysqli_fetch_row($result)) {
print('<tr>');
if($row[1]=='D'){ // deleted items
for($i=0; $i<$count; $i++){
}
print('</table>');
print('</form>');
- $close_flag = mysql_close($link);
+ $close_flag = mysqli_close($link);
?>
<p>status char: A=Actice, I=InActive, D=Deleted</p>
-<?php\r
-\r
-// Create or Update the vendor table in Management DB.\r
-// The table is used in opengatemchk\r
-//\r
-// At installation, run to create vendor table\r
-//\r
-// After installation, run periodically to update vendor table.\r
-\r
-\r
-//connect to Management DB (* set proper parameters *)\r
-$link = mysql_connect("localhost", "root", "");\r
-if (!$link) die('Cannot connect to DB.'.mysql_error());\r
-\r
-// select opengatem database\r
-$db_selected = mysql_select_db('opengatem', $link);\r
-if (!$db_selected) die('Cannot select DB.'.mysql_error());\r
-\r
-// create table if not exists\r
-$sql = "CREATE TABLE IF NOT EXISTS nicvendors(oui CHAR(8), org TINYTEXT)";\r
-mysql_query($sql);\r
-\r
-// connect to oui list in IEEE site\r
-$fp = fopen("http://standards.ieee.org/develop/regauth/oui/oui.txt", "r");\r
-if(!$fp) die('Cannot connect to IEEE site. Check network connection');\r
-\r
-// scan the download list\r
-while (!feof($fp)) {\r
-\r
- // get one line\r
- $line = fgets($fp);\r
-\r
- // columns 0-7 may be oui \r
- $oui = substr($line, 0, 8);\r
-\r
- //if $oui is not "**-**-**", skip the line\r
- if(preg_match('/^[0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2}$/',$oui)!=1)continue;\r
-\r
- // reformat $oui from "01-56-AB" to "01:56:ab"\r
- $oui = str_replace("-",":",$oui);\r
- $oui = strtolower($oui);\r
-\r
- // column 16- should be vendor name (trim CR code)\r
- $org = substr($line, 16);\r
-\r
- // remove CR code and quotation code\r
- $org = str_replace(array("\r\n","\n","\r"), "", $org);\r
- $org = str_replace("\"", "", $org);\r
- $org = str_replace("\t", "", $org);\r
-\r
- // insert to db\r
- $sql = sprintf(\r
- 'REPLACE INTO nicvendors (oui,org) VALUES( "%s", "%s")',\r
- $oui, $org);\r
- mysql_query($sql);\r
-\r
- // log to console\r
- print $oui." ".$org."<br>\n";\r
-}\r
-fclose($fp);\r
-?>\r
-\r
+<?php
+
+// Create or Update the vendor table in Management DB.
+// The table is used in opengatemchk
+//
+// At installation, run to create vendor table
+//
+// After installation, run periodically to update vendor table.
+
+
+//connect to Management DB (* set proper parameters *)
+$link = mysqli_connect("localhost", "root", "");
+if (!$link) die('Cannot connect to DB.'.mysqli_error());
+
+// select opengatem database
+$db_selected = mysqli_select_db($link, 'opengatem');
+if (!$db_selected) die('Cannot select DB.'.mysqli_error());
+
+// create table if not exists
+$sql = "CREATE TABLE IF NOT EXISTS nicvendors(oui CHAR(8), org TINYTEXT)";
+mysqli_query($link, $sql);
+
+// open oui list in IEEE site
+// $fp = fopen("http://standards.ieee.org/develop/regauth/oui/oui.txt", "r");
+$fp = fopen("./oui.txt", "r");
+if(!$fp) die('Cannot connect to IEEE data');
+
+// scan the download list
+while (!feof($fp)) {
+
+ // get one line
+ $line = fgets($fp);
+
+ // get oui(MAC-left-3bytes) and org(company name) from header line
+ // such as "AB-CD-EF (hex) Foo-bar company"
+ $pattern='/([0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2})\s*\(hex\)\s*(.*)$/';
+ if(preg_match($pattern, $line, $matches)!=1) continue;
+ $oui=$matches[1];
+ $org=$matches[2];
+
+ // replace AB-CD-EF to ab:cd:ef
+ $oui = str_replace("-",":",$oui);
+ $oui = strtolower($oui);
+
+ // remove quotation and tab code
+ $org = str_replace("\"", "", $org);
+ $org = str_replace("\t", "", $org);
+
+ // insert to db
+ $sql = sprintf(
+ 'REPLACE INTO nicvendors (oui,org) VALUES( "%s", "%s")',
+ $oui, $org);
+ mysqli_query($link, $sql);
+
+ // log to console
+ print $oui." ".$org."<br>\n";
+}
+fclose($fp);
+?>
+