mirror of
https://github.com/falk-werner/webfused
synced 2024-10-27 20:44:08 +00:00
make userdb optional
This commit is contained in:
parent
3c0fce8eee
commit
dfd2cd4bc0
40
meson.build
40
meson.build
@ -1,30 +1,42 @@
|
|||||||
project('webfused', 'c', 'cpp', version: '0.6.0', license: 'LGPL-3.0+')
|
project('webfused', 'c', 'cpp', version: '0.6.0', license: 'LGPL-3.0+')
|
||||||
|
|
||||||
without_tests = get_option('without_tests')
|
without_tests = get_option('without_tests')
|
||||||
|
without_userdb = get_option('without_userdb')
|
||||||
|
|
||||||
c_compiler = meson.get_compiler('c')
|
c_compiler = meson.get_compiler('c')
|
||||||
|
|
||||||
openssl_dep = dependency('openssl', version: '>=1.1.1')
|
libconfig_dep = dependency('libconfig', version: '>=1.4')
|
||||||
libconfig_dep = dependency('libconfig', version: '>=1.5')
|
|
||||||
pam_dep = c_compiler.find_library('pam')
|
pam_dep = c_compiler.find_library('pam')
|
||||||
|
|
||||||
libwebsockets_dep = dependency('libwebsockets', version: '>=4.0.0')
|
libwebsockets_dep = dependency('libwebsockets', version: '>=4.0.0')
|
||||||
jansson_dep = dependency('jansson', version: '>=2.11')
|
libfuse_dep = dependency('fuse3', version: '>=3.1.0')
|
||||||
libfuse_dep = dependency('fuse3', version: '>=3.8.0')
|
|
||||||
|
|
||||||
webfuse_adapter_dep = dependency('webfuse', version: '>=0.5.0')
|
webfuse_adapter_dep = dependency('webfuse', version: '>=0.5.0')
|
||||||
|
|
||||||
inc_dir = include_directories('src')
|
inc_dir = include_directories('src')
|
||||||
|
|
||||||
libuserdb = static_library('userdb',
|
if not without_userdb
|
||||||
'src/userdb/userdb.c',
|
openssl_dep = dependency('openssl', version: '>=1.1.1')
|
||||||
include_directories: inc_dir,
|
jansson_dep = dependency('jansson', version: '>=2.7')
|
||||||
dependencies: [libconfig_dep, openssl_dep, jansson_dep])
|
|
||||||
|
|
||||||
libuserdb_dep = declare_dependency(
|
libuserdb = static_library('userdb',
|
||||||
include_directories: inc_dir,
|
'src/userdb/userdb_openssl.c',
|
||||||
link_with: libuserdb,
|
include_directories: inc_dir,
|
||||||
dependencies: [libconfig_dep, openssl_dep, jansson_dep])
|
dependencies: [openssl_dep, jansson_dep])
|
||||||
|
|
||||||
|
libuserdb_dep = declare_dependency(
|
||||||
|
include_directories: inc_dir,
|
||||||
|
link_with: libuserdb,
|
||||||
|
dependencies: [openssl_dep, jansson_dep])
|
||||||
|
else
|
||||||
|
libuserdb = static_library('userdb',
|
||||||
|
'src/userdb/userdb_none.c',
|
||||||
|
include_directories: inc_dir)
|
||||||
|
|
||||||
|
libuserdb_dep = declare_dependency(
|
||||||
|
include_directories: inc_dir,
|
||||||
|
link_with: libuserdb)
|
||||||
|
endif
|
||||||
|
|
||||||
libwebfused = static_library('webfused',
|
libwebfused = static_library('webfused',
|
||||||
'src/webfused/daemon.c',
|
'src/webfused/daemon.c',
|
||||||
@ -43,13 +55,13 @@ libwebfused = static_library('webfused',
|
|||||||
'src/webfused/log/stderr_logger.c',
|
'src/webfused/log/stderr_logger.c',
|
||||||
'src/webfused/log/syslog_logger.c',
|
'src/webfused/log/syslog_logger.c',
|
||||||
include_directories: inc_dir,
|
include_directories: inc_dir,
|
||||||
dependencies: [libuserdb_dep, webfuse_adapter_dep, pam_dep],
|
dependencies: [libuserdb_dep, webfuse_adapter_dep, libconfig_dep, pam_dep],
|
||||||
install: false)
|
install: false)
|
||||||
|
|
||||||
libwebfused_dep = declare_dependency(
|
libwebfused_dep = declare_dependency(
|
||||||
include_directories: inc_dir,
|
include_directories: inc_dir,
|
||||||
link_with: libwebfused,
|
link_with: libwebfused,
|
||||||
dependencies: [libuserdb_dep, webfuse_adapter_dep, pam_dep],
|
dependencies: [libuserdb_dep, webfuse_adapter_dep, libconfig_dep, pam_dep],
|
||||||
install: false)
|
install: false)
|
||||||
|
|
||||||
webfused = executable('webfused',
|
webfused = executable('webfused',
|
||||||
|
@ -1 +1,2 @@
|
|||||||
option('without_tests', type: 'boolean', value: false, description: 'disable unit tests')
|
option('without_tests', type: 'boolean', value: false, description: 'disable unit tests')
|
||||||
|
option('without_userdb', type: 'boolean', value: false, description: 'disable userdb')
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
#include <openssl/opensslv.h>
|
#include <openssl/opensslv.h>
|
||||||
#include <openssl/engine.h>
|
#include <openssl/engine.h>
|
||||||
#include <openssl/evp.h>
|
#include <openssl/evp.h>
|
||||||
#include <jansson.h>
|
|
||||||
#include <userdb/userdb.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");
|
fprintf(stderr, "error: missing command\n");
|
||||||
args->show_help = true;
|
args->show_help = true;
|
||||||
result = EXIT_FAILURE;
|
result = EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -301,4 +300,4 @@ int main(int argc, char * argv[])
|
|||||||
args_cleanup(&args);
|
args_cleanup(&args);
|
||||||
openssl_cleanup();
|
openssl_cleanup();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
74
src/userdb/userdb_none.c
Normal file
74
src/userdb/userdb_none.c
Normal 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;
|
||||||
|
}
|
@ -9,8 +9,8 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
|
||||||
#if ((LIBCONFIG_VER_MAJOR != 1) || (LIBCONFIG_VER_MINOR < 5))
|
#if ((LIBCONFIG_VER_MAJOR != 1) || (LIBCONFIG_VER_MINOR < 4))
|
||||||
#error "linconfig 1.5 or higher needed"
|
#error "libconfig 1.5 or higher needed"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ wfd_config_check_version(
|
|||||||
|
|
||||||
if (WFD_CONFIG_VERSION_MAJOR != version_major)
|
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",
|
"incompatible versions: expected %d, but war %d",
|
||||||
WFD_CONFIG_VERSION_MAJOR, version_major);
|
WFD_CONFIG_VERSION_MAJOR, version_major);
|
||||||
return false;
|
return false;
|
||||||
@ -163,7 +163,7 @@ wfd_config_read_authenticator(
|
|||||||
}
|
}
|
||||||
|
|
||||||
char const * provider_name = NULL;
|
char const * provider_name = NULL;
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
int rc = config_setting_lookup_string(authenticator, "provider", &provider_name);
|
int rc = config_setting_lookup_string(authenticator, "provider", &provider_name);
|
||||||
if (CONFIG_TRUE != rc)
|
if (CONFIG_TRUE != rc)
|
||||||
@ -213,7 +213,7 @@ wfd_config_read_authentication(
|
|||||||
result = wfd_config_read_authenticator(authenticator, builder);
|
result = wfd_config_read_authenticator(authenticator, builder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,7 +272,7 @@ wfd_config_read_user(
|
|||||||
struct wfd_config * builder)
|
struct wfd_config * builder)
|
||||||
{
|
{
|
||||||
bool result = true;
|
bool result = true;
|
||||||
|
|
||||||
bool has_user = (NULL != config_lookup(config, "user"));
|
bool has_user = (NULL != config_lookup(config, "user"));
|
||||||
if (has_user)
|
if (has_user)
|
||||||
{
|
{
|
||||||
@ -318,12 +318,12 @@ wfd_config_load(
|
|||||||
&& wfd_config_read_filesystems(config, result)
|
&& wfd_config_read_filesystems(config, result)
|
||||||
&& wfd_config_read_user(config, result)
|
&& wfd_config_read_user(config, result)
|
||||||
;
|
;
|
||||||
|
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
wfd_config_read_server(config, result);
|
wfd_config_read_server(config, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!success)
|
if (!success)
|
||||||
{
|
{
|
||||||
wfd_config_dispose(result);
|
wfd_config_dispose(result);
|
||||||
@ -348,13 +348,13 @@ wfd_config_load_file(
|
|||||||
}
|
}
|
||||||
else
|
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_file(&config),
|
||||||
config_error_line(&config),
|
config_error_line(&config),
|
||||||
config_error_text(&config));
|
config_error_text(&config));
|
||||||
}
|
}
|
||||||
config_destroy(&config);
|
config_destroy(&config);
|
||||||
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -374,12 +374,12 @@ wfd_config_load_string(
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WFD_ERROR("failed to load config: %d: %s",
|
WFD_ERROR("failed to load config: %d: %s",
|
||||||
config_error_line(&config),
|
config_error_line(&config),
|
||||||
config_error_text(&config));
|
config_error_text(&config));
|
||||||
}
|
}
|
||||||
config_destroy(&config);
|
config_destroy(&config);
|
||||||
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user