diff --git a/CMakeLists.txt b/CMakeLists.txt index c1daeeb..ced825a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -213,9 +213,9 @@ add_executable(webfused example/daemon/main.c ) -target_link_libraries(webfused PUBLIC webfuse-adapter ${EXTRA_LIBS}) +target_link_libraries(webfused PUBLIC webfuse-adapter userdb ${OPENSSL_LIBRARIES} ${EXTRA_LIBS}) target_include_directories(webfused PUBLIC ${EXTRA_INCLUDE_DIRS}) -target_compile_options(webfused PUBLIC ${EXTRA_CFLAGS}) +target_compile_options(webfused PUBLIC ${C_WARNINGS} ${OPENSSL_CFLAGS_OTHER} ${EXTRA_CFLAGS}) # provider diff --git a/example/daemon/main.c b/example/daemon/main.c index f9b4798..1bafb8c 100644 --- a/example/daemon/main.c +++ b/example/daemon/main.c @@ -7,9 +7,9 @@ #include #include -#include #include +#include struct args @@ -50,24 +50,16 @@ static bool authenticate(struct wf_credentials * creds, void * user_data) char const * password = wf_credentials_get(creds, "password"); if ((NULL != username) && (NULL != password)) { - json_t * passwd = json_load_file(args->passwd_path, 0, NULL); - if (NULL != passwd) + struct userdb * db = userdb_create(""); + result = userdb_load(db, args->passwd_path); + if (result) { - json_t * user = json_object_get(passwd, username); - if (json_is_object(user)) - { - json_t * password_holder = json_object_get(user, "password"); - if (json_is_string(password_holder)) - { - result = (0 == strcmp(password, json_string_value(password_holder))); - } - } - - json_decref(passwd); + result = userdb_check(db, username, password); + userdb_dispose(db); } } - return result; + return result; } static int parse_arguments(int argc, char * argv[], struct args * args)