diff options
Diffstat (limited to 'eurephiadm')
-rw-r--r-- | eurephiadm/commands/attempts.c | 6 | ||||
-rw-r--r-- | eurephiadm/commands/blacklist.c | 6 | ||||
-rw-r--r-- | eurephiadm/commands/certificates.c | 55 | ||||
-rw-r--r-- | eurephiadm/commands/fwprofiles.c | 4 | ||||
-rw-r--r-- | eurephiadm/commands/lastlog.c | 4 | ||||
-rw-r--r-- | eurephiadm/commands/usercerts.c | 6 | ||||
-rw-r--r-- | eurephiadm/commands/users.c | 6 |
7 files changed, 62 insertions, 25 deletions
diff --git a/eurephiadm/commands/attempts.c b/eurephiadm/commands/attempts.c index 242d0f5..ff45c12 100644 --- a/eurephiadm/commands/attempts.c +++ b/eurephiadm/commands/attempts.c @@ -1,7 +1,7 @@ /* attempts.c -- eurephiadm attempts command: * Show/edit records registered in the attempts table * - * GPLv2 only - Copyright (C) 2009 - 2010 + * GPLv2 only - Copyright (C) 2009 - 2012 * David Sommerseth <dazo@users.sourceforge.net> * * This program is free software; you can redistribute it and/or @@ -191,9 +191,11 @@ int list_attempts(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, case 'h': display_attempts_help('l'); + xmlFreeDoc(srch_xml); return 0; default: + xmlFreeDoc(srch_xml); return 1; } } @@ -274,9 +276,11 @@ int modify_attempts(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg case 'h': display_attempts_help(mode); + xmlFreeDoc(upd_xml); return 0; default: + xmlFreeDoc(upd_xml); return 1; } } diff --git a/eurephiadm/commands/blacklist.c b/eurephiadm/commands/blacklist.c index 8d0c95d..205e931 100644 --- a/eurephiadm/commands/blacklist.c +++ b/eurephiadm/commands/blacklist.c @@ -1,7 +1,7 @@ /* blacklist.c -- eurephiadm blacklist command: * Show/edit blacklist * - * GPLv2 only - Copyright (C) 2009 - 2010 + * GPLv2 only - Copyright (C) 2009 - 2012 * David Sommerseth <dazo@users.sourceforge.net> * * This program is free software; you can redistribute it and/or @@ -192,9 +192,11 @@ int list_blacklist(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, case 'h': display_blacklist_help('l'); + xmlFreeDoc(srch_xml); return 0; default: + xmlFreeDoc(srch_xml); return 1; } } @@ -274,9 +276,11 @@ int modify_blacklist(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cf case 'h': display_blacklist_help(mode); + xmlFreeDoc(upd_xml); return 0; default: + xmlFreeDoc(upd_xml); return 1; } } diff --git a/eurephiadm/commands/certificates.c b/eurephiadm/commands/certificates.c index a3b875e..828bdef 100644 --- a/eurephiadm/commands/certificates.c +++ b/eurephiadm/commands/certificates.c @@ -1,7 +1,7 @@ /* certificates.c -- eurephiadm command: certs * Certificate management * - * GPLv2 only - Copyright (C) 2008 -2010 + * GPLv2 only - Copyright (C) 2008 - 2012 * David Sommerseth <dazo@users.sourceforge.net> * * This program is free software; you can redistribute it and/or @@ -276,20 +276,23 @@ int add_cert(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int a } if( chk == 0 ) { fprintf(stderr, "%s: Certificate depth must be a number\n", MODULE); - return 1; + rc = 1; + goto exit; } depth = atoi_nullsafe(optargs[0]); if( (depth < 0) || (depth > 99) ) { fprintf(stderr, "%s: Certificate depth must be between 0-99\n", MODULE); - return 1; + rc = 1; + goto exit; } break; case 'D': // Certificate digest if( strlen_nullsafe(optargs[0]) < 59 ) { fprintf(stderr, "%s: Certificate digest is too short\n", MODULE); - return 1; + rc = 1; + goto exit; } digest = strdup_nullsafe(optargs[0]); break; @@ -311,48 +314,57 @@ int add_cert(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int a case 'f': // Load certificate info from a certificate file if( strlen_nullsafe(optargs[0]) < 1 ) { fprintf(stderr, "%s: certfile is too short\n", MODULE); - return 1; + rc = 1; + goto exit; } certfile = optargs[0]; if( stat(certfile, &cert_stat) == -1 ) { fprintf(stderr, "%s: Could not access certfile: %s (%s)\n", MODULE, certfile, strerror(errno)); - return 1; + rc = 1; + goto exit; } if( cert_stat.st_size == 0 ) { fprintf(stderr, "%s: certfile '%s' is empty\n", MODULE, certfile); - return 1; + rc = 1; + goto exit; } break; #endif case 'h': display_certs_help('A'); - break; + rc = 0; + goto exit; + default: - return 2; + rc = 1; + goto exit; } } // Sanity check of input parameters if( depth < 0 ) { fprintf(stderr, "%s: You must set certificate depth (possibly, it needs to be 0)\n", MODULE); - return 1; + rc = 1; + goto exit; } if( (certfile != NULL) && ((digest != NULL) || (cname != NULL) || (org != NULL) || (email != NULL)) ){ fprintf(stderr, "%s: You cannot combine --certfile with --depth, --common-name,\n" "--organisation or --email\n", MODULE); - return 1; + rc = 1; + goto exit; } if( (certfile == NULL) && ((digest == NULL) || (cname == NULL) || (org == NULL) || (email == NULL)) ) { fprintf(stderr, "%s: You must use either --certfile or --depth, --common-name,\n" "--organisation and --email\n", MODULE); - return 1; + rc = 1; + goto exit; } #ifdef HAVE_OPENSSL @@ -416,14 +428,16 @@ int delete_cert(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, in case 'i': if( atoi_nullsafe(optargs[0]) < 1 ) { fprintf(stderr, "%s: Certificate ID (certid) must be > 0\n", MODULE); - return 1; + rc = 1; + goto exit; } certid = optargs[0]; break; case 'd': // Certificate digest if( strlen_nullsafe(optargs[0]) < 59 ) { fprintf(stderr, "%s: Certificate digest is too short\n", MODULE); - return 1; + rc = 1; + goto exit; } digest = optargs[0]; break; @@ -438,9 +452,11 @@ int delete_cert(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, in break; case 'h': display_certs_help('D'); - break; + rc = 0; + goto exit; default: - return 1; + rc = 1; + goto exit; } } @@ -449,7 +465,8 @@ int delete_cert(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, in fprintf(stderr, "%s: You must add at least one search criteria to delete a certificate\n", MODULE); - return 1; + rc = 1; + goto exit; } // Create a field mapping containing our search criteria(s) @@ -480,12 +497,14 @@ int delete_cert(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, in // Look up the certificate info and display it certlist = eDBadminCertificate(ctx, cert_xml); if( certlist == NULL ) { - return 0; + rc = 0; + goto exit; } delete_n = eurephiaXML_getRoot(ctx, certlist, "certificates", 1); if( atoi_nullsafe(xmlGetAttrValue(delete_n->properties, "certificates")) == 0 ) { printf("%s: No certificates found\n", MODULE); + rc = 0; goto exit; } diff --git a/eurephiadm/commands/fwprofiles.c b/eurephiadm/commands/fwprofiles.c index b62ee08..737f383 100644 --- a/eurephiadm/commands/fwprofiles.c +++ b/eurephiadm/commands/fwprofiles.c @@ -1,7 +1,7 @@ /* fwprofiles.c -- eurephiadm fwprofiles command: * Manages firewall profiles * - * GPLv2 only - Copyright (C) 2009 - 2010 + * GPLv2 only - Copyright (C) 2009 - 2012 * David Sommerseth <dazo@users.sourceforge.net> * * This program is free software; you can redistribute it and/or @@ -211,9 +211,11 @@ int list_profiles(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, case 'h': display_fwprofiles_help('l'); + xmlFreeDoc(srch_xml); return 0; default: + xmlFreeDoc(srch_xml); return 1; } } diff --git a/eurephiadm/commands/lastlog.c b/eurephiadm/commands/lastlog.c index b65f1be..c18fbbb 100644 --- a/eurephiadm/commands/lastlog.c +++ b/eurephiadm/commands/lastlog.c @@ -1,7 +1,7 @@ /* lastlog.c -- eurephiadm lastlog command: * Queries the lastlog table * - * GPLv2 only - Copyright (C) 2009 - 2010 + * GPLv2 only - Copyright (C) 2009 - 2012 * David Sommerseth <dazo@users.sourceforge.net> * * This program is free software; you can redistribute it and/or @@ -136,6 +136,7 @@ int cmd_Lastlog(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, in case 'h': help_Lastlog(); + xmlFreeDoc(srch_xml); return 0; case 'c': @@ -182,6 +183,7 @@ int cmd_Lastlog(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, in default: fprintf(stderr, "%s: Invalid argument: %s\n", MODULE, argv[i-1]); + xmlFreeDoc(srch_xml); return 1; } } diff --git a/eurephiadm/commands/usercerts.c b/eurephiadm/commands/usercerts.c index 553e16e..b0bbf34 100644 --- a/eurephiadm/commands/usercerts.c +++ b/eurephiadm/commands/usercerts.c @@ -1,7 +1,7 @@ /* usercerts.c -- eurephiadm usercerts command: * Management of user account <-> certificate links * - * GPLv2 only - Copyright (C) 2008 - 2010 + * GPLv2 only - Copyright (C) 2008 - 2012 * David Sommerseth <dazo@users.sourceforge.net> * * This program is free software; you can redistribute it and/or @@ -200,14 +200,17 @@ int list_usercerts(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, case 'h': display_usercerts_help('l'); + xmlFreeDoc(srch_xml); return 0; default: + xmlFreeDoc(srch_xml); return 1; } } list_xml = eDBadminUserCertsLink(ctx, srch_xml); + xmlFreeDoc(srch_xml); if( list_xml == NULL ) { fprintf(stderr, "%s: Error retrieving user/certificate link list\n", MODULE); return 1; @@ -215,7 +218,6 @@ int list_usercerts(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, xslt_print_xmldoc(stdout, cfg, list_xml, "usercerts.xsl", xsltparams); xmlFreeDoc(list_xml); - xmlFreeDoc(srch_xml); return 0; } diff --git a/eurephiadm/commands/users.c b/eurephiadm/commands/users.c index 033e6d2..52cf253 100644 --- a/eurephiadm/commands/users.c +++ b/eurephiadm/commands/users.c @@ -1,6 +1,6 @@ /* users.c -- eurephiadm command - User Account Management * - * GPLv2 only - Copyright (C) 2008 - 2010 + * GPLv2 only - Copyright (C) 2008 - 2012 * David Sommerseth <dazo@users.sourceforge.net> * * This program is free software; you can redistribute it and/or @@ -345,9 +345,11 @@ int show_user(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int case 'h': display_users_help('s'); + xmlFreeDoc(srch_xml); return 0; default: + xmlFreeDoc(srch_xml); return 1; } } @@ -517,6 +519,7 @@ int account_activation(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES * case 'h': display_users_help(actmode); + xmlFreeDoc(srch_xml); return 0; case 'P': @@ -524,6 +527,7 @@ int account_activation(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES * break; default: + xmlFreeDoc(srch_xml); return 1; } } |