If localbind fails, provide a more portable error message.
This commit is contained in:
@@ -295,10 +295,10 @@ static CURLcode bindlocal(struct connectdata *conn,
|
|||||||
if (setsockopt(sockfd, SOL_SOCKET, SO_BINDTODEVICE,
|
if (setsockopt(sockfd, SOL_SOCKET, SO_BINDTODEVICE,
|
||||||
data->set.device, strlen(data->set.device)+1) != 0) {
|
data->set.device, strlen(data->set.device)+1) != 0) {
|
||||||
/* printf("Failed to BINDTODEVICE, socket: %d device: %s error: %s\n",
|
/* printf("Failed to BINDTODEVICE, socket: %d device: %s error: %s\n",
|
||||||
sockfd, data->set.device, strerror(errno)); */
|
sockfd, data->set.device, strerror(Curl_ourerrno())); */
|
||||||
infof(data, "SO_BINDTODEVICE %s failed\n",
|
infof(data, "SO_BINDTODEVICE %s failed\n",
|
||||||
data->set.device);
|
data->set.device);
|
||||||
/* This is typiclally "errno 1, error: Operation not permitted" if
|
/* This is typically "errno 1, error: Operation not permitted" if
|
||||||
you're not running as root or another suitable privileged user */
|
you're not running as root or another suitable privileged user */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -353,34 +353,35 @@ static CURLcode bindlocal(struct connectdata *conn,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if(!bindworked) {
|
if(!bindworked) {
|
||||||
|
int err = Curl_ourerrno();
|
||||||
switch(errno) {
|
switch(errno) {
|
||||||
case EBADF:
|
case EBADF:
|
||||||
failf(data, "Invalid descriptor: %d", errno);
|
failf(data, "Invalid descriptor: %d", err);
|
||||||
break;
|
break;
|
||||||
case EINVAL:
|
case EINVAL:
|
||||||
failf(data, "Invalid request: %d", errno);
|
failf(data, "Invalid request: %d", err);
|
||||||
break;
|
break;
|
||||||
case EACCES:
|
case EACCES:
|
||||||
failf(data, "Address is protected, user not superuser: %d", errno);
|
failf(data, "Address is protected, user not superuser: %d", err);
|
||||||
break;
|
break;
|
||||||
case ENOTSOCK:
|
case ENOTSOCK:
|
||||||
failf(data,
|
failf(data,
|
||||||
"Argument is a descriptor for a file, not a socket: %d",
|
"Argument is a descriptor for a file, not a socket: %d",
|
||||||
errno);
|
err);
|
||||||
break;
|
break;
|
||||||
case EFAULT:
|
case EFAULT:
|
||||||
failf(data, "Inaccessable memory error: %d", errno);
|
failf(data, "Inaccessable memory error: %d", err);
|
||||||
break;
|
break;
|
||||||
case ENAMETOOLONG:
|
case ENAMETOOLONG:
|
||||||
failf(data, "Address too long: %d", errno);
|
failf(data, "Address too long: %d", err);
|
||||||
break;
|
break;
|
||||||
case ENOMEM:
|
case ENOMEM:
|
||||||
failf(data, "Insufficient kernel memory was available: %d", errno);
|
failf(data, "Insufficient kernel memory was available: %d", err);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
failf(data, "errno %d", errno);
|
failf(data, "errno %d", err);
|
||||||
break;
|
break;
|
||||||
} /* end of switch(errno) */
|
} /* end of switch(err) */
|
||||||
|
|
||||||
return CURLE_HTTP_PORT_FAILED;
|
return CURLE_HTTP_PORT_FAILED;
|
||||||
} /* end of else */
|
} /* end of else */
|
||||||
|
Reference in New Issue
Block a user