68 + nret++; /* signal failure with nonzero value */ |
68 + nret++; /* signal failure with nonzero value */ |
69 + else |
69 + else |
70 + crd->passwd = pv_val.rs; |
70 + crd->passwd = pv_val.rs; |
71 + |
71 + |
72 + if (nret) { /* if not found, look into predefined credentials */ |
72 + if (nret) { /* if not found, look into predefined credentials */ |
73 + tst = uac_auth_api._lookup_realm(&crd->realm); |
73 + tst = lookup_realm(&crd->realm); |
74 + |
74 + |
75 + if (tst==0) { /* found? */ |
75 + if (tst==0) { /* found? */ |
76 + LM_DBG("no credential for realm \"%.*s\"\n", \ |
76 + LM_DBG("no credential for realm \"%.*s\"\n", \ |
77 + crd->realm.len, crd->realm.s); |
77 + crd->realm.len, crd->realm.s); |
78 + pkg_free(crd); |
78 + pkg_free(crd); |
119 + goto error; |
119 + goto error; |
120 + } |
120 + } |
121 + |
121 + |
122 + /* set the nonce from existing UAC message */ |
122 + /* set the nonce from existing UAC message */ |
123 + tmp_hdr = msg->proxy_auth; |
123 + tmp_hdr = msg->proxy_auth; |
124 + auth->nonce.len = 0; |
124 + auth.nonce.len = 0; |
125 + auth->nonce.s = 0; |
125 + auth.nonce.s = 0; |
126 + while (tmp_hdr) { |
126 + while (tmp_hdr) { |
127 + if(pv_get_spec_value(msg, &auth_realm_spec, &pv_val)==0 \ |
127 + if(pv_get_spec_value(msg, &auth_realm_spec, &pv_val)==0 \ |
128 + && pv_val.rs.len>0) /* ensure realm is the desired one */ |
128 + && pv_val.rs.len>0) /* ensure realm is the desired one */ |
129 + if (strncmp(crd->realm.s, pv_val.rs.s, crd->realm.len)==0) { |
129 + if (strncmp(crd->realm.s, pv_val.rs.s, crd->realm.len)==0) { |
130 + auth->nonce.s = strchr(strstr(tmp_hdr->body.s, "nonce="), '"') + 1; |
130 + auth.nonce.s = strchr(strstr(tmp_hdr->body.s, "nonce="), '"') + 1; |
131 + auth->nonce.len = strchr(auth->nonce.s, '"') - auth->nonce.s; |
131 + auth.nonce.len = strchr(auth.nonce.s, '"') - auth.nonce.s; |
132 + } |
132 + } |
133 + tmp_hdr = tmp_hdr->sibling; |
133 + tmp_hdr = tmp_hdr->sibling; |
134 + } |
134 + } |
135 + if (auth->nonce.s == 0) { |
135 + if (auth.nonce.s == 0) { |
136 + LM_DBG("failed to retrieve nonce from UAC message\n"); |
136 + LM_DBG("failed to retrieve nonce from UAC message\n"); |
137 + pkg_free(crd); |
137 + pkg_free(crd); |
138 + goto error; |
138 + goto error; |
139 + } |
139 + } |
140 + |
140 + |
141 + /* do authentication */ |
141 + /* do authentication */ |
142 + uac_auth_api._do_uac_auth(msg, newuri, crd, auth, &auth_nc_cnonce, response); |
142 + do_uac_auth(msg, newuri, crd, &auth, response); |
143 + if (response==0) { |
143 + if (response==0) { |
144 + LM_ERR("failed to calculate challenge response\n"); |
144 + LM_ERR("failed to calculate challenge response\n"); |
145 + pkg_free(crd); |
145 + pkg_free(crd); |
146 + goto error; |
146 + goto error; |
147 + } |
147 + } |
148 + |
148 + |
149 + /* build the authorization header */ |
149 + /* build the authorization header */ |
150 + new_hdr = uac_auth_api._build_authorization_hdr(407, newuri, crd, auth, &auth_nc_cnonce, response); |
150 + new_hdr = build_authorization_hdr(407, newuri, crd, &auth, response); |
151 + if (new_hdr==0) { |
151 + if (new_hdr==0) { |
152 + LM_ERR("failed to build authorization hdr\n"); |
152 + LM_ERR("failed to build authorization hdr\n"); |
153 + pkg_free(crd); |
153 + pkg_free(crd); |
154 + goto error; |
154 + goto error; |
155 + } |
155 + } |
182 if (branch<0) { |
182 if (branch<0) { |
183 Index: modules/uac/uac.c |
183 Index: modules/uac/uac.c |
184 diff -Nau modules/uac/uac.c.orig modules/uac/uac.c |
184 diff -Nau modules/uac/uac.c.orig modules/uac/uac.c |
185 --- modules/uac/uac.c.orig 2008-08-03 15:53:40.000000000 +0200 |
185 --- modules/uac/uac.c.orig 2008-08-03 15:53:40.000000000 +0200 |
186 +++ modules/uac/uac.c 2009-03-24 21:49:48.922890737 +0100 |
186 +++ modules/uac/uac.c 2009-03-24 21:49:48.922890737 +0100 |
187 @@ -117,7 +117,7 @@ |
187 @@ -106,7 +106,7 @@ |
188 REQUEST_ROUTE|BRANCH_ROUTE|FAILURE_ROUTE }, |
188 REQUEST_ROUTE|BRANCH_ROUTE|FAILURE_ROUTE }, |
189 {"uac_auth", (cmd_function)w_uac_auth, 0, |
189 {"uac_auth", (cmd_function)w_uac_auth, 0, |
190 0, 0, |
190 0, 0, |
191 - FAILURE_ROUTE }, |
191 - FAILURE_ROUTE }, |
192 + REQUEST_ROUTE|FAILURE_ROUTE }, |
192 + REQUEST_ROUTE|FAILURE_ROUTE }, |