return NT_STATUS_OK;
}
-static int
+static NTSTATUS
net_share_enum_rpc(struct cli_state *cli,
void (*fn)(const char *name,
uint32_t type,
&pipe_hnd);
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(1, ("net_share_enum_rpc pipe open fail!\n"));
- return -1;
+ goto done;
}
ZERO_STRUCT(info_ctr);
/* Was it successful? */
if (!NT_STATUS_IS_OK(nt_status)) {
/* Nope. Go clean up. */
- result = ntstatus_to_werror(nt_status);
goto done;
}
if (!W_ERROR_IS_OK(result)) {
/* Nope. Go clean up. */
+ nt_status = werror_to_ntstatus(result);
goto done;
}
if (total_entries == 0) {
/* Nope. Go clean up. */
- result = WERR_GEN_FAILURE;
+ nt_status = NT_STATUS_NOT_FOUND;
goto done;
}
TALLOC_FREE(pipe_hnd);
/* Tell 'em if it worked */
- return W_ERROR_IS_OK(result) ? 0 : -1;
+ return nt_status;
}
}
} else if (srv ||
(resolve_name(server, &rem_ss, 0x20, false))) {
- int rc;
+ NTSTATUS status;
/*
* If we hadn't found the server, get one now
/* List the shares ... */
- rc = net_share_enum_rpc(srv->cli,
+ status = net_share_enum_rpc(srv->cli,
list_fn,
(void *)dir);
- if (rc != 0 &&
+ if (!NT_STATUS_IS_OK(status) &&
smbXcli_conn_protocol(srv->cli->conn) <=
PROTOCOL_NT1) {
/*
* Only call cli_RNetShareEnum()
* on SMB1 connections, not SMB2+.
*/
- rc = cli_RNetShareEnum(srv->cli,
+ int rc = cli_RNetShareEnum(srv->cli,
list_fn,
(void *)dir);
+ if (rc != 0) {
+ status = cli_nt_error(srv->cli);
+ } else {
+ status = NT_STATUS_OK;
+ }
}
- if (rc != 0) {
- errno = cli_errno(srv->cli);
+ if (!NT_STATUS_IS_OK(status)) {
+ /*
+ * Set cli->raw_status so SMBC_errno()
+ * will correctly return the error.
+ */
+ srv->cli->raw_status = status;
if (dir != NULL) {
SAFE_FREE(dir->fname);
SAFE_FREE(dir);
}
TALLOC_FREE(frame);
+ errno = map_errno_from_nt_status(
+ status);
return NULL;
}
} else {