summaryrefslogtreecommitdiffstats
path: root/database
diff options
context:
space:
mode:
Diffstat (limited to 'database')
-rw-r--r--database/eurephiadb_mapping.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/database/eurephiadb_mapping.c b/database/eurephiadb_mapping.c
index cd222c7..9b33f74 100644
--- a/database/eurephiadb_mapping.c
+++ b/database/eurephiadb_mapping.c
@@ -48,6 +48,7 @@ const char *TABLE_NAME[] = {
// in eurephia_xml.h, which would then cause multiple declarations of these functions if that
// include file gets included here.
char *xmlGetAttrValue(xmlAttr *properties, const char *key);
+char *xmlExtractContent(xmlNode *n);
void eDBfreeMapping(eDBfieldMap *p) {
@@ -157,14 +158,20 @@ eDBfieldMap *eDBxmlMapping(eurephiaCTX *ctx, eDBfieldMap *dbmap, const char *tbl
if( nptr->name != NULL ) {
int setnull = 0;
xmlAttr *atr;
+ char *pwhash = NULL;
// Check if we have the "setnull" attribute set to "1"
for( atr = nptr->properties; atr != NULL; atr = atr->next ) {
- if( (atr->name != NULL) && (xmlStrcmp(atr->name, (xmlChar *)"setnull") == 0) ) {
+ if( atr->name == NULL ) {
+ // Skip nodes without name (just in case)
+ continue;
+ }
+ if( xmlStrcmp(atr->name, (xmlChar *)"setnull") == 0 ) {
xmlNode *n = atr->children;
setnull = (((n != NULL) && (n->content != NULL)
&& (xmlStrcmp(n->content,(xmlChar *)"1") == 0)) ? 1 : 0);
- break;
+ } else if( xmlStrcmp(atr->name, (xmlChar *)"pwhash") == 0 ) {
+ pwhash = xmlExtractContent(atr->children);
}
}
@@ -184,9 +191,16 @@ eDBfieldMap *eDBxmlMapping(eurephiaCTX *ctx, eDBfieldMap *dbmap, const char *tbl
break;
case ft_PASSWD: // If it is a password field type, hash the value
- ptr->value = (nptr->children != NULL
- ? passwdhash((char *)nptr->children->content)
- : strdup(""));
+ if( strcmp(pwhash, "sha512") == 0 ) {
+ ptr->value = (nptr->children != NULL
+ ? (char *)nptr->children->content
+ : strdup(""));
+ } else {
+ // Hash value if it is not hashed or not approved hashing
+ ptr->value = (nptr->children != NULL
+ ? passwdhash((char *)nptr->children->content)
+ : strdup(""));
+ }
break;
default: