Please apply this patch, recompile the module and let me know if the
problem was solved.
Thanks and regards,
Bogdan
Bogdan-Andrei Iancu wrote:
Hi Carlo,
I found the bug...right now I'm testing the fix. I will shortly send
you a patch to test before backporting to 1.5.
Thanks and regards,
Bogdan
Carlo Dimaggio wrote:
Il giorno 26/mar/09, alle ore 17:38, Carlo Dimaggio ha scritto:
Hi Bogdan,
I have 5 blocks in which I use the function is_user_in():
if (is_user_in("Credentials", "quota")) {
if (!is_user_in("Credentials", "ITALY_NATIONAL")) {
if (is_user_in("Credentials", "ITALY_NATIONAL")) {
if (is_user_in("Credentials", "ITALY_MOBILE")) {
if (is_user_in("Credentials", "INTERNATIONAL")) {
In all functions I use "Credentials" as first parameter. Do you see
something wrong?
If I comment these lines I don't have errors...
Hi Bogdan,
I've added in group.c a line in order to print the User Filed
Identifier. I see that when I have the errors the output is like this:
Mar 30 10:35:33 sip /sbin/opensips[14789]: ERROR:group:get_hf:
DEBUG: User Field identifier = ###0^H#m^]^H^C
Mar 30 10:35:33 sip /sbin/opensips[14789]: ERROR:core:pv_parse_spec:
bad parameters
Mar 30 10:35:33 sip /sbin/opensips[14789]: ERROR:group:get_hf:
unsupported User Field identifier
Mar 30 10:35:33 sip /sbin/opensips[14789]: ERROR:group:is_user_in:
unable to get user/dom source
When I have no errors, the output is:
Mar 30 10:35:29 sip /sbin/opensips[14789]: ERROR:group:get_hf:
DEBUG: User Field identifier = Credentials
Is it possible that in my script there is a fault that changes the
user field identifier of is_user_in()?
Thanks and regards,
Carlo Dimaggio
_______________________________________________
Users mailing list
[email protected]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Index: modules/group/group.h
===================================================================
--- modules/group/group.h (revision 5560)
+++ modules/group/group.h (working copy)
@@ -46,8 +46,8 @@
/*
* extracts username and domain from MSG
*/
-int get_username_domain(struct sip_msg *msg, group_check_p gcp,
- str *username, str *domain);
+int get_username_domain(struct sip_msg *msg, str *hf_s,
+ str *username, str *domain);
/*
Index: modules/group/re_group.c
===================================================================
--- modules/group/re_group.c (revision 5560)
+++ modules/group/re_group.c (working copy)
@@ -27,6 +27,7 @@
#include <sys/types.h>
#include <regex.h>
+#include "../../mod_fix.h"
#include "../../str.h"
#include "../../mem/mem.h"
#include "../../route_struct.h"
@@ -131,6 +132,7 @@
int get_user_group(struct sip_msg *req, char *user, char *avp)
{
static char uri_buf[MAX_URI_SIZE];
+ str user_str;
str username;
str domain;
pv_spec_t *pvs;
@@ -140,7 +142,12 @@
char *c;
int n;
- if (get_username_domain( req, (group_check_p)user, &username, &domain)!=0){
+ if(user == NULL || fixup_get_svalue(req, (gparam_p)user, &user_str) != 0){
+ LM_ERR("Invalid parameter URI\n");
+ return -1;
+ }
+
+ if (get_username_domain( req, &user_str, &username, &domain)!=0){
LM_ERR("failed to get usern...@domain\n");
goto error;
}
Index: modules/group/group_mod.c
===================================================================
--- modules/group/group_mod.c (revision 5560)
+++ modules/group/group_mod.c (working copy)
@@ -230,13 +230,10 @@
static int get_gid_fixup(void** param, int param_no)
{
pv_spec_t *sp;
- void *ptr;
str name;
if (param_no == 1) {
- ptr = *param;
- if ( (*param = (void*)get_hf( ptr ))==0 )
- return E_UNSPEC;
+ return fixup_spve_spve(param, param_no);
} else if (param_no == 2) {
name.s = (char*)*param;
name.len = strlen(name.s);
Index: modules/group/group.c
===================================================================
--- modules/group/group.c (revision 5560)
+++ modules/group/group.c (working copy)
@@ -43,20 +43,19 @@
#include "group.h"
#include "group_mod.h" /* Module parameters */
-static group_check_p get_hf( char *str1);
+static unsigned int hf_type( str *str1);
-int get_username_domain(struct sip_msg *msg, group_check_p gcp,
+int get_username_domain(struct sip_msg *msg, str *hf_s,
str *username, str *domain)
{
struct sip_uri puri;
struct sip_uri *turi;
struct hdr_field* h;
struct auth_body* c = 0; /* Makes gcc happy */
- pv_value_t value;
turi = NULL;
- switch(gcp->id) {
+ switch( hf_type(hf_s) ) {
case 1: /* Request-URI */
if(parse_sip_msg_uri(msg)<0) {
LM_ERR("failed to get Request-URI\n");
@@ -92,22 +91,16 @@
c = (auth_body_t*)(h->parsed);
break;
- case 5: /* AVP spec */
- if(pv_get_spec_value( msg, &gcp->sp, &value)!=0
- || value.flags&PV_VAL_NULL || value.rs.len<=0)
- {
- LM_ERR("no AVP found (error in scripts)\n");
+ default: /* string */
+ if (parse_uri(hf_s->s, hf_s->len, &puri) < 0) {
+ LM_ERR("failed to parse URI <%.*s>\n",hf_s->len, hf_s->s);
return -1;
}
- if (parse_uri(value.rs.s, value.rs.len, &puri) < 0) {
- LM_ERR("failed to parse URI <%.*s>\n",value.rs.len, value.rs.s);
- return -1;
- }
turi = &puri;
break;
}
- if (gcp->id != 4) {
+ if ( c==NULL ) {
*username = turi->user;
*domain = turi->host;
} else {
@@ -148,13 +141,7 @@
return -1;
}
- group_check_p hfPtr = get_hf(hf_s.s);
- if (hfPtr==NULL) {
- LM_ERR("unable to get user/dom source\n");
- return -1;
- }
-
- if ( get_username_domain( _msg, hfPtr, &(VAL_STR(vals)),
+ if ( get_username_domain( _msg, &hf_s, &(VAL_STR(vals)),
&(VAL_STR(vals+2)))!=0) {
LM_ERR("failed to get usern...@domain\n");
return -1;
@@ -235,46 +222,20 @@
}
/*
- * * Convert HF description string to hdr_field pointer
- * *
- * * Supported strings:
* * "Request-URI", "To", "From", "Credentials"
- * * It is a copy from get_hf at group_mod.c
*/
-static group_check_p get_hf( char *str1)
+static unsigned int hf_type( str *str1)
{
- group_check_p gcp=NULL;
- str s;
-
- gcp = (group_check_p)pkg_malloc(sizeof(group_check_t));
- if(gcp == NULL) {
- LM_ERR("no pkg more memory\n");
- return NULL;
- }
- memset(gcp, 0, sizeof(group_check_t));
-
- if (!strcasecmp( str1, "Request-URI")) {
- gcp->id = 1;
- } else if (!strcasecmp( str1, "To")) {
- gcp->id = 2;
- } else if (!strcasecmp( str1, "From")) {
- gcp->id = 3;
- } else if (!strcasecmp( str1, "Credentials")) {
- gcp->id = 4;
+ if (str1->len==11 && !strncasecmp( str1->s, "Request-URI",11)) {
+ return 1;
+ } else if (str1->len==2 && !strncasecmp( str1->s, "To", 2)) {
+ return 2;
+ } else if (str1->len==4 && !strncasecmp( str1->s, "From", 4)) {
+ return 3;
+ } else if (str1->len==11 && !strncasecmp( str1->s, "Credentials",11)) {
+ return 4;
} else {
- s.s = str1; s.len = strlen(s.s);
- if(pv_parse_spec( &s, &gcp->sp)==NULL || gcp->sp.type!=PVT_AVP)
- {
- LM_ERR("unsupported User Field identifier\n");
- pkg_free( gcp );
- return NULL;
- }
- gcp->id = 5;
+ return 0;
}
- /* do not free all the time, needed by pseudo-variable spec */
- if(gcp->id!=5)
- pkg_free(str1);
-
- return gcp;
}
_______________________________________________
Users mailing list
[email protected]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users