From 54c9514a3171e581344e1823741ef1dd05108e4d Mon Sep 17 00:00:00 2001 From: Mathias Dietz Date: Wed, 5 Mar 2014 16:26:20 +0100 Subject: [PATCH] Add protocol version to smbstatus output Signed-off-by: Mathias Dietz Reviewed-by: Stefan Metzmacher --- source3/include/session.h | 1 + source3/lib/sessionid_tdb.c | 28 ++++++++++++++++++++++++++++ source3/utils/status.c | 8 ++++---- 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/source3/include/session.h b/source3/include/session.h index 2aca1df..ba96ae3 100644 --- a/source3/include/session.h +++ b/source3/include/session.h @@ -38,5 +38,6 @@ struct sessionid { struct server_id pid; fstring ip_addr_str; time_t connect_start; + fstring protocol_ver; }; diff --git a/source3/lib/sessionid_tdb.c b/source3/lib/sessionid_tdb.c index 7a19611..fd6cf75 100644 --- a/source3/lib/sessionid_tdb.c +++ b/source3/lib/sessionid_tdb.c @@ -45,6 +45,34 @@ static int sessionid_traverse_read_fn(struct smbXsrv_session_global0 *global, .pid = global->channels[0].server_id, }; + switch(global->connection_dialect){ + case SMB2_DIALECT_REVISION_000: + fstrcpy(session.protocol_ver, "NT1"); + break; + case SMB2_DIALECT_REVISION_202: + fstrcpy(session.protocol_ver, "SMB2_02"); + break; + case SMB2_DIALECT_REVISION_210: + fstrcpy(session.protocol_ver, "SMB2_10"); + break; + case SMB2_DIALECT_REVISION_222: + fstrcpy(session.protocol_ver, "SMB2_22"); + break; + case SMB2_DIALECT_REVISION_224: + fstrcpy(session.protocol_ver, "SMB2_24"); + break; + case SMB3_DIALECT_REVISION_300: + fstrcpy(session.protocol_ver, "SMB3_00"); + break; + case SMB3_DIALECT_REVISION_302: + fstrcpy(session.protocol_ver, "SMB3_02"); + break; + default: + fstr_sprintf(session.protocol_ver, "Unknown (0x%04x)", + global->connection_dialect); + break; + } + if (session_info != NULL) { session.uid = session_info->unix_token->uid; session.gid = session_info->unix_token->gid; diff --git a/source3/utils/status.c b/source3/utils/status.c index 40d38c9..61a450e 100644 --- a/source3/utils/status.c +++ b/source3/utils/status.c @@ -303,10 +303,10 @@ static int traverse_sessionid(const char *key, struct sessionid *session, } } - d_printf("%-7s %-12s %-12s %-12s (%s)\n", + d_printf("%-7s %-12s %-12s %-12s (%s) %-12s\n", procid_str_static(&session->pid), uid_str, gid_str, - session->remote_machine, session->hostname); + session->remote_machine, session->hostname, session->protocol_ver); return 0; } @@ -472,8 +472,8 @@ int main(int argc, const char *argv[]) if ( show_processes ) { d_printf("\nSamba version %s\n",samba_version_string()); - d_printf("PID Username Group Machine \n"); - d_printf("-------------------------------------------------------------------\n"); + d_printf("PID Username Group Machine Protocol Version \n"); + d_printf("------------------------------------------------------------------------------\n"); sessionid_traverse_read(traverse_sessionid, NULL); -- 1.7.9.5