[PATCH 1/7] Samba-VirusFilter: add write_data_timeout ... version 3

Jeremy Allison jra at samba.org
Tue Nov 1 16:25:24 UTC 2016

On Mon, Oct 31, 2016 at 05:33:46PM -0600, Trever L. Adams wrote:

> I was unaware of the tstream_context. I was trying to abstract this in a
> way that would be useful where eintr shouldn't be ignored too. I see the
> points you make below and you are correct. The timeout does need to be
> decremented for the reason you were giving. I was mistakenly thinking
> the user samba was running as (root, etc.) and the administrator could
> be trusted and the system was semi-sane. Thank you for reminding me that
> I shouldn't assume such.

I've been bitten too many times to make that assumption :-).

Using the tevent/timeout/IO paradigms fixes these bugs using
code we already know to be correct.

> > I think this code should connect using tstream_unix_socketpair(),
> > create a temp event context to loop on, set a timer event to fire
> > after msec_timeout, and then use tstream_writev_send()/tstream_writev_recv()
> > to push the data down the socket.
> tstream_unix_socketpair() requires two sockets, at least from my
> reading. It also seems I would be duplicating a lot of code found in
> util_sock.c.

Lots of that code pre-dates tsocket/tevent though. I'm trying to
avoid re-inventing the wheel (badly:-). We've suffered from that
a lot in the past.

> I see the function tstream_bsd_existing_socket() exists. It would allow
> a lot of the code already in place (util_sock.c) to be used. I do not
> see it used in any VFS modules. Is this an acceptable choice for a VFS
> module?

Yes - forgot about that function - well spotted ! That should be the one
to use with your existing connect code. Don't forget to make the socket
non-blocking though.

> Thank you for the input, Jeremy. Hopefully with the answers to these
> questions I can have a correct version within a day or two.

No problem, I think this will improve the overall submission. Thanks
for working with me on this !

More information about the samba-technical mailing list