mirror of
https://github.com/samba-team/samba.git
synced 2025-02-28 01:58:17 +03:00
s3:modules: make virusfilter_io_connect_path() more portable
We have existing utility functions to prepare a socket. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13343 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Björn Jacke <bjacke@samba.org>
This commit is contained in:
parent
fb7b67af98
commit
74278a7038
@ -147,8 +147,9 @@ bool virusfilter_io_connect_path(
|
||||
{
|
||||
struct sockaddr_un addr;
|
||||
NTSTATUS status;
|
||||
int socket, bes_result, flags, ret;
|
||||
int socket, ret;
|
||||
size_t len;
|
||||
bool ok;
|
||||
|
||||
ZERO_STRUCT(addr);
|
||||
addr.sun_family = AF_UNIX;
|
||||
@ -168,23 +169,23 @@ bool virusfilter_io_connect_path(
|
||||
}
|
||||
|
||||
/* We must not block */
|
||||
flags = fcntl(socket, F_GETFL);
|
||||
if (flags <= 0) {
|
||||
/* Handle error by ignoring */;
|
||||
flags = 0;
|
||||
DBG_WARNING("Could not get flags on socket (%s).\n",
|
||||
strerror(errno));
|
||||
}
|
||||
flags |= SOCK_NONBLOCK;
|
||||
ret = fcntl(socket, F_SETFL, flags);
|
||||
ret = set_blocking(socket, false);
|
||||
if (ret == -1) {
|
||||
/* Handle error by ignoring for now */
|
||||
DBG_WARNING("Could not set flags on socket: %s.\n",
|
||||
strerror(errno));
|
||||
close(socket);
|
||||
io_h->stream = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
bes_result = tstream_bsd_existing_socket(io_h, socket, &io_h->stream);
|
||||
if (bes_result < 0) {
|
||||
ok = smb_set_close_on_exec(socket);
|
||||
if (!ok) {
|
||||
close(socket);
|
||||
io_h->stream = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = tstream_bsd_existing_socket(io_h, socket, &io_h->stream);
|
||||
if (ret == -1) {
|
||||
close(socket);
|
||||
DBG_ERR("Could not convert socket to tstream: %s.\n",
|
||||
strerror(errno));
|
||||
io_h->stream = NULL;
|
||||
|
Loading…
x
Reference in New Issue
Block a user