Sfoglia il codice sorgente

auth_db: new flag for auth_check() to skip caller id check for forwarding requests

- caller id check is skipped for INVITE, BYE, PRACK, UPDATE, MESSAGE --
  these requests can come with an anonymous caller id
Daniel-Constantin Mierla 11 anni fa
parent
commit
8c98ff6472
2 ha cambiato i file con 9 aggiunte e 3 eliminazioni
  1. 1 0
      modules/auth/api.h
  2. 8 3
      modules/auth_db/authorize.c

+ 1 - 0
modules/auth/api.h

@@ -60,6 +60,7 @@ typedef enum auth_cfg_result {
  * flags for checks in auth functions
  */
 #define AUTH_CHECK_ID_F 1<<0
+#define AUTH_CHECK_SKIPFWD_F 1<<1
 
 /**
  * return codes to auth API functions

+ 8 - 3
modules/auth_db/authorize.c

@@ -506,9 +506,14 @@ int auth_check(struct sip_msg* _m, char* _realm, char* _table, char *_flags)
 		} else {
 			uri = furi;
 		}
-		if(srealm.len!=uri->user.len
-					|| strncmp(srealm.s, uri->user.s, srealm.len)!=0)
-			return AUTH_USER_MISMATCH;
+		if((iflags&AUTH_CHECK_SKIPFWD_F)
+				&& (_m->REQ_METHOD==METHOD_INVITE || _m->REQ_METHOD==METHOD_BYE
+					|| _m->REQ_METHOD==METHOD_PRACK || _m->REQ_METHOD==METHOD_UPDATE
+					|| _m->REQ_METHOD==METHOD_MESSAGE)) {
+			if(srealm.len!=uri->user.len
+						|| strncmp(srealm.s, uri->user.s, srealm.len)!=0)
+				return AUTH_USER_MISMATCH;
+		}
 
 		if(_m->REQ_METHOD==METHOD_REGISTER || _m->REQ_METHOD==METHOD_PUBLISH) {
 			/* check from==to */