Web lists-archives.com

Re: [Samba] eventlog functionality




On 2018-09-12 09:44 AM, Jeremy Allison via samba wrote:
On Wed, Sep 12, 2018 at 09:30:19AM -0700, Ray Klassen via samba wrote:

and from the what the hell department. I did it. Comparing

https://docs.microsoft.com/en-us/windows/desktop/api/lmshare/ns-lmshare-_session_info_1


and

https://docs.microsoft.com/en-us/windows/desktop/api/lmshare/ns-lmshare-_session_info_10

and

init_srv_sess_info_1


I copied, pasted and edited myself a init_srv_sess_info_1 and case  to go
with it. It seems to have compiled...

Woo hoo ! Please post as a patch for review :-).


Glad to. hope this is ok. I read up on the wiki about doing this via git, but as this is the very first patch I've ever posted to any FOSS project I hope you'll forgive the mess.

> /***/
>
966a969,1033
>  fill in a sess info level 10 structure.
>  ********************************************************************/
>
> static WERROR init_srv_sess_info_10(struct pipes_struct *p,
> 				   struct srvsvc_NetSessCtr10 *ctr10,
> 				   uint32_t *resume_handle_p,
> 				   uint32_t *total_entries)
> {
> 	struct sessionid *session_list;
> 	uint32_t num_entries = 0;
> 	time_t now = time(NULL);
> 	uint32_t resume_handle = resume_handle_p ? *resume_handle_p : 0;
>
> 	ZERO_STRUCTP(ctr10);
>
> 	if (ctr10 == NULL) {
> 		if (resume_handle_p) {
> 			*resume_handle_p = 0;
> 		}
> 		return WERR_OK;
> 	}
>
> 	*total_entries = list_sessions(p->mem_ctx, &session_list);
>
> 	if (resume_handle >= *total_entries) {
> 		if (resume_handle_p) {
> 			*resume_handle_p = 0;
> 		}
> 		return WERR_OK;
> 	}
>
> 	/* We know num_entries must be positive, due to
> 	   the check resume_handle >= *total_entries above. */
>
> 	num_entries = *total_entries - resume_handle;
>
> 	ctr10->array = talloc_zero_array(p->mem_ctx,
> 				   struct srvsvc_NetSessInfo10,
> 				   num_entries);
>
> 	W_ERROR_HAVE_NO_MEMORY(ctr10->array);
>
> for (num_entries = 0; resume_handle < *total_entries; num_entries++, resume_handle++) {
> 		uint32_t connect_time;
>
> connect_time = (uint32_t)(now - session_list[resume_handle].connect_start);
>
> ctr10->array[num_entries].client = session_list[resume_handle].remote_machine;
> 		ctr10->array[num_entries].user		= session_list[resume_handle].username;
> 		ctr10->array[num_entries].time		= connect_time;
> 		ctr10->array[num_entries].idle_time	= 0;
> 	}
>
> 	if (resume_handle_p) {
> 		if (*resume_handle_p >= *total_entries) {
> 			*resume_handle_p = 0;
> 		} else {
> 			*resume_handle_p = resume_handle;
> 		}
> 	}
>
> 	return WERR_OK;
> }
>
> /*******************************************************************
1481a1549,1555
> 						    r->in.resume_handle,
> 						    r->out.totalentries);
> 			break;
>
> 		case 10:
> 			werr = init_srv_sess_info_10(p,
> 						    r->in.info_ctr->ctr.ctr10,

--
To unsubscribe from this list go to the following URL and read the
instructions:  https://lists.samba.org/mailman/options/samba