diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2006-09-21 23:57:32 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:00:59 -0500 |
commit | 7ba2554d88a187ca1f4f40014363fdf9de2223a0 (patch) | |
tree | b2c64360d1f0dcd5ba593b666b89bd44d8581b86 /source3 | |
parent | 8ffe6c8a8d0c3315393506feabbbba5d503666e8 (diff) | |
download | samba-7ba2554d88a187ca1f4f40014363fdf9de2223a0.tar.gz samba-7ba2554d88a187ca1f4f40014363fdf9de2223a0.tar.bz2 samba-7ba2554d88a187ca1f4f40014363fdf9de2223a0.zip |
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 used to be commit ef10672399c4b82700dc431b4d93431ffdd42d98)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/Makefile.in | 30 | ||||
-rw-r--r-- | source3/client/client.c | 26 | ||||
-rw-r--r-- | source3/configure.in | 6 | ||||
-rw-r--r-- | source3/include/includes.h | 2 | ||||
-rw-r--r-- | source3/include/rpc_client.h | 2 | ||||
-rw-r--r-- | source3/include/rpc_misc.h | 5 | ||||
-rw-r--r-- | source3/include/rpc_srvsvc.h | 884 | ||||
-rw-r--r-- | source3/include/smb.h | 6 | ||||
-rw-r--r-- | source3/libsmb/libsmbclient.c | 35 | ||||
-rw-r--r-- | source3/rpc_client/cli_srvsvc.c | 613 | ||||
-rw-r--r-- | source3/rpc_parse/parse_misc.c | 47 | ||||
-rw-r--r-- | source3/rpc_parse/parse_srv.c | 3557 | ||||
-rw-r--r-- | source3/rpc_server/srv_echo_nt.c | 1 | ||||
-rw-r--r-- | source3/rpc_server/srv_srvsvc.c | 621 | ||||
-rw-r--r-- | source3/rpc_server/srv_srvsvc_nt.c | 1295 | ||||
-rw-r--r-- | source3/rpcclient/cmd_srvsvc.c | 172 | ||||
-rw-r--r-- | source3/smbd/open.c | 2 | ||||
-rw-r--r-- | source3/utils/net_rpc.c | 380 | ||||
-rw-r--r-- | source3/utils/smbtree.c | 24 |
19 files changed, 916 insertions, 6792 deletions
diff --git a/source3/Makefile.in b/source3/Makefile.in index 3fa8d30023..ddb1c2a864 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -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)" \ diff --git a/source3/client/client.c b/source3/client/client.c index d5dd93ac19..a8708a001e 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -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); diff --git a/source3/configure.in b/source3/configure.in index 54063d5fac..91796d87af 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -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) diff --git a/source3/include/includes.h b/source3/include/includes.h index 1dbf92f036..16056a56a1 100644 --- a/source3/include/includes.h +++ b/source3/include/includes.h @@ -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" diff --git a/source3/include/rpc_client.h b/source3/include/rpc_client.h index ee66682df1..72737eafaf 100644 --- a/source3/include/rpc_client.h +++ b/source3/include/rpc_client.h @@ -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" diff --git a/source3/include/rpc_misc.h b/source3/include/rpc_misc.h index 91e0115b69..62bef2cb38 100644 --- a/source3/include/rpc_misc.h +++ b/source3/include/rpc_misc.h @@ -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" :\ diff --git a/source3/include/rpc_srvsvc.h b/source3/include/rpc_srvsvc.h deleted file mode 100644 index 62acce5805..0000000000 --- a/source3/include/rpc_srvsvc.h +++ /dev/null @@ -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 */ diff --git a/source3/include/smb.h b/source3/include/smb.h index 700dbcdf85..765e153b37 100644 --- a/source3/include/smb.h +++ b/source3/include/smb.h @@ -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 diff --git a/source3/libsmb/libsmbclient.c b/source3/libsmb/libsmbclient.c index 15a1ad3055..2af72d670f 100644 --- a/source3/libsmb/libsmbclient.c +++ b/source3/libsmb/libsmbclient.c @@ -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: diff --git a/source3/rpc_client/cli_srvsvc.c b/source3/rpc_client/cli_srvsvc.c deleted file mode 100644 index 7b4818b4b0..0000000000 --- a/source3/rpc_client/cli_srvsvc.c +++ /dev/null @@ -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; -} diff --git a/source3/rpc_parse/parse_misc.c b/source3/rpc_parse/parse_misc.c index 401251286c..efc5274f45 100644 --- a/source3/rpc_parse/parse_misc.c +++ b/source3/rpc_parse/parse_misc.c @@ -152,53 +152,6 @@ BOOL smb_io_nttime(const char *desc, prs_struct *ps, int depth, NTTIME *nttime) } /******************************************************************* - 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. ********************************************************************/ diff --git a/source3/rpc_parse/parse_srv.c b/source3/rpc_parse/parse_srv.c deleted file mode 100644 index 5123d1c2cc..0000000000 --- a/source3/rpc_parse/parse_srv.c +++ /dev/null @@ -1,3557 +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 1999, - * Copyright (C) Nigel Williams 2001, - * Copyright (C) Jim McDonough (jmcd@us.ibm.com) 2002. - * 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" - -#undef DBGC_CLASS -#define DBGC_CLASS DBGC_RPC_PARSE - -/******************************************************************* - Inits a SH_INFO_0_STR structure -********************************************************************/ - -void init_srv_share_info0_str(SH_INFO_0_STR *sh0, const char *net_name) -{ - DEBUG(5,("init_srv_share_info0_str\n")); - - init_unistr2(&sh0->uni_netname, net_name, UNI_STR_TERMINATE); -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_share_info0_str(const char *desc, SH_INFO_0_STR *sh0, prs_struct *ps, int depth) -{ - if (sh0 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_share_info0_str"); - depth++; - - if(!prs_align(ps)) - return False; - if(sh0->ptrs->ptr_netname) - if(!smb_io_unistr2("", &sh0->uni_netname, True, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - makes a SH_INFO_0 structure -********************************************************************/ - -void init_srv_share_info0(SH_INFO_0 *sh0, const char *net_name) -{ - DEBUG(5,("init_srv_share_info0: %s\n", net_name)); - - sh0->ptr_netname = (net_name != NULL) ? 1 : 0; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_share_info0(const char *desc, SH_INFO_0 *sh0, prs_struct *ps, int depth) -{ - if (sh0 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_share_info0"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_netname", ps, depth, &sh0->ptr_netname)) - return False; - - return True; -} - -/******************************************************************* - Inits a SH_INFO_1_STR structure -********************************************************************/ - -void init_srv_share_info1_str(SH_INFO_1_STR *sh1, const char *net_name, const char *remark) -{ - DEBUG(5,("init_srv_share_info1_str\n")); - - init_unistr2(&sh1->uni_netname, net_name, UNI_STR_TERMINATE); - init_unistr2(&sh1->uni_remark, remark, UNI_STR_TERMINATE); -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_share_info1_str(const char *desc, SH_INFO_1_STR *sh1, prs_struct *ps, int depth) -{ - if (sh1 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_share_info1_str"); - depth++; - - if(!prs_align(ps)) - return False; - - if(sh1->ptrs->ptr_netname) - if(!smb_io_unistr2("", &sh1->uni_netname, True, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(sh1->ptrs->ptr_remark) - if(!smb_io_unistr2("", &sh1->uni_remark, True, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - makes a SH_INFO_1 structure -********************************************************************/ - -void init_srv_share_info1(SH_INFO_1 *sh1, const char *net_name, uint32 type, const char *remark) -{ - DEBUG(5,("init_srv_share_info1: %s %8x %s\n", net_name, type, remark)); - - sh1->ptr_netname = (net_name != NULL) ? 1 : 0; - sh1->type = type; - sh1->ptr_remark = (remark != NULL) ? 1 : 0; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_share_info1(const char *desc, SH_INFO_1 *sh1, prs_struct *ps, int depth) -{ - if (sh1 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_share_info1"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_netname", ps, depth, &sh1->ptr_netname)) - return False; - if(!prs_uint32("type ", ps, depth, &sh1->type)) - return False; - if(!prs_uint32("ptr_remark ", ps, depth, &sh1->ptr_remark)) - return False; - - return True; -} - -/******************************************************************* - Inits a SH_INFO_2_STR structure -********************************************************************/ - -void init_srv_share_info2_str(SH_INFO_2_STR *sh2, - const char *net_name, const char *remark, - const char *path, const char *passwd) -{ - DEBUG(5,("init_srv_share_info2_str\n")); - - init_unistr2(&sh2->uni_netname, net_name, UNI_STR_TERMINATE); - init_unistr2(&sh2->uni_remark, remark, UNI_STR_TERMINATE); - init_unistr2(&sh2->uni_path, path, UNI_STR_TERMINATE); - init_unistr2(&sh2->uni_passwd, passwd, UNI_STR_TERMINATE); -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_share_info2_str(const char *desc, SH_INFO_2 *sh, SH_INFO_2_STR *sh2, prs_struct *ps, int depth) -{ - if (sh2 == NULL) - return False; - - if (UNMARSHALLING(ps)) - ZERO_STRUCTP(sh2); - - prs_debug(ps, depth, desc, "srv_io_share_info2_str"); - depth++; - - if(!prs_align(ps)) - return False; - - if (sh->ptr_netname) - if(!smb_io_unistr2("", &sh2->uni_netname, True, ps, depth)) - return False; - - if (sh->ptr_remark) - if(!smb_io_unistr2("", &sh2->uni_remark, True, ps, depth)) - return False; - - if (sh->ptr_netname) - if(!smb_io_unistr2("", &sh2->uni_path, True, ps, depth)) - return False; - - if (sh->ptr_passwd) - if(!smb_io_unistr2("", &sh2->uni_passwd, True, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Inits a SH_INFO_2 structure -********************************************************************/ - -void init_srv_share_info2(SH_INFO_2 *sh2, - const char *net_name, uint32 type, const char *remark, - uint32 perms, uint32 max_uses, uint32 num_uses, - const char *path, const char *passwd) -{ - DEBUG(5,("init_srv_share_info2: %s %8x %s\n", net_name, type, remark)); - - sh2->ptr_netname = (net_name != NULL) ? 1 : 0; - sh2->type = type; - sh2->ptr_remark = (remark != NULL) ? 1 : 0; - sh2->perms = perms; - sh2->max_uses = max_uses; - sh2->num_uses = num_uses; - sh2->ptr_path = (path != NULL) ? 1 : 0; - sh2->ptr_passwd = (passwd != NULL) ? 1 : 0; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_share_info2(const char *desc, SH_INFO_2 *sh2, prs_struct *ps, int depth) -{ - if (sh2 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_share_info2"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_netname", ps, depth, &sh2->ptr_netname)) - return False; - if(!prs_uint32("type ", ps, depth, &sh2->type)) - return False; - if(!prs_uint32("ptr_remark ", ps, depth, &sh2->ptr_remark)) - return False; - if(!prs_uint32("perms ", ps, depth, &sh2->perms)) - return False; - if(!prs_uint32("max_uses ", ps, depth, &sh2->max_uses)) - return False; - if(!prs_uint32("num_uses ", ps, depth, &sh2->num_uses)) - return False; - if(!prs_uint32("ptr_path ", ps, depth, &sh2->ptr_path)) - return False; - if(!prs_uint32("ptr_passwd ", ps, depth, &sh2->ptr_passwd)) - return False; - - return True; -} - -/******************************************************************* - Inits a SH_INFO_501_STR structure -********************************************************************/ - -void init_srv_share_info501_str(SH_INFO_501_STR *sh501, - const char *net_name, const char *remark) -{ - DEBUG(5,("init_srv_share_info501_str\n")); - - init_unistr2(&sh501->uni_netname, net_name, UNI_STR_TERMINATE); - init_unistr2(&sh501->uni_remark, remark, UNI_STR_TERMINATE); -} - -/******************************************************************* - Inits a SH_INFO_2 structure -*******************************************************************/ - -void init_srv_share_info501(SH_INFO_501 *sh501, const char *net_name, uint32 type, const char *remark, uint32 csc_policy) -{ - DEBUG(5,("init_srv_share_info501: %s %8x %s %08x\n", net_name, type, - remark, csc_policy)); - - ZERO_STRUCTP(sh501); - - sh501->ptr_netname = (net_name != NULL) ? 1 : 0; - sh501->type = type; - sh501->ptr_remark = (remark != NULL) ? 1 : 0; - sh501->csc_policy = csc_policy; -} - -/******************************************************************* - Reads of writes a structure. -*******************************************************************/ - -static BOOL srv_io_share_info501(const char *desc, SH_INFO_501 *sh501, prs_struct *ps, int depth) -{ - if (sh501 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_share_info501"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("ptr_netname", ps, depth, &sh501->ptr_netname)) - return False; - if (!prs_uint32("type ", ps, depth, &sh501->type)) - return False; - if (!prs_uint32("ptr_remark ", ps, depth, &sh501->ptr_remark)) - return False; - if (!prs_uint32("csc_policy ", ps, depth, &sh501->csc_policy)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_share_info501_str(const char *desc, SH_INFO_501_STR *sh501, prs_struct *ps, int depth) -{ - if (sh501 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_share_info501_str"); - depth++; - - if(!prs_align(ps)) - return False; - if(!smb_io_unistr2("", &sh501->uni_netname, True, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - if(!smb_io_unistr2("", &sh501->uni_remark, True, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Inits a SH_INFO_502 structure -********************************************************************/ - -void init_srv_share_info502(SH_INFO_502 *sh502, - const char *net_name, uint32 type, const char *remark, - uint32 perms, uint32 max_uses, uint32 num_uses, - const char *path, const char *passwd, SEC_DESC *psd, size_t sd_size) -{ - DEBUG(5,("init_srv_share_info502: %s %8x %s\n", net_name, type, remark)); - - ZERO_STRUCTP(sh502); - - sh502->ptr_netname = (net_name != NULL) ? 1 : 0; - sh502->type = type; - sh502->ptr_remark = (remark != NULL) ? 1 : 0; - sh502->perms = perms; - sh502->max_uses = max_uses; - sh502->num_uses = num_uses; - sh502->ptr_path = (path != NULL) ? 1 : 0; - sh502->ptr_passwd = (passwd != NULL) ? 1 : 0; - sh502->reserved = 0; /* actual size within rpc */ - sh502->sd_size = (uint32)sd_size; - sh502->ptr_sd = (psd != NULL) ? 1 : 0; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_share_info502(const char *desc, SH_INFO_502 *sh502, prs_struct *ps, int depth) -{ - if (sh502 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_share_info502"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_netname", ps, depth, &sh502->ptr_netname)) - return False; - if(!prs_uint32("type ", ps, depth, &sh502->type)) - return False; - if(!prs_uint32("ptr_remark ", ps, depth, &sh502->ptr_remark)) - return False; - if(!prs_uint32("perms ", ps, depth, &sh502->perms)) - return False; - if(!prs_uint32("max_uses ", ps, depth, &sh502->max_uses)) - return False; - if(!prs_uint32("num_uses ", ps, depth, &sh502->num_uses)) - return False; - if(!prs_uint32("ptr_path ", ps, depth, &sh502->ptr_path)) - return False; - if(!prs_uint32("ptr_passwd ", ps, depth, &sh502->ptr_passwd)) - return False; - if(!prs_uint32_pre("reserved ", ps, depth, &sh502->reserved, &sh502->reserved_offset)) - return False; - if(!prs_uint32("ptr_sd ", ps, depth, &sh502->ptr_sd)) - return False; - - return True; -} - -/******************************************************************* - Inits a SH_INFO_502_STR structure -********************************************************************/ - -void init_srv_share_info502_str(SH_INFO_502_STR *sh502str, - const char *net_name, const char *remark, - const char *path, const char *passwd, SEC_DESC *psd, size_t sd_size) -{ - DEBUG(5,("init_srv_share_info502_str\n")); - - init_unistr2(&sh502str->uni_netname, net_name, UNI_STR_TERMINATE); - init_unistr2(&sh502str->uni_remark, remark, UNI_STR_TERMINATE); - init_unistr2(&sh502str->uni_path, path, UNI_STR_TERMINATE); - init_unistr2(&sh502str->uni_passwd, passwd, UNI_STR_TERMINATE); - sh502str->sd = psd; - sh502str->reserved = 0; - sh502str->sd_size = sd_size; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_share_info502_str(const char *desc, SH_INFO_502_STR *sh502, prs_struct *ps, int depth) -{ - if (sh502 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_share_info502_str"); - depth++; - - if(!prs_align(ps)) - return False; - - if(sh502->ptrs->ptr_netname) { - if(!smb_io_unistr2("", &sh502->uni_netname, True, ps, depth)) - return False; - } - - if(!prs_align(ps)) - return False; - - if(sh502->ptrs->ptr_remark) { - if(!smb_io_unistr2("", &sh502->uni_remark, True, ps, depth)) - return False; - } - - if(!prs_align(ps)) - return False; - - if(sh502->ptrs->ptr_path) { - if(!smb_io_unistr2("", &sh502->uni_path, True, ps, depth)) - return False; - } - - if(!prs_align(ps)) - return False; - - if(sh502->ptrs->ptr_passwd) { - if(!smb_io_unistr2("", &sh502->uni_passwd, True, ps, depth)) - return False; - } - - if(!prs_align(ps)) - return False; - - if(sh502->ptrs->ptr_sd) { - uint32 old_offset; - uint32 reserved_offset; - - if(!prs_uint32_pre("reserved ", ps, depth, &sh502->reserved, &reserved_offset)) - return False; - - old_offset = prs_offset(ps); - - if (!sec_io_desc(desc, &sh502->sd, ps, depth)) - return False; - - if(UNMARSHALLING(ps)) { - - sh502->ptrs->sd_size = sh502->sd_size = sec_desc_size(sh502->sd); - - prs_set_offset(ps, old_offset + sh502->reserved); - } - - prs_align(ps); - - if(MARSHALLING(ps)) { - - sh502->ptrs->reserved = sh502->reserved = prs_offset(ps) - old_offset; - } - - if(!prs_uint32_post("reserved ", ps, depth, - &sh502->reserved, reserved_offset, sh502->reserved)) - return False; - if(!prs_uint32_post("reserved ", ps, depth, - &sh502->ptrs->reserved, sh502->ptrs->reserved_offset, sh502->ptrs->reserved)) - return False; - } - - return True; -} - -/******************************************************************* - Inits a SH_INFO_1004_STR structure -********************************************************************/ - -void init_srv_share_info1004_str(SH_INFO_1004_STR *sh1004, const char *remark) -{ - DEBUG(5,("init_srv_share_info1004_str\n")); - - init_unistr2(&sh1004->uni_remark, remark, UNI_STR_TERMINATE); -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_share_info1004_str(const char *desc, SH_INFO_1004_STR *sh1004, prs_struct *ps, int depth) -{ - if (sh1004 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_share_info1004_str"); - depth++; - - if(!prs_align(ps)) - return False; - if(sh1004->ptrs->ptr_remark) - if(!smb_io_unistr2("", &sh1004->uni_remark, True, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - makes a SH_INFO_1004 structure -********************************************************************/ - -void init_srv_share_info1004(SH_INFO_1004 *sh1004, const char *remark) -{ - DEBUG(5,("init_srv_share_info1004: %s\n", remark)); - - sh1004->ptr_remark = (remark != NULL) ? 1 : 0; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_share_info1004(const char *desc, SH_INFO_1004 *sh1004, prs_struct *ps, int depth) -{ - if (sh1004 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_share_info1004"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_remark", ps, depth, &sh1004->ptr_remark)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_share_info1005(const char* desc, SRV_SHARE_INFO_1005* sh1005, prs_struct* ps, int depth) -{ - if(sh1005 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_share_info1005"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("share_info_flags", ps, depth, - &sh1005->share_info_flags)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_share_info1006(const char* desc, SRV_SHARE_INFO_1006* sh1006, prs_struct* ps, int depth) -{ - if(sh1006 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_share_info1006"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("max uses ", ps, depth, &sh1006->max_uses)) - return False; - - return True; -} - -/******************************************************************* - Inits a SH_INFO_1007_STR structure -********************************************************************/ - -void init_srv_share_info1007_str(SH_INFO_1007_STR *sh1007, const char *alternate_directory_name) -{ - DEBUG(5,("init_srv_share_info1007_str\n")); - - init_unistr2(&sh1007->uni_AlternateDirectoryName, alternate_directory_name, UNI_STR_TERMINATE); -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_share_info1007_str(const char *desc, SH_INFO_1007_STR *sh1007, prs_struct *ps, int depth) -{ - if (sh1007 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_share_info1007_str"); - depth++; - - if(!prs_align(ps)) - return False; - if(sh1007->ptrs->ptr_AlternateDirectoryName) - if(!smb_io_unistr2("", &sh1007->uni_AlternateDirectoryName, True, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - makes a SH_INFO_1007 structure -********************************************************************/ - -void init_srv_share_info1007(SH_INFO_1007 *sh1007, uint32 flags, const char *alternate_directory_name) -{ - DEBUG(5,("init_srv_share_info1007: %s\n", alternate_directory_name)); - - sh1007->flags = flags; - sh1007->ptr_AlternateDirectoryName = (alternate_directory_name != NULL) ? 1 : 0; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_share_info1007(const char *desc, SH_INFO_1007 *sh1007, prs_struct *ps, int depth) -{ - if (sh1007 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_share_info1007"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("flags ", ps, depth, &sh1007->flags)) - return False; - if(!prs_uint32("ptr_Alter..", ps, depth, &sh1007->ptr_AlternateDirectoryName)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_share_info1501(const char* desc, SRV_SHARE_INFO_1501* sh1501, - prs_struct* ps, int depth) -{ - if(sh1501 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_share_info1501"); - depth++; - - if(!prs_align(ps)) - return False; - - if (!sec_io_desc_buf(desc, &sh1501->sdb, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_srv_share_ctr(const char *desc, SRV_SHARE_INFO_CTR *ctr, prs_struct *ps, int depth) -{ - if (ctr == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_srv_share_ctr"); - depth++; - - if (UNMARSHALLING(ps)) { - memset(ctr, '\0', sizeof(SRV_SHARE_INFO_CTR)); - } - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("info_level", ps, depth, &ctr->info_level)) - return False; - - if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value)) - return False; - if(!prs_uint32("ptr_share_info", ps, depth, &ctr->ptr_share_info)) - return False; - - if (ctr->ptr_share_info == 0) - return True; - - if(!prs_uint32("num_entries", ps, depth, &ctr->num_entries)) - return False; - if(!prs_uint32("ptr_entries", ps, depth, &ctr->ptr_entries)) - return False; - - if (ctr->ptr_entries == 0) { - if (ctr->num_entries == 0) - return True; - else - return False; - } - - if(!prs_uint32("num_entries2", ps, depth, &ctr->num_entries2)) - return False; - - if (ctr->num_entries2 != ctr->num_entries) - return False; - - switch (ctr->switch_value) { - - case 0: - { - SRV_SHARE_INFO_0 *info0 = ctr->share.info0; - int num_entries = ctr->num_entries; - int i; - - if (UNMARSHALLING(ps)) { - if (!(info0 = PRS_ALLOC_MEM(ps, SRV_SHARE_INFO_0, num_entries))) - return False; - ctr->share.info0 = info0; - } - - for (i = 0; i < num_entries; i++) { - if(!srv_io_share_info0("", &info0[i].info_0, ps, depth)) - return False; - } - - for (i = 0; i < num_entries; i++) { - info0[i].info_0_str.ptrs = &info0[i].info_0; - if(!srv_io_share_info0_str("", &info0[i].info_0_str, ps, depth)) - return False; - } - - break; - } - - case 1: - { - SRV_SHARE_INFO_1 *info1 = ctr->share.info1; - int num_entries = ctr->num_entries; - int i; - - if (UNMARSHALLING(ps)) { - if (!(info1 = PRS_ALLOC_MEM(ps, SRV_SHARE_INFO_1, num_entries))) - return False; - ctr->share.info1 = info1; - } - - for (i = 0; i < num_entries; i++) { - if(!srv_io_share_info1("", &info1[i].info_1, ps, depth)) - return False; - } - - for (i = 0; i < num_entries; i++) { - info1[i].info_1_str.ptrs = &info1[i].info_1; - if(!srv_io_share_info1_str("", &info1[i].info_1_str, ps, depth)) - return False; - } - - break; - } - - case 2: - { - SRV_SHARE_INFO_2 *info2 = ctr->share.info2; - int num_entries = ctr->num_entries; - int i; - - if (UNMARSHALLING(ps)) { - if (!(info2 = PRS_ALLOC_MEM(ps,SRV_SHARE_INFO_2,num_entries))) - return False; - ctr->share.info2 = info2; - } - - for (i = 0; i < num_entries; i++) { - if(!srv_io_share_info2("", &info2[i].info_2, ps, depth)) - return False; - } - - for (i = 0; i < num_entries; i++) { - if(!srv_io_share_info2_str("", &info2[i].info_2, &info2[i].info_2_str, ps, depth)) - return False; - } - - break; - } - - case 501: - { - SRV_SHARE_INFO_501 *info501 = ctr->share.info501; - int num_entries = ctr->num_entries; - int i; - - if (UNMARSHALLING(ps)) { - if (!(info501 = PRS_ALLOC_MEM(ps, SRV_SHARE_INFO_501, num_entries))) - return False; - ctr->share.info501 = info501; - } - - for (i = 0; i < num_entries; i++) { - if (!srv_io_share_info501("", &info501[i].info_501, ps, depth)) - return False; - } - - for (i = 0; i < num_entries; i++) { - if (!srv_io_share_info501_str("", &info501[i].info_501_str, ps, depth)) - return False; - } - - break; - } - - case 502: - { - SRV_SHARE_INFO_502 *info502 = ctr->share.info502; - int num_entries = ctr->num_entries; - int i; - - if (UNMARSHALLING(ps)) { - if (!(info502 = PRS_ALLOC_MEM(ps,SRV_SHARE_INFO_502,num_entries))) - return False; - ctr->share.info502 = info502; - } - - for (i = 0; i < num_entries; i++) { - if(!srv_io_share_info502("", &info502[i].info_502, ps, depth)) - return False; - } - - for (i = 0; i < num_entries; i++) { - info502[i].info_502_str.ptrs = &info502[i].info_502; - if(!srv_io_share_info502_str("", &info502[i].info_502_str, ps, depth)) - return False; - } - - break; - } - - case 1004: - { - SRV_SHARE_INFO_1004 *info1004 = ctr->share.info1004; - int num_entries = ctr->num_entries; - int i; - - if (UNMARSHALLING(ps)) { - if (!(info1004 = PRS_ALLOC_MEM(ps,SRV_SHARE_INFO_1004,num_entries))) - return False; - ctr->share.info1004 = info1004; - } - - for (i = 0; i < num_entries; i++) { - if(!srv_io_share_info1004("", &info1004[i].info_1004, ps, depth)) - return False; - } - - for (i = 0; i < num_entries; i++) { - info1004[i].info_1004_str.ptrs = &info1004[i].info_1004; - if(!srv_io_share_info1004_str("", &info1004[i].info_1004_str, ps, depth)) - return False; - } - - break; - } - - case 1005: - { - SRV_SHARE_INFO_1005 *info1005 = ctr->share.info1005; - int num_entries = ctr->num_entries; - int i; - - if (UNMARSHALLING(ps)) { - if (!(info1005 = PRS_ALLOC_MEM(ps,SRV_SHARE_INFO_1005,num_entries))) - return False; - ctr->share.info1005 = info1005; - } - - for (i = 0; i < num_entries; i++) { - if(!srv_io_share_info1005("", &info1005[i], ps, depth)) - return False; - } - - break; - } - - case 1006: - { - SRV_SHARE_INFO_1006 *info1006 = ctr->share.info1006; - int num_entries = ctr->num_entries; - int i; - - if (UNMARSHALLING(ps)) { - if (!(info1006 = PRS_ALLOC_MEM(ps,SRV_SHARE_INFO_1006,num_entries))) - return False; - ctr->share.info1006 = info1006; - } - - for (i = 0; i < num_entries; i++) { - if(!srv_io_share_info1006("", &info1006[i], ps, depth)) - return False; - } - - break; - } - - case 1007: - { - SRV_SHARE_INFO_1007 *info1007 = ctr->share.info1007; - int num_entries = ctr->num_entries; - int i; - - if (UNMARSHALLING(ps)) { - if (!(info1007 = PRS_ALLOC_MEM(ps,SRV_SHARE_INFO_1007,num_entries))) - return False; - ctr->share.info1007 = info1007; - } - - for (i = 0; i < num_entries; i++) { - if(!srv_io_share_info1007("", &info1007[i].info_1007, ps, depth)) - return False; - } - - for (i = 0; i < num_entries; i++) { - info1007[i].info_1007_str.ptrs = &info1007[i].info_1007; - if(!srv_io_share_info1007_str("", &info1007[i].info_1007_str, ps, depth)) - return False; - } - - break; - } - - case 1501: - { - SRV_SHARE_INFO_1501 *info1501 = ctr->share.info1501; - int num_entries = ctr->num_entries; - int i; - - if (UNMARSHALLING(ps)) { - if (!(info1501 = PRS_ALLOC_MEM(ps,SRV_SHARE_INFO_1501,num_entries))) - return False; - ctr->share.info1501 = info1501; - } - - for (i = 0; i < num_entries; i++) { - if(!srv_io_share_info1501("", &info1501[i], ps, depth)) - return False; - } - - break; - } - - default: - DEBUG(5,("%s no share info at switch_value %d\n", - tab_depth(depth), ctr->switch_value)); - break; - } - - return True; -} - -/******************************************************************* - Inits a SRV_Q_NET_SHARE_ENUM structure. -********************************************************************/ - -void init_srv_q_net_share_enum(SRV_Q_NET_SHARE_ENUM *q_n, - const char *srv_name, uint32 info_level, - uint32 preferred_len, ENUM_HND *hnd) -{ - - DEBUG(5,("init_q_net_share_enum\n")); - - init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name); - - q_n->ctr.info_level = q_n->ctr.switch_value = info_level; - q_n->ctr.ptr_share_info = 1; - q_n->ctr.num_entries = 0; - q_n->ctr.ptr_entries = 0; - q_n->ctr.num_entries2 = 0; - q_n->preferred_len = preferred_len; - - memcpy(&q_n->enum_hnd, hnd, sizeof(*hnd)); -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL srv_io_q_net_share_enum(const char *desc, SRV_Q_NET_SHARE_ENUM *q_n, prs_struct *ps, int depth) -{ - if (q_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_q_net_share_enum"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name)) - return False; - if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth)) - return False; - - if(!srv_io_srv_share_ctr("share_ctr", &q_n->ctr, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("preferred_len", ps, depth, &q_n->preferred_len)) - return False; - - if(!smb_io_enum_hnd("enum_hnd", &q_n->enum_hnd, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL srv_io_r_net_share_enum(const char *desc, SRV_R_NET_SHARE_ENUM *r_n, prs_struct *ps, int depth) -{ - if (r_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_r_net_share_enum"); - depth++; - - if(!srv_io_srv_share_ctr("share_ctr", &r_n->ctr, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries)) - return False; - - if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth)) - return False; - - if(!prs_werror("status", ps, depth, &r_n->status)) - return False; - - return True; -} - -/******************************************************************* - initialises a structure. -********************************************************************/ - -BOOL init_srv_q_net_share_get_info(SRV_Q_NET_SHARE_GET_INFO *q_n, const char *srv_name, const char *share_name, uint32 info_level) -{ - - uint32 ptr_share_name; - - DEBUG(5,("init_srv_q_net_share_get_info\n")); - - init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name); - init_buf_unistr2(&q_n->uni_share_name, &ptr_share_name, share_name); - - q_n->info_level = info_level; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL srv_io_q_net_share_get_info(const char *desc, SRV_Q_NET_SHARE_GET_INFO *q_n, prs_struct *ps, int depth) -{ - if (q_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_q_net_share_get_info"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name)) - return False; - if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth)) - return False; - - if(!smb_io_unistr2("", &q_n->uni_share_name, True, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("info_level", ps, depth, &q_n->info_level)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_srv_share_info(const char *desc, prs_struct *ps, int depth, SRV_SHARE_INFO *r_n) -{ - if (r_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_srv_share_info"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("switch_value ", ps, depth, &r_n->switch_value )) - return False; - - if(!prs_uint32("ptr_share_ctr", ps, depth, &r_n->ptr_share_ctr)) - return False; - - if (r_n->ptr_share_ctr != 0) { - switch (r_n->switch_value) { - case 0: - if(!srv_io_share_info0("", &r_n->share.info0.info_0, ps, depth)) - return False; - - /* allow access to pointers in the str part. */ - r_n->share.info0.info_0_str.ptrs = &r_n->share.info0.info_0; - - if(!srv_io_share_info0_str("", &r_n->share.info0.info_0_str, ps, depth)) - return False; - - break; - case 1: - if(!srv_io_share_info1("", &r_n->share.info1.info_1, ps, depth)) - return False; - - /* allow access to pointers in the str part. */ - r_n->share.info1.info_1_str.ptrs = &r_n->share.info1.info_1; - - if(!srv_io_share_info1_str("", &r_n->share.info1.info_1_str, ps, depth)) - return False; - - break; - case 2: - if(!srv_io_share_info2("", &r_n->share.info2.info_2, ps, depth)) - return False; - - if(!srv_io_share_info2_str("", &r_n->share.info2.info_2, &r_n->share.info2.info_2_str, ps, depth)) - return False; - - break; - case 501: - if (!srv_io_share_info501("", &r_n->share.info501.info_501, ps, depth)) - return False; - if (!srv_io_share_info501_str("", &r_n->share.info501.info_501_str, ps, depth)) - return False; - break; - - case 502: - if(!srv_io_share_info502("", &r_n->share.info502.info_502, ps, depth)) - return False; - - /* allow access to pointers in the str part. */ - r_n->share.info502.info_502_str.ptrs = &r_n->share.info502.info_502; - - if(!srv_io_share_info502_str("", &r_n->share.info502.info_502_str, ps, depth)) - return False; - break; - case 1004: - if(!srv_io_share_info1004("", &r_n->share.info1004.info_1004, ps, depth)) - return False; - - /* allow access to pointers in the str part. */ - r_n->share.info1004.info_1004_str.ptrs = &r_n->share.info1004.info_1004; - - if(!srv_io_share_info1004_str("", &r_n->share.info1004.info_1004_str, ps, depth)) - return False; - break; - case 1005: - if(!srv_io_share_info1005("", &r_n->share.info1005, ps, depth)) - return False; - break; - case 1006: - if(!srv_io_share_info1006("", &r_n->share.info1006, ps, depth)) - return False; - break; - case 1007: - if(!srv_io_share_info1007("", &r_n->share.info1007.info_1007, ps, depth)) - return False; - - /* allow access to pointers in the str part. */ - r_n->share.info1007.info_1007_str.ptrs = &r_n->share.info1007.info_1007; - - if(!srv_io_share_info1007_str("", &r_n->share.info1007.info_1007_str, ps, depth)) - return False; - break; - case 1501: - if (!srv_io_share_info1501("", &r_n->share.info1501, ps, depth)) - return False; - default: - DEBUG(5,("%s no share info at switch_value %d\n", - tab_depth(depth), r_n->switch_value)); - break; - } - } - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL srv_io_r_net_share_get_info(const char *desc, SRV_R_NET_SHARE_GET_INFO *r_n, prs_struct *ps, int depth) -{ - if (r_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_r_net_share_get_info"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!srv_io_srv_share_info("info ", ps, depth, &r_n->info)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_werror("status", ps, depth, &r_n->status)) - return False; - - return True; -} - -/******************************************************************* - intialises a structure. -********************************************************************/ - -BOOL init_srv_q_net_share_set_info(SRV_Q_NET_SHARE_SET_INFO *q_n, - const char *srv_name, - const char *share_name, - uint32 info_level, - const SRV_SHARE_INFO *info) -{ - - uint32 ptr_share_name; - - DEBUG(5,("init_srv_q_net_share_set_info\n")); - - init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name); - init_buf_unistr2(&q_n->uni_share_name, &ptr_share_name, share_name); - - q_n->info_level = info_level; - - q_n->info = *info; - - q_n->ptr_parm_error = 1; - q_n->parm_error = 0; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL srv_io_q_net_share_set_info(const char *desc, SRV_Q_NET_SHARE_SET_INFO *q_n, prs_struct *ps, int depth) -{ - if (q_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_q_net_share_set_info"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name)) - return False; - if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth)) - return False; - - if(!smb_io_unistr2("", &q_n->uni_share_name, True, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("info_level", ps, depth, &q_n->info_level)) - return False; - - if(!prs_align(ps)) - return False; - - if(!srv_io_srv_share_info("info ", ps, depth, &q_n->info)) - return False; - - if(!prs_align(ps)) - return False; - if(!prs_uint32("ptr_parm_error", ps, depth, &q_n->ptr_parm_error)) - return False; - if(q_n->ptr_parm_error!=0) { - if(!prs_uint32("parm_error", ps, depth, &q_n->parm_error)) - return False; - } - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL srv_io_r_net_share_set_info(const char *desc, SRV_R_NET_SHARE_SET_INFO *r_n, prs_struct *ps, int depth) -{ - if (r_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_r_net_share_set_info"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_parm_error ", ps, depth, &r_n->ptr_parm_error)) - return False; - - if(r_n->ptr_parm_error) { - - if(!prs_uint32("parm_error ", ps, depth, &r_n->parm_error)) - return False; - } - - if(!prs_werror("status", ps, depth, &r_n->status)) - return False; - - return True; -} - - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL srv_io_q_net_share_add(const char *desc, SRV_Q_NET_SHARE_ADD *q_n, prs_struct *ps, int depth) -{ - if (q_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_q_net_share_add"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name)) - return False; - if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("info_level", ps, depth, &q_n->info_level)) - return False; - - if(!prs_align(ps)) - return False; - - if(!srv_io_srv_share_info("info ", ps, depth, &q_n->info)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_err_index", ps, depth, &q_n->ptr_err_index)) - return False; - if (q_n->ptr_err_index) - if (!prs_uint32("err_index", ps, depth, &q_n->err_index)) - return False; - - return True; -} - -void init_srv_q_net_share_add(SRV_Q_NET_SHARE_ADD *q, const char *srvname, - 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) -{ - switch(level) { - case 502: { - size_t sd_size = sec_desc_size(sd); - q->ptr_srv_name = 1; - init_unistr2(&q->uni_srv_name, srvname, UNI_STR_TERMINATE); - q->info.switch_value = q->info_level = level; - q->info.ptr_share_ctr = 1; - init_srv_share_info502(&q->info.share.info502.info_502, netname, type, - remark, perms, max_uses, num_uses, path, passwd, sd, sd_size); - init_srv_share_info502_str(&q->info.share.info502.info_502_str, netname, - remark, path, passwd, sd, sd_size); - q->ptr_err_index = 1; - q->err_index = 0; - } - break; - case 2: - default: - q->ptr_srv_name = 1; - init_unistr2(&q->uni_srv_name, srvname, UNI_STR_TERMINATE); - q->info.switch_value = q->info_level = level; - q->info.ptr_share_ctr = 1; - init_srv_share_info2(&q->info.share.info2.info_2, netname, type, - remark, perms, max_uses, num_uses, path, passwd); - init_srv_share_info2_str(&q->info.share.info2.info_2_str, netname, - remark, path, passwd); - q->ptr_err_index = 1; - q->err_index = 0; - break; - } -} - - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL srv_io_r_net_share_add(const char *desc, SRV_R_NET_SHARE_ADD *r_n, prs_struct *ps, int depth) -{ - if (r_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_r_net_share_add"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_parm_error", ps, depth, &r_n->ptr_parm_error)) - return False; - - if(r_n->ptr_parm_error) { - - if(!prs_uint32("parm_error", ps, depth, &r_n->parm_error)) - return False; - } - - if(!prs_werror("status", ps, depth, &r_n->status)) - return False; - - return True; -} - -/******************************************************************* - initialises a structure. -********************************************************************/ - -void init_srv_q_net_share_del(SRV_Q_NET_SHARE_DEL *del, const char *srvname, - const char *sharename) -{ - del->ptr_srv_name = 1; - init_unistr2(&del->uni_srv_name, srvname, UNI_STR_TERMINATE); - init_unistr2(&del->uni_share_name, sharename, UNI_STR_TERMINATE); -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL srv_io_q_net_share_del(const char *desc, SRV_Q_NET_SHARE_DEL *q_n, prs_struct *ps, int depth) -{ - if (q_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_q_net_share_del"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name)) - return False; - if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth)) - return False; - - if(!smb_io_unistr2("", &q_n->uni_share_name, True, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - if(!prs_uint32("reserved", ps, depth, &q_n->reserved)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL srv_io_r_net_share_del(const char *desc, SRV_R_NET_SHARE_DEL *q_n, prs_struct *ps, int depth) -{ - if (q_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_r_net_share_del"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_werror("status", ps, depth, &q_n->status)) - return False; - - return True; -} - -/******************************************************************* - Inits a SESS_INFO_0_STR structure -********************************************************************/ - -void init_srv_sess_info0( SESS_INFO_0 *ss0, const char *name ) -{ - ZERO_STRUCTP( ss0 ); - - if ( name ) { - if ( (ss0->sharename = TALLOC_P( get_talloc_ctx(), UNISTR2 )) == NULL ) { - DEBUG(0,("init_srv_sess_info0: talloc failed!\n")); - return; - } - init_unistr2( ss0->sharename, name, UNI_STR_TERMINATE ); - } -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_srv_sess_info_0(const char *desc, SRV_SESS_INFO_0 *ss0, prs_struct *ps, int depth) -{ - if (ss0 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_srv_sess_info_0"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("num_entries_read", ps, depth, &ss0->num_entries_read)) - return False; - if(!prs_uint32("ptr_sess_info", ps, depth, &ss0->ptr_sess_info)) - return False; - - if (ss0->ptr_sess_info != 0) { - uint32 i; - uint32 num_entries = ss0->num_entries_read; - - if (num_entries > MAX_SESS_ENTRIES) { - num_entries = MAX_SESS_ENTRIES; /* report this! */ - } - - if(!prs_uint32("num_entries_read2", ps, depth, &ss0->num_entries_read2)) - return False; - - SMB_ASSERT_ARRAY(ss0->info_0, num_entries); - - /* first the pointers */ - for (i = 0; i < num_entries; i++) { - if ( !prs_io_unistr2_p("", ps, depth, &ss0->info_0[i].sharename ) ) - return False; - } - - /* now the strings */ - for (i = 0; i < num_entries; i++) { - if ( !prs_io_unistr2("sharename", ps, depth, ss0->info_0[i].sharename )) - return False; - } - - if(!prs_align(ps)) - return False; - } - - return True; -} - -/******************************************************************* - Inits a SESS_INFO_1 structure -********************************************************************/ - -void init_srv_sess_info1( SESS_INFO_1 *ss1, const char *name, const char *user, - uint32 num_opens, uint32 open_time, uint32 idle_time, - uint32 user_flags) -{ - DEBUG(5,("init_srv_sess_info1: %s\n", name)); - - ZERO_STRUCTP( ss1 ); - - if ( name ) { - if ( (ss1->sharename = TALLOC_P( get_talloc_ctx(), UNISTR2 )) == NULL ) { - DEBUG(0,("init_srv_sess_info0: talloc failed!\n")); - return; - } - init_unistr2( ss1->sharename, name, UNI_STR_TERMINATE ); - } - - if ( user ) { - if ( (ss1->username = TALLOC_P( get_talloc_ctx(), UNISTR2 )) == NULL ) { - DEBUG(0,("init_srv_sess_info0: talloc failed!\n")); - return; - } - init_unistr2( ss1->username, user, UNI_STR_TERMINATE ); - } - - ss1->num_opens = num_opens; - ss1->open_time = open_time; - ss1->idle_time = idle_time; - ss1->user_flags = user_flags; -} - - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_srv_sess_info_1(const char *desc, SRV_SESS_INFO_1 *ss1, prs_struct *ps, int depth) -{ - if (ss1 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_srv_sess_info_1"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("num_entries_read", ps, depth, &ss1->num_entries_read)) - return False; - if(!prs_uint32("ptr_sess_info", ps, depth, &ss1->ptr_sess_info)) - return False; - - if (ss1->ptr_sess_info != 0) { - uint32 i; - uint32 num_entries = ss1->num_entries_read; - - if (num_entries > MAX_SESS_ENTRIES) { - num_entries = MAX_SESS_ENTRIES; /* report this! */ - } - - if(!prs_uint32("num_entries_read2", ps, depth, &ss1->num_entries_read2)) - return False; - - SMB_ASSERT_ARRAY(ss1->info_1, num_entries); - - /* first the pointers and flags */ - - for (i = 0; i < num_entries; i++) { - - if ( !prs_io_unistr2_p("", ps, depth, &ss1->info_1[i].sharename )) - return False; - if ( !prs_io_unistr2_p("", ps, depth, &ss1->info_1[i].username )) - return False; - - if(!prs_uint32("num_opens ", ps, depth, &ss1->info_1[i].num_opens)) - return False; - if(!prs_uint32("open_time ", ps, depth, &ss1->info_1[i].open_time)) - return False; - if(!prs_uint32("idle_time ", ps, depth, &ss1->info_1[i].idle_time)) - return False; - if(!prs_uint32("user_flags", ps, depth, &ss1->info_1[i].user_flags)) - return False; - } - - /* now the strings */ - - for (i = 0; i < num_entries; i++) { - if ( !prs_io_unistr2("", ps, depth, ss1->info_1[i].sharename )) - return False; - if ( !prs_io_unistr2("", ps, depth, ss1->info_1[i].username )) - return False; - } - - if(!prs_align(ps)) - return False; - } - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_srv_sess_ctr(const char *desc, SRV_SESS_INFO_CTR **pp_ctr, prs_struct *ps, int depth) -{ - SRV_SESS_INFO_CTR *ctr = *pp_ctr; - - prs_debug(ps, depth, desc, "srv_io_srv_sess_ctr"); - depth++; - - if(UNMARSHALLING(ps)) { - ctr = *pp_ctr = PRS_ALLOC_MEM(ps, SRV_SESS_INFO_CTR, 1); - if (ctr == NULL) - return False; - } - - if (ctr == NULL) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value)) - return False; - if(!prs_uint32("ptr_sess_ctr", ps, depth, &ctr->ptr_sess_ctr)) - return False; - - if (ctr->ptr_sess_ctr != 0) { - switch (ctr->switch_value) { - case 0: - if(!srv_io_srv_sess_info_0("", &ctr->sess.info0, ps, depth)) - return False; - break; - case 1: - if(!srv_io_srv_sess_info_1("", &ctr->sess.info1, ps, depth)) - return False; - break; - default: - DEBUG(5,("%s no session info at switch_value %d\n", - tab_depth(depth), ctr->switch_value)); - break; - } - } - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL srv_io_q_net_sess_enum(const char *desc, SRV_Q_NET_SESS_ENUM *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_q_net_sess_enum"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_pointer("servername", ps, depth, (void*)&q_u->servername, sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_pointer("qualifier", ps, depth, (void*)&q_u->qualifier, sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_pointer("username", ps, depth, (void*)&q_u->username, sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("sess_level", ps, depth, &q_u->sess_level)) - return False; - - if (q_u->sess_level != (uint32)-1) { - if(!srv_io_srv_sess_ctr("sess_ctr", &q_u->ctr, ps, depth)) - return False; - } - - if(!prs_uint32("preferred_len", ps, depth, &q_u->preferred_len)) - return False; - - if(!smb_io_enum_hnd("enum_hnd", &q_u->enum_hnd, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL srv_io_r_net_sess_enum(const char *desc, SRV_R_NET_SESS_ENUM *r_n, prs_struct *ps, int depth) -{ - if (r_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_r_net_sess_enum"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("sess_level", ps, depth, &r_n->sess_level)) - return False; - - if (r_n->sess_level != (uint32)-1) { - if(!srv_io_srv_sess_ctr("sess_ctr", &r_n->ctr, ps, depth)) - return False; - } - - if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries)) - return False; - if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth)) - return False; - if(!prs_werror("status", ps, depth, &r_n->status)) - return False; - - return True; -} - -/******************************************************************* - Inits a SRV_Q_NET_SESS_DEL structure. -********************************************************************/ - -void init_srv_q_net_sess_del(SRV_Q_NET_SESS_DEL *q_n, const char *srv_name, - const char *cli_name, const char *user_name) -{ - DEBUG(5,("init_q_net_sess_enum\n")); - - init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name); - init_buf_unistr2(&q_n->uni_cli_name, &q_n->ptr_cli_name, cli_name); - init_buf_unistr2(&q_n->uni_user_name, &q_n->ptr_user_name, user_name); -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL srv_io_q_net_sess_del(const char *desc, SRV_Q_NET_SESS_DEL *q_n, prs_struct *ps, int depth) -{ - if (q_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_q_net_sess_del"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name)) - return False; - if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_cli_name", ps, depth, &q_n->ptr_cli_name)) - return False; - if(!smb_io_unistr2("", &q_n->uni_cli_name, q_n->ptr_cli_name, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - if(!prs_uint32("ptr_user_name", ps, depth, &q_n->ptr_user_name)) - return False; - if(!smb_io_unistr2("", &q_n->uni_user_name, q_n->ptr_user_name, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL srv_io_r_net_sess_del(const char *desc, SRV_R_NET_SESS_DEL *r_n, prs_struct *ps, int depth) -{ - if (r_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_r_net_sess_del"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_werror("status", ps, depth, &r_n->status)) - return False; - - return True; -} - -/******************************************************************* - Inits a CONN_INFO_0 structure -********************************************************************/ - -void init_srv_conn_info0(CONN_INFO_0 *ss0, uint32 id) -{ - DEBUG(5,("init_srv_conn_info0\n")); - - ss0->id = id; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_conn_info0(const char *desc, CONN_INFO_0 *ss0, prs_struct *ps, int depth) -{ - if (ss0 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_conn_info0"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("id", ps, depth, &ss0->id)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_srv_conn_info_0(const char *desc, SRV_CONN_INFO_0 *ss0, prs_struct *ps, int depth) -{ - if (ss0 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_srv_conn_info_0"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("num_entries_read", ps, depth, &ss0->num_entries_read)) - return False; - if(!prs_uint32("ptr_conn_info", ps, depth, &ss0->ptr_conn_info)) - return False; - - if (ss0->ptr_conn_info != 0) { - int i; - int num_entries = ss0->num_entries_read; - - if (num_entries > MAX_CONN_ENTRIES) { - num_entries = MAX_CONN_ENTRIES; /* report this! */ - } - - if(!prs_uint32("num_entries_read2", ps, depth, &ss0->num_entries_read2)) - return False; - - for (i = 0; i < num_entries; i++) { - if(!srv_io_conn_info0("", &ss0->info_0[i], ps, depth)) - return False; - } - - if(!prs_align(ps)) - return False; - } - - return True; -} - -/******************************************************************* - Inits a CONN_INFO_1_STR structure -********************************************************************/ - -void init_srv_conn_info1_str(CONN_INFO_1_STR *ss1, const char *usr_name, const char *net_name) -{ - DEBUG(5,("init_srv_conn_info1_str\n")); - - init_unistr2(&ss1->uni_usr_name, usr_name, UNI_STR_TERMINATE); - init_unistr2(&ss1->uni_net_name, net_name, UNI_STR_TERMINATE); -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_conn_info1_str(const char *desc, CONN_INFO_1_STR *ss1, prs_struct *ps, int depth) -{ - if (ss1 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_conn_info1_str"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_unistr2("", &ss1->uni_usr_name, True, ps, depth)) - return False; - if(!smb_io_unistr2("", &ss1->uni_net_name, True, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Inits a CONN_INFO_1 structure -********************************************************************/ - -void init_srv_conn_info1(CONN_INFO_1 *ss1, - uint32 id, uint32 type, - uint32 num_opens, uint32 num_users, uint32 open_time, - const char *usr_name, const char *net_name) -{ - DEBUG(5,("init_srv_conn_info1: %s %s\n", usr_name, net_name)); - - ss1->id = id ; - ss1->type = type ; - ss1->num_opens = num_opens ; - ss1->num_users = num_users; - ss1->open_time = open_time; - - ss1->ptr_usr_name = (usr_name != NULL) ? 1 : 0; - ss1->ptr_net_name = (net_name != NULL) ? 1 : 0; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_conn_info1(const char *desc, CONN_INFO_1 *ss1, prs_struct *ps, int depth) -{ - if (ss1 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_conn_info1"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("id ", ps, depth, &ss1->id)) - return False; - if(!prs_uint32("type ", ps, depth, &ss1->type)) - return False; - if(!prs_uint32("num_opens ", ps, depth, &ss1->num_opens)) - return False; - if(!prs_uint32("num_users ", ps, depth, &ss1->num_users)) - return False; - if(!prs_uint32("open_time ", ps, depth, &ss1->open_time)) - return False; - - if(!prs_uint32("ptr_usr_name", ps, depth, &ss1->ptr_usr_name)) - return False; - if(!prs_uint32("ptr_net_name", ps, depth, &ss1->ptr_net_name)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_srv_conn_info_1(const char *desc, SRV_CONN_INFO_1 *ss1, prs_struct *ps, int depth) -{ - if (ss1 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_srv_conn_info_1"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("num_entries_read", ps, depth, &ss1->num_entries_read)) - return False; - if(!prs_uint32("ptr_conn_info", ps, depth, &ss1->ptr_conn_info)) - return False; - - if (ss1->ptr_conn_info != 0) { - int i; - int num_entries = ss1->num_entries_read; - - if (num_entries > MAX_CONN_ENTRIES) { - num_entries = MAX_CONN_ENTRIES; /* report this! */ - } - - if(!prs_uint32("num_entries_read2", ps, depth, &ss1->num_entries_read2)) - return False; - - for (i = 0; i < num_entries; i++) { - if(!srv_io_conn_info1("", &ss1->info_1[i], ps, depth)) - return False; - } - - for (i = 0; i < num_entries; i++) { - if(!srv_io_conn_info1_str("", &ss1->info_1_str[i], ps, depth)) - return False; - } - - if(!prs_align(ps)) - return False; - } - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_srv_conn_ctr(const char *desc, SRV_CONN_INFO_CTR **pp_ctr, prs_struct *ps, int depth) -{ - SRV_CONN_INFO_CTR *ctr = *pp_ctr; - - prs_debug(ps, depth, desc, "srv_io_srv_conn_ctr"); - depth++; - - if (UNMARSHALLING(ps)) { - ctr = *pp_ctr = PRS_ALLOC_MEM(ps, SRV_CONN_INFO_CTR, 1); - if (ctr == NULL) - return False; - } - - if (ctr == NULL) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value)) - return False; - if(!prs_uint32("ptr_conn_ctr", ps, depth, &ctr->ptr_conn_ctr)) - return False; - - if (ctr->ptr_conn_ctr != 0) { - switch (ctr->switch_value) { - case 0: - if(!srv_io_srv_conn_info_0("", &ctr->conn.info0, ps, depth)) - return False; - break; - case 1: - if(!srv_io_srv_conn_info_1("", &ctr->conn.info1, ps, depth)) - return False; - break; - default: - DEBUG(5,("%s no connection info at switch_value %d\n", - tab_depth(depth), ctr->switch_value)); - break; - } - } - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -void init_srv_q_net_conn_enum(SRV_Q_NET_CONN_ENUM *q_n, - const char *srv_name, const char *qual_name, - uint32 conn_level, SRV_CONN_INFO_CTR *ctr, - uint32 preferred_len, - ENUM_HND *hnd) -{ - DEBUG(5,("init_q_net_conn_enum\n")); - - q_n->ctr = ctr; - - init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name ); - init_buf_unistr2(&q_n->uni_qual_name, &q_n->ptr_qual_name, qual_name); - - q_n->conn_level = conn_level; - q_n->preferred_len = preferred_len; - - memcpy(&q_n->enum_hnd, hnd, sizeof(*hnd)); -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL srv_io_q_net_conn_enum(const char *desc, SRV_Q_NET_CONN_ENUM *q_n, prs_struct *ps, int depth) -{ - if (q_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_q_net_conn_enum"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_srv_name ", ps, depth, &q_n->ptr_srv_name)) - return False; - if(!smb_io_unistr2("", &q_n->uni_srv_name, q_n->ptr_srv_name, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_qual_name", ps, depth, &q_n->ptr_qual_name)) - return False; - if(!smb_io_unistr2("", &q_n->uni_qual_name, q_n->ptr_qual_name, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("conn_level", ps, depth, &q_n->conn_level)) - return False; - - if (q_n->conn_level != (uint32)-1) { - if(!srv_io_srv_conn_ctr("conn_ctr", &q_n->ctr, ps, depth)) - return False; - } - - if(!prs_uint32("preferred_len", ps, depth, &q_n->preferred_len)) - return False; - - if(!smb_io_enum_hnd("enum_hnd", &q_n->enum_hnd, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL srv_io_r_net_conn_enum(const char *desc, SRV_R_NET_CONN_ENUM *r_n, prs_struct *ps, int depth) -{ - if (r_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_r_net_conn_enum"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("conn_level", ps, depth, &r_n->conn_level)) - return False; - - if (r_n->conn_level != (uint32)-1) { - if(!srv_io_srv_conn_ctr("conn_ctr", &r_n->ctr, ps, depth)) - return False; - } - - if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries)) - return False; - if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth)) - return False; - if(!prs_werror("status", ps, depth, &r_n->status)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_file_info3_str(const char *desc, FILE_INFO_3 *sh1, prs_struct *ps, int depth) -{ - if (sh1 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_file_info3_str"); - depth++; - - if(!prs_align(ps)) - return False; - - if ( sh1->path ) { - if(!smb_io_unistr2("", sh1->path, True, ps, depth)) - return False; - } - - if ( sh1->user ) { - if(!smb_io_unistr2("", sh1->user, True, ps, depth)) - return False; - } - - return True; -} - -/******************************************************************* - Inits a FILE_INFO_3 structure -********************************************************************/ - -void init_srv_file_info3( FILE_INFO_3 *fl3, uint32 id, uint32 perms, uint32 num_locks, - const char *user_name, const char *path_name ) -{ - fl3->id = id; - fl3->perms = perms; - fl3->num_locks = num_locks; - - if ( path_name ) { - if ( (fl3->path = TALLOC_P( get_talloc_ctx(), UNISTR2 )) == NULL ) - return; - init_unistr2(fl3->path, path_name, UNI_STR_TERMINATE); - } - - if ( user_name ) { - if ( (fl3->user = TALLOC_P( get_talloc_ctx(), UNISTR2 )) == NULL ) - return; - init_unistr2(fl3->user, user_name, UNI_STR_TERMINATE); - } - - return; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_file_info3(const char *desc, FILE_INFO_3 *fl3, prs_struct *ps, int depth) -{ - uint32 uni_p; - - if (fl3 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_file_info3"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("id ", ps, depth, &fl3->id)) - return False; - if(!prs_uint32("perms ", ps, depth, &fl3->perms)) - return False; - if(!prs_uint32("num_locks ", ps, depth, &fl3->num_locks)) - return False; - - uni_p = fl3->path ? 1 : 0; - if(!prs_uint32("ptr", ps, depth, &uni_p)) - return False; - if (UNMARSHALLING(ps)) { - if ( (fl3->path = PRS_ALLOC_MEM( ps, UNISTR2, 1)) == NULL ) { - return False; - } - } - - uni_p = fl3->user ? 1 : 0; - if(!prs_uint32("ptr", ps, depth, &uni_p)) - return False; - if (UNMARSHALLING(ps)) { - if ( (fl3->user = PRS_ALLOC_MEM( ps, UNISTR2, 1)) == NULL ) { - return False; - } - } - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_srv_file_ctr(const char *desc, SRV_FILE_INFO_CTR *ctr, prs_struct *ps, int depth) -{ - if (ctr == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_srv_file_ctr"); - depth++; - - if (UNMARSHALLING(ps)) { - ZERO_STRUCTP(ctr); - } - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("level", ps, depth, &ctr->level)) - return False; - - if(!prs_uint32("ptr_file_info", ps, depth, &ctr->ptr_file_info)) - return False; - if(!prs_uint32("num_entries", ps, depth, &ctr->num_entries)) - return False; - if(!prs_uint32("ptr_entries", ps, depth, &ctr->ptr_entries)) - return False; - - if (ctr->ptr_entries == 0) - return True; - - if(!prs_uint32("num_entries2", ps, depth, &ctr->num_entries2)) - return False; - - switch (ctr->level) { - case 3: { - FILE_INFO_3 *info3 = ctr->file.info3; - int num_entries = ctr->num_entries; - int i; - - if (UNMARSHALLING(ps)) { - if (!(info3 = PRS_ALLOC_MEM(ps, FILE_INFO_3, num_entries))) - return False; - ctr->file.info3 = info3; - } - - for (i = 0; i < num_entries; i++) { - if(!srv_io_file_info3("", &ctr->file.info3[i], ps, depth)) - return False; - } - - for (i = 0; i < num_entries; i++) { - if(!srv_io_file_info3_str("", &ctr->file.info3[i], ps, depth)) - return False; - } - break; - } - default: - DEBUG(5,("%s no file info at switch_value %d\n", tab_depth(depth), ctr->level)); - break; - } - - return True; -} - -/******************************************************************* - Inits a SRV_Q_NET_FILE_ENUM structure. -********************************************************************/ - -void init_srv_q_net_file_enum(SRV_Q_NET_FILE_ENUM *q_n, - const char *srv_name, const char *qual_name, - const char *user_name, - uint32 file_level, SRV_FILE_INFO_CTR *ctr, - uint32 preferred_len, - ENUM_HND *hnd) -{ - uint32 ptr; - - if ( srv_name ) { - if ( (q_n->servername = TALLOC_P( get_talloc_ctx(), UNISTR2 )) == NULL ) - return; - init_buf_unistr2(q_n->servername, &ptr, srv_name); - } - - if ( qual_name ) { - if ( (q_n->qualifier = TALLOC_P( get_talloc_ctx(), UNISTR2 )) == NULL ) - return; - init_buf_unistr2(q_n->qualifier, &ptr, qual_name); - } - - if ( user_name ) { - if ( (q_n->username = TALLOC_P( get_talloc_ctx(), UNISTR2 )) == NULL ) - return; - init_buf_unistr2(q_n->username, &ptr, user_name); - } - - q_n->level = q_n->ctr.level = file_level; - - q_n->preferred_len = preferred_len; - q_n->ctr.ptr_file_info = 1; - q_n->ctr.num_entries = 0; - q_n->ctr.num_entries2 = 0; - - memcpy(&q_n->enum_hnd, hnd, sizeof(*hnd)); -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL srv_io_q_net_file_enum(const char *desc, SRV_Q_NET_FILE_ENUM *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_q_net_file_enum"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_pointer("servername", ps, depth, (void*)&q_u->servername, sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2)) - return False; - if(!prs_align(ps)) - return False; - - if(!prs_pointer("qualifier", ps, depth, (void*)&q_u->qualifier, sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2)) - return False; - if(!prs_align(ps)) - return False; - - if(!prs_pointer("username", ps, depth, (void*)&q_u->username, sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2)) - return False; - if(!prs_align(ps)) - return False; - - if(!prs_uint32("level", ps, depth, &q_u->level)) - return False; - - if (q_u->level != (uint32)-1) { - if(!srv_io_srv_file_ctr("file_ctr", &q_u->ctr, ps, depth)) - return False; - } - - if(!prs_uint32("preferred_len", ps, depth, &q_u->preferred_len)) - return False; - - if(!smb_io_enum_hnd("enum_hnd", &q_u->enum_hnd, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL srv_io_r_net_file_enum(const char *desc, SRV_R_NET_FILE_ENUM *r_n, prs_struct *ps, int depth) -{ - if (r_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_r_net_file_enum"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("level", ps, depth, &r_n->level)) - return False; - - if (r_n->level != 0) { - if(!srv_io_srv_file_ctr("file_ctr", &r_n->ctr, ps, depth)) - return False; - } - - if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries)) - return False; - if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth)) - return False; - if(!prs_werror("status", ps, depth, &r_n->status)) - return False; - - return True; -} - -/******************************************************************* - Initialize a net file close request -********************************************************************/ -void init_srv_q_net_file_close(SRV_Q_NET_FILE_CLOSE *q_n, const char *server, - uint32 file_id) -{ - if ( server ) { - if ( (q_n->servername = TALLOC_P( get_talloc_ctx(), UNISTR2 )) == NULL ) { - return; - } - init_unistr2(q_n->servername, server, UNI_STR_TERMINATE); - } - - q_n->file_id = file_id; -} - -/******************************************************************* - Inits a SRV_INFO_100 structure. - ********************************************************************/ - -void init_srv_info_100(SRV_INFO_100 *sv100, uint32 platform_id, const char *name) -{ - DEBUG(5,("init_srv_info_100\n")); - - sv100->platform_id = platform_id; - init_buf_unistr2(&sv100->uni_name, &sv100->ptr_name, name); -} - -/******************************************************************* - Reads or writes a SRV_INFO_101 structure. - ********************************************************************/ - -static BOOL srv_io_info_100(const char *desc, SRV_INFO_100 *sv100, prs_struct *ps, int depth) -{ - if (sv100 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_info_100"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("platform_id ", ps, depth, &sv100->platform_id)) - return False; - if(!prs_uint32("ptr_name ", ps, depth, &sv100->ptr_name)) - return False; - - if(!smb_io_unistr2("uni_name ", &sv100->uni_name, True, ps, depth)) - return False; - - return True; -} - - -/******************************************************************* - Inits a SRV_INFO_101 structure. - ********************************************************************/ - -void init_srv_info_101(SRV_INFO_101 *sv101, uint32 platform_id, const char *name, - uint32 ver_major, uint32 ver_minor, - uint32 srv_type, const char *comment) -{ - DEBUG(5,("init_srv_info_101\n")); - - sv101->platform_id = platform_id; - init_buf_unistr2(&sv101->uni_name, &sv101->ptr_name, name); - sv101->ver_major = ver_major; - sv101->ver_minor = ver_minor; - sv101->srv_type = srv_type; - init_buf_unistr2(&sv101->uni_comment, &sv101->ptr_comment, comment); -} - -/******************************************************************* - Reads or writes a SRV_INFO_101 structure. - ********************************************************************/ - -static BOOL srv_io_info_101(const char *desc, SRV_INFO_101 *sv101, prs_struct *ps, int depth) -{ - if (sv101 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_info_101"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("platform_id ", ps, depth, &sv101->platform_id)) - return False; - if(!prs_uint32("ptr_name ", ps, depth, &sv101->ptr_name)) - return False; - if(!prs_uint32("ver_major ", ps, depth, &sv101->ver_major)) - return False; - if(!prs_uint32("ver_minor ", ps, depth, &sv101->ver_minor)) - return False; - if(!prs_uint32("srv_type ", ps, depth, &sv101->srv_type)) - return False; - if(!prs_uint32("ptr_comment ", ps, depth, &sv101->ptr_comment)) - return False; - - if(!prs_align(ps)) - return False; - - if(!smb_io_unistr2("uni_name ", &sv101->uni_name, True, ps, depth)) - return False; - if(!smb_io_unistr2("uni_comment ", &sv101->uni_comment, True, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Inits a SRV_INFO_102 structure. - ********************************************************************/ - -void init_srv_info_102(SRV_INFO_102 *sv102, uint32 platform_id, const char *name, - const char *comment, uint32 ver_major, uint32 ver_minor, - uint32 srv_type, uint32 users, uint32 disc, uint32 hidden, - uint32 announce, uint32 ann_delta, uint32 licenses, - const char *usr_path) -{ - DEBUG(5,("init_srv_info_102\n")); - - sv102->platform_id = platform_id; - init_buf_unistr2(&sv102->uni_name, &sv102->ptr_name, name); - sv102->ver_major = ver_major; - sv102->ver_minor = ver_minor; - sv102->srv_type = srv_type; - init_buf_unistr2(&sv102->uni_comment, &sv102->ptr_comment, comment); - - /* same as 101 up to here */ - - sv102->users = users; - sv102->disc = disc; - sv102->hidden = hidden; - sv102->announce = announce; - sv102->ann_delta = ann_delta; - sv102->licenses = licenses; - init_buf_unistr2(&sv102->uni_usr_path, &sv102->ptr_usr_path, usr_path); -} - - -/******************************************************************* - Reads or writes a SRV_INFO_102 structure. - ********************************************************************/ - -static BOOL srv_io_info_102(const char *desc, SRV_INFO_102 *sv102, prs_struct *ps, int depth) -{ - if (sv102 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_info102"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("platform_id ", ps, depth, &sv102->platform_id)) - return False; - if(!prs_uint32("ptr_name ", ps, depth, &sv102->ptr_name)) - return False; - if(!prs_uint32("ver_major ", ps, depth, &sv102->ver_major)) - return False; - if(!prs_uint32("ver_minor ", ps, depth, &sv102->ver_minor)) - return False; - if(!prs_uint32("srv_type ", ps, depth, &sv102->srv_type)) - return False; - if(!prs_uint32("ptr_comment ", ps, depth, &sv102->ptr_comment)) - return False; - - /* same as 101 up to here */ - - if(!prs_uint32("users ", ps, depth, &sv102->users)) - return False; - if(!prs_uint32("disc ", ps, depth, &sv102->disc)) - return False; - if(!prs_uint32("hidden ", ps, depth, &sv102->hidden)) - return False; - if(!prs_uint32("announce ", ps, depth, &sv102->announce)) - return False; - if(!prs_uint32("ann_delta ", ps, depth, &sv102->ann_delta)) - return False; - if(!prs_uint32("licenses ", ps, depth, &sv102->licenses)) - return False; - if(!prs_uint32("ptr_usr_path", ps, depth, &sv102->ptr_usr_path)) - return False; - - if(!smb_io_unistr2("uni_name ", &sv102->uni_name, True, ps, depth)) - return False; - if(!prs_align(ps)) - return False; - if(!smb_io_unistr2("uni_comment ", &sv102->uni_comment, True, ps, depth)) - return False; - if(!prs_align(ps)) - return False; - if(!smb_io_unistr2("uni_usr_path", &sv102->uni_usr_path, True, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a SRV_INFO_102 structure. - ********************************************************************/ - -static BOOL srv_io_info_ctr(const char *desc, SRV_INFO_CTR *ctr, prs_struct *ps, int depth) -{ - if (ctr == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_info_ctr"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value)) - return False; - if(!prs_uint32("ptr_srv_ctr ", ps, depth, &ctr->ptr_srv_ctr)) - return False; - - if (ctr->ptr_srv_ctr != 0 && ctr->switch_value != 0 && ctr != NULL) { - switch (ctr->switch_value) { - case 100: - if(!srv_io_info_100("sv100", &ctr->srv.sv100, ps, depth)) - return False; - break; - case 101: - if(!srv_io_info_101("sv101", &ctr->srv.sv101, ps, depth)) - return False; - break; - case 102: - if(!srv_io_info_102("sv102", &ctr->srv.sv102, ps, depth)) - return False; - break; - default: - DEBUG(5,("%s no server info at switch_value %d\n", - tab_depth(depth), ctr->switch_value)); - break; - } - if(!prs_align(ps)) - return False; - } - - return True; -} - -/******************************************************************* - Inits a SRV_Q_NET_SRV_GET_INFO structure. - ********************************************************************/ - -void init_srv_q_net_srv_get_info(SRV_Q_NET_SRV_GET_INFO *srv, - const char *server_name, uint32 switch_value) -{ - DEBUG(5,("init_srv_q_net_srv_get_info\n")); - - init_buf_unistr2(&srv->uni_srv_name, &srv->ptr_srv_name, server_name); - - srv->switch_value = switch_value; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL srv_io_q_net_srv_get_info(const char *desc, SRV_Q_NET_SRV_GET_INFO *q_n, prs_struct *ps, int depth) -{ - if (q_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_q_net_srv_get_info"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_srv_name ", ps, depth, &q_n->ptr_srv_name)) - return False; - if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("switch_value ", ps, depth, &q_n->switch_value)) - return False; - - return True; -} - -/******************************************************************* - Inits a SRV_R_NET_SRV_GET_INFO structure. - ********************************************************************/ - -void init_srv_r_net_srv_get_info(SRV_R_NET_SRV_GET_INFO *srv, - uint32 switch_value, SRV_INFO_CTR *ctr, WERROR status) -{ - DEBUG(5,("init_srv_r_net_srv_get_info\n")); - - srv->ctr = ctr; - - if (W_ERROR_IS_OK(status)) { - srv->ctr->switch_value = switch_value; - srv->ctr->ptr_srv_ctr = 1; - } else { - srv->ctr->switch_value = 0; - srv->ctr->ptr_srv_ctr = 0; - } - - srv->status = status; -} - -/******************************************************************* - Inits a SRV_R_NET_SRV_SET_INFO structure. - ********************************************************************/ - -void init_srv_r_net_srv_set_info(SRV_R_NET_SRV_SET_INFO *srv, - uint32 switch_value, WERROR status) -{ - DEBUG(5,("init_srv_r_net_srv_set_info\n")); - - srv->switch_value = switch_value; - srv->status = status; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL srv_io_q_net_srv_set_info(const char *desc, SRV_Q_NET_SRV_SET_INFO *q_n, - prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "srv_io_q_net_srv_set_info"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_srv_name ", ps, depth, &q_n->ptr_srv_name)) - return False; - if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("switch_value ", ps, depth, &q_n->switch_value)) - return False; - - if (UNMARSHALLING(ps)) { - q_n->ctr = PRS_ALLOC_MEM(ps, SRV_INFO_CTR, 1); - - if (!q_n->ctr) - return False; - } - - if(!srv_io_info_ctr("ctr", q_n->ctr, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. - ********************************************************************/ - -BOOL srv_io_r_net_srv_get_info(const char *desc, SRV_R_NET_SRV_GET_INFO *r_n, prs_struct *ps, int depth) -{ - if (r_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_r_net_srv_get_info"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!srv_io_info_ctr("ctr", r_n->ctr, ps, depth)) - return False; - - if(!prs_werror("status", ps, depth, &r_n->status)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. - ********************************************************************/ - -BOOL srv_io_r_net_srv_set_info(const char *desc, SRV_R_NET_SRV_SET_INFO *r_n, - prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "srv_io_r_net_srv_set_info"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("switch value ", ps, depth, &r_n->switch_value)) - return False; - - if(!prs_werror("status", ps, depth, &r_n->status)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. - ********************************************************************/ - -BOOL srv_io_q_net_remote_tod(const char *desc, SRV_Q_NET_REMOTE_TOD *q_n, prs_struct *ps, int depth) -{ - if (q_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_q_net_remote_tod"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_srv_name ", ps, depth, &q_n->ptr_srv_name)) - return False; - if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a TIME_OF_DAY_INFO structure. - ********************************************************************/ - -static BOOL srv_io_time_of_day_info(const char *desc, TIME_OF_DAY_INFO *tod, prs_struct *ps, int depth) -{ - if (tod == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_time_of_day_info"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("elapsedt ", ps, depth, &tod->elapsedt)) - return False; - if(!prs_uint32("msecs ", ps, depth, &tod->msecs)) - return False; - if(!prs_uint32("hours ", ps, depth, &tod->hours)) - return False; - if(!prs_uint32("mins ", ps, depth, &tod->mins)) - return False; - if(!prs_uint32("secs ", ps, depth, &tod->secs)) - return False; - if(!prs_uint32("hunds ", ps, depth, &tod->hunds)) - return False; - if(!prs_uint32("timezone ", ps, depth, &tod->zone)) - return False; - if(!prs_uint32("tintervals ", ps, depth, &tod->tintervals)) - return False; - if(!prs_uint32("day ", ps, depth, &tod->day)) - return False; - if(!prs_uint32("month ", ps, depth, &tod->month)) - return False; - if(!prs_uint32("year ", ps, depth, &tod->year)) - return False; - if(!prs_uint32("weekday ", ps, depth, &tod->weekday)) - return False; - - return True; -} - -/******************************************************************* - Inits a TIME_OF_DAY_INFO structure. - ********************************************************************/ - -void init_time_of_day_info(TIME_OF_DAY_INFO *tod, uint32 elapsedt, uint32 msecs, - uint32 hours, uint32 mins, uint32 secs, uint32 hunds, - uint32 zone, uint32 tintervals, uint32 day, - uint32 month, uint32 year, uint32 weekday) -{ - DEBUG(5,("init_time_of_day_info\n")); - - tod->elapsedt = elapsedt; - tod->msecs = msecs; - tod->hours = hours; - tod->mins = mins; - tod->secs = secs; - tod->hunds = hunds; - tod->zone = zone; - tod->tintervals = tintervals; - tod->day = day; - tod->month = month; - tod->year = year; - tod->weekday = weekday; -} - - -/******************************************************************* - Reads or writes a structure. - ********************************************************************/ - -BOOL srv_io_r_net_remote_tod(const char *desc, SRV_R_NET_REMOTE_TOD *r_n, prs_struct *ps, int depth) -{ - if (r_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_r_net_remote_tod"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_srv_tod ", ps, depth, &r_n->ptr_srv_tod)) - return False; - - if(!srv_io_time_of_day_info("tod", r_n->tod, ps, depth)) - return False; - - if(!prs_werror("status", ps, depth, &r_n->status)) - return False; - - return True; -} - -/******************************************************************* - initialises a structure. - ********************************************************************/ - -BOOL init_srv_q_net_disk_enum(SRV_Q_NET_DISK_ENUM *q_n, - const char *srv_name, - uint32 preferred_len, - ENUM_HND *enum_hnd - ) -{ - - - DEBUG(5,("init_srv_q_net_srv_disk_enum\n")); - - init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name); - - q_n->disk_enum_ctr.level = 0; - q_n->disk_enum_ctr.disk_info_ptr = 0; - - q_n->preferred_len = preferred_len; - memcpy(&q_n->enum_hnd, enum_hnd, sizeof(*enum_hnd)); - - return True; -} - -/******************************************************************* - Reads or writes a structure. - ********************************************************************/ - -BOOL srv_io_q_net_disk_enum(const char *desc, SRV_Q_NET_DISK_ENUM *q_n, prs_struct *ps, int depth) -{ - if (q_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_q_net_disk_enum"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name)) - return False; - - if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("level", ps, depth, &q_n->disk_enum_ctr.level)) - return False; - - if(!prs_uint32("entries_read", ps, depth, &q_n->disk_enum_ctr.entries_read)) - return False; - - if(!prs_uint32("buffer", ps, depth, &q_n->disk_enum_ctr.disk_info_ptr)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("preferred_len", ps, depth, &q_n->preferred_len)) - return False; - if(!smb_io_enum_hnd("enum_hnd", &q_n->enum_hnd, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. - ********************************************************************/ - -BOOL srv_io_r_net_disk_enum(const char *desc, SRV_R_NET_DISK_ENUM *r_n, prs_struct *ps, int depth) -{ - - unsigned int i; - uint32 entries_read, entries_read2, entries_read3; - - if (r_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_r_net_disk_enum"); - depth++; - - entries_read = entries_read2 = entries_read3 = r_n->disk_enum_ctr.entries_read; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("entries_read", ps, depth, &entries_read)) - return False; - if(!prs_uint32("ptr_disk_info", ps, depth, &r_n->disk_enum_ctr.disk_info_ptr)) - return False; - - /*this may be max, unknown, actual?*/ - - if(!prs_uint32("max_elements", ps, depth, &entries_read2)) - return False; - if(!prs_uint32("unknown", ps, depth, &r_n->disk_enum_ctr.unknown)) - return False; - if(!prs_uint32("actual_elements", ps, depth, &entries_read3)) - return False; - - r_n->disk_enum_ctr.entries_read = entries_read3; - - if(UNMARSHALLING(ps)) { - - DISK_INFO *dinfo; - - if(!(dinfo = PRS_ALLOC_MEM(ps, DISK_INFO, entries_read3))) - return False; - r_n->disk_enum_ctr.disk_info = dinfo; - } - - for(i=0; i < r_n->disk_enum_ctr.entries_read; i++) { - - if(!prs_uint32("unknown", ps, depth, &r_n->disk_enum_ctr.disk_info[i].unknown)) - return False; - - if(!smb_io_unistr3("disk_name", &r_n->disk_enum_ctr.disk_info[i].disk_name, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - } - - if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries)) - return False; - - if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth)) - return False; - - if(!prs_werror("status", ps, depth, &r_n->status)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. - ********************************************************************/ - -BOOL srv_io_q_net_name_validate(const char *desc, SRV_Q_NET_NAME_VALIDATE *q_n, prs_struct *ps, int depth) -{ - if (q_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_q_net_name_validate"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_pointer("servername", ps, depth, (void*)&q_n->servername, sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2)) - return False; - - if(!prs_align(ps)) - return False; - - if(!smb_io_unistr2("", &q_n->sharename, True, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("type", ps, depth, &q_n->type)) - return False; - - if(!prs_uint32("flags", ps, depth, &q_n->flags)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. - ********************************************************************/ - -BOOL srv_io_r_net_name_validate(const char *desc, SRV_R_NET_NAME_VALIDATE *r_n, prs_struct *ps, int depth) -{ - if (r_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_r_net_name_validate"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_werror("status", ps, depth, &r_n->status)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL srv_io_q_net_file_query_secdesc(const char *desc, SRV_Q_NET_FILE_QUERY_SECDESC *q_n, prs_struct *ps, int depth) -{ - if (q_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_q_net_file_query_secdesc"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name)) - return False; - - if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_qual_name", ps, depth, &q_n->ptr_qual_name)) - return False; - - if(!smb_io_unistr2("", &q_n->uni_qual_name, True, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!smb_io_unistr2("", &q_n->uni_file_name, True, ps, depth)) - return False; - - if(!prs_uint32("unknown1", ps, depth, &q_n->unknown1)) - return False; - - if(!prs_uint32("unknown2", ps, depth, &q_n->unknown2)) - return False; - - if(!prs_uint32("unknown3", ps, depth, &q_n->unknown3)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL srv_io_r_net_file_query_secdesc(const char *desc, SRV_R_NET_FILE_QUERY_SECDESC *r_n, prs_struct *ps, int depth) -{ - if (r_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_r_net_file_query_secdesc"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_response", ps, depth, &r_n->ptr_response)) - return False; - - if(!prs_uint32("size_response", ps, depth, &r_n->size_response)) - return False; - - if(!prs_uint32("ptr_secdesc", ps, depth, &r_n->ptr_secdesc)) - return False; - - if(!prs_uint32("size_secdesc", ps, depth, &r_n->size_secdesc)) - return False; - - if(!sec_io_desc("sec_desc", &r_n->sec_desc, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_werror("status", ps, depth, &r_n->status)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL srv_io_q_net_file_set_secdesc(const char *desc, SRV_Q_NET_FILE_SET_SECDESC *q_n, prs_struct *ps, int depth) -{ - if (q_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_q_net_file_set_secdesc"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name)) - return False; - - if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_qual_name", ps, depth, &q_n->ptr_qual_name)) - return False; - - if(!smb_io_unistr2("", &q_n->uni_qual_name, True, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!smb_io_unistr2("", &q_n->uni_file_name, True, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("sec_info", ps, depth, &q_n->sec_info)) - return False; - - if(!prs_uint32("size_set", ps, depth, &q_n->size_set)) - return False; - - if(!prs_uint32("ptr_secdesc", ps, depth, &q_n->ptr_secdesc)) - return False; - - if(!prs_uint32("size_secdesc", ps, depth, &q_n->size_secdesc)) - return False; - - if(!sec_io_desc("sec_desc", &q_n->sec_desc, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL srv_io_r_net_file_set_secdesc(const char *desc, SRV_R_NET_FILE_SET_SECDESC *r_n, prs_struct *ps, int depth) -{ - if (r_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_r_net_file_set_secdesc"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_werror("status", ps, depth, &r_n->status)) - return False; - - return True; -} - -/******************************************************************* - Inits a structure -********************************************************************/ - -void init_srv_q_net_remote_tod(SRV_Q_NET_REMOTE_TOD *q_u, const char *server) -{ - q_u->ptr_srv_name = 1; - init_unistr2(&q_u->uni_srv_name, server, UNI_STR_TERMINATE); -} - - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL srv_io_q_net_file_close(const char *desc, SRV_Q_NET_FILE_CLOSE *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_q_net_file_close"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_pointer("servername", ps, depth, (void*)&q_u->servername, sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2)) - return False; - if(!prs_align(ps)) - return False; - - if(!prs_uint32("file_id", ps, depth, &q_u->file_id)) - return False; - - return True; -} - -/******************************************************************* - ********************************************************************/ - -BOOL srv_io_r_net_file_close(const char *desc, SRV_R_NET_FILE_CLOSE *r_n, - prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "srv_io_r_net_file_close"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_werror("status", ps, depth, &r_n->status)) - return False; - - return True; -} diff --git a/source3/rpc_server/srv_echo_nt.c b/source3/rpc_server/srv_echo_nt.c index 221f4bc8b2..b6c5442e03 100644 --- a/source3/rpc_server/srv_echo_nt.c +++ b/source3/rpc_server/srv_echo_nt.c @@ -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 diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c deleted file mode 100644 index e4f85d0bdb..0000000000 --- a/source3/rpc_server/srv_srvsvc.c +++ /dev/null @@ -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)); -} diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 21032a4ed9..ecb907e72d 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -5,6 +5,7 @@ * Copyright (C) Jeremy Allison 2001. * Copyright (C) Nigel Williams 2001. * Copyright (C) Gerald (Jerry) Carter 2006. + * 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 @@ -25,6 +26,8 @@ #include "includes.h" +#define MAX_SERVER_DISK_ENTRIES 15 + extern struct generic_mapping file_generic_mapping; extern userdom_struct current_user_info; @@ -35,8 +38,8 @@ extern userdom_struct current_user_info; struct file_enum_count { TALLOC_CTX *ctx; - int count; - FILE_INFO_3 *info; + uint32 count; + struct srvsvc_NetFileInfo3 *info; }; struct sess_file_count { @@ -60,26 +63,25 @@ static int pipe_enum_fn( TDB_CONTEXT *the_tdb, TDB_DATA kbuf, TDB_DATA dbuf, voi memcpy(&prec, dbuf.dptr, sizeof(struct pipe_open_rec)); if ( process_exists(prec.pid) ) { - FILE_INFO_3 *f; + struct srvsvc_NetFileInfo3 *f; int i = fenum->count; pstring fullpath; snprintf( fullpath, sizeof(fullpath), "\\PIPE\\%s", prec.name ); - f = TALLOC_REALLOC_ARRAY( fenum->ctx, fenum->info, FILE_INFO_3, i+1 ); + f = TALLOC_REALLOC_ARRAY( fenum->ctx, fenum->info, struct srvsvc_NetFileInfo3, i+1 ); if ( !f ) { DEBUG(0,("conn_enum_fn: realloc failed for %d items\n", i+1)); return 1; } + fenum->info = f; - - init_srv_file_info3( &fenum->info[i], - (uint32)((procid_to_pid(&prec.pid)<<16) & prec.pnum), - (FILE_READ_DATA|FILE_WRITE_DATA), - 0, - uidtoname( prec.uid ), - fullpath ); + fenum->info[i].fid = (uint32)((procid_to_pid(&prec.pid)<<16) & prec.pnum); + fenum->info[i].permissions = (FILE_READ_DATA|FILE_WRITE_DATA); + fenum->info[i].num_locks = 0; + fenum->info[i].user = uidtoname( prec.uid ); + fenum->info[i].path = fullpath; fenum->count++; } @@ -90,8 +92,8 @@ static int pipe_enum_fn( TDB_CONTEXT *the_tdb, TDB_DATA kbuf, TDB_DATA dbuf, voi /******************************************************************* ********************************************************************/ -static WERROR net_enum_pipes( TALLOC_CTX *ctx, FILE_INFO_3 **info, - uint32 *count, uint32 resume ) +static WERROR net_enum_pipes( TALLOC_CTX *ctx, struct srvsvc_NetFileInfo3 **info, + uint32 *count, uint32 *resume ) { struct file_enum_count fenum; TDB_CONTEXT *conn_tdb = conn_tdb_ctx(); @@ -102,8 +104,8 @@ static WERROR net_enum_pipes( TALLOC_CTX *ctx, FILE_INFO_3 **info, } fenum.ctx = ctx; - fenum.count = *count; fenum.info = *info; + fenum.count = *count; if (tdb_traverse(conn_tdb, pipe_enum_fn, &fenum) == -1) { DEBUG(0,("net_enum_pipes: traverse of connections.tdb failed with error %s.\n", @@ -131,7 +133,7 @@ static void enum_file_fn( const struct share_mode_entry *e, /* If the pid was not found delete the entry from connections.tdb */ if ( process_exists(e->pid) ) { - FILE_INFO_3 *f; + struct srvsvc_NetFileInfo3 *f; int i = fenum->count; files_struct fsp; struct byte_range_lock *brl; @@ -139,7 +141,7 @@ static void enum_file_fn( const struct share_mode_entry *e, pstring fullpath; uint32 permissions; - f = TALLOC_REALLOC_ARRAY( fenum->ctx, fenum->info, FILE_INFO_3, i+1 ); + f = TALLOC_REALLOC_ARRAY( fenum->ctx, fenum->info, struct srvsvc_NetFileInfo3, i+1 ); if ( !f ) { DEBUG(0,("conn_enum_fn: realloc failed for %d items\n", i+1)); return; @@ -167,13 +169,11 @@ static void enum_file_fn( const struct share_mode_entry *e, /* mask out create (what ever that is) */ permissions = e->share_access & (FILE_READ_DATA|FILE_WRITE_DATA); - /* now fill in the FILE_INFO_3 struct */ - init_srv_file_info3( &fenum->info[i], - e->share_file_id, - permissions, - num_locks, - uidtoname(e->uid), - fullpath ); + fenum->info[i].fid = e->share_file_id; + fenum->info[i].permissions = permissions; + fenum->info[i].num_locks = num_locks; + fenum->info[i].user = uidtoname(e->uid); + fenum->info[i].path = fullpath; fenum->count++; } @@ -185,8 +185,8 @@ static void enum_file_fn( const struct share_mode_entry *e, /******************************************************************* ********************************************************************/ -static WERROR net_enum_files( TALLOC_CTX *ctx, FILE_INFO_3 **info, - uint32 *count, uint32 resume ) +static WERROR net_enum_files( TALLOC_CTX *ctx, struct srvsvc_NetFileInfo3 **info, + uint32 *count, uint32 *resume ) { f_enum_cnt.ctx = ctx; f_enum_cnt.count = *count; @@ -225,41 +225,36 @@ static uint32 get_share_type(const struct share_params *params) Fill in a share info level 0 structure. ********************************************************************/ -static void init_srv_share_info_0(pipes_struct *p, SRV_SHARE_INFO_0 *sh0, +static void init_srv_share_info_0(pipes_struct *p, struct srvsvc_NetShareInfo0 *sh0, const struct share_params *params) { - char *net_name = lp_servicename(params->service); - init_srv_share_info0(&sh0->info_0, net_name); - init_srv_share_info0_str(&sh0->info_0_str, net_name); + sh0->name = lp_servicename(params->service); } /******************************************************************* Fill in a share info level 1 structure. ********************************************************************/ -static void init_srv_share_info_1(pipes_struct *p, SRV_SHARE_INFO_1 *sh1, +static void init_srv_share_info_1(pipes_struct *p, struct srvsvc_NetShareInfo1 *sh1, const struct share_params *params) { connection_struct *conn = p->conn; - char *net_name = lp_servicename(params->service); - char *remark; - remark = talloc_sub_advanced(p->mem_ctx, lp_servicename(SNUM(conn)), + sh1->comment = talloc_sub_advanced(p->mem_ctx, lp_servicename(SNUM(conn)), conn->user, conn->connectpath, conn->gid, get_current_username(), current_user_info.domain, lp_comment(params->service)); - init_srv_share_info1(&sh1->info_1, net_name, get_share_type(params), - remark); - init_srv_share_info1_str(&sh1->info_1_str, net_name, remark); + sh1->name = lp_servicename(params->service); + sh1->type = get_share_type(params); } /******************************************************************* Fill in a share info level 2 structure. ********************************************************************/ -static void init_srv_share_info_2(pipes_struct *p, SRV_SHARE_INFO_2 *sh2, +static void init_srv_share_info_2(pipes_struct *p, struct srvsvc_NetShareInfo2 *sh2, const struct share_params *params) { connection_struct *conn = p->conn; @@ -286,10 +281,14 @@ static void init_srv_share_info_2(pipes_struct *p, SRV_SHARE_INFO_2 *sh2, string_replace(path, '/', '\\'); count = count_current_connections( net_name, False ); - init_srv_share_info2(&sh2->info_2, net_name, get_share_type(params), - remark, 0, max_uses, count, path, ""); - - init_srv_share_info2_str(&sh2->info_2_str, net_name, remark, path, ""); + sh2->name = net_name; + sh2->type = get_share_type(params); + sh2->comment = remark; + sh2->permissions = 0; + sh2->max_users = max_uses; + sh2->current_users = count; + sh2->path = path; + sh2->password = ""; } /******************************************************************* @@ -321,7 +320,7 @@ static void map_generic_share_sd_bits(SEC_DESC *psd) Fill in a share info level 501 structure. ********************************************************************/ -static void init_srv_share_info_501(pipes_struct *p, SRV_SHARE_INFO_501 *sh501, +static void init_srv_share_info_501(pipes_struct *p, struct srvsvc_NetShareInfo501 *sh501, const struct share_params *params) { connection_struct *conn = p->conn; @@ -334,20 +333,24 @@ static void init_srv_share_info_501(pipes_struct *p, SRV_SHARE_INFO_501 *sh501, current_user_info.domain, lp_comment(params->service)); - init_srv_share_info501(&sh501->info_501, net_name, - get_share_type(params), remark, - (lp_csc_policy(params->service) << 4)); - init_srv_share_info501_str(&sh501->info_501_str, net_name, remark); + + sh501->name = net_name; + sh501->type = get_share_type(params); + sh501->comment = remark; + sh501->csc_policy = (lp_csc_policy(params->service) << 4); } /******************************************************************* Fill in a share info level 502 structure. ********************************************************************/ -static void init_srv_share_info_502(pipes_struct *p, SRV_SHARE_INFO_502 *sh502, +static void init_srv_share_info_502(pipes_struct *p, struct srvsvc_NetShareInfo502 *sh502, const struct share_params *params) { + int max_connections = lp_max_connections(params->service); + uint32 max_uses = max_connections!=0 ? max_connections : 0xffffffff; connection_struct *conn = p->conn; + int count; char *net_name; char *remark; char *path; @@ -359,7 +362,8 @@ static void init_srv_share_info_502(pipes_struct *p, SRV_SHARE_INFO_502 *sh502, ZERO_STRUCTP(sh502); net_name = lp_servicename(params->service); - + count = count_current_connections( net_name, False ); + remark = talloc_sub_advanced(p->mem_ctx, lp_servicename(SNUM(conn)), conn->user, conn->connectpath, conn->gid, get_current_username(), @@ -379,11 +383,16 @@ static void init_srv_share_info_502(pipes_struct *p, SRV_SHARE_INFO_502 *sh502, sd = get_share_security(ctx, lp_servicename(params->service), &sd_size); - init_srv_share_info502(&sh502->info_502, net_name, - get_share_type(params), remark, 0, 0xffffffff, - 1, path, "", sd, sd_size); - init_srv_share_info502_str(&sh502->info_502_str, net_name, remark, - path, "", sd, sd_size); + sh502->name = net_name; + sh502->type = get_share_type(params); + sh502->comment = remark; + sh502->path = path; + sh502->password = ""; + sh502->sd = sd; + sh502->permissions = 0; + sh502->max_users = max_uses; + sh502->current_users = count; + sh502->unknown = 1; } /*************************************************************************** @@ -391,7 +400,7 @@ static void init_srv_share_info_502(pipes_struct *p, SRV_SHARE_INFO_502 *sh502, ***************************************************************************/ static void init_srv_share_info_1004(pipes_struct *p, - SRV_SHARE_INFO_1004* sh1004, + struct srvsvc_NetShareInfo1004* sh1004, const struct share_params *params) { connection_struct *conn = p->conn; @@ -404,9 +413,8 @@ static void init_srv_share_info_1004(pipes_struct *p, lp_comment(params->service)); ZERO_STRUCTP(sh1004); - - init_srv_share_info1004(&sh1004->info_1004, remark); - init_srv_share_info1004_str(&sh1004->info_1004_str, remark); + + sh1004->comment = remark; } /*************************************************************************** @@ -414,15 +422,15 @@ static void init_srv_share_info_1004(pipes_struct *p, ***************************************************************************/ static void init_srv_share_info_1005(pipes_struct *p, - SRV_SHARE_INFO_1005* sh1005, + struct srvsvc_NetShareInfo1005* sh1005, const struct share_params *params) { - sh1005->share_info_flags = 0; + sh1005->dfs_flags = 0; if(lp_host_msdfs() && lp_msdfs_root(params->service)) - sh1005->share_info_flags |= + sh1005->dfs_flags |= SHARE_1005_IN_DFS | SHARE_1005_DFS_ROOT; - sh1005->share_info_flags |= + sh1005->dfs_flags |= lp_csc_policy(params->service) << SHARE_1005_CSC_POLICY_SHIFT; } /*************************************************************************** @@ -430,10 +438,10 @@ static void init_srv_share_info_1005(pipes_struct *p, ***************************************************************************/ static void init_srv_share_info_1006(pipes_struct *p, - SRV_SHARE_INFO_1006* sh1006, + struct srvsvc_NetShareInfo1006* sh1006, const struct share_params *params) { - sh1006->max_uses = -1; + sh1006->max_users = -1; } /*************************************************************************** @@ -441,18 +449,15 @@ static void init_srv_share_info_1006(pipes_struct *p, ***************************************************************************/ static void init_srv_share_info_1007(pipes_struct *p, - SRV_SHARE_INFO_1007* sh1007, + struct srvsvc_NetShareInfo1007* sh1007, const struct share_params *params) { - pstring alternate_directory_name = ""; uint32 flags = 0; ZERO_STRUCTP(sh1007); - init_srv_share_info1007(&sh1007->info_1007, flags, - alternate_directory_name); - init_srv_share_info1007_str(&sh1007->info_1007_str, - alternate_directory_name); + sh1007->flags = flags; + sh1007->alternate_directory_name = ""; } /******************************************************************* @@ -460,7 +465,7 @@ static void init_srv_share_info_1007(pipes_struct *p, ********************************************************************/ static void init_srv_share_info_1501(pipes_struct *p, - SRV_SHARE_INFO_1501 *sh1501, + struct sec_desc_buf *sh1501, const struct share_params *params) { SEC_DESC *sd; @@ -472,7 +477,7 @@ static void init_srv_share_info_1501(pipes_struct *p, sd = get_share_security(ctx, lp_servicename(params->service), &sd_size); - sh1501->sdb = make_sec_desc_buf(p->mem_ctx, sd_size, sd); + sh1501->sd = sd; } /******************************************************************* @@ -491,20 +496,18 @@ static BOOL is_hidden_share(const struct share_params *params) ********************************************************************/ static WERROR init_srv_share_info_ctr(pipes_struct *p, - SRV_SHARE_INFO_CTR *ctr, + union srvsvc_NetShareCtr *ctr, uint32 info_level, uint32 *resume_hnd, uint32 *total_entries, BOOL all_shares) { - int num_entries = 0; TALLOC_CTX *ctx = p->mem_ctx; struct share_iterator *shares; struct share_params *share; DEBUG(5,("init_srv_share_info_ctr\n")); - ZERO_STRUCT(ctr->share); + ZERO_STRUCTP(ctr); - ctr->info_level = ctr->switch_value = info_level; *resume_hnd = 0; /* Ensure all the usershares are loaded. */ @@ -512,15 +515,50 @@ static WERROR init_srv_share_info_ctr(pipes_struct *p, load_usershare_shares(); unbecome_root(); - num_entries = 0; - - ZERO_STRUCT(ctr->share); + *total_entries = 0; if (!(shares = share_list_all(ctx))) { DEBUG(5, ("Could not list shares\n")); return WERR_ACCESS_DENIED; } + switch (info_level) { + case 0: + ctr->ctr0 = talloc_zero(p->mem_ctx, struct srvsvc_NetShareCtr0); + break; + case 1: + ctr->ctr1 = talloc_zero(p->mem_ctx, struct srvsvc_NetShareCtr1); + break; + case 2: + ctr->ctr2 = talloc_zero(p->mem_ctx, struct srvsvc_NetShareCtr2); + break; + case 501: + ctr->ctr501 = talloc_zero(p->mem_ctx, struct srvsvc_NetShareCtr501); + break; + case 502: + ctr->ctr502 = talloc_zero(p->mem_ctx, struct srvsvc_NetShareCtr502); + break; + case 1004: + ctr->ctr1004 = talloc_zero(p->mem_ctx, struct srvsvc_NetShareCtr1004); + break; + case 1005: + ctr->ctr1005 = talloc_zero(p->mem_ctx, struct srvsvc_NetShareCtr1005); + break; + case 1006: + ctr->ctr1006 = talloc_zero(p->mem_ctx, struct srvsvc_NetShareCtr1006); + break; + case 1007: + ctr->ctr1007 = talloc_zero(p->mem_ctx, struct srvsvc_NetShareCtr1007); + break; + case 1501: + ctr->ctr1501 = talloc_zero(p->mem_ctx, struct srvsvc_NetShareCtr1501); + break; + default: + DEBUG(5,("init_srv_share_info_ctr: unsupported switch " + "value %d\n", info_level)); + return WERR_UNKNOWN_LEVEL; + } + while ((share = next_share(shares)) != NULL) { if (!lp_browseable(share->service)) { continue; @@ -532,61 +570,66 @@ static WERROR init_srv_share_info_ctr(pipes_struct *p, switch (info_level) { case 0: { - SRV_SHARE_INFO_0 i; + struct srvsvc_NetShareInfo0 i; init_srv_share_info_0(p, &i, share); - ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_0, i, - &ctr->share.info0, &num_entries); - if (ctr->share.info0 == NULL) { + ADD_TO_ARRAY(ctx, struct srvsvc_NetShareInfo0, i, + &ctr->ctr0->array, &ctr->ctr0->count); + if (ctr->ctr0->array == NULL) { return WERR_NOMEM; } + *total_entries = ctr->ctr0->count; break; } case 1: { - SRV_SHARE_INFO_1 i; + struct srvsvc_NetShareInfo1 i; init_srv_share_info_1(p, &i, share); - ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_1, i, - &ctr->share.info1, &num_entries); - if (ctr->share.info1 == NULL) { + ADD_TO_ARRAY(ctx, struct srvsvc_NetShareInfo1, i, + &ctr->ctr1->array, &ctr->ctr1->count); + if (ctr->ctr1->array == NULL) { return WERR_NOMEM; } + *total_entries = ctr->ctr1->count; break; } case 2: { - SRV_SHARE_INFO_2 i; + struct srvsvc_NetShareInfo2 i; init_srv_share_info_2(p, &i, share); - ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_2, i, - &ctr->share.info2, &num_entries); - if (ctr->share.info2 == NULL) { + ADD_TO_ARRAY(ctx, struct srvsvc_NetShareInfo2, i, + &ctr->ctr2->array, &ctr->ctr2->count); + if (ctr->ctr2->array == NULL) { return WERR_NOMEM; } + *total_entries = ctr->ctr2->count; break; } case 501: { - SRV_SHARE_INFO_501 i; + struct srvsvc_NetShareInfo501 i; init_srv_share_info_501(p, &i, share); - ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_501, i, - &ctr->share.info501, &num_entries); - if (ctr->share.info501 == NULL) { + ADD_TO_ARRAY(ctx, struct srvsvc_NetShareInfo501, i, + &ctr->ctr501->array, &ctr->ctr501->count); + if (ctr->ctr501->array == NULL) { return WERR_NOMEM; } + *total_entries = ctr->ctr501->count; break; } case 502: { - SRV_SHARE_INFO_502 i; + struct srvsvc_NetShareInfo502 i; init_srv_share_info_502(p, &i, share); - ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_502, i, - &ctr->share.info502, &num_entries); - if (ctr->share.info502 == NULL) { + ADD_TO_ARRAY(ctx, struct srvsvc_NetShareInfo502, i, + &ctr->ctr502->array, &ctr->ctr502->count); + if (ctr->ctr502->array == NULL) { return WERR_NOMEM; } + *total_entries = ctr->ctr502->count; break; } @@ -595,176 +638,81 @@ static WERROR init_srv_share_info_ctr(pipes_struct *p, case 1004: { - SRV_SHARE_INFO_1004 i; + struct srvsvc_NetShareInfo1004 i; init_srv_share_info_1004(p, &i, share); - ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_1004, i, - &ctr->share.info1004, &num_entries); - if (ctr->share.info1004 == NULL) { + ADD_TO_ARRAY(ctx, struct srvsvc_NetShareInfo1004, i, + &ctr->ctr1004->array, &ctr->ctr1004->count); + if (ctr->ctr1004->array == NULL) { return WERR_NOMEM; } + *total_entries = ctr->ctr1004->count; break; } case 1005: { - SRV_SHARE_INFO_1005 i; + struct srvsvc_NetShareInfo1005 i; init_srv_share_info_1005(p, &i, share); - ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_1005, i, - &ctr->share.info1005, &num_entries); - if (ctr->share.info1005 == NULL) { + ADD_TO_ARRAY(ctx, struct srvsvc_NetShareInfo1005, i, + &ctr->ctr1005->array, &ctr->ctr1005->count); + if (ctr->ctr1005->array == NULL) { return WERR_NOMEM; } + *total_entries = ctr->ctr1005->count; break; } case 1006: { - SRV_SHARE_INFO_1006 i; + struct srvsvc_NetShareInfo1006 i; init_srv_share_info_1006(p, &i, share); - ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_1006, i, - &ctr->share.info1006, &num_entries); - if (ctr->share.info1006 == NULL) { + ADD_TO_ARRAY(ctx, struct srvsvc_NetShareInfo1006, i, + &ctr->ctr1006->array, &ctr->ctr1006->count); + if (ctr->ctr1006->array == NULL) { return WERR_NOMEM; } + *total_entries = ctr->ctr1006->count; break; } case 1007: { - SRV_SHARE_INFO_1007 i; + struct srvsvc_NetShareInfo1007 i; init_srv_share_info_1007(p, &i, share); - ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_1007, i, - &ctr->share.info1007, &num_entries); - if (ctr->share.info1007 == NULL) { + ADD_TO_ARRAY(ctx, struct srvsvc_NetShareInfo1007, i, + &ctr->ctr1007->array, &ctr->ctr1007->count); + if (ctr->ctr1007->array == NULL) { return WERR_NOMEM; } + *total_entries = ctr->ctr1007->count; break; } case 1501: { - SRV_SHARE_INFO_1501 i; + struct sec_desc_buf i; init_srv_share_info_1501(p, &i, share); - ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_1501, i, - &ctr->share.info1501, &num_entries); - if (ctr->share.info1501 == NULL) { + ADD_TO_ARRAY(ctx, struct sec_desc_buf, i, + &ctr->ctr1501->array, &ctr->ctr1501->count); + if (ctr->ctr1501->array == NULL) { return WERR_NOMEM; } + *total_entries = ctr->ctr1501->count; break; } - default: - DEBUG(5,("init_srv_share_info_ctr: unsupported switch " - "value %d\n", info_level)); - return WERR_UNKNOWN_LEVEL; } TALLOC_FREE(share); } - *total_entries = num_entries; - ctr->num_entries2 = ctr->num_entries = num_entries; - ctr->ptr_share_info = ctr->ptr_entries = 1; - return WERR_OK; } /******************************************************************* - Inits a SRV_R_NET_SHARE_ENUM structure. -********************************************************************/ - -static void init_srv_r_net_share_enum(pipes_struct *p, SRV_R_NET_SHARE_ENUM *r_n, - uint32 info_level, uint32 resume_hnd, BOOL all) -{ - DEBUG(5,("init_srv_r_net_share_enum: %d\n", __LINE__)); - - r_n->status = init_srv_share_info_ctr(p, &r_n->ctr, info_level, - &resume_hnd, - &r_n->total_entries, all); - - init_enum_hnd(&r_n->enum_hnd, resume_hnd); -} - -/******************************************************************* - Inits a SRV_R_NET_SHARE_GET_INFO structure. -********************************************************************/ - -static void init_srv_r_net_share_get_info(pipes_struct *p, SRV_R_NET_SHARE_GET_INFO *r_n, - char *share_name, uint32 info_level) -{ - WERROR status = WERR_OK; - const struct share_params *params; - - DEBUG(5,("init_srv_r_net_share_get_info: %d\n", __LINE__)); - - r_n->info.switch_value = info_level; - - params = get_share_params(p->mem_ctx, share_name); - - if (params != NULL) { - switch (info_level) { - case 0: - init_srv_share_info_0(p, &r_n->info.share.info0, - params); - break; - case 1: - init_srv_share_info_1(p, &r_n->info.share.info1, - params); - break; - case 2: - init_srv_share_info_2(p, &r_n->info.share.info2, - params); - break; - case 501: - init_srv_share_info_501(p, &r_n->info.share.info501, - params); - break; - case 502: - init_srv_share_info_502(p, &r_n->info.share.info502, - params); - break; - - /* here for completeness */ - case 1004: - init_srv_share_info_1004(p, &r_n->info.share.info1004, - params); - break; - case 1005: - init_srv_share_info_1005(p, &r_n->info.share.info1005, - params); - break; - - /* here for completeness 1006 - 1501 */ - case 1006: - init_srv_share_info_1006(p, &r_n->info.share.info1006, - params); - break; - case 1007: - init_srv_share_info_1007(p, &r_n->info.share.info1007, - params); - break; - case 1501: - init_srv_share_info_1501(p, &r_n->info.share.info1501, - params); - break; - default: - DEBUG(5,("init_srv_net_share_get_info: unsupported " - "switch value %d\n", info_level)); - status = WERR_UNKNOWN_LEVEL; - break; - } - } else { - status = WERR_INVALID_NAME; - } - - r_n->info.ptr_share_ctr = W_ERROR_IS_OK(status) ? 1 : 0; - r_n->status = status; -} - -/******************************************************************* fill in a sess info level 0 structure. ********************************************************************/ -static void init_srv_sess_info_0(SRV_SESS_INFO_0 *ss0, uint32 *snum, uint32 *stot) +static void init_srv_sess_info_0(pipes_struct *p, struct srvsvc_NetSessCtr0 *ss0, uint32 *snum, uint32 *stot) { struct sessionid *session_list; uint32 num_entries = 0; @@ -780,24 +728,23 @@ static void init_srv_sess_info_0(SRV_SESS_INFO_0 *ss0, uint32 *snum, uint32 *sto DEBUG(5,("init_srv_sess_0_ss0\n")); + ss0->array = talloc_array(p->mem_ctx, struct srvsvc_NetSessInfo0, *stot); + if (snum) { - for (; (*snum) < (*stot) && num_entries < MAX_SESS_ENTRIES; (*snum)++) { - init_srv_sess_info0( &ss0->info_0[num_entries], session_list[(*snum)].remote_machine); + for (; (*snum) < (*stot); (*snum)++) { + ss0->array[num_entries].client = session_list[(*snum)].remote_machine; num_entries++; } - ss0->num_entries_read = num_entries; - ss0->ptr_sess_info = num_entries > 0 ? 1 : 0; - ss0->num_entries_read2 = num_entries; + ss0->count = num_entries; if ((*snum) >= (*stot)) { (*snum) = 0; } } else { - ss0->num_entries_read = 0; - ss0->ptr_sess_info = 0; - ss0->num_entries_read2 = 0; + ss0->array = NULL; + ss0->count = 0; } SAFE_FREE(session_list); } @@ -838,16 +785,15 @@ static int net_count_files( uid_t uid, pid_t pid ) fill in a sess info level 1 structure. ********************************************************************/ -static void init_srv_sess_info_1(SRV_SESS_INFO_1 *ss1, uint32 *snum, uint32 *stot) +static void init_srv_sess_info_1(pipes_struct *p, struct srvsvc_NetSessCtr1 *ss1, uint32 *snum, uint32 *stot) { struct sessionid *session_list; uint32 num_entries = 0; time_t now = time(NULL); if ( !snum ) { - ss1->num_entries_read = 0; - ss1->ptr_sess_info = 0; - ss1->num_entries_read2 = 0; + ss1->count = 0; + ss1->array = NULL; (*stot) = 0; @@ -860,9 +806,10 @@ static void init_srv_sess_info_1(SRV_SESS_INFO_1 *ss1, uint32 *snum, uint32 *sto } (*stot) = list_sessions(&session_list); - - for (; (*snum) < (*stot) && num_entries < MAX_SESS_ENTRIES; (*snum)++) { + ss1->array = talloc_array(p->mem_ctx, struct srvsvc_NetSessInfo1, *stot); + + for (; (*snum) < (*stot); (*snum)++) { uint32 num_files; uint32 connect_time; struct passwd *pw = sys_getpwnam(session_list[*snum].username); @@ -878,19 +825,17 @@ static void init_srv_sess_info_1(SRV_SESS_INFO_1 *ss1, uint32 *snum, uint32 *sto num_files = net_count_files(pw->pw_uid, session_list[*snum].pid); guest = strequal( session_list[*snum].username, lp_guestaccount() ); - init_srv_sess_info1( &ss1->info_1[num_entries], - session_list[*snum].remote_machine, - session_list[*snum].username, - num_files, - connect_time, - 0, - guest); + ss1->array[num_entries].client = session_list[*snum].remote_machine; + ss1->array[num_entries].user = session_list[*snum].username; + ss1->array[num_entries].num_open = num_files; + ss1->array[num_entries].time = connect_time; + ss1->array[num_entries].idle_time = 0; + ss1->array[num_entries].user_flags = guest; + num_entries++; } - ss1->num_entries_read = num_entries; - ss1->ptr_sess_info = num_entries > 0 ? 1 : 0; - ss1->num_entries_read2 = num_entries; + ss1->count = num_entries; if ((*snum) >= (*stot)) { (*snum) = 0; @@ -903,28 +848,26 @@ static void init_srv_sess_info_1(SRV_SESS_INFO_1 *ss1, uint32 *snum, uint32 *sto makes a SRV_R_NET_SESS_ENUM structure. ********************************************************************/ -static WERROR init_srv_sess_info_ctr(SRV_SESS_INFO_CTR *ctr, +static WERROR init_srv_sess_info_ctr(pipes_struct *p, union srvsvc_NetSessCtr *ctr, int switch_value, uint32 *resume_hnd, uint32 *total_entries) { WERROR status = WERR_OK; DEBUG(5,("init_srv_sess_info_ctr: %d\n", __LINE__)); - ctr->switch_value = switch_value; - switch (switch_value) { case 0: - init_srv_sess_info_0(&(ctr->sess.info0), resume_hnd, total_entries); - ctr->ptr_sess_ctr = 1; + ctr->ctr0 = talloc(p->mem_ctx, struct srvsvc_NetSessCtr0); + init_srv_sess_info_0(p, ctr->ctr0, resume_hnd, total_entries); break; case 1: - init_srv_sess_info_1(&(ctr->sess.info1), resume_hnd, total_entries); - ctr->ptr_sess_ctr = 1; + ctr->ctr1 = talloc(p->mem_ctx, struct srvsvc_NetSessCtr1); + init_srv_sess_info_1(p, ctr->ctr1, resume_hnd, total_entries); break; default: DEBUG(5,("init_srv_sess_info_ctr: unsupported switch value %d\n", switch_value)); (*resume_hnd) = 0; (*total_entries) = 0; - ctr->ptr_sess_ctr = 0; + ctr->ctr0 = NULL; status = WERR_UNKNOWN_LEVEL; break; } @@ -933,32 +876,10 @@ static WERROR init_srv_sess_info_ctr(SRV_SESS_INFO_CTR *ctr, } /******************************************************************* - makes a SRV_R_NET_SESS_ENUM structure. -********************************************************************/ - -static void init_srv_r_net_sess_enum(SRV_R_NET_SESS_ENUM *r_n, - uint32 resume_hnd, int sess_level, int switch_value) -{ - DEBUG(5,("init_srv_r_net_sess_enum: %d\n", __LINE__)); - - r_n->sess_level = sess_level; - - if (sess_level == -1) - r_n->status = WERR_UNKNOWN_LEVEL; - else - r_n->status = init_srv_sess_info_ctr(r_n->ctr, switch_value, &resume_hnd, &r_n->total_entries); - - if (!W_ERROR_IS_OK(r_n->status)) - resume_hnd = 0; - - init_enum_hnd(&r_n->enum_hnd, resume_hnd); -} - -/******************************************************************* fill in a conn info level 0 structure. ********************************************************************/ -static void init_srv_conn_info_0(SRV_CONN_INFO_0 *ss0, uint32 *snum, uint32 *stot) +static void init_srv_conn_info_0(pipes_struct *p, struct srvsvc_NetConnCtr0 *ss0, uint32 *snum, uint32 *stot) { uint32 num_entries = 0; (*stot) = 1; @@ -971,27 +892,25 @@ static void init_srv_conn_info_0(SRV_CONN_INFO_0 *ss0, uint32 *snum, uint32 *sto DEBUG(5,("init_srv_conn_0_ss0\n")); if (snum) { - for (; (*snum) < (*stot) && num_entries < MAX_CONN_ENTRIES; (*snum)++) { + ss0->array = talloc_array(p->mem_ctx, struct srvsvc_NetConnInfo0, *stot); + for (; (*snum) < (*stot); (*snum)++) { - init_srv_conn_info0(&ss0->info_0[num_entries], (*stot)); + ss0->array[num_entries].conn_id = (*stot); /* move on to creating next connection */ /* move on to creating next conn */ num_entries++; } - ss0->num_entries_read = num_entries; - ss0->ptr_conn_info = num_entries > 0 ? 1 : 0; - ss0->num_entries_read2 = num_entries; + ss0->count = num_entries; if ((*snum) >= (*stot)) { (*snum) = 0; } } else { - ss0->num_entries_read = 0; - ss0->ptr_conn_info = 0; - ss0->num_entries_read2 = 0; + ss0->array = NULL; + ss0->count = 0; (*stot) = 0; } @@ -1001,20 +920,7 @@ static void init_srv_conn_info_0(SRV_CONN_INFO_0 *ss0, uint32 *snum, uint32 *sto fill in a conn info level 1 structure. ********************************************************************/ -static void init_srv_conn_1_info(CONN_INFO_1 *se1, CONN_INFO_1_STR *str1, - uint32 id, uint32 type, - uint32 num_opens, uint32 num_users, uint32 open_time, - const char *usr_name, const char *net_name) -{ - init_srv_conn_info1(se1 , id, type, num_opens, num_users, open_time, usr_name, net_name); - init_srv_conn_info1_str(str1, usr_name, net_name); -} - -/******************************************************************* - fill in a conn info level 1 structure. - ********************************************************************/ - -static void init_srv_conn_info_1(SRV_CONN_INFO_1 *ss1, uint32 *snum, uint32 *stot) +static void init_srv_conn_info_1(pipes_struct *p, struct srvsvc_NetConnCtr1 *ss1, uint32 *snum, uint32 *stot) { uint32 num_entries = 0; (*stot) = 1; @@ -1027,29 +933,30 @@ static void init_srv_conn_info_1(SRV_CONN_INFO_1 *ss1, uint32 *snum, uint32 *sto DEBUG(5,("init_srv_conn_1_ss1\n")); if (snum) { - for (; (*snum) < (*stot) && num_entries < MAX_CONN_ENTRIES; (*snum)++) { - init_srv_conn_1_info(&ss1->info_1[num_entries], - &ss1->info_1_str[num_entries], - (*stot), 0x3, 1, 1, 3,"dummy_user", "IPC$"); + ss1->array = talloc_array(p->mem_ctx, struct srvsvc_NetConnInfo1, *stot); + for (; (*snum) < (*stot); (*snum)++) { + ss1->array[num_entries].conn_id = (*stot); + ss1->array[num_entries].conn_type = 0x3; + ss1->array[num_entries].num_open = 1; + ss1->array[num_entries].num_users = 1; + ss1->array[num_entries].conn_time = 3; + ss1->array[num_entries].user = "dummy_user"; + ss1->array[num_entries].share = "IPC$"; /* move on to creating next connection */ /* move on to creating next conn */ num_entries++; } - ss1->num_entries_read = num_entries; - ss1->ptr_conn_info = num_entries > 0 ? 1 : 0; - ss1->num_entries_read2 = num_entries; - + ss1->count = num_entries; if ((*snum) >= (*stot)) { (*snum) = 0; } } else { - ss1->num_entries_read = 0; - ss1->ptr_conn_info = 0; - ss1->num_entries_read2 = 0; + ss1->count = 0; + ss1->array = NULL; (*stot) = 0; } @@ -1059,28 +966,24 @@ static void init_srv_conn_info_1(SRV_CONN_INFO_1 *ss1, uint32 *snum, uint32 *sto makes a SRV_R_NET_CONN_ENUM structure. ********************************************************************/ -static WERROR init_srv_conn_info_ctr(SRV_CONN_INFO_CTR *ctr, +static WERROR init_srv_conn_info_ctr(pipes_struct *p, union srvsvc_NetConnCtr *ctr, int switch_value, uint32 *resume_hnd, uint32 *total_entries) { WERROR status = WERR_OK; DEBUG(5,("init_srv_conn_info_ctr: %d\n", __LINE__)); - ctr->switch_value = switch_value; - switch (switch_value) { case 0: - init_srv_conn_info_0(&ctr->conn.info0, resume_hnd, total_entries); - ctr->ptr_conn_ctr = 1; + init_srv_conn_info_0(p, ctr->ctr0, resume_hnd, total_entries); break; case 1: - init_srv_conn_info_1(&ctr->conn.info1, resume_hnd, total_entries); - ctr->ptr_conn_ctr = 1; + init_srv_conn_info_1(p, ctr->ctr1, resume_hnd, total_entries); break; default: DEBUG(5,("init_srv_conn_info_ctr: unsupported switch value %d\n", switch_value)); - (*resume_hnd = 0); + ctr->ctr0 = NULL; + (*resume_hnd) = 0; (*total_entries) = 0; - ctr->ptr_conn_ctr = 0; status = WERR_UNKNOWN_LEVEL; break; } @@ -1089,72 +992,41 @@ static WERROR init_srv_conn_info_ctr(SRV_CONN_INFO_CTR *ctr, } /******************************************************************* - makes a SRV_R_NET_CONN_ENUM structure. -********************************************************************/ - -static void init_srv_r_net_conn_enum(SRV_R_NET_CONN_ENUM *r_n, - uint32 resume_hnd, int conn_level, int switch_value) -{ - DEBUG(5,("init_srv_r_net_conn_enum: %d\n", __LINE__)); - - r_n->conn_level = conn_level; - if (conn_level == -1) - r_n->status = WERR_UNKNOWN_LEVEL; - else - r_n->status = init_srv_conn_info_ctr(r_n->ctr, switch_value, &resume_hnd, &r_n->total_entries); - - if (!W_ERROR_IS_OK(r_n->status)) - resume_hnd = 0; - - init_enum_hnd(&r_n->enum_hnd, resume_hnd); -} - -/******************************************************************* makes a SRV_R_NET_FILE_ENUM structure. ********************************************************************/ -static WERROR net_file_enum_3( SRV_R_NET_FILE_ENUM *r, uint32 resume_hnd ) +static WERROR net_file_enum_3(pipes_struct *p, union srvsvc_NetFileCtr *ctr, uint32 *resume_hnd, uint32 *num_entries ) { TALLOC_CTX *ctx = get_talloc_ctx(); - SRV_FILE_INFO_CTR *ctr = &r->ctr; + WERROR status; /* TODO -- Windows enumerates (b) active pipes (c) open directories and files */ - r->status = net_enum_files( ctx, &ctr->file.info3, &ctr->num_entries, resume_hnd ); - if ( !W_ERROR_IS_OK(r->status)) - goto done; - - r->status = net_enum_pipes( ctx, &ctr->file.info3, &ctr->num_entries, resume_hnd ); - if ( !W_ERROR_IS_OK(r->status)) - goto done; + ctr->ctr3 = talloc_zero(p->mem_ctx, struct srvsvc_NetFileCtr3); - r->level = ctr->level = 3; - r->total_entries = ctr->num_entries; - /* ctr->num_entries = r->total_entries - resume_hnd; */ - ctr->num_entries2 = ctr->num_entries; - ctr->ptr_file_info = 1; - - r->status = WERR_OK; - -done: - if ( ctr->num_entries > 0 ) - ctr->ptr_entries = 1; - - init_enum_hnd(&r->enum_hnd, 0); + status = net_enum_files( ctx, &ctr->ctr3->array, num_entries, resume_hnd ); + if ( !W_ERROR_IS_OK(status)) + return status; + + status = net_enum_pipes( ctx, &ctr->ctr3->array, num_entries, resume_hnd ); + if ( !W_ERROR_IS_OK(status)) + return status; - return r->status; + ctr->ctr3->count = *num_entries; + + return WERR_OK; } /******************************************************************* *******************************************************************/ -WERROR _srv_net_file_enum(pipes_struct *p, SRV_Q_NET_FILE_ENUM *q_u, SRV_R_NET_FILE_ENUM *r_u) +WERROR _srvsvc_NetFileEnum(pipes_struct *p, const char *server_unc, const char *path, const char *user, uint32_t *level, union srvsvc_NetFileCtr *ctr, uint32_t max_buffer, uint32_t *totalentries, uint32_t *resume_handle) { - switch ( q_u->level ) { + switch ( *level ) { case 3: - return net_file_enum_3( r_u, get_enum_hnd(&q_u->enum_hnd) ); + return net_file_enum_3(p, ctr, resume_handle, totalentries ); default: return WERR_UNKNOWN_LEVEL; } @@ -1166,15 +1038,11 @@ WERROR _srv_net_file_enum(pipes_struct *p, SRV_Q_NET_FILE_ENUM *q_u, SRV_R_NET_F net server get info ********************************************************************/ -WERROR _srv_net_srv_get_info(pipes_struct *p, SRV_Q_NET_SRV_GET_INFO *q_u, SRV_R_NET_SRV_GET_INFO *r_u) +WERROR _srvsvc_NetSrvGetInfo(pipes_struct *p, const char *server_unc, uint32_t level, union srvsvc_NetSrvInfo *info) { WERROR status = WERR_OK; - SRV_INFO_CTR *ctr = TALLOC_P(p->mem_ctx, SRV_INFO_CTR); - if (!ctr) - return WERR_NOMEM; - - ZERO_STRUCTP(ctr); + ZERO_STRUCTP(info); DEBUG(5,("srv_net_srv_get_info: %d\n", __LINE__)); @@ -1183,131 +1051,106 @@ WERROR _srv_net_srv_get_info(pipes_struct *p, SRV_Q_NET_SRV_GET_INFO *q_u, SRV_R return WERR_ACCESS_DENIED; } - switch (q_u->switch_value) { + switch (level) { /* Technically level 102 should only be available to Administrators but there isn't anything super-secret here, as most of it is made up. */ case 102: - init_srv_info_102(&ctr->srv.sv102, - 500, global_myname(), - string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH), - lp_major_announce_version(), lp_minor_announce_version(), - lp_default_server_announce(), - 0xffffffff, /* users */ - 0xf, /* disc */ - 0, /* hidden */ - 240, /* announce */ - 3000, /* announce delta */ - 100000, /* licenses */ - "c:\\"); /* user path */ + info->info102 = talloc_zero(p->mem_ctx, struct srvsvc_NetSrvInfo102); + + info->info102->platform_id = 500; + info->info102->version_major = lp_major_announce_version(); + info->info102->version_minor = lp_minor_announce_version(); + info->info102->server_name = global_myname(); + info->info102->server_type = lp_default_server_announce(); + info->info102->userpath = "C:\\"; + info->info102->licenses = 10000; + info->info102->anndelta = 3000; + info->info102->disc = 0xf; + info->info102->users = 0xffffffff; + info->info102->hidden = 0; + info->info102->announce = 240; + info->info102->comment = lp_serverstring(); break; case 101: - init_srv_info_101(&ctr->srv.sv101, - 500, global_myname(), - lp_major_announce_version(), lp_minor_announce_version(), - lp_default_server_announce(), - string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH)); + info->info101 = talloc_zero(p->mem_ctx, struct srvsvc_NetSrvInfo101); + info->info101->platform_id = 500; + info->info101->server_name = global_myname(); + info->info101->version_major = lp_major_announce_version(); + info->info101->version_minor = lp_minor_announce_version(); + info->info101->server_type = lp_default_server_announce(); + info->info101->comment = lp_serverstring(); break; case 100: - init_srv_info_100(&ctr->srv.sv100, 500, global_myname()); + info->info100 = talloc_zero(p->mem_ctx, struct srvsvc_NetSrvInfo100); + info->info100->platform_id = 500; + info->info100->server_name = global_myname(); break; default: - status = WERR_UNKNOWN_LEVEL; + return WERR_UNKNOWN_LEVEL; break; } - /* set up the net server get info structure */ - init_srv_r_net_srv_get_info(r_u, q_u->switch_value, ctr, status); - DEBUG(5,("srv_net_srv_get_info: %d\n", __LINE__)); - return r_u->status; + return status; } /******************************************************************* net server set info ********************************************************************/ -WERROR _srv_net_srv_set_info(pipes_struct *p, SRV_Q_NET_SRV_SET_INFO *q_u, SRV_R_NET_SRV_SET_INFO *r_u) +WERROR _srvsvc_NetSrvSetInfo(pipes_struct *p, const char *server_unc, uint32_t level, union srvsvc_NetSrvInfo info, uint32_t *parm_error) { - WERROR status = WERR_OK; - - DEBUG(5,("srv_net_srv_set_info: %d\n", __LINE__)); - /* Set up the net server set info structure. */ - - init_srv_r_net_srv_set_info(r_u, 0x0, status); - - DEBUG(5,("srv_net_srv_set_info: %d\n", __LINE__)); - - return r_u->status; + *parm_error = 0; + return WERR_OK; } /******************************************************************* net conn enum ********************************************************************/ -WERROR _srv_net_conn_enum(pipes_struct *p, SRV_Q_NET_CONN_ENUM *q_u, SRV_R_NET_CONN_ENUM *r_u) +WERROR _srvsvc_NetConnEnum(pipes_struct *p, const char *server_unc, const char *path, uint32_t *level, union srvsvc_NetConnCtr *ctr, uint32_t max_buffer, uint32_t *totalentries, uint32_t *resume_handle) { DEBUG(5,("srv_net_conn_enum: %d\n", __LINE__)); - r_u->ctr = TALLOC_P(p->mem_ctx, SRV_CONN_INFO_CTR); - if (!r_u->ctr) - return WERR_NOMEM; - - ZERO_STRUCTP(r_u->ctr); + ZERO_STRUCTP(ctr); /* set up the */ - init_srv_r_net_conn_enum(r_u, - get_enum_hnd(&q_u->enum_hnd), - q_u->conn_level, - q_u->ctr->switch_value); - - DEBUG(5,("srv_net_conn_enum: %d\n", __LINE__)); - - return r_u->status; + return init_srv_conn_info_ctr(p, ctr, *level, resume_handle, totalentries); } /******************************************************************* net sess enum ********************************************************************/ -WERROR _srv_net_sess_enum(pipes_struct *p, SRV_Q_NET_SESS_ENUM *q_u, SRV_R_NET_SESS_ENUM *r_u) +WERROR _srvsvc_NetSessEnum(pipes_struct *p, const char *server_unc, const char *client, const char *user, uint32_t *level, union srvsvc_NetSessCtr *ctr, uint32_t max_buffer, uint32_t *totalentries, uint32_t *resume_handle) { DEBUG(5,("_srv_net_sess_enum: %d\n", __LINE__)); - r_u->ctr = TALLOC_P(p->mem_ctx, SRV_SESS_INFO_CTR); - if (!r_u->ctr) - return WERR_NOMEM; - - ZERO_STRUCTP(r_u->ctr); + ZERO_STRUCTP(ctr); /* set up the */ - init_srv_r_net_sess_enum(r_u, - get_enum_hnd(&q_u->enum_hnd), - q_u->sess_level, - q_u->ctr->switch_value); - - DEBUG(5,("_srv_net_sess_enum: %d\n", __LINE__)); - - return r_u->status; + return init_srv_sess_info_ctr(p, ctr, + *level, + resume_handle, + totalentries); } /******************************************************************* net sess del ********************************************************************/ -WERROR _srv_net_sess_del(pipes_struct *p, SRV_Q_NET_SESS_DEL *q_u, SRV_R_NET_SESS_DEL *r_u) +WERROR _srvsvc_NetSessDel(pipes_struct *p, const char *server_unc, const char *client, const char *user) { struct sessionid *session_list; int num_sessions, snum; - fstring username; - fstring machine; + WERROR status; - rpcstr_pull_unistr2_fstring(username, &q_u->uni_user_name); - rpcstr_pull_unistr2_fstring(machine, &q_u->uni_cli_name); + char *machine = talloc_strdup(p->mem_ctx, server_unc); /* strip leading backslashes if any */ while (machine[0] == '\\') { @@ -1318,7 +1161,7 @@ WERROR _srv_net_sess_del(pipes_struct *p, SRV_Q_NET_SESS_DEL *q_u, SRV_R_NET_SES DEBUG(5,("_srv_net_sess_del: %d\n", __LINE__)); - r_u->status = WERR_ACCESS_DENIED; + status = WERR_ACCESS_DENIED; /* fail out now if you are not root or not a domain admin */ @@ -1330,11 +1173,11 @@ WERROR _srv_net_sess_del(pipes_struct *p, SRV_Q_NET_SESS_DEL *q_u, SRV_R_NET_SES for (snum = 0; snum < num_sessions; snum++) { - if ((strequal(session_list[snum].username, username) || username[0] == '\0' ) && + if ((strequal(session_list[snum].username, user) || user[0] == '\0' ) && strequal(session_list[snum].remote_machine, machine)) { if (message_send_pid(pid_to_procid(session_list[snum].pid), MSG_SHUTDOWN, NULL, 0, False)) - r_u->status = WERR_OK; + status = WERR_OK; } } @@ -1344,14 +1187,14 @@ WERROR _srv_net_sess_del(pipes_struct *p, SRV_Q_NET_SESS_DEL *q_u, SRV_R_NET_SES done: SAFE_FREE(session_list); - return r_u->status; + return status; } /******************************************************************* Net share enum all. ********************************************************************/ -WERROR _srv_net_share_enum_all(pipes_struct *p, SRV_Q_NET_SHARE_ENUM *q_u, SRV_R_NET_SHARE_ENUM *r_u) +WERROR _srvsvc_NetShareEnumAll(pipes_struct *p, const char *server_unc, uint32_t *level, union srvsvc_NetShareCtr *ctr, uint32_t max_buffer, uint32_t *totalentries, uint32_t *resume_handle) { DEBUG(5,("_srv_net_share_enum: %d\n", __LINE__)); @@ -1361,20 +1204,15 @@ WERROR _srv_net_share_enum_all(pipes_struct *p, SRV_Q_NET_SHARE_ENUM *q_u, SRV_R } /* Create the list of shares for the response. */ - init_srv_r_net_share_enum(p, r_u, - q_u->ctr.info_level, - get_enum_hnd(&q_u->enum_hnd), True); - - DEBUG(5,("_srv_net_share_enum: %d\n", __LINE__)); - - return r_u->status; + return init_srv_share_info_ctr(p, ctr, *level, + resume_handle, totalentries, True); } /******************************************************************* Net share enum. ********************************************************************/ -WERROR _srv_net_share_enum(pipes_struct *p, SRV_Q_NET_SHARE_ENUM *q_u, SRV_R_NET_SHARE_ENUM *r_u) +WERROR _srvsvc_NetShareEnum(pipes_struct *p, const char *server_unc, uint32_t *level, union srvsvc_NetShareCtr *ctr, uint32_t max_buffer, uint32_t *totalentries, uint32_t *resume_handle) { DEBUG(5,("_srv_net_share_enum: %d\n", __LINE__)); @@ -1384,32 +1222,87 @@ WERROR _srv_net_share_enum(pipes_struct *p, SRV_Q_NET_SHARE_ENUM *q_u, SRV_R_NET } /* Create the list of shares for the response. */ - init_srv_r_net_share_enum(p, r_u, - q_u->ctr.info_level, - get_enum_hnd(&q_u->enum_hnd), False); - - DEBUG(5,("_srv_net_share_enum: %d\n", __LINE__)); - - return r_u->status; + return init_srv_share_info_ctr(p, ctr, *level, + resume_handle, totalentries, False); } /******************************************************************* Net share get info. ********************************************************************/ -WERROR _srv_net_share_get_info(pipes_struct *p, SRV_Q_NET_SHARE_GET_INFO *q_u, SRV_R_NET_SHARE_GET_INFO *r_u) +WERROR _srvsvc_NetShareGetInfo(pipes_struct *p, const char *server_unc, const char *share_name, uint32_t level, union srvsvc_NetShareInfo *info) { - fstring share_name; + const struct share_params *params; - DEBUG(5,("_srv_net_share_get_info: %d\n", __LINE__)); + params = get_share_params(p->mem_ctx, share_name); - /* Create the list of shares for the response. */ - unistr2_to_ascii(share_name, &q_u->uni_share_name, sizeof(share_name)); - init_srv_r_net_share_get_info(p, r_u, share_name, q_u->info_level); + if (params != NULL) { + switch (level) { + case 0: + info->info0 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo0); + init_srv_share_info_0(p, info->info0, + params); + break; + case 1: + info->info1 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo1); + init_srv_share_info_1(p, info->info1, + params); + break; + case 2: + info->info2 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo2); + init_srv_share_info_2(p, info->info2, + params); + break; + case 501: + info->info501 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo501); + init_srv_share_info_501(p, info->info501, + params); + break; + case 502: + info->info502 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo502); + init_srv_share_info_502(p, info->info502, + params); + break; + + /* here for completeness */ + case 1004: + info->info1004 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo1004); + init_srv_share_info_1004(p, info->info1004, + params); + break; + case 1005: + info->info1005 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo1005); + init_srv_share_info_1005(p, info->info1005, + params); + break; - DEBUG(5,("_srv_net_share_get_info: %d\n", __LINE__)); + /* here for completeness 1006 - 1501 */ + case 1006: + info->info1006 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo1006); + init_srv_share_info_1006(p, info->info1006, + params); + break; + case 1007: + info->info1007 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo1007); + init_srv_share_info_1007(p, info->info1007, + params); + break; + case 1501: + info->info1501 = talloc(p->mem_ctx, struct sec_desc_buf); + init_srv_share_info_1501(p, info->info1501, + params); + break; + default: + DEBUG(5,("init_srv_net_share_get_info: unsupported " + "switch value %d\n", level)); + return WERR_UNKNOWN_LEVEL; + break; + } + } else { + return WERR_INVALID_NAME; + } - return r_u->status; + return WERR_OK; } /******************************************************************* @@ -1440,11 +1333,10 @@ char *valid_share_pathname(char *dos_pathname) Net share set info. Modify share details. ********************************************************************/ -WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, SRV_R_NET_SHARE_SET_INFO *r_u) +WERROR _srvsvc_NetShareSetInfo(pipes_struct *p, const char *server_unc, const char *share_name, uint32_t level, union srvsvc_NetShareInfo info, uint32_t *parm_error) { pstring command; - fstring share_name; - fstring comment; + pstring comment; pstring pathname; int type; int snum; @@ -1454,12 +1346,11 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S SE_PRIV se_diskop = SE_DISK_OPERATOR; BOOL is_disk_op = False; int max_connections = 0; + fstring tmp_share_name; DEBUG(5,("_srv_net_share_set_info: %d\n", __LINE__)); - unistr2_to_ascii(share_name, &q_u->uni_share_name, sizeof(share_name)); - - r_u->parm_error = 0; + *parm_error = 0; if ( strequal(share_name,"IPC$") || ( lp_enable_asu_support() && strequal(share_name,"ADMIN$") ) @@ -1468,7 +1359,8 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S return WERR_ACCESS_DENIED; } - snum = find_service(share_name); + fstrcpy(tmp_share_name, share_name); + snum = find_service(tmp_share_name); /* Does this share exist ? */ if (snum < 0) @@ -1485,18 +1377,18 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S if ( p->pipe_user.ut.uid != sec_initial_uid() && !is_disk_op ) return WERR_ACCESS_DENIED; - switch (q_u->info_level) { + switch (level) { case 1: pstrcpy(pathname, lp_pathname(snum)); - unistr2_to_ascii(comment, &q_u->info.share.info2.info_2_str.uni_remark, sizeof(comment)); - type = q_u->info.share.info2.info_2.type; + pstrcpy(comment, info.info1->comment); + type = info.info1->type; psd = NULL; break; case 2: - unistr2_to_ascii(comment, &q_u->info.share.info2.info_2_str.uni_remark, sizeof(comment)); - unistr2_to_ascii(pathname, &q_u->info.share.info2.info_2_str.uni_path, sizeof(pathname)); - type = q_u->info.share.info2.info_2.type; - max_connections = (q_u->info.share.info2.info_2.max_uses == 0xffffffff) ? 0 : q_u->info.share.info2.info_2.max_uses; + pstrcpy(comment, info.info2->comment); + pstrcpy(pathname, info.info2->path); + type = info.info2->type; + max_connections = (info.info2->max_users == 0xffffffff) ? 0 : info.info2->max_users; psd = NULL; break; #if 0 @@ -1508,15 +1400,15 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S break; #endif case 502: - unistr2_to_ascii(comment, &q_u->info.share.info502.info_502_str.uni_remark, sizeof(comment)); - unistr2_to_ascii(pathname, &q_u->info.share.info502.info_502_str.uni_path, sizeof(pathname)); - type = q_u->info.share.info502.info_502.type; - psd = q_u->info.share.info502.info_502_str.sd; + pstrcpy(comment, info.info502->comment); + pstrcpy(pathname, info.info502->path); + type = info.info502->type; + psd = info.info502->sd; map_generic_share_sd_bits(psd); break; case 1004: pstrcpy(pathname, lp_pathname(snum)); - unistr2_to_ascii(comment, &q_u->info.share.info1004.info_1004_str.uni_remark, sizeof(comment)); + pstrcpy(comment, info.info1004->comment); type = STYPE_DISKTREE; break; case 1005: @@ -1524,7 +1416,7 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S user, so we must compare it to see if it's what is set in smb.conf, so that we can contine other ops like setting ACLs on a share */ - if (((q_u->info.share.info1005.share_info_flags & + if (((info.info1005->dfs_flags & SHARE_1005_CSC_POLICY_MASK) >> SHARE_1005_CSC_POLICY_SHIFT) == lp_csc_policy(snum)) return WERR_OK; @@ -1537,13 +1429,13 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S return WERR_ACCESS_DENIED; case 1501: pstrcpy(pathname, lp_pathname(snum)); - fstrcpy(comment, lp_comment(snum)); - psd = q_u->info.share.info1501.sdb->sd; + pstrcpy(comment, lp_comment(snum)); + psd = info.info1501->sd; map_generic_share_sd_bits(psd); type = STYPE_DISKTREE; break; default: - DEBUG(5,("_srv_net_share_set_info: unsupported switch value %d\n", q_u->info_level)); + DEBUG(5,("_srv_net_share_set_info: unsupported switch value %d\n", level)); return WERR_UNKNOWN_LEVEL; } @@ -1556,7 +1448,7 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S return WERR_OBJECT_PATH_INVALID; /* Ensure share name, pathname and comment don't contain '"' characters. */ - string_replace(share_name, '"', ' '); + string_replace(tmp_share_name, '"', ' '); string_replace(path, '"', ' '); string_replace(comment, '"', ' '); @@ -1626,16 +1518,16 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S "comment" "max connections = " ********************************************************************/ -WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_SHARE_ADD *r_u) +WERROR _srvsvc_NetShareAdd(pipes_struct *p, const char *server_unc, uint32_t level, union srvsvc_NetShareInfo info, uint32_t *parm_error) { pstring command; - fstring share_name; - fstring comment; + pstring share_name; + pstring comment; pstring pathname; + char *path; int type; int snum; int ret; - char *path; SEC_DESC *psd = NULL; SE_PRIV se_diskop = SE_DISK_OPERATOR; BOOL is_disk_op; @@ -1643,7 +1535,7 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S DEBUG(5,("_srv_net_share_add: %d\n", __LINE__)); - r_u->parm_error = 0; + *parm_error = 0; is_disk_op = user_has_privileges( p->pipe_user.nt_user_token, &se_diskop ); @@ -1655,7 +1547,7 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S return WERR_ACCESS_DENIED; } - switch (q_u->info_level) { + switch (level) { case 0: /* No path. Not enough info in a level 0 to do anything. */ return WERR_ACCESS_DENIED; @@ -1663,21 +1555,21 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S /* Not enough info in a level 1 to do anything. */ return WERR_ACCESS_DENIED; case 2: - unistr2_to_ascii(share_name, &q_u->info.share.info2.info_2_str.uni_netname, sizeof(share_name)); - unistr2_to_ascii(comment, &q_u->info.share.info2.info_2_str.uni_remark, sizeof(share_name)); - unistr2_to_ascii(pathname, &q_u->info.share.info2.info_2_str.uni_path, sizeof(share_name)); - max_connections = (q_u->info.share.info2.info_2.max_uses == 0xffffffff) ? 0 : q_u->info.share.info2.info_2.max_uses; - type = q_u->info.share.info2.info_2.type; + pstrcpy(share_name, info.info2->name); + pstrcpy(comment, info.info2->comment); + pstrcpy(pathname, info.info2->path); + max_connections = (info.info2->max_users == 0xffffffff) ? 0 : info.info2->max_users; + type = info.info2->type; break; case 501: /* No path. Not enough info in a level 501 to do anything. */ return WERR_ACCESS_DENIED; case 502: - unistr2_to_ascii(share_name, &q_u->info.share.info502.info_502_str.uni_netname, sizeof(share_name)); - unistr2_to_ascii(comment, &q_u->info.share.info502.info_502_str.uni_remark, sizeof(share_name)); - unistr2_to_ascii(pathname, &q_u->info.share.info502.info_502_str.uni_path, sizeof(share_name)); - type = q_u->info.share.info502.info_502.type; - psd = q_u->info.share.info502.info_502_str.sd; + pstrcpy(share_name, info.info502->name); + pstrcpy(comment, info.info502->comment); + pstrcpy(pathname, info.info502->path); + type = info.info502->type; + psd = info.info502->sd; map_generic_share_sd_bits(psd); break; @@ -1692,7 +1584,7 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S /* DFS only level. */ return WERR_ACCESS_DENIED; default: - DEBUG(5,("_srv_net_share_add: unsupported switch value %d\n", q_u->info_level)); + DEBUG(5,("_srv_net_share_add: unsupported switch value %d\n", level)); return WERR_UNKNOWN_LEVEL; } @@ -1780,19 +1672,17 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S a parameter. ********************************************************************/ -WERROR _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_SHARE_DEL *r_u) +WERROR _srvsvc_NetShareDel(pipes_struct *p, const char *server_unc, const char *share_name, uint32_t reserved) { pstring command; - fstring share_name; int ret; int snum; SE_PRIV se_diskop = SE_DISK_OPERATOR; BOOL is_disk_op; + fstring tmp_share_name; DEBUG(5,("_srv_net_share_del: %d\n", __LINE__)); - unistr2_to_ascii(share_name, &q_u->uni_share_name, sizeof(share_name)); - if ( strequal(share_name,"IPC$") || ( lp_enable_asu_support() && strequal(share_name,"ADMIN$") ) || strequal(share_name,"global") ) @@ -1800,7 +1690,8 @@ WERROR _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_S return WERR_ACCESS_DENIED; } - snum = find_service(share_name); + fstrcpy(tmp_share_name, share_name); + snum = find_service(tmp_share_name); if (snum < 0) return WERR_NO_SUCH_SHARE; @@ -1852,22 +1743,22 @@ WERROR _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_S return WERR_OK; } -WERROR _srv_net_share_del_sticky(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_SHARE_DEL *r_u) +WERROR _srvsvc_NetShareDelSticky(pipes_struct *p, const char *server_unc, const char *share_name, uint32_t reserved) { DEBUG(5,("_srv_net_share_del_stick: %d\n", __LINE__)); - return _srv_net_share_del(p, q_u, r_u); + return _srvsvc_NetShareDel(p, server_unc, share_name, reserved); } /******************************************************************* time of day ********************************************************************/ -WERROR _srv_net_remote_tod(pipes_struct *p, SRV_Q_NET_REMOTE_TOD *q_u, SRV_R_NET_REMOTE_TOD *r_u) +WERROR _srvsvc_NetRemoteTOD(pipes_struct *p, const char *server_unc, struct srvsvc_NetRemoteTODInfo *tod) { - TIME_OF_DAY_INFO *tod; struct tm *t; time_t unixdate = time(NULL); + WERROR status = WERR_OK; /* We do this call first as if we do it *after* the gmtime call it overwrites the pointed-to values. JRA */ @@ -1876,101 +1767,87 @@ WERROR _srv_net_remote_tod(pipes_struct *p, SRV_Q_NET_REMOTE_TOD *q_u, SRV_R_NET DEBUG(5,("_srv_net_remote_tod: %d\n", __LINE__)); - if ( !(tod = TALLOC_ZERO_P(p->mem_ctx, TIME_OF_DAY_INFO)) ) - return WERR_NOMEM; - - r_u->tod = tod; - r_u->ptr_srv_tod = 0x1; - r_u->status = WERR_OK; - - DEBUG(5,("_srv_net_remote_tod: %d\n", __LINE__)); - t = gmtime(&unixdate); /* set up the */ - init_time_of_day_info(tod, - unixdate, - 0, - t->tm_hour, - t->tm_min, - t->tm_sec, - 0, - zone, - 10000, - t->tm_mday, - t->tm_mon + 1, - 1900+t->tm_year, - t->tm_wday); + tod->elapsed = unixdate; + tod->msecs = 0; + tod->hours = t->tm_hour; + tod->mins = t->tm_min; + tod->secs = t->tm_sec; + tod->hunds = 0; + tod->timezone = zone; + tod->tinterval = 10000; + tod->day = t->tm_mday; + tod->month = t->tm_mon + 1; + tod->year = 1900+t->tm_year; + tod->weekday = t->tm_wday; DEBUG(5,("_srv_net_remote_tod: %d\n", __LINE__)); - return r_u->status; + return status; } /*********************************************************************************** Win9x NT tools get security descriptor. ***********************************************************************************/ -WERROR _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC *q_u, - SRV_R_NET_FILE_QUERY_SECDESC *r_u) +WERROR _srvsvc_NetGetFileSecurity(pipes_struct *p, const char *server_unc, const char *share, const char *file, uint32_t securityinformation, struct sec_desc_buf *sd_buf) { SEC_DESC *psd = NULL; size_t sd_size; DATA_BLOB null_pw; - pstring filename; - pstring qualname; files_struct *fsp = NULL; SMB_STRUCT_STAT st; BOOL bad_path; NTSTATUS nt_status; connection_struct *conn = NULL; BOOL became_user = False; + WERROR status = WERR_OK; + pstring tmp_file; ZERO_STRUCT(st); - r_u->status = WERR_OK; - - unistr2_to_ascii(qualname, &q_u->uni_qual_name, sizeof(qualname)); /* Null password is ok - we are already an authenticated user... */ null_pw = data_blob(NULL, 0); become_root(); - conn = make_connection(qualname, null_pw, "A:", p->pipe_user.vuid, &nt_status); + conn = make_connection(share, null_pw, "A:", p->pipe_user.vuid, &nt_status); unbecome_root(); if (conn == NULL) { - DEBUG(3,("_srv_net_file_query_secdesc: Unable to connect to %s\n", qualname)); - r_u->status = ntstatus_to_werror(nt_status); + DEBUG(3,("_srv_net_file_query_secdesc: Unable to connect to %s\n", share)); + status = ntstatus_to_werror(nt_status); goto error_exit; } if (!become_user(conn, conn->vuid)) { DEBUG(0,("_srv_net_file_query_secdesc: Can't become connected user!\n")); - r_u->status = WERR_ACCESS_DENIED; + status = WERR_ACCESS_DENIED; goto error_exit; } became_user = True; - unistr2_to_ascii(filename, &q_u->uni_file_name, sizeof(filename)); - unix_convert(filename, conn, NULL, &bad_path, &st); + pstrcpy(tmp_file, file); + unix_convert(tmp_file, conn, NULL, &bad_path, &st); if (bad_path) { - DEBUG(3,("_srv_net_file_query_secdesc: bad pathname %s\n", filename)); - r_u->status = WERR_ACCESS_DENIED; + DEBUG(3,("_srv_net_file_query_secdesc: bad pathname %s\n", file)); + status = WERR_ACCESS_DENIED; goto error_exit; } - if (!check_name(filename,conn)) { - DEBUG(3,("_srv_net_file_query_secdesc: can't access %s\n", filename)); - r_u->status = WERR_ACCESS_DENIED; + if (!check_name(file,conn)) { + DEBUG(3,("_srv_net_file_query_secdesc: can't access %s\n", file)); + status = WERR_ACCESS_DENIED; goto error_exit; } - nt_status = open_file_stat(conn, filename, &st, &fsp); + nt_status = open_file_stat(conn, file, &st, &fsp); if (!NT_STATUS_IS_OK(nt_status)) { /* Perhaps it is a directory */ if (NT_STATUS_EQUAL(nt_status, NT_STATUS_FILE_IS_A_DIRECTORY)) - nt_status = open_directory(conn, filename, &st, + nt_status = open_directory(conn, file, &st, READ_CONTROL_ACCESS, FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, @@ -1978,8 +1855,8 @@ WERROR _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC NULL, &fsp); if (!NT_STATUS_IS_OK(nt_status)) { - DEBUG(3,("_srv_net_file_query_secdesc: Unable to open file %s\n", filename)); - r_u->status = WERR_ACCESS_DENIED; + DEBUG(3,("_srv_net_file_query_secdesc: Unable to open file %s\n", file)); + status = WERR_ACCESS_DENIED; goto error_exit; } } @@ -1987,23 +1864,20 @@ WERROR _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC sd_size = SMB_VFS_GET_NT_ACL(fsp, fsp->fsp_name, (OWNER_SECURITY_INFORMATION|GROUP_SECURITY_INFORMATION|DACL_SECURITY_INFORMATION), &psd); if (sd_size == 0) { - DEBUG(3,("_srv_net_file_query_secdesc: Unable to get NT ACL for file %s\n", filename)); - r_u->status = WERR_ACCESS_DENIED; + DEBUG(3,("_srv_net_file_query_secdesc: Unable to get NT ACL for file %s\n", file)); + status = WERR_ACCESS_DENIED; goto error_exit; } - r_u->ptr_response = 1; - r_u->size_response = sd_size; - r_u->ptr_secdesc = 1; - r_u->size_secdesc = sd_size; - r_u->sec_desc = psd; + sd_buf->sd_size= sd_size; + sd_buf->sd = psd; psd->dacl->revision = (uint16) NT4_ACL_REVISION; close_file(fsp, NORMAL_CLOSE); unbecome_user(); close_cnum(conn, p->pipe_user.vuid); - return r_u->status; + return status; error_exit: @@ -2017,19 +1891,16 @@ error_exit: if (conn) close_cnum(conn, p->pipe_user.vuid); - return r_u->status; + return status; } /*********************************************************************************** Win9x NT tools set security descriptor. ***********************************************************************************/ -WERROR _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_u, - SRV_R_NET_FILE_SET_SECDESC *r_u) +WERROR _srvsvc_NetSetFileSecurity(pipes_struct *p, const char *server_unc, const char *share, const char *file, uint32_t securityinformation, struct sec_desc_buf sd_buf) { BOOL ret; - pstring filename; - pstring qualname; DATA_BLOB null_pw; files_struct *fsp = NULL; SMB_STRUCT_STAT st; @@ -2037,54 +1908,52 @@ WERROR _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_ NTSTATUS nt_status; connection_struct *conn = NULL; BOOL became_user = False; + WERROR status = WERR_OK; + pstring tmp_file; ZERO_STRUCT(st); - r_u->status = WERR_OK; - - unistr2_to_ascii(qualname, &q_u->uni_qual_name, sizeof(qualname)); - /* Null password is ok - we are already an authenticated user... */ null_pw = data_blob(NULL, 0); become_root(); - conn = make_connection(qualname, null_pw, "A:", p->pipe_user.vuid, &nt_status); + conn = make_connection(share, null_pw, "A:", p->pipe_user.vuid, &nt_status); unbecome_root(); if (conn == NULL) { - DEBUG(3,("_srv_net_file_set_secdesc: Unable to connect to %s\n", qualname)); - r_u->status = ntstatus_to_werror(nt_status); + DEBUG(3,("_srv_net_file_set_secdesc: Unable to connect to %s\n", share)); + status = ntstatus_to_werror(nt_status); goto error_exit; } if (!become_user(conn, conn->vuid)) { DEBUG(0,("_srv_net_file_set_secdesc: Can't become connected user!\n")); - r_u->status = WERR_ACCESS_DENIED; + status = WERR_ACCESS_DENIED; goto error_exit; } became_user = True; - unistr2_to_ascii(filename, &q_u->uni_file_name, sizeof(filename)); - unix_convert(filename, conn, NULL, &bad_path, &st); + pstrcpy(tmp_file, file); + unix_convert(tmp_file, conn, NULL, &bad_path, &st); if (bad_path) { - DEBUG(3,("_srv_net_file_set_secdesc: bad pathname %s\n", filename)); - r_u->status = WERR_ACCESS_DENIED; + DEBUG(3,("_srv_net_file_set_secdesc: bad pathname %s\n", file)); + status = WERR_ACCESS_DENIED; goto error_exit; } - if (!check_name(filename,conn)) { - DEBUG(3,("_srv_net_file_set_secdesc: can't access %s\n", filename)); - r_u->status = WERR_ACCESS_DENIED; + if (!check_name(file,conn)) { + DEBUG(3,("_srv_net_file_set_secdesc: can't access %s\n", file)); + status = WERR_ACCESS_DENIED; goto error_exit; } - nt_status = open_file_stat(conn, filename, &st, &fsp); + nt_status = open_file_stat(conn, file, &st, &fsp); if (!NT_STATUS_IS_OK(nt_status)) { /* Perhaps it is a directory */ if (NT_STATUS_EQUAL(nt_status, NT_STATUS_FILE_IS_A_DIRECTORY)) - nt_status = open_directory(conn, filename, &st, + nt_status = open_directory(conn, file, &st, FILE_READ_ATTRIBUTES, FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, @@ -2092,24 +1961,24 @@ WERROR _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_ NULL, &fsp); if (!NT_STATUS_IS_OK(nt_status)) { - DEBUG(3,("_srv_net_file_set_secdesc: Unable to open file %s\n", filename)); - r_u->status = WERR_ACCESS_DENIED; + DEBUG(3,("_srv_net_file_set_secdesc: Unable to open file %s\n", file)); + status = WERR_ACCESS_DENIED; goto error_exit; } } - ret = SMB_VFS_SET_NT_ACL(fsp, fsp->fsp_name, q_u->sec_info, q_u->sec_desc); + ret = SMB_VFS_SET_NT_ACL(fsp, fsp->fsp_name, securityinformation, sd_buf.sd); if (ret == False) { - DEBUG(3,("_srv_net_file_set_secdesc: Unable to set NT ACL on file %s\n", filename)); - r_u->status = WERR_ACCESS_DENIED; + DEBUG(3,("_srv_net_file_set_secdesc: Unable to set NT ACL on file %s\n", file)); + status = WERR_ACCESS_DENIED; goto error_exit; } close_file(fsp, NORMAL_CLOSE); unbecome_user(); close_cnum(conn, p->pipe_user.vuid); - return r_u->status; + return status; error_exit: @@ -2125,7 +1994,7 @@ error_exit: close_cnum(conn, p->pipe_user.vuid); } - return r_u->status; + return status; } /*********************************************************************************** @@ -2174,76 +2043,68 @@ static const char *next_server_disk_enum(uint32 *resume) return disk; } -WERROR _srv_net_disk_enum(pipes_struct *p, SRV_Q_NET_DISK_ENUM *q_u, SRV_R_NET_DISK_ENUM *r_u) +WERROR _srvsvc_NetDiskEnum(pipes_struct *p, const char *server_unc, uint32_t level, struct srvsvc_NetDiskInfo *info, uint32_t maxlen, uint32_t *totalentries, uint32_t *resume_handle) { uint32 i; const char *disk_name; - TALLOC_CTX *ctx = p->mem_ctx; - uint32 resume=get_enum_hnd(&q_u->enum_hnd); - r_u->status=WERR_OK; - - r_u->total_entries = init_server_disk_enum(&resume); + WERROR status = WERR_OK; - r_u->disk_enum_ctr.unknown = 0; + *totalentries = init_server_disk_enum(resume_handle); + info->count = 0; - if(!(r_u->disk_enum_ctr.disk_info = TALLOC_ARRAY(ctx, DISK_INFO, MAX_SERVER_DISK_ENTRIES))) { + if(!(info->disks = TALLOC_ARRAY(p->mem_ctx, struct srvsvc_NetDiskInfo0, MAX_SERVER_DISK_ENTRIES))) { return WERR_NOMEM; } - r_u->disk_enum_ctr.disk_info_ptr = r_u->disk_enum_ctr.disk_info ? 1 : 0; - - /*allow one DISK_INFO for null terminator*/ + /*allow one struct srvsvc_NetDiskInfo0 for null terminator*/ - for(i = 0; i < MAX_SERVER_DISK_ENTRIES -1 && (disk_name = next_server_disk_enum(&resume)); i++) { + for(i = 0; i < MAX_SERVER_DISK_ENTRIES -1 && (disk_name = next_server_disk_enum(resume_handle)); i++) { - r_u->disk_enum_ctr.entries_read++; + info->count++; + (*totalentries)++; /*copy disk name into a unicode string*/ - init_unistr3(&r_u->disk_enum_ctr.disk_info[i].disk_name, disk_name); + info->disks[i].disk = disk_name; } /* add a terminating null string. Is this there if there is more data to come? */ - r_u->disk_enum_ctr.entries_read++; + info->count++; + (*totalentries)++; - init_unistr3(&r_u->disk_enum_ctr.disk_info[i].disk_name, ""); + info->disks[i].disk = ""; - init_enum_hnd(&r_u->enum_hnd, resume); - - return r_u->status; + return status; } /******************************************************************** ********************************************************************/ -WERROR _srv_net_name_validate(pipes_struct *p, SRV_Q_NET_NAME_VALIDATE *q_u, SRV_R_NET_NAME_VALIDATE *r_u) +WERROR _srvsvc_NetNameValidate(pipes_struct *p, const char *server_unc, const char *name, uint32_t name_type, uint32_t flags) { - fstring sharename; int len; - if ((q_u->flags != 0x0) && (q_u->flags != 0x80000000)) { + if ((flags != 0x0) && (flags != 0x80000000)) { return WERR_INVALID_PARAM; } - switch ( q_u->type ) { + switch ( name_type ) { case 0x9: - rpcstr_pull(sharename, q_u->sharename.buffer, sizeof(sharename), q_u->sharename.uni_str_len*2, 0); - - len = strlen_m(sharename); + len = strlen_m(name); - if ((q_u->flags == 0x0) && (len > 81)) { - DEBUG(5,("_srv_net_name_validate: share name too long (%s > 81 chars)\n", sharename)); + if ((flags == 0x0) && (len > 81)) { + DEBUG(5,("_srv_net_name_validate: share name too long (%s > 81 chars)\n", name)); return WERR_INVALID_NAME; } - if ((q_u->flags == 0x80000000) && (len > 13)) { - DEBUG(5,("_srv_net_name_validate: share name too long (%s > 13 chars)\n", sharename)); + if ((flags == 0x80000000) && (len > 13)) { + DEBUG(5,("_srv_net_name_validate: share name too long (%s > 13 chars)\n", name)); return WERR_INVALID_NAME; } - if ( ! validate_net_name( sharename, INVALID_SHARENAME_CHARS, sizeof(sharename) ) ) { - DEBUG(5,("_srv_net_name_validate: Bad sharename \"%s\"\n", sharename)); + if ( ! validate_net_name( name, INVALID_SHARENAME_CHARS, sizeof(name) ) ) { + DEBUG(5,("_srv_net_name_validate: Bad sharename \"%s\"\n", name)); return WERR_INVALID_NAME; } break; @@ -2259,8 +2120,182 @@ WERROR _srv_net_name_validate(pipes_struct *p, SRV_Q_NET_NAME_VALIDATE *q_u, SRV /******************************************************************** ********************************************************************/ -WERROR _srv_net_file_close(pipes_struct *p, SRV_Q_NET_FILE_CLOSE *q_u, SRV_R_NET_FILE_CLOSE *r_u) +WERROR _srvsvc_NetFileClose(pipes_struct *p, const char *server_unc, uint32_t fid) { return WERR_ACCESS_DENIED; } +WERROR _srvsvc_NetCharDevEnum(pipes_struct *p, const char *server_unc, uint32_t *level, union srvsvc_NetCharDevCtr *ctr, uint32_t max_buffer, uint32_t *totalentries, uint32_t *resume_handle) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NetCharDevGetInfo(pipes_struct *p, const char *server_unc, const char *device_name, uint32_t level, union srvsvc_NetCharDevInfo *info) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NetCharDevControl(pipes_struct *p, const char *server_unc, const char *device_name, uint32_t opcode) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NetCharDevQEnum(pipes_struct *p, const char *server_unc, const char *user, uint32_t *level, union srvsvc_NetCharDevQCtr *ctr, uint32_t max_buffer, uint32_t *totalentries, uint32_t *resume_handle) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NetCharDevQGetInfo(pipes_struct *p, const char *server_unc, const char *queue_name, const char *user, uint32_t level, union srvsvc_NetCharDevQInfo *info) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NetCharDevQSetInfo(pipes_struct *p, const char *server_unc, const char *queue_name, uint32_t level, union srvsvc_NetCharDevQInfo info, uint32_t *parm_error) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NetCharDevQPurge(pipes_struct *p, const char *server_unc, const char *queue_name) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NetCharDevQPurgeSelf(pipes_struct *p, const char *server_unc, const char *queue_name, const char *computer_name) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NetFileGetInfo(pipes_struct *p, const char *server_unc, uint32_t fid, uint32_t level, union srvsvc_NetFileInfo *info) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NetShareCheck(pipes_struct *p, const char *server_unc, const char *device_name, enum srvsvc_ShareType *type) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NetServerStatisticsGet(pipes_struct *p, const char *server_unc, const char *service, uint32_t level, uint32_t options, struct srvsvc_Statistics *stats) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NetTransportAdd(pipes_struct *p, const char *server_unc, uint32_t level, union srvsvc_NetTransportInfo info) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NetTransportEnum(pipes_struct *p, const char *server_unc, uint32_t *level, union srvsvc_NetTransportCtr *transports, uint32_t max_buffer, uint32_t *totalentries, uint32_t *resume_handle) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NetTransportDel(pipes_struct *p, const char *server_unc, uint32_t unknown, struct srvsvc_NetTransportInfo0 transport) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NetSetServiceBits(pipes_struct *p, const char *server_unc, const char *transport, uint32_t servicebits, uint32_t updateimmediately) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NetPathType(pipes_struct *p, const char *server_unc, const char *path, uint32_t pathflags, uint32_t *pathtype) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NetPathCanonicalize(pipes_struct *p, const char *server_unc, const char *path, uint8_t *can_path, uint32_t maxbuf, const char *prefix, uint32_t *pathtype, uint32_t pathflags) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NetPathCompare(pipes_struct *p, const char *server_unc, const char *path1, const char *path2, uint32_t pathtype, uint32_t pathflags) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NETRPRNAMECANONICALIZE(pipes_struct *p) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NetPRNameCompare(pipes_struct *p, const char *server_unc, const char *name1, const char *name2, uint32_t name_type, uint32_t flags) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NetShareDelStart(pipes_struct *p, const char *server_unc, const char *share, uint32_t reserved, struct policy_handle *hnd) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NetShareDelCommit(pipes_struct *p, struct policy_handle *hnd) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NetServerTransportAddEx(pipes_struct *p, const char *server_unc, uint32_t level, union srvsvc_NetTransportInfo info) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NetServerSetServiceBitsEx(pipes_struct *p, const char *server_unc, const char *emulated_server_unc, const char *transport, uint32_t servicebitsofinterest, uint32_t servicebits, uint32_t updateimmediately) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NETRDFSGETVERSION(pipes_struct *p) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NETRDFSCREATELOCALPARTITION(pipes_struct *p) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NETRDFSDELETELOCALPARTITION(pipes_struct *p) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NETRDFSSETLOCALVOLUMESTATE(pipes_struct *p) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NETRDFSSETSERVERINFO(pipes_struct *p) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NETRDFSCREATEEXITPOINT(pipes_struct *p) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NETRDFSDELETEEXITPOINT(pipes_struct *p) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NETRSERVERTRANSPORTDELEX(pipes_struct *p) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NETRDFSMANAGERREPORTSITEINFO(pipes_struct *p) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NETRDFSMODIFYPREFIX(pipes_struct *p) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NETRDFSFIXLOCALVOLUME(pipes_struct *p) +{ + return WERR_NOT_SUPPORTED; +} diff --git a/source3/rpcclient/cmd_srvsvc.c b/source3/rpcclient/cmd_srvsvc.c index 53ee7300da..d6e01eee85 100644 --- a/source3/rpcclient/cmd_srvsvc.c +++ b/source3/rpcclient/cmd_srvsvc.c @@ -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 = ""; - - 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("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); + + 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; diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 117d3ac595..9601329b9e 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -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; diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c index 766dd43faa..e6ba152ec9 100644 --- a/source3/utils/net_rpc.c +++ b/source3/utils/net_rpc.c @@ -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); - - 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); + ctr_src.ctr502->array[i].name, + ctr_src.ctr502->array[i].path, + ctr_src.ctr502->array[i].comment); + + 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; } diff --git a/source3/utils/smbtree.c b/source3/utils/smbtree.c index d9cd446f6c..1feb5b7e1d 100644 --- a/source3/utils/smbtree.c +++ b/source3/utils/smbtree.c @@ -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); |