summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Sommerseth <dazo@users.sourceforge.net>2009-09-21 19:04:36 +0200
committerDavid Sommerseth <dazo@users.sourceforge.net>2009-09-21 19:04:36 +0200
commit8fc41296cd27af9757f571627f7fd16befc9b8aa (patch)
tree9a2d242654c938ae0b0a327d649f7d7e7f875586
parent854f3bb476a3cb7cf370c0f7690d9a376d219609 (diff)
downloadeurephia-8fc41296cd27af9757f571627f7fd16befc9b8aa.tar.gz
eurephia-8fc41296cd27af9757f571627f7fd16befc9b8aa.tar.xz
eurephia-8fc41296cd27af9757f571627f7fd16befc9b8aa.zip
Rewrote eurephiaXML_ResultMsg() to also support adding an xmlNode* with more info
The eurephia result XML document is also changed, and all parsing of the result must be rewritten. To simplify this parsing, a new function is introduced, eurephiaXML_ParseResultMsg().
-rw-r--r--common/eurephia_xml.c72
-rw-r--r--common/eurephia_xml.h13
-rw-r--r--database/sqlite/administration/attempts.c14
-rw-r--r--database/sqlite/administration/blacklist.c14
-rw-r--r--database/sqlite/administration/configuration.c12
-rw-r--r--database/sqlite/administration/firewalladmin.c22
-rw-r--r--database/sqlite/administration/useraccount.c8
-rw-r--r--database/sqlite/administration/usercerts.c30
8 files changed, 127 insertions, 58 deletions
diff --git a/common/eurephia_xml.c b/common/eurephia_xml.c
index e78d2b3..80f2ccd 100644
--- a/common/eurephia_xml.c
+++ b/common/eurephia_xml.c
@@ -141,7 +141,7 @@ int eurephiaXML_CreateDoc(eurephiaCTX *ctx, int format, const char *eurephiaRoot
*
* @param ctx eurephiaCTX
* @param doc xmlDoc pointer to the XML document
- * @param nodeset The expected root node to be found
+ * @param nodeset The expected root node to be found.
* @param req_format The minimum format version to be accepted
*
* @return Returns pointer to the given xmlNode tag. On failure, NULL is returned.
@@ -173,14 +173,15 @@ xmlNode *eurephiaXML_getRoot(eurephiaCTX *ctx, xmlDoc *doc, const char *nodeset,
/**
* Creates a simple result message, formatted as an XML document.
*
- * @param ctx eurephiaCTX
- * @param type Can be exmlRESULT or exmlERROR. The former is used for informational messages.
- * @param fmt stdarg format string
+ * @param ctx eurephiaCTX
+ * @param type Can be exmlRESULT or exmlERROR. The former is used for informational messages.
+ * @param info_n xmlNode with more details about the result
+ * @param fmt stdarg format string
*
* @return Returns a valid eurephia XML document as a properly formatted result message.
* On failure, NULL is returned
*/
-xmlDoc *eurephiaXML_ResultMsg(eurephiaCTX *ctx, exmlResultType type, const char *fmt, ... ) {
+ xmlDoc *eurephiaXML_ResultMsg(eurephiaCTX *ctx, exmlResultType type, xmlNode *info_n, const char *fmt, ... ) {
va_list ap;
xmlChar msg[2050], *xmlfmt = NULL;
xmlDoc *msgdoc = NULL;
@@ -195,27 +196,80 @@ xmlDoc *eurephiaXML_ResultMsg(eurephiaCTX *ctx, exmlResultType type, const char
va_end(ap);
free_nullsafe(ctx, xmlfmt);
+ eurephiaXML_CreateDoc(ctx, 1, "Result", &msgdoc, &msg_n);
+ assert( (msgdoc != NULL) && (msg_n != NULL) );
+
switch( type ) {
case exmlRESULT:
- eurephiaXML_CreateDoc(ctx, 1, "Result", &msgdoc, &msg_n);
+ xmlNewProp(msg_n, (xmlChar *) "status", (xmlChar *) "Result");
break;
case exmlERROR:
- eurephiaXML_CreateDoc(ctx, 1, "Error", &msgdoc, &msg_n);
+ xmlNewProp(msg_n, (xmlChar *) "status", (xmlChar *) "Error");
break;
default:
eurephia_log(ctx, LOG_ERROR, 0, "Wrong XML result message type (%i)", type);
return NULL;
}
- assert( (msgdoc != NULL) && (msg_n != NULL) );
- xmlAddChild(msg_n, xmlNewText(msg));
+ xmlNewChild(msg_n, NULL, (xmlChar *) "Message", msg);
+
+ if( info_n != NULL ) {
+ // Create a new child tag (Details) and copy the info nodes into this tag
+ xmlAddChild(xmlNewChild(msg_n, NULL, (xmlChar *) "Details", NULL),
+ xmlCopyNode(info_n, 1));
+ }
return msgdoc;
}
/**
+ * Parses an eurephia Result XML document
+ *
+ * @param ctx eurephiaCTX
+ * @param resxml The result XML document
+ *
+ * @return Returns a pointer to an eurephiaRESULT structure containing the results.
+ * On failure NULL is returned. This structure can be freed with free_nullsafe().
+ *
+ * @remark If the result XML document is freed, the information in eurephiaRESULT will be invalidated
+ * Immediately. However, the eurephiaRESULT pointer must still be freed.
+ */
+eurephiaRESULT *eurephiaXML_ParseResultMsg(eurephiaCTX *ctx, xmlDoc *resxml) {
+ eurephiaRESULT *res = NULL;
+ xmlNode *res_n = NULL;
+ char *str = NULL;
+
+ assert( (ctx != NULL) && (resxml != NULL) );
+
+ res_n = eurephiaXML_getRoot(ctx, resxml, "Result", 1);
+ if( res_n == NULL) {
+ eurephia_log(ctx, LOG_ERROR, 0, "Could not find a valid <Result> tag");
+ return NULL;
+ }
+
+ res = (eurephiaRESULT *) malloc_nullsafe(ctx, sizeof(eurephiaRESULT) + 2);
+ assert( res != NULL );
+
+ str = xmlGetAttrValue(res_n->properties, "status");
+ if( strcmp(str, "Error") == 0 ) {
+ res->resultType = exmlERROR;
+ } else if( strcmp(str, "Result") == 0 ) {
+ res->resultType = exmlRESULT;
+ } else {
+ free_nullsafe(ctx, res);
+ eurephia_log(ctx, LOG_ERROR, 0, "Invalid result status");
+ return NULL;
+ }
+
+ res->message = xmlGetNodeContent(res_n, "Message");
+ res->details = xmlFindNode(res_n, "Details");
+ return res;
+}
+
+
+/**
* Return the text content of a given xmlNode
*
* @param n xmlNode to extract the value from.
diff --git a/common/eurephia_xml.h b/common/eurephia_xml.h
index 51ee9dd..614394a 100644
--- a/common/eurephia_xml.h
+++ b/common/eurephia_xml.h
@@ -45,6 +45,16 @@ typedef enum _exmlResultType { exmlRESULT = 1, /**< Operation successful. Additi
#include <libxml/tree.h>
/**
+ * Structure which is used when parsing eurephia Result XML documents
+ */
+typedef struct _eurephiaRESULT {
+ exmlResultType resultType; /**< Indicates what kind of result we received */
+ const char *message; /**< String containing the result message */
+ xmlNode *details; /**< A result message can attach an XML node with even more
+ detailed information */
+} eurephiaRESULT;
+
+/**
* Simple iterator macro for iterating xmlNode pointers
*
* @param start Pointer to an xmlNode where to start iterating
@@ -58,7 +68,8 @@ xmlNode *xmlFindNode(xmlNode *node, const char *key);
int eurephiaXML_CreateDoc(eurephiaCTX *ctx, int format, const char *rootname, xmlDoc **doc, xmlNode **root_n);
xmlNode *eurephiaXML_getRoot(eurephiaCTX *ctx, xmlDoc *doc, const char *nodeset, int min_format);
-xmlDoc *eurephiaXML_ResultMsg(eurephiaCTX *ctx, exmlResultType type, const char *fmt, ... );
+xmlDoc *eurephiaXML_ResultMsg(eurephiaCTX *ctx, exmlResultType type, xmlNode *info_n, const char *fmt, ... );
+eurephiaRESULT *eurephiaXML_ParseResultMsg(eurephiaCTX *ctx, xmlDoc *resxml);
inline char *xmlExtractContent(xmlNode *n);
inline char *xmlGetNodeContent(xmlNode *node, const char *key);
diff --git a/database/sqlite/administration/attempts.c b/database/sqlite/administration/attempts.c
index 08c6dc1..e94878a 100644
--- a/database/sqlite/administration/attempts.c
+++ b/database/sqlite/administration/attempts.c
@@ -144,16 +144,16 @@ xmlDoc *attempts_reset(eurephiaCTX *ctx, eDBfieldMap *fmap) {
fields = eDBmappingFieldsPresent(fmap);
if( (fields & (FIELD_UNAME | FIELD_CERTDIGEST | FIELD_REMOTEIP | FIELD_RECID)) == 0 ) {
- return eurephiaXML_ResultMsg(ctx, exmlERROR,
+ return eurephiaXML_ResultMsg(ctx, exmlERROR, NULL,
"Missing username, IP address, certificate digest or atpid");
}
res = sqlite_query_mapped(ctx, SQL_UPDATE, "UPDATE openvpn_attempts", update_vals, fmap, NULL);
if( res == NULL ) {
eurephia_log(ctx, LOG_FATAL, 0, "Could not reset the attempts count");
- ret = eurephiaXML_ResultMsg(ctx, exmlERROR, "Could not reset the attempts count");
+ ret = eurephiaXML_ResultMsg(ctx, exmlERROR, NULL, "Could not reset the attempts count");
} else {
- ret = eurephiaXML_ResultMsg(ctx, exmlRESULT, "Attempts count reset");
+ ret = eurephiaXML_ResultMsg(ctx, exmlRESULT, NULL, "Attempts count reset");
sqlite_free_results(res);
}
return ret;
@@ -175,16 +175,16 @@ xmlDoc *attempts_delete(eurephiaCTX *ctx, eDBfieldMap *fmap) {
fields = eDBmappingFieldsPresent(fmap);
if( (fields & (FIELD_UNAME | FIELD_CERTDIGEST | FIELD_REMOTEIP | FIELD_RECID)) == 0 ) {
- return eurephiaXML_ResultMsg(ctx, exmlERROR,
+ return eurephiaXML_ResultMsg(ctx, exmlERROR, NULL,
"Missing username, IP address, certificate digest or atpid");
}
res = sqlite_query_mapped(ctx, SQL_DELETE, "DELETE FROM openvpn_attempts", NULL, fmap, NULL);
if( res == NULL ) {
eurephia_log(ctx, LOG_FATAL, 0, "Could not remove attempts record");
- ret = eurephiaXML_ResultMsg(ctx, exmlERROR, "Could not delete the attempts record");
+ ret = eurephiaXML_ResultMsg(ctx, exmlERROR, NULL, "Could not delete the attempts record");
} else {
- ret = eurephiaXML_ResultMsg(ctx, exmlRESULT, "Attempts record removed");
+ ret = eurephiaXML_ResultMsg(ctx, exmlRESULT, NULL, "Attempts record removed");
sqlite_free_results(res);
}
return ret;
@@ -234,7 +234,7 @@ xmlDoc *eDBadminAttemptsLog(eurephiaCTX *ctx, xmlDoc *qryxml) {
resxml = attempts_delete(ctx, fmap);
} else {
eurephia_log(ctx, LOG_ERROR, 0, "Attempts - Unknown mode: '%s'", mode);
- resxml = eurephiaXML_ResultMsg(ctx, exmlERROR, "Unknown mode '%s'", mode);
+ resxml = eurephiaXML_ResultMsg(ctx, exmlERROR, NULL, "Unknown mode '%s'", mode);
}
eDBfreeMapping(fmap);
return resxml;
diff --git a/database/sqlite/administration/blacklist.c b/database/sqlite/administration/blacklist.c
index d8824ea..80c4506 100644
--- a/database/sqlite/administration/blacklist.c
+++ b/database/sqlite/administration/blacklist.c
@@ -139,7 +139,7 @@ xmlDoc *blacklist_add(eurephiaCTX *ctx, eDBfieldMap *fmap) {
fields = eDBmappingFieldsPresent(fmap);
if( (fields != FIELD_UNAME) && (fields != FIELD_CERTDIGEST) && (fields != FIELD_REMOTEIP) ) {
- return eurephiaXML_ResultMsg(ctx, exmlERROR,
+ return eurephiaXML_ResultMsg(ctx, exmlERROR, NULL,
"Missing username, IP address or certificate digest, "
"or multiple of these fields were given.");
}
@@ -147,9 +147,9 @@ xmlDoc *blacklist_add(eurephiaCTX *ctx, eDBfieldMap *fmap) {
res = sqlite_query_mapped(ctx, SQL_INSERT, "INSERT INTO openvpn_blacklist", fmap, NULL, NULL);
if( res == NULL ) {
eurephia_log(ctx, LOG_FATAL, 0, "Could not blacklist the requested data");
- ret = eurephiaXML_ResultMsg(ctx, exmlERROR, "Blacklisting failed");
+ ret = eurephiaXML_ResultMsg(ctx, exmlERROR, NULL, "Blacklisting failed");
} else {
- ret = eurephiaXML_ResultMsg(ctx, exmlRESULT, "Record registered in the blacklist");
+ ret = eurephiaXML_ResultMsg(ctx, exmlRESULT, NULL, "Record registered in the blacklist");
sqlite_free_results(res);
}
return ret;
@@ -171,16 +171,16 @@ xmlDoc *blacklist_delete(eurephiaCTX *ctx, eDBfieldMap *fmap) {
fields = eDBmappingFieldsPresent(fmap);
if( (fields & (FIELD_UNAME | FIELD_CERTDIGEST | FIELD_REMOTEIP | FIELD_RECID)) == 0 ) {
- return eurephiaXML_ResultMsg(ctx, exmlERROR,
+ return eurephiaXML_ResultMsg(ctx, exmlERROR, NULL,
"Missing username, IP address, certificate digest or blacklist ID");
}
res = sqlite_query_mapped(ctx, SQL_DELETE, "DELETE FROM openvpn_blacklist", NULL, fmap, NULL);
if( res == NULL ) {
eurephia_log(ctx, LOG_FATAL, 0, "Could not remove blacklisting");
- ret = eurephiaXML_ResultMsg(ctx, exmlERROR, "Failed to remove the blacklisting");
+ ret = eurephiaXML_ResultMsg(ctx, exmlERROR, NULL, "Failed to remove the blacklisting");
} else {
- ret = eurephiaXML_ResultMsg(ctx, exmlRESULT, "Blacklisting removed");
+ ret = eurephiaXML_ResultMsg(ctx, exmlRESULT, NULL, "Blacklisting removed");
sqlite_free_results(res);
}
return ret;
@@ -230,7 +230,7 @@ xmlDoc *eDBadminBlacklist(eurephiaCTX *ctx, xmlDoc *qryxml) {
resxml = blacklist_delete(ctx, fmap);
} else {
eurephia_log(ctx, LOG_ERROR, 0, "Blacklist - Unknown mode: '%s'", mode);
- resxml = eurephiaXML_ResultMsg(ctx, exmlERROR, "Unknown mode '%s'", mode);
+ resxml = eurephiaXML_ResultMsg(ctx, exmlERROR, NULL, "Unknown mode '%s'", mode);
}
eDBfreeMapping(fmap);
return resxml;
diff --git a/database/sqlite/administration/configuration.c b/database/sqlite/administration/configuration.c
index e27b257..dbf033e 100644
--- a/database/sqlite/administration/configuration.c
+++ b/database/sqlite/administration/configuration.c
@@ -155,7 +155,7 @@ xmlDoc *validate_key_value(eurephiaCTX *ctx, const char *key, const char *value)
v_null = (value == NULL ? 1 : 0);
if( k_null || v_null ) {
- return eurephiaXML_ResultMsg(ctx, exmlERROR, "%s%s%s",
+ return eurephiaXML_ResultMsg(ctx, exmlERROR, NULL, "%s%s%s",
(k_null ? "The key attribute was not set" : ""),
(k_null && v_null ? " and " : ""),
(v_null ? "The value tag was not set" : "")
@@ -200,11 +200,11 @@ xmlDoc *eDBadminConfiguration(eurephiaCTX *ctx, xmlDoc *cfgxml) {
}
if( config_set(ctx, key, value) ) {
- resxml = eurephiaXML_ResultMsg(ctx, exmlRESULT,
+ resxml = eurephiaXML_ResultMsg(ctx, exmlRESULT, NULL,
"Configuration key '%s' was set to '%s'",
key, value);
} else {
- resxml = eurephiaXML_ResultMsg(ctx, exmlERROR,
+ resxml = eurephiaXML_ResultMsg(ctx, exmlERROR, NULL,
"Failed to set the key '%s' to '%s'",
key, value);
}
@@ -223,15 +223,15 @@ xmlDoc *eDBadminConfiguration(eurephiaCTX *ctx, xmlDoc *cfgxml) {
}
if( config_delete(ctx, key) ) {
- resxml = eurephiaXML_ResultMsg(ctx, exmlRESULT,
+ resxml = eurephiaXML_ResultMsg(ctx, exmlRESULT, NULL,
"Configuration key '%s' was deleted", key);
} else {
- resxml = eurephiaXML_ResultMsg(ctx, exmlERROR,
+ resxml = eurephiaXML_ResultMsg(ctx, exmlERROR, NULL,
"Failed to delete the key '%s'", key);
}
return resxml;
}
// If not, it's an invalid input
- return eurephiaXML_ResultMsg(ctx, exmlERROR, "Unkown XML tag received");
+ return eurephiaXML_ResultMsg(ctx, exmlERROR, NULL, "Unkown XML tag received");
}
diff --git a/database/sqlite/administration/firewalladmin.c b/database/sqlite/administration/firewalladmin.c
index 378f265..6c6b91e 100644
--- a/database/sqlite/administration/firewalladmin.c
+++ b/database/sqlite/administration/firewalladmin.c
@@ -166,16 +166,19 @@ xmlDoc *fwadmin_add(eurephiaCTX *ctx, eDBfieldMap *fmap) {
// Check if we have the needed fields, and only the needed fields
if( eDBmappingFieldsPresent(fmap) != (FIELD_DESCR | FIELD_FWPROFILE) ) {
- return eurephiaXML_ResultMsg(ctx, exmlERROR, "Adding firewall profile only accepts "
+ return eurephiaXML_ResultMsg(ctx, exmlERROR, NULL,
+ "Adding firewall profile only accepts "
"description and firewall profile fields");
}
res = sqlite_query_mapped(ctx, SQL_INSERT, "INSERT INTO openvpn_accesses", fmap, NULL, NULL);
if( res == NULL ) {
eurephia_log(ctx, LOG_FATAL, 0, "Could not register the new firewall profile");
- ret = eurephiaXML_ResultMsg(ctx, exmlERROR, "Could not register the new firewall profile");
+ ret = eurephiaXML_ResultMsg(ctx, exmlERROR, NULL,
+ "Could not register the new firewall profile");
} else {
- ret = eurephiaXML_ResultMsg(ctx, exmlRESULT, "Firewall profile registered with id %i",
+ ret = eurephiaXML_ResultMsg(ctx, exmlRESULT, NULL,
+ "Firewall profile registered with id %i",
res->last_insert_id);
}
sqlite_free_results(res);
@@ -199,7 +202,8 @@ xmlDoc *fwadmin_delete(eurephiaCTX *ctx, eDBfieldMap *fmap) {
// Check if we have the needed fields, and only the needed fields
fields = eDBmappingFieldsPresent(fmap);
if( !(fields & FIELD_FWPROFILE) && !(fields & FIELD_RECID) ) {
- return eurephiaXML_ResultMsg(ctx, exmlERROR, "Deleting firewall profile only accepts "
+ return eurephiaXML_ResultMsg(ctx, exmlERROR, NULL,
+ "Deleting firewall profile only accepts "
"firewall profile and destination fields");
}
@@ -208,7 +212,7 @@ xmlDoc *fwadmin_delete(eurephiaCTX *ctx, eDBfieldMap *fmap) {
NULL, fmap, NULL);
if( res == NULL ) {
eurephia_log(ctx, LOG_FATAL, 0, "Could not delete the firewall profile (1)");
- return eurephiaXML_ResultMsg(ctx, exmlERROR, "Could not delete the firewall profile");
+ return eurephiaXML_ResultMsg(ctx, exmlERROR, NULL, "Could not delete the firewall profile");
}
// Delete all references to this access profile in openvpn_usercerts
@@ -223,7 +227,7 @@ xmlDoc *fwadmin_delete(eurephiaCTX *ctx, eDBfieldMap *fmap) {
sqlite_get_value(res, i, 0));
if( dres == NULL ) {
eurephia_log(ctx, LOG_FATAL, 0, "Could not delete the firewall profile (2)");
- ret = eurephiaXML_ResultMsg(ctx, exmlERROR,
+ ret = eurephiaXML_ResultMsg(ctx, exmlERROR, NULL,
"Could not delete the firewall profile");
sqlite_free_results(res);
return ret;
@@ -236,9 +240,9 @@ xmlDoc *fwadmin_delete(eurephiaCTX *ctx, eDBfieldMap *fmap) {
res = sqlite_query_mapped(ctx, SQL_DELETE, "DELETE FROM openvpn_accesses", NULL, fmap, NULL);
if( res == NULL ) {
eurephia_log(ctx, LOG_FATAL, 0, "Could not delete the firewall profile");
- ret = eurephiaXML_ResultMsg(ctx, exmlERROR, "Could not delete the firewall profile");
+ ret = eurephiaXML_ResultMsg(ctx, exmlERROR, NULL, "Could not delete the firewall profile");
} else {
- ret = eurephiaXML_ResultMsg(ctx, exmlRESULT, "Firewall profile deleted");
+ ret = eurephiaXML_ResultMsg(ctx, exmlRESULT, NULL, "Firewall profile deleted");
}
sqlite_free_results(res);
return ret;
@@ -288,7 +292,7 @@ xmlDoc *eDBadminFirewallProfiles(eurephiaCTX *ctx, xmlDoc *xmlqry) {
resxml = fwadmin_delete(ctx, fmap);
} else {
eurephia_log(ctx, LOG_ERROR, 0, "FirewallProfiles - Unknown mode: '%s'", mode);
- resxml = eurephiaXML_ResultMsg(ctx, exmlERROR, "Unknown mode '%s'", mode);
+ resxml = eurephiaXML_ResultMsg(ctx, exmlERROR, NULL, "Unknown mode '%s'", mode);
}
eDBfreeMapping(fmap);
return resxml;
diff --git a/database/sqlite/administration/useraccount.c b/database/sqlite/administration/useraccount.c
index e7d1da7..4f44789 100644
--- a/database/sqlite/administration/useraccount.c
+++ b/database/sqlite/administration/useraccount.c
@@ -588,7 +588,7 @@ xmlDoc *adminacclvl_Get(eurephiaCTX *ctx, eDBfieldMap *fmap) {
NULL, fmap, "uid, interface, access");
if( res == NULL ) {
eurephia_log(ctx, LOG_ERROR, 0, "Error querying the database for a access levels");
- return eurephiaXML_ResultMsg(ctx, exmlERROR,
+ return eurephiaXML_ResultMsg(ctx, exmlERROR, NULL,
"Error querying the database for a access levels");
}
@@ -656,7 +656,7 @@ xmlDoc *eDBadminAccessLevel(eurephiaCTX *ctx, xmlDoc *qryxml) {
sqlres = sqlite_query_mapped(ctx, SQL_INSERT, "INSERT INTO eurephia_adminaccess",
fmap_m, NULL, NULL);
if( sqlres && (sqlite_get_affected_rows(sqlres) > 0) ) {
- res_d = eurephiaXML_ResultMsg(ctx, exmlRESULT,
+ res_d = eurephiaXML_ResultMsg(ctx, exmlRESULT, NULL,
"Access level %s (%s) was granted to uid %s",
eDBmappingGetValue(fmap_m, FIELD_ACCESSLVL),
eDBmappingGetValue(fmap_m, FIELD_INTERFACE),
@@ -666,7 +666,7 @@ xmlDoc *eDBadminAccessLevel(eurephiaCTX *ctx, xmlDoc *qryxml) {
sqlres = sqlite_query_mapped(ctx, SQL_DELETE, "DELETE FROM eurephia_adminaccess",
NULL, fmap_m, NULL);
if( sqlres && (sqlite_get_affected_rows(sqlres) > 0) ) {
- res_d = eurephiaXML_ResultMsg(ctx, exmlRESULT,
+ res_d = eurephiaXML_ResultMsg(ctx, exmlRESULT, NULL,
"Access level %s (%s) was revoked from uid %s",
eDBmappingGetValue(fmap_m, FIELD_ACCESSLVL),
eDBmappingGetValue(fmap_m, FIELD_INTERFACE),
@@ -678,7 +678,7 @@ xmlDoc *eDBadminAccessLevel(eurephiaCTX *ctx, xmlDoc *qryxml) {
if( res_d == NULL ) {
eurephia_log(ctx, LOG_ERROR, 0, "Failed to update admin access");
- res_d = eurephiaXML_ResultMsg(ctx, exmlERROR, "Failed to complete %s operation", mode);
+ res_d = eurephiaXML_ResultMsg(ctx, exmlERROR, NULL, "Failed to complete %s operation", mode);
}
if( sqlres ) {
sqlite_free_results(sqlres);
diff --git a/database/sqlite/administration/usercerts.c b/database/sqlite/administration/usercerts.c
index 408891f..4387dcf 100644
--- a/database/sqlite/administration/usercerts.c
+++ b/database/sqlite/administration/usercerts.c
@@ -165,7 +165,7 @@ xmlDoc *usercerts_add_del(eurephiaCTX *ctx, const char *mode, eDBfieldMap *usrcr
dbres = sqlite_query_mapped(ctx, SQL_INSERT,
"INSERT INTO openvpn_usercerts", usrcrt_m, NULL, NULL);
if( dbres ) {
- res = eurephiaXML_ResultMsg(ctx, exmlRESULT,
+ res = eurephiaXML_ResultMsg(ctx, exmlRESULT, NULL,
"Registered new user-cert link with id %i",
dbres->last_insert_id);
}
@@ -173,21 +173,21 @@ xmlDoc *usercerts_add_del(eurephiaCTX *ctx, const char *mode, eDBfieldMap *usrcr
dbres = sqlite_query_mapped(ctx, SQL_DELETE,
"DELETE FROM openvpn_usercerts", NULL, usrcrt_m, NULL);
if( dbres ) {
- int num_rows = sqlite_get_affected_rows(dbres);
- if( num_rows > 0 ) {
- res = eurephiaXML_ResultMsg(ctx, exmlRESULT,
- "Removed %i user-cert %s successfully",
- num_rows, (num_rows == 1 ? "link" : "links"));
- } else {
- res = eurephiaXML_ResultMsg(ctx, exmlERROR,
- "No user-cert links where removed");
- }
+ int num_rows = sqlite_get_affected_rows(dbres);
+ if( num_rows > 0 ) {
+ res = eurephiaXML_ResultMsg(ctx, exmlRESULT, NULL,
+ "Removed %i user-cert %s successfully",
+ num_rows, (num_rows == 1 ? "link" : "links"));
+ } else {
+ res = eurephiaXML_ResultMsg(ctx, exmlERROR, NULL,
+ "No user-cert links where removed");
+ }
}
}
if( dbres == NULL ) {
eurephia_log(ctx, LOG_ERROR, 0, "Failed to %s user-cert link.", mode);
- res = eurephiaXML_ResultMsg(ctx, exmlERROR, "Failed to %s user-cert link", mode);
+ res = eurephiaXML_ResultMsg(ctx, exmlERROR, NULL, "Failed to %s user-cert link", mode);
} else {
sqlite_free_results(dbres);
}
@@ -233,17 +233,17 @@ xmlDoc *usercerts_update(eurephiaCTX *ctx, const char *uicid, eDBfieldMap *usrcr
if( dbres ) {
int num_rows = sqlite_get_affected_rows(dbres);
if( num_rows > 0 ) {
- res = eurephiaXML_ResultMsg(ctx, exmlRESULT,
+ res = eurephiaXML_ResultMsg(ctx, exmlRESULT, NULL,
"Updated firewall access profile on %i user-cert %s.",
num_rows, (num_rows == 1 ? "link" : "links"));
} else {
- res = eurephiaXML_ResultMsg(ctx, exmlERROR,
+ res = eurephiaXML_ResultMsg(ctx, exmlERROR, NULL,
"No user-cert links where updated");
}
sqlite_free_results(dbres);
} else {
eurephia_log(ctx, LOG_ERROR, 0, "Failed to update user-cert link.(uicid: %s)", uicid);
- res = eurephiaXML_ResultMsg(ctx, exmlERROR,
+ res = eurephiaXML_ResultMsg(ctx, exmlERROR, NULL,
"Failed to update user-cert link for uicid %s", uicid);
}
eDBfreeMapping(where_m);
@@ -306,7 +306,7 @@ xmlDoc *eDBadminUserCertsLink(eurephiaCTX *ctx, xmlDoc *usrcrt_xml) {
uicid = xmlGetAttrValue(usrcrt_n->properties, "uicid");
if( uicid == NULL ) {
eurephia_log(ctx, LOG_ERROR, 0, "Missing required attribute, uicid, for updates");
- resxml = eurephiaXML_ResultMsg(ctx, exmlERROR,
+ resxml = eurephiaXML_ResultMsg(ctx, exmlERROR, NULL,
"Can not set firewall access profile without uicid");
goto exit;
}