summaryrefslogtreecommitdiffstats
path: root/database/sqlite/firewalladmin.c
diff options
context:
space:
mode:
Diffstat (limited to 'database/sqlite/firewalladmin.c')
-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;