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

setsockopt with SO_LINGER returns EINVAL #3992

Closed
nmeocisco opened this issue Apr 23, 2019 · 2 comments
Closed

setsockopt with SO_LINGER returns EINVAL #3992

nmeocisco opened this issue Apr 23, 2019 · 2 comments
Labels

Comments

@nmeocisco
Copy link

  • Your Windows build number: 10.0.17763.437

  • What you're doing and what's happening: I was trying to setup osquery under WSL to duplicate a development environment I currently have inside an Ubuntu 18.04 VM. It appears to have a problem with configuring sockets which hinders full functionality. The osquery package used in Ubuntu 18.04 under WSL can be obtained from here:

https://pkg.osquery.io/deb/osquery_3.3.2_1.linux.amd64.deb

Once installed I run the following command:

/usr/bin/osqueryd --extensions_socket=/tmp/osquery.em -logger_path=/tmp/osqueryd_log --database_path=/tmp/osqueryd_db --pidfile=/tmp/osqueryd.pid --force=true --disable_watchdog --disable_events=false --events_expiry=3600 --events_max=50000

Among the messages displayed on start will be the following:

W0423 14:31:57.658298 149 interface.cpp:269] Extensions disabled: cannot start extension manager (/tmp/osquery.em) (Could not set SO_LINGER: Invalid argument)

  • What's wrong / what should be happening instead: The /tmp/osquery.em domain socket does not get created as a result of this failure. The SO_LINGER with setsockopt should succeed.

  • Strace of the failing command, if applicable: Inside my Ubuntu 18.04 VM where this works fine the strace is as follows:

socket(AF_UNIX, SOCK_STREAM, 0) = 14
setsockopt(14, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
setsockopt(14, SOL_SOCKET, SO_LINGER, {l_onoff=0, l_linger=0}, 8) = 0

The strace of the failure inside WSL with Ubuntu 18.04 is as follows:

socket(AF_UNIX, SOCK_STREAM, 0) = 11
setsockopt(11, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
setsockopt(11, SOL_SOCKET, SO_LINGER, {l_onoff=0, l_linger=0}, 8) = -1 EINVAL (Invalid argument)

@therealkenc
Copy link
Collaborator

Was able to reproduce; not a dupe AFAICT. Guess SO_LINGER isn't supported with WSL's AF_UNIX. Not too surprised it never came up before since lingering around on a IPC socket is "unusual". I think (?) it might make sense in some esoteric cases. Anyway, Real Linux eats it. Probably suffice to just no-op on WSL, in a pinch.

Oddly I couldn't find it in the osquery source. Maybe it's buried down below in a library. But if you can find the line of code and just comment it out, it'll probably work fine. Probably.

// g++ linger.cpp &&  strace ./a.out
#include <sys/types.h>
#include <sys/socket.h>
int main(int argc, const char *argv[])
{
    struct linger l = {};
    int sd = socket(AF_UNIX, SOCK_STREAM, 0);
    setsockopt(sd, SOL_SOCKET, SO_LINGER, &l, sizeof(l));
    return 0;
}

Copy link
Contributor

This issue has been automatically closed since it has not had any activity for the past year. If you're still experiencing this issue please re-file this as a new issue or feature request.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants