1
0
mirror of https://github.com/samba-team/samba.git synced 2025-11-21 12:23:50 +03:00

rpc_server3: Use fdopen_keepfd()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Martin Schwenke <mschwenke@ddn.com>
This commit is contained in:
Volker Lendecke
2024-04-10 13:08:06 +02:00
committed by Martin Schwenke
parent 28335cdb5d
commit b6f4acb9b4
2 changed files with 4 additions and 23 deletions

View File

@@ -2309,7 +2309,6 @@ static bool rpc_host_dump_status_filter(
struct rpc_server **servers = host->servers;
size_t i, num_servers = talloc_array_length(servers);
FILE *f = NULL;
int fd;
if (rec->msg_type != MSG_RPC_DUMP_STATUS) {
return false;
@@ -2319,18 +2318,9 @@ static bool rpc_host_dump_status_filter(
return false;
}
fd = dup(rec->fds[0]);
if (fd == -1) {
DBG_DEBUG("dup(%"PRIi64") failed: %s\n",
rec->fds[0],
strerror(errno));
return false;
}
f = fdopen(fd, "w");
f = fdopen_keepfd(rec->fds[0], "w");
if (f == NULL) {
DBG_DEBUG("fdopen failed: %s\n", strerror(errno));
close(fd);
return false;
}

View File

@@ -24,6 +24,7 @@
#include "source3/librpc/gen_ndr/ndr_rpc_host.h"
#include "lib/util/debug.h"
#include "lib/util/fault.h"
#include "lib/util/util_file.h"
#include "rpc_server.h"
#include "rpc_pipes.h"
#include "source3/smbd/proto.h"
@@ -569,7 +570,6 @@ static bool rpc_worker_status_filter(
private_data, struct rpc_worker);
struct dcerpc_ncacn_conn *conn = NULL;
FILE *f = NULL;
int fd;
if (rec->msg_type != MSG_RPC_DUMP_STATUS) {
return false;
@@ -580,18 +580,9 @@ static bool rpc_worker_status_filter(
return false;
}
fd = dup(rec->fds[0]);
if (fd == -1) {
DBG_DEBUG("dup(%"PRIi64") failed: %s\n",
rec->fds[0],
strerror(errno));
return false;
}
f = fdopen(fd, "w");
f = fdopen_keepfd(rec->fds[0], "w");
if (f == NULL) {
DBG_DEBUG("fdopen failed: %s\n", strerror(errno));
close(fd);
DBG_DEBUG("fdopen_keepfd failed: %s\n", strerror(errno));
return false;
}