1
0
mirror of https://github.com/falk-werner/webfused synced 2026-03-02 04:09:19 +00:00

make userdb optional

This commit is contained in:
Falk Werner
2020-11-11 21:56:11 +01:00
parent 3c0fce8eee
commit dfd2cd4bc0
6 changed files with 116 additions and 30 deletions

View File

@@ -10,7 +10,6 @@
#include <openssl/opensslv.h>
#include <openssl/engine.h>
#include <openssl/evp.h>
#include <jansson.h>
#include <userdb/userdb.h>
@@ -131,7 +130,7 @@ static int parse_args(struct args * args, int argc, char * argv[])
fprintf(stderr, "error: missing command\n");
args->show_help = true;
result = EXIT_FAILURE;
}
}
}
return result;
@@ -301,4 +300,4 @@ int main(int argc, char * argv[])
args_cleanup(&args);
openssl_cleanup();
return result;
}
}

74
src/userdb/userdb_none.c Normal file
View File

@@ -0,0 +1,74 @@
#include "userdb.h"
#include <stddef.h>
struct userdb * userdb_create(
char const * pepper)
{
(void) pepper;
return NULL;
}
void userdb_dispose(struct userdb * db)
{
(void) db;
}
bool userdb_save(
struct userdb * db,
char const * filename)
{
(void) db;
(void) filename;
return false;
}
bool userdb_load_file(
struct userdb * db,
char const * filename)
{
(void) db;
(void) filename;
return false;
}
bool userdb_load_string(
struct userdb * db,
char const * contents)
{
(void) db;
(void) contents;
return false;
}
void userdb_add(
struct userdb * db,
char const * username,
char const * password)
{
(void) db;
(void) username;
(void) password;
}
void userdb_remove(
struct userdb * db,
char const * user)
{
(void) db;
(void) user;
}
bool userdb_check(
struct userdb * db,
char const * username,
char const * password)
{
(void) db;
(void) username;
(void) password;
return false;
}

View File

@@ -9,8 +9,8 @@
#include <stdbool.h>
#if ((LIBCONFIG_VER_MAJOR != 1) || (LIBCONFIG_VER_MINOR < 5))
#error "linconfig 1.5 or higher needed"
#if ((LIBCONFIG_VER_MAJOR != 1) || (LIBCONFIG_VER_MINOR < 4))
#error "libconfig 1.5 or higher needed"
#endif
@@ -31,7 +31,7 @@ wfd_config_check_version(
if (WFD_CONFIG_VERSION_MAJOR != version_major)
{
WFD_ERROR("failed to load config: "
WFD_ERROR("failed to load config: "
"incompatible versions: expected %d, but war %d",
WFD_CONFIG_VERSION_MAJOR, version_major);
return false;
@@ -163,7 +163,7 @@ wfd_config_read_authenticator(
}
char const * provider_name = NULL;
if (result)
if (result)
{
int rc = config_setting_lookup_string(authenticator, "provider", &provider_name);
if (CONFIG_TRUE != rc)
@@ -213,7 +213,7 @@ wfd_config_read_authentication(
result = wfd_config_read_authenticator(authenticator, builder);
}
}
return result;
}
@@ -272,7 +272,7 @@ wfd_config_read_user(
struct wfd_config * builder)
{
bool result = true;
bool has_user = (NULL != config_lookup(config, "user"));
if (has_user)
{
@@ -318,12 +318,12 @@ wfd_config_load(
&& wfd_config_read_filesystems(config, result)
&& wfd_config_read_user(config, result)
;
if (success)
{
wfd_config_read_server(config, result);
}
if (!success)
{
wfd_config_dispose(result);
@@ -348,13 +348,13 @@ wfd_config_load_file(
}
else
{
WFD_ERROR("failed to load config: %s: %d: %s",
WFD_ERROR("failed to load config: %s: %d: %s",
config_error_file(&config),
config_error_line(&config),
config_error_text(&config));
}
config_destroy(&config);
return result;
}
@@ -374,12 +374,12 @@ wfd_config_load_string(
}
else
{
WFD_ERROR("failed to load config: %d: %s",
WFD_ERROR("failed to load config: %d: %s",
config_error_line(&config),
config_error_text(&config));
}
config_destroy(&config);
return result;
}