[PATCH] Add protocol version to smbstatus output

Volker Lendecke Volker.Lendecke at SerNet.DE
Thu May 22 05:40:04 MDT 2014


On Thu, May 22, 2014 at 11:33:04AM +0200, Stefan (metze) Metzmacher wrote:
> And now a version which compiles...

Reviewed-by: me

Volker

> 
> Am 22.05.2014 11:24, schrieb Stefan (metze) Metzmacher:
> > Hi Mathias,
> > 
> > this version applies to master.
> > If this is fine for you (I added your sign-off), we need a 2nd team
> > member to review and push this.
> > 
> > metze
> > 
> >> "Stefan (metze) Metzmacher" <metze at samba.org> wrote on 05/21/2014
> >> 08:15:03 PM:
> >>
> >>> From: "Stefan (metze) Metzmacher" <metze at samba.org>
> >>> To: Mathias Dietz/Germany/IBM at IBMDE
> >>> Cc: samba-technical at samba.org
> >>> Date: 05/21/2014 08:15 PM
> >>> Subject: Re: [PATCH] Add protocol version to smbstatus output
> >>>
> >>> Hi Mathias,
> >>>
> >>>> +   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_00");
> >>>> +         break;
> >>>
> >>> This should be SMB2_02.
> >>>
> >>>> +   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;
> >>>
> >>> Please also add SMB3_02.
> >>>
> >>> Thanks!
> >>>
> >>> metze
> >>>

> From 54c9514a3171e581344e1823741ef1dd05108e4d Mon Sep 17 00:00:00 2001
> From: Mathias Dietz <mdietz at de.ibm.com>
> Date: Wed, 5 Mar 2014 16:26:20 +0100
> Subject: [PATCH] Add protocol version to smbstatus output
> 
> Signed-off-by: Mathias Dietz <mdietz at de.ibm.com>
> Reviewed-by: Stefan Metzmacher <metze at samba.org>
> ---
>  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
> 




-- 
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de


More information about the samba-technical mailing list