/*
* Find an lsa pipe handle associated with a cli struct.
*/
-
static struct rpc_pipe_client *find_lsa_pipe_hnd(struct cli_state *ipc_cli)
{
struct rpc_pipe_client *pipe_hnd;
return NULL;
}
+ ipc_srv = SMB_MALLOC_P(SMBCSRV);
+ if (!ipc_srv) {
+ errno = ENOMEM;
+ cli_shutdown(ipc_cli);
+ return NULL;
+ }
+
+ ZERO_STRUCTP(ipc_srv);
+ ipc_srv->cli = *ipc_cli;
+
+ free(ipc_cli);
+
if (pol) {
- pipe_hnd = cli_rpc_pipe_open_noauth(ipc_cli,
+ pipe_hnd = cli_rpc_pipe_open_noauth(&ipc_srv->cli,
PI_LSARPC,
&nt_status);
if (!pipe_hnd) {
DEBUG(1, ("cli_nt_session_open fail!\n"));
errno = ENOTSUP;
- cli_shutdown(ipc_cli);
+ cli_shutdown(&ipc_srv->cli);
+ free(ipc_srv);
return NULL;
}
nt_status = rpccli_lsa_open_policy(
pipe_hnd,
- ipc_cli->mem_ctx,
+ ipc_srv->cli.mem_ctx,
True,
GENERIC_EXECUTE_ACCESS,
pol);
if (!NT_STATUS_IS_OK(nt_status)) {
- errno = smbc_errno(context, ipc_cli);
- cli_shutdown(ipc_cli);
+ errno = smbc_errno(context, &ipc_srv->cli);
+ cli_shutdown(&ipc_srv->cli);
return NULL;
}
}
- ipc_srv = SMB_MALLOC_P(SMBCSRV);
- if (!ipc_srv) {
- errno = ENOMEM;
- cli_shutdown(ipc_cli);
- return NULL;
- }
-
- ZERO_STRUCTP(ipc_srv);
- ipc_srv->cli = *ipc_cli;
-
- free(ipc_cli);
-
/* now add it to the cache (internal or external) */
errno = 0; /* let cache function set errno if it likes */
SMBCFILE *dir = (SMBCFILE *)state;
int dirent_type;
- /* We need to process the type a little ... */
-
+ /*
+ * We need to process the type a little ...
+ *
+ * Disk share = 0x00000000
+ * Print share = 0x00000001
+ * Comms share = 0x00000002 (obsolete?)
+ * IPC$ share = 0x00000003
+ *
+ * administrative shares:
+ * ADMIN$, IPC$, C$, D$, E$ ... are type |= 0x80000000
+ */
+
if (dir->dir_type == SMBC_FILE_SHARE) {
switch (type) {
- case 0: /* Directory tree */
+ case 0 | 0x80000000:
+ case 0:
dirent_type = SMBC_FILE_SHARE;
break;
dirent_type = SMBC_COMMS_SHARE;
break;
+ case 3 | 0x80000000:
case 3:
dirent_type = SMBC_IPC_SHARE;
break;
break;
}
}
- else dirent_type = dir->dir_type;
+ else {
+ dirent_type = dir->dir_type;
+ }
if (add_dirent(dir, name, comment, dirent_type) < 0) {
{
int i;
WERROR result;
- NTSTATUS nt_status;
ENUM_HND enum_hnd;
uint32 info_level = 1;
uint32 preferred_len = 0xffffffff;
+ uint32 type;
SRV_SHARE_INFO_CTR ctr;
fstring name = "";
fstring comment = "";
void *mem_ctx;
struct rpc_pipe_client *pipe_hnd;
+ NTSTATUS nt_status;
/* Open the server service pipe */
pipe_hnd = cli_rpc_pipe_open_noauth(cli, PI_SRVSVC, &nt_status);
mem_ctx = talloc_init("libsmbclient: net_share_enum_rpc");
if (mem_ctx == NULL) {
DEBUG(0, ("out of memory for net_share_enum_rpc!\n"));
+ cli_rpc_pipe_close(pipe_hnd);
return -1;
}
rpcstr_pull_unistr2_fstring(
comment, &ctr.share.info1[i].info_1_str.uni_remark);
+ /* Get the type value */
+ type = ctr.share.info1[i].info_1.type;
+
/* Add this share to the list */
- (*fn)(name, SMBC_FILE_SHARE, comment, state);
+ (*fn)(name, type, comment, state);
}
- /* We're done with the pipe */
- cli_rpc_pipe_close(pipe_hnd);
-
done:
+ /* Close the server service pipe */
+ cli_rpc_pipe_close(pipe_hnd);
+
/* Free all memory which was allocated for this request */
talloc_free(mem_ctx);
/****************************************************************************
Open a named pipe over SMB to a remote server.
+ *
+ * CAVEAT CALLER OF THIS FUNCTION:
+ * The returned rpc_pipe_client saves a copy of the cli_state cli pointer,
+ * so be sure that this function is called AFTER any structure (vs pointer)
+ * assignment of the cli. In particular, libsmbclient does structure
+ * assignments of cli, which invalidates the data in the returned
+ * rpc_pipe_client if this function is called before the structure assignment
+ * of cli.
+ *
****************************************************************************/
static struct rpc_pipe_client *cli_rpc_pipe_open(struct cli_state *cli, int pipe_idx, NTSTATUS *perr)