1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-22 22:04:08 +03:00

r18802: Use the pidl-generated code for the srvsvc interface, both client and server code.

This has had some basic testing. I'll do more during the next couple of days and hopefully also
make RPC-SRVSVC from Samba4 pass against it.
This commit is contained in:
Jelmer Vernooij 2006-09-21 23:57:32 +00:00 committed by Gerald (Jerry) Carter
parent fc6543ca78
commit ef10672399
19 changed files with 914 additions and 6790 deletions

View File

@ -206,11 +206,13 @@ ERRORMAP_OBJ = libsmb/errormap.o
PASSCHANGE_OBJ = libsmb/passchange.o
LIBNDR_OBJ = librpc/ndr/ndr_basic.o librpc/ndr/ndr.o librpc/ndr/ndr_misc.o \
librpc/ndr/ndr_sec_helper.o librpc/ndr/ndr_string.o librpc/ndr/sid.o
librpc/ndr/ndr_sec_helper.o librpc/ndr/ndr_string.o librpc/ndr/sid.o \
rpc_client/ndr.o
LIBNDR_GEN_OBJ = librpc/gen_ndr/ndr_unixinfo.o librpc/gen_ndr/ndr_lsa.o \
librpc/gen_ndr/ndr_dfs.o librpc/gen_ndr/ndr_echo.o \
librpc/gen_ndr/ndr_winreg.o librpc/gen_ndr/ndr_initshutdown.o \
librpc/gen_ndr/ndr_srvsvc.o librpc/gen_ndr/ndr_svcctl.o \
librpc/gen_ndr/ndr_eventlog.o librpc/gen_ndr/ndr_wkssvc.o
RPC_PARSE_OBJ0 = rpc_parse/parse_prs.o rpc_parse/parse_misc.o
@ -291,18 +293,18 @@ LIBSMB_OBJ = libsmb/clientgen.o libsmb/cliconnect.o libsmb/clifile.o \
$(RPC_PARSE_OBJ1) $(LIBSAMBA_OBJ) $(LIBNMB_OBJ)
LIBMSRPC_OBJ = rpc_client/cli_lsarpc.o rpc_client/cli_samr.o \
rpc_client/cli_netlogon.o rpc_client/cli_srvsvc.o \
rpc_client/cli_netlogon.o \
rpc_client/cli_reg.o $(RPC_CLIENT_OBJ) \
rpc_client/cli_spoolss.o rpc_client/cli_spoolss_notify.o \
rpc_client/cli_ds.o \
rpc_client/cli_shutdown.o rpc_client/cli_svcctl.o \
rpc_client/ndr.o
rpc_client/cli_shutdown.o rpc_client/cli_svcctl.o
LIBMSRPC_GEN_OBJ = librpc/gen_ndr/cli_unixinfo.o librpc/gen_ndr/cli_lsa.o \
librpc/gen_ndr/cli_dfs.o librpc/gen_ndr/cli_echo.o \
librpc/gen_ndr/cli_srvsvc.o \
librpc/gen_ndr/cli_winreg.o librpc/gen_ndr/cli_initshutdown.o \
librpc/gen_ndr/cli_eventlog.o \
$(LIBMSRPC_GEN_OBJ1) $(LIBNDR_GEN_OBJ) $(LIBNDR_OBJ)
$(LIBNDR_GEN_OBJ) $(LIBNDR_OBJ)
REGOBJS_OBJ = registry/reg_objects.o
@ -325,7 +327,7 @@ RPC_INITSHUTDOWN_OBJ = librpc/gen_ndr/srv_initshutdown.o rpc_server/srv_initshu
RPC_LSA_DS_OBJ = rpc_server/srv_lsa_ds.o rpc_server/srv_lsa_ds_nt.o
RPC_SVC_OBJ = rpc_server/srv_srvsvc.o rpc_server/srv_srvsvc_nt.o
RPC_SVC_OBJ = librpc/gen_ndr/srv_srvsvc.o rpc_server/srv_srvsvc_nt.o
RPC_WKS_OBJ = librpc/gen_ndr/srv_wkssvc.o rpc_server/srv_wkssvc_nt.o
@ -355,7 +357,7 @@ RPC_PARSE_OBJ1 = $(RPC_PARSE_OBJ0) rpc_parse/parse_sec.o
RPC_PARSE_OBJ = rpc_parse/parse_lsa.o rpc_parse/parse_net.o \
rpc_parse/parse_reg.o rpc_parse/parse_rpc.o \
rpc_parse/parse_samr.o rpc_parse/parse_srv.o \
rpc_parse/parse_samr.o \
rpc_parse/parse_ds.o rpc_parse/parse_spoolss.o \
rpc_parse/parse_shutdown.o rpc_parse/parse_svcctl.o \
rpc_parse/parse_eventlog.o rpc_parse/parse_buffer.o \
@ -518,9 +520,9 @@ SMBCONTROL_OBJ = utils/smbcontrol.o $(LOCKING_OBJ) $(PARAM_OBJ) \
SMBTREE_OBJ = utils/smbtree.o $(PARAM_OBJ) \
$(PROFILE_OBJ) $(LIB_NONSMBD_OBJ) $(LIBSMB_OBJ) \
$(KRBCLIENT_OBJ) $(POPT_LIB_OBJ) $(SECRETS_OBJ) \
rpc_client/cli_srvsvc.o rpc_parse/parse_srv.o \
rpc_client/cli_pipe.o rpc_parse/parse_rpc.o \
rpc_client/cli_netlogon.o rpc_parse/parse_net.o
rpc_client/cli_netlogon.o rpc_parse/parse_net.o \
$(LIBMSRPC_GEN_OBJ)
TESTPARM_OBJ = utils/testparm.o \
$(PARAM_OBJ) $(LIB_NONSMBD_OBJ) $(POPT_LIB_OBJ) \
@ -582,12 +584,12 @@ LIBBIGBALLOFMUD_OBJ = $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) $(SECRETS_OBJ) \
LIBBIGBALLOFMUD_PICOBJS = $(LIBBIGBALLOFMUD_OBJ:.o=.@PICSUFFIX@)
CLIENT_OBJ1 = client/client.o client/clitar.o rpc_client/cli_srvsvc.o \
rpc_parse/parse_srv.o rpc_client/cli_pipe.o rpc_parse/parse_rpc.o \
rpc_client/cli_netlogon.o rpc_parse/parse_net.o
CLIENT_OBJ1 = client/client.o client/clitar.o rpc_client/cli_pipe.o \
rpc_parse/parse_rpc.o rpc_client/cli_netlogon.o \
rpc_parse/parse_net.o
CLIENT_OBJ = $(CLIENT_OBJ1) $(PARAM_OBJ) $(LIBSMB_OBJ) \
$(LIB_NONSMBD_OBJ) $(KRBCLIENT_OBJ) \
$(LIB_NONSMBD_OBJ) $(KRBCLIENT_OBJ) $(LIBMSRPC_GEN_OBJ) \
$(READLINE_OBJ) $(POPT_LIB_OBJ) $(SECRETS_OBJ)
TOOL_OBJ = client/smbctool.o client/clitar.o $(PARAM_OBJ) $(LIBSMB_OBJ) \
@ -849,7 +851,7 @@ cac: SHOWFLAGS $(LIBMSRPC)
#####################################################################
## Perl IDL Compiler
IDL_FILES = unixinfo.idl lsa.idl dfs.idl echo.idl winreg.idl initshutdown.idl \
eventlog.idl wkssvc.idl netlogon.idl
srvsvc.idl svcctl.idl eventlog.idl wkssvc.idl netlogon.idl
idl:
@IDL_FILES="$(IDL_FILES)" CPP="$(CPP)" PERL="$(PERL)" \

View File

