diff --git a/lib/libwtmpdb.c b/lib/libwtmpdb.c index d8fa1b6..0a491d6 100644 --- a/lib/libwtmpdb.c +++ b/lib/libwtmpdb.c @@ -25,6 +25,8 @@ POSSIBILITY OF SUCH DAMAGE. */ +#include "config.h" + #include #include #include @@ -32,9 +34,12 @@ #include "basics.h" #include "wtmpdb.h" #include "sqlite.h" + +#if WITH_WTMPDBD #include "varlink.h" static int varlink_is_active = 1; +#endif /* Add new wtmp entry to db. @@ -46,6 +51,7 @@ wtmpdb_login (const char *db_path, int type, const char *user, uint64_t usec_login, const char *tty, const char *rhost, const char *service, char **error) { +#if WITH_WTMPDBD /* we can use varlink only if no specific database is requested */ if (varlink_is_active && db_path == NULL) { @@ -64,7 +70,7 @@ wtmpdb_login (const char *db_path, int type, const char *user, else return id; /* return the error if wtmpdbd is active */ } - +#endif return sqlite_login (db_path?db_path:_PATH_WTMPDB, type, user, usec_login, tty, rhost, service, error); } @@ -79,6 +85,7 @@ int wtmpdb_logout (const char *db_path, int64_t id, uint64_t usec_logout, char **error) { +#if WITH_WTMPDBD /* we can use varlink only if no specific database is requested */ if (varlink_is_active && db_path == NULL) { @@ -96,6 +103,7 @@ wtmpdb_logout (const char *db_path, int64_t id, uint64_t usec_logout, else return r; /* return the error if wtmpdbd is active */ } +#endif return sqlite_logout (db_path?db_path:_PATH_WTMPDB, id, usec_logout, error); } @@ -103,6 +111,7 @@ wtmpdb_logout (const char *db_path, int64_t id, uint64_t usec_logout, int64_t wtmpdb_get_id (const char *db_path, const char *tty, char **error) { +#if WITH_WTMPDBD /* we can use varlink only if no specific database is requested */ if (varlink_is_active && db_path == NULL) { @@ -120,6 +129,7 @@ wtmpdb_get_id (const char *db_path, const char *tty, char **error) else return id; /* return the error if wtmpdbd is active */ } +#endif return sqlite_get_id (db_path?db_path:_PATH_WTMPDB, tty, error); } @@ -153,6 +163,7 @@ int wtmpdb_rotate (const char *db_path, const int days, char **error, char **wtmpdb_name, uint64_t *entries) { +#if WITH_WTMPDBD /* we can use varlink only if no specific database is requested */ if (varlink_is_active && db_path == NULL) { @@ -170,6 +181,7 @@ wtmpdb_rotate (const char *db_path, const int days, char **error, else return r; /* return the error if wtmpdbd is active */ } +#endif return sqlite_rotate (db_path?db_path:_PATH_WTMPDB, days, wtmpdb_name, entries, error); } @@ -178,6 +190,7 @@ wtmpdb_rotate (const char *db_path, const int days, char **error, uint64_t wtmpdb_get_boottime (const char *db_path, char **error) { +#if WITH_WTMPDBD /* we can use varlink only if no specific database is requested */ if (varlink_is_active && db_path == NULL) { @@ -196,6 +209,7 @@ wtmpdb_get_boottime (const char *db_path, char **error) else return 0; /* return the error if wtmpdbd is active */ } +#endif return sqlite_get_boottime (db_path?db_path:_PATH_WTMPDB, error); } diff --git a/lib/varlink.c b/lib/varlink.c index 448f18f..1c48b4c 100644 --- a/lib/varlink.c +++ b/lib/varlink.c @@ -27,7 +27,7 @@ #include "config.h" -#if HAVE_SYSTEMD +#if WITH_WTMPDBD #include #include diff --git a/meson.build b/meson.build index 2227afe..b3584ac 100644 --- a/meson.build +++ b/meson.build @@ -10,8 +10,8 @@ project( 'default_library=shared', 'b_pie=true', 'b_lto=true', - 'warning_level=3',], - license : ['BSD-2-Clause',], + 'warning_level=2'], + license : ['BSD-2-Clause'], version : '0.50.0', ) @@ -103,14 +103,28 @@ else endif conf.set10('HAVE_AUDIT', have_audit) -want_systemd = get_option('systemd') -if want_systemd != 'false' - libsystemd = dependency('libsystemd', required : want_systemd == 'true') - have_systemd = libsystemd.found() +want_wtmpdbd = get_option('wtmpdbd') +if want_wtmpdbd != 'false' + libsystemd = dependency('libsystemd', version: '>= 257', required : want_wtmpdbd == 'true') + have_systemd257 = libsystemd.found() else - have_systemd = false + have_systemd257 = false libsystemd = [] endif +conf.set10('WITH_WTMPDBD', have_systemd257) + +want_systemd = get_option('systemd') +if have_systemd257 == false + if want_systemd != 'false' + libsystemd = dependency('libsystemd', required : want_systemd == 'true') + have_systemd = libsystemd.found() + else + have_systemd = false + libsystemd = [] + endif +else + have_systemd = true +endif conf.set10('HAVE_SYSTEMD', have_systemd) libwtmpdb_c = files('lib/libwtmpdb.c', 'lib/logwtmpdb.c', 'lib/sqlite.c', 'lib/varlink.c', 'lib/mkdir_p.c') @@ -158,12 +172,14 @@ pam_wtmpdb = shared_library( wtmpdb_c = ['src/wtmpdb.c'] wtmpdbd_c = ['src/wtmpdbd.c', 'src/varlink-org.openSUSE.wtmpdb.c', 'lib/mkdir_p.c'] -executable('wtmpdbd', - wtmpdbd_c, - include_directories : inc, - link_with : libwtmpdb, - dependencies : [libsystemd], - install : true) +if have_systemd257 + executable('wtmpdbd', + wtmpdbd_c, + include_directories : inc, + link_with : libwtmpdb, + dependencies : [libsystemd], + install : true) +endif executable('wtmpdb', wtmpdb_c, diff --git a/meson_options.txt b/meson_options.txt index f56de90..b16a56b 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,3 +1,6 @@ +option('wtmpdbd', type : 'combo', choices : ['auto', 'true', 'false'], + value : 'auto', + description : 'build daemon with sd-varlink support') option('split-usr', type : 'combo', choices : ['auto', 'true', 'false'], description : '''/bin, /sbin aren't symlinks into /usr''') option('rootprefix', type : 'string',