summaryrefslogtreecommitdiffstats
path: root/database
diff options
context:
space:
mode:
authorDavid Sommerseth <dazo@users.sourceforge.net>2009-09-01 23:43:30 +0200
committerDavid Sommerseth <dazo@users.sourceforge.net>2009-09-01 23:43:30 +0200
commit217a558a2443a74217ca4631f5ea2a8e71d867e2 (patch)
tree6355336616bd4b16339ee0220d5ed5a562d6df05 /database
parent3d3c25c9d255bc8ebf469c8c50dd765654b81fab (diff)
downloadeurephia-217a558a2443a74217ca4631f5ea2a8e71d867e2.tar.gz
eurephia-217a558a2443a74217ca4631f5ea2a8e71d867e2.tar.xz
eurephia-217a558a2443a74217ca4631f5ea2a8e71d867e2.zip
Don't try to populate granted access nodes with data if no access is granted
Diffstat (limited to 'database')
-rw-r--r--database/sqlite/firewalladmin.c35
1 files changed, 22 insertions, 13 deletions
diff --git a/database/sqlite/firewalladmin.c b/database/sqlite/firewalladmin.c
index 8429779..4c7fbbb 100644
--- a/database/sqlite/firewalladmin.c
+++ b/database/sqlite/firewalladmin.c
@@ -102,25 +102,34 @@ xmlDoc *fwadmin_search(eurephiaCTX *ctx, eDBfieldMap *fmap) {
last_acp = atoi_nullsafe(sqlite_get_value(res, i, 2));
}
+ // Only continue populating acc_n tags if we have some access info available
+ if( sqlite_get_value(res, i, 11) == NULL ) {
+ continue;
+ }
+
acc_n = xmlNewChild(acg_n, NULL, (xmlChar *) "access", NULL);
sqlite_xml_value(acc_n, XML_ATTR, "uicid", res, i, 11);
-
tmp_n = sqlite_xml_value(acc_n, XML_NODE, "username", res, i, 4);
sqlite_xml_value(tmp_n, XML_ATTR, "uid", res, i, 3);
tmp_n = xmlNewChild(acc_n, NULL, (xmlChar *) "certificate", NULL);
- sqlite_xml_value(tmp_n, XML_ATTR, "certid", res, i, 5);
- sqlite_xml_value(tmp_n, XML_ATTR, "registered", res, i, 10);
-
- tmp = (xmlChar *)sqlite_get_value(res, i, 6);
- xmlReplaceChars(tmp, '_', ' ');
- xmlNewChild(tmp_n, NULL, (xmlChar *) "common_name", tmp);
-
- tmp = (xmlChar *)sqlite_get_value(res, i, 7);
- xmlReplaceChars(tmp, '_', ' ');
- xmlNewChild(tmp_n, NULL, (xmlChar *) "organisation", tmp);
- sqlite_xml_value(tmp_n, XML_NODE, "email", res, i, 8);
- sqlite_xml_value(tmp_n, XML_NODE, "digest", res, i, 9);
+ // Only populate tags with certificate info if we have certificate info available
+ if( sqlite_xml_value(tmp_n, XML_ATTR, "certid", res, i, 5) ) {
+ sqlite_xml_value(tmp_n, XML_ATTR, "registered", res, i, 10);
+
+ // OpenVPN uses underscore as default value for "unsafe" characters
+ // in X509 fields. Replace with space for better readability.
+ tmp = (xmlChar *)sqlite_get_value(res, i, 6);
+ xmlReplaceChars(tmp, '_', ' ');
+ xmlNewChild(tmp_n, NULL, (xmlChar *) "common_name", tmp);
+
+ tmp = (xmlChar *)sqlite_get_value(res, i, 7);
+ xmlReplaceChars(tmp, '_', ' ');
+ xmlNewChild(tmp_n, NULL, (xmlChar *) "organisation", tmp);
+
+ sqlite_xml_value(tmp_n, XML_NODE, "email", res, i, 8);
+ sqlite_xml_value(tmp_n, XML_NODE, "digest", res, i, 9);
+ }
}
sqlite_free_results(res);
return doc;