summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Sommerseth <dazo@users.sourceforge.net>2010-12-14 18:57:07 +0100
committerDavid Sommerseth <dazo@users.sourceforge.net>2010-12-14 18:57:07 +0100
commite4ea19989e97fbecd1b22997cadb8fc5f54ade4a (patch)
tree3ce5255121a506c082a3665db23e338093de78fd
parent6440a3a4592a8c0f0f8fd50cd551b41c1e066efe (diff)
downloadeurephia-e4ea19989e97fbecd1b22997cadb8fc5f54ade4a.tar.gz
eurephia-e4ea19989e97fbecd1b22997cadb8fc5f54ade4a.tar.xz
eurephia-e4ea19989e97fbecd1b22997cadb8fc5f54ade4a.zip
eurephiadm users: Revoke all admin access privileges when deleting a user account
Matthew Gyurgyik noticed that when deleting a user account, the users granted access levels was still present. This resulted in a rather odd looking list when showing granted access levels. Signed-off-by: David Sommerseth <dazo@users.sourceforge.net>
-rw-r--r--CREDITS.txt2
-rw-r--r--database/sqlite/administration/useraccount.c20
-rw-r--r--eurephiadm/commands/users.c30
3 files changed, 45 insertions, 7 deletions
diff --git a/CREDITS.txt b/CREDITS.txt
index 878a5fb..0366573 100644
--- a/CREDITS.txt
+++ b/CREDITS.txt
@@ -47,3 +47,5 @@ or indirectly, will be credited here.
* Matthew Gyurgyik <pyther@pyther.net>
- Helped out testing the TUN support in eurephia on Linux with iptables support
+ - Found a bug when deleting users. Their access levels was not removed, making
+ eurephiadm adminaccess --list looking a bit odd.
diff --git a/database/sqlite/administration/useraccount.c b/database/sqlite/administration/useraccount.c
index 0571d98..a936294 100644
--- a/database/sqlite/administration/useraccount.c
+++ b/database/sqlite/administration/useraccount.c
@@ -686,12 +686,20 @@ 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, NULL,
- "Access level %s (%s) was revoked from uid %s",
- eDBmappingGetValue(fmap_m, FIELD_ACCESSLVL),
- eDBmappingGetValue(fmap_m, FIELD_INTERFACE),
- eDBmappingGetValue(fmap_m, FIELD_UID));
- }
+ const char *uid = eDBmappingGetValue(fmap_m, FIELD_UID);
+ const char *acclvl = eDBmappingGetValue(fmap_m, FIELD_ACCESSLVL);
+
+ if( acclvl != NULL ) {
+ res_d = eurephiaXML_ResultMsg(ctx, exmlRESULT, NULL,
+ "Access level %s (%s) was revoked from uid %s",
+ acclvl, eDBmappingGetValue(fmap_m, FIELD_ACCESSLVL),
+ uid);
+ } else {
+ res_d = eurephiaXML_ResultMsg(ctx, exmlRESULT, NULL,
+ "%i access levels was removed from uid %s",
+ sqlite_get_affected_rows(sqlres), uid);
+ }
+ }
} else if( strcmp(mode, "list") == 0 ) {
res_d = adminacclvl_Get(ctx, fmap_m);
}
diff --git a/eurephiadm/commands/users.c b/eurephiadm/commands/users.c
index 07051ba..7d514ba 100644
--- a/eurephiadm/commands/users.c
+++ b/eurephiadm/commands/users.c
@@ -682,6 +682,7 @@ int account_activation(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *
// No ResultMsg document was returned, which is also wrong.
break;
}
+
// Delete links between certificates associated to this user account
xmlFreeDoc(update_xml);
eurephiaXML_CreateDoc(ctx, 1, "usercerts", &update_xml, &update_n);
@@ -700,10 +701,37 @@ int account_activation(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *
rc = 0;
} else if( res->resultType == exmlERROR ) {
fprintf(stderr, "%s: %s\n", MODULE, res->message);
+ rc = 0;
} else {
fprintf(stdout, "%s: %s\n", MODULE, res->message);
rc = 1;
}
+
+ // Remove all user access levels for the user.
+ {
+ xmlDoc *acclvl_d = NULL, *acclvl_res_xml = NULL;
+ xmlNode *acclvl_n = NULL, *acclvl_fm = NULL;
+ eurephiaRESULT *acclvl_res = NULL;
+
+ eurephiaXML_CreateDoc(ctx, 1, "admin_access", &acclvl_d, &acclvl_n);
+ xmlNewProp(acclvl_n, (xmlChar *) "mode", (xmlChar *) "revoke");
+ acclvl_fm = xmlNewChild(acclvl_n, NULL, (xmlChar *) "fieldMapping", NULL);
+ xmlNewProp(acclvl_fm, (xmlChar *) "table", (xmlChar *) "eurephia_adminaccess");
+ xmlNewChild(acclvl_fm, NULL, (xmlChar *) "uid", (xmlChar *) uid_str);
+
+ acclvl_res_xml = eDBadminAccessLevel(ctx, acclvl_d);
+ acclvl_res = eurephiaXML_ParseResultMsg(ctx, acclvl_res_xml);
+ if( acclvl_res->resultType == exmlERROR ) {
+ fprintf(stderr, "%s: %s\n", MODULE, acclvl_res->message);
+ rc = 0;
+ } else {
+ fprintf(stdout, "%s: %s\n", MODULE, acclvl_res->message);
+ rc = rc ? 1 : 0;
+ }
+ free_nullsafe(ctx, res);
+ xmlFreeDoc(acclvl_res_xml);
+ xmlFreeDoc(acclvl_d);
+ }
free_nullsafe(ctx, res);
xmlFreeDoc(tmp_xml);
break;
@@ -716,7 +744,7 @@ int account_activation(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *
rc = 0;
} else {
fprintf(stdout, "%s: %s\n", MODULE, res->message);
- rc = 1;
+ rc = rc ? 1 : 0;
}
free_nullsafe(ctx, res);
} else {