diff --git a/meson.build b/meson.build index 2bdfb7c..80911c8 100644 --- a/meson.build +++ b/meson.build @@ -1,30 +1,42 @@ project('webfused', 'c', 'cpp', version: '0.6.0', license: 'LGPL-3.0+') without_tests = get_option('without_tests') +without_userdb = get_option('without_userdb') c_compiler = meson.get_compiler('c') -openssl_dep = dependency('openssl', version: '>=1.1.1') -libconfig_dep = dependency('libconfig', version: '>=1.5') +libconfig_dep = dependency('libconfig', version: '>=1.4') pam_dep = c_compiler.find_library('pam') libwebsockets_dep = dependency('libwebsockets', version: '>=4.0.0') -jansson_dep = dependency('jansson', version: '>=2.11') -libfuse_dep = dependency('fuse3', version: '>=3.8.0') +libfuse_dep = dependency('fuse3', version: '>=3.1.0') webfuse_adapter_dep = dependency('webfuse', version: '>=0.5.0') inc_dir = include_directories('src') -libuserdb = static_library('userdb', - 'src/userdb/userdb.c', - include_directories: inc_dir, - dependencies: [libconfig_dep, openssl_dep, jansson_dep]) - -libuserdb_dep = declare_dependency( - include_directories: inc_dir, - link_with: libuserdb, - dependencies: [libconfig_dep, openssl_dep, jansson_dep]) +if not without_userdb + openssl_dep = dependency('openssl', version: '>=1.1.1') + jansson_dep = dependency('jansson', version: '>=2.7') + + libuserdb = static_library('userdb', + 'src/userdb/userdb_openssl.c', + include_directories: inc_dir, + 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', 'src/webfused/daemon.c', @@ -43,13 +55,13 @@ libwebfused = static_library('webfused', 'src/webfused/log/stderr_logger.c', 'src/webfused/log/syslog_logger.c', include_directories: inc_dir, - dependencies: [libuserdb_dep, webfuse_adapter_dep, pam_dep], + dependencies: [libuserdb_dep, webfuse_adapter_dep, libconfig_dep, pam_dep], install: false) libwebfused_dep = declare_dependency( include_directories: inc_dir, link_with: libwebfused, - dependencies: [libuserdb_dep, webfuse_adapter_dep, pam_dep], + dependencies: [libuserdb_dep, webfuse_adapter_dep, libconfig_dep, pam_dep], install: false) webfused = executable('webfused', diff --git a/meson_options.txt b/meson_options.txt index ba5d687..b50b512 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1 +1,2 @@ -option('without_tests', type: 'boolean', value: false, description: 'disable unit tests') \ No newline at end of file +option('without_tests', type: 'boolean', value: false, description: 'disable unit tests') +option('without_userdb', type: 'boolean', value: false, description: 'disable userdb') diff --git a/src/passwd/main.c b/src/passwd/main.c index f2313b4..767ccc2 100644 --- a/src/passwd/main.c +++ b/src/passwd/main.c @@ -10,7 +10,6 @@ #include #include #include -#include #include @@ -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; -} \ No newline at end of file +} diff --git a/src/userdb/userdb_none.c b/src/userdb/userdb_none.c new file mode 100644 index 0000000..a6bba23 --- /dev/null +++ b/src/userdb/userdb_none.c @@ -0,0 +1,74 @@ +#include "userdb.h" +#include + +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; +} diff --git a/src/userdb/userdb.c b/src/userdb/userdb_openssl.c similarity index 100% rename from src/userdb/userdb.c rename to src/userdb/userdb_openssl.c diff --git a/src/webfused/config/factory.c b/src/webfused/config/factory.c index 83400bb..7f3f76d 100644 --- a/src/webfused/config/factory.c +++ b/src/webfused/config/factory.c @@ -9,8 +9,8 @@ #include -#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; }