diff options
| author | David Sommerseth <dazo@users.sourceforge.net> | 2008-12-11 00:05:29 +0100 |
|---|---|---|
| committer | David Sommerseth <dazo@users.sourceforge.net> | 2008-12-11 00:05:29 +0100 |
| commit | 94b035d4a269bf79374d8b43281cb516e5218a6c (patch) | |
| tree | 1e9d1f6cf3b29f0d0210eec33d496098edbfe712 /database/sqlite | |
| parent | c71f6dab57b454f19f3566b6ed544ff10342ec16 (diff) | |
| download | eurephia-94b035d4a269bf79374d8b43281cb516e5218a6c.tar.gz eurephia-94b035d4a269bf79374d8b43281cb516e5218a6c.tar.xz eurephia-94b035d4a269bf79374d8b43281cb516e5218a6c.zip | |
Added functions for processing eurephiaACCESSINFO/eurephiaACCESSLIST
Implemented saving VPN access profile to the eurephiaCERTINFO struct and
filling the eurephiaACCESSINFO with the proper information needed in the
eDBadminGetUserInfo(...) function.
The special thing about eurephiaACCESSINFO, is that it will not register
duplicate records. And when the eurephiaCERTINFO is free'd, the
eurephiaACCESSLIST will automatically be free'd as well.
Diffstat (limited to 'database/sqlite')
| -rw-r--r-- | database/sqlite/CMakeLists.txt | 3 | ||||
| -rw-r--r-- | database/sqlite/administration.c | 20 |
2 files changed, 20 insertions, 3 deletions
diff --git a/database/sqlite/CMakeLists.txt b/database/sqlite/CMakeLists.txt index 75d13d2..af905ce 100644 --- a/database/sqlite/CMakeLists.txt +++ b/database/sqlite/CMakeLists.txt @@ -41,6 +41,9 @@ IF(SQLITE3BIN) COMMENT "Creating template database: eurephiadb") ENDIF(SQLITE3BIN) +IF(FIREWALL) + ADD_DEFINITIONS(-DFIREWALL) +ENDIF(FIREWALL) TARGET_LINK_LIBRARIES(edb-sqlite sqlite3) ADD_DEFINITIONS(-DDRIVER_MODE) diff --git a/database/sqlite/administration.c b/database/sqlite/administration.c index 042bf8e..b7d09ef 100644 --- a/database/sqlite/administration.c +++ b/database/sqlite/administration.c @@ -454,7 +454,8 @@ int eDBadminGetUserInfo(eurephiaCTX *ctx, int getInfo, eurephiaUSERINFO *user) { // Extract certificate info certinf = sqlite_query(ctx, "SELECT depth, digest, common_name, organisation, email, " - " c.registered, c.certid, access_descr" + " c.registered, c.certid, uc.accessprofile, access_descr," + " fw_profile" " FROM openvpn_certificates c" " LEFT JOIN openvpn_usercerts uc ON (c.certid = uc.certid)" " LEFT JOIN openvpn_accesses a " @@ -463,9 +464,13 @@ int eDBadminGetUserInfo(eurephiaCTX *ctx, int getInfo, eurephiaUSERINFO *user) { if( (certinf != NULL) && (sqlite_get_numtuples(certinf) > 0) ) { eurephiaCERTINFO *rec = NULL; int i; +#ifdef FIREWALL + eurephiaACCESSLIST *aclst = NULL; + int acid = 0; + aclst = eAdminCreateACCESSLIST(); +#endif user->certlist = eAdminCreateCERTLIST(); - for( i = 0; i < sqlite_get_numtuples(certinf); i++ ) { rec = eAdminPopulateCERTINFO( atoi_nullsafe(sqlite_get_value(certinf, i, 6)), @@ -474,13 +479,22 @@ int eDBadminGetUserInfo(eurephiaCTX *ctx, int getInfo, eurephiaUSERINFO *user) { sqlite_get_value(certinf, i, 2), sqlite_get_value(certinf, i, 3), sqlite_get_value(certinf, i, 4), + sqlite_get_value(certinf, i, 5)); +#ifdef FIREWALL + acid = atoi_nullsafe(sqlite_get_value(certinf, i, 7)); + rec->access = eAdminRegisterACCESSINFO(aclst, acid, + sqlite_get_value(certinf, i, 9), + sqlite_get_value(certinf, i, 8)); +#endif eAdminInsertCERTINFO(user->certlist, rec); } - sqlite_free_results(certinf); } else { user->certlist = NULL; } + if( certinf != NULL ) { + sqlite_free_results(certinf); + } } else { user->certlist = NULL; } |
