This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "includes.h"
#include "system/network.h"
#include "system/filesys.h"
+_PUBLIC_ const struct socket_ops *socket_unixdom_ops(enum socket_type type);
/*
*/
static NTSTATUS unixdom_error(int ernum)
{
- return map_nt_error_from_unix(ernum);
+ return map_nt_error_from_unix_common(ernum);
}
static NTSTATUS unixdom_init(struct socket_context *sock)
sock->fd = socket(PF_UNIX, type, 0);
if (sock->fd == -1) {
- return map_nt_error_from_unix(errno);
+ return map_nt_error_from_unix_common(errno);
}
sock->private_data = NULL;
sock->backend_name = "unix";
+ smb_set_close_on_exec(sock->fd);
+
return NT_STATUS_OK;
}
for non-blocking connect */
ret = getsockopt(sock->fd, SOL_SOCKET, SO_ERROR, &error, &len);
if (ret == -1) {
- return map_nt_error_from_unix(errno);
+ return map_nt_error_from_unix_common(errno);
}
if (error != 0) {
- return map_nt_error_from_unix(error);
+ return map_nt_error_from_unix_common(error);
}
if (!(flags & SOCKET_FLAG_BLOCK)) {
- ret = set_blocking(sock->fd, False);
+ ret = set_blocking(sock->fd, false);
if (ret == -1) {
- return map_nt_error_from_unix(errno);
+ return map_nt_error_from_unix_common(errno);
}
}
}
if (!(flags & SOCKET_FLAG_BLOCK)) {
- ret = set_blocking(sock->fd, False);
+ ret = set_blocking(sock->fd, false);
if (ret == -1) {
return unixdom_error(errno);
}
}
if (!(sock->flags & SOCKET_FLAG_BLOCK)) {
- int ret = set_blocking(new_fd, False);
+ int ret = set_blocking(new_fd, false);
if (ret == -1) {
close(new_fd);
- return map_nt_error_from_unix(errno);
+ return map_nt_error_from_unix_common(errno);
}
}
+ smb_set_close_on_exec(new_fd);
+
(*new_sock) = talloc(NULL, struct socket_context);
if (!(*new_sock)) {
close(new_fd);
}
static NTSTATUS unixdom_recv(struct socket_context *sock, void *buf,
- size_t wantlen, size_t *nread, uint32_t flags)
+ size_t wantlen, size_t *nread)
{
ssize_t gotlen;
- int flgs = 0;
-
- /* TODO: we need to map all flags here */
- if (flags & SOCKET_FLAG_PEEK) {
- flgs |= MSG_PEEK;
- }
-
- if (flags & SOCKET_FLAG_BLOCK) {
- flgs |= MSG_WAITALL;
- }
*nread = 0;
- gotlen = recv(sock->fd, buf, wantlen, flgs);
+ gotlen = recv(sock->fd, buf, wantlen, 0);
if (gotlen == 0) {
return NT_STATUS_END_OF_FILE;
} else if (gotlen == -1) {
}
static NTSTATUS unixdom_send(struct socket_context *sock,
- const DATA_BLOB *blob, size_t *sendlen, uint32_t flags)
+ const DATA_BLOB *blob, size_t *sendlen)
{
ssize_t len;
- int flgs = 0;
*sendlen = 0;
- len = send(sock->fd, blob->data, blob->length, flgs);
+ len = send(sock->fd, blob->data, blob->length, 0);
if (len == -1) {
return unixdom_error(errno);
}
static NTSTATUS unixdom_sendto(struct socket_context *sock,
- const DATA_BLOB *blob, size_t *sendlen, uint32_t flags,
+ const DATA_BLOB *blob, size_t *sendlen,
const struct socket_address *dest)
{
ssize_t len;
- int flgs = 0;
*sendlen = 0;
if (dest->sockaddr) {
- len = sendto(sock->fd, blob->data, blob->length, flgs,
+ len = sendto(sock->fd, blob->data, blob->length, 0,
dest->sockaddr, dest->sockaddrlen);
} else {
struct sockaddr_un srv_addr;
srv_addr.sun_family = AF_UNIX;
strncpy(srv_addr.sun_path, dest->addr, sizeof(srv_addr.sun_path));
- len = sendto(sock->fd, blob->data, blob->length, flgs,
+ len = sendto(sock->fd, blob->data, blob->length, 0,
(struct sockaddr *)&srv_addr, sizeof(srv_addr));
}
if (len == -1) {
- return map_nt_error_from_unix(errno);
+ return map_nt_error_from_unix_common(errno);
}
*sendlen = len;
*npending = value;
return NT_STATUS_OK;
}
- return map_nt_error_from_unix(errno);
+ return map_nt_error_from_unix_common(errno);
}
static const struct socket_ops unixdom_ops = {
.fn_get_fd = unixdom_get_fd
};
-const struct socket_ops *socket_unixdom_ops(enum socket_type type)
+_PUBLIC_ const struct socket_ops *socket_unixdom_ops(enum socket_type type)
{
return &unixdom_ops;
}