summaryrefslogtreecommitdiffstats
path: root/database/sqlite
diff options
context:
space:
mode:
authorDavid Sommerseth <dazo@users.sourceforge.net>2012-12-26 00:02:10 +0100
committerDavid Sommerseth <dazo@users.sourceforge.net>2012-12-26 01:32:54 +0100
commitcc1485bbcf5002731b3ee91c795ca42447c54acb (patch)
treea53643f88c508eaa1bab325f644e121039615232 /database/sqlite
parent40e66aed101e5a448fe012f24abe33d15a68cee9 (diff)
downloadeurephia-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/sqlite')
-rw-r--r--database/sqlite/edb-sqlite.c28
1 files changed, 28 insertions, 0 deletions
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) {