static int lx_socketpair(ulong_t *args) { int domain; int type; int options; int protocol = (int)args[2]; int *sv = (int *)args[3]; int fds[2]; int r; r = convert_sock_args((int)args[0], (int)args[1], protocol, &domain, &type, &options); if (r != 0) return (r); lx_debug("\tsocketpair(%d, %d, %d, 0x%p)", domain, type, protocol, sv); r = socketpair(domain, type | options, protocol, fds); if (r == 0) { if (uucopy(fds, sv, sizeof (fds)) != 0) { r = errno; (void) close(fds[0]); (void) close(fds[1]); return (-r); } return (0); } if (errno == EPROTONOSUPPORT) return (-ESOCKTNOSUPPORT); return (-errno); }
static int lx_socket(ulong_t *args) { int domain; int type; int options; int protocol = (int)args[2]; int fd; int err; err = convert_sock_args((int)args[0], (int)args[1], protocol, &domain, &type, &options); if (err != 0) return (err); lx_debug("\tsocket(%d, %d, %d)", domain, type, protocol); /* Right now IPv6 sockets don't work */ if (domain == AF_INET6) return (-EAFNOSUPPORT); fd = socket(domain, type | options, protocol); if (fd >= 0) return (fd); if (errno == EPROTONOSUPPORT) return (-ESOCKTNOSUPPORT); return (-errno); }
static int lx_socket(ulong_t *args) { int domain; int type; int options; int protocol = (int)args[2]; int fd; int err; err = convert_sock_args((int)args[0], (int)args[1], protocol, &domain, &type, &options); if (err != 0) return (err); lx_debug("\tsocket(%d, %d, %d)", domain, type, protocol); /* Right now IPv6 sockets don't work */ if (domain == AF_INET6) return (-EAFNOSUPPORT); /* * AF_NETLINK Handling * * The AF_NETLINK address family gets mapped to AF_ROUTE. * * Clients of the auditing subsystem used by CentOS 4 and 5 expect to * be able to create AF_ROUTE SOCK_RAW sockets to communicate with the * auditing daemons. Failure to create these sockets will cause login, * ssh and useradd, amoung other programs to fail. To trick these * programs into working, we convert the socket domain and type to * something that we do support. Then when sendto is called on these * sockets, we return an error code. See lx_sendto. * * We have a similar issue with the newer startup code (e.g. mountall) * which wants to setup a netlink socket to receive from udev (protocol * NETLINK_KOBJECT_UEVENT). These apps basically poll on the socket * looking for udev events, which will never happen in our case, so we * let this go through and fail if the app tries to write. */ if (domain == AF_ROUTE && (type == SOCK_RAW || protocol == LX_NETLINK_KOBJECT_UEVENT)) { domain = AF_UNIX; type = SOCK_STREAM; protocol = 0; } fd = socket(domain, type | options, protocol); if (fd >= 0) return (fd); if (errno == EPROTONOSUPPORT) return (-ESOCKTNOSUPPORT); return (-errno); }