opensips/opensips.patch.uac

changeset 397
c98ae03f4266
parent 382
b972dc20871f
equal deleted inserted replaced
1:462f0283947f 2:c740a050db10
1 Index: modules/uac/auth.c 1 Index: modules/uac/auth.c
2 diff -Nau modules/uac/auth.c.orig modules/uac/auth.c 2 diff -Nau modules/uac/auth.c.orig modules/uac/auth.c
3 --- modules/uac/auth.c.orig 2008-08-03 15:53:40.000000000 +0200 3 --- modules/uac/auth.c.orig 2008-08-03 15:53:40.000000000 +0200
4 +++ modules/uac/auth.c 2009-03-24 21:48:53.478867420 +0100 4 +++ modules/uac/auth.c 2009-03-24 21:48:53.478867420 +0100
5 @@ -375,14 +375,172 @@ 5 @@ -143,14 +143,172 @@
6 HASHHEX response; 6 HASHHEX response;
7 str *new_hdr; 7 str *new_hdr;
8 8
9 + /* pretransact */ 9 + /* pretransact */
10 + int nret = 0; 10 + int nret = 0;
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 = lookup_realm(&crd->realm); 73 + tst = uac_auth_api._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 + do_uac_auth(msg, newuri, crd, &auth, response); 142 + uac_auth_api._do_uac_auth(msg, newuri, crd, auth, &auth_nc_cnonce, 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 = build_authorization_hdr(407, newuri, crd, &auth, response); 150 + new_hdr = uac_auth_api._build_authorization_hdr(407, newuri, crd, auth, &auth_nc_cnonce, 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 @@ -106,7 +106,7 @@ 187 @@ -117,7 +117,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 },

mercurial