aboutsummaryrefslogtreecommitdiffstats
path: root/src/eap_server
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2012-09-01 18:32:22 (GMT)
committerJouni Malinen <j@w1.fi>2012-09-01 18:32:22 (GMT)
commite95ffe04656245155f24f908da7985be83e724dd (patch)
treec4d3c5d430d7dab77637eecd297a9641cbeb06e7 /src/eap_server
parent741596a817c3037320471fd8adc1dd9e078b1561 (diff)
downloadhostap-e95ffe04656245155f24f908da7985be83e724dd.zip
hostap-e95ffe04656245155f24f908da7985be83e724dd.tar.gz
hostap-e95ffe04656245155f24f908da7985be83e724dd.tar.bz2
EAP-SIM DB: Return pseudonym username instead of structure with it
This cleans up the implemenation a bit. Signed-hostap: Jouni Malinen <j@w1.fi>
Diffstat (limited to 'src/eap_server')
-rw-r--r--src/eap_server/eap_sim_db.c22
1 files changed, 7 insertions, 15 deletions
diff --git a/src/eap_server/eap_sim_db.c b/src/eap_server/eap_sim_db.c
index 474b172..8d2d45c 100644
--- a/src/eap_server/eap_sim_db.c
+++ b/src/eap_server/eap_sim_db.c
@@ -216,26 +216,23 @@ static int get_pseudonym_cb(void *ctx, int argc, char *argv[], char *col[])
}
-static struct eap_sim_pseudonym *
+static char *
db_get_pseudonym(struct eap_sim_db_data *data, const char *pseudonym)
{
char cmd[128];
if (!valid_db_string(pseudonym))
return NULL;
- os_memset(&data->db_tmp_pseudonym, 0, sizeof(data->db_tmp_pseudonym));
- os_strlcpy(data->db_tmp_pseudonym_str, pseudonym,
- sizeof(data->db_tmp_pseudonym_str));
- data->db_tmp_pseudonym.pseudonym = data->db_tmp_pseudonym_str;
+ os_memset(&data->db_tmp_identity, 0, sizeof(data->db_tmp_identity));
os_snprintf(cmd, sizeof(cmd),
"SELECT permanent FROM pseudonyms WHERE pseudonym='%s';",
pseudonym);
if (sqlite3_exec(data->sqlite_db, cmd, get_pseudonym_cb, data, NULL) !=
SQLITE_OK)
return NULL;
- if (data->db_tmp_pseudonym.permanent == NULL)
+ if (data->db_tmp_identity[0] == '\0')
return NULL;
- return &data->db_tmp_pseudonym;
+ return data->db_tmp_identity;
}
@@ -945,7 +942,7 @@ int eap_sim_db_get_gsm_triplets(void *priv, const char *username, int max_chal,
}
-static struct eap_sim_pseudonym *
+static const char *
eap_sim_db_get_pseudonym(struct eap_sim_db_data *data, const char *pseudonym)
{
struct eap_sim_pseudonym *p;
@@ -963,7 +960,7 @@ eap_sim_db_get_pseudonym(struct eap_sim_db_data *data, const char *pseudonym)
p = data->pseudonyms;
while (p) {
if (os_strcmp(p->pseudonym, pseudonym) == 0)
- return p;
+ return p->permanent;
p = p->next;
}
@@ -1274,16 +1271,11 @@ int eap_sim_db_add_reauth_prime(void *priv, const char *permanent,
const char * eap_sim_db_get_permanent(void *priv, const char *pseudonym)
{
struct eap_sim_db_data *data = priv;
- struct eap_sim_pseudonym *p;
if (pseudonym == NULL)
return NULL;
- p = eap_sim_db_get_pseudonym(data, pseudonym);
- if (p == NULL)
- return NULL;
-
- return p->permanent;
+ return eap_sim_db_get_pseudonym(data, pseudonym);
}