summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Sommerseth <dazo@users.sourceforge.net>2008-12-19 15:06:48 +0100
committerDavid Sommerseth <dazo@users.sourceforge.net>2008-12-19 15:06:48 +0100
commite29713fb05ab8cac0fdbd904277d19bc4b2ec215 (patch)
treef05c2b7c28c370927b7e94f70dfaf86b756242fc
parentd2c2dab3607cf663c57d420ae0e08ca214d8297d (diff)
downloadeurephia-e29713fb05ab8cac0fdbd904277d19bc4b2ec215.tar.gz
eurephia-e29713fb05ab8cac0fdbd904277d19bc4b2ec215.tar.xz
eurephia-e29713fb05ab8cac0fdbd904277d19bc4b2ec215.zip
users command: Made a simpler lastlog view as well
-rw-r--r--eurephiadm/commands/users.c71
1 files changed, 39 insertions, 32 deletions
diff --git a/eurephiadm/commands/users.c b/eurephiadm/commands/users.c
index b90c49d..e226cfd 100644
--- a/eurephiadm/commands/users.c
+++ b/eurephiadm/commands/users.c
@@ -69,11 +69,12 @@ void display_users_help(int page) {
case 's':
printf("The show mode shows more information about a user account.\n"
"The needed arguments are one of the following arguments:\n\n"
- " -i | --uid Numeric user ID\n"
- " -u | --username User name\n"
- " -l | --lastlog Show users lastlog entries\n"
- " -a | --attempts Show users failed attempts and blaclisting\n"
- " -b | --blacklist Alias for --attempts\n"
+ " -i | --uid Numeric user ID\n"
+ " -u | --username User name\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"
+ " -b | --blacklist Alias for --attempts\n"
"\n");
break;
@@ -307,7 +308,7 @@ void xmlPrint_certs(xmlXPathContext *certsXP, const char *xpath) {
xmlXPathFreeObject(certsObj);
}
-void xmlPrint_lastlog(xmlXPathContext *xpathCTX, const char *xpath) {
+void xmlPrint_lastlog(xmlXPathContext *xpathCTX, int verb, const char *xpath) {
xmlXPathObject *lastlogObj = NULL;
int i = 0;
char tmp[66];
@@ -330,12 +331,14 @@ void xmlPrint_lastlog(xmlXPathContext *xpathCTX, const char *xpath) {
memset(&tmp, 0, 66);
printf(" %-10.10s %-22.22s %19.19s %19.19s\n",
"Status", "Login", "Logout", "Session closed");
- printf(" %-10.10s %-22.22s %19.19s %19.19s\n",
- "Protocol", "Remote:port", "VPN MAC", "VPN IP");
- printf(" %-37.37s %37.37s\n", "Common name", "Organisation");
+ if( verb == 1 ) {
+ printf(" %-10.10s %-22.22s %19.19s %19.19s\n",
+ "Protocol", "Remote:port", "VPN MAC", "VPN IP");
+ printf(" %-37.37s %37.37s\n", "Common name", "Organisation");
#ifdef FIREWALL
- printf(" %-37.37s %37.37s\n", "Firewall access profile", "FW Destination");
+ printf(" %-37.37s %37.37s\n", "Firewall access profile", "FW Destination");
#endif
+ }
printf(" --------------------------------------------------------------------"
"----------\n");
@@ -358,28 +361,29 @@ void xmlPrint_lastlog(xmlXPathContext *xpathCTX, const char *xpath) {
defaultValue(xmlGetNodeContent(session_n, "session_closed"), "-")
);
- snprintf(tmp, 64, "%s:%s",
- xmlGetNodeContent(conn, "remote_host"),
- xmlGetNodeContent(conn, "remote_port"));
- printf(" %-10.10s %-22.22s %19.19s %19.19s\n",
- xmlGetNodeContent(conn, "protocol"),
- tmp,
- defaultValue(xmlGetNodeContent(conn, "vpn_macaddr"), "(not available)"),
- xmlGetNodeContent(conn, "vpn_ipaddr")
- );
-
- printf(" %-37.37s %37.37s\n",
- xmlGetNodeContent(cert, "common_name"),
- xmlGetNodeContent(cert, "organisation")
- );
+ if( verb == 1 ) {
+ snprintf(tmp, 64, "%s:%s",
+ xmlGetNodeContent(conn, "remote_host"),
+ xmlGetNodeContent(conn, "remote_port"));
+ printf(" %-10.10s %-22.22s %19.19s %19.19s\n",
+ xmlGetNodeContent(conn, "protocol"),
+ tmp,
+ defaultValue(xmlGetNodeContent(conn, "vpn_macaddr"), "(not available)"),
+ xmlGetNodeContent(conn, "vpn_ipaddr")
+ );
+
+ printf(" %-37.37s %37.37s\n",
+ xmlGetNodeContent(cert, "common_name"),
+ xmlGetNodeContent(cert, "organisation")
+ );
#ifdef FIREWALL
- printf(" %-37.37s %37.37s\n",
- defaultValue(xmlExtractContent(acpr), "(not set)"),
- defaultValue(xmlGetAttrValue(acpr->properties, "fwdestination"), "-")
- );
+ printf(" %-37.37s %37.37s\n",
+ defaultValue(xmlExtractContent(acpr), "(not set)"),
+ defaultValue(xmlGetAttrValue(acpr->properties, "fwdestination"), "-")
+ );
#endif
- printf("\n");
-
+ printf("\n");
+ }
}
printf(" --------------------------------------------------------------------"
@@ -392,7 +396,7 @@ void xmlPrint_lastlog(xmlXPathContext *xpathCTX, const char *xpath) {
// Show account information for a particular user
int show_user(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int argc, char **argv) {
xmlXPathContext *user_XP = NULL;
- int i, crit_set = 0;
+ int i, crit_set = 0, lastlog_verb = 0;
long int show_info = USERINFO_user | USERINFO_certs;
xmlDoc *user_xml = NULL, *srch_xml = NULL;
xmlNode *srch_root = NULL, *user_n = NULL;
@@ -401,6 +405,7 @@ int show_user(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int
{"--uid", "-i", 1},
{"--username", "-u", 1},
{"--lastlog", "-l", 0},
+ {"--lastlog-details", "-L", 0},
{"--attempts", "-a", 0},
{"--blacklist", "-b", 0}, // Alias for -a | --attempts
{"--help", "-h", 0},
@@ -441,6 +446,8 @@ int show_user(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int
show_info = USERINFO_attempts | USERINFO_blacklist;
break;
+ case 'L':
+ lastlog_verb = 1;
case 'l':
show_info = USERINFO_lastlog;
break;
@@ -513,7 +520,7 @@ int show_user(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int
if( show_info & USERINFO_lastlog ) {
printf("** Lastlog entries for %s\n\n", xmlGetNodeContent(user_n, "username"));
- xmlPrint_lastlog(user_XP, "/eurephia/user/lastlog/session");
+ xmlPrint_lastlog(user_XP, lastlog_verb, "/eurephia/user/lastlog/session");
}
if( (show_info & USERINFO_attempts) || (show_info & USERINFO_blacklist) ) {