OpengateM Source Repository
Révision | fab2eb0243cfd2dea4631265b113c1a75f9a8699 (tree) |
---|---|
l'heure | 2016-05-18 10:34:28 |
Auteur | watanaby <watanaby@user...> |
Commiter | watanaby |
added warning at registrating other's device
@@ -267,6 +267,10 @@ OpengateM History</H3> | ||
267 | 267 | </DT><DD> |
268 | 268 | Replaced signal function to NO-RESTART one (openatem-all). |
269 | 269 | </DD> |
270 | + <DT>Ver.1.0.2 at 2016.5.18 | |
271 | + </DT><DD> | |
272 | + Added warning message at registrating other user's device (openatem-all). | |
273 | + </DD> | |
270 | 274 | </DL> |
271 | 275 | <P> |
272 | 276 | <B>Please see GIT on osdn.jp to check the differences between versions.</B> |
@@ -815,6 +815,51 @@ int isMacAddrStatusInactiveInMngDb(char* macAddr){ | ||
815 | 815 | return ret; |
816 | 816 | } |
817 | 817 | |
818 | +/******************************************************/ | |
819 | +/* Does the mac address belong to the userid@extraid */ | |
820 | +/* all-args:(input) */ | |
821 | +/* return value: true(1)=YES, false(0)=NO */ | |
822 | +/******************************************************/ | |
823 | +int doesMacAddrBelongToUser(char* macAddr, char* userId, char* extraId){ | |
824 | + | |
825 | + MYSQL_RES *res=NULL; | |
826 | + MYSQL_ROW row; | |
827 | + char queryStr[BUFFMAXLN]; | |
828 | + char existsStr[WORDMAXLN]; | |
829 | + int exists=FALSE; | |
830 | + | |
831 | + /* prepare query string */ | |
832 | + snprintf(queryStr, BUFFMAXLN, | |
833 | + "select exists(select * from macaddrs " | |
834 | + " where macAddress='%s' and userId='%s' " | |
835 | + " and extraId='%s' and status!='D') ", | |
836 | + macAddr, userId, extraId); | |
837 | + | |
838 | + /* send SQL query */ | |
839 | + if (mysql_query(&mysql, queryStr)){ | |
840 | + err_msg("ERR at %s#%d: mysql query: %s",__FILE__,__LINE__, | |
841 | + mysql_error(&mysql)); | |
842 | + return FALSE; | |
843 | + } | |
844 | + | |
845 | + /* store query result */ | |
846 | + res = mysql_store_result(&mysql); | |
847 | + | |
848 | + /* get a row from query result */ | |
849 | + row = mysql_fetch_row(res); | |
850 | + | |
851 | + /* if found, return the count */ | |
852 | + if(row!=NULL){ | |
853 | + strlcpy(existsStr, row[0], WORDMAXLN); | |
854 | + exists=atoi(existsStr); | |
855 | + } | |
856 | + | |
857 | + /* free memory area */ | |
858 | + mysql_free_result(res); | |
859 | + | |
860 | + return exists; | |
861 | +} | |
862 | + | |
818 | 863 | /******************************************** |
819 | 864 | routines for debugging output |
820 | 865 | ********************************************/ |
@@ -989,3 +1034,12 @@ int IsMacAddrStatusInactiveInMngDb(char* macAddress){ | ||
989 | 1034 | if(debug>1) err_msg("DEBUG:(%d)<=isMacAddrStatusInactiveInMngDb()",ret); |
990 | 1035 | return ret; |
991 | 1036 | } |
1037 | + | |
1038 | +int DoesMacAddrBelongToUser(char* macAddr, char* userId, char* extraId){ | |
1039 | + int ret; | |
1040 | + if(debug>1) err_msg("DEBUG:=>doesMacAddrBelongToUser(%s,%s,%s)", | |
1041 | + macAddr,userId,extraId); | |
1042 | + ret=doesMacAddrBelongToUser(macAddr,userId,extraId); | |
1043 | + if(debug>1) err_msg("DEBUG:(%d)<=doesMacAddrBelongToUser( )",ret); | |
1044 | + return ret; | |
1045 | +} |
@@ -86,7 +86,7 @@ void insertMessageToPage(char* language){ | ||
86 | 86 | /******************************/ |
87 | 87 | char* messagesInEn(int msgNo){ |
88 | 88 | char* messages[ENDOFLIST]; |
89 | - messages[ExistentMacAddr]="Error: Mac address is already registered. Update it in update page."; | |
89 | + messages[ExistentMacAddr]="Error: Mac address is already registered. Update or delete it."; | |
90 | 90 | messages[DeviceCountOver]="Error: Device count reachs to the limit per one user. To register new device, remove a registered device."; |
91 | 91 | messages[IllegalMacAddrForm]= "Error: Mac address format is illegal."; |
92 | 92 | messages[IllegalCharInDevice]="Error: Not permitted character is found in device name."; |
@@ -105,7 +105,7 @@ char* messagesInEn(int msgNo){ | ||
105 | 105 | messages[NotSetAdminCookie]="Error: Cannot found admin cookie. Enter from check page."; |
106 | 106 | messages[RequestAdminAuth]="Enter Administrator's userID and password."; |
107 | 107 | messages[UnallowableAgent]="Cannot recognize the terminal to be allowable."; |
108 | - | |
108 | + messages[MacBelongToOther]="Accessing terminal belongs to other user. To register the terminal, the user should delete the registration."; | |
109 | 109 | return messages[msgNo]; |
110 | 110 | } |
111 | 111 |
@@ -114,7 +114,7 @@ char* messagesInEn(int msgNo){ | ||
114 | 114 | /*************************************/ |
115 | 115 | char* messagesInJa(int msgNo){ |
116 | 116 | char* messages[ENDOFLIST]; |
117 | - messages[ExistentMacAddr]= "エラー:既登録のMACアドレスです。更新ページで更新してください。"; | |
117 | + messages[ExistentMacAddr]= "エラー:既登録のMACアドレスです。更新または削除をしてください。"; | |
118 | 118 | messages[DeviceCountOver]= "エラー:一人当りの許容機器数に達しています。新たな機器を登録するには登録済の一つを削除してください。"; |
119 | 119 | messages[IllegalMacAddrForm]= "エラー:MACアドレスの形式が不正です。"; |
120 | 120 | messages[IllegalCharInDevice]="エラー:許容されていない文字が機器名にあります。"; |
@@ -133,6 +133,8 @@ char* messagesInJa(int msgNo){ | ||
133 | 133 | messages[NotSetAdminCookie]="エラー : 管理者のCookieを取得できません。チェックページから入って下さい。"; |
134 | 134 | messages[RequestAdminAuth]="管理者のIDとPasswordを入力してください。"; |
135 | 135 | messages[UnallowableAgent]="登録許容端末と認識できません。"; |
136 | + messages[MacBelongToOther]="エラー : 別ユーザIDの登録端末です。再登録するには、そのユーザIDで登録を削除する必要があります。"; | |
137 | +; | |
136 | 138 | return messages[msgNo]; |
137 | 139 | } |
138 | 140 |
@@ -113,7 +113,7 @@ enum errs{ExistentMacAddr,DeviceCountOver,IllegalMacAddrForm, | ||
113 | 113 | IllegalCharInDevice,EmptyDeviceName,IllegalCharInMailAddr,SuspectNat, |
114 | 114 | NoInfoInDb,IllegalUserId,IllegalMacAddr,NoService, |
115 | 115 | NoDaemon,ModifyCountOver,RegisterSuccess,UpdateSuccess,IllegalCookie, |
116 | - NotSetAdminCookie,RequestAdminAuth,UnallowableAgent, | |
116 | + NotSetAdminCookie,RequestAdminAuth,UnallowableAgent,MacBelongToOther, | |
117 | 117 | ENDOFLIST}; |
118 | 118 | |
119 | 119 | /**********prototypes***************************************/ |
@@ -197,6 +197,7 @@ int RenameDeviceNameInMngDb(char* macAddr, char* nameStr); | ||
197 | 197 | int RenameMailAddressInMngDb(char* macAddr, char* mailStr); |
198 | 198 | int RegOrUpNobodyMacAddr(char* macAddress); |
199 | 199 | int IsMacAddrStatusInactiveInMngDb(char* macAddress); |
200 | +int DoesMacAddrBelongToUser(char* macAddr, char* userId, char* extraId); | |
200 | 201 | |
201 | 202 | /* workdb.c */ |
202 | 203 | int SetupSqliteBusyTimeoutValue(void); |
@@ -217,9 +217,18 @@ int main(int argc, char **argv) | ||
217 | 217 | ReturnToRedirectedPage(redirectedUrl, language); |
218 | 218 | } |
219 | 219 | |
220 | - /* if no execution and the MAC is registered, send back update page */ | |
220 | + /* if the MAC is registered in management db, */ | |
221 | 221 | else if(IsMacAddrFoundInMngDb(macAddress)){ |
222 | - PutUpdatePageToClient(language, userId, extraId, OWNER, redirectedUrl); | |
222 | + | |
223 | + /* and the MAC belongs to the accessing user, put the update page */ | |
224 | + if(DoesMacAddrBelongToUser(macAddress, userId, extraId)){ | |
225 | + PutUpdatePageToClient(language, userId, extraId, OWNER, redirectedUrl); | |
226 | + } | |
227 | + /* otherwise, put deny page */ | |
228 | + else{ | |
229 | + SetMessage(MacBelongToOther); | |
230 | + PutDenyToClient(language); | |
231 | + } | |
223 | 232 | } |
224 | 233 | |
225 | 234 | /* the MAC is not-registered */ |