Fix compilation on platforms without SO_PASSCRED

This commit is contained in:
Kovid Goyal 2022-06-08 14:19:39 +05:30
parent 6807f4d4ea
commit fafb8518e0
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -1801,6 +1801,10 @@ send_data_to_peer(PyObject *self UNUSED, PyObject *args) {
static PyObject *
random_unix_socket(PyObject *self UNUSED, PyObject *args UNUSED) {
#ifndef SO_PASSCRED
errno = ENOTSUP;
return PyErr_SetFromErrno(PyExc_OSError);
#else
int fd, optval = 1;
struct sockaddr_un bind_addr = {.sun_family=AF_UNIX};
fd = socket(AF_UNIX, SOCK_STREAM, 0);
@ -1811,6 +1815,7 @@ random_unix_socket(PyObject *self UNUSED, PyObject *args UNUSED) {
fail:
safe_close(fd, __FILE__, __LINE__);
return PyErr_SetFromErrno(PyExc_OSError);
#endif
}
static PyMethodDef module_methods[] = {