Use the credentials converter to determine user level.

This commit is contained in:
Jan Vidar Krey 2010-07-29 10:39:34 +02:00
parent 7c1e38602c
commit 5d135bb5b7

View File

@ -103,21 +103,26 @@ static int parse_line(char* line, int line_count, void* ptr_data)
enum auth_credentials cred; enum auth_credentials cred;
if (cfg_token_count(tokens) == 0) if (cfg_token_count(tokens) == 0)
{
cfg_tokens_free(tokens);
return 0; return 0;
}
if (cfg_token_count(tokens) < 2) if (cfg_token_count(tokens) < 2)
{
cfg_tokens_free(tokens);
return -1; return -1;
}
char* credential = cfg_token_get_first(tokens); char* credential = cfg_token_get_first(tokens);
char* username = cfg_token_get_next(tokens); char* username = cfg_token_get_next(tokens);
char* password = cfg_token_get_next(tokens); char* password = cfg_token_get_next(tokens);
if (strcmp(credential, "admin")) cred = auth_cred_admin; if (!auth_string_to_cred(credential, &cred))
else if (strcmp(credential, "super")) cred = auth_cred_super; {
else if (strcmp(credential, "op")) cred = auth_cred_operator; cfg_tokens_free(tokens);
else if (strcmp(credential, "reg")) cred = auth_cred_user;
else
return -1; return -1;
}
insert_user(users, username, password, cred); insert_user(users, username, password, cred);
cfg_tokens_free(tokens); cfg_tokens_free(tokens);