diff options
| author | Franklin Wei <git@fwei.tk> | 2016-04-03 12:15:44 -0400 |
|---|---|---|
| committer | Franklin Wei <git@fwei.tk> | 2016-04-03 12:15:44 -0400 |
| commit | 724f4ee59b0af7b64a3317af3c9ee5d3f45e9fc4 (patch) | |
| tree | 9e1f93726995bfd2d8e2e355f7ca3d0869be037f /src/auth.c | |
| parent | 73c9244faee21a65e2143cc52dcbcf5cfe0648c6 (diff) | |
| download | netcosm-724f4ee59b0af7b64a3317af3c9ee5d3f45e9fc4.zip netcosm-724f4ee59b0af7b64a3317af3c9ee5d3f45e9fc4.tar.gz netcosm-724f4ee59b0af7b64a3317af3c9ee5d3f45e9fc4.tar.bz2 netcosm-724f4ee59b0af7b64a3317af3c9ee5d3f45e9fc4.tar.xz | |
various fixes
Diffstat (limited to 'src/auth.c')
| -rw-r--r-- | src/auth.c | 15 |
1 files changed, 9 insertions, 6 deletions
@@ -20,6 +20,7 @@ #include "auth.h" #include "client.h" +#include "server.h" #include "userdb.h" static bool valid_login_name(const char *name); @@ -38,7 +39,7 @@ static char *hash_pass_hex(const char *pass, const char *salt) unsigned char hash[AUTH_HASHLEN]; - SHA512(salted, pass_len + SALT_LEN, hash); + AUTH_HASHFUNC(salted, pass_len + SALT_LEN, hash); unsigned char tmp[AUTH_HASHLEN]; /* now hash the hash a million times to slow things down */ @@ -176,13 +177,16 @@ void first_run_setup(void) struct userdata_t *auth_check(const char *name2, const char *pass2) { + if(!are_child) + debugf("WARNING: auth_check called from master!\n"); + /* get our own copy to remove newlines */ char *name = strdup(name2); char *pass = strdup(pass2); remove_cruft(name); remove_cruft(pass); - /* find it in the user list */ + /* request data from the master process */ struct userdata_t *data = userdb_request_lookup(name); free(name); @@ -191,8 +195,6 @@ struct userdata_t *auth_check(const char *name2, const char *pass2) if(data) { - debugf("auth module: user %s found\n", name2); - /* hashes are in lowercase hex to avoid the Trucha bug * but still allow comparison with strcmp() */ char *new_hash_hex = hash_pass_hex(pass, salt); @@ -216,12 +218,13 @@ struct userdata_t *auth_check(const char *name2, const char *pass2) } } - debugf("auth failure for user %s\n", name2); + debugf("Authentication failure for user %s\n", name2); memset(pass, 0, strlen(pass)); free(pass); - /* failure */ + /* failure: note that this function should be run exclusively by + * child processes */ sleep(2); return NULL; } |