diff options
Diffstat (limited to 'database/sqlite')
| -rw-r--r-- | database/sqlite/administration.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/database/sqlite/administration.c b/database/sqlite/administration.c index ef2e621..0e71e03 100644 --- a/database/sqlite/administration.c +++ b/database/sqlite/administration.c @@ -904,7 +904,7 @@ xmlDoc *eDBadminGetCertificateList(eurephiaCTX *ctx, const char *sortkeys) { xmlDoc *eDBadminGetCertificateInfo(eurephiaCTX *ctx, xmlDoc *srchxml, const char *sortkeys) { xmlDoc *certlist = NULL; xmlNode *srch_n = NULL, *cert_n = NULL, *tmp_n = NULL; - eDBfieldMap *srch_map = NULL; + eDBfieldMap *srch_map = NULL, *ptr = NULL; dbresult *res = NULL; xmlChar tmp[2050]; char *dbsort = NULL; @@ -932,6 +932,14 @@ xmlDoc *eDBadminGetCertificateInfo(eurephiaCTX *ctx, xmlDoc *srchxml, const char srch_map = eDBxmlMapping(ctx, tbl_sqlite_certs, NULL, srch_n); assert( srch_map != NULL ); + // Replace spaces with underscore in common name and + // in organisation fields, to comply with OpenVPN standards + for( ptr = srch_map; ptr != NULL; ptr = ptr->next ) { + if( ptr->field_id & (FIELD_CNAME | FIELD_ORG) ) { + xmlReplaceChars((xmlChar *) ptr->value, ' ', '_'); + } + } + res = sqlite_query_mapped(ctx, SQL_SELECT, "SELECT depth, digest, common_name, organisation, email, registered, certid" " FROM openvpn_certificates", NULL, srch_map, dbsort); @@ -1054,7 +1062,7 @@ int eDBadminAddCertificate(eurephiaCTX *ctx, xmlDoc *certxml) { int eDBadminDeleteCertificate(eurephiaCTX *ctx, xmlDoc *certxml) { int rc = 0; xmlNode *crtinf_n = NULL; - eDBfieldMap *crtinf_map = NULL; + eDBfieldMap *crtinf_map = NULL, *ptr = NULL; dbresult *res = NULL; DEBUG(ctx, 20, "Function call: eDBadminDeleteCertificate(ctx, xmlDoc)"); @@ -1075,6 +1083,14 @@ int eDBadminDeleteCertificate(eurephiaCTX *ctx, xmlDoc *certxml) { crtinf_map = eDBxmlMapping(ctx, tbl_sqlite_certs, NULL, crtinf_n); assert( crtinf_map != NULL ); + // Replace spaces with underscore in common name and + // in organisation fields, to comply with OpenVPN standards + for( ptr = crtinf_map; ptr != NULL; ptr = ptr->next ) { + if( ptr->field_id & (FIELD_CNAME | FIELD_ORG) ) { + xmlReplaceChars((xmlChar *) ptr->value, ' ', '_'); + } + } + // Register the certificate res = sqlite_query_mapped(ctx, SQL_DELETE, "DELETE FROM openvpn_certificates", NULL, crtinf_map, NULL); if( res == NULL ) { |
