Merge branch 'master' of ssh://git.samba.org/data/git/samba
authorAndrew Tridgell <tridge@samba.org>
Tue, 23 Sep 2008 18:15:46 +0000 (11:15 -0700)
committerAndrew Tridgell <tridge@samba.org>
Tue, 23 Sep 2008 18:15:46 +0000 (11:15 -0700)
275 files changed:
lib/replace/Makefile.in
lib/replace/test/main.c [new file with mode: 0644]
lib/replace/test/testsuite.c
lib/talloc/talloc.mk
lib/talloc/testsuite.c
lib/talloc/testsuite_main.c [new file with mode: 0644]
libcli/nbt/libnbt.h [moved from source3/libcli/nbt/libnbt.h with 96% similarity]
libcli/nbt/namequery.c [moved from source4/libcli/nbt/namequery.c with 96% similarity]
libcli/nbt/namerefresh.c [moved from source4/libcli/nbt/namerefresh.c with 94% similarity]
libcli/nbt/nameregister.c [moved from source4/libcli/nbt/nameregister.c with 95% similarity]
libcli/nbt/namerelease.c [moved from source4/libcli/nbt/namerelease.c with 94% similarity]
libcli/nbt/nbtname.c [moved from source4/libcli/nbt/nbtname.c with 96% similarity]
libcli/nbt/nbtsocket.c [moved from source4/libcli/nbt/nbtsocket.c with 91% similarity]
libcli/nbt/pynbt.c [moved from source4/libcli/nbt/pynbt.c with 94% similarity]
pidl/pidl
release-scripts/create-tarball
source3/Makefile.in
source3/client/mount.cifs.c
source3/configure.in
source3/include/charset.h
source3/include/proto.h
source3/lib/messages_local.c
source3/lib/netapi/examples/user/user_modalsset.c
source3/lib/netapi/tests/Makefile.in
source3/lib/netapi/tests/common.h
source3/lib/netapi/tests/netapitest.c
source3/lib/netapi/tests/netfile.c [new file with mode: 0644]
source3/lib/secdesc.c
source3/libads/authdata.c
source3/libads/cldap.c
source3/libcli/nbt/nbtname.c [deleted file]
source3/libnet/libnet_dssync_keytab.c
source3/libnet/libnet_samsync.c
source3/librpc/gen_ndr/libnetapi.h
source3/librpc/gen_ndr/nbt.h
source3/librpc/gen_ndr/ndr_libnetapi.c
source3/librpc/gen_ndr/ndr_nbt.c
source3/librpc/gen_ndr/ndr_nbt.h
source3/librpc/idl/libnetapi.idl
source3/librpc/idl/nbt.idl
source3/librpc/ndr/ndr.c
source3/libsmb/clidgram.c
source3/libsmb/clientgen.c
source3/libsmb/dsgetdcname.c
source3/libsmb/samlogon_cache.c
source3/libsmb/trusts_util.c
source3/modules/vfs_acl_xattr.c
source3/modules/vfs_xattr_tdb.c
source3/rpc_client/cli_netlogon.c
source3/rpc_client/init_netlogon.c
source3/samba4.m4
source3/samba4.mk
source3/script/build_idl.sh
source3/smbd/notify_internal.c
source3/utils/net_rpc_registry.c
source3/winbindd/idmap_adex/cell_util.c [new file with mode: 0644]
source3/winbindd/idmap_adex/domain_util.c [new file with mode: 0644]
source3/winbindd/idmap_adex/gc_util.c [new file with mode: 0644]
source3/winbindd/idmap_adex/idmap_adex.c [new file with mode: 0644]
source3/winbindd/idmap_adex/idmap_adex.h [new file with mode: 0644]
source3/winbindd/idmap_adex/likewise_cell.c [new file with mode: 0644]
source3/winbindd/idmap_adex/provider_unified.c [new file with mode: 0644]
source3/winbindd/winbindd_ads.c
source3/winbindd/winbindd_async.c
source3/winbindd/winbindd_group.c
source3/winbindd/winbindd_pam.c
source3/winbindd/winbindd_proto.h
source3/winbindd/winbindd_rpc.c
source3/winbindd/winbindd_util.c
source4/Makefile
source4/auth/gensec/gensec_gssapi.c
source4/auth/gensec/gensec_krb5.c
source4/auth/ntlmssp/ntlmssp.c
source4/configure.ac
source4/dsdb/samdb/ldb_modules/tests/samba3sam.py
source4/kdc/kdc.c
source4/ldap_server/ldap_server.c
source4/lib/appweb/README [deleted file]
source4/lib/appweb/config.m4 [deleted file]
source4/lib/appweb/config.mk [deleted file]
source4/lib/appweb/ejs-2.0/.bashrc [deleted file]
source4/lib/appweb/ejs-2.0/.exrc [deleted file]
source4/lib/appweb/ejs-2.0/.ignore [deleted file]
source4/lib/appweb/ejs-2.0/.loginrc [deleted file]
source4/lib/appweb/ejs-2.0/ejs/.ignore [deleted file]
source4/lib/appweb/ejs-2.0/ejs/Makefile [deleted file]
source4/lib/appweb/ejs-2.0/ejs/classes/.ignore [deleted file]
source4/lib/appweb/ejs-2.0/ejs/classes/Makefile [deleted file]
source4/lib/appweb/ejs-2.0/ejs/classes/ejsArray.c [deleted file]
source4/lib/appweb/ejs-2.0/ejs/classes/ejsDate.c [deleted file]
source4/lib/appweb/ejs-2.0/ejs/classes/ejsError.c [deleted file]
source4/lib/appweb/ejs-2.0/ejs/classes/ejsObject.c [deleted file]
source4/lib/appweb/ejs-2.0/ejs/classes/ejsStndClasses.c [deleted file]
source4/lib/appweb/ejs-2.0/ejs/classes/ejsString.c [deleted file]
source4/lib/appweb/ejs-2.0/ejs/classes/ejsXml.c [deleted file]
source4/lib/appweb/ejs-2.0/ejs/ejs.c [deleted file]
source4/lib/appweb/ejs-2.0/ejs/ejs.h [deleted file]
source4/lib/appweb/ejs-2.0/ejs/ejsClass.c [deleted file]
source4/lib/appweb/ejs-2.0/ejs/ejsCmd.c [deleted file]
source4/lib/appweb/ejs-2.0/ejs/ejsGarbage.c [deleted file]
source4/lib/appweb/ejs-2.0/ejs/ejsLex.c [deleted file]
source4/lib/appweb/ejs-2.0/ejs/ejsParser.c [deleted file]
source4/lib/appweb/ejs-2.0/ejs/ejsVar.c [deleted file]
source4/lib/appweb/ejs-2.0/ejs/ejsVar.h [deleted file]
source4/lib/appweb/ejs-2.0/ejs/lib/event.js [deleted file]
source4/lib/appweb/ejs-2.0/ejs/lib/global.js [deleted file]
source4/lib/appweb/ejs-2.0/ejs/lib/startup.js [deleted file]
source4/lib/appweb/ejs-2.0/ejs/lib/timer.js [deleted file]
source4/lib/appweb/ejs-2.0/ejs/system/.ignore [deleted file]
source4/lib/appweb/ejs-2.0/ejs/system/Makefile [deleted file]
source4/lib/appweb/ejs-2.0/ejs/system/README.TXT [deleted file]
source4/lib/appweb/ejs-2.0/ejs/system/UNIX/.ignore [deleted file]
source4/lib/appweb/ejs-2.0/ejs/system/UNIX/Makefile [deleted file]
source4/lib/appweb/ejs-2.0/ejs/system/UNIX/ejsFile.c [deleted file]
source4/lib/appweb/ejs-2.0/ejs/system/UNIX/ejsFileSystem.c [deleted file]
source4/lib/appweb/ejs-2.0/ejs/system/UNIX/ejsHTTP.c [deleted file]
source4/lib/appweb/ejs-2.0/ejs/system/WIN/.ignore [deleted file]
source4/lib/appweb/ejs-2.0/ejs/system/WIN/Makefile [deleted file]
source4/lib/appweb/ejs-2.0/ejs/system/WIN/ejsFile.c [deleted file]
source4/lib/appweb/ejs-2.0/ejs/system/WIN/ejsFileSystem.c [deleted file]
source4/lib/appweb/ejs-2.0/ejs/system/WIN/ejsHTTP.c [deleted file]
source4/lib/appweb/ejs-2.0/ejs/system/ejsGC.c [deleted file]
source4/lib/appweb/ejs-2.0/ejs/system/ejsGlobal.c [deleted file]
source4/lib/appweb/ejs-2.0/ejs/system/ejsSystem.c [deleted file]
source4/lib/appweb/ejs-2.0/ejs/system/ejsSystemApp.c [deleted file]
source4/lib/appweb/ejs-2.0/ejs/system/ejsSystemDebug.c [deleted file]
source4/lib/appweb/ejs-2.0/ejs/system/ejsSystemLog.c [deleted file]
source4/lib/appweb/ejs-2.0/ejs/system/ejsSystemMemory.c [deleted file]
source4/lib/appweb/ejs-2.0/exml/Makefile [deleted file]
source4/lib/appweb/ejs-2.0/exml/exml.h [deleted file]
source4/lib/appweb/ejs-2.0/exml/exmlParser.c [deleted file]
source4/lib/appweb/ejs-2.0/exml/files [deleted file]
source4/lib/appweb/ejs-2.0/mpr/Makefile [deleted file]
source4/lib/appweb/ejs-2.0/mpr/UNIX/Makefile [deleted file]
source4/lib/appweb/ejs-2.0/mpr/UNIX/mprFile.c [deleted file]
source4/lib/appweb/ejs-2.0/mpr/UNIX/mprPlatform.c [deleted file]
source4/lib/appweb/ejs-2.0/mpr/UNIX/mprTime.c [deleted file]
source4/lib/appweb/ejs-2.0/mpr/VXWORKS/Makefile [deleted file]
source4/lib/appweb/ejs-2.0/mpr/VXWORKS/mprFile.c [deleted file]
source4/lib/appweb/ejs-2.0/mpr/VXWORKS/mprPlatform.c [deleted file]
source4/lib/appweb/ejs-2.0/mpr/VXWORKS/mprTime.c [deleted file]
source4/lib/appweb/ejs-2.0/mpr/WIN/Makefile [deleted file]
source4/lib/appweb/ejs-2.0/mpr/WIN/mprFile.c [deleted file]
source4/lib/appweb/ejs-2.0/mpr/WIN/mprPlatform.c [deleted file]
source4/lib/appweb/ejs-2.0/mpr/WIN/mprTime.c [deleted file]
source4/lib/appweb/ejs-2.0/mpr/files [deleted file]
source4/lib/appweb/ejs-2.0/mpr/mpr.c [deleted file]
source4/lib/appweb/ejs-2.0/mpr/mpr.h [deleted file]
source4/lib/appweb/ejs-2.0/mpr/mprAlloc.c [deleted file]
source4/lib/appweb/ejs-2.0/mpr/mprArray.c [deleted file]
source4/lib/appweb/ejs-2.0/mpr/mprBuf.c [deleted file]
source4/lib/appweb/ejs-2.0/mpr/mprGenFile.c [deleted file]
source4/lib/appweb/ejs-2.0/mpr/mprGenTime.c [deleted file]
source4/lib/appweb/ejs-2.0/mpr/mprLock.c [deleted file]
source4/lib/appweb/ejs-2.0/mpr/mprLog.c [deleted file]
source4/lib/appweb/ejs-2.0/mpr/mprOs.h [deleted file]
source4/lib/appweb/ejs-2.0/mpr/mprPrintf.c [deleted file]
source4/lib/appweb/ejs-2.0/mpr/mprString.c [deleted file]
source4/lib/appweb/ejs-2.0/mpr/mprSymbol.c [deleted file]
source4/lib/appweb/ejs-2.0/mpr/mprUnix.h [deleted file]
source4/lib/appweb/ejs/config.h [deleted file]
source4/lib/appweb/ejs/ejs.h [deleted file]
source4/lib/appweb/ejs/ejsInternal.h [deleted file]
source4/lib/appweb/ejs/ejsLex.c [deleted file]
source4/lib/appweb/ejs/ejsLib.c [deleted file]
source4/lib/appweb/ejs/ejsParser.c [deleted file]
source4/lib/appweb/ejs/ejsProcs.c [deleted file]
source4/lib/appweb/esp/esp.c [deleted file]
source4/lib/appweb/esp/esp.h [deleted file]
source4/lib/appweb/esp/espEnv.h [deleted file]
source4/lib/appweb/esp/espProcs.c [deleted file]
source4/lib/appweb/mpr/miniMpr.c [deleted file]
source4/lib/appweb/mpr/miniMpr.h [deleted file]
source4/lib/appweb/mpr/var.c [deleted file]
source4/lib/appweb/mpr/var.h [deleted file]
source4/lib/charset/util_unistr.c
source4/lib/com/config.mk
source4/lib/ldb/ldb.i
source4/lib/ldb/ldb_wrap.c
source4/lib/ldb/tests/python/api.py
source4/lib/registry/patchfile.c
source4/lib/registry/rpc.c
source4/lib/registry/tools/regdiff.c
source4/lib/registry/tools/regshell.c
source4/lib/registry/tools/regtree.c
source4/libcli/auth/smbencrypt.c
source4/libcli/composite/composite.c
source4/libcli/config.mk
source4/libcli/finddcs.c
source4/libcli/nbt/libnbt.h [deleted file]
source4/libcli/raw/clitransport.c
source4/libcli/raw/libcliraw.h
source4/libcli/raw/rawrequest.c
source4/libcli/raw/smb_signing.c
source4/libcli/resolve/nbtlist.c
source4/libcli/resolve/resolve.h
source4/libcli/resolve/wins.c
source4/libcli/smb_composite/sesssetup.c
source4/librpc/config.mk
source4/librpc/idl/nbt.idl
source4/main.mk
source4/nbt_server/defense.c
source4/nbt_server/interfaces.c
source4/nbt_server/nbt_server.h
source4/nbt_server/nodestatus.c
source4/nbt_server/packet.c
source4/nbt_server/query.c
source4/nbt_server/register.c
source4/nbt_server/wins/wins_dns_proxy.c
source4/nbt_server/wins/winsserver.c
source4/nbt_server/wins/winswack.c
source4/nsswitch/tests/test_wbinfo.sh
source4/ntp_signd/ntp_signd.c
source4/param/loadparm.c
source4/rpc_server/netlogon/dcerpc_netlogon.c
source4/rpc_server/samr/samr_password.c
source4/samba4-quick
source4/samba4-skip
source4/script/find_unused_makefilevars.pl
source4/script/installmisc.sh
source4/script/installmodules.sh [deleted file]
source4/script/installscripts.sh [deleted file]
source4/script/uninstallmodules.sh [deleted file]
source4/script/uninstallscripts.sh [deleted file]
source4/scripting/bin/autoidl [moved from source4/scripting/bin/autoidl.py with 100% similarity]
source4/scripting/bin/epdump [moved from source4/scripting/bin/epdump.py with 100% similarity, mode: 0755]
source4/scripting/bin/minschema [moved from source4/scripting/bin/minschema.py with 100% similarity]
source4/scripting/bin/smbstatus
source4/scripting/ejs/config.mk [deleted file]
source4/scripting/ejs/mprutil.c [deleted file]
source4/scripting/ejs/smbcalls.c [deleted file]
source4/scripting/ejs/smbcalls.h [deleted file]
source4/scripting/ejs/smbcalls_auth.c [deleted file]
source4/scripting/ejs/smbcalls_config.c [deleted file]
source4/scripting/ejs/smbcalls_creds.c [deleted file]
source4/scripting/ejs/smbcalls_ldb.c [deleted file]
source4/scripting/ejs/smbcalls_options.c [deleted file]
source4/scripting/ejs/smbcalls_string.c [deleted file]
source4/scripting/ejs/smbcalls_sys.c [deleted file]
source4/scripting/ejs/smbscript.c [deleted file]
source4/scripting/libjs/base.js [deleted file]
source4/scripting/python/misc_wrap.c
source4/selftest/output/plain.pm
source4/selftest/samba4_tests.sh
source4/selftest/selftest.pl
source4/selftest/target/Samba4.pm
source4/smb_server/config.mk
source4/smb_server/smb/sesssetup.c
source4/smb_server/smb/signing.c
source4/smb_server/smb_samba3.c [new file with mode: 0644]
source4/smbd/process_model.c
source4/smbd/process_model.h
source4/smbd/server.c
source4/torture/nbt/nbt.c
source4/torture/nbt/query.c
source4/torture/nbt/winsbench.c
source4/torture/nbt/winsreplication.c
source4/torture/rpc/netlogon.c
source4/torture/rpc/remote_pac.c
source4/torture/rpc/winreg.c
source4/utils/nmblookup.c
source4/web_server/config.mk
source4/web_server/http.c [deleted file]
source4/web_server/swat/__init__.py
source4/web_server/web_server.c
source4/web_server/web_server.h
source4/web_server/wsgi.c [new file with mode: 0644]
source4/winbind/wb_server.c
source4/wrepl_server/wrepl_in_connection.c
testprogs/ejs/base.js [deleted file]
testprogs/ejs/bugs.js [deleted file]
testprogs/ejs/ldb.js [deleted file]
testprogs/ejs/minschema.js [deleted file]
testprogs/ejs/samba3sam.js [deleted file]
testprogs/ejs/sprintf.js [deleted file]

index c889a0e45793c3198ceeef024706c339d6afb8d5..65f8125efdeb07c3f8fed6d918457cbf9f42fb8d 100644 (file)
@@ -47,7 +47,7 @@ test: all
 
 installcheck: install test
 
-TEST_OBJS = test/testsuite.o test/os2_delete.o test/strptime.o test/getifaddrs.o
+TEST_OBJS = test/main.o test/testsuite.o test/os2_delete.o test/strptime.o test/getifaddrs.o
 
 testsuite: libreplace.a $(TEST_OBJS)
        $(CC) -o testsuite $(TEST_OBJS) -L. -lreplace $(LDFLAGS) $(LIBS)
diff --git a/lib/replace/test/main.c b/lib/replace/test/main.c
new file mode 100644 (file)
index 0000000..9bd1284
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+   Unix SMB/CIFS implementation.
+
+   libreplace tests
+
+   Copyright (C) Jelmer Vernooij 2006
+
+     ** NOTE! The following LGPL license applies to the talloc
+     ** library. This does NOT imply that all of Samba is released
+     ** under the LGPL
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 3 of the License, or (at your option) any later version.
+
+   This library 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "replace.h"
+
+struct torture_context;
+bool torture_local_replace(struct torture_context *ctx);
+
+int main(void)
+{
+       bool ret = torture_local_replace(NULL);
+       if (ret)
+               return 0;
+       return -1;
+}
index dcb05fbbf4ead2d522e1b44550548f04a5237e7e..7929f11addf0a660ba9ca6e19ca4d02f420339eb 100644 (file)
@@ -1068,14 +1068,3 @@ bool torture_local_replace(struct torture_context *ctx)
 
        return ret;
 }
-
-#if _SAMBA_BUILD_>3
-#else
-int main(void)
-{
-       bool ret = torture_local_replace(NULL);
-       if (ret) 
-               return 0;
-       return -1;
-}
-#endif
index 23331b6365b61fba5807c822401637425cbc870b..f183cd57ef4d7d607b658d0dc4fff6686905dff0 100644 (file)
@@ -5,8 +5,8 @@ TALLOC_SONAME = libtalloc.$(SHLIBEXT).1
 
 all:: libtalloc.a $(TALLOC_SOLIB) testsuite
 
-testsuite:: $(LIBOBJ) testsuite.o
-       $(CC) $(CFLAGS) -o testsuite testsuite.o $(LIBOBJ) $(LIBS)
+testsuite:: $(LIBOBJ) testsuite.o testsuite_main.o
+       $(CC) $(CFLAGS) -o testsuite testsuite.o testsuite_main.o $(LIBOBJ) $(LIBS)
 
 libtalloc.a: $(LIBOBJ)
        ar -rv $@ $(LIBOBJ)
@@ -28,7 +28,7 @@ install:: all
 doc:: talloc.3 talloc.3.html
 
 clean::
-       rm -f *~ $(LIBOBJ) $(TALLOC_SOLIB) libtalloc.a testsuite testsuite.o *.gc?? talloc.3 talloc.3.html
+       rm -f *~ $(LIBOBJ) $(TALLOC_SOLIB) libtalloc.a testsuite testsuite.o testsuite_main.o *.gc?? talloc.3 talloc.3.html
 
 test:: testsuite
        ./testsuite
index 3f06eee5667d4b285afdcdbf6c1c986c297c6815..3d490ddf49319139093893caff827c9fd0346bc6 100644 (file)
@@ -1140,13 +1140,3 @@ bool torture_local_talloc(struct torture_context *tctx)
 
        return ret;
 }
-
-#if _SAMBA_BUILD_ < 4
-int main(void)
-{
-       bool ret = torture_local_talloc(NULL);
-       if (!ret)
-               return -1;
-       return 0;
-}
-#endif
diff --git a/lib/talloc/testsuite_main.c b/lib/talloc/testsuite_main.c
new file mode 100644 (file)
index 0000000..1b51333
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+   Unix SMB/CIFS implementation.
+
+   local testing of talloc routines.
+
+   Copyright (C) Andrew Tridgell 2004
+
+     ** NOTE! The following LGPL license applies to the talloc
+     ** library. This does NOT imply that all of Samba is released
+     ** under the LGPL
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 3 of the License, or (at your option) any later version.
+
+   This library 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "replace.h"
+
+struct torture_context;
+bool torture_local_talloc(struct torture_context *tctx);
+
+int main(void)
+{
+       bool ret = torture_local_talloc(NULL);
+       if (!ret)
+               return -1;
+       return 0;
+}
similarity index 96%
rename from source3/libcli/nbt/libnbt.h
rename to libcli/nbt/libnbt.h
index d37a17c19211450a1716d56143ae7d0efde75079..4ef4e9d60d15766dad3eaacba24b30d1ef523ccc 100644 (file)
@@ -83,7 +83,7 @@ struct nbt_name_request {
        /* information on what to do on completion */
        struct {
                void (*fn)(struct nbt_name_request *);
-               void *_private;
+               void *private_data;
        } async;
 };
 
@@ -95,9 +95,8 @@ struct nbt_name_request {
 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;
 
@@ -114,14 +113,14 @@ struct nbt_name_socket {
        struct {
                void (*handler)(struct nbt_name_socket *, struct nbt_name_packet *,
                                struct socket_address *);
-               void *_private;
+               void *private_data;
        } incoming;
 
        /* what to do with unexpected replies */
        struct {
                void (*handler)(struct nbt_name_socket *, struct nbt_name_packet *,
                                struct socket_address *);
-               void *_private;
+               void *private_data;
        } unexpected;
 };
 
@@ -276,9 +275,8 @@ struct nbt_name_release {
 };
 
 struct nbt_name_socket *nbt_name_socket_init(TALLOC_CTX *mem_ctx,
-                                            struct event_context *event_ctx);
-                                            /*,
-                                            struct smb_iconv_convenience *iconv_convenience);*/
+                                            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,
@@ -293,7 +291,7 @@ 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_to_blob(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, 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);
@@ -325,7 +323,7 @@ NTSTATUS nbt_name_refresh_recv(struct nbt_name_request *req,
 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);
+                                 void *private_data);
 NTSTATUS nbt_name_reply_send(struct nbt_name_socket *nbtsock,
                             struct socket_address *dest,
                             struct nbt_name_packet *request);
similarity index 96%
rename from source4/libcli/nbt/namequery.c
rename to libcli/nbt/namequery.c
index 2e1bcd818bebed7b65b8667ef25f9f4b142d236b..ed3d8a24925bbf535bee3fa573dccb005dfc7a32 100644 (file)
@@ -1,27 +1,27 @@
-/* 
+/*
    Unix SMB/CIFS implementation.
 
    make nbt name query requests
 
    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/>.
 */
 
 #include "includes.h"
-#include "libcli/nbt/libnbt.h"
-#include "libcli/nbt/nbt_proto.h"
+#include "../libcli/nbt/libnbt.h"
+#include "../libcli/nbt/nbt_proto.h"
 #include "lib/socket/socket.h"
 #include "param/param.h"
 
@@ -66,13 +66,13 @@ _PUBLIC_ struct nbt_name_request *nbt_name_query_send(struct nbt_name_socket *nb
 
 failed:
        talloc_free(packet);
-       return NULL;    
+       return NULL;
 }
 
 /**
   wait for a name query reply
 */
-_PUBLIC_ NTSTATUS nbt_name_query_recv(struct nbt_name_request *req, 
+_PUBLIC_ NTSTATUS nbt_name_query_recv(struct nbt_name_request *req,
                             TALLOC_CTX *mem_ctx, struct nbt_name_query *io)
 {
        NTSTATUS status;
@@ -85,7 +85,7 @@ _PUBLIC_ NTSTATUS nbt_name_query_recv(struct nbt_name_request *req,
                talloc_free(req);
                return status;
        }
-       
+
        packet = req->replies[0].packet;
        io->out.reply_from = talloc_steal(mem_ctx, req->replies[0].dest->addr);
 
@@ -109,16 +109,16 @@ _PUBLIC_ NTSTATUS nbt_name_query_recv(struct nbt_name_request *req,
                talloc_free(req);
                return NT_STATUS_NO_MEMORY;
        }
-       
+
        for (i=0;i<io->out.num_addrs;i++) {
-               io->out.reply_addrs[i] = talloc_steal(io->out.reply_addrs, 
+               io->out.reply_addrs[i] = talloc_steal(io->out.reply_addrs,
                                                      packet->answers[0].rdata.netbios.addresses[i].ipaddr);
        }
        io->out.reply_addrs[i] = NULL;
 
        talloc_steal(mem_ctx, io->out.name.name);
        talloc_steal(mem_ctx, io->out.name.scope);
-           
+
        talloc_free(req);
 
        return NT_STATUS_OK;
@@ -127,7 +127,7 @@ _PUBLIC_ NTSTATUS nbt_name_query_recv(struct nbt_name_request *req,
 /**
   wait for a name query reply
 */
-_PUBLIC_ NTSTATUS nbt_name_query(struct nbt_name_socket *nbtsock, 
+_PUBLIC_ NTSTATUS nbt_name_query(struct nbt_name_socket *nbtsock,
                        TALLOC_CTX *mem_ctx, struct nbt_name_query *io)
 {
        struct nbt_name_request *req = nbt_name_query_send(nbtsock, io);
@@ -170,13 +170,13 @@ _PUBLIC_ struct nbt_name_request *nbt_name_status_send(struct nbt_name_socket *n
 
 failed:
        talloc_free(packet);
-       return NULL;    
+       return NULL;
 }
 
 /**
   wait for a name status reply
 */
-_PUBLIC_ NTSTATUS nbt_name_status_recv(struct nbt_name_request *req, 
+_PUBLIC_ NTSTATUS nbt_name_status_recv(struct nbt_name_request *req,
                             TALLOC_CTX *mem_ctx, struct nbt_name_status *io)
 {
        NTSTATUS status;
@@ -189,7 +189,7 @@ _PUBLIC_ NTSTATUS nbt_name_status_recv(struct nbt_name_request *req,
                talloc_free(req);
                return status;
        }
-       
+
        packet = req->replies[0].packet;
        io->out.reply_from = talloc_steal(mem_ctx, req->replies[0].dest->addr);
 
@@ -216,7 +216,7 @@ _PUBLIC_ NTSTATUS nbt_name_status_recv(struct nbt_name_request *req,
                talloc_steal(io->out.status.names, io->out.status.names[i].name);
        }
 
-           
+
        talloc_free(req);
 
        return NT_STATUS_OK;
@@ -225,7 +225,7 @@ _PUBLIC_ NTSTATUS nbt_name_status_recv(struct nbt_name_request *req,
 /**
   wait for a name status reply
 */
-_PUBLIC_ NTSTATUS nbt_name_status(struct nbt_name_socket *nbtsock, 
+_PUBLIC_ NTSTATUS nbt_name_status(struct nbt_name_socket *nbtsock,
                        TALLOC_CTX *mem_ctx, struct nbt_name_status *io)
 {
        struct nbt_name_request *req = nbt_name_status_send(nbtsock, io);
similarity index 94%
rename from source4/libcli/nbt/namerefresh.c
rename to libcli/nbt/namerefresh.c
index b372e4a3f3b0e2d0012ea84f1b50903d9d35686c..37bf0fc8f121a4af0e75ae3b0c0105953a809c0a 100644 (file)
@@ -1,27 +1,27 @@
-/* 
+/*
    Unix SMB/CIFS implementation.
 
    send out a name refresh request
 
    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/>.
 */
 
 #include "includes.h"
-#include "libcli/nbt/libnbt.h"
-#include "libcli/nbt/nbt_proto.h"
+#include "../libcli/nbt/libnbt.h"
+#include "../libcli/nbt/nbt_proto.h"
 #include "libcli/composite/composite.h"
 #include "lib/socket/socket.h"
 #include "param/param.h"
@@ -65,11 +65,11 @@ struct nbt_name_request *nbt_name_refresh_send(struct nbt_name_socket *nbtsock,
                                                                     struct nbt_rdata_address, 1);
        if (packet->additional[0].rdata.netbios.addresses == NULL) goto failed;
        packet->additional[0].rdata.netbios.addresses[0].nb_flags = io->in.nb_flags;
-       packet->additional[0].rdata.netbios.addresses[0].ipaddr = 
+       packet->additional[0].rdata.netbios.addresses[0].ipaddr =
                talloc_strdup(packet->additional, io->in.address);
 
-       dest = socket_address_from_strings(nbtsock, 
-                                          nbtsock->sock->backend_name, 
+       dest = socket_address_from_strings(nbtsock,
+                                          nbtsock->sock->backend_name,
                                           io->in.dest_addr, io->in.dest_port);
        if (dest == NULL) goto failed;
        req = nbt_name_request_send(nbtsock, dest, packet,
@@ -81,13 +81,13 @@ struct nbt_name_request *nbt_name_refresh_send(struct nbt_name_socket *nbtsock,
 
 failed:
        talloc_free(packet);
-       return NULL;    
+       return NULL;
 }
 
 /*
   wait for a refresh reply
 */
-_PUBLIC_ NTSTATUS nbt_name_refresh_recv(struct nbt_name_request *req, 
+_PUBLIC_ NTSTATUS nbt_name_refresh_recv(struct nbt_name_request *req,
                               TALLOC_CTX *mem_ctx, struct nbt_name_refresh *io)
 {
        NTSTATUS status;
@@ -99,7 +99,7 @@ _PUBLIC_ NTSTATUS nbt_name_refresh_recv(struct nbt_name_request *req,
                talloc_free(req);
                return status;
        }
-       
+
        packet = req->replies[0].packet;
        io->out.reply_from = talloc_steal(mem_ctx, req->replies[0].dest->addr);
 
@@ -116,7 +116,7 @@ _PUBLIC_ NTSTATUS nbt_name_refresh_recv(struct nbt_name_request *req,
                talloc_free(req);
                return NT_STATUS_INVALID_NETWORK_RESPONSE;
        }
-       io->out.reply_addr = talloc_steal(mem_ctx, 
+       io->out.reply_addr = talloc_steal(mem_ctx,
                                          packet->answers[0].rdata.netbios.addresses[0].ipaddr);
        talloc_steal(mem_ctx, io->out.name.name);
        talloc_steal(mem_ctx, io->out.name.scope);
@@ -129,7 +129,7 @@ _PUBLIC_ NTSTATUS nbt_name_refresh_recv(struct nbt_name_request *req,
 /*
   synchronous name refresh request
 */
-_PUBLIC_ NTSTATUS nbt_name_refresh(struct nbt_name_socket *nbtsock, 
+_PUBLIC_ NTSTATUS nbt_name_refresh(struct nbt_name_socket *nbtsock,
                           TALLOC_CTX *mem_ctx, struct nbt_name_refresh *io)
 {
        struct nbt_name_request *req = nbt_name_refresh_send(nbtsock, io);
@@ -159,9 +159,9 @@ struct refresh_wins_state {
 */
 static void name_refresh_wins_handler(struct nbt_name_request *req)
 {
-       struct composite_context *c = talloc_get_type(req->async.private
+       struct composite_context *c = talloc_get_type(req->async.private_data,
                                                      struct composite_context);
-       struct refresh_wins_state *state = talloc_get_type(c->private_data, 
+       struct refresh_wins_state *state = talloc_get_type(c->private_data,
                                                            struct refresh_wins_state);
        NTSTATUS status;
 
@@ -184,7 +184,7 @@ static void name_refresh_wins_handler(struct nbt_name_request *req)
                        c->status = NT_STATUS_NO_MEMORY;
                } else {
                        state->req->async.fn      = name_refresh_wins_handler;
-                       state->req->async.private = c;
+                       state->req->async.private_data = c;
                }
        } else if (!NT_STATUS_IS_OK(status)) {
                c->state = COMPOSITE_STATE_ERROR;
@@ -200,7 +200,7 @@ static void name_refresh_wins_handler(struct nbt_name_request *req)
                                c->status = NT_STATUS_NO_MEMORY;
                        } else {
                                state->req->async.fn      = name_refresh_wins_handler;
-                               state->req->async.private = c;
+                               state->req->async.private_data = c;
                        }
                } else {
                        c->state = COMPOSITE_STATE_DONE;
@@ -235,11 +235,11 @@ _PUBLIC_ struct composite_context *nbt_name_refresh_wins_send(struct nbt_name_so
 
        state->wins_port = io->in.wins_port;
        state->wins_servers = str_list_copy(state, io->in.wins_servers);
-       if (state->wins_servers == NULL || 
+       if (state->wins_servers == NULL ||
            state->wins_servers[0] == NULL) goto failed;
 
        state->addresses = str_list_copy(state, io->in.addresses);
-       if (state->addresses == NULL || 
+       if (state->addresses == NULL ||
            state->addresses[0] == NULL) goto failed;
 
        state->io->in.name            = io->in.name;
@@ -259,7 +259,7 @@ _PUBLIC_ struct composite_context *nbt_name_refresh_wins_send(struct nbt_name_so
        if (state->req == NULL) goto failed;
 
        state->req->async.fn      = name_refresh_wins_handler;
-       state->req->async.private = c;
+       state->req->async.private_data = c;
 
        c->private_data = state;
        c->state        = COMPOSITE_STATE_IN_PROGRESS;
@@ -281,7 +281,7 @@ _PUBLIC_ NTSTATUS nbt_name_refresh_wins_recv(struct composite_context *c, TALLOC
        NTSTATUS status;
        status = composite_wait(c);
        if (NT_STATUS_IS_OK(status)) {
-               struct refresh_wins_state *state = 
+               struct refresh_wins_state *state =
                        talloc_get_type(c->private_data, struct refresh_wins_state);
                io->out.wins_server = talloc_steal(mem_ctx, state->wins_servers[0]);
                io->out.rcode = state->io->out.rcode;
similarity index 95%
rename from source4/libcli/nbt/nameregister.c
rename to libcli/nbt/nameregister.c
index 9c5ae43d4076dd46314603f2db8b1a114106543c..d4728a8e021d3e693de37da044d24f9a941e3404 100644 (file)
@@ -1,27 +1,27 @@
-/* 
+/*
    Unix SMB/CIFS implementation.
 
    send out a name registration request
 
    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/>.
 */
 
 #include "includes.h"
-#include "libcli/nbt/libnbt.h"
-#include "libcli/nbt/nbt_proto.h"
+#include "../libcli/nbt/libnbt.h"
+#include "../libcli/nbt/nbt_proto.h"
 #include "libcli/composite/composite.h"
 #include "lib/socket/socket.h"
 #include "librpc/gen_ndr/ndr_nbt.h"
@@ -73,11 +73,11 @@ struct nbt_name_request *nbt_name_register_send(struct nbt_name_socket *nbtsock,
                                                                     struct nbt_rdata_address, 1);
        if (packet->additional[0].rdata.netbios.addresses == NULL) goto failed;
        packet->additional[0].rdata.netbios.addresses[0].nb_flags = io->in.nb_flags;
-       packet->additional[0].rdata.netbios.addresses[0].ipaddr = 
+       packet->additional[0].rdata.netbios.addresses[0].ipaddr =
                talloc_strdup(packet->additional, io->in.address);
        if (packet->additional[0].rdata.netbios.addresses[0].ipaddr == NULL) goto failed;
 
-       dest = socket_address_from_strings(packet, nbtsock->sock->backend_name, 
+       dest = socket_address_from_strings(packet, nbtsock->sock->backend_name,
                                           io->in.dest_addr, io->in.dest_port);
        if (dest == NULL) goto failed;
        req = nbt_name_request_send(nbtsock, dest, packet,
@@ -89,13 +89,13 @@ struct nbt_name_request *nbt_name_register_send(struct nbt_name_socket *nbtsock,
 
 failed:
        talloc_free(packet);
-       return NULL;    
+       return NULL;
 }
 
 /*
   wait for a registration reply
 */
-_PUBLIC_ NTSTATUS nbt_name_register_recv(struct nbt_name_request *req, 
+_PUBLIC_ NTSTATUS nbt_name_register_recv(struct nbt_name_request *req,
                                TALLOC_CTX *mem_ctx, struct nbt_name_register *io)
 {
        NTSTATUS status;
@@ -107,7 +107,7 @@ _PUBLIC_ NTSTATUS nbt_name_register_recv(struct nbt_name_request *req,
                talloc_free(req);
                return status;
        }
-       
+
        packet = req->replies[0].packet;
        io->out.reply_from = talloc_steal(mem_ctx, req->replies[0].dest->addr);
 
@@ -124,11 +124,11 @@ _PUBLIC_ NTSTATUS nbt_name_register_recv(struct nbt_name_request *req,
                talloc_free(req);
                return NT_STATUS_INVALID_NETWORK_RESPONSE;
        }
-       io->out.reply_addr = talloc_steal(mem_ctx, 
+       io->out.reply_addr = talloc_steal(mem_ctx,
                                          packet->answers[0].rdata.netbios.addresses[0].ipaddr);
        talloc_steal(mem_ctx, io->out.name.name);
        talloc_steal(mem_ctx, io->out.name.scope);
-           
+
        talloc_free(req);
 
        return NT_STATUS_OK;
@@ -137,7 +137,7 @@ _PUBLIC_ NTSTATUS nbt_name_register_recv(struct nbt_name_request *req,
 /*
   synchronous name registration request
 */
-_PUBLIC_ NTSTATUS nbt_name_register(struct nbt_name_socket *nbtsock, 
+_PUBLIC_ NTSTATUS nbt_name_register(struct nbt_name_socket *nbtsock,
                           TALLOC_CTX *mem_ctx, struct nbt_name_register *io)
 {
        struct nbt_name_request *req = nbt_name_register_send(nbtsock, io);
@@ -161,7 +161,7 @@ struct register_bcast_state {
 */
 static void name_register_bcast_handler(struct nbt_name_request *req)
 {
-       struct composite_context *c = talloc_get_type(req->async.private, struct composite_context);
+       struct composite_context *c = talloc_get_type(req->async.private_data, struct composite_context);
        struct register_bcast_state *state = talloc_get_type(c->private_data, struct register_bcast_state);
        NTSTATUS status;
 
@@ -183,7 +183,7 @@ static void name_register_bcast_handler(struct nbt_name_request *req)
                        c->status = NT_STATUS_NO_MEMORY;
                } else {
                        state->req->async.fn      = name_register_bcast_handler;
-                       state->req->async.private = c;
+                       state->req->async.private_data = c;
                }
        } else if (!NT_STATUS_IS_OK(status)) {
                c->state = COMPOSITE_STATE_ERROR;
@@ -192,7 +192,7 @@ static void name_register_bcast_handler(struct nbt_name_request *req)
                c->state = COMPOSITE_STATE_ERROR;
                c->status = NT_STATUS_CONFLICTING_ADDRESSES;
                DEBUG(3,("Name registration conflict from %s for %s with ip %s - rcode %d\n",
-                        state->io->out.reply_from, 
+                        state->io->out.reply_from,
                         nbt_name_string(state, &state->io->out.name),
                         state->io->out.reply_addr,
                         state->io->out.rcode));
@@ -241,7 +241,7 @@ _PUBLIC_ struct composite_context *nbt_name_register_bcast_send(struct nbt_name_
        if (state->req == NULL) goto failed;
 
        state->req->async.fn      = name_register_bcast_handler;
-       state->req->async.private = c;
+       state->req->async.private_data = c;
 
        c->private_data = state;
        c->state        = COMPOSITE_STATE_IN_PROGRESS;
@@ -297,9 +297,9 @@ struct register_wins_state {
 */
 static void name_register_wins_handler(struct nbt_name_request *req)
 {
-       struct composite_context *c = talloc_get_type(req->async.private
+       struct composite_context *c = talloc_get_type(req->async.private_data,
                                                      struct composite_context);
-       struct register_wins_state *state = talloc_get_type(c->private_data, 
+       struct register_wins_state *state = talloc_get_type(c->private_data,
                                                            struct register_wins_state);
        NTSTATUS status;
 
@@ -322,7 +322,7 @@ static void name_register_wins_handler(struct nbt_name_request *req)
                        c->status = NT_STATUS_NO_MEMORY;
                } else {
                        state->req->async.fn      = name_register_wins_handler;
-                       state->req->async.private = c;
+                       state->req->async.private_data = c;
                }
        } else if (!NT_STATUS_IS_OK(status)) {
                c->state = COMPOSITE_STATE_ERROR;
@@ -338,7 +338,7 @@ static void name_register_wins_handler(struct nbt_name_request *req)
                                c->status = NT_STATUS_NO_MEMORY;
                        } else {
                                state->req->async.fn      = name_register_wins_handler;
-                               state->req->async.private = c;
+                               state->req->async.private_data = c;
                        }
                } else {
                        c->state = COMPOSITE_STATE_DONE;
@@ -373,11 +373,11 @@ _PUBLIC_ struct composite_context *nbt_name_register_wins_send(struct nbt_name_s
 
        state->wins_port = io->in.wins_port;
        state->wins_servers = str_list_copy(state, io->in.wins_servers);
-       if (state->wins_servers == NULL || 
+       if (state->wins_servers == NULL ||
            state->wins_servers[0] == NULL) goto failed;
 
        state->addresses = str_list_copy(state, io->in.addresses);
-       if (state->addresses == NULL || 
+       if (state->addresses == NULL ||
            state->addresses[0] == NULL) goto failed;
 
        state->io->in.name            = io->in.name;
@@ -399,7 +399,7 @@ _PUBLIC_ struct composite_context *nbt_name_register_wins_send(struct nbt_name_s
        if (state->req == NULL) goto failed;
 
        state->req->async.fn      = name_register_wins_handler;
-       state->req->async.private = c;
+       state->req->async.private_data = c;
 
        c->private_data = state;
        c->state        = COMPOSITE_STATE_IN_PROGRESS;
@@ -421,7 +421,7 @@ _PUBLIC_ NTSTATUS nbt_name_register_wins_recv(struct composite_context *c, TALLO
        NTSTATUS status;
        status = composite_wait(c);
        if (NT_STATUS_IS_OK(status)) {
-               struct register_wins_state *state = 
+               struct register_wins_state *state =
                        talloc_get_type(c->private_data, struct register_wins_state);
                io->out.wins_server = talloc_steal(mem_ctx, state->wins_servers[0]);
                io->out.rcode = state->io->out.rcode;
similarity index 94%
rename from source4/libcli/nbt/namerelease.c
rename to libcli/nbt/namerelease.c
index ba3af417529df0355c203a54874b0d25a9bbae30..e57a2f396e8705f7e1fc50e73b2561e747e78dc5 100644 (file)
@@ -1,27 +1,27 @@
-/* 
+/*
    Unix SMB/CIFS implementation.
 
    send out a name release request
 
    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/>.
 */
 
 #include "includes.h"
-#include "libcli/nbt/libnbt.h"
-#include "libcli/nbt/nbt_proto.h"
+#include "../libcli/nbt/libnbt.h"
+#include "../libcli/nbt/nbt_proto.h"
 #include "lib/socket/socket.h"
 #include "param/param.h"
 
@@ -64,10 +64,10 @@ _PUBLIC_ struct nbt_name_request *nbt_name_release_send(struct nbt_name_socket *
                                                                     struct nbt_rdata_address, 1);
        if (packet->additional[0].rdata.netbios.addresses == NULL) goto failed;
        packet->additional[0].rdata.netbios.addresses[0].nb_flags = io->in.nb_flags;
-       packet->additional[0].rdata.netbios.addresses[0].ipaddr = 
+       packet->additional[0].rdata.netbios.addresses[0].ipaddr =
                talloc_strdup(packet->additional, io->in.address);
 
-       dest = socket_address_from_strings(packet, nbtsock->sock->backend_name, 
+       dest = socket_address_from_strings(packet, nbtsock->sock->backend_name,
                                           io->in.dest_addr, io->in.dest_port);
        if (dest == NULL) goto failed;
        req = nbt_name_request_send(nbtsock, dest, packet,
@@ -79,13 +79,13 @@ _PUBLIC_ struct nbt_name_request *nbt_name_release_send(struct nbt_name_socket *
 
 failed:
        talloc_free(packet);
-       return NULL;    
+       return NULL;
 }
 
 /*
   wait for a release reply
 */
-_PUBLIC_ NTSTATUS nbt_name_release_recv(struct nbt_name_request *req, 
+_PUBLIC_ NTSTATUS nbt_name_release_recv(struct nbt_name_request *req,
                               TALLOC_CTX *mem_ctx, struct nbt_name_release *io)
 {
        NTSTATUS status;
@@ -97,7 +97,7 @@ _PUBLIC_ NTSTATUS nbt_name_release_recv(struct nbt_name_request *req,
                talloc_free(req);
                return status;
        }
-       
+
        packet = req->replies[0].packet;
        io->out.reply_from = talloc_steal(mem_ctx, req->replies[0].dest->addr);
 
@@ -114,7 +114,7 @@ _PUBLIC_ NTSTATUS nbt_name_release_recv(struct nbt_name_request *req,
                talloc_free(req);
                return NT_STATUS_INVALID_NETWORK_RESPONSE;
        }
-       io->out.reply_addr = talloc_steal(mem_ctx, 
+       io->out.reply_addr = talloc_steal(mem_ctx,
                                          packet->answers[0].rdata.netbios.addresses[0].ipaddr);
        talloc_steal(mem_ctx, io->out.name.name);
        talloc_steal(mem_ctx, io->out.name.scope);
@@ -127,7 +127,7 @@ _PUBLIC_ NTSTATUS nbt_name_release_recv(struct nbt_name_request *req,
 /*
   synchronous name release request
 */
-_PUBLIC_ NTSTATUS nbt_name_release(struct nbt_name_socket *nbtsock, 
+_PUBLIC_ NTSTATUS nbt_name_release(struct nbt_name_socket *nbtsock,
                           TALLOC_CTX *mem_ctx, struct nbt_name_release *io)
 {
        struct nbt_name_request *req = nbt_name_release_send(nbtsock, io);
similarity index 96%
rename from source4/libcli/nbt/nbtname.c
rename to libcli/nbt/nbtname.c
index 97ae2e9d724974b8c9eee3050a9c64954adec135..338cb210897e71f45fb8627241a86806839473f5 100644 (file)
@@ -1,20 +1,20 @@
-/* 
+/*
    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/>.
 */
@@ -27,7 +27,6 @@
 #include "librpc/gen_ndr/ndr_nbt.h"
 #include "librpc/gen_ndr/ndr_misc.h"
 #include "system/locale.h"
-#include "param/param.h"
 
 /* don't allow an unlimited number of name components */
 #define MAX_COMPONENTS 10
@@ -112,7 +111,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_nbt_string(struct ndr_pull *ndr, int ndr_fla
 
        /* break up name into a list of components */
        for (num_components=0;num_components<MAX_COMPONENTS;num_components++) {
-               uint8_t *component;
+               uint8_t *component = NULL;
                NDR_CHECK(ndr_pull_component(ndr, &component, &offset, &max_offset));
                if (component == NULL) break;
                if (name) {
@@ -158,7 +157,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_nbt_string(struct ndr_push *ndr, int ndr_fla
                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",
@@ -219,7 +218,7 @@ static bool decompress_name(char *name, enum nbt_name_type *type)
                    c2 < 'A' || c2 > 'P') {
                        return false;
                }
-               name[i] = ((c1-'A')<<4) | (c2-'A');                 
+               name[i] = ((c1-'A')<<4) | (c2-'A');
        }
        name[i] = 0;
        if (i == 16) {
@@ -234,7 +233,7 @@ static bool decompress_name(char *name, enum nbt_name_type *type)
        for (;i>0 && name[i-1]==' ';i--) {
                name[i-1] = 0;
        }
-       
+
        return true;
 }
 
@@ -242,7 +241,7 @@ static bool decompress_name(char *name, enum nbt_name_type *type)
 /*
   compress a name component
  */
-static uint8_t *compress_name(TALLOC_CTX *mem_ctx, 
+static uint8_t *compress_name(TALLOC_CTX *mem_ctx,
                              const uint8_t *name, enum nbt_name_type type)
 {
        uint8_t *cname;
@@ -356,7 +355,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_nbt_name(struct ndr_push *ndr, int ndr_flags
        } else {
                fullname = cname;
        }
-       
+
        ndr_err = ndr_push_nbt_string(ndr, ndr_flags, (const char *)fullname);
 
        return ndr_err;
@@ -422,7 +421,7 @@ _PUBLIC_ void nbt_choose_called_name(TALLOC_CTX *mem_ctx,
        n->scope = NULL;
        n->type = type;
 
-       if (is_ipaddress(name) || name == NULL) {
+       if ((name == NULL) || is_ipaddress(name)) {
                n->name = "*SMBSERVER";
                return;
        }
@@ -434,11 +433,11 @@ _PUBLIC_ void nbt_choose_called_name(TALLOC_CTX *mem_ctx,
                        return;
                }
                s = talloc_strndup(mem_ctx, name, PTR_DIFF(p, name));
-               n->name = strupper_talloc(mem_ctx, s);
+               n->name = talloc_strdup_upper(mem_ctx, s);
                return;
        }
 
-       n->name = strupper_talloc(mem_ctx, name);
+       n->name = talloc_strdup_upper(mem_ctx, name);
 }
 
 
@@ -483,14 +482,14 @@ _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) {              
+       if (name->scope) {
                ret = talloc_asprintf(mem_ctx, "%s<%02x>-%s",
                                      nbt_hex_encode(tmp_ctx, name->name),
-                                     name->type, 
+                                     name->type,
                                      nbt_hex_encode(tmp_ctx, name->scope));
        } else {
-               ret = talloc_asprintf(mem_ctx, "%s<%02x>", 
-                                     nbt_hex_encode(tmp_ctx, name->name), 
+               ret = talloc_asprintf(mem_ctx, "%s<%02x>",
+                                     nbt_hex_encode(tmp_ctx, name->name),
                                      name->type);
        }
        talloc_free(tmp_ctx);
@@ -518,7 +517,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_wrepl_nbt_name(struct ndr_pull *ndr, int ndr
        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); 
+       NDR_PULL_ALLOC(ndr, r);
 
        /* oh wow, what a nasty bug in windows ... */
        if (namebuf[0] == 0x1b && namebuf_len >= 16) {
@@ -565,7 +564,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_wrepl_nbt_name(struct ndr_push *ndr, int ndr
 {
        uint8_t *namebuf;
        uint32_t namebuf_len;
-       uint32_t name_len;
+       uint32_t _name_len;
        uint32_t scope_len = 0;
 
        if (r == NULL) {
@@ -577,8 +576,8 @@ _PUBLIC_ enum ndr_err_code ndr_push_wrepl_nbt_name(struct ndr_push *ndr, int ndr
                return NDR_ERR_SUCCESS;
        }
 
-       name_len = strlen(r->name);
-       if (name_len > 15) {
+       _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);
similarity index 91%
rename from source4/libcli/nbt/nbtsocket.c
rename to libcli/nbt/nbtsocket.c
index 5d4611e2d95a32c508d3dd0b676889ec6f667906..57531d2e7b404fa4982bf2880dad696d6fcc18b6 100644 (file)
@@ -1,20 +1,20 @@
-/* 
+/*
    Unix SMB/CIFS implementation.
 
    low level socket handling for nbt requests
 
    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/>.
 */
@@ -22,7 +22,7 @@
 #include "includes.h"
 #include "lib/events/events.h"
 #include "lib/util/dlinklist.h"
-#include "libcli/nbt/libnbt.h"
+#include "../libcli/nbt/libnbt.h"
 #include "lib/socket/socket.h"
 #include "librpc/gen_ndr/ndr_nbt.h"
 #include "param/param.h"
@@ -33,7 +33,7 @@
   destroy a pending request
 */
 static int nbt_name_request_destructor(struct nbt_name_request *req)
-{      
+{
        if (req->state == NBT_REQUEST_SEND) {
                DLIST_REMOVE(req->nbtsock->send_queue, req);
        }
@@ -51,7 +51,7 @@ static int nbt_name_request_destructor(struct nbt_name_request *req)
        if (req->nbtsock->send_queue == NULL) {
                EVENT_FD_NOT_WRITEABLE(req->nbtsock->fde);
        }
-       if (req->nbtsock->num_pending == 0 && 
+       if (req->nbtsock->num_pending == 0 &&
            req->nbtsock->incoming.handler == NULL) {
                EVENT_FD_NOT_READABLE(req->nbtsock->fde);
        }
@@ -70,11 +70,11 @@ static void nbt_name_socket_send(struct nbt_name_socket *nbtsock)
 
        while ((req = nbtsock->send_queue)) {
                size_t len;
-               
+
                len = req->encoded.length;
-               status = socket_sendto(nbtsock->sock, &req->encoded, &len, 
+               status = socket_sendto(nbtsock->sock, &req->encoded, &len,
                                       req->dest);
-               if (NT_STATUS_IS_ERR(status)) goto failed;              
+               if (NT_STATUS_IS_ERR(status)) goto failed;
 
                if (!NT_STATUS_IS_OK(status)) {
                        talloc_free(tmp_ctx);
@@ -116,17 +116,17 @@ failed:
 static void nbt_name_socket_timeout(struct event_context *ev, struct timed_event *te,
                                    struct timeval t, void *private)
 {
-       struct nbt_name_request *req = talloc_get_type(private, 
+       struct nbt_name_request *req = talloc_get_type(private,
                                                       struct nbt_name_request);
 
        if (req->num_retries != 0) {
                req->num_retries--;
-               req->te = event_add_timed(req->nbtsock->event_ctx, req, 
+               req->te = event_add_timed(req->nbtsock->event_ctx, req,
                                          timeval_add(&t, req->timeout, 0),
                                          nbt_name_socket_timeout, req);
                if (req->state != NBT_REQUEST_SEND) {
                        req->state = NBT_REQUEST_SEND;
-                       DLIST_ADD_END(req->nbtsock->send_queue, req, 
+                       DLIST_ADD_END(req->nbtsock->send_queue, req,
                                      struct nbt_name_request *);
                }
                EVENT_FD_WRITEABLE(req->nbtsock->fde);
@@ -201,7 +201,7 @@ static void nbt_name_socket_recv(struct nbt_name_socket *nbtsock)
        }
 
        if (DEBUGLVL(10)) {
-               DEBUG(10,("Received nbt packet of length %d from %s:%d\n", 
+               DEBUG(10,("Received nbt packet of length %d from %s:%d\n",
                          (int)blob.length, src->addr, src->port));
                NDR_PRINT_DEBUG(nbt_name_packet, packet);
        }
@@ -217,7 +217,7 @@ static void nbt_name_socket_recv(struct nbt_name_socket *nbtsock)
        }
 
        /* find the matching request */
-       req = (struct nbt_name_request *)idr_find(nbtsock->idr, 
+       req = (struct nbt_name_request *)idr_find(nbtsock->idr,
                                                  packet->name_trn_id);
        if (req == NULL) {
                if (nbtsock->unexpected.handler) {
@@ -245,15 +245,15 @@ static void nbt_name_socket_recv(struct nbt_name_socket *nbtsock)
                req->num_retries   = 0;
                req->received_wack = true;
                /* although there can be a timeout in the packet, w2k3 screws it up,
-                  so better to set it ourselves */                
+                  so better to set it ourselves */
                req->timeout = lp_parm_int(global_loadparm, NULL, "nbt", "wack_timeout", 30);
-               req->te = event_add_timed(req->nbtsock->event_ctx, req, 
+               req->te = event_add_timed(req->nbtsock->event_ctx, req,
                                          timeval_current_ofs(req->timeout, 0),
                                          nbt_name_socket_timeout, req);
                talloc_free(tmp_ctx);
                return;
        }
-       
+
 
        req->replies = talloc_realloc(req, req->replies, struct nbt_name_reply, req->num_replies+1);
        if (req->replies == NULL) {
@@ -293,11 +293,11 @@ done:
 static void nbt_name_socket_handler(struct event_context *ev, struct fd_event *fde,
                                    uint16_t flags, void *private)
 {
-       struct nbt_name_socket *nbtsock = talloc_get_type(private, 
+       struct nbt_name_socket *nbtsock = talloc_get_type(private,
                                                          struct nbt_name_socket);
        if (flags & EVENT_FD_WRITE) {
                nbt_name_socket_send(nbtsock);
-       } 
+       }
        if (flags & EVENT_FD_READ) {
                nbt_name_socket_recv(nbtsock);
        }
@@ -308,7 +308,7 @@ static void nbt_name_socket_handler(struct event_context *ev, struct fd_event *f
   initialise a nbt_name_socket. The event_ctx is optional, if provided
   then operations will use that event context
 */
-_PUBLIC_ struct nbt_name_socket *nbt_name_socket_init(TALLOC_CTX *mem_ctx, 
+_PUBLIC_ struct nbt_name_socket *nbt_name_socket_init(TALLOC_CTX *mem_ctx,
                                             struct event_context *event_ctx,
                                             struct smb_iconv_convenience *iconv_convenience)
 {
@@ -337,10 +337,10 @@ _PUBLIC_ struct nbt_name_socket *nbt_name_socket_init(TALLOC_CTX *mem_ctx,
        nbtsock->unexpected.handler = NULL;
        nbtsock->iconv_convenience = iconv_convenience;
 
-       nbtsock->fde = event_add_fd(nbtsock->event_ctx, nbtsock, 
+       nbtsock->fde = event_add_fd(nbtsock->event_ctx, nbtsock,
                                    socket_get_fd(nbtsock->sock), 0,
                                    nbt_name_socket_handler, nbtsock);
-       
+
        return nbtsock;
 
 failed:
@@ -351,7 +351,7 @@ failed:
 /*
   send off a nbt name request
 */
-struct nbt_name_request *nbt_name_request_send(struct nbt_name_socket *nbtsock, 
+struct nbt_name_request *nbt_name_request_send(struct nbt_name_socket *nbtsock,
                                               struct socket_address *dest,
                                               struct nbt_name_packet *request,
                                               int timeout, int retries,
@@ -378,7 +378,7 @@ struct nbt_name_request *nbt_name_request_send(struct nbt_name_socket *nbtsock,
                id = idr_get_new_random(req->nbtsock->idr, req, UINT16_MAX);
        } else {
                if (idr_find(req->nbtsock->idr, request->name_trn_id)) goto failed;
-               id = idr_get_new_above(req->nbtsock->idr, req, request->name_trn_id, 
+               id = idr_get_new_above(req->nbtsock->idr, req, request->name_trn_id,
                                       UINT16_MAX);
        }
        if (id == -1) goto failed;
@@ -386,13 +386,13 @@ struct nbt_name_request *nbt_name_request_send(struct nbt_name_socket *nbtsock,
        request->name_trn_id = id;
        req->name_trn_id     = id;
 
-       req->te = event_add_timed(nbtsock->event_ctx, req, 
+       req->te = event_add_timed(nbtsock->event_ctx, req,
                                  timeval_current_ofs(req->timeout, 0),
                                  nbt_name_socket_timeout, req);
-       
-       talloc_set_destructor(req, nbt_name_request_destructor);        
 
-       ndr_err = ndr_push_struct_blob(&req->encoded, req, 
+       talloc_set_destructor(req, nbt_name_request_destructor);
+
+       ndr_err = ndr_push_struct_blob(&req->encoded, req,
                                       req->nbtsock->iconv_convenience,
                                       request,
                                       (ndr_push_flags_fn_t)ndr_push_nbt_name_packet);
@@ -401,7 +401,7 @@ struct nbt_name_request *nbt_name_request_send(struct nbt_name_socket *nbtsock,
        DLIST_ADD_END(nbtsock->send_queue, req, struct nbt_name_request *);
 
        if (DEBUGLVL(10)) {
-               DEBUG(10,("Queueing nbt packet to %s:%d\n", 
+               DEBUG(10,("Queueing nbt packet to %s:%d\n",
                          req->dest->addr, req->dest->port));
                NDR_PRINT_DEBUG(nbt_name_packet, request);
        }
@@ -419,7 +419,7 @@ failed:
 /*
   send off a nbt name reply
 */
-_PUBLIC_ NTSTATUS nbt_name_reply_send(struct nbt_name_socket *nbtsock, 
+_PUBLIC_ NTSTATUS nbt_name_reply_send(struct nbt_name_socket *nbtsock,
                             struct socket_address *dest,
                             struct nbt_name_packet *request)
 {
@@ -435,13 +435,13 @@ _PUBLIC_ NTSTATUS nbt_name_reply_send(struct nbt_name_socket *nbtsock,
        req->state     = NBT_REQUEST_SEND;
        req->is_reply = true;
 
-       talloc_set_destructor(req, nbt_name_request_destructor);        
+       talloc_set_destructor(req, nbt_name_request_destructor);
 
        if (DEBUGLVL(10)) {
-               NDR_PRINT_DEBUG(nbt_name_packet, request);              
+               NDR_PRINT_DEBUG(nbt_name_packet, request);
        }
 
-       ndr_err = ndr_push_struct_blob(&req->encoded, req, 
+       ndr_err = ndr_push_struct_blob(&req->encoded, req,
                                       req->nbtsock->iconv_convenience,
                                       request,
                                       (ndr_push_flags_fn_t)ndr_push_nbt_name_packet);
@@ -483,12 +483,12 @@ NTSTATUS nbt_name_request_recv(struct nbt_name_request *req)
   setup a handler for incoming requests
 */
 _PUBLIC_ NTSTATUS nbt_set_incoming_handler(struct nbt_name_socket *nbtsock,
-                                 void (*handler)(struct nbt_name_socket *, struct nbt_name_packet *, 
+                                 void (*handler)(struct nbt_name_socket *, struct nbt_name_packet *,
                                                  struct socket_address *),
                                  void *private)
 {
        nbtsock->incoming.handler = handler;
-       nbtsock->incoming.private = private;
+       nbtsock->incoming.private_data = private;
        EVENT_FD_READABLE(nbtsock->fde);
        return NT_STATUS_OK;
 }
similarity index 94%
rename from source4/libcli/nbt/pynbt.c
rename to libcli/nbt/pynbt.c
index e91096630a2f5e3ddbe7fe98f545c5bfaac1cdcd..e49c1776a3379c5124d1d258ba23b237588ef47f 100644 (file)
@@ -1,18 +1,18 @@
-/* 
+/*
    Unix SMB/CIFS implementation.
    Samba utility functions
    Copyright © 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/>.
 */
@@ -20,7 +20,7 @@
 #include "includes.h"
 #include <Python.h>
 #include "libcli/util/pyerrors.h"
-#include "libcli/nbt/libnbt.h"
+#include "../libcli/nbt/libnbt.h"
 #include "lib/events/events.h"
 #include "param/param.h"
 
@@ -48,7 +48,7 @@ static PyObject *py_nbt_node_init(PyTypeObject *self, PyObject *args, PyObject *
                return NULL;
 
        ev = s4_event_context_init(ret->mem_ctx);
-       ret->socket = nbt_name_socket_init(ret->mem_ctx, ev, lp_iconv_convenience(global_loadparm)); 
+       ret->socket = nbt_name_socket_init(ret->mem_ctx, ev, lp_iconv_convenience(global_loadparm));
        return (PyObject *)ret;
 }
 
@@ -58,14 +58,14 @@ static bool PyObject_AsDestinationTuple(PyObject *obj, const char **dest_addr, u
                *dest_addr = PyString_AsString(obj);
                *dest_port = NBT_NAME_SERVICE_PORT;
                return true;
-       } 
+       }
 
        if (PyTuple_Check(obj)) {
                if (PyTuple_Size(obj) < 1) {
                        PyErr_SetString(PyExc_TypeError, "Destination tuple size invalid");
                        return false;
                }
-               
+
                if (!PyString_Check(PyTuple_GetItem(obj, 0))) {
                        PyErr_SetString(PyExc_TypeError, "Destination tuple first element not string");
                        return false;
@@ -120,7 +120,7 @@ static bool PyObject_AsNBTName(PyObject *obj, struct nbt_name_socket *socket, st
        return false;
 }
 
-static PyObject *PyObject_FromNBTName(struct nbt_name_socket *socket, struct smb_iconv_convenience *ic, 
+static PyObject *PyObject_FromNBTName(struct nbt_name_socket *socket, struct smb_iconv_convenience *ic,
                                      struct nbt_name *name)
 {
        if (name->scope) {
@@ -145,10 +145,10 @@ static PyObject *py_nbt_name_query(PyObject *self, PyObject *args, PyObject *kwa
        io.in.timeout = 0;
        io.in.retries = 3;
 
-       if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|bbii:query_name", 
+       if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|bbii:query_name",
                                         discard_const_p(char *, kwnames),
-                                        &py_name, &py_dest, 
-                                        &io.in.broadcast, &io.in.wins_lookup, 
+                                        &py_name, &py_dest,
+                                        &io.in.broadcast, &io.in.wins_lookup,
                                         &io.in.timeout, &io.in.retries)) {
                return NULL;
        }
@@ -182,7 +182,7 @@ static PyObject *py_nbt_name_query(PyObject *self, PyObject *args, PyObject *kwa
                Py_DECREF(ret);
                return NULL;
        }
-       
+
        for (i = 0; i < io.out.num_addrs; i++) {
                PyList_SetItem(reply_addrs, i, PyString_FromString(io.out.reply_addrs[i]));
        }
@@ -204,9 +204,9 @@ static PyObject *py_nbt_name_status(PyObject *self, PyObject *args, PyObject *kw
        io.in.timeout = 0;
        io.in.retries = 0;
 
-       if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|ii:name_status", 
+       if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|ii:name_status",
                                         discard_const_p(char *, kwnames),
-                                        &py_name, &py_dest, 
+                                        &py_name, &py_dest,
                                         &io.in.timeout, &io.in.retries)) {
                return NULL;
        }
@@ -238,9 +238,9 @@ static PyObject *py_nbt_name_status(PyObject *self, PyObject *args, PyObject *kw
        py_names = PyList_New(io.out.status.num_names);
 
        for (i = 0; i < io.out.status.num_names; i++) {
-               PyList_SetItem(py_names, i, Py_BuildValue("(sii)", 
+               PyList_SetItem(py_names, i, Py_BuildValue("(sii)",
                                io.out.status.names[i].name,
-                               io.out.status.names[i].nb_flags, 
+                               io.out.status.names[i].nb_flags,
                                io.out.status.names[i].type));
        }
 
@@ -256,7 +256,7 @@ static PyObject *py_nbt_name_register(PyObject *self, PyObject *args, PyObject *
        struct nbt_name_register io;
        NTSTATUS status;
 
-       const char *kwnames[] = { "name", "address", "dest", "register_demand", "broadcast", 
+       const char *kwnames[] = { "name", "address", "dest", "register_demand", "broadcast",
                                  "multi_homed", "ttl", "timeout", "retries", NULL };
 
        io.in.broadcast = true;
@@ -265,11 +265,11 @@ static PyObject *py_nbt_name_register(PyObject *self, PyObject *args, PyObject *
        io.in.timeout = 0;
        io.in.retries = 0;
 
-       if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OsO|bbbiii:query_name", 
+       if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OsO|bbbiii:query_name",
                                         discard_const_p(char *, kwnames),
-                                        &py_name, &io.in.address, &py_dest, 
-                                        &io.in.register_demand, 
-                                        &io.in.broadcast, &io.in.multi_homed, 
+                                        &py_name, &io.in.address, &py_dest,
+                                        &io.in.register_demand,
+                                        &io.in.broadcast, &io.in.multi_homed,
                                         &io.in.ttl, &io.in.timeout, &io.in.retries)) {
                return NULL;
        }
@@ -312,7 +312,7 @@ static PyObject *py_nbt_name_refresh(PyObject *self, PyObject *args, PyObject *k
        struct nbt_name_refresh io;
        NTSTATUS status;
 
-       const char *kwnames[] = { "name", "address", "dest", "nb_flags", "broadcast", 
+       const char *kwnames[] = { "name", "address", "dest", "nb_flags", "broadcast",
                                  "ttl", "timeout", "retries", NULL };
 
        io.in.broadcast = true;
@@ -320,11 +320,11 @@ static PyObject *py_nbt_name_refresh(PyObject *self, PyObject *args, PyObject *k
        io.in.timeout = 0;
        io.in.retries = 0;
 
-       if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OsO|ibiii:query_name", 
+       if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OsO|ibiii:query_name",
                                         discard_const_p(char *, kwnames),
-                                        &py_name, &io.in.address, &py_dest, 
-                                        &io.in.nb_flags, 
-                                        &io.in.broadcast, 
+                                        &py_name, &io.in.address, &py_dest,
+                                        &io.in.nb_flags,
+                                        &io.in.broadcast,
                                         &io.in.ttl, &io.in.timeout, &io.in.retries)) {
                return NULL;
        }
@@ -366,7 +366,7 @@ static PyObject *py_nbt_name_release(PyObject *self, PyObject *args, PyObject *k
 }
 
 static PyMethodDef py_nbt_methods[] = {
-       { "query_name", (PyCFunction)py_nbt_name_query, METH_VARARGS|METH_KEYWORDS, 
+       { "query_name", (PyCFunction)py_nbt_name_query, METH_VARARGS|METH_KEYWORDS,
                "S.query_name(name, dest, broadcast=True, wins=False, timeout=0, retries=3) -> (reply_from, name, reply_addr)\n"
                "Query for a NetBIOS name" },
        { "register_name", (PyCFunction)py_nbt_name_register, METH_VARARGS|METH_KEYWORDS,
index e58442ba1b696edb0eb84b0cad392ac720dd1aa7..577db0a53fda2852f408263bb1e20d6656f1d744 100755 (executable)
--- a/pidl/pidl
+++ b/pidl/pidl
@@ -17,7 +17,7 @@ pidl - An IDL compiler written in Perl
 
 pidl --help
 
-pidl [--outputdir[=OUTNAME]] [--includedir DIR...] [--parse-idl-tree] [--dump-idl-tree] [--dump-ndr-tree] [--header[=OUTPUT]] [--ejs[=OUTPUT]] [--python[=OUTPUT]] [--swig[=OUTPUT]] [--ndr-parser[=OUTPUT]] [--client] [--server] [--warn-compat] [--quiet] [--verbose] [--template] [--ws-parser[=OUTPUT]] [--diff] [--dump-idl] [--tdr-parser[=OUTPUT]] [--samba3-ndr-client[=OUTPUT]] [--samba3-ndr-server[=OUTPUT]] [--typelib=[OUTPUT]] [<idlfile>.idl]...
+pidl [--outputdir[=OUTNAME]] [--includedir DIR...] [--parse-idl-tree] [--dump-idl-tree] [--dump-ndr-tree] [--header[=OUTPUT]] [--python[=OUTPUT]] [--swig[=OUTPUT]] [--ndr-parser[=OUTPUT]] [--client] [--server] [--warn-compat] [--quiet] [--verbose] [--template] [--ws-parser[=OUTPUT]] [--diff] [--dump-idl] [--tdr-parser[=OUTPUT]] [--samba3-ndr-client[=OUTPUT]] [--samba3-ndr-server[=OUTPUT]] [--typelib=[OUTPUT]] [<idlfile>.idl]...
 
 =head1 DESCRIPTION
 
@@ -478,7 +478,6 @@ my($opt_ndr_parser);
 my($opt_tdr_parser);
 my($opt_ws_parser);
 my($opt_swig);
-my($opt_ejs);
 my($opt_python);
 my($opt_quiet) = 0;
 my($opt_outputdir) = '.';
@@ -521,7 +520,6 @@ Samba 4 output:
  --ndr-parser[=OUTFILE]  create a C NDR parser [ndr_BASENAME.c]
  --client[=OUTFILE]      create a C NDR client [ndr_BASENAME_c.c]
  --tdr-parser[=OUTFILE]  create a C TDR parser [tdr_BASENAME.c]
- --ejs[=OUTFILE]         create ejs wrapper file [BASENAME_ejs.c]
  --python[=OUTFILE]      create python wrapper file [py_BASENAME.c]
  --swig[=OUTFILE]        create swig wrapper file [BASENAME.i]
  --server[=OUTFILE]      create server boilerplate [ndr_BASENAME_s.c]
@@ -567,7 +565,6 @@ my $result = GetOptions (
            'ndr-parser:s' => \$opt_ndr_parser,
            'client:s' => \$opt_client,
            'ws-parser:s' => \$opt_ws_parser,
-           'ejs' => \$opt_ejs,
                'python' => \$opt_python,
            'diff' => \$opt_diff,
            'swig:s' => \$opt_swig,
@@ -664,7 +661,6 @@ sub process_file($)
            defined($opt_server) or 
            defined($opt_header) or
            defined($opt_ndr_parser) or
-           defined($opt_ejs) or 
            defined($opt_python) or 
            defined($opt_dump_ndr_tree) or
            defined($opt_samba3_header) or 
@@ -709,14 +705,6 @@ sub process_file($)
                  FileSave($filename, $code);
        }
 
-       if (defined($opt_ejs)) {
-               require Parse::Pidl::Samba4::EJS;
-               my $generator = new Parse::Pidl::Samba4::EJS(); 
-               my ($hdr,$prsr) = $generator->Parse($ndr, $h_filename);
-               FileSave("$outputdir/ndr_$basename\_ejs.c", $prsr);
-               FileSave("$outputdir/ndr_$basename\_ejs.h", $hdr);
-       }
-
        if (defined($opt_python)) {
                require Parse::Pidl::Samba4::Python;
                my $generator = new Parse::Pidl::Samba4::Python(); 
index 3463f012a5bc466aa27ff3763300629fc8297319..04728d835d3fbde9708b38e0b0d699343eec236a 100755 (executable)
@@ -7,7 +7,7 @@ OPT_TAG=""
 OPT_KEYID=""
 
 TOPDIR="`dirname $0`/.."
-VER_H="${TOPDIR}/source/include/version.h"
+VER_H="${TOPDIR}/source3/include/version.h"
 
 function exitOnError
 {
@@ -38,7 +38,7 @@ function printUsage
 }
 
 ##
-## Parse the command line options 
+## Parse the command line options
 ##
 
 function parseOptions
@@ -115,7 +115,7 @@ function buildDocs
 
        rsync -av "${OPT_DOCSDIR}"/ docs/
        exitOnError $? "Failed top copy docs from ${OPT_DOCSDIR}"
-       
+
        return 0
     fi
 
@@ -163,23 +163,23 @@ function createReleaseTag
 ##
 ## Main driver
 ##
-function main 
+function main
 {
     parseOptions "$@"
     exitOnError $? "Failed to parse options"
-    
+
     cd $TOPDIR
 
     git-checkout ${OPT_BRANCH}
     exitOnError $? "Invalid branch name \"${OPT_BRANCH}\""
 
-    (cd source && ./script/mkversion.sh)
+    (cd source3 && ./script/mkversion.sh)
     if [ ! -f $VER_H ]; then
        exitOnError 1 "Failed to find ${VER_H}!"
     fi
 
-    version=`grep SAMBA_VERSION_OFFICIAL_STRING $VER_H | awk '{print $3}'`
-    vendor_version=`grep SAMBA_VERSION_VENDOR_SUFFIX $VER_H | awk '{print $3}'`
+    version=`grep "define SAMBA_VERSION_OFFICIAL_STRING" $VER_H | awk '{print $3}'`
+    vendor_version=`grep "define SAMBA_VERSION_VENDOR_SUFFIX" $VER_H | awk '{print $3}'`
     if [ -n "$vendor_version" ]; then
        version="$version-$vendor_version"
     fi
@@ -198,7 +198,7 @@ function main
     buildDocs
     exitOnError $? "Failed to build documentation"
 
-    ( cd source && ./autogen.sh )
+    ( cd source3 && ./autogen.sh )
 
     cd ..
     tar cf samba-${version}.tar --exclude=.git* --exclude=CVS --exclude=.svn samba-${version}
index 2300e4a20c745ca48a430fae6eb169689f3ec525..94d8d50da8f7865925db4f85a3a9265568f5c71e 100644 (file)
@@ -376,7 +376,7 @@ LIBADS_SERVER_OBJ = libads/kerberos_verify.o libads/authdata.o \
 
 SECRETS_OBJ = passdb/secrets.o passdb/machine_sid.o
 
-LIBNBT_OBJ = libcli/nbt/nbtname.o \
+LIBNBT_OBJ = ../libcli/nbt/nbtname.o \
             librpc/gen_ndr/ndr_nbt.o \
             librpc/gen_ndr/ndr_svcctl.o
 
@@ -946,13 +946,14 @@ SHARESEC_OBJ  = $(SHARESEC_OBJ0) $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) \
                $(LIBSAMBA_OBJ) \
                 $(POPT_LIB_OBJ)
 
-TALLOCTORT_OBJ = @tallocdir@/testsuite.o $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) \
-                 $(LIBSAMBA_OBJ)
+TALLOCTORT_OBJ = @tallocdir@/testsuite.o @tallocdir@/testsuite_main.o \
+               $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) $(LIBSAMBA_OBJ)
 
 REPLACETORT_OBJ = @libreplacedir@/test/testsuite.o \
                @libreplacedir@/test/getifaddrs.o \
                @libreplacedir@/test/os2_delete.o \
                @libreplacedir@/test/strptime.o \
+               @libreplacedir@/test/main.o \
                $(LIBREPLACE_OBJ)
 
 NDRDUMP_OBJ = librpc/tools/ndrdump.o \
@@ -984,6 +985,14 @@ IDMAP_HASH_OBJ = \
                winbindd/idmap_hash/idmap_hash.o \
                winbindd/idmap_hash/mapfile.o
 
+IDMAP_ADEX_OBJ = \
+               winbindd/idmap_adex/idmap_adex.o \
+               winbindd/idmap_adex/cell_util.o \
+               winbindd/idmap_adex/likewise_cell.o \
+               winbindd/idmap_adex/provider_unified.o \
+               winbindd/idmap_adex/gc_util.o \
+               winbindd/idmap_adex/domain_util.o
+
 WINBINDD_OBJ1 = \
                winbindd/winbindd.o       \
                winbindd/winbindd_user.o  \
@@ -2217,6 +2226,10 @@ bin/hash.@SHLIBEXT@: $(BINARY_PREREQS) $(IDMAP_HASH_OBJ)
        @echo "Building plugin $@"
        @$(SHLD_MODULE) $(IDMAP_HASH_OBJ)
 
+bin/adex.@SHLIBEXT@: $(BINARY_PREREQS) $(IDMAP_ADEX_OBJ)
+       @echo "Building plugin $@"
+       @$(SHLD_MODULE) $(IDMAP_ADEX_OBJ)
+
 bin/tdb2.@SHLIBEXT@: $(BINARY_PREREQS) winbindd/idmap_tdb2.o
        @echo "Building plugin $@"
        @$(SHLD_MODULE) winbindd/idmap_tdb2.o
index 3b56e5f861a6a2cbb05721ed17b982f0b9e80b75..b7a76c61024abfd37651659e0ab34ec924b8d886 100644 (file)
  #endif /* _SAMBA_BUILD_ */
 #endif /* MOUNT_CIFS_VENDOR_SUFFIX */
 
+#ifdef _SAMBA_BUILD_
+#include "include/config.h"
+#endif
+
 #ifndef MS_MOVE 
 #define MS_MOVE 8192 
 #endif 
@@ -94,6 +98,8 @@ char * prefixpath = NULL;
 
 /* like strncpy but does not 0 fill the buffer and always null
  *    terminates. bufsize is the size of the destination buffer */
+
+#ifndef HAVE_STRLCPY
 static size_t strlcpy(char *d, const char *s, size_t bufsize)
 {
        size_t len = strlen(s);
@@ -104,10 +110,13 @@ static size_t strlcpy(char *d, const char *s, size_t bufsize)
        d[len] = 0;
        return ret;
 }
+#endif
 
 /* like strncat but does not 0 fill the buffer and always null
  *    terminates. bufsize is the length of the buffer, which should
  *       be one more than the maximum resulting string length */
+
+#ifndef HAVE_STRLCAT
 static size_t strlcat(char *d, const char *s, size_t bufsize)
 {
        size_t len1 = strlen(d);
@@ -126,6 +135,7 @@ static size_t strlcat(char *d, const char *s, size_t bufsize)
        }
        return ret;
 }
+#endif
 
 /* BB finish BB
 
index 640afc47fb8123ef129fb6002ec364688f4cec99..f23f6b55be304b36ecbaad3075d69c0c01b3ccfd 100644 (file)
@@ -6058,6 +6058,7 @@ SMB_MODULE(idmap_nss, winbindd/idmap_nss.o, "bin/nss.$SHLIBEXT", IDMAP)
 SMB_MODULE(idmap_rid, winbindd/idmap_rid.o, "bin/rid.$SHLIBEXT", IDMAP)
 SMB_MODULE(idmap_ad, winbindd/idmap_ad.o, "bin/ad.$SHLIBEXT", IDMAP)
 SMB_MODULE(idmap_hash, \$(IDMAP_HASH_OBJ), "bin/hash.$SHLIBEXT", IDMAP)
+SMB_MODULE(idmap_adex, \$(IDMAP_ADEX_OBJ), "bin/adex.$SHLIBEXT", IDMAP)
 SMB_SUBSYSTEM(IDMAP, winbindd/idmap.o)
 
 SMB_MODULE(nss_info_template, winbindd/nss_info_template.o, "bin/template.$SHLIBEXT", NSS_INFO)
@@ -6271,8 +6272,10 @@ fi
 SMBD_LIBS="$samba_dmapi_libs"
 AC_SUBST(SMBD_LIBS)
 
+CFLAGS="${CFLAGS} \$(FLAGS)"
+
 if test x$MERGED_BUILD != x1; then
-       CFLAGS="${CFLAGS} \$(FLAGS) -D_SAMBA_BUILD_=3"
+       CFLAGS="${CFLAGS} -D_SAMBA_BUILD_=3"
 fi
 
 AC_OUTPUT(Makefile
index 4d04b5a1a678ad0d40222ea2b796e89aa0b441de..1c2a5fb5f093d345d40bdb748e8abf2980c63846 100644 (file)
@@ -18,6 +18,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
+struct smb_iconv_convenience;
+
 /* this defines the charset types used in samba */
 typedef enum {CH_UTF16LE=0, CH_UTF16=0, CH_UNIX=1, CH_DISPLAY=2, CH_DOS=3, CH_UTF8=4, CH_UTF16BE=5} charset_t;
 
index 2901911c70db268b8a183e4b0062e7e5ad25241a..a2772384c57fcf14a970b8f84463afea6d6b7bcc 100644 (file)
@@ -2204,23 +2204,6 @@ ADS_STATUS ads_change_trust_account_password(ADS_STRUCT *ads, char *host_princip
 ADS_STATUS ads_guess_service_principal(ADS_STRUCT *ads,
                                       char **returned_principal);
 
-/* The following definitions come from libcli/nbt/nbtname.c  */
-
-_PUBLIC_ void ndr_print_nbt_string(struct ndr_print *ndr, const char *name, const char *s);
-_PUBLIC_ enum ndr_err_code ndr_pull_nbt_string(struct ndr_pull *ndr, int ndr_flags, const char **s);
-_PUBLIC_ enum ndr_err_code ndr_push_nbt_string(struct ndr_push *ndr, int ndr_flags, const char *s);
-_PUBLIC_ enum ndr_err_code ndr_pull_nbt_name(struct ndr_pull *ndr, int ndr_flags, struct nbt_name *r);
-_PUBLIC_ enum ndr_err_code ndr_push_nbt_name(struct ndr_push *ndr, int ndr_flags, const struct nbt_name *r);
-_PUBLIC_ NTSTATUS nbt_name_dup(TALLOC_CTX *mem_ctx, struct nbt_name *name, struct nbt_name *newname);
-_PUBLIC_ NTSTATUS nbt_name_to_blob(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, struct nbt_name *name);
-_PUBLIC_ NTSTATUS nbt_name_from_blob(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob, struct nbt_name *name);
-_PUBLIC_ void nbt_choose_called_name(TALLOC_CTX *mem_ctx,
-                           struct nbt_name *n, const char *name, int type);
-_PUBLIC_ char *nbt_name_string(TALLOC_CTX *mem_ctx, const struct nbt_name *name);
-_PUBLIC_ enum ndr_err_code ndr_pull_wrepl_nbt_name(struct ndr_pull *ndr, int ndr_flags, const struct nbt_name **_r);
-_PUBLIC_ enum ndr_err_code ndr_push_wrepl_nbt_name(struct ndr_push *ndr, int ndr_flags, const struct nbt_name *r);
-_PUBLIC_ void ndr_print_wrepl_nbt_name(struct ndr_print *ndr, const char *name, const struct nbt_name *r);
-
 /* The following definitions come from libgpo/gpext/gpext.c  */
 
 struct gp_extension *get_gp_extension_list(void);
@@ -3960,16 +3943,14 @@ _PUBLIC_ enum ndr_err_code ndr_print_set_switch_value(struct ndr_print *ndr, con
 _PUBLIC_ uint32_t ndr_push_get_switch_value(struct ndr_push *ndr, const void *p);
 _PUBLIC_ uint32_t ndr_pull_get_switch_value(struct ndr_pull *ndr, const void *p);
 _PUBLIC_ uint32_t ndr_print_get_switch_value(struct ndr_print *ndr, const void *p);
-_PUBLIC_ enum ndr_err_code ndr_pull_struct_blob(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p,
-                             ndr_pull_flags_fn_t fn);
+_PUBLIC_ enum ndr_err_code ndr_pull_struct_blob(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, void *p, ndr_pull_flags_fn_t fn);
 _PUBLIC_ enum ndr_err_code ndr_pull_struct_blob_all(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p,
                                  ndr_pull_flags_fn_t fn);
 _PUBLIC_ enum ndr_err_code ndr_pull_union_blob(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p,
                             uint32_t level, ndr_pull_flags_fn_t fn);
 _PUBLIC_ enum ndr_err_code ndr_pull_union_blob_all(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p,
                             uint32_t level, ndr_pull_flags_fn_t fn);
-_PUBLIC_ enum ndr_err_code ndr_push_struct_blob(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, const void *p,
-                             ndr_push_flags_fn_t fn);
+_PUBLIC_ enum ndr_err_code ndr_push_struct_blob(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, const void *p, ndr_push_flags_fn_t fn);
 _PUBLIC_ enum ndr_err_code ndr_push_union_blob(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p,
                             uint32_t level, ndr_push_flags_fn_t fn);
 _PUBLIC_ size_t ndr_size_struct(const void *p, int flags, ndr_push_flags_fn_t push);
@@ -7049,6 +7030,12 @@ NTSTATUS rpccli_netlogon_sam_network_logon_ex(struct rpc_pipe_client *cli,
                                              DATA_BLOB lm_response,
                                              DATA_BLOB nt_response,
                                              struct netr_SamInfo3 **info3);
+NTSTATUS rpccli_netlogon_set_trust_password(struct rpc_pipe_client *cli,
+                                           TALLOC_CTX *mem_ctx,
+                                           const unsigned char orig_trust_passwd_hash[16],
+                                           const char *new_trust_pwd_cleartext,
+                                           const unsigned char new_trust_passwd_hash[16],
+                                           uint32_t sec_channel_type);
 
 /* The following definitions come from rpc_client/cli_pipe.c  */
 
@@ -7427,6 +7414,9 @@ void init_netr_PasswordInfo(struct netr_PasswordInfo *r,
                            const char *workstation,
                            struct samr_Password lmpassword,
                            struct samr_Password ntpassword);
+void init_netr_CryptPassword(const char *pwd,
+                            unsigned char session_key[16],
+                            struct netr_CryptPassword *pwd_buf);
 
 /* The following definitions come from rpc_client/init_samr.c  */
 
index f436afc2fff367ff595220374ee409e9993491ac..9f7f88f783004ee32bc6bdb452e7b512b0822a25 100644 (file)
@@ -160,7 +160,7 @@ static NTSTATUS messaging_tdb_fetch(TDB_CONTEXT *msg_tdb,
        blob = data_blob_const(data.dptr, data.dsize);
 
        ndr_err = ndr_pull_struct_blob(
-               &blob, result, result,
+               &blob, result, NULL, result,
                (ndr_pull_flags_fn_t)ndr_pull_messaging_array);
 
        SAFE_FREE(data.dptr);
@@ -203,7 +203,7 @@ static NTSTATUS messaging_tdb_store(TDB_CONTEXT *msg_tdb,
        }
 
        ndr_err = ndr_push_struct_blob(
-               &blob, mem_ctx, array,
+               &blob, mem_ctx, NULL, array,
                (ndr_push_flags_fn_t)ndr_push_messaging_array);
 
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
index 57e1ef70ea26b2274d898e982d0deef865cef43e..c6958a9012ef7799806b108aecf67732cc9c9b3f 100644 (file)
@@ -95,6 +95,7 @@ int main(int argc, const char **argv)
                case 1:
                case 2:
                case 3:
+                       break;
                case 1001:
                        u1001.usrmod1001_min_passwd_len = 0;
                        buffer = (uint8_t *)&u1001;
index 01457532120c2fce2fa098c16a634adfaea4f764..659f82c9d8c1e7184045fdad939291674a28b89b 100644 (file)
@@ -44,7 +44,7 @@ bin/.dummy:
 
 CMDLINE_OBJ = common.o
 NETAPIBUFFER_OBJ = netapibuffer.o
-NETAPITEST_OBJ = netapitest.o netlocalgroup.o netuser.o netgroup.o netdisplay.o netshare.o $(CMDLINE_OBJ)
+NETAPITEST_OBJ = netapitest.o netlocalgroup.o netuser.o netgroup.o netdisplay.o netshare.o netfile.o $(CMDLINE_OBJ)
 
 bin/netapitest@EXEEXT@: $(BINARY_PREREQS) $(NETAPITEST_OBJ)
        @echo Linking $@
index 5a320321baa2a9228d25bb0051ee7bbf4293dd9d..932084090910b893d6d87002a7d1afbabff1343c 100644 (file)
@@ -41,6 +41,8 @@ NET_API_STATUS netapitest_display(struct libnetapi_ctx *ctx,
                                  const char *hostname);
 NET_API_STATUS netapitest_share(struct libnetapi_ctx *ctx,
                                const char *hostname);
+NET_API_STATUS netapitest_file(struct libnetapi_ctx *ctx,
+                              const char *hostname);
 
 #ifndef ARRAY_SIZE
 #define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
index 87144020f5d9c2d11b3cdbba39aeb309b5eaaaaa..4a38f721d8f1c3144104c95c1de875aad6a25493 100644 (file)
@@ -84,6 +84,11 @@ int main(int argc, const char **argv)
                goto out;
        }
 
+       status = netapitest_file(ctx, hostname);
+       if (status) {
+               goto out;
+       }
+
  out:
        if (status != 0) {
                printf("testsuite failed with: %s\n",
diff --git a/source3/lib/netapi/tests/netfile.c b/source3/lib/netapi/tests/netfile.c
new file mode 100644 (file)
index 0000000..36ee828
--- /dev/null
@@ -0,0 +1,143 @@
+/*
+ *  Unix SMB/CIFS implementation.
+ *  NetFile testsuite
+ *  Copyright (C) Guenther Deschner 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 <sys/types.h>
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <netapi.h>
+
+#include "common.h"
+
+static NET_API_STATUS test_netfileenum(const char *hostname,
+                                      uint32_t level)
+{
+       NET_API_STATUS status;
+       uint32_t entries_read = 0;
+       uint32_t total_entries = 0;
+       uint32_t resume_handle = 0;
+       uint8_t *buffer = NULL;
+       int i;
+
+       struct FILE_INFO_2 *i2;
+       struct FILE_INFO_3 *i3;
+
+       printf("testing NetFileEnum level %d\n", level);
+
+       do {
+               status = NetFileEnum(hostname,
+                                    NULL,
+                                    NULL,
+                                    level,
+                                    &buffer,
+                                    (uint32_t)-1,
+                                    &entries_read,
+                                    &total_entries,
+                                    &resume_handle);
+               if (status == 0 || status == ERROR_MORE_DATA) {
+                       switch (level) {
+                               case 2:
+                                       i2 = (struct FILE_INFO_2 *)buffer;
+                                       break;
+                               case 3:
+                                       i3 = (struct FILE_INFO_3 *)buffer;
+                                       break;
+                               default:
+                                       return -1;
+                       }
+
+                       for (i=0; i<entries_read; i++) {
+
+                               switch (level) {
+                                       case 2:
+                                       case 3:
+                                               break;
+                                       default:
+                                               break;
+                               }
+
+                               switch (level) {
+                                       case 2:
+                                               i2++;
+                                               break;
+                                       case 3:
+                                               i3++;
+                                               break;
+                               }
+                       }
+                       NetApiBufferFree(buffer);
+               }
+       } while (status == ERROR_MORE_DATA);
+
+       if (status) {
+               return status;
+       }
+
+       return 0;
+}
+
+NET_API_STATUS netapitest_file(struct libnetapi_ctx *ctx,
+                              const char *hostname)
+{
+       NET_API_STATUS status = 0;
+       uint8_t *buffer = NULL;
+       uint32_t levels[] = { 2, 3 };
+       uint32_t enum_levels[] = { 2, 3 };
+       int i;
+
+       printf("NetFile tests\n");
+
+       /* test enum */
+
+       for (i=0; i<ARRAY_SIZE(enum_levels); i++) {
+
+               status = test_netfileenum(hostname, enum_levels[i]);
+               if (status) {
+                       NETAPI_STATUS(ctx, status, "NetFileEnum");
+                       goto out;
+               }
+       }
+
+       /* basic queries */
+#if 0
+       for (i=0; i<ARRAY_SIZE(levels); i++) {
+
+               printf("testing NetFileGetInfo level %d\n", levels[i]);
+
+               status = NetFileGetInfo(hostname, fid, levels[i], &buffer);
+               if (status && status != 124) {
+                       NETAPI_STATUS(ctx, status, "NetFileGetInfo");
+                       goto out;
+               }
+       }
+#endif
+
+       status = 0;
+
+       printf("NetFile tests succeeded\n");
+ out:
+       if (status != 0) {
+               printf("NetFile testsuite failed with: %s\n",
+                       libnetapi_get_error_string(ctx, status));
+       }
+
+       return status;
+}
index 44ae23271ef45261ea1d6a4a0cce868e78e31703..4965200bc1129f254798f3faf5ba87902a3d416c 100644 (file)
@@ -249,7 +249,7 @@ NTSTATUS marshall_sec_desc(TALLOC_CTX *mem_ctx,
        enum ndr_err_code ndr_err;
 
        ndr_err = ndr_push_struct_blob(
-               &blob, mem_ctx, secdesc,
+               &blob, mem_ctx, NULL, secdesc,
                (ndr_push_flags_fn_t)ndr_push_security_descriptor);
 
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
@@ -285,7 +285,7 @@ NTSTATUS unmarshall_sec_desc(TALLOC_CTX *mem_ctx, uint8 *data, size_t len,
        blob = data_blob_const(data, len);
 
        ndr_err = ndr_pull_struct_blob(
-               &blob, result, result,
+               &blob, result, NULL, result,
                (ndr_pull_flags_fn_t)ndr_pull_security_descriptor);
 
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
index 0bde3e6984aa0f2dd4f7cfd762bc0c43c6a9af1d..40f051c8510960587a50e7c15197d1c9b75cbd5e 100644 (file)
@@ -108,7 +108,7 @@ static krb5_error_code check_pac_checksum(TALLOC_CTX *mem_ctx,
        }
 
        ndr_err = ndr_pull_struct_blob(pac_data_blob, pac_data,
-                       pac_data,
+                       NULL, pac_data,
                       (ndr_pull_flags_fn_t)ndr_pull_PAC_DATA);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                status = ndr_map_error2ntstatus(ndr_err);
@@ -124,7 +124,7 @@ static krb5_error_code check_pac_checksum(TALLOC_CTX *mem_ctx,
        }
 
        ndr_err = ndr_pull_struct_blob(pac_data_blob, pac_data_raw,
-                                      pac_data_raw,
+                                      NULL, pac_data_raw,
                                       (ndr_pull_flags_fn_t)ndr_pull_PAC_DATA_RAW);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                status = ndr_map_error2ntstatus(ndr_err);
@@ -205,7 +205,7 @@ static krb5_error_code check_pac_checksum(TALLOC_CTX *mem_ctx,
 
        /* We find the data blobs above, now we parse them to get at the exact portion we should zero */
        ndr_err = ndr_pull_struct_blob(kdc_sig_blob, kdc_sig_wipe,
-                                      kdc_sig_wipe,
+                                      NULL, kdc_sig_wipe,
                                       (ndr_pull_flags_fn_t)ndr_pull_PAC_SIGNATURE_DATA);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                status = ndr_map_error2ntstatus(ndr_err);
@@ -215,7 +215,7 @@ static krb5_error_code check_pac_checksum(TALLOC_CTX *mem_ctx,
        }
 
        ndr_err = ndr_pull_struct_blob(srv_sig_blob, srv_sig_wipe,
-                                      srv_sig_wipe,
+                                      NULL, srv_sig_wipe,
                                       (ndr_pull_flags_fn_t)ndr_pull_PAC_SIGNATURE_DATA);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                status = ndr_map_error2ntstatus(ndr_err);
@@ -230,7 +230,7 @@ static krb5_error_code check_pac_checksum(TALLOC_CTX *mem_ctx,
 
        /* and reencode, back into the same place it came from */
        ndr_err = ndr_push_struct_blob(kdc_sig_blob, pac_data_raw,
-                                      kdc_sig_wipe,
+                                      NULL, kdc_sig_wipe,
                                       (ndr_push_flags_fn_t)ndr_push_PAC_SIGNATURE_DATA);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                status = ndr_map_error2ntstatus(ndr_err);
@@ -239,7 +239,7 @@ static krb5_error_code check_pac_checksum(TALLOC_CTX *mem_ctx,
                return status;
        }
        ndr_err = ndr_push_struct_blob(srv_sig_blob, pac_data_raw,
-                                      srv_sig_wipe,
+                                      NULL, srv_sig_wipe,
                                       (ndr_push_flags_fn_t)ndr_push_PAC_SIGNATURE_DATA);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                status = ndr_map_error2ntstatus(ndr_err);
@@ -250,7 +250,7 @@ static krb5_error_code check_pac_checksum(TALLOC_CTX *mem_ctx,
 
        /* push out the whole structure, but now with zero'ed signatures */
        ndr_err = ndr_push_struct_blob(&modified_pac_blob, pac_data_raw,
-                                      pac_data_raw,
+                                      NULL, pac_data_raw,
                                       (ndr_push_flags_fn_t)ndr_push_PAC_DATA_RAW);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                status = ndr_map_error2ntstatus(ndr_err);
index 11565065af955886f1242d457a424a8e3a084ee8..73b28b523acc18b79e356176b5cca7eebccdffa5 100644 (file)
@@ -294,7 +294,7 @@ bool pull_mailslot_cldap_reply(TALLOC_CTX *mem_ctx,
        uint32_t nt_version_query = ((*nt_version) & 0x0000001f);
        uint16_t command = 0;
 
-       ndr_err = ndr_pull_struct_blob(blob, mem_ctx, &command,
+       ndr_err = ndr_pull_struct_blob(blob, mem_ctx, NULL, &command,
                        (ndr_pull_flags_fn_t)ndr_pull_uint16);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                return false;
diff --git a/source3/libcli/nbt/nbtname.c b/source3/libcli/nbt/nbtname.c
deleted file mode 100644 (file)
index fbb9550..0000000
+++ /dev/null
@@ -1,626 +0,0 @@
-/*
-   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 ((name == NULL) || is_ipaddress(name)) {
-               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);
-}
index 6ba2c3aa41962665912f1a1ae14d936bd4e0bbd4..e762ecbe49200b0b7bba8a492a49995fcc62402f 100644 (file)
@@ -86,7 +86,7 @@ static NTSTATUS keytab_startup(struct dssync_context *ctx, TALLOC_CTX *mem_ctx,
                old_utdv = talloc(mem_ctx, struct replUpToDateVectorBlob);
 
                ndr_err = ndr_pull_struct_blob(&entry->password, old_utdv,
-                               old_utdv,
+                               NULL, old_utdv,
                                (ndr_pull_flags_fn_t)ndr_pull_replUpToDateVectorBlob);
                if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                        NTSTATUS status = ndr_map_error2ntstatus(ndr_err);
@@ -124,7 +124,7 @@ static NTSTATUS keytab_finish(struct dssync_context *ctx, TALLOC_CTX *mem_ctx,
                        NDR_PRINT_DEBUG(replUpToDateVectorBlob, new_utdv);
                }
 
-               ndr_err = ndr_push_struct_blob(&blob, mem_ctx, new_utdv,
+               ndr_err = ndr_push_struct_blob(&blob, mem_ctx, NULL, new_utdv,
                                (ndr_push_flags_fn_t)ndr_push_replUpToDateVectorBlob);
                if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                        status = ndr_map_error2ntstatus(ndr_err);
@@ -236,7 +236,7 @@ static  NTSTATUS parse_supplemental_credentials(TALLOC_CTX *mem_ctx,
                status = NT_STATUS_NO_MEMORY;
                goto done;
        }
-       ndr_err = ndr_pull_struct_blob(&scpk_blob, mem_ctx, pkb,
+       ndr_err = ndr_pull_struct_blob(&scpk_blob, mem_ctx, NULL, pkb,
                        (ndr_pull_flags_fn_t)ndr_pull_package_PrimaryKerberosBlob);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                status = ndr_map_error2ntstatus(ndr_err);
index daf27ffb51c3279f0f7bcc96f7f7676b74fea77a..64dcf6de51beaca5a6e0664be9ed80d678f5fe17 100644 (file)
@@ -65,7 +65,7 @@ static NTSTATUS fix_user(TALLOC_CTX *mem_ctx,
                user->user_private_info.SensitiveData = data.data;
                user->user_private_info.DataLength = data.length;
 
-               ndr_err = ndr_pull_struct_blob(&data, mem_ctx, &keys,
+               ndr_err = ndr_pull_struct_blob(&data, mem_ctx, NULL, &keys,
                        (ndr_pull_flags_fn_t)ndr_pull_netr_USER_KEYS);
                if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                        dump_data(10, data.data, data.length);
@@ -397,7 +397,7 @@ NTSTATUS pull_netr_AcctLockStr(TALLOC_CTX *mem_ctx,
 
        blob = data_blob_const(r->array, r->length);
 
-       ndr_err = ndr_pull_struct_blob(&blob, mem_ctx, str,
+       ndr_err = ndr_pull_struct_blob(&blob, mem_ctx, NULL, str,
                       (ndr_pull_flags_fn_t)ndr_pull_netr_AcctLockStr);
 
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
index 98da9e12ea0242aab241fa35f688787f6f2726eb..ae7acbf5728df105b2e03056cf2214d55750533e 100644 (file)
@@ -413,7 +413,9 @@ struct USER_INFO_X {
        uint32_t usriX_code_page;
        const char * usriX_profile;
        const char * usriX_home_dir_drive;
+       uint32_t usriX_user_id;
        uint32_t usriX_primary_group_id;
+       uint32_t usriX_password_expired;
 };
 
 struct GROUP_USERS_INFO_0 {
index 62ad524a916b0bb25315500d647854596f04e9eb..0943ee1a4d82d0893ad8ae9f0d4ad393ba38fb77 100644 (file)
@@ -221,7 +221,7 @@ 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] */;
+}/* [nodiscriminant,public] */;
 
 struct nbt_res_rec {
        struct nbt_name name;
index a5266827b61043b7bc92230c372bb3213a70c457..d7bf63e62fa74f6b0f524f8c4e8371838f56e2b5 100644 (file)
@@ -1895,7 +1895,9 @@ _PUBLIC_ enum ndr_err_code ndr_push_USER_INFO_X(struct ndr_push *ndr, int ndr_fl
                NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->usriX_code_page));
                NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->usriX_profile));
                NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->usriX_home_dir_drive));
+               NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->usriX_user_id));
                NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->usriX_primary_group_id));
+               NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->usriX_password_expired));
        }
        if (ndr_flags & NDR_BUFFERS) {
                if (r->usriX_logon_hours) {
@@ -1942,7 +1944,9 @@ _PUBLIC_ enum ndr_err_code ndr_pull_USER_INFO_X(struct ndr_pull *ndr, int ndr_fl
                NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->usriX_code_page));
                NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->usriX_profile));
                NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->usriX_home_dir_drive));
+               NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->usriX_user_id));
                NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->usriX_primary_group_id));
+               NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->usriX_password_expired));
        }
        if (ndr_flags & NDR_BUFFERS) {
                if (r->usriX_logon_hours) {
@@ -1990,7 +1994,9 @@ _PUBLIC_ void ndr_print_USER_INFO_X(struct ndr_print *ndr, const char *name, con
        ndr_print_uint32(ndr, "usriX_code_page", r->usriX_code_page);
        ndr_print_string(ndr, "usriX_profile", r->usriX_profile);
        ndr_print_string(ndr, "usriX_home_dir_drive", r->usriX_home_dir_drive);
+       ndr_print_uint32(ndr, "usriX_user_id", r->usriX_user_id);
        ndr_print_uint32(ndr, "usriX_primary_group_id", r->usriX_primary_group_id);
+       ndr_print_uint32(ndr, "usriX_password_expired", r->usriX_password_expired);
        ndr->depth--;
 }
 
index 75667183a80d3b22c68137aaa4cbec0476ef300a..01cccd674271e040db1ccd9909d82266d4ea6994 100644 (file)
@@ -77,13 +77,13 @@ _PUBLIC_ void ndr_print_nbt_name(struct ndr_print *ndr, const char *name, const
        ndr->depth--;
 }
 
-static enum ndr_err_code ndr_push_nbt_qclass(struct ndr_push *ndr, int ndr_flags, enum nbt_qclass r)
+_PUBLIC_ 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)
+_PUBLIC_ 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));
@@ -101,13 +101,13 @@ _PUBLIC_ void ndr_print_nbt_qclass(struct ndr_print *ndr, const char *name, enum
        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)
+_PUBLIC_ 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)
+_PUBLIC_ 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));
@@ -496,7 +496,7 @@ _PUBLIC_ void ndr_print_nbt_rdata_data(struct ndr_print *ndr, const char *name,
        ndr->depth--;
 }
 
-static enum ndr_err_code ndr_push_nbt_rdata(struct ndr_push *ndr, int ndr_flags, const union nbt_rdata *r)
+_PUBLIC_ 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);
@@ -532,7 +532,7 @@ static enum ndr_err_code ndr_push_nbt_rdata(struct ndr_push *ndr, int ndr_flags,
        return NDR_ERR_SUCCESS;
 }
 
-static enum ndr_err_code ndr_pull_nbt_rdata(struct ndr_pull *ndr, int ndr_flags, union nbt_rdata *r)
+_PUBLIC_ 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);
index 6e9702d5d5a0f071abce54d317ae52b9f80276c5..f70d1ba8dfd70b3a219e13f75a06b419da4e43dd 100644 (file)
@@ -6,14 +6,18 @@
 #ifndef _HEADER_NDR_nbt
 #define _HEADER_NDR_nbt
 
-#include "libcli/nbt/libnbt.h"
+#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);
+enum ndr_err_code ndr_push_nbt_qclass(struct ndr_push *ndr, int ndr_flags, enum nbt_qclass r);
+enum ndr_err_code ndr_pull_nbt_qclass(struct ndr_pull *ndr, int ndr_flags, enum nbt_qclass *r);
 void ndr_print_nbt_qclass(struct ndr_print *ndr, const char *name, enum nbt_qclass r);
+enum ndr_err_code ndr_push_nbt_qtype(struct ndr_push *ndr, int ndr_flags, enum nbt_qtype r);
+enum ndr_err_code ndr_pull_nbt_qtype(struct ndr_pull *ndr, int ndr_flags, enum nbt_qtype *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);
@@ -23,6 +27,8 @@ void ndr_print_nbt_statistics(struct ndr_print *ndr, const char *name, const str
 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);
+enum ndr_err_code ndr_push_nbt_rdata(struct ndr_push *ndr, int ndr_flags, const union nbt_rdata *r);
+enum ndr_err_code ndr_pull_nbt_rdata(struct ndr_pull *ndr, int ndr_flags, union nbt_rdata *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);
index 039dcf4152b6b51e038abf937477013b57c732bf..f2f4a16c1243b13ae9ff4e5477f7010ab3dd945d 100644 (file)
@@ -517,7 +517,9 @@ interface libnetapi
                uint32 usriX_code_page;
                string usriX_profile;
                string usriX_home_dir_drive;
+               uint32 usriX_user_id;
                uint32 usriX_primary_group_id;
+               uint32 usriX_password_expired;
        } USER_INFO_X;
 
        [nopush,nopull] NET_API_STATUS NetUserAdd(
index 654f53c52f49cc4ddfa722bf68587795185e1316..da1eb2ef3fcf0d157f3542bc22d0dc6b71ab22aa 100644 (file)
@@ -10,7 +10,7 @@
 
 import "misc.idl", "security.idl", "svcctl.idl", "samr.idl";
 [
-helper("libcli/nbt/libnbt.h")
+helper("../libcli/nbt/libnbt.h")
 ]
 interface nbt
 {
@@ -73,11 +73,11 @@ interface nbt
                nbt_name_type type;
        } nbt_name;
 
-       typedef [enum16bit] enum {
+       typedef [public,enum16bit] enum {
                NBT_QCLASS_IP = 0x01
        } nbt_qclass;
 
-       typedef [enum16bit] enum {
+       typedef [public,enum16bit] enum {
                NBT_QTYPE_ADDRESS     = 0x0001,
                NBT_QTYPE_NAMESERVICE = 0x0002,
                NBT_QTYPE_NULL        = 0x000A,
@@ -160,7 +160,7 @@ interface nbt
                uint8  data[length];
        } nbt_rdata_data;
 
-       typedef [nodiscriminant] union {
+       typedef [nodiscriminant,public] union {
                [case(NBT_QTYPE_NETBIOS)] nbt_rdata_netbios netbios;
                [case(NBT_QTYPE_STATUS)]  nbt_rdata_status status;
                [default]                 nbt_rdata_data   data;
index d94d12e1466c0ad66e5f52f20c5b347d880f76f0..624024c94d9a13c8fc5b38ad0c147878843a7f93 100644 (file)
@@ -803,8 +803,11 @@ _PUBLIC_ uint32_t ndr_print_get_switch_value(struct ndr_print *ndr, const void *
 /*
   pull a struct from a blob using NDR
 */
-_PUBLIC_ enum ndr_err_code ndr_pull_struct_blob(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p,
-                             ndr_pull_flags_fn_t fn)
+_PUBLIC_ enum ndr_err_code ndr_pull_struct_blob(const DATA_BLOB *blob,
+                                               TALLOC_CTX *mem_ctx,
+                                               struct smb_iconv_convenience *iconv_convenience,
+                                               void *p,
+                                               ndr_pull_flags_fn_t fn)
 {
        struct ndr_pull *ndr;
        ndr = ndr_pull_init_blob(blob, mem_ctx);
@@ -868,8 +871,11 @@ _PUBLIC_ enum ndr_err_code ndr_pull_union_blob_all(const DATA_BLOB *blob, TALLOC
 /*
   push a struct to a blob using NDR
 */
-_PUBLIC_ enum ndr_err_code ndr_push_struct_blob(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, const void *p,
-                             ndr_push_flags_fn_t fn)
+_PUBLIC_ enum ndr_err_code ndr_push_struct_blob(DATA_BLOB *blob,
+                                               TALLOC_CTX *mem_ctx,
+                                               struct smb_iconv_convenience *iconv_convenience,
+                                               const void *p,
+                                               ndr_push_flags_fn_t fn)
 {
        struct ndr_push *ndr;
        ndr = ndr_push_init_ctx(mem_ctx);
index 8b35a69defec1ae301dfd101386f0ec0a1b6223f..8ee3507a04f51b2e52431b99622ea869529ebd94 100644 (file)
@@ -181,7 +181,7 @@ bool send_getdc_request(TALLOC_CTX *mem_ctx,
                NDR_PRINT_DEBUG(nbt_ntlogon_packet, &packet);
        }
 
-       ndr_err = ndr_push_struct_blob(&blob, mem_ctx, &packet,
+       ndr_err = ndr_push_struct_blob(&blob, mem_ctx, NULL, &packet,
                       (ndr_push_flags_fn_t)ndr_push_nbt_ntlogon_packet);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                return false;
index 9d65fb4e94423ccc19bc2a7428693a90387e1b46..8a5aedfde5697d0907d931c15e10cc3e2595e626 100644 (file)
@@ -464,13 +464,11 @@ struct cli_state *cli_initialise(void)
                return NULL;
        }
 
-       cli = talloc(NULL, struct cli_state);
+       cli = TALLOC_ZERO_P(NULL, struct cli_state);
        if (!cli) {
                return NULL;
        }
 
-       ZERO_STRUCTP(cli);
-
        cli->port = 0;
        cli->fd = -1;
        cli->cnum = -1;
index 2a445cbd5a7b40cee5da72216ea8cb2e2955c5ff..e82263554605d04360ce6e0f6e2faeebc7c64385 100644 (file)
@@ -331,7 +331,7 @@ static NTSTATUS store_cldap_reply(TALLOC_CTX *mem_ctx,
                return status;
        }
 
-       ndr_err = ndr_push_struct_blob(&blob, mem_ctx, &logon29,
+       ndr_err = ndr_push_struct_blob(&blob, mem_ctx, NULL, &logon29,
                       (ndr_push_flags_fn_t)ndr_push_nbt_cldap_netlogon_29);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                return ndr_map_error2ntstatus(ndr_err);
@@ -508,7 +508,7 @@ static NTSTATUS dsgetdcname_cache_fetch(TALLOC_CTX *mem_ctx,
                return NT_STATUS_NO_MEMORY;
        }
 
-       ndr_err = ndr_pull_struct_blob(&blob, mem_ctx, &r,
+       ndr_err = ndr_pull_struct_blob(&blob, mem_ctx, NULL, &r,
                      (ndr_pull_flags_fn_t)ndr_pull_nbt_cldap_netlogon_29);
 
        data_blob_free(&blob);
index 4abe5bb6de2250a0c32b71ba20cdf000805d8d3d..af4986fa9d681d9bb50fd9df2a2b9cdb1c266142 100644 (file)
@@ -141,7 +141,7 @@ bool netsamlogon_cache_store(const char *username, struct netr_SamInfo3 *info3)
                NDR_PRINT_DEBUG(netsamlogoncache_entry, &r);
        }
 
-       ndr_err = ndr_push_struct_blob(&blob, mem_ctx, &r,
+       ndr_err = ndr_push_struct_blob(&blob, mem_ctx, NULL, &r,
                                       (ndr_push_flags_fn_t)ndr_push_netsamlogoncache_entry);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                DEBUG(0,("netsamlogon_cache_store: failed to push entry to cache\n"));
@@ -197,7 +197,7 @@ struct netr_SamInfo3 *netsamlogon_cache_get(TALLOC_CTX *mem_ctx, const DOM_SID *
 
        blob = data_blob_const(data.dptr, data.dsize);
 
-       ndr_err = ndr_pull_struct_blob(&blob, mem_ctx, &r,
+       ndr_err = ndr_pull_struct_blob(&blob, mem_ctx, NULL, &r,
                                      (ndr_pull_flags_fn_t)ndr_pull_netsamlogoncache_entry);
 
        if (DEBUGLEVEL >= 10) {
index 08a49930b4d3e7e834fa13b230096671a61ccbe9..2f336f14e6d58b41380a53cda23e34eb1d4585db 100644 (file)
 
 #include "includes.h"
 
-/*********************************************************
- Change the domain password on the PDC.
-
- Just changes the password betwen the two values specified.
-
- Caller must have the cli connected to the netlogon pipe
- already.
-**********************************************************/
-
-static NTSTATUS just_change_the_password(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, 
-                                        const unsigned char orig_trust_passwd_hash[16],
-                                        const char *new_trust_pwd_cleartext,
-                                        const unsigned char new_trust_passwd_hash[16],
-                                        uint32 sec_channel_type)
-{
-       NTSTATUS result;
-       uint32_t neg_flags = NETLOGON_NEG_AUTH2_ADS_FLAGS;
-
-       result = rpccli_netlogon_setup_creds(cli,
-                                            cli->desthost, /* server name */
-                                            lp_workgroup(), /* domain */
-                                            global_myname(), /* client name */
-                                            global_myname(), /* machine account name */
-                                            orig_trust_passwd_hash,
-                                            sec_channel_type,
-                                            &neg_flags);
-
-       if (!NT_STATUS_IS_OK(result)) {
-               DEBUG(3,("just_change_the_password: unable to setup creds (%s)!\n",
-                        nt_errstr(result)));
-               return result;
-       }
-
-       if (neg_flags & NETLOGON_NEG_PASSWORD_SET2) {
-
-               struct netr_Authenticator clnt_creds, srv_cred;
-               struct netr_CryptPassword new_password;
-               struct samr_CryptPassword password_buf;
-
-               netlogon_creds_client_step(cli->dc, &clnt_creds);
-
-               encode_pw_buffer(password_buf.data, new_trust_pwd_cleartext, STR_UNICODE);
-
-               SamOEMhash(password_buf.data, cli->dc->sess_key, 516);
-               memcpy(new_password.data, password_buf.data, 512);
-               new_password.length = IVAL(password_buf.data, 512);
-
-               result = rpccli_netr_ServerPasswordSet2(cli, mem_ctx,
-                                                      cli->dc->remote_machine,
-                                                      cli->dc->mach_acct,
-                                                      sec_channel_type,
-                                                      global_myname(),
-                                                      &clnt_creds,
-                                                      &srv_cred,
-                                                      &new_password);
-
-               /* Always check returned credentials. */
-               if (!netlogon_creds_client_check(cli->dc, &srv_cred.cred)) {
-                       DEBUG(0,("rpccli_netr_ServerPasswordSet2: "
-                               "credentials chain check failed\n"));
-                       return NT_STATUS_ACCESS_DENIED;
-               }
-
-       } else {
-
-               struct netr_Authenticator clnt_creds, srv_cred;
-               struct samr_Password new_password;
-
-               netlogon_creds_client_step(cli->dc, &clnt_creds);
-
-               cred_hash3(new_password.hash,
-                          new_trust_passwd_hash,
-                          cli->dc->sess_key, 1);
-
-               result = rpccli_netr_ServerPasswordSet(cli, mem_ctx,
-                                                      cli->dc->remote_machine,
-                                                      cli->dc->mach_acct,
-                                                      sec_channel_type,
-                                                      global_myname(),
-                                                      &clnt_creds,
-                                                      &srv_cred,
-                                                      &new_password);
-
-               /* Always check returned credentials. */
-               if (!netlogon_creds_client_check(cli->dc, &srv_cred.cred)) {
-                       DEBUG(0,("rpccli_netr_ServerPasswordSet: "
-                               "credentials chain check failed\n"));
-                       return NT_STATUS_ACCESS_DENIED;
-               }
-       }
-
-       if (!NT_STATUS_IS_OK(result)) {
-               DEBUG(0,("just_change_the_password: unable to change password (%s)!\n",
-                        nt_errstr(result)));
-       }
-       return result;
-}
-
 /*********************************************************
  Change the domain password on the PDC.
  Store the password ourselves, but use the supplied password
@@ -144,11 +46,11 @@ NTSTATUS trust_pw_change_and_store_it(struct rpc_pipe_client *cli, TALLOC_CTX *m
        
        E_md4hash(new_trust_passwd, new_trust_passwd_hash);
 
-       nt_status = just_change_the_password(cli, mem_ctx,
-                                            orig_trust_passwd_hash,
-                                            new_trust_passwd,
-                                            new_trust_passwd_hash,
-                                            sec_channel_type);
+       nt_status = rpccli_netlogon_set_trust_password(cli, mem_ctx,
+                                                      orig_trust_passwd_hash,
+                                                      new_trust_passwd,
+                                                      new_trust_passwd_hash,
+                                                      sec_channel_type);
        
        if (NT_STATUS_IS_OK(nt_status)) {
                DEBUG(3,("%s : trust_pw_change_and_store_it: Changed password.\n", 
index fd5931075557dd8250086ce781d0686acabb965b..a2f3477b764b1927143272d3d7d10f580d4f01a4 100644 (file)
@@ -38,7 +38,7 @@ static NTSTATUS parse_acl_blob(const DATA_BLOB *pblob,
        size_t sd_size;
        struct timespec ts;
 
-       ndr_err = ndr_pull_struct_blob(pblob, ctx, &xacl,
+       ndr_err = ndr_pull_struct_blob(pblob, ctx, NULL, &xacl,
                        (ndr_pull_flags_fn_t)ndr_pull_xattr_NTACL);
 
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
@@ -245,7 +245,7 @@ static NTSTATUS create_acl_blob(SEC_DESC *psd, DATA_BLOB *pblob)
        unix_timespec_to_nt_time(&xacl.info.sd_ts->last_changed, curr);
 
        ndr_err = ndr_push_struct_blob(
-                       pblob, ctx, &xacl,
+                       pblob, ctx, NULL, &xacl,
                        (ndr_push_flags_fn_t)ndr_push_xattr_NTACL);
 
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
index 7b5e5107476be34d26c59b14b98bf1a6d5179d9c..c707a1828f146641d1b2482cbabc58b3421f64d1 100644 (file)
@@ -48,7 +48,7 @@ static NTSTATUS xattr_tdb_pull_attrs(TALLOC_CTX *mem_ctx,
        blob = data_blob_const(data->dptr, data->dsize);
 
        ndr_err = ndr_pull_struct_blob(
-               &blob, result, result,
+               &blob, result, NULL, result,
                (ndr_pull_flags_fn_t)ndr_pull_tdb_xattrs);
 
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
@@ -74,7 +74,7 @@ static NTSTATUS xattr_tdb_push_attrs(TALLOC_CTX *mem_ctx,
        enum ndr_err_code ndr_err;
 
        ndr_err = ndr_push_struct_blob(
-               &blob, mem_ctx, attribs,
+               &blob, mem_ctx, NULL, attribs,
                (ndr_push_flags_fn_t)ndr_push_tdb_xattrs);
 
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
index df87ed13d132ddd97bbd3f2da255e5516d3cdc06..23618efd9fc9482a4a5037ed23176976e5fcc461 100644 (file)
@@ -538,3 +538,94 @@ NTSTATUS rpccli_netlogon_sam_network_logon_ex(struct rpc_pipe_client *cli,
 
        return result;
 }
+
+/*********************************************************
+ Change the domain password on the PDC.
+
+ Just changes the password betwen the two values specified.
+
+ Caller must have the cli connected to the netlogon pipe
+ already.
+**********************************************************/
+
+NTSTATUS rpccli_netlogon_set_trust_password(struct rpc_pipe_client *cli,
+                                           TALLOC_CTX *mem_ctx,
+                                           const unsigned char orig_trust_passwd_hash[16],
+                                           const char *new_trust_pwd_cleartext,
+                                           const unsigned char new_trust_passwd_hash[16],
+                                           uint32_t sec_channel_type)
+{
+       NTSTATUS result;
+       uint32_t neg_flags = NETLOGON_NEG_AUTH2_ADS_FLAGS;
+       struct netr_Authenticator clnt_creds, srv_cred;
+
+       result = rpccli_netlogon_setup_creds(cli,
+                                            cli->desthost, /* server name */
+                                            lp_workgroup(), /* domain */
+                                            global_myname(), /* client name */
+                                            global_myname(), /* machine account name */
+                                            orig_trust_passwd_hash,
+                                            sec_channel_type,
+                                            &neg_flags);
+
+       if (!NT_STATUS_IS_OK(result)) {
+               DEBUG(3,("rpccli_netlogon_set_trust_password: unable to setup creds (%s)!\n",
+                        nt_errstr(result)));
+               return result;
+       }
+
+       netlogon_creds_client_step(cli->dc, &clnt_creds);
+
+       if (neg_flags & NETLOGON_NEG_PASSWORD_SET2) {
+
+               struct netr_CryptPassword new_password;
+
+               init_netr_CryptPassword(new_trust_pwd_cleartext,
+                                       cli->dc->sess_key,
+                                       &new_password);
+
+               result = rpccli_netr_ServerPasswordSet2(cli, mem_ctx,
+                                                       cli->dc->remote_machine,
+                                                       cli->dc->mach_acct,
+                                                       sec_channel_type,
+                                                       global_myname(),
+                                                       &clnt_creds,
+                                                       &srv_cred,
+                                                       &new_password);
+               if (!NT_STATUS_IS_OK(result)) {
+                       DEBUG(0,("rpccli_netr_ServerPasswordSet2 failed: %s\n",
+                               nt_errstr(result)));
+                       return result;
+               }
+       } else {
+
+               struct samr_Password new_password;
+
+               cred_hash3(new_password.hash,
+                          new_trust_passwd_hash,
+                          cli->dc->sess_key, 1);
+
+               result = rpccli_netr_ServerPasswordSet(cli, mem_ctx,
+                                                      cli->dc->remote_machine,
+                                                      cli->dc->mach_acct,
+                                                      sec_channel_type,
+                                                      global_myname(),
+                                                      &clnt_creds,
+                                                      &srv_cred,
+                                                      &new_password);
+               if (!NT_STATUS_IS_OK(result)) {
+                       DEBUG(0,("rpccli_netr_ServerPasswordSet failed: %s\n",
+                               nt_errstr(result)));
+                       return result;
+               }
+       }
+
+       /* Always check returned credentials. */
+       if (!netlogon_creds_client_check(cli->dc, &srv_cred.cred)) {
+               DEBUG(0,("credentials chain check failed\n"));
+               return NT_STATUS_ACCESS_DENIED;
+       }
+
+       return result;
+}
+
index 61841953fc61de6d6e8ebc2071711b9629ee5296..e4c39e739ee4150788aebbca581a9595f6d056f1 100644 (file)
@@ -391,3 +391,20 @@ void init_netr_PasswordInfo(struct netr_PasswordInfo *r,
        r->lmpassword = lmpassword;
        r->ntpassword = ntpassword;
 }
+
+/*************************************************************************
+ inits a netr_CryptPassword structure
+ *************************************************************************/
+
+void init_netr_CryptPassword(const char *pwd,
+                            unsigned char session_key[16],
+                            struct netr_CryptPassword *pwd_buf)
+{
+       struct samr_CryptPassword password_buf;
+
+       encode_pw_buffer(password_buf.data, pwd, STR_UNICODE);
+
+       SamOEMhash(password_buf.data, session_key, 516);
+       memcpy(pwd_buf->data, password_buf.data, 512);
+       pwd_buf->length = IVAL(password_buf.data, 512);
+}
index c02d3d4b3be9bf5f68268c00a0c0d8e517339dc9..728fd2d45d907688dca7eeb2ec3c35e202c6dbc4 100644 (file)
@@ -95,7 +95,6 @@ m4_include(ntvfs/unixuid/config.m4)
 m4_include(auth/config.m4)
 m4_include(kdc/config.m4)
 m4_include(ntvfs/sysdep/config.m4)
-m4_include(lib/appweb/config.m4)
 m4_include(nsswitch/config.m4)
 
 dnl Samba 4 files
index 294eef8b8fbca0fc0c3613a8a7f415494b5a4684..2646b12a0d335a84d9bfc65b03915cf856cfc05f 100644 (file)
@@ -7,7 +7,7 @@ PARTLINK = $(PROG_LD) -r
 MDLD = $(SHLD)
 MDLD_FLAGS = $(LDSHFLAGS) 
 
-samba4srcdir = $(call abspath,$(srcdir)/../source4)
+samba4srcdir = $(srcdir)/../source4
 
 # Flags used for the samba 4 files
 # $(srcdir)/include is required for config.h
@@ -83,7 +83,6 @@ libcmdlinesrcdir := $(samba4srcdir)/lib/cmdline
 poptsrcdir := $(samba4srcdir)/../lib/popt
 socketwrappersrcdir := $(samba4srcdir)/../lib/socket_wrapper
 nsswrappersrcdir := $(samba4srcdir)/../lib/nss_wrapper
-appwebsrcdir := $(samba4srcdir)/lib/appweb
 libstreamsrcdir := $(samba4srcdir)/lib/stream
 libutilsrcdir := $(samba4srcdir)/lib/util
 libtdrsrcdir := $(samba4srcdir)/lib/tdr
@@ -108,7 +107,6 @@ ntvfssrcdir := $(samba4srcdir)/ntvfs
 ntptrsrcdir := $(samba4srcdir)/ntptr
 clientsrcdir := $(samba4srcdir)/client
 libclisrcdir := $(samba4srcdir)/libcli
-ejsscriptsrcdir := $(samba4srcdir)/scripting/ejs
 pyscriptsrcdir := $(samba4srcdir)/scripting/python
 kdcsrcdir := $(samba4srcdir)/kdc
 smbreadlinesrcdir := $(samba4srcdir)/lib/smbreadline
@@ -116,6 +114,7 @@ ntp_signdsrcdir := $(samba4srcdir)/ntp_signd
 tdbsrcdir := $(samba4srcdir)/../lib/tdb
 ldbsrcdir := $(samba4srcdir)/lib/ldb
 tallocsrcdir := $(samba4srcdir)/../lib/talloc
+comsrcdir := $(samba4srcdir)/lib/com
 override ASN1C = bin/asn1_compile4
 override ET_COMPILER = bin/compile_et4
 include samba4-data.mk
index 8ff5dcd9495d78a519a86918faf6d1114e930cdd..2027fd3937b7b491bc2efdb6152a41d39d58247a 100755 (executable)
@@ -19,7 +19,7 @@ for f in ${IDL_FILES}; do
        basename=`basename $f .idl`
        ndr="librpc/gen_ndr/ndr_$basename.c"
 
-       if [ -f $ndr ] && false; then
+       if [ -f $ndr ]; then
                if [ "x`find librpc/idl/$f -newer $ndr -print`" = "xlibrpc/idl/$f" ]; then
                        list="$list librpc/idl/$f"
                fi
index 84b8e1098e77b5aa2efe7c5d23b5c9ef2aa3633b..06da717799b1acb2ff7e4d6d048dff3d0b0f42f4 100644 (file)
@@ -166,7 +166,7 @@ static NTSTATUS notify_load(struct notify_context *notify, struct db_record *rec
        status = NT_STATUS_OK;
        if (blob.length > 0) {
                enum ndr_err_code ndr_err;
-               ndr_err = ndr_pull_struct_blob(&blob, notify->array, notify->array,
+               ndr_err = ndr_pull_struct_blob(&blob, notify->array, NULL, notify->array,
                                               (ndr_pull_flags_fn_t)ndr_pull_notify_array);
                if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                        status = ndr_map_error2ntstatus(ndr_err);
@@ -220,7 +220,7 @@ static NTSTATUS notify_save(struct notify_context *notify, struct db_record *rec
        tmp_ctx = talloc_new(notify);
        NT_STATUS_HAVE_NO_MEMORY(tmp_ctx);
 
-       ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, notify->array,
+       ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, NULL, notify->array,
                                      (ndr_push_flags_fn_t)ndr_push_notify_array);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                talloc_free(tmp_ctx);
@@ -258,7 +258,7 @@ static void notify_handler(struct messaging_context *msg_ctx, void *private_data
                return;
        }
 
-       ndr_err = ndr_pull_struct_blob(data, tmp_ctx, &ev,
+       ndr_err = ndr_pull_struct_blob(data, tmp_ctx, NULL, &ev,
                                       (ndr_pull_flags_fn_t)ndr_pull_notify_event);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                talloc_free(tmp_ctx);
@@ -561,7 +561,7 @@ static NTSTATUS notify_send(struct notify_context *notify, struct notify_entry *
 
        tmp_ctx = talloc_new(notify);
 
-       ndr_err = ndr_push_struct_blob(&data, tmp_ctx, &ev,
+       ndr_err = ndr_push_struct_blob(&data, tmp_ctx, NULL, &ev,
                                       (ndr_push_flags_fn_t)ndr_push_notify_event);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                talloc_free(tmp_ctx);
index 124af00b57dff2fcd289e36fd7d3605e73af8dca..005e3ca556085c831f543c07f6d7d00ad9090000 100644 (file)
@@ -1186,7 +1186,7 @@ static NTSTATUS rpc_registry_getsd_internal(struct net_context *c,
        blob.data = sd->data;
        blob.length = sd->size;
 
-       ndr_err = ndr_pull_struct_blob(&blob, mem_ctx, &sec_desc,
+       ndr_err = ndr_pull_struct_blob(&blob, mem_ctx, NULL, &sec_desc,
                                       (ndr_pull_flags_fn_t)ndr_pull_security_descriptor);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                status = ndr_map_error2ntstatus(ndr_err);
diff --git a/source3/winbindd/idmap_adex/cell_util.c b/source3/winbindd/idmap_adex/cell_util.c
new file mode 100644 (file)
index 0000000..f5c08a0
--- /dev/null
@@ -0,0 +1,292 @@
+/*
+ * idmap_adex: Support for AD Forests
+ *
+ * Copyright (C) Gerald (Jerry) Carter 2006-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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include "includes.h"
+#include "idmap_adex.h"
+
+#undef DBGC_CLASS
+#define DBGC_CLASS DBGC_IDMAP
+
+/**********************************************************************
+**********************************************************************/
+
+ char *find_attr_string(char **list, size_t num_lines, const char *substr)
+{
+       int i;
+       int cmplen = strlen(substr);
+
+       for (i = 0; i < num_lines; i++) {
+               /* make sure to avoid substring matches like uid
+                  and uidNumber */
+               if ((StrnCaseCmp(list[i], substr, cmplen) == 0) &&
+                   (list[i][cmplen] == '=')) {
+                       /* Don't return an empty string */
+                       if (list[i][cmplen + 1] != '\0')
+                               return &(list[i][cmplen + 1]);
+
+                       return NULL;
+               }
+       }
+
+       return NULL;
+}
+
+/**********************************************************************
+**********************************************************************/
+
+ bool is_object_class(char **list, size_t num_lines, const char *substr)
+{
+       int i;
+
+       for (i = 0; i < num_lines; i++) {
+               if (strequal(list[i], substr)) {
+                       return true;
+               }
+       }
+
+       return false;
+}
+
+/**********************************************************************
+ Find out about the cell (e.g. use2307Attrs, etc...)
+**********************************************************************/
+
+ NTSTATUS cell_lookup_settings(struct likewise_cell * cell)
+{
+       NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
+
+       /* Parameter check */
+
+       if (!cell) {
+               nt_status = NT_STATUS_INVALID_PARAMETER;
+               BAIL_ON_NTSTATUS_ERROR(nt_status);
+       }
+
+       /* Only supporting Forest-wide, schema based searches */
+
+       cell_set_flags(cell, LWCELL_FLAG_USE_RFC2307_ATTRS);
+       cell_set_flags(cell, LWCELL_FLAG_SEARCH_FOREST);
+
+       cell->provider = &ccp_unified;
+
+       nt_status = NT_STATUS_OK;
+
+done:
+       if (!NT_STATUS_IS_OK(nt_status)) {
+               DEBUG(1,("LWI: Failed to obtain cell settings (%s)\n",
+                        nt_errstr(nt_status)));
+       }
+
+       return nt_status;
+}
+
+
+static NTSTATUS cell_lookup_forest(struct likewise_cell *c)
+{
+       NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
+       struct gc_info *gc = NULL;
+
+       if (!c) {
+               return NT_STATUS_INVALID_PARAMETER;
+       }
+
+       if ((gc = TALLOC_ZERO_P(NULL, struct gc_info)) == NULL) {
+               nt_status = NT_STATUS_NO_MEMORY;
+               BAIL_ON_NTSTATUS_ERROR(nt_status);
+       }
+
+       /* Query the rootDSE for the forest root naming conect first.
+           Check that the a GC server for the forest has not already
+          been added */
+
+       nt_status = gc_find_forest_root(gc, cell_dns_domain(c));
+       BAIL_ON_NTSTATUS_ERROR(nt_status);
+
+       c->forest_name = talloc_strdup(c, gc->forest_name);
+       BAIL_ON_PTR_ERROR(c->forest_name, nt_status);
+
+done:
+       if (gc) {
+               talloc_free(gc);
+       }
+
+       return nt_status;
+}
+
+/**********************************************************************
+**********************************************************************/
+
+ NTSTATUS cell_locate_membership(ADS_STRUCT * ads)
+{
+       ADS_STATUS status;
+       char *domain_dn = ads_build_dn(lp_realm());
+       NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
+       DOM_SID sid;
+       struct likewise_cell *cell = NULL;
+
+       /* In the Likewise plugin, I had to support the concept of cells
+          based on the machine's membership in an OU.  However, now I'll
+          just assume our membership in the forest cell */
+
+       DEBUG(2, ("locate_cell_membership: Located membership "
+                 "in cell \"%s\"\n", domain_dn));
+
+       if ((cell = cell_new()) == NULL) {
+               nt_status = NT_STATUS_NO_MEMORY;
+               BAIL_ON_NTSTATUS_ERROR(nt_status);
+       }
+
+       status = ads_domain_sid(ads, &sid);
+       if (!ADS_ERR_OK(status)) {
+               DEBUG(3,("locate_cell_membership: Failed to find "
+                        "domain SID for %s\n", domain_dn));
+       }
+
+       /* save the SID and search base for our domain */
+
+       cell_set_dns_domain(cell, lp_realm());
+       cell_set_connection(cell, ads);
+       cell_set_dn(cell, domain_dn);
+       cell_set_domain_sid(cell, &sid);
+
+       /* Now save our forest root */
+
+       cell_lookup_forest(cell);
+
+       /* Add the cell to the list */
+
+       if (!cell_list_add(cell)) {
+               nt_status = NT_STATUS_INSUFFICIENT_RESOURCES;
+               BAIL_ON_NTSTATUS_ERROR(nt_status);
+       }
+
+       /* Done! */
+       nt_status = NT_STATUS_OK;
+
+done:
+       if (!NT_STATUS_IS_OK(nt_status)) {
+               DEBUG(0,("LWI: Failed to locate cell membership (%s)\n",
+                        nt_errstr(nt_status)));
+       }
+
+       SAFE_FREE(domain_dn);
+
+       return nt_status;
+}
+
+/*********************************************************************
+ ********************************************************************/
+
+ int min_id_value(void)
+{
+       int id_val;
+
+       id_val = lp_parm_int(-1, "lwidentity", "min_id_value", MIN_ID_VALUE);
+
+       /* Still don't let it go below 50 */
+
+       return MAX(50, id_val);
+}
+
+/********************************************************************
+ *******************************************************************/
+
+ char *cell_dn_to_dns(const char *dn)
+{
+       NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
+       char *domain = NULL;
+       char *dns_name = NULL;
+       const char *tmp_dn;
+       char *buffer = NULL;
+       TALLOC_CTX *frame = talloc_stackframe();
+
+       if (!dn || !*dn) {
+               goto done;
+       }
+
+       tmp_dn = talloc_strdup(frame, dn);
+       BAIL_ON_PTR_ERROR(tmp_dn, nt_status);
+
+       while (next_token_talloc(frame, &tmp_dn, &buffer, ",")) {
+
+               /* skip everything up the where DC=... begins */
+               if (StrnCaseCmp(buffer, "DC=", 3) != 0)
+                       continue;
+
+               if (!domain) {
+                       domain = talloc_strdup(frame, &buffer[3]);
+               } else {
+                       domain = talloc_asprintf_append(domain, ".%s",
+                                                       &buffer[3]);
+               }
+               BAIL_ON_PTR_ERROR(domain, nt_status);
+       }
+
+       dns_name = SMB_STRDUP(domain);
+       BAIL_ON_PTR_ERROR(dns_name, nt_status);
+
+       nt_status = NT_STATUS_OK;
+
+done:
+       PRINT_NTSTATUS_ERROR(nt_status, "cell_dn_to_dns", 1);
+
+       talloc_destroy(frame);
+
+       return dns_name;
+}
+
+/*********************************************************************
+ ********************************************************************/
+
+ NTSTATUS get_sid_type(ADS_STRUCT *ads,
+                      LDAPMessage *msg,
+                      enum lsa_SidType *type)
+{
+       NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
+       uint32_t atype;
+
+       if (!ads_pull_uint32(ads, msg, "sAMAccountType", &atype)) {
+               nt_status = NT_STATUS_INVALID_USER_BUFFER;
+               BAIL_ON_NTSTATUS_ERROR(nt_status);
+       }
+
+       switch (atype &0xF0000000) {
+       case ATYPE_SECURITY_GLOBAL_GROUP:
+               *type = SID_NAME_DOM_GRP;
+               break;
+       case ATYPE_SECURITY_LOCAL_GROUP:
+               *type = SID_NAME_ALIAS;
+               break;
+       case ATYPE_NORMAL_ACCOUNT:
+       case ATYPE_WORKSTATION_TRUST:
+       case ATYPE_INTERDOMAIN_TRUST:
+               *type = SID_NAME_USER;
+               break;
+       default:
+               *type = SID_NAME_USE_NONE;
+               nt_status = NT_STATUS_INVALID_ACCOUNT_NAME;
+               BAIL_ON_NTSTATUS_ERROR(nt_status);
+       }
+
+       nt_status = NT_STATUS_OK;
+
+done:
+       return nt_status;
+}
diff --git a/source3/winbindd/idmap_adex/domain_util.c b/source3/winbindd/idmap_adex/domain_util.c
new file mode 100644 (file)
index 0000000..ab31cce
--- /dev/null
@@ -0,0 +1,278 @@
+/*
+ * idmap_adex: Domain search interface
+ *
+ * Copyright (C) Gerald (Jerry) Carter 2007-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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include "includes.h"
+#include "idmap_adex.h"
+
+#undef DBGC_CLASS
+#define DBGC_CLASS DBGC_IDMAP
+
+struct dc_info {
+       struct dc_info *prev, *next;
+       char *dns_name;
+       struct likewise_cell *domain_cell;
+};
+
+static struct dc_info *_dc_server_list = NULL;
+
+
+/**********************************************************************
+ *********************************************************************/
+
+static struct dc_info *dc_list_head(void)
+{
+       return _dc_server_list;
+}
+
+/**********************************************************************
+ *********************************************************************/
+
+static NTSTATUS dc_add_domain(const char *domain)
+{
+       NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
+       struct dc_info *dc = NULL;
+
+       /* Check for duplicates */
+
+       dc = dc_list_head();
+       while (dc) {
+               if (strequal (dc->dns_name, domain))
+                       break;
+               dc = dc->next;
+       }
+
+       if (dc) {
+               DEBUG(10,("dc_add_domain: %s already in list\n", domain));
+               return NT_STATUS_OK;
+       }
+
+       dc = TALLOC_ZERO_P(NULL, struct dc_info);
+       BAIL_ON_PTR_ERROR(dc, nt_status);
+
+       dc->dns_name = talloc_strdup(dc, domain);
+       BAIL_ON_PTR_ERROR(dc->dns_name, nt_status);
+
+       DLIST_ADD_END(_dc_server_list, dc, struct dc_info*);
+
+       nt_status = NT_STATUS_OK;
+
+done:
+       if (!NT_STATUS_IS_OK(nt_status)) {
+               talloc_destroy(dc);
+               DEBUG(0,("LWI: Failed to add new DC connection for %s (%s)\n",
+                        domain, nt_errstr(nt_status)));
+       }
+
+       return nt_status;
+}
+
+/**********************************************************************
+ *********************************************************************/
+
+static void dc_server_list_destroy(void)
+{
+       struct dc_info *dc = dc_list_head();
+
+       while (dc) {
+               struct dc_info *p = dc->next;
+
+               cell_destroy(dc->domain_cell);
+               talloc_destroy(dc);
+
+               dc = p;
+       }
+
+       return;
+}
+
+
+/**********************************************************************
+ *********************************************************************/
+
+ NTSTATUS domain_init_list(void)
+{
+       NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
+       struct winbindd_tdc_domain *domains = NULL;
+       size_t num_domains = 0;
+       int i;
+
+       if (_dc_server_list != NULL) {
+               dc_server_list_destroy();
+       }
+
+       /* Add our domain */
+
+       nt_status = dc_add_domain(lp_realm());
+       BAIL_ON_NTSTATUS_ERROR(nt_status);
+
+       if (!wcache_tdc_fetch_list(&domains, &num_domains)) {
+               nt_status = NT_STATUS_CANT_ACCESS_DOMAIN_INFO;
+               BAIL_ON_NTSTATUS_ERROR(nt_status);
+       }
+
+       /* Add all domains with an incoming trust path */
+
+       for (i=0; i<num_domains; i++) {
+               uint32_t flags = (NETR_TRUST_FLAG_INBOUND|NETR_TRUST_FLAG_IN_FOREST);
+
+               /* We just require one of the flags to be set here */
+
+               if (domains[i].trust_flags & flags) {
+                       nt_status = dc_add_domain(domains[i].dns_name);
+                       BAIL_ON_NTSTATUS_ERROR(nt_status);
+               }
+       }
+
+       nt_status = NT_STATUS_OK;
+
+done:
+       if (!NT_STATUS_IS_OK(nt_status)) {
+               DEBUG(2,("LWI: Failed to initialize DC list (%s)\n",
+                        nt_errstr(nt_status)));
+       }
+
+       TALLOC_FREE(domains);
+
+       return nt_status;
+}
+
+/********************************************************************
+ *******************************************************************/
+
+static NTSTATUS dc_do_search(struct dc_info *dc,
+                            const char *search_base,
+                            int scope,
+                            const char *expr,
+                            const char **attrs,
+                            LDAPMessage ** msg)
+{
+       ADS_STATUS status = ADS_ERROR_NT(NT_STATUS_UNSUCCESSFUL);
+       NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
+
+       status = cell_do_search(dc->domain_cell, search_base,
+                               scope, expr, attrs, msg);
+       nt_status = ads_ntstatus(status);
+
+       return nt_status;
+}
+
+/**********************************************************************
+ *********************************************************************/
+
+static struct dc_info *dc_find_domain(const char *dns_domain)
+{
+       struct dc_info *dc = dc_list_head();
+
+       if (!dc)
+               return NULL;
+
+       while (dc) {
+               if (strequal(dc->dns_name, dns_domain)) {
+                       return dc;
+               }
+
+               dc = dc->next;
+       }
+
+       return NULL;
+}
+
+/**********************************************************************
+ *********************************************************************/
+
+ NTSTATUS dc_search_domains(struct likewise_cell **cell,
+                           LDAPMessage **msg,
+                           const char *dn,
+                           const DOM_SID *sid)
+{
+       NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
+       TALLOC_CTX *frame = talloc_stackframe();
+       char *dns_domain;
+       const char *attrs[] = { "*", NULL };
+       struct dc_info *dc = NULL;
+       const char *base = NULL;
+
+       if (!dn || !*dn) {
+               nt_status = NT_STATUS_INVALID_PARAMETER;
+               BAIL_ON_NTSTATUS_ERROR(nt_status);
+       }
+
+       dns_domain = cell_dn_to_dns(dn);
+       BAIL_ON_PTR_ERROR(dns_domain, nt_status);
+
+       if ((dc = dc_find_domain(dns_domain)) == NULL) {
+               nt_status = NT_STATUS_TRUSTED_DOMAIN_FAILURE;
+               BAIL_ON_NTSTATUS_ERROR(nt_status);
+       }
+
+       /* Reparse the cell settings for the domain if necessary */
+
+       if (!dc->domain_cell) {
+               char *base_dn;
+
+               base_dn = ads_build_dn(dc->dns_name);
+               BAIL_ON_PTR_ERROR(base_dn, nt_status);
+
+               nt_status = cell_connect_dn(&dc->domain_cell, base_dn);
+               SAFE_FREE(base_dn);
+               BAIL_ON_NTSTATUS_ERROR(nt_status);
+
+               nt_status = cell_lookup_settings(dc->domain_cell);
+               BAIL_ON_NTSTATUS_ERROR(nt_status);
+
+               /* By definition this is already part of a larger
+                  forest-wide search scope */
+
+               cell_set_flags(dc->domain_cell, LWCELL_FLAG_SEARCH_FOREST);
+       }
+
+       /* Check whether we are operating in non-schema or RFC2307
+          mode */
+
+       if (cell_flags(dc->domain_cell) & LWCELL_FLAG_USE_RFC2307_ATTRS) {
+               nt_status = dc_do_search(dc, dn, LDAP_SCOPE_BASE,
+                                        "(objectclass=*)", attrs, msg);
+       } else {
+               const char *sid_str = NULL;
+               char *filter = NULL;
+
+               sid_str = sid_string_talloc(frame, sid);
+               BAIL_ON_PTR_ERROR(sid_str, nt_status);
+
+               filter = talloc_asprintf(frame, "(keywords=backLink=%s)",
+                                        sid_str);
+               BAIL_ON_PTR_ERROR(filter, nt_status);
+
+               base = cell_search_base(dc->domain_cell);
+               BAIL_ON_PTR_ERROR(base, nt_status);
+
+               nt_status = dc_do_search(dc, base, LDAP_SCOPE_SUBTREE,
+                                        filter, attrs, msg);
+       }
+       BAIL_ON_NTSTATUS_ERROR(nt_status);
+
+       *cell = dc->domain_cell;
+
+done:
+       talloc_destroy(CONST_DISCARD(char*, base));
+       talloc_destroy(frame);
+
+       return nt_status;
+}
diff --git a/source3/winbindd/idmap_adex/gc_util.c b/source3/winbindd/idmap_adex/gc_util.c
new file mode 100644 (file)
index 0000000..87dd3c0
--- /dev/null
@@ -0,0 +1,848 @@
+/*
+ * idmap_adex: Global Catalog search interface
+ *
+ * Copyright (C) Gerald (Jerry) Carter 2007-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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include "includes.h"
+#include "idmap_adex.h"
+
+#undef DBGC_CLASS
+#define DBGC_CLASS DBGC_IDMAP
+
+static struct gc_info *_gc_server_list = NULL;
+
+
+/**********************************************************************
+ *********************************************************************/
+
+static struct gc_info *gc_list_head(void)
+{
+       return _gc_server_list;
+}
+
+/**********************************************************************
+ Checks if either of the domains is a subdomain of the other
+ *********************************************************************/
+
+static bool is_subdomain(const char* a, const char *b)
+{
+       char *s;
+       TALLOC_CTX *frame = talloc_stackframe();
+       char *x, *y;
+       bool ret = false;
+
+       /* Trivial cases */
+
+       if (!a && !b)
+               return true;
+
+       if (!a || !b)
+               return false;
+
+       /* Normalize the case */
+
+       x = talloc_strdup(frame, a);
+       y = talloc_strdup(frame, b);
+       if (!x || !y) {
+               ret = false;
+               goto done;
+       }
+
+       strupper_m(x);
+       strupper_m(y);
+
+       /* Exact match */
+
+       if (strcmp(x, y) == 0) {
+               ret = true;
+               goto done;
+       }
+
+       /* Check for trailing substrings */
+
+       s = strstr_m(x, y);
+       if (s && (strlen(s) == strlen(y))) {
+               ret = true;
+               goto done;
+       }
+
+       s = strstr_m(y, x);
+       if (s && (strlen(s) == strlen(x))) {
+               ret = true;
+               goto done;
+       }
+
+done:
+       talloc_destroy(frame);
+
+       return ret;
+}
+
+/**********************************************************************
+ *********************************************************************/
+
+ NTSTATUS gc_find_forest_root(struct gc_info *gc, const char *domain)
+{
+       ADS_STRUCT *ads = NULL;
+       ADS_STATUS ads_status;
+       NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
+       struct nbt_cldap_netlogon_5 cldap_reply;
+       TALLOC_CTX *frame = talloc_stackframe();
+
+       if (!gc || !domain) {
+               return NT_STATUS_INVALID_PARAMETER;
+       }
+
+       ZERO_STRUCT(cldap_reply);
+
+       ads = ads_init(domain, NULL, NULL);
+       BAIL_ON_PTR_ERROR(ads, nt_status);
+
+       ads->auth.flags = ADS_AUTH_NO_BIND;
+       ads_status = ads_connect(ads);
+       if (!ADS_ERR_OK(ads_status)) {
+               DEBUG(4, ("find_forest_root: ads_connect(%s) failed! (%s)\n",
+                         domain, ads_errstr(ads_status)));
+       }
+       nt_status = ads_ntstatus(ads_status);
+       BAIL_ON_NTSTATUS_ERROR(nt_status);
+
+       if (!ads_cldap_netlogon_5(frame,
+                                 ads->config.ldap_server_name,
+                                 ads->config.realm,
+                                 &cldap_reply))
+       {
+               DEBUG(4,("find_forest_root: Failed to get a CLDAP reply from %s!\n",
+                        ads->server.ldap_server));
+               nt_status = NT_STATUS_IO_TIMEOUT;
+               BAIL_ON_NTSTATUS_ERROR(nt_status);
+       }
+
+       gc->forest_name = talloc_strdup(gc, cldap_reply.forest);
+       BAIL_ON_PTR_ERROR(gc->forest_name, nt_status);
+
+done:
+       if (ads) {
+               ads_destroy(&ads);
+       }
+
+       return nt_status;
+}
+
+/**********************************************************************
+ *********************************************************************/
+
+static NTSTATUS gc_add_forest(const char *domain)
+{
+       NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
+       struct gc_info *gc = NULL;
+       struct gc_info *find_gc = NULL;
+       char *dn;
+       ADS_STRUCT *ads = NULL;
+       struct likewise_cell *primary_cell = NULL;
+
+       primary_cell = cell_list_head();
+       if (!primary_cell) {
+               nt_status = NT_STATUS_INVALID_SERVER_STATE;
+               BAIL_ON_NTSTATUS_ERROR(nt_status);
+       }
+
+       /* Check for duplicates based on domain name first as this
+           requires no connection */
+
+       find_gc = gc_list_head();
+       while (find_gc) {
+               if (strequal (find_gc->forest_name, domain))
+                       break;
+               find_gc = find_gc->next;
+       }
+
+       if (find_gc) {
+               DEBUG(10,("gc_add_forest: %s already in list\n", find_gc->forest_name));
+               return NT_STATUS_OK;
+       }
+
+       if ((gc = TALLOC_ZERO_P(NULL, struct gc_info)) == NULL) {
+               nt_status = NT_STATUS_NO_MEMORY;
+               BAIL_ON_NTSTATUS_ERROR(nt_status);
+       }
+
+       /* Query the rootDSE for the forest root naming conect first.
+           Check that the a GC server for the forest has not already
+          been added */
+
+       nt_status = gc_find_forest_root(gc, domain);
+       BAIL_ON_NTSTATUS_ERROR(nt_status);
+
+       find_gc = gc_list_head();
+       while (find_gc) {
+               if (strequal (find_gc->forest_name, gc->forest_name))
+                       break;
+               find_gc = find_gc->next;
+       }
+
+       if (find_gc) {
+               DEBUG(10,("gc_add_forest: Forest %s already in list\n",
+                         find_gc->forest_name));
+               return NT_STATUS_OK;
+       }
+
+       /* Not found, so add it here.  Make sure we connect to
+          a DC in _this_ domain and not the forest root. */
+
+       dn = ads_build_dn(gc->forest_name);
+       BAIL_ON_PTR_ERROR(dn, nt_status);
+
+       gc->search_base = talloc_strdup(gc, dn);
+       SAFE_FREE(dn);
+       BAIL_ON_PTR_ERROR(gc->search_base, nt_status);
+
+#if 0
+       /* Can't use cell_connect_dn() here as there is no way to
+          specifiy the LWCELL_FLAG_GC_CELL flag setting for cell_connect() */
+
+       nt_status = cell_connect_dn(&gc->forest_cell, gc->search_base);
+       BAIL_ON_NTSTATUS_ERROR(nt_status);
+#else
+
+       gc->forest_cell = cell_new();
+       BAIL_ON_PTR_ERROR(gc->forest_cell, nt_status);
+
+       /* Set the DNS domain, dn, etc ... and add it to the list */
+
+       cell_set_dns_domain(gc->forest_cell, gc->forest_name);
+       cell_set_dn(gc->forest_cell, gc->search_base);
+       cell_set_flags(gc->forest_cell, LWCELL_FLAG_GC_CELL);
+#endif
+
+       /* It is possible to belong to a non-forest cell and a
+          non-provisioned forest (at our domain levele). In that
+          case, we should just inherit the flags from our primary
+          cell since the GC searches will match our own schema
+          model. */
+
+       if (strequal(primary_cell->forest_name, gc->forest_name)
+           || is_subdomain(primary_cell->dns_domain, gc->forest_name))
+       {
+               cell_set_flags(gc->forest_cell, cell_flags(primary_cell));
+       } else {
+               /* outside of our domain */
+
+               nt_status = cell_connect(gc->forest_cell);
+               BAIL_ON_NTSTATUS_ERROR(nt_status);
+
+               nt_status = cell_lookup_settings(gc->forest_cell);
+               BAIL_ON_NTSTATUS_ERROR(nt_status);
+
+               /* Drop the connection now that we have the settings */
+
+               ads = cell_connection(gc->forest_cell);
+               ads_destroy(&ads);
+               cell_set_connection(gc->forest_cell, NULL);
+       }
+
+       DLIST_ADD_END(_gc_server_list, gc, struct gc_info*);
+
+       DEBUG(10,("gc_add_forest: Added %s to Global Catalog list of servers\n",
+                 gc->forest_name));
+
+       nt_status = NT_STATUS_OK;
+
+done:
+       if (!NT_STATUS_IS_OK(nt_status)) {
+               talloc_destroy(gc);
+               DEBUG(3,("LWI: Failed to add new GC connection for %s (%s)\n",
+                        domain, nt_errstr(nt_status)));
+       }
+
+       return nt_status;
+}
+
+/**********************************************************************
+ *********************************************************************/
+
+static void gc_server_list_destroy(void)
+{
+       struct gc_info *gc = gc_list_head();
+
+       while (gc) {
+               struct gc_info *p = gc->next;
+
+               cell_destroy(gc->forest_cell);
+               talloc_destroy(gc);
+
+               gc = p;
+       }
+
+       _gc_server_list = NULL;
+
+       return;
+}
+
+/**********************************************************************
+ Setup the initial list of forests and initial the forest cell
+ settings for each.  FIXME!!!
+ *********************************************************************/
+
+ NTSTATUS gc_init_list(void)
+{
+       NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
+       struct winbindd_tdc_domain *domains = NULL;
+       size_t num_domains = 0;
+       int i;
+
+       if (_gc_server_list != NULL) {
+               gc_server_list_destroy();
+       }
+
+       if (!wcache_tdc_fetch_list(&domains, &num_domains)) {
+               nt_status = NT_STATUS_CANT_ACCESS_DOMAIN_INFO;
+               BAIL_ON_NTSTATUS_ERROR(nt_status);
+       }
+
+       /* Find our forest first.  Have to try all domains here starting
+          with our own.  gc_add_forest() filters duplicates */
+
+       nt_status = gc_add_forest(lp_realm());
+       WARN_ON_NTSTATUS_ERROR(nt_status);
+
+       for (i=0; i<num_domains; i++) {
+               uint32_t flags = (NETR_TRUST_FLAG_IN_FOREST);
+
+               /* I think we should be able to break out of loop once
+                  we add a GC for our forest and not have to test every one.
+                  In fact, this entire loop is probably irrelevant since
+                  the GC location code should always find a GC given lp_realm().
+                  Will have to spend time testing before making the change.
+                  --jerry */
+
+               if ((domains[i].trust_flags & flags) == flags) {
+                       nt_status = gc_add_forest(domains[i].dns_name);
+                       WARN_ON_NTSTATUS_ERROR(nt_status);
+                       /* Don't BAIL here since not every domain may
+                          have a GC server */
+               }
+       }
+
+       /* Now add trusted forests.  gc_add_forest() will filter out
+          duplicates. Check everything with an incoming trust path
+          that is not in our own forest.  */
+
+       for (i=0; i<num_domains; i++) {
+               uint32_t flags = domains[i].trust_flags;
+               uint32_t attribs = domains[i].trust_attribs;
+
+               /* Skip non_AD domains */
+
+               if (strlen(domains[i].dns_name) == 0) {
+                       continue;
+               }
+
+               /* Only add a GC for a forest outside of our own.
+                  Ignore QUARANTINED/EXTERNAL trusts */
+
+               if ((flags & NETR_TRUST_FLAG_INBOUND)
+                   && !(flags & NETR_TRUST_FLAG_IN_FOREST)
+                   && (attribs & NETR_TRUST_ATTRIBUTE_FOREST_TRANSITIVE))
+               {
+                       nt_status = gc_add_forest(domains[i].dns_name);
+                       WARN_ON_NTSTATUS_ERROR(nt_status);
+               }
+       }
+
+       nt_status = NT_STATUS_OK;
+
+done:
+       if (!NT_STATUS_IS_OK(nt_status)) {
+               DEBUG(2,("LWI: Failed to initialized GC list (%s)\n",
+                        nt_errstr(nt_status)));
+       }
+
+       TALLOC_FREE(domains);
+
+       return nt_status;
+}
+
+
+/**********************************************************************
+ *********************************************************************/
+
+ struct gc_info *gc_search_start(void)
+{
+       NTSTATUS nt_status = NT_STATUS_OK;
+       struct gc_info *gc = gc_list_head();
+
+       if (!gc) {
+               nt_status = gc_init_list();
+               BAIL_ON_NTSTATUS_ERROR(nt_status);
+
+               gc = gc_list_head();
+       }
+
+done:
+       if (!NT_STATUS_IS_OK(nt_status)) {
+               DEBUG(2,("LWI: Failed to initialize GC list (%s)\n",
+                        nt_errstr(nt_status)));
+       }
+
+       return gc;
+}
+
+/**********************************************************************
+ Search Global Catalog.  Always search our own forest.  The flags set
+ controls whether or not we search cross forest.  Assume that the
+ resulting set is always returned from one GC so that we don't have to
+ both combining the LDAPMessage * results
+ *********************************************************************/
+
+ NTSTATUS gc_search_forest(struct gc_info *gc,
+                          LDAPMessage **msg,
+                          const char *filter)
+{
+       NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
+       ADS_STATUS ads_status = ADS_ERROR_NT(NT_STATUS_UNSUCCESSFUL);
+       const char *attrs[] = {"*", NULL};
+       LDAPMessage *m = NULL;
+
+       if (!gc || !msg || !filter) {
+               nt_status = NT_STATUS_INVALID_PARAMETER;
+               BAIL_ON_NTSTATUS_ERROR(nt_status);
+       }
+
+       /* When you have multiple domain trees in a forest, the
+          GC will search all naming contexts when you send it
+          and empty ("") base search suffix.   Tested against
+          Windows 2003.  */
+
+       ads_status = cell_do_search(gc->forest_cell, "",
+                                  LDAP_SCOPE_SUBTREE, filter, attrs, &m);
+       nt_status = ads_ntstatus(ads_status);
+       BAIL_ON_NTSTATUS_ERROR(nt_status);
+
+       *msg = m;
+
+done:
+       if (!NT_STATUS_IS_OK(nt_status)) {
+               DEBUG(2,("LWI: Forest wide search %s failed (%s)\n",
+                        filter, nt_errstr(nt_status)));
+       }
+
+       return nt_status;
+}
+
+/**********************************************************************
+ Search all forests via GC and return the results in an array of
+ ADS_STRUCT/LDAPMessage pairs.
+ *********************************************************************/
+
+ NTSTATUS gc_search_all_forests(const char *filter,
+                               ADS_STRUCT ***ads_list,
+                               LDAPMessage ***msg_list,
+                               int *num_resp, uint32_t flags)
+{
+       NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
+       struct gc_info *gc = NULL;
+       uint32_t test_flags = ADEX_GC_SEARCH_CHECK_UNIQUE;
+
+       *ads_list = NULL;
+       *msg_list = NULL;
+       *num_resp = 0;
+
+       if ((gc = gc_search_start()) == NULL) {
+               nt_status = NT_STATUS_INVALID_DOMAIN_STATE;
+               BAIL_ON_NTSTATUS_ERROR(nt_status);
+       }
+
+       while (gc) {
+               LDAPMessage *m = NULL;
+
+               nt_status = gc_search_forest(gc, &m, filter);
+               if (!NT_STATUS_IS_OK(nt_status)) {
+                       gc = gc->next;
+                       continue;
+               }
+
+               nt_status = add_ads_result_to_array(cell_connection(gc->forest_cell),
+                                                   m, ads_list, msg_list,
+                                                   num_resp);
+               BAIL_ON_NTSTATUS_ERROR(nt_status);
+
+               /* If there can only be one match, then we are done */
+
+               if ((*num_resp > 0) && ((flags & test_flags) == test_flags)) {
+                       break;
+               }
+
+               gc = gc->next;
+       }
+
+       if (*num_resp == 0) {
+               nt_status = NT_STATUS_OBJECT_NAME_NOT_FOUND;
+               BAIL_ON_NTSTATUS_ERROR(nt_status);
+       }
+
+       nt_status = NT_STATUS_OK;
+
+done:
+       return nt_status;
+}
+
+/**********************************************************************
+ Search all forests via GC and return the results in an array of
+ ADS_STRUCT/LDAPMessage pairs.
+ *********************************************************************/
+
+ NTSTATUS gc_search_all_forests_unique(const char *filter,
+                                      ADS_STRUCT **ads,
+                                      LDAPMessage **msg)
+{
+       ADS_STRUCT **ads_list = NULL;
+       LDAPMessage **msg_list = NULL;
+       int num_resp;
+       NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
+
+       nt_status = gc_search_all_forests(filter, &ads_list,
+                                         &msg_list, &num_resp,
+                                         ADEX_GC_SEARCH_CHECK_UNIQUE);
+       BAIL_ON_NTSTATUS_ERROR(nt_status);
+
+       nt_status = check_result_unique(ads_list[0], msg_list[0]);
+       BAIL_ON_NTSTATUS_ERROR(nt_status);
+
+       *ads = ads_list[0];
+       *msg = msg_list[0];
+
+done:
+       /* Be care that we don't free the msg result being returned */
+
+       if (!NT_STATUS_IS_OK(nt_status)) {
+               free_result_array(ads_list, msg_list, num_resp);
+       } else {
+               talloc_destroy(ads_list);
+               talloc_destroy(msg_list);
+       }
+
+       return nt_status;
+}
+
+/*********************************************************************
+ ********************************************************************/
+
+ NTSTATUS gc_name_to_sid(const char *domain,
+                        const char *name,
+                        DOM_SID *sid,
+                        enum lsa_SidType *sid_type)
+{
+       TALLOC_CTX *frame = talloc_stackframe();
+       char *p, *name_user;
+       NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
+       char *name_filter;
+       ADS_STRUCT *ads = NULL;
+       LDAPMessage *msg = NULL;
+       LDAPMessage *e = NULL;
+       char *dn = NULL;
+       char *dns_domain = NULL;
+       ADS_STRUCT **ads_list = NULL;
+       LDAPMessage **msg_list = NULL;
+       int num_resp = 0;
+       int i;
+
+       /* Strip the "DOMAIN\" prefix if necessary and search for
+          a matching sAMAccountName in the forest */
+
+       if ((p = strchr_m( name, '\\' )) == NULL)
+               name_user = talloc_strdup( frame, name );
+       else
+               name_user = talloc_strdup( frame, p+1 );
+       BAIL_ON_PTR_ERROR(name_user, nt_status);
+
+       name_filter = talloc_asprintf(frame, "(sAMAccountName=%s)", name_user);
+       BAIL_ON_PTR_ERROR(name_filter, nt_status);
+
+       nt_status = gc_search_all_forests(name_filter, &ads_list,
+                                         &msg_list, &num_resp, 0);
+       BAIL_ON_NTSTATUS_ERROR(nt_status);
+
+       /* Assume failure until we know otherwise*/
+
+       nt_status = NT_STATUS_OBJECT_NAME_NOT_FOUND;
+
+       /* Match the domain name from the DN */
+
+       for (i=0; i<num_resp; i++) {
+               ads = ads_list[i];
+               msg = msg_list[i];
+
+               e = ads_first_entry(ads, msg);
+               while (e) {
+                       struct winbindd_tdc_domain *domain_rec;
+
+                       dn = ads_get_dn(ads, e);
+                       BAIL_ON_PTR_ERROR(dn, nt_status);
+
+                       dns_domain = cell_dn_to_dns(dn);
+                       SAFE_FREE(dn);
+                       BAIL_ON_PTR_ERROR(dns_domain, nt_status);
+
+                       domain_rec = wcache_tdc_fetch_domain(frame, dns_domain);
+                       SAFE_FREE(dns_domain);
+
+                       /* Ignore failures and continue the search */
+
+                       if (!domain_rec) {
+                               e = ads_next_entry(ads, e);
+                               continue;
+                       }
+
+                       /* Check for a match on the domain name */
+
+                       if (strequal(domain, domain_rec->domain_name)) {
+                               if (!ads_pull_sid(ads, e, "objectSid", sid)) {
+                                       nt_status = NT_STATUS_INVALID_SID;
+                                       BAIL_ON_NTSTATUS_ERROR(nt_status);
+                               }
+
+                               talloc_destroy(domain_rec);
+
+                               nt_status = get_sid_type(ads, msg, sid_type);
+                               BAIL_ON_NTSTATUS_ERROR(nt_status);
+
+                               /* We're done! */
+                               nt_status = NT_STATUS_OK;
+                               break;
+                       }
+
+                       /* once more around thew merry-go-round */
+
+                       talloc_destroy(domain_rec);
+                       e = ads_next_entry(ads, e);
+               }
+       }
+
+done:
+       free_result_array(ads_list, msg_list, num_resp);
+       talloc_destroy(frame);
+
+       return nt_status;
+}
+
+/********************************************************************
+ Pull an attribute string value
+ *******************************************************************/
+
+static NTSTATUS get_object_account_name(ADS_STRUCT *ads,
+                                       LDAPMessage *msg,
+                                       char **name)
+{
+       NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
+       char *sam_name = NULL;
+       struct winbindd_tdc_domain *domain_rec = NULL;
+       char *dns_domain = NULL;
+       char *dn = NULL;
+       TALLOC_CTX *frame = talloc_stackframe();
+       int len;
+
+       /* Check parameters */
+
+       if (!ads || !msg || !name) {
+               nt_status = NT_STATUS_INVALID_PARAMETER;
+               BAIL_ON_NTSTATUS_ERROR(nt_status);
+       }
+
+       /* get the name and domain */
+
+       dn = ads_get_dn(ads, msg);
+       BAIL_ON_PTR_ERROR(dn, nt_status);
+
+       DEBUG(10,("get_object_account_name: dn = \"%s\"\n", dn));
+
+       dns_domain = cell_dn_to_dns(dn);
+       SAFE_FREE(dn);
+       BAIL_ON_PTR_ERROR(dns_domain, nt_status);
+
+       domain_rec = wcache_tdc_fetch_domain(frame, dns_domain);
+       SAFE_FREE(dns_domain);
+
+       if (!domain_rec) {
+               nt_status = NT_STATUS_TRUSTED_DOMAIN_FAILURE;
+               BAIL_ON_NTSTATUS_ERROR(nt_status);
+       }
+
+       sam_name = ads_pull_string(ads, frame, msg, "sAMAccountName");
+       BAIL_ON_PTR_ERROR(sam_name, nt_status);
+
+       len = asprintf(name, "%s\\%s", domain_rec->domain_name, sam_name);
+       if (len == -1) {
+               *name = NULL;
+               BAIL_ON_PTR_ERROR((*name), nt_status);
+       }
+
+       nt_status = NT_STATUS_OK;
+
+done:
+       talloc_destroy(frame);
+
+       return nt_status;
+}
+
+/*********************************************************************
+ ********************************************************************/
+
+ NTSTATUS gc_sid_to_name(const DOM_SID *sid,
+                        char **name,
+                        enum lsa_SidType *sid_type)
+{
+       TALLOC_CTX *frame = talloc_stackframe();
+       NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
+       char *filter;
+       ADS_STRUCT *ads = NULL;
+       LDAPMessage *msg = NULL;
+       char *sid_string;
+
+       *name = NULL;
+
+       sid_string = sid_binstring(sid);
+       BAIL_ON_PTR_ERROR(sid_string, nt_status);
+
+       filter = talloc_asprintf(frame, "(objectSid=%s)", sid_string);
+       SAFE_FREE(sid_string);
+       BAIL_ON_PTR_ERROR(filter, nt_status);
+
+       nt_status = gc_search_all_forests_unique(filter, &ads, &msg);
+       BAIL_ON_NTSTATUS_ERROR(nt_status);
+
+       nt_status = get_object_account_name(ads, msg, name);
+       BAIL_ON_NTSTATUS_ERROR(nt_status);
+
+       nt_status = get_sid_type(ads, msg, sid_type);
+       BAIL_ON_NTSTATUS_ERROR(nt_status);
+
+done:
+       ads_msgfree(ads, msg);
+       talloc_destroy(frame);
+
+       return nt_status;
+}
+
+/**********************************************************************
+ *********************************************************************/
+
+ NTSTATUS add_ads_result_to_array(ADS_STRUCT *ads,
+                                 LDAPMessage *msg,
+                                 ADS_STRUCT ***ads_list,
+                                 LDAPMessage ***msg_list,
+                                 int *size)
+{
+       NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
+       ADS_STRUCT **ads_tmp = NULL;
+       LDAPMessage **msg_tmp = NULL;
+       int count = *size;
+
+       if (!ads || !msg) {
+               nt_status = NT_STATUS_INVALID_PARAMETER;
+               BAIL_ON_NTSTATUS_ERROR(nt_status);
+       }
+
+#if 0
+       /* Don't add a response with no entries */
+
+       if (ads_count_replies(ads, msg) == 0) {
+               return NT_STATUS_OK;
+       }
+#endif
+
+       if (count == 0) {
+               ads_tmp = TALLOC_ARRAY(NULL, ADS_STRUCT*, 1);
+               BAIL_ON_PTR_ERROR(ads_tmp, nt_status);
+
+               msg_tmp = TALLOC_ARRAY(NULL, LDAPMessage*, 1);
+               BAIL_ON_PTR_ERROR(msg_tmp, nt_status);
+       } else {
+               ads_tmp = TALLOC_REALLOC_ARRAY(*ads_list, *ads_list, ADS_STRUCT*,
+                                              count+1);
+               BAIL_ON_PTR_ERROR(ads_tmp, nt_status);
+
+               msg_tmp = TALLOC_REALLOC_ARRAY(*msg_list, *msg_list, LDAPMessage*,
+                                              count+1);
+               BAIL_ON_PTR_ERROR(msg_tmp, nt_status);
+       }
+
+       ads_tmp[count] = ads;
+       msg_tmp[count] = msg;
+       count++;
+
+       *ads_list = ads_tmp;
+       *msg_list = msg_tmp;
+       *size = count;
+
+       nt_status = NT_STATUS_OK;
+
+done:
+       if (!NT_STATUS_IS_OK(nt_status)) {
+               talloc_destroy(ads_tmp);
+               talloc_destroy(msg_tmp);
+       }
+
+       return nt_status;
+}
+
+/**********************************************************************
+ Frees search results.  Do not free the ads_list as these are
+ references back to the GC search structures.
+ *********************************************************************/
+
+ void free_result_array(ADS_STRUCT **ads_list,
+                       LDAPMessage **msg_list,
+                       int num_resp)
+{
+       int i;
+
+       for (i=0; i<num_resp; i++) {
+               ads_msgfree(ads_list[i], msg_list[i]);
+       }
+
+       talloc_destroy(ads_list);
+       talloc_destroy(msg_list);
+}
+
+/**********************************************************************
+ Check that we have exactly one entry from the search
+ *********************************************************************/
+
+ NTSTATUS check_result_unique(ADS_STRUCT *ads, LDAPMessage *msg)
+{
+       NTSTATUS nt_status;
+       int count;
+
+       count = ads_count_replies(ads, msg);
+
+       if (count <= 0) {
+               nt_status = NT_STATUS_OBJECT_NAME_NOT_FOUND;
+               BAIL_ON_NTSTATUS_ERROR(nt_status);
+       }
+
+       if (count > 1) {
+               nt_status = NT_STATUS_DUPLICATE_NAME;
+               BAIL_ON_NTSTATUS_ERROR(nt_status);
+       }
+
+       nt_status = NT_STATUS_OK;
+
+done:
+       return nt_status;
+}
diff --git a/source3/winbindd/idmap_adex/idmap_adex.c b/source3/winbindd/idmap_adex/idmap_adex.c
new file mode 100644 (file)
index 0000000..23ab843
--- /dev/null
@@ -0,0 +1,460 @@
+/*
+ * idmap_adex: Support for D Forests
+ *
+ * Copyright (C) Gerald (Jerry) Carter 2006-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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include "includes.h"
+#include "idmap_adex.h"
+
+#undef DBGC_CLASS
+#define DBGC_CLASS DBGC_IDMAP
+
+#define WINBIND_CCACHE_NAME "MEMORY:winbind_ccache"
+
+NTSTATUS init_module(void);
+
+/*
+ * IdMap backend
+ */
+
+/********************************************************************
+ Basic init function responsible for determining our current mode
+ (standalone or using Centeris Cells).  This must return success or
+ it will be dropped from the idmap backend list.
+ *******************************************************************/
+
+static NTSTATUS _idmap_adex_init(struct idmap_domain *dom,
+                                    const char *params)
+{
+       ADS_STRUCT *ads = NULL;
+       ADS_STATUS status;
+       static NTSTATUS init_status = NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND;
+       DOM_SID domain_sid;
+       fstring dcname;
+       struct sockaddr_storage ip;
+       struct likewise_cell *lwcell;
+
+       if (NT_STATUS_IS_OK(init_status))
+               return NT_STATUS_OK;
+
+       /* Silently fail if we are not a member server in security = ads */
+
+       if ((lp_server_role() != ROLE_DOMAIN_MEMBER) ||
+           (lp_security() != SEC_ADS)) {
+               init_status = NT_STATUS_INVALID_SERVER_STATE;
+               BAIL_ON_NTSTATUS_ERROR(init_status);
+       }
+
+       /* fetch our domain SID first */
+
+       if (!secrets_fetch_domain_sid(lp_workgroup(), &domain_sid)) {
+               init_status = NT_STATUS_CANT_ACCESS_DOMAIN_INFO;
+               BAIL_ON_NTSTATUS_ERROR(init_status);
+       }
+
+       /* reuse the same ticket cache as winbindd */
+
+       setenv("KRB5CCNAME", WINBIND_CCACHE_NAME, 1);
+
+       /* Establish a connection to a DC */
+
+       if ((ads = ads_init(lp_realm(), lp_workgroup(), NULL)) == NULL) {
+               init_status = NT_STATUS_NO_MEMORY;
+               BAIL_ON_NTSTATUS_ERROR(init_status);
+       }
+
+       ads->auth.password =
+           secrets_fetch_machine_password(lp_workgroup(), NULL, NULL);
+       ads->auth.realm = SMB_STRDUP(lp_realm());
+
+       /* get the DC name here to setup the server affinity cache and
+          local krb5.conf */
+
+       get_dc_name(lp_workgroup(), lp_realm(), dcname, &ip);
+
+       status = ads_connect(ads);
+       if (!ADS_ERR_OK(status)) {
+               DEBUG(0, ("_idmap_adex_init: ads_connect() failed! (%s)\n",
+                         ads_errstr(status)));
+       }
+       init_status = ads_ntstatus(status);
+       BAIL_ON_NTSTATUS_ERROR(init_status);
+
+
+       /* Find out cell membership */
+
+       init_status = cell_locate_membership(ads);
+       if (!NT_STATUS_IS_OK(init_status)) {
+               DEBUG(0,("LWI: Fail to locate cell membership (%s).",
+                        nt_errstr(init_status)));
+               goto done;
+       }
+
+       /* Fill in the cell information */
+
+       lwcell = cell_list_head();
+
+       init_status = cell_lookup_settings(lwcell);
+       BAIL_ON_NTSTATUS_ERROR(init_status);
+
+       /* Miscellaneous setup.  E.g. set up the list of GC
+          servers and domain list for our forest (does not actually
+          connect). */
+
+       init_status = gc_init_list();
+       BAIL_ON_NTSTATUS_ERROR(init_status);
+
+       init_status = domain_init_list();
+       BAIL_ON_NTSTATUS_ERROR(init_status);
+
+done:
+       if (!NT_STATUS_IS_OK(init_status)) {
+               DEBUG(1,("Likewise initialization failed (%s)\n",
+                        nt_errstr(init_status)));
+       }
+
+       /* cleanup */
+
+       if (!NT_STATUS_IS_OK(init_status)) {
+               cell_list_destroy();
+
+               /* init_status stores the failure reason but we need to
+                  return success or else idmap_init() will drop us from the
+                  backend list */
+               return NT_STATUS_OK;
+       }
+
+       init_status = NT_STATUS_OK;
+
+       return init_status;
+}
+
+/**********************************************************************
+ *********************************************************************/
+
+static NTSTATUS _idmap_adex_get_sid_from_id(struct
+                                               idmap_domain
+                                               *dom, struct
+                                               id_map
+                                               **ids)
+{
+       int i;
+       bool one_mapped = false;
+       bool all_mapped = true;
+       NTSTATUS nt_status;
+        struct likewise_cell *cell;
+
+       nt_status = _idmap_adex_init(dom, NULL);
+       if (!NT_STATUS_IS_OK(nt_status))
+               return nt_status;
+
+       if ((cell = cell_list_head()) == NULL) {
+               return NT_STATUS_INVALID_SERVER_STATE;
+       }
+
+       /* have to work through these one by one */
+       for (i = 0; ids[i]; i++) {
+               NTSTATUS status;
+               status = cell->provider->get_sid_from_id(ids[i]->sid,
+                                                        ids[i]->xid.id,
+                                                        ids[i]->xid.type);
+               /* Fail if we cannot find any DC */
+               if (NT_STATUS_EQUAL
+                   (status, NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND)) {
+                       return status;
+               }
+
+               if (!NT_STATUS_IS_OK(status)) {
+                       ids[i]->status = ID_UNMAPPED;
+                       all_mapped = false;
+                       continue;
+               }
+
+               ids[i]->status = ID_MAPPED;
+               one_mapped = true;
+       }
+
+       return NT_STATUS_OK;
+}
+
+/**********************************************************************
+ *********************************************************************/
+
+static NTSTATUS _idmap_adex_get_id_from_sid(struct
+                                               idmap_domain
+                                               *dom, struct
+                                               id_map
+                                               **ids)
+{
+       int i;
+       bool one_mapped = false;
+       bool all_mapped = true;
+       NTSTATUS nt_status;
+        struct likewise_cell *cell;
+
+       nt_status = _idmap_adex_init(dom, NULL);
+       if (!NT_STATUS_IS_OK(nt_status))
+               return nt_status;
+
+       if ((cell = cell_list_head()) == NULL) {
+               return NT_STATUS_INVALID_SERVER_STATE;
+       }
+
+       /* have to work through these one by one */
+       for (i = 0; ids[i]; i++) {
+               NTSTATUS status;
+               status = cell->provider->get_id_from_sid(&ids[i]->xid.id,
+                                                        &ids[i]->xid.
+                                                        type, ids[i]->sid);
+               /* Fail if we cannot find any DC */
+               if (NT_STATUS_EQUAL
+                   (status, NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND)) {
+                       return status;
+               }
+
+               if (!NT_STATUS_IS_OK(status)) {
+                       ids[i]->status = ID_UNMAPPED;
+                       all_mapped = false;
+                       continue;
+               }
+
+               ids[i]->status = ID_MAPPED;
+               one_mapped = true;
+       }
+
+       return NT_STATUS_OK;
+}
+
+/**********************************************************************
+ *********************************************************************/
+
+static NTSTATUS _idmap_adex_set_mapping(struct
+                                           idmap_domain
+                                           *dom, const struct
+                                           id_map *map)
+{
+       DEBUG(0, ("_idmap_adex_set_mapping: not implemented\n"));
+       return NT_STATUS_NOT_IMPLEMENTED;
+}
+
+/**********************************************************************
+ *********************************************************************/
+
+static NTSTATUS _idmap_adex_remove_mapping(struct
+                                              idmap_domain
+                                              *dom, const
+                                              struct
+                                              id_map
+                                              *map)
+{
+       DEBUG(0, ("_idmap_adex_remove_mapping: not implemented\n"));
+       return NT_STATUS_NOT_IMPLEMENTED;
+}
+
+/**********************************************************************
+ *********************************************************************/
+
+static NTSTATUS _idmap_adex_dump(struct idmap_domain
+                                    *dom, struct id_map **maps, int *num_map)
+{
+       return NT_STATUS_NOT_IMPLEMENTED;
+}
+
+/**********************************************************************
+ *********************************************************************/
+
+static NTSTATUS _idmap_adex_close(struct idmap_domain
+                                     *dom)
+{
+       /* FIXME!  need to do cleanup here */
+
+       return NT_STATUS_OK;
+}
+
+/*
+ * IdMap NSS plugin
+ */
+
+/**********************************************************************
+ *********************************************************************/
+
+static NTSTATUS _nss_adex_init(struct nss_domain_entry
+                                 *e)
+{
+       return _idmap_adex_init(NULL, NULL);
+}
+
+/**********************************************************************
+ *********************************************************************/
+
+static NTSTATUS _nss_adex_get_info(struct
+                                     nss_domain_entry *e,
+                                     const DOM_SID * sid,
+                                     TALLOC_CTX * ctx,
+                                     ADS_STRUCT * ads,
+                                     LDAPMessage * msg,
+                                     char **homedir,
+                                     char **shell, char **gecos, gid_t * p_gid)
+{
+       NTSTATUS nt_status;
+        struct likewise_cell *cell;
+
+       nt_status = _idmap_adex_init(NULL, NULL);
+       if (!NT_STATUS_IS_OK(nt_status))
+               return nt_status;
+
+       if ((cell = cell_list_head()) == NULL) {
+               return NT_STATUS_INVALID_SERVER_STATE;
+       }
+
+       return cell->provider->get_nss_info(sid, ctx, homedir,
+                                           shell, gecos, p_gid);
+}
+
+/**********************************************************************
+ *********************************************************************/
+
+static NTSTATUS _nss_adex_map_to_alias(TALLOC_CTX * mem_ctx, const char
+                                         *domain, const char
+                                         *name, char **alias)
+{
+       NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
+        struct likewise_cell *cell = NULL;
+
+       nt_status = _idmap_adex_init(NULL, NULL);
+       BAIL_ON_NTSTATUS_ERROR(nt_status);
+
+       if ((cell = cell_list_head()) == NULL) {
+               nt_status = NT_STATUS_INVALID_SERVER_STATE;
+               BAIL_ON_NTSTATUS_ERROR(nt_status);
+       }
+
+       nt_status = cell->provider->map_to_alias(mem_ctx, domain,
+                                                name, alias);
+
+       /* go ahead and allow the cache mgr to mark this in
+          negative cache */
+
+       if (!NT_STATUS_IS_OK(nt_status))
+               nt_status = NT_STATUS_NONE_MAPPED;
+
+done:
+       return nt_status;
+}
+
+/**********************************************************************
+ *********************************************************************/
+
+static NTSTATUS _nss_adex_map_from_alias(TALLOC_CTX * mem_ctx, const char
+                                           *domain, const char
+                                           *alias, char **name)
+{
+       NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
+        struct likewise_cell *cell = NULL;
+
+       nt_status = _idmap_adex_init(NULL, NULL);
+       BAIL_ON_NTSTATUS_ERROR(nt_status);
+
+       if ((cell = cell_list_head()) == NULL) {
+               nt_status = NT_STATUS_INVALID_SERVER_STATE;
+               BAIL_ON_NTSTATUS_ERROR(nt_status);
+       }
+
+
+       nt_status = cell->provider->map_from_alias(mem_ctx, domain,
+                                                  alias, name);
+
+       /* go ahead and allow the cache mgr to mark this in
+          negative cache */
+
+       if (!NT_STATUS_IS_OK(nt_status))
+               nt_status = NT_STATUS_NONE_MAPPED;
+
+done:
+       return nt_status;
+}
+
+/**********************************************************************
+ *********************************************************************/
+
+static NTSTATUS _nss_adex_close(void)
+{
+       return NT_STATUS_NOT_IMPLEMENTED;
+}
+
+/**********************************************************************
+ *********************************************************************/
+
+static struct idmap_methods adex_idmap_methods = {
+
+       .init             = _idmap_adex_init,
+       .unixids_to_sids  = _idmap_adex_get_sid_from_id,
+       .sids_to_unixids  = _idmap_adex_get_id_from_sid,
+       .set_mapping      = _idmap_adex_set_mapping,
+       .remove_mapping   = _idmap_adex_remove_mapping,
+       .dump_data        = _idmap_adex_dump,
+       .close_fn         = _idmap_adex_close
+};
+static struct nss_info_methods adex_nss_methods = {
+       .init           = _nss_adex_init,
+       .get_nss_info   = _nss_adex_get_info,
+       .map_to_alias   = _nss_adex_map_to_alias,
+       .map_from_alias = _nss_adex_map_from_alias,
+       .close_fn       = _nss_adex_close
+};
+
+/**********************************************************************
+ Register with the idmap and idmap_nss subsystems. We have to protect
+ against the idmap and nss_info interfaces being in a half-registered
+ state.
+ **********************************************************************/
+NTSTATUS idmap_adex_init(void)
+{
+       static NTSTATUS idmap_status = NT_STATUS_UNSUCCESSFUL;
+       static NTSTATUS nss_status = NT_STATUS_UNSUCCESSFUL;
+       if (!NT_STATUS_IS_OK(idmap_status)) {
+               idmap_status =
+                   smb_register_idmap(SMB_IDMAP_INTERFACE_VERSION,
+                                      "adex", &adex_idmap_methods);
+               if (!NT_STATUS_IS_OK(idmap_status)) {
+                       DEBUG(0,
+                             ("idmap_centeris_init: Failed to register the adex"
+                              "idmap plugin.\n"));
+                       return idmap_status;
+               }
+       }
+
+       if (!NT_STATUS_IS_OK(nss_status)) {
+               nss_status =
+                   smb_register_idmap_nss(SMB_NSS_INFO_INTERFACE_VERSION,
+                                          "adex", &adex_nss_methods);
+               if (!NT_STATUS_IS_OK(nss_status)) {
+                       DEBUG(0,
+                             ("idmap_adex_init: Failed to register the adex"
+                              "nss plugin.\n"));
+                       return nss_status;
+               }
+       }
+
+       return NT_STATUS_OK;
+}
+
+NTSTATUS nss_info_adex_init(void)
+{
+       return idmap_adex_init();
+}
diff --git a/source3/winbindd/idmap_adex/idmap_adex.h b/source3/winbindd/idmap_adex/idmap_adex.h
new file mode 100644 (file)
index 0000000..f91bba8
--- /dev/null
@@ -0,0 +1,257 @@
+/*
+ * idmap_centeris: Support for Local IDs and Centeris Cell Structure
+ *
+ * Copyright (C) Gerald (Jerry) Carter 2006-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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef _IDMAP_ADEX_H
+#define _IDMAP_ADEX_H
+
+#include "winbindd/winbindd.h"
+
+#define ADEX_CELL_RDN             "$LikewiseIdentityCell"
+
+#define ADEX_OC_USER              "centerisLikewiseUser"
+#define ADEX_OC_GROUP             "centerisLikewiseGroup"
+
+#define AD_USER                 "User"
+#define AD_GROUP                "Group"
+
+#define ADEX_OC_POSIX_USER        "posixAccount"
+#define ADEX_OC_POSIX_GROUP       "posixGroup"
+
+#define ADEX_ATTR_UIDNUM          "uidNumber"
+#define ADEX_ATTR_GIDNUM          "gidNUmber"
+#define ADEX_ATTR_HOMEDIR         "unixHomeDirectory"
+#define ADEX_ATTR_USERPW          "unixUserPassword"
+#define ADEX_ATTR_GROUPALIAS      "groupAlias" /* Not part of RFC2307 */
+#define ADEX_ATTR_SHELL           "loginShell"
+#define ADEX_ATTR_GECOS           "gecos"
+#define ADEX_ATTR_UID             "uid"
+#define ADEX_ATTR_DISPLAYNAME     "displayName"
+
+#define MIN_ID_VALUE            100
+
+#define BAIL_ON_NTSTATUS_ERROR(x)         \
+       do {                               \
+               if (!NT_STATUS_IS_OK(x)) { \
+                       DEBUG(10,("Failed! (%s)\n", nt_errstr(x)));     \
+                       goto done;         \
+               }                          \
+       }                                  \
+       while (0);                         \
+
+#define WARN_ON_NTSTATUS_ERROR(x)         \
+       do {                               \
+               if (!NT_STATUS_IS_OK(x)) { \
+                       DEBUG(10,("Failure ignored! (%s)\n", nt_errstr(x)));    \
+               }                          \
+       }                                  \
+       while (0);                         \
+
+#define BAIL_ON_ADS_ERROR(x)              \
+       do {                               \
+               if (!ADS_ERR_OK(x)) {      \
+                       goto done;         \
+               }                          \
+       }                                  \
+       while (0);
+
+#define BAIL_ON_PTR_ERROR(p, x)                                \
+       do {                                            \
+               if ((p) == NULL ) {                     \
+                       DEBUG(10,("NULL pointer!\n"));  \
+                       x = NT_STATUS_NO_MEMORY;        \
+                       goto done;                      \
+               }                                       \
+       } while (0);
+
+#define PRINT_NTSTATUS_ERROR(x, hdr, level)                            \
+       do {                                                            \
+               if (!NT_STATUS_IS_OK(x)) {                              \
+                       DEBUG(level,("LWI ("hdr"): %s\n", nt_errstr(x))); \
+               }                                                       \
+       } while(0);
+/*
+ * Cell Provider API
+ */
+
+struct cell_provider_api {
+       NTSTATUS(*get_sid_from_id) (DOM_SID * sid,
+                                   uint32_t id, enum id_type type);
+       NTSTATUS(*get_id_from_sid) (uint32_t * id,
+                                   enum id_type * type, const DOM_SID * sid);
+       NTSTATUS(*get_nss_info) (const DOM_SID * sid,
+                                TALLOC_CTX * ctx,
+                                char **homedir,
+                                char **shell, char **gecos, gid_t * p_gid);
+       NTSTATUS(*map_to_alias) (TALLOC_CTX * mem_ctx,
+                                const char *domain,
+                                const char *name, char **alias);
+       NTSTATUS(*map_from_alias) (TALLOC_CTX * mem_ctx,
+                                  const char *domain,
+                                  const char *alias, char **name);
+};
+
+/* registered providers */
+
+extern struct cell_provider_api ccp_unified;
+extern struct cell_provider_api ccp_local;
+
+#define LWCELL_FLAG_USE_RFC2307_ATTRS     0x00000001
+#define LWCELL_FLAG_SEARCH_FOREST         0x00000002
+#define LWCELL_FLAG_GC_CELL               0x00000004
+#define LWCELL_FLAG_LOCAL_MODE            0x00000008
+
+struct likewise_cell {
+       struct likewise_cell *prev, *next;
+       ADS_STRUCT *conn;
+       struct likewise_cell *gc_search_cell;
+       DOM_SID domain_sid;
+       char *dns_domain;
+       char *forest_name;
+       char *dn;
+       struct GUID *links;        /* only held by owning cell */
+       size_t num_links;
+       uint32_t flags;
+       struct cell_provider_api *provider;
+};
+
+/* Search flags used for Global Catalog API */
+
+#define ADEX_GC_SEARCH_CHECK_UNIQUE        0x00000001
+
+struct gc_info {
+       struct gc_info *prev, *next;
+       char *forest_name;
+       char *search_base;
+       struct likewise_cell *forest_cell;
+};
+
+/* Available functions outside of idmap_lwidentity.c */
+
+/* cell_util.c */
+
+char *find_attr_string(char **list, size_t num_lines, const char *substr);
+bool is_object_class(char **list, size_t num_lines, const char *substr);
+int min_id_value(void);
+char *cell_dn_to_dns(const char *dn);
+NTSTATUS get_sid_type(ADS_STRUCT *ads,
+                     LDAPMessage *msg,
+                     enum lsa_SidType *type);
+
+NTSTATUS cell_locate_membership(ADS_STRUCT * ads);
+NTSTATUS cell_lookup_settings(struct likewise_cell * cell);
+NTSTATUS cell_follow_links(struct likewise_cell *cell);
+NTSTATUS cell_set_local_provider(void);
+
+/* likewise_cell.c */
+
+struct likewise_cell *cell_new(void);
+struct likewise_cell *cell_list_head(void);
+
+bool cell_list_add(struct likewise_cell *cell);
+bool cell_list_remove(struct likewise_cell * cell);
+
+void cell_list_destroy();
+void cell_destroy(struct likewise_cell *c);
+void cell_set_forest_searches(struct likewise_cell *c,
+                               bool search);
+void cell_set_dns_domain(struct likewise_cell *c,
+                          const char *dns_domain);
+void cell_set_connection(struct likewise_cell *c,
+                          ADS_STRUCT *ads);
+void cell_set_dn(struct likewise_cell *c,
+                  const char *dn);
+void cell_set_domain_sid(struct likewise_cell *c,
+                          DOM_SID *sid);
+void cell_set_flags(struct likewise_cell *c, uint32_t flags);
+void cell_clear_flags(struct likewise_cell *c, uint32_t flags);
+
+const char* cell_search_base(struct likewise_cell *c);
+const char *cell_dns_domain(struct likewise_cell *c);
+ADS_STRUCT *cell_connection(struct likewise_cell *c);
+bool cell_search_forest(struct likewise_cell *c);
+ADS_STATUS cell_do_search(struct likewise_cell *c,
+                         const char *search_base,
+                         int scope,
+                         const char *expr,
+                         const char **attrs,
+                         LDAPMessage ** msg);
+uint32_t cell_flags(struct likewise_cell *c);
+
+NTSTATUS cell_connect_dn(struct likewise_cell **c,
+                        const char *dn);
+NTSTATUS cell_connect(struct likewise_cell *c);
+
+
+/* gc_util.c */
+
+NTSTATUS gc_init_list(void);
+
+NTSTATUS gc_find_forest_root(struct gc_info *gc,
+                            const char *domain);
+
+struct gc_info *gc_search_start(void);
+
+NTSTATUS gc_search_forest(struct gc_info *gc,
+                         LDAPMessage **msg,
+                         const char *filter);
+
+NTSTATUS gc_search_all_forests(const char *filter,
+                              ADS_STRUCT ***ads_list,
+                              LDAPMessage ***msg_list,
+                              int *num_resp, uint32_t flags);
+
+NTSTATUS gc_search_all_forests_unique(const char *filter,
+                                     ADS_STRUCT **ads,
+                                     LDAPMessage **msg);
+
+NTSTATUS gc_name_to_sid(const char *domain,
+                       const char *name,
+                       DOM_SID *sid,
+                       enum lsa_SidType *sid_type);
+
+NTSTATUS gc_sid_to_name(const DOM_SID *sid,
+                       char **name,
+                       enum lsa_SidType *sid_type);
+
+NTSTATUS add_ads_result_to_array(ADS_STRUCT *ads,
+                                LDAPMessage *msg,
+                                ADS_STRUCT ***ads_list,
+                                LDAPMessage ***msg_list,
+                                int *size);
+
+void free_result_array(ADS_STRUCT **ads_list,
+                      LDAPMessage **msg_list,
+                      int num_resp);
+
+NTSTATUS check_result_unique(ADS_STRUCT *ads,
+                            LDAPMessage *msg);
+
+
+/* domain_util.c */
+
+NTSTATUS domain_init_list(void);
+
+NTSTATUS dc_search_domains(struct likewise_cell **cell,
+                          LDAPMessage **msg,
+               &nbs