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

Error with X11 Forwarding #459

Open
mattmix opened this issue Apr 8, 2019 · 1 comment
Open

Error with X11 Forwarding #459

mattmix opened this issue Apr 8, 2019 · 1 comment

Comments

@mattmix
Copy link

mattmix commented Apr 8, 2019

Users see 'could not bind local socket: Invalid argument' in their error stream when using qsub -X. The error originates from

fprintf(stderr, "could not bind local socket: %s", strerror(errno));

It is because the get_local_address() function returns a sa_family=AF_INET struct but the loop at

for (ai = aitop; ai; ai = ai->ai_next)
{
/* Create a socket. */
sock = socket(ai->ai_family, SOCK_STREAM, 0);
if (sock < 0)
{
fprintf(stderr, "socket: %.100s", strerror(errno));
continue;
}
#ifdef BIND_OUTBOUND_SOCKETS
/* Bind to the IP address associated with the hostname, in case there are
* muliple possible source IPs for this destination.*/
// don't bind localhost addr
if (!islocalhostaddr(&local))
{
if (bind(sock, (struct sockaddr *)&local, sizeof(sockaddr_in)))
{
fprintf(stderr, "could not bind local socket: %s", strerror(errno));
close(sock);
continue;
}
}
#endif
will attempt to bind all types, causing bind to be called on a AF_INET6 socket with a AF_INET argument and producing the error message.

I've submitted #458 as a potential fix, but should probably be revisited so that it will work with IPv6. Note that the IPv6 limitation is one of get_local_address() and not the patch.

@mattmix
Copy link
Author

mattmix commented Apr 8, 2019

An example from strace of it trying to bind a mismatched AF_ family and then succeeding on the second:

[pid 27167] socket(AF_INET6, SOCK_STREAM, IPPROTO_IP) = 8
[pid 27167] bind(8, {sa_family=AF_INET, sin_port=htons(0), sin_addr=inet_addr("redacted")}, 16) = -1 EINVAL (Invalid argument)
[pid 27167] write(2, "could not bind local socket: Inv"..., 45) = 45
[pid 27167] close(8) = 0
[pid 27167] socket(AF_INET, SOCK_STREAM, IPPROTO_IP) = 8
[pid 27167] bind(8, {sa_family=AF_INET, sin_port=htons(0), sin_addr=inet_addr("redacted")}, 16) = 0

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

No branches or pull requests

1 participant