[Samba] eventlog functionality
ray klassen
julius_ahenobarbus at yahoo.co.uk
Thu Sep 13 00:48:13 UTC 2018
maybe if this gets to be a habit I will do the git thing. But for now I've got 3 DC's to patch
--- ../samba.orig/samba-4.8.4/source3/rpc_server/srvsvc/srv_srvsvc_nt.c 2018-01-17 00:08:39.000000000 -0800
+++ source3/rpc_server/srvsvc/srv_srvsvc_nt.c 2018-09-12 16:11:12.847142820 -0700
@@ -872,6 +872,8 @@
* count the num of open files on all sessions
*******************************************************************/
+/***/
+
static void net_count_files_for_all_sess(struct srvsvc_NetSessCtr1 *ctr1,
struct sessionid *session_list,
uint32_t resume_handle,
@@ -964,6 +966,71 @@
}
/*******************************************************************
+ 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;
+}
+
+/*******************************************************************
find the share connection on which this open exists.
********************************************************************/
@@ -1482,6 +1549,13 @@
r->in.resume_handle,
r->out.totalentries);
break;
+
+ case 10:
+ werr = init_srv_sess_info_10(p,
+ r->in.info_ctr->ctr.ctr10,
+ r->in.resume_handle,
+ r->out.totalentries);
+ break;
default:
return WERR_INVALID_LEVEL;
}
On Wednesday, 12 September 2018, 16:37:26 GMT-7, Andrew Bartlett via samba <samba at lists.samba.org> wrote:
On Wed, 2018-09-12 at 16:23 -0700, Ray Klassen via samba wrote:
> 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-l
> > > mshare-_session_info_1
> > >
> > >
> > > and
> > >
> > > https://docs.microsoft.com/en-us/windows/desktop/api/lmshare/ns-l
> > > mshare-_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.
Thanks for having a go! Can you re-generate that with diff -u?
If you have the time and patience, Jeremy and I would like to introduce
you to git, and how to make a full git commit and patch, but a diff -u
would be a good start.
Thanks!
Andrew Bartlett
--
Andrew Bartlett http://samba.org/~abartlet/
Authentication Developer, Samba Team http://samba.org
Samba Developer, Catalyst IT http://catalyst.net.nz/services/samba
--
To unsubscribe from this list go to the following URL and read the
instructions: https://lists.samba.org/mailman/options/samba
More information about the samba
mailing list