From 575f27dabcbd89351ccffe4a05c274a91c8fcc8a Mon Sep 17 00:00:00 2001 From: Georg Hopp Date: Sun, 22 Sep 2013 12:14:45 +0100 Subject: [PATCH] everything builds again --- include/auth/storage.h | 2 ++ src/Makefile.am | 2 +- src/application/Makefile.am | 1 + src/application/adapter/http/update.c | 2 +- src/application/application.c | 2 +- src/application/signup.c | 12 +++++++----- src/auth/Makefile.am | 6 +++++- src/auth/storage/hash_pw.c | 5 +++-- src/auth/storage/storage.c | 6 +++--- src/storage/Makefile.am | 2 +- src/storage/put.c | 7 ------- src/storage/update.c | 7 ++++++- 12 files changed, 31 insertions(+), 23 deletions(-) diff --git a/include/auth/storage.h b/include/auth/storage.h index 5409f36..26501da 100644 --- a/include/auth/storage.h +++ b/include/auth/storage.h @@ -28,6 +28,8 @@ #include #include "class.h" +#include // storage must move to storage/storage.h + // to be loadable with " #define SALT_SIZE 32 diff --git a/src/Makefile.am b/src/Makefile.am index d1cced4..b0ee584 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -33,7 +33,7 @@ AM_CFLAGS = -Wall -I ../include/ bin_PROGRAMS = taskrambler taskrambler_SOURCES = taskrambler.c $(IFACE) $(UTILS) -taskrambler_CFLAGS = $(CFLAGS) -Wall -DPWD=\"$(PWD)\" -I ../include/# $(COVERAGE_CFLAGS) +taskrambler_CFLAGS = $(CFLAGS) -Wall -DPWD=\"$(PWD)\" -I../include/ # $(COVERAGE_CFLAGS) taskrambler_LDADD = $(LIBS) -lrt -lssl -lldap -lgdbm -luuid #taskrambler_LDFLAGS = $(COVERAGE_LDFLAGS) diff --git a/src/application/Makefile.am b/src/application/Makefile.am index 9e9f036..c901a6e 100644 --- a/src/application/Makefile.am +++ b/src/application/Makefile.am @@ -3,6 +3,7 @@ AUTOMAKE_OPTIONS = subdir-objects APPLICATION = application.c \ login.c \ + signup.c \ session_start.c \ session_stop.c \ session_update.c \ diff --git a/src/application/adapter/http/update.c b/src/application/adapter/http/update.c index a78b28a..01eb375 100644 --- a/src/application/adapter/http/update.c +++ b/src/application/adapter/http/update.c @@ -217,7 +217,7 @@ signupAdapter(Application application, HttpWorker worker, Session session) (char *)(surname->value), surname->nvalue); if (! applicationSignup(application, credential, user, session)) { - worker->current_response = httpResonse500(); + worker->current_response = httpResponse500(); } else { loginAdapter(application, worker, session); } diff --git a/src/application/application.c b/src/application/application.c index ffa1d7c..d038370 100644 --- a/src/application/application.c +++ b/src/application/application.c @@ -57,7 +57,7 @@ applicationCtor(void * _this, va_list * params) * password database. */ this->users = new(Storage, "./run/users.db"); - this->passwords = new(Storage, "./run/passwords.db") + this->passwords = new(Storage, "./run/passwords.db"); return 0; } diff --git a/src/application/signup.c b/src/application/signup.c index acd6b0c..8e3afe3 100644 --- a/src/application/signup.c +++ b/src/application/signup.c @@ -36,11 +36,13 @@ int applicationSignup( Application this, - Credential credential, + Credential cred, User user, Session session) { - unsigned char hash[SALT_SIZE+HASH_SIZE]; + unsigned char hash_data[SALT_SIZE+HASH_SIZE]; + unsigned char * salt = hash_data; + unsigned char * hash = hash_data + SALT_SIZE; if (NULL != userLoad(user, this->users)) { /* @@ -56,8 +58,8 @@ applicationSignup( if (FALSE == hash_pw( CRED_PWD(cred).pass, CRED_PWD(cred).npass, - &hash, - &(hash+SALT_SIZE))) { + hash, + &salt)) { /* * @TODO if we come here we have to delete the previously saved * user again... @@ -69,7 +71,7 @@ applicationSignup( this->passwords, CRED_PWD(cred).user, CRED_PWD(cred).nuser, - hash, + (char *)hash_data, SALT_SIZE + HASH_SIZE); return 0; diff --git a/src/auth/Makefile.am b/src/auth/Makefile.am index 3233da7..6a8c9d0 100644 --- a/src/auth/Makefile.am +++ b/src/auth/Makefile.am @@ -3,5 +3,9 @@ AUTOMAKE_OPTIONS = subdir-objects noinst_LIBRARIES = libauth.a -libauth_a_SOURCES = interface/auth.c credential.c ldap.c +libauth_a_SOURCES = interface/auth.c \ + credential.c \ + ldap.c \ + storage/storage.c \ + storage/hash_pw.c libauth_a_CFLAGS = $(CFLAGS) -Wall -I ../../include/ diff --git a/src/auth/storage/hash_pw.c b/src/auth/storage/hash_pw.c index 93228f3..9614630 100644 --- a/src/auth/storage/hash_pw.c +++ b/src/auth/storage/hash_pw.c @@ -26,8 +26,9 @@ #include #include "class.h" -#include "storage.h" +#include "auth/storage.h" #include "utils/memory.h" +#include "commons.h" /* * I have to hash the passwords, maybe this will move in @@ -78,7 +79,7 @@ hash_pw( { if (NULL == *salt) { *salt = memMalloc(SALT_SIZE * sizeof(unsigned char)); - if (0 > RAND_pseudo_bytes(unsigned char *buf, int num)) { + if (0 > RAND_pseudo_bytes(*salt, SALT_SIZE)) { MEM_FREE(*salt); return FALSE; } diff --git a/src/auth/storage/storage.c b/src/auth/storage/storage.c index 5aa8e47..86373d3 100644 --- a/src/auth/storage/storage.c +++ b/src/auth/storage/storage.c @@ -22,9 +22,9 @@ #include "class.h" #include "storage.h" -#include "auth/storage.h" -#include "auth/credential.h" +#include "auth.h" #include "commons.h" +#include "utils/memory.h" static int @@ -61,7 +61,7 @@ authStorageAuthenticate(void * _this, Credential cred) this->store, CRED_PWD(cred).user, CRED_PWD(cred).nuser, - &found_hash, + (char **)&found_hash, &nfound_hash); if (NULL == found_hash || (SALT_SIZE + HASH_SIZE) != nfound_hash) { diff --git a/src/storage/Makefile.am b/src/storage/Makefile.am index 3e6aeb0..b6ea977 100644 --- a/src/storage/Makefile.am +++ b/src/storage/Makefile.am @@ -3,5 +3,5 @@ AUTOMAKE_OPTIONS = subdir-objects noinst_LIBRARIES = libstorage.a -libstorage_a_SOURCES = storage.c get.c put.c +libstorage_a_SOURCES = storage.c get.c put.c update.c libstorage_a_CFLAGS = $(CFLAGS) -Wall -I ../../include/ diff --git a/src/storage/put.c b/src/storage/put.c index c992e4f..387fa58 100644 --- a/src/storage/put.c +++ b/src/storage/put.c @@ -29,13 +29,6 @@ #include "utils/memory.h" -typedef enum e_StoragePutResults { - SPR_OK = 0, - SPR_READ_ONLY = 1, - SPR_EXISTS = 2, - SPR_UNKNOWN = -1 -} StoragePutResult; - StoragePutResult storagePut(Storage this, char * _key, size_t nkey, char * data, size_t ndata) diff --git a/src/storage/update.c b/src/storage/update.c index a48ef96..3cbaeb2 100644 --- a/src/storage/update.c +++ b/src/storage/update.c @@ -30,7 +30,12 @@ #include "utils/memory.h" StoragePutResult -storagePut(Storage this, char * _key, size_t nkey, char * data, size_t ndata) +storageUpdate( + Storage this, + char * _key, + size_t nkey, + char * data, + size_t ndata) { datum key = {_key, nkey}; datum value = {data, ndata};