Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unixsock v2.2 #3196

Closed
wants to merge 2 commits into from
Closed

Unixsock v2.2 #3196

wants to merge 2 commits into from

Conversation

regit
Copy link
Contributor

@regit regit commented Jan 28, 2018

2 unix socket related patches. First one introduce a new version of the protocol to fix issue with long answer. Second one propose a simple implementation of automatic reconnect for suricatasc.

Link to redmine ticket:

PRScript output:

This patch updates the unix socket protocol. Messages send from
the server and the client have now a '\n' at the end. This allows
both sides to detect easily the end of a command.

As a side effect, this fixes the problem of long answer in
suricatasc. There is now a limit at the arbitrary value of 65536.

Backward compatility is preserved as a client with the older
version of the protocol can still connect to a Suricata with
version 2 of the protocol.
Implement a basic autoreconnect support. It tries to reconnect once
when connection has been lost. If it fails, it discards the command
and try again to connect at next command.
@regit regit requested a review from a team as a code owner January 28, 2018 11:07
@victorjulien
Copy link
Member

+ PYTHONPATH=scripts/suricatasc/src
+ python3 scripts/suricatasc/suricatasc -v -c 'register-tenant 1 /home/victor/sync/qa/tests/multi-tenant/tenant-1.yaml' /home/buildbot/tmp/suriqa.8ifETH1/custom.socket
Traceback (most recent call last):
  File "scripts/suricatasc/suricatasc", line 21, in 
    from suricatasc import *
  File "/home/buildbot/qa/buildbot/donkey/bugs/Private/scripts/suricatasc/src/suricatasc.py", line 380
    except IOError, err:
                  ^
SyntaxError: invalid syntax

@@ -414,9 +426,16 @@ static int UnixCommandAccept(UnixCommand *this)

json_decref(server_msg);

if (client_version > UNIX_PROTO_V1) {
if (send(client, "\n", 1, MSG_NOSIGNAL) == -1) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to just oversize the buffer on UNIX_PROTO_V2 or higher, and after write set the write length + 1 to the return, rather than sending the return as an additional send?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, make sense indeed, as pointed by @inliniac this code is quite old and was done before the code was switched to use a memory buffer. Gonna fix that.

@regit
Copy link
Contributor Author

regit commented Jan 29, 2018

Fixing these problems.

@regit regit closed this Jan 29, 2018
@regit regit mentioned this pull request Jan 29, 2018
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants