summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/Makefile.in21
-rw-r--r--source3/auth/token_util.c2
-rw-r--r--source3/client/client.c14
-rw-r--r--source3/configure.in16
-rw-r--r--source3/include/client.h14
-rw-r--r--source3/include/doserr.h2
-rw-r--r--source3/include/includes.h1
-rw-r--r--source3/include/nameserv.h2
-rw-r--r--source3/include/rpc_client.h2
-rw-r--r--source3/include/rpc_dce.h9
-rw-r--r--source3/include/smb.h1
-rw-r--r--source3/include/smb_macros.h3
-rw-r--r--source3/include/vfs.h3
-rw-r--r--source3/include/vfs_macros.h6
-rw-r--r--source3/lib/messages_ctdbd.c30
-rw-r--r--source3/lib/netapi/Doxyfile1362
-rw-r--r--source3/lib/netapi/cm.c6
-rw-r--r--source3/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c6
-rw-r--r--source3/lib/netapi/netapi.c7
-rw-r--r--source3/lib/netapi/netapi.h256
-rw-r--r--source3/lib/netapi/user.c40
-rw-r--r--source3/lib/replace/libreplace_cc.m43
-rw-r--r--source3/lib/replace/replace.c2
-rw-r--r--source3/lib/replace/replace.h2
-rw-r--r--source3/lib/smbconf/smbconf_reg.c2
-rw-r--r--source3/lib/talloc/libtalloc.m48
-rw-r--r--source3/lib/talloc/talloc.c4
-rw-r--r--source3/lib/util.c30
-rw-r--r--source3/libads/ldap_printer.c7
-rw-r--r--source3/libcli/nbt/libnbt.h353
-rw-r--r--source3/libcli/nbt/nbtname.c626
-rw-r--r--source3/libgpo/gpo_reg.c2
-rw-r--r--source3/libgpo/gpo_util.c3
-rw-r--r--source3/libnet/libnet_join.c10
-rw-r--r--source3/librpc/gen_ndr/nbt.h756
-rw-r--r--source3/librpc/gen_ndr/ndr_nbt.c4148
-rw-r--r--source3/librpc/gen_ndr/ndr_nbt.h87
-rw-r--r--source3/librpc/gen_ndr/security.h1
-rw-r--r--source3/librpc/idl/drsuapi.idl1503
-rw-r--r--source3/librpc/idl/nbt.idl699
-rw-r--r--source3/librpc/idl/security.idl3
-rw-r--r--source3/librpc/ndr/libndr.h11
-rw-r--r--source3/librpc/ndr/ndr_basic.c4
-rw-r--r--source3/librpc/ndr/ndr_sec_helper.c26
-rw-r--r--source3/librpc/ndr/sid.c41
-rw-r--r--source3/librpc/rpc/binding.c708
-rw-r--r--source3/librpc/rpc/dcerpc.c187
-rw-r--r--source3/librpc/rpc/dcerpc.h75
-rw-r--r--source3/librpc/rpc/dcerpc_util.c1438
-rw-r--r--source3/libsmb/cliconnect.c2
-rw-r--r--source3/libsmb/clidfs.c7
-rw-r--r--source3/libsmb/clidgram.c165
-rw-r--r--source3/libsmb/clientgen.c48
-rw-r--r--source3/libsmb/clireadwrite.c5
-rw-r--r--source3/libsmb/doserr.c4
-rw-r--r--source3/libsmb/dsgetdcname.c40
-rw-r--r--source3/libsmb/libsmb_dir.c4
-rw-r--r--source3/libsmb/libsmb_xattr.c2
-rw-r--r--source3/libsmb/passchange.c15
-rw-r--r--source3/libsmb/trusts_util.c2
-rw-r--r--source3/locking/posix.c36
-rw-r--r--source3/modules/vfs_audit.c8
-rw-r--r--source3/modules/vfs_cacheprime.c2
-rw-r--r--source3/modules/vfs_commit.c5
-rw-r--r--source3/modules/vfs_default.c5
-rw-r--r--source3/modules/vfs_extd_audit.c10
-rw-r--r--source3/modules/vfs_full_audit.c6
-rw-r--r--source3/modules/vfs_streams_xattr.c2
-rw-r--r--source3/modules/vfs_syncops.c6
-rw-r--r--source3/nmbd/asyncdns.c5
-rw-r--r--source3/nmbd/nmbd.c20
-rw-r--r--source3/nsswitch/libwbclient/wbc_pam.c63
-rw-r--r--source3/nsswitch/libwbclient/wbc_sid.c10
-rw-r--r--source3/nsswitch/libwbclient/wbc_util.c300
-rw-r--r--source3/nsswitch/libwbclient/wbclient.c4
-rw-r--r--source3/nsswitch/libwbclient/wbclient.h39
-rw-r--r--source3/nsswitch/wbinfo.c198
-rw-r--r--source3/param/loadparm.c80
-rw-r--r--source3/printing/printing.c5
-rw-r--r--source3/rpc_client/cli_lsarpc.c2
-rw-r--r--source3/rpc_client/cli_netlogon.c10
-rw-r--r--source3/rpc_client/cli_pipe.c307
-rw-r--r--source3/rpc_client/cli_samr.c12
-rw-r--r--source3/rpc_client/cli_spoolss.c16
-rw-r--r--source3/rpc_client/ndr.c2
-rw-r--r--source3/rpc_parse/parse_rpc.c231
-rw-r--r--source3/rpc_server/srv_pipe.c8
-rw-r--r--source3/rpc_server/srv_spoolss_nt.c6
-rw-r--r--source3/rpc_server/srv_wkssvc_nt.c1
-rw-r--r--source3/rpcclient/cmd_lsarpc.c2
-rw-r--r--source3/rpcclient/cmd_netlogon.c40
-rw-r--r--source3/rpcclient/cmd_samr.c5
-rw-r--r--source3/rpcclient/cmd_spoolss.c78
-rw-r--r--source3/rpcclient/cmd_srvsvc.c30
-rw-r--r--source3/rpcclient/cmd_test.c10
-rw-r--r--source3/rpcclient/cmd_wkssvc.c12
-rw-r--r--source3/rpcclient/rpcclient.c8
-rw-r--r--source3/smbd/change_trust_pw.c3
-rw-r--r--source3/smbd/chgpasswd.c6
-rw-r--r--source3/smbd/open.c10
-rw-r--r--source3/smbd/server.c49
-rw-r--r--source3/torture/cmd_vfs.c2
-rw-r--r--source3/utils/net.c7
-rw-r--r--source3/utils/net.h2
-rw-r--r--source3/utils/net_ads.c13
-rw-r--r--source3/utils/net_dom.c3
-rw-r--r--source3/utils/net_rpc.c400
-rw-r--r--source3/utils/net_rpc_join.c10
-rw-r--r--source3/utils/net_rpc_printer.c9
-rw-r--r--source3/utils/net_rpc_samsync.c17
-rw-r--r--source3/utils/net_rpc_service.c12
-rw-r--r--source3/utils/net_rpc_sh_acct.c2
-rw-r--r--source3/utils/net_rpc_shell.c2
-rw-r--r--source3/utils/net_util.c2
-rw-r--r--source3/utils/smbcacls.c8
-rw-r--r--source3/utils/smbtree.c6
-rw-r--r--source3/winbindd/winbindd.c24
-rw-r--r--source3/winbindd/winbindd_ads.c2
-rw-r--r--source3/winbindd/winbindd_cm.c233
-rw-r--r--source3/winbindd/winbindd_dual.c5
-rw-r--r--source3/winbindd/winbindd_misc.c4
-rw-r--r--source3/winbindd/winbindd_rpc.c4
122 files changed, 13819 insertions, 1436 deletions
diff --git a/source3/Makefile.in b/source3/Makefile.in
index 243a3535d8..09af6fcf5d 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -151,7 +151,7 @@ LIBTDB_SHARED_TARGET=@LIBTDB_SHARED_TARGET@
LIBTDB_STATIC_TARGET=@LIBTDB_STATIC_TARGET@
LIBTDB=$(LIBTDB_STATIC_TARGET) @LIBTDB_SHARED@
LIBTDB_SYMS=$(srcdir)/exports/libtdb.syms
-LIBTDB_HEADERS=@tdbdir@/include/tdb.h
+LIBTDB_HEADERS=$(srcdir)/@tdbdir@/include/tdb.h
LIBSMBCLIENT=bin/libsmbclient.a @LIBSMBCLIENT_SHARED@
LIBSMBSHAREMODES=bin/libsmbsharemodes.a @LIBSMBSHAREMODES_SHARED@
@@ -292,7 +292,8 @@ LIBNDR_GEN_OBJ = librpc/gen_ndr/ndr_wkssvc.o \
librpc/gen_ndr/ndr_dssetup.o \
librpc/gen_ndr/ndr_notify.o \
librpc/gen_ndr/ndr_xattr.o \
- librpc/gen_ndr/ndr_ntsvcs.o
+ librpc/gen_ndr/ndr_ntsvcs.o \
+ librpc/gen_ndr/ndr_nbt.o
RPC_PARSE_OBJ0 = rpc_parse/parse_prs.o rpc_parse/parse_misc.o
@@ -403,7 +404,8 @@ LIBADS_SERVER_OBJ = libads/kerberos_verify.o libads/authdata.o \
SECRETS_OBJ = passdb/secrets.o passdb/machine_sid.o
LIBNMB_OBJ = libsmb/unexpected.o libsmb/namecache.o libsmb/nmblib.o \
- libsmb/namequery.o libsmb/conncache.o libads/dns.o
+ libsmb/namequery.o libsmb/conncache.o libads/dns.o \
+ libcli/nbt/nbtname.o
NTERR_OBJ = libsmb/nterr.o
DOSERR_OBJ = libsmb/doserr.o
@@ -443,7 +445,9 @@ LIBMSRPC_OBJ = rpc_client/cli_lsarpc.o rpc_client/cli_samr.o \
$(RPC_CLIENT_OBJ1) rpc_client/cli_reg.o $(RPC_CLIENT_OBJ) \
rpc_client/cli_spoolss.o rpc_client/cli_spoolss_notify.o \
rpc_client/cli_svcctl.o \
- rpc_client/init_samr.o
+ rpc_client/init_samr.o \
+ librpc/rpc/dcerpc.o \
+ librpc/rpc/binding.o
LIBMSRPC_GEN_OBJ = librpc/gen_ndr/cli_lsa.o \
librpc/gen_ndr/cli_dfs.o \
@@ -969,7 +973,8 @@ REPLACETORT_OBJ = lib/replace/test/testsuite.o \
NDRDUMP_OBJ = librpc/tools/ndrdump.o \
$(PARAM_OBJ) $(LIBNDR_GEN_OBJ) \
- $(LIBSAMBA_OBJ) $(LIB_NONSMBD_OBJ) $(POPT_LIB_OBJ)
+ $(LIBSAMBA_OBJ) $(LIB_NONSMBD_OBJ) $(POPT_LIB_OBJ) \
+ libcli/nbt/nbtname.o
DEBUG2HTML_OBJ = utils/debug2html.o utils/debugparse.o
@@ -1191,7 +1196,7 @@ modules: SHOWFLAGS $(MODULES)
IDL_FILES = lsa.idl dfs.idl echo.idl winreg.idl initshutdown.idl \
srvsvc.idl svcctl.idl eventlog.idl wkssvc.idl netlogon.idl notify.idl \
epmapper.idl messaging.idl xattr.idl misc.idl samr.idl security.idl \
- dssetup.idl krb5pac.idl ntsvcs.idl libnetapi.idl
+ dssetup.idl krb5pac.idl ntsvcs.idl libnetapi.idl drsuapi.idl nbt.idl
idl:
@IDL_FILES="$(IDL_FILES)" CPP="$(CPP)" PERL="$(PERL)" \
@@ -2007,7 +2012,7 @@ bin/ntlm_auth@EXEEXT@: $(BINARY_PREREQS) $(NTLM_AUTH_OBJ) $(PARAM_OBJ) \
@POPTLIBS@ $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) \
@LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @WINBIND_LIBS@
-bin/pam_smbpass.@SHLIBEXT@: $(BINARY_PREREQS) $(PAM_SMBPASS_OBJ) @LIBTALLOC_SHARED@ @LIBWBCLIENT_SHARED@
+bin/pam_smbpass.@SHLIBEXT@: $(BINARY_PREREQS) $(PAM_SMBPASS_OBJ) @LIBTALLOC_SHARED@ @LIBWBCLIENT_SHARED@ @LIBTDB_SHARED@
@echo "Linking shared library $@"
@$(SHLD) $(LDSHFLAGS) -o $@ $(PAM_SMBPASS_OBJ) -lpam $(DYNEXP) \
$(LIBS) $(LDAP_LIBS) $(KRB5LIBS) $(NSCD_LIBS) \
@@ -2131,7 +2136,7 @@ installlibtalloc: installdirs libtalloc
-$(INSTALLLIBCMD_SH) $(LIBTALLOC_SHARED_TARGET) $(DESTDIR)$(LIBDIR)
-$(INSTALLLIBCMD_A) $(LIBTALLOC_STATIC_TARGET) $(DESTDIR)$(LIBDIR)
@$(SHELL) $(srcdir)/script/installdirs.sh $(INSTALLPERMS_BIN) $(DESTDIR) ${prefix}/include
- -$(INSTALLCMD) -m $(INSTALLPERMS_DATA) @tallocdir@/talloc.h $(DESTDIR)${prefix}/include
+ -$(INSTALLCMD) -m $(INSTALLPERMS_DATA) $(srcdir)/@tallocdir@/talloc.h $(DESTDIR)${prefix}/include
installlibtdb: installdirs libtdb
@$(SHELL) $(srcdir)/script/installdirs.sh $(INSTALLPERMS_BIN) $(DESTDIR) $(LIBDIR)
diff --git a/source3/auth/token_util.c b/source3/auth/token_util.c
index fc93060fc6..6720a2cbd8 100644
--- a/source3/auth/token_util.c
+++ b/source3/auth/token_util.c
@@ -105,6 +105,8 @@ NT_USER_TOKEN *get_root_nt_token( void )
token = create_local_nt_token(NULL, &u_sid, False,
1, &global_sid_Builtin_Administrators);
+ token->privileges = se_disk_operators;
+
memcache_add_talloc(
NULL, SINGLETON_CACHE_TALLOC,
data_blob_string_const("root_nt_token"), token);
diff --git a/source3/client/client.c b/source3/client/client.c
index 882ed4dbdd..b4e1985a83 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -3650,7 +3650,7 @@ static bool browse_host_rpc(bool sort)
info_ctr.ctr.ctr1 = &ctr1;
status = rpccli_srvsvc_NetShareEnumAll(pipe_hnd, frame,
- pipe_hnd->cli->desthost,
+ pipe_hnd->desthost,
&info_ctr,
0xffffffff,
&total_entries,
@@ -3658,7 +3658,7 @@ static bool browse_host_rpc(bool sort)
&werr);
if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(werr)) {
- cli_rpc_pipe_close(pipe_hnd);
+ TALLOC_FREE(pipe_hnd);
TALLOC_FREE(frame);
return false;
}
@@ -3668,7 +3668,7 @@ static bool browse_host_rpc(bool sort)
browse_fn(info.name, info.type, info.comment, NULL);
}
- cli_rpc_pipe_close(pipe_hnd);
+ TALLOC_FREE(pipe_hnd);
TALLOC_FREE(frame);
return true;
}
@@ -4514,6 +4514,8 @@ static int process(const char *base_directory)
static int do_host_query(const char *query_host)
{
+ struct sockaddr_storage ss;
+
cli = cli_cm_open(talloc_tos(), NULL,
query_host, "IPC$", true, smb_encrypt);
if (!cli)
@@ -4521,6 +4523,12 @@ static int do_host_query(const char *query_host)
browse_host(true);
+ if (interpret_string_addr(&ss, query_host, 0) && (ss.ss_family != AF_INET)) {
+ d_printf("%s is an IPv6 address -- no workgroup available\n",
+ query_host);
+ return 1;
+ }
+
if (port != 139) {
/* Workgroups simply don't make sense over anything
diff --git a/source3/configure.in b/source3/configure.in
index 01808a43f3..07e5bbe1d8 100644
--- a/source3/configure.in
+++ b/source3/configure.in
@@ -33,9 +33,9 @@ AC_SUBST(TALLOC_OBJS)
# TODO: These should come from m4_include(lib/tdb/libtdb.m4)
# but currently this fails: things have to get merged from s4.
-tdbdir="${srcdir-.}/lib/tdb"
+tdbdir="lib/tdb"
AC_SUBST(tdbdir)
-TDB_CFLAGS="-I$tdbdir/include"
+TDB_CFLAGS="-I${srcdir-.}/$tdbdir/include"
AC_SUBST(TDB_CFLAGS)
TDB_OBJ="common/tdb.o common/dump.o common/transaction.o common/error.o common/traverse.o"
TDB_OBJ="$TDB_OBJ common/freelist.o common/freelistcheck.o common/io.o common/lock.o common/open.o"
@@ -307,6 +307,18 @@ AC_CACHE_CHECK([that the C compiler understands -w2],samba_cv_HAVE_w2, [
samba_cv_HAVE_w2=yes,samba_cv_HAVE_w2=no,samba_cv_HAVE_w2=cross)])
if test x"$samba_cv_HAVE_w2" = x"yes"; then
Werror_FLAGS="-w2"
+else
+dnl Check if the C compiler understands -errwarn
+AC_CACHE_CHECK([that the C compiler understands -errwarn],samba_cv_HAVE_errwarn, [
+ AC_TRY_RUN_STRICT([
+ int main(void)
+ {
+ return 0;
+ }],[-errwarn=%all],[$CPPFLAGS],[$LDFLAGS],
+ samba_cv_HAVE_errwarn=yes,samba_cv_HAVE_errwarn=no,samba_cv_HAVE_errwarn=cross)])
+if test x"$samba_cv_HAVE_errwarn" = x"yes"; then
+ Werror_FLAGS="-errwarn=%all"
+fi
fi
fi
diff --git a/source3/include/client.h b/source3/include/client.h
index 0e73745edb..5cfc9a6f92 100644
--- a/source3/include/client.h
+++ b/source3/include/client.h
@@ -60,16 +60,19 @@ struct cli_pipe_auth_data {
struct rpc_pipe_client {
struct rpc_pipe_client *prev, *next;
- TALLOC_CTX *mem_ctx;
-
struct cli_state *cli;
- int pipe_idx;
const char *pipe_name;
uint16 fnum;
- const char *domain;
- const char *user_name;
+ const struct ndr_syntax_id *abstract_syntax;
+ const struct ndr_syntax_id *transfer_syntax;
+
+ char *desthost;
+ char *srv_name_slash;
+
+ char *domain;
+ char *user_name;
struct pwd_info pwd;
uint16 max_xmit_frag;
@@ -123,7 +126,6 @@ struct cli_state {
int privileges;
fstring desthost;
- fstring srv_name_slash;
/* The credentials used to open the cli_state connection. */
fstring domain;
diff --git a/source3/include/doserr.h b/source3/include/doserr.h
index 684f17298f..65892d3abd 100644
--- a/source3/include/doserr.h
+++ b/source3/include/doserr.h
@@ -207,9 +207,11 @@
#define WERR_NO_LOGON_SERVERS W_ERROR(1311)
#define WERR_NO_SUCH_LOGON_SESSION W_ERROR(1312)
#define WERR_USER_ALREADY_EXISTS W_ERROR(1316)
+#define WERR_NO_SUCH_USER W_ERROR(1317)
#define WERR_PASSWORD_RESTRICTION W_ERROR(1325)
#define WERR_LOGON_FAILURE W_ERROR(1326)
#define WERR_NO_SUCH_DOMAIN W_ERROR(1355)
+#define WERR_NONE_MAPPED W_ERROR(1332)
#define WERR_INVALID_SECURITY_DESCRIPTOR W_ERROR(1338)
#define WERR_INVALID_DOMAIN_STATE W_ERROR(1353)
#define WERR_INVALID_DOMAIN_ROLE W_ERROR(1354)
diff --git a/source3/include/includes.h b/source3/include/includes.h
index 0b3565f632..06d41957c9 100644
--- a/source3/include/includes.h
+++ b/source3/include/includes.h
@@ -703,6 +703,7 @@ typedef char fstring[FSTRING_LEN];
#include "rpc_perfcount_defs.h"
#include "librpc/gen_ndr/notify.h"
#include "librpc/gen_ndr/xattr.h"
+#include "librpc/rpc/dcerpc.h"
#include "nt_printing.h"
#include "idmap.h"
#include "client.h"
diff --git a/source3/include/nameserv.h b/source3/include/nameserv.h
index 46236970a6..4377e3330a 100644
--- a/source3/include/nameserv.h
+++ b/source3/include/nameserv.h
@@ -491,7 +491,9 @@ struct nmb_packet {
#define DGRAM_UNIQUE 0x10
#define DGRAM_GROUP 0x11
#define DGRAM_BROADCAST 0x12
+/* defined in IDL
#define DGRAM_ERROR 0x13
+*/
#define DGRAM_QUERY_REQUEST 0x14
#define DGRAM_POSITIVE_QUERY_RESPONSE 0x15
#define DGRAM_NEGATIVE_QUERT_RESPONSE 0x16
diff --git a/source3/include/rpc_client.h b/source3/include/rpc_client.h
index c552271ee7..ce0c932981 100644
--- a/source3/include/rpc_client.h
+++ b/source3/include/rpc_client.h
@@ -91,7 +91,7 @@
#define CLI_DO_RPC_WERR( pcli, ctx, p_idx, opnum, q_in, r_out, \
q_ps, r_ps, q_io_fn, r_io_fn, default_error ) \
{\
- SMB_ASSERT(pcli->pipe_idx == p_idx); \
+ SMB_ASSERT(rpccli_is_pipe_idx(pcli, p_idx)); \
if (!prs_init( &q_ps, RPC_MAX_PDU_FRAG_LEN, ctx, MARSHALL )) { \
return WERR_NOMEM;\
}\
diff --git a/source3/include/rpc_dce.h b/source3/include/rpc_dce.h
index 33ab365160..9b2044fa20 100644
--- a/source3/include/rpc_dce.h
+++ b/source3/include/rpc_dce.h
@@ -157,10 +157,7 @@ enum schannel_direction {
#define RPC_MAX_PDU_FRAG_LEN 0x10b8 /* this is what w2k sets */
/* RPC_IFACE */
-typedef struct rpc_iface_info {
- struct GUID uuid; /* 16 bytes of rpc interface identification */
- uint32 version; /* the interface version number */
-} RPC_IFACE;
+typedef struct ndr_syntax_id RPC_IFACE;
#define RPC_IFACE_LEN (UUID_SIZE + 4)
@@ -168,10 +165,10 @@ struct pipe_id_info {
/* the names appear not to matter: the syntaxes _do_ matter */
const char *client_pipe;
- RPC_IFACE abstr_syntax; /* this one is the abstract syntax id */
+ const RPC_IFACE *abstr_syntax; /* this one is the abstract syntax id */
const char *server_pipe; /* this one is the secondary syntax name */
- RPC_IFACE trans_syntax; /* this one is the primary syntax id */
+ const RPC_IFACE *trans_syntax; /* this one is the primary syntax id */
};
/* RPC_HDR - dce rpc header */
diff --git a/source3/include/smb.h b/source3/include/smb.h
index d52d8493d0..598708bfe3 100644
--- a/source3/include/smb.h
+++ b/source3/include/smb.h
@@ -310,6 +310,7 @@ extern const DATA_BLOB data_blob_null;
#include "librpc/gen_ndr/libnet_join.h"
#include "librpc/gen_ndr/krb5pac.h"
#include "librpc/gen_ndr/ntsvcs.h"
+#include "librpc/gen_ndr/nbt.h"
struct lsa_dom_info {
bool valid;
diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h
index c98c4244de..0e21431226 100644
--- a/source3/include/smb_macros.h
+++ b/source3/include/smb_macros.h
@@ -169,8 +169,11 @@
#define reply_botherror(req,status,eclass,ecode) reply_both_error(req,eclass,ecode,status,__LINE__,__FILE__)
#define reply_unixerror(req,defclass,deferror) reply_unix_error(req,defclass,deferror,NT_STATUS_OK,__LINE__,__FILE__)
+#if 0
+/* defined in IDL */
/* these are the datagram types */
#define DGRAM_DIRECT_UNIQUE 0x10
+#endif
#define SMB_ROUNDUP(x,r) ( ((x)%(r)) ? ( (((x)+(r))/(r))*(r) ) : (x))
diff --git a/source3/include/vfs.h b/source3/include/vfs.h
index ca176aabb2..c8397164bc 100644
--- a/source3/include/vfs.h
+++ b/source3/include/vfs.h
@@ -105,6 +105,7 @@
/* Leave at 22 - not yet released. Remove parameter fromfd from recvfile. - obnox */
/* Leave at 22 - not yet released. Additional change: add operations for offline files -- ab */
/* Leave at 22 - not yet released. Add the streaminfo call. -- jpeach, vl */
+/* Leave at 22 - not yet released. Remove parameter fd from close_fn. - obnox */
#define SMB_VFS_INTERFACE_VERSION 22
@@ -301,7 +302,7 @@ struct vfs_ops {
/* File operations */
int (*open)(struct vfs_handle_struct *handle, const char *fname, files_struct *fsp, int flags, mode_t mode);
- int (*close_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, int fd);
+ int (*close_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp);
ssize_t (*read)(struct vfs_handle_struct *handle, struct files_struct *fsp, void *data, size_t n);
ssize_t (*pread)(struct vfs_handle_struct *handle, struct files_struct *fsp, void *data, size_t n, SMB_OFF_T offset);
ssize_t (*write)(struct vfs_handle_struct *handle, struct files_struct *fsp, const void *data, size_t n);
diff --git a/source3/include/vfs_macros.h b/source3/include/vfs_macros.h
index 1e64bd5ac3..f0a9809ecc 100644
--- a/source3/include/vfs_macros.h
+++ b/source3/include/vfs_macros.h
@@ -48,7 +48,7 @@
/* File operations */
#define SMB_VFS_OPEN(conn, fname, fsp, flags, mode) (((conn)->vfs.ops.open)((conn)->vfs.handles.open, (fname), (fsp), (flags), (mode)))
-#define SMB_VFS_CLOSE(fsp, fd) ((fsp)->conn->vfs.ops.close_fn((fsp)->conn->vfs.handles.close_hnd, (fsp), (fd)))
+#define SMB_VFS_CLOSE(fsp) ((fsp)->conn->vfs.ops.close_fn((fsp)->conn->vfs.handles.close_hnd, (fsp)))
#define SMB_VFS_READ(fsp, data, n) ((fsp)->conn->vfs.ops.read((fsp)->conn->vfs.handles.read, (fsp), (data), (n)))
#define SMB_VFS_PREAD(fsp, data, n, off) ((fsp)->conn->vfs.ops.pread((fsp)->conn->vfs.handles.pread, (fsp), (data), (n), (off)))
#define SMB_VFS_WRITE(fsp, data, n) ((fsp)->conn->vfs.ops.write((fsp)->conn->vfs.handles.write, (fsp), (data), (n)))
@@ -174,7 +174,7 @@
/* File operations */
#define SMB_VFS_OPAQUE_OPEN(conn, fname, fsp, flags, mode) (((conn)->vfs_opaque.ops.open)((conn)->vfs_opaque.handles.open, (fname), (fsp), (flags), (mode)))
-#define SMB_VFS_OPAQUE_CLOSE(fsp, fd) ((fsp)->conn->vfs_opaque.ops.close_fn((fsp)->conn->vfs_opaque.handles.close_hnd, (fsp), (fd)))
+#define SMB_VFS_OPAQUE_CLOSE(fsp) ((fsp)->conn->vfs_opaque.ops.close_fn((fsp)->conn->vfs_opaque.handles.close_hnd, (fsp)))
#define SMB_VFS_OPAQUE_READ(fsp, data, n) ((fsp)->conn->vfs_opaque.ops.read((fsp)->conn->vfs_opaque.handles.read, (fsp), (data), (n)))
#define SMB_VFS_OPAQUE_PREAD(fsp, data, n, off) ((fsp)->conn->vfs_opaque.ops.pread((fsp)->conn->vfs_opaque.handles.pread, (fsp), (data), (n), (off)))
#define SMB_VFS_OPAQUE_WRITE(fsp, data, n) ((fsp)->conn->vfs_opaque.ops.write((fsp)->conn->vfs_opaque.handles.write, (fsp), (data), (n)))
@@ -301,7 +301,7 @@
/* File operations */
#define SMB_VFS_NEXT_OPEN(handle, fname, fsp, flags, mode) (((handle)->vfs_next.ops.open)((handle)->vfs_next.handles.open, (fname), (fsp), (flags), (mode)))
-#define SMB_VFS_NEXT_CLOSE(handle, fsp, fd) ((handle)->vfs_next.ops.close_fn((handle)->vfs_next.handles.close_hnd, (fsp), (fd)))
+#define SMB_VFS_NEXT_CLOSE(handle, fsp) ((handle)->vfs_next.ops.close_fn((handle)->vfs_next.handles.close_hnd, (fsp)))
#define SMB_VFS_NEXT_READ(handle, fsp, data, n) ((handle)->vfs_next.ops.read((handle)->vfs_next.handles.read, (fsp), (data), (n)))
#define SMB_VFS_NEXT_PREAD(handle, fsp, data, n, off) ((handle)->vfs_next.ops.pread((handle)->vfs_next.handles.pread, (fsp), (data), (n), (off)))
#define SMB_VFS_NEXT_WRITE(handle, fsp, data, n) ((handle)->vfs_next.ops.write((handle)->vfs_next.handles.write, (fsp), (data), (n)))
diff --git a/source3/lib/messages_ctdbd.c b/source3/lib/messages_ctdbd.c
index f1a02e6af9..7d182a57d8 100644
--- a/source3/lib/messages_ctdbd.c
+++ b/source3/lib/messages_ctdbd.c
@@ -35,10 +35,36 @@ struct messaging_ctdbd_context {
* This is a Samba3 hack/optimization. Routines like process_exists need to
* talk to ctdbd, and they don't get handed a messaging context.
*/
-struct ctdbd_connection *global_ctdbd_connection;
+static struct ctdbd_connection *global_ctdbd_connection;
+static int global_ctdb_connection_pid;
struct ctdbd_connection *messaging_ctdbd_connection(void)
{
+ if (global_ctdb_connection_pid == 0 &&
+ global_ctdbd_connection == NULL) {
+ struct event_context *ev;
+ struct messaging_context *msg;
+
+ ev = event_context_init(NULL);
+ if (!ev) {
+ DEBUG(0,("event_context_init failed\n"));
+ }
+
+ msg = messaging_init(NULL, procid_self(), ev);
+ if (!msg) {
+ DEBUG(0,("messaging_init failed\n"));
+ }
+
+ db_tdb2_setup_messaging(msg, false);
+ }
+
+ if (global_ctdb_connection_pid != getpid()) {
+ DEBUG(0,("messaging_ctdbd_connection():"
+ "valid for pid[%d] but it's [%d]\n",
+ global_ctdb_connection_pid, getpid()));
+ smb_panic("messaging_ctdbd_connection() invalid process\n");
+ }
+
return global_ctdbd_connection;
}
@@ -66,6 +92,7 @@ static int messaging_ctdbd_destructor(struct messaging_ctdbd_context *ctx)
/*
* The global connection just went away
*/
+ global_ctdb_connection_pid = 0;
global_ctdbd_connection = NULL;
return 0;
}
@@ -107,6 +134,7 @@ NTSTATUS messaging_ctdbd_init(struct messaging_context *msg_ctx,
return status;
}
+ global_ctdb_connection_pid = getpid();
global_ctdbd_connection = ctx->conn;
talloc_set_destructor(ctx, messaging_ctdbd_destructor);
diff --git a/source3/lib/netapi/Doxyfile b/source3/lib/netapi/Doxyfile
new file mode 100644
index 0000000000..44bf78b06c
--- /dev/null
+++ b/source3/lib/netapi/Doxyfile
@@ -0,0 +1,1362 @@
+# Doxyfile 1.5.5
+
+# This file describes the settings to be used by the documentation system
+# doxygen (www.doxygen.org) for a project
+#
+# All text after a hash (#) is considered a comment and will be ignored
+# The format is:
+# TAG = value [value, ...]
+# For lists items can also be appended using:
+# TAG += value [value, ...]
+# Values that contain spaces should be placed between quotes (" ")
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+
+# This tag specifies the encoding used for all characters in the config file
+# that follow. The default is UTF-8 which is also the encoding used for all
+# text before the first occurrence of this tag. Doxygen uses libiconv (or the
+# iconv built into libc) for the transcoding. See
+# http://www.gnu.org/software/libiconv for the list of possible encodings.
+
+DOXYFILE_ENCODING = UTF-8
+
+# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
+# by quotes) that should identify the project.
+
+PROJECT_NAME = Samba
+
+# The PROJECT_NUMBER tag can be used to enter a project or revision number.
+# This could be handy for archiving the generated documentation or
+# if some version control system is used.
+
+PROJECT_NUMBER = 3.2.0pre3
+
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
+# base path where the generated documentation will be put.
+# If a relative path is entered, it will be relative to the location
+# where doxygen was started. If left blank the current directory will be used.
+
+OUTPUT_DIRECTORY = dox
+
+# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
+# 4096 sub-directories (in 2 levels) under the output directory of each output
+# format and will distribute the generated files over these directories.
+# Enabling this option can be useful when feeding doxygen a huge amount of
+# source files, where putting all generated files in the same directory would
+# otherwise cause performance problems for the file system.
+
+CREATE_SUBDIRS = NO
+
+# The OUTPUT_LANGUAGE tag is used to specify the language in which all
+# documentation generated by doxygen is written. Doxygen will use this
+# information to generate all constant output in the proper language.
+# The default language is English, other supported languages are:
+# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional,
+# Croatian, Czech, Danish, Dutch, Farsi, Finnish, French, German, Greek,
+# Hungarian, Italian, Japanese, Japanese-en (Japanese with English messages),
+# Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, Polish,
+# Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish, Swedish,
+# and Ukrainian.
+
+OUTPUT_LANGUAGE = English
+
+# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
+# include brief member descriptions after the members that are listed in
+# the file and class documentation (similar to JavaDoc).
+# Set to NO to disable this.
+
+BRIEF_MEMBER_DESC = YES
+
+# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
+# the brief description of a member or function before the detailed description.
+# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
+# brief descriptions will be completely suppressed.
+
+REPEAT_BRIEF = YES
+
+# This tag implements a quasi-intelligent brief description abbreviator
+# that is used to form the text in various listings. Each string
+# in this list, if found as the leading text of the brief description, will be
+# stripped from the text and the result after processing the whole list, is
+# used as the annotated text. Otherwise, the brief description is used as-is.
+# If left blank, the following values are used ("$name" is automatically
+# replaced with the name of the entity): "The $name class" "The $name widget"
+# "The $name file" "is" "provides" "specifies" "contains"
+# "represents" "a" "an" "the"
+
+ABBREVIATE_BRIEF =
+
+# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
+# Doxygen will generate a detailed section even if there is only a brief
+# description.
+
+ALWAYS_DETAILED_SEC = NO
+
+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
+# inherited members of a class in the documentation of that class as if those
+# members were ordinary class members. Constructors, destructors and assignment
+# operators of the base classes will not be shown.
+
+INLINE_INHERITED_MEMB = NO
+
+# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
+# path before files name in the file list and in the header files. If set
+# to NO the shortest path that makes the file name unique will be used.
+
+FULL_PATH_NAMES = YES
+
+# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
+# can be used to strip a user-defined part of the path. Stripping is
+# only done if one of the specified strings matches the left-hand part of
+# the path. The tag can be used to show relative paths in the file list.
+# If left blank the directory from which doxygen is run is used as the
+# path to strip.
+
+STRIP_FROM_PATH = $(PWD)/
+
+# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of
+# the path mentioned in the documentation of a class, which tells
+# the reader which header file to include in order to use a class.
+# If left blank only the name of the header file containing the class
+# definition is used. Otherwise one should specify the include paths that
+# are normally passed to the compiler using the -I flag.
+
+STRIP_FROM_INC_PATH =
+
+# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
+# (but less readable) file names. This can be useful is your file systems
+# doesn't support long names like on DOS, Mac, or CD-ROM.
+
+SHORT_NAMES = NO
+
+# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
+# will interpret the first line (until the first dot) of a JavaDoc-style
+# comment as the brief description. If set to NO, the JavaDoc
+# comments will behave just like regular Qt-style comments
+# (thus requiring an explicit @brief command for a brief description.)
+
+JAVADOC_AUTOBRIEF = YES
+
+# If the QT_AUTOBRIEF tag is set to YES then Doxygen will
+# interpret the first line (until the first dot) of a Qt-style
+# comment as the brief description. If set to NO, the comments
+# will behave just like regular Qt-style comments (thus requiring
+# an explicit \brief command for a brief description.)
+
+QT_AUTOBRIEF = NO
+
+# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen
+# treat a multi-line C++ special comment block (i.e. a block of //! or ///
+# comments) as a brief description. This used to be the default behaviour.
+# The new default is to treat a multi-line C++ comment block as a detailed
+# description. Set this tag to YES if you prefer the old behaviour instead.
+
+MULTILINE_CPP_IS_BRIEF = NO
+
+# If the DETAILS_AT_TOP tag is set to YES then Doxygen
+# will output the detailed description near the top, like JavaDoc.
+# If set to NO, the detailed description appears after the member
+# documentation.
+
+DETAILS_AT_TOP = NO
+
+# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
+# member inherits the documentation from any documented member that it
+# re-implements.
+
+INHERIT_DOCS = YES
+
+# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce
+# a new page for each member. If set to NO, the documentation of a member will
+# be part of the file/class/namespace that contains it.
+
+SEPARATE_MEMBER_PAGES = NO
+
+# The TAB_SIZE tag can be used to set the number of spaces in a tab.
+# Doxygen uses this value to replace tabs by spaces in code fragments.
+
+TAB_SIZE = 8
+
+# This tag can be used to specify a number of aliases that acts
+# as commands in the documentation. An alias has the form "name=value".
+# For example adding "sideeffect=\par Side Effects:\n" will allow you to
+# put the command \sideeffect (or @sideeffect) in the documentation, which
+# will result in a user-defined paragraph with heading "Side Effects:".
+# You can put \n's in the value part of an alias to insert newlines.
+
+ALIASES =
+
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C
+# sources only. Doxygen will then generate output that is more tailored for C.
+# For instance, some of the names that are used will be different. The list
+# of all members will be omitted, etc.
+
+OPTIMIZE_OUTPUT_FOR_C = YES
+
+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java
+# sources only. Doxygen will then generate output that is more tailored for
+# Java. For instance, namespaces will be presented as packages, qualified
+# scopes will look different, etc.
+
+OPTIMIZE_OUTPUT_JAVA = NO
+
+# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran
+# sources only. Doxygen will then generate output that is more tailored for
+# Fortran.
+
+OPTIMIZE_FOR_FORTRAN = NO
+
+# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL
+# sources. Doxygen will then generate output that is tailored for
+# VHDL.
+
+OPTIMIZE_OUTPUT_VHDL = NO
+
+# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want
+# to include (a tag file for) the STL sources as input, then you should
+# set this tag to YES in order to let doxygen match functions declarations and
+# definitions whose arguments contain STL classes (e.g. func(std::string); v.s.
+# func(std::string) {}). This also make the inheritance and collaboration
+# diagrams that involve STL classes more complete and accurate.
+
+BUILTIN_STL_SUPPORT = NO
+
+# If you use Microsoft's C++/CLI language, you should set this option to YES to
+# enable parsing support.
+
+CPP_CLI_SUPPORT = NO
+
+# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only.
+# Doxygen will parse them like normal C++ but will assume all classes use public
+# instead of private inheritance when no explicit protection keyword is present.
+
+SIP_SUPPORT = NO
+
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
+# tag is set to YES, then doxygen will reuse the documentation of the first
+# member in the group (if any) for the other members of the group. By default
+# all members of a group must be documented explicitly.
+
+DISTRIBUTE_GROUP_DOC = NO
+
+# Set the SUBGROUPING tag to YES (the default) to allow class member groups of
+# the same type (for instance a group of public functions) to be put as a
+# subgroup of that type (e.g. under the Public Functions section). Set it to
+# NO to prevent subgrouping. Alternatively, this can be done per class using
+# the \nosubgrouping command.
+
+SUBGROUPING = YES
+
+# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum
+# is documented as struct, union, or enum with the name of the typedef. So
+# typedef struct TypeS {} TypeT, will appear in the documentation as a struct
+# with name TypeT. When disabled the typedef will appear as a member of a file,
+# namespace, or class. And the struct will be named TypeS. This can typically
+# be useful for C code in case the coding convention dictates that all compound
+# types are typedef'ed and only the typedef is referenced, never the tag name.
+
+TYPEDEF_HIDES_STRUCT = NO
+
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+
+# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
+# documentation are documented, even if no documentation was available.
+# Private class members and static file members will be hidden unless
+# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
+
+EXTRACT_ALL = YES
+
+# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
+# will be included in the documentation.
+
+EXTRACT_PRIVATE = YES
+
+# If the EXTRACT_STATIC tag is set to YES all static members of a file
+# will be included in the documentation.
+
+EXTRACT_STATIC = YES
+
+# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
+# defined locally in source files will be included in the documentation.
+# If set to NO only classes defined in header files are included.
+
+EXTRACT_LOCAL_CLASSES = YES
+
+# This flag is only useful for Objective-C code. When set to YES local
+# methods, which are defined in the implementation section but not in
+# the interface are included in the documentation.
+# If set to NO (the default) only methods in the interface are included.
+
+EXTRACT_LOCAL_METHODS = NO
+
+# If this flag is set to YES, the members of anonymous namespaces will be
+# extracted and appear in the documentation as a namespace called
+# 'anonymous_namespace{file}', where file will be replaced with the base
+# name of the file that contains the anonymous namespace. By default
+# anonymous namespace are hidden.
+
+EXTRACT_ANON_NSPACES = NO
+
+# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
+# undocumented members of documented classes, files or namespaces.
+# If set to NO (the default) these members will be included in the
+# various overviews, but no documentation section is generated.
+# This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_MEMBERS = NO
+
+# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
+# undocumented classes that are normally visible in the class hierarchy.
+# If set to NO (the default) these classes will be included in the various
+# overviews. This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_CLASSES = NO
+
+# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all
+# friend (class|struct|union) declarations.
+# If set to NO (the default) these declarations will be included in the
+# documentation.
+
+HIDE_FRIEND_COMPOUNDS = NO
+
+# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any
+# documentation blocks found inside the body of a function.
+# If set to NO (the default) these blocks will be appended to the
+# function's detailed documentation block.
+
+HIDE_IN_BODY_DOCS = NO
+
+# The INTERNAL_DOCS tag determines if documentation
+# that is typed after a \internal command is included. If the tag is set
+# to NO (the default) then the documentation will be excluded.
+# Set it to YES to include the internal documentation.
+
+INTERNAL_DOCS = YES
+
+# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
+# file names in lower-case letters. If set to YES upper-case letters are also
+# allowed. This is useful if you have classes or files whose names only differ
+# in case and if your file system supports case sensitive file names. Windows
+# and Mac users are advised to set this option to NO.
+
+CASE_SENSE_NAMES = YES
+
+# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
+# will show members with their full class and namespace scopes in the
+# documentation. If set to YES the scope will be hidden.
+
+HIDE_SCOPE_NAMES = YES
+
+# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
+# will put a list of the files that are included by a file in the documentation
+# of that file.
+
+SHOW_INCLUDE_FILES = YES
+
+# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
+# is inserted in the documentation for inline members.
+
+INLINE_INFO = YES
+
+# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
+# will sort the (detailed) documentation of file and class members
+# alphabetically by member name. If set to NO the members will appear in
+# declaration order.
+
+SORT_MEMBER_DOCS = NO
+
+# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the
+# brief documentation of file, namespace and class members alphabetically
+# by member name. If set to NO (the default) the members will appear in
+# declaration order.
+
+SORT_BRIEF_DOCS = NO
+
+# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the
+# hierarchy of group names into alphabetical order. If set to NO (the default)
+# the group names will appear in their defined order.
+
+SORT_GROUP_NAMES = NO
+
+# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be
+# sorted by fully-qualified names, including namespaces. If set to
+# NO (the default), the class list will be sorted only by class name,
+# not including the namespace part.
+# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
+# Note: This option applies only to the class list, not to the
+# alphabetical list.
+
+SORT_BY_SCOPE_NAME = NO
+
+# The GENERATE_TODOLIST tag can be used to enable (YES) or
+# disable (NO) the todo list. This list is created by putting \todo
+# commands in the documentation.
+
+GENERATE_TODOLIST = YES
+
+# The GENERATE_TESTLIST tag can be used to enable (YES) or
+# disable (NO) the test list. This list is created by putting \test
+# commands in the documentation.
+
+GENERATE_TESTLIST = YES
+
+# The GENERATE_BUGLIST tag can be used to enable (YES) or
+# disable (NO) the bug list. This list is created by putting \bug
+# commands in the documentation.
+
+GENERATE_BUGLIST = YES
+
+# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or
+# disable (NO) the deprecated list. This list is created by putting
+# \deprecated commands in the documentation.
+
+GENERATE_DEPRECATEDLIST= YES
+
+# The ENABLED_SECTIONS tag can be used to enable conditional
+# documentation sections, marked by \if sectionname ... \endif.
+
+ENABLED_SECTIONS =
+
+# The MAX_INITIALIZER_LINES tag determines the maximum number of lines
+# the initial value of a variable or define consists of for it to appear in
+# the documentation. If the initializer consists of more lines than specified
+# here it will be hidden. Use a value of 0 to hide initializers completely.
+# The appearance of the initializer of individual variables and defines in the
+# documentation can be controlled using \showinitializer or \hideinitializer
+# command in the documentation regardless of this setting.
+
+MAX_INITIALIZER_LINES = 30
+
+# Set the SHOW_USED_FILES tag to NO to disable the list of files generated
+# at the bottom of the documentation of classes and structs. If set to YES the
+# list will mention the files that were used to generate the documentation.
+
+SHOW_USED_FILES = YES
+
+# If the sources in your project are distributed over multiple directories
+# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy
+# in the documentation. The default is NO.
+
+SHOW_DIRECTORIES = NO
+
+# The FILE_VERSION_FILTER tag can be used to specify a program or script that
+# doxygen should invoke to get the current version for each file (typically from
+# the version control system). Doxygen will invoke the program by executing (via
+# popen()) the command <command> <input-file>, where <command> is the value of
+# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file
+# provided by doxygen. Whatever the program writes to standard output
+# is used as the file version. See the manual for examples.
+
+FILE_VERSION_FILTER =
+
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+
+# The QUIET tag can be used to turn on/off the messages that are generated
+# by doxygen. Possible values are YES and NO. If left blank NO is used.
+
+QUIET = YES
+
+# The WARNINGS tag can be used to turn on/off the warning messages that are
+# generated by doxygen. Possible values are YES and NO. If left blank
+# NO is used.
+
+WARNINGS = NO
+
+# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
+# for undocumented members. If EXTRACT_ALL is set to YES then this flag will
+# automatically be disabled.
+
+WARN_IF_UNDOCUMENTED = NO
+
+# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for
+# potential errors in the documentation, such as not documenting some
+# parameters in a documented function, or documenting parameters that
+# don't exist or using markup commands wrongly.
+
+WARN_IF_DOC_ERROR = YES
+
+# This WARN_NO_PARAMDOC option can be abled to get warnings for
+# functions that are documented, but have no documentation for their parameters
+# or return value. If set to NO (the default) doxygen will only warn about
+# wrong or incomplete parameter documentation, but not about the absence of
+# documentation.
+
+WARN_NO_PARAMDOC = NO
+
+# The WARN_FORMAT tag determines the format of the warning messages that
+# doxygen can produce. The string should contain the $file, $line, and $text
+# tags, which will be replaced by the file and line number from which the
+# warning originated and the warning text. Optionally the format may contain
+# $version, which will be replaced by the version of the file (if it could
+# be obtained via FILE_VERSION_FILTER)
+
+WARN_FORMAT = "$file:$line: $text"
+
+# The WARN_LOGFILE tag can be used to specify a file to which warning
+# and error messages should be written. If left blank the output is written
+# to stderr.
+
+WARN_LOGFILE =
+
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+
+# The INPUT tag can be used to specify the files and/or directories that contain
+# documented source files. You may enter file names like "myfile.cpp" or
+# directories like "/usr/src/myproject". Separate the files or directories
+# with spaces.
+
+INPUT = netapi.h
+
+# This tag can be used to specify the character encoding of the source files
+# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
+# also the default input encoding. Doxygen uses libiconv (or the iconv built
+# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for
+# the list of possible encodings.
+
+INPUT_ENCODING = UTF-8
+
+# If the value of the INPUT tag contains directories, you can use the
+# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
+# blank the following patterns are tested:
+# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx
+# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90
+
+FILE_PATTERNS = *.c \
+ *.h \
+ *.idl
+
+# The RECURSIVE tag can be used to turn specify whether or not subdirectories
+# should be searched for input files as well. Possible values are YES and NO.
+# If left blank NO is used.
+
+RECURSIVE = YES
+
+# The EXCLUDE tag can be used to specify files and/or directories that should
+# excluded from the INPUT source files. This way you can easily exclude a
+# subdirectory from a directory tree whose root is specified with the INPUT tag.
+
+EXCLUDE = include/includes.h \
+ include/proto.h \
+ libnetapi.c \
+ libnetapi.h \
+ netapi.c
+
+# The EXCLUDE_SYMLINKS tag can be used select whether or not files or
+# directories that are symbolic links (a Unix filesystem feature) are excluded
+# from the input.
+
+EXCLUDE_SYMLINKS = NO
+
+# If the value of the INPUT tag contains directories, you can use the
+# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
+# certain files from those directories. Note that the wildcards are matched
+# against the file with absolute path, so to exclude all test directories
+# for example use the pattern */test/*
+
+EXCLUDE_PATTERNS =
+
+# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
+# (namespaces, classes, functions, etc.) that should be excluded from the
+# output. The symbol name can be a fully qualified name, a word, or if the
+# wildcard * is used, a substring. Examples: ANamespace, AClass,
+# AClass::ANamespace, ANamespace::*Test
+
+EXCLUDE_SYMBOLS =
+
+# The EXAMPLE_PATH tag can be used to specify one or more files or
+# directories that contain example code fragments that are included (see
+# the \include command).
+
+EXAMPLE_PATH = examples
+
+# If the value of the EXAMPLE_PATH tag contains directories, you can use the
+# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
+# blank all files are included.
+
+EXAMPLE_PATTERNS =
+
+# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
+# searched for input files to be used with the \include or \dontinclude
+# commands irrespective of the value of the RECURSIVE tag.
+# Possible values are YES and NO. If left blank NO is used.
+
+EXAMPLE_RECURSIVE = NO
+
+# The IMAGE_PATH tag can be used to specify one or more files or
+# directories that contain image that are included in the documentation (see
+# the \image command).
+
+IMAGE_PATH =
+
+# The INPUT_FILTER tag can be used to specify a program that doxygen should
+# invoke to filter for each input file. Doxygen will invoke the filter program
+# by executing (via popen()) the command <filter> <input-file>, where <filter>
+# is the value of the INPUT_FILTER tag, and <input-file> is the name of an
+# input file. Doxygen will then use the output that the filter program writes
+# to standard output. If FILTER_PATTERNS is specified, this tag will be
+# ignored.
+
+INPUT_FILTER =
+
+# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
+# basis. Doxygen will compare the file name with each pattern and apply the
+# filter if there is a match. The filters are a list of the form:
+# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further
+# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER
+# is applied to all files.
+
+FILTER_PATTERNS =
+
+# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
+# INPUT_FILTER) will be used to filter the input files when producing source
+# files to browse (i.e. when SOURCE_BROWSER is set to YES).
+
+FILTER_SOURCE_FILES = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+
+# If the SOURCE_BROWSER tag is set to YES then a list of source files will
+# be generated. Documented entities will be cross-referenced with these sources.
+# Note: To get rid of all source code in the generated output, make sure also
+# VERBATIM_HEADERS is set to NO.
+
+SOURCE_BROWSER = YES
+
+# Setting the INLINE_SOURCES tag to YES will include the body
+# of functions and classes directly in the documentation.
+
+INLINE_SOURCES = YES
+
+# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
+# doxygen to hide any special comment blocks from generated source code
+# fragments. Normal C and C++ comments will always remain visible.
+
+STRIP_CODE_COMMENTS = NO
+
+# If the REFERENCED_BY_RELATION tag is set to YES (the default)
+# then for each documented function all documented
+# functions referencing it will be listed.
+
+REFERENCED_BY_RELATION = YES
+
+# If the REFERENCES_RELATION tag is set to YES (the default)
+# then for each documented function all documented entities
+# called/used by that function will be listed.
+
+REFERENCES_RELATION = NO
+
+# If the REFERENCES_LINK_SOURCE tag is set to YES (the default)
+# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from
+# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will
+# link to the source code. Otherwise they will link to the documentstion.
+
+REFERENCES_LINK_SOURCE = YES
+
+# If the USE_HTAGS tag is set to YES then the references to source code
+# will point to the HTML generated by the htags(1) tool instead of doxygen
+# built-in source browser. The htags tool is part of GNU's global source
+# tagging system (see http://www.gnu.org/software/global/global.html). You
+# will need version 4.8.6 or higher.
+
+USE_HTAGS = NO
+
+# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
+# will generate a verbatim copy of the header file for each class for
+# which an include is specified. Set to NO to disable this.
+
+VERBATIM_HEADERS = YES
+
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+
+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index
+# of all compounds will be generated. Enable this if the project
+# contains a lot of classes, structs, unions or interfaces.
+
+ALPHABETICAL_INDEX = YES
+
+# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then
+# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
+# in which this list will be split (can be a number in the range [1..20])
+
+COLS_IN_ALPHA_INDEX = 1
+
+# In case all classes in a project start with a common prefix, all
+# classes will be put under the same header in the alphabetical index.
+# The IGNORE_PREFIX tag can be used to specify one or more prefixes that
+# should be ignored while generating the index headers.
+
+IGNORE_PREFIX =
+
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_HTML tag is set to YES (the default) Doxygen will
+# generate HTML output.
+
+GENERATE_HTML = YES
+
+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `html' will be used as the default path.
+
+HTML_OUTPUT = .
+
+# The HTML_FILE_EXTENSION tag can be used to specify the file extension for
+# each generated HTML page (for example: .htm,.php,.asp). If it is left blank
+# doxygen will generate files with .html extension.
+
+HTML_FILE_EXTENSION = .html
+
+# The HTML_HEADER tag can be used to specify a personal HTML header for
+# each generated HTML page. If it is left blank doxygen will generate a
+# standard header.
+
+HTML_HEADER =
+
+# The HTML_FOOTER tag can be used to specify a personal HTML footer for
+# each generated HTML page. If it is left blank doxygen will generate a
+# standard footer.
+
+HTML_FOOTER =
+
+# The HTML_STYLESHEET tag can be used to specify a user-defined cascading
+# style sheet that is used by each HTML page. It can be used to
+# fine-tune the look of the HTML output. If the tag is left blank doxygen
+# will generate a default style sheet. Note that doxygen will try to copy
+# the style sheet file to the HTML output directory, so don't put your own
+# stylesheet in the HTML output directory as well, or it will be erased!
+
+HTML_STYLESHEET =
+
+# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
+# files or namespaces will be aligned in HTML using tables. If set to
+# NO a bullet list will be used.
+
+HTML_ALIGN_MEMBERS = YES
+
+# If the GENERATE_HTMLHELP tag is set to YES, additional index files
+# will be generated that can be used as input for tools like the
+# Microsoft HTML help workshop to generate a compiled HTML help file (.chm)
+# of the generated HTML documentation.
+
+GENERATE_HTMLHELP = NO
+
+# If the GENERATE_DOCSET tag is set to YES, additional index files
+# will be generated that can be used as input for Apple's Xcode 3
+# integrated development environment, introduced with OSX 10.5 (Leopard).
+# To create a documentation set, doxygen will generate a Makefile in the
+# HTML output directory. Running make will produce the docset in that
+# directory and running "make install" will install the docset in
+# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find
+# it at startup.
+
+GENERATE_DOCSET = NO
+
+# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the
+# feed. A documentation feed provides an umbrella under which multiple
+# documentation sets from a single provider (such as a company or product suite)
+# can be grouped.
+
+DOCSET_FEEDNAME = "Doxygen generated docs"
+
+# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that
+# should uniquely identify the documentation set bundle. This should be a
+# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen
+# will append .docset to the name.
+
+DOCSET_BUNDLE_ID = org.doxygen.Project
+
+# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
+# documentation will contain sections that can be hidden and shown after the
+# page has loaded. For this to work a browser that supports
+# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox
+# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari).
+
+HTML_DYNAMIC_SECTIONS = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can
+# be used to specify the file name of the resulting .chm file. You
+# can add a path in front of the file if the result should not be
+# written to the html output directory.
+
+CHM_FILE =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can
+# be used to specify the location (absolute path including file name) of
+# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run
+# the HTML help compiler on the generated index.hhp.
+
+HHC_LOCATION =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
+# controls if a separate .chi index file is generated (YES) or that
+# it should be included in the master .chm file (NO).
+
+GENERATE_CHI = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag
+# controls whether a binary table of contents is generated (YES) or a
+# normal table of contents (NO) in the .chm file.
+
+BINARY_TOC = NO
+
+# The TOC_EXPAND flag can be set to YES to add extra items for group members
+# to the contents of the HTML help documentation and to the tree view.
+
+TOC_EXPAND = NO
+
+# The DISABLE_INDEX tag can be used to turn on/off the condensed index at
+# top of each HTML page. The value NO (the default) enables the index and
+# the value YES disables it.
+
+DISABLE_INDEX = NO
+
+# This tag can be used to set the number of enum values (range [1..20])
+# that doxygen will group on one line in the generated HTML documentation.
+
+ENUM_VALUES_PER_LINE = 3
+
+# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be
+# generated containing a tree-like index structure (just like the one that
+# is generated for HTML Help). For this to work a browser that supports
+# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+,
+# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are
+# probably better off using the HTML help feature.
+
+GENERATE_TREEVIEW = NO
+
+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
+# used to set the initial width (in pixels) of the frame in which the tree
+# is shown.
+
+TREEVIEW_WIDTH = 250
+
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
+# generate Latex output.
+
+GENERATE_LATEX = NO
+
+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `latex' will be used as the default path.
+
+LATEX_OUTPUT = latex
+
+# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
+# invoked. If left blank `latex' will be used as the default command name.
+
+LATEX_CMD_NAME = latex
+
+# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to
+# generate index for LaTeX. If left blank `makeindex' will be used as the
+# default command name.
+
+MAKEINDEX_CMD_NAME = makeindex
+
+# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
+# LaTeX documents. This may be useful for small projects and may help to
+# save some trees in general.
+
+COMPACT_LATEX = NO
+
+# The PAPER_TYPE tag can be used to set the paper type that is used
+# by the printer. Possible values are: a4, a4wide, letter, legal and
+# executive. If left blank a4wide will be used.
+
+PAPER_TYPE = a4wide
+
+# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
+# packages that should be included in the LaTeX output.
+
+EXTRA_PACKAGES =
+
+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for
+# the generated latex document. The header should contain everything until
+# the first chapter. If it is left blank doxygen will generate a
+# standard header. Notice: only use this tag if you know what you are doing!
+
+LATEX_HEADER =
+
+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
+# is prepared for conversion to pdf (using ps2pdf). The pdf file will
+# contain links (just like the HTML output) instead of page references
+# This makes the output suitable for online browsing using a pdf viewer.
+
+PDF_HYPERLINKS = YES
+
+# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
+# plain latex in the generated Makefile. Set this option to YES to get a
+# higher quality PDF documentation.
+
+USE_PDFLATEX = YES
+
+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
+# command to the generated LaTeX files. This will instruct LaTeX to keep
+# running if errors occur, instead of asking the user for help.
+# This option is also used when generating formulas in HTML.
+
+LATEX_BATCHMODE = YES
+
+# If LATEX_HIDE_INDICES is set to YES then doxygen will not
+# include the index chapters (such as File Index, Compound Index, etc.)
+# in the output.
+
+LATEX_HIDE_INDICES = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
+# The RTF output is optimized for Word 97 and may not look very pretty with
+# other RTF readers or editors.
+
+GENERATE_RTF = NO
+
+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `rtf' will be used as the default path.
+
+RTF_OUTPUT = rtf
+
+# If the COMPACT_RTF tag is set to YES Doxygen generates more compact
+# RTF documents. This may be useful for small projects and may help to
+# save some trees in general.
+
+COMPACT_RTF = NO
+
+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated
+# will contain hyperlink fields. The RTF file will
+# contain links (just like the HTML output) instead of page references.
+# This makes the output suitable for online browsing using WORD or other
+# programs which support those fields.
+# Note: wordpad (write) and others do not support links.
+
+RTF_HYPERLINKS = NO
+
+# Load stylesheet definitions from file. Syntax is similar to doxygen's
+# config file, i.e. a series of assignments. You only have to provide
+# replacements, missing definitions are set to their default value.
+
+RTF_STYLESHEET_FILE =
+
+# Set optional variables used in the generation of an rtf document.
+# Syntax is similar to doxygen's config file.
+
+RTF_EXTENSIONS_FILE =
+
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
+# generate man pages
+
+GENERATE_MAN = YES
+
+# The MAN_OUTPUT tag is used to specify where the man pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `man' will be used as the default path.
+
+MAN_OUTPUT = man
+
+# The MAN_EXTENSION tag determines the extension that is added to
+# the generated man pages (default is the subroutine's section .3)
+
+MAN_EXTENSION = .3
+
+# If the MAN_LINKS tag is set to YES and Doxygen generates man output,
+# then it will generate one additional man file for each entity
+# documented in the real man page(s). These additional files
+# only source the real man page, but without them the man command
+# would be unable to find the correct page. The default is NO.
+
+MAN_LINKS = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_XML tag is set to YES Doxygen will
+# generate an XML file that captures the structure of
+# the code including all documentation.
+
+GENERATE_XML = NO
+
+# The XML_OUTPUT tag is used to specify where the XML pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `xml' will be used as the default path.
+
+XML_OUTPUT = xml
+
+# The XML_SCHEMA tag can be used to specify an XML schema,
+# which can be used by a validating XML parser to check the
+# syntax of the XML files.
+
+XML_SCHEMA =
+
+# The XML_DTD tag can be used to specify an XML DTD,
+# which can be used by a validating XML parser to check the
+# syntax of the XML files.
+
+XML_DTD =
+
+# If the XML_PROGRAMLISTING tag is set to YES Doxygen will
+# dump the program listings (including syntax highlighting
+# and cross-referencing information) to the XML output. Note that
+# enabling this will significantly increase the size of the XML output.
+
+XML_PROGRAMLISTING = YES
+
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will
+# generate an AutoGen Definitions (see autogen.sf.net) file
+# that captures the structure of the code including all
+# documentation. Note that this feature is still experimental
+# and incomplete at the moment.
+
+GENERATE_AUTOGEN_DEF = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_PERLMOD tag is set to YES Doxygen will
+# generate a Perl module file that captures the structure of
+# the code including all documentation. Note that this
+# feature is still experimental and incomplete at the
+# moment.
+
+GENERATE_PERLMOD = NO
+
+# If the PERLMOD_LATEX tag is set to YES Doxygen will generate
+# the necessary Makefile rules, Perl scripts and LaTeX code to be able
+# to generate PDF and DVI output from the Perl module output.
+
+PERLMOD_LATEX = NO
+
+# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be
+# nicely formatted so it can be parsed by a human reader. This is useful
+# if you want to understand what is going on. On the other hand, if this
+# tag is set to NO the size of the Perl module output will be much smaller
+# and Perl will parse it just the same.
+
+PERLMOD_PRETTY = YES
+
+# The names of the make variables in the generated doxyrules.make file
+# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX.
+# This is useful so different doxyrules.make files included by the same
+# Makefile don't overwrite each other's variables.
+
+PERLMOD_MAKEVAR_PREFIX =
+
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+
+# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
+# evaluate all C-preprocessor directives found in the sources and include
+# files.
+
+ENABLE_PREPROCESSING = NO
+
+# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
+# names in the source code. If set to NO (the default) only conditional
+# compilation will be performed. Macro expansion can be done in a controlled
+# way by setting EXPAND_ONLY_PREDEF to YES.
+
+MACRO_EXPANSION = NO
+
+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
+# then the macro expansion is limited to the macros specified with the
+# PREDEFINED and EXPAND_AS_DEFINED tags.
+
+EXPAND_ONLY_PREDEF = NO
+
+# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
+# in the INCLUDE_PATH (see below) will be search if a #include is found.
+
+SEARCH_INCLUDES = YES
+
+# The INCLUDE_PATH tag can be used to specify one or more directories that
+# contain include files that are not input files but should be processed by
+# the preprocessor.
+
+INCLUDE_PATH =
+
+# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
+# patterns (like *.h and *.hpp) to filter out the header-files in the
+# directories. If left blank, the patterns specified with FILE_PATTERNS will
+# be used.
+
+INCLUDE_FILE_PATTERNS =
+
+# The PREDEFINED tag can be used to specify one or more macro names that
+# are defined before the preprocessor is started (similar to the -D option of
+# gcc). The argument of the tag is a list of macros of the form: name
+# or name=definition (no spaces). If the definition and the = are
+# omitted =1 is assumed. To prevent a macro definition from being
+# undefined via #undef or recursively expanded use the := operator
+# instead of the = operator.
+
+PREDEFINED =
+
+# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
+# this tag can be used to specify a list of macro names that should be expanded.
+# The macro definition that is found in the sources will be used.
+# Use the PREDEFINED tag if you want to use a different macro definition.
+
+EXPAND_AS_DEFINED =
+
+# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
+# doxygen's preprocessor will remove all function-like macros that are alone
+# on a line, have an all uppercase name, and do not end with a semicolon. Such
+# function macros are typically used for boiler-plate code, and will confuse
+# the parser if not removed.
+
+SKIP_FUNCTION_MACROS = YES
+
+#---------------------------------------------------------------------------
+# Configuration::additions related to external references
+#---------------------------------------------------------------------------
+
+# The TAGFILES option can be used to specify one or more tagfiles.
+# Optionally an initial location of the external documentation
+# can be added for each tagfile. The format of a tag file without
+# this location is as follows:
+# TAGFILES = file1 file2 ...
+# Adding location for the tag files is done as follows:
+# TAGFILES = file1=loc1 "file2 = loc2" ...
+# where "loc1" and "loc2" can be relative or absolute paths or
+# URLs. If a location is present for each tag, the installdox tool
+# does not have to be run to correct the links.
+# Note that each tag file must have a unique name
+# (where the name does NOT include the path)
+# If a tag file is not located in the directory in which doxygen
+# is run, you must also specify the path to the tagfile here.
+
+TAGFILES =
+
+# When a file name is specified after GENERATE_TAGFILE, doxygen will create
+# a tag file that is based on the input files it reads.
+
+GENERATE_TAGFILE =
+
+# If the ALLEXTERNALS tag is set to YES all external classes will be listed
+# in the class index. If set to NO only the inherited external classes
+# will be listed.
+
+ALLEXTERNALS = NO
+
+# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed
+# in the modules index. If set to NO, only the current project's groups will
+# be listed.
+
+EXTERNAL_GROUPS = YES
+
+# The PERL_PATH should be the absolute path and name of the perl script
+# interpreter (i.e. the result of `which perl').
+
+PERL_PATH = /usr/bin/perl
+
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+#---------------------------------------------------------------------------
+
+# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
+# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base
+# or super classes. Setting the tag to NO turns the diagrams off. Note that
+# this option is superseded by the HAVE_DOT option below. This is only a
+# fallback. It is recommended to install and use dot, since it yields more
+# powerful graphs.
+
+CLASS_DIAGRAMS = YES
+
+# You can define message sequence charts within doxygen comments using the \msc
+# command. Doxygen will then run the mscgen tool (see
+# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the
+# documentation. The MSCGEN_PATH tag allows you to specify the directory where
+# the mscgen tool resides. If left empty the tool is assumed to be found in the
+# default search path.
+
+MSCGEN_PATH =
+
+# If set to YES, the inheritance and collaboration graphs will hide
+# inheritance and usage relations if the target is undocumented
+# or is not a class.
+
+HIDE_UNDOC_RELATIONS = YES
+
+# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
+# available from the path. This tool is part of Graphviz, a graph visualization
+# toolkit from AT&T and Lucent Bell Labs. The other options in this section
+# have no effect if this option is set to NO (the default)
+
+HAVE_DOT = NO
+
+# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for each documented class showing the direct and
+# indirect inheritance relations. Setting this tag to YES will force the
+# the CLASS_DIAGRAMS tag to NO.
+
+CLASS_GRAPH = YES
+
+# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for each documented class showing the direct and
+# indirect implementation dependencies (inheritance, containment, and
+# class references variables) of the class with other documented classes.
+
+COLLABORATION_GRAPH = YES
+
+# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for groups, showing the direct groups dependencies
+
+GROUP_GRAPHS = YES
+
+# If the UML_LOOK tag is set to YES doxygen will generate inheritance and
+# collaboration diagrams in a style similar to the OMG's Unified Modeling
+# Language.
+
+UML_LOOK = NO
+
+# If set to YES, the inheritance and collaboration graphs will show the
+# relations between templates and their instances.
+
+TEMPLATE_RELATIONS = YES
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT
+# tags are set to YES then doxygen will generate a graph for each documented
+# file showing the direct and indirect include dependencies of the file with
+# other documented files.
+
+INCLUDE_GRAPH = YES
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and
+# HAVE_DOT tags are set to YES then doxygen will generate a graph for each
+# documented header file showing the documented files that directly or
+# indirectly include this file.
+
+INCLUDED_BY_GRAPH = YES
+
+# If the CALL_GRAPH and HAVE_DOT options are set to YES then
+# doxygen will generate a call dependency graph for every global function
+# or class method. Note that enabling this option will significantly increase
+# the time of a run. So in most cases it will be better to enable call graphs
+# for selected functions only using the \callgraph command.
+
+CALL_GRAPH = NO
+
+# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then
+# doxygen will generate a caller dependency graph for every global function
+# or class method. Note that enabling this option will significantly increase
+# the time of a run. So in most cases it will be better to enable caller
+# graphs for selected functions only using the \callergraph command.
+
+CALLER_GRAPH = NO
+
+# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
+# will graphical hierarchy of all classes instead of a textual one.
+
+GRAPHICAL_HIERARCHY = YES
+
+# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES
+# then doxygen will show the dependencies a directory has on other directories
+# in a graphical way. The dependency relations are determined by the #include
+# relations between the files in the directories.
+
+DIRECTORY_GRAPH = YES
+
+# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
+# generated by dot. Possible values are png, jpg, or gif
+# If left blank png will be used.
+
+DOT_IMAGE_FORMAT = png
+
+# The tag DOT_PATH can be used to specify the path where the dot tool can be
+# found. If left blank, it is assumed the dot tool can be found in the path.
+
+DOT_PATH =
+
+# The DOTFILE_DIRS tag can be used to specify one or more directories that
+# contain dot files that are included in the documentation (see the
+# \dotfile command).
+
+DOTFILE_DIRS =
+
+# The MAX_DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of
+# nodes that will be shown in the graph. If the number of nodes in a graph
+# becomes larger than this value, doxygen will truncate the graph, which is
+# visualized by representing a node as a red box. Note that doxygen if the
+# number of direct children of the root node in a graph is already larger than
+# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note
+# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
+
+DOT_GRAPH_MAX_NODES = 50
+
+# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the
+# graphs generated by dot. A depth value of 3 means that only nodes reachable
+# from the root by following a path via at most 3 edges will be shown. Nodes
+# that lay further from the root node will be omitted. Note that setting this
+# option to 1 or 2 may greatly reduce the computation time needed for large
+# code bases. Also note that the size of a graph can be further restricted by
+# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
+
+MAX_DOT_GRAPH_DEPTH = 0
+
+# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
+# background. This is enabled by default, which results in a transparent
+# background. Warning: Depending on the platform used, enabling this option
+# may lead to badly anti-aliased labels on the edges of a graph (i.e. they
+# become hard to read).
+
+DOT_TRANSPARENT = YES
+
+# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output
+# files in one run (i.e. multiple -o and -T options on the command line). This
+# makes dot run faster, but since only newer versions of dot (>1.8.10)
+# support this, this feature is disabled by default.
+
+DOT_MULTI_TARGETS = NO
+
+# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
+# generate a legend page explaining the meaning of the various boxes and
+# arrows in the dot generated graphs.
+
+GENERATE_LEGEND = YES
+
+# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will
+# remove the intermediate dot files that are used to generate
+# the various graphs.
+
+DOT_CLEANUP = YES
+
+#---------------------------------------------------------------------------
+# Configuration::additions related to the search engine
+#---------------------------------------------------------------------------
+
+# The SEARCHENGINE tag specifies whether or not a search engine should be
+# used. If set to NO the values of all tags below this one will be ignored.
+
+SEARCHENGINE = NO
diff --git a/source3/lib/netapi/cm.c b/source3/lib/netapi/cm.c
index 071ebfd4bc..ae1091c504 100644
--- a/source3/lib/netapi/cm.c
+++ b/source3/lib/netapi/cm.c
@@ -99,13 +99,13 @@ static struct rpc_pipe_client *pipe_cm_find(struct cli_state *cli,
for (p = pipe_connections; p; p = p->next) {
- if (!p->pipe->cli) {
+ if (!rpc_pipe_np_smb_conn(p->pipe)) {
*status = NT_STATUS_PIPE_EMPTY;
return NULL;
}
- if (strequal(cli->desthost, p->pipe->cli->desthost) &&
- pipe_idx == p->pipe->pipe_idx) {
+ if (strequal(cli->desthost, p->pipe->desthost) &&
+ rpccli_is_pipe_idx(p->pipe, pipe_idx)) {
*status = NT_STATUS_OK;
return p->pipe;
}
diff --git a/source3/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c b/source3/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c
index a7b2079f95..5ce4ca2c87 100644
--- a/source3/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c
+++ b/source3/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c
@@ -650,6 +650,9 @@ static void callback_do_join(GtkWidget *widget,
err_str = libnetapi_get_error_string(state->ctx, status);
g_print("callback_do_join: failed to unjoin (%s)\n",
err_str);
+#if 0
+
+ /* in fact we shouldn't annoy the user with an error message here */
dialog = gtk_message_dialog_new(GTK_WINDOW(state->window_parent),
GTK_DIALOG_DESTROY_WITH_PARENT,
@@ -662,6 +665,7 @@ static void callback_do_join(GtkWidget *widget,
gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
+#endif
}
}
@@ -1306,7 +1310,7 @@ static int draw_main_window(struct join_state *state)
{
/* Label */
label = gtk_label_new("Computer description:");
-/* gtk_misc_set_alignment(GTK_MISC(label), 0, 0); */
+ gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1);
gtk_widget_show(label);
diff --git a/source3/lib/netapi/netapi.c b/source3/lib/netapi/netapi.c
index 9e309634b4..944c2c9304 100644
--- a/source3/lib/netapi/netapi.c
+++ b/source3/lib/netapi/netapi.c
@@ -40,7 +40,7 @@ NET_API_STATUS libnetapi_init(struct libnetapi_ctx **context)
return NET_API_STATUS_SUCCESS;
}
-#ifdef DEVELOPER
+#if 0
talloc_enable_leak_report();
#endif
frame = talloc_stackframe();
@@ -253,8 +253,9 @@ NET_API_STATUS libnetapi_set_error_string(struct libnetapi_ctx *ctx,
****************************************************************/
const char *libnetapi_get_error_string(struct libnetapi_ctx *ctx,
- NET_API_STATUS status)
+ NET_API_STATUS status_in)
{
+ NET_API_STATUS status;
struct libnetapi_ctx *tmp_ctx = ctx;
if (!tmp_ctx) {
@@ -268,7 +269,7 @@ const char *libnetapi_get_error_string(struct libnetapi_ctx *ctx,
return tmp_ctx->error_string;
}
- return libnetapi_errstr(status);
+ return libnetapi_errstr(status_in);
}
/****************************************************************
diff --git a/source3/lib/netapi/netapi.h b/source3/lib/netapi/netapi.h
index 0d21067a20..e9fcc3777a 100644
--- a/source3/lib/netapi/netapi.h
+++ b/source3/lib/netapi/netapi.h
@@ -77,6 +77,31 @@ struct USER_INFO_1 {
const char * usri1_script_path;
};
+struct NET_DISPLAY_USER {
+ const char * usri1_name;
+ const char * usri1_comment;
+ uint32_t usri1_flags;
+ const char * usri1_full_name;
+ uint32_t usri1_user_id;
+ uint32_t usri1_next_index;
+};
+
+struct NET_DISPLAY_MACHINE {
+ const char * usri2_name;
+ const char * usri2_comment;
+ uint32_t usri2_flags;
+ uint32_t usri2_user_id;
+ uint32_t usri2_next_index;
+};
+
+struct NET_DISPLAY_GROUP {
+ const char * grpi3_name;
+ const char * grpi3_comment;
+ uint32_t grpi3_group_id;
+ uint32_t grpi3_attributes;
+ uint32_t grpi3_next_index;
+};
+
#endif /* _HEADER_libnetapi */
/****************************************************************
@@ -154,9 +179,23 @@ const char *libnetapi_get_error_string(struct libnetapi_ctx *ctx,
NET_API_STATUS NetApiBufferFree(void *buffer);
-/****************************************************************
- NetJoinDomain
-****************************************************************/
+/************************************************************//**
+ *
+ * NetJoinDomain
+ *
+ * @brief Join a computer to a domain or workgroup
+ *
+ * @param[in] server The server name to connect to
+ * @param[in] domain The domain or workgroup to join
+ * @param[in] account_ou The organizational Unit to create the computer account
+ * in (AD only)
+ * @param[in] account The domain account used for joining a domain
+ * @param[in] password The domain account's password used for joining a domain
+ * @param[in] join_flags Bitmask field to define specific join features
+ * @return NET_API_STATUS
+ *
+ * example netdomjoin/netdomjoin.c
+ ***************************************************************/
NET_API_STATUS NetJoinDomain(const char * server /* [in] */,
const char * domain /* [in] [ref] */,
@@ -165,26 +204,62 @@ NET_API_STATUS NetJoinDomain(const char * server /* [in] */,
const char * password /* [in] */,
uint32_t join_flags /* [in] */);
-/****************************************************************
- NetUnjoinDomain
-****************************************************************/
+/************************************************************//**
+ *
+ * NetUnjoinDomain
+ *
+ * @brief Unjoin a computer from a domain or workgroup
+ *
+ * @param[in] server_name The server name to connect to
+ * @param[in] account The domain account used for unjoining a domain
+ * @param[in] password The domain account's password used for unjoining a domain
+ * @param[in] unjoin_flags Bitmask field to define specific unjoin features
+ * @return NET_API_STATUS
+ *
+ ***************************************************************/
NET_API_STATUS NetUnjoinDomain(const char * server_name /* [in] */,
const char * account /* [in] */,
const char * password /* [in] */,
uint32_t unjoin_flags /* [in] */);
-/****************************************************************
- NetGetJoinInformation
-****************************************************************/
+/************************************************************//**
+ *
+ * NetGetJoinInformation
+ *
+ * @brief Unjoin a computer from a domain or workgroup
+ *
+ * @param[in] server_name The server name to connect to
+ * @param[out] name_buffer Returns the name of the workgroup or domain
+ * @param[out] name_type Returns the type of that name
+ * @return NET_API_STATUS
+ *
+ * example netdomjoin-gui/netdomjoin-gui.c
+ *
+ ***************************************************************/
NET_API_STATUS NetGetJoinInformation(const char * server_name /* [in] */,
const char * *name_buffer /* [out] [ref] */,
uint16_t *name_type /* [out] [ref] */);
-/****************************************************************
- NetGetJoinableOUs
-****************************************************************/
+/************************************************************//**
+ *
+ * NetGetJoinableOUs
+ *
+ * @brief Query for the list of joinable organizational Units that can be used
+ * for joining AD
+ *
+ * @param[in] server_name The server name to connect to
+ * @param[in] domain The AD domain to query
+ * @param[in] account The domain account used for the query
+ * @param[in] password The domain account's password used for the query
+ * @param[out] ou_count The number of ous returned
+ * @param[out] ous Returned string array containing the ous
+ * @return NET_API_STATUS
+ *
+ * example netdomjoin-gui/netdomjoin-gui.c
+ *
+ ***************************************************************/
NET_API_STATUS NetGetJoinableOUs(const char * server_name /* [in] */,
const char * domain /* [in] [ref] */,
@@ -193,43 +268,95 @@ NET_API_STATUS NetGetJoinableOUs(const char * server_name /* [in] */,
uint32_t *ou_count /* [out] [ref] */,
const char * **ous /* [out] [ref] */);
-/****************************************************************
- NetServerGetInfo
-****************************************************************/
+/************************************************************//**
+ *
+ * NetServerGetInfo
+ *
+ * @brief Get Information on a server
+ *
+ * @param[in] server_name The server name to connect to
+ * @param[in] level The level to define which information is requested
+ * @param[out] buffer The returned buffer carrying the SERVER_INFO structure
+ * @return NET_API_STATUS
+ *
+ ***************************************************************/
NET_API_STATUS NetServerGetInfo(const char * server_name /* [in] */,
uint32_t level /* [in] */,
uint8_t **buffer /* [out] [ref] */);
-/****************************************************************
- NetServerSetInfo
-****************************************************************/
+/************************************************************//**
+ *
+ * NetServerSetInfo
+ *
+ * @brief Get Information on a server
+ *
+ * @param[in] server_name The server name to connect to
+ * @param[in] level The level to define which information is set
+ * @param[in] buffer The buffer carrying the SERVER_INFO structure
+ * @param[out] parm_error On failure returns the invalid SERVER_INFO member
+ * @return NET_API_STATUS
+ *
+ ***************************************************************/
NET_API_STATUS NetServerSetInfo(const char * server_name /* [in] */,
uint32_t level /* [in] */,
uint8_t *buffer /* [in] [ref] */,
uint32_t *parm_error /* [out] [ref] */);
-/****************************************************************
- NetGetDCName
-****************************************************************/
+/************************************************************//**
+ *
+ * NetGetDCName
+ *
+ * @brief Query for the PDC for a given domain
+ *
+ * @param[in] server_name The server name to connect to
+ * @param[in] domain_name The name of the domain to lookup
+ * @param[out] buffer The name of the domain to lookup
+ * @return NET_API_STATUS
+ *
+ * example getdc/getdc.c
+ ***************************************************************/
NET_API_STATUS NetGetDCName(const char * server_name /* [in] */,
const char * domain_name /* [in] */,
uint8_t **buffer /* [out] [ref] */);
-/****************************************************************
- NetGetAnyDCName
-****************************************************************/
+/************************************************************//**
+ *
+ * NetGetAnyDCName
+ *
+ * @brief Query for any DC for a given domain
+ *
+ * @param[in] server_name The server name to connect to
+ * @param[in] domain_name The name of the domain to lookup
+ * @param[out] buffer The name of the domain to lookup
+ * @return NET_API_STATUS
+ *
+ * example getdc/getdc.c
+ ***************************************************************/
NET_API_STATUS NetGetAnyDCName(const char * server_name /* [in] */,
const char * domain_name /* [in] */,
uint8_t **buffer /* [out] [ref] */);
-/****************************************************************
- DsGetDcName
-****************************************************************/
+/************************************************************//**
+ *
+ * DsGetDcName
+ *
+ * @brief Lookup a DC for a given domain and return information structure
+ *
+ * @param[in] server_name The server name to connect to
+ * @param[in] domain_name The name of the domain to lookup (cannot be NULL)
+ * @param[in] domain_guid The GUID of the domain to lookup (optional)
+ * @param[in] site_name The name of the site the DC should reside in
+ * @param[in] flags A bitmask to request specific features supported by the DC
+ * @param[out] dc_info Pointer to a DOMAIN_CONTROLLER_INFO structure
+ * @return NET_API_STATUS
+ *
+ * example dsgetdc/dsgetdc.c
+ ***************************************************************/
NET_API_STATUS DsGetDcName(const char * server_name /* [in] [unique] */,
const char * domain_name /* [in] [ref] */,
@@ -238,25 +365,64 @@ NET_API_STATUS DsGetDcName(const char * server_name /* [in] [unique] */,
uint32_t flags /* [in] */,
struct DOMAIN_CONTROLLER_INFO **dc_info /* [out] [ref] */);
-/****************************************************************
- NetUserAdd
-****************************************************************/
+/************************************************************//**
+ *
+ * NetUserAdd
+ *
+ * @brief Create a user on a given server
+ *
+ * @param[in] server_name The server name to connect to
+ * @param[in] level The level of the USER_INFO structure passed in (Currently
+ * only level 1 is supported)
+ * @param[in] buffer The buffer carrying the USER_INFO structure
+ * @param[out] parm_error In case of error returns the failing member of the
+ * structure
+ * @return NET_API_STATUS
+ *
+ * example user/user_add.c
+ ***************************************************************/
NET_API_STATUS NetUserAdd(const char * server_name /* [in] */,
uint32_t level /* [in] */,
uint8_t *buffer /* [in] [ref] */,
uint32_t *parm_error /* [out] [ref] */);
-/****************************************************************
- NetUserDel
-****************************************************************/
+/************************************************************//**
+ *
+ * NetUserDel
+ *
+ * @brief Delete a user on a given server
+ *
+ * @param[in] server_name The server name to connect to
+ * @param[in] user_name The user account to delete
+ * @return NET_API_STATUS
+ *
+ * example user/user_del.c
+ ***************************************************************/
NET_API_STATUS NetUserDel(const char * server_name /* [in] */,
const char * user_name /* [in] */);
-/****************************************************************
- NetUserEnum
-****************************************************************/
+/************************************************************//**
+ *
+ * NetUserEnum
+ *
+ * @brief Enumerate accounts on a server
+ *
+ * @param[in] server_name The server name to connect to
+ * @param[in] level The enumeration level used for the query (Currently only
+ * level 0 is supported)
+ * @param[in] filter The account flags filter used for the query
+ * @param[out] buffer The returned enumeration buffer
+ * @param[in] prefmaxlen The requested maximal buffer size
+ * @param[out] entries_read The number of returned entries
+ * @param[out] total_entries The number of total entries
+ * @param[in,out] resume_handle A handle passed in and returned for resuming
+ * operations
+ * @return NET_API_STATUS
+ *
+ * example user/user_enum.c
+ ***************************************************************/
NET_API_STATUS NetUserEnum(const char * server_name /* [in] */,
uint32_t level /* [in] */,
@@ -267,6 +433,24 @@ NET_API_STATUS NetUserEnum(const char * server_name /* [in] */,
uint32_t *total_entries /* [out] [ref] */,
uint32_t *resume_handle /* [in,out] [ref] */);
+/************************************************************//**
+ *
+ * NetQueryDisplayInformation
+ *
+ * @brief Enumerate accounts on a server
+ *
+ * @param[in] server_name The server name to connect to
+ * @param[in] level The enumeration level used for the query
+ * @param[in] idx The index to start the the display enumeration at
+ * @param[in] entries_requested The number of entries requested
+ * @param[in] prefmaxlen The requested maximal buffer size
+ * @param[out] entries_read The number of returned entries
+ * @param[out] buffer The returned display information buffer
+ * @return NET_API_STATUS
+ *
+ * example user/user_dispinfo.c
+ ***************************************************************/
+
NET_API_STATUS NetQueryDisplayInformation(const char * server_name /* [in] [unique] */,
uint32_t level /* [in] */,
uint32_t idx /* [in] */,
diff --git a/source3/lib/netapi/user.c b/source3/lib/netapi/user.c
index 55d9795f2d..f2dc785a36 100644
--- a/source3/lib/netapi/user.c
+++ b/source3/lib/netapi/user.c
@@ -27,15 +27,6 @@
/****************************************************************
****************************************************************/
-WERROR NetUserAdd_l(struct libnetapi_ctx *ctx,
- struct NetUserAdd *r)
-{
- return WERR_NOT_SUPPORTED;
-}
-
-/****************************************************************
-****************************************************************/
-
static void convert_USER_INFO_1_to_samr_user_info25(struct USER_INFO_1 *info1,
DATA_BLOB *user_session_key,
struct samr_UserInfo25 *info25)
@@ -344,6 +335,20 @@ WERROR NetUserAdd_r(struct libnetapi_ctx *ctx,
/****************************************************************
****************************************************************/
+WERROR NetUserAdd_l(struct libnetapi_ctx *ctx,
+ struct NetUserAdd *r)
+{
+ /* for now just talk to local RPC server */
+ if (!r->in.server_name) {
+ r->in.server_name = "localhost";
+ }
+
+ return NetUserAdd_r(ctx, r);
+}
+
+/****************************************************************
+****************************************************************/
+
WERROR NetUserDel_r(struct libnetapi_ctx *ctx,
struct NetUserDel *r)
{
@@ -515,7 +520,12 @@ WERROR NetUserDel_r(struct libnetapi_ctx *ctx,
WERROR NetUserDel_l(struct libnetapi_ctx *ctx,
struct NetUserDel *r)
{
- return WERR_NOT_SUPPORTED;
+ /* for now just talk to local RPC server */
+ if (!r->in.server_name) {
+ r->in.server_name = "localhost";
+ }
+
+ return NetUserDel_r(ctx, r);
}
/****************************************************************
@@ -835,11 +845,11 @@ static WERROR convert_samr_dispinfo_to_NET_DISPLAY_GROUP(TALLOC_CTX *mem_ctx,
/****************************************************************
****************************************************************/
-WERROR convert_samr_dispinfo_to_NET_DISPLAY(TALLOC_CTX *mem_ctx,
- union samr_DispInfo *info,
- uint32_t level,
- uint32_t *entries_read,
- void **buffer)
+static WERROR convert_samr_dispinfo_to_NET_DISPLAY(TALLOC_CTX *mem_ctx,
+ union samr_DispInfo *info,
+ uint32_t level,
+ uint32_t *entries_read,
+ void **buffer)
{
switch (level) {
case 1:
diff --git a/source3/lib/replace/libreplace_cc.m4 b/source3/lib/replace/libreplace_cc.m4
index bf5056838d..0ce0958a96 100644
--- a/source3/lib/replace/libreplace_cc.m4
+++ b/source3/lib/replace/libreplace_cc.m4
@@ -132,7 +132,8 @@ AC_CHECK_SIZEOF(off_t)
AC_CHECK_SIZEOF(size_t)
AC_CHECK_SIZEOF(ssize_t)
-AC_CHECK_TYPE(intptr_t, unsigned long long)
+AC_CHECK_TYPE(intptr_t, long long)
+AC_CHECK_TYPE(uintptr_t, unsigned long long)
AC_CHECK_TYPE(ptrdiff_t, unsigned long long)
if test x"$ac_cv_type_long_long" != x"yes";then
diff --git a/source3/lib/replace/replace.c b/source3/lib/replace/replace.c
index 6930f9b079..443da2ab24 100644
--- a/source3/lib/replace/replace.c
+++ b/source3/lib/replace/replace.c
@@ -458,7 +458,7 @@ char *rep_strcasestr(const char *haystack, const char *needle)
for (s=haystack;*s;s++) {
if (toupper(*needle) == toupper(*s) &&
strncasecmp(s, needle, nlen) == 0) {
- return (char *)((intptr_t)s);
+ return (char *)((uintptr_t)s);
}
}
return NULL;
diff --git a/source3/lib/replace/replace.h b/source3/lib/replace/replace.h
index 5fe79394eb..bf95169352 100644
--- a/source3/lib/replace/replace.h
+++ b/source3/lib/replace/replace.h
@@ -499,7 +499,7 @@ typedef int bool;
Also, please call this via the discard_const_p() macro interface, as that
makes the return type safe.
*/
-#define discard_const(ptr) ((void *)((intptr_t)(ptr)))
+#define discard_const(ptr) ((void *)((uintptr_t)(ptr)))
/** Type-safe version of discard_const */
#define discard_const_p(type, ptr) ((type *)discard_const(ptr))
diff --git a/source3/lib/smbconf/smbconf_reg.c b/source3/lib/smbconf/smbconf_reg.c
index 39b05f7016..930999cc3f 100644
--- a/source3/lib/smbconf/smbconf_reg.c
+++ b/source3/lib/smbconf/smbconf_reg.c
@@ -784,7 +784,7 @@ static WERROR smbconf_reg_get_share_names(struct smbconf_ctx *ctx,
/* make sure "global" is always listed first */
if (smbconf_share_exists(ctx, GLOBAL_NAME)) {
werr = smbconf_add_string_to_array(tmp_ctx, &tmp_share_names,
- 1, GLOBAL_NAME);
+ added_count, GLOBAL_NAME);
if (!W_ERROR_IS_OK(werr)) {
goto done;
}
diff --git a/source3/lib/talloc/libtalloc.m4 b/source3/lib/talloc/libtalloc.m4
index d2e8eba81a..fd2b4b22cd 100644
--- a/source3/lib/talloc/libtalloc.m4
+++ b/source3/lib/talloc/libtalloc.m4
@@ -1,10 +1,10 @@
dnl find the talloc sources. This is meant to work both for
dnl talloc standalone builds, and builds of packages using talloc
tallocdir=""
-tallocpaths="$srcdir $srcdir/lib/talloc $srcdir/talloc $srcdir/../talloc"
+tallocpaths=". lib/talloc talloc ../talloc"
for d in $tallocpaths; do
- if test -f "$d/talloc.c"; then
- tallocdir="$d"
+ if test -f "$srcdir/$d/talloc.c"; then
+ tallocdir="$d"
AC_SUBST(tallocdir)
break;
fi
@@ -15,7 +15,7 @@ fi
TALLOC_OBJ="talloc.o"
AC_SUBST(TALLOC_OBJ)
-TALLOC_CFLAGS="-I$tallocdir"
+TALLOC_CFLAGS="-I$srcdir/$tallocdir"
AC_SUBST(TALLOC_CFLAGS)
TALLOC_LIBS=""
diff --git a/source3/lib/talloc/talloc.c b/source3/lib/talloc/talloc.c
index 9dcd8a2a83..d535c3d784 100644
--- a/source3/lib/talloc/talloc.c
+++ b/source3/lib/talloc/talloc.c
@@ -85,8 +85,8 @@
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
#else
-#define likely(x) x
-#define unlikely(x) x
+#define likely(x) (x)
+#define unlikely(x) (x)
#endif
/* this null_context is only used if talloc_enable_leak_report() or
diff --git a/source3/lib/util.c b/source3/lib/util.c
index b52cc692a2..db0da541f9 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -990,6 +990,36 @@ void become_daemon(bool Fork, bool no_process_group)
attach it to the logfile */
}
+bool reinit_after_fork(struct messaging_context *msg_ctx)
+{
+ NTSTATUS status;
+
+ /* Reset the state of the random
+ * number generation system, so
+ * children do not get the same random
+ * numbers as each other */
+ set_need_random_reseed();
+
+ /* tdb needs special fork handling */
+ if (tdb_reopen_all(1) == -1) {
+ DEBUG(0,("tdb_reopen_all failed.\n"));
+ return false;
+ }
+
+ /*
+ * For clustering, we need to re-init our ctdbd connection after the
+ * fork
+ */
+ status = messaging_reinit(msg_ctx);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0,("messaging_reinit() failed: %s\n",
+ nt_errstr(status)));
+ return false;
+ }
+
+ return true;
+}
+
/****************************************************************************
Put up a yes/no prompt.
****************************************************************************/
diff --git a/source3/libads/ldap_printer.c b/source3/libads/ldap_printer.c
index 05fbc071d8..6682ec24d0 100644
--- a/source3/libads/ldap_printer.c
+++ b/source3/libads/ldap_printer.c
@@ -288,16 +288,15 @@ WERROR get_remote_printer_publishing_data(struct rpc_pipe_client *cli,
uint32 i;
POLICY_HND pol;
- asprintf(&servername, "\\\\%s", cli->cli->desthost);
- asprintf(&printername, "%s\\%s", servername, printer);
- if (!servername || !printername) {
+ if ((asprintf(&servername, "\\\\%s", cli->desthost) == -1)
+ || (asprintf(&printername, "%s\\%s", servername, printer) == -1)) {
DEBUG(3, ("Insufficient memory\n"));
return WERR_NOMEM;
}
result = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername,
"", MAXIMUM_ALLOWED_ACCESS,
- servername, cli->cli->user_name, &pol);
+ servername, cli->user_name, &pol);
if (!W_ERROR_IS_OK(result)) {
DEBUG(3, ("Unable to open printer %s, error is %s.\n",
printername, dos_errstr(result)));
diff --git a/source3/libcli/nbt/libnbt.h b/source3/libcli/nbt/libnbt.h
new file mode 100644
index 0000000000..d37a17c192
--- /dev/null
+++ b/source3/libcli/nbt/libnbt.h
@@ -0,0 +1,353 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ a raw async NBT library
+
+ Copyright (C) Andrew Tridgell 2005
+
+ 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 3 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, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef __LIBNBT_H__
+#define __LIBNBT_H__
+
+#include "librpc/gen_ndr/nbt.h"
+#include "librpc/ndr/libndr.h"
+
+/*
+ possible states for pending requests
+*/
+enum nbt_request_state {NBT_REQUEST_SEND,
+ NBT_REQUEST_WAIT,
+ NBT_REQUEST_DONE,
+ NBT_REQUEST_TIMEOUT,
+ NBT_REQUEST_ERROR};
+
+/*
+ a nbt name request
+*/
+struct nbt_name_request {
+ struct nbt_name_request *next, *prev;
+
+ enum nbt_request_state state;
+
+ NTSTATUS status;
+
+ /* the socket this was on */
+ struct nbt_name_socket *nbtsock;
+
+ /* where to send the request */
+ struct socket_address *dest;
+
+ /* timeout between retries */
+ int timeout;
+
+ /* how many retries to send on timeout */
+ int num_retries;
+
+ /* whether we have received a WACK */
+ bool received_wack;
+
+ /* the timeout event */
+ struct timed_event *te;
+
+ /* the name transaction id */
+ uint16_t name_trn_id;
+
+ /* is it a reply? */
+ bool is_reply;
+
+ /* the encoded request */
+ DATA_BLOB encoded;
+
+ /* shall we allow multiple replies? */
+ bool allow_multiple_replies;
+
+ unsigned int num_replies;
+ struct nbt_name_reply {
+ struct nbt_name_packet *packet;
+ struct socket_address *dest;
+ } *replies;
+
+ /* information on what to do on completion */
+ struct {
+ void (*fn)(struct nbt_name_request *);
+ void *_private;
+ } async;
+};
+
+
+
+/*
+ context structure for operations on name queries
+*/
+struct nbt_name_socket {
+ struct socket_context *sock;
+ struct event_context *event_ctx;
+/*
+ struct smb_iconv_convenience *iconv_convenience;
+*/
+ /* a queue of requests pending to be sent */
+ struct nbt_name_request *send_queue;
+
+ /* the fd event */
+ struct fd_event *fde;
+
+ /* mapping from name_trn_id to pending event */
+ struct idr_context *idr;
+
+ /* how many requests are waiting for a reply */
+ uint16_t num_pending;
+
+ /* what to do with incoming request packets */
+ struct {
+ void (*handler)(struct nbt_name_socket *, struct nbt_name_packet *,
+ struct socket_address *);
+ void *_private;
+ } incoming;
+
+ /* what to do with unexpected replies */
+ struct {
+ void (*handler)(struct nbt_name_socket *, struct nbt_name_packet *,
+ struct socket_address *);
+ void *_private;
+ } unexpected;
+};
+
+
+/* a simple name query */
+struct nbt_name_query {
+ struct {
+ struct nbt_name name;
+ const char *dest_addr;
+ uint16_t dest_port;
+ bool broadcast;
+ bool wins_lookup;
+ int timeout; /* in seconds */
+ int retries;
+ } in;
+ struct {
+ const char *reply_from;
+ struct nbt_name name;
+ int16_t num_addrs;
+ const char **reply_addrs;
+ } out;
+};
+
+/* a simple name status query */
+struct nbt_name_status {
+ struct {
+ struct nbt_name name;
+ const char *dest_addr;
+ uint16_t dest_port;
+ int timeout; /* in seconds */
+ int retries;
+ } in;
+ struct {
+ const char *reply_from;
+ struct nbt_name name;
+ struct nbt_rdata_status status;
+ } out;
+};
+
+/* a name registration request */
+struct nbt_name_register {
+ struct {
+ struct nbt_name name;
+ const char *dest_addr;
+ uint16_t dest_port;
+ const char *address;
+ uint16_t nb_flags;
+ bool register_demand;
+ bool broadcast;
+ bool multi_homed;
+ uint32_t ttl;
+ int timeout; /* in seconds */
+ int retries;
+ } in;
+ struct {
+ const char *reply_from;
+ struct nbt_name name;
+ const char *reply_addr;
+ uint8_t rcode;
+ } out;
+};
+
+/* a send 3 times then demand name broadcast name registration */
+struct nbt_name_register_bcast {
+ struct {
+ struct nbt_name name;
+ const char *dest_addr;
+ uint16_t dest_port;
+ const char *address;
+ uint16_t nb_flags;
+ uint32_t ttl;
+ } in;
+};
+
+
+/* wins name register with multiple wins servers to try and multiple
+ addresses to register */
+struct nbt_name_register_wins {
+ struct {
+ struct nbt_name name;
+ const char **wins_servers;
+ uint16_t wins_port;
+ const char **addresses;
+ uint16_t nb_flags;
+ uint32_t ttl;
+ } in;
+ struct {
+ const char *wins_server;
+ uint8_t rcode;
+ } out;
+};
+
+
+
+/* a name refresh request */
+struct nbt_name_refresh {
+ struct {
+ struct nbt_name name;
+ const char *dest_addr;
+ uint16_t dest_port;
+ const char *address;
+ uint16_t nb_flags;
+ bool broadcast;
+ uint32_t ttl;
+ int timeout; /* in seconds */
+ int retries;
+ } in;
+ struct {
+ const char *reply_from;
+ struct nbt_name name;
+ const char *reply_addr;
+ uint8_t rcode;
+ } out;
+};
+
+/* wins name refresh with multiple wins servers to try and multiple
+ addresses to register */
+struct nbt_name_refresh_wins {
+ struct {
+ struct nbt_name name;
+ const char **wins_servers;
+ uint16_t wins_port;
+ const char **addresses;
+ uint16_t nb_flags;
+ uint32_t ttl;
+ } in;
+ struct {
+ const char *wins_server;
+ uint8_t rcode;
+ } out;
+};
+
+
+/* a name release request */
+struct nbt_name_release {
+ struct {
+ struct nbt_name name;
+ const char *dest_addr;
+ uint16_t dest_port;
+ const char *address;
+ uint16_t nb_flags;
+ bool broadcast;
+ int timeout; /* in seconds */
+ int retries;
+ } in;
+ struct {
+ const char *reply_from;
+ struct nbt_name name;
+ const char *reply_addr;
+ uint8_t rcode;
+ } out;
+};
+
+struct nbt_name_socket *nbt_name_socket_init(TALLOC_CTX *mem_ctx,
+ struct event_context *event_ctx);
+ /*,
+ struct smb_iconv_convenience *iconv_convenience);*/
+struct nbt_name_request *nbt_name_query_send(struct nbt_name_socket *nbtsock,
+ struct nbt_name_query *io);
+NTSTATUS nbt_name_query_recv(struct nbt_name_request *req,
+ TALLOC_CTX *mem_ctx, struct nbt_name_query *io);
+NTSTATUS nbt_name_query(struct nbt_name_socket *nbtsock,
+ TALLOC_CTX *mem_ctx, struct nbt_name_query *io);
+struct nbt_name_request *nbt_name_status_send(struct nbt_name_socket *nbtsock,
+ struct nbt_name_status *io);
+NTSTATUS nbt_name_status_recv(struct nbt_name_request *req,
+ TALLOC_CTX *mem_ctx, struct nbt_name_status *io);
+NTSTATUS nbt_name_status(struct nbt_name_socket *nbtsock,
+ TALLOC_CTX *mem_ctx, struct nbt_name_status *io);
+
+NTSTATUS nbt_name_dup(TALLOC_CTX *mem_ctx, struct nbt_name *name, struct nbt_name *newname);
+NTSTATUS nbt_name_to_blob(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, struct nbt_name *name);
+NTSTATUS nbt_name_from_blob(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob, struct nbt_name *name);
+void nbt_choose_called_name(TALLOC_CTX *mem_ctx, struct nbt_name *n, const char *name, int type);
+char *nbt_name_string(TALLOC_CTX *mem_ctx, const struct nbt_name *name);
+NTSTATUS nbt_name_register(struct nbt_name_socket *nbtsock,
+ TALLOC_CTX *mem_ctx, struct nbt_name_register *io);
+NTSTATUS nbt_name_refresh(struct nbt_name_socket *nbtsock,
+ TALLOC_CTX *mem_ctx, struct nbt_name_refresh *io);
+NTSTATUS nbt_name_release(struct nbt_name_socket *nbtsock,
+ TALLOC_CTX *mem_ctx, struct nbt_name_release *io);
+NTSTATUS nbt_name_register_wins(struct nbt_name_socket *nbtsock,
+ TALLOC_CTX *mem_ctx,
+ struct nbt_name_register_wins *io);
+NTSTATUS nbt_name_refresh_wins(struct nbt_name_socket *nbtsock,
+ TALLOC_CTX *mem_ctx,
+ struct nbt_name_refresh_wins *io);
+NTSTATUS nbt_name_register_recv(struct nbt_name_request *req,
+ TALLOC_CTX *mem_ctx, struct nbt_name_register *io);
+struct nbt_name_request *nbt_name_register_send(struct nbt_name_socket *nbtsock,
+ struct nbt_name_register *io);
+NTSTATUS nbt_name_release_recv(struct nbt_name_request *req,
+ TALLOC_CTX *mem_ctx, struct nbt_name_release *io);
+
+struct nbt_name_request *nbt_name_release_send(struct nbt_name_socket *nbtsock,
+ struct nbt_name_release *io);
+
+NTSTATUS nbt_name_refresh_recv(struct nbt_name_request *req,
+ TALLOC_CTX *mem_ctx, struct nbt_name_refresh *io);
+
+NTSTATUS nbt_set_incoming_handler(struct nbt_name_socket *nbtsock,
+ void (*handler)(struct nbt_name_socket *, struct nbt_name_packet *,
+ struct socket_address *),
+ void *_private);
+NTSTATUS nbt_name_reply_send(struct nbt_name_socket *nbtsock,
+ struct socket_address *dest,
+ struct nbt_name_packet *request);
+
+
+NDR_SCALAR_PROTO(wrepl_nbt_name, const struct nbt_name *);
+NDR_SCALAR_PROTO(nbt_string, const char *);
+NDR_BUFFER_PROTO(nbt_name, struct nbt_name);
+NTSTATUS nbt_rcode_to_ntstatus(uint8_t rcode);
+
+struct composite_context;
+struct composite_context *nbt_name_register_bcast_send(struct nbt_name_socket *nbtsock,
+ struct nbt_name_register_bcast *io);
+NTSTATUS nbt_name_register_bcast_recv(struct composite_context *c);
+struct composite_context *nbt_name_register_wins_send(struct nbt_name_socket *nbtsock,
+ struct nbt_name_register_wins *io);
+NTSTATUS nbt_name_refresh_wins_recv(struct composite_context *c, TALLOC_CTX *mem_ctx,
+ struct nbt_name_refresh_wins *io);
+struct composite_context *nbt_name_refresh_wins_send(struct nbt_name_socket *nbtsock,
+ struct nbt_name_refresh_wins *io);
+NTSTATUS nbt_name_register_wins_recv(struct composite_context *c, TALLOC_CTX *mem_ctx,
+ struct nbt_name_register_wins *io);
+
+
+#endif /* __LIBNBT_H__ */
diff --git a/source3/libcli/nbt/nbtname.c b/source3/libcli/nbt/nbtname.c
new file mode 100644
index 0000000000..2025ef70e7
--- /dev/null
+++ b/source3/libcli/nbt/nbtname.c
@@ -0,0 +1,626 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ manipulate nbt name structures
+
+ Copyright (C) Andrew Tridgell 2005
+
+ 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 3 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, see <http://www.gnu.org/licenses/>.
+*/
+
+/*
+ see rfc1002 for the detailed format of compressed names
+*/
+
+#include "includes.h"
+#include "librpc/gen_ndr/ndr_nbt.h"
+#include "librpc/gen_ndr/ndr_misc.h"
+
+/* don't allow an unlimited number of name components */
+#define MAX_COMPONENTS 10
+
+/**
+ print a nbt string
+*/
+_PUBLIC_ void ndr_print_nbt_string(struct ndr_print *ndr, const char *name, const char *s)
+{
+ ndr_print_string(ndr, name, s);
+}
+
+/*
+ pull one component of a nbt_string
+*/
+static enum ndr_err_code ndr_pull_component(struct ndr_pull *ndr,
+ uint8_t **component,
+ uint32_t *offset,
+ uint32_t *max_offset)
+{
+ uint8_t len;
+ uint_t loops = 0;
+ while (loops < 5) {
+ if (*offset >= ndr->data_size) {
+ return ndr_pull_error(ndr, NDR_ERR_STRING,
+ "BAD NBT NAME component");
+ }
+ len = ndr->data[*offset];
+ if (len == 0) {
+ *offset += 1;
+ *max_offset = MAX(*max_offset, *offset);
+ *component = NULL;
+ return NDR_ERR_SUCCESS;
+ }
+ if ((len & 0xC0) == 0xC0) {
+ /* its a label pointer */
+ if (1 + *offset >= ndr->data_size) {
+ return ndr_pull_error(ndr, NDR_ERR_STRING,
+ "BAD NBT NAME component");
+ }
+ *max_offset = MAX(*max_offset, *offset + 2);
+ *offset = ((len&0x3F)<<8) | ndr->data[1 + *offset];
+ *max_offset = MAX(*max_offset, *offset);
+ loops++;
+ continue;
+ }
+ if ((len & 0xC0) != 0) {
+ /* its a reserved length field */
+ return ndr_pull_error(ndr, NDR_ERR_STRING,
+ "BAD NBT NAME component");
+ }
+ if (*offset + len + 2 > ndr->data_size) {
+ return ndr_pull_error(ndr, NDR_ERR_STRING,
+ "BAD NBT NAME component");
+ }
+ *component = (uint8_t*)talloc_strndup(ndr, (const char *)&ndr->data[1 + *offset], len);
+ NDR_ERR_HAVE_NO_MEMORY(*component);
+ *offset += len + 1;
+ *max_offset = MAX(*max_offset, *offset);
+ return NDR_ERR_SUCCESS;
+ }
+
+ /* too many pointers */
+ return ndr_pull_error(ndr, NDR_ERR_STRING, "BAD NBT NAME component");
+}
+
+/**
+ pull a nbt_string from the wire
+*/
+_PUBLIC_ enum ndr_err_code ndr_pull_nbt_string(struct ndr_pull *ndr, int ndr_flags, const char **s)
+{
+ uint32_t offset = ndr->offset;
+ uint32_t max_offset = offset;
+ unsigned num_components;
+ char *name;
+
+ if (!(ndr_flags & NDR_SCALARS)) {
+ return NDR_ERR_SUCCESS;
+ }
+
+ name = NULL;
+
+ /* break up name into a list of components */
+ for (num_components=0;num_components<MAX_COMPONENTS;num_components++) {
+ uint8_t *component = NULL;
+ NDR_CHECK(ndr_pull_component(ndr, &component, &offset, &max_offset));
+ if (component == NULL) break;
+ if (name) {
+ name = talloc_asprintf_append_buffer(name, ".%s", component);
+ NDR_ERR_HAVE_NO_MEMORY(name);
+ } else {
+ name = (char *)component;
+ }
+ }
+ if (num_components == MAX_COMPONENTS) {
+ return ndr_pull_error(ndr, NDR_ERR_STRING,
+ "BAD NBT NAME too many components");
+ }
+ if (num_components == 0) {
+ name = talloc_strdup(ndr, "");
+ NDR_ERR_HAVE_NO_MEMORY(name);
+ }
+
+ (*s) = name;
+ ndr->offset = max_offset;
+
+ return NDR_ERR_SUCCESS;
+}
+
+/**
+ push a nbt string to the wire
+*/
+_PUBLIC_ enum ndr_err_code ndr_push_nbt_string(struct ndr_push *ndr, int ndr_flags, const char *s)
+{
+ if (!(ndr_flags & NDR_SCALARS)) {
+ return NDR_ERR_SUCCESS;
+ }
+
+ while (s && *s) {
+ enum ndr_err_code ndr_err;
+ char *compname;
+ size_t complen;
+ uint32_t offset;
+
+ /* see if we have pushed the remaing string allready,
+ * if so we use a label pointer to this string
+ */
+ ndr_err = ndr_token_retrieve_cmp_fn(&ndr->nbt_string_list, s, &offset, (comparison_fn_t)strcmp, false);
+ if (NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ uint8_t b[2];
+
+ if (offset > 0x3FFF) {
+ return ndr_push_error(ndr, NDR_ERR_STRING,
+ "offset for nbt string label pointer %u[%08X] > 0x00003FFF",
+ offset, offset);
+ }
+
+ b[0] = 0xC0 | (offset>>8);
+ b[1] = (offset & 0xFF);
+
+ return ndr_push_bytes(ndr, b, 2);
+ }
+
+ complen = strcspn(s, ".");
+
+ /* we need to make sure the length fits into 6 bytes */
+ if (complen >= 0x3F) {
+ return ndr_push_error(ndr, NDR_ERR_STRING,
+ "component length %u[%08X] > 0x00003F",
+ (unsigned)complen, (unsigned)complen);
+ }
+
+ compname = talloc_asprintf(ndr, "%c%*.*s",
+ (unsigned char)complen,
+ (unsigned char)complen,
+ (unsigned char)complen, s);
+ NDR_ERR_HAVE_NO_MEMORY(compname);
+
+ /* remember the current componemt + the rest of the string
+ * so it can be reused later
+ */
+ NDR_CHECK(ndr_token_store(ndr, &ndr->nbt_string_list, s, ndr->offset));
+
+ /* push just this component into the blob */
+ NDR_CHECK(ndr_push_bytes(ndr, (const uint8_t *)compname, complen+1));
+ talloc_free(compname);
+
+ s += complen;
+ if (*s == '.') s++;
+ }
+
+ /* if we reach the end of the string and have pushed the last component
+ * without using a label pointer, we need to terminate the string
+ */
+ return ndr_push_bytes(ndr, (const uint8_t *)"", 1);
+}
+
+
+/*
+ decompress a 'compressed' name component
+ */
+static bool decompress_name(char *name, enum nbt_name_type *type)
+{
+ int i;
+ for (i=0;name[2*i];i++) {
+ uint8_t c1 = name[2*i];
+ uint8_t c2 = name[1+(2*i)];
+ if (c1 < 'A' || c1 > 'P' ||
+ c2 < 'A' || c2 > 'P') {
+ return false;
+ }
+ name[i] = ((c1-'A')<<4) | (c2-'A');
+ }
+ name[i] = 0;
+ if (i == 16) {
+ *type = (enum nbt_name_type)(name[15]);
+ name[15] = 0;
+ i--;
+ } else {
+ *type = NBT_NAME_CLIENT;
+ }
+
+ /* trim trailing spaces */
+ for (;i>0 && name[i-1]==' ';i--) {
+ name[i-1] = 0;
+ }
+
+ return true;
+}
+
+
+/*
+ compress a name component
+ */
+static uint8_t *compress_name(TALLOC_CTX *mem_ctx,
+ const uint8_t *name, enum nbt_name_type type)
+{
+ uint8_t *cname;
+ int i;
+ uint8_t pad_char;
+
+ if (strlen((const char *)name) > 15) {
+ return NULL;
+ }
+
+ cname = talloc_array(mem_ctx, uint8_t, 33);
+ if (cname == NULL) return NULL;
+
+ for (i=0;name[i];i++) {
+ cname[2*i] = 'A' + (name[i]>>4);
+ cname[1+2*i] = 'A' + (name[i]&0xF);
+ }
+ if (strcmp((const char *)name, "*") == 0) {
+ pad_char = 0;
+ } else {
+ pad_char = ' ';
+ }
+ for (;i<15;i++) {
+ cname[2*i] = 'A' + (pad_char>>4);
+ cname[1+2*i] = 'A' + (pad_char&0xF);
+ }
+
+ pad_char = type;
+ cname[2*i] = 'A' + (pad_char>>4);
+ cname[1+2*i] = 'A' + (pad_char&0xF);
+
+ cname[32] = 0;
+ return cname;
+}
+
+
+/**
+ pull a nbt name from the wire
+*/
+_PUBLIC_ enum ndr_err_code ndr_pull_nbt_name(struct ndr_pull *ndr, int ndr_flags, struct nbt_name *r)
+{
+ uint8_t *scope;
+ char *cname;
+ const char *s;
+ bool ok;
+
+ if (!(ndr_flags & NDR_SCALARS)) {
+ return NDR_ERR_SUCCESS;
+ }
+
+ NDR_CHECK(ndr_pull_nbt_string(ndr, ndr_flags, &s));
+
+ scope = (uint8_t *)strchr(s, '.');
+ if (scope) {
+ *scope = 0;
+ r->scope = talloc_strdup(ndr->current_mem_ctx, (const char *)&scope[1]);
+ NDR_ERR_HAVE_NO_MEMORY(r->scope);
+ } else {
+ r->scope = NULL;
+ }
+
+ cname = discard_const_p(char, s);
+
+ /* the first component is limited to 16 bytes in the DOS charset,
+ which is 32 in the 'compressed' form */
+ if (strlen(cname) > 32) {
+ return ndr_pull_error(ndr, NDR_ERR_STRING,
+ "NBT NAME cname > 32");
+ }
+
+ /* decompress the first component */
+ ok = decompress_name(cname, &r->type);
+ if (!ok) {
+ return ndr_pull_error(ndr, NDR_ERR_STRING,
+ "NBT NAME failed to decompress");
+ }
+
+ r->name = talloc_strdup(ndr->current_mem_ctx, cname);
+ NDR_ERR_HAVE_NO_MEMORY(r->name);
+
+ talloc_free(cname);
+
+ return NDR_ERR_SUCCESS;
+}
+
+/**
+ push a nbt name to the wire
+*/
+_PUBLIC_ enum ndr_err_code ndr_push_nbt_name(struct ndr_push *ndr, int ndr_flags, const struct nbt_name *r)
+{
+ uint8_t *cname, *fullname;
+ enum ndr_err_code ndr_err;
+
+ if (!(ndr_flags & NDR_SCALARS)) {
+ return NDR_ERR_SUCCESS;
+ }
+
+ if (strlen(r->name) > 15) {
+ return ndr_push_error(ndr, NDR_ERR_STRING,
+ "nbt_name longer as 15 chars: %s",
+ r->name);
+ }
+
+ cname = compress_name(ndr, (const uint8_t *)r->name, r->type);
+ NDR_ERR_HAVE_NO_MEMORY(cname);
+
+ if (r->scope) {
+ fullname = (uint8_t *)talloc_asprintf(ndr, "%s.%s", cname, r->scope);
+ NDR_ERR_HAVE_NO_MEMORY(fullname);
+ talloc_free(cname);
+ } else {
+ fullname = cname;
+ }
+
+ ndr_err = ndr_push_nbt_string(ndr, ndr_flags, (const char *)fullname);
+
+ return ndr_err;
+}
+
+
+/**
+ copy a nbt name structure
+*/
+_PUBLIC_ NTSTATUS nbt_name_dup(TALLOC_CTX *mem_ctx, struct nbt_name *name, struct nbt_name *newname)
+{
+ *newname = *name;
+ newname->name = talloc_strdup(mem_ctx, newname->name);
+ NT_STATUS_HAVE_NO_MEMORY(newname->name);
+ newname->scope = talloc_strdup(mem_ctx, newname->scope);
+ if (name->scope) {
+ NT_STATUS_HAVE_NO_MEMORY(newname->scope);
+ }
+ return NT_STATUS_OK;
+}
+
+/**
+ push a nbt name into a blob
+*/
+_PUBLIC_ NTSTATUS nbt_name_to_blob(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, struct nbt_name *name)
+{
+ enum ndr_err_code ndr_err;
+
+ ndr_err = ndr_push_struct_blob(blob, mem_ctx, name, (ndr_push_flags_fn_t)ndr_push_nbt_name);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ return ndr_map_error2ntstatus(ndr_err);
+ }
+
+ return NT_STATUS_OK;
+}
+
+/**
+ pull a nbt name from a blob
+*/
+_PUBLIC_ NTSTATUS nbt_name_from_blob(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob, struct nbt_name *name)
+{
+ enum ndr_err_code ndr_err;
+
+ ndr_err = ndr_pull_struct_blob(blob, mem_ctx, name,
+ (ndr_pull_flags_fn_t)ndr_pull_nbt_name);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ return ndr_map_error2ntstatus(ndr_err);
+ }
+
+ return NT_STATUS_OK;
+}
+
+
+/**
+ choose a name to use when calling a server in a NBT session request.
+ we use heuristics to see if the name we have been given is a IP
+ address, or a too-long name. If it is then use *SMBSERVER, or a
+ truncated name
+*/
+_PUBLIC_ void nbt_choose_called_name(TALLOC_CTX *mem_ctx,
+ struct nbt_name *n, const char *name, int type)
+{
+ n->scope = NULL;
+ n->type = type;
+
+ if (is_ipaddress(name) || name == NULL) {
+ n->name = "*SMBSERVER";
+ return;
+ }
+ if (strlen(name) > 15) {
+ const char *p = strchr(name, '.');
+ char *s;
+ if (p - name > 15) {
+ n->name = "*SMBSERVER";
+ return;
+ }
+ s = talloc_strndup(mem_ctx, name, PTR_DIFF(p, name));
+ n->name = talloc_strdup_upper(mem_ctx, s);
+ return;
+ }
+
+ n->name = talloc_strdup_upper(mem_ctx, name);
+}
+
+
+/*
+ escape a string into a form containing only a small set of characters,
+ the rest is hex encoded. This is similar to URL encoding
+*/
+static const char *nbt_hex_encode(TALLOC_CTX *mem_ctx, const char *s)
+{
+ int i, len;
+ char *ret;
+ const char *valid_chars = "_-.$@ ";
+#define NBT_CHAR_ALLOW(c) (isalnum((unsigned char)c) || strchr(valid_chars, c))
+
+ for (len=i=0;s[i];i++,len++) {
+ if (!NBT_CHAR_ALLOW(s[i])) {
+ len += 2;
+ }
+ }
+
+ ret = talloc_array(mem_ctx, char, len+1);
+ if (ret == NULL) return NULL;
+
+ for (len=i=0;s[i];i++) {
+ if (NBT_CHAR_ALLOW(s[i])) {
+ ret[len++] = s[i];
+ } else {
+ snprintf(&ret[len], 4, "%%%02x", (unsigned char)s[i]);
+ len += 3;
+ }
+ }
+ ret[len] = 0;
+
+ return ret;
+}
+
+
+/**
+ form a string for a NBT name
+*/
+_PUBLIC_ char *nbt_name_string(TALLOC_CTX *mem_ctx, const struct nbt_name *name)
+{
+ TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
+ char *ret;
+ if (name->scope) {
+ ret = talloc_asprintf(mem_ctx, "%s<%02x>-%s",
+ nbt_hex_encode(tmp_ctx, name->name),
+ name->type,
+ nbt_hex_encode(tmp_ctx, name->scope));
+ } else {
+ ret = talloc_asprintf(mem_ctx, "%s<%02x>",
+ nbt_hex_encode(tmp_ctx, name->name),
+ name->type);
+ }
+ talloc_free(tmp_ctx);
+ return ret;
+}
+
+/**
+ pull a nbt name, WINS Replication uses another on wire format for nbt name
+*/
+_PUBLIC_ enum ndr_err_code ndr_pull_wrepl_nbt_name(struct ndr_pull *ndr, int ndr_flags, const struct nbt_name **_r)
+{
+ struct nbt_name *r;
+ uint8_t *namebuf;
+ uint32_t namebuf_len;
+
+ if (!(ndr_flags & NDR_SCALARS)) {
+ return NDR_ERR_SUCCESS;
+ }
+
+ NDR_CHECK(ndr_pull_align(ndr, 4));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &namebuf_len));
+ if (namebuf_len < 1 || namebuf_len > 255) {
+ return ndr_pull_error(ndr, NDR_ERR_ALLOC, "value out of range");
+ }
+ NDR_PULL_ALLOC_N(ndr, namebuf, namebuf_len);
+ NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS, namebuf, namebuf_len));
+
+ NDR_PULL_ALLOC(ndr, r);
+
+ /* oh wow, what a nasty bug in windows ... */
+ if (namebuf[0] == 0x1b && namebuf_len >= 16) {
+ namebuf[0] = namebuf[15];
+ namebuf[15] = 0x1b;
+ }
+
+ if (namebuf_len < 17) {
+ r->type = 0x00;
+
+ r->name = talloc_strndup(r, (char *)namebuf, namebuf_len);
+ if (!r->name) return ndr_pull_error(ndr, NDR_ERR_ALLOC, "out of memory");
+
+ r->scope= NULL;
+
+ talloc_free(namebuf);
+ *_r = r;
+ return NDR_ERR_SUCCESS;
+ }
+
+ r->type = namebuf[15];
+
+ namebuf[15] = '\0';
+ trim_string((char *)namebuf, NULL, " ");
+ r->name = talloc_strdup(r, (char *)namebuf);
+ if (!r->name) return ndr_pull_error(ndr, NDR_ERR_ALLOC, "out of memory");
+
+ if (namebuf_len > 18) {
+ r->scope = talloc_strndup(r, (char *)(namebuf+17), namebuf_len-17);
+ if (!r->scope) return ndr_pull_error(ndr, NDR_ERR_ALLOC, "out of memory");
+ } else {
+ r->scope = NULL;
+ }
+
+ talloc_free(namebuf);
+ *_r = r;
+ return NDR_ERR_SUCCESS;
+}
+
+/**
+ push a nbt name, WINS Replication uses another on wire format for nbt name
+*/
+_PUBLIC_ enum ndr_err_code ndr_push_wrepl_nbt_name(struct ndr_push *ndr, int ndr_flags, const struct nbt_name *r)
+{
+ uint8_t *namebuf;
+ uint32_t namebuf_len;
+ uint32_t _name_len;
+ uint32_t scope_len = 0;
+
+ if (r == NULL) {
+ return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER,
+ "wrepl_nbt_name NULL pointer");
+ }
+
+ if (!(ndr_flags & NDR_SCALARS)) {
+ return NDR_ERR_SUCCESS;
+ }
+
+ _name_len = strlen(r->name);
+ if (_name_len > 15) {
+ return ndr_push_error(ndr, NDR_ERR_STRING,
+ "wrepl_nbt_name longer as 15 chars: %s",
+ r->name);
+ }
+
+ if (r->scope) {
+ scope_len = strlen(r->scope);
+ }
+ if (scope_len > 238) {
+ return ndr_push_error(ndr, NDR_ERR_STRING,
+ "wrepl_nbt_name scope longer as 238 chars: %s",
+ r->scope);
+ }
+
+ namebuf = (uint8_t *)talloc_asprintf(ndr, "%-15s%c%s",
+ r->name, 'X',
+ (r->scope?r->scope:""));
+ if (!namebuf) return ndr_push_error(ndr, NDR_ERR_ALLOC, "out of memory");
+
+ namebuf_len = strlen((char *)namebuf) + 1;
+
+ /*
+ * we need to set the type here, and use a place-holder in the talloc_asprintf()
+ * as the type can be 0x00, and then the namebuf_len = strlen(namebuf); would give wrong results
+ */
+ namebuf[15] = r->type;
+
+ /* oh wow, what a nasty bug in windows ... */
+ if (r->type == 0x1b) {
+ namebuf[15] = namebuf[0];
+ namebuf[0] = 0x1b;
+ }
+
+ NDR_CHECK(ndr_push_align(ndr, 4));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, namebuf_len));
+ NDR_CHECK(ndr_push_array_uint8(ndr, NDR_SCALARS, namebuf, namebuf_len));
+
+ talloc_free(namebuf);
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_wrepl_nbt_name(struct ndr_print *ndr, const char *name, const struct nbt_name *r)
+{
+ char *s = nbt_name_string(ndr, r);
+ ndr_print_string(ndr, name, s);
+ talloc_free(s);
+}
diff --git a/source3/libgpo/gpo_reg.c b/source3/libgpo/gpo_reg.c
index 7a005d85a2..920deeb189 100644
--- a/source3/libgpo/gpo_reg.c
+++ b/source3/libgpo/gpo_reg.c
@@ -789,7 +789,7 @@ void dump_reg_val(int lvl, const char *direction,
type_str = reg_type_lookup(val->type);
- DEBUG(lvl,("\tdump_reg_val: %s '%s' '%s' %s: ",
+ DEBUG(lvl,("\tdump_reg_val:\t%s '%s'\n\t\t\t'%s' %s: ",
direction, key, subkey, type_str));
switch (val->type) {
diff --git a/source3/libgpo/gpo_util.c b/source3/libgpo/gpo_util.c
index 7105b21de8..04597b3b57 100644
--- a/source3/libgpo/gpo_util.c
+++ b/source3/libgpo/gpo_util.c
@@ -664,7 +664,8 @@ NTSTATUS check_refresh_gpo(ADS_STRUCT *ads,
share, "A:",
ads->auth.user_name, NULL,
ads->auth.password,
- CLI_FULL_CONNECTION_USE_KERBEROS,
+ CLI_FULL_CONNECTION_USE_KERBEROS |
+ CLI_FULL_CONNECTION_FALLBACK_AFTER_KERBEROS,
Undefined, NULL);
if (!NT_STATUS_IS_OK(result)) {
DEBUG(10,("check_refresh_gpo: "
diff --git a/source3/libnet/libnet_join.c b/source3/libnet/libnet_join.c
index 16a7ea4566..d22fbc21b9 100644
--- a/source3/libnet/libnet_join.c
+++ b/source3/libnet/libnet_join.c
@@ -706,7 +706,7 @@ static NTSTATUS libnet_join_lookup_dc_rpc(TALLOC_CTX *mem_ctx,
}
rpccli_lsa_Close(pipe_hnd, mem_ctx, &lsa_pol);
- cli_rpc_pipe_close(pipe_hnd);
+ TALLOC_FREE(pipe_hnd);
done:
return status;
@@ -755,7 +755,7 @@ static NTSTATUS libnet_join_joindomain_rpc(TALLOC_CTX *mem_ctx,
}
status = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
- pipe_hnd->cli->desthost,
+ pipe_hnd->desthost,
SEC_RIGHTS_MAXIMUM_ALLOWED,
&sam_pol);
if (!NT_STATUS_IS_OK(status)) {
@@ -951,7 +951,7 @@ static NTSTATUS libnet_join_joindomain_rpc(TALLOC_CTX *mem_ctx,
if (is_valid_policy_hnd(&user_pol)) {
rpccli_samr_Close(pipe_hnd, mem_ctx, &user_pol);
}
- cli_rpc_pipe_close(pipe_hnd);
+ TALLOC_FREE(pipe_hnd);
return status;
}
@@ -1137,7 +1137,7 @@ static NTSTATUS libnet_join_unjoindomain_rpc(TALLOC_CTX *mem_ctx,
}
status = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
- pipe_hnd->cli->desthost,
+ pipe_hnd->desthost,
SEC_RIGHTS_MAXIMUM_ALLOWED,
&sam_pol);
if (!NT_STATUS_IS_OK(status)) {
@@ -1217,7 +1217,7 @@ done:
if (pipe_hnd) {
rpccli_samr_Close(pipe_hnd, mem_ctx, &domain_pol);
rpccli_samr_Close(pipe_hnd, mem_ctx, &sam_pol);
- cli_rpc_pipe_close(pipe_hnd);
+ TALLOC_FREE(pipe_hnd);
}
if (cli) {
diff --git a/source3/librpc/gen_ndr/nbt.h b/source3/librpc/gen_ndr/nbt.h
new file mode 100644
index 0000000000..8f2c38aef4
--- /dev/null
+++ b/source3/librpc/gen_ndr/nbt.h
@@ -0,0 +1,756 @@
+/* header auto-generated by pidl */
+
+#include <stdint.h>
+
+#include "librpc/gen_ndr/misc.h"
+#include "librpc/gen_ndr/security.h"
+#include "librpc/gen_ndr/svcctl.h"
+#ifndef _HEADER_nbt
+#define _HEADER_nbt
+
+#define NBT_NAME_SERVICE_PORT ( 137 )
+#define NBT_DGRAM_SERVICE_PORT ( 138 )
+#define NBT_MAILSLOT_NETLOGON ( "\\MAILSLOT\\NET\\NETLOGON" )
+#define NBT_MAILSLOT_NTLOGON ( "\\MAILSLOT\\NET\\NTLOGON" )
+#define NBT_MAILSLOT_GETDC ( "\\MAILSLOT\\NET\\GETDC" )
+#define NBT_MAILSLOT_BROWSE ( "\\MAILSLOT\\BROWSE" )
+#define DGRAM_SMB ( 0xff534d42 )
+/* bitmap nbt_operation */
+#define NBT_RCODE ( 0x000F )
+#define NBT_FLAG_BROADCAST ( 0x0010 )
+#define NBT_FLAG_RECURSION_AVAIL ( 0x0080 )
+#define NBT_FLAG_RECURSION_DESIRED ( 0x0100 )
+#define NBT_FLAG_TRUNCATION ( 0x0200 )
+#define NBT_FLAG_AUTHORITIVE ( 0x0400 )
+#define NBT_OPCODE ( 0x7800 )
+#define NBT_FLAG_REPLY ( 0x8000 )
+
+enum nbt_opcode
+#ifndef USE_UINT_ENUMS
+ {
+ NBT_OPCODE_QUERY=(0x0<<11),
+ NBT_OPCODE_REGISTER=(0x5<<11),
+ NBT_OPCODE_RELEASE=(0x6<<11),
+ NBT_OPCODE_WACK=(0x7<<11),
+ NBT_OPCODE_REFRESH=(0x8<<11),
+ NBT_OPCODE_REFRESH2=(0x9<<11),
+ NBT_OPCODE_MULTI_HOME_REG=(0xf<<11)
+}
+#else
+ { __donnot_use_enum_nbt_opcode=0x7FFFFFFF}
+#define NBT_OPCODE_QUERY ( (0x0<<11) )
+#define NBT_OPCODE_REGISTER ( (0x5<<11) )
+#define NBT_OPCODE_RELEASE ( (0x6<<11) )
+#define NBT_OPCODE_WACK ( (0x7<<11) )
+#define NBT_OPCODE_REFRESH ( (0x8<<11) )
+#define NBT_OPCODE_REFRESH2 ( (0x9<<11) )
+#define NBT_OPCODE_MULTI_HOME_REG ( (0xf<<11) )
+#endif
+;
+
+enum nbt_rcode
+#ifndef USE_UINT_ENUMS
+ {
+ NBT_RCODE_OK=0x0,
+ NBT_RCODE_FMT=0x1,
+ NBT_RCODE_SVR=0x2,
+ NBT_RCODE_NAM=0x3,
+ NBT_RCODE_IMP=0x4,
+ NBT_RCODE_RFS=0x5,
+ NBT_RCODE_ACT=0x6,
+ NBT_RCODE_CFT=0x7
+}
+#else
+ { __donnot_use_enum_nbt_rcode=0x7FFFFFFF}
+#define NBT_RCODE_OK ( 0x0 )
+#define NBT_RCODE_FMT ( 0x1 )
+#define NBT_RCODE_SVR ( 0x2 )
+#define NBT_RCODE_NAM ( 0x3 )
+#define NBT_RCODE_IMP ( 0x4 )
+#define NBT_RCODE_RFS ( 0x5 )
+#define NBT_RCODE_ACT ( 0x6 )
+#define NBT_RCODE_CFT ( 0x7 )
+#endif
+;
+
+enum nbt_name_type
+#ifndef USE_UINT_ENUMS
+ {
+ NBT_NAME_CLIENT=0x00,
+ NBT_NAME_MS=0x01,
+ NBT_NAME_USER=0x03,
+ NBT_NAME_SERVER=0x20,
+ NBT_NAME_PDC=0x1B,
+ NBT_NAME_LOGON=0x1C,
+ NBT_NAME_MASTER=0x1D,
+ NBT_NAME_BROWSER=0x1E
+}
+#else
+ { __donnot_use_enum_nbt_name_type=0x7FFFFFFF}
+#define NBT_NAME_CLIENT ( 0x00 )
+#define NBT_NAME_MS ( 0x01 )
+#define NBT_NAME_USER ( 0x03 )
+#define NBT_NAME_SERVER ( 0x20 )
+#define NBT_NAME_PDC ( 0x1B )
+#define NBT_NAME_LOGON ( 0x1C )
+#define NBT_NAME_MASTER ( 0x1D )
+#define NBT_NAME_BROWSER ( 0x1E )
+#endif
+;
+
+struct nbt_name {
+ const char * name;
+ const char * scope;
+ enum nbt_name_type type;
+}/* [nopull,public,nopush] */;
+
+enum nbt_qclass
+#ifndef USE_UINT_ENUMS
+ {
+ NBT_QCLASS_IP=0x01
+}
+#else
+ { __donnot_use_enum_nbt_qclass=0x7FFFFFFF}
+#define NBT_QCLASS_IP ( 0x01 )
+#endif
+;
+
+enum nbt_qtype
+#ifndef USE_UINT_ENUMS
+ {
+ NBT_QTYPE_ADDRESS=0x0001,
+ NBT_QTYPE_NAMESERVICE=0x0002,
+ NBT_QTYPE_NULL=0x000A,
+ NBT_QTYPE_NETBIOS=0x0020,
+ NBT_QTYPE_STATUS=0x0021
+}
+#else
+ { __donnot_use_enum_nbt_qtype=0x7FFFFFFF}
+#define NBT_QTYPE_ADDRESS ( 0x0001 )
+#define NBT_QTYPE_NAMESERVICE ( 0x0002 )
+#define NBT_QTYPE_NULL ( 0x000A )
+#define NBT_QTYPE_NETBIOS ( 0x0020 )
+#define NBT_QTYPE_STATUS ( 0x0021 )
+#endif
+;
+
+struct nbt_name_question {
+ struct nbt_name name;
+ enum nbt_qtype question_type;
+ enum nbt_qclass question_class;
+};
+
+enum nbt_node_type
+#ifndef USE_UINT_ENUMS
+ {
+ NBT_NODE_B=0x0000,
+ NBT_NODE_P=0x2000,
+ NBT_NODE_M=0x4000,
+ NBT_NODE_H=0x6000
+}
+#else
+ { __donnot_use_enum_nbt_node_type=0x7FFFFFFF}
+#define NBT_NODE_B ( 0x0000 )
+#define NBT_NODE_P ( 0x2000 )
+#define NBT_NODE_M ( 0x4000 )
+#define NBT_NODE_H ( 0x6000 )
+#endif
+;
+
+/* bitmap nb_flags */
+#define NBT_NM_PERMANENT ( 0x0200 )
+#define NBT_NM_ACTIVE ( 0x0400 )
+#define NBT_NM_CONFLICT ( 0x0800 )
+#define NBT_NM_DEREGISTER ( 0x1000 )
+#define NBT_NM_OWNER_TYPE ( 0x6000 )
+#define NBT_NM_GROUP ( 0x8000 )
+
+struct nbt_rdata_address {
+ uint16_t nb_flags;
+ const char * ipaddr;
+};
+
+struct nbt_rdata_netbios {
+ uint16_t length;
+ struct nbt_rdata_address *addresses;
+};
+
+struct nbt_statistics {
+ uint8_t unit_id[6];
+ uint8_t jumpers;
+ uint8_t test_result;
+ uint16_t version_number;
+ uint16_t period_of_statistics;
+ uint16_t number_of_crcs;
+ uint16_t number_alignment_errors;
+ uint16_t number_of_collisions;
+ uint16_t number_send_aborts;
+ uint32_t number_good_sends;
+ uint32_t number_good_receives;
+ uint16_t number_retransmits;
+ uint16_t number_no_resource_conditions;
+ uint16_t number_free_command_blocks;
+ uint16_t total_number_command_blocks;
+ uint16_t max_total_number_command_blocks;
+ uint16_t number_pending_sessions;
+ uint16_t max_number_pending_sessions;
+ uint16_t max_total_sessions_possible;
+ uint16_t session_data_packet_size;
+};
+
+struct nbt_status_name {
+ const char *name;/* [charset(DOS)] */
+ enum nbt_name_type type;
+ uint16_t nb_flags;
+};
+
+struct nbt_rdata_status {
+ uint16_t length;/* [value(num_names*18+47)] */
+ uint8_t num_names;
+ struct nbt_status_name *names;
+ struct nbt_statistics statistics;
+};
+
+struct nbt_rdata_data {
+ uint16_t length;
+ uint8_t *data;
+};
+
+union nbt_rdata {
+ struct nbt_rdata_netbios netbios;/* [case(NBT_QTYPE_NETBIOS)] */
+ struct nbt_rdata_status status;/* [case(NBT_QTYPE_STATUS)] */
+ struct nbt_rdata_data data;/* [default] */
+}/* [nodiscriminant] */;
+
+struct nbt_res_rec {
+ struct nbt_name name;
+ enum nbt_qtype rr_type;
+ enum nbt_qclass rr_class;
+ uint32_t ttl;
+ union nbt_rdata rdata;/* [switch_is(((((rr_type)==NBT_QTYPE_NETBIOS)&&talloc_check_name(ndr,"struct ndr_push")&&((rdata).data.length==2))?0:rr_type))] */
+}/* [flag(LIBNDR_PRINT_ARRAY_HEX)] */;
+
+struct nbt_name_packet {
+ uint16_t name_trn_id;
+ uint16_t operation;
+ uint16_t qdcount;
+ uint16_t ancount;
+ uint16_t nscount;
+ uint16_t arcount;
+ struct nbt_name_question *questions;
+ struct nbt_res_rec *answers;
+ struct nbt_res_rec *nsrecs;
+ struct nbt_res_rec *additional;
+ DATA_BLOB padding;/* [flag(LIBNDR_FLAG_REMAINING)] */
+}/* [public,flag(LIBNDR_FLAG_NOALIGN|LIBNDR_FLAG_BIGENDIAN|LIBNDR_PRINT_ARRAY_HEX)] */;
+
+enum dgram_msg_type
+#ifndef USE_UINT_ENUMS
+ {
+ DGRAM_DIRECT_UNIQUE=0x10,
+ DGRAM_DIRECT_GROUP=0x11,
+ DGRAM_BCAST=0x12,
+ DGRAM_ERROR=0x13,
+ DGRAM_QUERY=0x14,
+ DGRAM_QUERY_POSITIVE=0x15,
+ DGRAM_QUERY_NEGATIVE=0x16
+}
+#else
+ { __donnot_use_enum_dgram_msg_type=0x7FFFFFFF}
+#define DGRAM_DIRECT_UNIQUE ( 0x10 )
+#define DGRAM_DIRECT_GROUP ( 0x11 )
+#define DGRAM_BCAST ( 0x12 )
+#define DGRAM_ERROR ( 0x13 )
+#define DGRAM_QUERY ( 0x14 )
+#define DGRAM_QUERY_POSITIVE ( 0x15 )
+#define DGRAM_QUERY_NEGATIVE ( 0x16 )
+#endif
+;
+
+/* bitmap dgram_flags */
+#define DGRAM_FLAG_MORE ( 0x01 )
+#define DGRAM_FLAG_FIRST ( 0x02 )
+#define DGRAM_FLAG_NODE_TYPE ( 0x0C )
+
+enum dgram_node_type
+#ifndef USE_UINT_ENUMS
+ {
+ DGRAM_NODE_B=0x00,
+ DGRAM_NODE_P=0x04,
+ DGRAM_NODE_M=0x08,
+ DGRAM_NODE_NBDD=0x0C
+}
+#else
+ { __donnot_use_enum_dgram_node_type=0x7FFFFFFF}
+#define DGRAM_NODE_B ( 0x00 )
+#define DGRAM_NODE_P ( 0x04 )
+#define DGRAM_NODE_M ( 0x08 )
+#define DGRAM_NODE_NBDD ( 0x0C )
+#endif
+;
+
+enum smb_command
+#ifndef USE_UINT_ENUMS
+ {
+ SMB_TRANSACTION=0x25
+}
+#else
+ { __donnot_use_enum_smb_command=0x7FFFFFFF}
+#define SMB_TRANSACTION ( 0x25 )
+#endif
+;
+
+struct smb_trans_body {
+ uint8_t wct;/* [value(17),range(17,17)] */
+ uint16_t total_param_count;
+ uint16_t total_data_count;
+ uint16_t max_param_count;
+ uint16_t max_data_count;
+ uint8_t max_setup_count;
+ uint8_t pad;
+ uint16_t trans_flags;
+ uint32_t timeout;
+ uint16_t reserved;
+ uint16_t param_count;
+ uint16_t param_offset;
+ uint16_t data_count;
+ uint16_t data_offset;
+ uint8_t setup_count;/* [value(3),range(3,3)] */
+ uint8_t pad2;
+ uint16_t opcode;
+ uint16_t priority;
+ uint16_t _class;
+ uint16_t byte_count;/* [value(strlen(mailslot_name)+1+data.length)] */
+ const char * mailslot_name;/* [flag(LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM)] */
+ DATA_BLOB data;/* [flag(LIBNDR_FLAG_REMAINING)] */
+};
+
+union smb_body {
+ struct smb_trans_body trans;/* [case(SMB_TRANSACTION)] */
+}/* [nodiscriminant] */;
+
+struct dgram_smb_packet {
+ enum smb_command smb_command;
+ uint8_t err_class;
+ uint8_t pad;
+ uint16_t err_code;
+ uint8_t flags;
+ uint16_t flags2;
+ uint16_t pid_high;
+ uint8_t signature[8];
+ uint16_t reserved;
+ uint16_t tid;
+ uint16_t pid;
+ uint16_t vuid;
+ uint16_t mid;
+ union smb_body body;/* [switch_is(smb_command)] */
+}/* [public,flag(LIBNDR_FLAG_NOALIGN|LIBNDR_FLAG_LITTLE_ENDIAN|LIBNDR_PRINT_ARRAY_HEX)] */;
+
+union dgram_message_body {
+ struct dgram_smb_packet smb;/* [case(DGRAM_SMB)] */
+}/* [nodiscriminant] */;
+
+struct dgram_message {
+ uint16_t length;
+ uint16_t offset;
+ struct nbt_name source_name;
+ struct nbt_name dest_name;
+ uint32_t dgram_body_type;
+ union dgram_message_body body;/* [switch_is(dgram_body_type)] */
+};
+
+enum dgram_err_code
+#ifndef USE_UINT_ENUMS
+ {
+ DGRAM_ERROR_NAME_NOT_PRESENT=0x82,
+ DGRAM_ERROR_INVALID_SOURCE=0x83,
+ DGRAM_ERROR_INVALID_DEST=0x84
+}
+#else
+ { __donnot_use_enum_dgram_err_code=0x7FFFFFFF}
+#define DGRAM_ERROR_NAME_NOT_PRESENT ( 0x82 )
+#define DGRAM_ERROR_INVALID_SOURCE ( 0x83 )
+#define DGRAM_ERROR_INVALID_DEST ( 0x84 )
+#endif
+;
+
+union dgram_data {
+ struct dgram_message msg;/* [case(DGRAM_DIRECT_UNIQUE)] */
+ enum dgram_err_code error;/* [case(DGRAM_ERROR)] */
+ struct nbt_name dest_name;/* [case(DGRAM_QUERY)] */
+}/* [nodiscriminant] */;
+
+struct nbt_dgram_packet {
+ enum dgram_msg_type msg_type;
+ uint8_t flags;
+ uint16_t dgram_id;
+ const char * src_addr;
+ uint16_t src_port;
+ union dgram_data data;/* [switch_is(msg_type)] */
+}/* [public,flag(LIBNDR_FLAG_NOALIGN|LIBNDR_FLAG_BIGENDIAN|LIBNDR_PRINT_ARRAY_HEX)] */;
+
+enum nbt_netlogon_command
+#ifndef USE_UINT_ENUMS
+ {
+ NETLOGON_QUERY_FOR_PDC=0x7,
+ NETLOGON_ANNOUNCE_UAS=0xa,
+ NETLOGON_RESPONSE_FROM_PDC=0xc,
+ NETLOGON_QUERY_FOR_PDC2=0x12,
+ NETLOGON_RESPONSE_FROM_PDC2=0x17,
+ NETLOGON_RESPONSE_FROM_PDC_USER=0x19
+}
+#else
+ { __donnot_use_enum_nbt_netlogon_command=0x7FFFFFFF}
+#define NETLOGON_QUERY_FOR_PDC ( 0x7 )
+#define NETLOGON_ANNOUNCE_UAS ( 0xa )
+#define NETLOGON_RESPONSE_FROM_PDC ( 0xc )
+#define NETLOGON_QUERY_FOR_PDC2 ( 0x12 )
+#define NETLOGON_RESPONSE_FROM_PDC2 ( 0x17 )
+#define NETLOGON_RESPONSE_FROM_PDC_USER ( 0x19 )
+#endif
+;
+
+struct nbt_netlogon_query_for_pdc {
+ const char * computer_name;/* [flag(LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM)] */
+ const char * mailslot_name;/* [flag(LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM)] */
+ DATA_BLOB _pad;/* [flag(LIBNDR_FLAG_ALIGN2)] */
+ const char * unicode_name;/* [flag(LIBNDR_FLAG_STR_NULLTERM)] */
+ uint32_t nt_version;
+ uint16_t lmnt_token;
+ uint16_t lm20_token;
+};
+
+struct nbt_netlogon_query_for_pdc2 {
+ uint16_t request_count;
+ const char * computer_name;/* [flag(LIBNDR_FLAG_STR_NULLTERM)] */
+ const char * user_name;/* [flag(LIBNDR_FLAG_STR_NULLTERM)] */
+ const char * mailslot_name;/* [flag(LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM)] */
+ uint32_t unknown[2];
+ uint32_t nt_version;
+ uint16_t lmnt_token;
+ uint16_t lm20_token;
+};
+
+struct nbt_netlogon_response_from_pdc {
+ const char * pdc_name;/* [flag(LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM)] */
+ DATA_BLOB _pad;/* [flag(LIBNDR_FLAG_ALIGN2)] */
+ const char * unicode_pdc_name;/* [flag(LIBNDR_FLAG_STR_NULLTERM)] */
+ const char * domain_name;/* [flag(LIBNDR_FLAG_STR_NULLTERM)] */
+ uint32_t nt_version;
+ uint16_t lmnt_token;
+ uint16_t lm20_token;
+};
+
+/* bitmap nbt_server_type */
+#define NBT_SERVER_PDC ( 0x00000001 )
+#define NBT_SERVER_GC ( 0x00000004 )
+#define NBT_SERVER_LDAP ( 0x00000008 )
+#define NBT_SERVER_DS ( 0x00000010 )
+#define NBT_SERVER_KDC ( 0x00000020 )
+#define NBT_SERVER_TIMESERV ( 0x00000040 )
+#define NBT_SERVER_CLOSEST ( 0x00000080 )
+#define NBT_SERVER_WRITABLE ( 0x00000100 )
+#define NBT_SERVER_GOOD_TIMESERV ( 0x00000200 )
+
+struct nbt_netlogon_response_from_pdc2 {
+ DATA_BLOB _pad;/* [flag(LIBNDR_FLAG_ALIGN4)] */
+ uint32_t server_type;
+ struct GUID domain_uuid;
+ const char * forest;
+ const char * dns_domain;
+ const char * pdc_dns_name;
+ const char * domain;
+ const char * pdc_name;
+ const char * user_name;
+ const char * server_site;
+ const char * client_site;
+ uint8_t unknown;
+ uint32_t unknown2;
+ const char * pdc_ip;/* [flag(LIBNDR_FLAG_BIGENDIAN)] */
+ uint32_t unknown3[2];
+ uint32_t nt_version;
+ uint16_t lmnt_token;
+ uint16_t lm20_token;
+};
+
+enum netr_SamDatabaseID;
+
+struct nbt_db_change {
+ enum netr_SamDatabaseID db_index;
+ uint64_t serial;
+ NTTIME timestamp;
+};
+
+struct nbt_netlogon_announce_uas {
+ uint32_t serial_lo;
+ time_t timestamp;
+ uint32_t pulse;
+ uint32_t random;
+ const char * pdc_name;/* [flag(LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM)] */
+ const char * domain;/* [flag(LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM)] */
+ DATA_BLOB _pad;/* [flag(LIBNDR_FLAG_ALIGN2)] */
+ const char * unicode_pdc_name;/* [flag(LIBNDR_FLAG_STR_NULLTERM)] */
+ const char * unicode_domain;/* [flag(LIBNDR_FLAG_STR_NULLTERM)] */
+ uint32_t db_count;
+ struct nbt_db_change *dbchange;
+ uint32_t sid_size;/* [value(ndr_size_dom_sid0(&sid,ndr->flags))] */
+ struct dom_sid0 sid;/* [subcontext_size(sid_size),subcontext(0)] */
+ uint32_t nt_version;
+ uint16_t lmnt_token;
+ uint16_t lm20_token;
+};
+
+union nbt_netlogon_request {
+ struct nbt_netlogon_query_for_pdc pdc;/* [case(NETLOGON_QUERY_FOR_PDC)] */
+ struct nbt_netlogon_query_for_pdc2 pdc2;/* [case(NETLOGON_QUERY_FOR_PDC2)] */
+ struct nbt_netlogon_announce_uas uas;/* [case(NETLOGON_ANNOUNCE_UAS)] */
+ struct nbt_netlogon_response_from_pdc response;/* [case(NETLOGON_RESPONSE_FROM_PDC)] */
+ struct nbt_netlogon_response_from_pdc2 response2;/* [case(NETLOGON_RESPONSE_FROM_PDC2)] */
+}/* [nodiscriminant] */;
+
+struct nbt_netlogon_packet {
+ enum nbt_netlogon_command command;
+ union nbt_netlogon_request req;/* [switch_is(command)] */
+}/* [public,flag(LIBNDR_FLAG_NOALIGN)] */;
+
+struct nbt_cldap_netlogon_1 {
+ uint16_t type;
+ const char * pdc_name;/* [flag(LIBNDR_FLAG_STR_NULLTERM)] */
+ const char * user_name;/* [flag(LIBNDR_FLAG_STR_NULLTERM)] */
+ const char * domain_name;/* [flag(LIBNDR_FLAG_STR_NULLTERM)] */
+ uint32_t nt_version;/* [value] */
+ uint16_t lmnt_token;
+ uint16_t lm20_token;
+};
+
+struct nbt_cldap_netlogon_3 {
+ uint16_t type;
+ const char * pdc_name;/* [flag(LIBNDR_FLAG_STR_NULLTERM)] */
+ const char * user_name;/* [flag(LIBNDR_FLAG_STR_NULLTERM)] */
+ const char * domain_name;/* [flag(LIBNDR_FLAG_STR_NULLTERM)] */
+ struct GUID domain_uuid;
+ struct GUID unknown_uuid;
+ const char * forest;
+ const char * dns_domain;
+ const char * pdc_dns_name;
+ const char * pdc_ip;
+ uint32_t server_type;
+ uint32_t nt_version;/* [value(3)] */
+ uint16_t lmnt_token;
+ uint16_t lm20_token;
+};
+
+struct nbt_cldap_netlogon_5 {
+ uint32_t type;
+ uint32_t server_type;
+ struct GUID domain_uuid;
+ const char * forest;
+ const char * dns_domain;
+ const char * pdc_dns_name;
+ const char * domain;
+ const char * pdc_name;
+ const char * user_name;
+ const char * server_site;
+ const char * client_site;
+ uint32_t nt_version;/* [value(5)] */
+ uint16_t lmnt_token;
+ uint16_t lm20_token;
+};
+
+struct nbt_cldap_netlogon_13 {
+ uint32_t type;
+ uint32_t server_type;
+ struct GUID domain_uuid;
+ const char * forest;
+ const char * dns_domain;
+ const char * pdc_dns_name;
+ const char * domain;
+ const char * pdc_name;
+ const char * user_name;
+ const char * server_site;
+ const char * client_site;
+ uint8_t unknown;
+ uint32_t unknown2;
+ const char * pdc_ip;/* [flag(LIBNDR_FLAG_BIGENDIAN)] */
+ uint32_t unknown3[2];
+ uint32_t nt_version;/* [value(13)] */
+ uint16_t lmnt_token;
+ uint16_t lm20_token;
+};
+
+union nbt_cldap_netlogon {
+ struct nbt_cldap_netlogon_1 logon1;/* [case(0)] */
+ struct nbt_cldap_netlogon_3 logon3;/* [case(2)] */
+ struct nbt_cldap_netlogon_5 logon5;/* [case(4)] */
+ struct nbt_cldap_netlogon_13 logon13;/* [default] */
+}/* [public,nodiscriminant,flag(LIBNDR_FLAG_NOALIGN)] */;
+
+enum nbt_ntlogon_command
+#ifndef USE_UINT_ENUMS
+ {
+ NTLOGON_SAM_LOGON=0x12,
+ NTLOGON_SAM_LOGON_REPLY=0x13,
+ NTLOGON_SAM_LOGON_REPLY15=0x15
+}
+#else
+ { __donnot_use_enum_nbt_ntlogon_command=0x7FFFFFFF}
+#define NTLOGON_SAM_LOGON ( 0x12 )
+#define NTLOGON_SAM_LOGON_REPLY ( 0x13 )
+#define NTLOGON_SAM_LOGON_REPLY15 ( 0x15 )
+#endif
+;
+
+struct nbt_ntlogon_sam_logon {
+ uint16_t request_count;
+ const char * computer_name;/* [flag(LIBNDR_FLAG_STR_NULLTERM)] */
+ const char * user_name;/* [flag(LIBNDR_FLAG_STR_NULLTERM)] */
+ const char * mailslot_name;/* [flag(LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM)] */
+ uint32_t acct_control;
+ uint32_t sid_size;/* [value(ndr_size_dom_sid0(&sid,ndr->flags))] */
+ struct dom_sid0 sid;/* [subcontext_size(sid_size),subcontext(0)] */
+ uint32_t nt_version;
+ uint16_t lmnt_token;
+ uint16_t lm20_token;
+};
+
+struct nbt_ntlogon_sam_logon_reply {
+ const char * server;/* [flag(LIBNDR_FLAG_STR_NULLTERM)] */
+ const char * user_name;/* [flag(LIBNDR_FLAG_STR_NULLTERM)] */
+ const char * domain;/* [flag(LIBNDR_FLAG_STR_NULLTERM)] */
+ uint32_t nt_version;
+ uint16_t lmnt_token;
+ uint16_t lm20_token;
+};
+
+union nbt_ntlogon_request {
+ struct nbt_ntlogon_sam_logon logon;/* [case(NTLOGON_SAM_LOGON)] */
+ struct nbt_ntlogon_sam_logon_reply reply;/* [case(NTLOGON_SAM_LOGON_REPLY)] */
+ struct nbt_netlogon_response_from_pdc2 reply2;/* [case(NETLOGON_RESPONSE_FROM_PDC2)] */
+}/* [nodiscriminant] */;
+
+struct nbt_ntlogon_packet {
+ enum nbt_ntlogon_command command;
+ union nbt_ntlogon_request req;/* [switch_is(command)] */
+}/* [public,flag(LIBNDR_FLAG_NOALIGN)] */;
+
+enum nbt_browse_opcode
+#ifndef USE_UINT_ENUMS
+ {
+ HostAnnouncement=1,
+ AnnouncementRequest=2,
+ Election=8,
+ GetBackupListReq=9,
+ GetBackupListResp=10,
+ BecomeBackup=11,
+ DomainAnnouncement=12,
+ MasterAnnouncement=13,
+ ResetBrowserState=14,
+ LocalMasterAnnouncement=15
+}
+#else
+ { __donnot_use_enum_nbt_browse_opcode=0x7FFFFFFF}
+#define HostAnnouncement ( 1 )
+#define AnnouncementRequest ( 2 )
+#define Election ( 8 )
+#define GetBackupListReq ( 9 )
+#define GetBackupListResp ( 10 )
+#define BecomeBackup ( 11 )
+#define DomainAnnouncement ( 12 )
+#define MasterAnnouncement ( 13 )
+#define ResetBrowserState ( 14 )
+#define LocalMasterAnnouncement ( 15 )
+#endif
+;
+
+struct nbt_browse_host_announcement {
+ uint8_t UpdateCount;
+ uint32_t Periodicity;
+ const char *ServerName;/* [charset(DOS)] */
+ uint8_t OSMajor;
+ uint8_t OSMinor;
+ uint32_t ServerType;
+ uint8_t BroMajorVer;
+ uint8_t BroMinorVer;
+ uint16_t Signature;
+ const char * Comment;/* [flag(LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM)] */
+};
+
+struct nbt_browse_announcement_request {
+ uint8_t Unused;
+ const char * ResponseName;/* [flag(LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM)] */
+};
+
+struct nbt_browse_election_request {
+ uint8_t Version;
+ uint32_t Criteria;
+ uint32_t UpTime;
+ uint32_t Reserved;
+ const char * ServerName;/* [flag(LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM)] */
+};
+
+struct nbt_browse_backup_list_request {
+ uint8_t ReqCount;
+ uint32_t Token;
+};
+
+struct nbt_browse_backup_list_response {
+ uint8_t BackupCount;
+ uint32_t Token;
+ struct nbt_name *BackupServerList;
+};
+
+struct nbt_browse_become_backup {
+ const char * BrowserName;/* [flag(LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM)] */
+};
+
+struct nbt_browse_domain_announcement {
+ uint8_t UpdateCount;
+ uint32_t Periodicity;
+ const char *ServerName;/* [charset(DOS)] */
+ uint8_t OSMajor;
+ uint8_t OSMinor;
+ uint32_t ServerType;
+ uint32_t MysteriousField;
+ const char * Comment;/* [flag(LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM)] */
+};
+
+struct nbt_browse_master_announcement {
+ const char * ServerName;/* [flag(LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM)] */
+};
+
+struct nbt_browse_reset_state {
+ uint8_t Command;
+};
+
+struct nbt_browse_local_master_announcement {
+ uint8_t UpdateCount;
+ uint32_t Periodicity;
+ const char *ServerName;/* [charset(DOS)] */
+ uint8_t OSMajor;
+ uint8_t OSMinor;
+ uint32_t ServerType;
+ uint8_t BroMajorVer;
+ uint8_t BroMinorVer;
+ uint16_t Signature;
+ const char * Comment;/* [flag(LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM)] */
+};
+
+union nbt_browse_payload {
+ struct nbt_browse_host_announcement host_annoucement;/* [case(HostAnnouncement)] */
+ struct nbt_browse_announcement_request announcement_request;/* [case(AnnouncementRequest)] */
+ struct nbt_browse_election_request election_request;/* [case(Election)] */
+ struct nbt_browse_backup_list_request backup_list_request;/* [case(GetBackupListReq)] */
+ struct nbt_browse_backup_list_response backup_list_response;/* [case(GetBackupListResp)] */
+ struct nbt_browse_become_backup become_backup;/* [case(BecomeBackup)] */
+ struct nbt_browse_domain_announcement domain_announcement;/* [case(DomainAnnouncement)] */
+ struct nbt_browse_master_announcement master_announcement;/* [case(MasterAnnouncement)] */
+ struct nbt_browse_reset_state reset_browser_state;/* [case(ResetBrowserState)] */
+ struct nbt_browse_local_master_announcement local_master_announcement;/* [case(LocalMasterAnnouncement)] */
+}/* [nodiscriminant] */;
+
+struct nbt_browse_packet {
+ enum nbt_browse_opcode opcode;
+ union nbt_browse_payload payload;/* [switch_is(opcode)] */
+}/* [public,flag(LIBNDR_FLAG_NOALIGN)] */;
+
+#endif /* _HEADER_nbt */
diff --git a/source3/librpc/gen_ndr/ndr_nbt.c b/source3/librpc/gen_ndr/ndr_nbt.c
new file mode 100644
index 0000000000..45fd54d52f
--- /dev/null
+++ b/source3/librpc/gen_ndr/ndr_nbt.c
@@ -0,0 +1,4148 @@
+/* parser auto-generated by pidl */
+
+#include "includes.h"
+#include "librpc/gen_ndr/ndr_nbt.h"
+
+#include "librpc/gen_ndr/ndr_misc.h"
+#include "librpc/gen_ndr/ndr_security.h"
+#include "librpc/gen_ndr/ndr_svcctl.h"
+static enum ndr_err_code ndr_push_nbt_operation(struct ndr_push *ndr, int ndr_flags, uint16_t r)
+{
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r));
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_nbt_operation(struct ndr_pull *ndr, int ndr_flags, uint16_t *r)
+{
+ uint16_t v;
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &v));
+ *r = v;
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_nbt_operation(struct ndr_print *ndr, const char *name, uint16_t r)
+{
+ ndr_print_uint16(ndr, name, r);
+ ndr->depth++;
+ ndr_print_bitmap_flag(ndr, sizeof(uint16_t), "NBT_RCODE", NBT_RCODE, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint16_t), "NBT_FLAG_BROADCAST", NBT_FLAG_BROADCAST, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint16_t), "NBT_FLAG_RECURSION_AVAIL", NBT_FLAG_RECURSION_AVAIL, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint16_t), "NBT_FLAG_RECURSION_DESIRED", NBT_FLAG_RECURSION_DESIRED, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint16_t), "NBT_FLAG_TRUNCATION", NBT_FLAG_TRUNCATION, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint16_t), "NBT_FLAG_AUTHORITIVE", NBT_FLAG_AUTHORITIVE, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint16_t), "NBT_OPCODE", NBT_OPCODE, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint16_t), "NBT_FLAG_REPLY", NBT_FLAG_REPLY, r);
+ ndr->depth--;
+}
+
+static enum ndr_err_code ndr_push_nbt_name_type(struct ndr_push *ndr, int ndr_flags, enum nbt_name_type r)
+{
+ NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r));
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_nbt_name_type(struct ndr_pull *ndr, int ndr_flags, enum nbt_name_type *r)
+{
+ uint8_t v;
+ NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &v));
+ *r = v;
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_nbt_name_type(struct ndr_print *ndr, const char *name, enum nbt_name_type r)
+{
+ const char *val = NULL;
+
+ switch (r) {
+ case NBT_NAME_CLIENT: val = "NBT_NAME_CLIENT"; break;
+ case NBT_NAME_MS: val = "NBT_NAME_MS"; break;
+ case NBT_NAME_USER: val = "NBT_NAME_USER"; break;
+ case NBT_NAME_SERVER: val = "NBT_NAME_SERVER"; break;
+ case NBT_NAME_PDC: val = "NBT_NAME_PDC"; break;
+ case NBT_NAME_LOGON: val = "NBT_NAME_LOGON"; break;
+ case NBT_NAME_MASTER: val = "NBT_NAME_MASTER"; break;
+ case NBT_NAME_BROWSER: val = "NBT_NAME_BROWSER"; break;
+ }
+ ndr_print_enum(ndr, name, "ENUM", val, r);
+}
+
+_PUBLIC_ void ndr_print_nbt_name(struct ndr_print *ndr, const char *name, const struct nbt_name *r)
+{
+ ndr_print_struct(ndr, name, "nbt_name");
+ ndr->depth++;
+ ndr_print_string(ndr, "name", r->name);
+ ndr_print_string(ndr, "scope", r->scope);
+ ndr_print_nbt_name_type(ndr, "type", r->type);
+ ndr->depth--;
+}
+
+static enum ndr_err_code ndr_push_nbt_qclass(struct ndr_push *ndr, int ndr_flags, enum nbt_qclass r)
+{
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r));
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_nbt_qclass(struct ndr_pull *ndr, int ndr_flags, enum nbt_qclass *r)
+{
+ uint16_t v;
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &v));
+ *r = v;
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_nbt_qclass(struct ndr_print *ndr, const char *name, enum nbt_qclass r)
+{
+ const char *val = NULL;
+
+ switch (r) {
+ case NBT_QCLASS_IP: val = "NBT_QCLASS_IP"; break;
+ }
+ ndr_print_enum(ndr, name, "ENUM", val, r);
+}
+
+static enum ndr_err_code ndr_push_nbt_qtype(struct ndr_push *ndr, int ndr_flags, enum nbt_qtype r)
+{
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r));
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_nbt_qtype(struct ndr_pull *ndr, int ndr_flags, enum nbt_qtype *r)
+{
+ uint16_t v;
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &v));
+ *r = v;
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_nbt_qtype(struct ndr_print *ndr, const char *name, enum nbt_qtype r)
+{
+ const char *val = NULL;
+
+ switch (r) {
+ case NBT_QTYPE_ADDRESS: val = "NBT_QTYPE_ADDRESS"; break;
+ case NBT_QTYPE_NAMESERVICE: val = "NBT_QTYPE_NAMESERVICE"; break;
+ case NBT_QTYPE_NULL: val = "NBT_QTYPE_NULL"; break;
+ case NBT_QTYPE_NETBIOS: val = "NBT_QTYPE_NETBIOS"; break;
+ case NBT_QTYPE_STATUS: val = "NBT_QTYPE_STATUS"; break;
+ }
+ ndr_print_enum(ndr, name, "ENUM", val, r);
+}
+
+static enum ndr_err_code ndr_push_nbt_name_question(struct ndr_push *ndr, int ndr_flags, const struct nbt_name_question *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_push_align(ndr, 4));
+ NDR_CHECK(ndr_push_nbt_name(ndr, NDR_SCALARS, &r->name));
+ NDR_CHECK(ndr_push_nbt_qtype(ndr, NDR_SCALARS, r->question_type));
+ NDR_CHECK(ndr_push_nbt_qclass(ndr, NDR_SCALARS, r->question_class));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_nbt_name_question(struct ndr_pull *ndr, int ndr_flags, struct nbt_name_question *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_pull_align(ndr, 4));
+ NDR_CHECK(ndr_pull_nbt_name(ndr, NDR_SCALARS, &r->name));
+ NDR_CHECK(ndr_pull_nbt_qtype(ndr, NDR_SCALARS, &r->question_type));
+ NDR_CHECK(ndr_pull_nbt_qclass(ndr, NDR_SCALARS, &r->question_class));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_nbt_name_question(struct ndr_print *ndr, const char *name, const struct nbt_name_question *r)
+{
+ ndr_print_struct(ndr, name, "nbt_name_question");
+ ndr->depth++;
+ ndr_print_nbt_name(ndr, "name", &r->name);
+ ndr_print_nbt_qtype(ndr, "question_type", r->question_type);
+ ndr_print_nbt_qclass(ndr, "question_class", r->question_class);
+ ndr->depth--;
+}
+
+static enum ndr_err_code ndr_push_nb_flags(struct ndr_push *ndr, int ndr_flags, uint16_t r)
+{
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r));
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_nb_flags(struct ndr_pull *ndr, int ndr_flags, uint16_t *r)
+{
+ uint16_t v;
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &v));
+ *r = v;
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_nb_flags(struct ndr_print *ndr, const char *name, uint16_t r)
+{
+ ndr_print_uint16(ndr, name, r);
+ ndr->depth++;
+ ndr_print_bitmap_flag(ndr, sizeof(uint16_t), "NBT_NM_PERMANENT", NBT_NM_PERMANENT, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint16_t), "NBT_NM_ACTIVE", NBT_NM_ACTIVE, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint16_t), "NBT_NM_CONFLICT", NBT_NM_CONFLICT, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint16_t), "NBT_NM_DEREGISTER", NBT_NM_DEREGISTER, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint16_t), "NBT_NM_OWNER_TYPE", NBT_NM_OWNER_TYPE, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint16_t), "NBT_NM_GROUP", NBT_NM_GROUP, r);
+ ndr->depth--;
+}
+
+static enum ndr_err_code ndr_push_nbt_rdata_address(struct ndr_push *ndr, int ndr_flags, const struct nbt_rdata_address *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_push_align(ndr, 4));
+ NDR_CHECK(ndr_push_nb_flags(ndr, NDR_SCALARS, r->nb_flags));
+ NDR_CHECK(ndr_push_ipv4address(ndr, NDR_SCALARS, r->ipaddr));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_nbt_rdata_address(struct ndr_pull *ndr, int ndr_flags, struct nbt_rdata_address *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_pull_align(ndr, 4));
+ NDR_CHECK(ndr_pull_nb_flags(ndr, NDR_SCALARS, &r->nb_flags));
+ NDR_CHECK(ndr_pull_ipv4address(ndr, NDR_SCALARS, &r->ipaddr));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_nbt_rdata_address(struct ndr_print *ndr, const char *name, const struct nbt_rdata_address *r)
+{
+ ndr_print_struct(ndr, name, "nbt_rdata_address");
+ ndr->depth++;
+ ndr_print_nb_flags(ndr, "nb_flags", r->nb_flags);
+ ndr_print_ipv4address(ndr, "ipaddr", r->ipaddr);
+ ndr->depth--;
+}
+
+static enum ndr_err_code ndr_push_nbt_rdata_netbios(struct ndr_push *ndr, int ndr_flags, const struct nbt_rdata_netbios *r)
+{
+ uint32_t cntr_addresses_0;
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_push_align(ndr, 4));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->length));
+ for (cntr_addresses_0 = 0; cntr_addresses_0 < r->length / 6; cntr_addresses_0++) {
+ NDR_CHECK(ndr_push_nbt_rdata_address(ndr, NDR_SCALARS, &r->addresses[cntr_addresses_0]));
+ }
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_nbt_rdata_netbios(struct ndr_pull *ndr, int ndr_flags, struct nbt_rdata_netbios *r)
+{
+ uint32_t cntr_addresses_0;
+ TALLOC_CTX *_mem_save_addresses_0;
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_pull_align(ndr, 4));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->length));
+ NDR_PULL_ALLOC_N(ndr, r->addresses, r->length / 6);
+ _mem_save_addresses_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->addresses, 0);
+ for (cntr_addresses_0 = 0; cntr_addresses_0 < r->length / 6; cntr_addresses_0++) {
+ NDR_CHECK(ndr_pull_nbt_rdata_address(ndr, NDR_SCALARS, &r->addresses[cntr_addresses_0]));
+ }
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_addresses_0, 0);
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_nbt_rdata_netbios(struct ndr_print *ndr, const char *name, const struct nbt_rdata_netbios *r)
+{
+ uint32_t cntr_addresses_0;
+ ndr_print_struct(ndr, name, "nbt_rdata_netbios");
+ ndr->depth++;
+ ndr_print_uint16(ndr, "length", r->length);
+ ndr->print(ndr, "%s: ARRAY(%d)", "addresses", r->length / 6);
+ ndr->depth++;
+ for (cntr_addresses_0=0;cntr_addresses_0<r->length / 6;cntr_addresses_0++) {
+ char *idx_0=NULL;
+ if (asprintf(&idx_0, "[%d]", cntr_addresses_0) != -1) {
+ ndr_print_nbt_rdata_address(ndr, "addresses", &r->addresses[cntr_addresses_0]);
+ free(idx_0);
+ }
+ }
+ ndr->depth--;
+ ndr->depth--;
+}
+
+static enum ndr_err_code ndr_push_nbt_statistics(struct ndr_push *ndr, int ndr_flags, const struct nbt_statistics *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_push_align(ndr, 4));
+ NDR_CHECK(ndr_push_array_uint8(ndr, NDR_SCALARS, r->unit_id, 6));
+ NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r->jumpers));
+ NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r->test_result));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->version_number));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->period_of_statistics));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->number_of_crcs));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->number_alignment_errors));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->number_of_collisions));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->number_send_aborts));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->number_good_sends));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->number_good_receives));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->number_retransmits));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->number_no_resource_conditions));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->number_free_command_blocks));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->total_number_command_blocks));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->max_total_number_command_blocks));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->number_pending_sessions));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->max_number_pending_sessions));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->max_total_sessions_possible));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->session_data_packet_size));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_nbt_statistics(struct ndr_pull *ndr, int ndr_flags, struct nbt_statistics *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_pull_align(ndr, 4));
+ NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS, r->unit_id, 6));
+ NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->jumpers));
+ NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->test_result));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->version_number));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->period_of_statistics));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->number_of_crcs));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->number_alignment_errors));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->number_of_collisions));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->number_send_aborts));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->number_good_sends));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->number_good_receives));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->number_retransmits));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->number_no_resource_conditions));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->number_free_command_blocks));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->total_number_command_blocks));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->max_total_number_command_blocks));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->number_pending_sessions));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->max_number_pending_sessions));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->max_total_sessions_possible));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->session_data_packet_size));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_nbt_statistics(struct ndr_print *ndr, const char *name, const struct nbt_statistics *r)
+{
+ ndr_print_struct(ndr, name, "nbt_statistics");
+ ndr->depth++;
+ ndr_print_array_uint8(ndr, "unit_id", r->unit_id, 6);
+ ndr_print_uint8(ndr, "jumpers", r->jumpers);
+ ndr_print_uint8(ndr, "test_result", r->test_result);
+ ndr_print_uint16(ndr, "version_number", r->version_number);
+ ndr_print_uint16(ndr, "period_of_statistics", r->period_of_statistics);
+ ndr_print_uint16(ndr, "number_of_crcs", r->number_of_crcs);
+ ndr_print_uint16(ndr, "number_alignment_errors", r->number_alignment_errors);
+ ndr_print_uint16(ndr, "number_of_collisions", r->number_of_collisions);
+ ndr_print_uint16(ndr, "number_send_aborts", r->number_send_aborts);
+ ndr_print_uint32(ndr, "number_good_sends", r->number_good_sends);
+ ndr_print_uint32(ndr, "number_good_receives", r->number_good_receives);
+ ndr_print_uint16(ndr, "number_retransmits", r->number_retransmits);
+ ndr_print_uint16(ndr, "number_no_resource_conditions", r->number_no_resource_conditions);
+ ndr_print_uint16(ndr, "number_free_command_blocks", r->number_free_command_blocks);
+ ndr_print_uint16(ndr, "total_number_command_blocks", r->total_number_command_blocks);
+ ndr_print_uint16(ndr, "max_total_number_command_blocks", r->max_total_number_command_blocks);
+ ndr_print_uint16(ndr, "number_pending_sessions", r->number_pending_sessions);
+ ndr_print_uint16(ndr, "max_number_pending_sessions", r->max_number_pending_sessions);
+ ndr_print_uint16(ndr, "max_total_sessions_possible", r->max_total_sessions_possible);
+ ndr_print_uint16(ndr, "session_data_packet_size", r->session_data_packet_size);
+ ndr->depth--;
+}
+
+static enum ndr_err_code ndr_push_nbt_status_name(struct ndr_push *ndr, int ndr_flags, const struct nbt_status_name *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_push_align(ndr, 2));
+ NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->name, 15, sizeof(uint8_t), CH_DOS));
+ NDR_CHECK(ndr_push_nbt_name_type(ndr, NDR_SCALARS, r->type));
+ NDR_CHECK(ndr_push_nb_flags(ndr, NDR_SCALARS, r->nb_flags));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_nbt_status_name(struct ndr_pull *ndr, int ndr_flags, struct nbt_status_name *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_pull_align(ndr, 2));
+ NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->name, 15, sizeof(uint8_t), CH_DOS));
+ NDR_CHECK(ndr_pull_nbt_name_type(ndr, NDR_SCALARS, &r->type));
+ NDR_CHECK(ndr_pull_nb_flags(ndr, NDR_SCALARS, &r->nb_flags));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_nbt_status_name(struct ndr_print *ndr, const char *name, const struct nbt_status_name *r)
+{
+ ndr_print_struct(ndr, name, "nbt_status_name");
+ ndr->depth++;
+ ndr_print_string(ndr, "name", r->name);
+ ndr_print_nbt_name_type(ndr, "type", r->type);
+ ndr_print_nb_flags(ndr, "nb_flags", r->nb_flags);
+ ndr->depth--;
+}
+
+static enum ndr_err_code ndr_push_nbt_rdata_status(struct ndr_push *ndr, int ndr_flags, const struct nbt_rdata_status *r)
+{
+ uint32_t cntr_names_0;
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_push_align(ndr, 4));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->num_names * 18 + 47));
+ NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r->num_names));
+ for (cntr_names_0 = 0; cntr_names_0 < r->num_names; cntr_names_0++) {
+ NDR_CHECK(ndr_push_nbt_status_name(ndr, NDR_SCALARS, &r->names[cntr_names_0]));
+ }
+ NDR_CHECK(ndr_push_nbt_statistics(ndr, NDR_SCALARS, &r->statistics));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_nbt_rdata_status(struct ndr_pull *ndr, int ndr_flags, struct nbt_rdata_status *r)
+{
+ uint32_t cntr_names_0;
+ TALLOC_CTX *_mem_save_names_0;
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_pull_align(ndr, 4));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->length));
+ NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->num_names));
+ NDR_PULL_ALLOC_N(ndr, r->names, r->num_names);
+ _mem_save_names_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->names, 0);
+ for (cntr_names_0 = 0; cntr_names_0 < r->num_names; cntr_names_0++) {
+ NDR_CHECK(ndr_pull_nbt_status_name(ndr, NDR_SCALARS, &r->names[cntr_names_0]));
+ }
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_names_0, 0);
+ NDR_CHECK(ndr_pull_nbt_statistics(ndr, NDR_SCALARS, &r->statistics));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_nbt_rdata_status(struct ndr_print *ndr, const char *name, const struct nbt_rdata_status *r)
+{
+ uint32_t cntr_names_0;
+ ndr_print_struct(ndr, name, "nbt_rdata_status");
+ ndr->depth++;
+ ndr_print_uint16(ndr, "length", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?r->num_names * 18 + 47:r->length);
+ ndr_print_uint8(ndr, "num_names", r->num_names);
+ ndr->print(ndr, "%s: ARRAY(%d)", "names", r->num_names);
+ ndr->depth++;
+ for (cntr_names_0=0;cntr_names_0<r->num_names;cntr_names_0++) {
+ char *idx_0=NULL;
+ if (asprintf(&idx_0, "[%d]", cntr_names_0) != -1) {
+ ndr_print_nbt_status_name(ndr, "names", &r->names[cntr_names_0]);
+ free(idx_0);
+ }
+ }
+ ndr->depth--;
+ ndr_print_nbt_statistics(ndr, "statistics", &r->statistics);
+ ndr->depth--;
+}
+
+static enum ndr_err_code ndr_push_nbt_rdata_data(struct ndr_push *ndr, int ndr_flags, const struct nbt_rdata_data *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_push_align(ndr, 2));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->length));
+ NDR_CHECK(ndr_push_array_uint8(ndr, NDR_SCALARS, r->data, r->length));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_nbt_rdata_data(struct ndr_pull *ndr, int ndr_flags, struct nbt_rdata_data *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_pull_align(ndr, 2));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->length));
+ NDR_PULL_ALLOC_N(ndr, r->data, r->length);
+ NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS, r->data, r->length));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_nbt_rdata_data(struct ndr_print *ndr, const char *name, const struct nbt_rdata_data *r)
+{
+ ndr_print_struct(ndr, name, "nbt_rdata_data");
+ ndr->depth++;
+ ndr_print_uint16(ndr, "length", r->length);
+ ndr_print_array_uint8(ndr, "data", r->data, r->length);
+ ndr->depth--;
+}
+
+static enum ndr_err_code ndr_push_nbt_rdata(struct ndr_push *ndr, int ndr_flags, const union nbt_rdata *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ int level = ndr_push_get_switch_value(ndr, r);
+ switch (level) {
+ case NBT_QTYPE_NETBIOS: {
+ NDR_CHECK(ndr_push_nbt_rdata_netbios(ndr, NDR_SCALARS, &r->netbios));
+ break; }
+
+ case NBT_QTYPE_STATUS: {
+ NDR_CHECK(ndr_push_nbt_rdata_status(ndr, NDR_SCALARS, &r->status));
+ break; }
+
+ default: {
+ NDR_CHECK(ndr_push_nbt_rdata_data(ndr, NDR_SCALARS, &r->data));
+ break; }
+
+ }
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ int level = ndr_push_get_switch_value(ndr, r);
+ switch (level) {
+ case NBT_QTYPE_NETBIOS:
+ break;
+
+ case NBT_QTYPE_STATUS:
+ break;
+
+ default:
+ break;
+
+ }
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_nbt_rdata(struct ndr_pull *ndr, int ndr_flags, union nbt_rdata *r)
+{
+ int level;
+ level = ndr_pull_get_switch_value(ndr, r);
+ if (ndr_flags & NDR_SCALARS) {
+ switch (level) {
+ case NBT_QTYPE_NETBIOS: {
+ NDR_CHECK(ndr_pull_nbt_rdata_netbios(ndr, NDR_SCALARS, &r->netbios));
+ break; }
+
+ case NBT_QTYPE_STATUS: {
+ NDR_CHECK(ndr_pull_nbt_rdata_status(ndr, NDR_SCALARS, &r->status));
+ break; }
+
+ default: {
+ NDR_CHECK(ndr_pull_nbt_rdata_data(ndr, NDR_SCALARS, &r->data));
+ break; }
+
+ }
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ switch (level) {
+ case NBT_QTYPE_NETBIOS:
+ break;
+
+ case NBT_QTYPE_STATUS:
+ break;
+
+ default:
+ break;
+
+ }
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_nbt_rdata(struct ndr_print *ndr, const char *name, const union nbt_rdata *r)
+{
+ int level;
+ level = ndr_print_get_switch_value(ndr, r);
+ ndr_print_union(ndr, name, level, "nbt_rdata");
+ switch (level) {
+ case NBT_QTYPE_NETBIOS:
+ ndr_print_nbt_rdata_netbios(ndr, "netbios", &r->netbios);
+ break;
+
+ case NBT_QTYPE_STATUS:
+ ndr_print_nbt_rdata_status(ndr, "status", &r->status);
+ break;
+
+ default:
+ ndr_print_nbt_rdata_data(ndr, "data", &r->data);
+ break;
+
+ }
+}
+
+static enum ndr_err_code ndr_push_nbt_res_rec(struct ndr_push *ndr, int ndr_flags, const struct nbt_res_rec *r)
+{
+ {
+ uint32_t _flags_save_STRUCT = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_PRINT_ARRAY_HEX);
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_push_align(ndr, 4));
+ NDR_CHECK(ndr_push_nbt_name(ndr, NDR_SCALARS, &r->name));
+ NDR_CHECK(ndr_push_nbt_qtype(ndr, NDR_SCALARS, r->rr_type));
+ NDR_CHECK(ndr_push_nbt_qclass(ndr, NDR_SCALARS, r->rr_class));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->ttl));
+ NDR_CHECK(ndr_push_set_switch_value(ndr, &r->rdata, ((((r->rr_type) == NBT_QTYPE_NETBIOS) && talloc_check_name(ndr, "struct ndr_push") && ((r->rdata).data.length == 2))?0:r->rr_type)));
+ NDR_CHECK(ndr_push_nbt_rdata(ndr, NDR_SCALARS, &r->rdata));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ ndr->flags = _flags_save_STRUCT;
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_nbt_res_rec(struct ndr_pull *ndr, int ndr_flags, struct nbt_res_rec *r)
+{
+ {
+ uint32_t _flags_save_STRUCT = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_PRINT_ARRAY_HEX);
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_pull_align(ndr, 4));
+ NDR_CHECK(ndr_pull_nbt_name(ndr, NDR_SCALARS, &r->name));
+ NDR_CHECK(ndr_pull_nbt_qtype(ndr, NDR_SCALARS, &r->rr_type));
+ NDR_CHECK(ndr_pull_nbt_qclass(ndr, NDR_SCALARS, &r->rr_class));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->ttl));
+ NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->rdata, ((((r->rr_type) == NBT_QTYPE_NETBIOS) && talloc_check_name(ndr, "struct ndr_push") && ((r->rdata).data.length == 2))?0:r->rr_type)));
+ NDR_CHECK(ndr_pull_nbt_rdata(ndr, NDR_SCALARS, &r->rdata));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ ndr->flags = _flags_save_STRUCT;
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_nbt_res_rec(struct ndr_print *ndr, const char *name, const struct nbt_res_rec *r)
+{
+ ndr_print_struct(ndr, name, "nbt_res_rec");
+ {
+ uint32_t _flags_save_STRUCT = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_PRINT_ARRAY_HEX);
+ ndr->depth++;
+ ndr_print_nbt_name(ndr, "name", &r->name);
+ ndr_print_nbt_qtype(ndr, "rr_type", r->rr_type);
+ ndr_print_nbt_qclass(ndr, "rr_class", r->rr_class);
+ ndr_print_uint32(ndr, "ttl", r->ttl);
+ ndr_print_set_switch_value(ndr, &r->rdata, ((((r->rr_type) == NBT_QTYPE_NETBIOS) && talloc_check_name(ndr, "struct ndr_push") && ((r->rdata).data.length == 2))?0:r->rr_type));
+ ndr_print_nbt_rdata(ndr, "rdata", &r->rdata);
+ ndr->depth--;
+ ndr->flags = _flags_save_STRUCT;
+ }
+}
+
+_PUBLIC_ enum ndr_err_code ndr_push_nbt_name_packet(struct ndr_push *ndr, int ndr_flags, const struct nbt_name_packet *r)
+{
+ uint32_t cntr_questions_0;
+ uint32_t cntr_answers_0;
+ uint32_t cntr_nsrecs_0;
+ uint32_t cntr_additional_0;
+ {
+ uint32_t _flags_save_STRUCT = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN|LIBNDR_FLAG_BIGENDIAN|LIBNDR_PRINT_ARRAY_HEX);
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_push_align(ndr, 4));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->name_trn_id));
+ NDR_CHECK(ndr_push_nbt_operation(ndr, NDR_SCALARS, r->operation));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->qdcount));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->ancount));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->nscount));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->arcount));
+ for (cntr_questions_0 = 0; cntr_questions_0 < r->qdcount; cntr_questions_0++) {
+ NDR_CHECK(ndr_push_nbt_name_question(ndr, NDR_SCALARS, &r->questions[cntr_questions_0]));
+ }
+ for (cntr_answers_0 = 0; cntr_answers_0 < r->ancount; cntr_answers_0++) {
+ NDR_CHECK(ndr_push_nbt_res_rec(ndr, NDR_SCALARS, &r->answers[cntr_answers_0]));
+ }
+ for (cntr_nsrecs_0 = 0; cntr_nsrecs_0 < r->nscount; cntr_nsrecs_0++) {
+ NDR_CHECK(ndr_push_nbt_res_rec(ndr, NDR_SCALARS, &r->nsrecs[cntr_nsrecs_0]));
+ }
+ for (cntr_additional_0 = 0; cntr_additional_0 < r->arcount; cntr_additional_0++) {
+ NDR_CHECK(ndr_push_nbt_res_rec(ndr, NDR_SCALARS, &r->additional[cntr_additional_0]));
+ }
+ {
+ uint32_t _flags_save_DATA_BLOB = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_REMAINING);
+ NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, r->padding));
+ ndr->flags = _flags_save_DATA_BLOB;
+ }
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ ndr->flags = _flags_save_STRUCT;
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ enum ndr_err_code ndr_pull_nbt_name_packet(struct ndr_pull *ndr, int ndr_flags, struct nbt_name_packet *r)
+{
+ uint32_t cntr_questions_0;
+ TALLOC_CTX *_mem_save_questions_0;
+ uint32_t cntr_answers_0;
+ TALLOC_CTX *_mem_save_answers_0;
+ uint32_t cntr_nsrecs_0;
+ TALLOC_CTX *_mem_save_nsrecs_0;
+ uint32_t cntr_additional_0;
+ TALLOC_CTX *_mem_save_additional_0;
+ {
+ uint32_t _flags_save_STRUCT = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN|LIBNDR_FLAG_BIGENDIAN|LIBNDR_PRINT_ARRAY_HEX);
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_pull_align(ndr, 4));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->name_trn_id));
+ NDR_CHECK(ndr_pull_nbt_operation(ndr, NDR_SCALARS, &r->operation));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->qdcount));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->ancount));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->nscount));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->arcount));
+ NDR_PULL_ALLOC_N(ndr, r->questions, r->qdcount);
+ _mem_save_questions_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->questions, 0);
+ for (cntr_questions_0 = 0; cntr_questions_0 < r->qdcount; cntr_questions_0++) {
+ NDR_CHECK(ndr_pull_nbt_name_question(ndr, NDR_SCALARS, &r->questions[cntr_questions_0]));
+ }
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_questions_0, 0);
+ NDR_PULL_ALLOC_N(ndr, r->answers, r->ancount);
+ _mem_save_answers_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->answers, 0);
+ for (cntr_answers_0 = 0; cntr_answers_0 < r->ancount; cntr_answers_0++) {
+ NDR_CHECK(ndr_pull_nbt_res_rec(ndr, NDR_SCALARS, &r->answers[cntr_answers_0]));
+ }
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_answers_0, 0);
+ NDR_PULL_ALLOC_N(ndr, r->nsrecs, r->nscount);
+ _mem_save_nsrecs_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->nsrecs, 0);
+ for (cntr_nsrecs_0 = 0; cntr_nsrecs_0 < r->nscount; cntr_nsrecs_0++) {
+ NDR_CHECK(ndr_pull_nbt_res_rec(ndr, NDR_SCALARS, &r->nsrecs[cntr_nsrecs_0]));
+ }
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_nsrecs_0, 0);
+ NDR_PULL_ALLOC_N(ndr, r->additional, r->arcount);
+ _mem_save_additional_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->additional, 0);
+ for (cntr_additional_0 = 0; cntr_additional_0 < r->arcount; cntr_additional_0++) {
+ NDR_CHECK(ndr_pull_nbt_res_rec(ndr, NDR_SCALARS, &r->additional[cntr_additional_0]));
+ }
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_additional_0, 0);
+ {
+ uint32_t _flags_save_DATA_BLOB = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_REMAINING);
+ NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, &r->padding));
+ ndr->flags = _flags_save_DATA_BLOB;
+ }
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ ndr->flags = _flags_save_STRUCT;
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_nbt_name_packet(struct ndr_print *ndr, const char *name, const struct nbt_name_packet *r)
+{
+ uint32_t cntr_questions_0;
+ uint32_t cntr_answers_0;
+ uint32_t cntr_nsrecs_0;
+ uint32_t cntr_additional_0;
+ ndr_print_struct(ndr, name, "nbt_name_packet");
+ {
+ uint32_t _flags_save_STRUCT = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN|LIBNDR_FLAG_BIGENDIAN|LIBNDR_PRINT_ARRAY_HEX);
+ ndr->depth++;
+ ndr_print_uint16(ndr, "name_trn_id", r->name_trn_id);
+ ndr_print_nbt_operation(ndr, "operation", r->operation);
+ ndr_print_uint16(ndr, "qdcount", r->qdcount);
+ ndr_print_uint16(ndr, "ancount", r->ancount);
+ ndr_print_uint16(ndr, "nscount", r->nscount);
+ ndr_print_uint16(ndr, "arcount", r->arcount);
+ ndr->print(ndr, "%s: ARRAY(%d)", "questions", r->qdcount);
+ ndr->depth++;
+ for (cntr_questions_0=0;cntr_questions_0<r->qdcount;cntr_questions_0++) {
+ char *idx_0=NULL;
+ if (asprintf(&idx_0, "[%d]", cntr_questions_0) != -1) {
+ ndr_print_nbt_name_question(ndr, "questions", &r->questions[cntr_questions_0]);
+ free(idx_0);
+ }
+ }
+ ndr->depth--;
+ ndr->print(ndr, "%s: ARRAY(%d)", "answers", r->ancount);
+ ndr->depth++;
+ for (cntr_answers_0=0;cntr_answers_0<r->ancount;cntr_answers_0++) {
+ char *idx_0=NULL;
+ if (asprintf(&idx_0, "[%d]", cntr_answers_0) != -1) {
+ ndr_print_nbt_res_rec(ndr, "answers", &r->answers[cntr_answers_0]);
+ free(idx_0);
+ }
+ }
+ ndr->depth--;
+ ndr->print(ndr, "%s: ARRAY(%d)", "nsrecs", r->nscount);
+ ndr->depth++;
+ for (cntr_nsrecs_0=0;cntr_nsrecs_0<r->nscount;cntr_nsrecs_0++) {
+ char *idx_0=NULL;
+ if (asprintf(&idx_0, "[%d]", cntr_nsrecs_0) != -1) {
+ ndr_print_nbt_res_rec(ndr, "nsrecs", &r->nsrecs[cntr_nsrecs_0]);
+ free(idx_0);
+ }
+ }
+ ndr->depth--;
+ ndr->print(ndr, "%s: ARRAY(%d)", "additional", r->arcount);
+ ndr->depth++;
+ for (cntr_additional_0=0;cntr_additional_0<r->arcount;cntr_additional_0++) {
+ char *idx_0=NULL;
+ if (asprintf(&idx_0, "[%d]", cntr_additional_0) != -1) {
+ ndr_print_nbt_res_rec(ndr, "additional", &r->additional[cntr_additional_0]);
+ free(idx_0);
+ }
+ }
+ ndr->depth--;
+ ndr_print_DATA_BLOB(ndr, "padding", r->padding);
+ ndr->depth--;
+ ndr->flags = _flags_save_STRUCT;
+ }
+}
+
+static enum ndr_err_code ndr_push_dgram_msg_type(struct ndr_push *ndr, int ndr_flags, enum dgram_msg_type r)
+{
+ NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r));
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_dgram_msg_type(struct ndr_pull *ndr, int ndr_flags, enum dgram_msg_type *r)
+{
+ uint8_t v;
+ NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &v));
+ *r = v;
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_dgram_msg_type(struct ndr_print *ndr, const char *name, enum dgram_msg_type r)
+{
+ const char *val = NULL;
+
+ switch (r) {
+ case DGRAM_DIRECT_UNIQUE: val = "DGRAM_DIRECT_UNIQUE"; break;
+ case DGRAM_DIRECT_GROUP: val = "DGRAM_DIRECT_GROUP"; break;
+ case DGRAM_BCAST: val = "DGRAM_BCAST"; break;
+ case DGRAM_ERROR: val = "DGRAM_ERROR"; break;
+ case DGRAM_QUERY: val = "DGRAM_QUERY"; break;
+ case DGRAM_QUERY_POSITIVE: val = "DGRAM_QUERY_POSITIVE"; break;
+ case DGRAM_QUERY_NEGATIVE: val = "DGRAM_QUERY_NEGATIVE"; break;
+ }
+ ndr_print_enum(ndr, name, "ENUM", val, r);
+}
+
+static enum ndr_err_code ndr_push_dgram_flags(struct ndr_push *ndr, int ndr_flags, uint8_t r)
+{
+ NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r));
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_dgram_flags(struct ndr_pull *ndr, int ndr_flags, uint8_t *r)
+{
+ uint8_t v;
+ NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &v));
+ *r = v;
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_dgram_flags(struct ndr_print *ndr, const char *name, uint8_t r)
+{
+ ndr_print_uint8(ndr, name, r);
+ ndr->depth++;
+ ndr_print_bitmap_flag(ndr, sizeof(uint8_t), "DGRAM_FLAG_MORE", DGRAM_FLAG_MORE, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint8_t), "DGRAM_FLAG_FIRST", DGRAM_FLAG_FIRST, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint8_t), "DGRAM_FLAG_NODE_TYPE", DGRAM_FLAG_NODE_TYPE, r);
+ ndr->depth--;
+}
+
+static enum ndr_err_code ndr_push_smb_command(struct ndr_push *ndr, int ndr_flags, enum smb_command r)
+{
+ NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r));
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_smb_command(struct ndr_pull *ndr, int ndr_flags, enum smb_command *r)
+{
+ uint8_t v;
+ NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &v));
+ *r = v;
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_smb_command(struct ndr_print *ndr, const char *name, enum smb_command r)
+{
+ const char *val = NULL;
+
+ switch (r) {
+ case SMB_TRANSACTION: val = "SMB_TRANSACTION"; break;
+ }
+ ndr_print_enum(ndr, name, "ENUM", val, r);
+}
+
+static enum ndr_err_code ndr_push_smb_trans_body(struct ndr_push *ndr, int ndr_flags, const struct smb_trans_body *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_push_align(ndr, 4));
+ NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, 17));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->total_param_count));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->total_data_count));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->max_param_count));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->max_data_count));
+ NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r->max_setup_count));
+ NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r->pad));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->trans_flags));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->timeout));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->reserved));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->param_count));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->param_offset));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->data_count));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->data_offset));
+ NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, 3));
+ NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r->pad2));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->opcode));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->priority));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->_class));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, strlen(r->mailslot_name) + 1 + r->data.length));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->mailslot_name));
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_DATA_BLOB = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_REMAINING);
+ NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, r->data));
+ ndr->flags = _flags_save_DATA_BLOB;
+ }
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_smb_trans_body(struct ndr_pull *ndr, int ndr_flags, struct smb_trans_body *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_pull_align(ndr, 4));
+ NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->wct));
+ if (r->wct < 17 || r->wct > 17) {
+ return ndr_pull_error(ndr, NDR_ERR_RANGE, "value out of range");
+ }
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->total_param_count));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->total_data_count));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->max_param_count));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->max_data_count));
+ NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->max_setup_count));
+ NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->pad));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->trans_flags));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->timeout));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->reserved));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->param_count));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->param_offset));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->data_count));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->data_offset));
+ NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->setup_count));
+ if (r->setup_count < 3 || r->setup_count > 3) {
+ return ndr_pull_error(ndr, NDR_ERR_RANGE, "value out of range");
+ }
+ NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->pad2));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->opcode));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->priority));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->_class));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->byte_count));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->mailslot_name));
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_DATA_BLOB = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_REMAINING);
+ NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, &r->data));
+ ndr->flags = _flags_save_DATA_BLOB;
+ }
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_smb_trans_body(struct ndr_print *ndr, const char *name, const struct smb_trans_body *r)
+{
+ ndr_print_struct(ndr, name, "smb_trans_body");
+ ndr->depth++;
+ ndr_print_uint8(ndr, "wct", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?17:r->wct);
+ ndr_print_uint16(ndr, "total_param_count", r->total_param_count);
+ ndr_print_uint16(ndr, "total_data_count", r->total_data_count);
+ ndr_print_uint16(ndr, "max_param_count", r->max_param_count);
+ ndr_print_uint16(ndr, "max_data_count", r->max_data_count);
+ ndr_print_uint8(ndr, "max_setup_count", r->max_setup_count);
+ ndr_print_uint8(ndr, "pad", r->pad);
+ ndr_print_uint16(ndr, "trans_flags", r->trans_flags);
+ ndr_print_uint32(ndr, "timeout", r->timeout);
+ ndr_print_uint16(ndr, "reserved", r->reserved);
+ ndr_print_uint16(ndr, "param_count", r->param_count);
+ ndr_print_uint16(ndr, "param_offset", r->param_offset);
+ ndr_print_uint16(ndr, "data_count", r->data_count);
+ ndr_print_uint16(ndr, "data_offset", r->data_offset);
+ ndr_print_uint8(ndr, "setup_count", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?3:r->setup_count);
+ ndr_print_uint8(ndr, "pad2", r->pad2);
+ ndr_print_uint16(ndr, "opcode", r->opcode);
+ ndr_print_uint16(ndr, "priority", r->priority);
+ ndr_print_uint16(ndr, "_class", r->_class);
+ ndr_print_uint16(ndr, "byte_count", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?strlen(r->mailslot_name) + 1 + r->data.length:r->byte_count);
+ ndr_print_string(ndr, "mailslot_name", r->mailslot_name);
+ ndr_print_DATA_BLOB(ndr, "data", r->data);
+ ndr->depth--;
+}
+
+static enum ndr_err_code ndr_push_smb_body(struct ndr_push *ndr, int ndr_flags, const union smb_body *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ int level = ndr_push_get_switch_value(ndr, r);
+ switch (level) {
+ case SMB_TRANSACTION: {
+ NDR_CHECK(ndr_push_smb_trans_body(ndr, NDR_SCALARS, &r->trans));
+ break; }
+
+ default:
+ return ndr_push_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level);
+ }
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ int level = ndr_push_get_switch_value(ndr, r);
+ switch (level) {
+ case SMB_TRANSACTION:
+ break;
+
+ default:
+ return ndr_push_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level);
+ }
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_smb_body(struct ndr_pull *ndr, int ndr_flags, union smb_body *r)
+{
+ int level;
+ level = ndr_pull_get_switch_value(ndr, r);
+ if (ndr_flags & NDR_SCALARS) {
+ switch (level) {
+ case SMB_TRANSACTION: {
+ NDR_CHECK(ndr_pull_smb_trans_body(ndr, NDR_SCALARS, &r->trans));
+ break; }
+
+ default:
+ return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level);
+ }
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ switch (level) {
+ case SMB_TRANSACTION:
+ break;
+
+ default:
+ return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level);
+ }
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_smb_body(struct ndr_print *ndr, const char *name, const union smb_body *r)
+{
+ int level;
+ level = ndr_print_get_switch_value(ndr, r);
+ ndr_print_union(ndr, name, level, "smb_body");
+ switch (level) {
+ case SMB_TRANSACTION:
+ ndr_print_smb_trans_body(ndr, "trans", &r->trans);
+ break;
+
+ default:
+ ndr_print_bad_level(ndr, name, level);
+ }
+}
+
+_PUBLIC_ enum ndr_err_code ndr_push_dgram_smb_packet(struct ndr_push *ndr, int ndr_flags, const struct dgram_smb_packet *r)
+{
+ {
+ uint32_t _flags_save_STRUCT = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN|LIBNDR_FLAG_LITTLE_ENDIAN|LIBNDR_PRINT_ARRAY_HEX);
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_push_align(ndr, 4));
+ NDR_CHECK(ndr_push_smb_command(ndr, NDR_SCALARS, r->smb_command));
+ NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r->err_class));
+ NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r->pad));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->err_code));
+ NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r->flags));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->flags2));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->pid_high));
+ NDR_CHECK(ndr_push_array_uint8(ndr, NDR_SCALARS, r->signature, 8));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->reserved));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->tid));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->pid));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->vuid));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->mid));
+ NDR_CHECK(ndr_push_set_switch_value(ndr, &r->body, r->smb_command));
+ NDR_CHECK(ndr_push_smb_body(ndr, NDR_SCALARS, &r->body));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ ndr->flags = _flags_save_STRUCT;
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ enum ndr_err_code ndr_pull_dgram_smb_packet(struct ndr_pull *ndr, int ndr_flags, struct dgram_smb_packet *r)
+{
+ {
+ uint32_t _flags_save_STRUCT = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN|LIBNDR_FLAG_LITTLE_ENDIAN|LIBNDR_PRINT_ARRAY_HEX);
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_pull_align(ndr, 4));
+ NDR_CHECK(ndr_pull_smb_command(ndr, NDR_SCALARS, &r->smb_command));
+ NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->err_class));
+ NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->pad));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->err_code));
+ NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->flags));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->flags2));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->pid_high));
+ NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS, r->signature, 8));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->reserved));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->tid));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->pid));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->vuid));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->mid));
+ NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->body, r->smb_command));
+ NDR_CHECK(ndr_pull_smb_body(ndr, NDR_SCALARS, &r->body));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ ndr->flags = _flags_save_STRUCT;
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_dgram_smb_packet(struct ndr_print *ndr, const char *name, const struct dgram_smb_packet *r)
+{
+ ndr_print_struct(ndr, name, "dgram_smb_packet");
+ {
+ uint32_t _flags_save_STRUCT = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN|LIBNDR_FLAG_LITTLE_ENDIAN|LIBNDR_PRINT_ARRAY_HEX);
+ ndr->depth++;
+ ndr_print_smb_command(ndr, "smb_command", r->smb_command);
+ ndr_print_uint8(ndr, "err_class", r->err_class);
+ ndr_print_uint8(ndr, "pad", r->pad);
+ ndr_print_uint16(ndr, "err_code", r->err_code);
+ ndr_print_uint8(ndr, "flags", r->flags);
+ ndr_print_uint16(ndr, "flags2", r->flags2);
+ ndr_print_uint16(ndr, "pid_high", r->pid_high);
+ ndr_print_array_uint8(ndr, "signature", r->signature, 8);
+ ndr_print_uint16(ndr, "reserved", r->reserved);
+ ndr_print_uint16(ndr, "tid", r->tid);
+ ndr_print_uint16(ndr, "pid", r->pid);
+ ndr_print_uint16(ndr, "vuid", r->vuid);
+ ndr_print_uint16(ndr, "mid", r->mid);
+ ndr_print_set_switch_value(ndr, &r->body, r->smb_command);
+ ndr_print_smb_body(ndr, "body", &r->body);
+ ndr->depth--;
+ ndr->flags = _flags_save_STRUCT;
+ }
+}
+
+static enum ndr_err_code ndr_push_dgram_message_body(struct ndr_push *ndr, int ndr_flags, const union dgram_message_body *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ int level = ndr_push_get_switch_value(ndr, r);
+ switch (level) {
+ case DGRAM_SMB: {
+ NDR_CHECK(ndr_push_dgram_smb_packet(ndr, NDR_SCALARS, &r->smb));
+ break; }
+
+ default:
+ return ndr_push_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level);
+ }
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ int level = ndr_push_get_switch_value(ndr, r);
+ switch (level) {
+ case DGRAM_SMB:
+ break;
+
+ default:
+ return ndr_push_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level);
+ }
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_dgram_message_body(struct ndr_pull *ndr, int ndr_flags, union dgram_message_body *r)
+{
+ int level;
+ level = ndr_pull_get_switch_value(ndr, r);
+ if (ndr_flags & NDR_SCALARS) {
+ switch (level) {
+ case DGRAM_SMB: {
+ NDR_CHECK(ndr_pull_dgram_smb_packet(ndr, NDR_SCALARS, &r->smb));
+ break; }
+
+ default:
+ return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level);
+ }
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ switch (level) {
+ case DGRAM_SMB:
+ break;
+
+ default:
+ return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level);
+ }
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_dgram_message_body(struct ndr_print *ndr, const char *name, const union dgram_message_body *r)
+{
+ int level;
+ level = ndr_print_get_switch_value(ndr, r);
+ ndr_print_union(ndr, name, level, "dgram_message_body");
+ switch (level) {
+ case DGRAM_SMB:
+ ndr_print_dgram_smb_packet(ndr, "smb", &r->smb);
+ break;
+
+ default:
+ ndr_print_bad_level(ndr, name, level);
+ }
+}
+
+static enum ndr_err_code ndr_push_dgram_message(struct ndr_push *ndr, int ndr_flags, const struct dgram_message *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_push_align(ndr, 4));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->length));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->offset));
+ NDR_CHECK(ndr_push_nbt_name(ndr, NDR_SCALARS, &r->source_name));
+ NDR_CHECK(ndr_push_nbt_name(ndr, NDR_SCALARS, &r->dest_name));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->dgram_body_type));
+ NDR_CHECK(ndr_push_set_switch_value(ndr, &r->body, r->dgram_body_type));
+ NDR_CHECK(ndr_push_dgram_message_body(ndr, NDR_SCALARS, &r->body));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_dgram_message(struct ndr_pull *ndr, int ndr_flags, struct dgram_message *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_pull_align(ndr, 4));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->length));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->offset));
+ NDR_CHECK(ndr_pull_nbt_name(ndr, NDR_SCALARS, &r->source_name));
+ NDR_CHECK(ndr_pull_nbt_name(ndr, NDR_SCALARS, &r->dest_name));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->dgram_body_type));
+ NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->body, r->dgram_body_type));
+ NDR_CHECK(ndr_pull_dgram_message_body(ndr, NDR_SCALARS, &r->body));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_dgram_message(struct ndr_print *ndr, const char *name, const struct dgram_message *r)
+{
+ ndr_print_struct(ndr, name, "dgram_message");
+ ndr->depth++;
+ ndr_print_uint16(ndr, "length", r->length);
+ ndr_print_uint16(ndr, "offset", r->offset);
+ ndr_print_nbt_name(ndr, "source_name", &r->source_name);
+ ndr_print_nbt_name(ndr, "dest_name", &r->dest_name);
+ ndr_print_uint32(ndr, "dgram_body_type", r->dgram_body_type);
+ ndr_print_set_switch_value(ndr, &r->body, r->dgram_body_type);
+ ndr_print_dgram_message_body(ndr, "body", &r->body);
+ ndr->depth--;
+}
+
+static enum ndr_err_code ndr_push_dgram_err_code(struct ndr_push *ndr, int ndr_flags, enum dgram_err_code r)
+{
+ NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r));
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_dgram_err_code(struct ndr_pull *ndr, int ndr_flags, enum dgram_err_code *r)
+{
+ uint8_t v;
+ NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &v));
+ *r = v;
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_dgram_err_code(struct ndr_print *ndr, const char *name, enum dgram_err_code r)
+{
+ const char *val = NULL;
+
+ switch (r) {
+ case DGRAM_ERROR_NAME_NOT_PRESENT: val = "DGRAM_ERROR_NAME_NOT_PRESENT"; break;
+ case DGRAM_ERROR_INVALID_SOURCE: val = "DGRAM_ERROR_INVALID_SOURCE"; break;
+ case DGRAM_ERROR_INVALID_DEST: val = "DGRAM_ERROR_INVALID_DEST"; break;
+ }
+ ndr_print_enum(ndr, name, "ENUM", val, r);
+}
+
+static enum ndr_err_code ndr_push_dgram_data(struct ndr_push *ndr, int ndr_flags, const union dgram_data *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ int level = ndr_push_get_switch_value(ndr, r);
+ switch (level) {
+ case DGRAM_DIRECT_UNIQUE: {
+ NDR_CHECK(ndr_push_dgram_message(ndr, NDR_SCALARS, &r->msg));
+ break; }
+
+ case DGRAM_DIRECT_GROUP: {
+ NDR_CHECK(ndr_push_dgram_message(ndr, NDR_SCALARS, &r->msg));
+ break; }
+
+ case DGRAM_BCAST: {
+ NDR_CHECK(ndr_push_dgram_message(ndr, NDR_SCALARS, &r->msg));
+ break; }
+
+ case DGRAM_ERROR: {
+ NDR_CHECK(ndr_push_dgram_err_code(ndr, NDR_SCALARS, r->error));
+ break; }
+
+ case DGRAM_QUERY: {
+ NDR_CHECK(ndr_push_nbt_name(ndr, NDR_SCALARS, &r->dest_name));
+ break; }
+
+ case DGRAM_QUERY_POSITIVE: {
+ NDR_CHECK(ndr_push_nbt_name(ndr, NDR_SCALARS, &r->dest_name));
+ break; }
+
+ case DGRAM_QUERY_NEGATIVE: {
+ NDR_CHECK(ndr_push_nbt_name(ndr, NDR_SCALARS, &r->dest_name));
+ break; }
+
+ default:
+ return ndr_push_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level);
+ }
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ int level = ndr_push_get_switch_value(ndr, r);
+ switch (level) {
+ case DGRAM_DIRECT_UNIQUE:
+ break;
+
+ case DGRAM_DIRECT_GROUP:
+ break;
+
+ case DGRAM_BCAST:
+ break;
+
+ case DGRAM_ERROR:
+ break;
+
+ case DGRAM_QUERY:
+ break;
+
+ case DGRAM_QUERY_POSITIVE:
+ break;
+
+ case DGRAM_QUERY_NEGATIVE:
+ break;
+
+ default:
+ return ndr_push_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level);
+ }
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_dgram_data(struct ndr_pull *ndr, int ndr_flags, union dgram_data *r)
+{
+ int level;
+ level = ndr_pull_get_switch_value(ndr, r);
+ if (ndr_flags & NDR_SCALARS) {
+ switch (level) {
+ case DGRAM_DIRECT_UNIQUE: {
+ NDR_CHECK(ndr_pull_dgram_message(ndr, NDR_SCALARS, &r->msg));
+ break; }
+
+ case DGRAM_DIRECT_GROUP: {
+ NDR_CHECK(ndr_pull_dgram_message(ndr, NDR_SCALARS, &r->msg));
+ break; }
+
+ case DGRAM_BCAST: {
+ NDR_CHECK(ndr_pull_dgram_message(ndr, NDR_SCALARS, &r->msg));
+ break; }
+
+ case DGRAM_ERROR: {
+ NDR_CHECK(ndr_pull_dgram_err_code(ndr, NDR_SCALARS, &r->error));
+ break; }
+
+ case DGRAM_QUERY: {
+ NDR_CHECK(ndr_pull_nbt_name(ndr, NDR_SCALARS, &r->dest_name));
+ break; }
+
+ case DGRAM_QUERY_POSITIVE: {
+ NDR_CHECK(ndr_pull_nbt_name(ndr, NDR_SCALARS, &r->dest_name));
+ break; }
+
+ case DGRAM_QUERY_NEGATIVE: {
+ NDR_CHECK(ndr_pull_nbt_name(ndr, NDR_SCALARS, &r->dest_name));
+ break; }
+
+ default:
+ return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level);
+ }
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ switch (level) {
+ case DGRAM_DIRECT_UNIQUE:
+ break;
+
+ case DGRAM_DIRECT_GROUP:
+ break;
+
+ case DGRAM_BCAST:
+ break;
+
+ case DGRAM_ERROR:
+ break;
+
+ case DGRAM_QUERY:
+ break;
+
+ case DGRAM_QUERY_POSITIVE:
+ break;
+
+ case DGRAM_QUERY_NEGATIVE:
+ break;
+
+ default:
+ return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level);
+ }
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_dgram_data(struct ndr_print *ndr, const char *name, const union dgram_data *r)
+{
+ int level;
+ level = ndr_print_get_switch_value(ndr, r);
+ ndr_print_union(ndr, name, level, "dgram_data");
+ switch (level) {
+ case DGRAM_DIRECT_UNIQUE:
+ ndr_print_dgram_message(ndr, "msg", &r->msg);
+ break;
+
+ case DGRAM_DIRECT_GROUP:
+ ndr_print_dgram_message(ndr, "msg", &r->msg);
+ break;
+
+ case DGRAM_BCAST:
+ ndr_print_dgram_message(ndr, "msg", &r->msg);
+ break;
+
+ case DGRAM_ERROR:
+ ndr_print_dgram_err_code(ndr, "error", r->error);
+ break;
+
+ case DGRAM_QUERY:
+ ndr_print_nbt_name(ndr, "dest_name", &r->dest_name);
+ break;
+
+ case DGRAM_QUERY_POSITIVE:
+ ndr_print_nbt_name(ndr, "dest_name", &r->dest_name);
+ break;
+
+ case DGRAM_QUERY_NEGATIVE:
+ ndr_print_nbt_name(ndr, "dest_name", &r->dest_name);
+ break;
+
+ default:
+ ndr_print_bad_level(ndr, name, level);
+ }
+}
+
+_PUBLIC_ enum ndr_err_code ndr_push_nbt_dgram_packet(struct ndr_push *ndr, int ndr_flags, const struct nbt_dgram_packet *r)
+{
+ {
+ uint32_t _flags_save_STRUCT = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN|LIBNDR_FLAG_BIGENDIAN|LIBNDR_PRINT_ARRAY_HEX);
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_push_align(ndr, 4));
+ NDR_CHECK(ndr_push_dgram_msg_type(ndr, NDR_SCALARS, r->msg_type));
+ NDR_CHECK(ndr_push_dgram_flags(ndr, NDR_SCALARS, r->flags));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->dgram_id));
+ NDR_CHECK(ndr_push_ipv4address(ndr, NDR_SCALARS, r->src_addr));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->src_port));
+ NDR_CHECK(ndr_push_set_switch_value(ndr, &r->data, r->msg_type));
+ NDR_CHECK(ndr_push_dgram_data(ndr, NDR_SCALARS, &r->data));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ ndr->flags = _flags_save_STRUCT;
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ enum ndr_err_code ndr_pull_nbt_dgram_packet(struct ndr_pull *ndr, int ndr_flags, struct nbt_dgram_packet *r)
+{
+ {
+ uint32_t _flags_save_STRUCT = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN|LIBNDR_FLAG_BIGENDIAN|LIBNDR_PRINT_ARRAY_HEX);
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_pull_align(ndr, 4));
+ NDR_CHECK(ndr_pull_dgram_msg_type(ndr, NDR_SCALARS, &r->msg_type));
+ NDR_CHECK(ndr_pull_dgram_flags(ndr, NDR_SCALARS, &r->flags));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->dgram_id));
+ NDR_CHECK(ndr_pull_ipv4address(ndr, NDR_SCALARS, &r->src_addr));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->src_port));
+ NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->data, r->msg_type));
+ NDR_CHECK(ndr_pull_dgram_data(ndr, NDR_SCALARS, &r->data));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ ndr->flags = _flags_save_STRUCT;
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_nbt_dgram_packet(struct ndr_print *ndr, const char *name, const struct nbt_dgram_packet *r)
+{
+ ndr_print_struct(ndr, name, "nbt_dgram_packet");
+ {
+ uint32_t _flags_save_STRUCT = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN|LIBNDR_FLAG_BIGENDIAN|LIBNDR_PRINT_ARRAY_HEX);
+ ndr->depth++;
+ ndr_print_dgram_msg_type(ndr, "msg_type", r->msg_type);
+ ndr_print_dgram_flags(ndr, "flags", r->flags);
+ ndr_print_uint16(ndr, "dgram_id", r->dgram_id);
+ ndr_print_ipv4address(ndr, "src_addr", r->src_addr);
+ ndr_print_uint16(ndr, "src_port", r->src_port);
+ ndr_print_set_switch_value(ndr, &r->data, r->msg_type);
+ ndr_print_dgram_data(ndr, "data", &r->data);
+ ndr->depth--;
+ ndr->flags = _flags_save_STRUCT;
+ }
+}
+
+static enum ndr_err_code ndr_push_nbt_netlogon_command(struct ndr_push *ndr, int ndr_flags, enum nbt_netlogon_command r)
+{
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r));
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_nbt_netlogon_command(struct ndr_pull *ndr, int ndr_flags, enum nbt_netlogon_command *r)
+{
+ uint16_t v;
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &v));
+ *r = v;
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_nbt_netlogon_command(struct ndr_print *ndr, const char *name, enum nbt_netlogon_command r)
+{
+ const char *val = NULL;
+
+ switch (r) {
+ case NETLOGON_QUERY_FOR_PDC: val = "NETLOGON_QUERY_FOR_PDC"; break;
+ case NETLOGON_ANNOUNCE_UAS: val = "NETLOGON_ANNOUNCE_UAS"; break;
+ case NETLOGON_RESPONSE_FROM_PDC: val = "NETLOGON_RESPONSE_FROM_PDC"; break;
+ case NETLOGON_QUERY_FOR_PDC2: val = "NETLOGON_QUERY_FOR_PDC2"; break;
+ case NETLOGON_RESPONSE_FROM_PDC2: val = "NETLOGON_RESPONSE_FROM_PDC2"; break;
+ case NETLOGON_RESPONSE_FROM_PDC_USER: val = "NETLOGON_RESPONSE_FROM_PDC_USER"; break;
+ }
+ ndr_print_enum(ndr, name, "ENUM", val, r);
+}
+
+static enum ndr_err_code ndr_push_nbt_netlogon_query_for_pdc(struct ndr_push *ndr, int ndr_flags, const struct nbt_netlogon_query_for_pdc *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_push_align(ndr, 4));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->computer_name));
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->mailslot_name));
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_DATA_BLOB = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN2);
+ NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, r->_pad));
+ ndr->flags = _flags_save_DATA_BLOB;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->unicode_name));
+ ndr->flags = _flags_save_string;
+ }
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->nt_version));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lmnt_token));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lm20_token));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_nbt_netlogon_query_for_pdc(struct ndr_pull *ndr, int ndr_flags, struct nbt_netlogon_query_for_pdc *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_pull_align(ndr, 4));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->computer_name));
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->mailslot_name));
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_DATA_BLOB = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN2);
+ NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, &r->_pad));
+ ndr->flags = _flags_save_DATA_BLOB;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->unicode_name));
+ ndr->flags = _flags_save_string;
+ }
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->nt_version));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lmnt_token));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lm20_token));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_nbt_netlogon_query_for_pdc(struct ndr_print *ndr, const char *name, const struct nbt_netlogon_query_for_pdc *r)
+{
+ ndr_print_struct(ndr, name, "nbt_netlogon_query_for_pdc");
+ ndr->depth++;
+ ndr_print_string(ndr, "computer_name", r->computer_name);
+ ndr_print_string(ndr, "mailslot_name", r->mailslot_name);
+ ndr_print_DATA_BLOB(ndr, "_pad", r->_pad);
+ ndr_print_string(ndr, "unicode_name", r->unicode_name);
+ ndr_print_uint32(ndr, "nt_version", r->nt_version);
+ ndr_print_uint16(ndr, "lmnt_token", r->lmnt_token);
+ ndr_print_uint16(ndr, "lm20_token", r->lm20_token);
+ ndr->depth--;
+}
+
+static enum ndr_err_code ndr_push_nbt_netlogon_query_for_pdc2(struct ndr_push *ndr, int ndr_flags, const struct nbt_netlogon_query_for_pdc2 *r)
+{
+ uint32_t cntr_unknown_0;
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_push_align(ndr, 4));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->request_count));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->computer_name));
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->user_name));
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->mailslot_name));
+ ndr->flags = _flags_save_string;
+ }
+ for (cntr_unknown_0 = 0; cntr_unknown_0 < 2; cntr_unknown_0++) {
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->unknown[cntr_unknown_0]));
+ }
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->nt_version));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lmnt_token));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lm20_token));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_nbt_netlogon_query_for_pdc2(struct ndr_pull *ndr, int ndr_flags, struct nbt_netlogon_query_for_pdc2 *r)
+{
+ uint32_t cntr_unknown_0;
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_pull_align(ndr, 4));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->request_count));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->computer_name));
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->user_name));
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->mailslot_name));
+ ndr->flags = _flags_save_string;
+ }
+ for (cntr_unknown_0 = 0; cntr_unknown_0 < 2; cntr_unknown_0++) {
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->unknown[cntr_unknown_0]));
+ }
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->nt_version));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lmnt_token));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lm20_token));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_nbt_netlogon_query_for_pdc2(struct ndr_print *ndr, const char *name, const struct nbt_netlogon_query_for_pdc2 *r)
+{
+ uint32_t cntr_unknown_0;
+ ndr_print_struct(ndr, name, "nbt_netlogon_query_for_pdc2");
+ ndr->depth++;
+ ndr_print_uint16(ndr, "request_count", r->request_count);
+ ndr_print_string(ndr, "computer_name", r->computer_name);
+ ndr_print_string(ndr, "user_name", r->user_name);
+ ndr_print_string(ndr, "mailslot_name", r->mailslot_name);
+ ndr->print(ndr, "%s: ARRAY(%d)", "unknown", 2);
+ ndr->depth++;
+ for (cntr_unknown_0=0;cntr_unknown_0<2;cntr_unknown_0++) {
+ char *idx_0=NULL;
+ if (asprintf(&idx_0, "[%d]", cntr_unknown_0) != -1) {
+ ndr_print_uint32(ndr, "unknown", r->unknown[cntr_unknown_0]);
+ free(idx_0);
+ }
+ }
+ ndr->depth--;
+ ndr_print_uint32(ndr, "nt_version", r->nt_version);
+ ndr_print_uint16(ndr, "lmnt_token", r->lmnt_token);
+ ndr_print_uint16(ndr, "lm20_token", r->lm20_token);
+ ndr->depth--;
+}
+
+static enum ndr_err_code ndr_push_nbt_netlogon_response_from_pdc(struct ndr_push *ndr, int ndr_flags, const struct nbt_netlogon_response_from_pdc *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_push_align(ndr, 4));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->pdc_name));
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_DATA_BLOB = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN2);
+ NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, r->_pad));
+ ndr->flags = _flags_save_DATA_BLOB;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->unicode_pdc_name));
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->domain_name));
+ ndr->flags = _flags_save_string;
+ }
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->nt_version));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lmnt_token));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lm20_token));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_nbt_netlogon_response_from_pdc(struct ndr_pull *ndr, int ndr_flags, struct nbt_netlogon_response_from_pdc *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_pull_align(ndr, 4));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->pdc_name));
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_DATA_BLOB = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN2);
+ NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, &r->_pad));
+ ndr->flags = _flags_save_DATA_BLOB;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->unicode_pdc_name));
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->domain_name));
+ ndr->flags = _flags_save_string;
+ }
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->nt_version));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lmnt_token));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lm20_token));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_nbt_netlogon_response_from_pdc(struct ndr_print *ndr, const char *name, const struct nbt_netlogon_response_from_pdc *r)
+{
+ ndr_print_struct(ndr, name, "nbt_netlogon_response_from_pdc");
+ ndr->depth++;
+ ndr_print_string(ndr, "pdc_name", r->pdc_name);
+ ndr_print_DATA_BLOB(ndr, "_pad", r->_pad);
+ ndr_print_string(ndr, "unicode_pdc_name", r->unicode_pdc_name);
+ ndr_print_string(ndr, "domain_name", r->domain_name);
+ ndr_print_uint32(ndr, "nt_version", r->nt_version);
+ ndr_print_uint16(ndr, "lmnt_token", r->lmnt_token);
+ ndr_print_uint16(ndr, "lm20_token", r->lm20_token);
+ ndr->depth--;
+}
+
+static enum ndr_err_code ndr_push_nbt_server_type(struct ndr_push *ndr, int ndr_flags, uint32_t r)
+{
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r));
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_nbt_server_type(struct ndr_pull *ndr, int ndr_flags, uint32_t *r)
+{
+ uint32_t v;
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &v));
+ *r = v;
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_nbt_server_type(struct ndr_print *ndr, const char *name, uint32_t r)
+{
+ ndr_print_uint32(ndr, name, r);
+ ndr->depth++;
+ ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NBT_SERVER_PDC", NBT_SERVER_PDC, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NBT_SERVER_GC", NBT_SERVER_GC, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NBT_SERVER_LDAP", NBT_SERVER_LDAP, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NBT_SERVER_DS", NBT_SERVER_DS, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NBT_SERVER_KDC", NBT_SERVER_KDC, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NBT_SERVER_TIMESERV", NBT_SERVER_TIMESERV, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NBT_SERVER_CLOSEST", NBT_SERVER_CLOSEST, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NBT_SERVER_WRITABLE", NBT_SERVER_WRITABLE, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NBT_SERVER_GOOD_TIMESERV", NBT_SERVER_GOOD_TIMESERV, r);
+ ndr->depth--;
+}
+
+static enum ndr_err_code ndr_push_nbt_netlogon_response_from_pdc2(struct ndr_push *ndr, int ndr_flags, const struct nbt_netlogon_response_from_pdc2 *r)
+{
+ uint32_t cntr_unknown3_0;
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_push_align(ndr, 4));
+ {
+ uint32_t _flags_save_DATA_BLOB = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN4);
+ NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, r->_pad));
+ ndr->flags = _flags_save_DATA_BLOB;
+ }
+ NDR_CHECK(ndr_push_nbt_server_type(ndr, NDR_SCALARS, r->server_type));
+ NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS, &r->domain_uuid));
+ NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->forest));
+ NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->dns_domain));
+ NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->pdc_dns_name));
+ NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->domain));
+ NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->pdc_name));
+ NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->user_name));
+ NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->server_site));
+ NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->client_site));
+ NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r->unknown));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->unknown2));
+ {
+ uint32_t _flags_save_ipv4address = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_BIGENDIAN);
+ NDR_CHECK(ndr_push_ipv4address(ndr, NDR_SCALARS, r->pdc_ip));
+ ndr->flags = _flags_save_ipv4address;
+ }
+ for (cntr_unknown3_0 = 0; cntr_unknown3_0 < 2; cntr_unknown3_0++) {
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->unknown3[cntr_unknown3_0]));
+ }
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->nt_version));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lmnt_token));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lm20_token));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_nbt_netlogon_response_from_pdc2(struct ndr_pull *ndr, int ndr_flags, struct nbt_netlogon_response_from_pdc2 *r)
+{
+ uint32_t cntr_unknown3_0;
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_pull_align(ndr, 4));
+ {
+ uint32_t _flags_save_DATA_BLOB = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN4);
+ NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, &r->_pad));
+ ndr->flags = _flags_save_DATA_BLOB;
+ }
+ NDR_CHECK(ndr_pull_nbt_server_type(ndr, NDR_SCALARS, &r->server_type));
+ NDR_CHECK(ndr_pull_GUID(ndr, NDR_SCALARS, &r->domain_uuid));
+ NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->forest));
+ NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->dns_domain));
+ NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->pdc_dns_name));
+ NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->domain));
+ NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->pdc_name));
+ NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->user_name));
+ NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->server_site));
+ NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->client_site));
+ NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->unknown));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->unknown2));
+ {
+ uint32_t _flags_save_ipv4address = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_BIGENDIAN);
+ NDR_CHECK(ndr_pull_ipv4address(ndr, NDR_SCALARS, &r->pdc_ip));
+ ndr->flags = _flags_save_ipv4address;
+ }
+ for (cntr_unknown3_0 = 0; cntr_unknown3_0 < 2; cntr_unknown3_0++) {
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->unknown3[cntr_unknown3_0]));
+ }
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->nt_version));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lmnt_token));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lm20_token));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_nbt_netlogon_response_from_pdc2(struct ndr_print *ndr, const char *name, const struct nbt_netlogon_response_from_pdc2 *r)
+{
+ uint32_t cntr_unknown3_0;
+ ndr_print_struct(ndr, name, "nbt_netlogon_response_from_pdc2");
+ ndr->depth++;
+ ndr_print_DATA_BLOB(ndr, "_pad", r->_pad);
+ ndr_print_nbt_server_type(ndr, "server_type", r->server_type);
+ ndr_print_GUID(ndr, "domain_uuid", &r->domain_uuid);
+ ndr_print_nbt_string(ndr, "forest", r->forest);
+ ndr_print_nbt_string(ndr, "dns_domain", r->dns_domain);
+ ndr_print_nbt_string(ndr, "pdc_dns_name", r->pdc_dns_name);
+ ndr_print_nbt_string(ndr, "domain", r->domain);
+ ndr_print_nbt_string(ndr, "pdc_name", r->pdc_name);
+ ndr_print_nbt_string(ndr, "user_name", r->user_name);
+ ndr_print_nbt_string(ndr, "server_site", r->server_site);
+ ndr_print_nbt_string(ndr, "client_site", r->client_site);
+ ndr_print_uint8(ndr, "unknown", r->unknown);
+ ndr_print_uint32(ndr, "unknown2", r->unknown2);
+ ndr_print_ipv4address(ndr, "pdc_ip", r->pdc_ip);
+ ndr->print(ndr, "%s: ARRAY(%d)", "unknown3", 2);
+ ndr->depth++;
+ for (cntr_unknown3_0=0;cntr_unknown3_0<2;cntr_unknown3_0++) {
+ char *idx_0=NULL;
+ if (asprintf(&idx_0, "[%d]", cntr_unknown3_0) != -1) {
+ ndr_print_uint32(ndr, "unknown3", r->unknown3[cntr_unknown3_0]);
+ free(idx_0);
+ }
+ }
+ ndr->depth--;
+ ndr_print_uint32(ndr, "nt_version", r->nt_version);
+ ndr_print_uint16(ndr, "lmnt_token", r->lmnt_token);
+ ndr_print_uint16(ndr, "lm20_token", r->lm20_token);
+ ndr->depth--;
+}
+
+static enum ndr_err_code ndr_push_nbt_db_change(struct ndr_push *ndr, int ndr_flags, const struct nbt_db_change *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_push_align(ndr, 8));
+ NDR_CHECK(ndr_push_netr_SamDatabaseID(ndr, NDR_SCALARS, r->db_index));
+ NDR_CHECK(ndr_push_hyper(ndr, NDR_SCALARS, r->serial));
+ NDR_CHECK(ndr_push_NTTIME(ndr, NDR_SCALARS, r->timestamp));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_nbt_db_change(struct ndr_pull *ndr, int ndr_flags, struct nbt_db_change *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_pull_align(ndr, 8));
+ NDR_CHECK(ndr_pull_netr_SamDatabaseID(ndr, NDR_SCALARS, &r->db_index));
+ NDR_CHECK(ndr_pull_hyper(ndr, NDR_SCALARS, &r->serial));
+ NDR_CHECK(ndr_pull_NTTIME(ndr, NDR_SCALARS, &r->timestamp));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_nbt_db_change(struct ndr_print *ndr, const char *name, const struct nbt_db_change *r)
+{
+ ndr_print_struct(ndr, name, "nbt_db_change");
+ ndr->depth++;
+ ndr_print_netr_SamDatabaseID(ndr, "db_index", r->db_index);
+ ndr_print_hyper(ndr, "serial", r->serial);
+ ndr_print_NTTIME(ndr, "timestamp", r->timestamp);
+ ndr->depth--;
+}
+
+static enum ndr_err_code ndr_push_nbt_netlogon_announce_uas(struct ndr_push *ndr, int ndr_flags, const struct nbt_netlogon_announce_uas *r)
+{
+ uint32_t cntr_dbchange_0;
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_push_align(ndr, 8));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->serial_lo));
+ NDR_CHECK(ndr_push_time_t(ndr, NDR_SCALARS, r->timestamp));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->pulse));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->random));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->pdc_name));
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->domain));
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_DATA_BLOB = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN2);
+ NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, r->_pad));
+ ndr->flags = _flags_save_DATA_BLOB;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->unicode_pdc_name));
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->unicode_domain));
+ ndr->flags = _flags_save_string;
+ }
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->db_count));
+ for (cntr_dbchange_0 = 0; cntr_dbchange_0 < r->db_count; cntr_dbchange_0++) {
+ NDR_CHECK(ndr_push_nbt_db_change(ndr, NDR_SCALARS, &r->dbchange[cntr_dbchange_0]));
+ }
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_size_dom_sid0(&r->sid, ndr->flags)));
+ {
+ struct ndr_push *_ndr_sid;
+ NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_sid, 0, ndr_size_dom_sid0(&r->sid, ndr->flags)));
+ NDR_CHECK(ndr_push_dom_sid0(_ndr_sid, NDR_SCALARS|NDR_BUFFERS, &r->sid));
+ NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_sid, 0, ndr_size_dom_sid0(&r->sid, ndr->flags)));
+ }
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->nt_version));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lmnt_token));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lm20_token));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_nbt_netlogon_announce_uas(struct ndr_pull *ndr, int ndr_flags, struct nbt_netlogon_announce_uas *r)
+{
+ uint32_t cntr_dbchange_0;
+ TALLOC_CTX *_mem_save_dbchange_0;
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_pull_align(ndr, 8));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->serial_lo));
+ NDR_CHECK(ndr_pull_time_t(ndr, NDR_SCALARS, &r->timestamp));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->pulse));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->random));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->pdc_name));
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->domain));
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_DATA_BLOB = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN2);
+ NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, &r->_pad));
+ ndr->flags = _flags_save_DATA_BLOB;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->unicode_pdc_name));
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->unicode_domain));
+ ndr->flags = _flags_save_string;
+ }
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->db_count));
+ NDR_PULL_ALLOC_N(ndr, r->dbchange, r->db_count);
+ _mem_save_dbchange_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->dbchange, 0);
+ for (cntr_dbchange_0 = 0; cntr_dbchange_0 < r->db_count; cntr_dbchange_0++) {
+ NDR_CHECK(ndr_pull_nbt_db_change(ndr, NDR_SCALARS, &r->dbchange[cntr_dbchange_0]));
+ }
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_dbchange_0, 0);
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->sid_size));
+ {
+ struct ndr_pull *_ndr_sid;
+ NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_sid, 0, r->sid_size));
+ NDR_CHECK(ndr_pull_dom_sid0(_ndr_sid, NDR_SCALARS|NDR_BUFFERS, &r->sid));
+ NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_sid, 0, r->sid_size));
+ }
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->nt_version));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lmnt_token));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lm20_token));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_nbt_netlogon_announce_uas(struct ndr_print *ndr, const char *name, const struct nbt_netlogon_announce_uas *r)
+{
+ uint32_t cntr_dbchange_0;
+ ndr_print_struct(ndr, name, "nbt_netlogon_announce_uas");
+ ndr->depth++;
+ ndr_print_uint32(ndr, "serial_lo", r->serial_lo);
+ ndr_print_time_t(ndr, "timestamp", r->timestamp);
+ ndr_print_uint32(ndr, "pulse", r->pulse);
+ ndr_print_uint32(ndr, "random", r->random);
+ ndr_print_string(ndr, "pdc_name", r->pdc_name);
+ ndr_print_string(ndr, "domain", r->domain);
+ ndr_print_DATA_BLOB(ndr, "_pad", r->_pad);
+ ndr_print_string(ndr, "unicode_pdc_name", r->unicode_pdc_name);
+ ndr_print_string(ndr, "unicode_domain", r->unicode_domain);
+ ndr_print_uint32(ndr, "db_count", r->db_count);
+ ndr->print(ndr, "%s: ARRAY(%d)", "dbchange", r->db_count);
+ ndr->depth++;
+ for (cntr_dbchange_0=0;cntr_dbchange_0<r->db_count;cntr_dbchange_0++) {
+ char *idx_0=NULL;
+ if (asprintf(&idx_0, "[%d]", cntr_dbchange_0) != -1) {
+ ndr_print_nbt_db_change(ndr, "dbchange", &r->dbchange[cntr_dbchange_0]);
+ free(idx_0);
+ }
+ }
+ ndr->depth--;
+ ndr_print_uint32(ndr, "sid_size", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?ndr_size_dom_sid0(&r->sid, ndr->flags):r->sid_size);
+ ndr_print_dom_sid0(ndr, "sid", &r->sid);
+ ndr_print_uint32(ndr, "nt_version", r->nt_version);
+ ndr_print_uint16(ndr, "lmnt_token", r->lmnt_token);
+ ndr_print_uint16(ndr, "lm20_token", r->lm20_token);
+ ndr->depth--;
+}
+
+static enum ndr_err_code ndr_push_nbt_netlogon_request(struct ndr_push *ndr, int ndr_flags, const union nbt_netlogon_request *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ int level = ndr_push_get_switch_value(ndr, r);
+ switch (level) {
+ case NETLOGON_QUERY_FOR_PDC: {
+ NDR_CHECK(ndr_push_nbt_netlogon_query_for_pdc(ndr, NDR_SCALARS, &r->pdc));
+ break; }
+
+ case NETLOGON_QUERY_FOR_PDC2: {
+ NDR_CHECK(ndr_push_nbt_netlogon_query_for_pdc2(ndr, NDR_SCALARS, &r->pdc2));
+ break; }
+
+ case NETLOGON_ANNOUNCE_UAS: {
+ NDR_CHECK(ndr_push_nbt_netlogon_announce_uas(ndr, NDR_SCALARS, &r->uas));
+ break; }
+
+ case NETLOGON_RESPONSE_FROM_PDC: {
+ NDR_CHECK(ndr_push_nbt_netlogon_response_from_pdc(ndr, NDR_SCALARS, &r->response));
+ break; }
+
+ case NETLOGON_RESPONSE_FROM_PDC2: {
+ NDR_CHECK(ndr_push_nbt_netlogon_response_from_pdc2(ndr, NDR_SCALARS, &r->response2));
+ break; }
+
+ case NETLOGON_RESPONSE_FROM_PDC_USER: {
+ NDR_CHECK(ndr_push_nbt_netlogon_response_from_pdc2(ndr, NDR_SCALARS, &r->response2));
+ break; }
+
+ default:
+ return ndr_push_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level);
+ }
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ int level = ndr_push_get_switch_value(ndr, r);
+ switch (level) {
+ case NETLOGON_QUERY_FOR_PDC:
+ break;
+
+ case NETLOGON_QUERY_FOR_PDC2:
+ break;
+
+ case NETLOGON_ANNOUNCE_UAS:
+ NDR_CHECK(ndr_push_nbt_netlogon_announce_uas(ndr, NDR_BUFFERS, &r->uas));
+ break;
+
+ case NETLOGON_RESPONSE_FROM_PDC:
+ break;
+
+ case NETLOGON_RESPONSE_FROM_PDC2:
+ break;
+
+ case NETLOGON_RESPONSE_FROM_PDC_USER:
+ break;
+
+ default:
+ return ndr_push_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level);
+ }
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_nbt_netlogon_request(struct ndr_pull *ndr, int ndr_flags, union nbt_netlogon_request *r)
+{
+ int level;
+ level = ndr_pull_get_switch_value(ndr, r);
+ if (ndr_flags & NDR_SCALARS) {
+ switch (level) {
+ case NETLOGON_QUERY_FOR_PDC: {
+ NDR_CHECK(ndr_pull_nbt_netlogon_query_for_pdc(ndr, NDR_SCALARS, &r->pdc));
+ break; }
+
+ case NETLOGON_QUERY_FOR_PDC2: {
+ NDR_CHECK(ndr_pull_nbt_netlogon_query_for_pdc2(ndr, NDR_SCALARS, &r->pdc2));
+ break; }
+
+ case NETLOGON_ANNOUNCE_UAS: {
+ NDR_CHECK(ndr_pull_nbt_netlogon_announce_uas(ndr, NDR_SCALARS, &r->uas));
+ break; }
+
+ case NETLOGON_RESPONSE_FROM_PDC: {
+ NDR_CHECK(ndr_pull_nbt_netlogon_response_from_pdc(ndr, NDR_SCALARS, &r->response));
+ break; }
+
+ case NETLOGON_RESPONSE_FROM_PDC2: {
+ NDR_CHECK(ndr_pull_nbt_netlogon_response_from_pdc2(ndr, NDR_SCALARS, &r->response2));
+ break; }
+
+ case NETLOGON_RESPONSE_FROM_PDC_USER: {
+ NDR_CHECK(ndr_pull_nbt_netlogon_response_from_pdc2(ndr, NDR_SCALARS, &r->response2));
+ break; }
+
+ default:
+ return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level);
+ }
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ switch (level) {
+ case NETLOGON_QUERY_FOR_PDC:
+ break;
+
+ case NETLOGON_QUERY_FOR_PDC2:
+ break;
+
+ case NETLOGON_ANNOUNCE_UAS:
+ NDR_CHECK(ndr_pull_nbt_netlogon_announce_uas(ndr, NDR_BUFFERS, &r->uas));
+ break;
+
+ case NETLOGON_RESPONSE_FROM_PDC:
+ break;
+
+ case NETLOGON_RESPONSE_FROM_PDC2:
+ break;
+
+ case NETLOGON_RESPONSE_FROM_PDC_USER:
+ break;
+
+ default:
+ return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level);
+ }
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_nbt_netlogon_request(struct ndr_print *ndr, const char *name, const union nbt_netlogon_request *r)
+{
+ int level;
+ level = ndr_print_get_switch_value(ndr, r);
+ ndr_print_union(ndr, name, level, "nbt_netlogon_request");
+ switch (level) {
+ case NETLOGON_QUERY_FOR_PDC:
+ ndr_print_nbt_netlogon_query_for_pdc(ndr, "pdc", &r->pdc);
+ break;
+
+ case NETLOGON_QUERY_FOR_PDC2:
+ ndr_print_nbt_netlogon_query_for_pdc2(ndr, "pdc2", &r->pdc2);
+ break;
+
+ case NETLOGON_ANNOUNCE_UAS:
+ ndr_print_nbt_netlogon_announce_uas(ndr, "uas", &r->uas);
+ break;
+
+ case NETLOGON_RESPONSE_FROM_PDC:
+ ndr_print_nbt_netlogon_response_from_pdc(ndr, "response", &r->response);
+ break;
+
+ case NETLOGON_RESPONSE_FROM_PDC2:
+ ndr_print_nbt_netlogon_response_from_pdc2(ndr, "response2", &r->response2);
+ break;
+
+ case NETLOGON_RESPONSE_FROM_PDC_USER:
+ ndr_print_nbt_netlogon_response_from_pdc2(ndr, "response2", &r->response2);
+ break;
+
+ default:
+ ndr_print_bad_level(ndr, name, level);
+ }
+}
+
+_PUBLIC_ enum ndr_err_code ndr_push_nbt_netlogon_packet(struct ndr_push *ndr, int ndr_flags, const struct nbt_netlogon_packet *r)
+{
+ {
+ uint32_t _flags_save_STRUCT = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_push_align(ndr, 8));
+ NDR_CHECK(ndr_push_nbt_netlogon_command(ndr, NDR_SCALARS, r->command));
+ NDR_CHECK(ndr_push_set_switch_value(ndr, &r->req, r->command));
+ NDR_CHECK(ndr_push_nbt_netlogon_request(ndr, NDR_SCALARS, &r->req));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ NDR_CHECK(ndr_push_nbt_netlogon_request(ndr, NDR_BUFFERS, &r->req));
+ }
+ ndr->flags = _flags_save_STRUCT;
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ enum ndr_err_code ndr_pull_nbt_netlogon_packet(struct ndr_pull *ndr, int ndr_flags, struct nbt_netlogon_packet *r)
+{
+ {
+ uint32_t _flags_save_STRUCT = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_pull_align(ndr, 8));
+ NDR_CHECK(ndr_pull_nbt_netlogon_command(ndr, NDR_SCALARS, &r->command));
+ NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->req, r->command));
+ NDR_CHECK(ndr_pull_nbt_netlogon_request(ndr, NDR_SCALARS, &r->req));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ NDR_CHECK(ndr_pull_nbt_netlogon_request(ndr, NDR_BUFFERS, &r->req));
+ }
+ ndr->flags = _flags_save_STRUCT;
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_nbt_netlogon_packet(struct ndr_print *ndr, const char *name, const struct nbt_netlogon_packet *r)
+{
+ ndr_print_struct(ndr, name, "nbt_netlogon_packet");
+ {
+ uint32_t _flags_save_STRUCT = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
+ ndr->depth++;
+ ndr_print_nbt_netlogon_command(ndr, "command", r->command);
+ ndr_print_set_switch_value(ndr, &r->req, r->command);
+ ndr_print_nbt_netlogon_request(ndr, "req", &r->req);
+ ndr->depth--;
+ ndr->flags = _flags_save_STRUCT;
+ }
+}
+
+static enum ndr_err_code ndr_push_nbt_cldap_netlogon_1(struct ndr_push *ndr, int ndr_flags, const struct nbt_cldap_netlogon_1 *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_push_align(ndr, 4));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->type));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->pdc_name));
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->user_name));
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->domain_name));
+ ndr->flags = _flags_save_string;
+ }
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 1));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lmnt_token));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lm20_token));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_nbt_cldap_netlogon_1(struct ndr_pull *ndr, int ndr_flags, struct nbt_cldap_netlogon_1 *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_pull_align(ndr, 4));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->type));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->pdc_name));
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->user_name));
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->domain_name));
+ ndr->flags = _flags_save_string;
+ }
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->nt_version));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lmnt_token));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lm20_token));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_nbt_cldap_netlogon_1(struct ndr_print *ndr, const char *name, const struct nbt_cldap_netlogon_1 *r)
+{
+ ndr_print_struct(ndr, name, "nbt_cldap_netlogon_1");
+ ndr->depth++;
+ ndr_print_uint16(ndr, "type", r->type);
+ ndr_print_string(ndr, "pdc_name", r->pdc_name);
+ ndr_print_string(ndr, "user_name", r->user_name);
+ ndr_print_string(ndr, "domain_name", r->domain_name);
+ ndr_print_uint32(ndr, "nt_version", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?1:r->nt_version);
+ ndr_print_uint16(ndr, "lmnt_token", r->lmnt_token);
+ ndr_print_uint16(ndr, "lm20_token", r->lm20_token);
+ ndr->depth--;
+}
+
+static enum ndr_err_code ndr_push_nbt_cldap_netlogon_3(struct ndr_push *ndr, int ndr_flags, const struct nbt_cldap_netlogon_3 *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_push_align(ndr, 4));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->type));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->pdc_name));
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->user_name));
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->domain_name));
+ ndr->flags = _flags_save_string;
+ }
+ NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS, &r->domain_uuid));
+ NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS, &r->unknown_uuid));
+ NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->forest));
+ NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->dns_domain));
+ NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->pdc_dns_name));
+ NDR_CHECK(ndr_push_ipv4address(ndr, NDR_SCALARS, r->pdc_ip));
+ NDR_CHECK(ndr_push_nbt_server_type(ndr, NDR_SCALARS, r->server_type));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 3));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lmnt_token));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lm20_token));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_nbt_cldap_netlogon_3(struct ndr_pull *ndr, int ndr_flags, struct nbt_cldap_netlogon_3 *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_pull_align(ndr, 4));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->type));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->pdc_name));
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->user_name));
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->domain_name));
+ ndr->flags = _flags_save_string;
+ }
+ NDR_CHECK(ndr_pull_GUID(ndr, NDR_SCALARS, &r->domain_uuid));
+ NDR_CHECK(ndr_pull_GUID(ndr, NDR_SCALARS, &r->unknown_uuid));
+ NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->forest));
+ NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->dns_domain));
+ NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->pdc_dns_name));
+ NDR_CHECK(ndr_pull_ipv4address(ndr, NDR_SCALARS, &r->pdc_ip));
+ NDR_CHECK(ndr_pull_nbt_server_type(ndr, NDR_SCALARS, &r->server_type));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->nt_version));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lmnt_token));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lm20_token));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_nbt_cldap_netlogon_3(struct ndr_print *ndr, const char *name, const struct nbt_cldap_netlogon_3 *r)
+{
+ ndr_print_struct(ndr, name, "nbt_cldap_netlogon_3");
+ ndr->depth++;
+ ndr_print_uint16(ndr, "type", r->type);
+ ndr_print_string(ndr, "pdc_name", r->pdc_name);
+ ndr_print_string(ndr, "user_name", r->user_name);
+ ndr_print_string(ndr, "domain_name", r->domain_name);
+ ndr_print_GUID(ndr, "domain_uuid", &r->domain_uuid);
+ ndr_print_GUID(ndr, "unknown_uuid", &r->unknown_uuid);
+ ndr_print_nbt_string(ndr, "forest", r->forest);
+ ndr_print_nbt_string(ndr, "dns_domain", r->dns_domain);
+ ndr_print_nbt_string(ndr, "pdc_dns_name", r->pdc_dns_name);
+ ndr_print_ipv4address(ndr, "pdc_ip", r->pdc_ip);
+ ndr_print_nbt_server_type(ndr, "server_type", r->server_type);
+ ndr_print_uint32(ndr, "nt_version", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?3:r->nt_version);
+ ndr_print_uint16(ndr, "lmnt_token", r->lmnt_token);
+ ndr_print_uint16(ndr, "lm20_token", r->lm20_token);
+ ndr->depth--;
+}
+
+static enum ndr_err_code ndr_push_nbt_cldap_netlogon_5(struct ndr_push *ndr, int ndr_flags, const struct nbt_cldap_netlogon_5 *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_push_align(ndr, 4));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->type));
+ NDR_CHECK(ndr_push_nbt_server_type(ndr, NDR_SCALARS, r->server_type));
+ NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS, &r->domain_uuid));
+ NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->forest));
+ NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->dns_domain));
+ NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->pdc_dns_name));
+ NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->domain));
+ NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->pdc_name));
+ NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->user_name));
+ NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->server_site));
+ NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->client_site));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 5));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lmnt_token));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lm20_token));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_nbt_cldap_netlogon_5(struct ndr_pull *ndr, int ndr_flags, struct nbt_cldap_netlogon_5 *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_pull_align(ndr, 4));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->type));
+ NDR_CHECK(ndr_pull_nbt_server_type(ndr, NDR_SCALARS, &r->server_type));
+ NDR_CHECK(ndr_pull_GUID(ndr, NDR_SCALARS, &r->domain_uuid));
+ NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->forest));
+ NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->dns_domain));
+ NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->pdc_dns_name));
+ NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->domain));
+ NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->pdc_name));
+ NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->user_name));
+ NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->server_site));
+ NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->client_site));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->nt_version));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lmnt_token));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lm20_token));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_nbt_cldap_netlogon_5(struct ndr_print *ndr, const char *name, const struct nbt_cldap_netlogon_5 *r)
+{
+ ndr_print_struct(ndr, name, "nbt_cldap_netlogon_5");
+ ndr->depth++;
+ ndr_print_uint32(ndr, "type", r->type);
+ ndr_print_nbt_server_type(ndr, "server_type", r->server_type);
+ ndr_print_GUID(ndr, "domain_uuid", &r->domain_uuid);
+ ndr_print_nbt_string(ndr, "forest", r->forest);
+ ndr_print_nbt_string(ndr, "dns_domain", r->dns_domain);
+ ndr_print_nbt_string(ndr, "pdc_dns_name", r->pdc_dns_name);
+ ndr_print_nbt_string(ndr, "domain", r->domain);
+ ndr_print_nbt_string(ndr, "pdc_name", r->pdc_name);
+ ndr_print_nbt_string(ndr, "user_name", r->user_name);
+ ndr_print_nbt_string(ndr, "server_site", r->server_site);
+ ndr_print_nbt_string(ndr, "client_site", r->client_site);
+ ndr_print_uint32(ndr, "nt_version", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?5:r->nt_version);
+ ndr_print_uint16(ndr, "lmnt_token", r->lmnt_token);
+ ndr_print_uint16(ndr, "lm20_token", r->lm20_token);
+ ndr->depth--;
+}
+
+static enum ndr_err_code ndr_push_nbt_cldap_netlogon_13(struct ndr_push *ndr, int ndr_flags, const struct nbt_cldap_netlogon_13 *r)
+{
+ uint32_t cntr_unknown3_0;
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_push_align(ndr, 4));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->type));
+ NDR_CHECK(ndr_push_nbt_server_type(ndr, NDR_SCALARS, r->server_type));
+ NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS, &r->domain_uuid));
+ NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->forest));
+ NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->dns_domain));
+ NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->pdc_dns_name));
+ NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->domain));
+ NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->pdc_name));
+ NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->user_name));
+ NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->server_site));
+ NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->client_site));
+ NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r->unknown));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->unknown2));
+ {
+ uint32_t _flags_save_ipv4address = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_BIGENDIAN);
+ NDR_CHECK(ndr_push_ipv4address(ndr, NDR_SCALARS, r->pdc_ip));
+ ndr->flags = _flags_save_ipv4address;
+ }
+ for (cntr_unknown3_0 = 0; cntr_unknown3_0 < 2; cntr_unknown3_0++) {
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->unknown3[cntr_unknown3_0]));
+ }
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 13));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lmnt_token));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lm20_token));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_nbt_cldap_netlogon_13(struct ndr_pull *ndr, int ndr_flags, struct nbt_cldap_netlogon_13 *r)
+{
+ uint32_t cntr_unknown3_0;
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_pull_align(ndr, 4));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->type));
+ NDR_CHECK(ndr_pull_nbt_server_type(ndr, NDR_SCALARS, &r->server_type));
+ NDR_CHECK(ndr_pull_GUID(ndr, NDR_SCALARS, &r->domain_uuid));
+ NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->forest));
+ NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->dns_domain));
+ NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->pdc_dns_name));
+ NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->domain));
+ NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->pdc_name));
+ NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->user_name));
+ NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->server_site));
+ NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->client_site));
+ NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->unknown));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->unknown2));
+ {
+ uint32_t _flags_save_ipv4address = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_BIGENDIAN);
+ NDR_CHECK(ndr_pull_ipv4address(ndr, NDR_SCALARS, &r->pdc_ip));
+ ndr->flags = _flags_save_ipv4address;
+ }
+ for (cntr_unknown3_0 = 0; cntr_unknown3_0 < 2; cntr_unknown3_0++) {
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->unknown3[cntr_unknown3_0]));
+ }
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->nt_version));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lmnt_token));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lm20_token));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_nbt_cldap_netlogon_13(struct ndr_print *ndr, const char *name, const struct nbt_cldap_netlogon_13 *r)
+{
+ uint32_t cntr_unknown3_0;
+ ndr_print_struct(ndr, name, "nbt_cldap_netlogon_13");
+ ndr->depth++;
+ ndr_print_uint32(ndr, "type", r->type);
+ ndr_print_nbt_server_type(ndr, "server_type", r->server_type);
+ ndr_print_GUID(ndr, "domain_uuid", &r->domain_uuid);
+ ndr_print_nbt_string(ndr, "forest", r->forest);
+ ndr_print_nbt_string(ndr, "dns_domain", r->dns_domain);
+ ndr_print_nbt_string(ndr, "pdc_dns_name", r->pdc_dns_name);
+ ndr_print_nbt_string(ndr, "domain", r->domain);
+ ndr_print_nbt_string(ndr, "pdc_name", r->pdc_name);
+ ndr_print_nbt_string(ndr, "user_name", r->user_name);
+ ndr_print_nbt_string(ndr, "server_site", r->server_site);
+ ndr_print_nbt_string(ndr, "client_site", r->client_site);
+ ndr_print_uint8(ndr, "unknown", r->unknown);
+ ndr_print_uint32(ndr, "unknown2", r->unknown2);
+ ndr_print_ipv4address(ndr, "pdc_ip", r->pdc_ip);
+ ndr->print(ndr, "%s: ARRAY(%d)", "unknown3", 2);
+ ndr->depth++;
+ for (cntr_unknown3_0=0;cntr_unknown3_0<2;cntr_unknown3_0++) {
+ char *idx_0=NULL;
+ if (asprintf(&idx_0, "[%d]", cntr_unknown3_0) != -1) {
+ ndr_print_uint32(ndr, "unknown3", r->unknown3[cntr_unknown3_0]);
+ free(idx_0);
+ }
+ }
+ ndr->depth--;
+ ndr_print_uint32(ndr, "nt_version", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?13:r->nt_version);
+ ndr_print_uint16(ndr, "lmnt_token", r->lmnt_token);
+ ndr_print_uint16(ndr, "lm20_token", r->lm20_token);
+ ndr->depth--;
+}
+
+_PUBLIC_ enum ndr_err_code ndr_push_nbt_cldap_netlogon(struct ndr_push *ndr, int ndr_flags, const union nbt_cldap_netlogon *r)
+{
+ {
+ uint32_t _flags_save_UNION = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
+ if (ndr_flags & NDR_SCALARS) {
+ int level = ndr_push_get_switch_value(ndr, r);
+ switch (level) {
+ case 0: {
+ NDR_CHECK(ndr_push_nbt_cldap_netlogon_1(ndr, NDR_SCALARS, &r->logon1));
+ break; }
+
+ case 1: {
+ NDR_CHECK(ndr_push_nbt_cldap_netlogon_1(ndr, NDR_SCALARS, &r->logon1));
+ break; }
+
+ case 2: {
+ NDR_CHECK(ndr_push_nbt_cldap_netlogon_3(ndr, NDR_SCALARS, &r->logon3));
+ break; }
+
+ case 3: {
+ NDR_CHECK(ndr_push_nbt_cldap_netlogon_3(ndr, NDR_SCALARS, &r->logon3));
+ break; }
+
+ case 4: {
+ NDR_CHECK(ndr_push_nbt_cldap_netlogon_5(ndr, NDR_SCALARS, &r->logon5));
+ break; }
+
+ case 5: {
+ NDR_CHECK(ndr_push_nbt_cldap_netlogon_5(ndr, NDR_SCALARS, &r->logon5));
+ break; }
+
+ case 6: {
+ NDR_CHECK(ndr_push_nbt_cldap_netlogon_5(ndr, NDR_SCALARS, &r->logon5));
+ break; }
+
+ case 7: {
+ NDR_CHECK(ndr_push_nbt_cldap_netlogon_5(ndr, NDR_SCALARS, &r->logon5));
+ break; }
+
+ default: {
+ NDR_CHECK(ndr_push_nbt_cldap_netlogon_13(ndr, NDR_SCALARS, &r->logon13));
+ break; }
+
+ }
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ int level = ndr_push_get_switch_value(ndr, r);
+ switch (level) {
+ case 0:
+ break;
+
+ case 1:
+ break;
+
+ case 2:
+ break;
+
+ case 3:
+ break;
+
+ case 4:
+ break;
+
+ case 5:
+ break;
+
+ case 6:
+ break;
+
+ case 7:
+ break;
+
+ default:
+ break;
+
+ }
+ }
+ ndr->flags = _flags_save_UNION;
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ enum ndr_err_code ndr_pull_nbt_cldap_netlogon(struct ndr_pull *ndr, int ndr_flags, union nbt_cldap_netlogon *r)
+{
+ int level;
+ {
+ uint32_t _flags_save_UNION = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
+ level = ndr_pull_get_switch_value(ndr, r);
+ if (ndr_flags & NDR_SCALARS) {
+ switch (level) {
+ case 0: {
+ NDR_CHECK(ndr_pull_nbt_cldap_netlogon_1(ndr, NDR_SCALARS, &r->logon1));
+ break; }
+
+ case 1: {
+ NDR_CHECK(ndr_pull_nbt_cldap_netlogon_1(ndr, NDR_SCALARS, &r->logon1));
+ break; }
+
+ case 2: {
+ NDR_CHECK(ndr_pull_nbt_cldap_netlogon_3(ndr, NDR_SCALARS, &r->logon3));
+ break; }
+
+ case 3: {
+ NDR_CHECK(ndr_pull_nbt_cldap_netlogon_3(ndr, NDR_SCALARS, &r->logon3));
+ break; }
+
+ case 4: {
+ NDR_CHECK(ndr_pull_nbt_cldap_netlogon_5(ndr, NDR_SCALARS, &r->logon5));
+ break; }
+
+ case 5: {
+ NDR_CHECK(ndr_pull_nbt_cldap_netlogon_5(ndr, NDR_SCALARS, &r->logon5));
+ break; }
+
+ case 6: {
+ NDR_CHECK(ndr_pull_nbt_cldap_netlogon_5(ndr, NDR_SCALARS, &r->logon5));
+ break; }
+
+ case 7: {
+ NDR_CHECK(ndr_pull_nbt_cldap_netlogon_5(ndr, NDR_SCALARS, &r->logon5));
+ break; }
+
+ default: {
+ NDR_CHECK(ndr_pull_nbt_cldap_netlogon_13(ndr, NDR_SCALARS, &r->logon13));
+ break; }
+
+ }
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ switch (level) {
+ case 0:
+ break;
+
+ case 1:
+ break;
+
+ case 2:
+ break;
+
+ case 3:
+ break;
+
+ case 4:
+ break;
+
+ case 5:
+ break;
+
+ case 6:
+ break;
+
+ case 7:
+ break;
+
+ default:
+ break;
+
+ }
+ }
+ ndr->flags = _flags_save_UNION;
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_nbt_cldap_netlogon(struct ndr_print *ndr, const char *name, const union nbt_cldap_netlogon *r)
+{
+ int level;
+ {
+ uint32_t _flags_save_UNION = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
+ level = ndr_print_get_switch_value(ndr, r);
+ ndr_print_union(ndr, name, level, "nbt_cldap_netlogon");
+ switch (level) {
+ case 0:
+ ndr_print_nbt_cldap_netlogon_1(ndr, "logon1", &r->logon1);
+ break;
+
+ case 1:
+ ndr_print_nbt_cldap_netlogon_1(ndr, "logon1", &r->logon1);
+ break;
+
+ case 2:
+ ndr_print_nbt_cldap_netlogon_3(ndr, "logon3", &r->logon3);
+ break;
+
+ case 3:
+ ndr_print_nbt_cldap_netlogon_3(ndr, "logon3", &r->logon3);
+ break;
+
+ case 4:
+ ndr_print_nbt_cldap_netlogon_5(ndr, "logon5", &r->logon5);
+ break;
+
+ case 5:
+ ndr_print_nbt_cldap_netlogon_5(ndr, "logon5", &r->logon5);
+ break;
+
+ case 6:
+ ndr_print_nbt_cldap_netlogon_5(ndr, "logon5", &r->logon5);
+ break;
+
+ case 7:
+ ndr_print_nbt_cldap_netlogon_5(ndr, "logon5", &r->logon5);
+ break;
+
+ default:
+ ndr_print_nbt_cldap_netlogon_13(ndr, "logon13", &r->logon13);
+ break;
+
+ }
+ ndr->flags = _flags_save_UNION;
+ }
+}
+
+static enum ndr_err_code ndr_push_nbt_ntlogon_command(struct ndr_push *ndr, int ndr_flags, enum nbt_ntlogon_command r)
+{
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r));
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_nbt_ntlogon_command(struct ndr_pull *ndr, int ndr_flags, enum nbt_ntlogon_command *r)
+{
+ uint16_t v;
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &v));
+ *r = v;
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_nbt_ntlogon_command(struct ndr_print *ndr, const char *name, enum nbt_ntlogon_command r)
+{
+ const char *val = NULL;
+
+ switch (r) {
+ case NTLOGON_SAM_LOGON: val = "NTLOGON_SAM_LOGON"; break;
+ case NTLOGON_SAM_LOGON_REPLY: val = "NTLOGON_SAM_LOGON_REPLY"; break;
+ case NTLOGON_SAM_LOGON_REPLY15: val = "NTLOGON_SAM_LOGON_REPLY15"; break;
+ }
+ ndr_print_enum(ndr, name, "ENUM", val, r);
+}
+
+static enum ndr_err_code ndr_push_nbt_ntlogon_sam_logon(struct ndr_push *ndr, int ndr_flags, const struct nbt_ntlogon_sam_logon *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_push_align(ndr, 4));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->request_count));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->computer_name));
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->user_name));
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->mailslot_name));
+ ndr->flags = _flags_save_string;
+ }
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->acct_control));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_size_dom_sid0(&r->sid, ndr->flags)));
+ {
+ struct ndr_push *_ndr_sid;
+ NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_sid, 0, ndr_size_dom_sid0(&r->sid, ndr->flags)));
+ NDR_CHECK(ndr_push_dom_sid0(_ndr_sid, NDR_SCALARS|NDR_BUFFERS, &r->sid));
+ NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_sid, 0, ndr_size_dom_sid0(&r->sid, ndr->flags)));
+ }
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->nt_version));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lmnt_token));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lm20_token));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_nbt_ntlogon_sam_logon(struct ndr_pull *ndr, int ndr_flags, struct nbt_ntlogon_sam_logon *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_pull_align(ndr, 4));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->request_count));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->computer_name));
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->user_name));
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->mailslot_name));
+ ndr->flags = _flags_save_string;
+ }
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->acct_control));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->sid_size));
+ {
+ struct ndr_pull *_ndr_sid;
+ NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_sid, 0, r->sid_size));
+ NDR_CHECK(ndr_pull_dom_sid0(_ndr_sid, NDR_SCALARS|NDR_BUFFERS, &r->sid));
+ NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_sid, 0, r->sid_size));
+ }
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->nt_version));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lmnt_token));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lm20_token));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_nbt_ntlogon_sam_logon(struct ndr_print *ndr, const char *name, const struct nbt_ntlogon_sam_logon *r)
+{
+ ndr_print_struct(ndr, name, "nbt_ntlogon_sam_logon");
+ ndr->depth++;
+ ndr_print_uint16(ndr, "request_count", r->request_count);
+ ndr_print_string(ndr, "computer_name", r->computer_name);
+ ndr_print_string(ndr, "user_name", r->user_name);
+ ndr_print_string(ndr, "mailslot_name", r->mailslot_name);
+ ndr_print_uint32(ndr, "acct_control", r->acct_control);
+ ndr_print_uint32(ndr, "sid_size", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?ndr_size_dom_sid0(&r->sid, ndr->flags):r->sid_size);
+ ndr_print_dom_sid0(ndr, "sid", &r->sid);
+ ndr_print_uint32(ndr, "nt_version", r->nt_version);
+ ndr_print_uint16(ndr, "lmnt_token", r->lmnt_token);
+ ndr_print_uint16(ndr, "lm20_token", r->lm20_token);
+ ndr->depth--;
+}
+
+static enum ndr_err_code ndr_push_nbt_ntlogon_sam_logon_reply(struct ndr_push *ndr, int ndr_flags, const struct nbt_ntlogon_sam_logon_reply *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_push_align(ndr, 4));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->server));
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->user_name));
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->domain));
+ ndr->flags = _flags_save_string;
+ }
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->nt_version));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lmnt_token));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lm20_token));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_nbt_ntlogon_sam_logon_reply(struct ndr_pull *ndr, int ndr_flags, struct nbt_ntlogon_sam_logon_reply *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_pull_align(ndr, 4));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->server));
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->user_name));
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->domain));
+ ndr->flags = _flags_save_string;
+ }
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->nt_version));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lmnt_token));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lm20_token));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_nbt_ntlogon_sam_logon_reply(struct ndr_print *ndr, const char *name, const struct nbt_ntlogon_sam_logon_reply *r)
+{
+ ndr_print_struct(ndr, name, "nbt_ntlogon_sam_logon_reply");
+ ndr->depth++;
+ ndr_print_string(ndr, "server", r->server);
+ ndr_print_string(ndr, "user_name", r->user_name);
+ ndr_print_string(ndr, "domain", r->domain);
+ ndr_print_uint32(ndr, "nt_version", r->nt_version);
+ ndr_print_uint16(ndr, "lmnt_token", r->lmnt_token);
+ ndr_print_uint16(ndr, "lm20_token", r->lm20_token);
+ ndr->depth--;
+}
+
+static enum ndr_err_code ndr_push_nbt_ntlogon_request(struct ndr_push *ndr, int ndr_flags, const union nbt_ntlogon_request *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ int level = ndr_push_get_switch_value(ndr, r);
+ switch (level) {
+ case NTLOGON_SAM_LOGON: {
+ NDR_CHECK(ndr_push_nbt_ntlogon_sam_logon(ndr, NDR_SCALARS, &r->logon));
+ break; }
+
+ case NTLOGON_SAM_LOGON_REPLY: {
+ NDR_CHECK(ndr_push_nbt_ntlogon_sam_logon_reply(ndr, NDR_SCALARS, &r->reply));
+ break; }
+
+ case NTLOGON_SAM_LOGON_REPLY15: {
+ NDR_CHECK(ndr_push_nbt_ntlogon_sam_logon_reply(ndr, NDR_SCALARS, &r->reply));
+ break; }
+
+ case NETLOGON_RESPONSE_FROM_PDC2: {
+ NDR_CHECK(ndr_push_nbt_netlogon_response_from_pdc2(ndr, NDR_SCALARS, &r->reply2));
+ break; }
+
+ default:
+ return ndr_push_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level);
+ }
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ int level = ndr_push_get_switch_value(ndr, r);
+ switch (level) {
+ case NTLOGON_SAM_LOGON:
+ NDR_CHECK(ndr_push_nbt_ntlogon_sam_logon(ndr, NDR_BUFFERS, &r->logon));
+ break;
+
+ case NTLOGON_SAM_LOGON_REPLY:
+ break;
+
+ case NTLOGON_SAM_LOGON_REPLY15:
+ break;
+
+ case NETLOGON_RESPONSE_FROM_PDC2:
+ break;
+
+ default:
+ return ndr_push_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level);
+ }
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_nbt_ntlogon_request(struct ndr_pull *ndr, int ndr_flags, union nbt_ntlogon_request *r)
+{
+ int level;
+ level = ndr_pull_get_switch_value(ndr, r);
+ if (ndr_flags & NDR_SCALARS) {
+ switch (level) {
+ case NTLOGON_SAM_LOGON: {
+ NDR_CHECK(ndr_pull_nbt_ntlogon_sam_logon(ndr, NDR_SCALARS, &r->logon));
+ break; }
+
+ case NTLOGON_SAM_LOGON_REPLY: {
+ NDR_CHECK(ndr_pull_nbt_ntlogon_sam_logon_reply(ndr, NDR_SCALARS, &r->reply));
+ break; }
+
+ case NTLOGON_SAM_LOGON_REPLY15: {
+ NDR_CHECK(ndr_pull_nbt_ntlogon_sam_logon_reply(ndr, NDR_SCALARS, &r->reply));
+ break; }
+
+ case NETLOGON_RESPONSE_FROM_PDC2: {
+ NDR_CHECK(ndr_pull_nbt_netlogon_response_from_pdc2(ndr, NDR_SCALARS, &r->reply2));
+ break; }
+
+ default:
+ return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level);
+ }
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ switch (level) {
+ case NTLOGON_SAM_LOGON:
+ NDR_CHECK(ndr_pull_nbt_ntlogon_sam_logon(ndr, NDR_BUFFERS, &r->logon));
+ break;
+
+ case NTLOGON_SAM_LOGON_REPLY:
+ break;
+
+ case NTLOGON_SAM_LOGON_REPLY15:
+ break;
+
+ case NETLOGON_RESPONSE_FROM_PDC2:
+ break;
+
+ default:
+ return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level);
+ }
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_nbt_ntlogon_request(struct ndr_print *ndr, const char *name, const union nbt_ntlogon_request *r)
+{
+ int level;
+ level = ndr_print_get_switch_value(ndr, r);
+ ndr_print_union(ndr, name, level, "nbt_ntlogon_request");
+ switch (level) {
+ case NTLOGON_SAM_LOGON:
+ ndr_print_nbt_ntlogon_sam_logon(ndr, "logon", &r->logon);
+ break;
+
+ case NTLOGON_SAM_LOGON_REPLY:
+ ndr_print_nbt_ntlogon_sam_logon_reply(ndr, "reply", &r->reply);
+ break;
+
+ case NTLOGON_SAM_LOGON_REPLY15:
+ ndr_print_nbt_ntlogon_sam_logon_reply(ndr, "reply", &r->reply);
+ break;
+
+ case NETLOGON_RESPONSE_FROM_PDC2:
+ ndr_print_nbt_netlogon_response_from_pdc2(ndr, "reply2", &r->reply2);
+ break;
+
+ default:
+ ndr_print_bad_level(ndr, name, level);
+ }
+}
+
+_PUBLIC_ enum ndr_err_code ndr_push_nbt_ntlogon_packet(struct ndr_push *ndr, int ndr_flags, const struct nbt_ntlogon_packet *r)
+{
+ {
+ uint32_t _flags_save_STRUCT = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_push_align(ndr, 4));
+ NDR_CHECK(ndr_push_nbt_ntlogon_command(ndr, NDR_SCALARS, r->command));
+ NDR_CHECK(ndr_push_set_switch_value(ndr, &r->req, r->command));
+ NDR_CHECK(ndr_push_nbt_ntlogon_request(ndr, NDR_SCALARS, &r->req));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ NDR_CHECK(ndr_push_nbt_ntlogon_request(ndr, NDR_BUFFERS, &r->req));
+ }
+ ndr->flags = _flags_save_STRUCT;
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ enum ndr_err_code ndr_pull_nbt_ntlogon_packet(struct ndr_pull *ndr, int ndr_flags, struct nbt_ntlogon_packet *r)
+{
+ {
+ uint32_t _flags_save_STRUCT = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_pull_align(ndr, 4));
+ NDR_CHECK(ndr_pull_nbt_ntlogon_command(ndr, NDR_SCALARS, &r->command));
+ NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->req, r->command));
+ NDR_CHECK(ndr_pull_nbt_ntlogon_request(ndr, NDR_SCALARS, &r->req));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ NDR_CHECK(ndr_pull_nbt_ntlogon_request(ndr, NDR_BUFFERS, &r->req));
+ }
+ ndr->flags = _flags_save_STRUCT;
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_nbt_ntlogon_packet(struct ndr_print *ndr, const char *name, const struct nbt_ntlogon_packet *r)
+{
+ ndr_print_struct(ndr, name, "nbt_ntlogon_packet");
+ {
+ uint32_t _flags_save_STRUCT = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
+ ndr->depth++;
+ ndr_print_nbt_ntlogon_command(ndr, "command", r->command);
+ ndr_print_set_switch_value(ndr, &r->req, r->command);
+ ndr_print_nbt_ntlogon_request(ndr, "req", &r->req);
+ ndr->depth--;
+ ndr->flags = _flags_save_STRUCT;
+ }
+}
+
+static enum ndr_err_code ndr_push_nbt_browse_opcode(struct ndr_push *ndr, int ndr_flags, enum nbt_browse_opcode r)
+{
+ NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r));
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_nbt_browse_opcode(struct ndr_pull *ndr, int ndr_flags, enum nbt_browse_opcode *r)
+{
+ uint8_t v;
+ NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &v));
+ *r = v;
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_nbt_browse_opcode(struct ndr_print *ndr, const char *name, enum nbt_browse_opcode r)
+{
+ const char *val = NULL;
+
+ switch (r) {
+ case HostAnnouncement: val = "HostAnnouncement"; break;
+ case AnnouncementRequest: val = "AnnouncementRequest"; break;
+ case Election: val = "Election"; break;
+ case GetBackupListReq: val = "GetBackupListReq"; break;
+ case GetBackupListResp: val = "GetBackupListResp"; break;
+ case BecomeBackup: val = "BecomeBackup"; break;
+ case DomainAnnouncement: val = "DomainAnnouncement"; break;
+ case MasterAnnouncement: val = "MasterAnnouncement"; break;
+ case ResetBrowserState: val = "ResetBrowserState"; break;
+ case LocalMasterAnnouncement: val = "LocalMasterAnnouncement"; break;
+ }
+ ndr_print_enum(ndr, name, "ENUM", val, r);
+}
+
+static enum ndr_err_code ndr_push_nbt_browse_host_announcement(struct ndr_push *ndr, int ndr_flags, const struct nbt_browse_host_announcement *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_push_align(ndr, 4));
+ NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r->UpdateCount));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->Periodicity));
+ NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->ServerName, 16, sizeof(uint8_t), CH_DOS));
+ NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r->OSMajor));
+ NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r->OSMinor));
+ NDR_CHECK(ndr_push_svcctl_ServerType(ndr, NDR_SCALARS, r->ServerType));
+ NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r->BroMajorVer));
+ NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r->BroMinorVer));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->Signature));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->Comment));
+ ndr->flags = _flags_save_string;
+ }
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_nbt_browse_host_announcement(struct ndr_pull *ndr, int ndr_flags, struct nbt_browse_host_announcement *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_pull_align(ndr, 4));
+ NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->UpdateCount));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->Periodicity));
+ NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->ServerName, 16, sizeof(uint8_t), CH_DOS));
+ NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->OSMajor));
+ NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->OSMinor));
+ NDR_CHECK(ndr_pull_svcctl_ServerType(ndr, NDR_SCALARS, &r->ServerType));
+ NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->BroMajorVer));
+ NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->BroMinorVer));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->Signature));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->Comment));
+ ndr->flags = _flags_save_string;
+ }
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_nbt_browse_host_announcement(struct ndr_print *ndr, const char *name, const struct nbt_browse_host_announcement *r)
+{
+ ndr_print_struct(ndr, name, "nbt_browse_host_announcement");
+ ndr->depth++;
+ ndr_print_uint8(ndr, "UpdateCount", r->UpdateCount);
+ ndr_print_uint32(ndr, "Periodicity", r->Periodicity);
+ ndr_print_string(ndr, "ServerName", r->ServerName);
+ ndr_print_uint8(ndr, "OSMajor", r->OSMajor);
+ ndr_print_uint8(ndr, "OSMinor", r->OSMinor);
+ ndr_print_svcctl_ServerType(ndr, "ServerType", r->ServerType);
+ ndr_print_uint8(ndr, "BroMajorVer", r->BroMajorVer);
+ ndr_print_uint8(ndr, "BroMinorVer", r->BroMinorVer);
+ ndr_print_uint16(ndr, "Signature", r->Signature);
+ ndr_print_string(ndr, "Comment", r->Comment);
+ ndr->depth--;
+}
+
+static enum ndr_err_code ndr_push_nbt_browse_announcement_request(struct ndr_push *ndr, int ndr_flags, const struct nbt_browse_announcement_request *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_push_align(ndr, 4));
+ NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r->Unused));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->ResponseName));
+ ndr->flags = _flags_save_string;
+ }
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_nbt_browse_announcement_request(struct ndr_pull *ndr, int ndr_flags, struct nbt_browse_announcement_request *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_pull_align(ndr, 4));
+ NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->Unused));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->ResponseName));
+ ndr->flags = _flags_save_string;
+ }
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_nbt_browse_announcement_request(struct ndr_print *ndr, const char *name, const struct nbt_browse_announcement_request *r)
+{
+ ndr_print_struct(ndr, name, "nbt_browse_announcement_request");
+ ndr->depth++;
+ ndr_print_uint8(ndr, "Unused", r->Unused);
+ ndr_print_string(ndr, "ResponseName", r->ResponseName);
+ ndr->depth--;
+}
+
+static enum ndr_err_code ndr_push_nbt_browse_election_request(struct ndr_push *ndr, int ndr_flags, const struct nbt_browse_election_request *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_push_align(ndr, 4));
+ NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r->Version));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->Criteria));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->UpTime));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->Reserved));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->ServerName));
+ ndr->flags = _flags_save_string;
+ }
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_nbt_browse_election_request(struct ndr_pull *ndr, int ndr_flags, struct nbt_browse_election_request *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_pull_align(ndr, 4));
+ NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->Version));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->Criteria));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->UpTime));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->Reserved));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->ServerName));
+ ndr->flags = _flags_save_string;
+ }
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_nbt_browse_election_request(struct ndr_print *ndr, const char *name, const struct nbt_browse_election_request *r)
+{
+ ndr_print_struct(ndr, name, "nbt_browse_election_request");
+ ndr->depth++;
+ ndr_print_uint8(ndr, "Version", r->Version);
+ ndr_print_uint32(ndr, "Criteria", r->Criteria);
+ ndr_print_uint32(ndr, "UpTime", r->UpTime);
+ ndr_print_uint32(ndr, "Reserved", r->Reserved);
+ ndr_print_string(ndr, "ServerName", r->ServerName);
+ ndr->depth--;
+}
+
+static enum ndr_err_code ndr_push_nbt_browse_backup_list_request(struct ndr_push *ndr, int ndr_flags, const struct nbt_browse_backup_list_request *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_push_align(ndr, 4));
+ NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r->ReqCount));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->Token));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_nbt_browse_backup_list_request(struct ndr_pull *ndr, int ndr_flags, struct nbt_browse_backup_list_request *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_pull_align(ndr, 4));
+ NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->ReqCount));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->Token));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_nbt_browse_backup_list_request(struct ndr_print *ndr, const char *name, const struct nbt_browse_backup_list_request *r)
+{
+ ndr_print_struct(ndr, name, "nbt_browse_backup_list_request");
+ ndr->depth++;
+ ndr_print_uint8(ndr, "ReqCount", r->ReqCount);
+ ndr_print_uint32(ndr, "Token", r->Token);
+ ndr->depth--;
+}
+
+static enum ndr_err_code ndr_push_nbt_browse_backup_list_response(struct ndr_push *ndr, int ndr_flags, const struct nbt_browse_backup_list_response *r)
+{
+ uint32_t cntr_BackupServerList_0;
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_push_align(ndr, 4));
+ NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r->BackupCount));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->Token));
+ for (cntr_BackupServerList_0 = 0; cntr_BackupServerList_0 < r->BackupCount; cntr_BackupServerList_0++) {
+ NDR_CHECK(ndr_push_nbt_name(ndr, NDR_SCALARS, &r->BackupServerList[cntr_BackupServerList_0]));
+ }
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_nbt_browse_backup_list_response(struct ndr_pull *ndr, int ndr_flags, struct nbt_browse_backup_list_response *r)
+{
+ uint32_t cntr_BackupServerList_0;
+ TALLOC_CTX *_mem_save_BackupServerList_0;
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_pull_align(ndr, 4));
+ NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->BackupCount));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->Token));
+ NDR_PULL_ALLOC_N(ndr, r->BackupServerList, r->BackupCount);
+ _mem_save_BackupServerList_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->BackupServerList, 0);
+ for (cntr_BackupServerList_0 = 0; cntr_BackupServerList_0 < r->BackupCount; cntr_BackupServerList_0++) {
+ NDR_CHECK(ndr_pull_nbt_name(ndr, NDR_SCALARS, &r->BackupServerList[cntr_BackupServerList_0]));
+ }
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_BackupServerList_0, 0);
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_nbt_browse_backup_list_response(struct ndr_print *ndr, const char *name, const struct nbt_browse_backup_list_response *r)
+{
+ uint32_t cntr_BackupServerList_0;
+ ndr_print_struct(ndr, name, "nbt_browse_backup_list_response");
+ ndr->depth++;
+ ndr_print_uint8(ndr, "BackupCount", r->BackupCount);
+ ndr_print_uint32(ndr, "Token", r->Token);
+ ndr->print(ndr, "%s: ARRAY(%d)", "BackupServerList", r->BackupCount);
+ ndr->depth++;
+ for (cntr_BackupServerList_0=0;cntr_BackupServerList_0<r->BackupCount;cntr_BackupServerList_0++) {
+ char *idx_0=NULL;
+ if (asprintf(&idx_0, "[%d]", cntr_BackupServerList_0) != -1) {
+ ndr_print_nbt_name(ndr, "BackupServerList", &r->BackupServerList[cntr_BackupServerList_0]);
+ free(idx_0);
+ }
+ }
+ ndr->depth--;
+ ndr->depth--;
+}
+
+static enum ndr_err_code ndr_push_nbt_browse_become_backup(struct ndr_push *ndr, int ndr_flags, const struct nbt_browse_become_backup *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_push_align(ndr, 4));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->BrowserName));
+ ndr->flags = _flags_save_string;
+ }
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_nbt_browse_become_backup(struct ndr_pull *ndr, int ndr_flags, struct nbt_browse_become_backup *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_pull_align(ndr, 4));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->BrowserName));
+ ndr->flags = _flags_save_string;
+ }
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_nbt_browse_become_backup(struct ndr_print *ndr, const char *name, const struct nbt_browse_become_backup *r)
+{
+ ndr_print_struct(ndr, name, "nbt_browse_become_backup");
+ ndr->depth++;
+ ndr_print_string(ndr, "BrowserName", r->BrowserName);
+ ndr->depth--;
+}
+
+static enum ndr_err_code ndr_push_nbt_browse_domain_announcement(struct ndr_push *ndr, int ndr_flags, const struct nbt_browse_domain_announcement *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_push_align(ndr, 4));
+ NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r->UpdateCount));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->Periodicity));
+ NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->ServerName, 16, sizeof(uint8_t), CH_DOS));
+ NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r->OSMajor));
+ NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r->OSMinor));
+ NDR_CHECK(ndr_push_svcctl_ServerType(ndr, NDR_SCALARS, r->ServerType));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->MysteriousField));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->Comment));
+ ndr->flags = _flags_save_string;
+ }
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_nbt_browse_domain_announcement(struct ndr_pull *ndr, int ndr_flags, struct nbt_browse_domain_announcement *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_pull_align(ndr, 4));
+ NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->UpdateCount));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->Periodicity));
+ NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->ServerName, 16, sizeof(uint8_t), CH_DOS));
+ NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->OSMajor));
+ NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->OSMinor));
+ NDR_CHECK(ndr_pull_svcctl_ServerType(ndr, NDR_SCALARS, &r->ServerType));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->MysteriousField));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->Comment));
+ ndr->flags = _flags_save_string;
+ }
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_nbt_browse_domain_announcement(struct ndr_print *ndr, const char *name, const struct nbt_browse_domain_announcement *r)
+{
+ ndr_print_struct(ndr, name, "nbt_browse_domain_announcement");
+ ndr->depth++;
+ ndr_print_uint8(ndr, "UpdateCount", r->UpdateCount);
+ ndr_print_uint32(ndr, "Periodicity", r->Periodicity);
+ ndr_print_string(ndr, "ServerName", r->ServerName);
+ ndr_print_uint8(ndr, "OSMajor", r->OSMajor);
+ ndr_print_uint8(ndr, "OSMinor", r->OSMinor);
+ ndr_print_svcctl_ServerType(ndr, "ServerType", r->ServerType);
+ ndr_print_uint32(ndr, "MysteriousField", r->MysteriousField);
+ ndr_print_string(ndr, "Comment", r->Comment);
+ ndr->depth--;
+}
+
+static enum ndr_err_code ndr_push_nbt_browse_master_announcement(struct ndr_push *ndr, int ndr_flags, const struct nbt_browse_master_announcement *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_push_align(ndr, 4));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->ServerName));
+ ndr->flags = _flags_save_string;
+ }
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_nbt_browse_master_announcement(struct ndr_pull *ndr, int ndr_flags, struct nbt_browse_master_announcement *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_pull_align(ndr, 4));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->ServerName));
+ ndr->flags = _flags_save_string;
+ }
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_nbt_browse_master_announcement(struct ndr_print *ndr, const char *name, const struct nbt_browse_master_announcement *r)
+{
+ ndr_print_struct(ndr, name, "nbt_browse_master_announcement");
+ ndr->depth++;
+ ndr_print_string(ndr, "ServerName", r->ServerName);
+ ndr->depth--;
+}
+
+static enum ndr_err_code ndr_push_nbt_browse_reset_state(struct ndr_push *ndr, int ndr_flags, const struct nbt_browse_reset_state *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_push_align(ndr, 1));
+ NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r->Command));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_nbt_browse_reset_state(struct ndr_pull *ndr, int ndr_flags, struct nbt_browse_reset_state *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_pull_align(ndr, 1));
+ NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->Command));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_nbt_browse_reset_state(struct ndr_print *ndr, const char *name, const struct nbt_browse_reset_state *r)
+{
+ ndr_print_struct(ndr, name, "nbt_browse_reset_state");
+ ndr->depth++;
+ ndr_print_uint8(ndr, "Command", r->Command);
+ ndr->depth--;
+}
+
+static enum ndr_err_code ndr_push_nbt_browse_local_master_announcement(struct ndr_push *ndr, int ndr_flags, const struct nbt_browse_local_master_announcement *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_push_align(ndr, 4));
+ NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r->UpdateCount));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->Periodicity));
+ NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->ServerName, 16, sizeof(uint8_t), CH_DOS));
+ NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r->OSMajor));
+ NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r->OSMinor));
+ NDR_CHECK(ndr_push_svcctl_ServerType(ndr, NDR_SCALARS, r->ServerType));
+ NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r->BroMajorVer));
+ NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r->BroMinorVer));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->Signature));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->Comment));
+ ndr->flags = _flags_save_string;
+ }
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_nbt_browse_local_master_announcement(struct ndr_pull *ndr, int ndr_flags, struct nbt_browse_local_master_announcement *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_pull_align(ndr, 4));
+ NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->UpdateCount));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->Periodicity));
+ NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->ServerName, 16, sizeof(uint8_t), CH_DOS));
+ NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->OSMajor));
+ NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->OSMinor));
+ NDR_CHECK(ndr_pull_svcctl_ServerType(ndr, NDR_SCALARS, &r->ServerType));
+ NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->BroMajorVer));
+ NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->BroMinorVer));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->Signature));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->Comment));
+ ndr->flags = _flags_save_string;
+ }
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_nbt_browse_local_master_announcement(struct ndr_print *ndr, const char *name, const struct nbt_browse_local_master_announcement *r)
+{
+ ndr_print_struct(ndr, name, "nbt_browse_local_master_announcement");
+ ndr->depth++;
+ ndr_print_uint8(ndr, "UpdateCount", r->UpdateCount);
+ ndr_print_uint32(ndr, "Periodicity", r->Periodicity);
+ ndr_print_string(ndr, "ServerName", r->ServerName);
+ ndr_print_uint8(ndr, "OSMajor", r->OSMajor);
+ ndr_print_uint8(ndr, "OSMinor", r->OSMinor);
+ ndr_print_svcctl_ServerType(ndr, "ServerType", r->ServerType);
+ ndr_print_uint8(ndr, "BroMajorVer", r->BroMajorVer);
+ ndr_print_uint8(ndr, "BroMinorVer", r->BroMinorVer);
+ ndr_print_uint16(ndr, "Signature", r->Signature);
+ ndr_print_string(ndr, "Comment", r->Comment);
+ ndr->depth--;
+}
+
+static enum ndr_err_code ndr_push_nbt_browse_payload(struct ndr_push *ndr, int ndr_flags, const union nbt_browse_payload *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ int level = ndr_push_get_switch_value(ndr, r);
+ switch (level) {
+ case HostAnnouncement: {
+ NDR_CHECK(ndr_push_nbt_browse_host_announcement(ndr, NDR_SCALARS, &r->host_annoucement));
+ break; }
+
+ case AnnouncementRequest: {
+ NDR_CHECK(ndr_push_nbt_browse_announcement_request(ndr, NDR_SCALARS, &r->announcement_request));
+ break; }
+
+ case Election: {
+ NDR_CHECK(ndr_push_nbt_browse_election_request(ndr, NDR_SCALARS, &r->election_request));
+ break; }
+
+ case GetBackupListReq: {
+ NDR_CHECK(ndr_push_nbt_browse_backup_list_request(ndr, NDR_SCALARS, &r->backup_list_request));
+ break; }
+
+ case GetBackupListResp: {
+ NDR_CHECK(ndr_push_nbt_browse_backup_list_response(ndr, NDR_SCALARS, &r->backup_list_response));
+ break; }
+
+ case BecomeBackup: {
+ NDR_CHECK(ndr_push_nbt_browse_become_backup(ndr, NDR_SCALARS, &r->become_backup));
+ break; }
+
+ case DomainAnnouncement: {
+ NDR_CHECK(ndr_push_nbt_browse_domain_announcement(ndr, NDR_SCALARS, &r->domain_announcement));
+ break; }
+
+ case MasterAnnouncement: {
+ NDR_CHECK(ndr_push_nbt_browse_master_announcement(ndr, NDR_SCALARS, &r->master_announcement));
+ break; }
+
+ case ResetBrowserState: {
+ NDR_CHECK(ndr_push_nbt_browse_reset_state(ndr, NDR_SCALARS, &r->reset_browser_state));
+ break; }
+
+ case LocalMasterAnnouncement: {
+ NDR_CHECK(ndr_push_nbt_browse_local_master_announcement(ndr, NDR_SCALARS, &r->local_master_announcement));
+ break; }
+
+ default:
+ return ndr_push_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level);
+ }
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ int level = ndr_push_get_switch_value(ndr, r);
+ switch (level) {
+ case HostAnnouncement:
+ break;
+
+ case AnnouncementRequest:
+ break;
+
+ case Election:
+ break;
+
+ case GetBackupListReq:
+ break;
+
+ case GetBackupListResp:
+ break;
+
+ case BecomeBackup:
+ break;
+
+ case DomainAnnouncement:
+ break;
+
+ case MasterAnnouncement:
+ break;
+
+ case ResetBrowserState:
+ break;
+
+ case LocalMasterAnnouncement:
+ break;
+
+ default:
+ return ndr_push_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level);
+ }
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_nbt_browse_payload(struct ndr_pull *ndr, int ndr_flags, union nbt_browse_payload *r)
+{
+ int level;
+ level = ndr_pull_get_switch_value(ndr, r);
+ if (ndr_flags & NDR_SCALARS) {
+ switch (level) {
+ case HostAnnouncement: {
+ NDR_CHECK(ndr_pull_nbt_browse_host_announcement(ndr, NDR_SCALARS, &r->host_annoucement));
+ break; }
+
+ case AnnouncementRequest: {
+ NDR_CHECK(ndr_pull_nbt_browse_announcement_request(ndr, NDR_SCALARS, &r->announcement_request));
+ break; }
+
+ case Election: {
+ NDR_CHECK(ndr_pull_nbt_browse_election_request(ndr, NDR_SCALARS, &r->election_request));
+ break; }
+
+ case GetBackupListReq: {
+ NDR_CHECK(ndr_pull_nbt_browse_backup_list_request(ndr, NDR_SCALARS, &r->backup_list_request));
+ break; }
+
+ case GetBackupListResp: {
+ NDR_CHECK(ndr_pull_nbt_browse_backup_list_response(ndr, NDR_SCALARS, &r->backup_list_response));
+ break; }
+
+ case BecomeBackup: {
+ NDR_CHECK(ndr_pull_nbt_browse_become_backup(ndr, NDR_SCALARS, &r->become_backup));
+ break; }
+
+ case DomainAnnouncement: {
+ NDR_CHECK(ndr_pull_nbt_browse_domain_announcement(ndr, NDR_SCALARS, &r->domain_announcement));
+ break; }
+
+ case MasterAnnouncement: {
+ NDR_CHECK(ndr_pull_nbt_browse_master_announcement(ndr, NDR_SCALARS, &r->master_announcement));
+ break; }
+
+ case ResetBrowserState: {
+ NDR_CHECK(ndr_pull_nbt_browse_reset_state(ndr, NDR_SCALARS, &r->reset_browser_state));
+ break; }
+
+ case LocalMasterAnnouncement: {
+ NDR_CHECK(ndr_pull_nbt_browse_local_master_announcement(ndr, NDR_SCALARS, &r->local_master_announcement));
+ break; }
+
+ default:
+ return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level);
+ }
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ switch (level) {
+ case HostAnnouncement:
+ break;
+
+ case AnnouncementRequest:
+ break;
+
+ case Election:
+ break;
+
+ case GetBackupListReq:
+ break;
+
+ case GetBackupListResp:
+ break;
+
+ case BecomeBackup:
+ break;
+
+ case DomainAnnouncement:
+ break;
+
+ case MasterAnnouncement:
+ break;
+
+ case ResetBrowserState:
+ break;
+
+ case LocalMasterAnnouncement:
+ break;
+
+ default:
+ return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level);
+ }
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_nbt_browse_payload(struct ndr_print *ndr, const char *name, const union nbt_browse_payload *r)
+{
+ int level;
+ level = ndr_print_get_switch_value(ndr, r);
+ ndr_print_union(ndr, name, level, "nbt_browse_payload");
+ switch (level) {
+ case HostAnnouncement:
+ ndr_print_nbt_browse_host_announcement(ndr, "host_annoucement", &r->host_annoucement);
+ break;
+
+ case AnnouncementRequest:
+ ndr_print_nbt_browse_announcement_request(ndr, "announcement_request", &r->announcement_request);
+ break;
+
+ case Election:
+ ndr_print_nbt_browse_election_request(ndr, "election_request", &r->election_request);
+ break;
+
+ case GetBackupListReq:
+ ndr_print_nbt_browse_backup_list_request(ndr, "backup_list_request", &r->backup_list_request);
+ break;
+
+ case GetBackupListResp:
+ ndr_print_nbt_browse_backup_list_response(ndr, "backup_list_response", &r->backup_list_response);
+ break;
+
+ case BecomeBackup:
+ ndr_print_nbt_browse_become_backup(ndr, "become_backup", &r->become_backup);
+ break;
+
+ case DomainAnnouncement:
+ ndr_print_nbt_browse_domain_announcement(ndr, "domain_announcement", &r->domain_announcement);
+ break;
+
+ case MasterAnnouncement:
+ ndr_print_nbt_browse_master_announcement(ndr, "master_announcement", &r->master_announcement);
+ break;
+
+ case ResetBrowserState:
+ ndr_print_nbt_browse_reset_state(ndr, "reset_browser_state", &r->reset_browser_state);
+ break;
+
+ case LocalMasterAnnouncement:
+ ndr_print_nbt_browse_local_master_announcement(ndr, "local_master_announcement", &r->local_master_announcement);
+ break;
+
+ default:
+ ndr_print_bad_level(ndr, name, level);
+ }
+}
+
+_PUBLIC_ enum ndr_err_code ndr_push_nbt_browse_packet(struct ndr_push *ndr, int ndr_flags, const struct nbt_browse_packet *r)
+{
+ {
+ uint32_t _flags_save_STRUCT = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_push_align(ndr, 4));
+ NDR_CHECK(ndr_push_nbt_browse_opcode(ndr, NDR_SCALARS, r->opcode));
+ NDR_CHECK(ndr_push_set_switch_value(ndr, &r->payload, r->opcode));
+ NDR_CHECK(ndr_push_nbt_browse_payload(ndr, NDR_SCALARS, &r->payload));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ ndr->flags = _flags_save_STRUCT;
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ enum ndr_err_code ndr_pull_nbt_browse_packet(struct ndr_pull *ndr, int ndr_flags, struct nbt_browse_packet *r)
+{
+ {
+ uint32_t _flags_save_STRUCT = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_pull_align(ndr, 4));
+ NDR_CHECK(ndr_pull_nbt_browse_opcode(ndr, NDR_SCALARS, &r->opcode));
+ NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->payload, r->opcode));
+ NDR_CHECK(ndr_pull_nbt_browse_payload(ndr, NDR_SCALARS, &r->payload));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ ndr->flags = _flags_save_STRUCT;
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_nbt_browse_packet(struct ndr_print *ndr, const char *name, const struct nbt_browse_packet *r)
+{
+ ndr_print_struct(ndr, name, "nbt_browse_packet");
+ {
+ uint32_t _flags_save_STRUCT = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
+ ndr->depth++;
+ ndr_print_nbt_browse_opcode(ndr, "opcode", r->opcode);
+ ndr_print_set_switch_value(ndr, &r->payload, r->opcode);
+ ndr_print_nbt_browse_payload(ndr, "payload", &r->payload);
+ ndr->depth--;
+ ndr->flags = _flags_save_STRUCT;
+ }
+}
+
diff --git a/source3/librpc/gen_ndr/ndr_nbt.h b/source3/librpc/gen_ndr/ndr_nbt.h
new file mode 100644
index 0000000000..645669972d
--- /dev/null
+++ b/source3/librpc/gen_ndr/ndr_nbt.h
@@ -0,0 +1,87 @@
+/* header auto-generated by pidl */
+
+#include "librpc/ndr/libndr.h"
+#include "librpc/gen_ndr/nbt.h"
+
+#ifndef _HEADER_NDR_nbt
+#define _HEADER_NDR_nbt
+
+#include "libcli/nbt/libnbt.h"
+#define NDR_NBT_CALL_COUNT (0)
+void ndr_print_nbt_operation(struct ndr_print *ndr, const char *name, uint16_t r);
+void ndr_print_nbt_name_type(struct ndr_print *ndr, const char *name, enum nbt_name_type r);
+enum ndr_err_code ndr_push_nbt_name(struct ndr_push *ndr, int ndr_flags, const struct nbt_name *r);
+enum ndr_err_code ndr_pull_nbt_name(struct ndr_pull *ndr, int ndr_flags, struct nbt_name *r);
+void ndr_print_nbt_name(struct ndr_print *ndr, const char *name, const struct nbt_name *r);
+void ndr_print_nbt_qclass(struct ndr_print *ndr, const char *name, enum nbt_qclass r);
+void ndr_print_nbt_qtype(struct ndr_print *ndr, const char *name, enum nbt_qtype r);
+void ndr_print_nbt_name_question(struct ndr_print *ndr, const char *name, const struct nbt_name_question *r);
+void ndr_print_nb_flags(struct ndr_print *ndr, const char *name, uint16_t r);
+void ndr_print_nbt_rdata_address(struct ndr_print *ndr, const char *name, const struct nbt_rdata_address *r);
+void ndr_print_nbt_rdata_netbios(struct ndr_print *ndr, const char *name, const struct nbt_rdata_netbios *r);
+void ndr_print_nbt_statistics(struct ndr_print *ndr, const char *name, const struct nbt_statistics *r);
+void ndr_print_nbt_status_name(struct ndr_print *ndr, const char *name, const struct nbt_status_name *r);
+void ndr_print_nbt_rdata_status(struct ndr_print *ndr, const char *name, const struct nbt_rdata_status *r);
+void ndr_print_nbt_rdata_data(struct ndr_print *ndr, const char *name, const struct nbt_rdata_data *r);
+void ndr_print_nbt_rdata(struct ndr_print *ndr, const char *name, const union nbt_rdata *r);
+void ndr_print_nbt_res_rec(struct ndr_print *ndr, const char *name, const struct nbt_res_rec *r);
+enum ndr_err_code ndr_push_nbt_name_packet(struct ndr_push *ndr, int ndr_flags, const struct nbt_name_packet *r);
+enum ndr_err_code ndr_pull_nbt_name_packet(struct ndr_pull *ndr, int ndr_flags, struct nbt_name_packet *r);
+void ndr_print_nbt_name_packet(struct ndr_print *ndr, const char *name, const struct nbt_name_packet *r);
+void ndr_print_dgram_msg_type(struct ndr_print *ndr, const char *name, enum dgram_msg_type r);
+void ndr_print_dgram_flags(struct ndr_print *ndr, const char *name, uint8_t r);
+void ndr_print_smb_command(struct ndr_print *ndr, const char *name, enum smb_command r);
+void ndr_print_smb_trans_body(struct ndr_print *ndr, const char *name, const struct smb_trans_body *r);
+void ndr_print_smb_body(struct ndr_print *ndr, const char *name, const union smb_body *r);
+enum ndr_err_code ndr_push_dgram_smb_packet(struct ndr_push *ndr, int ndr_flags, const struct dgram_smb_packet *r);
+enum ndr_err_code ndr_pull_dgram_smb_packet(struct ndr_pull *ndr, int ndr_flags, struct dgram_smb_packet *r);
+void ndr_print_dgram_smb_packet(struct ndr_print *ndr, const char *name, const struct dgram_smb_packet *r);
+void ndr_print_dgram_message_body(struct ndr_print *ndr, const char *name, const union dgram_message_body *r);
+void ndr_print_dgram_message(struct ndr_print *ndr, const char *name, const struct dgram_message *r);
+void ndr_print_dgram_err_code(struct ndr_print *ndr, const char *name, enum dgram_err_code r);
+void ndr_print_dgram_data(struct ndr_print *ndr, const char *name, const union dgram_data *r);
+enum ndr_err_code ndr_push_nbt_dgram_packet(struct ndr_push *ndr, int ndr_flags, const struct nbt_dgram_packet *r);
+enum ndr_err_code ndr_pull_nbt_dgram_packet(struct ndr_pull *ndr, int ndr_flags, struct nbt_dgram_packet *r);
+void ndr_print_nbt_dgram_packet(struct ndr_print *ndr, const char *name, const struct nbt_dgram_packet *r);
+void ndr_print_nbt_netlogon_command(struct ndr_print *ndr, const char *name, enum nbt_netlogon_command r);
+void ndr_print_nbt_netlogon_query_for_pdc(struct ndr_print *ndr, const char *name, const struct nbt_netlogon_query_for_pdc *r);
+void ndr_print_nbt_netlogon_query_for_pdc2(struct ndr_print *ndr, const char *name, const struct nbt_netlogon_query_for_pdc2 *r);
+void ndr_print_nbt_netlogon_response_from_pdc(struct ndr_print *ndr, const char *name, const struct nbt_netlogon_response_from_pdc *r);
+void ndr_print_nbt_server_type(struct ndr_print *ndr, const char *name, uint32_t r);
+void ndr_print_nbt_netlogon_response_from_pdc2(struct ndr_print *ndr, const char *name, const struct nbt_netlogon_response_from_pdc2 *r);
+void ndr_print_nbt_db_change(struct ndr_print *ndr, const char *name, const struct nbt_db_change *r);
+void ndr_print_nbt_netlogon_announce_uas(struct ndr_print *ndr, const char *name, const struct nbt_netlogon_announce_uas *r);
+void ndr_print_nbt_netlogon_request(struct ndr_print *ndr, const char *name, const union nbt_netlogon_request *r);
+enum ndr_err_code ndr_push_nbt_netlogon_packet(struct ndr_push *ndr, int ndr_flags, const struct nbt_netlogon_packet *r);
+enum ndr_err_code ndr_pull_nbt_netlogon_packet(struct ndr_pull *ndr, int ndr_flags, struct nbt_netlogon_packet *r);
+void ndr_print_nbt_netlogon_packet(struct ndr_print *ndr, const char *name, const struct nbt_netlogon_packet *r);
+void ndr_print_nbt_cldap_netlogon_1(struct ndr_print *ndr, const char *name, const struct nbt_cldap_netlogon_1 *r);
+void ndr_print_nbt_cldap_netlogon_3(struct ndr_print *ndr, const char *name, const struct nbt_cldap_netlogon_3 *r);
+void ndr_print_nbt_cldap_netlogon_5(struct ndr_print *ndr, const char *name, const struct nbt_cldap_netlogon_5 *r);
+void ndr_print_nbt_cldap_netlogon_13(struct ndr_print *ndr, const char *name, const struct nbt_cldap_netlogon_13 *r);
+enum ndr_err_code ndr_push_nbt_cldap_netlogon(struct ndr_push *ndr, int ndr_flags, const union nbt_cldap_netlogon *r);
+enum ndr_err_code ndr_pull_nbt_cldap_netlogon(struct ndr_pull *ndr, int ndr_flags, union nbt_cldap_netlogon *r);
+void ndr_print_nbt_cldap_netlogon(struct ndr_print *ndr, const char *name, const union nbt_cldap_netlogon *r);
+void ndr_print_nbt_ntlogon_command(struct ndr_print *ndr, const char *name, enum nbt_ntlogon_command r);
+void ndr_print_nbt_ntlogon_sam_logon(struct ndr_print *ndr, const char *name, const struct nbt_ntlogon_sam_logon *r);
+void ndr_print_nbt_ntlogon_sam_logon_reply(struct ndr_print *ndr, const char *name, const struct nbt_ntlogon_sam_logon_reply *r);
+void ndr_print_nbt_ntlogon_request(struct ndr_print *ndr, const char *name, const union nbt_ntlogon_request *r);
+enum ndr_err_code ndr_push_nbt_ntlogon_packet(struct ndr_push *ndr, int ndr_flags, const struct nbt_ntlogon_packet *r);
+enum ndr_err_code ndr_pull_nbt_ntlogon_packet(struct ndr_pull *ndr, int ndr_flags, struct nbt_ntlogon_packet *r);
+void ndr_print_nbt_ntlogon_packet(struct ndr_print *ndr, const char *name, const struct nbt_ntlogon_packet *r);
+void ndr_print_nbt_browse_opcode(struct ndr_print *ndr, const char *name, enum nbt_browse_opcode r);
+void ndr_print_nbt_browse_host_announcement(struct ndr_print *ndr, const char *name, const struct nbt_browse_host_announcement *r);
+void ndr_print_nbt_browse_announcement_request(struct ndr_print *ndr, const char *name, const struct nbt_browse_announcement_request *r);
+void ndr_print_nbt_browse_election_request(struct ndr_print *ndr, const char *name, const struct nbt_browse_election_request *r);
+void ndr_print_nbt_browse_backup_list_request(struct ndr_print *ndr, const char *name, const struct nbt_browse_backup_list_request *r);
+void ndr_print_nbt_browse_backup_list_response(struct ndr_print *ndr, const char *name, const struct nbt_browse_backup_list_response *r);
+void ndr_print_nbt_browse_become_backup(struct ndr_print *ndr, const char *name, const struct nbt_browse_become_backup *r);
+void ndr_print_nbt_browse_domain_announcement(struct ndr_print *ndr, const char *name, const struct nbt_browse_domain_announcement *r);
+void ndr_print_nbt_browse_master_announcement(struct ndr_print *ndr, const char *name, const struct nbt_browse_master_announcement *r);
+void ndr_print_nbt_browse_reset_state(struct ndr_print *ndr, const char *name, const struct nbt_browse_reset_state *r);
+void ndr_print_nbt_browse_local_master_announcement(struct ndr_print *ndr, const char *name, const struct nbt_browse_local_master_announcement *r);
+void ndr_print_nbt_browse_payload(struct ndr_print *ndr, const char *name, const union nbt_browse_payload *r);
+enum ndr_err_code ndr_push_nbt_browse_packet(struct ndr_push *ndr, int ndr_flags, const struct nbt_browse_packet *r);
+enum ndr_err_code ndr_pull_nbt_browse_packet(struct ndr_pull *ndr, int ndr_flags, struct nbt_browse_packet *r);
+void ndr_print_nbt_browse_packet(struct ndr_print *ndr, const char *name, const struct nbt_browse_packet *r);
+#endif /* _HEADER_NDR_nbt */
diff --git a/source3/librpc/gen_ndr/security.h b/source3/librpc/gen_ndr/security.h
index a17fd512f7..04655b178e 100644
--- a/source3/librpc/gen_ndr/security.h
+++ b/source3/librpc/gen_ndr/security.h
@@ -5,6 +5,7 @@
#include "librpc/gen_ndr/misc.h"
#define dom_sid2 dom_sid
#define dom_sid28 dom_sid
+#define dom_sid0 dom_sid
#ifndef _HEADER_security
#define _HEADER_security
diff --git a/source3/librpc/idl/drsuapi.idl b/source3/librpc/idl/drsuapi.idl
new file mode 100644
index 0000000000..80d800c533
--- /dev/null
+++ b/source3/librpc/idl/drsuapi.idl
@@ -0,0 +1,1503 @@
+#include "idl_types.h"
+
+import "security.idl", "misc.idl", "samr.idl";
+
+[
+ uuid("e3514235-4b06-11d1-ab04-00c04fc2dcd2"),
+ version(4.0),
+ endpoint("ncacn_np:[\\pipe\\lsass]","ncacn_np:[\\pipe\\protected_storage]", "ncacn_ip_tcp:", "ncalrpc:"),
+ authservice("ldap"),
+ helpstring("Active Directory Replication"),
+ helper("librpc/ndr/ndr_drsuapi.h"),
+ pointer_default(unique)
+]
+interface drsuapi
+{
+ typedef bitmap samr_GroupAttrs samr_GroupAttrs;
+
+ /*****************/
+ /* Function 0x00 */
+ typedef [bitmap32bit] bitmap {
+ DRSUAPI_SUPPORTED_EXTENSION_BASE = 0x00000001,
+ DRSUAPI_SUPPORTED_EXTENSION_ASYNC_REPLICATION = 0x00000002,
+ DRSUAPI_SUPPORTED_EXTENSION_REMOVEAPI = 0x00000004,
+ DRSUAPI_SUPPORTED_EXTENSION_MOVEREQ_V2 = 0x00000008,
+ DRSUAPI_SUPPORTED_EXTENSION_GETCHG_COMPRESS = 0x00000010,
+ DRSUAPI_SUPPORTED_EXTENSION_DCINFO_V1 = 0x00000020,
+ DRSUAPI_SUPPORTED_EXTENSION_RESTORE_USN_OPTIMIZATION = 0x00000040,
+ DRSUAPI_SUPPORTED_EXTENSION_00000080 = 0x00000080,
+ DRSUAPI_SUPPORTED_EXTENSION_KCC_EXECUTE = 0x00000100,
+ DRSUAPI_SUPPORTED_EXTENSION_ADDENTRY_V2 = 0x00000200,
+ DRSUAPI_SUPPORTED_EXTENSION_LINKED_VALUE_REPLICATION = 0x00000400,
+ DRSUAPI_SUPPORTED_EXTENSION_DCINFO_V2 = 0x00000800,
+ DRSUAPI_SUPPORTED_EXTENSION_INSTANCE_TYPE_NOT_REQ_ON_MOD= 0x00001000,
+ DRSUAPI_SUPPORTED_EXTENSION_CRYPTO_BIND = 0x00002000,
+ DRSUAPI_SUPPORTED_EXTENSION_GET_REPL_INFO = 0x00004000,
+ DRSUAPI_SUPPORTED_EXTENSION_STRONG_ENCRYPTION = 0x00008000,
+ DRSUAPI_SUPPORTED_EXTENSION_DCINFO_V01 = 0x00010000,
+ DRSUAPI_SUPPORTED_EXTENSION_TRANSITIVE_MEMBERSHIP = 0x00020000,
+ DRSUAPI_SUPPORTED_EXTENSION_ADD_SID_HISTORY = 0x00040000,
+ DRSUAPI_SUPPORTED_EXTENSION_POST_BETA3 = 0x00080000,
+ DRSUAPI_SUPPORTED_EXTENSION_00100000 = 0x00100000,
+ DRSUAPI_SUPPORTED_EXTENSION_GET_MEMBERSHIPS2 = 0x00200000,
+ DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V6 = 0x00400000,
+ DRSUAPI_SUPPORTED_EXTENSION_NONDOMAIN_NCS = 0x00800000,
+ DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V8 = 0x01000000,
+ DRSUAPI_SUPPORTED_EXTENSION_GETCHGREPLY_V5 = 0x02000000,
+ DRSUAPI_SUPPORTED_EXTENSION_GETCHGREPLY_V6 = 0x04000000,
+ /*
+ * the following 3 have the same value
+ * repadmin.exe /bind says that
+ */
+ DRSUAPI_SUPPORTED_EXTENSION_ADDENTRYREPLY_V3 = 0x08000000,
+ DRSUAPI_SUPPORTED_EXTENSION_GETCHGREPLY_V7 = 0x08000000,
+ DRSUAPI_SUPPORTED_EXTENSION_VERIFY_OBJECT = 0x08000000,
+ DRSUAPI_SUPPORTED_EXTENSION_XPRESS_COMPRESS = 0x10000000,
+ DRSUAPI_SUPPORTED_EXTENSION_20000000 = 0x20000000,
+ DRSUAPI_SUPPORTED_EXTENSION_40000000 = 0x40000000,
+ DRSUAPI_SUPPORTED_EXTENSION_80000000 = 0x80000000
+ } drsuapi_SupportedExtensions;
+
+ /* this is used by w2k */
+ typedef struct {
+ drsuapi_SupportedExtensions supported_extensions;
+ GUID site_guid;
+ uint32 u1;
+ } drsuapi_DsBindInfo24;
+
+ /* this is used by w2k3 */
+ typedef struct {
+ drsuapi_SupportedExtensions supported_extensions;
+ GUID site_guid;
+ uint32 u1;
+ uint32 repl_epoch;
+ } drsuapi_DsBindInfo28;
+
+ typedef struct {
+ [flag(NDR_REMAINING)] DATA_BLOB info;
+ } drsuapi_DsBindInfoFallBack;
+
+ typedef [nodiscriminant] union {
+ [case(24)][subcontext(4)] drsuapi_DsBindInfo24 info24;
+ [case(28)][subcontext(4)] drsuapi_DsBindInfo28 info28;
+ [default][subcontext(4)] drsuapi_DsBindInfoFallBack FallBack;
+ } drsuapi_DsBindInfo;
+
+ /* the drsuapi_DsBindInfoCtr was this before
+ * typedef [flag(NDR_PAHEX)] struct {
+ * [range(1,10000)] uint32 length;
+ * [size_is(length)] uint8 data[];
+ * } drsuapi_DsBindInfo;
+ *
+ * but we don't want the caller to manually decode this blob,
+ * so we're doing it here
+ */
+
+ typedef struct {
+ [range(1,10000)] uint32 length;
+ [switch_is(length)] drsuapi_DsBindInfo info;
+ } drsuapi_DsBindInfoCtr;
+
+ /* this is a magic guid you need to pass to DsBind to make drsuapi_DsWriteAccountSpn() work
+ *
+ * maybe the bind_guid could also be the invocation_id see drsuapi_DsReplicaConnection04
+ */
+ const char *DRSUAPI_DS_BIND_GUID = "e24d201a-4fd6-11d1-a3da-0000f875ae0d";
+ /*
+ * this magic guid are needed to fetch the whole tree with drsuapi_DsGetNCChanges()
+ * as administrator and this values are also used in the destination_dsa_guid field
+ * of drsuapi_DsGetNCChangesReq5/8 and the source_dsa_guid is zero.
+ */
+ const char *DRSUAPI_DS_BIND_GUID_W2K = "6abec3d1-3054-41c8-a362-5a0c5b7d5d71";
+ const char *DRSUAPI_DS_BIND_GUID_W2K3 = "6afab99c-6e26-464a-975f-f58f105218bc";
+
+ [public] WERROR drsuapi_DsBind(
+ [in,unique] GUID *bind_guid,
+ [in,out,unique] drsuapi_DsBindInfoCtr *bind_info,
+ [out] policy_handle *bind_handle
+ );
+
+ /*****************/
+ /* Function 0x01 */
+ WERROR drsuapi_DsUnbind(
+ [in,out] policy_handle *bind_handle
+ );
+
+ /*****************/
+ /* Function 0x02 */
+ typedef [public,gensize] struct {
+ [value(ndr_size_drsuapi_DsReplicaObjectIdentifier(r, ndr->flags)-4)] uint32 __ndr_size;
+ [value(ndr_size_dom_sid28(&sid, ndr->flags))] uint32 __ndr_size_sid;
+ GUID guid;
+ dom_sid28 sid;
+ [value(strlen_m(dn))] uint32 __ndr_size_dn;
+ [charset(UTF16),size_is(__ndr_size_dn+1)] uint16 dn[];
+ } drsuapi_DsReplicaObjectIdentifier;
+
+ typedef [public] bitmap {
+ DRSUAPI_DS_REPLICA_SYNC_ASYNCHRONOUS_OPERATION = 0x00000001,
+ DRSUAPI_DS_REPLICA_SYNC_WRITEABLE = 0x00000002,
+ DRSUAPI_DS_REPLICA_SYNC_PERIODIC = 0x00000004,
+ DRSUAPI_DS_REPLICA_SYNC_INTERSITE_MESSAGING = 0x00000008,
+ DRSUAPI_DS_REPLICA_SYNC_ALL_SOURCES = 0x00000010,
+ DRSUAPI_DS_REPLICA_SYNC_FULL = 0x00000020,
+ DRSUAPI_DS_REPLICA_SYNC_URGENT = 0x00000040,
+ DRSUAPI_DS_REPLICA_SYNC_NO_DISCARD = 0x00000080,
+ DRSUAPI_DS_REPLICA_SYNC_FORCE = 0x00000100,
+ DRSUAPI_DS_REPLICA_SYNC_ADD_REFERENCE = 0x00000200,
+ DRSUAPI_DS_REPLICA_SYNC_NEVER_COMPLETED = 0x00000400,
+ DRSUAPI_DS_REPLICA_SYNC_TWO_WAY = 0x00000800,
+ DRSUAPI_DS_REPLICA_SYNC_NEVER_NOTIFY = 0x00001000,
+ DRSUAPI_DS_REPLICA_SYNC_INITIAL = 0x00002000,
+ DRSUAPI_DS_REPLICA_SYNC_USE_COMPRESSION = 0x00004000,
+ DRSUAPI_DS_REPLICA_SYNC_ABANDONED = 0x00008000,
+ DRSUAPI_DS_REPLICA_SYNC_INITIAL_IN_PROGRESS = 0x00010000,
+ DRSUAPI_DS_REPLICA_SYNC_PARTIAL_ATTRIBUTE_SET = 0x00020000,
+ DRSUAPI_DS_REPLICA_SYNC_REQUEUE = 0x00040000,
+ DRSUAPI_DS_REPLICA_SYNC_NOTIFICATION = 0x00080000,
+ DRSUAPI_DS_REPLICA_SYNC_ASYNCHRONOUS_REPLICA = 0x00100000,
+ DRSUAPI_DS_REPLICA_SYNC_CRITICAL = 0x00200000,
+ DRSUAPI_DS_REPLICA_SYNC_FULL_IN_PROGRESS = 0x00400000,
+ DRSUAPI_DS_REPLICA_SYNC_PREEMPTED = 0x00800000
+ } drsuapi_DsReplicaSyncOptions;
+
+ typedef struct {
+ drsuapi_DsReplicaObjectIdentifier *naming_context;
+ GUID source_dsa_guid;
+ astring *other_info; /* I assume this is related to the repsFromTo1OtherInfo dns_name */
+ drsuapi_DsReplicaSyncOptions options;
+ } drsuapi_DsReplicaSyncRequest1;
+
+ typedef [switch_type(int32)] union {
+ [case(1)] drsuapi_DsReplicaSyncRequest1 req1;
+ } drsuapi_DsReplicaSyncRequest;
+
+ WERROR drsuapi_DsReplicaSync(
+ [in] policy_handle *bind_handle,
+ [in] int32 level,
+ [in,switch_is(level)] drsuapi_DsReplicaSyncRequest req
+ );
+
+ /*****************/
+ /* Function 0x03 */
+ typedef [public] struct {
+ hyper tmp_highest_usn; /* updated after each object update */
+ hyper reserved_usn;
+ hyper highest_usn; /* updated after a full replication cycle */
+ } drsuapi_DsReplicaHighWaterMark;
+
+ typedef [public] struct {
+ GUID source_dsa_invocation_id; /* the 'invocationId' field of the CN=NTDS Settings object */
+ hyper highest_usn; /* updated after a full replication cycle */
+ } drsuapi_DsReplicaCursor;
+
+ typedef struct {
+ uint32 u1;
+ uint32 u2;
+ [range(0,0x100000)] uint32 count;
+ uint32 u3;
+ [size_is(count)] drsuapi_DsReplicaCursor cursors[];
+ } drsuapi_DsReplicaCursorCtrEx;
+
+ typedef [public] bitmap {
+ /* the _WRITEABLE flag indicates a replication with all attributes
+ *
+ * --metze
+ */
+ DRSUAPI_DS_REPLICA_NEIGHBOUR_WRITEABLE = 0x00000010,
+ DRSUAPI_DS_REPLICA_NEIGHBOUR_SYNC_ON_STARTUP = 0x00000020,
+ DRSUAPI_DS_REPLICA_NEIGHBOUR_DO_SCHEDULED_SYNCS = 0x00000040,
+ DRSUAPI_DS_REPLICA_NEIGHBOUR_USE_ASYNC_INTERSIDE_TRANSPORT = 0x00000080,
+ DRSUAPI_DS_REPLICA_NEIGHBOUR_TWO_WAY_SYNC = 0x00000200,
+ DRSUAPI_DS_REPLICA_NEIGHBOUR_RETURN_OBJECT_PARENTS = 0x00000800,
+ DRSUAPI_DS_REPLICA_NEIGHBOUR_FULL_IN_PROGRESS = 0x00001000, /* was 0x00010000, */
+ DRSUAPI_DS_REPLICA_NEIGHBOUR_FULL_NEXT_PACKET = 0x00002000, /* was 0x00020000, */
+ DRSUAPI_DS_REPLICA_NEIGHBOUR_NEVER_SYNCED = 0x00200000,
+ DRSUAPI_DS_REPLICA_NEIGHBOUR_PREEMPTED = 0x01000000,
+ DRSUAPI_DS_REPLICA_NEIGHBOUR_IGNORE_CHANGE_NOTIFICATIONS = 0x04000000,
+ DRSUAPI_DS_REPLICA_NEIGHBOUR_DISABLE_SCHEDULED_SYNC = 0x08000000,
+ /*
+ * the following NOTE applies to DsGetNCChangesRequest5:
+ * - the data is only compressed when 10 or more objects are replicated
+ * - but there could also be a size limit of 35 KBytes or something like that
+ * - the reply is DsGetNCChangesCtr2
+ * - maybe the same applies to DsGetNCChangesRequest8...
+ *
+ * --metze
+ */
+ DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES = 0x10000000,
+ DRSUAPI_DS_REPLICA_NEIGHBOUR_NO_CHANGE_NOTIFICATIONS = 0x20000000,
+ DRSUAPI_DS_REPLICA_NEIGHBOUR_PARTIAL_ATTRIBUTE_SET = 0x40000000
+ } drsuapi_DsReplicaNeighbourFlags;
+
+ typedef struct {
+ GUID destination_dsa_guid;
+ GUID source_dsa_invocation_id; /* the 'invocationId' field of the CN=NTDS Settings object */
+ [ref] drsuapi_DsReplicaObjectIdentifier *naming_context;
+ drsuapi_DsReplicaHighWaterMark highwatermark;
+ drsuapi_DsReplicaCursorCtrEx *uptodateness_vector;
+ drsuapi_DsReplicaNeighbourFlags replica_flags;
+ uint32 max_object_count; /* w2k3 uses min(133,max(100,max_object_count)) */
+ uint32 max_ndr_size; /* w2k3 seems to ignore this */
+ uint32 unknown4;
+ hyper h1;
+ } drsuapi_DsGetNCChangesRequest5;
+
+ /*
+ * In DRSUAPI all attributes with syntax 2.5.5.2
+ * are identified by uint32 values
+ *
+ * the following table shows the mapping used between the two representations
+ * e.g. - objectClass 'nTDSDSA' has governsID: 1.2.840.113556.1.5.7000.47
+ * and a UINT32-ID of '0x0017002F'.
+ * - so the OID 1.2.840.113556.1.5.7000.47 is splitted into a
+ * OID-prefix: 1.2.840.113556.1.5.7000
+ * and a value: 47 => 0x2F
+ * - the mapping table gives a UINT32-prefix: 0x00170000
+ * - and the UINT32-ID is 0x0017002F = 0x00170000 | 0x2F
+ *
+ * This prefix mapping table is replied in the drsuapi_DsReplicaOIDMapping_Ctr
+ * array. The following are the default mappings of w2k3
+ *
+ * OID-prefix => UINT32-Id prefix
+ *
+ * 2.5.4.* => 0x00000000 (standard attributes RFC2256 core.schema)
+ * 2.5.6.* => 0x00010000 (standard object classes RFC2256 core.schema)
+ * 1.2.840.113556.1.2.* => 0x00020000
+ * 1.2.840.113556.1.3.* => 0x00030000
+ * 2.5.5.* => 0x00080000 (attributeSyntax OID's)
+ * 1.2.840.113556.1.4.* => 0x00090000
+ * 1.2.840.113556.1.5.* => 0x000A0000
+ * 2.16.840.1.113730.3.* => 0x00140000
+ * 0.9.2342.19200300.100.1.* => 0x00150000
+ * 2.16.840.1.113730.3.1.* => 0x00160000
+ * 1.2.840.113556.1.5.7000.* => 0x00170000
+ * 2.5.21.* => 0x00180000 (attrs for SubSchema)
+ * 2.5.18.* => 0x00190000 (createTimeStamp,modifyTimeStamp, SubSchema)
+ * 2.5.20.* => 0x001A0000
+ * 1.3.6.1.4.1.1466.101.119.* => 0x001B0000 (dynamicObject, entryTTL)
+ * 2.16.840.1.113730.3.2.* => 0x001C0000
+ * 1.3.6.1.4.1.250.1.* => 0x001D0000
+ * 1.2.840.113549.1.9.* => 0x001E0000 (unstructuredAddress,unstructuredName)
+ * 0.9.2342.19200300.100.4.* => 0x001F0000
+ *
+ * Here's a list of used 'attributeSyntax' OID's
+ *
+ * 2.5.5.1 => Object(DS-DN) string
+ * struct drsuapi_DsObjectIdentifier3
+ *
+ * 2.5.5.2 => OID-string
+ * => all values are represented as uint32 values in drsuapi
+ * => governsID, attributeID and attributeSyntax returned as OID-Strings in LDAP
+ * => mayContain, mustContain and all other attributes with 2.5.5.2 syntax
+ * are returned as attribute names
+ *
+ * 2.5.5.4 => String(Teletex) case-insensitive string with teletex charset
+ *
+ * 2.5.5.5 => String(IA5) case-sensitive string
+ *
+ * 2.5.5.6 => String(Numeric)
+ * => eg. internationalISDNNumber
+ *
+ * 2.5.5.7 => Object(DN-Binary) B:<byte count>:<bytes>:<object DN>
+ * => e.g. wellKnownObjects
+ *
+ * 2.5.5.8 => BOOL
+ *
+ * 2.5.5.9 => int32
+ *
+ * 2.5.5.10 => DATA_BLOB
+ * => struct GUID
+ *
+ * 2.5.5.11 => LDAP timestring
+ * => NTTIME_1sec
+ *
+ * 2.5.5.12 => String(Unicode) case-insensitive string
+ * => 'standard strings'
+ *
+ * 2.5.5.13 => Object(Presentation-Address) string
+ * => used in objectClass applicationEntity
+ *
+ * 2.5.5.14 => Object(DN-String) S:<char count>:<string>:<object DN>
+ * => not used
+ *
+ * 2.5.5.15 => ntSecurityDescriptor
+ *
+ * 2.5.5.16 => int64
+ *
+ * 2.5.5.17 => dom_sid
+ */
+ typedef [nopush,nopull] struct {
+ [range(0,10000),value(ndr_size_drsuapi_DsReplicaOID_oid(oid, 0))] uint32 __ndr_size;
+ [size_is(__ndr_size),charset(DOS)] uint8 *oid; /* it's encoded with asn1_write_OID_String() */
+ } drsuapi_DsReplicaOID;
+
+ typedef struct {
+ uint32 id_prefix;
+ drsuapi_DsReplicaOID oid;
+ } drsuapi_DsReplicaOIDMapping;
+
+ typedef [public] struct {
+ [range(0,0x100000)] uint32 num_mappings;
+ [size_is(num_mappings)] drsuapi_DsReplicaOIDMapping *mappings;
+ } drsuapi_DsReplicaOIDMapping_Ctr;
+
+ typedef [flag(NDR_PAHEX),v1_enum] enum {
+ DRSUAPI_OBJECTCLASS_top = 0x00010000,
+ DRSUAPI_OBJECTCLASS_classSchema = 0x0003000d,
+ DRSUAPI_OBJECTCLASS_attributeSchema = 0x0003000e
+ } drsuapi_DsObjectClassId;
+
+ typedef [flag(NDR_PAHEX),v1_enum,public] enum {
+ DRSUAPI_ATTRIBUTE_objectClass = 0x00000000,
+ DRSUAPI_ATTRIBUTE_description = 0x0000000d,
+ DRSUAPI_ATTRIBUTE_member = 0x0000001f,
+ DRSUAPI_ATTRIBUTE_instanceType = 0x00020001,
+ DRSUAPI_ATTRIBUTE_whenCreated = 0x00020002,
+ DRSUAPI_ATTRIBUTE_hasMasterNCs = 0x0002000e,
+ DRSUAPI_ATTRIBUTE_governsID = 0x00020016,
+ DRSUAPI_ATTRIBUTE_attributeID = 0x0002001e,
+ DRSUAPI_ATTRIBUTE_attributeSyntax = 0x00020020,
+ DRSUAPI_ATTRIBUTE_isSingleValued = 0x00020021,
+ DRSUAPI_ATTRIBUTE_rangeLower = 0x00020022,
+ DRSUAPI_ATTRIBUTE_rangeUpper = 0x00020023,
+ DRSUAPI_ATTRIBUTE_dMDLocation = 0x00020024,
+ DRSUAPI_ATTRIBUTE_objectVersion = 0x0002004c,
+ DRSUAPI_ATTRIBUTE_invocationId = 0x00020073,
+ DRSUAPI_ATTRIBUTE_showInAdvancedViewOnly = 0x000200a9,
+ DRSUAPI_ATTRIBUTE_adminDisplayName = 0x000200c2,
+ DRSUAPI_ATTRIBUTE_adminDescription = 0x000200e2,
+ DRSUAPI_ATTRIBUTE_oMSyntax = 0x000200e7,
+ DRSUAPI_ATTRIBUTE_ntSecurityDescriptor = 0x00020119,
+ DRSUAPI_ATTRIBUTE_searchFlags = 0x0002014e,
+ DRSUAPI_ATTRIBUTE_lDAPDisplayName = 0x000201cc,
+ DRSUAPI_ATTRIBUTE_name = 0x00090001,
+ DRSUAPI_ATTRIBUTE_currentValue = 0x0009001b,
+ DRSUAPI_ATTRIBUTE_objectSid = 0x00090092,
+ DRSUAPI_ATTRIBUTE_schemaIDGUID = 0x00090094,
+ DRSUAPI_ATTRIBUTE_dBCSPwd = 0x00090037,/* lmPwdHash */
+ DRSUAPI_ATTRIBUTE_unicodePwd = 0x0009005a,/* ntPwdHash */
+ DRSUAPI_ATTRIBUTE_ntPwdHistory = 0x0009005e,
+ DRSUAPI_ATTRIBUTE_priorValue = 0x00090064,
+ DRSUAPI_ATTRIBUTE_supplementalCredentials = 0x0009007d,
+ DRSUAPI_ATTRIBUTE_trustAuthIncoming = 0x00090081,
+ DRSUAPI_ATTRIBUTE_trustAuthOutgoing = 0x00090087,
+ DRSUAPI_ATTRIBUTE_lmPwdHistory = 0x000900a0,
+ DRSUAPI_ATTRIBUTE_sAMAccountName = 0x000900dd,
+ DRSUAPI_ATTRIBUTE_fSMORoleOwner = 0x00090171,
+ DRSUAPI_ATTRIBUTE_systemFlags = 0x00090177,
+ DRSUAPI_ATTRIBUTE_serverReference = 0x00090203,
+ DRSUAPI_ATTRIBUTE_serverReferenceBL = 0x00090204,
+ DRSUAPI_ATTRIBUTE_initialAuthIncoming = 0x0009021b,
+ DRSUAPI_ATTRIBUTE_initialAuthOutgoing = 0x0009021c,
+ DRSUAPI_ATTRIBUTE_wellKnownObjects = 0x0009026a,
+ DRSUAPI_ATTRIBUTE_isMemberOfPartialAttributeSet = 0x0009027f,
+ DRSUAPI_ATTRIBUTE_objectCategory = 0x0009030e,
+ DRSUAPI_ATTRIBUTE_gPLink = 0x0009037b,
+ DRSUAPI_ATTRIBUTE_msDS_Behavior_Version = 0x000905b3,
+ DRSUAPI_ATTRIBUTE_msDS_KeyVersionNumber = 0x000906f6,
+ DRSUAPI_ATTRIBUTE_msDS_HasDomainNCs = 0x0009071c,
+ DRSUAPI_ATTRIBUTE_msDS_hasMasterNCs = 0x0009072c
+ } drsuapi_DsAttributeId;
+
+ typedef struct {
+ GUID destination_dsa_guid;
+ GUID source_dsa_invocation_id; /* the 'invocationId' field of the CN=NTDS Settings object */
+ [ref] drsuapi_DsReplicaObjectIdentifier *naming_context;
+ drsuapi_DsReplicaHighWaterMark highwatermark;
+ drsuapi_DsReplicaCursorCtrEx *uptodateness_vector;
+ drsuapi_DsReplicaNeighbourFlags replica_flags;
+ uint32 max_object_count; /* w2k3 uses min(133,max(100,max_object_count)) */
+ uint32 max_ndr_size; /* w2k3 seems to ignore this */
+ uint32 unknown4;
+ hyper h1;
+ uint32 unique_ptr1;
+ uint32 unique_ptr2;
+ drsuapi_DsReplicaOIDMapping_Ctr mapping_ctr;
+ } drsuapi_DsGetNCChangesRequest8;
+
+ typedef [switch_type(int32)] union {
+ [case(5)] drsuapi_DsGetNCChangesRequest5 req5;
+ [case(8)] drsuapi_DsGetNCChangesRequest8 req8;
+ } drsuapi_DsGetNCChangesRequest;
+
+ typedef [public] struct {
+ GUID source_dsa_invocation_id; /* the 'invocationId' field of the CN=NTDS Settings object */
+ hyper highest_usn; /* updated after a full replication cycle */
+ NTTIME last_sync_success;
+ } drsuapi_DsReplicaCursor2;
+
+ typedef struct {
+ uint32 u1;
+ uint32 u2;
+ [range(0,0x100000)] uint32 count;
+ uint32 u3;
+ [size_is(count)] drsuapi_DsReplicaCursor2 cursors[];
+ } drsuapi_DsReplicaCursor2CtrEx;
+
+ /* Generic DATA_BLOB values */
+ typedef struct {
+ [range(0,10485760),value(ndr_size_DATA_BLOB(0,blob,0))] uint32 __ndr_size;
+ DATA_BLOB *blob;
+ } drsuapi_DsAttributeValue;
+
+ typedef struct {
+ [range(0,10485760)] uint32 num_values;
+ [size_is(num_values)] drsuapi_DsAttributeValue *values;
+ } drsuapi_DsAttributeValueCtr;
+
+ /* DN String values */
+ typedef [public,gensize] struct {
+ [value(ndr_size_drsuapi_DsReplicaObjectIdentifier3(r, ndr->flags))] uint32 __ndr_size;
+ [value(ndr_size_dom_sid28(&sid,ndr->flags))] uint32 __ndr_size_sid;
+ GUID guid;
+ dom_sid28 sid;
+ [value(strlen_m(dn))] uint32 __ndr_size_dn;
+ [charset(UTF16)] uint16 dn[__ndr_size_dn+1];
+ } drsuapi_DsReplicaObjectIdentifier3;
+
+ typedef [public,gensize] struct {
+ [value(ndr_size_drsuapi_DsReplicaObjectIdentifier3Binary(r, ndr->flags))] uint32 __ndr_size;
+ [value(ndr_size_dom_sid28(&sid,ndr->flags))] uint32 __ndr_size_sid;
+ GUID guid;
+ dom_sid28 sid;
+ [value(strlen_m(dn))] uint32 __ndr_size_dn;
+ [charset(UTF16)] uint16 dn[__ndr_size_dn+1];
+ [value(binary.length + 4)] uint32 __ndr_size_binary;
+ [flag(NDR_REMAINING)] DATA_BLOB binary;
+ } drsuapi_DsReplicaObjectIdentifier3Binary;
+
+ typedef [public] struct {
+ drsuapi_DsAttributeId attid;
+ drsuapi_DsAttributeValueCtr value_ctr;
+ } drsuapi_DsReplicaAttribute;
+
+ typedef struct {
+ [range(0,1048576)] uint32 num_attributes;
+ [size_is(num_attributes)] drsuapi_DsReplicaAttribute *attributes;
+ } drsuapi_DsReplicaAttributeCtr;
+
+ typedef [public] struct {
+ drsuapi_DsReplicaObjectIdentifier *identifier;
+ uint32 unknown1;
+ drsuapi_DsReplicaAttributeCtr attribute_ctr;
+ } drsuapi_DsReplicaObject;
+
+ typedef struct {
+ uint32 version;
+ NTTIME_1sec originating_change_time;
+ GUID originating_invocation_id;
+ hyper originating_usn;
+ } drsuapi_DsReplicaMetaData;
+
+ typedef [public] struct {
+ [range(0,1048576)] uint32 count;
+ [size_is(count)] drsuapi_DsReplicaMetaData meta_data[];
+ } drsuapi_DsReplicaMetaDataCtr;
+
+ typedef [public,noprint] struct {
+ drsuapi_DsReplicaObjectListItemEx *next_object;
+ drsuapi_DsReplicaObject object;
+ uint32 unknown1;
+ GUID *parent_object_guid;
+ drsuapi_DsReplicaMetaDataCtr *meta_data_ctr;
+ } drsuapi_DsReplicaObjectListItemEx;
+
+ typedef [public,gensize] struct {
+ GUID source_dsa_guid; /* the 'objectGUID' field of the CN=NTDS Settings object */
+ GUID source_dsa_invocation_id; /* the 'invocationId' field of the CN=NTDS Settings object */
+ drsuapi_DsReplicaObjectIdentifier *naming_context;
+ drsuapi_DsReplicaHighWaterMark old_highwatermark;
+ drsuapi_DsReplicaHighWaterMark new_highwatermark;
+ drsuapi_DsReplicaCursorCtrEx *uptodateness_vector;
+ drsuapi_DsReplicaOIDMapping_Ctr mapping_ctr;
+ uint32 total_object_count;
+ uint32 object_count;
+ /* this +55 is sometimes +56, so I don't know where this comes from... --metze */
+ [value(ndr_size_drsuapi_DsGetNCChangesCtr1(r,ndr->flags)+55)] uint32 __ndr_size;
+ drsuapi_DsReplicaObjectListItemEx *first_object;
+ uint32 unknown4;
+ } drsuapi_DsGetNCChangesCtr1;
+
+ /*
+ * if the DRSUAPI_DS_LINKED_ATTRIBUTE_FLAG_ACTIVE flag
+ * isn't there it means the value is deleted
+ */
+ typedef [public] bitmap {
+ DRSUAPI_DS_LINKED_ATTRIBUTE_FLAG_ACTIVE = 0x00000001
+ } drsuapi_DsLinkedAttributeFlags;
+
+ typedef [public] struct {
+ drsuapi_DsReplicaObjectIdentifier *identifier;
+ drsuapi_DsAttributeId attid;
+ drsuapi_DsAttributeValue value;
+ drsuapi_DsLinkedAttributeFlags flags;
+ NTTIME_1sec originating_add_time;
+ drsuapi_DsReplicaMetaData meta_data;
+ } drsuapi_DsReplicaLinkedAttribute;
+
+ typedef [public,gensize] struct {
+ GUID source_dsa_guid; /* the 'objectGUID' field of the CN=NTDS Settings object */
+ GUID source_dsa_invocation_id; /* the 'invocationId' field of the CN=NTDS Settings object */
+ drsuapi_DsReplicaObjectIdentifier *naming_context;
+ drsuapi_DsReplicaHighWaterMark old_highwatermark;
+ drsuapi_DsReplicaHighWaterMark new_highwatermark;
+ drsuapi_DsReplicaCursor2CtrEx *uptodateness_vector;
+ drsuapi_DsReplicaOIDMapping_Ctr mapping_ctr;
+ uint32 total_object_count;
+ uint32 object_count;
+ /* this +55 is sometimes +56, so I don't know where this comes from... --metze */
+ [value(ndr_size_drsuapi_DsGetNCChangesCtr6(r,ndr->flags)+55)] uint32 __ndr_size;
+ drsuapi_DsReplicaObjectListItemEx *first_object;
+ uint32 unknown4;
+ uint32 unknown5;
+ uint32 unknown6;
+ [range(0,1048576)] uint32 linked_attributes_count;
+ [size_is(linked_attributes_count)] drsuapi_DsReplicaLinkedAttribute *linked_attributes;
+ uint32 unknown7;
+ } drsuapi_DsGetNCChangesCtr6;
+
+ typedef struct {
+ uint32 decompressed_length;
+ uint32 compressed_length;
+ [subcontext(4),subcontext_size(compressed_length),
+ compression(NDR_COMPRESSION_MSZIP,compressed_length,decompressed_length)]
+ drsuapi_DsGetNCChangesCtr1 *ctr1;
+ } drsuapi_DsGetNCChangesMSZIPCtr1;
+
+ typedef struct {
+ uint32 decompressed_length;
+ uint32 compressed_length;
+ [subcontext(4),subcontext_size(compressed_length),
+ compression(NDR_COMPRESSION_MSZIP,compressed_length,decompressed_length)]
+ drsuapi_DsGetNCChangesCtr6 *ctr6;
+ } drsuapi_DsGetNCChangesMSZIPCtr6;
+
+ typedef struct {
+ uint32 decompressed_length;
+ uint32 compressed_length;
+ [subcontext(4),subcontext_size(compressed_length),
+ compression(NDR_COMPRESSION_XPRESS,compressed_length,decompressed_length),
+ flag(NDR_REMAINING)] DATA_BLOB *decompressed;
+ } drsuapi_DsGetNCChangesXPRESSCtr1;
+
+ typedef struct {
+ uint32 decompressed_length;
+ uint32 compressed_length;
+ [subcontext(4),subcontext_size(compressed_length),
+ compression(NDR_COMPRESSION_XPRESS,compressed_length,decompressed_length),
+ flag(NDR_REMAINING)] DATA_BLOB *decompressed;
+ } drsuapi_DsGetNCChangesXPRESSCtr6;
+
+ typedef [enum16bit] enum {
+ DRSUAPI_COMPRESSION_TYPE_MSZIP = 2,
+ DRSUAPI_COMPRESSION_TYPE_XPRESS = 3
+ } drsuapi_DsGetNCChangesCompressionType;
+
+ typedef [nodiscriminant,flag(NDR_PAHEX)] union {
+ [case(1|(DRSUAPI_COMPRESSION_TYPE_MSZIP<<16))] drsuapi_DsGetNCChangesMSZIPCtr1 mszip1;
+ [case(6|(DRSUAPI_COMPRESSION_TYPE_MSZIP<<16))] drsuapi_DsGetNCChangesMSZIPCtr6 mszip6;
+ [case(1|(DRSUAPI_COMPRESSION_TYPE_XPRESS<<16))] drsuapi_DsGetNCChangesXPRESSCtr1 xpress1;
+ [case(6|(DRSUAPI_COMPRESSION_TYPE_XPRESS<<16))] drsuapi_DsGetNCChangesXPRESSCtr6 xpress6;
+ } drsuapi_DsGetNCChangesCompressedCtr;
+
+ typedef struct {
+ /*
+ * this is a bit ugly, as the compression depends on the flags
+ * in the DsBind(), but only w2k uses DsGetNCChangesReq5
+ * and will get DsGetNCChangesCtr2 replies, and w2k only knowns
+ * about MSZIP and level 1 replies
+ */
+ [switch_is(1|(DRSUAPI_COMPRESSION_TYPE_MSZIP<<16))] drsuapi_DsGetNCChangesCompressedCtr ctr;
+ } drsuapi_DsGetNCChangesCtr2;
+
+ typedef struct {
+ [range(0,6)] int32 level;
+ [range(2,3)] drsuapi_DsGetNCChangesCompressionType type;
+ [switch_is(level | (type<<16))] drsuapi_DsGetNCChangesCompressedCtr ctr;
+ } drsuapi_DsGetNCChangesCtr7;
+
+ typedef [switch_type(int32)] union {
+ [case(1)] drsuapi_DsGetNCChangesCtr1 ctr1;
+ [case(2)] drsuapi_DsGetNCChangesCtr2 ctr2;
+ [case(6)] drsuapi_DsGetNCChangesCtr6 ctr6;
+ [case(7)] drsuapi_DsGetNCChangesCtr7 ctr7;
+ } drsuapi_DsGetNCChangesCtr;
+
+ WERROR drsuapi_DsGetNCChanges(
+ [in] policy_handle *bind_handle,
+ [in,out,ref] int32 *level,
+ [in,ref,switch_is(*level)] drsuapi_DsGetNCChangesRequest *req,
+ [out,ref,switch_is(*level)] drsuapi_DsGetNCChangesCtr *ctr
+ );
+
+ /*****************/
+ /* Function 0x04 */
+ typedef bitmap {
+ DRSUAPI_DS_REPLICA_UPDATE_ASYNCHRONOUS_OPERATION = 0x00000001,
+ DRSUAPI_DS_REPLICA_UPDATE_WRITEABLE = 0x00000002,
+ DRSUAPI_DS_REPLICA_UPDATE_ADD_REFERENCE = 0x00000004,
+ DRSUAPI_DS_REPLICA_UPDATE_DELETE_REFERENCE = 0x00000008,
+ DRSUAPI_DS_REPLICA_UPDATE_0x00000010 = 0x00000010
+ } drsuapi_DsReplicaUpdateRefsOptions;
+
+ typedef struct {
+ [ref] drsuapi_DsReplicaObjectIdentifier *naming_context;
+ [ref,charset(DOS),string] uint8 *dest_dsa_dns_name;
+ GUID dest_dsa_guid;
+ drsuapi_DsReplicaUpdateRefsOptions options;
+ } drsuapi_DsReplicaUpdateRefsRequest1;
+
+ typedef [switch_type(int32)] union {
+ [case(1)] drsuapi_DsReplicaUpdateRefsRequest1 req1;
+ } drsuapi_DsReplicaUpdateRefsRequest;
+
+ WERROR drsuapi_DsReplicaUpdateRefs(
+ [in] policy_handle *bind_handle,
+ [in] int32 level,
+ [in,switch_is(level)] drsuapi_DsReplicaUpdateRefsRequest req
+ );
+
+ /*****************/
+ /* Function 0x05 */
+ typedef bitmap {
+ DRSUAPI_DS_REPLICA_ADD_ASYNCHRONOUS_OPERATION = 0x00000001,
+ DRSUAPI_DS_REPLICA_ADD_WRITEABLE = 0x00000002
+ /* TODO ... */
+ } drsuapi_DsReplicaAddOptions;
+
+ WERROR DRSUAPI_REPLICA_ADD();
+
+ /*****************/
+ /* Function 0x06 */
+ typedef bitmap {
+ DRSUAPI_DS_REPLICA_DELETE_ASYNCHRONOUS_OPERATION = 0x00000001,
+ DRSUAPI_DS_REPLICA_DELETE_WRITEABLE = 0x00000002
+ /* TODO ... */
+ } drsuapi_DsReplicaDeleteOptions;
+
+ WERROR DRSUAPI_REPLICA_DEL();
+
+ /*****************/
+ /* Function 0x07 */
+ typedef bitmap {
+ DRSUAPI_DS_REPLICA_MODIFY_ASYNCHRONOUS_OPERATION = 0x00000001,
+ DRSUAPI_DS_REPLICA_MODIFY_WRITEABLE = 0x00000002
+ } drsuapi_DsReplicaModifyOptions;
+
+ WERROR DRSUAPI_REPLICA_MODIFY();
+
+ /*****************/
+ /* Function 0x08 */
+ WERROR DRSUAPI_VERIFY_NAMES();
+
+ /*****************/
+ /* Function 0x09 */
+
+ /* how are type 4 and 7 different from 2 and 3 ? */
+ typedef [v1_enum] enum {
+ DRSUAPI_DS_MEMBERSHIP_TYPE_UNIVERSAL_AND_DOMAIN_GROUPS = 1,
+ DRSUAPI_DS_MEMBERSHIP_TYPE_DOMAIN_LOCAL_GROUPS = 2,
+ DRSUAPI_DS_MEMBERSHIP_TYPE_DOMAIN_GROUPS = 3,
+ DRSUAPI_DS_MEMBERSHIP_TYPE_DOMAIN_LOCAL_GROUPS2 = 4,
+ DRSUAPI_DS_MEMBERSHIP_TYPE_UNIVERSAL_GROUPS = 5,
+ DRSUAPI_DS_MEMBERSHIP_TYPE_GROUPMEMBERS = 6,
+ DRSUAPI_DS_MEMBERSHIP_TYPE_DOMAIN_GROUPS2 = 7
+ } drsuapi_DsMembershipType;
+
+ typedef struct {
+ NTSTATUS status;
+ [range(0,10000)] uint32 num_memberships;
+ [range(0,10000)] uint32 num_sids;
+ [size_is(num_memberships)] drsuapi_DsReplicaObjectIdentifier **info_array;
+ [size_is(num_memberships)] samr_GroupAttrs *group_attrs;
+ [size_is(num_sids)] dom_sid28 **sids;
+ } drsuapi_DsGetMembershipsCtr1;
+
+ typedef [switch_type(int32)] union {
+ [case(1)] drsuapi_DsGetMembershipsCtr1 ctr1;
+ } drsuapi_DsGetMembershipsCtr;
+
+ const int DRSUAPI_DS_MEMBERSHIP_FLAG_GROUP_ATTR = 0x1;
+
+ typedef struct {
+ [range(1,10000)] uint32 count;
+ [size_is(count)] drsuapi_DsReplicaObjectIdentifier **info_array;
+ uint32 flags;
+ drsuapi_DsMembershipType type;
+ drsuapi_DsReplicaObjectIdentifier *domain;
+ } drsuapi_DsGetMembershipsRequest1;
+
+ typedef [switch_type(int32)] union {
+ [case(1)] drsuapi_DsGetMembershipsRequest1 req1;
+ } drsuapi_DsGetMembershipsRequest;
+
+ WERROR drsuapi_DsGetMemberships(
+ [in] policy_handle *bind_handle,
+ [in] int32 level,
+ [in,ref] [switch_is(level)] drsuapi_DsGetMembershipsRequest *req,
+ [out,ref] int32 *level_out,
+ [out,ref] [switch_is(*level_out)] drsuapi_DsGetMembershipsCtr *ctr
+ );
+
+ /*****************/
+ /* Function 0x0a */
+ WERROR DRSUAPI_INTER_DOMAIN_MOVE();
+
+ /*****************/
+ /* Function 0x0b */
+ typedef struct {
+ uint32 unknown1;
+ uint32 unknown2;
+ [range(0,0x00A00000)] uint32 length;
+ [size_is(length)] uint8 *data;
+ } drsuapi_DsGetNT4ChangeLogRequest1;
+
+ typedef [switch_type(uint32)] union {
+ [case(1)] drsuapi_DsGetNT4ChangeLogRequest1 req1;
+ } drsuapi_DsGetNT4ChangeLogRequest;
+
+ typedef struct {
+ [range(0,0x00A00000)] uint32 length1;
+ [range(0,0x00A00000)] uint32 length2;
+ hyper unknown1;
+ NTTIME time2;
+ hyper unknown3;
+ NTTIME time4;
+ hyper unknown5;
+ NTTIME time6;
+ NTSTATUS status;
+ [size_is(length1)] uint8 *data1;
+ [size_is(length2)] uint8 *data2;
+ } drsuapi_DsGetNT4ChangeLogInfo1;
+
+ typedef [switch_type(uint32)] union {
+ [case(1)] drsuapi_DsGetNT4ChangeLogInfo1 info1;
+ } drsuapi_DsGetNT4ChangeLogInfo;
+
+ WERROR drsuapi_DsGetNT4ChangeLog(
+ [in] policy_handle *bind_handle,
+ [in] uint32 level,
+ [in,ref] [switch_is(level)] drsuapi_DsGetNT4ChangeLogRequest *req,
+ [out,ref] uint32 *level_out,
+ [out,ref] [switch_is(*level_out)] drsuapi_DsGetNT4ChangeLogInfo *info
+ );
+
+ /*****************/
+ /* Function 0x0c */
+ typedef [v1_enum] enum {
+ DRSUAPI_DS_NAME_STATUS_OK = 0,
+ DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR = 1,
+ DRSUAPI_DS_NAME_STATUS_NOT_FOUND = 2,
+ DRSUAPI_DS_NAME_STATUS_NOT_UNIQUE = 3,
+ DRSUAPI_DS_NAME_STATUS_NO_MAPPING = 4,
+ DRSUAPI_DS_NAME_STATUS_DOMAIN_ONLY = 5,
+ DRSUAPI_DS_NAME_STATUS_NO_SYNTACTICAL_MAPPING = 6,
+ DRSUAPI_DS_NAME_STATUS_TRUST_REFERRAL = 7
+ } drsuapi_DsNameStatus;
+
+ typedef [v1_enum] enum {
+ DRSUAPI_DS_NAME_FLAG_NO_FLAGS = 0x0,
+ DRSUAPI_DS_NAME_FLAG_SYNTACTICAL_ONLY = 0x1,
+ DRSUAPI_DS_NAME_FLAG_EVAL_AT_DC = 0x2,
+ DRSUAPI_DS_NAME_FLAG_GCVERIFY = 0x4,
+ DRSUAPI_DS_NAME_FLAG_TRUST_REFERRAL = 0x8
+ } drsuapi_DsNameFlags;
+
+ typedef [v1_enum] enum {
+ DRSUAPI_DS_NAME_FORMAT_UKNOWN = 0,
+ DRSUAPI_DS_NAME_FORMAT_FQDN_1779 = 1,
+ DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT = 2,
+ DRSUAPI_DS_NAME_FORMAT_DISPLAY = 3,
+ DRSUAPI_DS_NAME_FORMAT_GUID = 6,
+ DRSUAPI_DS_NAME_FORMAT_CANONICAL = 7,
+ DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL = 8,
+ DRSUAPI_DS_NAME_FORMAT_CANONICAL_EX = 9,
+ DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL = 10,
+ DRSUAPI_DS_NAME_FORMAT_SID_OR_SID_HISTORY = 11,
+ DRSUAPI_DS_NAME_FORMAT_DNS_DOMAIN = 12
+ } drsuapi_DsNameFormat;
+
+ typedef struct {
+ [string,charset(UTF16)] uint16 *str;
+ } drsuapi_DsNameString;
+
+ typedef struct {
+ uint32 codepage; /* 0x000004e4 - 1252 is german codepage*/
+ uint32 language; /* 0x00000407 - german language ID*/
+ drsuapi_DsNameFlags format_flags;
+ drsuapi_DsNameFormat format_offered;
+ drsuapi_DsNameFormat format_desired;
+ [range(1,10000)] uint32 count;
+ [size_is(count)] drsuapi_DsNameString *names;
+ } drsuapi_DsNameRequest1;
+
+ typedef [switch_type(int32)] union {
+ [case(1)] drsuapi_DsNameRequest1 req1;
+ } drsuapi_DsNameRequest;
+
+ typedef struct {
+ drsuapi_DsNameStatus status;
+ [charset(UTF16),string] uint16 *dns_domain_name;
+ [charset(UTF16),string] uint16 *result_name;
+ } drsuapi_DsNameInfo1;
+
+ typedef struct {
+ uint32 count;
+ [size_is(count)] drsuapi_DsNameInfo1 *array;
+ } drsuapi_DsNameCtr1;
+
+ typedef [switch_type(int32)] union {
+ [case(1)] drsuapi_DsNameCtr1 *ctr1;
+ } drsuapi_DsNameCtr;
+
+ WERROR drsuapi_DsCrackNames(
+ [in] policy_handle *bind_handle,
+ [in] int32 level,
+ [in,ref,switch_is(level)] drsuapi_DsNameRequest *req,
+ [out,ref] int32 *level_out,
+ [out,ref,switch_is(*level_out)] drsuapi_DsNameCtr *ctr
+ );
+
+ /*****************/
+ /* Function 0x0d */
+ typedef [v1_enum] enum {
+ DRSUAPI_DS_SPN_OPERATION_ADD = 0,
+ DRSUAPI_DS_SPN_OPERATION_REPLACE= 1,
+ DRSUAPI_DS_SPN_OPERATION_DELETE = 2
+ } drsuapi_DsSpnOperation;
+
+ typedef struct {
+ drsuapi_DsSpnOperation operation;
+ uint32 unknown1;
+ [charset(UTF16),string] uint16 *object_dn;
+ [range(0,10000)] uint32 count;
+ [size_is(count)] drsuapi_DsNameString *spn_names;
+ } drsuapi_DsWriteAccountSpnRequest1;
+
+ typedef [switch_type(int32)] union {
+ [case(1)] drsuapi_DsWriteAccountSpnRequest1 req1;
+ } drsuapi_DsWriteAccountSpnRequest;
+
+ typedef struct {
+ WERROR status;
+ } drsuapi_DsWriteAccountSpnResult1;
+
+ typedef [switch_type(int32)] union {
+ [case(1)] drsuapi_DsWriteAccountSpnResult1 res1;
+ } drsuapi_DsWriteAccountSpnResult;
+
+ WERROR drsuapi_DsWriteAccountSpn(
+ [in] policy_handle *bind_handle,
+ [in] int32 level,
+ [in,ref,switch_is(level)] drsuapi_DsWriteAccountSpnRequest *req,
+ [out,ref] int32 *level_out,
+ [out,ref,switch_is(*level_out)] drsuapi_DsWriteAccountSpnResult *res
+ );
+
+ /*****************/
+ /* Function 0x0e */
+ typedef struct {
+ [charset(UTF16),string] uint16 *server_dn;
+ [charset(UTF16),string] uint16 *domain_dn;
+ uint32 unknown; /* 0x000000001 */
+ } drsuapi_DsRemoveDSServerRequest1;
+
+ typedef [switch_type(int32)] union {
+ [case(1)] drsuapi_DsRemoveDSServerRequest1 req1;
+ } drsuapi_DsRemoveDSServerRequest;
+
+ typedef struct {
+ WERROR status;
+ } drsuapi_DsRemoveDSServerResult1;
+
+ typedef [switch_type(int32)] union {
+ [case(1)] drsuapi_DsRemoveDSServerResult1 res1;
+ } drsuapi_DsRemoveDSServerResult;
+
+ WERROR drsuapi_DsRemoveDSServer(
+ [in] policy_handle *bind_handle,
+ [in] int32 level,
+ [in,ref,switch_is(level)] drsuapi_DsRemoveDSServerRequest *req,
+ [out,ref] int32 *level_out,
+ [out,ref,switch_is(*level_out)] drsuapi_DsRemoveDSServerResult *res
+ );
+
+ /*****************/
+ /* Function 0x0f */
+ WERROR DRSUAPI_REMOVE_DS_DOMAIN();
+
+ /*****************/
+ /* Function 0x10 */
+ typedef struct {
+ [charset(UTF16),string] uint16 *domain_name; /* netbios or dns */
+ int32 level; /* specifies the switch level for the request */
+ } drsuapi_DsGetDCInfoRequest1;
+
+ typedef [switch_type(int32)] union {
+ [case(1)] drsuapi_DsGetDCInfoRequest1 req1;
+ } drsuapi_DsGetDCInfoRequest;
+
+ typedef struct {
+ [charset(UTF16),string] uint16 *netbios_name;
+ [charset(UTF16),string] uint16 *dns_name;
+ [charset(UTF16),string] uint16 *site_name;
+ [charset(UTF16),string] uint16 *computer_dn;
+ [charset(UTF16),string] uint16 *server_dn;
+ uint32 is_pdc;
+ uint32 is_enabled;
+ } drsuapi_DsGetDCInfo1;
+
+ typedef struct {
+ [range(0,10000)] uint32 count;
+ [size_is(count)] drsuapi_DsGetDCInfo1 *array;
+ } drsuapi_DsGetDCInfoCtr1;
+
+ typedef struct {
+ [charset(UTF16),string] uint16 *netbios_name;
+ [charset(UTF16),string] uint16 *dns_name;
+ [charset(UTF16),string] uint16 *site_name;
+ [charset(UTF16),string] uint16 *site_dn;
+ [charset(UTF16),string] uint16 *computer_dn;
+ [charset(UTF16),string] uint16 *server_dn;
+ [charset(UTF16),string] uint16 *ntds_dn;
+ uint32 is_pdc;
+ uint32 is_enabled;
+ uint32 is_gc;
+ GUID site_guid;
+ GUID computer_guid;
+ GUID server_guid;
+ GUID ntds_guid;
+ } drsuapi_DsGetDCInfo2;
+
+ typedef struct {
+ [range(0,10000)] uint32 count;
+ [size_is(count)] drsuapi_DsGetDCInfo2 *array;
+ } drsuapi_DsGetDCInfoCtr2;
+
+ /*
+ * this represents an active connection to the
+ * Directory System Agent (DSA)
+ * this can be via LDAP or DRSUAPI
+ */
+ typedef struct {
+ [flag(NDR_BIG_ENDIAN)] ipv4address client_ip_address;
+ uint32 unknown2;
+ uint32 connection_time; /* in seconds */
+ uint32 unknown4;
+ uint32 unknown5;
+ uint32 unknown6;
+ /*
+ * client_account can be the following:
+ * "W2K3\Administrator"
+ * "Administrator@W2K3"
+ * "cn=Administrator,cn=Users,DC=w2k3,DC=vmnet1,DC=vm,DC=base"
+ * ""
+ * or NULL
+ */
+ [charset(UTF16),string] uint16 *client_account;
+ } drsuapi_DsGetDCConnection01;
+
+ typedef struct {
+ [range(0,10000)] uint32 count;
+ [size_is(count)] drsuapi_DsGetDCConnection01 *array;
+ } drsuapi_DsGetDCConnectionCtr01;
+
+ typedef [v1_enum] enum {
+ DRSUAPI_DC_INFO_CTR_1 = 1,
+ DRSUAPI_DC_INFO_CTR_2 = 2,
+ DRSUAPI_DC_CONNECTION_CTR_01 = -1
+ } drsuapi_DsGetDCInfoCtrLevels;
+
+ typedef [switch_type(int32)] union {
+ [case(DRSUAPI_DC_INFO_CTR_1)] drsuapi_DsGetDCInfoCtr1 ctr1;
+ [case(DRSUAPI_DC_INFO_CTR_2)] drsuapi_DsGetDCInfoCtr2 ctr2;
+ [case(DRSUAPI_DC_CONNECTION_CTR_01)] drsuapi_DsGetDCConnectionCtr01 ctr01;
+ } drsuapi_DsGetDCInfoCtr;
+
+ WERROR drsuapi_DsGetDomainControllerInfo(
+ [in] policy_handle *bind_handle,
+ [in] int32 level,
+ [in,ref,switch_is(level)] drsuapi_DsGetDCInfoRequest *req,
+ [out,ref] int32 *level_out,
+ [out,ref,switch_is(*level_out)] drsuapi_DsGetDCInfoCtr *ctr
+ );
+
+ /*****************/
+ /* Function 0x11 */
+ typedef [public,noprint] struct {
+ drsuapi_DsReplicaObjectListItem *next_object;
+ drsuapi_DsReplicaObject object;
+ } drsuapi_DsReplicaObjectListItem;
+
+ /*
+ * The DsAddEntry() call which creates a nTDSDSA object,
+ * also adds a servicePrincipalName in the following form
+ * to the computer account of the new domain controller
+ * referenced by the "serverReferenece" attribute.
+ *
+ * E3514235-4B06-11D1-AB04-00C04FC2DCD2/<new-ntdsdsa-object-guid-as-string>/<domain-dns-name>
+ *
+ * also note that the "serverReference" isn't added to the new object!
+ */
+ const char *DRSUAPI_NTDSDSA_KRB5_SERVICE_GUID = "E3514235-4B06-11D1-AB04-00C04FC2DCD2";
+
+ /*
+ * please note the the current idl
+ * for DsAddEntry does only parse
+ * what I saw between 2 w2k3 boxes
+ * in my dssync experiments I got some other replies
+ * so all I want to say is that this is very incomplete yet...
+ * --metze
+ */
+ typedef struct {
+ drsuapi_DsReplicaObjectListItem first_object;
+ } drsuapi_DsAddEntryRequest2;
+
+ typedef [switch_type(int32)] union {
+ [case(2)] drsuapi_DsAddEntryRequest2 req2;
+ } drsuapi_DsAddEntryRequest;
+
+ typedef struct {
+ uint32 unknown1;
+ WERROR status;
+ uint32 unknown2;
+ uint16 unknown3;
+ } drsuapi_DsAddEntryErrorInfoX;
+
+ typedef struct {
+ [range(0,10485760)] uint32 size;
+ [size_is(size)] uint8 *data;
+ } drsuapi_DsAddEntryExtraErrorBuffer;
+
+ typedef struct {
+ drsuapi_DsAddEntryErrorInfoX error;
+ drsuapi_DsAttributeId attid;
+ uint32 unknown2;
+ drsuapi_DsAddEntryExtraErrorBuffer buffer;
+ } drsuapi_DsAddEntryExtraError1;
+
+ typedef /*[noprint]*/ struct {
+ drsuapi_DsAddEntryErrorListItem1 *next;
+ drsuapi_DsAddEntryExtraError1 error;
+ } drsuapi_DsAddEntryErrorListItem1;
+
+ typedef struct {
+ drsuapi_DsReplicaObjectIdentifier *id;
+ WERROR status;
+ drsuapi_DsAddEntryErrorListItem1 first;
+ } drsuapi_DsAddEntryErrorInfo1;
+
+ typedef [switch_type(uint32)] union {
+ [case(1)] drsuapi_DsAddEntryErrorInfo1 error1;
+/* [case(2)] drsuapi_DsAddEntryErrorInfo2 error2;
+ [case(3)] drsuapi_DsAddEntryErrorInfo3 error3;
+*/ [case(4)] drsuapi_DsAddEntryErrorInfoX errorX;
+ [case(5)] drsuapi_DsAddEntryErrorInfoX errorX;
+ [case(6)] drsuapi_DsAddEntryErrorInfoX errorX;
+ [case(7)] drsuapi_DsAddEntryErrorInfoX errorX;
+ } drsuapi_DsAddEntryErrorInfo;
+
+ typedef struct {
+ WERROR status;
+ uint32 level;
+ [switch_is(level)] drsuapi_DsAddEntryErrorInfo *info;
+ } drsuapi_DsAddEntryError1;
+
+ typedef [switch_type(uint32)] union {
+ [case(1)] drsuapi_DsAddEntryError1 info1;
+ } drsuapi_DsAddEntryError;
+
+ typedef struct {
+ GUID guid;
+ dom_sid28 sid;
+ } drsuapi_DsReplicaObjectIdentifier2;
+
+ typedef struct {
+ drsuapi_DsReplicaObjectIdentifier *id;
+ uint32 unknown1;
+ drsuapi_DsAddEntryErrorInfoX error;
+ [range(0,10000)] uint32 count;
+ [size_is(count)] drsuapi_DsReplicaObjectIdentifier2 *objects;
+ } drsuapi_DsAddEntryCtr2;
+
+ typedef struct {
+ drsuapi_DsReplicaObjectIdentifier *id;
+ uint32 level;
+ [switch_is(level)] drsuapi_DsAddEntryError *error;
+ [range(0,10000)] uint32 count;
+ [size_is(count)] drsuapi_DsReplicaObjectIdentifier2 *objects;
+ } drsuapi_DsAddEntryCtr3;
+
+ typedef [switch_type(int32)] union {
+ [case(2)] drsuapi_DsAddEntryCtr2 ctr2;
+ [case(3)] drsuapi_DsAddEntryCtr3 ctr3;
+ } drsuapi_DsAddEntryCtr;
+
+ [public] WERROR drsuapi_DsAddEntry(
+ [in] policy_handle *bind_handle,
+ [in] int32 level,
+ [in,ref,switch_is(level)] drsuapi_DsAddEntryRequest *req,
+ [out,ref] int32 *level_out,
+ [out,ref,switch_is(*level_out)] drsuapi_DsAddEntryCtr *ctr
+ );
+
+ /*****************/
+ /* Function 0x12 */
+ WERROR DRSUAPI_EXECUTE_KCC();
+
+ /*****************/
+ /* Function 0x13 */
+ typedef [v1_enum] enum {
+ DRSUAPI_DS_REPLICA_GET_INFO = 1,
+ DRSUAPI_DS_REPLICA_GET_INFO2 = 2
+ } drsuapi_DsReplicaGetInfoLevel;
+
+ typedef [v1_enum] enum {
+ DRSUAPI_DS_REPLICA_INFO_NEIGHBORS = 0,
+ DRSUAPI_DS_REPLICA_INFO_CURSORS = 1,
+ DRSUAPI_DS_REPLICA_INFO_OBJ_METADATA = 2,
+ DRSUAPI_DS_REPLICA_INFO_KCC_DSA_CONNECT_FAILURES = 3,
+ DRSUAPI_DS_REPLICA_INFO_KCC_DSA_LINK_FAILURES = 4,
+ DRSUAPI_DS_REPLICA_INFO_PENDING_OPS = 5,
+ DRSUAPI_DS_REPLICA_INFO_ATTRIBUTE_VALUE_METADATA = 6,
+ DRSUAPI_DS_REPLICA_INFO_CURSORS2 = 7,
+ DRSUAPI_DS_REPLICA_INFO_CURSORS3 = 8,
+ DRSUAPI_DS_REPLICA_INFO_OBJ_METADATA2 = 9,
+ DRSUAPI_DS_REPLICA_INFO_ATTRIBUTE_VALUE_METADATA2 = 10,
+ DRSUAPI_DS_REPLICA_INFO_NEIGHBORS02 = -2,
+ DRSUAPI_DS_REPLICA_INFO_CONNECTIONS04 = -4,
+ DRSUAPI_DS_REPLICA_INFO_CURSORS05 = -5,
+ DRSUAPI_DS_REPLICA_INFO_06 = -6
+ } drsuapi_DsReplicaInfoType;
+
+ typedef struct {
+ drsuapi_DsReplicaInfoType info_type;
+ [charset(UTF16),string] uint16 *object_dn;
+ GUID guid1;
+ } drsuapi_DsReplicaGetInfoRequest1;
+
+ typedef struct {
+ drsuapi_DsReplicaInfoType info_type;
+ [charset(UTF16),string] uint16 *object_dn;
+ GUID guid1;
+ uint32 unknown1;
+ [charset(UTF16),string] uint16 *string1;
+ [charset(UTF16),string] uint16 *string2;
+ uint32 unknown2;
+ } drsuapi_DsReplicaGetInfoRequest2;
+
+ typedef [switch_type(drsuapi_DsReplicaGetInfoLevel)] union {
+ [case(DRSUAPI_DS_REPLICA_GET_INFO)] drsuapi_DsReplicaGetInfoRequest1 req1;
+ [case(DRSUAPI_DS_REPLICA_GET_INFO2)] drsuapi_DsReplicaGetInfoRequest2 req2;
+ } drsuapi_DsReplicaGetInfoRequest;
+
+ typedef struct {
+ [charset(UTF16),string] uint16 *naming_context_dn;
+ [charset(UTF16),string] uint16 *source_dsa_obj_dn;
+ [charset(UTF16),string] uint16 *source_dsa_address;
+ [charset(UTF16),string] uint16 *transport_obj_dn;
+ drsuapi_DsReplicaNeighbourFlags replica_flags;
+ uint32 reserved;
+ GUID naming_context_obj_guid;
+ GUID source_dsa_obj_guid;
+ GUID source_dsa_invocation_id;
+ GUID transport_obj_guid;
+ hyper tmp_highest_usn;
+ hyper highest_usn;
+ NTTIME last_success;
+ NTTIME last_attempt;
+ WERROR result_last_attempt;
+ uint32 consecutive_sync_failures;
+ } drsuapi_DsReplicaNeighbour;
+
+ typedef struct {
+ uint32 count;
+ uint32 reserved;
+ [size_is(count)] drsuapi_DsReplicaNeighbour array[];
+ } drsuapi_DsReplicaNeighbourCtr;
+
+ typedef struct {
+ uint32 count;
+ uint32 reserved;
+ [size_is(count)] drsuapi_DsReplicaCursor array[];
+ } drsuapi_DsReplicaCursorCtr;
+
+ typedef struct {
+ [charset(UTF16),string] uint16 *attribute_name;
+ uint32 version;
+ NTTIME originating_change_time;
+ GUID originating_invocation_id;
+ hyper originating_usn;
+ hyper local_usn;
+ } drsuapi_DsReplicaObjMetaData;
+
+ typedef struct {
+ uint32 count;
+ uint32 reserved;
+ [size_is(count)] drsuapi_DsReplicaObjMetaData array[];
+ } drsuapi_DsReplicaObjMetaDataCtr;
+
+ typedef struct {
+ [charset(UTF16),string] uint16 *dsa_obj_dn;
+ GUID dsa_obj_guid;
+ NTTIME first_failure;
+ uint32 num_failures;
+ WERROR last_result;
+ } drsuapi_DsReplicaKccDsaFailure;
+
+ typedef struct {
+ uint32 count;
+ uint32 reserved;
+ [size_is(count)] drsuapi_DsReplicaKccDsaFailure array[];
+ } drsuapi_DsReplicaKccDsaFailuresCtr;
+
+ typedef enum {
+ DRSUAPI_DS_REPLICA_OP_TYPE_SYNC = 0,
+ DRSUAPI_DS_REPLICA_OP_TYPE_ADD = 1,
+ DRSUAPI_DS_REPLICA_OP_TYPE_DELETE = 2,
+ DRSUAPI_DS_REPLICA_OP_TYPE_MODIFY = 3,
+ DRSUAPI_DS_REPLICA_OP_TYPE_UPDATE_REFS = 4
+ } drsuapi_DsReplicaOpType;
+
+ typedef [switch_type(drsuapi_DsReplicaOpType)] union {
+ [case(DRSUAPI_DS_REPLICA_OP_TYPE_SYNC)] drsuapi_DsReplicaSyncOptions sync;
+ [case(DRSUAPI_DS_REPLICA_OP_TYPE_ADD)] drsuapi_DsReplicaAddOptions add;
+ [case(DRSUAPI_DS_REPLICA_OP_TYPE_DELETE)] drsuapi_DsReplicaDeleteOptions op_delete;
+ [case(DRSUAPI_DS_REPLICA_OP_TYPE_MODIFY)] drsuapi_DsReplicaModifyOptions modify;
+ [case(DRSUAPI_DS_REPLICA_OP_TYPE_UPDATE_REFS)] drsuapi_DsReplicaUpdateRefsOptions update_refs;
+ [default] uint32 unknown;
+ } drsuapi_DsRplicaOpOptions;
+
+ typedef struct {
+ NTTIME operation_start;
+ uint32 serial_num; /* unique till reboot */
+ uint32 priority;
+ drsuapi_DsReplicaOpType operation_type;
+ [switch_is(operation_type)] drsuapi_DsRplicaOpOptions options;
+ [charset(UTF16),string] uint16 *nc_dn;
+ [charset(UTF16),string] uint16 *remote_dsa_obj_dn;
+ [charset(UTF16),string] uint16 *remote_dsa_address;
+ GUID nc_obj_guid;
+ GUID remote_dsa_obj_guid;
+ } drsuapi_DsReplicaOp;
+
+ typedef struct {
+ NTTIME time;
+ uint32 count;
+ [size_is(count)] drsuapi_DsReplicaOp array[];
+ } drsuapi_DsReplicaOpCtr;
+
+ typedef struct {
+ [charset(UTF16),string] uint16 *attribute_name;
+ [charset(UTF16),string] uint16 *object_dn;
+ [value(ndr_size_DATA_BLOB(0,binary,0))] uint32 __ndr_size_binary;
+ DATA_BLOB *binary;
+ NTTIME deleted;
+ NTTIME created;
+ uint32 version;
+ NTTIME originating_change_time;
+ GUID originating_invocation_id;
+ hyper originating_usn;
+ hyper local_usn;
+ } drsuapi_DsReplicaAttrValMetaData;
+
+ typedef struct {
+ uint32 count;
+ int32 enumeration_context;
+ [size_is(count)] drsuapi_DsReplicaAttrValMetaData array[];
+ } drsuapi_DsReplicaAttrValMetaDataCtr;
+
+ typedef struct {
+ uint32 count;
+ int32 enumeration_context;
+ [size_is(count)] drsuapi_DsReplicaCursor2 array[];
+ } drsuapi_DsReplicaCursor2Ctr;
+
+ typedef struct {
+ GUID source_dsa_invocation_id;
+ hyper highest_usn;
+ NTTIME last_sync_success;
+ [charset(UTF16),string] uint16 *source_dsa_obj_dn;
+ } drsuapi_DsReplicaCursor3;
+
+ typedef struct {
+ uint32 count;
+ int32 enumeration_context;
+ [size_is(count)] drsuapi_DsReplicaCursor3 array[];
+ } drsuapi_DsReplicaCursor3Ctr;
+
+ typedef struct {
+ [charset(UTF16),string] uint16 *attribute_name;
+ uint32 version;
+ NTTIME originating_change_time;
+ GUID originating_invocation_id;
+ hyper originating_usn;
+ hyper local_usn;
+ [charset(UTF16),string] uint16 *originating_dsa_dn;
+ } drsuapi_DsReplicaObjMetaData2;
+
+ typedef struct {
+ uint32 count;
+ int32 enumeration_context;
+ [size_is(count)] drsuapi_DsReplicaObjMetaData2 array[];
+ } drsuapi_DsReplicaObjMetaData2Ctr;
+
+ typedef struct {
+ [charset(UTF16),string] uint16 *attribute_name;
+ [charset(UTF16),string] uint16 *object_dn;
+ [value(ndr_size_DATA_BLOB(0,binary,0))] uint32 __ndr_size_binary;
+ DATA_BLOB *binary;
+ NTTIME deleted;
+ NTTIME created;
+ uint32 version;
+ NTTIME originating_change_time;
+ GUID originating_invocation_id;
+ hyper originating_usn;
+ hyper local_usn;
+ [charset(UTF16),string] uint16 *originating_dsa_dn;
+ } drsuapi_DsReplicaAttrValMetaData2;
+
+ typedef struct {
+ uint32 count;
+ int32 enumeration_context;
+ [size_is(count)] drsuapi_DsReplicaAttrValMetaData2 array[];
+ } drsuapi_DsReplicaAttrValMetaData2Ctr;
+
+ typedef struct {
+ hyper u1; /* session number? */
+ uint32 u2;
+ uint32 u3;
+ GUID bind_guid;
+ NTTIME_1sec bind_time;
+ [flag(NDR_BIG_ENDIAN)] ipv4address client_ip_address;
+ uint32 u5; /* this is the same value the client used as u1 in the DsBindInfoX struct */
+ } drsuapi_DsReplicaConnection04;
+
+ typedef struct {
+ [range(0,10000)] uint32 count;
+ uint32 reserved;
+ [size_is(count)] drsuapi_DsReplicaConnection04 array[];
+ } drsuapi_DsReplicaConnection04Ctr;
+
+ typedef struct {
+ [charset(UTF16),string] uint16 *str1;
+ uint32 u1;
+ uint32 u2;
+ uint32 u3;
+ uint32 u4;
+ uint32 u5;
+ hyper u6;
+ uint32 u7;
+ } drsuapi_DsReplica06;
+
+ typedef struct {
+ [range(0,256)] uint32 count;
+ uint32 reserved;
+ [size_is(count)] drsuapi_DsReplica06 array[];
+ } drsuapi_DsReplica06Ctr;
+
+ typedef [switch_type(drsuapi_DsReplicaInfoType)] union {
+ [case(DRSUAPI_DS_REPLICA_INFO_NEIGHBORS)] drsuapi_DsReplicaNeighbourCtr *neighbours;
+ [case(DRSUAPI_DS_REPLICA_INFO_CURSORS)] drsuapi_DsReplicaCursorCtr *cursors;
+ [case(DRSUAPI_DS_REPLICA_INFO_OBJ_METADATA)] drsuapi_DsReplicaObjMetaDataCtr *objmetadata;
+ [case(DRSUAPI_DS_REPLICA_INFO_KCC_DSA_CONNECT_FAILURES)] drsuapi_DsReplicaKccDsaFailuresCtr *connectfailures;
+ [case(DRSUAPI_DS_REPLICA_INFO_KCC_DSA_LINK_FAILURES)] drsuapi_DsReplicaKccDsaFailuresCtr *linkfailures;
+ [case(DRSUAPI_DS_REPLICA_INFO_PENDING_OPS)] drsuapi_DsReplicaOpCtr *pendingops;
+ [case(DRSUAPI_DS_REPLICA_INFO_ATTRIBUTE_VALUE_METADATA)] drsuapi_DsReplicaAttrValMetaDataCtr *attrvalmetadata;
+ [case(DRSUAPI_DS_REPLICA_INFO_CURSORS2)] drsuapi_DsReplicaCursor2Ctr *cursors2;
+ [case(DRSUAPI_DS_REPLICA_INFO_CURSORS3)] drsuapi_DsReplicaCursor3Ctr *cursors3;
+ [case(DRSUAPI_DS_REPLICA_INFO_OBJ_METADATA2)] drsuapi_DsReplicaObjMetaData2Ctr *objmetadata2;
+ [case(DRSUAPI_DS_REPLICA_INFO_ATTRIBUTE_VALUE_METADATA2)] drsuapi_DsReplicaAttrValMetaData2Ctr *attrvalmetadata2;
+ [case(DRSUAPI_DS_REPLICA_INFO_NEIGHBORS02)] drsuapi_DsReplicaNeighbourCtr *neighbours02;
+ [case(DRSUAPI_DS_REPLICA_INFO_CONNECTIONS04)] drsuapi_DsReplicaConnection04Ctr *connections04;
+ [case(DRSUAPI_DS_REPLICA_INFO_CURSORS05)] drsuapi_DsReplicaCursorCtrEx *cursors05;
+ [case(DRSUAPI_DS_REPLICA_INFO_06)] drsuapi_DsReplica06Ctr *i06;
+ } drsuapi_DsReplicaInfo;
+
+ WERROR drsuapi_DsReplicaGetInfo(
+ [in] policy_handle *bind_handle,
+ [in] drsuapi_DsReplicaGetInfoLevel level,
+ [in,ref,switch_is(level)] drsuapi_DsReplicaGetInfoRequest *req,
+ [out,ref] drsuapi_DsReplicaInfoType *info_type,
+ [out,ref,switch_is(*info_type)] drsuapi_DsReplicaInfo *info
+ );
+
+ /*****************/
+ /* Function 0x14 */
+ WERROR DRSUAPI_ADD_SID_HISTORY();
+
+ /*****************/
+ /* Function 0x15 */
+
+ typedef struct {
+ [range(0,10000)] uint32 num_entries;
+ [size_is(num_entries)] drsuapi_DsGetMembershipsCtr1 **ctrl_array;
+ } drsuapi_DsGetMemberships2Ctr1;
+
+ typedef [switch_type(int32)] union {
+ [case(1)] drsuapi_DsGetMembershipsCtr1 ctr1;
+ } drsuapi_DsGetMemberships2Ctr;
+
+ typedef struct {
+ [range(1,10000)] uint32 num_req;
+ [size_is(num_req)] drsuapi_DsGetMembershipsRequest1 **req_array;
+ } drsuapi_DsGetMemberships2Request1;
+
+ typedef [switch_type(int32)] union {
+ [case(1)] drsuapi_DsGetMemberships2Request1 req1;
+ } drsuapi_DsGetMemberships2Request;
+
+ WERROR drsuapi_DsGetMemberships2(
+ [in] policy_handle *bind_handle,
+ [in] int32 level,
+ [in,ref] [switch_is(level)] drsuapi_DsGetMemberships2Request *req,
+ [out,ref] int32 *level_out,
+ [out,ref] [switch_is(*level_out)] drsuapi_DsGetMemberships2Ctr *ctr
+ );
+
+
+ /*****************/
+ /* Function 0x16 */
+ WERROR DRSUAPI_REPLICA_VERIFY_OBJECTS();
+
+ /*****************/
+ /* Function 0x17 */
+ WERROR DRSUAPI_GET_OBJECT_EXISTENCE();
+
+ /*****************/
+ /* Function 0x18 */
+ typedef struct {
+ WERROR error_code;
+ uint32 site_cost;
+ } drsuapi_DsSiteCostInfo;
+
+ typedef struct {
+ [range(0,10000)] uint32 num_info;
+ [size_is(num_info)] drsuapi_DsSiteCostInfo *info;
+ uint32 unknown;
+ } drsuapi_QuerySitesByCostCtr1;
+
+ typedef [switch_type(int32)] union {
+ [case(1)] drsuapi_QuerySitesByCostCtr1 ctr1;
+ } drsuapi_QuerySitesByCostCtr;
+
+ typedef struct {
+ [charset(UTF16),string] uint16 *site_from;
+ [range(1,10000)] uint32 num_req;
+ [size_is(num_req)] [charset(UTF16),string] uint16 **site_to;
+ uint32 flags;
+ } drsuapi_QuerySitesByCostRequest1;
+
+ typedef [switch_type(int32)] union {
+ [case(1)] drsuapi_QuerySitesByCostRequest1 req1;
+ } drsuapi_QuerySitesByCostRequest;
+
+ WERROR drsuapi_QuerySitesByCost(
+ [in] policy_handle *bind_handle,
+ [in] int32 level,
+ [in,ref] [switch_is(level)] drsuapi_QuerySitesByCostRequest *req,
+ [out,ref] int32 *level_out,
+ [out,ref] [switch_is(*level_out)] drsuapi_QuerySitesByCostCtr *ctr
+ );
+}
diff --git a/source3/librpc/idl/nbt.idl b/source3/librpc/idl/nbt.idl
new file mode 100644
index 0000000000..4dc7972e45
--- /dev/null
+++ b/source3/librpc/idl/nbt.idl
@@ -0,0 +1,699 @@
+#include "idl_types.h"
+
+/*
+ IDL structures for NBT operations
+
+ NBT is not traditionally encoded using IDL/NDR. This is a bit of an
+ experiment, and I may well switch us back to a more traditional
+ encoding if it doesn't work out
+*/
+
+import "misc.idl", "security.idl", "svcctl.idl";
+[
+helper("libcli/nbt/libnbt.h")
+]
+interface nbt
+{
+ const int NBT_NAME_SERVICE_PORT = 137;
+ const int NBT_DGRAM_SERVICE_PORT = 138;
+
+ typedef [bitmap16bit] bitmap {
+ NBT_RCODE = 0x000F,
+ NBT_FLAG_BROADCAST = 0x0010,
+ NBT_FLAG_RECURSION_AVAIL = 0x0080,
+ NBT_FLAG_RECURSION_DESIRED = 0x0100,
+ NBT_FLAG_TRUNCATION = 0x0200,
+ NBT_FLAG_AUTHORITIVE = 0x0400,
+ NBT_OPCODE = 0x7800,
+ NBT_FLAG_REPLY = 0x8000
+ } nbt_operation;
+
+ /* the opcodes are in the operation field, masked with
+ NBT_OPCODE */
+ typedef enum {
+ NBT_OPCODE_QUERY = (0x0<<11),
+ NBT_OPCODE_REGISTER = (0x5<<11),
+ NBT_OPCODE_RELEASE = (0x6<<11),
+ NBT_OPCODE_WACK = (0x7<<11),
+ NBT_OPCODE_REFRESH = (0x8<<11),
+ NBT_OPCODE_REFRESH2 = (0x9<<11),
+ NBT_OPCODE_MULTI_HOME_REG = (0xf<<11)
+ } nbt_opcode;
+
+ /* rcode values */
+ typedef enum {
+ NBT_RCODE_OK = 0x0,
+ NBT_RCODE_FMT = 0x1,
+ NBT_RCODE_SVR = 0x2,
+ NBT_RCODE_NAM = 0x3,
+ NBT_RCODE_IMP = 0x4,
+ NBT_RCODE_RFS = 0x5,
+ NBT_RCODE_ACT = 0x6,
+ NBT_RCODE_CFT = 0x7
+ } nbt_rcode;
+
+ /* we support any 8bit name type, but by defining the common
+ ones here we get better debug displays */
+ typedef [enum8bit] enum {
+ NBT_NAME_CLIENT = 0x00,
+ NBT_NAME_MS = 0x01,
+ NBT_NAME_USER = 0x03,
+ NBT_NAME_SERVER = 0x20,
+ NBT_NAME_PDC = 0x1B,
+ NBT_NAME_LOGON = 0x1C,
+ NBT_NAME_MASTER = 0x1D,
+ NBT_NAME_BROWSER = 0x1E
+ } nbt_name_type;
+
+ /* the ndr parser for nbt_name is separately defined in
+ nbtname.c (along with the parsers for nbt_string) */
+ typedef [public,nopull,nopush] struct {
+ string name;
+ string scope;
+ nbt_name_type type;
+ } nbt_name;
+
+ typedef [enum16bit] enum {
+ NBT_QCLASS_IP = 0x01
+ } nbt_qclass;
+
+ typedef [enum16bit] enum {
+ NBT_QTYPE_ADDRESS = 0x0001,
+ NBT_QTYPE_NAMESERVICE = 0x0002,
+ NBT_QTYPE_NULL = 0x000A,
+ NBT_QTYPE_NETBIOS = 0x0020,
+ NBT_QTYPE_STATUS = 0x0021
+ } nbt_qtype;
+
+ typedef struct {
+ nbt_name name;
+ nbt_qtype question_type;
+ nbt_qclass question_class;
+ } nbt_name_question;
+
+ /* these are the possible values of the NBT_NM_OWNER_TYPE
+ field */
+ typedef enum {
+ NBT_NODE_B = 0x0000,
+ NBT_NODE_P = 0x2000,
+ NBT_NODE_M = 0x4000,
+ NBT_NODE_H = 0x6000
+ } nbt_node_type;
+
+ typedef [bitmap16bit] bitmap {
+ NBT_NM_PERMANENT = 0x0200,
+ NBT_NM_ACTIVE = 0x0400,
+ NBT_NM_CONFLICT = 0x0800,
+ NBT_NM_DEREGISTER = 0x1000,
+ NBT_NM_OWNER_TYPE = 0x6000,
+ NBT_NM_GROUP = 0x8000
+ } nb_flags;
+
+ typedef struct {
+ nb_flags nb_flags;
+ ipv4address ipaddr;
+ } nbt_rdata_address;
+
+ typedef struct {
+ uint16 length;
+ nbt_rdata_address addresses[length/6];
+ } nbt_rdata_netbios;
+
+ typedef struct {
+ uint8 unit_id[6];
+ uint8 jumpers;
+ uint8 test_result;
+ uint16 version_number;
+ uint16 period_of_statistics;
+ uint16 number_of_crcs;
+ uint16 number_alignment_errors;
+ uint16 number_of_collisions;
+ uint16 number_send_aborts;
+ uint32 number_good_sends;
+ uint32 number_good_receives;
+ uint16 number_retransmits;
+ uint16 number_no_resource_conditions;
+ uint16 number_free_command_blocks;
+ uint16 total_number_command_blocks;
+ uint16 max_total_number_command_blocks;
+ uint16 number_pending_sessions;
+ uint16 max_number_pending_sessions;
+ uint16 max_total_sessions_possible;
+ uint16 session_data_packet_size;
+ } nbt_statistics;
+
+ typedef struct {
+ [charset(DOS)] uint8 name[15];
+ nbt_name_type type;
+ nb_flags nb_flags;
+ } nbt_status_name;
+
+ typedef struct {
+ [value(num_names * 18 + 47)] uint16 length;
+ uint8 num_names;
+ nbt_status_name names[num_names];
+ nbt_statistics statistics;
+ } nbt_rdata_status;
+
+ typedef struct {
+ uint16 length;
+ uint8 data[length];
+ } nbt_rdata_data;
+
+ typedef [nodiscriminant] union {
+ [case(NBT_QTYPE_NETBIOS)] nbt_rdata_netbios netbios;
+ [case(NBT_QTYPE_STATUS)] nbt_rdata_status status;
+ [default] nbt_rdata_data data;
+ } nbt_rdata;
+
+/*
+ * this macro works arround the problem
+ * that we need to use nbt_rdata_data
+ * together with NBT_QTYPE_NETBIOS
+ * for WACK replies
+ */
+#define NBT_RES_REC_LEVEL(rr_type, rdata) (\
+ (((rr_type) == NBT_QTYPE_NETBIOS) && \
+ talloc_check_name(ndr, "struct ndr_push") && \
+ ((rdata).data.length == 2)) \
+ ? 0 : rr_type)
+
+ typedef [flag(LIBNDR_PRINT_ARRAY_HEX)] struct {
+ nbt_name name;
+ nbt_qtype rr_type;
+ nbt_qclass rr_class;
+ uint32 ttl;
+ [switch_is(NBT_RES_REC_LEVEL(rr_type, rdata))] nbt_rdata rdata;
+ } nbt_res_rec;
+
+ typedef [flag(NDR_NOALIGN|NDR_BIG_ENDIAN|NDR_PAHEX),public] struct {
+ uint16 name_trn_id;
+ nbt_operation operation;
+ uint16 qdcount;
+ uint16 ancount;
+ uint16 nscount;
+ uint16 arcount;
+ nbt_name_question questions[qdcount];
+ nbt_res_rec answers[ancount];
+ nbt_res_rec nsrecs[nscount];
+ nbt_res_rec additional[arcount];
+ [flag(NDR_REMAINING)] DATA_BLOB padding;
+ } nbt_name_packet;
+
+
+ /*
+ NBT DGRAM packets (UDP/138)
+ */
+
+ typedef [enum8bit] enum {
+ DGRAM_DIRECT_UNIQUE = 0x10,
+ DGRAM_DIRECT_GROUP = 0x11,
+ DGRAM_BCAST = 0x12,
+ DGRAM_ERROR = 0x13,
+ DGRAM_QUERY = 0x14,
+ DGRAM_QUERY_POSITIVE = 0x15,
+ DGRAM_QUERY_NEGATIVE = 0x16
+ } dgram_msg_type;
+
+ typedef [bitmap8bit] bitmap {
+ DGRAM_FLAG_MORE = 0x01,
+ DGRAM_FLAG_FIRST = 0x02,
+ DGRAM_FLAG_NODE_TYPE = 0x0C
+ } dgram_flags;
+
+ typedef [enum8bit] enum {
+ DGRAM_NODE_B = 0x00,
+ DGRAM_NODE_P = 0x04,
+ DGRAM_NODE_M = 0x08,
+ DGRAM_NODE_NBDD = 0x0C
+ } dgram_node_type;
+
+ /* a dgram_message is the main dgram body in general use */
+
+ /* the most common datagram type is a SMB_TRANSACTION
+ operation, where a SMB packet is used in the data section
+ of a dgram_message to hold a trans request, which in turn
+ holds a small command structure. It's a very strange beast
+ indeed. To make the code cleaner we define a basic SMB
+ packet in IDL here. This is not a general purpose SMB
+ packet, and won't be used in the core SMB client/server
+ code, but it does make working with these types of dgrams
+ easier */
+
+ const string NBT_MAILSLOT_NETLOGON = "\\MAILSLOT\\NET\\NETLOGON";
+ const string NBT_MAILSLOT_NTLOGON = "\\MAILSLOT\\NET\\NTLOGON";
+ const string NBT_MAILSLOT_GETDC = "\\MAILSLOT\\NET\\GETDC";
+ const string NBT_MAILSLOT_BROWSE = "\\MAILSLOT\\BROWSE";
+
+ typedef [enum8bit] enum {
+ SMB_TRANSACTION = 0x25
+ } smb_command;
+
+ typedef struct {
+ [range(17,17),value(17)] uint8 wct;
+ uint16 total_param_count;
+ uint16 total_data_count;
+ uint16 max_param_count;
+ uint16 max_data_count;
+ uint8 max_setup_count;
+ uint8 pad;
+ uint16 trans_flags;
+ uint32 timeout;
+ uint16 reserved;
+ uint16 param_count;
+ uint16 param_offset;
+ uint16 data_count;
+ uint16 data_offset;
+ [range(3,3),value(3)] uint8 setup_count;
+ uint8 pad2;
+ uint16 opcode;
+ uint16 priority;
+ uint16 _class;
+ [value(strlen(mailslot_name)+1+data.length)]
+ uint16 byte_count;
+ astring mailslot_name;
+ [flag(NDR_REMAINING)] DATA_BLOB data;
+ } smb_trans_body;
+
+ typedef [nodiscriminant] union {
+ [case(SMB_TRANSACTION)] smb_trans_body trans;
+ } smb_body;
+
+
+ typedef [flag(NDR_NOALIGN|NDR_LITTLE_ENDIAN|NDR_PAHEX),public] struct {
+ smb_command smb_command;
+ uint8 err_class;
+ uint8 pad;
+ uint16 err_code;
+ uint8 flags;
+ uint16 flags2;
+ uint16 pid_high;
+ uint8 signature[8];
+ uint16 reserved;
+ uint16 tid;
+ uint16 pid;
+ uint16 vuid;
+ uint16 mid;
+ [switch_is(smb_command)] smb_body body;
+ } dgram_smb_packet;
+
+ const uint32 DGRAM_SMB = 0xff534d42; /* 0xffSMB */
+
+ typedef [nodiscriminant] union {
+ [case(DGRAM_SMB)] dgram_smb_packet smb;
+ } dgram_message_body;
+
+ typedef struct {
+ uint16 length;
+ uint16 offset;
+ nbt_name source_name;
+ nbt_name dest_name;
+ uint32 dgram_body_type;
+ [switch_is(dgram_body_type)] dgram_message_body body;
+ } dgram_message;
+
+ typedef [enum8bit] enum {
+ DGRAM_ERROR_NAME_NOT_PRESENT = 0x82,
+ DGRAM_ERROR_INVALID_SOURCE = 0x83,
+ DGRAM_ERROR_INVALID_DEST = 0x84
+ } dgram_err_code;
+
+ typedef [nodiscriminant] union {
+ [case(DGRAM_DIRECT_UNIQUE)] dgram_message msg;
+ [case(DGRAM_DIRECT_GROUP)] dgram_message msg;
+ [case(DGRAM_BCAST)] dgram_message msg;
+ [case(DGRAM_ERROR)] dgram_err_code error;
+ [case(DGRAM_QUERY)] nbt_name dest_name;
+ [case(DGRAM_QUERY_POSITIVE)] nbt_name dest_name;
+ [case(DGRAM_QUERY_NEGATIVE)] nbt_name dest_name;
+ } dgram_data;
+
+ typedef [flag(NDR_NOALIGN|NDR_BIG_ENDIAN|NDR_PAHEX),public] struct {
+ dgram_msg_type msg_type;
+ dgram_flags flags;
+ uint16 dgram_id;
+ ipv4address src_addr;
+ uint16 src_port;
+ [switch_is(msg_type)] dgram_data data;
+ } nbt_dgram_packet;
+
+
+ /*******************************************/
+ /* \MAILSLOT\NET\NETLOGON mailslot requests */
+ typedef enum {
+ NETLOGON_QUERY_FOR_PDC = 0x7,
+ NETLOGON_ANNOUNCE_UAS = 0xa,
+ NETLOGON_RESPONSE_FROM_PDC = 0xc,
+ NETLOGON_QUERY_FOR_PDC2 = 0x12,
+ NETLOGON_RESPONSE_FROM_PDC2 = 0x17,
+ NETLOGON_RESPONSE_FROM_PDC_USER = 0x19
+ } nbt_netlogon_command;
+
+ /* query for pdc request */
+ typedef struct {
+ astring computer_name;
+ astring mailslot_name;
+ [flag(NDR_ALIGN2)] DATA_BLOB _pad;
+ nstring unicode_name;
+ uint32 nt_version;
+ uint16 lmnt_token;
+ uint16 lm20_token;
+ } nbt_netlogon_query_for_pdc;
+
+ /* query for pdc request - new style */
+ typedef struct {
+ uint16 request_count;
+ nstring computer_name;
+ nstring user_name;
+ astring mailslot_name;
+ uint32 unknown[2];
+ uint32 nt_version;
+ uint16 lmnt_token;
+ uint16 lm20_token;
+ } nbt_netlogon_query_for_pdc2;
+
+ /* response from pdc */
+ typedef struct {
+ astring pdc_name;
+ [flag(NDR_ALIGN2)] DATA_BLOB _pad;
+ nstring unicode_pdc_name;
+ nstring domain_name;
+ uint32 nt_version;
+ uint16 lmnt_token;
+ uint16 lm20_token;
+ } nbt_netlogon_response_from_pdc;
+
+ typedef [bitmap32bit] bitmap {
+ NBT_SERVER_PDC = 0x00000001,
+ NBT_SERVER_GC = 0x00000004,
+ NBT_SERVER_LDAP = 0x00000008,
+ NBT_SERVER_DS = 0x00000010,
+ NBT_SERVER_KDC = 0x00000020,
+ NBT_SERVER_TIMESERV = 0x00000040,
+ NBT_SERVER_CLOSEST = 0x00000080,
+ NBT_SERVER_WRITABLE = 0x00000100,
+ NBT_SERVER_GOOD_TIMESERV = 0x00000200
+ } nbt_server_type;
+
+ /* response from pdc - type2 */
+ typedef struct {
+ [flag(NDR_ALIGN4)] DATA_BLOB _pad;
+ nbt_server_type server_type;
+ GUID domain_uuid;
+ nbt_string forest;
+ nbt_string dns_domain;
+ nbt_string pdc_dns_name;
+ nbt_string domain;
+ nbt_string pdc_name;
+ nbt_string user_name;
+ nbt_string server_site;
+ nbt_string client_site;
+ uint8 unknown;
+ uint32 unknown2;
+ [flag(NDR_BIG_ENDIAN)]
+ ipv4address pdc_ip;
+ uint32 unknown3[2];
+ uint32 nt_version;
+ uint16 lmnt_token;
+ uint16 lm20_token;
+ } nbt_netlogon_response_from_pdc2;
+
+ typedef enum netr_SamDatabaseID netr_SamDatabaseID;
+
+ /* announce change to UAS or SAM */
+ typedef struct {
+ netr_SamDatabaseID db_index;
+ hyper serial;
+ NTTIME timestamp;
+ } nbt_db_change;
+
+ /* used to announce SAM changes */
+ typedef struct {
+ uint32 serial_lo;
+ time_t timestamp;
+ uint32 pulse;
+ uint32 random;
+ astring pdc_name;
+ astring domain;
+ [flag(NDR_ALIGN2)] DATA_BLOB _pad;
+ nstring unicode_pdc_name;
+ nstring unicode_domain;
+ uint32 db_count;
+ nbt_db_change dbchange[db_count];
+ [value(ndr_size_dom_sid0(&sid, ndr->flags))] uint32 sid_size;
+ [subcontext(0),subcontext_size(sid_size)] dom_sid0 sid;
+ uint32 nt_version;
+ uint16 lmnt_token;
+ uint16 lm20_token;
+ } nbt_netlogon_announce_uas;
+
+ typedef [nodiscriminant] union {
+ [case(NETLOGON_QUERY_FOR_PDC)] nbt_netlogon_query_for_pdc pdc;
+ [case(NETLOGON_QUERY_FOR_PDC2)] nbt_netlogon_query_for_pdc2 pdc2;
+ [case(NETLOGON_ANNOUNCE_UAS)] nbt_netlogon_announce_uas uas;
+ [case(NETLOGON_RESPONSE_FROM_PDC)] nbt_netlogon_response_from_pdc response;
+ [case(NETLOGON_RESPONSE_FROM_PDC2)] nbt_netlogon_response_from_pdc2 response2;
+ [case(NETLOGON_RESPONSE_FROM_PDC_USER)] nbt_netlogon_response_from_pdc2 response2;
+ } nbt_netlogon_request;
+
+ typedef [flag(NDR_NOALIGN),public] struct {
+ nbt_netlogon_command command;
+ [switch_is(command)] nbt_netlogon_request req;
+ } nbt_netlogon_packet;
+
+ /*******************************************/
+ /* CLDAP netlogon response */
+
+ /* note that these structures are very similar to, but not
+ quite identical to, the netlogon structures above */
+
+ typedef struct {
+ uint16 type;
+ nstring pdc_name;
+ nstring user_name;
+ nstring domain_name;
+ [value(1)] uint32 nt_version;
+ uint16 lmnt_token;
+ uint16 lm20_token;
+ } nbt_cldap_netlogon_1;
+
+ typedef struct {
+ uint16 type;
+ nstring pdc_name;
+ nstring user_name;
+ nstring domain_name;
+ GUID domain_uuid;
+ GUID unknown_uuid;
+ nbt_string forest;
+ nbt_string dns_domain;
+ nbt_string pdc_dns_name;
+ ipv4address pdc_ip;
+ nbt_server_type server_type;
+ [value(3)] uint32 nt_version;
+ uint16 lmnt_token;
+ uint16 lm20_token;
+ } nbt_cldap_netlogon_3;
+
+ typedef struct {
+ uint32 type;
+ nbt_server_type server_type;
+ GUID domain_uuid;
+ nbt_string forest;
+ nbt_string dns_domain;
+ nbt_string pdc_dns_name;
+ nbt_string domain;
+ nbt_string pdc_name;
+ nbt_string user_name;
+ nbt_string server_site;
+ nbt_string client_site;
+ [value(5)] uint32 nt_version;
+ uint16 lmnt_token;
+ uint16 lm20_token;
+ } nbt_cldap_netlogon_5;
+
+ typedef struct {
+ uint32 type;
+ nbt_server_type server_type;
+ GUID domain_uuid;
+ nbt_string forest;
+ nbt_string dns_domain;
+ nbt_string pdc_dns_name;
+ nbt_string domain;
+ nbt_string pdc_name;
+ nbt_string user_name;
+ nbt_string server_site;
+ nbt_string client_site;
+ uint8 unknown;
+ uint32 unknown2;
+ [flag(NDR_BIG_ENDIAN)]
+ ipv4address pdc_ip;
+ uint32 unknown3[2];
+ [value(13)] uint32 nt_version;
+ uint16 lmnt_token;
+ uint16 lm20_token;
+ } nbt_cldap_netlogon_13;
+
+ typedef [flag(NDR_NOALIGN),public,nodiscriminant] union {
+ [case(0)] nbt_cldap_netlogon_1 logon1;
+ [case(1)] nbt_cldap_netlogon_1 logon1;
+ [case(2)] nbt_cldap_netlogon_3 logon3;
+ [case(3)] nbt_cldap_netlogon_3 logon3;
+ [case(4)] nbt_cldap_netlogon_5 logon5;
+ [case(5)] nbt_cldap_netlogon_5 logon5;
+ [case(6)] nbt_cldap_netlogon_5 logon5;
+ [case(7)] nbt_cldap_netlogon_5 logon5;
+ [default] nbt_cldap_netlogon_13 logon13;
+ } nbt_cldap_netlogon;
+
+ /*******************************************/
+ /* \MAILSLOT\NET\NTLOGON mailslot requests */
+ typedef enum {
+ NTLOGON_SAM_LOGON = 0x12,
+ NTLOGON_SAM_LOGON_REPLY = 0x13,
+ NTLOGON_SAM_LOGON_REPLY15 = 0x15
+ } nbt_ntlogon_command;
+
+ typedef struct {
+ uint16 request_count;
+ nstring computer_name;
+ nstring user_name;
+ astring mailslot_name;
+ uint32 acct_control;
+ [value(ndr_size_dom_sid0(&sid, ndr->flags))] uint32 sid_size;
+ [subcontext(0),subcontext_size(sid_size)] dom_sid0 sid;
+ uint32 nt_version;
+ uint16 lmnt_token;
+ uint16 lm20_token;
+ } nbt_ntlogon_sam_logon;
+
+ typedef struct {
+ nstring server;
+ nstring user_name;
+ nstring domain;
+ uint32 nt_version;
+ uint16 lmnt_token;
+ uint16 lm20_token;
+ } nbt_ntlogon_sam_logon_reply;
+
+ typedef [nodiscriminant] union {
+ [case(NTLOGON_SAM_LOGON)] nbt_ntlogon_sam_logon logon;
+ [case(NTLOGON_SAM_LOGON_REPLY)] nbt_ntlogon_sam_logon_reply reply;
+ [case(NTLOGON_SAM_LOGON_REPLY15)] nbt_ntlogon_sam_logon_reply reply;
+ [case(NETLOGON_RESPONSE_FROM_PDC2)] nbt_netlogon_response_from_pdc2 reply2;
+ } nbt_ntlogon_request;
+
+ typedef [flag(NDR_NOALIGN),public] struct {
+ nbt_ntlogon_command command;
+ [switch_is(command)] nbt_ntlogon_request req;
+ } nbt_ntlogon_packet;
+
+ /********************************************************/
+ /* \MAILSLOT\BROWSE mailslot requests */
+ /* for details see http://ubiqx.org/cifs/Browsing.html */
+ /********************************************************/
+ typedef bitmap svcctl_ServerType svcctl_ServerType;
+
+ typedef [enum8bit] enum {
+ HostAnnouncement = 1,
+ AnnouncementRequest = 2,
+ Election = 8,
+ GetBackupListReq = 9,
+ GetBackupListResp = 10,
+ BecomeBackup = 11,
+ DomainAnnouncement = 12,
+ MasterAnnouncement = 13,
+ ResetBrowserState = 14,
+ LocalMasterAnnouncement = 15
+ } nbt_browse_opcode;
+
+ typedef struct {
+ uint8 UpdateCount;
+ uint32 Periodicity;
+ [charset(DOS)] uint8 ServerName[16];
+ uint8 OSMajor;
+ uint8 OSMinor;
+ svcctl_ServerType ServerType;
+ uint8 BroMajorVer;
+ uint8 BroMinorVer;
+ uint16 Signature;
+ astring Comment;
+ } nbt_browse_host_announcement;
+
+ typedef struct {
+ uint8 Unused;
+ astring ResponseName;
+ } nbt_browse_announcement_request;
+
+ typedef struct {
+ uint8 Version;
+ uint32 Criteria;
+ uint32 UpTime; /* In milliseconds */
+ uint32 Reserved; /* Must be zero */
+ astring ServerName;
+ } nbt_browse_election_request;
+
+ typedef struct {
+ uint8 ReqCount;
+ uint32 Token;
+ } nbt_browse_backup_list_request;
+
+ typedef struct {
+ uint8 BackupCount;
+ uint32 Token;
+ nbt_name BackupServerList[BackupCount];/* TODO: this is wrong */
+ } nbt_browse_backup_list_response;
+
+ typedef struct {
+ astring BrowserName;
+ } nbt_browse_become_backup;
+
+ typedef struct {
+ uint8 UpdateCount;
+ uint32 Periodicity;
+ [charset(DOS)] uint8 ServerName[16];
+ uint8 OSMajor;
+ uint8 OSMinor;
+ svcctl_ServerType ServerType;
+ uint32 MysteriousField;
+ astring Comment;
+ } nbt_browse_domain_announcement;
+
+ typedef struct {
+ astring ServerName;
+ } nbt_browse_master_announcement;
+
+ typedef struct {
+ uint8 Command;
+ } nbt_browse_reset_state;
+
+ typedef struct {
+ uint8 UpdateCount;
+ uint32 Periodicity;
+ [charset(DOS)] uint8 ServerName[16];
+ uint8 OSMajor;
+ uint8 OSMinor;
+ svcctl_ServerType ServerType;
+ uint8 BroMajorVer;
+ uint8 BroMinorVer;
+ uint16 Signature;
+ astring Comment;
+ } nbt_browse_local_master_announcement;
+
+ typedef [nodiscriminant] union {
+ [case(HostAnnouncement)] nbt_browse_host_announcement host_annoucement;
+ [case(AnnouncementRequest)] nbt_browse_announcement_request announcement_request;
+ [case(Election)] nbt_browse_election_request election_request;
+ [case(GetBackupListReq)] nbt_browse_backup_list_request backup_list_request;
+ [case(GetBackupListResp)] nbt_browse_backup_list_response backup_list_response;
+ [case(BecomeBackup)] nbt_browse_become_backup become_backup;
+ [case(DomainAnnouncement)] nbt_browse_domain_announcement domain_announcement;
+ [case(MasterAnnouncement)] nbt_browse_master_announcement master_announcement;
+ [case(ResetBrowserState)] nbt_browse_reset_state reset_browser_state;
+ [case(LocalMasterAnnouncement)] nbt_browse_local_master_announcement local_master_announcement;
+ } nbt_browse_payload;
+
+ typedef [public,flag(NDR_NOALIGN)] struct {
+ nbt_browse_opcode opcode;
+ [switch_is(opcode)] nbt_browse_payload payload;
+ } nbt_browse_packet;
+}
diff --git a/source3/librpc/idl/security.idl b/source3/librpc/idl/security.idl
index c4c30e9b5a..c1dfe272e9 100644
--- a/source3/librpc/idl/security.idl
+++ b/source3/librpc/idl/security.idl
@@ -22,6 +22,9 @@ cpp_quote("#define dom_sid2 dom_sid")
/* same struct as dom_sid but inside a 28 bytes fixed buffer in NDR */
cpp_quote("#define dom_sid28 dom_sid")
+/* same struct as dom_sid but in a variable byte buffer, which is maybe empty in NDR */
+cpp_quote("#define dom_sid0 dom_sid")
+
[
pointer_default(unique)
]
diff --git a/source3/librpc/ndr/libndr.h b/source3/librpc/ndr/libndr.h
index a277a626c7..35a5b136a7 100644
--- a/source3/librpc/ndr/libndr.h
+++ b/source3/librpc/ndr/libndr.h
@@ -337,4 +337,15 @@ struct ndr_interface_list {
const struct ndr_interface_table *table;
};
+#define NDR_SCALAR_PROTO(name, type) \
+enum ndr_err_code ndr_push_ ## name(struct ndr_push *ndr, int ndr_flags, type v); \
+enum ndr_err_code ndr_pull_ ## name(struct ndr_pull *ndr, int ndr_flags, type *v); \
+void ndr_print_ ## name(struct ndr_print *ndr, const char *var_name, type v);
+
+#define NDR_BUFFER_PROTO(name, type) \
+enum ndr_err_code ndr_push_ ## name(struct ndr_push *ndr, int ndr_flags, const type *v); \
+enum ndr_err_code ndr_pull_ ## name(struct ndr_pull *ndr, int ndr_flags, type *v); \
+void ndr_print_ ## name(struct ndr_print *ndr, const char *var_name, const type *v);
+
+
#endif /* __LIBNDR_H__ */
diff --git a/source3/librpc/ndr/ndr_basic.c b/source3/librpc/ndr/ndr_basic.c
index f342c6e36f..c8fa70b185 100644
--- a/source3/librpc/ndr/ndr_basic.c
+++ b/source3/librpc/ndr/ndr_basic.c
@@ -196,7 +196,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_hyper(struct ndr_pull *ndr, int ndr_flags, u
*/
_PUBLIC_ enum ndr_err_code ndr_pull_pointer(struct ndr_pull *ndr, int ndr_flags, void* *v)
{
- intptr_t h;
+ uintptr_t h;
NDR_PULL_ALIGN(ndr, sizeof(h));
NDR_PULL_NEED_BYTES(ndr, sizeof(h));
memcpy(&h, ndr->data+ndr->offset, sizeof(h));
@@ -393,7 +393,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_hyper(struct ndr_push *ndr, int ndr_flags, u
*/
_PUBLIC_ enum ndr_err_code ndr_push_pointer(struct ndr_push *ndr, int ndr_flags, void* v)
{
- intptr_t h = (intptr_t)v;
+ uintptr_t h = (intptr_t)v;
NDR_PUSH_ALIGN(ndr, sizeof(h));
NDR_PUSH_NEED_BYTES(ndr, sizeof(h));
memcpy(ndr->data+ndr->offset, &h, sizeof(h));
diff --git a/source3/librpc/ndr/ndr_sec_helper.c b/source3/librpc/ndr/ndr_sec_helper.c
index f8bad6ca61..18d343799e 100644
--- a/source3/librpc/ndr/ndr_sec_helper.c
+++ b/source3/librpc/ndr/ndr_sec_helper.c
@@ -31,6 +31,26 @@ size_t ndr_size_dom_sid(const struct dom_sid *sid, int flags)
return 8 + 4*sid->num_auths;
}
+size_t ndr_size_dom_sid28(const struct dom_sid *sid, int flags)
+{
+ struct dom_sid zero_sid;
+
+ if (!sid) return 0;
+
+ ZERO_STRUCT(zero_sid);
+
+ if (memcmp(&zero_sid, sid, sizeof(zero_sid)) == 0) {
+ return 0;
+ }
+
+ return 8 + 4*sid->num_auths;
+}
+
+size_t ndr_size_dom_sid0(const struct dom_sid *sid, int flags)
+{
+ return ndr_size_dom_sid28(sid, flags);
+}
+
/*
return the wire size of a security_ace
*/
@@ -89,3 +109,9 @@ void ndr_print_dom_sid28(struct ndr_print *ndr, const char *name, const struct d
{
ndr_print_dom_sid(ndr, name, sid);
}
+
+void ndr_print_dom_sid0(struct ndr_print *ndr, const char *name, const struct dom_sid *sid)
+{
+ ndr_print_dom_sid(ndr, name, sid);
+}
+
diff --git a/source3/librpc/ndr/sid.c b/source3/librpc/ndr/sid.c
index b6ec045806..ed27375de1 100644
--- a/source3/librpc/ndr/sid.c
+++ b/source3/librpc/ndr/sid.c
@@ -187,3 +187,44 @@ enum ndr_err_code ndr_push_dom_sid28(struct ndr_push *ndr, int ndr_flags, const
return NDR_ERR_SUCCESS;
}
+
+/*
+ parse a dom_sid0 - this is a dom_sid in a variable byte buffer, which is maybe empty
+*/
+enum ndr_err_code ndr_pull_dom_sid0(struct ndr_pull *ndr, int ndr_flags, struct dom_sid *sid)
+{
+ if (!(ndr_flags & NDR_SCALARS)) {
+ return NDR_ERR_SUCCESS;
+ }
+
+ if (ndr->data_size == ndr->offset) {
+ ZERO_STRUCTP(sid);
+ return NDR_ERR_SUCCESS;
+ }
+
+ return ndr_pull_dom_sid(ndr, ndr_flags, sid);
+}
+
+/*
+ push a dom_sid0 - this is a dom_sid in a variable byte buffer, which is maybe empty
+*/
+enum ndr_err_code ndr_push_dom_sid0(struct ndr_push *ndr, int ndr_flags, const struct dom_sid *sid)
+{
+ struct dom_sid zero_sid;
+
+ if (!(ndr_flags & NDR_SCALARS)) {
+ return NDR_ERR_SUCCESS;
+ }
+
+ if (!sid) {
+ return NDR_ERR_SUCCESS;
+ }
+
+ ZERO_STRUCT(zero_sid);
+
+ if (memcmp(&zero_sid, sid, sizeof(zero_sid)) == 0) {
+ return NDR_ERR_SUCCESS;
+ }
+
+ return ndr_push_dom_sid(ndr, ndr_flags, sid);
+}
diff --git a/source3/librpc/rpc/binding.c b/source3/librpc/rpc/binding.c
new file mode 100644
index 0000000000..92f65b5827
--- /dev/null
+++ b/source3/librpc/rpc/binding.c
@@ -0,0 +1,708 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ dcerpc utility functions
+
+ Copyright (C) Andrew Tridgell 2003
+ Copyright (C) Jelmer Vernooij 2004
+ Copyright (C) Andrew Bartlett <abartlet@samba.org> 2005
+ Copyright (C) Rafal Szczesniak 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 3 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, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+
+#define MAX_PROTSEQ 10
+
+static const struct {
+ const char *name;
+ enum dcerpc_transport_t transport;
+ int num_protocols;
+ enum epm_protocol protseq[MAX_PROTSEQ];
+} transports[] = {
+ { "ncacn_np", NCACN_NP, 3,
+ { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_SMB, EPM_PROTOCOL_NETBIOS }},
+ { "ncacn_ip_tcp", NCACN_IP_TCP, 3,
+ { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_TCP, EPM_PROTOCOL_IP } },
+ { "ncacn_http", NCACN_HTTP, 3,
+ { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_HTTP, EPM_PROTOCOL_IP } },
+ { "ncadg_ip_udp", NCACN_IP_UDP, 3,
+ { EPM_PROTOCOL_NCADG, EPM_PROTOCOL_UDP, EPM_PROTOCOL_IP } },
+ { "ncalrpc", NCALRPC, 2,
+ { EPM_PROTOCOL_NCALRPC, EPM_PROTOCOL_PIPE } },
+ { "ncacn_unix_stream", NCACN_UNIX_STREAM, 2,
+ { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_UNIX_DS } },
+ { "ncadg_unix_dgram", NCADG_UNIX_DGRAM, 2,
+ { EPM_PROTOCOL_NCADG, EPM_PROTOCOL_UNIX_DS } },
+ { "ncacn_at_dsp", NCACN_AT_DSP, 3,
+ { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_APPLETALK, EPM_PROTOCOL_DSP } },
+ { "ncadg_at_ddp", NCADG_AT_DDP, 3,
+ { EPM_PROTOCOL_NCADG, EPM_PROTOCOL_APPLETALK, EPM_PROTOCOL_DDP } },
+ { "ncacn_vns_ssp", NCACN_VNS_SPP, 3,
+ { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_STREETTALK, EPM_PROTOCOL_VINES_SPP } },
+ { "ncacn_vns_ipc", NCACN_VNS_IPC, 3,
+ { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_STREETTALK, EPM_PROTOCOL_VINES_IPC }, },
+ { "ncadg_ipx", NCADG_IPX, 2,
+ { EPM_PROTOCOL_NCADG, EPM_PROTOCOL_IPX },
+ },
+ { "ncacn_spx", NCACN_SPX, 3,
+ /* I guess some MS programmer confused the identifier for
+ * EPM_PROTOCOL_UUID (0x0D or 13) with the one for
+ * EPM_PROTOCOL_SPX (0x13) here. -- jelmer*/
+ { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_NCALRPC, EPM_PROTOCOL_UUID },
+ },
+};
+
+static const struct {
+ const char *name;
+ uint32_t flag;
+} ncacn_options[] = {
+};
+
+const char *epm_floor_string(TALLOC_CTX *mem_ctx, struct epm_floor *epm_floor)
+{
+ struct ndr_syntax_id syntax;
+ NTSTATUS status;
+
+ switch(epm_floor->lhs.protocol) {
+ case EPM_PROTOCOL_UUID:
+ status = dcerpc_floor_get_lhs_data(epm_floor, &syntax);
+ if (NT_STATUS_IS_OK(status)) {
+ /* lhs is used: UUID */
+ char *uuidstr;
+
+ if (GUID_equal(&syntax.uuid, &ndr_transfer_syntax.uuid)) {
+ return "NDR";
+ }
+
+ if (GUID_equal(&syntax.uuid, &ndr64_transfer_syntax.uuid)) {
+ return "NDR64";
+ }
+
+ uuidstr = GUID_string(mem_ctx, &syntax.uuid);
+
+ return talloc_asprintf(mem_ctx, " uuid %s/0x%02x", uuidstr, syntax.if_version);
+ } else { /* IPX */
+ return NULL;
+ }
+
+ case EPM_PROTOCOL_NCACN:
+ return "RPC-C";
+
+ case EPM_PROTOCOL_NCADG:
+ return "RPC";
+
+ case EPM_PROTOCOL_NCALRPC:
+ return "NCALRPC";
+
+ case EPM_PROTOCOL_DNET_NSP:
+ return "DNET/NSP";
+
+ case EPM_PROTOCOL_IP:
+ return talloc_asprintf(mem_ctx, "IP:%s", epm_floor->rhs.ip.ipaddr);
+
+ case EPM_PROTOCOL_PIPE:
+ return talloc_asprintf(mem_ctx, "PIPE:%s", epm_floor->rhs.pipe.path);
+
+ case EPM_PROTOCOL_SMB:
+ return talloc_asprintf(mem_ctx, "SMB:%s", epm_floor->rhs.smb.unc);
+
+ case EPM_PROTOCOL_UNIX_DS:
+ return talloc_asprintf(mem_ctx, "Unix:%s", epm_floor->rhs.unix_ds.path);
+
+ case EPM_PROTOCOL_NETBIOS:
+ return talloc_asprintf(mem_ctx, "NetBIOS:%s", epm_floor->rhs.netbios.name);
+
+ case EPM_PROTOCOL_NETBEUI:
+ return "NETBeui";
+
+ case EPM_PROTOCOL_SPX:
+ return "SPX";
+
+ case EPM_PROTOCOL_NB_IPX:
+ return "NB_IPX";
+
+ case EPM_PROTOCOL_HTTP:
+ return talloc_asprintf(mem_ctx, "HTTP:%d", epm_floor->rhs.http.port);
+
+ case EPM_PROTOCOL_TCP:
+ return talloc_asprintf(mem_ctx, "TCP:%d", epm_floor->rhs.tcp.port);
+
+ case EPM_PROTOCOL_UDP:
+ return talloc_asprintf(mem_ctx, "UDP:%d", epm_floor->rhs.udp.port);
+
+ default:
+ return talloc_asprintf(mem_ctx, "UNK(%02x):", epm_floor->lhs.protocol);
+ }
+}
+
+
+/*
+ form a binding string from a binding structure
+*/
+_PUBLIC_ char *dcerpc_binding_string(TALLOC_CTX *mem_ctx, const struct dcerpc_binding *b)
+{
+ char *s = talloc_strdup(mem_ctx, "");
+ int i;
+ const char *t_name = NULL;
+
+ if (b->transport != NCA_UNKNOWN) {
+ for (i=0;i<ARRAY_SIZE(transports);i++) {
+ if (transports[i].transport == b->transport) {
+ t_name = transports[i].name;
+ }
+ }
+ if (!t_name) {
+ return NULL;
+ }
+ }
+
+ if (!GUID_all_zero(&b->object.uuid)) {
+ s = talloc_asprintf(s, "%s@",
+ GUID_string(mem_ctx, &b->object.uuid));
+ }
+
+ if (t_name != NULL) {
+ s = talloc_asprintf_append_buffer(s, "%s:", t_name);
+ if (s == NULL) {
+ return NULL;
+ }
+ }
+
+ if (b->host) {
+ s = talloc_asprintf_append_buffer(s, "%s", b->host);
+ }
+
+ if (!b->endpoint && !b->options && !b->flags) {
+ return s;
+ }
+
+ s = talloc_asprintf_append_buffer(s, "[");
+
+ if (b->endpoint) {
+ s = talloc_asprintf_append_buffer(s, "%s", b->endpoint);
+ }
+
+ /* this is a *really* inefficent way of dealing with strings,
+ but this is rarely called and the strings are always short,
+ so I don't care */
+ for (i=0;b->options && b->options[i];i++) {
+ s = talloc_asprintf_append_buffer(s, ",%s", b->options[i]);
+ if (!s) return NULL;
+ }
+
+ for (i=0;i<ARRAY_SIZE(ncacn_options);i++) {
+ if (b->flags & ncacn_options[i].flag) {
+ s = talloc_asprintf_append_buffer(s, ",%s", ncacn_options[i].name);
+ if (!s) return NULL;
+ }
+ }
+
+ s = talloc_asprintf_append_buffer(s, "]");
+
+ return s;
+}
+
+/*
+ parse a binding string into a dcerpc_binding structure
+*/
+_PUBLIC_ NTSTATUS dcerpc_parse_binding(TALLOC_CTX *mem_ctx, const char *s, struct dcerpc_binding **b_out)
+{
+ struct dcerpc_binding *b;
+ char *options;
+ char *p;
+ int i, j, comma_count;
+
+ b = talloc(mem_ctx, struct dcerpc_binding);
+ if (!b) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ p = strchr(s, '@');
+
+ if (p && PTR_DIFF(p, s) == 36) { /* 36 is the length of a UUID */
+ NTSTATUS status;
+
+ status = GUID_from_string(s, &b->object.uuid);
+
+ if (NT_STATUS_IS_ERR(status)) {
+ DEBUG(0, ("Failed parsing UUID\n"));
+ return status;
+ }
+
+ s = p + 1;
+ } else {
+ ZERO_STRUCT(b->object);
+ }
+
+ b->object.if_version = 0;
+
+ p = strchr(s, ':');
+
+ if (p == NULL) {
+ b->transport = NCA_UNKNOWN;
+ } else {
+ char *type = talloc_strndup(mem_ctx, s, PTR_DIFF(p, s));
+ if (!type) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ for (i=0;i<ARRAY_SIZE(transports);i++) {
+ if (strcmp(type, transports[i].name) == 0) {
+ b->transport = transports[i].transport;
+ break;
+ }
+ }
+
+ if (i==ARRAY_SIZE(transports)) {
+ DEBUG(0,("Unknown dcerpc transport '%s'\n", type));
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ talloc_free(type);
+
+ s = p+1;
+ }
+
+ p = strchr(s, '[');
+ if (p) {
+ b->host = talloc_strndup(b, s, PTR_DIFF(p, s));
+ options = talloc_strdup(mem_ctx, p+1);
+ if (options[strlen(options)-1] != ']') {
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+ options[strlen(options)-1] = 0;
+ } else {
+ b->host = talloc_strdup(b, s);
+ options = NULL;
+ }
+ if (!b->host) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ b->target_hostname = b->host;
+
+ b->options = NULL;
+ b->flags = 0;
+ b->assoc_group_id = 0;
+ b->endpoint = NULL;
+
+ if (!options) {
+ *b_out = b;
+ return NT_STATUS_OK;
+ }
+
+ comma_count = count_chars(options, ',');
+
+ b->options = talloc_array(b, const char *, comma_count+2);
+ if (!b->options) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ for (i=0; (p = strchr(options, ',')); i++) {
+ b->options[i] = talloc_strndup(b, options, PTR_DIFF(p, options));
+ if (!b->options[i]) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ options = p+1;
+ }
+ b->options[i] = options;
+ b->options[i+1] = NULL;
+
+ /* some options are pre-parsed for convenience */
+ for (i=0;b->options[i];i++) {
+ for (j=0;j<ARRAY_SIZE(ncacn_options);j++) {
+ if (strcmp(ncacn_options[j].name, b->options[i]) == 0) {
+ int k;
+ b->flags |= ncacn_options[j].flag;
+ for (k=i;b->options[k];k++) {
+ b->options[k] = b->options[k+1];
+ }
+ i--;
+ break;
+ }
+ }
+ }
+
+ if (b->options[0]) {
+ /* Endpoint is first option */
+ b->endpoint = b->options[0];
+ if (strlen(b->endpoint) == 0) b->endpoint = NULL;
+
+ for (i=0;b->options[i];i++) {
+ b->options[i] = b->options[i+1];
+ }
+ }
+
+ if (b->options[0] == NULL)
+ b->options = NULL;
+
+ *b_out = b;
+ return NT_STATUS_OK;
+}
+
+_PUBLIC_ NTSTATUS dcerpc_floor_get_lhs_data(struct epm_floor *epm_floor, struct ndr_syntax_id *syntax)
+{
+ TALLOC_CTX *mem_ctx = talloc_init("floor_get_lhs_data");
+ struct ndr_pull *ndr = ndr_pull_init_blob(&epm_floor->lhs.lhs_data, mem_ctx);
+ enum ndr_err_code ndr_err;
+ uint16_t if_version=0;
+
+ ndr->flags |= LIBNDR_FLAG_NOALIGN;
+
+ ndr_err = ndr_pull_GUID(ndr, NDR_SCALARS | NDR_BUFFERS, &syntax->uuid);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ talloc_free(mem_ctx);
+ return ndr_map_error2ntstatus(ndr_err);
+ }
+
+ ndr_err = ndr_pull_uint16(ndr, NDR_SCALARS, &if_version);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ talloc_free(mem_ctx);
+ return ndr_map_error2ntstatus(ndr_err);
+ }
+
+ syntax->if_version = if_version;
+
+ talloc_free(mem_ctx);
+
+ return NT_STATUS_OK;
+}
+
+static DATA_BLOB dcerpc_floor_pack_lhs_data(TALLOC_CTX *mem_ctx, const struct ndr_syntax_id *syntax)
+{
+ struct ndr_push *ndr = ndr_push_init_ctx(mem_ctx);
+
+ ndr->flags |= LIBNDR_FLAG_NOALIGN;
+
+ ndr_push_GUID(ndr, NDR_SCALARS | NDR_BUFFERS, &syntax->uuid);
+ ndr_push_uint16(ndr, NDR_SCALARS, syntax->if_version);
+
+ return ndr_push_blob(ndr);
+}
+
+const char *dcerpc_floor_get_rhs_data(TALLOC_CTX *mem_ctx, struct epm_floor *epm_floor)
+{
+ switch (epm_floor->lhs.protocol) {
+ case EPM_PROTOCOL_TCP:
+ if (epm_floor->rhs.tcp.port == 0) return NULL;
+ return talloc_asprintf(mem_ctx, "%d", epm_floor->rhs.tcp.port);
+
+ case EPM_PROTOCOL_UDP:
+ if (epm_floor->rhs.udp.port == 0) return NULL;
+ return talloc_asprintf(mem_ctx, "%d", epm_floor->rhs.udp.port);
+
+ case EPM_PROTOCOL_HTTP:
+ if (epm_floor->rhs.http.port == 0) return NULL;
+ return talloc_asprintf(mem_ctx, "%d", epm_floor->rhs.http.port);
+
+ case EPM_PROTOCOL_IP:
+ return talloc_strdup(mem_ctx, epm_floor->rhs.ip.ipaddr);
+
+ case EPM_PROTOCOL_NCACN:
+ return NULL;
+
+ case EPM_PROTOCOL_NCADG:
+ return NULL;
+
+ case EPM_PROTOCOL_SMB:
+ if (strlen(epm_floor->rhs.smb.unc) == 0) return NULL;
+ return talloc_strdup(mem_ctx, epm_floor->rhs.smb.unc);
+
+ case EPM_PROTOCOL_PIPE:
+ if (strlen(epm_floor->rhs.pipe.path) == 0) return NULL;
+ return talloc_strdup(mem_ctx, epm_floor->rhs.pipe.path);
+
+ case EPM_PROTOCOL_NETBIOS:
+ if (strlen(epm_floor->rhs.netbios.name) == 0) return NULL;
+ return talloc_strdup(mem_ctx, epm_floor->rhs.netbios.name);
+
+ case EPM_PROTOCOL_NCALRPC:
+ return NULL;
+
+ case EPM_PROTOCOL_VINES_SPP:
+ return talloc_asprintf(mem_ctx, "%d", epm_floor->rhs.vines_spp.port);
+
+ case EPM_PROTOCOL_VINES_IPC:
+ return talloc_asprintf(mem_ctx, "%d", epm_floor->rhs.vines_ipc.port);
+
+ case EPM_PROTOCOL_STREETTALK:
+ return talloc_strdup(mem_ctx, epm_floor->rhs.streettalk.streettalk);
+
+ case EPM_PROTOCOL_UNIX_DS:
+ if (strlen(epm_floor->rhs.unix_ds.path) == 0) return NULL;
+ return talloc_strdup(mem_ctx, epm_floor->rhs.unix_ds.path);
+
+ case EPM_PROTOCOL_NULL:
+ return NULL;
+
+ default:
+ DEBUG(0,("Unsupported lhs protocol %d\n", epm_floor->lhs.protocol));
+ break;
+ }
+
+ return NULL;
+}
+
+static NTSTATUS dcerpc_floor_set_rhs_data(TALLOC_CTX *mem_ctx,
+ struct epm_floor *epm_floor,
+ const char *data)
+{
+ switch (epm_floor->lhs.protocol) {
+ case EPM_PROTOCOL_TCP:
+ epm_floor->rhs.tcp.port = atoi(data);
+ return NT_STATUS_OK;
+
+ case EPM_PROTOCOL_UDP:
+ epm_floor->rhs.udp.port = atoi(data);
+ return NT_STATUS_OK;
+
+ case EPM_PROTOCOL_HTTP:
+ epm_floor->rhs.http.port = atoi(data);
+ return NT_STATUS_OK;
+
+ case EPM_PROTOCOL_IP:
+ epm_floor->rhs.ip.ipaddr = talloc_strdup(mem_ctx, data);
+ NT_STATUS_HAVE_NO_MEMORY(epm_floor->rhs.ip.ipaddr);
+ return NT_STATUS_OK;
+
+ case EPM_PROTOCOL_NCACN:
+ epm_floor->rhs.ncacn.minor_version = 0;
+ return NT_STATUS_OK;
+
+ case EPM_PROTOCOL_NCADG:
+ epm_floor->rhs.ncadg.minor_version = 0;
+ return NT_STATUS_OK;
+
+ case EPM_PROTOCOL_SMB:
+ epm_floor->rhs.smb.unc = talloc_strdup(mem_ctx, data);
+ NT_STATUS_HAVE_NO_MEMORY(epm_floor->rhs.smb.unc);
+ return NT_STATUS_OK;
+
+ case EPM_PROTOCOL_PIPE:
+ epm_floor->rhs.pipe.path = talloc_strdup(mem_ctx, data);
+ NT_STATUS_HAVE_NO_MEMORY(epm_floor->rhs.pipe.path);
+ return NT_STATUS_OK;
+
+ case EPM_PROTOCOL_NETBIOS:
+ epm_floor->rhs.netbios.name = talloc_strdup(mem_ctx, data);
+ NT_STATUS_HAVE_NO_MEMORY(epm_floor->rhs.netbios.name);
+ return NT_STATUS_OK;
+
+ case EPM_PROTOCOL_NCALRPC:
+ return NT_STATUS_OK;
+
+ case EPM_PROTOCOL_VINES_SPP:
+ epm_floor->rhs.vines_spp.port = atoi(data);
+ return NT_STATUS_OK;
+
+ case EPM_PROTOCOL_VINES_IPC:
+ epm_floor->rhs.vines_ipc.port = atoi(data);
+ return NT_STATUS_OK;
+
+ case EPM_PROTOCOL_STREETTALK:
+ epm_floor->rhs.streettalk.streettalk = talloc_strdup(mem_ctx, data);
+ NT_STATUS_HAVE_NO_MEMORY(epm_floor->rhs.streettalk.streettalk);
+ return NT_STATUS_OK;
+
+ case EPM_PROTOCOL_UNIX_DS:
+ epm_floor->rhs.unix_ds.path = talloc_strdup(mem_ctx, data);
+ NT_STATUS_HAVE_NO_MEMORY(epm_floor->rhs.unix_ds.path);
+ return NT_STATUS_OK;
+
+ case EPM_PROTOCOL_NULL:
+ return NT_STATUS_OK;
+
+ default:
+ DEBUG(0,("Unsupported lhs protocol %d\n", epm_floor->lhs.protocol));
+ break;
+ }
+
+ return NT_STATUS_NOT_SUPPORTED;
+}
+
+enum dcerpc_transport_t dcerpc_transport_by_endpoint_protocol(int prot)
+{
+ int i;
+
+ /* Find a transport that has 'prot' as 4th protocol */
+ for (i=0;i<ARRAY_SIZE(transports);i++) {
+ if (transports[i].num_protocols >= 2 &&
+ transports[i].protseq[1] == prot) {
+ return transports[i].transport;
+ }
+ }
+
+ /* Unknown transport */
+ return (unsigned int)-1;
+}
+
+_PUBLIC_ enum dcerpc_transport_t dcerpc_transport_by_tower(struct epm_tower *tower)
+{
+ int i;
+
+ /* Find a transport that matches this tower */
+ for (i=0;i<ARRAY_SIZE(transports);i++) {
+ int j;
+ if (transports[i].num_protocols != tower->num_floors - 2) {
+ continue;
+ }
+
+ for (j = 0; j < transports[i].num_protocols; j++) {
+ if (transports[i].protseq[j] != tower->floors[j+2].lhs.protocol) {
+ break;
+ }
+ }
+
+ if (j == transports[i].num_protocols) {
+ return transports[i].transport;
+ }
+ }
+
+ /* Unknown transport */
+ return (unsigned int)-1;
+}
+
+_PUBLIC_ NTSTATUS dcerpc_binding_from_tower(TALLOC_CTX *mem_ctx,
+ struct epm_tower *tower,
+ struct dcerpc_binding **b_out)
+{
+ NTSTATUS status;
+ struct dcerpc_binding *binding;
+
+ binding = talloc(mem_ctx, struct dcerpc_binding);
+ NT_STATUS_HAVE_NO_MEMORY(binding);
+
+ ZERO_STRUCT(binding->object);
+ binding->options = NULL;
+ binding->host = NULL;
+ binding->target_hostname = NULL;
+ binding->flags = 0;
+ binding->assoc_group_id = 0;
+
+ binding->transport = dcerpc_transport_by_tower(tower);
+
+ if (binding->transport == (unsigned int)-1) {
+ return NT_STATUS_NOT_SUPPORTED;
+ }
+
+ if (tower->num_floors < 1) {
+ return NT_STATUS_OK;
+ }
+
+ /* Set object uuid */
+ status = dcerpc_floor_get_lhs_data(&tower->floors[0], &binding->object);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(1, ("Error pulling object uuid and version: %s", nt_errstr(status)));
+ return status;
+ }
+
+ /* Ignore floor 1, it contains the NDR version info */
+
+ binding->options = NULL;
+
+ /* Set endpoint */
+ if (tower->num_floors >= 4) {
+ binding->endpoint = dcerpc_floor_get_rhs_data(mem_ctx, &tower->floors[3]);
+ } else {
+ binding->endpoint = NULL;
+ }
+
+ /* Set network address */
+ if (tower->num_floors >= 5) {
+ binding->host = dcerpc_floor_get_rhs_data(mem_ctx, &tower->floors[4]);
+ NT_STATUS_HAVE_NO_MEMORY(binding->host);
+ binding->target_hostname = binding->host;
+ }
+ *b_out = binding;
+ return NT_STATUS_OK;
+}
+
+_PUBLIC_ NTSTATUS dcerpc_binding_build_tower(TALLOC_CTX *mem_ctx, struct dcerpc_binding *binding, struct epm_tower *tower)
+{
+ const enum epm_protocol *protseq = NULL;
+ int num_protocols = -1, i;
+ NTSTATUS status;
+
+ /* Find transport */
+ for (i=0;i<ARRAY_SIZE(transports);i++) {
+ if (transports[i].transport == binding->transport) {
+ protseq = transports[i].protseq;
+ num_protocols = transports[i].num_protocols;
+ break;
+ }
+ }
+
+ if (num_protocols == -1) {
+ DEBUG(0, ("Unable to find transport with id '%d'\n", binding->transport));
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
+ tower->num_floors = 2 + num_protocols;
+ tower->floors = talloc_array(mem_ctx, struct epm_floor, tower->num_floors);
+
+ /* Floor 0 */
+ tower->floors[0].lhs.protocol = EPM_PROTOCOL_UUID;
+
+ tower->floors[0].lhs.lhs_data = dcerpc_floor_pack_lhs_data(mem_ctx, &binding->object);
+
+ tower->floors[0].rhs.uuid.unknown = data_blob_talloc_zero(mem_ctx, 2);
+
+ /* Floor 1 */
+ tower->floors[1].lhs.protocol = EPM_PROTOCOL_UUID;
+
+ tower->floors[1].lhs.lhs_data = dcerpc_floor_pack_lhs_data(mem_ctx,
+ &ndr_transfer_syntax);
+
+ tower->floors[1].rhs.uuid.unknown = data_blob_talloc_zero(mem_ctx, 2);
+
+ /* Floor 2 to num_protocols */
+ for (i = 0; i < num_protocols; i++) {
+ tower->floors[2 + i].lhs.protocol = protseq[i];
+ tower->floors[2 + i].lhs.lhs_data = data_blob_talloc(mem_ctx, NULL, 0);
+ ZERO_STRUCT(tower->floors[2 + i].rhs);
+ dcerpc_floor_set_rhs_data(mem_ctx, &tower->floors[2 + i], "");
+ }
+
+ /* The 4th floor contains the endpoint */
+ if (num_protocols >= 2 && binding->endpoint) {
+ status = dcerpc_floor_set_rhs_data(mem_ctx, &tower->floors[3], binding->endpoint);
+ if (NT_STATUS_IS_ERR(status)) {
+ return status;
+ }
+ }
+
+ /* The 5th contains the network address */
+ if (num_protocols >= 3 && binding->host) {
+ if (is_ipaddress(binding->host)) {
+ status = dcerpc_floor_set_rhs_data(mem_ctx, &tower->floors[4],
+ binding->host);
+ } else {
+ /* note that we don't attempt to resolve the
+ name here - when we get a hostname here we
+ are in the client code, and want to put in
+ a wildcard all-zeros IP for the server to
+ fill in */
+ status = dcerpc_floor_set_rhs_data(mem_ctx, &tower->floors[4],
+ "0.0.0.0");
+ }
+ if (NT_STATUS_IS_ERR(status)) {
+ return status;
+ }
+ }
+
+ return NT_STATUS_OK;
+}
diff --git a/source3/librpc/rpc/dcerpc.c b/source3/librpc/rpc/dcerpc.c
new file mode 100644
index 0000000000..c8bca8d3eb
--- /dev/null
+++ b/source3/librpc/rpc/dcerpc.c
@@ -0,0 +1,187 @@
+/*
+ Unix SMB/CIFS implementation.
+ Samba 4-compatible DCE/RPC API on top of the Samba 3 DCE/RPC client library.
+ Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2008
+
+ 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 3 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, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include "librpc/rpc/dcerpc.h"
+
+/**
+ * Send a struct-based RPC request using the Samba 3 RPC client library.
+ */
+struct rpc_request *dcerpc_ndr_request_send(struct dcerpc_pipe *p, const struct GUID *object,
+ const struct ndr_interface_table *table, uint32_t opnum,
+ TALLOC_CTX *mem_ctx, void *r)
+{
+ const struct ndr_interface_call *call;
+ struct ndr_push *push;
+ struct rpc_request *ret = talloc(mem_ctx, struct rpc_request);
+ enum ndr_err_code ndr_err;
+ DATA_BLOB blob;
+
+ if (ret == NULL)
+ return NULL;
+
+ SMB_ASSERT(p->table->num_calls > opnum);
+
+ call = &p->table->calls[opnum];
+
+ ret->call = call;
+ ret->r = r;
+
+ push = ndr_push_init_ctx(mem_ctx);
+ if (!push) {
+ return NULL;
+ }
+
+ ndr_err = call->ndr_push(push, NDR_IN, r);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ /* FIXME: ndr_map_error2ntstatus(ndr_err); */
+ return NULL;
+ }
+
+ blob = ndr_push_blob(push);
+
+ if (!prs_init_data_blob(&ret->q_ps, &blob, mem_ctx)) {
+ return NULL;
+ }
+
+ talloc_free(push);
+
+ ret->opnum = opnum;
+
+ ret->pipe = p;
+
+ return ret;
+}
+
+/**
+ * Wait for a DCE/RPC request.
+ *
+ * @note at the moment this is still sync, even though the API is async.
+ */
+NTSTATUS dcerpc_ndr_request_recv(struct rpc_request *req)
+{
+ prs_struct r_ps;
+ struct ndr_pull *pull;
+ NTSTATUS status;
+ DATA_BLOB blob;
+ enum ndr_err_code ndr_err;
+
+ prs_init_empty( &r_ps, req, UNMARSHALL );
+
+ status = rpc_api_pipe_req(req->pipe->rpc_cli, req->opnum, &req->q_ps, &r_ps);
+
+ prs_mem_free( &req->q_ps );
+
+ if (!NT_STATUS_IS_OK(status)) {
+ prs_mem_free( &r_ps );
+ return status;
+ }
+
+ if (!prs_data_blob(&r_ps, &blob, req)) {
+ prs_mem_free( &r_ps );
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ prs_mem_free( &r_ps );
+
+ pull = ndr_pull_init_blob(&blob, req);
+ if (pull == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ /* have the ndr parser alloc memory for us */
+ pull->flags |= LIBNDR_FLAG_REF_ALLOC;
+ ndr_err = req->call->ndr_pull(pull, NDR_OUT, req->r);
+ talloc_free(pull);
+
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ return ndr_map_error2ntstatus(ndr_err);
+ }
+
+ return NT_STATUS_OK;
+}
+
+/**
+ * Connect to a DCE/RPC interface.
+ *
+ * @note lp_ctx and ev are ignored at the moment but present
+ * for API compatibility.
+ */
+_PUBLIC_ NTSTATUS dcerpc_pipe_connect(TALLOC_CTX *parent_ctx, struct dcerpc_pipe **pp,
+ const char *binding_string, const struct ndr_interface_table *table,
+ struct cli_credentials *credentials, struct event_context *ev,
+ struct loadparm_context *lp_ctx)
+{
+ struct dcerpc_pipe *p = talloc(parent_ctx, struct dcerpc_pipe);
+ struct dcerpc_binding *binding;
+ NTSTATUS nt_status;
+ int idx;
+
+ nt_status = dcerpc_parse_binding(p, binding_string, &binding);
+
+ if (NT_STATUS_IS_ERR(nt_status)) {
+ DEBUG(1, ("Unable to parse binding string '%s'", binding_string));
+ talloc_free(p);
+ return nt_status;
+ }
+
+ if (binding->transport != NCACN_NP) {
+ DEBUG(0, ("Only ncacn_np supported"));
+ talloc_free(p);
+ return NT_STATUS_NOT_SUPPORTED;
+ }
+
+ /* FIXME: Actually use loadparm_context.. */
+
+ /* FIXME: actually use credentials */
+
+ nt_status = cli_full_connection(&p->cli, global_myname(), binding->host,
+ NULL, 0,
+ "IPC$", "IPC",
+ get_cmdline_auth_info_username(),
+ lp_workgroup(),
+ get_cmdline_auth_info_password(),
+ get_cmdline_auth_info_use_kerberos() ? CLI_FULL_CONNECTION_USE_KERBEROS : 0,
+ get_cmdline_auth_info_signing_state(), NULL);
+
+ if (NT_STATUS_IS_ERR(nt_status)) {
+ talloc_free(p);
+ return nt_status;
+ }
+
+ idx = cli_get_pipe_idx(&table->syntax_id);
+ if (idx < 0) {
+ DEBUG(0, ("Unable to find interface index"));
+ talloc_free(p);
+ return NT_STATUS_OBJECT_PATH_INVALID;
+ }
+
+ p->rpc_cli = cli_rpc_pipe_open_noauth(p->cli, idx, &nt_status);
+
+ if (p->rpc_cli == NULL) {
+ talloc_free(p);
+ return nt_status;
+ }
+
+ p->table = table;
+
+ *pp = p;
+
+ return nt_status;
+}
diff --git a/source3/librpc/rpc/dcerpc.h b/source3/librpc/rpc/dcerpc.h
new file mode 100644
index 0000000000..739e60a341
--- /dev/null
+++ b/source3/librpc/rpc/dcerpc.h
@@ -0,0 +1,75 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ DCERPC client side interface structures
+
+ Copyright (C) 2008 Jelmer Vernooij
+
+ 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 3 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, see <http://www.gnu.org/licenses/>.
+*/
+
+/* This is a public header file that is installed as part of Samba.
+ * If you remove any functions or change their signature, update
+ * the so version number. */
+
+#ifndef __DCERPC_H__
+#define __DCERPC_H__
+
+#include "includes.h"
+#include "librpc/rpc/dcerpc.h"
+#include "librpc/gen_ndr/epmapper.h"
+
+struct loadparm_context;
+struct cli_credentials;
+
+/**
+ * Connection to a particular DCE/RPC interface.
+ */
+struct dcerpc_pipe {
+ const struct ndr_interface_table *table;
+
+ /** SMB context used when transport is ncacn_np. */
+ struct cli_state *cli;
+
+ /** Samba 3 DCE/RPC client context. */
+ struct rpc_pipe_client *rpc_cli;
+};
+
+struct rpc_request {
+ const struct ndr_interface_call *call;
+ prs_struct q_ps;
+ uint32_t opnum;
+ struct dcerpc_pipe *pipe;
+ void *r;
+};
+
+enum dcerpc_transport_t {
+ NCA_UNKNOWN, NCACN_NP, NCACN_IP_TCP, NCACN_IP_UDP, NCACN_VNS_IPC,
+ NCACN_VNS_SPP, NCACN_AT_DSP, NCADG_AT_DDP, NCALRPC, NCACN_UNIX_STREAM,
+ NCADG_UNIX_DGRAM, NCACN_HTTP, NCADG_IPX, NCACN_SPX };
+
+
+/** this describes a binding to a particular transport/pipe */
+struct dcerpc_binding {
+ enum dcerpc_transport_t transport;
+ struct ndr_syntax_id object;
+ const char *host;
+ const char *target_hostname;
+ const char *endpoint;
+ const char **options;
+ uint32_t flags;
+ uint32_t assoc_group_id;
+};
+
+#endif /* __DCERPC_H__ */
diff --git a/source3/librpc/rpc/dcerpc_util.c b/source3/librpc/rpc/dcerpc_util.c
new file mode 100644
index 0000000000..3b8768ccc2
--- /dev/null
+++ b/source3/librpc/rpc/dcerpc_util.c
@@ -0,0 +1,1438 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ dcerpc utility functions
+
+ Copyright (C) Andrew Tridgell 2003
+ Copyright (C) Jelmer Vernooij 2004
+ Copyright (C) Andrew Bartlett <abartlet@samba.org> 2005
+ Copyright (C) Rafal Szczesniak 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 3 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, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include "lib/events/events.h"
+#include "libcli/composite/composite.h"
+#include "librpc/gen_ndr/ndr_epmapper_c.h"
+#include "librpc/gen_ndr/ndr_dcerpc.h"
+#include "librpc/gen_ndr/ndr_misc.h"
+#include "librpc/rpc/dcerpc_proto.h"
+#include "auth/credentials/credentials.h"
+#include "param/param.h"
+
+/*
+ find a dcerpc call on an interface by name
+*/
+const struct ndr_interface_call *dcerpc_iface_find_call(const struct ndr_interface_table *iface,
+ const char *name)
+{
+ int i;
+ for (i=0;i<iface->num_calls;i++) {
+ if (strcmp(iface->calls[i].name, name) == 0) {
+ return &iface->calls[i];
+ }
+ }
+ return NULL;
+}
+
+/*
+ push a ncacn_packet into a blob, potentially with auth info
+*/
+NTSTATUS ncacn_push_auth(DATA_BLOB *blob, TALLOC_CTX *mem_ctx,
+ struct smb_iconv_convenience *iconv_convenience,
+ struct ncacn_packet *pkt,
+ struct dcerpc_auth *auth_info)
+{
+ struct ndr_push *ndr;
+ enum ndr_err_code ndr_err;
+
+ ndr = ndr_push_init_ctx(mem_ctx, iconv_convenience);
+ if (!ndr) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ if (!(pkt->drep[0] & DCERPC_DREP_LE)) {
+ ndr->flags |= LIBNDR_FLAG_BIGENDIAN;
+ }
+
+ if (pkt->pfc_flags & DCERPC_PFC_FLAG_OBJECT_UUID) {
+ ndr->flags |= LIBNDR_FLAG_OBJECT_PRESENT;
+ }
+
+ if (auth_info) {
+ pkt->auth_length = auth_info->credentials.length;
+ } else {
+ pkt->auth_length = 0;
+ }
+
+ ndr_err = ndr_push_ncacn_packet(ndr, NDR_SCALARS|NDR_BUFFERS, pkt);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ return ndr_map_error2ntstatus(ndr_err);
+ }
+
+ if (auth_info) {
+ ndr_err = ndr_push_dcerpc_auth(ndr, NDR_SCALARS|NDR_BUFFERS, auth_info);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ return ndr_map_error2ntstatus(ndr_err);
+ }
+ }
+
+ *blob = ndr_push_blob(ndr);
+
+ /* fill in the frag length */
+ dcerpc_set_frag_length(blob, blob->length);
+
+ return NT_STATUS_OK;
+}
+
+#define MAX_PROTSEQ 10
+
+static const struct {
+ const char *name;
+ enum dcerpc_transport_t transport;
+ int num_protocols;
+ enum epm_protocol protseq[MAX_PROTSEQ];
+} transports[] = {
+ { "ncacn_np", NCACN_NP, 3,
+ { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_SMB, EPM_PROTOCOL_NETBIOS }},
+ { "ncacn_ip_tcp", NCACN_IP_TCP, 3,
+ { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_TCP, EPM_PROTOCOL_IP } },
+ { "ncacn_http", NCACN_HTTP, 3,
+ { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_HTTP, EPM_PROTOCOL_IP } },
+ { "ncadg_ip_udp", NCACN_IP_UDP, 3,
+ { EPM_PROTOCOL_NCADG, EPM_PROTOCOL_UDP, EPM_PROTOCOL_IP } },
+ { "ncalrpc", NCALRPC, 2,
+ { EPM_PROTOCOL_NCALRPC, EPM_PROTOCOL_PIPE } },
+ { "ncacn_unix_stream", NCACN_UNIX_STREAM, 2,
+ { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_UNIX_DS } },
+ { "ncadg_unix_dgram", NCADG_UNIX_DGRAM, 2,
+ { EPM_PROTOCOL_NCADG, EPM_PROTOCOL_UNIX_DS } },
+ { "ncacn_at_dsp", NCACN_AT_DSP, 3,
+ { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_APPLETALK, EPM_PROTOCOL_DSP } },
+ { "ncadg_at_ddp", NCADG_AT_DDP, 3,
+ { EPM_PROTOCOL_NCADG, EPM_PROTOCOL_APPLETALK, EPM_PROTOCOL_DDP } },
+ { "ncacn_vns_ssp", NCACN_VNS_SPP, 3,
+ { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_STREETTALK, EPM_PROTOCOL_VINES_SPP } },
+ { "ncacn_vns_ipc", NCACN_VNS_IPC, 3,
+ { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_STREETTALK, EPM_PROTOCOL_VINES_IPC }, },
+ { "ncadg_ipx", NCADG_IPX, 2,
+ { EPM_PROTOCOL_NCADG, EPM_PROTOCOL_IPX },
+ },
+ { "ncacn_spx", NCACN_SPX, 3,
+ /* I guess some MS programmer confused the identifier for
+ * EPM_PROTOCOL_UUID (0x0D or 13) with the one for
+ * EPM_PROTOCOL_SPX (0x13) here. -- jelmer*/
+ { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_NCALRPC, EPM_PROTOCOL_UUID },
+ },
+};
+
+static const struct {
+ const char *name;
+ uint32_t flag;
+} ncacn_options[] = {
+ {"sign", DCERPC_SIGN},
+ {"seal", DCERPC_SEAL},
+ {"connect", DCERPC_CONNECT},
+ {"spnego", DCERPC_AUTH_SPNEGO},
+ {"ntlm", DCERPC_AUTH_NTLM},
+ {"krb5", DCERPC_AUTH_KRB5},
+ {"validate", DCERPC_DEBUG_VALIDATE_BOTH},
+ {"print", DCERPC_DEBUG_PRINT_BOTH},
+ {"padcheck", DCERPC_DEBUG_PAD_CHECK},
+ {"bigendian", DCERPC_PUSH_BIGENDIAN},
+ {"smb2", DCERPC_SMB2}
+};
+
+const char *epm_floor_string(TALLOC_CTX *mem_ctx, struct epm_floor *epm_floor)
+{
+ struct ndr_syntax_id syntax;
+ NTSTATUS status;
+
+ switch(epm_floor->lhs.protocol) {
+ case EPM_PROTOCOL_UUID:
+ status = dcerpc_floor_get_lhs_data(epm_floor, &syntax);
+ if (NT_STATUS_IS_OK(status)) {
+ /* lhs is used: UUID */
+ char *uuidstr;
+
+ if (GUID_equal(&syntax.uuid, &ndr_transfer_syntax.uuid)) {
+ return "NDR";
+ }
+
+ if (GUID_equal(&syntax.uuid, &ndr64_transfer_syntax.uuid)) {
+ return "NDR64";
+ }
+
+ uuidstr = GUID_string(mem_ctx, &syntax.uuid);
+
+ return talloc_asprintf(mem_ctx, " uuid %s/0x%02x", uuidstr, syntax.if_version);
+ } else { /* IPX */
+ return talloc_asprintf(mem_ctx, "IPX:%s",
+ data_blob_hex_string(mem_ctx, &epm_floor->rhs.uuid.unknown));
+ }
+
+ case EPM_PROTOCOL_NCACN:
+ return "RPC-C";
+
+ case EPM_PROTOCOL_NCADG:
+ return "RPC";
+
+ case EPM_PROTOCOL_NCALRPC:
+ return "NCALRPC";
+
+ case EPM_PROTOCOL_DNET_NSP:
+ return "DNET/NSP";
+
+ case EPM_PROTOCOL_IP:
+ return talloc_asprintf(mem_ctx, "IP:%s", epm_floor->rhs.ip.ipaddr);
+
+ case EPM_PROTOCOL_PIPE:
+ return talloc_asprintf(mem_ctx, "PIPE:%s", epm_floor->rhs.pipe.path);
+
+ case EPM_PROTOCOL_SMB:
+ return talloc_asprintf(mem_ctx, "SMB:%s", epm_floor->rhs.smb.unc);
+
+ case EPM_PROTOCOL_UNIX_DS:
+ return talloc_asprintf(mem_ctx, "Unix:%s", epm_floor->rhs.unix_ds.path);
+
+ case EPM_PROTOCOL_NETBIOS:
+ return talloc_asprintf(mem_ctx, "NetBIOS:%s", epm_floor->rhs.netbios.name);
+
+ case EPM_PROTOCOL_NETBEUI:
+ return "NETBeui";
+
+ case EPM_PROTOCOL_SPX:
+ return "SPX";
+
+ case EPM_PROTOCOL_NB_IPX:
+ return "NB_IPX";
+
+ case EPM_PROTOCOL_HTTP:
+ return talloc_asprintf(mem_ctx, "HTTP:%d", epm_floor->rhs.http.port);
+
+ case EPM_PROTOCOL_TCP:
+ return talloc_asprintf(mem_ctx, "TCP:%d", epm_floor->rhs.tcp.port);
+
+ case EPM_PROTOCOL_UDP:
+ return talloc_asprintf(mem_ctx, "UDP:%d", epm_floor->rhs.udp.port);
+
+ default:
+ return talloc_asprintf(mem_ctx, "UNK(%02x):", epm_floor->lhs.protocol);
+ }
+}
+
+
+/*
+ form a binding string from a binding structure
+*/
+_PUBLIC_ char *dcerpc_binding_string(TALLOC_CTX *mem_ctx, const struct dcerpc_binding *b)
+{
+ char *s = talloc_strdup(mem_ctx, "");
+ int i;
+ const char *t_name = NULL;
+
+ if (b->transport != NCA_UNKNOWN) {
+ for (i=0;i<ARRAY_SIZE(transports);i++) {
+ if (transports[i].transport == b->transport) {
+ t_name = transports[i].name;
+ }
+ }
+ if (!t_name) {
+ return NULL;
+ }
+ }
+
+ if (!GUID_all_zero(&b->object.uuid)) {
+ s = talloc_asprintf(s, "%s@",
+ GUID_string(mem_ctx, &b->object.uuid));
+ }
+
+ if (t_name != NULL) {
+ s = talloc_asprintf_append_buffer(s, "%s:", t_name);
+ if (s == NULL) {
+ return NULL;
+ }
+ }
+
+ if (b->host) {
+ s = talloc_asprintf_append_buffer(s, "%s", b->host);
+ }
+
+ if (!b->endpoint && !b->options && !b->flags) {
+ return s;
+ }
+
+ s = talloc_asprintf_append_buffer(s, "[");
+
+ if (b->endpoint) {
+ s = talloc_asprintf_append_buffer(s, "%s", b->endpoint);
+ }
+
+ /* this is a *really* inefficent way of dealing with strings,
+ but this is rarely called and the strings are always short,
+ so I don't care */
+ for (i=0;b->options && b->options[i];i++) {
+ s = talloc_asprintf_append_buffer(s, ",%s", b->options[i]);
+ if (!s) return NULL;
+ }
+
+ for (i=0;i<ARRAY_SIZE(ncacn_options);i++) {
+ if (b->flags & ncacn_options[i].flag) {
+ s = talloc_asprintf_append_buffer(s, ",%s", ncacn_options[i].name);
+ if (!s) return NULL;
+ }
+ }
+
+ s = talloc_asprintf_append_buffer(s, "]");
+
+ return s;
+}
+
+/*
+ parse a binding string into a dcerpc_binding structure
+*/
+_PUBLIC_ NTSTATUS dcerpc_parse_binding(TALLOC_CTX *mem_ctx, const char *s, struct dcerpc_binding **b_out)
+{
+ struct dcerpc_binding *b;
+ char *options;
+ char *p;
+ int i, j, comma_count;
+
+ b = talloc(mem_ctx, struct dcerpc_binding);
+ if (!b) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ p = strchr(s, '@');
+
+ if (p && PTR_DIFF(p, s) == 36) { /* 36 is the length of a UUID */
+ NTSTATUS status;
+
+ status = GUID_from_string(s, &b->object.uuid);
+
+ if (NT_STATUS_IS_ERR(status)) {
+ DEBUG(0, ("Failed parsing UUID\n"));
+ return status;
+ }
+
+ s = p + 1;
+ } else {
+ ZERO_STRUCT(b->object);
+ }
+
+ b->object.if_version = 0;
+
+ p = strchr(s, ':');
+
+ if (p == NULL) {
+ b->transport = NCA_UNKNOWN;
+ } else {
+ char *type = talloc_strndup(mem_ctx, s, PTR_DIFF(p, s));
+ if (!type) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ for (i=0;i<ARRAY_SIZE(transports);i++) {
+ if (strcasecmp(type, transports[i].name) == 0) {
+ b->transport = transports[i].transport;
+ break;
+ }
+ }
+
+ if (i==ARRAY_SIZE(transports)) {
+ DEBUG(0,("Unknown dcerpc transport '%s'\n", type));
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ talloc_free(type);
+
+ s = p+1;
+ }
+
+ p = strchr(s, '[');
+ if (p) {
+ b->host = talloc_strndup(b, s, PTR_DIFF(p, s));
+ options = talloc_strdup(mem_ctx, p+1);
+ if (options[strlen(options)-1] != ']') {
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+ options[strlen(options)-1] = 0;
+ } else {
+ b->host = talloc_strdup(b, s);
+ options = NULL;
+ }
+ if (!b->host) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ b->target_hostname = b->host;
+
+ b->options = NULL;
+ b->flags = 0;
+ b->assoc_group_id = 0;
+ b->endpoint = NULL;
+
+ if (!options) {
+ *b_out = b;
+ return NT_STATUS_OK;
+ }
+
+ comma_count = count_chars(options, ',');
+
+ b->options = talloc_array(b, const char *, comma_count+2);
+ if (!b->options) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ for (i=0; (p = strchr(options, ',')); i++) {
+ b->options[i] = talloc_strndup(b, options, PTR_DIFF(p, options));
+ if (!b->options[i]) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ options = p+1;
+ }
+ b->options[i] = options;
+ b->options[i+1] = NULL;
+
+ /* some options are pre-parsed for convenience */
+ for (i=0;b->options[i];i++) {
+ for (j=0;j<ARRAY_SIZE(ncacn_options);j++) {
+ if (strcasecmp(ncacn_options[j].name, b->options[i]) == 0) {
+ int k;
+ b->flags |= ncacn_options[j].flag;
+ for (k=i;b->options[k];k++) {
+ b->options[k] = b->options[k+1];
+ }
+ i--;
+ break;
+ }
+ }
+ }
+
+ if (b->options[0]) {
+ /* Endpoint is first option */
+ b->endpoint = b->options[0];
+ if (strlen(b->endpoint) == 0) b->endpoint = NULL;
+
+ for (i=0;b->options[i];i++) {
+ b->options[i] = b->options[i+1];
+ }
+ }
+
+ if (b->options[0] == NULL)
+ b->options = NULL;
+
+ *b_out = b;
+ return NT_STATUS_OK;
+}
+
+_PUBLIC_ NTSTATUS dcerpc_floor_get_lhs_data(struct epm_floor *epm_floor, struct ndr_syntax_id *syntax)
+{
+ TALLOC_CTX *mem_ctx = talloc_init("floor_get_lhs_data");
+ struct ndr_pull *ndr = ndr_pull_init_blob(&epm_floor->lhs.lhs_data, mem_ctx, NULL);
+ enum ndr_err_code ndr_err;
+ uint16_t if_version=0;
+
+ ndr->flags |= LIBNDR_FLAG_NOALIGN;
+
+ ndr_err = ndr_pull_GUID(ndr, NDR_SCALARS | NDR_BUFFERS, &syntax->uuid);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ talloc_free(mem_ctx);
+ return ndr_map_error2ntstatus(ndr_err);
+ }
+
+ ndr_err = ndr_pull_uint16(ndr, NDR_SCALARS, &if_version);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ talloc_free(mem_ctx);
+ return ndr_map_error2ntstatus(ndr_err);
+ }
+
+ syntax->if_version = if_version;
+
+ talloc_free(mem_ctx);
+
+ return NT_STATUS_OK;
+}
+
+static DATA_BLOB dcerpc_floor_pack_lhs_data(TALLOC_CTX *mem_ctx, const struct ndr_syntax_id *syntax)
+{
+ struct ndr_push *ndr = ndr_push_init_ctx(mem_ctx, NULL);
+
+ ndr->flags |= LIBNDR_FLAG_NOALIGN;
+
+ ndr_push_GUID(ndr, NDR_SCALARS | NDR_BUFFERS, &syntax->uuid);
+ ndr_push_uint16(ndr, NDR_SCALARS, syntax->if_version);
+
+ return ndr_push_blob(ndr);
+}
+
+const char *dcerpc_floor_get_rhs_data(TALLOC_CTX *mem_ctx, struct epm_floor *epm_floor)
+{
+ switch (epm_floor->lhs.protocol) {
+ case EPM_PROTOCOL_TCP:
+ if (epm_floor->rhs.tcp.port == 0) return NULL;
+ return talloc_asprintf(mem_ctx, "%d", epm_floor->rhs.tcp.port);
+
+ case EPM_PROTOCOL_UDP:
+ if (epm_floor->rhs.udp.port == 0) return NULL;
+ return talloc_asprintf(mem_ctx, "%d", epm_floor->rhs.udp.port);
+
+ case EPM_PROTOCOL_HTTP:
+ if (epm_floor->rhs.http.port == 0) return NULL;
+ return talloc_asprintf(mem_ctx, "%d", epm_floor->rhs.http.port);
+
+ case EPM_PROTOCOL_IP:
+ return talloc_strdup(mem_ctx, epm_floor->rhs.ip.ipaddr);
+
+ case EPM_PROTOCOL_NCACN:
+ return NULL;
+
+ case EPM_PROTOCOL_NCADG:
+ return NULL;
+
+ case EPM_PROTOCOL_SMB:
+ if (strlen(epm_floor->rhs.smb.unc) == 0) return NULL;
+ return talloc_strdup(mem_ctx, epm_floor->rhs.smb.unc);
+
+ case EPM_PROTOCOL_PIPE:
+ if (strlen(epm_floor->rhs.pipe.path) == 0) return NULL;
+ return talloc_strdup(mem_ctx, epm_floor->rhs.pipe.path);
+
+ case EPM_PROTOCOL_NETBIOS:
+ if (strlen(epm_floor->rhs.netbios.name) == 0) return NULL;
+ return talloc_strdup(mem_ctx, epm_floor->rhs.netbios.name);
+
+ case EPM_PROTOCOL_NCALRPC:
+ return NULL;
+
+ case EPM_PROTOCOL_VINES_SPP:
+ return talloc_asprintf(mem_ctx, "%d", epm_floor->rhs.vines_spp.port);
+
+ case EPM_PROTOCOL_VINES_IPC:
+ return talloc_asprintf(mem_ctx, "%d", epm_floor->rhs.vines_ipc.port);
+
+ case EPM_PROTOCOL_STREETTALK:
+ return talloc_strdup(mem_ctx, epm_floor->rhs.streettalk.streettalk);
+
+ case EPM_PROTOCOL_UNIX_DS:
+ if (strlen(epm_floor->rhs.unix_ds.path) == 0) return NULL;
+ return talloc_strdup(mem_ctx, epm_floor->rhs.unix_ds.path);
+
+ case EPM_PROTOCOL_NULL:
+ return NULL;
+
+ default:
+ DEBUG(0,("Unsupported lhs protocol %d\n", epm_floor->lhs.protocol));
+ break;
+ }
+
+ return NULL;
+}
+
+static NTSTATUS dcerpc_floor_set_rhs_data(TALLOC_CTX *mem_ctx,
+ struct epm_floor *epm_floor,
+ const char *data)
+{
+ switch (epm_floor->lhs.protocol) {
+ case EPM_PROTOCOL_TCP:
+ epm_floor->rhs.tcp.port = atoi(data);
+ return NT_STATUS_OK;
+
+ case EPM_PROTOCOL_UDP:
+ epm_floor->rhs.udp.port = atoi(data);
+ return NT_STATUS_OK;
+
+ case EPM_PROTOCOL_HTTP:
+ epm_floor->rhs.http.port = atoi(data);
+ return NT_STATUS_OK;
+
+ case EPM_PROTOCOL_IP:
+ epm_floor->rhs.ip.ipaddr = talloc_strdup(mem_ctx, data);
+ NT_STATUS_HAVE_NO_MEMORY(epm_floor->rhs.ip.ipaddr);
+ return NT_STATUS_OK;
+
+ case EPM_PROTOCOL_NCACN:
+ epm_floor->rhs.ncacn.minor_version = 0;
+ return NT_STATUS_OK;
+
+ case EPM_PROTOCOL_NCADG:
+ epm_floor->rhs.ncadg.minor_version = 0;
+ return NT_STATUS_OK;
+
+ case EPM_PROTOCOL_SMB:
+ epm_floor->rhs.smb.unc = talloc_strdup(mem_ctx, data);
+ NT_STATUS_HAVE_NO_MEMORY(epm_floor->rhs.smb.unc);
+ return NT_STATUS_OK;
+
+ case EPM_PROTOCOL_PIPE:
+ epm_floor->rhs.pipe.path = talloc_strdup(mem_ctx, data);
+ NT_STATUS_HAVE_NO_MEMORY(epm_floor->rhs.pipe.path);
+ return NT_STATUS_OK;
+
+ case EPM_PROTOCOL_NETBIOS:
+ epm_floor->rhs.netbios.name = talloc_strdup(mem_ctx, data);
+ NT_STATUS_HAVE_NO_MEMORY(epm_floor->rhs.netbios.name);
+ return NT_STATUS_OK;
+
+ case EPM_PROTOCOL_NCALRPC:
+ return NT_STATUS_OK;
+
+ case EPM_PROTOCOL_VINES_SPP:
+ epm_floor->rhs.vines_spp.port = atoi(data);
+ return NT_STATUS_OK;
+
+ case EPM_PROTOCOL_VINES_IPC:
+ epm_floor->rhs.vines_ipc.port = atoi(data);
+ return NT_STATUS_OK;
+
+ case EPM_PROTOCOL_STREETTALK:
+ epm_floor->rhs.streettalk.streettalk = talloc_strdup(mem_ctx, data);
+ NT_STATUS_HAVE_NO_MEMORY(epm_floor->rhs.streettalk.streettalk);
+ return NT_STATUS_OK;
+
+ case EPM_PROTOCOL_UNIX_DS:
+ epm_floor->rhs.unix_ds.path = talloc_strdup(mem_ctx, data);
+ NT_STATUS_HAVE_NO_MEMORY(epm_floor->rhs.unix_ds.path);
+ return NT_STATUS_OK;
+
+ case EPM_PROTOCOL_NULL:
+ return NT_STATUS_OK;
+
+ default:
+ DEBUG(0,("Unsupported lhs protocol %d\n", epm_floor->lhs.protocol));
+ break;
+ }
+
+ return NT_STATUS_NOT_SUPPORTED;
+}
+
+enum dcerpc_transport_t dcerpc_transport_by_endpoint_protocol(int prot)
+{
+ int i;
+
+ /* Find a transport that has 'prot' as 4th protocol */
+ for (i=0;i<ARRAY_SIZE(transports);i++) {
+ if (transports[i].num_protocols >= 2 &&
+ transports[i].protseq[1] == prot) {
+ return transports[i].transport;
+ }
+ }
+
+ /* Unknown transport */
+ return (unsigned int)-1;
+}
+
+_PUBLIC_ enum dcerpc_transport_t dcerpc_transport_by_tower(struct epm_tower *tower)
+{
+ int i;
+
+ /* Find a transport that matches this tower */
+ for (i=0;i<ARRAY_SIZE(transports);i++) {
+ int j;
+ if (transports[i].num_protocols != tower->num_floors - 2) {
+ continue;
+ }
+
+ for (j = 0; j < transports[i].num_protocols; j++) {
+ if (transports[i].protseq[j] != tower->floors[j+2].lhs.protocol) {
+ break;
+ }
+ }
+
+ if (j == transports[i].num_protocols) {
+ return transports[i].transport;
+ }
+ }
+
+ /* Unknown transport */
+ return (unsigned int)-1;
+}
+
+_PUBLIC_ NTSTATUS dcerpc_binding_from_tower(TALLOC_CTX *mem_ctx,
+ struct epm_tower *tower,
+ struct dcerpc_binding **b_out)
+{
+ NTSTATUS status;
+ struct dcerpc_binding *binding;
+
+ binding = talloc(mem_ctx, struct dcerpc_binding);
+ NT_STATUS_HAVE_NO_MEMORY(binding);
+
+ ZERO_STRUCT(binding->object);
+ binding->options = NULL;
+ binding->host = NULL;
+ binding->target_hostname = NULL;
+ binding->flags = 0;
+ binding->assoc_group_id = 0;
+
+ binding->transport = dcerpc_transport_by_tower(tower);
+
+ if (binding->transport == (unsigned int)-1) {
+ return NT_STATUS_NOT_SUPPORTED;
+ }
+
+ if (tower->num_floors < 1) {
+ return NT_STATUS_OK;
+ }
+
+ /* Set object uuid */
+ status = dcerpc_floor_get_lhs_data(&tower->floors[0], &binding->object);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(1, ("Error pulling object uuid and version: %s", nt_errstr(status)));
+ return status;
+ }
+
+ /* Ignore floor 1, it contains the NDR version info */
+
+ binding->options = NULL;
+
+ /* Set endpoint */
+ if (tower->num_floors >= 4) {
+ binding->endpoint = dcerpc_floor_get_rhs_data(mem_ctx, &tower->floors[3]);
+ } else {
+ binding->endpoint = NULL;
+ }
+
+ /* Set network address */
+ if (tower->num_floors >= 5) {
+ binding->host = dcerpc_floor_get_rhs_data(mem_ctx, &tower->floors[4]);
+ NT_STATUS_HAVE_NO_MEMORY(binding->host);
+ binding->target_hostname = binding->host;
+ }
+ *b_out = binding;
+ return NT_STATUS_OK;
+}
+
+_PUBLIC_ NTSTATUS dcerpc_binding_build_tower(TALLOC_CTX *mem_ctx, struct dcerpc_binding *binding, struct epm_tower *tower)
+{
+ const enum epm_protocol *protseq = NULL;
+ int num_protocols = -1, i;
+ NTSTATUS status;
+
+ /* Find transport */
+ for (i=0;i<ARRAY_SIZE(transports);i++) {
+ if (transports[i].transport == binding->transport) {
+ protseq = transports[i].protseq;
+ num_protocols = transports[i].num_protocols;
+ break;
+ }
+ }
+
+ if (num_protocols == -1) {
+ DEBUG(0, ("Unable to find transport with id '%d'\n", binding->transport));
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
+ tower->num_floors = 2 + num_protocols;
+ tower->floors = talloc_array(mem_ctx, struct epm_floor, tower->num_floors);
+
+ /* Floor 0 */
+ tower->floors[0].lhs.protocol = EPM_PROTOCOL_UUID;
+
+ tower->floors[0].lhs.lhs_data = dcerpc_floor_pack_lhs_data(mem_ctx, &binding->object);
+
+ tower->floors[0].rhs.uuid.unknown = data_blob_talloc_zero(mem_ctx, 2);
+
+ /* Floor 1 */
+ tower->floors[1].lhs.protocol = EPM_PROTOCOL_UUID;
+
+ tower->floors[1].lhs.lhs_data = dcerpc_floor_pack_lhs_data(mem_ctx,
+ &ndr_transfer_syntax);
+
+ tower->floors[1].rhs.uuid.unknown = data_blob_talloc_zero(mem_ctx, 2);
+
+ /* Floor 2 to num_protocols */
+ for (i = 0; i < num_protocols; i++) {
+ tower->floors[2 + i].lhs.protocol = protseq[i];
+ tower->floors[2 + i].lhs.lhs_data = data_blob_talloc(mem_ctx, NULL, 0);
+ ZERO_STRUCT(tower->floors[2 + i].rhs);
+ dcerpc_floor_set_rhs_data(mem_ctx, &tower->floors[2 + i], "");
+ }
+
+ /* The 4th floor contains the endpoint */
+ if (num_protocols >= 2 && binding->endpoint) {
+ status = dcerpc_floor_set_rhs_data(mem_ctx, &tower->floors[3], binding->endpoint);
+ if (NT_STATUS_IS_ERR(status)) {
+ return status;
+ }
+ }
+
+ /* The 5th contains the network address */
+ if (num_protocols >= 3 && binding->host) {
+ if (is_ipaddress(binding->host)) {
+ status = dcerpc_floor_set_rhs_data(mem_ctx, &tower->floors[4],
+ binding->host);
+ } else {
+ /* note that we don't attempt to resolve the
+ name here - when we get a hostname here we
+ are in the client code, and want to put in
+ a wildcard all-zeros IP for the server to
+ fill in */
+ status = dcerpc_floor_set_rhs_data(mem_ctx, &tower->floors[4],
+ "0.0.0.0");
+ }
+ if (NT_STATUS_IS_ERR(status)) {
+ return status;
+ }
+ }
+
+ return NT_STATUS_OK;
+}
+
+
+struct epm_map_binding_state {
+ struct dcerpc_binding *binding;
+ const struct ndr_interface_table *table;
+ struct dcerpc_pipe *pipe;
+ struct policy_handle handle;
+ struct GUID guid;
+ struct epm_twr_t twr;
+ struct epm_twr_t *twr_r;
+ struct epm_Map r;
+};
+
+
+static void continue_epm_recv_binding(struct composite_context *ctx);
+static void continue_epm_map(struct rpc_request *req);
+
+
+/*
+ Stage 2 of epm_map_binding: Receive connected rpc pipe and send endpoint
+ mapping rpc request
+*/
+static void continue_epm_recv_binding(struct composite_context *ctx)
+{
+ struct rpc_request *map_req;
+
+ struct composite_context *c = talloc_get_type(ctx->async.private_data,
+ struct composite_context);
+ struct epm_map_binding_state *s = talloc_get_type(c->private_data,
+ struct epm_map_binding_state);
+
+ /* receive result of rpc pipe connect request */
+ c->status = dcerpc_pipe_connect_b_recv(ctx, c, &s->pipe);
+ if (!composite_is_ok(c)) return;
+
+ s->pipe->conn->flags |= DCERPC_NDR_REF_ALLOC;
+
+ /* prepare requested binding parameters */
+ s->binding->object = s->table->syntax_id;
+
+ c->status = dcerpc_binding_build_tower(s->pipe, s->binding, &s->twr.tower);
+ if (!composite_is_ok(c)) return;
+
+ /* with some nice pretty paper around it of course */
+ s->r.in.object = &s->guid;
+ s->r.in.map_tower = &s->twr;
+ s->r.in.entry_handle = &s->handle;
+ s->r.in.max_towers = 1;
+ s->r.out.entry_handle = &s->handle;
+
+ /* send request for an endpoint mapping - a rpc request on connected pipe */
+ map_req = dcerpc_epm_Map_send(s->pipe, c, &s->r);
+ if (composite_nomem(map_req, c)) return;
+
+ composite_continue_rpc(c, map_req, continue_epm_map, c);
+}
+
+
+/*
+ Stage 3 of epm_map_binding: Receive endpoint mapping and provide binding details
+*/
+static void continue_epm_map(struct rpc_request *req)
+{
+ struct composite_context *c = talloc_get_type(req->async.private_data,
+ struct composite_context);
+ struct epm_map_binding_state *s = talloc_get_type(c->private_data,
+ struct epm_map_binding_state);
+
+ /* receive result of a rpc request */
+ c->status = dcerpc_ndr_request_recv(req);
+ if (!composite_is_ok(c)) return;
+
+ /* check the details */
+ if (s->r.out.result != 0 || *s->r.out.num_towers != 1) {
+ composite_error(c, NT_STATUS_PORT_UNREACHABLE);
+ return;
+ }
+
+ s->twr_r = s->r.out.towers[0].twr;
+ if (s->twr_r == NULL) {
+ composite_error(c, NT_STATUS_PORT_UNREACHABLE);
+ return;
+ }
+
+ if (s->twr_r->tower.num_floors != s->twr.tower.num_floors ||
+ s->twr_r->tower.floors[3].lhs.protocol != s->twr.tower.floors[3].lhs.protocol) {
+ composite_error(c, NT_STATUS_PORT_UNREACHABLE);
+ return;
+ }
+
+ /* get received endpoint */
+ s->binding->endpoint = talloc_reference(s->binding,
+ dcerpc_floor_get_rhs_data(c, &s->twr_r->tower.floors[3]));
+ if (composite_nomem(s->binding->endpoint, c)) return;
+
+ composite_done(c);
+}
+
+
+/*
+ Request for endpoint mapping of dcerpc binding - try to request for endpoint
+ unless there is default one.
+*/
+struct composite_context *dcerpc_epm_map_binding_send(TALLOC_CTX *mem_ctx,
+ struct dcerpc_binding *binding,
+ const struct ndr_interface_table *table,
+ struct event_context *ev,
+ struct loadparm_context *lp_ctx)
+{
+ struct composite_context *c;
+ struct epm_map_binding_state *s;
+ struct composite_context *pipe_connect_req;
+ struct cli_credentials *anon_creds;
+ struct event_context *new_ev = NULL;
+
+ NTSTATUS status;
+ struct dcerpc_binding *epmapper_binding;
+ int i;
+
+ /* Try to find event context in memory context in case passed
+ * event_context (argument) was NULL. If there's none, just
+ * create a new one.
+ */
+ if (ev == NULL) {
+ ev = event_context_find(mem_ctx);
+ if (ev == NULL) {
+ new_ev = event_context_init(mem_ctx);
+ if (new_ev == NULL) return NULL;
+ ev = new_ev;
+ }
+ }
+
+ /* composite context allocation and setup */
+ c = composite_create(mem_ctx, ev);
+ if (c == NULL) {
+ talloc_free(new_ev);
+ return NULL;
+ }
+ talloc_steal(c, new_ev);
+
+ s = talloc_zero(c, struct epm_map_binding_state);
+ if (composite_nomem(s, c)) return c;
+ c->private_data = s;
+
+ s->binding = binding;
+ s->table = table;
+
+ /* anonymous credentials for rpc connection used to get endpoint mapping */
+ anon_creds = cli_credentials_init(mem_ctx);
+ cli_credentials_set_event_context(anon_creds, ev);
+ cli_credentials_set_anonymous(anon_creds);
+
+ /*
+ First, check if there is a default endpoint specified in the IDL
+ */
+ if (table != NULL) {
+ struct dcerpc_binding *default_binding;
+
+ /* Find one of the default pipes for this interface */
+ for (i = 0; i < table->endpoints->count; i++) {
+ status = dcerpc_parse_binding(mem_ctx, table->endpoints->names[i], &default_binding);
+
+ if (NT_STATUS_IS_OK(status)) {
+ if (binding->transport == NCA_UNKNOWN)
+ binding->transport = default_binding->transport;
+ if (default_binding->transport == binding->transport &&
+ default_binding->endpoint) {
+ binding->endpoint = talloc_reference(binding, default_binding->endpoint);
+ talloc_free(default_binding);
+
+ composite_done(c);
+ return c;
+
+ } else {
+ talloc_free(default_binding);
+ }
+ }
+ }
+ }
+
+ epmapper_binding = talloc_zero(c, struct dcerpc_binding);
+ if (composite_nomem(epmapper_binding, c)) return c;
+
+ /* basic endpoint mapping data */
+ epmapper_binding->transport = binding->transport;
+ epmapper_binding->host = talloc_reference(epmapper_binding, binding->host);
+ epmapper_binding->target_hostname = epmapper_binding->host;
+ epmapper_binding->options = NULL;
+ epmapper_binding->flags = 0;
+ epmapper_binding->assoc_group_id = 0;
+ epmapper_binding->endpoint = NULL;
+
+ /* initiate rpc pipe connection */
+ pipe_connect_req = dcerpc_pipe_connect_b_send(c, epmapper_binding,
+ &ndr_table_epmapper,
+ anon_creds, c->event_ctx,
+ lp_ctx);
+ if (composite_nomem(pipe_connect_req, c)) return c;
+
+ composite_continue(c, pipe_connect_req, continue_epm_recv_binding, c);
+ return c;
+}
+
+
+/*
+ Receive result of endpoint mapping request
+ */
+NTSTATUS dcerpc_epm_map_binding_recv(struct composite_context *c)
+{
+ NTSTATUS status = composite_wait(c);
+
+ talloc_free(c);
+ return status;
+}
+
+
+/*
+ Get endpoint mapping for rpc connection
+*/
+_PUBLIC_ NTSTATUS dcerpc_epm_map_binding(TALLOC_CTX *mem_ctx, struct dcerpc_binding *binding,
+ const struct ndr_interface_table *table, struct event_context *ev,
+ struct loadparm_context *lp_ctx)
+{
+ struct composite_context *c;
+
+ c = dcerpc_epm_map_binding_send(mem_ctx, binding, table, ev, lp_ctx);
+ return dcerpc_epm_map_binding_recv(c);
+}
+
+
+struct pipe_auth_state {
+ struct dcerpc_pipe *pipe;
+ struct dcerpc_binding *binding;
+ const struct ndr_interface_table *table;
+ struct loadparm_context *lp_ctx;
+ struct cli_credentials *credentials;
+};
+
+
+static void continue_auth_schannel(struct composite_context *ctx);
+static void continue_auth(struct composite_context *ctx);
+static void continue_auth_none(struct composite_context *ctx);
+static void continue_ntlmssp_connection(struct composite_context *ctx);
+static void continue_spnego_after_wrong_pass(struct composite_context *ctx);
+
+
+/*
+ Stage 2 of pipe_auth: Receive result of schannel bind request
+*/
+static void continue_auth_schannel(struct composite_context *ctx)
+{
+ struct composite_context *c = talloc_get_type(ctx->async.private_data,
+ struct composite_context);
+
+ c->status = dcerpc_bind_auth_schannel_recv(ctx);
+ if (!composite_is_ok(c)) return;
+
+ composite_done(c);
+}
+
+
+/*
+ Stage 2 of pipe_auth: Receive result of authenticated bind request
+*/
+static void continue_auth(struct composite_context *ctx)
+{
+ struct composite_context *c = talloc_get_type(ctx->async.private_data,
+ struct composite_context);
+
+ c->status = dcerpc_bind_auth_recv(ctx);
+ if (!composite_is_ok(c)) return;
+
+ composite_done(c);
+}
+/*
+ Stage 2 of pipe_auth: Receive result of authenticated bind request, but handle fallbacks:
+ SPNEGO -> NTLMSSP
+*/
+static void continue_auth_auto(struct composite_context *ctx)
+{
+ struct composite_context *c = talloc_get_type(ctx->async.private_data,
+ struct composite_context);
+ struct pipe_auth_state *s = talloc_get_type(c->private_data, struct pipe_auth_state);
+ struct composite_context *sec_conn_req;
+
+ c->status = dcerpc_bind_auth_recv(ctx);
+ if (NT_STATUS_EQUAL(c->status, NT_STATUS_INVALID_PARAMETER)) {
+ /*
+ * Retry with NTLMSSP auth as fallback
+ * send a request for secondary rpc connection
+ */
+ sec_conn_req = dcerpc_secondary_connection_send(s->pipe,
+ s->binding);
+ composite_continue(c, sec_conn_req, continue_ntlmssp_connection, c);
+ return;
+ } else if (NT_STATUS_EQUAL(c->status, NT_STATUS_LOGON_FAILURE)) {
+ if (cli_credentials_wrong_password(s->credentials)) {
+ /*
+ * Retry SPNEGO with a better password
+ * send a request for secondary rpc connection
+ */
+ sec_conn_req = dcerpc_secondary_connection_send(s->pipe,
+ s->binding);
+ composite_continue(c, sec_conn_req, continue_spnego_after_wrong_pass, c);
+ return;
+ }
+ }
+
+ if (!composite_is_ok(c)) return;
+
+ composite_done(c);
+}
+
+/*
+ Stage 3 of pipe_auth (fallback to NTLMSSP case): Receive secondary
+ rpc connection (the first one can't be used any more, due to the
+ bind nak) and perform authenticated bind request
+*/
+static void continue_ntlmssp_connection(struct composite_context *ctx)
+{
+ struct composite_context *c;
+ struct pipe_auth_state *s;
+ struct composite_context *auth_req;
+ struct dcerpc_pipe *p2;
+
+ c = talloc_get_type(ctx->async.private_data, struct composite_context);
+ s = talloc_get_type(c->private_data, struct pipe_auth_state);
+
+ /* receive secondary rpc connection */
+ c->status = dcerpc_secondary_connection_recv(ctx, &p2);
+ if (!composite_is_ok(c)) return;
+
+ talloc_steal(s, p2);
+ talloc_steal(p2, s->pipe);
+ s->pipe = p2;
+
+ /* initiate a authenticated bind */
+ auth_req = dcerpc_bind_auth_send(c, s->pipe, s->table,
+ s->credentials, s->lp_ctx,
+ DCERPC_AUTH_TYPE_NTLMSSP,
+ dcerpc_auth_level(s->pipe->conn),
+ s->table->authservices->names[0]);
+ composite_continue(c, auth_req, continue_auth, c);
+}
+
+/*
+ Stage 3 of pipe_auth (retry on wrong password): Receive secondary
+ rpc connection (the first one can't be used any more, due to the
+ bind nak) and perform authenticated bind request
+*/
+static void continue_spnego_after_wrong_pass(struct composite_context *ctx)
+{
+ struct composite_context *c;
+ struct pipe_auth_state *s;
+ struct composite_context *auth_req;
+ struct dcerpc_pipe *p2;
+
+ c = talloc_get_type(ctx->async.private_data, struct composite_context);
+ s = talloc_get_type(c->private_data, struct pipe_auth_state);
+
+ /* receive secondary rpc connection */
+ c->status = dcerpc_secondary_connection_recv(ctx, &p2);
+ if (!composite_is_ok(c)) return;
+
+ talloc_steal(s, p2);
+ talloc_steal(p2, s->pipe);
+ s->pipe = p2;
+
+ /* initiate a authenticated bind */
+ auth_req = dcerpc_bind_auth_send(c, s->pipe, s->table,
+ s->credentials, s->lp_ctx, DCERPC_AUTH_TYPE_SPNEGO,
+ dcerpc_auth_level(s->pipe->conn),
+ s->table->authservices->names[0]);
+ composite_continue(c, auth_req, continue_auth, c);
+}
+
+
+/*
+ Stage 2 of pipe_auth: Receive result of non-authenticated bind request
+*/
+static void continue_auth_none(struct composite_context *ctx)
+{
+ struct composite_context *c = talloc_get_type(ctx->async.private_data,
+ struct composite_context);
+
+ c->status = dcerpc_bind_auth_none_recv(ctx);
+ if (!composite_is_ok(c)) return;
+
+ composite_done(c);
+}
+
+
+/*
+ Request to perform an authenticated bind if required. Authentication
+ is determined using credentials passed and binding flags.
+*/
+struct composite_context *dcerpc_pipe_auth_send(struct dcerpc_pipe *p,
+ struct dcerpc_binding *binding,
+ const struct ndr_interface_table *table,
+ struct cli_credentials *credentials,
+ struct loadparm_context *lp_ctx)
+{
+ struct composite_context *c;
+ struct pipe_auth_state *s;
+ struct composite_context *auth_schannel_req;
+ struct composite_context *auth_req;
+ struct composite_context *auth_none_req;
+ struct dcerpc_connection *conn;
+ uint8_t auth_type;
+
+ /* composite context allocation and setup */
+ c = composite_create(p, p->conn->event_ctx);
+ if (c == NULL) return NULL;
+
+ s = talloc_zero(c, struct pipe_auth_state);
+ if (composite_nomem(s, c)) return c;
+ c->private_data = s;
+
+ /* store parameters in state structure */
+ s->binding = binding;
+ s->table = table;
+ s->credentials = credentials;
+ s->pipe = p;
+ s->lp_ctx = lp_ctx;
+
+ conn = s->pipe->conn;
+ conn->flags = binding->flags;
+
+ /* remember the binding string for possible secondary connections */
+ conn->binding_string = dcerpc_binding_string(p, binding);
+
+ if (cli_credentials_is_anonymous(s->credentials)) {
+ auth_none_req = dcerpc_bind_auth_none_send(c, s->pipe, s->table);
+ composite_continue(c, auth_none_req, continue_auth_none, c);
+ return c;
+ }
+
+ if ((binding->flags & DCERPC_SCHANNEL) &&
+ !cli_credentials_get_netlogon_creds(s->credentials)) {
+ /* If we don't already have netlogon credentials for
+ * the schannel bind, then we have to get these
+ * first */
+ auth_schannel_req = dcerpc_bind_auth_schannel_send(c, s->pipe, s->table,
+ s->credentials, s->lp_ctx,
+ dcerpc_auth_level(conn));
+ composite_continue(c, auth_schannel_req, continue_auth_schannel, c);
+ return c;
+ }
+
+ /*
+ * we rely on the already authenticated CIFS connection
+ * if not doing sign or seal
+ */
+ if (conn->transport.transport == NCACN_NP &&
+ !(s->binding->flags & (DCERPC_SIGN|DCERPC_SEAL))) {
+ auth_none_req = dcerpc_bind_auth_none_send(c, s->pipe, s->table);
+ composite_continue(c, auth_none_req, continue_auth_none, c);
+ return c;
+ }
+
+
+ /* Perform an authenticated DCE-RPC bind
+ */
+ if (!(conn->flags & (DCERPC_SIGN|DCERPC_SEAL))) {
+ /*
+ we are doing an authenticated connection,
+ but not using sign or seal. We must force
+ the CONNECT dcerpc auth type as a NONE auth
+ type doesn't allow authentication
+ information to be passed.
+ */
+ conn->flags |= DCERPC_CONNECT;
+ }
+
+ if (s->binding->flags & DCERPC_AUTH_SPNEGO) {
+ auth_type = DCERPC_AUTH_TYPE_SPNEGO;
+
+ } else if (s->binding->flags & DCERPC_AUTH_KRB5) {
+ auth_type = DCERPC_AUTH_TYPE_KRB5;
+
+ } else if (s->binding->flags & DCERPC_SCHANNEL) {
+ auth_type = DCERPC_AUTH_TYPE_SCHANNEL;
+
+ } else if (s->binding->flags & DCERPC_AUTH_NTLM) {
+ auth_type = DCERPC_AUTH_TYPE_NTLMSSP;
+
+ } else {
+ /* try SPNEGO with fallback to NTLMSSP */
+ auth_req = dcerpc_bind_auth_send(c, s->pipe, s->table,
+ s->credentials, s->lp_ctx, DCERPC_AUTH_TYPE_SPNEGO,
+ dcerpc_auth_level(conn),
+ s->table->authservices->names[0]);
+ composite_continue(c, auth_req, continue_auth_auto, c);
+ return c;
+ }
+
+ auth_req = dcerpc_bind_auth_send(c, s->pipe, s->table,
+ s->credentials, s->lp_ctx, auth_type,
+ dcerpc_auth_level(conn),
+ s->table->authservices->names[0]);
+ composite_continue(c, auth_req, continue_auth, c);
+ return c;
+}
+
+
+/*
+ Receive result of authenticated bind request on dcerpc pipe
+
+ This returns *p, which may be different to the one originally
+ supllied, as it rebinds to a new pipe due to authentication fallback
+
+*/
+NTSTATUS dcerpc_pipe_auth_recv(struct composite_context *c, TALLOC_CTX *mem_ctx,
+ struct dcerpc_pipe **p)
+{
+ NTSTATUS status;
+
+ struct pipe_auth_state *s = talloc_get_type(c->private_data,
+ struct pipe_auth_state);
+ status = composite_wait(c);
+ if (!NT_STATUS_IS_OK(status)) {
+ char *uuid_str = GUID_string(s->pipe, &s->table->syntax_id.uuid);
+ DEBUG(0, ("Failed to bind to uuid %s - %s\n", uuid_str, nt_errstr(status)));
+ talloc_free(uuid_str);
+ } else {
+ talloc_steal(mem_ctx, s->pipe);
+ *p = s->pipe;
+ }
+
+ talloc_free(c);
+ return status;
+}
+
+
+/*
+ Perform an authenticated bind if needed - sync version
+
+ This may change *p, as it rebinds to a new pipe due to authentication fallback
+*/
+_PUBLIC_ NTSTATUS dcerpc_pipe_auth(TALLOC_CTX *mem_ctx,
+ struct dcerpc_pipe **p,
+ struct dcerpc_binding *binding,
+ const struct ndr_interface_table *table,
+ struct cli_credentials *credentials,
+ struct loadparm_context *lp_ctx)
+{
+ struct composite_context *c;
+
+ c = dcerpc_pipe_auth_send(*p, binding, table, credentials, lp_ctx);
+ return dcerpc_pipe_auth_recv(c, mem_ctx, p);
+}
+
+
+NTSTATUS dcerpc_generic_session_key(struct dcerpc_connection *c,
+ DATA_BLOB *session_key)
+{
+ /* this took quite a few CPU cycles to find ... */
+ session_key->data = discard_const_p(unsigned char, "SystemLibraryDTC");
+ session_key->length = 16;
+ return NT_STATUS_OK;
+}
+
+/*
+ fetch the user session key - may be default (above) or the SMB session key
+*/
+_PUBLIC_ NTSTATUS dcerpc_fetch_session_key(struct dcerpc_pipe *p,
+ DATA_BLOB *session_key)
+{
+ return p->conn->security_state.session_key(p->conn, session_key);
+}
+
+
+/*
+ log a rpc packet in a format suitable for ndrdump. This is especially useful
+ for sealed packets, where ethereal cannot easily see the contents
+
+ this triggers on a debug level of >= 10
+*/
+_PUBLIC_ void dcerpc_log_packet(const struct ndr_interface_table *ndr,
+ uint32_t opnum, uint32_t flags,
+ DATA_BLOB *pkt)
+{
+ const int num_examples = 20;
+ int i;
+
+ if (DEBUGLEVEL < 10) return;
+
+ for (i=0;i<num_examples;i++) {
+ char *name=NULL;
+ asprintf(&name, "%s/rpclog/%s-%u.%d.%s",
+ lp_lockdir(global_loadparm), ndr->name, opnum, i,
+ (flags&NDR_IN)?"in":"out");
+ if (name == NULL) {
+ return;
+ }
+ if (!file_exist(name)) {
+ if (file_save(name, pkt->data, pkt->length)) {
+ DEBUG(10,("Logged rpc packet to %s\n", name));
+ }
+ free(name);
+ break;
+ }
+ free(name);
+ }
+}
+
+
+
+/*
+ create a secondary context from a primary connection
+
+ this uses dcerpc_alter_context() to create a new dcerpc context_id
+*/
+_PUBLIC_ NTSTATUS dcerpc_secondary_context(struct dcerpc_pipe *p,
+ struct dcerpc_pipe **pp2,
+ const struct ndr_interface_table *table)
+{
+ NTSTATUS status;
+ struct dcerpc_pipe *p2;
+
+ p2 = talloc_zero(p, struct dcerpc_pipe);
+ if (p2 == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ p2->conn = talloc_reference(p2, p->conn);
+ p2->request_timeout = p->request_timeout;
+
+ p2->context_id = ++p->conn->next_context_id;
+
+ p2->syntax = table->syntax_id;
+
+ p2->transfer_syntax = ndr_transfer_syntax;
+
+ p2->binding = talloc_reference(p2, p->binding);
+
+ status = dcerpc_alter_context(p2, p2, &p2->syntax, &p2->transfer_syntax);
+ if (!NT_STATUS_IS_OK(status)) {
+ talloc_free(p2);
+ return status;
+ }
+
+ *pp2 = p2;
+
+ return NT_STATUS_OK;
+}
diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c
index 949bca747d..7d3d246da5 100644
--- a/source3/libsmb/cliconnect.c
+++ b/source3/libsmb/cliconnect.c
@@ -1492,8 +1492,6 @@ NTSTATUS cli_connect(struct cli_state *cli,
}
fstrcpy(cli->desthost, host);
- fstr_sprintf(cli->srv_name_slash, "\\\\%s", cli->desthost);
- strupper_m(cli->srv_name_slash);
/* allow hostnames of the form NAME#xx and do a netbios lookup */
if ((p = strchr(cli->desthost, '#'))) {
diff --git a/source3/libsmb/clidfs.c b/source3/libsmb/clidfs.c
index 0b55d930aa..7b63f9535e 100644
--- a/source3/libsmb/clidfs.c
+++ b/source3/libsmb/clidfs.c
@@ -202,10 +202,15 @@ static struct cli_state *do_connect(TALLOC_CTX *ctx,
}
if (!cm_creds.got_pass && !cm_creds.use_kerberos) {
- char *pass = getpass("Password: ");
+ char *label = NULL;
+ char *pass;
+ label = talloc_asprintf(ctx, "Enter %s's password: ",
+ cm_creds.username);
+ pass = getpass(label);
if (pass) {
cm_set_password(pass);
}
+ TALLOC_FREE(label);
}
username = cm_creds.username ? cm_creds.username : "";
diff --git a/source3/libsmb/clidgram.c b/source3/libsmb/clidgram.c
index 66c6ee1022..baee95b9aa 100644
--- a/source3/libsmb/clidgram.c
+++ b/source3/libsmb/clidgram.c
@@ -119,3 +119,168 @@ bool cli_send_mailslot(struct messaging_context *msg_ctx,
MSG_SEND_PACKET,
(uint8 *)&p, sizeof(p)));
}
+
+static void mailslot_name(struct in_addr dc_ip, fstring name)
+{
+ fstr_sprintf(name, "\\MAILSLOT\\NET\\GETDC%X", dc_ip.s_addr);
+}
+
+bool send_getdc_request(struct messaging_context *msg_ctx,
+ struct sockaddr_storage *dc_ss,
+ const char *domain_name,
+ const DOM_SID *sid)
+{
+ char outbuf[1024];
+ struct in_addr dc_ip;
+ char *p;
+ fstring my_acct_name;
+ fstring my_mailslot;
+ size_t sid_size;
+
+ if (dc_ss->ss_family != AF_INET) {
+ return false;
+ }
+
+ dc_ip = ((struct sockaddr_in *)dc_ss)->sin_addr;
+ mailslot_name(dc_ip, my_mailslot);
+
+ memset(outbuf, '\0', sizeof(outbuf));
+
+ p = outbuf;
+
+ SCVAL(p, 0, SAMLOGON);
+ p++;
+
+ SCVAL(p, 0, 0); /* Count pointer ... */
+ p++;
+
+ SIVAL(p, 0, 0); /* The sender's token ... */
+ p += 2;
+
+ p += dos_PutUniCode(p, global_myname(),
+ sizeof(outbuf) - PTR_DIFF(p, outbuf), True);
+ fstr_sprintf(my_acct_name, "%s$", global_myname());
+ p += dos_PutUniCode(p, my_acct_name,
+ sizeof(outbuf) - PTR_DIFF(p, outbuf), True);
+
+ if (strlen(my_mailslot)+1 > sizeof(outbuf) - PTR_DIFF(p, outbuf)) {
+ return false;
+ }
+
+ memcpy(p, my_mailslot, strlen(my_mailslot)+1);
+ p += strlen(my_mailslot)+1;
+
+ if (sizeof(outbuf) - PTR_DIFF(p, outbuf) < 8) {
+ return false;
+ }
+
+ SIVAL(p, 0, 0x80);
+ p+=4;
+
+ sid_size = ndr_size_dom_sid(sid, 0);
+
+ SIVAL(p, 0, sid_size);
+ p+=4;
+
+ p = ALIGN4(p, outbuf);
+ if (PTR_DIFF(p, outbuf) > sizeof(outbuf)) {
+ return false;
+ }
+
+ if (sid_size + 8 > sizeof(outbuf) - PTR_DIFF(p, outbuf)) {
+ return false;
+ }
+ if (sid) {
+ sid_linearize(p, sizeof(outbuf) - PTR_DIFF(p, outbuf), sid);
+ }
+
+ p += sid_size;
+
+ SIVAL(p, 0, 1);
+ SSVAL(p, 4, 0xffff);
+ SSVAL(p, 6, 0xffff);
+ p+=8;
+
+ return cli_send_mailslot(msg_ctx,
+ False, "\\MAILSLOT\\NET\\NTLOGON", 0,
+ outbuf, PTR_DIFF(p, outbuf),
+ global_myname(), 0, domain_name, 0x1c,
+ dc_ss);
+}
+
+bool receive_getdc_response(struct sockaddr_storage *dc_ss,
+ const char *domain_name,
+ fstring dc_name)
+{
+ struct packet_struct *packet;
+ fstring my_mailslot;
+ char *buf, *p;
+ fstring dcname, user, domain;
+ int len;
+ struct in_addr dc_ip;
+
+ if (dc_ss->ss_family != AF_INET) {
+ return false;
+ }
+ dc_ip = ((struct sockaddr_in *)dc_ss)->sin_addr;
+ mailslot_name(dc_ip, my_mailslot);
+
+ packet = receive_unexpected(DGRAM_PACKET, 0, my_mailslot);
+
+ if (packet == NULL) {
+ DEBUG(5, ("Did not receive packet for %s\n", my_mailslot));
+ return False;
+ }
+
+ DEBUG(5, ("Received packet for %s\n", my_mailslot));
+
+ buf = packet->packet.dgram.data;
+ len = packet->packet.dgram.datasize;
+
+ if (len < 70) {
+ /* 70 is a completely arbitrary value to make sure
+ the SVAL below does not read uninitialized memory */
+ DEBUG(3, ("GetDC got short response\n"));
+ return False;
+ }
+
+ /* This should be (buf-4)+SVAL(buf-4, smb_vwv12)... */
+ p = buf+SVAL(buf, smb_vwv10);
+
+ switch (CVAL(p, 0)) {
+ case SAMLOGON_R:
+ case SAMLOGON_UNK_R:
+ p+=2;
+ pull_ucs2(buf, dcname, p, sizeof(dcname), PTR_DIFF(buf+len, p),
+ STR_TERMINATE|STR_NOALIGN);
+ p = skip_unibuf(p, PTR_DIFF(buf+len, p));
+ pull_ucs2(buf, user, p, sizeof(user), PTR_DIFF(buf+len, p),
+ STR_TERMINATE|STR_NOALIGN);
+ p = skip_unibuf(p, PTR_DIFF(buf+len, p));
+ pull_ucs2(buf, domain, p, sizeof(domain), PTR_DIFF(buf+len, p),
+ STR_TERMINATE|STR_NOALIGN);
+ p = skip_unibuf(p, PTR_DIFF(buf+len, p));
+
+ if (!strequal(domain, domain_name)) {
+ DEBUG(3, ("GetDC: Expected domain %s, got %s\n",
+ domain_name, domain));
+ return False;
+ }
+ break;
+
+ default:
+ DEBUG(8, ("GetDC got invalid response type %d\n", CVAL(p, 0)));
+ return False;
+ }
+ p = dcname;
+ if (*p == '\\') p += 1;
+ if (*p == '\\') p += 1;
+
+ fstrcpy(dc_name, p);
+
+ DEBUG(10, ("GetDC gave name %s for domain %s\n",
+ dc_name, domain));
+
+ return True;
+}
+
diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c
index 64191239d3..e64b6fa278 100644
--- a/source3/libsmb/clientgen.c
+++ b/source3/libsmb/clientgen.c
@@ -617,54 +617,16 @@ struct cli_state *cli_initialise(void)
}
/****************************************************************************
- External interface.
- Close an open named pipe over SMB. Free any authentication data.
- Returns false if the cli_close call failed.
- ****************************************************************************/
-
-bool cli_rpc_pipe_close(struct rpc_pipe_client *cli)
-{
- bool ret;
-
- if (!cli) {
- return false;
- }
-
- ret = cli_close(cli->cli, cli->fnum);
-
- if (!ret) {
- DEBUG(1,("cli_rpc_pipe_close: cli_close failed on pipe %s, "
- "fnum 0x%x "
- "to machine %s. Error was %s\n",
- cli->pipe_name,
- (int) cli->fnum,
- cli->cli->desthost,
- cli_errstr(cli->cli)));
- }
-
- if (cli->auth.cli_auth_data_free_func) {
- (*cli->auth.cli_auth_data_free_func)(&cli->auth);
- }
-
- DEBUG(10,("cli_rpc_pipe_close: closed pipe %s to machine %s\n",
- cli->pipe_name, cli->cli->desthost ));
-
- DLIST_REMOVE(cli->cli->pipe_list, cli);
- talloc_destroy(cli->mem_ctx);
- return ret;
-}
-
-/****************************************************************************
Close all pipes open on this session.
****************************************************************************/
void cli_nt_pipes_close(struct cli_state *cli)
{
- struct rpc_pipe_client *cp, *next;
-
- for (cp = cli->pipe_list; cp; cp = next) {
- next = cp->next;
- cli_rpc_pipe_close(cp);
+ while (cli->pipe_list != NULL) {
+ /*
+ * No TALLOC_FREE here!
+ */
+ talloc_free(cli->pipe_list);
}
}
diff --git a/source3/libsmb/clireadwrite.c b/source3/libsmb/clireadwrite.c
index e79fd90614..12ba4b737f 100644
--- a/source3/libsmb/clireadwrite.c
+++ b/source3/libsmb/clireadwrite.c
@@ -150,11 +150,6 @@ NTSTATUS cli_read_andx_recv(struct async_req *req, ssize_t *received,
return NT_STATUS_UNEXPECTED_IO_ERROR;
}
- if (size < 0) {
- DEBUG(5,("read return < 0!\n"));
- return NT_STATUS_UNEXPECTED_IO_ERROR;
- }
-
*rcvbuf = (uint8_t *)
(smb_base(cli_req->inbuf) + SVAL(cli_req->inbuf, smb_vwv6));
*received = size;
diff --git a/source3/libsmb/doserr.c b/source3/libsmb/doserr.c
index fb5f2e1bac..8761106e58 100644
--- a/source3/libsmb/doserr.c
+++ b/source3/libsmb/doserr.c
@@ -67,6 +67,7 @@ werror_code_struct dos_errs[] =
{ "WERR_NO_LOGON_SERVERS", WERR_NO_LOGON_SERVERS },
{ "WERR_NO_SUCH_LOGON_SESSION", WERR_NO_SUCH_LOGON_SESSION },
{ "WERR_USER_ALREADY_EXISTS", WERR_USER_ALREADY_EXISTS },
+ { "WERR_NO_SUCH_USER", WERR_NO_SUCH_USER },
{ "WERR_PRINTER_DRIVER_IN_USE", WERR_PRINTER_DRIVER_IN_USE },
{ "WERR_STATUS_MORE_ENTRIES ", WERR_STATUS_MORE_ENTRIES },
{ "WERR_DFS_NO_SUCH_VOL", WERR_DFS_NO_SUCH_VOL },
@@ -85,6 +86,7 @@ werror_code_struct dos_errs[] =
{ "WERR_LOGON_FAILURE", WERR_LOGON_FAILURE },
{ "WERR_PASSWORD_RESTRICTION", WERR_PASSWORD_RESTRICTION },
{ "WERR_NO_SUCH_DOMAIN", WERR_NO_SUCH_DOMAIN },
+ { "WERR_NONE_MAPPED", WERR_NONE_MAPPED },
{ "WERR_INVALID_SECURITY_DESCRIPTOR", WERR_INVALID_SECURITY_DESCRIPTOR },
{ "WERR_INVALID_DOMAIN_STATE", WERR_INVALID_DOMAIN_STATE },
{ "WERR_INVALID_DOMAIN_ROLE", WERR_INVALID_DOMAIN_ROLE },
@@ -130,6 +132,8 @@ werror_str_struct dos_err_strs[] = {
{ WERR_TIME_SKEW, "Time difference between client and server" },
{ WERR_USER_ALREADY_EXISTS, "User already exists" },
{ WERR_PASSWORD_RESTRICTION, "Password does not meet restrictions" },
+ { WERR_NONE_MAPPED, "Could not map names to SIDs" },
+ { WERR_NO_SUCH_USER, "No such User" },
};
/*****************************************************************************
diff --git a/source3/libsmb/dsgetdcname.c b/source3/libsmb/dsgetdcname.c
index 7af43648d7..00841f0684 100644
--- a/source3/libsmb/dsgetdcname.c
+++ b/source3/libsmb/dsgetdcname.c
@@ -418,6 +418,8 @@ static NTSTATUS discover_dc_dns(TALLOC_CTX *mem_ctx,
struct dns_rr_srv *dcs = NULL;
int numdcs = 0;
int numaddrs = 0;
+ struct ip_service_name *dclist = NULL;
+ int count = 0;
if ((!(flags & DS_DIRECTORY_SERVICE_REQUIRED)) &&
(!(flags & DS_KDC_REQUIRED)) &&
@@ -460,9 +462,10 @@ static NTSTATUS discover_dc_dns(TALLOC_CTX *mem_ctx,
numaddrs += MAX(dcs[i].num_ips,1);
}
- if ((*returned_dclist = TALLOC_ZERO_ARRAY(mem_ctx,
- struct ip_service_name,
- numaddrs)) == NULL) {
+ dclist = TALLOC_ZERO_ARRAY(mem_ctx,
+ struct ip_service_name,
+ numaddrs);
+ if (!dclist) {
return NT_STATUS_NO_MEMORY;
}
@@ -471,15 +474,16 @@ static NTSTATUS discover_dc_dns(TALLOC_CTX *mem_ctx,
*return_count = 0;
i = 0;
j = 0;
- while (i < numdcs && (*return_count<numaddrs)) {
- struct ip_service_name *r = &(*returned_dclist)[*return_count];
+ while ((i < numdcs) && (count < numaddrs)) {
+
+ struct ip_service_name *r = &dclist[count];
r->port = dcs[i].port;
r->hostname = dcs[i].hostname;
if (!(flags & DS_IP_REQUIRED)) {
- (*return_count)++;
+ count++;
continue;
}
@@ -511,13 +515,19 @@ static NTSTATUS discover_dc_dns(TALLOC_CTX *mem_ctx,
* anything about the DC's -- jerry */
if (!is_zero_addr(&r->ss)) {
- (*return_count)++;
+ count++;
continue;
}
}
- return (*return_count > 0) ? NT_STATUS_OK :
- NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND;
+ *returned_dclist = dclist;
+ *return_count = count;
+
+ if (count > 0) {
+ return NT_STATUS_OK;
+ }
+
+ return NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND;
}
/****************************************************************
@@ -590,7 +600,7 @@ static NTSTATUS make_domain_controller_info(TALLOC_CTX *mem_ctx,
static NTSTATUS process_dc_dns(TALLOC_CTX *mem_ctx,
const char *domain_name,
uint32_t flags,
- struct ip_service_name **dclist,
+ struct ip_service_name *dclist,
int num_dcs,
struct netr_DsRGetDCNameInfo **info)
{
@@ -607,7 +617,9 @@ static NTSTATUS process_dc_dns(TALLOC_CTX *mem_ctx,
ZERO_STRUCT(r);
- if ((ads_cldap_netlogon(dclist[i]->hostname,
+ DEBUG(10,("LDAP ping to %s\n", dclist[i].hostname));
+
+ if ((ads_cldap_netlogon(dclist[i].hostname,
domain_name, &r)) &&
(check_cldap_reply_required_flags(r.flags, flags))) {
valid_dc = true;
@@ -645,7 +657,7 @@ static NTSTATUS process_dc_dns(TALLOC_CTX *mem_ctx,
if (flags & DS_IP_REQUIRED) {
char addr[INET6_ADDRSTRLEN];
- print_sockaddr(addr, sizeof(addr), &dclist[i]->ss);
+ print_sockaddr(addr, sizeof(addr), &dclist[i].ss);
dc_address = talloc_asprintf(mem_ctx, "\\\\%s",
addr);
dc_address_type = DS_ADDRESS_TYPE_INET;
@@ -723,7 +735,7 @@ static NTSTATUS dsgetdcname_rediscover(TALLOC_CTX *mem_ctx,
NT_STATUS_NOT_OK_RETURN(status);
return process_dc_dns(mem_ctx, domain_name, flags,
- &dclist, num_dcs, info);
+ dclist, num_dcs, info);
}
status = discover_dc_dns(mem_ctx, domain_name, domain_guid, flags,
@@ -731,7 +743,7 @@ static NTSTATUS dsgetdcname_rediscover(TALLOC_CTX *mem_ctx,
if (NT_STATUS_IS_OK(status) && num_dcs != 0) {
- status = process_dc_dns(mem_ctx, domain_name, flags, &dclist,
+ status = process_dc_dns(mem_ctx, domain_name, flags, dclist,
num_dcs, info);
if (NT_STATUS_IS_OK(status)) {
return status;
diff --git a/source3/libsmb/libsmb_dir.c b/source3/libsmb/libsmb_dir.c
index f836989004..aea4f103b6 100644
--- a/source3/libsmb/libsmb_dir.c
+++ b/source3/libsmb/libsmb_dir.c
@@ -287,7 +287,7 @@ net_share_enum_rpc(struct cli_state *cli,
/* Issue the NetShareEnum RPC call and retrieve the response */
nt_status = rpccli_srvsvc_NetShareEnumAll(pipe_hnd, talloc_tos(),
- pipe_hnd->cli->desthost,
+ pipe_hnd->desthost,
&info_ctr,
preferred_len,
&total_entries,
@@ -319,7 +319,7 @@ net_share_enum_rpc(struct cli_state *cli,
done:
/* Close the server service pipe */
- cli_rpc_pipe_close(pipe_hnd);
+ TALLOC_FREE(pipe_hnd);
/* Tell 'em if it worked */
return W_ERROR_IS_OK(result) ? 0 : -1;
diff --git a/source3/libsmb/libsmb_xattr.c b/source3/libsmb/libsmb_xattr.c
index e17146e611..8763205d1f 100644
--- a/source3/libsmb/libsmb_xattr.c
+++ b/source3/libsmb/libsmb_xattr.c
@@ -39,7 +39,7 @@ find_lsa_pipe_hnd(struct cli_state *ipc_cli)
pipe_hnd;
pipe_hnd = pipe_hnd->next) {
- if (pipe_hnd->pipe_idx == PI_LSARPC) {
+ if (rpccli_is_pipe_idx(pipe_hnd, PI_LSARPC)) {
return pipe_hnd;
}
}
diff --git a/source3/libsmb/passchange.c b/source3/libsmb/passchange.c
index 468750f801..8f7cbf265e 100644
--- a/source3/libsmb/passchange.c
+++ b/source3/libsmb/passchange.c
@@ -177,8 +177,9 @@ NTSTATUS remote_password_change(const char *remote_machine, const char *user_nam
}
}
- if (NT_STATUS_IS_OK(result = rpccli_samr_chgpasswd_user(pipe_hnd, pipe_hnd->mem_ctx, user_name,
- new_passwd, old_passwd))) {
+ result = rpccli_samr_chgpasswd_user(pipe_hnd, talloc_tos(),
+ user_name, new_passwd, old_passwd);
+ if (NT_STATUS_IS_OK(result)) {
/* Great - it all worked! */
cli_shutdown(cli);
return NT_STATUS_OK;
@@ -195,7 +196,7 @@ NTSTATUS remote_password_change(const char *remote_machine, const char *user_nam
}
/* OK, that failed, so try again... */
- cli_rpc_pipe_close(pipe_hnd);
+ TALLOC_FREE(pipe_hnd);
/* Try anonymous NTLMSSP... */
cli_init_creds(cli, "", "", NULL);
@@ -206,11 +207,9 @@ NTSTATUS remote_password_change(const char *remote_machine, const char *user_nam
pipe_hnd = cli_rpc_pipe_open_noauth(cli, PI_SAMR, &result);
if ( pipe_hnd &&
- (NT_STATUS_IS_OK(result = rpccli_samr_chgpasswd_user(pipe_hnd,
- pipe_hnd->mem_ctx,
- user_name,
- new_passwd,
- old_passwd)))) {
+ (NT_STATUS_IS_OK(result = rpccli_samr_chgpasswd_user(
+ pipe_hnd, talloc_tos(), user_name,
+ new_passwd, old_passwd)))) {
/* Great - it all worked! */
cli_shutdown(cli);
return NT_STATUS_OK;
diff --git a/source3/libsmb/trusts_util.c b/source3/libsmb/trusts_util.c
index c3f5f2538a..20ac0143fd 100644
--- a/source3/libsmb/trusts_util.c
+++ b/source3/libsmb/trusts_util.c
@@ -43,7 +43,7 @@ static NTSTATUS just_change_the_password(struct rpc_pipe_client *cli, TALLOC_CTX
uint32_t neg_flags = NETLOGON_NEG_AUTH2_ADS_FLAGS;
result = rpccli_netlogon_setup_creds(cli,
- cli->cli->desthost, /* server name */
+ cli->desthost, /* server name */
lp_workgroup(), /* domain */
global_myname(), /* client name */
global_myname(), /* machine account name */
diff --git a/source3/locking/posix.c b/source3/locking/posix.c
index 1b88c472b0..32e1ee9fbf 100644
--- a/source3/locking/posix.c
+++ b/source3/locking/posix.c
@@ -607,37 +607,34 @@ static size_t get_posix_pending_close_entries(TALLOC_CTX *mem_ctx,
to delete all locks on this fsp before this function is called.
****************************************************************************/
-NTSTATUS fd_close_posix(struct files_struct *fsp)
+int fd_close_posix(struct files_struct *fsp)
{
int saved_errno = 0;
int ret;
int *fd_array = NULL;
size_t count, i;
- if (!lp_locking(fsp->conn->params) || !lp_posix_locking(fsp->conn->params)) {
+ if (!lp_locking(fsp->conn->params) ||
+ !lp_posix_locking(fsp->conn->params))
+ {
/*
* No locking or POSIX to worry about or we want POSIX semantics
* which will lose all locks on all fd's open on this dev/inode,
* just close.
*/
- ret = SMB_VFS_CLOSE(fsp,fsp->fh->fd);
- fsp->fh->fd = -1;
- if (ret == -1) {
- return map_nt_error_from_unix(errno);
- }
- return NT_STATUS_OK;
+ return close(fsp->fh->fd);
}
if (get_windows_lock_ref_count(fsp)) {
/*
- * There are outstanding locks on this dev/inode pair on other fds.
- * Add our fd to the pending close tdb and set fsp->fh->fd to -1.
+ * There are outstanding locks on this dev/inode pair on
+ * other fds. Add our fd to the pending close tdb and set
+ * fsp->fh->fd to -1.
*/
add_fd_to_close_entry(fsp);
- fsp->fh->fd = -1;
- return NT_STATUS_OK;
+ return 0;
}
/*
@@ -648,10 +645,11 @@ NTSTATUS fd_close_posix(struct files_struct *fsp)
count = get_posix_pending_close_entries(talloc_tos(), fsp, &fd_array);
if (count) {
- DEBUG(10,("fd_close_posix: doing close on %u fd's.\n", (unsigned int)count ));
+ DEBUG(10,("fd_close_posix: doing close on %u fd's.\n",
+ (unsigned int)count));
for(i = 0; i < count; i++) {
- if (SMB_VFS_CLOSE(fsp,fd_array[i]) == -1) {
+ if (close(fd_array[i]) == -1) {
saved_errno = errno;
}
}
@@ -673,20 +671,14 @@ NTSTATUS fd_close_posix(struct files_struct *fsp)
* Finally close the fd associated with this fsp.
*/
- ret = SMB_VFS_CLOSE(fsp,fsp->fh->fd);
+ ret = close(fsp->fh->fd);
if (ret == 0 && saved_errno != 0) {
errno = saved_errno;
ret = -1;
- }
-
- fsp->fh->fd = -1;
-
- if (ret == -1) {
- return map_nt_error_from_unix(errno);
}
- return NT_STATUS_OK;
+ return ret;
}
/****************************************************************************
diff --git a/source3/modules/vfs_audit.c b/source3/modules/vfs_audit.c
index cfb4ddf590..4000580c42 100644
--- a/source3/modules/vfs_audit.c
+++ b/source3/modules/vfs_audit.c
@@ -34,7 +34,7 @@ static SMB_STRUCT_DIR *audit_opendir(vfs_handle_struct *handle, const char *fnam
static int audit_mkdir(vfs_handle_struct *handle, const char *path, mode_t mode);
static int audit_rmdir(vfs_handle_struct *handle, const char *path);
static int audit_open(vfs_handle_struct *handle, const char *fname, files_struct *fsp, int flags, mode_t mode);
-static int audit_close(vfs_handle_struct *handle, files_struct *fsp, int fd);
+static int audit_close(vfs_handle_struct *handle, files_struct *fsp);
static int audit_rename(vfs_handle_struct *handle, const char *oldname, const char *newname);
static int audit_unlink(vfs_handle_struct *handle, const char *path);
static int audit_chmod(vfs_handle_struct *handle, const char *path, mode_t mode);
@@ -202,14 +202,14 @@ static int audit_open(vfs_handle_struct *handle, const char *fname, files_struct
return result;
}
-static int audit_close(vfs_handle_struct *handle, files_struct *fsp, int fd)
+static int audit_close(vfs_handle_struct *handle, files_struct *fsp)
{
int result;
- result = SMB_VFS_NEXT_CLOSE(handle, fsp, fd);
+ result = SMB_VFS_NEXT_CLOSE(handle, fsp);
syslog(audit_syslog_priority(handle), "close fd %d %s%s\n",
- fd,
+ fsp->fh->fd,
(result < 0) ? "failed: " : "",
(result < 0) ? strerror(errno) : "");
diff --git a/source3/modules/vfs_cacheprime.c b/source3/modules/vfs_cacheprime.c
index be934f6bd6..fed051ca8d 100644
--- a/source3/modules/vfs_cacheprime.c
+++ b/source3/modules/vfs_cacheprime.c
@@ -54,7 +54,7 @@ static bool prime_cache(
SMB_OFF_T * last;
ssize_t nread;
- last = VFS_ADD_FSP_EXTENSION(handle, fsp, SMB_OFF_T);
+ last = (SMB_OFF_T *)VFS_ADD_FSP_EXTENSION(handle, fsp, SMB_OFF_T);
if (!last) {
return False;
}
diff --git a/source3/modules/vfs_commit.c b/source3/modules/vfs_commit.c
index ac391cf007..1cef6d0243 100644
--- a/source3/modules/vfs_commit.c
+++ b/source3/modules/vfs_commit.c
@@ -265,12 +265,11 @@ static ssize_t commit_pwrite(
static int commit_close(
vfs_handle_struct * handle,
- files_struct * fsp,
- int fd)
+ files_struct * fsp)
{
/* Commit errors not checked, close() will find them again */
commit_all(handle, fsp);
- return SMB_VFS_NEXT_CLOSE(handle, fsp, fd);
+ return SMB_VFS_NEXT_CLOSE(handle, fsp);
}
static int commit_ftruncate(
diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c
index 31ebb6352a..de801a2041 100644
--- a/source3/modules/vfs_default.c
+++ b/source3/modules/vfs_default.c
@@ -208,13 +208,12 @@ static int vfswrap_open(vfs_handle_struct *handle, const char *fname,
return result;
}
-static int vfswrap_close(vfs_handle_struct *handle, files_struct *fsp, int fd)
+static int vfswrap_close(vfs_handle_struct *handle, files_struct *fsp)
{
int result;
START_PROFILE(syscall_close);
-
- result = close(fd);
+ result = fd_close_posix(fsp);
END_PROFILE(syscall_close);
return result;
}
diff --git a/source3/modules/vfs_extd_audit.c b/source3/modules/vfs_extd_audit.c
index 926ec36259..7516cba1d3 100644
--- a/source3/modules/vfs_extd_audit.c
+++ b/source3/modules/vfs_extd_audit.c
@@ -37,7 +37,7 @@ static SMB_STRUCT_DIR *audit_opendir(vfs_handle_struct *handle, const char *fnam
static int audit_mkdir(vfs_handle_struct *handle, const char *path, mode_t mode);
static int audit_rmdir(vfs_handle_struct *handle, const char *path);
static int audit_open(vfs_handle_struct *handle, const char *fname, files_struct *fsp, int flags, mode_t mode);
-static int audit_close(vfs_handle_struct *handle, files_struct *fsp, int fd);
+static int audit_close(vfs_handle_struct *handle, files_struct *fsp);
static int audit_rename(vfs_handle_struct *handle, const char *oldname, const char *newname);
static int audit_unlink(vfs_handle_struct *handle, const char *path);
static int audit_chmod(vfs_handle_struct *handle, const char *path, mode_t mode);
@@ -224,18 +224,18 @@ static int audit_open(vfs_handle_struct *handle, const char *fname, files_struct
return result;
}
-static int audit_close(vfs_handle_struct *handle, files_struct *fsp, int fd)
+static int audit_close(vfs_handle_struct *handle, files_struct *fsp)
{
int result;
- result = SMB_VFS_NEXT_CLOSE(handle, fsp, fd);
+ result = SMB_VFS_NEXT_CLOSE(handle, fsp);
syslog(audit_syslog_priority(handle), "close fd %d %s%s\n",
- fd,
+ fsp->fh->fd,
(result < 0) ? "failed: " : "",
(result < 0) ? strerror(errno) : "");
DEBUG(2, ("vfs_extd_audit: close fd %d %s %s\n",
- fd,
+ fsp->fh->fd,
(result < 0) ? "failed: " : "",
(result < 0) ? strerror(errno) : ""));
diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c
index 19218cc47d..2f8098de9b 100644
--- a/source3/modules/vfs_full_audit.c
+++ b/source3/modules/vfs_full_audit.c
@@ -111,7 +111,7 @@ static int smb_full_audit_closedir(vfs_handle_struct *handle,
SMB_STRUCT_DIR *dirp);
static int smb_full_audit_open(vfs_handle_struct *handle,
const char *fname, files_struct *fsp, int flags, mode_t mode);
-static int smb_full_audit_close(vfs_handle_struct *handle, files_struct *fsp, int fd);
+static int smb_full_audit_close(vfs_handle_struct *handle, files_struct *fsp);
static ssize_t smb_full_audit_read(vfs_handle_struct *handle, files_struct *fsp,
void *data, size_t n);
static ssize_t smb_full_audit_pread(vfs_handle_struct *handle, files_struct *fsp,
@@ -1083,11 +1083,11 @@ static int smb_full_audit_open(vfs_handle_struct *handle,
return result;
}
-static int smb_full_audit_close(vfs_handle_struct *handle, files_struct *fsp, int fd)
+static int smb_full_audit_close(vfs_handle_struct *handle, files_struct *fsp)
{
int result;
- result = SMB_VFS_NEXT_CLOSE(handle, fsp, fd);
+ result = SMB_VFS_NEXT_CLOSE(handle, fsp);
do_log(SMB_VFS_OP_CLOSE, (result >= 0), handle, "%s", fsp->fsp_name);
diff --git a/source3/modules/vfs_streams_xattr.c b/source3/modules/vfs_streams_xattr.c
index 766e7d10ab..b74c4f7902 100644
--- a/source3/modules/vfs_streams_xattr.c
+++ b/source3/modules/vfs_streams_xattr.c
@@ -345,7 +345,7 @@ static int streams_xattr_open(vfs_handle_struct *handle, const char *fname,
* BUGBUGBUG -- we would need to call fd_close_posix here, but
* we don't have a full fsp yet
*/
- SMB_VFS_CLOSE(fsp, hostfd);
+ SMB_VFS_CLOSE(fsp);
}
TALLOC_FREE(frame);
diff --git a/source3/modules/vfs_syncops.c b/source3/modules/vfs_syncops.c
index 3aa89b40a6..d3f7868400 100644
--- a/source3/modules/vfs_syncops.c
+++ b/source3/modules/vfs_syncops.c
@@ -165,14 +165,14 @@ static int syncops_rmdir(vfs_handle_struct *handle, const char *fname)
}
/* close needs to be handled specially */
-static int syncops_close(vfs_handle_struct *handle, files_struct *fsp, int fd)
+static int syncops_close(vfs_handle_struct *handle, files_struct *fsp)
{
if (fsp->can_write && sync_onclose) {
/* ideally we'd only do this if we have written some
data, but there is no flag for that in fsp yet. */
- fsync(fd);
+ fsync(fsp->fh->fd);
}
- return SMB_VFS_NEXT_CLOSE(handle, fsp, fd);
+ return SMB_VFS_NEXT_CLOSE(handle, fsp);
}
diff --git a/source3/nmbd/asyncdns.c b/source3/nmbd/asyncdns.c
index 5e5565991e..0329491c4a 100644
--- a/source3/nmbd/asyncdns.c
+++ b/source3/nmbd/asyncdns.c
@@ -164,6 +164,11 @@ void start_async_dns(void)
CatchSignal(SIGHUP, SIG_IGN);
CatchSignal(SIGTERM, SIGNAL_CAST sig_term );
+ if (!reinit_after_fork(nmbd_messaging_context())) {
+ DEBUG(0,("reinit_after_fork() failed\n"));
+ smb_panic("reinit_after_fork() failed");
+ }
+
asyncdns_process();
}
diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c
index 01fdbbc5a4..9396219ea7 100644
--- a/source3/nmbd/nmbd.c
+++ b/source3/nmbd/nmbd.c
@@ -762,6 +762,8 @@ static bool open_sockets(bool isdaemon, int port)
};
TALLOC_CTX *frame = talloc_stackframe(); /* Setup tos. */
+ db_tdb2_setup_messaging(NULL, false);
+
load_case_tables();
global_nmb_port = NMB_PORT;
@@ -847,7 +849,16 @@ static bool open_sockets(bool isdaemon, int port)
DEBUG(0,("nmbd version %s started.\n", SAMBA_VERSION_STRING));
DEBUGADD(0,("%s\n", COPYRIGHT_STARTUP_MESSAGE));
- db_tdb2_setup_messaging(NULL, false);
+ if (!lp_load_initial_only(get_dyn_CONFIGFILE())) {
+ DEBUG(0, ("error opening config file\n"));
+ exit(1);
+ }
+
+ if (nmbd_messaging_context() == NULL) {
+ return 1;
+ }
+
+ db_tdb2_setup_messaging(nmbd_messaging_context(), true);
if ( !reload_nmbd_services(False) )
return(-1);
@@ -901,6 +912,11 @@ static bool open_sockets(bool isdaemon, int port)
pidfile_create("nmbd");
+ if (!reinit_after_fork(nmbd_messaging_context())) {
+ DEBUG(0,("reinit_after_fork() failed\n"));
+ exit(1);
+ }
+
/* get broadcast messages */
claim_connection(NULL,"",FLAG_MSG_GENERAL|FLAG_MSG_DBWRAP);
@@ -918,8 +934,6 @@ static bool open_sockets(bool isdaemon, int port)
messaging_register(nmbd_messaging_context(), NULL,
MSG_SEND_PACKET, msg_nmbd_send_packet);
- db_tdb2_setup_messaging(nmbd_messaging_context(), true);
-
TimeInit();
DEBUG( 3, ( "Opening sockets %d\n", global_nmb_port ) );
diff --git a/source3/nsswitch/libwbclient/wbc_pam.c b/source3/nsswitch/libwbclient/wbc_pam.c
index 2b33f55990..a0e91faaf3 100644
--- a/source3/nsswitch/libwbclient/wbc_pam.c
+++ b/source3/nsswitch/libwbclient/wbc_pam.c
@@ -138,7 +138,7 @@ static wbcErr wbc_create_auth_info(TALLOC_CTX *mem_ctx,
p = (char *)resp->extra_data.data;
if (!p) {
- wbc_status = WBC_INVALID_RESPONSE;
+ wbc_status = WBC_ERR_INVALID_RESPONSE;
BAIL_ON_WBC_ERROR(wbc_status);
}
@@ -149,7 +149,7 @@ static wbcErr wbc_create_auth_info(TALLOC_CTX *mem_ctx,
char *s = p;
char *e = strchr(p, '\n');
if (!e) {
- wbc_status = WBC_INVALID_RESPONSE;
+ wbc_status = WBC_ERR_INVALID_RESPONSE;
BAIL_ON_WBC_ERROR(wbc_status);
}
e[0] = '\0';
@@ -157,7 +157,7 @@ static wbcErr wbc_create_auth_info(TALLOC_CTX *mem_ctx,
ret = sscanf(s, "0x%08X:0x%08X", &rid, &attrs);
if (ret != 2) {
- wbc_status = WBC_INVALID_RESPONSE;
+ wbc_status = WBC_ERR_INVALID_RESPONSE;
BAIL_ON_WBC_ERROR(wbc_status);
}
@@ -173,7 +173,7 @@ static wbcErr wbc_create_auth_info(TALLOC_CTX *mem_ctx,
char *a;
char *e = strchr(p, '\n');
if (!e) {
- wbc_status = WBC_INVALID_RESPONSE;
+ wbc_status = WBC_ERR_INVALID_RESPONSE;
BAIL_ON_WBC_ERROR(wbc_status);
}
e[0] = '\0';
@@ -181,7 +181,7 @@ static wbcErr wbc_create_auth_info(TALLOC_CTX *mem_ctx,
e = strchr(s, ':');
if (!e) {
- wbc_status = WBC_INVALID_RESPONSE;
+ wbc_status = WBC_ERR_INVALID_RESPONSE;
BAIL_ON_WBC_ERROR(wbc_status);
}
e[0] = '\0';
@@ -190,7 +190,7 @@ static wbcErr wbc_create_auth_info(TALLOC_CTX *mem_ctx,
ret = sscanf(a, "0x%08X",
&attrs);
if (ret != 1) {
- wbc_status = WBC_INVALID_RESPONSE;
+ wbc_status = WBC_ERR_INVALID_RESPONSE;
BAIL_ON_WBC_ERROR(wbc_status);
}
@@ -419,3 +419,54 @@ done:
return wbc_status;
}
+
+/** @brief Trigger a verification of the trust credentials of a specific domain
+ *
+ * @param *domain The name of the domain, only NULL for the default domain is
+ * supported yet. Other values than NULL will result in
+ * WBC_ERR_NOT_IMPLEMENTED.
+ * @param error Output details on WBC_ERR_AUTH_ERROR
+ *
+ * @return #wbcErr
+ *
+ **/
+wbcErr wbcCheckTrustCredentials(const char *domain,
+ struct wbcAuthErrorInfo **error)
+{
+ struct winbindd_request request;
+ struct winbindd_response response;
+ wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
+
+ if (domain) {
+ /*
+ * the current protocol doesn't support
+ * specifying a domain
+ */
+ wbc_status = WBC_ERR_NOT_IMPLEMENTED;
+ BAIL_ON_WBC_ERROR(wbc_status);
+ }
+
+ ZERO_STRUCT(request);
+ ZERO_STRUCT(response);
+
+ /* Send request */
+
+ wbc_status = wbcRequestResponse(WINBINDD_CHECK_MACHACC,
+ &request,
+ &response);
+ if (response.data.auth.nt_status != 0) {
+ if (error) {
+ wbc_status = wbc_create_error_info(NULL,
+ &response,
+ error);
+ BAIL_ON_WBC_ERROR(wbc_status);
+ }
+
+ wbc_status = WBC_ERR_AUTH_ERROR;
+ BAIL_ON_WBC_ERROR(wbc_status);
+ }
+ BAIL_ON_WBC_ERROR(wbc_status);
+
+ done:
+ return wbc_status;
+}
diff --git a/source3/nsswitch/libwbclient/wbc_sid.c b/source3/nsswitch/libwbclient/wbc_sid.c
index 6ef9f44c3b..de9b02822f 100644
--- a/source3/nsswitch/libwbclient/wbc_sid.c
+++ b/source3/nsswitch/libwbclient/wbc_sid.c
@@ -372,21 +372,21 @@ wbcErr wbcLookupRids(struct wbcDomainSid *dom_sid,
char *q;
if (*p == '\0') {
- wbc_status = WBC_INVALID_RESPONSE;
+ wbc_status = WBC_ERR_INVALID_RESPONSE;
BAIL_ON_WBC_ERROR(wbc_status);
}
(*types)[i] = (enum wbcSidType)strtoul(p, &q, 10);
if (*q != ' ') {
- wbc_status = WBC_INVALID_RESPONSE;
+ wbc_status = WBC_ERR_INVALID_RESPONSE;
BAIL_ON_WBC_ERROR(wbc_status);
}
p = q+1;
if ((q = strchr(p, '\n')) == NULL) {
- wbc_status = WBC_INVALID_RESPONSE;
+ wbc_status = WBC_ERR_INVALID_RESPONSE;
BAIL_ON_WBC_ERROR(wbc_status);
}
@@ -399,7 +399,7 @@ wbcErr wbcLookupRids(struct wbcDomainSid *dom_sid,
}
if (*p != '\0') {
- wbc_status = WBC_INVALID_RESPONSE;
+ wbc_status = WBC_ERR_INVALID_RESPONSE;
BAIL_ON_WBC_ERROR(wbc_status);
}
@@ -471,7 +471,7 @@ wbcErr wbcLookupUserSids(const struct wbcDomainSid *user_sid,
if (response.data.num_entries &&
!response.extra_data.data) {
- wbc_status = WBC_INVALID_RESPONSE;
+ wbc_status = WBC_ERR_INVALID_RESPONSE;
BAIL_ON_WBC_ERROR(wbc_status);
}
diff --git a/source3/nsswitch/libwbclient/wbc_util.c b/source3/nsswitch/libwbclient/wbc_util.c
index 7bdae91544..a1b6626bd3 100644
--- a/source3/nsswitch/libwbclient/wbc_util.c
+++ b/source3/nsswitch/libwbclient/wbc_util.c
@@ -3,7 +3,7 @@
Winbind client API
- Copyright (C) Gerald (Jerry) Carter 2007
+ Copyright (C) Gerald (Jerry) Carter 2007-2008
This library is free software; you can redistribute it and/or
@@ -170,11 +170,11 @@ wbcErr wbcDomainInfo(const char *domain, struct wbcDomainInfo **dinfo)
BAIL_ON_WBC_ERROR(wbc_status);
if (response.data.domain_info.native_mode)
- info->flags |= WBC_DOMINFO_NATIVE;
+ info->domain_flags |= WBC_DOMINFO_NATIVE;
if (response.data.domain_info.active_directory)
- info->flags |= WBC_DOMINFO_AD;
+ info->domain_flags |= WBC_DOMINFO_AD;
if (response.data.domain_info.primary)
- info->flags |= WBC_DOMINFO_PRIMARY;
+ info->domain_flags |= WBC_DOMINFO_PRIMARY;
*dinfo = info;
@@ -187,3 +187,295 @@ wbcErr wbcDomainInfo(const char *domain, struct wbcDomainInfo **dinfo)
return wbc_status;
}
+
+
+/** @brief Resolve a NetbiosName via WINS
+ *
+ * @param name Name to resolve
+ * @param *ip Pointer to the ip address string
+ *
+ * @return #wbcErr
+ *
+ **/
+wbcErr wbcResolveWinsByName(const char *name, char **ip)
+{
+ struct winbindd_request request;
+ struct winbindd_response response;
+ wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
+ char *ipaddr;
+
+ ZERO_STRUCT(request);
+ ZERO_STRUCT(response);
+
+ /* Send request */
+
+ strncpy(request.data.winsreq, name,
+ sizeof(request.data.winsreq)-1);
+
+ wbc_status = wbcRequestResponse(WINBINDD_WINS_BYNAME,
+ &request,
+ &response);
+ BAIL_ON_WBC_ERROR(wbc_status);
+
+ /* Display response */
+
+ ipaddr = talloc_strdup(NULL, response.data.winsresp);
+ BAIL_ON_PTR_ERROR(ipaddr, wbc_status);
+
+ *ip = ipaddr;
+ wbc_status = WBC_ERR_SUCCESS;
+
+ done:
+ return wbc_status;
+}
+
+/** @brief Resolve an IP address via WINS into a NetbiosName
+ *
+ * @param ip The ip address string
+ * @param *name Pointer to the name
+ *
+ * @return #wbcErr
+ *
+ **/
+wbcErr wbcResolveWinsByIP(const char *ip, char **name)
+{
+ struct winbindd_request request;
+ struct winbindd_response response;
+ wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
+ char *name_str;
+
+ ZERO_STRUCT(request);
+ ZERO_STRUCT(response);
+
+ /* Send request */
+
+ strncpy(request.data.winsreq, ip,
+ sizeof(request.data.winsreq)-1);
+
+ wbc_status = wbcRequestResponse(WINBINDD_WINS_BYIP,
+ &request,
+ &response);
+ BAIL_ON_WBC_ERROR(wbc_status);
+
+ /* Display response */
+
+ name_str = talloc_strdup(NULL, response.data.winsresp);
+ BAIL_ON_PTR_ERROR(name_str, wbc_status);
+
+ *name = name_str;
+ wbc_status = WBC_ERR_SUCCESS;
+
+ done:
+ return wbc_status;
+}
+
+/**
+ */
+
+static wbcErr process_domain_info_string(TALLOC_CTX *ctx,
+ struct wbcDomainInfo *info,
+ char *info_string)
+{
+ wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
+ char *r = NULL;
+ char *s = NULL;
+
+ if (!info || !info_string) {
+ wbc_status = WBC_ERR_INVALID_PARAM;
+ BAIL_ON_WBC_ERROR(wbc_status);
+ }
+
+ r = info_string;
+
+ /* Short Name */
+ if ((s = strchr(r, '\\')) == NULL) {
+ wbc_status = WBC_ERR_INVALID_RESPONSE;
+ BAIL_ON_WBC_ERROR(wbc_status);
+ }
+ *s = '\0';
+ s++;
+
+ info->short_name = talloc_strdup(ctx, r);
+ BAIL_ON_PTR_ERROR(info->short_name, wbc_status);
+
+
+ /* DNS Name */
+ r = s;
+ if ((s = strchr(r, '\\')) == NULL) {
+ wbc_status = WBC_ERR_INVALID_RESPONSE;
+ BAIL_ON_WBC_ERROR(wbc_status);
+ }
+ *s = '\0';
+ s++;
+
+ info->dns_name = talloc_strdup(ctx, r);
+ BAIL_ON_PTR_ERROR(info->dns_name, wbc_status);
+
+ /* SID */
+ r = s;
+ if ((s = strchr(r, '\\')) == NULL) {
+ wbc_status = WBC_ERR_INVALID_RESPONSE;
+ BAIL_ON_WBC_ERROR(wbc_status);
+ }
+ *s = '\0';
+ s++;
+
+ wbc_status = wbcStringToSid(r, &info->sid);
+ BAIL_ON_WBC_ERROR(wbc_status);
+
+ /* Trust type */
+ r = s;
+ if ((s = strchr(r, '\\')) == NULL) {
+ wbc_status = WBC_ERR_INVALID_RESPONSE;
+ BAIL_ON_WBC_ERROR(wbc_status);
+ }
+ *s = '\0';
+ s++;
+
+ if (strcmp(r, "None") == 0) {
+ info->trust_type = WBC_DOMINFO_TRUSTTYPE_NONE;
+ } else if (strcmp(r, "External") == 0) {
+ info->trust_type = WBC_DOMINFO_TRUSTTYPE_EXTERNAL;
+ } else if (strcmp(r, "Forest") == 0) {
+ info->trust_type = WBC_DOMINFO_TRUSTTYPE_FOREST;
+ } else if (strcmp(r, "In Forest") == 0) {
+ info->trust_type = WBC_DOMINFO_TRUSTTYPE_IN_FOREST;
+ } else {
+ wbc_status = WBC_ERR_INVALID_RESPONSE;
+ BAIL_ON_WBC_ERROR(wbc_status);
+ }
+
+ /* Transitive */
+ r = s;
+ if ((s = strchr(r, '\\')) == NULL) {
+ wbc_status = WBC_ERR_INVALID_RESPONSE;
+ BAIL_ON_WBC_ERROR(wbc_status);
+ }
+ *s = '\0';
+ s++;
+
+ if (strcmp(r, "Yes") == 0) {
+ info->trust_flags |= WBC_DOMINFO_TRUST_TRANSITIVE;
+ }
+
+ /* Incoming */
+ r = s;
+ if ((s = strchr(r, '\\')) == NULL) {
+ wbc_status = WBC_ERR_INVALID_RESPONSE;
+ BAIL_ON_WBC_ERROR(wbc_status);
+ }
+ *s = '\0';
+ s++;
+
+ if (strcmp(r, "Yes") == 0) {
+ info->trust_flags |= WBC_DOMINFO_TRUST_INCOMING;
+ }
+
+ /* Outgoing */
+ r = s;
+ if (r == NULL) {
+ wbc_status = WBC_ERR_INVALID_RESPONSE;
+ BAIL_ON_WBC_ERROR(wbc_status);
+ }
+
+ if (strcmp(r, "Yes") == 0) {
+ info->trust_flags |= WBC_DOMINFO_TRUST_OUTGOING;
+ }
+
+ wbc_status = WBC_ERR_SUCCESS;
+
+ done:
+ return wbc_status;
+}
+
+/** @brief Enumerate the domain trusts known by Winbind
+ *
+ * @param **domains Pointer to the allocated domain list array
+ * @param *num_domains Pointer to number of domains returned
+ *
+ * @return #wbcErr
+ *
+ **/
+wbcErr wbcListTrusts(struct wbcDomainInfo **domains, size_t *num_domains)
+{
+ struct winbindd_response response;
+ wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
+ char *p = NULL;
+ char *q = NULL;
+ char *extra_data = NULL;
+ int count = 0;
+ struct wbcDomainInfo *d_list = NULL;
+ int i = 0;
+
+ *domains = NULL;
+ *num_domains = 0;
+
+ ZERO_STRUCT(response);
+
+ /* Send request */
+
+ wbc_status = wbcRequestResponse(WINBINDD_LIST_TRUSTDOM,
+ NULL,
+ &response);
+ BAIL_ON_WBC_ERROR(wbc_status);
+
+ /* Decode the response */
+
+ p = (char *)response.extra_data.data;
+
+ if (strlen(p) == 0) {
+ /* We should always at least get back our
+ own SAM domain */
+
+ wbc_status = WBC_ERR_DOMAIN_NOT_FOUND;
+ BAIL_ON_WBC_ERROR(wbc_status);
+ }
+
+ /* Count number of domains */
+
+ count = 0;
+ while (p) {
+ count++;
+
+ if ((q = strchr(p, '\n')) != NULL)
+ q++;
+ p = q;
+ }
+
+ d_list = talloc_array(NULL, struct wbcDomainInfo, count);
+ BAIL_ON_PTR_ERROR(d_list, wbc_status);
+
+ extra_data = strdup((char*)response.extra_data.data);
+ BAIL_ON_PTR_ERROR(extra_data, wbc_status);
+
+ p = extra_data;
+
+ /* Outer loop processes the list of domain information */
+
+ for (i=0; i<count && p; i++) {
+ char *next = strchr(p, '\n');
+
+ if (next) {
+ *next = '\0';
+ next++;
+ }
+
+ wbc_status = process_domain_info_string(d_list, &d_list[i], p);
+ BAIL_ON_WBC_ERROR(wbc_status);
+
+ p = next;
+ }
+
+ *domains = d_list;
+ *num_domains = i;
+
+ done:
+ if (!WBC_ERROR_IS_OK(wbc_status)) {
+ if (d_list)
+ talloc_free(d_list);
+ if (extra_data)
+ free(extra_data);
+ }
+
+ return wbc_status;
+}
diff --git a/source3/nsswitch/libwbclient/wbclient.c b/source3/nsswitch/libwbclient/wbclient.c
index b52c6b01e4..9383fd5406 100644
--- a/source3/nsswitch/libwbclient/wbclient.c
+++ b/source3/nsswitch/libwbclient/wbclient.c
@@ -106,8 +106,8 @@ const char *wbcErrorString(wbcErr error)
return "WBC_ERR_WINBIND_NOT_AVAILABLE";
case WBC_ERR_DOMAIN_NOT_FOUND:
return "WBC_ERR_DOMAIN_NOT_FOUND";
- case WBC_INVALID_RESPONSE:
- return "WBC_INVALID_RESPONSE";
+ case WBC_ERR_INVALID_RESPONSE:
+ return "WBC_ERR_INVALID_RESPONSE";
case WBC_ERR_NSS_ERROR:
return "WBC_ERR_NSS_ERROR";
case WBC_ERR_AUTH_ERROR:
diff --git a/source3/nsswitch/libwbclient/wbclient.h b/source3/nsswitch/libwbclient/wbclient.h
index 4e7e5aff25..d73ea297a3 100644
--- a/source3/nsswitch/libwbclient/wbclient.h
+++ b/source3/nsswitch/libwbclient/wbclient.h
@@ -40,7 +40,7 @@ enum _wbcErrType {
WBC_ERR_INVALID_PARAM, /**< An Invalid parameter was supplied **/
WBC_ERR_WINBIND_NOT_AVAILABLE, /**< Winbind daemon is not available **/
WBC_ERR_DOMAIN_NOT_FOUND, /**< Domain is not trusted or cannot be found **/
- WBC_INVALID_RESPONSE, /**< Winbind returned an invalid response **/
+ WBC_ERR_INVALID_RESPONSE, /**< Winbind returned an invalid response **/
WBC_ERR_NSS_ERROR, /**< NSS_STATUS error **/
WBC_ERR_AUTH_ERROR /**< Authentication failed **/
};
@@ -128,15 +128,32 @@ struct wbcDomainInfo {
char *short_name;
char *dns_name;
struct wbcDomainSid sid;
- uint32_t flags;
+ uint32_t domain_flags;
+ uint32_t trust_flags;
+ uint32_t trust_type;
};
-/* wbcDomainInfo->flags */
+/* wbcDomainInfo->domain_flags */
+#define WBC_DOMINFO_UNKNOWN 0x00000000
#define WBC_DOMINFO_NATIVE 0x00000001
#define WBC_DOMINFO_AD 0x00000002
#define WBC_DOMINFO_PRIMARY 0x00000004
+/* wbcDomainInfo->trust_flags */
+
+#define WBC_DOMINFO_TRUST_TRANSITIVE 0x00000001
+#define WBC_DOMINFO_TRUST_INCOMING 0x00000002
+#define WBC_DOMINFO_TRUST_OUTGOING 0x00000004
+
+/* wbcDomainInfo->trust_type */
+
+#define WBC_DOMINFO_TRUSTTYPE_NONE 0x00000000
+#define WBC_DOMINFO_TRUSTTYPE_FOREST 0x00000001
+#define WBC_DOMINFO_TRUSTTYPE_IN_FOREST 0x00000002
+#define WBC_DOMINFO_TRUSTTYPE_EXTERNAL 0x00000003
+
+
/**
* @brief Auth User Parameters
**/
@@ -390,6 +407,10 @@ wbcErr wbcGetGroups(const char *account,
wbcErr wbcDomainInfo(const char *domain,
struct wbcDomainInfo **info);
+wbcErr wbcListTrusts(struct wbcDomainInfo **domains,
+ size_t *num_domains);
+
+
/*
* Athenticate functions
*/
@@ -401,4 +422,16 @@ wbcErr wbcAuthenticateUserEx(const struct wbcAuthUserParams *params,
struct wbcAuthUserInfo **info,
struct wbcAuthErrorInfo **error);
+/*
+ * Resolve functions
+ */
+wbcErr wbcResolveWinsByName(const char *name, char **ip);
+wbcErr wbcResolveWinsByIP(const char *ip, char **name);
+
+/*
+ * Trusted domain functions
+ */
+wbcErr wbcCheckTrustCredentials(const char *domain,
+ struct wbcAuthErrorInfo **error);
+
#endif /* _WBCLIENT_H */
diff --git a/source3/nsswitch/wbinfo.c b/source3/nsswitch/wbinfo.c
index ba358bd1dd..8aa4e5f15f 100644
--- a/source3/nsswitch/wbinfo.c
+++ b/source3/nsswitch/wbinfo.c
@@ -297,52 +297,42 @@ static bool wbinfo_get_userdomgroups(const char *user_sid_str)
/* Convert NetBIOS name to IP */
-static bool wbinfo_wins_byname(char *name)
+static bool wbinfo_wins_byname(const char *name)
{
- struct winbindd_request request;
- struct winbindd_response response;
-
- ZERO_STRUCT(request);
- ZERO_STRUCT(response);
-
- /* Send request */
-
- fstrcpy(request.data.winsreq, name);
+ wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
+ char *ip = NULL;
- if (winbindd_request_response(WINBINDD_WINS_BYNAME, &request, &response) !=
- NSS_STATUS_SUCCESS) {
+ wbc_status = wbcResolveWinsByName(name, &ip);
+ if (!WBC_ERROR_IS_OK(wbc_status)) {
return false;
}
/* Display response */
- d_printf("%s\n", response.data.winsresp);
+ d_printf("%s\n", ip);
+
+ wbcFreeMemory(ip);
return true;
}
/* Convert IP to NetBIOS name */
-static bool wbinfo_wins_byip(char *ip)
+static bool wbinfo_wins_byip(const char *ip)
{
- struct winbindd_request request;
- struct winbindd_response response;
-
- ZERO_STRUCT(request);
- ZERO_STRUCT(response);
-
- /* Send request */
-
- fstrcpy(request.data.winsreq, ip);
+ wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
+ char *name = NULL;
- if (winbindd_request_response(WINBINDD_WINS_BYIP, &request, &response) !=
- NSS_STATUS_SUCCESS) {
+ wbc_status = wbcResolveWinsByIP(ip, &name);
+ if (!WBC_ERROR_IS_OK(wbc_status)) {
return false;
}
/* Display response */
- d_printf("%s\n", response.data.winsresp);
+ d_printf("%s\n", name);
+
+ wbcFreeMemory(name);
return true;
}
@@ -351,101 +341,67 @@ static bool wbinfo_wins_byip(char *ip)
static bool wbinfo_list_domains(bool list_all_domains, bool verbose)
{
- struct winbindd_request request;
- struct winbindd_response response;
-
+ struct wbcDomainInfo *domain_list = NULL;
+ size_t num_domains;
+ wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
bool print_all = !list_all_domains && verbose;
+ int i;
- ZERO_STRUCT(request);
- ZERO_STRUCT(response);
-
- /* Send request */
-
- request.data.list_all_domains = list_all_domains;
-
- if (winbindd_request_response(WINBINDD_LIST_TRUSTDOM, &request, &response) !=
- NSS_STATUS_SUCCESS)
+ wbc_status = wbcListTrusts(&domain_list, &num_domains);
+ if (!WBC_ERROR_IS_OK(wbc_status)) {
return false;
+ }
- /* Display response */
+ if (print_all) {
+ d_printf("%-16s%-24s%-12s%-12s%-5s%-5s\n",
+ "Domain Name", "DNS Domain", "Trust Type",
+ "Transitive", "In", "Out");
+ }
- if (response.extra_data.data) {
- const char *extra_data = (char *)response.extra_data.data;
- char *name;
- char *beg, *end;
- TALLOC_CTX *frame = talloc_stackframe();
+ for (i=0; i<num_domains; i++) {
+ d_printf("%-16s", domain_list[i].short_name);
- if (print_all) {
- d_printf("%-16s%-24s%-12s%-12s%-5s%-5s\n",
- "Domain Name", "DNS Domain", "Trust Type",
- "Transitive", "In", "Out");
+ if (!print_all) {
+ d_printf("\n");
+ continue;
}
- while(next_token_talloc(frame,&extra_data,&name,"\n")) {
- /* Print Domain Name */
- if ((beg = strchr(name, '\\')) == NULL)
- goto error;
- *beg = 0;
- beg++;
- if ((end = strchr(beg, '\\')) == NULL)
- goto error;
- *end = 0;
-
- /* Print short name */
+ d_printf("%-24s", domain_list[i].dns_name);
- d_printf("%-16s", name);
-
- if (!print_all) {
- d_printf("\n");
- continue;
- }
+ switch(domain_list[i].trust_type) {
+ case WBC_DOMINFO_TRUSTTYPE_NONE:
+ d_printf("None ");
+ break;
+ case WBC_DOMINFO_TRUSTTYPE_FOREST:
+ d_printf("Forest ");
+ break;
+ case WBC_DOMINFO_TRUSTTYPE_EXTERNAL:
+ d_printf("External ");
+ break;
+ case WBC_DOMINFO_TRUSTTYPE_IN_FOREST:
+ d_printf("In-Forest ");
+ break;
+ }
- /* Print DNS domain */
+ if (domain_list[i].trust_flags & WBC_DOMINFO_TRUST_TRANSITIVE) {
+ d_printf("Yes ");
+ } else {
+ d_printf("No ");
+ }
- if (beg) {
- d_printf("%-24s", beg);
- }
+ if (domain_list[i].trust_flags & WBC_DOMINFO_TRUST_INCOMING) {
+ d_printf("Yes ");
+ } else {
+ d_printf("No ");
+ }
- /* Skip SID */
- beg = ++end;
- if ((end = strchr(beg, '\\')) == NULL)
- goto error;
-
- /* Print Trust Type */
- beg = ++end;
- if ((end = strchr(beg, '\\')) == NULL)
- goto error;
- *end = 0;
- d_printf("%-12s", beg);
-
- /* Print Transitive */
- beg = ++end;
- if ((end = strchr(beg, '\\')) == NULL)
- goto error;
- *end = 0;
- d_printf("%-12s", beg);
-
- /* Print Incoming */
- beg = ++end;
- if ((end = strchr(beg, '\\')) == NULL)
- goto error;
- *end = 0;
- d_printf("%-5s", beg);
-
- /* Print Outgoing */
- beg = ++end;
- d_printf("%-5s\n", beg);
+ if (domain_list[i].trust_flags & WBC_DOMINFO_TRUST_OUTGOING) {
+ d_printf("Yes ");
+ } else {
+ d_printf("No ");
}
- goto out;
-error:
- d_fprintf(stderr, "Got invalid response: %s\n", extra_data);
- TALLOC_FREE(frame);
- SAFE_FREE(response.extra_data.data);
- return false;
-out:
- TALLOC_FREE(frame);
- SAFE_FREE(response.extra_data.data);
+ d_printf("\n");
}
return true;
@@ -529,12 +485,12 @@ static bool wbinfo_domain_info(const char *domain)
d_printf("SID : %s\n", sid_str);
d_printf("Active Directory : %s\n",
- (dinfo->flags & WBC_DOMINFO_AD) ? "Yes" : "No");
+ (dinfo->domain_flags & WBC_DOMINFO_AD) ? "Yes" : "No");
d_printf("Native : %s\n",
- (dinfo->flags & WBC_DOMINFO_NATIVE) ? "Yes" : "No");
+ (dinfo->domain_flags & WBC_DOMINFO_NATIVE) ? "Yes" : "No");
d_printf("Primary : %s\n",
- (dinfo->flags & WBC_DOMINFO_PRIMARY) ? "Yes" : "No");
+ (dinfo->domain_flags & WBC_DOMINFO_PRIMARY) ? "Yes" : "No");
wbcFreeMemory(sid_str);
wbcFreeMemory(dinfo);
@@ -601,22 +557,24 @@ static bool wbinfo_dsgetdcname(const char *domain_name, uint32_t flags)
static bool wbinfo_check_secret(void)
{
- struct winbindd_response response;
- NSS_STATUS result;
-
- ZERO_STRUCT(response);
+ wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
+ struct wbcAuthErrorInfo *error = NULL;
- result = winbindd_request_response(WINBINDD_CHECK_MACHACC, NULL, &response);
+ wbc_status = wbcCheckTrustCredentials(NULL, &error);
d_printf("checking the trust secret via RPC calls %s\n",
- (result == NSS_STATUS_SUCCESS) ? "succeeded" : "failed");
+ WBC_ERROR_IS_OK(wbc_status) ? "succeeded" : "failed");
- if (result != NSS_STATUS_SUCCESS)
+ if (wbc_status == WBC_ERR_AUTH_ERROR) {
d_fprintf(stderr, "error code was %s (0x%x)\n",
- response.data.auth.nt_status_string,
- response.data.auth.nt_status);
+ error->nt_string, error->nt_status);
+ wbcFreeMemory(error);
+ }
+ if (!WBC_ERROR_IS_OK(wbc_status)) {
+ return false;
+ }
- return result == NSS_STATUS_SUCCESS;
+ return true;
}
/* Convert uid to sid */
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index d5fd571ce4..962c0a4627 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -70,6 +70,14 @@ extern userdom_struct current_user_info;
#define HOMES_NAME "homes"
#endif
+/* the special value for the include parameter
+ * to be interpreted not as a file name but to
+ * trigger loading of the global smb.conf options
+ * from registry. */
+#ifndef INCLUDE_REGISTRY_NAME
+#define INCLUDE_REGISTRY_NAME "registry"
+#endif
+
static bool in_client = False; /* Not in the client by default */
static struct smbconf_csn conf_last_csn;
static struct smbconf_ctx *conf_ctx = NULL;
@@ -6486,7 +6494,7 @@ bool service_ok(int iService)
/*
* process_registry_globals
*/
-static bool process_registry_globals(bool (*pfunc)(const char *, const char *, void *))
+static bool process_registry_globals(void)
{
WERROR werr;
char **param_names;
@@ -6518,13 +6526,14 @@ static bool process_registry_globals(bool (*pfunc)(const char *, const char *, v
}
for (count = 0; count < num_params; count++) {
- ret = pfunc(param_names[count], param_values[count], NULL);
+ ret = do_parameter(param_names[count], param_values[count],
+ NULL);
if (ret != true) {
goto done;
}
}
- ret = pfunc("registry shares", "yes", NULL);
+ ret = do_parameter("registry shares", "yes", NULL);
/* store the csn */
smbconf_changed(conf_ctx, &conf_last_csn, NULL, NULL);
@@ -6718,11 +6727,25 @@ static bool handle_netbios_aliases(int snum, const char *pszParmValue, char **pt
/***************************************************************************
Handle the include operation.
***************************************************************************/
+static bool bAllowIncludeRegistry = true;
static bool handle_include(int snum, const char *pszParmValue, char **ptr)
{
char *fname;
+ if (strequal(pszParmValue, INCLUDE_REGISTRY_NAME)) {
+ if (!bAllowIncludeRegistry) {
+ return true;
+ }
+ if (bInGlobalSection) {
+ return process_registry_globals();
+ } else {
+ DEBUG(1, ("\"include = registry\" only effective "
+ "in %s section\n", GLOBAL_NAME));
+ return false;
+ }
+ }
+
fname = alloc_sub_basic(get_current_username(),
current_user_info.domain,
pszParmValue);
@@ -8632,11 +8655,12 @@ bool lp_is_in_client(void)
False on failure.
***************************************************************************/
-bool lp_load(const char *pszFname,
- bool global_only,
- bool save_defaults,
- bool add_ipc,
- bool initialize_globals)
+bool lp_load_ex(const char *pszFname,
+ bool global_only,
+ bool save_defaults,
+ bool add_ipc,
+ bool initialize_globals,
+ bool allow_include_registry)
{
char *n2 = NULL;
bool bRetval;
@@ -8644,10 +8668,11 @@ bool lp_load(const char *pszFname,
bRetval = False;
- DEBUG(3, ("lp_load: refreshing parameters\n"));
+ DEBUG(3, ("lp_load_ex: refreshing parameters\n"));
bInGlobalSection = True;
bGlobalOnly = global_only;
+ bAllowIncludeRegistry = allow_include_registry;
init_globals(! initialize_globals);
debug_init();
@@ -8675,7 +8700,7 @@ bool lp_load(const char *pszFname,
current_user_info.domain,
pszFname);
if (!n2) {
- smb_panic("lp_load: out of memory");
+ smb_panic("lp_load_ex: out of memory");
}
add_to_file_list(pszFname, n2);
@@ -8703,15 +8728,16 @@ bool lp_load(const char *pszFname,
*/
config_backend = CONFIG_BACKEND_REGISTRY;
/* start over */
- DEBUG(1, ("lp_load: changing to config backend "
+ DEBUG(1, ("lp_load_ex: changing to config backend "
"registry\n"));
init_globals(false);
lp_kill_all_services();
- return lp_load(pszFname, global_only, save_defaults,
- add_ipc, initialize_globals);
+ return lp_load_ex(pszFname, global_only, save_defaults,
+ add_ipc, initialize_globals,
+ allow_include_registry);
}
} else if (lp_config_backend_is_registry()) {
- bRetval = process_registry_globals(do_parameter);
+ bRetval = process_registry_globals();
} else {
DEBUG(0, ("Illegal config backend given: %d\n",
lp_config_backend()));
@@ -8743,9 +8769,35 @@ bool lp_load(const char *pszFname,
init_iconv();
+ bAllowIncludeRegistry = true;
+
return (bRetval);
}
+bool lp_load(const char *pszFname,
+ bool global_only,
+ bool save_defaults,
+ bool add_ipc,
+ bool initialize_globals)
+{
+ return lp_load_ex(pszFname,
+ global_only,
+ save_defaults,
+ add_ipc,
+ initialize_globals,
+ false);
+}
+
+bool lp_load_initial_only(const char *pszFname)
+{
+ return lp_load_ex(pszFname,
+ true,
+ false,
+ false,
+ true,
+ true);
+}
+
/***************************************************************************
Reset the max number of services.
***************************************************************************/
diff --git a/source3/printing/printing.c b/source3/printing/printing.c
index eb304e7641..fdf5e6cc22 100644
--- a/source3/printing/printing.c
+++ b/source3/printing/printing.c
@@ -1406,6 +1406,11 @@ void start_background_queue(void)
/* Child. */
DEBUG(5,("start_background_queue: background LPQ thread started\n"));
+ if (!reinit_after_fork(smbd_messaging_context())) {
+ DEBUG(0,("reinit_after_fork() failed\n"));
+ smb_panic("reinit_after_fork() failed");
+ }
+
claim_connection( NULL, "smbd lpq backend",
FLAG_MSG_GENERAL|FLAG_MSG_SMBD|FLAG_MSG_PRINT_GENERAL);
diff --git a/source3/rpc_client/cli_lsarpc.c b/source3/rpc_client/cli_lsarpc.c
index 37387a04dd..a799f9221d 100644
--- a/source3/rpc_client/cli_lsarpc.c
+++ b/source3/rpc_client/cli_lsarpc.c
@@ -108,7 +108,7 @@ NTSTATUS rpccli_lsa_open_policy2(struct rpc_pipe_client *cli,
}
return rpccli_lsa_OpenPolicy2(cli, mem_ctx,
- cli->cli->srv_name_slash,
+ cli->srv_name_slash,
&attr,
des_access,
pol);
diff --git a/source3/rpc_client/cli_netlogon.c b/source3/rpc_client/cli_netlogon.c
index 851a4a8da8..cb1d93e9c1 100644
--- a/source3/rpc_client/cli_netlogon.c
+++ b/source3/rpc_client/cli_netlogon.c
@@ -134,7 +134,7 @@ NTSTATUS rpccli_netlogon_setup_creds(struct rpc_pipe_client *cli,
struct dcinfo *dc;
bool retried = false;
- SMB_ASSERT(cli->pipe_idx == PI_NETLOGON);
+ SMB_ASSERT(rpccli_is_pipe_idx(cli, PI_NETLOGON));
dc = cli->dc;
if (!dc) {
@@ -159,7 +159,7 @@ NTSTATUS rpccli_netlogon_setup_creds(struct rpc_pipe_client *cli,
generate_random_buffer(clnt_chal_send.data, 8);
/* Get the server challenge. */
- result = rpccli_netr_ServerReqChallenge(cli, cli->mem_ctx,
+ result = rpccli_netr_ServerReqChallenge(cli, talloc_tos(),
dc->remote_machine,
clnt_name,
&clnt_chal_send,
@@ -180,7 +180,7 @@ NTSTATUS rpccli_netlogon_setup_creds(struct rpc_pipe_client *cli,
* Send client auth-2 challenge and receive server repy.
*/
- result = rpccli_netr_ServerAuthenticate2(cli, cli->mem_ctx,
+ result = rpccli_netr_ServerAuthenticate2(cli, talloc_tos(),
dc->remote_machine,
dc->mach_acct,
sec_chan_type,
@@ -212,13 +212,13 @@ NTSTATUS rpccli_netlogon_setup_creds(struct rpc_pipe_client *cli,
*/
DEBUG(0,("rpccli_netlogon_setup_creds: server %s "
"replied with bad credential\n",
- cli->cli->desthost ));
+ cli->desthost ));
return NT_STATUS_ACCESS_DENIED;
}
DEBUG(5,("rpccli_netlogon_setup_creds: server %s credential "
"chain established.\n",
- cli->cli->desthost ));
+ cli->desthost ));
return NT_STATUS_OK;
}
diff --git a/source3/rpc_client/cli_pipe.c b/source3/rpc_client/cli_pipe.c
index 71422cd9ad..d4ce45446b 100644
--- a/source3/rpc_client/cli_pipe.c
+++ b/source3/rpc_client/cli_pipe.c
@@ -279,7 +279,7 @@ static NTSTATUS cli_pipe_verify_ntlmssp(struct rpc_pipe_client *cli, RPC_HDR *pr
DEBUG(0,("cli_pipe_verify_ntlmssp: failed to unseal "
"packet from remote machine %s on pipe %s "
"fnum 0x%x. Error was %s.\n",
- cli->cli->desthost,
+ cli->desthost,
cli->pipe_name,
(unsigned int)cli->fnum,
nt_errstr(status) ));
@@ -297,7 +297,7 @@ static NTSTATUS cli_pipe_verify_ntlmssp(struct rpc_pipe_client *cli, RPC_HDR *pr
DEBUG(0,("cli_pipe_verify_ntlmssp: check signing failed on "
"packet from remote machine %s on pipe %s "
"fnum 0x%x. Error was %s.\n",
- cli->cli->desthost,
+ cli->desthost,
cli->pipe_name,
(unsigned int)cli->fnum,
nt_errstr(status) ));
@@ -373,7 +373,7 @@ static NTSTATUS cli_pipe_verify_schannel(struct rpc_pipe_client *cli, RPC_HDR *p
(unsigned int)RPC_HEADER_LEN + RPC_HDR_RESP_LEN + data_len ));
return NT_STATUS_BUFFER_TOO_SMALL;
}
-
+
if(!smb_io_rpc_hdr_auth("hdr_auth", &auth_info, current_pdu, 0)) {
DEBUG(0,("cli_pipe_verify_schannel: failed to unmarshall RPC_HDR_AUTH.\n"));
return NT_STATUS_BUFFER_TOO_SMALL;
@@ -400,7 +400,7 @@ static NTSTATUS cli_pipe_verify_schannel(struct rpc_pipe_client *cli, RPC_HDR *p
DEBUG(3,("cli_pipe_verify_schannel: failed to decode PDU "
"Connection to remote machine %s "
"pipe %s fnum 0x%x.\n",
- cli->cli->desthost,
+ cli->desthost,
cli->pipe_name,
(unsigned int)cli->fnum ));
return NT_STATUS_INVALID_PARAMETER;
@@ -461,7 +461,7 @@ static NTSTATUS cli_pipe_validate_rpc_response(struct rpc_pipe_client *cli, RPC_
if (prhdr->auth_len) {
DEBUG(3, ("cli_pipe_validate_rpc_response: Connection to remote machine %s "
"pipe %s fnum 0x%x - got non-zero auth len %u.\n",
- cli->cli->desthost,
+ cli->desthost,
cli->pipe_name,
(unsigned int)cli->fnum,
(unsigned int)prhdr->auth_len ));
@@ -489,7 +489,7 @@ static NTSTATUS cli_pipe_validate_rpc_response(struct rpc_pipe_client *cli, RPC_
default:
DEBUG(3, ("cli_pipe_validate_rpc_response: Connection to remote machine %s "
"pipe %s fnum %x - unknown internal auth type %u.\n",
- cli->cli->desthost,
+ cli->desthost,
cli->pipe_name,
(unsigned int)cli->fnum,
cli->auth.auth_type ));
@@ -595,7 +595,7 @@ static NTSTATUS cli_pipe_validate_current_pdu(struct rpc_pipe_client *cli, RPC_H
case RPC_BINDNACK:
DEBUG(1, ("cli_pipe_validate_current_pdu: Bind NACK received from remote machine %s "
"pipe %s fnum 0x%x!\n",
- cli->cli->desthost,
+ cli->desthost,
cli->pipe_name,
(unsigned int)cli->fnum));
/* Use this for now... */
@@ -619,7 +619,7 @@ static NTSTATUS cli_pipe_validate_current_pdu(struct rpc_pipe_client *cli, RPC_H
DEBUG(1, ("cli_pipe_validate_current_pdu: RPC fault code %s received from remote machine %s "
"pipe %s fnum 0x%x!\n",
dcerpc_errstr(NT_STATUS_V(fault_resp.status)),
- cli->cli->desthost,
+ cli->desthost,
cli->pipe_name,
(unsigned int)cli->fnum));
if (NT_STATUS_IS_OK(fault_resp.status)) {
@@ -627,14 +627,13 @@ static NTSTATUS cli_pipe_validate_current_pdu(struct rpc_pipe_client *cli, RPC_H
} else {
return fault_resp.status;
}
-
}
default:
DEBUG(0, ("cli_pipe_validate_current_pdu: unknown packet type %u received "
"from remote machine %s pipe %s fnum 0x%x!\n",
(unsigned int)prhdr->pkt_type,
- cli->cli->desthost,
+ cli->desthost,
cli->pipe_name,
(unsigned int)cli->fnum));
return NT_STATUS_INVALID_INFO_CLASS;
@@ -644,7 +643,7 @@ static NTSTATUS cli_pipe_validate_current_pdu(struct rpc_pipe_client *cli, RPC_H
DEBUG(3, ("cli_pipe_validate_current_pdu: Connection to remote machine %s "
"pipe %s fnum %x got an unexpected RPC packet "
"type - %u, not %u\n",
- cli->cli->desthost,
+ cli->desthost,
cli->pipe_name,
(unsigned int)cli->fnum,
prhdr->pkt_type,
@@ -750,7 +749,7 @@ static NTSTATUS rpc_api_pipe(struct rpc_pipe_client *cli,
uint32 max_data = cli->max_xmit_frag ? cli->max_xmit_frag : RPC_MAX_PDU_FRAG_LEN;
uint32 current_rbuf_offset = 0;
prs_struct current_pdu;
-
+
#ifdef DEVELOPER
/* Ensure we're not sending too much. */
SMB_ASSERT(data_len <= max_data);
@@ -764,7 +763,7 @@ static NTSTATUS rpc_api_pipe(struct rpc_pipe_client *cli,
setup[1] = cli->fnum; /* Pipe file handle. */
DEBUG(5,("rpc_api_pipe: Remote machine %s pipe %s fnum 0x%x\n",
- cli->cli->desthost,
+ cli->desthost,
cli->pipe_name,
(unsigned int)cli->fnum ));
@@ -783,7 +782,7 @@ static NTSTATUS rpc_api_pipe(struct rpc_pipe_client *cli,
{
DEBUG(0, ("rpc_api_pipe: Remote machine %s pipe %s fnum 0x%x "
"returned critical error. Error was %s\n",
- cli->cli->desthost,
+ cli->desthost,
cli->pipe_name,
(unsigned int)cli->fnum,
cli_errstr(cli->cli)));
@@ -800,7 +799,7 @@ static NTSTATUS rpc_api_pipe(struct rpc_pipe_client *cli,
if (prdata == NULL) {
DEBUG(3,("rpc_api_pipe: Remote machine %s pipe %s "
"fnum 0x%x failed to return data.\n",
- cli->cli->desthost,
+ cli->desthost,
cli->pipe_name,
(unsigned int)cli->fnum));
/* Yes - some calls can truely return no data... */
@@ -850,7 +849,7 @@ static NTSTATUS rpc_api_pipe(struct rpc_pipe_client *cli,
/* Set the data type correctly for big-endian data on the first packet. */
DEBUG(10,("rpc_api_pipe: On machine %s pipe %s fnum 0x%x "
"PDU data format is big-endian.\n",
- cli->cli->desthost,
+ cli->desthost,
cli->pipe_name,
(unsigned int)cli->fnum));
@@ -887,7 +886,7 @@ static NTSTATUS rpc_api_pipe(struct rpc_pipe_client *cli,
}
DEBUG(10,("rpc_api_pipe: Remote machine %s pipe %s fnum 0x%x returned %u bytes.\n",
- cli->cli->desthost,
+ cli->desthost,
cli->pipe_name,
(unsigned int)cli->fnum,
(unsigned int)prs_data_size(rbuf) ));
@@ -1066,7 +1065,10 @@ static NTSTATUS create_schannel_auth_rpc_bind_req( struct rpc_pipe_client *cli,
/* Use lp_workgroup() if domain not specified */
if (!cli->domain || !cli->domain[0]) {
- cli->domain = lp_workgroup();
+ cli->domain = talloc_strdup(cli, lp_workgroup());
+ if (cli->domain == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
}
init_rpc_auth_schannel_neg(&schannel_neg, cli->domain, global_myname());
@@ -1092,8 +1094,8 @@ static NTSTATUS create_schannel_auth_rpc_bind_req( struct rpc_pipe_client *cli,
static NTSTATUS create_bind_or_alt_ctx_internal(enum RPC_PKT_TYPE pkt_type,
prs_struct *rpc_out,
uint32 rpc_call_id,
- RPC_IFACE *abstract,
- RPC_IFACE *transfer,
+ const RPC_IFACE *abstract,
+ const RPC_IFACE *transfer,
RPC_HDR_AUTH *phdr_auth,
prs_struct *pauth_info)
{
@@ -1174,7 +1176,8 @@ static NTSTATUS create_bind_or_alt_ctx_internal(enum RPC_PKT_TYPE pkt_type,
static NTSTATUS create_rpc_bind_req(struct rpc_pipe_client *cli,
prs_struct *rpc_out,
uint32 rpc_call_id,
- RPC_IFACE *abstract, RPC_IFACE *transfer,
+ const RPC_IFACE *abstract,
+ const RPC_IFACE *transfer,
enum pipe_auth_type auth_type,
enum pipe_auth_level auth_level)
{
@@ -1307,14 +1310,14 @@ static NTSTATUS add_ntlmssp_auth_footer(struct rpc_pipe_client *cli,
}
/* Finally marshall the blob. */
-
+
if (!prs_copy_data_in(outgoing_pdu, (const char *)auth_blob.data, NTLMSSP_SIG_SIZE)) {
DEBUG(0,("add_ntlmssp_auth_footer: failed to add %u bytes auth blob.\n",
(unsigned int)NTLMSSP_SIG_SIZE));
data_blob_free(&auth_blob);
return NT_STATUS_NO_MEMORY;
}
-
+
data_blob_free(&auth_blob);
return NT_STATUS_OK;
}
@@ -1379,7 +1382,7 @@ static NTSTATUS add_schannel_auth_footer(struct rpc_pipe_client *cli,
&verf,
outgoing_pdu,
0);
-
+
return NT_STATUS_OK;
}
@@ -1639,58 +1642,14 @@ static bool rpc_pipe_set_hnd_state(struct rpc_pipe_client *cli,
Check the rpc bind acknowledge response.
****************************************************************************/
-static bool valid_pipe_name(const int pipe_idx, RPC_IFACE *abstract, RPC_IFACE *transfer)
-{
- if ( pipe_idx >= PI_MAX_PIPES ) {
- DEBUG(0,("valid_pipe_name: Programmer error! Invalid pipe index [%d]\n",
- pipe_idx));
- return False;
- }
-
- DEBUG(5,("Bind Abstract Syntax: "));
- dump_data(5, (uint8 *)&pipe_names[pipe_idx].abstr_syntax,
- sizeof(pipe_names[pipe_idx].abstr_syntax));
- DEBUG(5,("Bind Transfer Syntax: "));
- dump_data(5, (uint8 *)&pipe_names[pipe_idx].trans_syntax,
- sizeof(pipe_names[pipe_idx].trans_syntax));
-
- /* copy the required syntaxes out so we can do the right bind */
-
- *transfer = pipe_names[pipe_idx].trans_syntax;
- *abstract = pipe_names[pipe_idx].abstr_syntax;
-
- return True;
-}
-
-/****************************************************************************
- Check the rpc bind acknowledge response.
-****************************************************************************/
-
-static bool check_bind_response(RPC_HDR_BA *hdr_ba, const int pipe_idx, RPC_IFACE *transfer)
+static bool check_bind_response(RPC_HDR_BA *hdr_ba, const RPC_IFACE *transfer)
{
if ( hdr_ba->addr.len == 0) {
DEBUG(4,("Ignoring length check -- ASU bug (server didn't fill in the pipe name correctly)"));
}
-# if 0 /* JERRY -- apparently ASU forgets to fill in the server pipe name sometimes */
- if ( !strequal(hdr_ba->addr.str, pipe_names[pipe_idx].client_pipe) &&
- !strequal(hdr_ba->addr.str, pipe_names[pipe_idx].server_pipe) )
- {
- DEBUG(4,("bind_rpc_pipe: pipe_name %s != expected pipe %s. oh well!\n",
- pipe_names[i].server_pipe ,hdr_ba->addr.str));
- return False;
- }
-
- DEBUG(5,("bind_rpc_pipe: server pipe_name found: %s\n", pipe_names[i].server_pipe ));
-
- if (pipe_names[pipe_idx].server_pipe == NULL) {
- DEBUG(2,("bind_rpc_pipe: pipe name %s unsupported\n", hdr_ba->addr.str));
- return False;
- }
-#endif /* JERRY */
-
/* check the transfer syntax */
- if ((hdr_ba->transfer.version != transfer->version) ||
+ if ((hdr_ba->transfer.if_version != transfer->if_version) ||
(memcmp(&hdr_ba->transfer.uuid, &transfer->uuid, sizeof(transfer->uuid)) !=0)) {
DEBUG(2,("bind_rpc_pipe: transfer syntax differs\n"));
return False;
@@ -1727,7 +1686,7 @@ static NTSTATUS create_rpc_bind_auth3(struct rpc_pipe_client *cli,
init_rpc_hdr(&hdr, RPC_AUTH3, RPC_FLG_FIRST|RPC_FLG_LAST, rpc_call_id,
RPC_HEADER_LEN + 4 /* pad */ + RPC_HDR_AUTH_LEN + pauth_blob->length,
pauth_blob->length );
-
+
/* Marshall it. */
if(!smb_io_rpc_hdr("hdr", &hdr, rpc_out, 0)) {
DEBUG(0,("create_rpc_bind_auth3: failed to marshall RPC_HDR.\n"));
@@ -1802,11 +1761,11 @@ static NTSTATUS rpc_finish_auth3_bind(struct rpc_pipe_client *cli,
server_response = data_blob(NULL, phdr->auth_len);
prs_copy_data_out((char *)server_response.data, rbuf, phdr->auth_len);
-
+
nt_status = ntlmssp_update(cli->auth.a_u.ntlmssp_state,
server_response,
&client_reply);
-
+
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(0,("rpc_finish_auth3_bind: NTLMSSP update using server blob failed.\n"));
data_blob_free(&server_response);
@@ -1840,7 +1799,7 @@ static NTSTATUS rpc_finish_auth3_bind(struct rpc_pipe_client *cli,
DEBUG(5,("rpc_send_auth_auth3: Remote machine %s pipe %s "
"fnum 0x%x sent auth3 response ok.\n",
- cli->cli->desthost,
+ cli->desthost,
cli->pipe_name,
(unsigned int)cli->fnum));
@@ -1856,8 +1815,8 @@ static NTSTATUS rpc_finish_auth3_bind(struct rpc_pipe_client *cli,
********************************************************************/
static NTSTATUS create_rpc_alter_context(uint32 rpc_call_id,
- RPC_IFACE *abstract,
- RPC_IFACE *transfer,
+ const RPC_IFACE *abstract,
+ const RPC_IFACE *transfer,
enum pipe_auth_level auth_level,
const DATA_BLOB *pauth_blob, /* spnego auth blob already created. */
prs_struct *rpc_out)
@@ -1900,8 +1859,8 @@ static NTSTATUS rpc_finish_spnego_ntlmssp_bind(struct rpc_pipe_client *cli,
RPC_HDR *phdr,
prs_struct *rbuf,
uint32 rpc_call_id,
- RPC_IFACE *abstract,
- RPC_IFACE *transfer,
+ const RPC_IFACE *abstract,
+ const RPC_IFACE *transfer,
enum pipe_auth_type auth_type,
enum pipe_auth_level auth_level)
{
@@ -1928,7 +1887,7 @@ static NTSTATUS rpc_finish_spnego_ntlmssp_bind(struct rpc_pipe_client *cli,
server_spnego_response = data_blob(NULL, phdr->auth_len);
prs_copy_data_out((char *)server_spnego_response.data, rbuf, phdr->auth_len);
-
+
/* The server might give us back two challenges - tmp_blob is for the second. */
if (!spnego_parse_challenge(server_spnego_response, &server_ntlm_response, &tmp_blob)) {
data_blob_free(&server_spnego_response);
@@ -1944,7 +1903,7 @@ static NTSTATUS rpc_finish_spnego_ntlmssp_bind(struct rpc_pipe_client *cli,
nt_status = ntlmssp_update(cli->auth.a_u.ntlmssp_state,
server_ntlm_response,
&client_reply);
-
+
/* Finished with the server_ntlm response */
data_blob_free(&server_ntlm_response);
@@ -1979,7 +1938,7 @@ static NTSTATUS rpc_finish_spnego_ntlmssp_bind(struct rpc_pipe_client *cli,
/* Initialize the returning data struct. */
prs_mem_free(rbuf);
- prs_init_empty(rbuf, cli->mem_ctx, UNMARSHALL);
+ prs_init_empty(rbuf, talloc_tos(), UNMARSHALL);
nt_status = rpc_api_pipe(cli, &rpc_out, rbuf, RPC_ALTCONTRESP);
if (!NT_STATUS_IS_OK(nt_status)) {
@@ -2018,7 +1977,7 @@ static NTSTATUS rpc_finish_spnego_ntlmssp_bind(struct rpc_pipe_client *cli,
DEBUG(5,("rpc_finish_spnego_ntlmssp_bind: alter context request to "
"remote machine %s pipe %s fnum 0x%x.\n",
- cli->cli->desthost,
+ cli->desthost,
cli->pipe_name,
(unsigned int)cli->fnum));
@@ -2035,8 +1994,6 @@ static NTSTATUS rpc_pipe_bind(struct rpc_pipe_client *cli,
{
RPC_HDR hdr;
RPC_HDR_BA hdr_ba;
- RPC_IFACE abstract;
- RPC_IFACE transfer;
prs_struct rpc_out;
prs_struct rbuf;
uint32 rpc_call_id;
@@ -2048,17 +2005,14 @@ static NTSTATUS rpc_pipe_bind(struct rpc_pipe_client *cli,
(unsigned int)auth_type,
(unsigned int)auth_level ));
- if (!valid_pipe_name(cli->pipe_idx, &abstract, &transfer)) {
- return NT_STATUS_INVALID_PARAMETER;
- }
-
- prs_init_empty(&rpc_out, cli->mem_ctx, MARSHALL);
+ prs_init_empty(&rpc_out, talloc_tos(), MARSHALL);
rpc_call_id = get_rpc_call_id();
/* Marshall the outgoing data. */
status = create_rpc_bind_req(cli, &rpc_out, rpc_call_id,
- &abstract, &transfer,
+ cli->abstract_syntax,
+ cli->transfer_syntax,
auth_type,
auth_level);
@@ -2068,7 +2022,7 @@ static NTSTATUS rpc_pipe_bind(struct rpc_pipe_client *cli,
}
/* Initialize the incoming data struct. */
- prs_init_empty(&rbuf, cli->mem_ctx, UNMARSHALL);
+ prs_init_empty(&rbuf, talloc_tos(), UNMARSHALL);
/* send data on \PIPE\. receive a response */
status = rpc_api_pipe(cli, &rpc_out, &rbuf, RPC_BINDACK);
@@ -2081,7 +2035,7 @@ static NTSTATUS rpc_pipe_bind(struct rpc_pipe_client *cli,
DEBUG(3,("rpc_pipe_bind: Remote machine %s pipe %s "
"fnum 0x%x bind request returned ok.\n",
- cli->cli->desthost,
+ cli->desthost,
cli->pipe_name,
(unsigned int)cli->fnum));
@@ -2098,7 +2052,7 @@ static NTSTATUS rpc_pipe_bind(struct rpc_pipe_client *cli,
return NT_STATUS_BUFFER_TOO_SMALL;
}
- if(!check_bind_response(&hdr_ba, cli->pipe_idx, &transfer)) {
+ if(!check_bind_response(&hdr_ba, cli->transfer_syntax)) {
DEBUG(2,("rpc_pipe_bind: check_bind_response failed.\n"));
prs_mem_free(&rbuf);
return NT_STATUS_BUFFER_TOO_SMALL;
@@ -2128,7 +2082,8 @@ static NTSTATUS rpc_pipe_bind(struct rpc_pipe_client *cli,
case PIPE_AUTH_TYPE_SPNEGO_NTLMSSP:
/* Need to send alter context request and reply. */
status = rpc_finish_spnego_ntlmssp_bind(cli, &hdr, &rbuf, rpc_call_id,
- &abstract, &transfer,
+ cli->abstract_syntax,
+ cli->transfer_syntax,
auth_type, auth_level);
if (!NT_STATUS_IS_OK(status)) {
prs_mem_free(&rbuf);
@@ -2173,6 +2128,46 @@ static NTSTATUS rpc_pipe_bind(struct rpc_pipe_client *cli,
return NT_STATUS_OK;
}
+unsigned int rpccli_set_timeout(struct rpc_pipe_client *cli,
+ unsigned int timeout)
+{
+ return cli_set_timeout(cli->cli, timeout);
+}
+
+bool rpccli_is_pipe_idx(struct rpc_pipe_client *cli, int pipe_idx)
+{
+ return (cli->abstract_syntax == pipe_names[pipe_idx].abstr_syntax);
+}
+
+struct cli_state *rpc_pipe_np_smb_conn(struct rpc_pipe_client *p)
+{
+ return p->cli;
+}
+
+static int rpc_pipe_destructor(struct rpc_pipe_client *p)
+{
+ bool ret;
+
+ ret = cli_close(p->cli, p->fnum);
+ if (!ret) {
+ DEBUG(1, ("rpc_pipe_destructor: cli_close failed on pipe %s, "
+ "fnum 0x%x to machine %s. Error was %s\n",
+ p->pipe_name, (int) p->fnum,
+ p->desthost, cli_errstr(p->cli)));
+ }
+
+ if (p->auth.cli_auth_data_free_func) {
+ (*p->auth.cli_auth_data_free_func)(&p->auth);
+ }
+
+ DEBUG(10, ("rpc_pipe_destructor: closed pipe %s to machine %s\n",
+ p->pipe_name, p->desthost ));
+
+ DLIST_REMOVE(p->cli->pipe_list, p);
+
+ return ret ? -1 : 0;
+}
+
/****************************************************************************
Open a named pipe over SMB to a remote server.
*
@@ -2188,7 +2183,6 @@ static NTSTATUS rpc_pipe_bind(struct rpc_pipe_client *cli,
static struct rpc_pipe_client *cli_rpc_pipe_open(struct cli_state *cli, int pipe_idx, NTSTATUS *perr)
{
- TALLOC_CTX *mem_ctx;
struct rpc_pipe_client *result;
int fnum;
@@ -2204,48 +2198,61 @@ static struct rpc_pipe_client *cli_rpc_pipe_open(struct cli_state *cli, int pipe
/* The pipe name index must fall within our array */
SMB_ASSERT((pipe_idx >= 0) && (pipe_idx < PI_MAX_PIPES));
- mem_ctx = talloc_init("struct rpc_pipe_client");
- if (mem_ctx == NULL) {
+ result = TALLOC_ZERO_P(NULL, struct rpc_pipe_client);
+ if (result == NULL) {
+ *perr = NT_STATUS_NO_MEMORY;
return NULL;
}
- result = TALLOC_ZERO_P(mem_ctx, struct rpc_pipe_client);
- if (result == NULL) {
+ result->pipe_name = cli_get_pipe_name(pipe_idx);
+
+ result->cli = cli;
+ result->abstract_syntax = pipe_names[pipe_idx].abstr_syntax;
+ result->transfer_syntax = pipe_names[pipe_idx].trans_syntax;
+ result->auth.auth_type = PIPE_AUTH_TYPE_NONE;
+ result->auth.auth_level = PIPE_AUTH_LEVEL_NONE;
+
+ result->domain = talloc_strdup(result, cli->domain);
+ result->user_name = talloc_strdup(result, cli->user_name);
+ result->desthost = talloc_strdup(result, cli->desthost);
+ result->srv_name_slash = talloc_asprintf_strupper_m(
+ result, "\\\\%s", result->desthost);
+
+ if ((result->domain == NULL)
+ || (result->user_name == NULL)
+ || (result->desthost == NULL)
+ || (result->srv_name_slash == NULL)) {
+ *perr = NT_STATUS_NO_MEMORY;
+ TALLOC_FREE(result);
return NULL;
}
- result->mem_ctx = mem_ctx;
-
- result->pipe_name = cli_get_pipe_name(pipe_idx);
+ if (pipe_idx == PI_NETLOGON) {
+ /* Set up a netlogon credential chain for a netlogon pipe. */
+ result->dc = TALLOC_ZERO_P(result, struct dcinfo);
+ if (result->dc == NULL) {
+ *perr = NT_STATUS_NO_MEMORY;
+ TALLOC_FREE(result);
+ return NULL;
+ }
+ }
fnum = cli_nt_create(cli, result->pipe_name, DESIRED_ACCESS_PIPE);
-
if (fnum == -1) {
DEBUG(1,("cli_rpc_pipe_open: cli_nt_create failed on pipe %s "
"to machine %s. Error was %s\n",
result->pipe_name, cli->desthost,
cli_errstr(cli)));
*perr = cli_get_nt_error(cli);
- talloc_destroy(result->mem_ctx);
+ talloc_destroy(result);
return NULL;
}
result->fnum = fnum;
- result->cli = cli;
- result->pipe_idx = pipe_idx;
- result->auth.auth_type = PIPE_AUTH_TYPE_NONE;
- result->auth.auth_level = PIPE_AUTH_LEVEL_NONE;
-
- if (pipe_idx == PI_NETLOGON) {
- /* Set up a netlogon credential chain for a netlogon pipe. */
- result->dc = TALLOC_ZERO_P(mem_ctx, struct dcinfo);
- if (result->dc == NULL) {
- talloc_destroy(result->mem_ctx);
- return NULL;
- }
- }
DLIST_ADD(cli->pipe_list, result);
+ talloc_set_destructor(result, rpc_pipe_destructor);
+
*perr = NT_STATUS_OK;
return result;
@@ -2267,14 +2274,14 @@ struct rpc_pipe_client *cli_rpc_pipe_open_noauth(struct cli_state *cli, int pipe
*perr = rpc_pipe_bind(result, PIPE_AUTH_TYPE_NONE, PIPE_AUTH_LEVEL_NONE);
if (!NT_STATUS_IS_OK(*perr)) {
int lvl = 0;
- if (pipe_idx == PI_DSSETUP) {
+ if (rpccli_is_pipe_idx(result, PI_DSSETUP)) {
/* non AD domains just don't have this pipe, avoid
* level 0 statement in that case - gd */
lvl = 3;
}
DEBUG(lvl, ("cli_rpc_pipe_open_noauth: rpc_pipe_bind for pipe %s failed with error %s\n",
cli_get_pipe_name(pipe_idx), nt_errstr(*perr) ));
- cli_rpc_pipe_close(result);
+ TALLOC_FREE(result);
return NULL;
}
@@ -2316,11 +2323,20 @@ static struct rpc_pipe_client *cli_rpc_pipe_open_ntlmssp_internal(struct cli_sta
if (result == NULL) {
return NULL;
}
-
+
result->auth.cli_auth_data_free_func = cli_ntlmssp_auth_free;
- result->domain = domain;
- result->user_name = username;
+ TALLOC_FREE(result->domain);
+ TALLOC_FREE(result->user_name);
+
+ result->domain = talloc_strdup(result, domain);
+ result->user_name = talloc_strdup(result, username);
+
+ if ((result->domain == NULL) || (result->user_name == NULL)) {
+ *perr = NT_STATUS_NO_MEMORY;
+ goto err;
+ }
+
pwd_set_cleartext(&result->pwd, password);
*perr = ntlmssp_client_start(&ntlmssp_state);
@@ -2330,12 +2346,12 @@ static struct rpc_pipe_client *cli_rpc_pipe_open_ntlmssp_internal(struct cli_sta
result->auth.a_u.ntlmssp_state = ntlmssp_state;
- *perr = ntlmssp_set_username(ntlmssp_state, cli->user_name);
+ *perr = ntlmssp_set_username(ntlmssp_state, username);
if (!NT_STATUS_IS_OK(*perr)) {
goto err;
}
- *perr = ntlmssp_set_domain(ntlmssp_state, cli->domain);
+ *perr = ntlmssp_set_domain(ntlmssp_state, domain);
if (!NT_STATUS_IS_OK(*perr)) {
goto err;
}
@@ -2360,7 +2376,7 @@ static struct rpc_pipe_client *cli_rpc_pipe_open_ntlmssp_internal(struct cli_sta
} else if (auth_level == PIPE_AUTH_LEVEL_PRIVACY) {
ntlmssp_state->neg_flags |= NTLMSSP_NEGOTIATE_SEAL | NTLMSSP_NEGOTIATE_SIGN;
}
-
+
*perr = rpc_pipe_bind(result, auth_type, auth_level);
if (!NT_STATUS_IS_OK(*perr)) {
DEBUG(0, ("cli_rpc_pipe_open_ntlmssp_internal: cli_rpc_pipe_bind failed with error %s\n",
@@ -2377,7 +2393,7 @@ static struct rpc_pipe_client *cli_rpc_pipe_open_ntlmssp_internal(struct cli_sta
err:
- cli_rpc_pipe_close(result);
+ TALLOC_FREE(result);
return NULL;
}
@@ -2498,7 +2514,7 @@ struct rpc_pipe_client *get_schannel_session_key(struct cli_state *cli,
if (!get_schannel_session_key_common(netlogon_pipe, cli, domain,
pneg_flags, perr))
{
- cli_rpc_pipe_close(netlogon_pipe);
+ TALLOC_FREE(netlogon_pipe);
return NULL;
}
@@ -2525,21 +2541,29 @@ struct rpc_pipe_client *cli_rpc_pipe_open_schannel_with_key(struct cli_state *cl
return NULL;
}
- result->auth.a_u.schannel_auth = TALLOC_ZERO_P(result->mem_ctx, struct schannel_auth_struct);
+ result->auth.a_u.schannel_auth = TALLOC_ZERO_P(
+ result, struct schannel_auth_struct);
if (!result->auth.a_u.schannel_auth) {
- cli_rpc_pipe_close(result);
+ TALLOC_FREE(result);
+ *perr = NT_STATUS_NO_MEMORY;
+ return NULL;
+ }
+
+ TALLOC_FREE(result->domain);
+ result->domain = talloc_strdup(result, domain);
+ if (result->domain == NULL) {
+ TALLOC_FREE(result);
*perr = NT_STATUS_NO_MEMORY;
return NULL;
}
- result->domain = domain;
memcpy(result->auth.a_u.schannel_auth->sess_key, pdc->sess_key, 16);
*perr = rpc_pipe_bind(result, PIPE_AUTH_TYPE_SCHANNEL, auth_level);
if (!NT_STATUS_IS_OK(*perr)) {
DEBUG(0, ("cli_rpc_pipe_open_schannel_with_key: cli_rpc_pipe_bind failed with error %s\n",
nt_errstr(*perr) ));
- cli_rpc_pipe_close(result);
+ TALLOC_FREE(result);
return NULL;
}
@@ -2579,7 +2603,7 @@ static struct rpc_pipe_client *get_schannel_session_key_auth_ntlmssp(struct cli_
if (!get_schannel_session_key_common(netlogon_pipe, cli, domain,
pneg_flags, perr))
{
- cli_rpc_pipe_close(netlogon_pipe);
+ TALLOC_FREE(netlogon_pipe);
return NULL;
}
@@ -2618,7 +2642,7 @@ struct rpc_pipe_client *cli_rpc_pipe_open_ntlmssp_auth_schannel(struct cli_state
domain, netlogon_pipe->dc, perr);
/* Now we've bound using the session key we can close the netlog pipe. */
- cli_rpc_pipe_close(netlogon_pipe);
+ TALLOC_FREE(netlogon_pipe);
return result;
}
@@ -2651,7 +2675,7 @@ struct rpc_pipe_client *cli_rpc_pipe_open_schannel(struct cli_state *cli,
domain, netlogon_pipe->dc, perr);
/* Now we've bound using the session key we can close the netlog pipe. */
- cli_rpc_pipe_close(netlogon_pipe);
+ TALLOC_FREE(netlogon_pipe);
return result;
}
@@ -2693,10 +2717,10 @@ struct rpc_pipe_client *cli_rpc_pipe_open_krb5(struct cli_state *cli,
/* Default service principal is "desthost$@realm" */
if (!service_princ) {
- service_princ = talloc_asprintf(result->mem_ctx, "%s$@%s",
- cli->desthost, lp_realm() );
+ service_princ = talloc_asprintf(result, "%s$@%s",
+ cli->desthost, lp_realm() );
if (!service_princ) {
- cli_rpc_pipe_close(result);
+ TALLOC_FREE(result);
return NULL;
}
}
@@ -2705,14 +2729,15 @@ struct rpc_pipe_client *cli_rpc_pipe_open_krb5(struct cli_state *cli,
if (username && password) {
int ret = kerberos_kinit_password(username, password, 0, NULL);
if (ret) {
- cli_rpc_pipe_close(result);
+ TALLOC_FREE(result);
return NULL;
}
}
- result->auth.a_u.kerberos_auth = TALLOC_ZERO_P(result->mem_ctx, struct kerberos_auth_struct);
+ result->auth.a_u.kerberos_auth = TALLOC_ZERO_P(
+ result, struct kerberos_auth_struct);
if (!result->auth.a_u.kerberos_auth) {
- cli_rpc_pipe_close(result);
+ TALLOC_FREE(result);
*perr = NT_STATUS_NO_MEMORY;
return NULL;
}
@@ -2724,7 +2749,7 @@ struct rpc_pipe_client *cli_rpc_pipe_open_krb5(struct cli_state *cli,
if (!NT_STATUS_IS_OK(*perr)) {
DEBUG(0, ("cli_rpc_pipe_open_krb5: cli_rpc_pipe_bind failed with error %s\n",
nt_errstr(*perr) ));
- cli_rpc_pipe_close(result);
+ TALLOC_FREE(result);
return NULL;
}
diff --git a/source3/rpc_client/cli_samr.c b/source3/rpc_client/cli_samr.c
index fd4fbfc9f4..21fecc4196 100644
--- a/source3/rpc_client/cli_samr.c
+++ b/source3/rpc_client/cli_samr.c
@@ -45,7 +45,7 @@ NTSTATUS rpccli_samr_chgpasswd_user(struct rpc_pipe_client *cli,
DEBUG(10,("rpccli_samr_chgpasswd_user\n"));
- init_lsa_String(&server, cli->cli->srv_name_slash);
+ init_lsa_String(&server, cli->srv_name_slash);
init_lsa_String(&account, username);
/* Calculate the MD4 hash (NT compatible) of the password */
@@ -105,7 +105,7 @@ NTSTATUS rpccli_samr_chng_pswd_auth_crap(struct rpc_pipe_client *cli,
DEBUG(10,("rpccli_samr_chng_pswd_auth_crap\n"));
- init_lsa_String(&server, cli->cli->srv_name_slash);
+ init_lsa_String(&server, cli->srv_name_slash);
init_lsa_String(&account, username);
memcpy(&new_nt_password.data, new_nt_password_blob.data, 516);
@@ -151,7 +151,7 @@ NTSTATUS rpccli_samr_chgpasswd3(struct rpc_pipe_client *cli,
DEBUG(10,("rpccli_samr_chgpasswd_user3\n"));
- init_lsa_String(&server, cli->cli->srv_name_slash);
+ init_lsa_String(&server, cli->srv_name_slash);
init_lsa_String(&account, username);
/* Calculate the MD4 hash (NT compatible) of the password */
@@ -242,7 +242,7 @@ NTSTATUS rpccli_try_samr_connects(struct rpc_pipe_client *cli,
info_in.info1 = info1;
status = rpccli_samr_Connect5(cli, mem_ctx,
- cli->cli->srv_name_slash,
+ cli->srv_name_slash,
access_mask,
1,
&info_in,
@@ -254,7 +254,7 @@ NTSTATUS rpccli_try_samr_connects(struct rpc_pipe_client *cli,
}
status = rpccli_samr_Connect4(cli, mem_ctx,
- cli->cli->srv_name_slash,
+ cli->srv_name_slash,
SAMR_CONNECT_W2K,
access_mask,
connect_pol);
@@ -263,7 +263,7 @@ NTSTATUS rpccli_try_samr_connects(struct rpc_pipe_client *cli,
}
status = rpccli_samr_Connect2(cli, mem_ctx,
- cli->cli->srv_name_slash,
+ cli->srv_name_slash,
access_mask,
connect_pol);
return status;
diff --git a/source3/rpc_client/cli_spoolss.c b/source3/rpc_client/cli_spoolss.c
index bbb29511ba..823af6fb4f 100644
--- a/source3/rpc_client/cli_spoolss.c
+++ b/source3/rpc_client/cli_spoolss.c
@@ -597,7 +597,7 @@ WERROR rpccli_spoolss_enum_ports(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ct
ZERO_STRUCT(in);
ZERO_STRUCT(out);
- slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
+ slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->desthost);
strupper_m(server);
offered = 0;
@@ -777,7 +777,7 @@ WERROR rpccli_spoolss_getprinterdriver(struct rpc_pipe_client *cli,
ZERO_STRUCT(in);
ZERO_STRUCT(out);
- fstrcpy(server, cli->cli->desthost);
+ fstrcpy(server, cli->desthost);
strupper_m(server);
offered = 0;
@@ -855,7 +855,7 @@ WERROR rpccli_spoolss_enumprinterdrivers (struct rpc_pipe_client *cli,
ZERO_STRUCT(in);
ZERO_STRUCT(out);
- slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
+ slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->desthost);
strupper_m(server);
offered = 0;
@@ -938,7 +938,7 @@ WERROR rpccli_spoolss_getprinterdriverdir (struct rpc_pipe_client *cli,
ZERO_STRUCT(in);
ZERO_STRUCT(out);
- slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
+ slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->desthost);
strupper_m(server);
offered = 0;
@@ -996,7 +996,7 @@ WERROR rpccli_spoolss_addprinterdriver (struct rpc_pipe_client *cli,
ZERO_STRUCT(in);
ZERO_STRUCT(out);
- slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
+ slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->desthost);
strupper_m(server);
make_spoolss_q_addprinterdriver( mem_ctx, &in, server, level, ctr );
@@ -1026,7 +1026,7 @@ WERROR rpccli_spoolss_addprinterex (struct rpc_pipe_client *cli, TALLOC_CTX *mem
ZERO_STRUCT(out);
slprintf(client, sizeof(fstring)-1, "\\\\%s", global_myname());
- slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
+ slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->desthost);
strupper_m(client);
strupper_m(server);
@@ -1061,7 +1061,7 @@ WERROR rpccli_spoolss_deleteprinterdriverex(struct rpc_pipe_client *cli,
ZERO_STRUCT(in);
ZERO_STRUCT(out);
- slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
+ slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->desthost);
strupper_m(server);
make_spoolss_q_deleteprinterdriverex( mem_ctx, &in, server, arch, driver, version );
@@ -1091,7 +1091,7 @@ WERROR rpccli_spoolss_deleteprinterdriver (struct rpc_pipe_client *cli,
ZERO_STRUCT(in);
ZERO_STRUCT(out);
- slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
+ slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->desthost);
strupper_m(server);
make_spoolss_q_deleteprinterdriver( mem_ctx, &in, server, arch, driver );
diff --git a/source3/rpc_client/ndr.c b/source3/rpc_client/ndr.c
index ae705b313b..91751a2d71 100644
--- a/source3/rpc_client/ndr.c
+++ b/source3/rpc_client/ndr.c
@@ -35,7 +35,7 @@ NTSTATUS cli_do_rpc_ndr(struct rpc_pipe_client *cli,
NTSTATUS status;
enum ndr_err_code ndr_err;
- SMB_ASSERT(cli->pipe_idx == p_idx);
+ SMB_ASSERT(rpccli_is_pipe_idx(cli, p_idx));
SMB_ASSERT(table->num_calls > opnum);
call = &table->calls[opnum];
diff --git a/source3/rpc_parse/parse_rpc.c b/source3/rpc_parse/parse_rpc.c
index b696080aef..d0be83bd4e 100644
--- a/source3/rpc_parse/parse_rpc.c
+++ b/source3/rpc_parse/parse_rpc.c
@@ -29,176 +29,14 @@
interface/version dce/rpc pipe identification
********************************************************************/
-#define TRANS_SYNT_V2 \
-{ \
- { \
- 0x8a885d04, 0x1ceb, 0x11c9, \
- { 0x9f, 0xe8 }, \
- { 0x08, 0x00, \
- 0x2b, 0x10, 0x48, 0x60 } \
- }, 0x02 \
-}
-
-#define SYNT_NETLOGON_V2 \
-{ \
- { \
- 0x8a885d04, 0x1ceb, 0x11c9, \
- { 0x9f, 0xe8 }, \
- { 0x08, 0x00, \
- 0x2b, 0x10, 0x48, 0x60 } \
- }, 0x02 \
-}
-
-#define SYNT_WKSSVC_V1 \
-{ \
- { \
- 0x6bffd098, 0xa112, 0x3610, \
- { 0x98, 0x33 }, \
- { 0x46, 0xc3, \
- 0xf8, 0x7e, 0x34, 0x5a } \
- }, 0x01 \
-}
-
-#define SYNT_SRVSVC_V3 \
-{ \
- { \
- 0x4b324fc8, 0x1670, 0x01d3, \
- { 0x12, 0x78 }, \
- { 0x5a, 0x47, \
- 0xbf, 0x6e, 0xe1, 0x88 } \
- }, 0x03 \
-}
-
-#define SYNT_LSARPC_V0 \
-{ \
- { \
- 0x12345778, 0x1234, 0xabcd, \
- { 0xef, 0x00 }, \
- { 0x01, 0x23, \
- 0x45, 0x67, 0x89, 0xab } \
- }, 0x00 \
-}
-
-#define SYNT_LSARPC_V0_DS \
-{ \
- { \
- 0x3919286a, 0xb10c, 0x11d0, \
- { 0x9b, 0xa8 }, \
- { 0x00, 0xc0, \
- 0x4f, 0xd9, 0x2e, 0xf5 } \
- }, 0x00 \
-}
-
-#define SYNT_SAMR_V1 \
-{ \
- { \
- 0x12345778, 0x1234, 0xabcd, \
- { 0xef, 0x00 }, \
- { 0x01, 0x23, \
- 0x45, 0x67, 0x89, 0xac } \
- }, 0x01 \
-}
-
-#define SYNT_NETLOGON_V1 \
-{ \
- { \
- 0x12345678, 0x1234, 0xabcd, \
- { 0xef, 0x00 }, \
- { 0x01, 0x23, \
- 0x45, 0x67, 0xcf, 0xfb } \
- }, 0x01 \
-}
-
-#define SYNT_WINREG_V1 \
-{ \
- { \
- 0x338cd001, 0x2244, 0x31f1, \
- { 0xaa, 0xaa }, \
- { 0x90, 0x00, \
- 0x38, 0x00, 0x10, 0x03 } \
- }, 0x01 \
-}
-
-#define SYNT_SPOOLSS_V1 \
-{ \
- { \
- 0x12345678, 0x1234, 0xabcd, \
- { 0xef, 0x00 }, \
- { 0x01, 0x23, \
- 0x45, 0x67, 0x89, 0xab } \
- }, 0x01 \
-}
-
-#define SYNT_NONE_V0 \
-{ \
- { \
- 0x0, 0x0, 0x0, \
- { 0x00, 0x00 }, \
- { 0x00, 0x00, \
- 0x00, 0x00, 0x00, 0x00 } \
- }, 0x00 \
-}
-
-#define SYNT_NETDFS_V3 \
-{ \
- { \
- 0x4fc742e0, 0x4a10, 0x11cf, \
- { 0x82, 0x73 }, \
- { 0x00, 0xaa, \
- 0x00, 0x4a, 0xe6, 0x73 } \
- }, 0x03 \
-}
-
-#define SYNT_ECHO_V1 \
-{ \
- { \
- 0x60a15ec5, 0x4de8, 0x11d7, \
- { 0xa6, 0x37 }, \
- { 0x00, 0x50, \
- 0x56, 0xa2, 0x01, 0x82 } \
- }, 0x01 \
-}
-
-#define SYNT_SHUTDOWN_V1 \
-{ \
- { \
- 0x894de0c0, 0x0d55, 0x11d3, \
- { 0xa3, 0x22 }, \
- { 0x00, 0xc0, \
- 0x4f, 0xa3, 0x21, 0xa1 } \
- }, 0x01 \
-}
-
-#define SYNT_SVCCTL_V2 \
-{ \
- { \
- 0x367abb81, 0x9844, 0x35f1, \
- { 0xad, 0x32 }, \
- { 0x98, 0xf0, \
- 0x38, 0x00, 0x10, 0x03 } \
- }, 0x02 \
-}
-
-
-#define SYNT_EVENTLOG_V0 \
-{ \
- { \
- 0x82273fdc, 0xe32a, 0x18c3, \
- { 0x3f, 0x78 }, \
- { 0x82, 0x79, \
- 0x29, 0xdc, 0x23, 0xea } \
- }, 0x00 \
-}
-
-#define SYNT_NTSVCS_V1 \
-{ \
- { \
- 0x8d9f4e40, 0xa03d, 0x11ce, \
- { 0x8f, 0x69}, \
- { 0x08, 0x00, \
- 0x3e, 0x30, 0x05, 0x1b } \
- }, 0x01 \
-}
+const struct ndr_syntax_id syntax_spoolss = {
+ {
+ 0x12345678, 0x1234, 0xabcd,
+ { 0xef, 0x00 },
+ { 0x01, 0x23,
+ 0x45, 0x67, 0x89, 0xab }
+ }, 0x01
+};
/*
* IMPORTANT!! If you update this structure, make sure to
@@ -207,22 +45,21 @@ interface/version dce/rpc pipe identification
const struct pipe_id_info pipe_names [] =
{
- /* client pipe , abstract syntax , server pipe , transfer syntax */
- { PIPE_LSARPC , SYNT_LSARPC_V0 , PIPE_LSASS , TRANS_SYNT_V2 },
- { PIPE_LSARPC , SYNT_LSARPC_V0_DS , PIPE_LSASS , TRANS_SYNT_V2 },
- { PIPE_SAMR , SYNT_SAMR_V1 , PIPE_LSASS , TRANS_SYNT_V2 },
- { PIPE_NETLOGON, SYNT_NETLOGON_V1 , PIPE_LSASS , TRANS_SYNT_V2 },
- { PIPE_SRVSVC , SYNT_SRVSVC_V3 , PIPE_NTSVCS , TRANS_SYNT_V2 },
- { PIPE_WKSSVC , SYNT_WKSSVC_V1 , PIPE_NTSVCS , TRANS_SYNT_V2 },
- { PIPE_WINREG , SYNT_WINREG_V1 , PIPE_WINREG , TRANS_SYNT_V2 },
- { PIPE_SPOOLSS , SYNT_SPOOLSS_V1 , PIPE_SPOOLSS , TRANS_SYNT_V2 },
- { PIPE_NETDFS , SYNT_NETDFS_V3 , PIPE_NETDFS , TRANS_SYNT_V2 },
- { PIPE_ECHO , SYNT_ECHO_V1 , PIPE_ECHO , TRANS_SYNT_V2 },
- { PIPE_SHUTDOWN, SYNT_SHUTDOWN_V1 , PIPE_SHUTDOWN , TRANS_SYNT_V2 },
- { PIPE_SVCCTL , SYNT_SVCCTL_V2 , PIPE_NTSVCS , TRANS_SYNT_V2 },
- { PIPE_EVENTLOG, SYNT_EVENTLOG_V0 , PIPE_EVENTLOG , TRANS_SYNT_V2 },
- { PIPE_NTSVCS , SYNT_NTSVCS_V1 , PIPE_NTSVCS , TRANS_SYNT_V2 },
- { NULL , SYNT_NONE_V0 , NULL , SYNT_NONE_V0 }
+ { PIPE_LSARPC , &ndr_table_lsarpc.syntax_id, PIPE_LSASS , &ndr_transfer_syntax },
+ { PIPE_LSARPC , &ndr_table_dssetup.syntax_id, PIPE_LSASS , &ndr_transfer_syntax },
+ { PIPE_SAMR , &ndr_table_samr.syntax_id, PIPE_LSASS , &ndr_transfer_syntax },
+ { PIPE_NETLOGON, &ndr_table_netlogon.syntax_id, PIPE_LSASS , &ndr_transfer_syntax },
+ { PIPE_SRVSVC , &ndr_table_srvsvc.syntax_id, PIPE_NTSVCS , &ndr_transfer_syntax },
+ { PIPE_WKSSVC , &ndr_table_wkssvc.syntax_id, PIPE_NTSVCS , &ndr_transfer_syntax },
+ { PIPE_WINREG , &ndr_table_winreg.syntax_id, PIPE_WINREG , &ndr_transfer_syntax },
+ { PIPE_SPOOLSS , &syntax_spoolss , PIPE_SPOOLSS , &ndr_transfer_syntax },
+ { PIPE_NETDFS , &ndr_table_netdfs.syntax_id, PIPE_NETDFS , &ndr_transfer_syntax },
+ { PIPE_ECHO , &ndr_table_rpcecho.syntax_id, PIPE_ECHO , &ndr_transfer_syntax },
+ { PIPE_SHUTDOWN, &ndr_table_initshutdown.syntax_id, PIPE_SHUTDOWN , &ndr_transfer_syntax },
+ { PIPE_SVCCTL , &ndr_table_svcctl.syntax_id, PIPE_NTSVCS , &ndr_transfer_syntax },
+ { PIPE_EVENTLOG, &ndr_table_eventlog.syntax_id, PIPE_EVENTLOG , &ndr_transfer_syntax },
+ { PIPE_NTSVCS , &ndr_table_ntsvcs.syntax_id, PIPE_NTSVCS , &ndr_transfer_syntax },
+ { NULL , NULL , NULL , NULL }
};
/****************************************************************************
@@ -234,6 +71,21 @@ const char *cli_get_pipe_name(int pipe_idx)
return &pipe_names[pipe_idx].client_pipe[5];
}
+/****************************************************************************
+ Return the pipe idx from the syntax.
+ ****************************************************************************/
+int cli_get_pipe_idx(const RPC_IFACE *syntax)
+{
+ int i;
+ for (i = 0; pipe_names[i].client_pipe; i++) {
+ if (GUID_equal(&pipe_names[i].abstr_syntax->uuid, &syntax->uuid) &&
+ pipe_names[i].abstr_syntax->if_version == syntax->if_version)
+ return i;
+ }
+
+ return -1;
+}
+
/*******************************************************************
Inits an RPC_HDR structure.
********************************************************************/
@@ -326,7 +178,7 @@ static bool smb_io_rpc_iface(const char *desc, RPC_IFACE *ifc, prs_struct *ps, i
if (!smb_io_uuid( "uuid", &ifc->uuid, ps, depth))
return False;
- if(!prs_uint32 ("version", ps, depth, &ifc->version))
+ if(!prs_uint32 ("version", ps, depth, &ifc->if_version))
return False;
return True;
@@ -400,7 +252,8 @@ static bool smb_io_rpc_hdr_bba(const char *desc, RPC_HDR_BBA *rpc, prs_struct *
Note the transfer pointer must remain valid until this is marshalled.
********************************************************************/
-void init_rpc_context(RPC_CONTEXT *rpc_ctx, uint16 context_id, RPC_IFACE *abstract, RPC_IFACE *transfer)
+void init_rpc_context(RPC_CONTEXT *rpc_ctx, uint16 context_id,
+ const RPC_IFACE *abstract, const RPC_IFACE *transfer)
{
rpc_ctx->context_id = context_id ; /* presentation context identifier (0x0) */
rpc_ctx->num_transfer_syntaxes = 1 ; /* the number of syntaxes (has always been 1?)(0x1) */
@@ -409,7 +262,7 @@ void init_rpc_context(RPC_CONTEXT *rpc_ctx, uint16 context_id, RPC_IFACE *abstra
rpc_ctx->abstract = *abstract;
/* vers. of interface to use for replies */
- rpc_ctx->transfer = transfer;
+ rpc_ctx->transfer = CONST_DISCARD(RPC_IFACE *, transfer);
}
/*******************************************************************
diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c
index 4ac9f7a6f4..52e4fdfd5b 100644
--- a/source3/rpc_server/srv_pipe.c
+++ b/source3/rpc_server/srv_pipe.c
@@ -986,10 +986,10 @@ bool check_bind_req(struct pipes_struct *p, RPC_IFACE* abstract,
for ( i=0; pipe_names[i].client_pipe; i++ ) {
DEBUGADD(10,("checking %s\n", pipe_names[i].client_pipe));
if ( strequal(pipe_names[i].client_pipe, pname)
- && (abstract->version == pipe_names[i].abstr_syntax.version)
- && (memcmp(&abstract->uuid, &pipe_names[i].abstr_syntax.uuid, sizeof(struct GUID)) == 0)
- && (transfer->version == pipe_names[i].trans_syntax.version)
- && (memcmp(&transfer->uuid, &pipe_names[i].trans_syntax.uuid, sizeof(struct GUID)) == 0) ) {
+ && (abstract->if_version == pipe_names[i].abstr_syntax->if_version)
+ && (memcmp(&abstract->uuid, &pipe_names[i].abstr_syntax->uuid, sizeof(struct GUID)) == 0)
+ && (transfer->if_version == pipe_names[i].trans_syntax->if_version)
+ && (memcmp(&transfer->uuid, &pipe_names[i].trans_syntax->uuid, sizeof(struct GUID)) == 0) ) {
struct api_struct *fns = NULL;
int n_fns = 0;
PIPE_RPC_FNS *context_fns;
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c
index 7788e763fa..4c5fcf5341 100644
--- a/source3/rpc_server/srv_spoolss_nt.c
+++ b/source3/rpc_server/srv_spoolss_nt.c
@@ -164,7 +164,7 @@ static void srv_spoolss_replycloseprinter(int snum, POLICY_HND *handle)
/* if it's the last connection, deconnect the IPC$ share */
if (smb_connections==1) {
- cli_shutdown( notify_cli_pipe->cli );
+ cli_shutdown( rpc_pipe_np_smb_conn(notify_cli_pipe) );
notify_cli_pipe = NULL; /* The above call shuts downn the pipe also. */
messaging_deregister(smbd_messaging_context(),
@@ -2609,10 +2609,6 @@ static bool spoolss_connect_to_client(struct rpc_pipe_client **pp_pipe,
return False;
}
- /* make sure to save the cli_state pointer. Keep its own talloc_ctx */
-
- (*pp_pipe)->cli = the_cli;
-
return True;
}
diff --git a/source3/rpc_server/srv_wkssvc_nt.c b/source3/rpc_server/srv_wkssvc_nt.c
index 71f1960a67..3c006fd655 100644
--- a/source3/rpc_server/srv_wkssvc_nt.c
+++ b/source3/rpc_server/srv_wkssvc_nt.c
@@ -406,6 +406,7 @@ WERROR _wkssvc_NetrUnjoinDomain2(pipes_struct *p,
u->in.admin_account = admin_account;
u->in.admin_password = cleartext_pwd;
u->in.debug = true;
+ u->in.modify_config = lp_config_backend_is_registry();
become_root();
werr = libnet_Unjoin(p->mem_ctx, u);
diff --git a/source3/rpcclient/cmd_lsarpc.c b/source3/rpcclient/cmd_lsarpc.c
index 0d530ceaf2..88e49546b1 100644
--- a/source3/rpcclient/cmd_lsarpc.c
+++ b/source3/rpcclient/cmd_lsarpc.c
@@ -1137,7 +1137,7 @@ static NTSTATUS cmd_lsa_get_username(struct rpc_pipe_client *cli,
{
POLICY_HND pol;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
- const char *servername = cli->cli->desthost;
+ const char *servername = cli->desthost;
struct lsa_String *account_name = NULL;
struct lsa_String *authority_name = NULL;
diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c
index 95d79b5825..12d8cf3052 100644
--- a/source3/rpcclient/cmd_netlogon.c
+++ b/source3/rpcclient/cmd_netlogon.c
@@ -28,7 +28,7 @@ static WERROR cmd_netlogon_logon_ctrl2(struct rpc_pipe_client *cli,
{
NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
WERROR werr;
- const char *logon_server = cli->cli->desthost;
+ const char *logon_server = cli->desthost;
enum netr_LogonControlCode function_code = NETLOGON_CONTROL_REDISCOVER;
uint32_t level = 1;
union netr_CONTROL_DATA_INFORMATION data;
@@ -101,14 +101,15 @@ static WERROR cmd_netlogon_getanydcname(struct rpc_pipe_client *cli,
}
/* Make sure to wait for our DC's reply */
- old_timeout = cli_set_timeout(cli->cli, MAX(cli->cli->timeout,30000)); /* 30 seconds. */
+ old_timeout = rpccli_set_timeout(cli, 30000); /* 30 seconds. */
+ rpccli_set_timeout(cli, MAX(old_timeout, 30000)); /* At least 30 sec */
status = rpccli_netr_GetAnyDCName(cli, mem_ctx,
- cli->cli->desthost,
+ cli->desthost,
argv[1],
&dcname,
&werr);
- cli_set_timeout(cli->cli, old_timeout);
+ rpccli_set_timeout(cli, old_timeout);
if (!NT_STATUS_IS_OK(status)) {
return ntstatus_to_werror(status);
@@ -140,14 +141,15 @@ static WERROR cmd_netlogon_getdcname(struct rpc_pipe_client *cli,
}
/* Make sure to wait for our DC's reply */
- old_timeout = cli_set_timeout(cli->cli, MAX(cli->cli->timeout,30000)); /* 30 seconds. */
+ old_timeout = rpccli_set_timeout(cli, 30000); /* 30 seconds. */
+ rpccli_set_timeout(cli, MAX(30000, old_timeout)); /* At least 30 sec */
status = rpccli_netr_GetDcName(cli, mem_ctx,
- cli->cli->desthost,
+ cli->desthost,
argv[1],
&dcname,
&werr);
- cli_set_timeout(cli->cli, old_timeout);
+ rpccli_set_timeout(cli, old_timeout);
if (!NT_STATUS_IS_OK(status)) {
return ntstatus_to_werror(status);
@@ -171,7 +173,7 @@ static WERROR cmd_netlogon_dsr_getdcname(struct rpc_pipe_client *cli,
NTSTATUS result;
WERROR werr = WERR_OK;
uint32 flags = DS_RETURN_DNS_NAME;
- const char *server_name = cli->cli->desthost;
+ const char *server_name = cli->desthost;
const char *domain_name;
struct GUID domain_guid = GUID_zero();
struct GUID site_guid = GUID_zero();
@@ -231,7 +233,7 @@ static WERROR cmd_netlogon_dsr_getdcnameex(struct rpc_pipe_client *cli,
WERROR result;
NTSTATUS status;
uint32_t flags = DS_RETURN_DNS_NAME;
- const char *server_name = cli->cli->desthost;
+ const char *server_name = cli->desthost;
const char *domain_name;
const char *site_name = NULL;
struct GUID domain_guid = GUID_zero();
@@ -290,7 +292,7 @@ static WERROR cmd_netlogon_dsr_getdcnameex2(struct rpc_pipe_client *cli,
WERROR result;
NTSTATUS status;
uint32_t flags = DS_RETURN_DNS_NAME;
- const char *server_name = cli->cli->desthost;
+ const char *server_name = cli->desthost;
const char *domain_name = NULL;
const char *client_account = NULL;
uint32_t mask = 0;
@@ -396,7 +398,7 @@ static WERROR cmd_netlogon_logon_ctrl(struct rpc_pipe_client *cli,
{
NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
WERROR werr;
- const char *logon_server = cli->cli->desthost;
+ const char *logon_server = cli->desthost;
enum netr_LogonControlCode function_code = 1;
uint32_t level = 1;
union netr_CONTROL_QUERY_INFORMATION info;
@@ -560,7 +562,7 @@ static NTSTATUS cmd_netlogon_sam_sync(struct rpc_pipe_client *cli,
const char **argv)
{
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
- const char *logon_server = cli->cli->desthost;
+ const char *logon_server = cli->desthost;
const char *computername = global_myname();
struct netr_Authenticator credential;
struct netr_Authenticator return_authenticator;
@@ -625,7 +627,7 @@ static NTSTATUS cmd_netlogon_sam_deltas(struct rpc_pipe_client *cli,
{
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
uint32_t tmp;
- const char *logon_server = cli->cli->desthost;
+ const char *logon_server = cli->desthost;
const char *computername = global_myname();
struct netr_Authenticator credential;
struct netr_Authenticator return_authenticator;
@@ -759,7 +761,7 @@ static WERROR cmd_netlogon_gettrustrid(struct rpc_pipe_client *cli,
{
NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
WERROR werr = WERR_GENERAL_FAILURE;
- const char *server_name = cli->cli->desthost;
+ const char *server_name = cli->desthost;
const char *domain_name = lp_workgroup();
uint32_t rid = 0;
@@ -799,7 +801,7 @@ static WERROR cmd_netlogon_dsr_enumtrustdom(struct rpc_pipe_client *cli,
{
NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
WERROR werr = WERR_GENERAL_FAILURE;
- const char *server_name = cli->cli->desthost;
+ const char *server_name = cli->desthost;
uint32_t trust_flags = NETR_TRUST_FLAG_IN_FOREST;
struct netr_DomainTrustList trusts;
@@ -847,7 +849,7 @@ static WERROR cmd_netlogon_deregisterdnsrecords(struct rpc_pipe_client *cli,
{
NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
WERROR werr = WERR_GENERAL_FAILURE;
- const char *server_name = cli->cli->desthost;
+ const char *server_name = cli->desthost;
const char *domain = lp_workgroup();
const char *dns_host = NULL;
@@ -893,7 +895,7 @@ static WERROR cmd_netlogon_dsr_getforesttrustinfo(struct rpc_pipe_client *cli,
{
NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
WERROR werr = WERR_GENERAL_FAILURE;
- const char *server_name = cli->cli->desthost;
+ const char *server_name = cli->desthost;
const char *trusted_domain_name = NULL;
struct lsa_ForestTrustInformation *info = NULL;
uint32_t flags = 0;
@@ -939,7 +941,7 @@ static WERROR cmd_netlogon_enumtrusteddomains(struct rpc_pipe_client *cli,
{
NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
WERROR werr = WERR_GENERAL_FAILURE;
- const char *server_name = cli->cli->desthost;
+ const char *server_name = cli->desthost;
struct netr_Blob blob;
@@ -974,7 +976,7 @@ static WERROR cmd_netlogon_enumtrusteddomainsex(struct rpc_pipe_client *cli,
{
NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
WERROR werr = WERR_GENERAL_FAILURE;
- const char *server_name = cli->cli->desthost;
+ const char *server_name = cli->desthost;
struct netr_DomainTrustList list;
if (argc < 1 || argc > 3) {
diff --git a/source3/rpcclient/cmd_samr.c b/source3/rpcclient/cmd_samr.c
index e58354d0d3..4a820cd618 100644
--- a/source3/rpcclient/cmd_samr.c
+++ b/source3/rpcclient/cmd_samr.c
@@ -735,13 +735,14 @@ static NTSTATUS cmd_samr_query_groupmem(struct rpc_pipe_client *cli,
goto done;
/* Make sure to wait for our DC's reply */
- old_timeout = cli_set_timeout(cli->cli, MAX(cli->cli->timeout,30000)); /* 30 seconds. */
+ old_timeout = rpccli_set_timeout(cli, 30000); /* 30 seconds. */
+ rpccli_set_timeout(cli, MAX(30000, old_timeout)); /* At least 30 sec */
result = rpccli_samr_QueryGroupMember(cli, mem_ctx,
&group_pol,
&rids);
- cli_set_timeout(cli->cli, old_timeout);
+ rpccli_set_timeout(cli, old_timeout);
if (!NT_STATUS_IS_OK(result))
goto done;
diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c
index 7530ab1911..c89f987446 100644
--- a/source3/rpcclient/cmd_spoolss.c
+++ b/source3/rpcclient/cmd_spoolss.c
@@ -109,7 +109,7 @@ static WERROR cmd_spoolss_open_printer_ex(struct rpc_pipe_client *cli,
if (!cli)
return WERR_GENERAL_FAILURE;
- slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->cli->desthost);
+ slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost);
strupper_m(servername);
fstrcpy(user, cli->user_name);
fstrcpy(printername, argv[1]);
@@ -317,7 +317,7 @@ static WERROR cmd_spoolss_enum_printers(struct rpc_pipe_client *cli,
if (argc == 3)
fstrcpy(name, argv[2]);
else {
- slprintf(name, sizeof(name)-1, "\\\\%s", cli->cli->desthost);
+ slprintf(name, sizeof(name)-1, "\\\\%s", cli->desthost);
strupper_m(name);
}
@@ -488,7 +488,7 @@ static WERROR cmd_spoolss_setprinter(struct rpc_pipe_client *cli,
fstrcpy(comment, argv[2]);
}
- slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->cli->desthost);
+ slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost);
strupper_m(servername);
slprintf(printername, sizeof(servername)-1, "%s\\%s", servername, argv[1]);
fstrcpy(user, cli->user_name);
@@ -554,7 +554,7 @@ static WERROR cmd_spoolss_setprintername(struct rpc_pipe_client *cli,
fstrcpy(new_printername, argv[2]);
}
- slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->cli->desthost);
+ slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost);
strupper_m(servername);
slprintf(printername, sizeof(printername)-1, "%s\\%s", servername, argv[1]);
fstrcpy(user, cli->user_name);
@@ -617,7 +617,7 @@ static WERROR cmd_spoolss_getprinter(struct rpc_pipe_client *cli,
info_level = atoi(argv[2]);
}
- slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->cli->desthost);
+ slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost);
strupper_m(servername);
slprintf(printername, sizeof(printername)-1, "%s\\%s", servername, argv[1]);
fstrcpy(user, cli->user_name);
@@ -756,7 +756,7 @@ static WERROR cmd_spoolss_getprinterdata(struct rpc_pipe_client *cli,
/* Open a printer handle */
- slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->cli->desthost);
+ slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost);
strupper_m(servername);
if (strncmp(argv[1], ".", sizeof(".")) == 0)
fstrcpy(printername, servername);
@@ -823,7 +823,7 @@ static WERROR cmd_spoolss_getprinterdataex(struct rpc_pipe_client *cli,
/* Open a printer handle */
- slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->cli->desthost);
+ slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost);
strupper_m(servername);
if (strncmp(argv[1], ".", sizeof(".")) == 0)
fstrcpy(printername, servername);
@@ -999,7 +999,7 @@ static WERROR cmd_spoolss_getdriver(struct rpc_pipe_client *cli,
}
/* get the arguments need to open the printer handle */
- slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->cli->desthost);
+ slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost);
strupper_m(servername);
fstrcpy(user, cli->user_name);
slprintf(printername, sizeof(servername)-1, "%s\\%s", servername, argv[1]);
@@ -1382,7 +1382,7 @@ static WERROR cmd_spoolss_addprinterex(struct rpc_pipe_client *cli,
return WERR_OK;
}
- slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->cli->desthost);
+ slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost);
strupper_m(servername);
/* Fill in the DRIVER_INFO_2 struct */
@@ -1444,7 +1444,7 @@ static WERROR cmd_spoolss_setdriver(struct rpc_pipe_client *cli,
return WERR_OK;
}
- slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->cli->desthost);
+ slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost);
strupper_m(servername);
slprintf(printername, sizeof(printername)-1, "%s\\%s", servername, argv[1]);
fstrcpy(user, cli->user_name);
@@ -1570,7 +1570,7 @@ static WERROR cmd_spoolss_deletedriver(struct rpc_pipe_client *cli,
return WERR_OK;
}
- slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->cli->desthost);
+ slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost);
strupper_m(servername);
/* delete the driver for all architectures */
@@ -1611,7 +1611,7 @@ static WERROR cmd_spoolss_getprintprocdir(struct rpc_pipe_client *cli,
return WERR_OK;
}
- if (asprintf(&servername, "\\\\%s", cli->cli->desthost) < 0)
+ if (asprintf(&servername, "\\\\%s", cli->desthost) < 0)
return WERR_NOMEM;
strupper_m(servername);
@@ -1654,7 +1654,7 @@ static WERROR cmd_spoolss_addform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c
/* Get a printer handle */
- asprintf(&servername, "\\\\%s", cli->cli->desthost);
+ asprintf(&servername, "\\\\%s", cli->desthost);
strupper_m(servername);
asprintf(&printername, "%s\\%s", servername, argv[1]);
@@ -1714,7 +1714,7 @@ static WERROR cmd_spoolss_setform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c
/* Get a printer handle */
- asprintf(&servername, "\\\\%s", cli->cli->desthost);
+ asprintf(&servername, "\\\\%s", cli->desthost);
strupper_m(servername);
asprintf(&printername, "%s\\%s", servername, argv[1]);
@@ -1811,7 +1811,7 @@ static WERROR cmd_spoolss_getform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c
/* Get a printer handle */
- asprintf(&servername, "\\\\%s", cli->cli->desthost);
+ asprintf(&servername, "\\\\%s", cli->desthost);
strupper_m(servername);
asprintf(&printername, "%s\\%s", servername, argv[1]);
@@ -1864,7 +1864,7 @@ static WERROR cmd_spoolss_deleteform(struct rpc_pipe_client *cli,
/* Get a printer handle */
- asprintf(&servername, "\\\\%s", cli->cli->desthost);
+ asprintf(&servername, "\\\\%s", cli->desthost);
strupper_m(servername);
asprintf(&printername, "%s\\%s", servername, argv[1]);
@@ -1914,7 +1914,7 @@ static WERROR cmd_spoolss_enum_forms(struct rpc_pipe_client *cli,
/* Get a printer handle */
- asprintf(&servername, "\\\\%s", cli->cli->desthost);
+ asprintf(&servername, "\\\\%s", cli->desthost);
strupper_m(servername);
asprintf(&printername, "%s\\%s", servername, argv[1]);
@@ -1977,7 +1977,7 @@ static WERROR cmd_spoolss_setprinterdata(struct rpc_pipe_client *cli,
goto done;
}
- slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->cli->desthost);
+ slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost);
strupper_m(servername);
slprintf(printername, sizeof(servername)-1, "%s\\%s", servername, argv[1]);
fstrcpy(user, cli->user_name);
@@ -2187,12 +2187,10 @@ static WERROR cmd_spoolss_enum_jobs(struct rpc_pipe_client *cli,
/* Open printer handle */
- slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->cli->desthost);
+ slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost);
strupper_m(servername);
fstrcpy(user, cli->user_name);
- printername = talloc_asprintf(mem_ctx,
- "\\\\%s\\",
- cli->cli->desthost);
+ printername = talloc_asprintf(mem_ctx, "\\\\%s\\", cli->desthost);
if (!printername) {
return WERR_NOMEM;
}
@@ -2261,12 +2259,10 @@ static WERROR cmd_spoolss_enum_data( struct rpc_pipe_client *cli,
/* Open printer handle */
- slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->cli->desthost);
+ slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost);
strupper_m(servername);
fstrcpy(user, cli->user_name);
- printername = talloc_asprintf(mem_ctx,
- "\\\\%s\\",
- cli->cli->desthost);
+ printername = talloc_asprintf(mem_ctx, "\\\\%s\\", cli->desthost);
if (!printername) {
return WERR_NOMEM;
}
@@ -2333,13 +2329,11 @@ static WERROR cmd_spoolss_enum_data_ex( struct rpc_pipe_client *cli,
/* Open printer handle */
- slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->cli->desthost);
+ slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost);
strupper_m(servername);
fstrcpy(user, cli->user_name);
- printername = talloc_asprintf(mem_ctx,
- "\\\\%s\\",
- cli->cli->desthost);
+ printername = talloc_asprintf(mem_ctx, "\\\\%s\\", cli->desthost);
if (!printername) {
return WERR_NOMEM;
}
@@ -2408,13 +2402,11 @@ static WERROR cmd_spoolss_enum_printerkey( struct rpc_pipe_client *cli,
/* Open printer handle */
- slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->cli->desthost);
+ slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost);
strupper_m(servername);
fstrcpy(user, cli->user_name);
- printername = talloc_asprintf(mem_ctx,
- "\\\\%s\\",
- cli->cli->desthost);
+ printername = talloc_asprintf(mem_ctx, "\\\\%s\\", cli->desthost);
if (!printername) {
return WERR_NOMEM;
}
@@ -2484,11 +2476,11 @@ static WERROR cmd_spoolss_rffpcnex(struct rpc_pipe_client *cli,
/* Open printer */
- slprintf(servername, sizeof(servername) - 1, "\\\\%s", cli->cli->desthost);
+ slprintf(servername, sizeof(servername) - 1, "\\\\%s", cli->desthost);
strupper_m(servername);
- slprintf(printername, sizeof(printername) - 1, "\\\\%s\\%s", cli->cli->desthost,
- argv[1]);
+ slprintf(printername, sizeof(printername) - 1, "\\\\%s\\%s",
+ cli->desthost, argv[1]);
strupper_m(printername);
result = rpccli_spoolss_open_printer_ex(
@@ -2558,7 +2550,7 @@ static bool compare_printer( struct rpc_pipe_client *cli1, POLICY_HND *hnd1,
WERROR werror;
TALLOC_CTX *mem_ctx = talloc_init("compare_printer");
- printf("Retrieving printer propertiesfor %s...", cli1->cli->desthost);
+ printf("Retrieving printer propertiesfor %s...", cli1->desthost);
werror = rpccli_spoolss_getprinter( cli1, mem_ctx, hnd1, 2, &ctr1);
if ( !W_ERROR_IS_OK(werror) ) {
printf("failed (%s)\n", dos_errstr(werror));
@@ -2567,7 +2559,7 @@ static bool compare_printer( struct rpc_pipe_client *cli1, POLICY_HND *hnd1,
}
printf("ok\n");
- printf("Retrieving printer properties for %s...", cli2->cli->desthost);
+ printf("Retrieving printer properties for %s...", cli2->desthost);
werror = rpccli_spoolss_getprinter( cli2, mem_ctx, hnd2, 2, &ctr2);
if ( !W_ERROR_IS_OK(werror) ) {
printf("failed (%s)\n", dos_errstr(werror));
@@ -2594,7 +2586,7 @@ static bool compare_printer_secdesc( struct rpc_pipe_client *cli1, POLICY_HND *h
bool result = True;
- printf("Retreiving printer security for %s...", cli1->cli->desthost);
+ printf("Retrieving printer security for %s...", cli1->desthost);
werror = rpccli_spoolss_getprinter( cli1, mem_ctx, hnd1, 3, &ctr1);
if ( !W_ERROR_IS_OK(werror) ) {
printf("failed (%s)\n", dos_errstr(werror));
@@ -2603,7 +2595,7 @@ static bool compare_printer_secdesc( struct rpc_pipe_client *cli1, POLICY_HND *h
}
printf("ok\n");
- printf("Retrieving printer security for %s...", cli2->cli->desthost);
+ printf("Retrieving printer security for %s...", cli2->desthost);
werror = rpccli_spoolss_getprinter( cli2, mem_ctx, hnd2, 3, &ctr2);
if ( !W_ERROR_IS_OK(werror) ) {
printf("failed (%s)\n", dos_errstr(werror));
@@ -2653,7 +2645,7 @@ static WERROR cmd_spoolss_printercmp(struct rpc_pipe_client *cli,
{
fstring printername, servername1, servername2;
char *printername_path = NULL;
- struct cli_state *cli_server1 = cli->cli;
+ struct cli_state *cli_server1 = rpc_pipe_np_smb_conn(cli);
struct cli_state *cli_server2 = NULL;
struct rpc_pipe_client *cli2 = NULL;
POLICY_HND hPrinter1, hPrinter2;
@@ -2667,7 +2659,7 @@ static WERROR cmd_spoolss_printercmp(struct rpc_pipe_client *cli,
fstrcpy( printername, argv[1] );
- fstrcpy( servername1, cli->cli->desthost );
+ fstrcpy( servername1, cli->desthost );
fstrcpy( servername2, argv[2] );
strupper_m( servername1 );
strupper_m( servername2 );
diff --git a/source3/rpcclient/cmd_srvsvc.c b/source3/rpcclient/cmd_srvsvc.c
index 070fb36e30..9efd4c9792 100644
--- a/source3/rpcclient/cmd_srvsvc.c
+++ b/source3/rpcclient/cmd_srvsvc.c
@@ -183,7 +183,7 @@ static WERROR cmd_srvsvc_srv_query_info(struct rpc_pipe_client *cli,
info_level = atoi(argv[1]);
server_name = talloc_asprintf_strupper_m(mem_ctx, "\\\\%s",
- cli->cli->desthost);
+ cli->desthost);
W_ERROR_HAVE_NO_MEMORY(server_name);
status = rpccli_srvsvc_NetSrvGetInfo(cli, mem_ctx,
@@ -336,7 +336,7 @@ static WERROR cmd_srvsvc_net_share_enum_int(struct rpc_pipe_client *cli,
switch (opcode) {
case NDR_SRVSVC_NETSHAREENUM:
status = rpccli_srvsvc_NetShareEnum(cli, mem_ctx,
- cli->cli->desthost,
+ cli->desthost,
&info_ctr,
preferred_len,
&totalentries,
@@ -345,7 +345,7 @@ static WERROR cmd_srvsvc_net_share_enum_int(struct rpc_pipe_client *cli,
break;
case NDR_SRVSVC_NETSHAREENUMALL:
status = rpccli_srvsvc_NetShareEnumAll(cli, mem_ctx,
- cli->cli->desthost,
+ cli->desthost,
&info_ctr,
preferred_len,
&totalentries,
@@ -420,7 +420,7 @@ static WERROR cmd_srvsvc_net_share_get_info(struct rpc_pipe_client *cli,
info_level = atoi(argv[2]);
status = rpccli_srvsvc_NetShareGetInfo(cli, mem_ctx,
- cli->cli->desthost,
+ cli->desthost,
argv[1],
info_level,
&info,
@@ -468,7 +468,7 @@ static WERROR cmd_srvsvc_net_share_set_info(struct rpc_pipe_client *cli,
/* retrieve share info */
status = rpccli_srvsvc_NetShareGetInfo(cli, mem_ctx,
- cli->cli->desthost,
+ cli->desthost,
argv[1],
info_level,
&info_get,
@@ -482,7 +482,7 @@ static WERROR cmd_srvsvc_net_share_set_info(struct rpc_pipe_client *cli,
/* set share info */
status = rpccli_srvsvc_NetShareSetInfo(cli, mem_ctx,
- cli->cli->desthost,
+ cli->desthost,
argv[1],
info_level,
&info_get,
@@ -495,7 +495,7 @@ static WERROR cmd_srvsvc_net_share_set_info(struct rpc_pipe_client *cli,
/* re-retrieve share info and display */
status = rpccli_srvsvc_NetShareGetInfo(cli, mem_ctx,
- cli->cli->desthost,
+ cli->desthost,
argv[1],
info_level,
&info_get,
@@ -525,7 +525,7 @@ static WERROR cmd_srvsvc_net_remote_tod(struct rpc_pipe_client *cli,
}
status = rpccli_srvsvc_NetRemoteTOD(cli, mem_ctx,
- cli->cli->srv_name_slash,
+ cli->srv_name_slash,
&tod,
&result);
if (!NT_STATUS_IS_OK(status)) {
@@ -568,7 +568,7 @@ static WERROR cmd_srvsvc_net_file_enum(struct rpc_pipe_client *cli,
info_ctr.ctr.ctr3 = &ctr3;
status = rpccli_srvsvc_NetFileEnum(cli, mem_ctx,
- cli->cli->desthost,
+ cli->desthost,
NULL,
NULL,
&info_ctr,
@@ -603,7 +603,7 @@ static WERROR cmd_srvsvc_net_name_validate(struct rpc_pipe_client *cli,
}
status = rpccli_srvsvc_NetNameValidate(cli, mem_ctx,
- cli->cli->desthost,
+ cli->desthost,
argv[1],
name_type,
flags,
@@ -630,7 +630,7 @@ static WERROR cmd_srvsvc_net_file_get_sec(struct rpc_pipe_client *cli,
}
status = rpccli_srvsvc_NetGetFileSecurity(cli, mem_ctx,
- cli->cli->desthost,
+ cli->desthost,
argv[1],
argv[2],
SECINFO_DACL,
@@ -660,7 +660,7 @@ static WERROR cmd_srvsvc_net_sess_del(struct rpc_pipe_client *cli,
}
status = rpccli_srvsvc_NetSessDel(cli, mem_ctx,
- cli->cli->desthost,
+ cli->desthost,
argv[1],
argv[2],
&result);
@@ -744,7 +744,7 @@ static WERROR cmd_srvsvc_net_sess_enum(struct rpc_pipe_client *cli,
}
status = rpccli_srvsvc_NetSessEnum(cli, mem_ctx,
- cli->cli->desthost,
+ cli->desthost,
client,
user,
&info_ctr,
@@ -788,7 +788,7 @@ static WERROR cmd_srvsvc_net_disk_enum(struct rpc_pipe_client *cli,
ZERO_STRUCT(info);
status = rpccli_srvsvc_NetDiskEnum(cli, mem_ctx,
- cli->cli->desthost,
+ cli->desthost,
level,
&info,
0xffffffff,
@@ -855,7 +855,7 @@ static WERROR cmd_srvsvc_net_conn_enum(struct rpc_pipe_client *cli,
}
status = rpccli_srvsvc_NetConnEnum(cli, mem_ctx,
- cli->cli->desthost,
+ cli->desthost,
path,
&info_ctr,
0xffffffff,
diff --git a/source3/rpcclient/cmd_test.c b/source3/rpcclient/cmd_test.c
index 089d7bcaa3..dd956604cc 100644
--- a/source3/rpcclient/cmd_test.c
+++ b/source3/rpcclient/cmd_test.c
@@ -30,10 +30,12 @@ static NTSTATUS cmd_testme(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
d_printf("testme\n");
- lsa_pipe = cli_rpc_pipe_open_noauth(cli->cli, PI_LSARPC, &status);
+ lsa_pipe = cli_rpc_pipe_open_noauth(rpc_pipe_np_smb_conn(cli),
+ PI_LSARPC, &status);
if (lsa_pipe == NULL) goto done;
- samr_pipe = cli_rpc_pipe_open_noauth(cli->cli, PI_SAMR, &status);
+ samr_pipe = cli_rpc_pipe_open_noauth(rpc_pipe_np_smb_conn(cli),
+ PI_SAMR, &status);
if (samr_pipe == NULL) goto done;
status = rpccli_lsa_open_policy(lsa_pipe, mem_ctx, False,
@@ -48,8 +50,8 @@ static NTSTATUS cmd_testme(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
goto done;
done:
- if (lsa_pipe != NULL) cli_rpc_pipe_close(lsa_pipe);
- if (samr_pipe != NULL) cli_rpc_pipe_close(samr_pipe);
+ TALLOC_FREE(lsa_pipe);
+ TALLOC_FREE(samr_pipe);
return status;
}
diff --git a/source3/rpcclient/cmd_wkssvc.c b/source3/rpcclient/cmd_wkssvc.c
index 68f408cf48..fbf483bd2b 100644
--- a/source3/rpcclient/cmd_wkssvc.c
+++ b/source3/rpcclient/cmd_wkssvc.c
@@ -41,7 +41,7 @@ static WERROR cmd_wkssvc_wkstagetinfo(struct rpc_pipe_client *cli,
level = atoi(argv[1]);
}
- server_name = cli->cli->desthost;
+ server_name = cli->desthost;
status = rpccli_wkssvc_NetWkstaGetInfo(cli, mem_ctx,
server_name,
@@ -66,7 +66,7 @@ static WERROR cmd_wkssvc_getjoininformation(struct rpc_pipe_client *cli,
NTSTATUS status;
WERROR werr;
- server_name = cli->cli->desthost;
+ server_name = cli->desthost;
name_buffer = "";
status = rpccli_wkssvc_NetrGetJoinInformation(cli, mem_ctx,
@@ -90,9 +90,9 @@ static WERROR cmd_wkssvc_messagebuffersend(struct rpc_pipe_client *cli,
int argc,
const char **argv)
{
- const char *server_name = cli->cli->desthost;
- const char *message_name = cli->cli->desthost;
- const char *message_sender_name = cli->cli->desthost;
+ const char *server_name = cli->desthost;
+ const char *message_name = cli->desthost;
+ const char *message_sender_name = cli->desthost;
smb_ucs2_t *message_buffer = NULL;
size_t message_size = 0;
const char *message = "my message";
@@ -135,7 +135,7 @@ static WERROR cmd_wkssvc_enumeratecomputernames(struct rpc_pipe_client *cli,
struct wkssvc_ComputerNamesCtr *ctr = NULL;
WERROR werr;
- server_name = cli->cli->desthost;
+ server_name = cli->desthost;
if (argc >= 2) {
name_type = atoi(argv[1]);
diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c
index 52dba2291b..ebd38044b8 100644
--- a/source3/rpcclient/rpcclient.c
+++ b/source3/rpcclient/rpcclient.c
@@ -169,7 +169,7 @@ static void fetch_machine_sid(struct cli_state *cli)
sid_copy(&domain_sid, info->account_domain.sid);
rpccli_lsa_Close(lsapipe, mem_ctx, &pol);
- cli_rpc_pipe_close(lsapipe);
+ TALLOC_FREE(lsapipe);
talloc_destroy(mem_ctx);
return;
@@ -177,7 +177,7 @@ static void fetch_machine_sid(struct cli_state *cli)
error:
if (lsapipe) {
- cli_rpc_pipe_close(lsapipe);
+ TALLOC_FREE(lsapipe);
}
fprintf(stderr, "could not obtain sid for domain %s\n", cli->domain);
@@ -336,7 +336,7 @@ static NTSTATUS cmd_set_ss_level(void)
if (tmp_set->rpc_pipe->auth.auth_type != pipe_default_auth_type ||
tmp_set->rpc_pipe->auth.auth_level != pipe_default_auth_level) {
- cli_rpc_pipe_close(tmp_set->rpc_pipe);
+ TALLOC_FREE(tmp_set->rpc_pipe);
tmp_set->rpc_pipe = NULL;
}
}
@@ -420,7 +420,7 @@ static NTSTATUS cmd_timeout(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
continue;
}
- cli_set_timeout(tmp_set->rpc_pipe->cli, timeout);
+ rpccli_set_timeout(tmp_set->rpc_pipe, timeout);
}
}
}
diff --git a/source3/smbd/change_trust_pw.c b/source3/smbd/change_trust_pw.c
index 4773eeff86..227b2d6899 100644
--- a/source3/smbd/change_trust_pw.c
+++ b/source3/smbd/change_trust_pw.c
@@ -82,7 +82,8 @@ NTSTATUS change_trust_account_password( const char *domain, const char *remote_m
goto failed;
}
- nt_status = trust_pw_find_change_and_store_it(netlogon_pipe, netlogon_pipe->mem_ctx, domain);
+ nt_status = trust_pw_find_change_and_store_it(
+ netlogon_pipe, netlogon_pipe, domain);
cli_shutdown(cli);
cli = NULL;
diff --git a/source3/smbd/chgpasswd.c b/source3/smbd/chgpasswd.c
index b2b082363f..2596e73380 100644
--- a/source3/smbd/chgpasswd.c
+++ b/source3/smbd/chgpasswd.c
@@ -249,6 +249,7 @@ static int expect(int master, char *issue, char *expected)
bool match = False;
for (attempts = 0; attempts < 2; attempts++) {
+ NTSTATUS status;
if (!strequal(issue, ".")) {
if (lp_passwd_chat_debug())
DEBUG(100, ("expect: sending [%s]\n", issue));
@@ -269,7 +270,6 @@ static int expect(int master, char *issue, char *expected)
buffer[nread] = 0;
while (True) {
- NTSTATUS status;
status = read_socket_with_timeout(
master, buffer + nread, 1,
sizeof(buffer) - nread - 1,
@@ -305,8 +305,8 @@ static int expect(int master, char *issue, char *expected)
if (match)
break;
- if (len < 0) {
- DEBUG(2, ("expect: %s\n", strerror(errno)));
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(2, ("expect: %s\n", nt_errstr(status)));
return False;
}
}
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index f3ed234c87..0d1dd31cd6 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -72,13 +72,21 @@ static NTSTATUS fd_open(struct connection_struct *conn,
NTSTATUS fd_close(files_struct *fsp)
{
+ int ret;
+
if (fsp->fh->fd == -1) {
return NT_STATUS_OK; /* What we used to call a stat open. */
}
if (fsp->fh->ref_count > 1) {
return NT_STATUS_OK; /* Shared handle. Only close last reference. */
}
- return fd_close_posix(fsp);
+
+ ret = SMB_VFS_CLOSE(fsp);
+ fsp->fh->fd = -1;
+ if (ret == -1) {
+ return map_nt_error_from_unix(errno);
+ }
+ return NT_STATUS_OK;
}
/****************************************************************************
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index b71d6271f2..59bbfdbc17 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -575,8 +575,6 @@ static bool open_sockets_smbd(bool is_daemon, bool interactive, const char *smb_
MSG_SMB_INJECT_FAULT, msg_inject_fault);
#endif
- db_tdb2_setup_messaging(smbd_messaging_context(), true);
-
/* now accept incoming connections - forking a new process
for each incoming connection */
DEBUG(2,("waiting for a connection\n"));
@@ -741,17 +739,9 @@ static bool open_sockets_smbd(bool is_daemon, bool interactive, const char *smb_
sizeof(remaddr)),
false);
- /* Reset the state of the random
- * number generation system, so
- * children do not get the same random
- * numbers as each other */
-
- set_need_random_reseed();
- /* tdb needs special fork handling - remove
- * CLEAR_IF_FIRST flags */
- if (tdb_reopen_all(1) == -1) {
- DEBUG(0,("tdb_reopen_all failed.\n"));
- smb_panic("tdb_reopen_all failed");
+ if (!reinit_after_fork(smbd_messaging_context())) {
+ DEBUG(0,("reinit_after_fork() failed\n"));
+ smb_panic("reinit_after_fork() failed");
}
return True;
@@ -1103,6 +1093,8 @@ extern void build_options(bool screen);
TimeInit();
+ db_tdb2_setup_messaging(NULL, false);
+
#ifdef HAVE_SET_AUTH_PARAMETERS
set_auth_parameters(argc,argv);
#endif
@@ -1226,10 +1218,18 @@ extern void build_options(bool screen);
exit(1);
}
+ if (!lp_load_initial_only(get_dyn_CONFIGFILE())) {
+ DEBUG(0, ("error opening config file\n"));
+ exit(1);
+ }
+
+ if (smbd_messaging_context() == NULL)
+ exit(1);
+
/*
* Do this before reload_services.
*/
- db_tdb2_setup_messaging(NULL, false);
+ db_tdb2_setup_messaging(smbd_messaging_context(), true);
if (!reload_services(False))
return(-1);
@@ -1285,10 +1285,12 @@ extern void build_options(bool screen);
if (is_daemon)
pidfile_create("smbd");
- /* Setup all the TDB's - including CLEAR_IF_FIRST tdb's. */
-
- if (smbd_messaging_context() == NULL)
+ if (!reinit_after_fork(smbd_messaging_context())) {
+ DEBUG(0,("reinit_after_fork() failed\n"));
exit(1);
+ }
+
+ /* Setup all the TDB's - including CLEAR_IF_FIRST tdb's. */
if (smbd_memcache() == NULL) {
exit(1);
@@ -1344,8 +1346,10 @@ extern void build_options(bool screen);
smbd is launched via inetd and we fork a copy of
ourselves here */
- if ( is_daemon && !interactive )
- start_background_queue();
+ if (is_daemon && !interactive
+ && lp_parm_bool(-1, "smbd", "backgroundqueue", true)) {
+ start_background_queue();
+ }
if (!open_sockets_smbd(is_daemon, interactive, ports))
exit(1);
@@ -1382,13 +1386,6 @@ extern void build_options(bool screen);
/* Setup aio signal handler. */
initialize_async_io_handler();
- /*
- * For clustering, we need to re-init our ctdbd connection after the
- * fork
- */
- if (!NT_STATUS_IS_OK(messaging_reinit(smbd_messaging_context())))
- exit(1);
-
/* register our message handlers */
messaging_register(smbd_messaging_context(), NULL,
MSG_SMB_FORCE_TDIS, msg_force_tdis);
diff --git a/source3/torture/cmd_vfs.c b/source3/torture/cmd_vfs.c
index 9359b58599..28400887ef 100644
--- a/source3/torture/cmd_vfs.c
+++ b/source3/torture/cmd_vfs.c
@@ -355,7 +355,7 @@ static NTSTATUS cmd_close(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc,
return NT_STATUS_OK;
}
- ret = SMB_VFS_CLOSE(vfs->files[fd], fd);
+ ret = SMB_VFS_CLOSE(vfs->files[fd]);
if (ret == -1 )
printf("close: error=%d (%s)\n", errno, strerror(errno));
else
diff --git a/source3/utils/net.c b/source3/utils/net.c
index 5706e336de..f6851f69da 100644
--- a/source3/utils/net.c
+++ b/source3/utils/net.c
@@ -1169,6 +1169,13 @@ static struct functable net_func[] = {
rc = net_run_function(argc_new-1, argv_new+1, net_func, net_help);
DEBUG(2,("return code = %d\n", rc));
+
+ {
+ struct libnetapi_ctx *ctx = NULL;
+ libnetapi_getctx(&ctx);
+ libnetapi_free(ctx);
+ }
+
TALLOC_FREE(frame);
return rc;
}
diff --git a/source3/utils/net.h b/source3/utils/net.h
index 3a4b1da7b0..00a818a606 100644
--- a/source3/utils/net.h
+++ b/source3/utils/net.h
@@ -22,6 +22,8 @@
* include
*/
+#include "lib/netapi/netapi.h"
+
typedef NTSTATUS (*rpc_command_fn)(const DOM_SID *,
const char *,
struct cli_state *cli,
diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c
index 88051ec4a1..c8bfc2630c 100644
--- a/source3/utils/net_ads.c
+++ b/source3/utils/net_ads.c
@@ -1199,7 +1199,7 @@ int net_ads_join(int argc, const char **argv)
/* Check the short name of the domain */
- if (!strequal(lp_workgroup(), r->out.netbios_domain_name)) {
+ if (!modify_config && !strequal(lp_workgroup(), r->out.netbios_domain_name)) {
d_printf("The workgroup in %s does not match the short\n", get_dyn_CONFIGFILE());
d_printf("domain name obtained from the server.\n");
d_printf("Using the name [%s] from the server.\n", r->out.netbios_domain_name);
@@ -1209,11 +1209,16 @@ int net_ads_join(int argc, const char **argv)
d_printf("Using short domain name -- %s\n", r->out.netbios_domain_name);
- d_printf("Joined '%s' to realm '%s'\n", r->in.machine_name,
- r->out.dns_domain_name);
+ if (r->out.dns_domain_name) {
+ d_printf("Joined '%s' to realm '%s'\n", r->in.machine_name,
+ r->out.dns_domain_name);
+ } else {
+ d_printf("Joined '%s' to domain '%s'\n", r->in.machine_name,
+ r->out.netbios_domain_name);
+ }
#if defined(WITH_DNS_UPDATES)
- {
+ if (r->out.domain_is_ad) {
/* We enter this block with user creds */
ADS_STRUCT *ads_dns = NULL;
diff --git a/source3/utils/net_dom.c b/source3/utils/net_dom.c
index e88bbdb276..6e4bf14c84 100644
--- a/source3/utils/net_dom.c
+++ b/source3/utils/net_dom.c
@@ -19,7 +19,6 @@
#include "includes.h"
#include "utils/net.h"
-#include "lib/netapi/netapi.h"
static int net_dom_usage(int argc, const char **argv)
{
@@ -130,7 +129,6 @@ static int net_dom_unjoin(int argc, const char **argv)
cli_shutdown(cli);
}
- /* libnetapi_free(ctx); */
return ret;
}
@@ -244,7 +242,6 @@ static int net_dom_join(int argc, const char **argv)
cli_shutdown(cli);
}
- /* libnetapi_free(ctx); */
return ret;
}
diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c
index 5663680eb7..924398fc33 100644
--- a/source3/utils/net_rpc.c
+++ b/source3/utils/net_rpc.c
@@ -88,7 +88,7 @@ NTSTATUS net_get_remote_domain_sid(struct cli_state *cli, TALLOC_CTX *mem_ctx,
*domain_sid = info->account_domain.sid;
rpccli_lsa_Close(lsa_pipe, mem_ctx, &pol);
- cli_rpc_pipe_close(lsa_pipe);
+ TALLOC_FREE(lsa_pipe);
return NT_STATUS_OK;
}
@@ -185,7 +185,7 @@ int run_rpc_command(struct cli_state *cli_arg,
if (!(conn_flags & NET_FLAGS_NO_PIPE)) {
if (pipe_hnd) {
- cli_rpc_pipe_close(pipe_hnd);
+ TALLOC_FREE(pipe_hnd);
}
}
@@ -451,7 +451,7 @@ NTSTATUS rpc_info_internals(const DOM_SID *domain_sid,
/* Get sam policy handle */
result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
- pipe_hnd->cli->desthost,
+ pipe_hnd->desthost,
MAXIMUM_ALLOWED_ACCESS,
&connect_pol);
if (!NT_STATUS_IS_OK(result)) {
@@ -571,156 +571,6 @@ static int rpc_user_usage(int argc, const char **argv)
/**
* Add a new user to a remote RPC server
*
- * All parameters are provided by the run_rpc_command function, except for
- * argc, argv which are passes through.
- *
- * @param domain_sid The domain sid acquired from the remote server
- * @param cli A cli_state connected to the server.
- * @param mem_ctx Talloc context, destoyed on completion of the function.
- * @param argc Standard main() style argc
- * @param argv Standard main() style argv. Initial components are already
- * stripped
- *
- * @return Normal NTSTATUS return.
- **/
-
-static NTSTATUS rpc_user_add_internals(const DOM_SID *domain_sid,
- const char *domain_name,
- struct cli_state *cli,
- struct rpc_pipe_client *pipe_hnd,
- TALLOC_CTX *mem_ctx,
- int argc, const char **argv)
-{
-
- POLICY_HND connect_pol, domain_pol, user_pol;
- NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
- const char *acct_name;
- struct lsa_String lsa_acct_name;
- uint32 acb_info;
- uint32 acct_flags, user_rid;
- uint32_t access_granted = 0;
- struct samr_Ids user_rids, name_types;
-
- if (argc < 1) {
- d_printf("User must be specified\n");
- rpc_user_usage(argc, argv);
- return NT_STATUS_OK;
- }
-
- acct_name = argv[0];
- init_lsa_String(&lsa_acct_name, acct_name);
-
- /* Get sam policy handle */
-
- result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
- pipe_hnd->cli->desthost,
- MAXIMUM_ALLOWED_ACCESS,
- &connect_pol);
- if (!NT_STATUS_IS_OK(result)) {
- goto done;
- }
-
- /* Get domain policy handle */
-
- result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,
- &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- CONST_DISCARD(struct dom_sid2 *, domain_sid),
- &domain_pol);
- if (!NT_STATUS_IS_OK(result)) {
- goto done;
- }
-
- /* Create domain user */
-
- acb_info = ACB_NORMAL;
- acct_flags = SEC_GENERIC_READ | SEC_GENERIC_WRITE | SEC_GENERIC_EXECUTE |
- SEC_STD_WRITE_DAC | SEC_STD_DELETE |
- SAMR_USER_ACCESS_SET_PASSWORD |
- SAMR_USER_ACCESS_GET_ATTRIBUTES |
- SAMR_USER_ACCESS_SET_ATTRIBUTES;
-
- result = rpccli_samr_CreateUser2(pipe_hnd, mem_ctx,
- &domain_pol,
- &lsa_acct_name,
- acb_info,
- acct_flags,
- &user_pol,
- &access_granted,
- &user_rid);
-
- if (!NT_STATUS_IS_OK(result)) {
- goto done;
- }
-
- if (argc == 2) {
-
- union samr_UserInfo info;
- uchar pwbuf[516];
-
- result = rpccli_samr_LookupNames(pipe_hnd, mem_ctx,
- &domain_pol,
- 1,
- &lsa_acct_name,
- &user_rids,
- &name_types);
-
- if (!NT_STATUS_IS_OK(result)) {
- goto done;
- }
-
- result = rpccli_samr_OpenUser(pipe_hnd, mem_ctx,
- &domain_pol,
- MAXIMUM_ALLOWED_ACCESS,
- user_rids.ids[0],
- &user_pol);
-
- if (!NT_STATUS_IS_OK(result)) {
- goto done;
- }
-
- /* Set password on account */
-
- encode_pw_buffer(pwbuf, argv[1], STR_UNICODE);
-
- init_samr_user_info24(&info.info24, pwbuf, 24);
-
- SamOEMhashBlob(info.info24.password.data, 516,
- &cli->user_session_key);
-
- result = rpccli_samr_SetUserInfo2(pipe_hnd, mem_ctx,
- &user_pol,
- 24,
- &info);
-
- if (!NT_STATUS_IS_OK(result)) {
- d_fprintf(stderr, "Failed to set password for user %s - %s\n",
- acct_name, nt_errstr(result));
-
- result = rpccli_samr_DeleteUser(pipe_hnd, mem_ctx,
- &user_pol);
-
- if (!NT_STATUS_IS_OK(result)) {
- d_fprintf(stderr, "Failed to delete user %s - %s\n",
- acct_name, nt_errstr(result));
- return result;
- }
- }
-
- }
- done:
- if (!NT_STATUS_IS_OK(result)) {
- d_fprintf(stderr, "Failed to add user '%s' with %s.\n",
- acct_name, nt_errstr(result));
- } else {
- d_printf("Added user '%s'.\n", acct_name);
- }
- return result;
-}
-
-/**
- * Add a new user to a remote RPC server
- *
* @param argc Standard main() style argc
* @param argv Standard main() style argv. Initial components are already
* stripped
@@ -730,115 +580,34 @@ static NTSTATUS rpc_user_add_internals(const DOM_SID *domain_sid,
static int rpc_user_add(int argc, const char **argv)
{
- return run_rpc_command(NULL, PI_SAMR, 0, rpc_user_add_internals,
- argc, argv);
-}
-
-/**
- * Delete a user from a remote RPC server
- *
- * All parameters are provided by the run_rpc_command function, except for
- * argc, argv which are passes through.
- *
- * @param domain_sid The domain sid acquired from the remote server
- * @param cli A cli_state connected to the server.
- * @param mem_ctx Talloc context, destoyed on completion of the function.
- * @param argc Standard main() style argc
- * @param argv Standard main() style argv. Initial components are already
- * stripped
- *
- * @return Normal NTSTATUS return.
- **/
-
-static NTSTATUS rpc_user_del_internals(const DOM_SID *domain_sid,
- const char *domain_name,
- struct cli_state *cli,
- struct rpc_pipe_client *pipe_hnd,
- TALLOC_CTX *mem_ctx,
- int argc,
- const char **argv)
-{
- NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
- POLICY_HND connect_pol, domain_pol, user_pol;
- const char *acct_name;
+ NET_API_STATUS status;
+ struct USER_INFO_1 info1;
+ uint32_t parm_error = 0;
if (argc < 1) {
d_printf("User must be specified\n");
rpc_user_usage(argc, argv);
- return NT_STATUS_OK;
- }
-
- acct_name = argv[0];
-
- /* Get sam policy and domain handles */
-
- result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
- pipe_hnd->cli->desthost,
- MAXIMUM_ALLOWED_ACCESS,
- &connect_pol);
-
- if (!NT_STATUS_IS_OK(result)) {
- goto done;
- }
-
- result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,
- &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- CONST_DISCARD(struct dom_sid2 *, domain_sid),
- &domain_pol);
-
- if (!NT_STATUS_IS_OK(result)) {
- goto done;
+ return 0;
}
- /* Get handle on user */
-
- {
- struct samr_Ids user_rids, name_types;
- struct lsa_String lsa_acct_name;
-
- init_lsa_String(&lsa_acct_name, acct_name);
-
- result = rpccli_samr_LookupNames(pipe_hnd, mem_ctx,
- &domain_pol,
- 1,
- &lsa_acct_name,
- &user_rids,
- &name_types);
-
- if (!NT_STATUS_IS_OK(result)) {
- goto done;
- }
+ ZERO_STRUCT(info1);
- result = rpccli_samr_OpenUser(pipe_hnd, mem_ctx,
- &domain_pol,
- MAXIMUM_ALLOWED_ACCESS,
- user_rids.ids[0],
- &user_pol);
-
- if (!NT_STATUS_IS_OK(result)) {
- goto done;
- }
+ info1.usri1_name = argv[0];
+ if (argc == 2) {
+ info1.usri1_password = argv[1];
}
- /* Delete user */
+ status = NetUserAdd(opt_host, 1, (uint8_t *)&info1, &parm_error);
- result = rpccli_samr_DeleteUser(pipe_hnd, mem_ctx,
- &user_pol);
-
- if (!NT_STATUS_IS_OK(result)) {
- goto done;
+ if (status != 0) {
+ d_fprintf(stderr, "Failed to add user '%s' with: %s.\n",
+ argv[0], libnetapi_get_error_string(NULL, status));
+ return -1;
+ } else {
+ d_printf("Added user '%s'.\n", argv[0]);
}
- done:
- if (!NT_STATUS_IS_OK(result)) {
- d_fprintf(stderr, "Failed to delete user '%s' with %s.\n",
- acct_name, nt_errstr(result));
- } else {
- d_printf("Deleted user '%s'.\n", acct_name);
- }
-
- return result;
+ return 0;
}
/**
@@ -885,7 +654,7 @@ static NTSTATUS rpc_user_rename_internals(const DOM_SID *domain_sid,
/* Get sam policy handle */
result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
- pipe_hnd->cli->desthost,
+ pipe_hnd->desthost,
MAXIMUM_ALLOWED_ACCESS,
&connect_pol);
@@ -987,8 +756,26 @@ static int rpc_user_rename(int argc, const char **argv)
static int rpc_user_delete(int argc, const char **argv)
{
- return run_rpc_command(NULL, PI_SAMR, 0, rpc_user_del_internals,
- argc, argv);
+ NET_API_STATUS status;
+
+ if (argc < 1) {
+ d_printf("User must be specified\n");
+ rpc_user_usage(argc, argv);
+ return 0;
+ }
+
+ status = NetUserDel(opt_host, argv[0]);
+
+ if (status != 0) {
+ d_fprintf(stderr, "Failed to delete user '%s' with: %s.\n",
+ argv[0],
+ libnetapi_get_error_string(NULL, status));
+ return -1;
+ } else {
+ d_printf("Deleted user '%s'.\n", argv[0]);
+ }
+
+ return 0;
}
/**
@@ -1042,7 +829,7 @@ static NTSTATUS rpc_user_password_internals(const DOM_SID *domain_sid,
/* Get sam policy and domain handles */
result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
- pipe_hnd->cli->desthost,
+ pipe_hnd->desthost,
MAXIMUM_ALLOWED_ACCESS,
&connect_pol);
@@ -1173,7 +960,7 @@ static NTSTATUS rpc_user_info_internals(const DOM_SID *domain_sid,
/* Get sam policy handle */
result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
- pipe_hnd->cli->desthost,
+ pipe_hnd->desthost,
MAXIMUM_ALLOWED_ACCESS,
&connect_pol);
if (!NT_STATUS_IS_OK(result)) goto done;
@@ -1291,7 +1078,7 @@ static NTSTATUS rpc_user_list_internals(const DOM_SID *domain_sid,
/* Get sam policy handle */
result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
- pipe_hnd->cli->desthost,
+ pipe_hnd->desthost,
MAXIMUM_ALLOWED_ACCESS,
&connect_pol);
if (!NT_STATUS_IS_OK(result)) {
@@ -1360,6 +1147,9 @@ static NTSTATUS rpc_user_list_internals(const DOM_SID *domain_sid,
int net_rpc_user(int argc, const char **argv)
{
+ struct libnetapi_ctx *ctx = NULL;
+ NET_API_STATUS status;
+
struct functable func[] = {
{"add", rpc_user_add},
{"info", rpc_user_info},
@@ -1368,7 +1158,14 @@ int net_rpc_user(int argc, const char **argv)
{"rename", rpc_user_rename},
{NULL, NULL}
};
-
+
+ status = libnetapi_init(&ctx);
+ if (status != 0) {
+ return -1;
+ }
+ libnetapi_set_username(ctx, opt_user_name);
+ libnetapi_set_password(ctx, opt_password);
+
if (argc == 0) {
return run_rpc_command(NULL,PI_SAMR, 0,
rpc_user_list_internals,
@@ -1424,8 +1221,8 @@ static NTSTATUS rpc_sh_handle_user(TALLOC_CTX *mem_ctx,
ZERO_STRUCT(domain_pol);
ZERO_STRUCT(user_pol);
- result = net_rpc_lookup_name(mem_ctx, pipe_hnd->cli, argv[0],
- NULL, NULL, &sid, &type);
+ result = net_rpc_lookup_name(mem_ctx, rpc_pipe_np_smb_conn(pipe_hnd),
+ argv[0], NULL, NULL, &sid, &type);
if (!NT_STATUS_IS_OK(result)) {
d_fprintf(stderr, "Could not lookup %s: %s\n", argv[0],
nt_errstr(result));
@@ -1446,7 +1243,7 @@ static NTSTATUS rpc_sh_handle_user(TALLOC_CTX *mem_ctx,
}
result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
- pipe_hnd->cli->desthost,
+ pipe_hnd->desthost,
MAXIMUM_ALLOWED_ACCESS,
&connect_pol);
if (!NT_STATUS_IS_OK(result)) {
@@ -1814,7 +1611,7 @@ static NTSTATUS rpc_group_delete_internals(const DOM_SID *domain_sid,
}
result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
- pipe_hnd->cli->desthost,
+ pipe_hnd->desthost,
MAXIMUM_ALLOWED_ACCESS,
&connect_pol);
@@ -2012,7 +1809,7 @@ static NTSTATUS rpc_group_add_internals(const DOM_SID *domain_sid,
/* Get sam policy handle */
result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
- pipe_hnd->cli->desthost,
+ pipe_hnd->desthost,
MAXIMUM_ALLOWED_ACCESS,
&connect_pol);
if (!NT_STATUS_IS_OK(result)) goto done;
@@ -2082,7 +1879,7 @@ static NTSTATUS rpc_alias_add_internals(const DOM_SID *domain_sid,
/* Get sam policy handle */
result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
- pipe_hnd->cli->desthost,
+ pipe_hnd->desthost,
MAXIMUM_ALLOWED_ACCESS,
&connect_pol);
if (!NT_STATUS_IS_OK(result)) goto done;
@@ -2176,7 +1973,7 @@ static NTSTATUS get_sid_from_name(struct cli_state *cli,
done:
if (pipe_hnd) {
- cli_rpc_pipe_close(pipe_hnd);
+ TALLOC_FREE(pipe_hnd);
}
if (!NT_STATUS_IS_OK(result) && (StrnCaseCmp(name, "S-", 2) == 0)) {
@@ -2218,7 +2015,7 @@ static NTSTATUS rpc_add_groupmem(struct rpc_pipe_client *pipe_hnd,
/* Get sam policy handle */
result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
- pipe_hnd->cli->desthost,
+ pipe_hnd->desthost,
MAXIMUM_ALLOWED_ACCESS,
&connect_pol);
if (!NT_STATUS_IS_OK(result)) {
@@ -2290,8 +2087,8 @@ static NTSTATUS rpc_add_aliasmem(struct rpc_pipe_client *pipe_hnd,
return NT_STATUS_UNSUCCESSFUL;
}
- result = get_sid_from_name(pipe_hnd->cli, mem_ctx, member,
- &member_sid, &member_type);
+ result = get_sid_from_name(rpc_pipe_np_smb_conn(pipe_hnd), mem_ctx,
+ member, &member_sid, &member_type);
if (!NT_STATUS_IS_OK(result)) {
d_fprintf(stderr, "Could not lookup up group member %s\n", member);
@@ -2300,7 +2097,7 @@ static NTSTATUS rpc_add_aliasmem(struct rpc_pipe_client *pipe_hnd,
/* Get sam policy handle */
result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
- pipe_hnd->cli->desthost,
+ pipe_hnd->desthost,
MAXIMUM_ALLOWED_ACCESS,
&connect_pol);
if (!NT_STATUS_IS_OK(result)) {
@@ -2419,7 +2216,7 @@ static NTSTATUS rpc_del_groupmem(struct rpc_pipe_client *pipe_hnd,
/* Get sam policy handle */
result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
- pipe_hnd->cli->desthost,
+ pipe_hnd->desthost,
MAXIMUM_ALLOWED_ACCESS,
&connect_pol);
if (!NT_STATUS_IS_OK(result))
@@ -2485,8 +2282,8 @@ static NTSTATUS rpc_del_aliasmem(struct rpc_pipe_client *pipe_hnd,
if (!sid_split_rid(&sid, &alias_rid))
return NT_STATUS_UNSUCCESSFUL;
- result = get_sid_from_name(pipe_hnd->cli, mem_ctx, member,
- &member_sid, &member_type);
+ result = get_sid_from_name(rpc_pipe_np_smb_conn(pipe_hnd), mem_ctx,
+ member, &member_sid, &member_type);
if (!NT_STATUS_IS_OK(result)) {
d_fprintf(stderr, "Could not lookup up group member %s\n", member);
@@ -2495,7 +2292,7 @@ static NTSTATUS rpc_del_aliasmem(struct rpc_pipe_client *pipe_hnd,
/* Get sam policy handle */
result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
- pipe_hnd->cli->desthost,
+ pipe_hnd->desthost,
MAXIMUM_ALLOWED_ACCESS,
&connect_pol);
if (!NT_STATUS_IS_OK(result)) {
@@ -2642,7 +2439,7 @@ static NTSTATUS rpc_group_list_internals(const DOM_SID *domain_sid,
/* Get sam policy handle */
result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
- pipe_hnd->cli->desthost,
+ pipe_hnd->desthost,
MAXIMUM_ALLOWED_ACCESS,
&connect_pol);
if (!NT_STATUS_IS_OK(result)) {
@@ -2939,7 +2736,8 @@ static NTSTATUS rpc_list_alias_members(struct rpc_pipe_client *pipe_hnd,
return NT_STATUS_OK;
}
- lsa_pipe = cli_rpc_pipe_open_noauth(pipe_hnd->cli, PI_LSARPC, &result);
+ lsa_pipe = cli_rpc_pipe_open_noauth(rpc_pipe_np_smb_conn(pipe_hnd),
+ PI_LSARPC, &result);
if (!lsa_pipe) {
d_fprintf(stderr, "Couldn't open LSA pipe. Error was %s\n",
nt_errstr(result) );
@@ -2951,14 +2749,14 @@ static NTSTATUS rpc_list_alias_members(struct rpc_pipe_client *pipe_hnd,
if (!NT_STATUS_IS_OK(result)) {
d_fprintf(stderr, "Couldn't open LSA policy handle\n");
- cli_rpc_pipe_close(lsa_pipe);
+ TALLOC_FREE(lsa_pipe);
return result;
}
alias_sids = TALLOC_ZERO_ARRAY(mem_ctx, DOM_SID, num_members);
if (!alias_sids) {
d_fprintf(stderr, "Out of memory\n");
- cli_rpc_pipe_close(lsa_pipe);
+ TALLOC_FREE(lsa_pipe);
return NT_STATUS_NO_MEMORY;
}
@@ -2973,7 +2771,7 @@ static NTSTATUS rpc_list_alias_members(struct rpc_pipe_client *pipe_hnd,
if (!NT_STATUS_IS_OK(result) &&
!NT_STATUS_EQUAL(result, STATUS_SOME_UNMAPPED)) {
d_fprintf(stderr, "Couldn't lookup SIDs\n");
- cli_rpc_pipe_close(lsa_pipe);
+ TALLOC_FREE(lsa_pipe);
return result;
}
@@ -2993,7 +2791,7 @@ static NTSTATUS rpc_list_alias_members(struct rpc_pipe_client *pipe_hnd,
}
}
- cli_rpc_pipe_close(lsa_pipe);
+ TALLOC_FREE(lsa_pipe);
return NT_STATUS_OK;
}
@@ -3013,7 +2811,7 @@ static NTSTATUS rpc_group_members_internals(const DOM_SID *domain_sid,
/* Get sam policy handle */
result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
- pipe_hnd->cli->desthost,
+ pipe_hnd->desthost,
MAXIMUM_ALLOWED_ACCESS,
&connect_pol);
@@ -3126,7 +2924,7 @@ static NTSTATUS rpc_group_rename_internals(const DOM_SID *domain_sid,
/* Get sam policy handle */
result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
- pipe_hnd->cli->desthost,
+ pipe_hnd->desthost,
MAXIMUM_ALLOWED_ACCESS,
&connect_pol);
@@ -3287,7 +3085,7 @@ static NTSTATUS rpc_share_add_internals(const DOM_SID *domain_sid,
info.info2 = &info2;
status = rpccli_srvsvc_NetShareAdd(pipe_hnd, mem_ctx,
- pipe_hnd->cli->desthost,
+ pipe_hnd->desthost,
level,
&info,
&parm_error,
@@ -3332,7 +3130,7 @@ static NTSTATUS rpc_share_del_internals(const DOM_SID *domain_sid,
WERROR result;
return rpccli_srvsvc_NetShareDel(pipe_hnd, mem_ctx,
- pipe_hnd->cli->desthost,
+ pipe_hnd->desthost,
argv[0],
0,
&result);
@@ -3398,7 +3196,7 @@ static WERROR get_share_info(struct rpc_pipe_client *pipe_hnd,
info_ctr->level = level;
status = rpccli_srvsvc_NetShareEnumAll(pipe_hnd, mem_ctx,
- pipe_hnd->cli->desthost,
+ pipe_hnd->desthost,
info_ctr,
preferred_len,
&total_entries,
@@ -3409,7 +3207,7 @@ static WERROR get_share_info(struct rpc_pipe_client *pipe_hnd,
/* request just one share */
status = rpccli_srvsvc_NetShareGetInfo(pipe_hnd, mem_ctx,
- pipe_hnd->cli->desthost,
+ pipe_hnd->desthost,
argv[0],
level,
&info,
@@ -3628,7 +3426,7 @@ static NTSTATUS rpc_share_migrate_shares_internals(const DOM_SID *domain_sid,
info.info502 = &info502;
nt_status = rpccli_srvsvc_NetShareAdd(srvsvc_pipe, mem_ctx,
- srvsvc_pipe->cli->desthost,
+ srvsvc_pipe->desthost,
502,
&info,
&parm_error,
@@ -4051,7 +3849,7 @@ static NTSTATUS rpc_share_migrate_security_internals(const DOM_SID *domain_sid,
/* finally modify the share on the dst server */
nt_status = rpccli_srvsvc_NetShareSetInfo(srvsvc_pipe, mem_ctx,
- srvsvc_pipe->cli->desthost,
+ srvsvc_pipe->desthost,
info502.name,
level,
&info,
@@ -4344,7 +4142,7 @@ static NTSTATUS rpc_aliaslist_internals(const DOM_SID *domain_sid,
POLICY_HND connect_pol;
result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
- pipe_hnd->cli->desthost,
+ pipe_hnd->desthost,
MAXIMUM_ALLOWED_ACCESS,
&connect_pol);
@@ -4683,7 +4481,7 @@ static void show_userlist(struct rpc_pipe_client *pipe_hnd,
int fnum;
SEC_DESC *share_sd = NULL;
SEC_DESC *root_sd = NULL;
- struct cli_state *cli = pipe_hnd->cli;
+ struct cli_state *cli = rpc_pipe_np_smb_conn(pipe_hnd);
int i;
union srvsvc_NetShareInfo info;
WERROR result;
@@ -4691,7 +4489,7 @@ static void show_userlist(struct rpc_pipe_client *pipe_hnd,
uint16 cnum;
status = rpccli_srvsvc_NetShareGetInfo(pipe_hnd, mem_ctx,
- pipe_hnd->cli->desthost,
+ pipe_hnd->desthost,
netname,
502,
&info,
@@ -5010,7 +4808,7 @@ static NTSTATUS rpc_sh_share_add(TALLOC_CTX *mem_ctx,
info.info2 = &info2;
status = rpccli_srvsvc_NetShareAdd(pipe_hnd, mem_ctx,
- pipe_hnd->cli->desthost,
+ pipe_hnd->desthost,
2,
&info,
&parm_err,
@@ -5033,7 +4831,7 @@ static NTSTATUS rpc_sh_share_delete(TALLOC_CTX *mem_ctx,
}
status = rpccli_srvsvc_NetShareDel(pipe_hnd, mem_ctx,
- pipe_hnd->cli->desthost,
+ pipe_hnd->desthost,
argv[0],
0,
&result);
@@ -5056,7 +4854,7 @@ static NTSTATUS rpc_sh_share_info(TALLOC_CTX *mem_ctx,
}
status = rpccli_srvsvc_NetShareGetInfo(pipe_hnd, mem_ctx,
- pipe_hnd->cli->desthost,
+ pipe_hnd->desthost,
argv[0],
2,
&info,
@@ -5128,7 +4926,7 @@ static NTSTATUS rpc_file_close_internals(const DOM_SID *domain_sid,
const char **argv)
{
return rpccli_srvsvc_NetFileClose(pipe_hnd, mem_ctx,
- pipe_hnd->cli->desthost,
+ pipe_hnd->desthost,
atoi(argv[0]), NULL);
}
@@ -5209,7 +5007,7 @@ static NTSTATUS rpc_file_list_internals(const DOM_SID *domain_sid,
info_ctr.ctr.ctr3 = &ctr3;
status = rpccli_srvsvc_NetFileEnum(pipe_hnd, mem_ctx,
- pipe_hnd->cli->desthost,
+ pipe_hnd->desthost,
NULL,
username,
&info_ctr,
@@ -5574,7 +5372,7 @@ static NTSTATUS rpc_trustdom_add_internals(const DOM_SID *domain_sid,
/* Get samr policy handle */
result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
- pipe_hnd->cli->desthost,
+ pipe_hnd->desthost,
MAXIMUM_ALLOWED_ACCESS,
&connect_pol);
if (!NT_STATUS_IS_OK(result)) {
@@ -5730,7 +5528,7 @@ static NTSTATUS rpc_trustdom_del_internals(const DOM_SID *domain_sid,
/* Get samr policy handle */
result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
- pipe_hnd->cli->desthost,
+ pipe_hnd->desthost,
MAXIMUM_ALLOWED_ACCESS,
&connect_pol);
if (!NT_STATUS_IS_OK(result)) {
@@ -5855,7 +5653,7 @@ static NTSTATUS rpc_trustdom_get_pdc(struct cli_state *cli,
domain_name,
&buffer,
NULL);
- cli_rpc_pipe_close(netr);
+ TALLOC_FREE(netr);
if (NT_STATUS_IS_OK(status)) {
return status;
@@ -6148,8 +5946,8 @@ static NTSTATUS vampire_trusted_domain(struct rpc_pipe_client *pipe_hnd,
data = data_blob(info->password.password->data,
info->password.password->length);
- cleartextpwd = decrypt_trustdom_secret(pipe_hnd->cli->pwd.password,
- &data);
+ cleartextpwd = decrypt_trustdom_secret(
+ rpc_pipe_np_smb_conn(pipe_hnd)->pwd.password, &data);
if (cleartextpwd == NULL) {
DEBUG(0,("retrieved NULL password\n"));
@@ -6451,7 +6249,7 @@ static int rpc_trustdom_list(int argc, const char **argv)
return -1;
};
- cli_rpc_pipe_close(pipe_hnd);
+ TALLOC_FREE(pipe_hnd);
/*
* Listing trusting domains (stored in passdb backend, if local)
@@ -6472,7 +6270,7 @@ static int rpc_trustdom_list(int argc, const char **argv)
/* SamrConnect2 */
nt_status = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
- pipe_hnd->cli->desthost,
+ pipe_hnd->desthost,
SA_RIGHT_SAM_OPEN_DOMAIN,
&connect_hnd);
if (!NT_STATUS_IS_OK(nt_status)) {
diff --git a/source3/utils/net_rpc_join.c b/source3/utils/net_rpc_join.c
index ea3bb10c22..c94e9d1a40 100644
--- a/source3/utils/net_rpc_join.c
+++ b/source3/utils/net_rpc_join.c
@@ -221,7 +221,7 @@ int net_rpc_join_newstyle(int argc, const char **argv)
domain_sid = info->account_domain.sid;
rpccli_lsa_Close(pipe_hnd, mem_ctx, &lsa_pol);
- cli_rpc_pipe_close(pipe_hnd); /* Done with this pipe */
+ TALLOC_FREE(pipe_hnd); /* Done with this pipe */
/* Bail out if domain didn't get set. */
if (!domain) {
@@ -238,7 +238,7 @@ int net_rpc_join_newstyle(int argc, const char **argv)
}
CHECK_RPC_ERR(rpccli_samr_Connect2(pipe_hnd, mem_ctx,
- pipe_hnd->cli->desthost,
+ pipe_hnd->desthost,
SEC_RIGHTS_MAXIMUM_ALLOWED,
&sam_pol),
"could not connect to SAM database");
@@ -368,7 +368,7 @@ int net_rpc_join_newstyle(int argc, const char **argv)
&set_info);
rpccli_samr_Close(pipe_hnd, mem_ctx, &user_pol);
- cli_rpc_pipe_close(pipe_hnd); /* Done with this pipe */
+ TALLOC_FREE(pipe_hnd); /* Done with this pipe */
/* Now check the whole process from top-to-bottom */
@@ -429,10 +429,10 @@ int net_rpc_join_newstyle(int argc, const char **argv)
goto done;
}
- cli_rpc_pipe_close(netlogon_schannel_pipe);
+ TALLOC_FREE(netlogon_schannel_pipe);
}
- cli_rpc_pipe_close(pipe_hnd);
+ TALLOC_FREE(pipe_hnd);
/* Now store the secret in the secrets database */
diff --git a/source3/utils/net_rpc_printer.c b/source3/utils/net_rpc_printer.c
index bcfb37713c..9dc409123e 100644
--- a/source3/utils/net_rpc_printer.c
+++ b/source3/utils/net_rpc_printer.c
@@ -721,7 +721,8 @@ static bool net_spoolss_open_printer_ex(struct rpc_pipe_client *pipe_hnd,
WERROR result;
fstring servername, printername2;
- slprintf(servername, sizeof(servername)-1, "\\\\%s", pipe_hnd->cli->desthost);
+ slprintf(servername, sizeof(servername)-1, "\\\\%s",
+ pipe_hnd->desthost);
fstrcpy(printername2, servername);
fstrcat(printername2, "\\");
@@ -993,7 +994,7 @@ static bool get_printer_info(struct rpc_pipe_client *pipe_hnd,
/* argument given, get a single printer by name */
if (!net_spoolss_open_printer_ex(pipe_hnd, mem_ctx, argv[0],
- MAXIMUM_ALLOWED_ACCESS, pipe_hnd->cli->user_name, &hnd))
+ MAXIMUM_ALLOWED_ACCESS, pipe_hnd->user_name, &hnd))
return False;
if (!net_spoolss_getprinter(pipe_hnd, mem_ctx, &hnd, level, ctr)) {
@@ -1189,7 +1190,7 @@ static NTSTATUS rpc_printer_publish_internals_args(struct rpc_pipe_client *pipe_
/* open printer handle */
if (!net_spoolss_open_printer_ex(pipe_hnd, mem_ctx, sharename,
- PRINTER_ALL_ACCESS, pipe_hnd->cli->user_name, &hnd))
+ PRINTER_ALL_ACCESS, pipe_hnd->user_name, &hnd))
goto done;
got_hnd = True;
@@ -1837,7 +1838,7 @@ NTSTATUS rpc_printer_migrate_drivers_internals(const DOM_SID *domain_sid,
/* open src printer handle */
if (!net_spoolss_open_printer_ex(pipe_hnd, mem_ctx, sharename,
- MAXIMUM_ALLOWED_ACCESS, pipe_hnd->cli->user_name, &hnd_src))
+ MAXIMUM_ALLOWED_ACCESS, pipe_hnd->user_name, &hnd_src))
goto done;
got_hnd_src = True;
diff --git a/source3/utils/net_rpc_samsync.c b/source3/utils/net_rpc_samsync.c
index 986499731a..6ea0a2dcfc 100644
--- a/source3/utils/net_rpc_samsync.c
+++ b/source3/utils/net_rpc_samsync.c
@@ -330,7 +330,7 @@ static void dump_database(struct rpc_pipe_client *pipe_hnd,
NTSTATUS result;
int i;
TALLOC_CTX *mem_ctx;
- const char *logon_server = pipe_hnd->cli->desthost;
+ const char *logon_server = pipe_hnd->desthost;
const char *computername = global_myname();
struct netr_Authenticator credential;
struct netr_Authenticator return_authenticator;
@@ -1028,7 +1028,6 @@ static NTSTATUS fetch_domain_info(uint32_t rid,
struct netr_DELTA_DOMAIN *r)
{
time_t u_max_age, u_min_age, u_logout;
- time_t u_lockoutreset, u_lockouttime;
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
const char *domname;
struct netr_AcctLockStr *lockstr = NULL;
@@ -1046,11 +1045,6 @@ static NTSTATUS fetch_domain_info(uint32_t rid,
u_min_age = uint64s_nt_time_to_unix_abs((uint64 *)&r->min_password_age);
u_logout = uint64s_nt_time_to_unix_abs((uint64 *)&r->force_logoff_time);
- if (lockstr) {
- u_lockoutreset = uint64s_nt_time_to_unix_abs(&lockstr->reset_count);
- u_lockouttime = uint64s_nt_time_to_unix_abs((uint64_t *)&lockstr->lockout_duration);
- }
-
domname = r->domain_name.string;
if (!domname) {
return NT_STATUS_NO_MEMORY;
@@ -1081,6 +1075,11 @@ static NTSTATUS fetch_domain_info(uint32_t rid,
return nt_status;
if (lockstr) {
+ time_t u_lockoutreset, u_lockouttime;
+
+ u_lockoutreset = uint64s_nt_time_to_unix_abs(&lockstr->reset_count);
+ u_lockouttime = uint64s_nt_time_to_unix_abs((uint64_t *)&lockstr->lockout_duration);
+
if (!pdb_set_account_policy(AP_BAD_ATTEMPT_LOCKOUT,
lockstr->bad_attempt_lockout))
return nt_status;
@@ -1191,7 +1190,7 @@ static NTSTATUS fetch_database(struct rpc_pipe_client *pipe_hnd, uint32 db_type,
NTSTATUS result;
int i;
TALLOC_CTX *mem_ctx;
- const char *logon_server = pipe_hnd->cli->desthost;
+ const char *logon_server = pipe_hnd->desthost;
const char *computername = global_myname();
struct netr_Authenticator credential;
struct netr_Authenticator return_authenticator;
@@ -2012,7 +2011,7 @@ static NTSTATUS fetch_database_to_ldif(struct rpc_pipe_client *pipe_hnd,
uint32 num_deltas;
FILE *add_file = NULL, *mod_file = NULL, *ldif_file = NULL;
int num_alloced = 0, g_index = 0, a_index = 0;
- const char *logon_server = pipe_hnd->cli->desthost;
+ const char *logon_server = pipe_hnd->desthost;
const char *computername = global_myname();
struct netr_Authenticator credential;
struct netr_Authenticator return_authenticator;
diff --git a/source3/utils/net_rpc_service.c b/source3/utils/net_rpc_service.c
index 1b12bd3114..b886283adc 100644
--- a/source3/utils/net_rpc_service.c
+++ b/source3/utils/net_rpc_service.c
@@ -213,7 +213,7 @@ static NTSTATUS rpc_service_list_internal(const DOM_SID *domain_sid,
}
status = rpccli_svcctl_OpenSCManagerW(pipe_hnd, mem_ctx,
- pipe_hnd->cli->srv_name_slash,
+ pipe_hnd->srv_name_slash,
NULL,
SC_RIGHT_MGR_ENUMERATE_SERVICE,
&hSCM,
@@ -272,7 +272,7 @@ static NTSTATUS rpc_service_status_internal(const DOM_SID *domain_sid,
/* Open the Service Control Manager */
status = rpccli_svcctl_OpenSCManagerW(pipe_hnd, mem_ctx,
- pipe_hnd->cli->srv_name_slash,
+ pipe_hnd->srv_name_slash,
NULL,
SC_RIGHT_MGR_ENUMERATE_SERVICE,
&hSCM,
@@ -384,7 +384,7 @@ static NTSTATUS rpc_service_stop_internal(const DOM_SID *domain_sid,
/* Open the Service Control Manager */
status = rpccli_svcctl_OpenSCManagerW(pipe_hnd, mem_ctx,
- pipe_hnd->cli->srv_name_slash,
+ pipe_hnd->srv_name_slash,
NULL,
SC_RIGHT_MGR_ENUMERATE_SERVICE,
&hSCM,
@@ -427,7 +427,7 @@ static NTSTATUS rpc_service_pause_internal(const DOM_SID *domain_sid,
/* Open the Service Control Manager */
status = rpccli_svcctl_OpenSCManagerW(pipe_hnd, mem_ctx,
- pipe_hnd->cli->srv_name_slash,
+ pipe_hnd->srv_name_slash,
NULL,
SC_RIGHT_MGR_ENUMERATE_SERVICE,
&hSCM,
@@ -470,7 +470,7 @@ static NTSTATUS rpc_service_resume_internal(const DOM_SID *domain_sid,
/* Open the Service Control Manager */
status = rpccli_svcctl_OpenSCManagerW(pipe_hnd, mem_ctx,
- pipe_hnd->cli->srv_name_slash,
+ pipe_hnd->srv_name_slash,
NULL,
SC_RIGHT_MGR_ENUMERATE_SERVICE,
&hSCM,
@@ -511,7 +511,7 @@ static NTSTATUS rpc_service_start_internal(const DOM_SID *domain_sid,
/* Open the Service Control Manager */
status = rpccli_svcctl_OpenSCManagerW(pipe_hnd, mem_ctx,
- pipe_hnd->cli->srv_name_slash,
+ pipe_hnd->srv_name_slash,
NULL,
SC_RIGHT_MGR_ENUMERATE_SERVICE,
&hSCM,
diff --git a/source3/utils/net_rpc_sh_acct.c b/source3/utils/net_rpc_sh_acct.c
index 57640ca3a8..00a7967f07 100644
--- a/source3/utils/net_rpc_sh_acct.c
+++ b/source3/utils/net_rpc_sh_acct.c
@@ -49,7 +49,7 @@ static NTSTATUS rpc_sh_acct_do(TALLOC_CTX *mem_ctx,
/* Get sam policy handle */
result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
- pipe_hnd->cli->desthost,
+ pipe_hnd->desthost,
MAXIMUM_ALLOWED_ACCESS,
&connect_pol);
if (!NT_STATUS_IS_OK(result)) {
diff --git a/source3/utils/net_rpc_shell.c b/source3/utils/net_rpc_shell.c
index e6302b652e..7bd726e614 100644
--- a/source3/utils/net_rpc_shell.c
+++ b/source3/utils/net_rpc_shell.c
@@ -85,7 +85,7 @@ static NTSTATUS net_sh_run(struct rpc_sh_ctx *ctx, struct rpc_sh_cmd *cmd,
status = cmd->fn(mem_ctx, ctx, pipe_hnd, argc, argv);
- cli_rpc_pipe_close(pipe_hnd);
+ TALLOC_FREE(pipe_hnd);
talloc_destroy(mem_ctx);
diff --git a/source3/utils/net_util.c b/source3/utils/net_util.c
index f844992d56..576c2191b3 100644
--- a/source3/utils/net_util.c
+++ b/source3/utils/net_util.c
@@ -75,7 +75,7 @@ NTSTATUS net_rpc_lookup_name(TALLOC_CTX *mem_ctx, struct cli_state *cli,
if (is_valid_policy_hnd(&pol)) {
rpccli_lsa_Close(lsa_pipe, mem_ctx, &pol);
}
- cli_rpc_pipe_close(lsa_pipe);
+ TALLOC_FREE(lsa_pipe);
return result;
}
diff --git a/source3/utils/smbcacls.c b/source3/utils/smbcacls.c
index 134f561760..af14c622dc 100644
--- a/source3/utils/smbcacls.c
+++ b/source3/utils/smbcacls.c
@@ -103,9 +103,7 @@ static NTSTATUS cli_lsa_lookup_sid(struct cli_state *cli,
status = NT_STATUS_OK;
fail:
- if (p != NULL) {
- cli_rpc_pipe_close(p);
- }
+ TALLOC_FREE(p);
cli_tdis(cli);
cli->cnum = orig_cnum;
TALLOC_FREE(frame);
@@ -151,9 +149,7 @@ static NTSTATUS cli_lsa_lookup_name(struct cli_state *cli,
status = NT_STATUS_OK;
fail:
- if (p != NULL) {
- cli_rpc_pipe_close(p);
- }
+ TALLOC_FREE(p);
cli_tdis(cli);
cli->cnum = orig_cnum;
TALLOC_FREE(frame);
diff --git a/source3/utils/smbtree.c b/source3/utils/smbtree.c
index 48eae5ac5c..c2b364d1e9 100644
--- a/source3/utils/smbtree.c
+++ b/source3/utils/smbtree.c
@@ -179,7 +179,7 @@ static bool get_rpc_shares(struct cli_state *cli,
info_ctr.ctr.ctr1 = &ctr1;
status = rpccli_srvsvc_NetShareEnumAll(pipe_hnd, mem_ctx,
- pipe_hnd->cli->desthost,
+ pipe_hnd->desthost,
&info_ctr,
0xffffffff,
&total_entries,
@@ -188,7 +188,7 @@ static bool get_rpc_shares(struct cli_state *cli,
if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(werr)) {
TALLOC_FREE(mem_ctx);
- cli_rpc_pipe_close(pipe_hnd);
+ TALLOC_FREE(pipe_hnd);
return False;
}
@@ -198,7 +198,7 @@ static bool get_rpc_shares(struct cli_state *cli,
}
TALLOC_FREE(mem_ctx);
- cli_rpc_pipe_close(pipe_hnd);
+ TALLOC_FREE(pipe_hnd);
return True;
}
diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c
index ff9bbf1c24..64674b8ace 100644
--- a/source3/winbindd/winbindd.c
+++ b/source3/winbindd/winbindd.c
@@ -1023,6 +1023,8 @@ int main(int argc, char **argv, char **envp)
load_case_tables();
+ db_tdb2_setup_messaging(NULL, false);
+
/* Initialise for running in non-root mode */
sec_init();
@@ -1102,7 +1104,19 @@ int main(int argc, char **argv, char **envp)
DEBUG(0,("winbindd version %s started.\n", SAMBA_VERSION_STRING));
DEBUGADD(0,("%s\n", COPYRIGHT_STARTUP_MESSAGE));
- db_tdb2_setup_messaging(NULL, false);
+ if (!lp_load_initial_only(get_dyn_CONFIGFILE())) {
+ DEBUG(0, ("error opening config file\n"));
+ exit(1);
+ }
+
+ /* Initialise messaging system */
+
+ if (winbind_messaging_context() == NULL) {
+ DEBUG(0, ("unable to initialize messaging system\n"));
+ exit(1);
+ }
+
+ db_tdb2_setup_messaging(winbind_messaging_context(), true);
if (!reload_services_file()) {
DEBUG(0, ("error opening config file\n"));
@@ -1175,10 +1189,8 @@ int main(int argc, char **argv, char **envp)
TimeInit();
- /* Initialise messaging system */
-
- if (winbind_messaging_context() == NULL) {
- DEBUG(0, ("unable to initialize messaging system\n"));
+ if (!reinit_after_fork(winbind_messaging_context())) {
+ DEBUG(0,("reinit_after_fork() failed\n"));
exit(1);
}
@@ -1219,8 +1231,6 @@ int main(int argc, char **argv, char **envp)
MSG_WINBIND_DUMP_DOMAIN_LIST,
winbind_msg_dump_domain_list);
- db_tdb2_setup_messaging(winbind_messaging_context(), true);
-
netsamlogon_cache_init(); /* Non-critical */
/* clear the cached list of trusted domains */
diff --git a/source3/winbindd/winbindd_ads.c b/source3/winbindd/winbindd_ads.c
index ae8ad9dd1a..8be6a47998 100644
--- a/source3/winbindd/winbindd_ads.c
+++ b/source3/winbindd/winbindd_ads.c
@@ -1195,7 +1195,7 @@ static NTSTATUS trusted_domains(struct winbindd_domain *domain,
}
result = rpccli_netr_DsrEnumerateDomainTrusts(cli, mem_ctx,
- cli->cli->desthost,
+ cli->desthost,
flags,
&trusts,
NULL);
diff --git a/source3/winbindd/winbindd_cm.c b/source3/winbindd/winbindd_cm.c
index 8e275b2269..73f74ca8ec 100644
--- a/source3/winbindd/winbindd_cm.c
+++ b/source3/winbindd/winbindd_cm.c
@@ -199,9 +199,8 @@ static bool fork_child_dc_connect(struct winbindd_domain *domain)
/* Leave messages blocked - we will never process one. */
- /* tdb needs special fork handling */
- if (tdb_reopen_all(1) == -1) {
- DEBUG(0,("tdb_reopen_all failed.\n"));
+ if (!reinit_after_fork(winbind_messaging_context())) {
+ DEBUG(0,("reinit_after_fork() failed\n"));
_exit(0);
}
@@ -599,7 +598,7 @@ static bool get_dc_name_via_netlogon(struct winbindd_domain *domain,
/* This call can take a long time - allow the server to time out.
35 seconds should do it. */
- orig_timeout = cli_set_timeout(netlogon_pipe->cli, 35000);
+ orig_timeout = rpccli_set_timeout(netlogon_pipe, 35000);
if (our_domain->active_directory) {
struct netr_DsRGetDCNameInfo *domain_info = NULL;
@@ -639,7 +638,7 @@ static bool get_dc_name_via_netlogon(struct winbindd_domain *domain,
}
/* And restore our original timeout. */
- cli_set_timeout(netlogon_pipe->cli, orig_timeout);
+ rpccli_set_timeout(netlogon_pipe, orig_timeout);
if (!NT_STATUS_IS_OK(result)) {
DEBUG(10,("rpccli_netr_GetAnyDCName failed: %s\n",
@@ -1021,167 +1020,6 @@ static bool add_sockaddr_to_array(TALLOC_CTX *mem_ctx,
return True;
}
-static void mailslot_name(struct in_addr dc_ip, fstring name)
-{
- fstr_sprintf(name, "\\MAILSLOT\\NET\\GETDC%X", dc_ip.s_addr);
-}
-
-static bool send_getdc_request(struct sockaddr_storage *dc_ss,
- const char *domain_name,
- const DOM_SID *sid)
-{
- char outbuf[1024];
- struct in_addr dc_ip;
- char *p;
- fstring my_acct_name;
- fstring my_mailslot;
- size_t sid_size;
-
- if (dc_ss->ss_family != AF_INET) {
- return false;
- }
-
- dc_ip = ((struct sockaddr_in *)dc_ss)->sin_addr;
- mailslot_name(dc_ip, my_mailslot);
-
- memset(outbuf, '\0', sizeof(outbuf));
-
- p = outbuf;
-
- SCVAL(p, 0, SAMLOGON);
- p++;
-
- SCVAL(p, 0, 0); /* Count pointer ... */
- p++;
-
- SIVAL(p, 0, 0); /* The sender's token ... */
- p += 2;
-
- p += dos_PutUniCode(p, global_myname(),
- sizeof(outbuf) - PTR_DIFF(p, outbuf), True);
- fstr_sprintf(my_acct_name, "%s$", global_myname());
- p += dos_PutUniCode(p, my_acct_name,
- sizeof(outbuf) - PTR_DIFF(p, outbuf), True);
-
- if (strlen(my_mailslot)+1 > sizeof(outbuf) - PTR_DIFF(p, outbuf)) {
- return false;
- }
-
- memcpy(p, my_mailslot, strlen(my_mailslot)+1);
- p += strlen(my_mailslot)+1;
-
- if (sizeof(outbuf) - PTR_DIFF(p, outbuf) < 8) {
- return false;
- }
-
- SIVAL(p, 0, 0x80);
- p+=4;
-
- sid_size = ndr_size_dom_sid(sid, 0);
-
- SIVAL(p, 0, sid_size);
- p+=4;
-
- p = ALIGN4(p, outbuf);
- if (PTR_DIFF(p, outbuf) > sizeof(outbuf)) {
- return false;
- }
-
- if (sid_size + 8 > sizeof(outbuf) - PTR_DIFF(p, outbuf)) {
- return false;
- }
- sid_linearize(p, sizeof(outbuf) - PTR_DIFF(p, outbuf), sid);
-
- p += sid_size;
-
- SIVAL(p, 0, 1);
- SSVAL(p, 4, 0xffff);
- SSVAL(p, 6, 0xffff);
- p+=8;
-
- return cli_send_mailslot(winbind_messaging_context(),
- False, "\\MAILSLOT\\NET\\NTLOGON", 0,
- outbuf, PTR_DIFF(p, outbuf),
- global_myname(), 0, domain_name, 0x1c,
- dc_ss);
-}
-
-static bool receive_getdc_response(struct sockaddr_storage *dc_ss,
- const char *domain_name,
- fstring dc_name)
-{
- struct packet_struct *packet;
- fstring my_mailslot;
- char *buf, *p;
- fstring dcname, user, domain;
- int len;
- struct in_addr dc_ip;
-
- if (dc_ss->ss_family != AF_INET) {
- return false;
- }
- dc_ip = ((struct sockaddr_in *)dc_ss)->sin_addr;
- mailslot_name(dc_ip, my_mailslot);
-
- packet = receive_unexpected(DGRAM_PACKET, 0, my_mailslot);
-
- if (packet == NULL) {
- DEBUG(5, ("Did not receive packet for %s\n", my_mailslot));
- return False;
- }
-
- DEBUG(5, ("Received packet for %s\n", my_mailslot));
-
- buf = packet->packet.dgram.data;
- len = packet->packet.dgram.datasize;
-
- if (len < 70) {
- /* 70 is a completely arbitrary value to make sure
- the SVAL below does not read uninitialized memory */
- DEBUG(3, ("GetDC got short response\n"));
- return False;
- }
-
- /* This should be (buf-4)+SVAL(buf-4, smb_vwv12)... */
- p = buf+SVAL(buf, smb_vwv10);
-
- switch (CVAL(p, 0)) {
- case SAMLOGON_R:
- case SAMLOGON_UNK_R:
- p+=2;
- pull_ucs2(buf, dcname, p, sizeof(dcname), PTR_DIFF(buf+len, p),
- STR_TERMINATE|STR_NOALIGN);
- p = skip_unibuf(p, PTR_DIFF(buf+len, p));
- pull_ucs2(buf, user, p, sizeof(user), PTR_DIFF(buf+len, p),
- STR_TERMINATE|STR_NOALIGN);
- p = skip_unibuf(p, PTR_DIFF(buf+len, p));
- pull_ucs2(buf, domain, p, sizeof(domain), PTR_DIFF(buf+len, p),
- STR_TERMINATE|STR_NOALIGN);
- p = skip_unibuf(p, PTR_DIFF(buf+len, p));
-
- if (!strequal(domain, domain_name)) {
- DEBUG(3, ("GetDC: Expected domain %s, got %s\n",
- domain_name, domain));
- return False;
- }
- break;
-
- default:
- DEBUG(8, ("GetDC got invalid response type %d\n", CVAL(p, 0)));
- return False;
- }
- p = dcname;
- if (*p == '\\') p += 1;
- if (*p == '\\') p += 1;
-
- fstrcpy(dc_name, p);
-
- DEBUG(10, ("GetDC gave name %s for domain %s\n",
- dc_name, domain));
-
- return True;
-}
-
/*******************************************************************
convert an ip to a name
*******************************************************************/
@@ -1253,7 +1091,8 @@ static bool dcip_to_name(const struct winbindd_domain *domain,
/* try GETDC requests next */
- if (send_getdc_request(pss, domain->name, &domain->sid)) {
+ if (send_getdc_request(winbind_messaging_context(),
+ pss, domain->name, &domain->sid)) {
int i;
smb_msleep(100);
for (i=0; i<5; i++) {
@@ -1593,33 +1432,27 @@ void invalidate_cm_connection(struct winbindd_cm_conn *conn)
}
if (conn->samr_pipe != NULL) {
- if (!cli_rpc_pipe_close(conn->samr_pipe)) {
- /* Ok, it must be dead. Drop timeout to 0.5 sec. */
- if (conn->cli) {
- cli_set_timeout(conn->cli, 500);
- }
+ TALLOC_FREE(conn->samr_pipe);
+ /* Ok, it must be dead. Drop timeout to 0.5 sec. */
+ if (conn->cli) {
+ cli_set_timeout(conn->cli, 500);
}
- conn->samr_pipe = NULL;
}
if (conn->lsa_pipe != NULL) {
- if (!cli_rpc_pipe_close(conn->lsa_pipe)) {
- /* Ok, it must be dead. Drop timeout to 0.5 sec. */
- if (conn->cli) {
- cli_set_timeout(conn->cli, 500);
- }
+ TALLOC_FREE(conn->lsa_pipe);
+ /* Ok, it must be dead. Drop timeout to 0.5 sec. */
+ if (conn->cli) {
+ cli_set_timeout(conn->cli, 500);
}
- conn->lsa_pipe = NULL;
}
if (conn->netlogon_pipe != NULL) {
- if (!cli_rpc_pipe_close(conn->netlogon_pipe)) {
- /* Ok, it must be dead. Drop timeout to 0.5 sec. */
- if (conn->cli) {
- cli_set_timeout(conn->cli, 500);
- }
+ TALLOC_FREE(conn->netlogon_pipe);
+ /* Ok, it must be dead. Drop timeout to 0.5 sec. */
+ if (conn->cli) {
+ cli_set_timeout(conn->cli, 500);
}
- conn->netlogon_pipe = NULL;
}
if (conn->cli) {
@@ -1770,7 +1603,7 @@ static bool set_dc_type_and_flags_trustinfo( struct winbindd_domain *domain )
}
result = rpccli_netr_DsrEnumerateDomainTrusts(cli, mem_ctx,
- cli->cli->desthost,
+ cli->desthost,
flags,
&trusts,
NULL);
@@ -1872,7 +1705,7 @@ static void set_dc_type_and_flags_connect( struct winbindd_domain *domain )
DS_ROLE_BASIC_INFORMATION,
&info,
&werr);
- cli_rpc_pipe_close(cli);
+ TALLOC_FREE(cli);
if (!NT_STATUS_IS_OK(result)) {
DEBUG(5, ("set_dc_type_and_flags_connect: rpccli_ds_getprimarydominfo "
@@ -1906,7 +1739,7 @@ no_dssetup:
DEBUG(5, ("set_dc_type_and_flags_connect: Could not bind to "
"PI_LSARPC on domain %s: (%s)\n",
domain->name, nt_errstr(result)));
- cli_rpc_pipe_close(cli);
+ TALLOC_FREE(cli);
TALLOC_FREE(mem_ctx);
return;
}
@@ -1986,7 +1819,7 @@ done:
DEBUG(5,("set_dc_type_and_flags_connect: domain %s is %srunning active directory.\n",
domain->name, domain->active_directory ? "" : "NOT "));
- cli_rpc_pipe_close(cli);
+ TALLOC_FREE(cli);
TALLOC_FREE(mem_ctx);
@@ -2123,7 +1956,7 @@ NTSTATUS cm_connect_sam(struct winbindd_domain *domain, TALLOC_CTX *mem_ctx,
domain_name, machine_account));
result = rpccli_samr_Connect2(conn->samr_pipe, mem_ctx,
- conn->samr_pipe->cli->desthost,
+ conn->samr_pipe->desthost,
SEC_RIGHTS_MAXIMUM_ALLOWED,
&conn->sam_connect_handle);
if (NT_STATUS_IS_OK(result)) {
@@ -2132,7 +1965,7 @@ NTSTATUS cm_connect_sam(struct winbindd_domain *domain, TALLOC_CTX *mem_ctx,
DEBUG(10,("cm_connect_sam: ntlmssp-sealed rpccli_samr_Connect2 "
"failed for domain %s, error was %s. Trying schannel\n",
domain->name, nt_errstr(result) ));
- cli_rpc_pipe_close(conn->samr_pipe);
+ TALLOC_FREE(conn->samr_pipe);
schannel:
@@ -2158,7 +1991,7 @@ NTSTATUS cm_connect_sam(struct winbindd_domain *domain, TALLOC_CTX *mem_ctx,
"schannel.\n", domain->name ));
result = rpccli_samr_Connect2(conn->samr_pipe, mem_ctx,
- conn->samr_pipe->cli->desthost,
+ conn->samr_pipe->desthost,
SEC_RIGHTS_MAXIMUM_ALLOWED,
&conn->sam_connect_handle);
if (NT_STATUS_IS_OK(result)) {
@@ -2167,7 +2000,7 @@ NTSTATUS cm_connect_sam(struct winbindd_domain *domain, TALLOC_CTX *mem_ctx,
DEBUG(10,("cm_connect_sam: schannel-sealed rpccli_samr_Connect2 failed "
"for domain %s, error was %s. Trying anonymous\n",
domain->name, nt_errstr(result) ));
- cli_rpc_pipe_close(conn->samr_pipe);
+ TALLOC_FREE(conn->samr_pipe);
anonymous:
@@ -2181,7 +2014,7 @@ NTSTATUS cm_connect_sam(struct winbindd_domain *domain, TALLOC_CTX *mem_ctx,
}
result = rpccli_samr_Connect2(conn->samr_pipe, mem_ctx,
- conn->samr_pipe->cli->desthost,
+ conn->samr_pipe->desthost,
SEC_RIGHTS_MAXIMUM_ALLOWED,
&conn->sam_connect_handle);
if (!NT_STATUS_IS_OK(result)) {
@@ -2269,7 +2102,7 @@ NTSTATUS cm_connect_lsa(struct winbindd_domain *domain, TALLOC_CTX *mem_ctx,
DEBUG(10,("cm_connect_lsa: rpccli_lsa_open_policy failed, trying "
"schannel\n"));
- cli_rpc_pipe_close(conn->lsa_pipe);
+ TALLOC_FREE(conn->lsa_pipe);
schannel:
@@ -2304,7 +2137,7 @@ NTSTATUS cm_connect_lsa(struct winbindd_domain *domain, TALLOC_CTX *mem_ctx,
DEBUG(10,("cm_connect_lsa: rpccli_lsa_open_policy failed, trying "
"anonymous\n"));
- cli_rpc_pipe_close(conn->lsa_pipe);
+ TALLOC_FREE(conn->lsa_pipe);
anonymous:
@@ -2379,7 +2212,7 @@ NTSTATUS cm_connect_netlogon(struct winbindd_domain *domain,
if (!get_trust_pw_hash(domain->name, mach_pwd, &account_name,
&sec_chan_type))
{
- cli_rpc_pipe_close(netlogon_pipe);
+ TALLOC_FREE(netlogon_pipe);
return NT_STATUS_CANT_ACCESS_DOMAIN_INFO;
}
@@ -2394,14 +2227,14 @@ NTSTATUS cm_connect_netlogon(struct winbindd_domain *domain,
&neg_flags);
if (!NT_STATUS_IS_OK(result)) {
- cli_rpc_pipe_close(netlogon_pipe);
+ TALLOC_FREE(netlogon_pipe);
return result;
}
if ((lp_client_schannel() == True) &&
((neg_flags & NETLOGON_NEG_SCHANNEL) == 0)) {
DEBUG(3, ("Server did not offer schannel\n"));
- cli_rpc_pipe_close(netlogon_pipe);
+ TALLOC_FREE(netlogon_pipe);
return NT_STATUS_ACCESS_DENIED;
}
@@ -2434,7 +2267,7 @@ NTSTATUS cm_connect_netlogon(struct winbindd_domain *domain,
&result);
/* We can now close the initial netlogon pipe. */
- cli_rpc_pipe_close(netlogon_pipe);
+ TALLOC_FREE(netlogon_pipe);
if (conn->netlogon_pipe == NULL) {
DEBUG(3, ("Could not open schannel'ed NETLOGON pipe. Error "
diff --git a/source3/winbindd/winbindd_dual.c b/source3/winbindd/winbindd_dual.c
index 3c342e54a4..77fbe3c0ed 100644
--- a/source3/winbindd/winbindd_dual.c
+++ b/source3/winbindd/winbindd_dual.c
@@ -1005,9 +1005,8 @@ static bool fork_domain_child(struct winbindd_child *child)
state.sock = fdpair[0];
close(fdpair[1]);
- /* tdb needs special fork handling */
- if (tdb_reopen_all(1) == -1) {
- DEBUG(0,("tdb_reopen_all failed.\n"));
+ if (!reinit_after_fork(winbind_messaging_context())) {
+ DEBUG(0,("reinit_after_fork() failed\n"));
_exit(0);
}
diff --git a/source3/winbindd/winbindd_misc.c b/source3/winbindd/winbindd_misc.c
index 93986d174e..bde2eafb53 100644
--- a/source3/winbindd/winbindd_misc.c
+++ b/source3/winbindd/winbindd_misc.c
@@ -333,7 +333,7 @@ enum winbindd_result winbindd_dual_getdcname(struct winbindd_domain *domain,
/* This call can take a long time - allow the server to time out.
35 seconds should do it. */
- orig_timeout = cli_set_timeout(netlogon_pipe->cli, 35000);
+ orig_timeout = rpccli_set_timeout(netlogon_pipe, 35000);
req_domain = find_domain_from_name_noinit(state->request.domain_name);
if (req_domain == domain) {
@@ -352,7 +352,7 @@ enum winbindd_result winbindd_dual_getdcname(struct winbindd_domain *domain,
&werr);
}
/* And restore our original timeout. */
- cli_set_timeout(netlogon_pipe->cli, orig_timeout);
+ rpccli_set_timeout(netlogon_pipe, orig_timeout);
if (!NT_STATUS_IS_OK(result)) {
DEBUG(5,("Error requesting DCname for domain %s: %s\n",
diff --git a/source3/winbindd/winbindd_rpc.c b/source3/winbindd/winbindd_rpc.c
index 2a7704c8a5..bb79d7ec12 100644
--- a/source3/winbindd/winbindd_rpc.c
+++ b/source3/winbindd/winbindd_rpc.c
@@ -750,14 +750,14 @@ static NTSTATUS lookup_groupmem(struct winbindd_domain *domain,
/* This call can take a long time - allow the server to time out.
35 seconds should do it. */
- orig_timeout = cli_set_timeout(cli->cli, 35000);
+ orig_timeout = rpccli_set_timeout(cli, 35000);
result = rpccli_samr_QueryGroupMember(cli, mem_ctx,
&group_pol,
&rids);
/* And restore our original timeout. */
- cli_set_timeout(cli->cli, orig_timeout);
+ rpccli_set_timeout(cli, orig_timeout);
rpccli_samr_Close(cli, mem_ctx, &group_pol);