Changeset 4788:482fc1a96c7a in roaraudio for libroar
- Timestamp:
- 03/11/11 04:10:22 (13 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libroar/auth.c
r4745 r4788 137 137 138 138 mes.cmd = ROAR_CMD_AUTH; 139 mes.datalen = 4; 139 mes.datalen = 4 + authmes->len; 140 141 if ( mes.datalen > sizeof(mes.data) ) 142 return -1; 140 143 141 144 header[0] = authmes->type; … … 143 146 header[2] = authmes->reserved.c[0]; 144 147 header[3] = authmes->reserved.c[1]; 148 149 if ( authmes->len ) { 150 memcpy(mes.data + 4, authmes->data, authmes->len); 151 } 145 152 146 153 if ( (ret = roar_req(con, &mes, NULL)) == -1 ) { … … 222 229 223 230 return -1; 231 } 232 233 static int try_cookie (struct roar_connection * con, int * next) { 234 struct roar_libroar_config * config = roar_libroar_get_config(); 235 struct roar_auth_message authmes; 236 struct roar_authfile * authfile; 237 struct roar_authfile_key * key; 238 int idx; 239 int done = 0; 240 241 roar_auth_mes_init(&authmes, ROAR_AUTH_T_COOKIE); 242 243 if ( (authfile = roar_authfile_open(ROAR_AUTHFILE_TYPE_AUTO, config->authfile, 0, ROAR_AUTHFILE_VERSION_AUTO)) == NULL ) 244 return -1; 245 246 for (idx = 0; !done; idx++) { 247 if ( (key = roar_authfile_lookup_key(authfile, ROAR_AUTH_T_COOKIE, idx, NULL)) == NULL ) 248 break; 249 250 authmes.data = key->data; 251 authmes.len = key->len; 252 253 if ( roar_auth_ask_server(con, &authmes) != -1 ) 254 done = 1; 255 256 roar_authfile_key_unref(key); 257 } 258 259 roar_authfile_close(authfile); 260 261 return done ? 0 : -1; 224 262 } 225 263 … … 236 274 ROAR_AUTH_T_RHOST, 237 275 // ROAR_AUTH_T_PASSWORD, 276 ROAR_AUTH_T_COOKIE, 238 277 ROAR_AUTH_T_NONE, 239 278 _EOL … … 249 288 250 289 switch (cur) { 251 290 case ROAR_AUTH_T_PASSWORD: 252 291 if ( (ret = try_password(con, &next)) == -1 ) 253 292 done = 0; 254 293 break; 255 256 257 258 294 case ROAR_AUTH_T_TRUST: 295 case ROAR_AUTH_T_IDENT: 296 case ROAR_AUTH_T_RHOST: 297 case ROAR_AUTH_T_NONE: 259 298 roar_auth_mes_init(&authmes, ltt[i]); 260 299 if ( (ret = roar_auth_ask_server(con, &authmes)) == -1 ) … … 262 301 263 302 next = authmes.type; 303 break; 304 case ROAR_AUTH_T_COOKIE: 305 if ( (ret = try_cookie(con, &next)) == -1 ) 306 done = 0; 307 break; 264 308 break; 265 309 default: /* Bad error! */
Note: See TracChangeset
for help on using the changeset viewer.