1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

libsmb: Convert cli_RNetShareEnum() to NTSTATUS

Avoid a call to cli_nt_error()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
This commit is contained in:
Volker Lendecke 2024-08-18 20:48:48 +02:00
parent 9812f87268
commit c58ff4367a
5 changed files with 23 additions and 20 deletions

View File

@ -4995,7 +4995,7 @@ static bool browse_host_rpc(bool sort)
static bool browse_host(bool sort)
{
int ret;
NTSTATUS status;
if (!grepable) {
d_printf("\n\tSharename Type Comment\n");
@ -5010,14 +5010,14 @@ static bool browse_host(bool sort)
return false;
}
ret = cli_RNetShareEnum(cli, browse_fn, NULL);
if (ret == -1) {
NTSTATUS status = cli_nt_error(cli);
status = cli_RNetShareEnum(cli, browse_fn, NULL);
if (!NT_STATUS_IS_OK(status)) {
d_printf("Error returning browse list: %s\n",
nt_errstr(status));
return false;
}
return (ret != -1);
return true;
}
/****************************************************************************

View File

@ -101,7 +101,10 @@ fail:
Call a NetShareEnum - try and browse available connections on a host.
****************************************************************************/
int cli_RNetShareEnum(struct cli_state *cli, void (*fn)(const char *, uint32_t, const char *, void *), void *state)
NTSTATUS cli_RNetShareEnum(
struct cli_state *cli,
void (*fn)(const char *, uint32_t, const char *, void *),
void *state)
{
uint8_t *rparam = NULL;
uint8_t *rdata = NULL;
@ -165,6 +168,7 @@ int cli_RNetShareEnum(struct cli_state *cli, void (*fn)(const char *, uint32_t,
if (!(res == 0 || res == ERRmoredata)) {
DEBUG(4,("NetShareEnum res=%d\n", res));
status = werror_to_ntstatus(W_ERROR(res));
goto done;
}
@ -224,7 +228,7 @@ done:
TALLOC_FREE(rparam);
TALLOC_FREE(rdata);
return count;
return status;
}
/****************************************************************************

View File

@ -34,7 +34,10 @@ bool cli_api(struct cli_state *cli,
char *data, int drcnt, int mdrcnt,
char **rparam, unsigned int *rprcnt,
char **rdata, unsigned int *rdrcnt);
int cli_RNetShareEnum(struct cli_state *cli, void (*fn)(const char *, uint32_t, const char *, void *), void *state);
NTSTATUS cli_RNetShareEnum(
struct cli_state *cli,
void (*fn)(const char *, uint32_t, const char *, void *),
void *state);
bool cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32_t stype,
void (*fn)(const char *, uint32_t, const char *, void *),
void *state);

View File

@ -869,14 +869,10 @@ SMBC_opendir_ctx(SMBCCTX *context,
* Only call cli_RNetShareEnum()
* on SMB1 connections, not SMB2+.
*/
int rc = cli_RNetShareEnum(srv->cli,
list_fn,
(void *)dir);
if (rc != 0) {
status = cli_nt_error(srv->cli);
} else {
status = NT_STATUS_OK;
}
status = cli_RNetShareEnum(
srv->cli,
list_fn,
(void *)dir);
}
if (!NT_STATUS_IS_OK(status)) {
/*

View File

@ -301,7 +301,7 @@ int net_rap_share(struct net_context *c, int argc, const char **argv)
if (argc == 0) {
struct cli_state *cli;
int ret;
NTSTATUS status;
if (c->display_usage) {
d_printf(_("Usage:\n"));
@ -319,12 +319,12 @@ int net_rap_share(struct net_context *c, int argc, const char **argv)
"\nEnumerating shared resources (exports) on remote server:\n\n"
"\nShare name Type Description\n"
"---------- ---- -----------\n"));
ret = cli_RNetShareEnum(cli, long_share_fn, NULL);
status = cli_RNetShareEnum(cli, long_share_fn, NULL);
} else {
ret = cli_RNetShareEnum(cli, share_fn, NULL);
status = cli_RNetShareEnum(cli, share_fn, NULL);
}
cli_shutdown(cli);
return ret;
return NT_STATUS_IS_OK(status) ? 0 : -1;
}
return net_run_function(c, argc, argv, "net rap share", func);