summaryrefslogtreecommitdiffstats
path: root/eurephiadm
diff options
context:
space:
mode:
authorDavid Sommerseth <dazo@users.sourceforge.net>2008-12-28 20:43:47 +0100
committerDavid Sommerseth <dazo@users.sourceforge.net>2008-12-28 20:43:47 +0100
commit5856a56db1f049a8e81b96878a0eaa3b2c2e2157 (patch)
treea88ed167e6ffb985a02bed98cd69f1f0a6064967 /eurephiadm
parenta24aaf691132c26658f1706fff8f050338d73c97 (diff)
downloadeurephia-5856a56db1f049a8e81b96878a0eaa3b2c2e2157.tar.gz
eurephia-5856a56db1f049a8e81b96878a0eaa3b2c2e2157.tar.xz
eurephia-5856a56db1f049a8e81b96878a0eaa3b2c2e2157.zip
usercerts command: Added list user/cert links
Diffstat (limited to 'eurephiadm')
-rw-r--r--eurephiadm/commands/usercerts.c83
1 files changed, 82 insertions, 1 deletions
diff --git a/eurephiadm/commands/usercerts.c b/eurephiadm/commands/usercerts.c
index 2436546..23e3279 100644
--- a/eurephiadm/commands/usercerts.c
+++ b/eurephiadm/commands/usercerts.c
@@ -92,6 +92,87 @@ int help_UserCerts2(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg
return 0;
}
+int list_usercerts(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int argc, char **argv) {
+ xmlDoc *list_xml = NULL;
+ xmlNode *list_n = NULL, *tmp_n = NULL;
+ int i = 0;
+ char *sortkeys = NULL;
+
+ e_options listargs[] = {
+ {"--sort", "-S", 1},
+ {"--help", "-h", 0},
+ {NULL, NULL, 0}
+ };
+
+ assert( (ctx != NULL) && (ctx->dbc != NULL) && (ctx->dbc->config != NULL));
+
+ // Parse arguments
+ for( i = 1; i < argc; i++ ) {
+ switch( eurephia_getopt(&i, argc, argv, listargs) ) {
+ case 'S':
+ sortkeys = optargs[0];
+ break;
+
+ case 'h':
+ display_usercerts_help('l');
+ return 0;
+
+ default:
+ return 1;
+ }
+ }
+
+ list_xml = eDBadminGetUserCertsList(ctx, sortkeys);
+ if( list_xml == NULL ) {
+ fprintf(stderr, "%s: Error retrieving user/certificate link list\n", MODULE);
+ return 1;
+ }
+
+ list_n = eurephiaXML_getRoot(ctx, list_xml, "usercerts_links", 1);
+ if( list_n == NULL ) {
+ fprintf(stderr, "%s: Error retrieving user/certificate link list\n", MODULE);
+ xmlFreeDoc(list_xml);
+ return 1;
+ }
+
+ printf(" UICID - Registered\n"
+ " U: [uid] Username\n"
+ " C: [certid] Common name/Organisation (cert.depth)\n"
+ " A: [accessprofile] Access profile name\n");
+ printf("----------------------------------------------------------------------------\n");
+
+ for( list_n = list_n->children; list_n != NULL; list_n = list_n->next ) {
+ printf(" %5.5s - %s\n",
+ xmlGetAttrValue(list_n->properties, "uicid"),
+ xmlGetAttrValue(list_n->properties, "registered"));
+
+ tmp_n = xmlFindNode(list_n, "username");
+ printf(" U: [%3.3s] %s\n",
+ xmlGetAttrValue(tmp_n->properties, "uid"),
+ defaultValue(xmlGetNodeContent(list_n, "username"), "(unknown user account)"));
+
+ tmp_n = xmlFindNode(list_n, "certificate");
+ printf(" C: [%3.3s] %s/%s (%s)\n",
+ xmlGetAttrValue(tmp_n->properties, "certid"),
+ defaultValue(xmlGetNodeContent(tmp_n, "common_name"), "-"),
+ defaultValue(xmlGetNodeContent(tmp_n, "organisation"), "-"),
+ xmlGetAttrValue(tmp_n->properties, "depth"));
+
+ tmp_n = xmlFindNode(list_n, "access_profile");
+ printf(" A: [%3.3s] %s\n",
+ xmlGetAttrValue(tmp_n->properties, "accessprofile"),
+ defaultValue(xmlGetNodeContent(list_n, "access_profile"), ""));
+
+ if( list_n->next != NULL ) {
+ printf("\n");
+ }
+ }
+ printf("----------------------------------------------------------------------------\n");
+ xmlFreeDoc(list_xml);
+ return 0;
+}
+
+
int cmd_UserCerts(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int argc, char **argv) {
char **mode_argv;
int i, mode_argc = 0, rc = 0;
@@ -110,7 +191,7 @@ int cmd_UserCerts(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg,
for( i = 1; i < argc; i++ ) {
switch( eurephia_getopt(&i, argc, argv, modeargs) ) {
case 'l':
- // mode_fnc = list_usercerts;
+ mode_fnc = list_usercerts;
break;
case 'h':