Skip to content

Commit

Permalink
libwtmpdb: return error if varlink support is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
thkukuk committed Jan 8, 2025
1 parent 208c7b9 commit 093636d
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions lib/libwtmpdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ 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
VARLINK_CHECKS
{
#if WITH_WTMPDBD
int64_t id;

id = varlink_login (type, user, usec_login, tty, rhost,
Expand All @@ -82,8 +82,10 @@ wtmpdb_login (const char *db_path, int type, const char *user,
}
else
return id; /* return the error if wtmpdbd is active */
}
#else
return -EPROTONOSUPPORT;
#endif
}
return sqlite_login (db_path?db_path:_PATH_WTMPDB, type, user,
usec_login, tty, rhost, service, error);
}
Expand All @@ -98,9 +100,9 @@ int
wtmpdb_logout (const char *db_path, int64_t id, uint64_t usec_logout,
char **error)
{
#if WITH_WTMPDBD
VARLINK_CHECKS
{
#if WITH_WTMPDBD
int r;

r = varlink_logout (id, usec_logout, error);
Expand All @@ -115,18 +117,20 @@ wtmpdb_logout (const char *db_path, int64_t id, uint64_t usec_logout,
}
else
return r; /* return the error if wtmpdbd is active */
}
#else
return -EPROTONOSUPPORT;
#endif
}

return sqlite_logout (db_path?db_path:_PATH_WTMPDB, id, usec_logout, error);
}

int64_t
wtmpdb_get_id (const char *db_path, const char *tty, char **error)
{
#if WITH_WTMPDBD
VARLINK_CHECKS
{
#if WITH_WTMPDBD
int64_t id;

id = varlink_get_id (tty, error);
Expand All @@ -141,8 +145,10 @@ wtmpdb_get_id (const char *db_path, const char *tty, char **error)
}
else
return id; /* return the error if wtmpdbd is active */
}
#else
return -EPROTONOSUPPORT;
#endif
}

return sqlite_get_id (db_path?db_path:_PATH_WTMPDB, tty, error);
}
Expand All @@ -156,9 +162,9 @@ wtmpdb_read_all (const char *db_path,
char **azColName),
char **error)
{
#if WITH_WTMPDBD
VARLINK_CHECKS
{
#if WITH_WTMPDBD
int r;

r = varlink_read_all (cb_func, NULL, error);
Expand All @@ -173,8 +179,10 @@ wtmpdb_read_all (const char *db_path,
}
else
return r; /* return the error if wtmpdbd is active */
}
#else
return -EPROTONOSUPPORT;
#endif
}

return sqlite_read_all (db_path?db_path:_PATH_WTMPDB, cb_func, NULL, error);
}
Expand All @@ -185,9 +193,9 @@ wtmpdb_read_all_v2 (const char *db_path,
char **azColName),
void *userdata, char **error)
{
#if WITH_WTMPDBD
VARLINK_CHECKS
{
#if WITH_WTMPDBD
int r;

r = varlink_read_all (cb_func, userdata, error);
Expand Down Expand Up @@ -216,9 +224,9 @@ int
wtmpdb_rotate (const char *db_path, const int days, char **error,
char **wtmpdb_name, uint64_t *entries)
{
#if WITH_WTMPDBD
VARLINK_CHECKS
{
#if WITH_WTMPDBD
int r;

r = varlink_rotate (days, wtmpdb_name, entries, error);
Expand All @@ -233,8 +241,10 @@ wtmpdb_rotate (const char *db_path, const int days, char **error,
}
else
return r; /* return the error if wtmpdbd is active */
}
#else
return -EPROTONOSUPPORT;
#endif
}

return sqlite_rotate (db_path?db_path:_PATH_WTMPDB, days, wtmpdb_name, entries, error);
}
Expand All @@ -246,9 +256,9 @@ wtmpdb_get_boottime (const char *db_path, char **error)
uint64_t boottime;
int r;

#if WITH_WTMPDBD
VARLINK_CHECKS
{
#if WITH_WTMPDBD
r = varlink_get_boottime (&boottime, error);
if (r >= 0)
return boottime;
Expand All @@ -261,8 +271,10 @@ wtmpdb_get_boottime (const char *db_path, char **error)
}
else
return 0; /* return the error if wtmpdbd is active */
}
#else
return -EPROTONOSUPPORT;
#endif
}

r = sqlite_get_boottime (db_path?db_path:_PATH_WTMPDB,
&boottime, error);
Expand Down

0 comments on commit 093636d

Please sign in to comment.