Changeset 4474:bf3206323cae in roaraudio for roard/auth.c
- Timestamp:
- 10/11/10 00:10:25 (14 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
roard/auth.c
r4469 r4474 37 37 } 38 38 39 // enable guest access. 40 if ( auth_regkey_simple(ROAR_AUTH_T_NONE, ACCLEV_ALL) == NULL ) 41 return -1; 42 39 43 return 0; 40 44 } … … 44 48 } 45 49 50 union auth_typeunion * auth_regkey_simple(int type, enum roard_client_acclev acclev) { 51 struct auth_key * key; 52 int i; 53 54 for (i = 0; i < AUTH_KEYRING_LEN; i++) { 55 if ( (key = &(g_auth_keyring[i]))->type == _NONE ) { 56 memset(key, 0, sizeof(struct auth_key)); 57 key->type = type; 58 key->acclev = acclev; 59 return &(key->at_data); 60 } 61 } 62 63 return NULL; 64 } 65 66 static int _ck_password(struct auth_key * key, struct roar_auth_message * authmes) { 67 size_t len = strlen(key->at_data.password.password); 68 69 // need to check here if we have a padding \0-byte. 70 71 if ( len == authmes->len ) { 72 if ( memcmp(key->at_data.password.password, authmes->data, len) ) { 73 return -1; 74 } else { 75 return 1; 76 } 77 } 78 79 return -1; 80 } 81 82 int auth_client_ckeck(struct roar_client_server * cs, struct roar_auth_message * authmes) { 83 struct auth_key * key; 84 int i; 85 int ret; 86 87 if ( cs == NULL || authmes == NULL ) 88 return -1; 89 90 for (i = 0; i < AUTH_KEYRING_LEN; i++) { 91 if ( (key = &(g_auth_keyring[i]))->type == authmes->type ) { 92 ret = -1; 93 switch (key->type) { 94 case ROAR_AUTH_T_NONE: 95 ret = 1; 96 break; 97 case ROAR_AUTH_T_PASSWORD: 98 ret = _ck_password(key, authmes); 99 break; 100 case ROAR_AUTH_T_TRUST: 101 case ROAR_AUTH_T_COOKIE: 102 case ROAR_AUTH_T_SYSUSER: 103 case ROAR_AUTH_T_RHOST: 104 default: 105 /* don't know what to do... */ 106 return -1; 107 break; 108 } 109 switch (ret) { 110 case -1: 111 /* ignore this case and continue */ 112 break; 113 case 0: 114 return 0; 115 break; 116 case 1: 117 cs->acclev = key->acclev; 118 return 1; 119 break; 120 default: /* error! */ 121 return -1; 122 break; 123 } 124 } 125 } 126 127 return -1; 128 } 129 46 130 //ll
Note: See TracChangeset
for help on using the changeset viewer.