diff options
| author | David Sommerseth <dazo@users.sourceforge.net> | 2012-12-26 00:02:10 +0100 |
|---|---|---|
| committer | David Sommerseth <dazo@users.sourceforge.net> | 2012-12-26 01:32:54 +0100 |
| commit | cc1485bbcf5002731b3ee91c795ca42447c54acb (patch) | |
| tree | a53643f88c508eaa1bab325f644e121039615232 /database | |
| parent | 40e66aed101e5a448fe012f24abe33d15a68cee9 (diff) | |
| download | eurephia-cc1485bbcf5002731b3ee91c795ca42447c54acb.tar.gz eurephia-cc1485bbcf5002731b3ee91c795ca42447c54acb.tar.xz eurephia-cc1485bbcf5002731b3ee91c795ca42447c54acb.zip | |
Added eDBget_accessprofile() function
This retrieves the accessprofile ID field from the database for a
given uid/certid combination. This is useful when logging which
firewall profile was used for a certain session.
Signed-off-by: David Sommerseth <dazo@users.sourceforge.net>
Diffstat (limited to 'database')
| -rw-r--r-- | database/eurephiadb.c | 1 | ||||
| -rw-r--r-- | database/eurephiadb_driver.h | 15 | ||||
| -rw-r--r-- | database/sqlite/edb-sqlite.c | 28 |
3 files changed, 44 insertions, 0 deletions
diff --git a/database/eurephiadb.c b/database/eurephiadb.c index 711ddef..186cf3f 100644 --- a/database/eurephiadb.c +++ b/database/eurephiadb.c @@ -116,6 +116,7 @@ int eDBlink_init(eurephiaCTX *ctx, const char *dbdriver, const int minver) case 4: eDBregister_login2 = eGetSym(ctx, ctx->eurephia_driver, "eDBregister_login2"); + eDBget_accessprofile = eGetSym(ctx, ctx->eurephia_driver, "eDBget_accessprofile"); case 3: eDBregister_vpnclientaddr = eGetSym(ctx, ctx->eurephia_driver, "eDBregister_vpnclientaddr"); diff --git a/database/eurephiadb_driver.h b/database/eurephiadb_driver.h index f7f503e..c6785f3 100644 --- a/database/eurephiadb_driver.h +++ b/database/eurephiadb_driver.h @@ -292,6 +292,21 @@ int EUREPHIA_DRIVERAPI_FUNC(eDBregister_logout)(eurephiaCTX *ctx, eurephiaSESSIO */ char * EUREPHIA_DRIVERAPI_FUNC(eDBget_firewall_profile) (eurephiaCTX *ctx, eurephiaSESSION *session); + +/** + * Retrieves the accessprofile reference ID from the user/certs link table for a given + * UID and certID. This is used for tracking which firewall profile was used when storing + * it in the lastlog table. + * + * @version API version level 4 + * @param ctx eurephiaCTX + * @param session eurephiaSESSION + * + * @return Returns an a positive integer when reference was found. Otherwise -1 is returned. + */ +int EUREPHIA_DRIVERAPI_FUNC(eDBget_accessprofile) (eurephiaCTX *ctx, const int uid, const int certid); + + /** * Retrieve a list of IP addresses found in the IP address blacklist table. * diff --git a/database/sqlite/edb-sqlite.c b/database/sqlite/edb-sqlite.c index 85b27d9..25e6f8b 100644 --- a/database/sqlite/edb-sqlite.c +++ b/database/sqlite/edb-sqlite.c @@ -1173,6 +1173,34 @@ char *eDBget_firewall_profile(eurephiaCTX *ctx, eurephiaSESSION *session) /** + * @copydoc eDBget_accessprofile() + */ +int eDBget_accessprofile(eurephiaCTX *ctx, const int uid, const int certid) +{ + int ret = -1; + dbresult *res = NULL; + + DEBUG(ctx, 20, "Function call: eDBget_firewall_profile_id(ctx, %i, %i)", uid, certid); + + res = sqlite_query(ctx, + "SELECT accessprofile " + " FROM openvpn_usercerts " + " WHERE uid = %i AND certid = %i", + uid, certid); + if( sqlite_query_status(res) == dbSUCCESS ) { + ret = atoi_nullsafe(sqlite_get_value(res, 0, 0)); + } else { + eurephia_log(ctx, LOG_FATAL, 0, "Could not retrieve access profile for uid %i and certid %i", + uid, certid); + sqlite_log_error(ctx, res); + ret = -1; + } + sqlite_free_results(res); + return ret; +} + + +/** * @copydoc eDBget_blacklisted_ip() */ eurephiaVALUES *eDBget_blacklisted_ip(eurephiaCTX *ctx) { |
