diff options
| author | David Sommerseth <dazo@users.sourceforge.net> | 2009-09-05 00:43:10 +0200 |
|---|---|---|
| committer | David Sommerseth <dazo@users.sourceforge.net> | 2009-09-05 00:43:10 +0200 |
| commit | 727d91f8a4d038f07618ceaafb073a2eb00eb749 (patch) | |
| tree | 06a78e98ba2812f1d87fcf0e5e434c5183229497 | |
| parent | 0695956b4b419beaf1b596d69243c09d00bfa9f7 (diff) | |
| download | eurephia-727d91f8a4d038f07618ceaafb073a2eb00eb749.tar.gz eurephia-727d91f8a4d038f07618ceaafb073a2eb00eb749.tar.xz eurephia-727d91f8a4d038f07618ceaafb073a2eb00eb749.zip | |
Even more commenting. Now the complete eurephiadm should be documented.
| -rw-r--r-- | eurephiadm/commands/adminaccess.c | 73 | ||||
| -rw-r--r-- | eurephiadm/commands/attempts.c | 71 | ||||
| -rw-r--r-- | eurephiadm/commands/blacklist.c | 66 | ||||
| -rw-r--r-- | eurephiadm/commands/certificates.c | 102 | ||||
| -rw-r--r-- | eurephiadm/commands/edit_config.c | 33 | ||||
| -rw-r--r-- | eurephiadm/commands/fwprofiles.c | 65 | ||||
| -rw-r--r-- | eurephiadm/commands/lastlog.c | 31 | ||||
| -rw-r--r-- | eurephiadm/commands/usercerts.c | 78 | ||||
| -rw-r--r-- | eurephiadm/commands/users.c | 120 |
9 files changed, 598 insertions, 41 deletions
diff --git a/eurephiadm/commands/adminaccess.c b/eurephiadm/commands/adminaccess.c index 056b314..e9f6de2 100644 --- a/eurephiadm/commands/adminaccess.c +++ b/eurephiadm/commands/adminaccess.c @@ -1,5 +1,5 @@ /* useraccess.c -- eurephiadm useraccess command: - * Management of user access levels (eurpehia_adminaccess table) + * Management of user access levels (eurephia_adminaccess table) * * GPLv2 only - Copyright (C) 2009 * David Sommerseth <dazo@users.sourceforge.net> @@ -20,6 +20,15 @@ * */ +/** + * @file adminaccess.c + * @author David Sommerseth <dazo@users.sourceforge.net> + * @date 2009-03-24 + * + * @brief eurephiadm command 'useraccess'. Management of user access levels + * + */ + #include <stdio.h> #include <string.h> #include <assert.h> @@ -29,7 +38,7 @@ #include <libxml/xpath.h> #endif -#define MODULE "eurephia::AdminAccess" +#define MODULE "eurephia::UserAdmin" /**< Need to define the active module before including argparser.h */ #include <eurephia_nullsafe.h> #include <eurephia_context.h> #include <eurephia_log.h> @@ -45,12 +54,17 @@ #include "../field_print.h" #include "../xsltparser.h" +/** + * Help screens for the adminaccess command + * + * @param page which help screen to display + */ void display_adminaccess_help(int page) { switch( page ) { case 'G': printf("The grant mode will grant a user access to a specified access level.\n" "\n" - " -i | --uid User accound ID\n" + " -i | --uid User account ID\n" " -u | --username User name\n" " -I | --interface Grant access through which interface (default 'C')\n" " -a | --access-level Grant access which access level\n" @@ -60,7 +74,7 @@ void display_adminaccess_help(int page) { case 'R': printf("The revoke mode will remove the access from the desired user accounts.\n" "\n" - " -i | --uid User accound ID\n" + " -i | --uid User account ID\n" " -I | --interface Grant access through which interface (default 'C')\n" " -a | --access-level Grant access which access level\n" "\n" @@ -69,7 +83,7 @@ void display_adminaccess_help(int page) { case 'l': printf("The list mode will show the granted user access levels\n" "\n" - " -i | --uid User accound ID\n" + " -i | --uid User account ID\n" " -u | --username User name\n" " -I | --interface Grant access through which interface (default 'C')\n" " -a | --access-level Grant access which access level\n" @@ -86,10 +100,25 @@ void display_adminaccess_help(int page) { } } +/** + * Help screen wrapper. Used by cmd_Help() + */ void help_AdminAccess() { display_adminaccess_help(0); } + +/** + * Help screen wrapper for the adminaccess help function. + * + * @param ctx eurephiaCTX + * @param sess eurephiaSESSION of the current logged in user + * @param cfg eurephiaVALUES struct of the current configuration + * @param argc argument count for the eurephiadm command + * @param argv argument table for the eurephiadm command + * + * @return returns 0 on success, otherwise 1. + */ int help_AdminAccess2(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int argc, char **argv) { e_options helpargs[] = { {"--list", "-l", 0}, @@ -103,6 +132,17 @@ int help_AdminAccess2(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *c return 0; } +/** + * adminaccess list mode, lists all users access levels + * + * @param ctx eurephiaCTX + * @param sess eurephiaSESSION of the current logged in user + * @param cfg eurephiaVALUES struct of the current configuration + * @param argc argument count for the eurephiadm command + * @param argv argument table for the eurephiadm command + * + * @return returns 0 on success, otherwise 1. + */ int list_adminaccess(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int argc, char **argv) { xmlDoc *list_xml = NULL, *srch_xml = NULL; xmlNode *srch_n = NULL, *tmp_n = NULL; @@ -178,6 +218,17 @@ int list_adminaccess(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cf } +/** + * Function for granting and revoking user access levels. + * + * @param ctx eurephiaCTX + * @param sess eurephiaSESSION of the current logged in user + * @param cfg eurephiaVALUES struct of the current configuration + * @param argc argument count for the eurephiadm command + * @param argv argument table for the eurephiadm command + * + * @return returns 0 on success, otherwise 1. + */ int grant_revoke(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int argc, char **argv) { xmlDoc *upd_xml = NULL; xmlNode *root_n = NULL, *fmap_n = NULL; @@ -274,6 +325,18 @@ int grant_revoke(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, i return rc; } + +/** + * Main function for the the adminaccess command + * + * @param ctx eurephiaCTX + * @param sess eurephiaSESSION of the current logged in user + * @param cfg eurephiaVALUES struct of the current configuration + * @param argc argument count for the eurephiadm command + * @param argv argument table for the eurephiadm command + * + * @return returns 0 on success, otherwise 1. + */ int cmd_AdminAccess(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int argc, char **argv) { char **mode_argv; int i, mode_argc = 0, rc = 0; diff --git a/eurephiadm/commands/attempts.c b/eurephiadm/commands/attempts.c index 05b08ee..4f5dd2f 100644 --- a/eurephiadm/commands/attempts.c +++ b/eurephiadm/commands/attempts.c @@ -20,6 +20,14 @@ * */ +/** + * @file attempts.c + * @author David Sommerseth <dazo@users.sourceforge.net> + * @date 2009-05-06 + * + * @brief eurephiadm attempts command. Show/edit records in the attempts table. + * + */ #include <stdio.h> #include <string.h> #include <assert.h> @@ -28,7 +36,7 @@ #include <libxml/tree.h> #endif -#define MODULE "eurephia::Attempts" +#define MODULE "eurephia::Attempts" /**< Need to define the active module before including argparser.h */ #include <eurephia_nullsafe.h> #include <eurephia_context.h> #include <eurephia_log.h> @@ -43,7 +51,11 @@ #include "../field_print.h" #include "../xsltparser.h" - +/** + * Help screens for the attempts command + * + * @param page which help screen to display + */ void display_attempts_help(int page) { switch( page ) { @@ -55,7 +67,7 @@ void display_attempts_help(int page) "Filters:\n" " -u | --username <username> User name\n" " -d | --digest <SHA1 digest> Certificate SHA1 digest\n" - " -i | --ipaddr <ip address> IP address\n\n"); + " -i | --ipaddr <IP address> IP address\n\n"); break; case 'D': @@ -64,7 +76,7 @@ void display_attempts_help(int page) "One of the following parameters must be given (only one):\n" " -u | --username <username> User name\n" " -d | --digest <SHA1 digest> Certificate SHA1 digest\n" - " -i | --ipaddr <ip address> IP address\n" + " -i | --ipaddr <IP address> IP address\n" " -a | --attemptid <ID> Attempts record ID\n" "\n" ); @@ -76,7 +88,7 @@ void display_attempts_help(int page) "One of the following parameters must be given (only one):\n" " -n | --username <username> User name\n" " -d | --digest <SHA1 digest> Certificate SHA1 digest\n" - " -i | --ipaddr <ip address> IP address\n" + " -i | --ipaddr <IP address> IP address\n" " -a | --attemptid <ID> Attempts record ID\n" "\n" ); @@ -93,11 +105,26 @@ void display_attempts_help(int page) } +/** + * Help screen wrapper. Used by cmd_Help() + */ void help_Attempts() { display_attempts_help(0); } + +/** + * Help screen wrapper for the attempts help function. + * + * @param ctx eurephiaCTX + * @param sess eurephiaSESSION of the current logged in user + * @param cfg eurephiaVALUES struct of the current configuration + * @param argc argument count for the eurephiadm command + * @param argv argument table for the eurephiadm command + * + * @return returns 0 on success, otherwise 1. + */ int help_Attempts2(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int argc, char **argv) { e_options modeargs[] = { @@ -112,6 +139,17 @@ int help_Attempts2(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, } +/** + * attempts list mode. List registered failed attempts + * + * @param ctx eurephiaCTX + * @param sess eurephiaSESSION of the current logged in user + * @param cfg eurephiaVALUES struct of the current configuration + * @param argc argument count for the eurephiadm command + * @param argv argument table for the eurephiadm command + * + * @return returns 0 on success, otherwise 1. + */ int list_attempts(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int argc, char **argv) { xmlDoc *log_xml = NULL, *srch_xml = NULL; @@ -174,6 +212,17 @@ int list_attempts(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, } +/** + * Function for modifying attempts records in the database. + * + * @param ctx eurephiaCTX + * @param sess eurephiaSESSION of the current logged in user + * @param cfg eurephiaVALUES struct of the current configuration + * @param argc argument count for the eurephiadm command + * @param argv argument table for the eurephiadm command + * + * @return returns 0 on success, otherwise 1. + */ int modify_attempts(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int argc, char **argv) { xmlDoc *result_xml = NULL, *upd_xml = NULL; @@ -259,6 +308,17 @@ int modify_attempts(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg } +/** + * Main function for the attempts command + * + * @param ctx eurephiaCTX + * @param sess eurephiaSESSION of the current logged in user + * @param cfg eurephiaVALUES struct of the current configuration + * @param argc argument count for the eurephiadm command + * @param argv argument table for the eurephiadm command + * + * @return returns 0 on success, otherwise 1. + */ int cmd_Attempts(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int argc, char **argv) { char **mode_argv; @@ -317,4 +377,3 @@ int cmd_Attempts(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, i return rc; } - diff --git a/eurephiadm/commands/blacklist.c b/eurephiadm/commands/blacklist.c index 334e6e3..fa8fe00 100644 --- a/eurephiadm/commands/blacklist.c +++ b/eurephiadm/commands/blacklist.c @@ -20,6 +20,15 @@ * */ +/** + * @file blacklist.c + * @author David Sommerseth <dazo@users.sourceforge.net> + * @date 2009-05-09 + * + * @brief eurephiadm blacklist command. Show and edit the eurephia blacklists + * + */ + #include <stdio.h> #include <string.h> #include <assert.h> @@ -28,7 +37,7 @@ #include <libxml/tree.h> #endif -#define MODULE "eurephia::Blacklist" +#define MODULE "eurephia::Blacklist" /**< Need to define the active module before including argparser.h */ #include <eurephia_nullsafe.h> #include <eurephia_context.h> #include <eurephia_log.h> @@ -44,6 +53,11 @@ #include "../xsltparser.h" +/** + * Help screens for the blacklist command + * + * @param page which help screen to display + */ void display_blacklist_help(int page) { switch( page ) { @@ -59,7 +73,7 @@ void display_blacklist_help(int page) break; case 'D': - printf("The blacklist delete mode will remove blaclisted items.\n" + printf("The blacklist delete mode will remove blacklisted items.\n" "\n" "One of the following parameters must be given (only one):\n" " -u | --username <username> User name\n" @@ -92,11 +106,26 @@ void display_blacklist_help(int page) } +/** + * Help screen wrapper. Used by cmd_Help() + */ void help_Blacklist() { display_blacklist_help(0); } + +/** + * Help screen wrapper for the blacklist help function. + * + * @param ctx eurephiaCTX + * @param sess eurephiaSESSION of the current logged in user + * @param cfg eurephiaVALUES struct of the current configuration + * @param argc argument count for the eurephiadm command + * @param argv argument table for the eurephiadm command + * + * @return returns 0 on success, otherwise 1. + */ int help_Blacklist2(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int argc, char **argv) { e_options modeargs[] = { @@ -111,6 +140,17 @@ int help_Blacklist2(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg } +/** + * blacklist list mode. Lists all blacklisted certificates, user account and/or IP addresses. + * + * @param ctx eurephiaCTX + * @param sess eurephiaSESSION of the current logged in user + * @param cfg eurephiaVALUES struct of the current configuration + * @param argc argument count for the eurephiadm command + * @param argv argument table for the eurephiadm command + * + * @return returns 0 on success, otherwise 1. + */ int list_blacklist(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int argc, char **argv) { xmlDoc *blst_xml = NULL, *srch_xml = NULL; @@ -172,6 +212,17 @@ int list_blacklist(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, } +/** + * Function for modifying the blacklists + * + * @param ctx eurephiaCTX + * @param sess eurephiaSESSION of the current logged in user + * @param cfg eurephiaVALUES struct of the current configuration + * @param argc argument count for the eurephiadm command + * @param argv argument table for the eurephiadm command + * + * @return returns 0 on success, otherwise 1. + */ int modify_blacklist(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int argc, char **argv) { xmlDoc *result_xml = NULL, *upd_xml = NULL; @@ -257,6 +308,17 @@ int modify_blacklist(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cf } +/** + * Main function for the the blacklist command + * + * @param ctx eurephiaCTX + * @param sess eurephiaSESSION of the current logged in user + * @param cfg eurephiaVALUES struct of the current configuration + * @param argc argument count for the eurephiadm command + * @param argv argument table for the eurephiadm command + * + * @return returns 0 on success, otherwise 1. +*/ int cmd_Blacklist(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int argc, char **argv) { char **mode_argv; diff --git a/eurephiadm/commands/certificates.c b/eurephiadm/commands/certificates.c index 8f56e58..953573b 100644 --- a/eurephiadm/commands/certificates.c +++ b/eurephiadm/commands/certificates.c @@ -20,6 +20,16 @@ * */ +/** + * @file certificates.c + * @author David Sommerseth <dazo@users.sourceforge.net> + * @date 2008-12-20 + * + * @brief eurephiadm certs command, for managing the eurephia certificates. + * + */ + + #include <stdio.h> #include <string.h> #include <ctype.h> @@ -34,7 +44,7 @@ #include <libxml/xpath.h> #endif -#define MODULE "eurephia::Certificates" +#define MODULE "eurephia::Certificates" /**< Need to define the active module before including argparser.h */ #include <eurephia_nullsafe.h> #include <eurephia_context.h> #include <eurephia_log.h> @@ -53,6 +63,11 @@ #include "../xsltparser.h" +/** + * Help screens for the certs command + * + * @param page which help screen to display + */ void display_certs_help(int page) { switch( page ) { case 'A': @@ -64,12 +79,12 @@ void display_certs_help(int page) { " -E | --email e-mail address (emailAddress) of the certificate\n" "\n" "Usually the certificate depth value needs to be 0, if you are registering user\n" - "account certificates. CA certificates usually havea value bigger than 0.\n\n"); + "account certificates. CA certificates usually have a value bigger than 0.\n\n"); #ifdef HAVE_OPENSSL printf("If you have the certificate file available, you can use the following\n" "options to retrieve the needed information directly from a certificate file.\n\n" " -f | --certfile File name of the certificate file.\n" - " -p | --pkcs12 If the file is in PKC#12 format.\n" + " -p | --pkcs12 If the file is in PKCS#12 format.\n" "\n" "The default format is PEM format, unless --pkcs12 is given. These two options\n" "cannot be used together with -D, -C, -O or -E. But the certificate depth must\n" @@ -97,19 +112,35 @@ void display_certs_help(int page) { "Available sort keys are: certid, depth, digest, cname, org, email and registered.\n\n"); break; default: - printf("Available modes for the certficate command are:\n\n" + printf("Available modes for the certificate command are:\n\n" " -A | --add Register a new certificate\n" - " -D | --delete Delete a registered certficate\n" + " -D | --delete Delete a registered certificate\n" " -l | --list List all registered certificates\n" " -h | --help <mode> Help about a specific mode\n\n"); break; } } + +/** + * Help screen wrapper. Used by cmd_Help() + */ void help_Certificates() { display_certs_help(0); } + +/** + * Help screen wrapper for the certs help function. + * + * @param ctx eurephiaCTX + * @param sess eurephiaSESSION of the current logged in user + * @param cfg eurephiaVALUES struct of the current configuration + * @param argc argument count for the eurephiadm command + * @param argv argument table for the eurephiadm command + * + * @return returns 0 on success, otherwise 1. + */ int help_Certificates2(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int argc, char **argv) { e_options helpargs[] = { {"--list", "-l", 0}, @@ -123,7 +154,18 @@ int help_Certificates2(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES * return 0; } - +/** + * Internal certs command, does the proper register request against the eurephia database. + * + * @param ctx eurephiaCTX + * @param depth Certificate depth of the certificate + * @param digest Certificate SHA1 fingerprint (digest) + * @param cname X.509 Common Name value of the certificate + * @param org X.509 Organisation value of the certificate + * @param email X.509 emailAddress value of the certificate + * + * @return Returns the certid reference to the certificate on successful registration, otherwise 0. + */ int register_certificate(eurephiaCTX *ctx, int depth, const char *digest, const char *cname, const char *org, const char *email) { @@ -166,6 +208,18 @@ int register_certificate(eurephiaCTX *ctx, int depth, const char *digest, return certid; } + +/** + * certs add mode. Registers a new certificate. + * + * @param ctx eurephiaCTX + * @param sess eurephiaSESSION of the current logged in user + * @param cfg eurephiaVALUES struct of the current configuration + * @param argc argument count for the eurephiadm command + * @param argv argument table for the eurephiadm command + * + * @return returns 0 on success, otherwise 1. + */ int add_cert(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int argc, char **argv) { char *digest = NULL, *cname = NULL, *org = NULL, *email = NULL, *certfile = NULL; int depth = -1, i = 0, j = 0, chk = 0, certfile_format = 0, rc = 0; @@ -310,6 +364,17 @@ int add_cert(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int a } +/** + * certs delete mode. Removes a registered certificate from the eurephia database. + * + * @param ctx eurephiaCTX + * @param sess eurephiaSESSION of the current logged in user + * @param cfg eurephiaVALUES struct of the current configuration + * @param argc argument count for the eurephiadm command + * @param argv argument table for the eurephiadm command + * + * @return returns 0 on success, otherwise 1. + */ int delete_cert(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int argc, char **argv) { xmlDoc *cert_xml = NULL, *delete_xml = NULL, *certlist = NULL; xmlNode *cert_n = NULL, *search_n = NULL, *delete_n = NULL; @@ -408,7 +473,7 @@ int delete_cert(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, in printf("\n"); get_console_input(confirm, 3, "Do you want to delete the listed certificate(s)? [y/N] ", 0); if( (confirm[0] != 'y') && (confirm[0] != 'Y') ) { - printf("%s: Aborted certficate deletion\n", MODULE); + printf("%s: Aborted certificate deletion\n", MODULE); rc = 0; goto exit; } @@ -435,6 +500,17 @@ int delete_cert(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, in } +/** + * certs list mode. Lists all registered certificate. + * + * @param ctx eurephiaCTX + * @param sess eurephiaSESSION of the current logged in user + * @param cfg eurephiaVALUES struct of the current configuration + * @param argc argument count for the eurephiadm command + * @param argv argument table for the eurephiadm command + * + * @return returns 0 on success, otherwise 1. + */ int list_certs(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int argc, char **argv) { xmlDoc *srch_xml = NULL, *certlist = NULL; xmlNode *cert_n = NULL, *srch_n = NULL; @@ -498,6 +574,18 @@ int list_certs(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int return rc; } + +/** + * Main function of the certs command. + * + * @param ctx eurephiaCTX + * @param sess eurephiaSESSION of the current logged in user + * @param cfg eurephiaVALUES struct of the current configuration + * @param argc argument count for the eurephiadm command + * @param argv argument table for the eurephiadm command + * + * @return returns 0 on success, otherwise 1. + */ int cmd_Certificates(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int argc, char **argv) { char **mode_argv; int i, mode_argc = 0, rc = 0; diff --git a/eurephiadm/commands/edit_config.c b/eurephiadm/commands/edit_config.c index b17175c..d029364 100644 --- a/eurephiadm/commands/edit_config.c +++ b/eurephiadm/commands/edit_config.c @@ -1,7 +1,7 @@ /* edit_config.c -- eurephiadm command: * Sets, deletes or prints a config setting in the database * - * GPLv2 only - Copyright (C) 2008 + * GPLv2 only - Copyright (C) 2008, 2009 * David Sommerseth <dazo@users.sourceforge.net> * * This program is free software; you can redistribute it and/or @@ -20,6 +20,16 @@ * */ +/** + * @file edit_config.c + * @author David Sommerseth <dazo@users.sourceforge.net> + * @date 2008-12-02 + * + * @brief eurephia config command. Sets, deletes or retrieves config settings + * + */ + + #include <stdio.h> #include <string.h> #include <assert.h> @@ -32,9 +42,13 @@ #include <eurephiadb_session_struct.h> #include <eurephiadb_driver.h> -#define MODULE "eurephiadm::config" +#define MODULE "eurephiadm::config" /**< Need to define the active module before including argparser.h */ #include "../argparser.h" +/** + * config help screen. + * + */ void help_EditConfig() { printf("%s - Edit eurephia configuration\n\n", MODULE); printf(" The config command let you add, change or delete\n" @@ -54,9 +68,22 @@ void help_EditConfig() { printf(" The command will exit with exit code 0 on success.\n\n"); } -// Reusing this function for the --list argument +/** + * Reusing this function for the --list argument + */ int cmd_ShowCfg(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int argc, char **argv); +/** + * Main function for the config command. + * + * @param ctx eurephiaCTX + * @param sess eurephiaSESSION of the current logged in user + * @param cfg eurephiaVALUES struct of the current configuration + * @param argc argument count for the eurephiadm command + * @param argv argument table for the eurephiadm command + * + * @return returns 0 on success, otherwise 1. + */ int cmd_EditConfig(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int argc, char **argv) { int rc = 0, i = 0; e_options editargs[] = { diff --git a/eurephiadm/commands/fwprofiles.c b/eurephiadm/commands/fwprofiles.c index 81d96bd..4c594dc 100644 --- a/eurephiadm/commands/fwprofiles.c +++ b/eurephiadm/commands/fwprofiles.c @@ -20,6 +20,15 @@ * */ +/** + * @file fwprofiles.c + * @author David Sommerseth <dazo@users.sourceforge.net> + * @date 2009-03-29 + * + * @brief eurephia fwprofiles command, to manage firewall profiles. + * + */ + #include <stdio.h> #include <string.h> #include <assert.h> @@ -28,7 +37,7 @@ #include <libxml/tree.h> #endif -#define MODULE "eurephia::fwProfiles" +#define MODULE "eurephia::fwProfiles" /**< Needed to define the active module before including argparser.h */ #include <eurephia_nullsafe.h> #include <eurephia_context.h> #include <eurephia_log.h> @@ -44,6 +53,11 @@ #include "../xsltparser.h" +/** + * Help screens for the fwprofiles command + * + * @param page which help screen to display + */ void display_fwprofiles_help(int page) { switch( page ) { @@ -91,11 +105,26 @@ void display_fwprofiles_help(int page) } +/** + * Help screen wrapper. Used by cmd_Help() + */ void help_fwProfiles() { display_fwprofiles_help(0); } + +/** + * Help screen wrapper for the fwprofile help function. + * + * @param ctx eurephiaCTX + * @param sess eurephiaSESSION of the current logged in user + * @param cfg eurephiaVALUES struct of the current configuration + * @param argc argument count for the eurephiadm command + * @param argv argument table for the eurephiadm command + * + * @return returns 0 on success, otherwise 1. + */ int help_fwProfiles2(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int argc, char **argv) { e_options fwprofilesargs[] = { @@ -110,6 +139,17 @@ int help_fwProfiles2(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cf } +/** + * fwprofiles list mode. Lists all registered firewall profiles. + * + * @param ctx eurephiaCTX + * @param sess eurephiaSESSION of the current logged in user + * @param cfg eurephiaVALUES struct of the current configuration + * @param argc argument count for the eurephiadm command + * @param argv argument table for the eurephiadm command + * + * @return returns 0 on success, otherwise 1. + */ int list_profiles(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int argc, char **argv) { xmlDoc *profiles_xml = NULL, *srch_xml = NULL; @@ -193,6 +233,17 @@ int list_profiles(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, } +/** + * fwprofile add/delete mode. Registers or removes firewall profiles. + * + * @param ctx eurephiaCTX + * @param sess eurephiaSESSION of the current logged in user + * @param cfg eurephiaVALUES struct of the current configuration + * @param argc argument count for the eurephiadm command + * @param argv argument table for the eurephiadm command + * + * @return returns 0 on success, otherwise 1. + */ int addelete_profile(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int argc, char **argv) { xmlDoc *result_xml = NULL, *srch_xml = NULL; @@ -284,6 +335,17 @@ int addelete_profile(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cf } +/** + * Main function for the fwprofiles command + * + * @param ctx eurephiaCTX + * @param sess eurephiaSESSION of the current logged in user + * @param cfg eurephiaVALUES struct of the current configuration + * @param argc argument count for the eurephiadm command + * @param argv argument table for the eurephiadm command + * + * @return returns 0 on success, otherwise 1. + */ int cmd_fwProfiles(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int argc, char **argv) { char **mode_argv; @@ -342,4 +404,3 @@ int cmd_fwProfiles(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, return rc; } - diff --git a/eurephiadm/commands/lastlog.c b/eurephiadm/commands/lastlog.c index 374ff24..586801e 100644 --- a/eurephiadm/commands/lastlog.c +++ b/eurephiadm/commands/lastlog.c @@ -1,5 +1,5 @@ -/* usercerts.c -- eurephiadm lastlog command: - * Queries the lastlog table +/* lastlog.c -- eurephiadm lastlog command: + * Queries the lastlog table * * GPLv2 only - Copyright (C) 2009 * David Sommerseth <dazo@users.sourceforge.net> @@ -20,6 +20,15 @@ * */ +/** + * @file lastlog.c + * @author David Sommerseth <dazo@users.sourceforge.net> + * @date 2009-03-24 + * + * @brief eurephiadm lastlog command. Queries the lastlog database. + * + */ + #include <stdio.h> #include <string.h> #include <assert.h> @@ -29,7 +38,7 @@ #include <libxml/xpath.h> #endif -#define MODULE "eurephia::UserCerts" +#define MODULE "eurephia::LastLog" /**< Need to define the active module before including argparser.h */ #include <eurephia_nullsafe.h> #include <eurephia_context.h> #include <eurephia_log.h> @@ -46,11 +55,14 @@ #include "../xsltparser.h" +/** + * Help screen for the lastlog command + */ void help_Lastlog() { printf("eurephiadm::Lastlog\n\n" "This command will query the lastlog entries, which contains information\n" - "about all logins done with the eurephia-auth plugin.\n\n" + "about all logins done with the eurephia-auth plug-in.\n\n" "Valid arguments:\n" " * Filters:\n" " -c | --certid Certificate ID\n" @@ -72,6 +84,17 @@ void help_Lastlog() } +/** + * Main function for the lastlog command. Does the querying of the database and show the result + * + * @param ctx eurephiaCTX + * @param sess eurephiaSESSION of the current logged in user + * @param cfg eurephiaVALUES struct of the current configuration + * @param argc argument count for the eurephiadm command + * @param argv argument table for the eurephiadm command + * + * @return returns 0 on success, otherwise 1. + */ int cmd_Lastlog(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int argc, char **argv) { xmlDoc *lastlog_xml = NULL, *srch_xml = NULL; diff --git a/eurephiadm/commands/usercerts.c b/eurephiadm/commands/usercerts.c index 322cefe..a0e5f8b 100644 --- a/eurephiadm/commands/usercerts.c +++ b/eurephiadm/commands/usercerts.c @@ -20,6 +20,15 @@ * */ +/** + * @file usercerts.c + * @author David Sommerseth <dazo@users.sourceforge.net> + * @date 2008-12-28 + * + * @brief eurephiadm usercerts command. Manages the user account and certificate links. + * + */ + #include <stdio.h> #include <string.h> #include <assert.h> @@ -29,7 +38,7 @@ #include <libxml/xpath.h> #endif -#define MODULE "eurephia::UserCerts" +#define MODULE "eurephia::UserCerts" /**< Need to define the current module before including argparser.h */ #include <eurephia_nullsafe.h> #include <eurephia_context.h> #include <eurephia_log.h> @@ -45,6 +54,12 @@ #include "../field_print.h" #include "../xsltparser.h" + +/** + * Help screens for the usercerts command + * + * @param page which help screen to display + */ void display_usercerts_help(int page) { switch( page ) { case 'A': @@ -104,10 +119,26 @@ void display_usercerts_help(int page) { } } + +/** + * Help screen wrapper. Used by cmd_Help() + */ void help_UserCerts() { display_usercerts_help(0); } + +/** + * Help screen wrapper for the usercerts help function. + * + * @param ctx eurephiaCTX + * @param sess eurephiaSESSION of the current logged in user + * @param cfg eurephiaVALUES struct of the current configuration + * @param argc argument count for the eurephiadm command + * @param argv argument table for the eurephiadm command + * + * @return returns 0 on success, otherwise 1. + */ int help_UserCerts2(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int argc, char **argv) { e_options helpargs[] = { {"--list", "-l", 0}, @@ -124,6 +155,18 @@ int help_UserCerts2(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg return 0; } + +/** + * usercerts list mode. Lists all registered user account and certificate links. + * + * @param ctx eurephiaCTX + * @param sess eurephiaSESSION of the current logged in user + * @param cfg eurephiaVALUES struct of the current configuration + * @param argc argument count for the eurephiadm command + * @param argv argument table for the eurephiadm command + * + * @return returns 0 on success, otherwise 1. + */ int list_usercerts(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int argc, char **argv) { xmlDoc *list_xml = NULL, *srch_xml = NULL; xmlNode *srch_n = NULL, *fmap_n = NULL; @@ -178,6 +221,17 @@ int list_usercerts(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, } +/** + * usercerts add and delete mode. Modifies the user-certs links. + * + * @param ctx eurephiaCTX + * @param sess eurephiaSESSION of the current logged in user + * @param cfg eurephiaVALUES struct of the current configuration + * @param argc argument count for the eurephiadm command + * @param argv argument table for the eurephiadm command + * + * @return returns 0 on success, otherwise 1. + */ int add_del_usercert(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int argc, char **argv) { xmlDoc *usercert_xml = NULL, *resxml = NULL; xmlNode *usercert_n = NULL, *res_n = NULL; @@ -313,6 +367,17 @@ int add_del_usercert(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cf #ifdef FIREWALL +/** + * usercerts set-fwprofile mode. Changes the firewall profile for a specific user-certs link + * + * @param ctx eurephiaCTX + * @param sess eurephiaSESSION of the current logged in user + * @param cfg eurephiaVALUES struct of the current configuration + * @param argc argument count for the eurephiadm command + * @param argv argument table for the eurephiadm command + * + * @return returns 0 on success, otherwise 1. + */ int set_fwprofile(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int argc, char **argv) { xmlDoc *usercert_xml = NULL, *res_xml = NULL; xmlNode *usercert_n = NULL, *fmap_n = NULL, *res_n = NULL; @@ -403,6 +468,17 @@ int set_fwprofile(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, #endif +/** + * Main function for the usercerts command. + * + * @param ctx eurephiaCTX + * @param sess eurephiaSESSION of the current logged in user + * @param cfg eurephiaVALUES struct of the current configuration + * @param argc argument count for the eurephiadm command + * @param argv argument table for the eurephiadm command + * + * @return returns 0 on success, otherwise 1. + */ int cmd_UserCerts(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int argc, char **argv) { char **mode_argv; int i, mode_argc = 0, rc = 0; diff --git a/eurephiadm/commands/users.c b/eurephiadm/commands/users.c index 4450b37..9210094 100644 --- a/eurephiadm/commands/users.c +++ b/eurephiadm/commands/users.c @@ -19,6 +19,15 @@ * */ +/** + * @file users.c + * @author David Sommerseth <dazo@users.sourceforge.net> + * @date 2008-12-01 + * + * @brief eurephiadm users command. User account management command. + * + */ + #include <stdio.h> #include <string.h> #include <sys/stat.h> @@ -30,7 +39,7 @@ #include <libxml/xpath.h> #endif -#define MODULE "eurephia::Users" +#define MODULE "eurephia::Users" /**< Need to define the active module before including argparser.h */ #include <eurephia_nullsafe.h> #include <eurephia_context.h> #include <eurephia_log.h> @@ -48,13 +57,22 @@ #include "../parse_certificate_files.h" #include "../xsltparser.h" -// Reuse code which is in certificats.c +// Reuse code which is in certificates.c #define SHOWCERTS_FIREWALL 0x001 #define SHOWCERTS_DIGEST 0x002 +/** + * Forward declaration of a function already found in certificates.c + */ int register_certificate(eurephiaCTX *ctx, int depth, const char *digest, const char *cname, const char *org, const char *email); + +/** + * Help screens for the users command + * + * @param page which help screen to display + */ void display_users_help(int page) { printf("\n%s -- Administer user accounts\n\n", MODULE); @@ -75,7 +93,7 @@ void display_users_help(int page) { "Optional arguments are:\n\n" " -l | --lastlog Show users lastlog entries\n" " -L | --lastlog-details Show a more verbose lastlog\n" - " -a | --attempts Show users failed attempts and blaclisting\n" + " -a | --attempts Show users failed attempts and blacklisting\n" " -b | --blacklist Alias for --attempts\n" "\n"); break; @@ -137,6 +155,18 @@ void display_users_help(int page) { } } + +/** + * Help screen wrapper for the users help function. + * + * @param ctx eurephiaCTX + * @param sess eurephiaSESSION of the current logged in user + * @param cfg eurephiaVALUES struct of the current configuration + * @param argc argument count for the eurephiadm command + * @param argv argument table for the eurephiadm command + * + * @return returns 0 on success, otherwise 1. + */ int help_Users2(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int argc, char **argv) { e_options helpargs[] = { {"--list", "-l", 0}, @@ -154,11 +184,25 @@ int help_Users2(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, in return 0; } +/** + * Help screen wrapper. Used by cmd_Help() + */ void help_Users() { display_users_help(0); } +/** + * users list mode. Lists all registered users. + * + * @param ctx eurephiaCTX + * @param sess eurephiaSESSION of the current logged in user + * @param cfg eurephiaVALUES struct of the current configuration + * @param argc argument count for the eurephiadm command + * @param argv argument table for the eurephiadm command + * + * @return returns 0 on success, otherwise 1. + */ int list_users(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int argc, char **argv) { xmlDoc *userlist = NULL; int i = 0; @@ -198,6 +242,15 @@ int list_users(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int return 0; } +/** + * Simple function to convert account flags from an XML document to a string of flags, + * separated by space + * + * @param xpathCTX XPath context of the XML document being parsed. + * @param xpath XPath expression of the flag nodes. + * + * @return Returns a string of flags on success, otherwise NULL is returned. + */ char *xmlFlags2str(xmlXPathContext *xpathCTX, const char *xpath) { xmlXPathObject *flagsObj = NULL; int i = 0; @@ -225,7 +278,17 @@ char *xmlFlags2str(xmlXPathContext *xpathCTX, const char *xpath) { } -// Show account information for a particular user +/** + * users show mode. Show account information for a particular user + * + * @param ctx eurephiaCTX + * @param sess eurephiaSESSION of the current logged in user + * @param cfg eurephiaVALUES struct of the current configuration + * @param argc argument count for the eurephiadm command + * @param argv argument table for the eurephiadm command + * + * @return returns 0 on success, otherwise 1. + */ int show_user(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int argc, char **argv) { int i, crit_set = 0, lastlog_verb = 0; long int show_info = USERINFO_user | USERINFO_certs; @@ -297,7 +360,7 @@ int show_user(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int } } - // Check if we have the needed search criterias + // Check if we have the needed search criteria if( crit_set == 0 ) { fprintf(stderr, "%s: Missing required parameter. You must provide either user id or user name\n", @@ -308,7 +371,7 @@ int show_user(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int if( crit_set > 1 ) { fprintf(stderr, - "%s: You cannot have several search criterias (-i | -u)\n", MODULE); + "%s: You cannot have several search criteria (-i | -u)\n", MODULE); xmlFreeDoc(srch_xml); return 1; } @@ -364,7 +427,19 @@ int show_user(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int } -// This function handles activation, deactivation and deletion of an account + + +/** + * This function handles activation, deactivation and deletion of an account + * + * @param ctx eurephiaCTX + * @param sess eurephiaSESSION of the current logged in user + * @param cfg eurephiaVALUES struct of the current configuration + * @param argc argument count for the eurephiadm command + * @param argv argument table for the eurephiadm command + * + * @return returns 0 on success, otherwise 1. + */ int account_activation(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int argc, char **argv) { xmlDoc *user_xml = NULL, *update_xml = NULL, *srch_xml = NULL, *tmp_xml = NULL; xmlNode *user_n = NULL, *update_n = NULL, *srch_root = NULL, *tmp_n = NULL; @@ -437,7 +512,7 @@ int account_activation(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES * } } - // Check if we have the needed search criterias + // Check if we have the needed search criteria if( crit_set == 0 ) { fprintf(stderr, "%s: Missing required parameter. You must provide either user id or user name\n", @@ -448,7 +523,7 @@ int account_activation(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES * if( crit_set > 1 ) { fprintf(stderr, - "%s: You cannot have several search criterias (-i | -u)\n", MODULE); + "%s: You cannot have several search criteria (-i | -u)\n", MODULE); xmlFreeDoc(srch_xml); return 1; } @@ -503,7 +578,7 @@ int account_activation(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES * case 'd': // Deactivate a user account if( (activated != NULL) && (deactivated != NULL) ) { - printf("User account is already deactived\n"); + printf("User account is already deactivated\n"); goto exit; } else if( (activated != NULL) ) { // Set deactivated to now() @@ -580,7 +655,7 @@ int account_activation(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES * tmp_xml = eDBadminUserCertsLink(ctx, update_xml); if( tmp_xml == NULL ) { - fprintf(stderr, "%s: Failed to deregister user <-> certificate link\n", MODULE); + fprintf(stderr, "%s: Failed to remove the user-certs link\n", MODULE); } tmp_n = eurephiaXML_getRoot(ctx, tmp_xml, NULL, 1); @@ -604,6 +679,18 @@ int account_activation(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES * return (rc != 1); } + +/** + * users add mode. Creates a new user account. + * + * @param ctx eurephiaCTX + * @param sess eurephiaSESSION of the current logged in user + * @param cfg eurephiaVALUES struct of the current configuration + * @param argc argument count for the eurephiadm command + * @param argv argument table for the eurephiadm command + * + * @return returns 0 on success, otherwise 1. + */ int add_user(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int argc, char **argv) { xmlDoc *user_xml = NULL; xmlNode *node = NULL, *node2 = NULL; @@ -862,6 +949,17 @@ int add_user(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int a } +/** + * Main function for the users command. + * + * @param ctx eurephiaCTX + * @param sess eurephiaSESSION of the current logged in user + * @param cfg eurephiaVALUES struct of the current configuration + * @param argc argument count for the eurephiadm command + * @param argv argument table for the eurephiadm command + * + * @return returns 0 on success, otherwise 1. + */ int cmd_Users(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int argc, char **argv) { char **mode_argv; int i, mode_argc = 0, rc = 0; |