@ -23,6 +23,7 @@
#include "includes.h"
#include "client/client_proto.h"
#include "include/rpc_client.h"
#ifndef REGISTER
#define REGISTER 0
#endif
@ -2724,10 +2725,12 @@ static BOOL browse_host_rpc(BOOL sort)
NTSTATUS status;
struct rpc_pipe_client *pipe_hnd;
TALLOC_CTX *mem_ctx;
ENUM_HND enum_hnd;
uint32 enum_hnd = 0;
WERROR werr;
SRV_SHARE_INFO_CTR ctr;
union srvsvc_NetShareCtr ctr;
int i;
uint32 level;
uint32 numentries;
mem_ctx = talloc_new(NULL);
if (mem_ctx == NULL) {
@ -2735,8 +2738,6 @@ static BOOL browse_host_rpc(BOOL sort)
return False;
}
init_enum_hnd(&enum_hnd, 0);
pipe_hnd = cli_rpc_pipe_open_noauth(cli, PI_SRVSVC, &status);
if (pipe_hnd == NULL) {
@ -2746,8 +2747,10 @@ static BOOL browse_host_rpc(BOOL sort)
return False;
}
werr = rpccli_srvsvc_net_share_enum(pipe_hnd, mem_ctx, 1, &ctr,
0xffffffff, &enum_hnd);
level = 1;
werr = rpccli_srvsvc_NetShareEnum(pipe_hnd, mem_ctx, NULL, &level, &ctr,
0xffffffff, &numentries, &enum_hnd);
if (!W_ERROR_IS_OK(werr)) {
TALLOC_FREE(mem_ctx);
@ -2755,14 +2758,9 @@ static BOOL browse_host_rpc(BOOL sort)
return False;
}
for (i=0; i<ctr.num_entries; i++) {
SRV_SHARE_INFO_1 *info = &ctr.share.info1[i];
char *name, *comment;
name = rpcstr_pull_unistr2_talloc(
mem_ctx, &info->info_1_str.uni_netname);
comment = rpcstr_pull_unistr2_talloc(
mem_ctx, &info->info_1_str.uni_remark);
browse_fn(name, info->info_1.type, comment, NULL);
for (i=0; i<numentries; i++) {
struct srvsvc_NetShareInfo1 *info = &ctr.ctr1->array[i];
browse_fn(info->name, info->type, info->comment, NULL);
}
TALLOC_FREE(mem_ctx);

View File

@ -579,7 +579,7 @@ DYNEXP=
dnl Add modules that have to be built by default here
dnl These have to be built static:
default_static_modules="pdb_smbpasswd pdb_tdbsam rpc_lsa rpc_samr rpc_winreg rpc_initshutdown rpc_lsa_ds rpc_wkssvc rpc_svcctl rpc_ntsvcs rpc_net rpc_netdfs rpc_srv rpc_spoolss rpc_eventlog rpc_unixinfo auth_sam auth_unix auth_winbind auth_server auth_domain auth_builtin vfs_default"
default_static_modules="pdb_smbpasswd pdb_tdbsam rpc_lsa rpc_samr rpc_winreg rpc_initshutdown rpc_lsa_ds rpc_wkssvc rpc_svcctl rpc_ntsvcs rpc_net rpc_netdfs rpc_srvsvc rpc_spoolss rpc_eventlog rpc_unixinfo auth_sam auth_unix auth_winbind auth_server auth_domain auth_builtin vfs_default"
dnl These are preferably build shared, and static if dlopen() is not available
default_shared_modules="vfs_recycle vfs_audit vfs_extd_audit vfs_full_audit vfs_netatalk vfs_fake_perms vfs_default_quota vfs_readonly vfs_cap vfs_expand_msdfs vfs_shadow_copy charset_CP850 charset_CP437 auth_script"
@ -5587,7 +5587,7 @@ done
dnl Always built these modules static
MODULE_rpc_spoolss=STATIC
MODULE_rpc_srv=STATIC
MODULE_rpc_srvsvc=STATIC
MODULE_idmap_tdb=STATIC
AC_ARG_WITH(static-modules,
@ -5624,7 +5624,7 @@ SMB_MODULE(rpc_svcctl, \$(RPC_SVCCTL_OBJ), "bin/librpc_svcctl.$SHLIBEXT", RPC)
SMB_MODULE(rpc_ntsvcs, \$(RPC_NTSVCS_OBJ), "bin/librpc_ntsvcs.$SHLIBEXT", RPC)
SMB_MODULE(rpc_net, \$(RPC_NETLOG_OBJ), "bin/librpc_NETLOGON.$SHLIBEXT", RPC)
SMB_MODULE(rpc_netdfs, \$(RPC_DFS_OBJ), "bin/librpc_netdfs.$SHLIBEXT", RPC)
SMB_MODULE(rpc_srv, \$(RPC_SVC_OBJ), "bin/librpc_srvsvc.$SHLIBEXT", RPC)
SMB_MODULE(rpc_srvsvc, \$(RPC_SVC_OBJ), "bin/librpc_srvsvc.$SHLIBEXT", RPC)
SMB_MODULE(rpc_spoolss, \$(RPC_SPOOLSS_OBJ), "bin/librpc_spoolss.$SHLIBEXT", RPC)
SMB_MODULE(rpc_eventlog, \$(RPC_EVENTLOG_OBJ), "bin/librpc_eventlog.$SHLIBEXT", RPC)
SMB_MODULE(rpc_samr, \$(RPC_SAMR_OBJ), "bin/librpc_samr.$SHLIBEXT", RPC)

View File

@ -684,7 +684,6 @@ typedef int BOOL;
#include "reg_objects.h"
#include "rpc_reg.h"
#include "rpc_samr.h"
#include "rpc_srvsvc.h"
#include "rpc_wkssvc.h"
#include "rpc_spoolss.h"
#include "rpc_eventlog.h"
@ -692,6 +691,7 @@ typedef int BOOL;
#include "rpc_shutdown.h"
#include "rpc_perfcount.h"
#include "rpc_perfcount_defs.h"
#include "librpc/gen_ndr/srvsvc.h"
#include "librpc/gen_ndr/echo.h"
#include "nt_printing.h"
#include "idmap.h"

View File

@ -27,6 +27,8 @@
#include "librpc/gen_ndr/cli_unixinfo.h"
#include "librpc/gen_ndr/cli_dfs.h"
#include "librpc/gen_ndr/cli_lsa.h"
#include "librpc/gen_ndr/cli_srvsvc.h"
#include "librpc/gen_ndr/cli_svcctl.h"
#include "librpc/gen_ndr/cli_winreg.h"
#include "librpc/gen_ndr/cli_initshutdown.h"
#include "librpc/gen_ndr/cli_wkssvc.h"

View File

@ -92,11 +92,6 @@ enum unistr2_term_codes { UNI_FLAGS_NONE = 0, UNI_STR_TERMINATE = 1, UNI_MAXLEN_
* RPC policy handle used pretty much everywhere
**********************************************************************/
typedef struct {
uint32 ptr_hnd; /* pointer to enumeration handle */
uint32 handle; /* enumeration handle */
} ENUM_HND;
typedef struct policy_handle POLICY_HND;
#define OUR_HANDLE(hnd) (((hnd)==NULL) ? "NULL" :\

View File

@ -1,884 +0,0 @@
/*
Unix SMB/CIFS implementation.
SMB parameters and setup
Copyright (C) Andrew Tridgell 1992-1997
Copyright (C) Luke Kenneth Casson Leighton 1996-1997
Copyright (C) Paul Ashton 1997
Copyright (C) Nigel Williams 2001
Copyright (C) Gerald (Jerry) Carter 2006.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef _RPC_SRVSVC_H /* _RPC_SRVSVC_H */
#define _RPC_SRVSVC_H
/* srvsvc pipe */
#define SRV_NET_CONN_ENUM 0x08
#define SRV_NET_FILE_ENUM 0x09
#define SRV_NET_FILE_CLOSE 0x0b
#define SRV_NET_SESS_ENUM 0x0c
#define SRV_NET_SESS_DEL 0x0d
#define SRV_NET_SHARE_ADD 0x0e
#define SRV_NET_SHARE_ENUM_ALL 0x0f
#define SRV_NET_SHARE_GET_INFO 0x10
#define SRV_NET_SHARE_SET_INFO 0x11
#define SRV_NET_SHARE_DEL 0x12
#define SRV_NET_SHARE_DEL_STICKY 0x13
#define SRV_NET_SRV_GET_INFO 0x15
#define SRV_NET_SRV_SET_INFO 0x16
#define SRV_NET_DISK_ENUM 0x17
#define SRV_NET_REMOTE_TOD 0x1c
#define SRV_NET_NAME_VALIDATE 0x21
#define SRV_NET_SHARE_ENUM 0x24
#define SRV_NET_FILE_QUERY_SECDESC 0x27
#define SRV_NET_FILE_SET_SECDESC 0x28
#define MAX_SERVER_DISK_ENTRIES 15
typedef struct disk_info {
uint32 unknown;
UNISTR3 disk_name;
} DISK_INFO;
typedef struct disk_enum_container {
uint32 level;
uint32 entries_read;
uint32 unknown;
uint32 disk_info_ptr;
DISK_INFO *disk_info;
} DISK_ENUM_CONTAINER;
typedef struct net_srv_disk_enum {
uint32 ptr_srv_name; /* pointer (to server name?) */
UNISTR2 uni_srv_name; /* server name */
DISK_ENUM_CONTAINER disk_enum_ctr;
uint32 preferred_len; /* preferred maximum length (0xffff ffff) */
uint32 total_entries; /* total number of entries */
ENUM_HND enum_hnd;
WERROR status; /* return status */
} SRV_Q_NET_DISK_ENUM, SRV_R_NET_DISK_ENUM;
/***************************/
typedef struct {
UNISTR2 *servername;
UNISTR2 sharename;
uint32 type;
uint32 flags;
WERROR status;
} SRV_Q_NET_NAME_VALIDATE;
typedef struct {
WERROR status;
} SRV_R_NET_NAME_VALIDATE;
/***************************/
/* oops - this is going to take up a *massive* amount of stack. */
/* the UNISTR2s already have 1024 uint16 chars in them... */
#define MAX_SESS_ENTRIES 32
typedef struct {
UNISTR2 *sharename;
} SESS_INFO_0;
typedef struct {
uint32 num_entries_read;
uint32 ptr_sess_info;
uint32 num_entries_read2;
SESS_INFO_0 info_0[MAX_SESS_ENTRIES];
} SRV_SESS_INFO_0;
typedef struct {
UNISTR2 *sharename;
UNISTR2 *username;
uint32 num_opens;
uint32 open_time;
uint32 idle_time;
uint32 user_flags;
} SESS_INFO_1;
typedef struct {
uint32 num_entries_read;
uint32 ptr_sess_info;
uint32 num_entries_read2;
SESS_INFO_1 info_1[MAX_SESS_ENTRIES];
} SRV_SESS_INFO_1;
typedef struct {
uint32 switch_value;
uint32 ptr_sess_ctr;
union {
SRV_SESS_INFO_0 info0;
SRV_SESS_INFO_1 info1;
} sess;
} SRV_SESS_INFO_CTR;
typedef struct {
UNISTR2 *servername;
UNISTR2 *qualifier;
UNISTR2 *username;
uint32 sess_level;
SRV_SESS_INFO_CTR *ctr;
uint32 preferred_len;
ENUM_HND enum_hnd;
} SRV_Q_NET_SESS_ENUM;
typedef struct {
uint32 sess_level;
SRV_SESS_INFO_CTR *ctr;
uint32 total_entries;
ENUM_HND enum_hnd;
WERROR status;
} SRV_R_NET_SESS_ENUM;
/***************************/
/* SRV_Q_NET_SESS_DEL */
typedef struct q_net_sess_del
{
uint32 ptr_srv_name; /* pointer (to server name?) */
UNISTR2 uni_srv_name; /* server name */
uint32 ptr_cli_name; /* pointer (to qualifier name) */
UNISTR2 uni_cli_name; /* qualifier name "\\qualifier" */
uint32 ptr_user_name; /* pointer (to user name */
UNISTR2 uni_user_name; /* user name */
} SRV_Q_NET_SESS_DEL;
/* SRV_R_NET_SESS_DEL */
typedef struct r_net_sess_del
{
WERROR status; /* return status */
} SRV_R_NET_SESS_DEL;
/* CONN_INFO_0 (pointers to level 0 connection info strings) */
typedef struct ptr_conn_info0
{
uint32 id; /* connection id. */
} CONN_INFO_0;
/* oops - this is going to take up a *massive* amount of stack. */
/* the UNISTR2s already have 1024 uint16 chars in them... */
#define MAX_CONN_ENTRIES 32
/* SRV_CONN_INFO_0 */
typedef struct srv_conn_info_0_info
{
uint32 num_entries_read; /* EntriesRead */
uint32 ptr_conn_info; /* Buffer */
uint32 num_entries_read2; /* EntriesRead */
CONN_INFO_0 info_0 [MAX_CONN_ENTRIES]; /* connection entry pointers */
} SRV_CONN_INFO_0;
/* CONN_INFO_1 (pointers to level 1 connection info strings) */
typedef struct ptr_conn_info1
{
uint32 id; /* connection id */
uint32 type; /* 0x3 */
uint32 num_opens;
uint32 num_users;
uint32 open_time;
uint32 ptr_usr_name; /* pointer to user name. */
uint32 ptr_net_name; /* pointer to network name (e.g IPC$). */
} CONN_INFO_1;
/* CONN_INFO_1_STR (level 1 connection info strings) */
typedef struct str_conn_info1
{
UNISTR2 uni_usr_name; /* unicode string of user */
UNISTR2 uni_net_name; /* unicode string of name */
} CONN_INFO_1_STR;
/* SRV_CONN_INFO_1 */
typedef struct srv_conn_info_1_info
{
uint32 num_entries_read; /* EntriesRead */
uint32 ptr_conn_info; /* Buffer */
uint32 num_entries_read2; /* EntriesRead */
CONN_INFO_1 info_1 [MAX_CONN_ENTRIES]; /* connection entry pointers */
CONN_INFO_1_STR info_1_str[MAX_CONN_ENTRIES]; /* connection entry strings */
} SRV_CONN_INFO_1;
/* SRV_CONN_INFO_CTR */
typedef struct srv_conn_info_ctr_info
{
uint32 switch_value; /* switch value */
uint32 ptr_conn_ctr; /* pointer to conn info union */
union
{
SRV_CONN_INFO_0 info0; /* connection info level 0 */
SRV_CONN_INFO_1 info1; /* connection info level 1 */
} conn;
} SRV_CONN_INFO_CTR;
/* SRV_Q_NET_CONN_ENUM */
typedef struct q_net_conn_enum_info
{
uint32 ptr_srv_name; /* pointer (to server name) */
UNISTR2 uni_srv_name; /* server name "\\server" */
uint32 ptr_qual_name; /* pointer (to qualifier name) */
UNISTR2 uni_qual_name; /* qualifier name "\\qualifier" */
uint32 conn_level; /* connection level */
SRV_CONN_INFO_CTR *ctr;
uint32 preferred_len; /* preferred maximum length (0xffff ffff) */
ENUM_HND enum_hnd;
} SRV_Q_NET_CONN_ENUM;
/* SRV_R_NET_CONN_ENUM */
typedef struct r_net_conn_enum_info
{
uint32 conn_level; /* share level */
SRV_CONN_INFO_CTR *ctr;
uint32 total_entries; /* total number of entries */
ENUM_HND enum_hnd;
WERROR status; /* return status */
} SRV_R_NET_CONN_ENUM;
/* SH_INFO_0 */
typedef struct ptr_share_info0
{
uint32 ptr_netname; /* pointer to net name. */
} SH_INFO_0;
/* SH_INFO_0_STR (level 0 share info strings) */
typedef struct str_share_info0
{
SH_INFO_0 *ptrs;
UNISTR2 uni_netname; /* unicode string of net name */
} SH_INFO_0_STR;
/* SRV_SHARE_INFO_0 */
typedef struct share_info_0_info
{
SH_INFO_0 info_0;
SH_INFO_0_STR info_0_str;
} SRV_SHARE_INFO_0;
/* SH_INFO_1 (pointers to level 1 share info strings) */
typedef struct ptr_share_info1
{
uint32 ptr_netname; /* pointer to net name. */
uint32 type; /* ipc, print, disk ... */
uint32 ptr_remark; /* pointer to comment. */
} SH_INFO_1;
/* SH_INFO_1_STR (level 1 share info strings) */
typedef struct str_share_info1
{
SH_INFO_1 *ptrs;
UNISTR2 uni_netname; /* unicode string of net name */
UNISTR2 uni_remark; /* unicode string of comment */
} SH_INFO_1_STR;
/* SRV_SHARE_INFO_1 */
typedef struct share_info_1_info
{
SH_INFO_1 info_1;
SH_INFO_1_STR info_1_str;
} SRV_SHARE_INFO_1;
/* SH_INFO_2 (pointers to level 2 share info strings) */
typedef struct ptr_share_info2
{
uint32 ptr_netname; /* pointer to net name. */
uint32 type; /* ipc, print, disk ... */
uint32 ptr_remark; /* pointer to comment. */
uint32 perms; /* permissions */
uint32 max_uses; /* maximum uses */
uint32 num_uses; /* current uses */
uint32 ptr_path; /* pointer to path name */
uint32 ptr_passwd; /* pointer to password */
} SH_INFO_2;
/* SH_INFO_2_STR (level 2 share info strings) */
typedef struct str_share_info2
{
SH_INFO_2 *ptrs;
UNISTR2 uni_netname; /* unicode string of net name (e.g NETLOGON) */
UNISTR2 uni_remark; /* unicode string of comment (e.g "Logon server share") */
UNISTR2 uni_path; /* unicode string of local path (e.g c:\winnt\system32\repl\import\scripts) */
UNISTR2 uni_passwd; /* unicode string of password - presumably for share level security (e.g NULL) */
} SH_INFO_2_STR;
/* SRV_SHARE_INFO_2 */
typedef struct share_info_2_info
{
SH_INFO_2 info_2;
SH_INFO_2_STR info_2_str;
} SRV_SHARE_INFO_2;
typedef struct ptr_share_info501
{
uint32 ptr_netname; /* pointer to net name */
uint32 type; /* ipc, print, disk */
uint32 ptr_remark; /* pointer to comment */
uint32 csc_policy; /* client-side offline caching policy << 4 */
} SH_INFO_501;
typedef struct str_share_info501
{
UNISTR2 uni_netname; /* unicode string of net name */
UNISTR2 uni_remark; /* unicode string of comment */
} SH_INFO_501_STR;
/* SRV_SHARE_INFO_501 */
typedef struct share_info_501_info
{
SH_INFO_501 info_501;
SH_INFO_501_STR info_501_str;
} SRV_SHARE_INFO_501;
/* SH_INFO_502 (pointers to level 502 share info strings) */
typedef struct ptr_share_info502
{
uint32 ptr_netname; /* pointer to net name. */
uint32 type; /* ipc, print, disk ... */
uint32 ptr_remark; /* pointer to comment. */
uint32 perms; /* permissions */
uint32 max_uses; /* maximum uses */
uint32 num_uses; /* current uses */
uint32 ptr_path; /* pointer to path name */
uint32 ptr_passwd; /* pointer to password */
uint32 reserved; /* this holds the space taken by the sd in the rpc packet */
uint32 reserved_offset; /* required for _post operation when marshalling */
uint32 sd_size; /* size of security descriptor */
uint32 ptr_sd; /* pointer to security descriptor */
} SH_INFO_502;
/* SH_INFO_502_STR (level 502 share info strings) */
typedef struct str_share_info502
{
SH_INFO_502 *ptrs;
UNISTR2 uni_netname; /* unicode string of net name (e.g NETLOGON) */
UNISTR2 uni_remark; /* unicode string of comment (e.g "Logon server share") */
UNISTR2 uni_path; /* unicode string of local path (e.g c:\winnt\system32\repl\import\scripts) */
UNISTR2 uni_passwd; /* unicode string of password - presumably for share level security (e.g NULL) */
uint32 reserved;
uint32 sd_size;
SEC_DESC *sd;
} SH_INFO_502_STR;
/* SRV_SHARE_INFO_502 */
typedef struct share_info_502_info
{
SH_INFO_502 info_502;
SH_INFO_502_STR info_502_str;
} SRV_SHARE_INFO_502;
typedef struct ptr_share_info1004
{
uint32 ptr_remark;
} SH_INFO_1004;
typedef struct str_share_info1004
{
SH_INFO_1004 *ptrs;
UNISTR2 uni_remark;
} SH_INFO_1004_STR;
typedef struct ptr_info_1004_info
{
SH_INFO_1004 info_1004;
SH_INFO_1004_STR info_1004_str;
} SRV_SHARE_INFO_1004;
typedef struct share_info_1005_info
{
uint32 share_info_flags;
} SRV_SHARE_INFO_1005;
typedef struct share_info_1006_info
{
uint32 max_uses;
} SRV_SHARE_INFO_1006;
typedef struct ptr_share_info1007
{
uint32 flags;
uint32 ptr_AlternateDirectoryName;
} SH_INFO_1007;
typedef struct str_share_info1007
{
SH_INFO_1007 *ptrs;
UNISTR2 uni_AlternateDirectoryName;
} SH_INFO_1007_STR;
typedef struct ptr_info_1007_info
{
SH_INFO_1007 info_1007;
SH_INFO_1007_STR info_1007_str;
} SRV_SHARE_INFO_1007;
/* SRV_SHARE_INFO_1501 */
typedef struct share_info_1501_info
{
SEC_DESC_BUF *sdb;
} SRV_SHARE_INFO_1501;
/* SRV_SHARE_INFO_CTR */
typedef struct srv_share_info_ctr_info
{
uint32 info_level;
uint32 switch_value;
uint32 ptr_share_info;
uint32 num_entries;
uint32 ptr_entries;
uint32 num_entries2;
union {
SRV_SHARE_INFO_0 *info0;
SRV_SHARE_INFO_1 *info1; /* share info level 1 */
SRV_SHARE_INFO_2 *info2; /* share info level 2 */
SRV_SHARE_INFO_501 *info501; /* share info level 501 */
SRV_SHARE_INFO_502 *info502; /* share info level 502 */
SRV_SHARE_INFO_1004 *info1004;
SRV_SHARE_INFO_1005 *info1005;
SRV_SHARE_INFO_1006 *info1006;
SRV_SHARE_INFO_1007 *info1007;
SRV_SHARE_INFO_1501 *info1501;
void *info;
} share;
} SRV_SHARE_INFO_CTR;
/* SRV_Q_NET_SHARE_ENUM */
typedef struct q_net_share_enum_info
{
uint32 ptr_srv_name; /* pointer (to server name?) */
UNISTR2 uni_srv_name; /* server name */
SRV_SHARE_INFO_CTR ctr; /* share info container */
uint32 preferred_len; /* preferred maximum length (0xffff ffff) */
ENUM_HND enum_hnd;
} SRV_Q_NET_SHARE_ENUM;
/* SRV_R_NET_SHARE_ENUM */
typedef struct r_net_share_enum_info
{
SRV_SHARE_INFO_CTR ctr; /* share info container */
uint32 total_entries; /* total number of entries */
ENUM_HND enum_hnd;
WERROR status; /* return status */
} SRV_R_NET_SHARE_ENUM;
/* SRV_Q_NET_SHARE_GET_INFO */
typedef struct q_net_share_get_info_info
{
uint32 ptr_srv_name;
UNISTR2 uni_srv_name;
UNISTR2 uni_share_name;
uint32 info_level;
} SRV_Q_NET_SHARE_GET_INFO;
/* SRV_SHARE_INFO */
typedef struct srv_share_info {
uint32 switch_value;
uint32 ptr_share_ctr;
union {
SRV_SHARE_INFO_0 info0;
SRV_SHARE_INFO_1 info1;
SRV_SHARE_INFO_2 info2;
SRV_SHARE_INFO_501 info501;
SRV_SHARE_INFO_502 info502;
SRV_SHARE_INFO_1004 info1004;
SRV_SHARE_INFO_1005 info1005;
SRV_SHARE_INFO_1006 info1006;
SRV_SHARE_INFO_1007 info1007;
SRV_SHARE_INFO_1501 info1501;
} share;
} SRV_SHARE_INFO;
/* SRV_R_NET_SHARE_GET_INFO */
typedef struct r_net_share_get_info_info
{
SRV_SHARE_INFO info;
WERROR status;
} SRV_R_NET_SHARE_GET_INFO;
/* SRV_Q_NET_SHARE_SET_INFO */
typedef struct q_net_share_set_info_info
{
uint32 ptr_srv_name;
UNISTR2 uni_srv_name;
UNISTR2 uni_share_name;
uint32 info_level;
SRV_SHARE_INFO info;
uint32 ptr_parm_error;
uint32 parm_error;
} SRV_Q_NET_SHARE_SET_INFO;
/* SRV_R_NET_SHARE_SET_INFO */
typedef struct r_net_share_set_info
{
uint32 ptr_parm_error;
uint32 parm_error;
WERROR status; /* return status */
} SRV_R_NET_SHARE_SET_INFO;
/* SRV_Q_NET_SHARE_ADD */
typedef struct q_net_share_add
{
uint32 ptr_srv_name;
UNISTR2 uni_srv_name;
uint32 info_level;
SRV_SHARE_INFO info;
uint32 ptr_err_index; /* pointer to error index */
uint32 err_index; /* index in info to field in error */
} SRV_Q_NET_SHARE_ADD;
/* SRV_R_NET_SHARE_ADD */
typedef struct r_net_share_add
{
uint32 ptr_parm_error;
uint32 parm_error;
WERROR status; /* return status */
} SRV_R_NET_SHARE_ADD;
/* SRV_Q_NET_SHARE_DEL */
typedef struct q_net_share_del
{
uint32 ptr_srv_name;
UNISTR2 uni_srv_name;
UNISTR2 uni_share_name;
uint32 reserved;
} SRV_Q_NET_SHARE_DEL;
/* SRV_R_NET_SHARE_DEL */
typedef struct r_net_share_del
{
WERROR status; /* return status */
} SRV_R_NET_SHARE_DEL;
/***************************/
typedef struct {
uint32 id; /* file index */
uint32 perms; /* file permissions. don't know what format */
uint32 num_locks; /* file locks */
UNISTR2 *path; /* file name */
UNISTR2 *user; /* file owner */
} FILE_INFO_3;
typedef struct {
uint32 level; /* switch value */
uint32 ptr_file_info; /* pointer to file info union */
uint32 num_entries;
uint32 ptr_entries;
uint32 num_entries2;
union {
FILE_INFO_3 *info3;
} file;
} SRV_FILE_INFO_CTR;
typedef struct {
UNISTR2 *servername;
UNISTR2 *qualifier;
UNISTR2 *username;
uint32 level;
SRV_FILE_INFO_CTR ctr;
uint32 preferred_len; /* preferred maximum length (0xffff ffff) */
ENUM_HND enum_hnd;
} SRV_Q_NET_FILE_ENUM;
typedef struct {
uint32 level;
SRV_FILE_INFO_CTR ctr;
uint32 total_entries;
ENUM_HND enum_hnd;
WERROR status;
} SRV_R_NET_FILE_ENUM;
/* SRV_INFO_100 */
typedef struct srv_info_100_info
{
uint32 platform_id; /* 0x500 */
uint32 ptr_name; /* pointer to server name */
UNISTR2 uni_name; /* server name "server" */
} SRV_INFO_100;
/* SRV_INFO_101 */
typedef struct srv_info_101_info
{
uint32 platform_id; /* 0x500 */
uint32 ptr_name; /* pointer to server name */
uint32 ver_major; /* 0x4 */
uint32 ver_minor; /* 0x2 */
uint32 srv_type; /* browse etc type */
uint32 ptr_comment; /* pointer to server comment */
UNISTR2 uni_name; /* server name "server" */
UNISTR2 uni_comment; /* server comment "samba x.x.x blah" */
} SRV_INFO_101;
/* SRV_INFO_102 */
typedef struct srv_info_102_info
{
uint32 platform_id; /* 0x500 */
uint32 ptr_name; /* pointer to server name */
uint32 ver_major; /* 0x4 */
uint32 ver_minor; /* 0x2 */
uint32 srv_type; /* browse etc type */
uint32 ptr_comment; /* pointer to server comment */
uint32 users; /* 0xffff ffff*/
uint32 disc; /* 0xf */
uint32 hidden; /* 0x0 */
uint32 announce; /* 240 */
uint32 ann_delta; /* 3000 */
uint32 licenses; /* 0 */
uint32 ptr_usr_path; /* pointer to user path */
UNISTR2 uni_name; /* server name "server" */
UNISTR2 uni_comment; /* server comment "samba x.x.x blah" */
UNISTR2 uni_usr_path; /* "c:\" (eh?) */
} SRV_INFO_102;
/* SRV_INFO_CTR */
typedef struct srv_info_ctr_info
{
uint32 switch_value; /* switch value */
uint32 ptr_srv_ctr; /* pointer to server info */
union
{
SRV_INFO_102 sv102; /* server info level 102 */
SRV_INFO_101 sv101; /* server info level 101 */
SRV_INFO_100 sv100; /* server info level 100 */
} srv;
} SRV_INFO_CTR;
/* SRV_Q_NET_SRV_GET_INFO */
typedef struct q_net_srv_get_info
{
uint32 ptr_srv_name;
UNISTR2 uni_srv_name; /* "\\server" */
uint32 switch_value;
} SRV_Q_NET_SRV_GET_INFO;
/* SRV_R_NET_SRV_GET_INFO */
typedef struct r_net_srv_get_info
{
SRV_INFO_CTR *ctr;
WERROR status; /* return status */
} SRV_R_NET_SRV_GET_INFO;
/* SRV_Q_NET_SRV_SET_INFO */
typedef struct q_net_srv_set_info
{
uint32 ptr_srv_name;
UNISTR2 uni_srv_name; /* "\\server" */
uint32 switch_value;
SRV_INFO_CTR *ctr;
} SRV_Q_NET_SRV_SET_INFO;
/* SRV_R_NET_SRV_SET_INFO */
typedef struct r_net_srv_set_info
{
uint32 switch_value; /* switch value */
WERROR status; /* return status */
} SRV_R_NET_SRV_SET_INFO;
/* SRV_Q_NET_REMOTE_TOD */
typedef struct q_net_remote_tod
{
uint32 ptr_srv_name;
UNISTR2 uni_srv_name; /* "\\server" */
} SRV_Q_NET_REMOTE_TOD;
/* TIME_OF_DAY_INFO */
typedef struct time_of_day_info
{
uint32 elapsedt;
uint32 msecs;
uint32 hours;
uint32 mins;
uint32 secs;
uint32 hunds;
uint32 zone;
uint32 tintervals;
uint32 day;
uint32 month;
uint32 year;
uint32 weekday;
} TIME_OF_DAY_INFO;
/* SRV_R_NET_REMOTE_TOD */
typedef struct r_net_remote_tod
{
uint32 ptr_srv_tod; /* pointer to TOD */
TIME_OF_DAY_INFO *tod;
WERROR status; /* return status */
} SRV_R_NET_REMOTE_TOD;
/* SRV_Q_NET_FILE_QUERY_SECDESC */
typedef struct q_net_file_query_secdesc
{
uint32 ptr_srv_name;
UNISTR2 uni_srv_name;
uint32 ptr_qual_name;
UNISTR2 uni_qual_name;
UNISTR2 uni_file_name;
uint32 unknown1;
uint32 unknown2;
uint32 unknown3;
} SRV_Q_NET_FILE_QUERY_SECDESC;
/* SRV_R_NET_FILE_QUERY_SECDESC */
typedef struct r_net_file_query_secdesc
{
uint32 ptr_response;
uint32 size_response;
uint32 ptr_secdesc;
uint32 size_secdesc;
SEC_DESC *sec_desc;
WERROR status;
} SRV_R_NET_FILE_QUERY_SECDESC;
/* SRV_Q_NET_FILE_SET_SECDESC */
typedef struct q_net_file_set_secdesc
{
uint32 ptr_srv_name;
UNISTR2 uni_srv_name;
uint32 ptr_qual_name;
UNISTR2 uni_qual_name;
UNISTR2 uni_file_name;
uint32 sec_info;
uint32 size_set;
uint32 ptr_secdesc;
uint32 size_secdesc;
SEC_DESC *sec_desc;
} SRV_Q_NET_FILE_SET_SECDESC;
/* SRV_R_NET_FILE_SET_SECDESC */
typedef struct r_net_file_set_secdesc
{
WERROR status;
} SRV_R_NET_FILE_SET_SECDESC;
/***************************/
typedef struct {
UNISTR2 *servername;
uint32 file_id;
} SRV_Q_NET_FILE_CLOSE;
typedef struct {
WERROR status;
} SRV_R_NET_FILE_CLOSE;
/***************************/
#endif /* _RPC_SRVSVC_H */

View File

@ -133,9 +133,6 @@
#define OPENX_FILE_CREATE_IF_NOT_EXIST 0x10
#define OPENX_FILE_FAIL_IF_NOT_EXIST 0
/* share types */
/* defined in librpc/gen_ndr/srvsvc.h */
#include "doserr.h"
typedef union unid_t {
@ -1357,9 +1354,6 @@ char *strdup(char *s);
#define SELECT_CAST
#endif
/* these are used in NetServerEnum to choose what to receive */
/* defined in librpc/gen_ndr/srvsvc.h */
/* This was set by JHT in liaison with Jeremy Allison early 1997
* History:
* Version 4.0 - never made public

View File

@ -2473,15 +2473,13 @@ net_share_enum_rpc(struct cli_state *cli,
{
int i;
WERROR result;
ENUM_HND enum_hnd;
uint32 enum_hnd;
uint32 info_level = 1;
uint32 preferred_len = 0xffffffff;
uint32 type;
SRV_SHARE_INFO_CTR ctr;
fstring name = "";
fstring comment = "";
union srvsvc_NetShareCtr ctr;
void *mem_ctx;
struct rpc_pipe_client *pipe_hnd;
uint32 numentries;
NTSTATUS nt_status;
/* Open the server service pipe */
@ -2500,36 +2498,29 @@ net_share_enum_rpc(struct cli_state *cli,
}
/* Issue the NetShareEnum RPC call and retrieve the response */
init_enum_hnd(&enum_hnd, 0);
result = rpccli_srvsvc_net_share_enum(pipe_hnd,
enum_hnd = 0;
result = rpccli_srvsvc_NetShareEnum(pipe_hnd,
mem_ctx,
info_level,
NULL,
&info_level,
&ctr,
preferred_len,
&numentries,
&enum_hnd);
/* Was it successful? */
if (!W_ERROR_IS_OK(result) || ctr.num_entries == 0) {
if (!W_ERROR_IS_OK(result) || numentries == 0) {
/* Nope. Go clean up. */
goto done;
}
/* For each returned entry... */
for (i = 0; i < ctr.num_entries; i++) {
/* pull out the share name */
rpcstr_pull_unistr2_fstring(
name, &ctr.share.info1[i].info_1_str.uni_netname);
/* pull out the share's comment */
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;
for (i = 0; i < numentries; i++) {
/* Add this share to the list */
(*fn)(name, type, comment, state);
(*fn)(ctr.ctr1->array[i].name,
ctr.ctr1->array[i].type,
ctr.ctr1->array[i].comment, state);
}
done:

View File

@ -1,613 +0,0 @@
/*
Unix SMB/CIFS implementation.
NT Domain Authentication SMB / MSRPC client
Copyright (C) Andrew Tridgell 1994-2000
Copyright (C) Tim Potter 2001
Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2002
Copyright (C) Jeremy Allison 2005.
Copyright (C) Gerald (Jerry) Carter 2006.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "includes.h"
WERROR rpccli_srvsvc_net_srv_get_info(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
uint32 switch_value, SRV_INFO_CTR *ctr)
{
prs_struct qbuf, rbuf;
SRV_Q_NET_SRV_GET_INFO q;
SRV_R_NET_SRV_GET_INFO r;
WERROR result = W_ERROR(ERRgeneral);
fstring server;
ZERO_STRUCT(q);
ZERO_STRUCT(r);
/* Initialise input parameters */
slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
strupper_m(server);
init_srv_q_net_srv_get_info(&q, server, switch_value);
r.ctr = ctr;
/* Marshall data and send request */
CLI_DO_RPC_WERR(cli, mem_ctx, PI_SRVSVC, SRV_NET_SRV_GET_INFO,
q, r,
qbuf, rbuf,
srv_io_q_net_srv_get_info,
srv_io_r_net_srv_get_info,
WERR_GENERAL_FAILURE);
result = r.status;
return result;
}
WERROR rpccli_srvsvc_net_share_enum(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
uint32 info_level, SRV_SHARE_INFO_CTR *ctr,
int preferred_len, ENUM_HND *hnd)
{
prs_struct qbuf, rbuf;
SRV_Q_NET_SHARE_ENUM q;
SRV_R_NET_SHARE_ENUM r;
WERROR result = W_ERROR(ERRgeneral);
fstring server;
int i;
ZERO_STRUCT(q);
ZERO_STRUCT(r);
/* Initialise input parameters */
slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
strupper_m(server);
init_srv_q_net_share_enum(&q, server, info_level, preferred_len, hnd);
/* Marshall data and send request */
CLI_DO_RPC_WERR(cli, mem_ctx, PI_SRVSVC, SRV_NET_SHARE_ENUM_ALL,
q, r,
qbuf, rbuf,
srv_io_q_net_share_enum,
srv_io_r_net_share_enum,
WERR_GENERAL_FAILURE);
result = r.status;
if (!W_ERROR_IS_OK(result))
goto done;
/* Oh yuck yuck yuck - we have to copy all the info out of the
SRV_SHARE_INFO_CTR in the SRV_R_NET_SHARE_ENUM as when we do a
prs_mem_free() it will all be invalidated. The various share
info structures suck badly too. This really is gross. */
ZERO_STRUCTP(ctr);
if (!r.ctr.num_entries)
goto done;
ctr->info_level = info_level;
ctr->num_entries = r.ctr.num_entries;
switch(info_level) {
case 1:
ctr->share.info1 = TALLOC_ARRAY(mem_ctx, SRV_SHARE_INFO_1, ctr->num_entries);
if (ctr->share.info1 == NULL) {
return WERR_NOMEM;
}
memset(ctr->share.info1, 0, sizeof(SRV_SHARE_INFO_1));
for (i = 0; i < ctr->num_entries; i++) {
SRV_SHARE_INFO_1 *info1 = &ctr->share.info1[i];
char *s;
/* Copy pointer crap */
memcpy(&info1->info_1, &r.ctr.share.info1[i].info_1,
sizeof(SH_INFO_1));
/* Duplicate strings */
s = unistr2_tdup(mem_ctx, &r.ctr.share.info1[i].info_1_str.uni_netname);
if (s)
init_unistr2(&info1->info_1_str.uni_netname, s, UNI_STR_TERMINATE);
s = unistr2_tdup(mem_ctx, &r.ctr.share.info1[i].info_1_str.uni_remark);
if (s)
init_unistr2(&info1->info_1_str.uni_remark, s, UNI_STR_TERMINATE);
}
break;
case 2:
ctr->share.info2 = TALLOC_ARRAY(mem_ctx, SRV_SHARE_INFO_2, ctr->num_entries);
if (ctr->share.info2 == NULL) {
return WERR_NOMEM;
}
memset(ctr->share.info2, 0, sizeof(SRV_SHARE_INFO_2));
for (i = 0; i < ctr->num_entries; i++) {
SRV_SHARE_INFO_2 *info2 = &ctr->share.info2[i];
char *s;
/* Copy pointer crap */
memcpy(&info2->info_2, &r.ctr.share.info2[i].info_2,
sizeof(SH_INFO_2));
/* Duplicate strings */
s = unistr2_tdup(mem_ctx, &r.ctr.share.info2[i].info_2_str.uni_netname);
if (s)
init_unistr2(&info2->info_2_str.uni_netname, s, UNI_STR_TERMINATE);
s = unistr2_tdup(mem_ctx, &r.ctr.share.info2[i].info_2_str.uni_remark);
if (s)
init_unistr2(&info2->info_2_str.uni_remark, s, UNI_STR_TERMINATE);
s = unistr2_tdup(mem_ctx, &r.ctr.share.info2[i].info_2_str.uni_path);
if (s)
init_unistr2(&info2->info_2_str.uni_path, s, UNI_STR_TERMINATE);
s = unistr2_tdup(mem_ctx, &r.ctr.share.info2[i].info_2_str.uni_passwd);
if (s)
init_unistr2(&info2->info_2_str.uni_passwd, s, UNI_STR_TERMINATE);
}
break;
/* adding info-level 502 here */
case 502:
ctr->share.info502 = TALLOC_ARRAY(mem_ctx, SRV_SHARE_INFO_502, ctr->num_entries);
if (ctr->share.info502 == NULL) {
return WERR_NOMEM;
}
memset(ctr->share.info502, 0, sizeof(SRV_SHARE_INFO_502));
for (i = 0; i < ctr->num_entries; i++) {
SRV_SHARE_INFO_502 *info502 = &ctr->share.info502[i];
char *s;
/* Copy pointer crap */
memcpy(&info502->info_502, &r.ctr.share.info502[i].info_502,
sizeof(SH_INFO_502));
/* Duplicate strings */
s = unistr2_tdup(mem_ctx, &r.ctr.share.info502[i].info_502_str.uni_netname);
if (s)
init_unistr2(&info502->info_502_str.uni_netname, s, UNI_STR_TERMINATE);
s = unistr2_tdup(mem_ctx, &r.ctr.share.info502[i].info_502_str.uni_remark);
if (s)
init_unistr2(&info502->info_502_str.uni_remark, s, UNI_STR_TERMINATE);
s = unistr2_tdup(mem_ctx, &r.ctr.share.info502[i].info_502_str.uni_path);
if (s)
init_unistr2(&info502->info_502_str.uni_path, s, UNI_STR_TERMINATE);
s = unistr2_tdup(mem_ctx, &r.ctr.share.info502[i].info_502_str.uni_passwd);
if (s)
init_unistr2(&info502->info_502_str.uni_passwd, s, UNI_STR_TERMINATE);
info502->info_502_str.sd = dup_sec_desc(mem_ctx, r.ctr.share.info502[i].info_502_str.sd);
}
break;
}
done:
return result;
}
WERROR rpccli_srvsvc_net_share_get_info(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
const char *sharename,
uint32 info_level,
SRV_SHARE_INFO *info)
{
prs_struct qbuf, rbuf;
SRV_Q_NET_SHARE_GET_INFO q;
SRV_R_NET_SHARE_GET_INFO r;
WERROR result = W_ERROR(ERRgeneral);
fstring server;
ZERO_STRUCT(q);
ZERO_STRUCT(r);
/* Initialise input parameters */
slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
strupper_m(server);
init_srv_q_net_share_get_info(&q, server, sharename, info_level);
/* Marshall data and send request */
CLI_DO_RPC_WERR(cli, mem_ctx, PI_SRVSVC, SRV_NET_SHARE_GET_INFO,
q, r,
qbuf, rbuf,
srv_io_q_net_share_get_info,
srv_io_r_net_share_get_info,
WERR_GENERAL_FAILURE);
result = r.status;
if (!W_ERROR_IS_OK(result))
goto done;
ZERO_STRUCTP(info);
info->switch_value = info_level;
switch(info_level) {
case 1:
{
SRV_SHARE_INFO_1 *info1 = &info->share.info1;
SH_INFO_1_STR *info1_str = &info1->info_1_str;
char *s;
info->share.info1 = r.info.share.info1;
/* Duplicate strings */
s = unistr2_tdup(mem_ctx, &info1_str->uni_netname);
if (s)
init_unistr2(&info1_str->uni_netname,
s, UNI_STR_TERMINATE);
s = unistr2_tdup(mem_ctx, &info1_str->uni_remark);
if (s)
init_unistr2(&info1_str->uni_remark,
s, UNI_STR_TERMINATE);
break;
}
case 2:
{
SRV_SHARE_INFO_2 *info2 = &info->share.info2;
SH_INFO_2_STR *info2_str = &info2->info_2_str;
char *s;
info->share.info2 = r.info.share.info2;
/* Duplicate strings */
s = unistr2_tdup(mem_ctx, &info2_str->uni_netname);
if (s)
init_unistr2(&info2_str->uni_netname,
s, UNI_STR_TERMINATE);
s = unistr2_tdup(mem_ctx, &info2_str->uni_remark);
if (s)
init_unistr2(&info2_str->uni_remark,
s, UNI_STR_TERMINATE);
s = unistr2_tdup(mem_ctx, &info2_str->uni_path);
if (s)
init_unistr2(&info2_str->uni_path,
s, UNI_STR_TERMINATE);
s = unistr2_tdup(mem_ctx, &info2_str->uni_passwd);
if (s)
init_unistr2(&info2_str->uni_passwd,
s, UNI_STR_TERMINATE);
break;
}
case 502:
{
SRV_SHARE_INFO_502 *info502 = &info->share.info502;
SH_INFO_502_STR *info502_str = &info502->info_502_str;
char *s;
info->share.info502 = r.info.share.info502;
/* Duplicate strings */
s = unistr2_tdup(mem_ctx, &info502_str->uni_netname);
if (s)
init_unistr2(&info502_str->uni_netname,
s, UNI_STR_TERMINATE);
s = unistr2_tdup(mem_ctx, &info502_str->uni_remark);
if (s)
init_unistr2(&info502_str->uni_remark,
s, UNI_STR_TERMINATE);
s = unistr2_tdup(mem_ctx, &info502_str->uni_path);
if (s)
init_unistr2(&info502_str->uni_path,
s, UNI_STR_TERMINATE);
s = unistr2_tdup(mem_ctx, &info502_str->uni_passwd);
if (s)
init_unistr2(&info502_str->uni_passwd,
s, UNI_STR_TERMINATE);
info502_str->sd = dup_sec_desc(mem_ctx, info502_str->sd);
break;
}
default:
DEBUG(0,("unimplemented info-level: %d\n", info_level));
break;
}
done:
return result;
}
WERROR rpccli_srvsvc_net_share_set_info(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
const char *sharename,
uint32 info_level,
SRV_SHARE_INFO *info)
{
prs_struct qbuf, rbuf;
SRV_Q_NET_SHARE_SET_INFO q;
SRV_R_NET_SHARE_SET_INFO r;
WERROR result = W_ERROR(ERRgeneral);
fstring server;
ZERO_STRUCT(q);
ZERO_STRUCT(r);
/* Initialise input parameters */
slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
strupper_m(server);
init_srv_q_net_share_set_info(&q, server, sharename, info_level, info);
/* Marshall data and send request */
CLI_DO_RPC_WERR(cli, mem_ctx, PI_SRVSVC, SRV_NET_SHARE_SET_INFO,
q, r,
qbuf, rbuf,
srv_io_q_net_share_set_info,
srv_io_r_net_share_set_info,
WERR_GENERAL_FAILURE);
result = r.status;
return result;
}
WERROR rpccli_srvsvc_net_share_del(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
const char *sharename)
{
prs_struct qbuf, rbuf;
SRV_Q_NET_SHARE_DEL q;
SRV_R_NET_SHARE_DEL r;
WERROR result = W_ERROR(ERRgeneral);
fstring server;
ZERO_STRUCT(q);
ZERO_STRUCT(r);
/* Initialise input parameters */
slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
strupper_m(server);
init_srv_q_net_share_del(&q, server, sharename);
/* Marshall data and send request */
CLI_DO_RPC_WERR(cli, mem_ctx, PI_SRVSVC, SRV_NET_SHARE_DEL,
q, r,
qbuf, rbuf,
srv_io_q_net_share_del,
srv_io_r_net_share_del,
WERR_GENERAL_FAILURE);
result = r.status;
return result;
}
WERROR rpccli_srvsvc_net_share_add(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
const char *netname, uint32 type,
const char *remark, uint32 perms,
uint32 max_uses, uint32 num_uses,
const char *path, const char *passwd,
int level, SEC_DESC *sd)
{
prs_struct qbuf, rbuf;
SRV_Q_NET_SHARE_ADD q;
SRV_R_NET_SHARE_ADD r;
WERROR result = W_ERROR(ERRgeneral);
fstring server;
ZERO_STRUCT(q);
ZERO_STRUCT(r);
slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
strupper_m(server);
init_srv_q_net_share_add(&q,server, netname, type, remark,
perms, max_uses, num_uses, path, passwd,
level, sd);
/* Marshall data and send request */
CLI_DO_RPC_WERR(cli, mem_ctx, PI_SRVSVC, SRV_NET_SHARE_ADD,
q, r,
qbuf, rbuf,
srv_io_q_net_share_add,
srv_io_r_net_share_add,
WERR_GENERAL_FAILURE);
result = r.status;
return result;
}
WERROR rpccli_srvsvc_net_remote_tod(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
char *server, TIME_OF_DAY_INFO *tod)
{
prs_struct qbuf, rbuf;
SRV_Q_NET_REMOTE_TOD q;
SRV_R_NET_REMOTE_TOD r;
WERROR result = W_ERROR(ERRgeneral);
fstring server_slash;
ZERO_STRUCT(q);
ZERO_STRUCT(r);
/* Initialise input parameters */
slprintf(server_slash, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
strupper_m(server_slash);
init_srv_q_net_remote_tod(&q, server_slash);
r.tod = tod;
/* Marshall data and send request */
CLI_DO_RPC_WERR(cli, mem_ctx, PI_SRVSVC, SRV_NET_REMOTE_TOD,
q, r,
qbuf, rbuf,
srv_io_q_net_remote_tod,
srv_io_r_net_remote_tod,
WERR_GENERAL_FAILURE);
result = r.status;
return result;
}
WERROR rpccli_srvsvc_net_file_enum(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
uint32 file_level, const char *user_name,
SRV_FILE_INFO_CTR *ctr, int preferred_len,
ENUM_HND *hnd)
{
prs_struct qbuf, rbuf;
SRV_Q_NET_FILE_ENUM q;
SRV_R_NET_FILE_ENUM r;
WERROR result = W_ERROR(ERRgeneral);
fstring server;
int i;
ZERO_STRUCT(q);
ZERO_STRUCT(r);
/* Initialise input parameters */
slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
strupper_m(server);
init_srv_q_net_file_enum(&q, server, NULL, user_name,
file_level, ctr, preferred_len, hnd);
/* Marshall data and send request */
CLI_DO_RPC_WERR(cli, mem_ctx, PI_SRVSVC, SRV_NET_FILE_ENUM,
q, r,
qbuf, rbuf,
srv_io_q_net_file_enum,
srv_io_r_net_file_enum,
WERR_GENERAL_FAILURE);
result = r.status;
if (!W_ERROR_IS_OK(result))
goto done;
/* copy the data over to the ctr */
ZERO_STRUCTP(ctr);
ctr->level = file_level;
ctr->num_entries = ctr->num_entries2 = r.ctr.num_entries;
switch(file_level) {
case 3:
if ( (ctr->file.info3 = TALLOC_ARRAY(mem_ctx, FILE_INFO_3, ctr->num_entries)) == NULL ) {
return WERR_NOMEM;
}
memset(ctr->file.info3, 0, sizeof(FILE_INFO_3) * ctr->num_entries);
for (i = 0; i < r.ctr.num_entries; i++) {
FILE_INFO_3 *info3 = &ctr->file.info3[i];
char *s;
/* Copy pointer crap */
memcpy(info3, &r.ctr.file.info3[i], sizeof(FILE_INFO_3));
/* Duplicate strings */
if ( (s = unistr2_tdup(mem_ctx, r.ctr.file.info3[i].path)) != NULL ) {
info3->path = TALLOC_P( mem_ctx, UNISTR2 );
init_unistr2(info3->path, s, UNI_STR_TERMINATE);
}
if ( (s = unistr2_tdup(mem_ctx, r.ctr.file.info3[i].user)) != NULL ) {
info3->user = TALLOC_P( mem_ctx, UNISTR2 );
init_unistr2(info3->user, s, UNI_STR_TERMINATE);
}
}
break;
}
done:
return result;
}
WERROR rpccli_srvsvc_net_file_close(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
uint32 file_id)
{
prs_struct qbuf, rbuf;
SRV_Q_NET_FILE_CLOSE q;
SRV_R_NET_FILE_CLOSE r;
WERROR result = W_ERROR(ERRgeneral);
fstring server;
ZERO_STRUCT(q);
ZERO_STRUCT(r);
/* Initialise input parameters */
slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
strupper_m(server);
init_srv_q_net_file_close(&q, server, file_id);
/* Marshall data and send request */
CLI_DO_RPC_WERR(cli, mem_ctx, PI_SRVSVC, SRV_NET_FILE_CLOSE,
q, r,
qbuf, rbuf,
srv_io_q_net_file_close,
srv_io_r_net_file_close,
WERR_GENERAL_FAILURE);
result = r.status;
return result;
}

View File

@ -151,53 +151,6 @@ BOOL smb_io_nttime(const char *desc, prs_struct *ps, int depth, NTTIME *nttime)
return smb_io_time( desc, nttime, ps, depth );
}
/*******************************************************************
Gets an enumeration handle from an ENUM_HND structure.
********************************************************************/
uint32 get_enum_hnd(ENUM_HND *enh)
{
return (enh && enh->ptr_hnd != 0) ? enh->handle : 0;
}
/*******************************************************************
Inits an ENUM_HND structure.
********************************************************************/
void init_enum_hnd(ENUM_HND *enh, uint32 hnd)
{
DEBUG(5,("smb_io_enum_hnd\n"));
enh->ptr_hnd = (hnd != 0) ? 1 : 0;
enh->handle = hnd;
}
/*******************************************************************
Reads or writes an ENUM_HND structure.
********************************************************************/
BOOL smb_io_enum_hnd(const char *desc, ENUM_HND *hnd, prs_struct *ps, int depth)
{
if (hnd == NULL)
return False;
prs_debug(ps, depth, desc, "smb_io_enum_hnd");
depth++;
if(!prs_align(ps))
return False;
if(!prs_uint32("ptr_hnd", ps, depth, &hnd->ptr_hnd)) /* pointer */
return False;
if (hnd->ptr_hnd != 0) {
if(!prs_uint32("handle ", ps, depth, &hnd->handle )) /* enum handle */
return False;
}
return True;
}
/*******************************************************************
Reads or writes a DOM_SID structure.
********************************************************************/

File diff suppressed because it is too large Load Diff

View File

@ -2,6 +2,7 @@
* Unix SMB/CIFS implementation.
* RPC Pipe client / server routines for rpcecho
* Copyright (C) Tim Potter 2003.
* Copyright (C) Jelmer Vernooij 2006.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,621 +0,0 @@
/*
* Unix SMB/CIFS implementation.
* RPC Pipe client / server routines
* Copyright (C) Andrew Tridgell 1992-1997,
* Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
* Copyright (C) Paul Ashton 1997,
* Copyright (C) Jeremy Allison 2001,
* Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2003.
* Copyright (C) Gera;d (Jerry) Carter 2006.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* This is the interface to the srvsvc pipe. */
#include "includes.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_SRV
/*******************************************************************
api_srv_net_srv_get_info
********************************************************************/
static BOOL api_srv_net_srv_get_info(pipes_struct *p)
{
SRV_Q_NET_SRV_GET_INFO q_u;
SRV_R_NET_SRV_GET_INFO r_u;
prs_struct *data = &p->in_data.data;
prs_struct *rdata = &p->out_data.rdata;
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
/* grab the net server get info */
if (!srv_io_q_net_srv_get_info("", &q_u, data, 0))
return False;
r_u.status = _srv_net_srv_get_info(p, &q_u, &r_u);
/* store the response in the SMB stream */
if (!srv_io_r_net_srv_get_info("", &r_u, rdata, 0))
return False;
return True;
}
/*******************************************************************
api_srv_net_srv_get_info
********************************************************************/
static BOOL api_srv_net_srv_set_info(pipes_struct *p)
{
SRV_Q_NET_SRV_SET_INFO q_u;
SRV_R_NET_SRV_SET_INFO r_u;
prs_struct *data = &p->in_data.data;
prs_struct *rdata = &p->out_data.rdata;
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
/* grab the net server set info */
if (!srv_io_q_net_srv_set_info("", &q_u, data, 0))
return False;
r_u.status = _srv_net_srv_set_info(p, &q_u, &r_u);
/* store the response in the SMB stream */
if (!srv_io_r_net_srv_set_info("", &r_u, rdata, 0))
return False;
return True;
}
/*******************************************************************
api_srv_net_file_enum
********************************************************************/
static BOOL api_srv_net_file_enum(pipes_struct *p)
{
SRV_Q_NET_FILE_ENUM q_u;
SRV_R_NET_FILE_ENUM r_u;
prs_struct *data = &p->in_data.data;
prs_struct *rdata = &p->out_data.rdata;
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
/* grab the net file enum */
if (!srv_io_q_net_file_enum("", &q_u, data, 0))
return False;
r_u.status = _srv_net_file_enum(p, &q_u, &r_u);
/* store the response in the SMB stream */
if(!srv_io_r_net_file_enum("", &r_u, rdata, 0))
return False;
return True;
}
/*******************************************************************
api_srv_net_conn_enum
********************************************************************/
static BOOL api_srv_net_conn_enum(pipes_struct *p)
{
SRV_Q_NET_CONN_ENUM q_u;
SRV_R_NET_CONN_ENUM r_u;
prs_struct *data = &p->in_data.data;
prs_struct *rdata = &p->out_data.rdata;
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
/* grab the net server get enum */
if (!srv_io_q_net_conn_enum("", &q_u, data, 0))
return False;
r_u.status = _srv_net_conn_enum(p, &q_u, &r_u);
/* store the response in the SMB stream */
if (!srv_io_r_net_conn_enum("", &r_u, rdata, 0))
return False;
return True;
}
/*******************************************************************
Enumerate sessions.
********************************************************************/
static BOOL api_srv_net_sess_enum(pipes_struct *p)
{
SRV_Q_NET_SESS_ENUM q_u;
SRV_R_NET_SESS_ENUM r_u;
prs_struct *data = &p->in_data.data;
prs_struct *rdata = &p->out_data.rdata;
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
/* grab the net server get enum */
if (!srv_io_q_net_sess_enum("", &q_u, data, 0))
return False;
/* construct reply. always indicate success */
r_u.status = _srv_net_sess_enum(p, &q_u, &r_u);
/* store the response in the SMB stream */
if (!srv_io_r_net_sess_enum("", &r_u, rdata, 0))
return False;
return True;
}
/*******************************************************************
Delete session.
********************************************************************/
static BOOL api_srv_net_sess_del(pipes_struct *p)
{
SRV_Q_NET_SESS_DEL q_u;
SRV_R_NET_SESS_DEL r_u;
prs_struct *data = &p->in_data.data;
prs_struct *rdata = &p->out_data.rdata;
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
/* grab the net server get enum */
if (!srv_io_q_net_sess_del("", &q_u, data, 0))
return False;
/* construct reply. always indicate success */
r_u.status = _srv_net_sess_del(p, &q_u, &r_u);
/* store the response in the SMB stream */
if (!srv_io_r_net_sess_del("", &r_u, rdata, 0))
return False;
return True;
}
/*******************************************************************
RPC to enumerate shares.
********************************************************************/
static BOOL api_srv_net_share_enum_all(pipes_struct *p)
{
SRV_Q_NET_SHARE_ENUM q_u;
SRV_R_NET_SHARE_ENUM r_u;
prs_struct *data = &p->in_data.data;
prs_struct *rdata = &p->out_data.rdata;
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
/* Unmarshall the net server get enum. */
if(!srv_io_q_net_share_enum("", &q_u, data, 0)) {
DEBUG(0,("api_srv_net_share_enum_all: Failed to unmarshall SRV_Q_NET_SHARE_ENUM.\n"));
return False;
}
r_u.status = _srv_net_share_enum_all(p, &q_u, &r_u);
if (!srv_io_r_net_share_enum("", &r_u, rdata, 0)) {
DEBUG(0,("api_srv_net_share_enum_all: Failed to marshall SRV_R_NET_SHARE_ENUM.\n"));
return False;
}
return True;
}
/*******************************************************************
RPC to enumerate shares.
********************************************************************/
static BOOL api_srv_net_share_enum(pipes_struct *p)
{
SRV_Q_NET_SHARE_ENUM q_u;
SRV_R_NET_SHARE_ENUM r_u;
prs_struct *data = &p->in_data.data;
prs_struct *rdata = &p->out_data.rdata;
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
/* Unmarshall the net server get enum. */
if(!srv_io_q_net_share_enum("", &q_u, data, 0)) {
DEBUG(0,("api_srv_net_share_enum: Failed to unmarshall SRV_Q_NET_SHARE_ENUM.\n"));
return False;
}
r_u.status = _srv_net_share_enum(p, &q_u, &r_u);
if (!srv_io_r_net_share_enum("", &r_u, rdata, 0)) {
DEBUG(0,("api_srv_net_share_enum: Failed to marshall SRV_R_NET_SHARE_ENUM.\n"));
return False;
}
return True;
}
/*******************************************************************
RPC to return share information.
********************************************************************/
static BOOL api_srv_net_share_get_info(pipes_struct *p)
{
SRV_Q_NET_SHARE_GET_INFO q_u;
SRV_R_NET_SHARE_GET_INFO r_u;
prs_struct *data = &p->in_data.data;
prs_struct *rdata = &p->out_data.rdata;
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
/* Unmarshall the net server get info. */
if(!srv_io_q_net_share_get_info("", &q_u, data, 0)) {
DEBUG(0,("api_srv_net_share_get_info: Failed to unmarshall SRV_Q_NET_SHARE_GET_INFO.\n"));
return False;
}
r_u.status = _srv_net_share_get_info(p, &q_u, &r_u);
if(!srv_io_r_net_share_get_info("", &r_u, rdata, 0)) {
DEBUG(0,("api_srv_net_share_get_info: Failed to marshall SRV_R_NET_SHARE_GET_INFO.\n"));
return False;
}
return True;
}
/*******************************************************************
RPC to set share information.
********************************************************************/
static BOOL api_srv_net_share_set_info(pipes_struct *p)
{
SRV_Q_NET_SHARE_SET_INFO q_u;
SRV_R_NET_SHARE_SET_INFO r_u;
prs_struct *data = &p->in_data.data;
prs_struct *rdata = &p->out_data.rdata;
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
/* Unmarshall the net server set info. */
if(!srv_io_q_net_share_set_info("", &q_u, data, 0)) {
DEBUG(0,("api_srv_net_share_set_info: Failed to unmarshall SRV_Q_NET_SHARE_SET_INFO.\n"));
return False;
}
r_u.status = _srv_net_share_set_info(p, &q_u, &r_u);
if(!srv_io_r_net_share_set_info("", &r_u, rdata, 0)) {
DEBUG(0,("api_srv_net_share_set_info: Failed to marshall SRV_R_NET_SHARE_SET_INFO.\n"));
return False;
}
return True;
}
/*******************************************************************
RPC to add share information.
********************************************************************/
static BOOL api_srv_net_share_add(pipes_struct *p)
{
SRV_Q_NET_SHARE_ADD q_u;
SRV_R_NET_SHARE_ADD r_u;
prs_struct *data = &p->in_data.data;
prs_struct *rdata = &p->out_data.rdata;
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
/* Unmarshall the net server add info. */
if(!srv_io_q_net_share_add("", &q_u, data, 0)) {
DEBUG(0,("api_srv_net_share_add: Failed to unmarshall SRV_Q_NET_SHARE_ADD.\n"));
return False;
}
r_u.status = _srv_net_share_add(p, &q_u, &r_u);
if(!srv_io_r_net_share_add("", &r_u, rdata, 0)) {
DEBUG(0,("api_srv_net_share_add: Failed to marshall SRV_R_NET_SHARE_ADD.\n"));
return False;
}
return True;
}
/*******************************************************************
RPC to delete share information.
********************************************************************/
static BOOL api_srv_net_share_del(pipes_struct *p)
{
SRV_Q_NET_SHARE_DEL q_u;
SRV_R_NET_SHARE_DEL r_u;
prs_struct *data = &p->in_data.data;
prs_struct *rdata = &p->out_data.rdata;
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
/* Unmarshall the net server del info. */
if(!srv_io_q_net_share_del("", &q_u, data, 0)) {
DEBUG(0,("api_srv_net_share_del: Failed to unmarshall SRV_Q_NET_SHARE_DEL.\n"));
return False;
}
r_u.status = _srv_net_share_del(p, &q_u, &r_u);
if(!srv_io_r_net_share_del("", &r_u, rdata, 0)) {
DEBUG(0,("api_srv_net_share_del: Failed to marshall SRV_R_NET_SHARE_DEL.\n"));
return False;
}
return True;
}
/*******************************************************************
RPC to delete share information.
********************************************************************/
static BOOL api_srv_net_share_del_sticky(pipes_struct *p)
{
SRV_Q_NET_SHARE_DEL q_u;
SRV_R_NET_SHARE_DEL r_u;
prs_struct *data = &p->in_data.data;
prs_struct *rdata = &p->out_data.rdata;
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
/* Unmarshall the net server del info. */
if(!srv_io_q_net_share_del("", &q_u, data, 0)) {
DEBUG(0,("api_srv_net_share_del_sticky: Failed to unmarshall SRV_Q_NET_SHARE_DEL.\n"));
return False;
}
r_u.status = _srv_net_share_del_sticky(p, &q_u, &r_u);
if(!srv_io_r_net_share_del("", &r_u, rdata, 0)) {
DEBUG(0,("api_srv_net_share_del_sticky: Failed to marshall SRV_R_NET_SHARE_DEL.\n"));
return False;
}
return True;
}
/*******************************************************************
api_srv_net_remote_tod
********************************************************************/
static BOOL api_srv_net_remote_tod(pipes_struct *p)
{
SRV_Q_NET_REMOTE_TOD q_u;
SRV_R_NET_REMOTE_TOD r_u;
prs_struct *data = &p->in_data.data;
prs_struct *rdata = &p->out_data.rdata;
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
/* grab the net server get enum */
if(!srv_io_q_net_remote_tod("", &q_u, data, 0))
return False;
r_u.status = _srv_net_remote_tod(p, &q_u, &r_u);
/* store the response in the SMB stream */
if(!srv_io_r_net_remote_tod("", &r_u, rdata, 0))
return False;
return True;
}
/*******************************************************************
RPC to enumerate disks available on a server e.g. C:, D: ...
*******************************************************************/
static BOOL api_srv_net_disk_enum(pipes_struct *p)
{
SRV_Q_NET_DISK_ENUM q_u;
SRV_R_NET_DISK_ENUM r_u;
prs_struct *data = &p->in_data.data;
prs_struct *rdata = &p->out_data.rdata;
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
/* Unmarshall the net server disk enum. */
if(!srv_io_q_net_disk_enum("", &q_u, data, 0)) {
DEBUG(0,("api_srv_net_disk_enum: Failed to unmarshall SRV_Q_NET_DISK_ENUM.\n"));
return False;
}
r_u.status = _srv_net_disk_enum(p, &q_u, &r_u);
if(!srv_io_r_net_disk_enum("", &r_u, rdata, 0)) {
DEBUG(0,("api_srv_net_disk_enum: Failed to marshall SRV_R_NET_DISK_ENUM.\n"));
return False;
}
return True;
}
/*******************************************************************
NetValidateName (opnum 0x21)
*******************************************************************/
static BOOL api_srv_net_name_validate(pipes_struct *p)
{
SRV_Q_NET_NAME_VALIDATE q_u;
SRV_R_NET_NAME_VALIDATE r_u;
prs_struct *data = &p->in_data.data;
prs_struct *rdata = &p->out_data.rdata;
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
/* Unmarshall the net server disk enum. */
if(!srv_io_q_net_name_validate("", &q_u, data, 0)) {
DEBUG(0,("api_srv_net_name_validate: Failed to unmarshall SRV_Q_NET_NAME_VALIDATE.\n"));
return False;
}
r_u.status = _srv_net_name_validate(p, &q_u, &r_u);
if(!srv_io_r_net_name_validate("", &r_u, rdata, 0)) {
DEBUG(0,("api_srv_net_name_validate: Failed to marshall SRV_R_NET_NAME_VALIDATE.\n"));
return False;
}
return True;
}
/*******************************************************************
NetFileQuerySecdesc (opnum 0x27)
*******************************************************************/
static BOOL api_srv_net_file_query_secdesc(pipes_struct *p)
{
SRV_Q_NET_FILE_QUERY_SECDESC q_u;
SRV_R_NET_FILE_QUERY_SECDESC r_u;
prs_struct *data = &p->in_data.data;
prs_struct *rdata = &p->out_data.rdata;
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
/* Unmarshall the net file get info from Win9x */
if(!srv_io_q_net_file_query_secdesc("", &q_u, data, 0)) {
DEBUG(0,("api_srv_net_file_query_secdesc: Failed to unmarshall SRV_Q_NET_FILE_QUERY_SECDESC.\n"));
return False;
}
r_u.status = _srv_net_file_query_secdesc(p, &q_u, &r_u);
if(!srv_io_r_net_file_query_secdesc("", &r_u, rdata, 0)) {
DEBUG(0,("api_srv_net_file_query_secdesc: Failed to marshall SRV_R_NET_FILE_QUERY_SECDESC.\n"));
return False;
}
return True;
}
/*******************************************************************
NetFileSetSecdesc (opnum 0x28)
*******************************************************************/
static BOOL api_srv_net_file_set_secdesc(pipes_struct *p)
{
SRV_Q_NET_FILE_SET_SECDESC q_u;
SRV_R_NET_FILE_SET_SECDESC r_u;
prs_struct *data = &p->in_data.data;
prs_struct *rdata = &p->out_data.rdata;
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
/* Unmarshall the net file set info from Win9x */
if(!srv_io_q_net_file_set_secdesc("", &q_u, data, 0)) {
DEBUG(0,("api_srv_net_file_set_secdesc: Failed to unmarshall SRV_Q_NET_FILE_SET_SECDESC.\n"));
return False;
}
r_u.status = _srv_net_file_set_secdesc(p, &q_u, &r_u);
if(!srv_io_r_net_file_set_secdesc("", &r_u, rdata, 0)) {
DEBUG(0,("api_srv_net_file_set_secdesc: Failed to marshall SRV_R_NET_FILE_SET_SECDESC.\n"));
return False;
}
return True;
}
/*******************************************************************
*******************************************************************/
static BOOL api_srv_net_file_close(pipes_struct *p)
{
SRV_Q_NET_FILE_CLOSE q_u;
SRV_R_NET_FILE_CLOSE r_u;
prs_struct *data = &p->in_data.data;
prs_struct *rdata = &p->out_data.rdata;
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
/* Unmarshall the net file set info from Win9x */
if(!srv_io_q_net_file_close("", &q_u, data, 0)) {
DEBUG(0,("api_srv_net_file_close: Failed to unmarshall SRV_Q_NET_FILE_SET_SECDESC.\n"));
return False;
}
r_u.status = _srv_net_file_close(p, &q_u, &r_u);
if(!srv_io_r_net_file_close("", &r_u, rdata, 0)) {
DEBUG(0,("api_srv_net_file_close: Failed to marshall SRV_R_NET_FILE_SET_SECDESC.\n"));
return False;
}
return True;
}
/*******************************************************************
\PIPE\srvsvc commands
********************************************************************/
static struct api_struct api_srv_cmds[] =
{
{ "SRV_NET_CONN_ENUM" , SRV_NET_CONN_ENUM , api_srv_net_conn_enum },
{ "SRV_NET_SESS_ENUM" , SRV_NET_SESS_ENUM , api_srv_net_sess_enum },
{ "SRV_NET_SESS_DEL" , SRV_NET_SESS_DEL , api_srv_net_sess_del },
{ "SRV_NET_SHARE_ENUM_ALL" , SRV_NET_SHARE_ENUM_ALL , api_srv_net_share_enum_all },
{ "SRV_NET_SHARE_ENUM" , SRV_NET_SHARE_ENUM , api_srv_net_share_enum },
{ "SRV_NET_SHARE_ADD" , SRV_NET_SHARE_ADD , api_srv_net_share_add },
{ "SRV_NET_SHARE_DEL" , SRV_NET_SHARE_DEL , api_srv_net_share_del },
{ "SRV_NET_SHARE_DEL_STICKY" , SRV_NET_SHARE_DEL_STICKY , api_srv_net_share_del_sticky },
{ "SRV_NET_SHARE_GET_INFO" , SRV_NET_SHARE_GET_INFO , api_srv_net_share_get_info },
{ "SRV_NET_SHARE_SET_INFO" , SRV_NET_SHARE_SET_INFO , api_srv_net_share_set_info },
{ "SRV_NET_FILE_ENUM" , SRV_NET_FILE_ENUM , api_srv_net_file_enum },
{ "SRV_NET_SRV_GET_INFO" , SRV_NET_SRV_GET_INFO , api_srv_net_srv_get_info },
{ "SRV_NET_SRV_SET_INFO" , SRV_NET_SRV_SET_INFO , api_srv_net_srv_set_info },
{ "SRV_NET_REMOTE_TOD" , SRV_NET_REMOTE_TOD , api_srv_net_remote_tod },
{ "SRV_NET_DISK_ENUM" , SRV_NET_DISK_ENUM , api_srv_net_disk_enum },
{ "SRV_NET_NAME_VALIDATE" , SRV_NET_NAME_VALIDATE , api_srv_net_name_validate },
{ "SRV_NET_FILE_QUERY_SECDESC", SRV_NET_FILE_QUERY_SECDESC, api_srv_net_file_query_secdesc },
{ "SRV_NET_FILE_SET_SECDESC" , SRV_NET_FILE_SET_SECDESC , api_srv_net_file_set_secdesc },
{ "SRV_NET_FILE_CLOSE" , SRV_NET_FILE_CLOSE , api_srv_net_file_close }
};
void srvsvc_get_pipe_fns( struct api_struct **fns, int *n_fns )
{
*fns = api_srv_cmds;
*n_fns = sizeof(api_srv_cmds) / sizeof(struct api_struct);
}
NTSTATUS rpc_srv_init(void)
{
return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "srvsvc", "ntsvcs", api_srv_cmds,
sizeof(api_srv_cmds) / sizeof(struct api_struct));
}

File diff suppressed because it is too large Load Diff

View File

@ -131,51 +131,38 @@ static char *get_server_type_str(uint32 type)
return typestr;
}
static void display_server(char *sname, uint32 type, const char *comment)
static void display_server(const char *sname, uint32 type, const char *comment)
{
printf("\t%-15.15s%-20s %s\n", sname, get_server_type_str(type),
comment);
}
static void display_srv_info_101(SRV_INFO_101 *sv101)
static void display_srv_info_101(struct srvsvc_NetSrvInfo101 *sv101)
{
fstring name;
fstring comment;
unistr2_to_ascii(name, &sv101->uni_name, sizeof(name) - 1);
unistr2_to_ascii(comment, &sv101->uni_comment, sizeof(comment) - 1);
display_server(name, sv101->srv_type, comment);
display_server(sv101->server_name, sv101->server_type, sv101->comment);
printf("\tplatform_id :\t%d\n", sv101->platform_id);
printf("\tos version :\t%d.%d\n", sv101->ver_major,
sv101->ver_minor);
printf("\tos version :\t%d.%d\n", sv101->version_major,
sv101->version_minor);
printf("\tserver type :\t0x%x\n", sv101->srv_type);
printf("\tserver type :\t0x%x\n", sv101->server_type);
}
static void display_srv_info_102(SRV_INFO_102 *sv102)
static void display_srv_info_102(struct srvsvc_NetSrvInfo102 *sv102)
{
fstring name;
fstring comment;
fstring usr_path;
unistr2_to_ascii(name, &sv102->uni_name, sizeof(name) - 1);
unistr2_to_ascii(comment, &sv102->uni_comment, sizeof(comment) - 1);
unistr2_to_ascii(usr_path, &sv102->uni_usr_path, sizeof(usr_path) - 1);
display_server(name, sv102->srv_type, comment);
display_server(sv102->server_name, sv102->server_type,
sv102->comment);
printf("\tplatform_id :\t%d\n", sv102->platform_id);
printf("\tos version :\t%d.%d\n", sv102->ver_major,
sv102->ver_minor);
printf("\tos version :\t%d.%d\n", sv102->version_major,
sv102->version_minor);
printf("\tusers :\t%x\n", sv102->users);
printf("\tdisc, hidden :\t%x, %x\n", sv102->disc, sv102->hidden);
printf("\tannounce, delta :\t%d, %d\n", sv102->announce,
sv102->ann_delta);
sv102->anndelta);
printf("\tlicenses :\t%d\n", sv102->licenses);
printf("\tuser path :\t%s\n", usr_path);
printf("\tuser path :\t%s\n", sv102->userpath);
}
/* Server query info */
@ -184,7 +171,7 @@ static WERROR cmd_srvsvc_srv_query_info(struct rpc_pipe_client *cli,
int argc, const char **argv)
{
uint32 info_level = 101;
SRV_INFO_CTR ctr;
union srvsvc_NetSrvInfo ctr;
WERROR result;
if (argc > 2) {
@ -195,7 +182,7 @@ static WERROR cmd_srvsvc_srv_query_info(struct rpc_pipe_client *cli,
if (argc == 2)
info_level = atoi(argv[1]);
result = rpccli_srvsvc_net_srv_get_info(cli, mem_ctx, info_level,
result = rpccli_srvsvc_NetSrvGetInfo(cli, mem_ctx, NULL, info_level,
&ctr);
if (!W_ERROR_IS_OK(result)) {
@ -206,10 +193,10 @@ static WERROR cmd_srvsvc_srv_query_info(struct rpc_pipe_client *cli,
switch (info_level) {
case 101:
display_srv_info_101(&ctr.srv.sv101);
display_srv_info_101(ctr.info101);
break;
case 102:
display_srv_info_102(&ctr.srv.sv102);
display_srv_info_102(ctr.info102);
break;
default:
printf("unsupported info level %d\n", info_level);
@ -220,53 +207,34 @@ static WERROR cmd_srvsvc_srv_query_info(struct rpc_pipe_client *cli,
return result;
}
static void display_share_info_1(SRV_SHARE_INFO_1 *info1)
static void display_share_info_1(struct srvsvc_NetShareInfo1 *info1)
{
fstring netname = "", remark = "";
rpcstr_pull_unistr2_fstring(netname, &info1->info_1_str.uni_netname);
rpcstr_pull_unistr2_fstring(remark, &info1->info_1_str.uni_remark);
printf("netname: %s\n", netname);
printf("\tremark:\t%s\n", remark);
printf("netname: %s\n", info1->name);
printf("\tremark:\t%s\n", info1->comment);
}
static void display_share_info_2(SRV_SHARE_INFO_2 *info2)
static void display_share_info_2(struct srvsvc_NetShareInfo2 *info2)
{
fstring netname = "", remark = "", path = "", passwd = "";
rpcstr_pull_unistr2_fstring(netname, &info2->info_2_str.uni_netname);
rpcstr_pull_unistr2_fstring(remark, &info2->info_2_str.uni_remark);
rpcstr_pull_unistr2_fstring(path, &info2->info_2_str.uni_path);
rpcstr_pull_unistr2_fstring(passwd, &info2->info_2_str.uni_passwd);
printf("netname: %s\n", netname);
printf("\tremark:\t%s\n", remark);
printf("\tpath:\t%s\n", path);
printf("\tpassword:\t%s\n", passwd);
printf("netname: %s\n", info2->name);
printf("\tremark:\t%s\n", info2->comment);
printf("\tpath:\t%s\n", info2->path);
printf("\tpassword:\t%s\n", info2->password);
}
static void display_share_info_502(SRV_SHARE_INFO_502 *info502)
static void display_share_info_502(struct srvsvc_NetShareInfo502 *info502)
{
fstring netname = "", remark = "", path = "", passwd = "";
printf("netname: %s\n", info502->name);
printf("\tremark:\t%s\n", info502->comment);
printf("\tpath:\t%s\n", info502->path);
printf("\tpassword:\t%s\n", info502->password);
rpcstr_pull_unistr2_fstring(netname, &info502->info_502_str.uni_netname);
rpcstr_pull_unistr2_fstring(remark, &info502->info_502_str.uni_remark);
rpcstr_pull_unistr2_fstring(path, &info502->info_502_str.uni_path);
rpcstr_pull_unistr2_fstring(passwd, &info502->info_502_str.uni_passwd);
printf("netname: %s\n", netname);
printf("\tremark:\t%s\n", remark);
printf("\tpath:\t%s\n", path);
printf("\tpassword:\t%s\n", passwd);
printf("\ttype:\t0x%x\n", info502->info_502.type);
printf("\tperms:\t%d\n", info502->info_502.perms);
printf("\tmax_uses:\t%d\n", info502->info_502.max_uses);
printf("\tnum_uses:\t%d\n", info502->info_502.num_uses);
printf("\ttype:\t0x%x\n", info502->type);
printf("\tperms:\t%d\n", info502->permissions);
printf("\tmax_uses:\t%d\n", info502->max_users);
printf("\tnum_uses:\t%d\n", info502->current_users);
if (info502->info_502_str.sd)
display_sec_desc(info502->info_502_str.sd);
if (info502->sd)
display_sec_desc(info502->sd);
}
@ -275,10 +243,11 @@ static WERROR cmd_srvsvc_net_share_enum(struct rpc_pipe_client *cli,
int argc, const char **argv)
{
uint32 info_level = 2;
SRV_SHARE_INFO_CTR ctr;
union srvsvc_NetShareCtr ctr;
WERROR result;
ENUM_HND hnd;
uint32 hnd;
uint32 preferred_len = 0xffffffff, i;
uint32 numentries;
if (argc > 2) {
printf("Usage: %s [infolevel]\n", argv[0]);
@ -288,28 +257,29 @@ static WERROR cmd_srvsvc_net_share_enum(struct rpc_pipe_client *cli,
if (argc == 2)
info_level = atoi(argv[1]);
init_enum_hnd(&hnd, 0);
hnd = 0;
result = rpccli_srvsvc_net_share_enum(
cli, mem_ctx, info_level, &ctr, preferred_len, &hnd);
result = rpccli_srvsvc_NetShareEnum(
cli, mem_ctx, NULL, &info_level, &ctr, preferred_len, &numentries,
&hnd);
if (!W_ERROR_IS_OK(result) || !ctr.num_entries)
if (!W_ERROR_IS_OK(result) || !numentries)
goto done;
/* Display results */
switch (info_level) {
case 1:
for (i = 0; i < ctr.num_entries; i++)
display_share_info_1(&ctr.share.info1[i]);
for (i = 0; i < numentries; i++)
display_share_info_1(&ctr.ctr1->array[i]);
break;
case 2:
for (i = 0; i < ctr.num_entries; i++)
display_share_info_2(&ctr.share.info2[i]);
for (i = 0; i < numentries; i++)
display_share_info_2(&ctr.ctr2->array[i]);
break;
case 502:
for (i = 0; i < ctr.num_entries; i++)
display_share_info_502(&ctr.share.info502[i]);
for (i = 0; i < numentries; i++)
display_share_info_502(&ctr.ctr502->array[i]);
break;
default:
printf("unsupported info level %d\n", info_level);
@ -325,7 +295,7 @@ static WERROR cmd_srvsvc_net_share_get_info(struct rpc_pipe_client *cli,
int argc, const char **argv)
{
uint32 info_level = 502;
SRV_SHARE_INFO info;
union srvsvc_NetShareInfo info;
WERROR result;
if (argc > 3) {
@ -336,7 +306,7 @@ static WERROR cmd_srvsvc_net_share_get_info(struct rpc_pipe_client *cli,
if (argc == 3)
info_level = atoi(argv[2]);
result = rpccli_srvsvc_net_share_get_info(cli, mem_ctx, argv[1], info_level, &info);
result = rpccli_srvsvc_NetShareGetInfo(cli, mem_ctx, NULL, argv[1], info_level, &info);
if (!W_ERROR_IS_OK(result))
goto done;
@ -345,13 +315,13 @@ static WERROR cmd_srvsvc_net_share_get_info(struct rpc_pipe_client *cli,
switch (info_level) {
case 1:
display_share_info_1(&info.share.info1);
display_share_info_1(info.info1);
break;
case 2:
display_share_info_2(&info.share.info2);
display_share_info_2(info.info2);
break;
case 502:
display_share_info_502(&info.share.info502);
display_share_info_502(info.info502);
break;
default:
printf("unsupported info level %d\n", info_level);
@ -367,8 +337,9 @@ static WERROR cmd_srvsvc_net_share_set_info(struct rpc_pipe_client *cli,
int argc, const char **argv)
{
uint32 info_level = 502;
SRV_SHARE_INFO info_get;
union srvsvc_NetShareInfo info_get;
WERROR result;
uint32 parm_error;
if (argc > 3) {
printf("Usage: %s [sharename] [comment]\n", argv[0]);
@ -376,26 +347,22 @@ static WERROR cmd_srvsvc_net_share_set_info(struct rpc_pipe_client *cli,
}
/* retrieve share info */
result = rpccli_srvsvc_net_share_get_info(cli, mem_ctx, argv[1], info_level, &info_get);
result = rpccli_srvsvc_NetShareGetInfo(cli, mem_ctx, NULL, argv[1], info_level, &info_get);
if (!W_ERROR_IS_OK(result))
goto done;
info_get.switch_value = info_level;
info_get.ptr_share_ctr = 1;
init_unistr2(&(info_get.share.info502.info_502_str.uni_remark), argv[2], UNI_STR_TERMINATE);
/* set share info */
result = rpccli_srvsvc_net_share_set_info(cli, mem_ctx, argv[1], info_level, &info_get);
result = rpccli_srvsvc_NetShareSetInfo(cli, mem_ctx, NULL, argv[1], info_level, info_get, &parm_error);
if (!W_ERROR_IS_OK(result))
goto done;
/* re-retrieve share info and display */
result = rpccli_srvsvc_net_share_get_info(cli, mem_ctx, argv[1], info_level, &info_get);
result = rpccli_srvsvc_NetShareGetInfo(cli, mem_ctx, NULL, argv[1], info_level, &info_get);
if (!W_ERROR_IS_OK(result))
goto done;
display_share_info_502(&info_get.share.info502);
display_share_info_502(info_get.info502);
done:
return result;
@ -405,9 +372,9 @@ static WERROR cmd_srvsvc_net_remote_tod(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
int argc, const char **argv)
{
TIME_OF_DAY_INFO tod;
fstring srv_name_slash;
WERROR result;
struct srvsvc_NetRemoteTODInfo tod;
if (argc > 1) {
printf("Usage: %s\n", argv[0]);
@ -415,7 +382,7 @@ static WERROR cmd_srvsvc_net_remote_tod(struct rpc_pipe_client *cli,
}
fstr_sprintf(srv_name_slash, "\\\\%s", cli->cli->desthost);
result = rpccli_srvsvc_net_remote_tod(
result = rpccli_srvsvc_NetRemoteTOD(
cli, mem_ctx, srv_name_slash, &tod);
if (!W_ERROR_IS_OK(result))
@ -430,10 +397,11 @@ static WERROR cmd_srvsvc_net_file_enum(struct rpc_pipe_client *cli,
int argc, const char **argv)
{
uint32 info_level = 3;
SRV_FILE_INFO_CTR ctr;
union srvsvc_NetFileCtr ctr;
WERROR result;
ENUM_HND hnd;
uint32 hnd;
uint32 preferred_len = 0xffff;
uint32 numentries;
if (argc > 2) {
printf("Usage: %s [infolevel]\n", argv[0]);
@ -443,12 +411,12 @@ static WERROR cmd_srvsvc_net_file_enum(struct rpc_pipe_client *cli,
if (argc == 2)
info_level = atoi(argv[1]);
init_enum_hnd(&hnd, 0);
hnd = 0;
ZERO_STRUCT(ctr);
result = rpccli_srvsvc_net_file_enum(
cli, mem_ctx, info_level, NULL, &ctr, preferred_len, &hnd);
result = rpccli_srvsvc_NetFileEnum(
cli, mem_ctx, NULL, NULL, NULL, &info_level, &ctr, preferred_len, &numentries, &hnd);
if (!W_ERROR_IS_OK(result))
goto done;

View File

@ -2057,7 +2057,7 @@ NTSTATUS open_directory(connection_struct *conn,
Open a pseudo-file (no locking checks - a 'stat' open).
****************************************************************************/
NTSTATUS open_file_stat(connection_struct *conn, char *fname,
NTSTATUS open_file_stat(connection_struct *conn, const char *fname,
SMB_STRUCT_STAT *psbuf, files_struct **result)
{
files_struct *fsp = NULL;

View File

@ -5,6 +5,7 @@
Copyright (C) 2002 Jim McDonough (jmcd@us.ibm.com)
Copyright (C) 2004 Guenther Deschner (gd@samba.org)
Copyright (C) 2005 Jeremy Allison (jra@samba.org)
Copyright (C) 2006 Jelmer Vernooij (jelmer@samba.org)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -3019,7 +3020,10 @@ static NTSTATUS rpc_share_add_internals(const DOM_SID *domain_sid,
uint32 type = STYPE_DISKTREE; /* only allow disk shares to be added */
uint32 num_users=0, perms=0;
char *password=NULL; /* don't allow a share password */
uint32 level = 2;
uint32 level = 2;
uint32 parm_error;
union srvsvc_NetShareInfo info;
struct srvsvc_NetShareInfo2 info2;
if ((sharename = talloc_strdup(mem_ctx, argv[0])) == NULL) {
return NT_STATUS_NO_MEMORY;
@ -3030,10 +3034,19 @@ static NTSTATUS rpc_share_add_internals(const DOM_SID *domain_sid,
return NT_STATUS_UNSUCCESSFUL;
*path++ = '\0';
result = rpccli_srvsvc_net_share_add(pipe_hnd, mem_ctx, sharename, type,
opt_comment, perms, opt_maxusers,
num_users, path, password,
level, NULL);
info.info2 = &info2;
info2.type = type;
info2.comment = opt_comment;
info2.permissions = perms;
info2.max_users = opt_maxusers;
info2.current_users = num_users;
info2.path = path;
info2.password = password;
info2.name = sharename;
result = rpccli_srvsvc_NetShareAdd(pipe_hnd, mem_ctx, NULL, level,
info, &parm_error);
return werror_to_ntstatus(result);
}
@ -3073,7 +3086,7 @@ static NTSTATUS rpc_share_del_internals(const DOM_SID *domain_sid,
{
WERROR result;
result = rpccli_srvsvc_net_share_del(pipe_hnd, mem_ctx, argv[0]);
result = rpccli_srvsvc_NetShareDel(pipe_hnd, mem_ctx, NULL, argv[0], 0);
return W_ERROR_IS_OK(result) ? NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL;
}
@ -3101,21 +3114,16 @@ static int rpc_share_delete(int argc, const char **argv)
/**
* Formatted print of share info
*
* @param info1 pointer to SRV_SHARE_INFO_1 to format
* @param info1 pointer to struct srvsvc_NetShareInfo1 to format
**/
static void display_share_info_1(SRV_SHARE_INFO_1 *info1)
static void display_share_info_1(struct srvsvc_NetShareInfo1 *info1)
{
fstring netname = "", remark = "";
rpcstr_pull_unistr2_fstring(netname, &info1->info_1_str.uni_netname);
rpcstr_pull_unistr2_fstring(remark, &info1->info_1_str.uni_remark);
if (opt_long_list_entries) {
d_printf("%-12s %-8.8s %-50s\n",
netname, share_type[info1->info_1.type], remark);
info1->name, share_type[info1->type], info1->comment);
} else {
d_printf("%s\n", netname);
d_printf("%s\n", info1->name);
}
}
@ -3125,145 +3133,21 @@ static WERROR get_share_info(struct rpc_pipe_client *pipe_hnd,
uint32 level,
int argc,
const char **argv,
SRV_SHARE_INFO_CTR *ctr)
union srvsvc_NetShareCtr *ctr,
uint32 *numentries)
{
WERROR result;
SRV_SHARE_INFO info;
union srvsvc_NetShareInfo info;
/* no specific share requested, enumerate all */
if (argc == 0) {
uint32 hnd = 0;
ENUM_HND hnd;
uint32 preferred_len = 0xffffffff;
init_enum_hnd(&hnd, 0);
return rpccli_srvsvc_net_share_enum(pipe_hnd, mem_ctx, level, ctr,
preferred_len, &hnd);
return rpccli_srvsvc_NetShareEnum(pipe_hnd, mem_ctx, NULL, &level, ctr,
0xffffffff, numentries, &hnd);
}
/* request just one share */
result = rpccli_srvsvc_net_share_get_info(pipe_hnd, mem_ctx, argv[0], level, &info);
if (!W_ERROR_IS_OK(result))
goto done;
/* construct ctr */
ZERO_STRUCTP(ctr);
ctr->info_level = ctr->switch_value = level;
ctr->ptr_share_info = ctr->ptr_entries = 1;
ctr->num_entries = ctr->num_entries2 = 1;
switch (level) {
case 1:
{
char *s;
SRV_SHARE_INFO_1 *info1;
ctr->share.info1 = TALLOC_ARRAY(mem_ctx, SRV_SHARE_INFO_1, 1);
if (ctr->share.info1 == NULL) {
result = WERR_NOMEM;
goto done;
}
info1 = ctr->share.info1;
memset(ctr->share.info1, 0, sizeof(SRV_SHARE_INFO_1));
/* Copy pointer crap */
memcpy(&info1->info_1, &info.share.info1.info_1, sizeof(SH_INFO_1));
/* Duplicate strings */
s = unistr2_tdup(mem_ctx, &info.share.info1.info_1_str.uni_netname);
if (s)
init_unistr2(&info1->info_1_str.uni_netname, s, UNI_STR_TERMINATE);
s = unistr2_tdup(mem_ctx, &info.share.info1.info_1_str.uni_remark);
if (s)
init_unistr2(&info1->info_1_str.uni_remark, s, UNI_STR_TERMINATE);
}
case 2:
{
char *s;
SRV_SHARE_INFO_2 *info2;
ctr->share.info2 = TALLOC_ARRAY(mem_ctx, SRV_SHARE_INFO_2, 1);
if (ctr->share.info2 == NULL) {
result = WERR_NOMEM;
goto done;
}
info2 = ctr->share.info2;
memset(ctr->share.info2, 0, sizeof(SRV_SHARE_INFO_2));
/* Copy pointer crap */
memcpy(&info2->info_2, &info.share.info2.info_2, sizeof(SH_INFO_2));
/* Duplicate strings */
s = unistr2_tdup(mem_ctx, &info.share.info2.info_2_str.uni_netname);
if (s)
init_unistr2(&info2->info_2_str.uni_netname, s, UNI_STR_TERMINATE);
s = unistr2_tdup(mem_ctx, &info.share.info2.info_2_str.uni_remark);
if (s)
init_unistr2(&info2->info_2_str.uni_remark, s, UNI_STR_TERMINATE);
s = unistr2_tdup(mem_ctx, &info.share.info2.info_2_str.uni_path);
if (s)
init_unistr2(&info2->info_2_str.uni_path, s, UNI_STR_TERMINATE);
s = unistr2_tdup(mem_ctx, &info.share.info2.info_2_str.uni_passwd);
if (s)
init_unistr2(&info2->info_2_str.uni_passwd, s, UNI_STR_TERMINATE);
}
case 502:
{
char *s;
SRV_SHARE_INFO_502 *info502;
ctr->share.info502 = TALLOC_ARRAY(mem_ctx, SRV_SHARE_INFO_502, 1);
if (ctr->share.info502 == NULL) {
result = WERR_NOMEM;
goto done;
}
info502 = ctr->share.info502;
memset(ctr->share.info502, 0, sizeof(SRV_SHARE_INFO_502));
/* Copy pointer crap */
memcpy(&info502->info_502, &info.share.info502.info_502, sizeof(SH_INFO_502));
/* Duplicate strings */
s = unistr2_tdup(mem_ctx, &info.share.info502.info_502_str.uni_netname);
if (s)
init_unistr2(&info502->info_502_str.uni_netname, s, UNI_STR_TERMINATE);
s = unistr2_tdup(mem_ctx, &info.share.info502.info_502_str.uni_remark);
if (s)
init_unistr2(&info502->info_502_str.uni_remark, s, UNI_STR_TERMINATE);
s = unistr2_tdup(mem_ctx, &info.share.info502.info_502_str.uni_path);
if (s)
init_unistr2(&info502->info_502_str.uni_path, s, UNI_STR_TERMINATE);
s = unistr2_tdup(mem_ctx, &info.share.info502.info_502_str.uni_passwd);
if (s)
init_unistr2(&info502->info_502_str.uni_passwd, s, UNI_STR_TERMINATE);
info502->info_502_str.sd = dup_sec_desc(mem_ctx, info.share.info502.info_502_str.sd);
}
} /* switch */
done:
return result;
return rpccli_srvsvc_NetShareGetInfo(pipe_hnd, mem_ctx, NULL, argv[0], level, &info);
}
/**
@ -3290,11 +3174,13 @@ static NTSTATUS rpc_share_list_internals(const DOM_SID *domain_sid,
int argc,
const char **argv)
{
SRV_SHARE_INFO_CTR ctr;
union srvsvc_NetShareCtr ctr;
WERROR result;
uint32 i, level = 1;
uint32 numentries;
result = get_share_info(pipe_hnd, mem_ctx, level, argc, argv, &ctr);
result = get_share_info(pipe_hnd, mem_ctx, level, argc, argv, &ctr,
&numentries);
if (!W_ERROR_IS_OK(result))
goto done;
@ -3306,8 +3192,8 @@ static NTSTATUS rpc_share_list_internals(const DOM_SID *domain_sid,
"\nShare name Type Description\n"\
"---------- ---- -----------\n");
}
for (i = 0; i < ctr.num_entries; i++)
display_share_info_1(&ctr.share.info1[i]);
for (i = 0; i < numentries; i++)
display_share_info_1(&ctr.ctr1->array[i]);
done:
return W_ERROR_IS_OK(result) ? NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL;
}
@ -3336,7 +3222,7 @@ static BOOL check_share_availability(struct cli_state *cli, const char *netname)
return True;
}
static BOOL check_share_sanity(struct cli_state *cli, fstring netname, uint32 type)
static BOOL check_share_sanity(struct cli_state *cli, const char *netname, uint32 type)
{
/* only support disk shares */
if (! ( type == STYPE_DISKTREE || type == (STYPE_DISKTREE | STYPE_HIDDEN)) ) {
@ -3384,15 +3270,15 @@ static NTSTATUS rpc_share_migrate_shares_internals(const DOM_SID *domain_sid,
{
WERROR result;
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
SRV_SHARE_INFO_CTR ctr_src;
uint32 type = STYPE_DISKTREE; /* only allow disk shares to be added */
char *password = NULL; /* don't allow a share password */
union srvsvc_NetShareCtr ctr_src;
uint32 i;
struct rpc_pipe_client *srvsvc_pipe = NULL;
struct cli_state *cli_dst = NULL;
uint32 level = 502; /* includes secdesc */
uint32 numentries;
result = get_share_info(pipe_hnd, mem_ctx, level, argc, argv, &ctr_src);
result = get_share_info(pipe_hnd, mem_ctx, level, argc, argv, &ctr_src,
&numentries);
if (!W_ERROR_IS_OK(result))
goto done;
@ -3402,36 +3288,32 @@ static NTSTATUS rpc_share_migrate_shares_internals(const DOM_SID *domain_sid,
return nt_status;
for (i = 0; i < ctr_src.num_entries; i++) {
for (i = 0; i < numentries; i++) {
uint32 parm_error;
union srvsvc_NetShareInfo info;
fstring netname = "", remark = "", path = "";
/* reset error-code */
nt_status = NT_STATUS_UNSUCCESSFUL;
rpcstr_pull_unistr2_fstring(
netname, &ctr_src.share.info502[i].info_502_str.uni_netname);
rpcstr_pull_unistr2_fstring(
remark, &ctr_src.share.info502[i].info_502_str.uni_remark);
rpcstr_pull_unistr2_fstring(
path, &ctr_src.share.info502[i].info_502_str.uni_path);
if (!check_share_sanity(cli, netname, ctr_src.share.info502[i].info_502.type))
if (!check_share_sanity(cli, ctr_src.ctr502->array[i].name,
ctr_src.ctr502->array[i].type))
continue;
/* finally add the share on the dst server */
printf("migrating: [%s], path: %s, comment: %s, without share-ACLs\n",
netname, path, remark);
ctr_src.ctr502->array[i].name,
ctr_src.ctr502->array[i].path,
ctr_src.ctr502->array[i].comment);
result = rpccli_srvsvc_net_share_add(srvsvc_pipe, mem_ctx, netname, type, remark,
ctr_src.share.info502[i].info_502.perms,
ctr_src.share.info502[i].info_502.max_uses,
ctr_src.share.info502[i].info_502.num_uses,
path, password, level,
NULL);
info.info502 = &ctr_src.ctr502->array[i];
result = rpccli_srvsvc_NetShareAdd(srvsvc_pipe, mem_ctx, NULL,
502, info, &parm_error);
if (W_ERROR_V(result) == W_ERROR_V(WERR_ALREADY_EXISTS)) {
printf(" [%s] does already exist\n", netname);
printf(" [%s] does already exist\n", ctr_src.ctr502->array[i].name);
continue;
}
@ -3660,7 +3542,7 @@ static NTSTATUS rpc_share_migrate_files_internals(const DOM_SID *domain_sid,
{
WERROR result;
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
SRV_SHARE_INFO_CTR ctr_src;
union srvsvc_NetShareCtr ctr_src;
uint32 i;
uint32 level = 502;
struct copy_clistate cp_clistate;
@ -3668,27 +3550,24 @@ static NTSTATUS rpc_share_migrate_files_internals(const DOM_SID *domain_sid,
BOOL got_dst_share = False;
pstring mask = "\\*";
char *dst = NULL;
uint32 numentries;
dst = SMB_STRDUP(opt_destination?opt_destination:"127.0.0.1");
result = get_share_info(pipe_hnd, mem_ctx, level, argc, argv, &ctr_src);
result = get_share_info(pipe_hnd, mem_ctx, level, argc, argv, &ctr_src,
&numentries);
if (!W_ERROR_IS_OK(result))
goto done;
for (i = 0; i < ctr_src.num_entries; i++) {
fstring netname = "";
rpcstr_pull_unistr2_fstring(
netname, &ctr_src.share.info502[i].info_502_str.uni_netname);
if (!check_share_sanity(cli, netname, ctr_src.share.info502[i].info_502.type))
for (i = 0; i < numentries; i++) {
if (!check_share_sanity(cli, ctr_src.ctr502->array[i].name,
ctr_src.ctr502->array[i].type))
continue;
/* one might not want to mirror whole discs :) */
if (strequal(netname, "print$") || netname[1] == '$') {
d_printf("skipping [%s]: builtin/hidden share\n", netname);
if (strequal(ctr_src.ctr502->array[i].name, "print$") || ctr_src.ctr502->array[i].name[1] == '$') {
d_printf("skipping [%s]: builtin/hidden share\n", ctr_src.ctr502->array[i].name);
continue;
}
@ -3702,7 +3581,7 @@ static NTSTATUS rpc_share_migrate_files_internals(const DOM_SID *domain_sid,
break;
}
printf(" [%s] files and directories %s ACLs, %s DOS Attributes %s\n",
netname,
ctr_src.ctr502->array[i].name,
opt_acls ? "including" : "without",
opt_attrs ? "including" : "without",
opt_timestamps ? "(preserving timestamps)" : "");
@ -3716,7 +3595,7 @@ static NTSTATUS rpc_share_migrate_files_internals(const DOM_SID *domain_sid,
/* open share source */
nt_status = connect_to_service(&cp_clistate.cli_share_src,
&cli->dest_ip, cli->desthost,
netname, "A:");
ctr_src.ctr502->array[i].name, "A:");
if (!NT_STATUS_IS_OK(nt_status))
goto done;
@ -3725,21 +3604,22 @@ static NTSTATUS rpc_share_migrate_files_internals(const DOM_SID *domain_sid,
if (net_mode_share == NET_MODE_SHARE_MIGRATE) {
/* open share destination */
nt_status = connect_to_service(&cp_clistate.cli_share_dst,
NULL, dst, netname, "A:");
NULL, dst, ctr_src.ctr502->array[i].name, "A:");
if (!NT_STATUS_IS_OK(nt_status))
goto done;
got_dst_share = True;
}
if (!copy_top_level_perms(&cp_clistate, netname)) {
d_fprintf(stderr, "Could not handle the top level directory permissions for the share: %s\n", netname);
if (!copy_top_level_perms(&cp_clistate, ctr_src.ctr502->array[i].name)) {
d_fprintf(stderr, "Could not handle the top level directory permissions for the share: %s\n", ctr_src.ctr502->array[i].name);
nt_status = NT_STATUS_UNSUCCESSFUL;
goto done;
}
if (!sync_files(&cp_clistate, mask)) {
d_fprintf(stderr, "could not handle files for share: %s\n", netname);
d_fprintf(stderr, "could not handle files for share: %s\n",
ctr_src.ctr502->array[i].name);
nt_status = NT_STATUS_UNSUCCESSFUL;
goto done;
}
@ -3798,14 +3678,17 @@ static NTSTATUS rpc_share_migrate_security_internals(const DOM_SID *domain_sid,
{
WERROR result;
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
SRV_SHARE_INFO_CTR ctr_src;
SRV_SHARE_INFO info;
union srvsvc_NetShareCtr ctr_src;
union srvsvc_NetShareInfo info;
uint32 i;
struct rpc_pipe_client *srvsvc_pipe = NULL;
struct cli_state *cli_dst = NULL;
uint32 level = 502; /* includes secdesc */
uint32 numentries;
uint32 parm_error;
result = get_share_info(pipe_hnd, mem_ctx, level, argc, argv, &ctr_src);
result = get_share_info(pipe_hnd, mem_ctx, level, argc, argv, &ctr_src,
&numentries);
if (!W_ERROR_IS_OK(result))
goto done;
@ -3816,39 +3699,28 @@ static NTSTATUS rpc_share_migrate_security_internals(const DOM_SID *domain_sid,
return nt_status;
for (i = 0; i < ctr_src.num_entries; i++) {
fstring netname = "", remark = "", path = "";
for (i = 0; i < numentries; i++) {
/* reset error-code */
nt_status = NT_STATUS_UNSUCCESSFUL;
rpcstr_pull_unistr2_fstring(
netname, &ctr_src.share.info502[i].info_502_str.uni_netname);
rpcstr_pull_unistr2_fstring(
remark, &ctr_src.share.info502[i].info_502_str.uni_remark);
rpcstr_pull_unistr2_fstring(
path, &ctr_src.share.info502[i].info_502_str.uni_path);
if (!check_share_sanity(cli, netname, ctr_src.share.info502[i].info_502.type))
if (!check_share_sanity(cli, ctr_src.ctr502->array[i].name, ctr_src.ctr502->array[i].type))
continue;
printf("migrating: [%s], path: %s, comment: %s, including share-ACLs\n",
netname, path, remark);
ctr_src.ctr502->array[i].name,
ctr_src.ctr502->array[i].path,
ctr_src.ctr502->array[i].comment);
if (opt_verbose)
display_sec_desc(ctr_src.share.info502[i].info_502_str.sd);
display_sec_desc(ctr_src.ctr502->array[i].sd);
/* init info */
ZERO_STRUCT(info);
info.switch_value = level;
info.ptr_share_ctr = 1;
/* FIXME: shouldn't we be able to just set the security descriptor ? */
info.share.info502 = ctr_src.share.info502[i];
/* finally modify the share on the dst server */
result = rpccli_srvsvc_net_share_set_info(srvsvc_pipe, mem_ctx, netname, level, &info);
result = rpccli_srvsvc_NetShareSetInfo(srvsvc_pipe, mem_ctx, NULL,
argv[0], level, info,
&parm_error);
if (!W_ERROR_IS_OK(result)) {
printf("cannot set share-acl: %s\n", dos_errstr(result));
@ -4481,11 +4353,11 @@ static void show_userlist(struct rpc_pipe_client *pipe_hnd,
SEC_DESC *root_sd = NULL;
struct cli_state *cli = pipe_hnd->cli;
int i;
SRV_SHARE_INFO info;
union srvsvc_NetShareInfo info;
WERROR result;
uint16 cnum;
result = rpccli_srvsvc_net_share_get_info(pipe_hnd, mem_ctx, netname,
result = rpccli_srvsvc_NetShareGetInfo(pipe_hnd, mem_ctx, NULL, netname,
502, &info);
if (!W_ERROR_IS_OK(result)) {
@ -4494,7 +4366,7 @@ static void show_userlist(struct rpc_pipe_client *pipe_hnd,
return;
}
share_sd = info.share.info502.info_502_str.sd;
share_sd = info.info502->sd;
if (share_sd == NULL) {
DEBUG(1, ("Got no secdesc for share %s\n",
netname));
@ -4608,7 +4480,7 @@ static NTSTATUS rpc_share_allowedusers_internals(const DOM_SID *domain_sid,
{
int ret;
BOOL r;
ENUM_HND hnd;
uint32 hnd;
uint32 i;
FILE *f;
@ -4646,8 +4518,7 @@ static NTSTATUS rpc_share_allowedusers_internals(const DOM_SID *domain_sid,
for (i=0; i<num_tokens; i++)
collect_alias_memberships(&tokens[i].token);
init_enum_hnd(&hnd, 0);
hnd = 0;
share_list.num_shares = 0;
share_list.shares = NULL;
@ -4778,7 +4649,10 @@ static NTSTATUS rpc_sh_share_add(TALLOC_CTX *mem_ctx,
struct rpc_pipe_client *pipe_hnd,
int argc, const char **argv)
{
union srvsvc_NetShareInfo info;
struct srvsvc_NetShareInfo2 info2;
WERROR result;
uint32 parm_error;
if ((argc < 2) || (argc > 3)) {
d_fprintf(stderr, "usage: %s <share> <path> [comment]\n",
@ -4786,10 +4660,13 @@ static NTSTATUS rpc_sh_share_add(TALLOC_CTX *mem_ctx,
return NT_STATUS_INVALID_PARAMETER;
}
result = rpccli_srvsvc_net_share_add(
pipe_hnd, mem_ctx, argv[0], STYPE_DISKTREE,
(argc == 3) ? argv[2] : "",
0, 0, 0, argv[1], NULL, 2, NULL);
info.info2 = &info2;
info2.name = argv[0];
info2.type = STYPE_DISKTREE;
info2.comment = (argc == 3) ? argv[2] : "";
result = rpccli_srvsvc_NetShareAdd(
pipe_hnd, mem_ctx, NULL, 2, info, &parm_error);
return werror_to_ntstatus(result);
}
@ -4806,7 +4683,7 @@ static NTSTATUS rpc_sh_share_delete(TALLOC_CTX *mem_ctx,
return NT_STATUS_INVALID_PARAMETER;
}
result = rpccli_srvsvc_net_share_del(pipe_hnd, mem_ctx, argv[0]);
result = rpccli_srvsvc_NetShareDel(pipe_hnd, mem_ctx, NULL, argv[0], 0);
return werror_to_ntstatus(result);
}
@ -4815,8 +4692,7 @@ static NTSTATUS rpc_sh_share_info(TALLOC_CTX *mem_ctx,
struct rpc_pipe_client *pipe_hnd,
int argc, const char **argv)
{
SRV_SHARE_INFO info;
SRV_SHARE_INFO_2 *info2 = &info.share.info2;
union srvsvc_NetShareInfo info;
WERROR result;
if (argc != 1) {
@ -4824,25 +4700,16 @@ static NTSTATUS rpc_sh_share_info(TALLOC_CTX *mem_ctx,
return NT_STATUS_INVALID_PARAMETER;
}
result = rpccli_srvsvc_net_share_get_info(
pipe_hnd, mem_ctx, argv[0], 2, &info);
result = rpccli_srvsvc_NetShareGetInfo(
pipe_hnd, mem_ctx, NULL, argv[0], 2, &info);
if (!W_ERROR_IS_OK(result)) {
goto done;
}
d_printf("Name: %s\n",
rpcstr_pull_unistr2_talloc(mem_ctx,
&info2->info_2_str.uni_netname));
d_printf("Comment: %s\n",
rpcstr_pull_unistr2_talloc(mem_ctx,
&info2->info_2_str.uni_remark));
d_printf("Path: %s\n",
rpcstr_pull_unistr2_talloc(mem_ctx,
&info2->info_2_str.uni_path));
d_printf("Password: %s\n",
rpcstr_pull_unistr2_talloc(mem_ctx,
&info2->info_2_str.uni_passwd));
d_printf("Name: %s\n", info.info2->name);
d_printf("Comment: %s\n", info.info2->comment);
d_printf("Path: %s\n", info.info2->path);
d_printf("Password: %s\n", info.info2->password);
done:
return werror_to_ntstatus(result);
@ -4902,7 +4769,7 @@ static NTSTATUS rpc_file_close_internals(const DOM_SID *domain_sid,
const char **argv)
{
WERROR result;
result = rpccli_srvsvc_net_file_close(pipe_hnd, mem_ctx, atoi(argv[0]));
result = rpccli_srvsvc_NetFileClose(pipe_hnd, mem_ctx, NULL, atoi(argv[0]));
return W_ERROR_IS_OK(result) ? NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL;
}
@ -4934,15 +4801,10 @@ static int rpc_file_close(int argc, const char **argv)
* @param str3 strings for FILE_INFO_3
**/
static void display_file_info_3( FILE_INFO_3 *info3 )
static void display_file_info_3( struct srvsvc_NetFileInfo3 *info3 )
{
fstring user = "", path = "";
rpcstr_pull_unistr2_fstring(user, info3->user);
rpcstr_pull_unistr2_fstring(path, info3->path);
d_printf("%-7.1d %-20.20s 0x%-4.2x %-6.1d %s\n",
info3->id, user, info3->perms, info3->num_locks, path);
info3->fid, info3->user, info3->permissions, info3->num_locks, info3->path);
}
/**
@ -4969,20 +4831,22 @@ static NTSTATUS rpc_file_list_internals(const DOM_SID *domain_sid,
int argc,
const char **argv)
{
SRV_FILE_INFO_CTR ctr;
union srvsvc_NetFileCtr ctr;
WERROR result;
ENUM_HND hnd;
uint32 hnd;
uint32 preferred_len = 0xffffffff, i;
const char *username=NULL;
uint32 level = 3;
uint32 numentries;
init_enum_hnd(&hnd, 0);
hnd = 0;
/* if argc > 0, must be user command */
if (argc > 0)
username = smb_xstrdup(argv[0]);
result = rpccli_srvsvc_net_file_enum(pipe_hnd,
mem_ctx, 3, username, &ctr, preferred_len, &hnd);
result = rpccli_srvsvc_NetFileEnum(pipe_hnd,
mem_ctx, NULL, NULL, username, &level, &ctr, preferred_len, &numentries, &hnd);
if (!W_ERROR_IS_OK(result))
goto done;
@ -4993,8 +4857,8 @@ static NTSTATUS rpc_file_list_internals(const DOM_SID *domain_sid,
"\nEnumerating open files on remote server:\n\n"\
"\nFileId Opened by Perms Locks Path"\
"\n------ --------- ----- ----- ---- \n");
for (i = 0; i < ctr.num_entries; i++)
display_file_info_3(&ctr.file.info3[i]);
for (i = 0; i < numentries; i++)
display_file_info_3(&ctr.ctr3->array[i]);
done:
return W_ERROR_IS_OK(result) ? NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL;
}

View File

@ -134,10 +134,12 @@ static BOOL get_rpc_shares(struct cli_state *cli,
NTSTATUS status;
struct rpc_pipe_client *pipe_hnd;
TALLOC_CTX *mem_ctx;
ENUM_HND enum_hnd;
uint32 enum_hnd;
WERROR werr;
SRV_SHARE_INFO_CTR ctr;
union srvsvc_NetShareCtr ctr;
uint32 numentries;
int i;
uint32 info_level = 1;
mem_ctx = talloc_new(NULL);
if (mem_ctx == NULL) {
@ -145,8 +147,7 @@ static BOOL get_rpc_shares(struct cli_state *cli,
return False;
}
init_enum_hnd(&enum_hnd, 0);
enum_hnd = 0;
pipe_hnd = cli_rpc_pipe_open_noauth(cli, PI_SRVSVC, &status);
if (pipe_hnd == NULL) {
@ -156,8 +157,8 @@ static BOOL get_rpc_shares(struct cli_state *cli,
return False;
}
werr = rpccli_srvsvc_net_share_enum(pipe_hnd, mem_ctx, 1, &ctr,
0xffffffff, &enum_hnd);
werr = rpccli_srvsvc_NetShareEnum(pipe_hnd, mem_ctx, NULL, &info_level, &ctr,
0xffffffff, &numentries, &enum_hnd);
if (!W_ERROR_IS_OK(werr)) {
TALLOC_FREE(mem_ctx);
@ -165,14 +166,9 @@ static BOOL get_rpc_shares(struct cli_state *cli,
return False;
}
for (i=0; i<ctr.num_entries; i++) {
SRV_SHARE_INFO_1 *info = &ctr.share.info1[i];
char *name, *comment;
name = rpcstr_pull_unistr2_talloc(
mem_ctx, &info->info_1_str.uni_netname);
comment = rpcstr_pull_unistr2_talloc(
mem_ctx, &info->info_1_str.uni_remark);
fn(name, info->info_1.type, comment, state);
for (i=0; i<numentries; i++) {
fn(ctr.ctr1->array[i].name, ctr.ctr1->array[i].type,
ctr.ctr1->array[i].comment, state);
}
TALLOC_FREE(mem_ctx);