Merge branch 'v4-0-test' into id10ts-registry
authorJelmer Vernooij <jelmer@samba.org>
Sun, 2 Mar 2008 23:23:09 +0000 (00:23 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Sun, 2 Mar 2008 23:23:09 +0000 (00:23 +0100)
(This used to be commit f98b59021a5ea39c7970ebc5520d17775e500b8c)

187 files changed:
.gitignore
source4/Makefile
source4/auth/auth_sam.c
source4/auth/config.mk
source4/auth/credentials/config.mk
source4/auth/gensec/config.mk
source4/auth/sam.c
source4/build/m4/check_make.m4
source4/build/smb_build/README.txt
source4/build/smb_build/cflags.pm [deleted file]
source4/build/smb_build/config_mk.pm
source4/build/smb_build/env.pm [deleted file]
source4/build/smb_build/input.pm
source4/build/smb_build/main.pl
source4/build/smb_build/makefile.pm
source4/build/smb_build/output.pm
source4/cldap_server/cldap_server.c
source4/cluster/ctdb/opendb_ctdb.c
source4/configure.ac
source4/dsdb/common/util.c
source4/dsdb/config.mk
source4/dsdb/samdb/ldb_modules/samldb.c
source4/dynconfig.mk
source4/kdc/hdb-ldb.c
source4/kdc/kdc.c
source4/kdc/kdc.h
source4/lib/appweb/mpr/miniMpr.c
source4/lib/appweb/mpr/miniMpr.h
source4/lib/basic.mk
source4/lib/charset/config.mk
source4/lib/charset/util_unistr.c
source4/lib/cmdline/config.mk
source4/lib/events/config.mk
source4/lib/ldb/config.mk
source4/lib/ldb/include/ldb.h
source4/lib/ldb/ldb.i
source4/lib/ldb/ldb_ildap/ldb_ildap.c
source4/lib/ldb/ldb_wrap.c
source4/lib/ldb/modules/rdn_name.c
source4/lib/ldb/tools/config.mk
source4/lib/nss_wrapper/config.mk
source4/lib/registry/config.mk
source4/lib/registry/hive.c
source4/lib/registry/hive.h
source4/lib/registry/ldb.c
source4/lib/registry/patchfile.c
source4/lib/registry/patchfile.h
source4/lib/registry/patchfile_dotreg.c
source4/lib/registry/patchfile_preg.c
source4/lib/registry/regf.c
source4/lib/registry/tests/hive.c
source4/lib/registry/tools/regdiff.c
source4/lib/replace/Makefile.in
source4/lib/replace/configure.ac
source4/lib/replace/getifaddrs.c
source4/lib/replace/getifaddrs.m4
source4/lib/replace/test/getifaddrs.c [new file with mode: 0644]
source4/lib/replace/test/testsuite.c
source4/lib/socket_wrapper/config.mk
source4/lib/talloc/config.mk
source4/lib/tdb/config.mk
source4/lib/tdr/config.mk
source4/lib/util/config.mk
source4/libcli/auth/config.mk
source4/libcli/cldap/cldap.c
source4/libcli/cldap/cldap.h
source4/libcli/config.mk
source4/libcli/dgram/dgramsocket.c
source4/libcli/dgram/libdgram.h
source4/libcli/finddcs.c
source4/libcli/ldap/config.mk
source4/libcli/nbt/libnbt.h
source4/libcli/nbt/nbtsocket.c
source4/libcli/raw/clisession.c
source4/libcli/raw/clisocket.c
source4/libcli/raw/libcliraw.h
source4/libcli/resolve/bcast.c
source4/libcli/resolve/nbtlist.c
source4/libcli/resolve/wins.c
source4/libcli/smb_composite/fetchfile.c
source4/libcli/smb_composite/sesssetup.c
source4/libcli/smb_composite/smb_composite.h
source4/libcli/swig/libcli_nbt.i
source4/libcli/swig/libcli_nbt_wrap.c
source4/libcli/wrepl/winsrepl.c
source4/libcli/wrepl/winsrepl.h
source4/libnet/config.mk
source4/libnet/libnet_become_dc.c
source4/libnet/libnet_lookup.c
source4/libnet/libnet_site.c
source4/libnet/libnet_unbecome_dc.c
source4/libnet/libnet_user.c
source4/libnet/libnet_user.h
source4/librpc/config.mk
source4/librpc/idl/unixinfo.idl
source4/librpc/rpc/dcerpc.c
source4/librpc/rpc/dcerpc_util.c
source4/nbt_server/dgram/request.c
source4/nbt_server/interfaces.c
source4/ntvfs/common/notify.c
source4/ntvfs/common/opendb.c
source4/ntvfs/common/opendb.h
source4/ntvfs/common/opendb_tdb.c
source4/ntvfs/config.mk
source4/ntvfs/posix/pvfs_open.c
source4/ntvfs/posix/pvfs_qfileinfo.c
source4/ntvfs/posix/pvfs_rename.c
source4/ntvfs/posix/pvfs_resolve.c
source4/ntvfs/posix/pvfs_setfileinfo.c
source4/ntvfs/posix/pvfs_xattr.c
source4/ntvfs/sysdep/inotify.c
source4/param/config.mk
source4/param/generic.c
source4/param/loadparm.c
source4/param/loadparm.h
source4/param/param.h
source4/param/param.i
source4/param/param.py
source4/param/param_wrap.c
source4/param/share.c
source4/param/share_classic.c
source4/param/share_ldb.c
source4/param/tests/loadparm.c
source4/rpc_server/config.mk
source4/rpc_server/dcerpc_server.c
source4/rpc_server/dcesrv_auth.c
source4/rpc_server/netlogon/dcerpc_netlogon.c
source4/rpc_server/samr/dcesrv_samr.c
source4/rules.mk
source4/script/cflags.pl [deleted file]
source4/script/mkproto.pl
source4/scripting/ejs/ejsnet/net_ctx.c
source4/scripting/ejs/smbcalls.c
source4/scripting/ejs/smbcalls_auth.c
source4/scripting/ejs/smbcalls_cli.c
source4/scripting/ejs/smbcalls_config.c
source4/scripting/ejs/smbcalls_creds.c
source4/scripting/ejs/smbcalls_data.c
source4/scripting/ejs/smbcalls_ldb.c
source4/scripting/ejs/smbcalls_nbt.c
source4/scripting/ejs/smbcalls_reg.c
source4/scripting/ejs/smbcalls_rpc.c
source4/scripting/ejs/smbcalls_sys.c
source4/scripting/python/config.mk
source4/scripting/python/samba/provision.py
source4/selftest/samba4_tests.sh
source4/setup/provision.reg
source4/setup/provision_self_join.ldif
source4/setup/provision_templates.ldif
source4/setup/provision_users.ldif
source4/smb_server/smb/request.c
source4/smb_server/smb_server.c
source4/smbd/config.mk
source4/smbd/server.c
source4/smbd/service_stream.c
source4/torture/config.mk
source4/torture/ldap/cldap.c
source4/torture/ldap/cldapbench.c
source4/torture/libnet/groupinfo.c
source4/torture/libnet/groupman.c
source4/torture/libnet/libnet_user.c
source4/torture/libnet/userinfo.c
source4/torture/libnet/userman.c
source4/torture/libnet/utils.c
source4/torture/libnet/utils.h
source4/torture/local/config.mk
source4/torture/nbt/dgram.c
source4/torture/nbt/query.c
source4/torture/nbt/register.c
source4/torture/nbt/wins.c
source4/torture/nbt/winsbench.c
source4/torture/nbt/winsreplication.c
source4/torture/raw/chkpath.c
source4/torture/raw/composite.c
source4/torture/raw/oplock.c
source4/torture/raw/qfsinfo.c
source4/torture/raw/setfileinfo.c
source4/torture/rpc/dssync.c
source4/torture/rpc/samr.c
source4/torture/t_strcmp.c [deleted file]
source4/utils/config.mk
source4/utils/nmblookup.c
source4/utils/testparm.c
source4/winbind/wb_dom_info.c
source4/winbind/wb_pam_auth.c
source4/wrepl_server/wrepl_out_helpers.c
testprogs/ejs/ldap.js

index f75f698c6565e05a39a721afcc5d8bb3bc062516..3a2e5642e7db93c9cdceb5f81091f5e3cddaaa49 100644 (file)
@@ -197,3 +197,4 @@ source/apidocs
 *.swp
 source/mkconfig.mk
 source/data.mk
+source/librpc/idl-deps
index 1fddfefce3b3fcb444165d5c1f3734a022a445ad..97518ebcb695ea71f16b726b74c6d227a949e105 100644 (file)
@@ -19,11 +19,39 @@ BNLD_FLAGS = $(LDFLAGS) $(SYS_LDFLAGS)
 HOSTCC_FLAGS = -D_SAMBA_HOSTCC_ $(CFLAGS)
 HOSTLD_FLAGS = $(LDFLAGS) $(SYS_LDFLAGS)
 
-default: all
+.DEFAULT_GOAL := all
+
+ifneq ($(automatic_deps),yes)
+ALL_PREDEP = proto
+.NOTPARALLEL:
+endif
 
 include rules.mk
 include data.mk
 
+DEP_FILES = $(patsubst %.ho,%.hd,$(patsubst %.o,%.d,$(ALL_OBJS))) \
+                  include/includes.d
+
+ifeq ($(automatic_deps),yes)
+ifneq ($(MAKECMDGOALS),clean)
+ifneq ($(MAKECMDGOALS),distclean)
+ifneq ($(MAKECMDGOALS),realdistclean)
+ifneq ($(SKIP_DEP_FILES),yes)
+-include $(DEP_FILES)
+endif
+endif
+endif
+endif
+
+ifneq ($(SKIP_DEP_FILES),yes)
+clean::
+       @echo Removing dependency files
+       @find . -name '*.d' -o -name '*.hd' | xargs rm -f
+endif
+else
+include $(srcdir)/static_deps.mk
+endif
+
 DEFAULT_HEADERS = $(srcdir)/lib/util/dlinklist.h \
                  $(srcdir)/version.h
 
index 918964015039951f11f605e394f1bce25eec40d2..4cb8d2b304f20661091d6d424d70a57e5e7d3c4f 100644 (file)
@@ -226,7 +226,9 @@ static NTSTATUS authsam_authenticate(struct auth_context *auth_context,
 {
        struct samr_Password *lm_pwd, *nt_pwd;
        NTSTATUS nt_status;
-       uint16_t acct_flags = samdb_result_acct_flags(msgs[0], "userAccountControl");
+       struct ldb_dn *domain_dn = samdb_result_dn(sam_ctx, mem_ctx, msgs_domain_ref[0], "nCName", NULL);
+
+       uint16_t acct_flags = samdb_result_acct_flags(sam_ctx, mem_ctx, msgs[0], domain_dn);
        
        /* Quit if the account was locked out. */
        if (acct_flags & ACB_AUTOLOCK) {
index 5b320bcf363d4b28c935c36dc5a8280a497decef..369c5bb4e622e2a5ea267cef40236a5a855e45ff 100644 (file)
@@ -6,13 +6,14 @@ mkinclude credentials/config.mk
 
 [SUBSYSTEM::auth_session]
 OBJ_FILES = session.o
-PUBLIC_HEADERS = session.h
-PUBLIC_PROTO_HEADER = session_proto.h
+PRIVATE_PROTO_HEADER = session_proto.h
 PUBLIC_DEPENDENCIES = CREDENTIALS
 
+PUBLIC_HEADERS += auth/session.h
+
 [SUBSYSTEM::auth_system_session]
 OBJ_FILES = system_session.o
-PUBLIC_PROTO_HEADER = system_session_proto.h
+PRIVATE_PROTO_HEADER = system_session_proto.h
 PUBLIC_DEPENDENCIES = CREDENTIALS
 PRIVATE_DEPENDENCIES = auth_session LIBSAMBA-UTIL LIBSECURITY 
 
@@ -81,8 +82,7 @@ OBJ_FILES = pam_errors.o
 [SUBSYSTEM::auth]
 #VERSION = 0.0.1
 #SO_VERSION = 0
-PUBLIC_HEADERS = auth.h
-PUBLIC_PROTO_HEADER = auth_proto.h
+PRIVATE_PROTO_HEADER = auth_proto.h
 OBJ_FILES = \
                auth.o \
                auth_util.o \
@@ -92,6 +92,8 @@ PRIVATE_DEPENDENCIES = LIBSAMBA-UTIL
 # End SUBSYSTEM auth
 #######################
 
+PUBLIC_HEADERS += auth/auth.h
+
 [PYTHON::swig_auth]
 PUBLIC_DEPENDENCIES = auth_system_session
 PRIVATE_DEPENDENCIES = SAMDB 
index fee9519ae5b8893287d537c6b7c8a2fab6f3e005..ef8db50109722f379a28ec1c3a5f92910d1cbbe0 100644 (file)
@@ -1,8 +1,7 @@
 #################################
 # Start SUBSYSTEM CREDENTIALS
 [SUBSYSTEM::CREDENTIALS]
-PUBLIC_PROTO_HEADER = credentials_proto.h
-PUBLIC_HEADERS = credentials.h credentials_krb5.h
+PRIVATE_PROTO_HEADER = credentials_proto.h
 OBJ_FILES = credentials.o \
                credentials_files.o \
                credentials_ntlm.o \
@@ -13,6 +12,8 @@ PUBLIC_DEPENDENCIES = \
 PRIVATE_DEPENDENCIES = \
                SECRETS
 
+PUBLIC_HEADERS += $(addprefix auth/credentials/, credentials.h credentials_krb5.h)
+
 [PYTHON::swig_credentials]
 PUBLIC_DEPENDENCIES = CREDENTIALS LIBCMDLINE_CREDENTIALS
 SWIG_FILE = credentials.i
index 9aab2c704ece2862670fe034756062f9924e3418..b60f039284f17c8cdb4527cc0414cee8bd9f2892 100644 (file)
@@ -4,14 +4,15 @@
 PC_FILE = gensec.pc
 VERSION = 0.0.1
 SO_VERSION = 0
-PUBLIC_HEADERS = gensec.h spnego.h
-PUBLIC_PROTO_HEADER = gensec_proto.h
+PRIVATE_PROTO_HEADER = gensec_proto.h
 OBJ_FILES = gensec.o socket.o
 PUBLIC_DEPENDENCIES = \
                CREDENTIALS LIBSAMBA-UTIL LIBCRYPTO ASN1_UTIL samba-socket LIBPACKET
 # End SUBSYSTEM gensec
 #################################
 
+PUBLIC_HEADERS += $(addprefix auth/gensec/, gensec.h spnego.h)
+
 ################################################
 # Start MODULE gensec_krb5
 [MODULE::gensec_krb5]
index fdd7de7c7103084805b63c7e18a1bb628e91e0fb..9a8045f62d62071aac9a5bfb05112ea261fbe845 100644 (file)
@@ -149,19 +149,20 @@ _PUBLIC_ NTSTATUS authsam_account_ok(TALLOC_CTX *mem_ctx,
        const char *workstation_list;
        NTTIME acct_expiry;
        NTTIME must_change_time;
-       NTTIME last_set_time;
 
        struct ldb_dn *domain_dn = samdb_result_dn(sam_ctx, mem_ctx, msg_domain_ref, "nCName", ldb_dn_new(mem_ctx, sam_ctx, NULL));
 
        NTTIME now;
        DEBUG(4,("authsam_account_ok: Checking SMB password for user %s\n", name_for_logs));
 
-       acct_flags = samdb_result_acct_flags(msg, "userAccountControl");
+       acct_flags = samdb_result_acct_flags(sam_ctx, mem_ctx, msg, domain_dn);
        
        acct_expiry = samdb_result_nttime(msg, "accountExpires", 0);
+
+       /* Check for when we must change this password, taking the
+        * userAccountControl flags into account */
        must_change_time = samdb_result_force_password_change(sam_ctx, mem_ctx, 
                                                              domain_dn, msg);
-       last_set_time = samdb_result_nttime(msg, "pwdLastSet", 0);
 
        workstation_list = samdb_result_string(msg, "userWorkstations", NULL);
 
@@ -186,22 +187,20 @@ _PUBLIC_ NTSTATUS authsam_account_ok(TALLOC_CTX *mem_ctx,
                return NT_STATUS_ACCOUNT_EXPIRED;
        }
 
-       if (!(acct_flags & ACB_PWNOEXP)) {
-               /* check for immediate expiry "must change at next logon" */
-               if (must_change_time == 0 && last_set_time != 0) {
-                       DEBUG(1,("sam_account_ok: Account for user '%s' password must change!.\n", 
-                                name_for_logs));
-                       return NT_STATUS_PASSWORD_MUST_CHANGE;
-               }
+       /* check for immediate expiry "must change at next logon" */
+       if (must_change_time == 0) {
+               DEBUG(1,("sam_account_ok: Account for user '%s' password must change!.\n", 
+                        name_for_logs));
+               return NT_STATUS_PASSWORD_MUST_CHANGE;
+       }
 
-               /* check for expired password */
-               if ((must_change_time != 0) && (must_change_time < now)) {
-                       DEBUG(1,("sam_account_ok: Account for user '%s' password expired!.\n", 
-                                name_for_logs));
-                       DEBUG(1,("sam_account_ok: Password expired at '%s' unix time.\n", 
-                                nt_time_string(mem_ctx, must_change_time)));
-                       return NT_STATUS_PASSWORD_EXPIRED;
-               }
+       /* check for expired password */
+       if (must_change_time < now) {
+               DEBUG(1,("sam_account_ok: Account for user '%s' password expired!.\n", 
+                        name_for_logs));
+               DEBUG(1,("sam_account_ok: Password expired at '%s' unix time.\n", 
+                        nt_time_string(mem_ctx, must_change_time)));
+               return NT_STATUS_PASSWORD_EXPIRED;
        }
 
        /* Test workstation. Workstation list is comma separated. */
@@ -267,6 +266,7 @@ _PUBLIC_ NTSTATUS authsam_make_server_info(TALLOC_CTX *mem_ctx, struct ldb_conte
        struct dom_sid **groupSIDs = NULL;
        struct dom_sid *account_sid;
        struct dom_sid *primary_group_sid;
+       struct ldb_dn *domain_dn;
        const char *str;
        struct ldb_dn *ncname;
        int i;
@@ -368,7 +368,10 @@ _PUBLIC_ NTSTATUS authsam_make_server_info(TALLOC_CTX *mem_ctx, struct ldb_conte
        server_info->logon_count = samdb_result_uint(msg, "logonCount", 0);
        server_info->bad_password_count = samdb_result_uint(msg, "badPwdCount", 0);
 
-       server_info->acct_flags = samdb_result_acct_flags(msg, "userAccountControl");
+       domain_dn = samdb_result_dn(sam_ctx, mem_ctx, msg_domain_ref, "nCName", NULL);
+
+       server_info->acct_flags = samdb_result_acct_flags(sam_ctx, mem_ctx, 
+                                                         msg, domain_dn);
 
        server_info->user_session_key = user_sess_key;
        server_info->lm_session_key = lm_sess_key;
index d7799649a7fd0c5e971e83e66831b97b59823ce7..f497684453982e89f6dbe1ef8023eaf30e61371c 100644 (file)
@@ -6,35 +6,26 @@ dnl  Released under the GNU GPL
 dnl -------------------------------------------------------
 dnl
 
-AC_PATH_PROG(MAKE,make)
+AC_PATH_PROGS(MAKE,gmake make)
 
 AC_CACHE_CHECK([whether we have GNU make], samba_cv_gnu_make, [
-if $ac_cv_path_MAKE --version | head -1 | grep GNU 2>/dev/null >/dev/null
+if $ac_cv_path_MAKE --version | head -1 | grep GNU 2>/dev/null >/dev/null
 then
-       samba_cv_gnu_make=yes
-else
-       samba_cv_gnu_make=no
+       AC_MSG_ERROR([Unable to find GNU make])
 fi
 ])
 
-GNU_MAKE=$samba_cv_gnu_make
-AC_SUBST(GNU_MAKE)
-
-if test "x$GNU_MAKE" = x"yes"; then
-       AC_CACHE_CHECK([GNU make version], samba_cv_gnu_make_version,[
+AC_CACHE_CHECK([GNU make version], samba_cv_gnu_make_version,[
                samba_cv_gnu_make_version=`$ac_cv_path_MAKE --version | head -1 | cut -d " " -f 3 2>/dev/null`
        ])
        GNU_MAKE_VERSION=$samba_cv_gnu_make_version
        AC_SUBST(GNU_MAKE_VERSION)
-fi
 
 
 new_make=no
 AC_MSG_CHECKING([for GNU make >= 3.81])
-if test x$GNU_MAKE = x"yes"; then
-       if $PERL -e " \$_ = '$GNU_MAKE_VERSION'; s/@<:@^\d\.@:>@.*//g; exit (\$_ < 3.81);"; then
-               new_make=yes
-       fi
+if $PERL -e " \$_ = '$GNU_MAKE_VERSION'; s/@<:@^\d\.@:>@.*//g; exit (\$_ < 3.81);"; then
+       new_make=yes
 fi
 AC_MSG_RESULT($new_make)
 automatic_dependencies=no
@@ -46,11 +37,3 @@ AC_ARG_ENABLE(automatic-dependencies,
 [ automatic_dependencies=no ])
 AC_MSG_RESULT($automatic_dependencies)
 AC_SUBST(automatic_dependencies)
-
-FIRST_PREREQ="\$*.c"
-AC_SUBST(FIRST_PREREQ)
-
-if test x$GNU_MAKE = xyes; then
-       FIRST_PREREQ="\$<"
-fi
-
index a5e4db99e0cc88acd8c9a2a199081954f5616e50..eac3905ccef651753cc88f222f624d096e996908 100644 (file)
@@ -1,6 +1,5 @@
 The Samba Build System\r
-----------------------\r
-----------------------\r
+======================\r
 \r
 The build system basically has two main parts: the autoconf-generated \r
 shell scripts which check for availability of functions and libraries \r
@@ -29,7 +28,7 @@ EXT_LIB:
 BINARY:\r
        a BINARY means a executable binary file.\r
        (e.g. 'smbtorture' or 'ldbedit')\r
-       a BINARY typicly has only commandline handling and basic \r
+       a BINARY typically has only commandline handling and basic \r
        functionality code in it and depends on the functions of\r
        SUBSYSTEM's (REQUIRED_SUBSYSTEMS).\r
 \r
@@ -50,8 +49,6 @@ input.pm - Input validation
 main.pm - Main\r
 makefile.pm - Makefile generation\r
 output.pm - Dependency calculation\r
-header.pm - build.h generation\r
-cflags.pm - Generates cflags.txt for file-specific cflags\r
 \r
 Layout\r
 -------\r
diff --git a/source4/build/smb_build/cflags.pm b/source4/build/smb_build/cflags.pm
deleted file mode 100755 (executable)
index a4ab90a..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-# SMB Build System
-#
-#  Copyright (C) Jelmer Vernooij 2006
-#  Released under the GNU GPL
-
-package cflags;
-use strict;
-
-my $sort_available = eval "use sort 'stable'; return 1;";
-$sort_available = 0 unless defined($sort_available);
-
-sub by_path {
-       return  1 if($a =~ m#^\-I/#);
-       return -1 if($b =~ m#^\-I/#);
-       return  0;
-}
-
-sub create_cflags($$$$) {
-       my $CTX = shift;
-       my $srcdir = shift;
-       my $builddir = shift;
-       my $file = shift;
-
-       open(CFLAGS_TXT,">$file") || die ("Can't open `$file'\n");
-
-       print CFLAGS_TXT "include mkconfig.mk\n";
-
-       my $src_ne_build = ($srcdir ne $builddir) ? 1 : 0;
-
-       foreach my $key (values %{$CTX}) {
-               next unless defined ($key->{OBJ_LIST});
-               next unless defined ($key->{FINAL_CFLAGS});
-               next unless (@{$key->{FINAL_CFLAGS}} > 0);
-
-               my @sorted_cflags = @{$key->{FINAL_CFLAGS}};
-               if ($sort_available) {
-                       @sorted_cflags = sort by_path @{$key->{FINAL_CFLAGS}};
-               }
-
-               # Rewrite CFLAGS so that both the source and the build
-               # directories are in the path.
-               my @cflags = ();
-               foreach my $flag (@sorted_cflags) {
-                       if($src_ne_build) {
-                               if($flag =~ m#^-I([^/].*$)#) {
-                                       my $dir = $1;
-                                       $dir =~ s#^\$\((?:src|build)dir\)/?##;
-                                       push(@cflags, "-I$builddir/$dir", "-I$srcdir/$dir");
-                                       next;
-                               }
-                       }
-                       push(@cflags, $flag);
-               }
-               
-               my $cflags = join(' ', @cflags);
-
-               foreach (@{$key->{OBJ_LIST}}) {
-                       my $ofile = $_;
-                       my $dfile = $_;
-                       $dfile =~ s/\.o$/.d/;
-                       $dfile =~ s/\.ho$/.d/;
-                       print CFLAGS_TXT "$ofile $dfile: CFLAGS+= $cflags\n";
-               }
-       }
-       close(CFLAGS_TXT);
-
-       print __FILE__.": creating $file\n";
-}
-1;
index 4d8db8a04ea54418a9ed74049d19ffc4174f1693..d8ec646910a49472634ae0240019ce8c62d88556 100644 (file)
@@ -36,13 +36,8 @@ my $section_types = {
 
                "ENABLE"                => "bool",
 
-               "MANPAGE"               => "string",
-
-               "PUBLIC_PROTO_HEADER"   => "string",
                "PRIVATE_PROTO_HEADER"  => "string",
 
-               "PUBLIC_HEADERS"        => "list",
-
                "CFLAGS"                => "list",
                "LDFLAGS"               => "list",
                "STANDARD_VISIBILITY"   => "string",
@@ -62,7 +57,6 @@ my $section_types = {
 
                "OUTPUT_TYPE"           => "list",
 
-               "MANPAGE"               => "string",
                "PRIVATE_PROTO_HEADER"  => "string",
 
                "CFLAGS"                => "list"
@@ -74,7 +68,6 @@ my $section_types = {
 
                "ENABLE"                => "bool",
 
-               "MANPAGE"               => "string",
                "INSTALLDIR"            => "string",
                "PRIVATE_PROTO_HEADER"  => "string",
 
@@ -102,11 +95,6 @@ my $section_types = {
 
                "ENABLE"                => "bool",
 
-               "MANPAGE"               => "string",
-
-               "PUBLIC_HEADERS"        => "list",
-
-               "PUBLIC_PROTO_HEADER"   => "string",
                "PRIVATE_PROTO_HEADER"  => "string",
 
                "CFLAGS"                => "list",
diff --git a/source4/build/smb_build/env.pm b/source4/build/smb_build/env.pm
deleted file mode 100644 (file)
index 76cd8d1..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-# Environment class
-#
-# Samba Build Environment
-#
-# (C) 2005 Jelmer Vernooij <jelmer@samba.org>
-#
-# Published under the GNU GPL
-
-package smb_build::env;
-use smb_build::input;
-use File::Path;
-use File::Basename;
-
-use strict;
-
-sub new($$)
-{ 
-       my ($name, $config) = @_;
-       my $self = { };
-       bless $self, $name;
-
-       $self->{items} = {};
-       $self->{info} = {};
-       
-       $self->_set_config($config);
-
-       return $self;
-}
-
-sub _set_config($$)
-{
-       my ($self, $config) = @_;
-
-       $self->{config} = $config;
-
-       if (not defined($self->{config}->{srcdir})) {
-               $self->{config}->{srcdir} = '.';
-       }
-
-       if (not defined($self->{config}->{builddir})) {
-               $self->{config}->{builddir}  = '.';
-       }
-
-       if ($self->{config}->{prefix} eq "NONE") {
-               $self->{config}->{prefix} = $self->{config}->{ac_default_prefix};
-       }
-
-       if ($self->{config}->{exec_prefix} eq "NONE") {
-               $self->{config}->{exec_prefix} = $self->{config}->{prefix};
-       }
-       
-       $self->{developer} = ($self->{config}->{developer} eq "yes");
-       $self->{gnu_make} = ($self->{config}->{GNU_MAKE} eq "yes");
-       $self->{automatic_deps} = ($self->{config}->{automatic_dependencies} eq "yes");
-}
-
-1;
index 8c9a6efacc3d7f79bb2ea0f4dccfdbf30a556f3c..948f2657b4cb7a9bca621d42646ac78b8696c6aa 100644 (file)
@@ -233,14 +233,6 @@ sub check($$$$$)
        my ($INPUT, $enabled, $subsys_ot, $lib_ot, $module_ot) = @_;
 
        foreach my $part (values %$INPUT) {
-               unless (defined($part->{PUBLIC_HEADERS})) {
-                       $part->{PUBLIC_HEADERS} = [];
-               }
-               
-               if (defined($part->{PUBLIC_PROTO_HEADER})) {
-                       push (@{$part->{PUBLIC_HEADERS}}, $part->{PUBLIC_PROTO_HEADER});
-               }
-
                if (defined($enabled->{$part->{NAME}})) { 
                        $part->{ENABLE} = $enabled->{$part->{NAME}};
                        next;
index 3ed0327d6d7fef90c7adff22d1abe16dd359cef3..c3dc46461bdb977abf8b01e9f48ba5807209e77c 100644 (file)
@@ -10,8 +10,6 @@ use smb_build::header;
 use smb_build::input;
 use smb_build::config_mk;
 use smb_build::output;
-use smb_build::env;
-use smb_build::cflags;
 use smb_build::summary;
 use smb_build::config;
 use strict;
@@ -56,7 +54,7 @@ foreach my $key (values %$OUTPUT) {
        $mkenv->MergedObj($key) if grep(/MERGED_OBJ/, @{$key->{OUTPUT_TYPE}});
        $mkenv->StaticLibrary($key) if grep(/STATIC_LIBRARY/, @{$key->{OUTPUT_TYPE}});
        if (defined($key->{PC_FILE})) {
-               push(@{$mkenv->{pc_files}}, "$key->{BASEDIR}/$key->{PC_FILE}");
+               $mkenv->output("PC_FILES += $key->{BASEDIR}/$key->{PC_FILE}\n");
        } 
        $mkenv->SharedLibraryPrimitives($key) if ($key->{TYPE} eq "LIBRARY") and
                                        grep(/SHARED_LIBRARY/, @{$key->{OUTPUT_TYPE}});
@@ -68,10 +66,8 @@ foreach my $key (values %$OUTPUT) {
                                                                   $key->{TYPE} eq "PYTHON") and
                                        grep(/SHARED_LIBRARY/, @{$key->{OUTPUT_TYPE}});
        $mkenv->PythonFiles($key) if defined($key->{PYTHON_FILES});
-       $mkenv->Manpage($key) if defined($key->{MANPAGE});
-       $mkenv->Header($key) if defined($key->{PUBLIC_HEADERS});
-       $mkenv->ProtoHeader($key) if defined($key->{PRIVATE_PROTO_HEADER}) or 
-                                        defined($key->{PUBLIC_PROTO_HEADER});
+       $mkenv->ProtoHeader($key) if defined($key->{PRIVATE_PROTO_HEADER});
+       $mkenv->CFlags($key);
 }
 
 foreach my $key (values %$OUTPUT) {
@@ -88,16 +84,6 @@ foreach my $key (values %$OUTPUT) {
 $mkenv->write("data.mk");
 header::create_smb_build_h($OUTPUT, "include/build.h");
 
-cflags::create_cflags($OUTPUT, $config::config{srcdir},
-                   $config::config{builddir}, "extra_cflags.txt");
-
 summary::show($OUTPUT, \%config::config);
 
-if ($shared_libs_used) {
-       print <<EOF;
-To run binaries without installing, set the following environment variable:
-       $config::config{LIB_PATH_VAR}=$config::config{builddir}/bin/shared
-EOF
-}
-
 1;
index 17474db00ecdabade885b1976e445f21e0548a35..f2bff1a029ca8ef5326a200cd2e2e2b449732a21 100644 (file)
@@ -6,32 +6,21 @@
 #  Released under the GNU GPL
 
 package smb_build::makefile;
-use smb_build::env;
 use smb_build::output;
 use File::Basename;
 use strict;
 
-use base 'smb_build::env';
 use Cwd 'abs_path';
 
 sub new($$$)
 {
        my ($myname, $config, $mkfile) = @_;
-       my $self = new smb_build::env($config);
-       
+       my $self = {};
+
        bless($self, $myname);
 
-       $self->{manpages} = [];
-       $self->{sbin_progs} = [];
-       $self->{bin_progs} = [];
-       $self->{static_libs} = [];
-       $self->{python_dsos} = [];
-       $self->{python_pys} = [];
-       $self->{shared_libs} = [];
-       $self->{headers} = [];
-       $self->{plugins} = [];
-       $self->{pc_files} = [];
-       $self->{proto_headers} = [];
+       $self->_set_config($config);
+
        $self->{output} = "";
 
        $self->{mkfile} = $mkfile;
@@ -41,12 +30,30 @@ sub new($$$)
        $self->output("################################################\n");
        $self->output("\n");
 
-       if (!$self->{automatic_deps}) {
-               $self->output("ALL_PREDEP = proto\n");
-               $self->output(".NOTPARALLEL:\n");
+       return $self;
+}
+
+sub _set_config($$)
+{
+       my ($self, $config) = @_;
+
+       $self->{config} = $config;
+
+       if (not defined($self->{config}->{srcdir})) {
+               $self->{config}->{srcdir} = '.';
        }
 
-       return $self;
+       if (not defined($self->{config}->{builddir})) {
+               $self->{config}->{builddir}  = '.';
+       }
+
+       if ($self->{config}->{prefix} eq "NONE") {
+               $self->{config}->{prefix} = $self->{config}->{ac_default_prefix};
+       }
+
+       if ($self->{config}->{exec_prefix} eq "NONE") {
+               $self->{config}->{exec_prefix} = $self->{config}->{prefix};
+       }
 }
 
 sub output($$)
@@ -66,23 +73,17 @@ sub _prepare_mk_files($)
                push (@tmp, $_);
        }
 
-       if ($self->{gnu_make}) {
-               $self->output("
+       $self->output("
 ifneq (\$(MAKECMDGOALS),clean)
 ifneq (\$(MAKECMDGOALS),distclean)
 ifneq (\$(MAKECMDGOALS),realdistclean)
 ");
-       }
-
        $self->output("MK_FILES = " . array2oneperline(\@tmp) . "\n");
-
-       if ($self->{gnu_make}) {
-               $self->output("
+       $self->output("
 endif
 endif
 endif
 ");
-       }
 }
 
 sub array2oneperline($)
@@ -129,10 +130,9 @@ sub SharedModule($$)
        $sane_subsystem =~ s/^lib//;
        
        if ($ctx->{TYPE} eq "PYTHON") {
-               push (@{$self->{python_dsos}}, 
-                       "$ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}");
+               $self->output("PYTHON_DSOS += $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}\n");
        } else {
-               push (@{$self->{plugins}}, "$ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}");
+               $self->output("PLUGINS += $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}\n");
                $self->output("installplugins:: $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}\n");
                $self->output("\t\@echo Installing $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME} as \$(DESTDIR)\$(modulesdir)/$sane_subsystem/$ctx->{LIBRARY_REALNAME}\n");
                $self->output("\t\@mkdir -p \$(DESTDIR)\$(modulesdir)/$sane_subsystem/\n");
@@ -220,36 +220,27 @@ sub SharedLibrary($$)
 {
        my ($self,$ctx) = @_;
 
-       push (@{$self->{shared_libs}}, $ctx->{RESULT_SHARED_LIBRARY}) if (defined($ctx->{SO_VERSION}));
+       $self->output("SHARED_LIBS += $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}\n") if (defined($ctx->{SO_VERSION}));
 
        $self->_prepare_list($ctx, "DEPEND_LIST");
        $self->_prepare_list($ctx, "LINK_FLAGS");
 
-       my $soarg = "";
-       my $lns = "";
-       if ($self->{config}->{SONAMEFLAG} ne "#" and defined($ctx->{LIBRARY_SONAME})) {
-               $soarg = "$self->{config}->{SONAMEFLAG}$ctx->{LIBRARY_SONAME}";
-               if ($ctx->{LIBRARY_REALNAME} ne $ctx->{LIBRARY_SONAME}) {
-                       $lns .= "\n\t\@test \$($ctx->{NAME}_VERSION) = \$($ctx->{NAME}_SOVERSION) || ln -fs $ctx->{LIBRARY_REALNAME} $ctx->{SHAREDDIR}/$ctx->{LIBRARY_SONAME}";
-               }
-       }
-
-       if (defined($ctx->{LIBRARY_SONAME})) {
-               $lns .= "\n\t\@ln -fs $ctx->{LIBRARY_REALNAME} $ctx->{SHAREDDIR}/$ctx->{LIBRARY_DEBUGNAME}";
-       }
-
        $self->output(<< "__EOD__"
-#
 $ctx->{RESULT_SHARED_LIBRARY}: \$($ctx->{NAME}_DEPEND_LIST) \$($ctx->{NAME}_FULL_OBJ_LIST)
        \@echo Linking \$\@
-       \@mkdir -p $ctx->{SHAREDDIR}
+       \@mkdir -p \$(\@D)
        \@\$(SHLD) \$(LDFLAGS) \$(SHLD_FLAGS) \$(INTERN_LDFLAGS) -o \$\@ \$(INSTALL_LINK_FLAGS) \\
                \$($ctx->{NAME}\_FULL_OBJ_LIST) \\
                \$($ctx->{NAME}_LINK_FLAGS) \\
-               $soarg$lns
+               \$(if \$(SONAMEFLAG), \$(SONAMEFLAG)$ctx->{LIBRARY_SONAME})
 __EOD__
 );
-       $self->output("\n");
+       if ($ctx->{LIBRARY_REALNAME} ne $ctx->{LIBRARY_SONAME}) {
+               $self->output("\t\@test \$($ctx->{NAME}_VERSION) = \$($ctx->{NAME}_SOVERSION) || ln -fs $ctx->{LIBRARY_REALNAME} $ctx->{SHAREDDIR}/$ctx->{LIBRARY_SONAME}\n");
+       }
+       $self->output("ifdef $ctx->{NAME}_SOVERSION\n");
+       $self->output("\t\@ln -fs $ctx->{LIBRARY_REALNAME} $ctx->{SHAREDDIR}/$ctx->{LIBRARY_DEBUGNAME}\n");
+       $self->output("endif\n");
 }
 
 sub MergedObj($$)
@@ -263,7 +254,7 @@ sub MergedObj($$)
 #
 $ctx->{RESULT_MERGED_OBJ}: \$($ctx->{NAME}_OBJ_LIST)
        \@echo Partially linking \$@
-       \@mkdir -p bin/mergedobj
+       \@mkdir -p \$(\@D)
        \$(PARTLINK) -o \$@ \$($ctx->{NAME}_OBJ_LIST)
 
 __EOD__
@@ -276,43 +267,23 @@ sub StaticLibrary($$)
 
        return unless (defined($ctx->{OBJ_FILES}));
 
-       push (@{$self->{static_libs}}, $ctx->{RESULT_STATIC_LIBRARY}) if ($ctx->{TYPE} eq "LIBRARY");
+       $self->output("STATIC_LIBS += $ctx->{TARGET_STATIC_LIBRARY}\n") if ($ctx->{TYPE} eq "LIBRARY");
 
        $self->output("$ctx->{NAME}_OUTPUT = $ctx->{OUTPUT}\n");
        $self->_prepare_list($ctx, "FULL_OBJ_LIST");
 
-       $self->output(<< "__EOD__"
-#
-$ctx->{RESULT_STATIC_LIBRARY}: \$($ctx->{NAME}_FULL_OBJ_LIST)
-       \@echo Linking \$@
-       \@rm -f \$@
-       \@mkdir -p $ctx->{STATICDIR}
-       \@\$(STLD) \$(STLD_FLAGS) \$@ \$($ctx->{NAME}_FULL_OBJ_LIST)
-
-__EOD__
-);
-}
-
-sub Header($$)
-{
-       my ($self,$ctx) = @_;
-
-       foreach (@{$ctx->{PUBLIC_HEADERS}}) {
-               push (@{$self->{headers}}, output::add_dir_str($ctx->{BASEDIR}, $_));
-       }
+       $self->output("$ctx->{RESULT_STATIC_LIBRARY}: \$($ctx->{NAME}_FULL_OBJ_LIST)\n");
 }
 
 sub Binary($$)
 {
        my ($self,$ctx) = @_;
 
-       my $extradir = "";
-
        unless (defined($ctx->{INSTALLDIR})) {
        } elsif ($ctx->{INSTALLDIR} eq "SBINDIR") {
-               push (@{$self->{sbin_progs}}, $ctx->{RESULT_BINARY});
+               $self->output("SBIN_PROGS += bin/$ctx->{BINARY}\n");
        } elsif ($ctx->{INSTALLDIR} eq "BINDIR") {
-               push (@{$self->{bin_progs}}, $ctx->{RESULT_BINARY});
+               $self->output("BIN_PROGS += bin/$ctx->{BINARY}\n");
        }
 
        $self->output("binaries:: $ctx->{TARGET_BINARY}\n");
@@ -350,103 +321,34 @@ sub PythonFiles($$)
        foreach (@{$ctx->{PYTHON_FILES}}) {
                my $target = "bin/python/".basename($_);
                my $source = output::add_dir_str($ctx->{BASEDIR}, $_);
-               $self->output("$target: $source\n" .
-                                         "\tmkdir -p \$(builddir)/bin/python\n" .
-                             "\tcp $source \$@\n\n");
-               push (@{$self->{python_pys}}, $target);
+               $self->output("$target: $source\n\n");
+               $self->output("PYTHON_PYS += $target\n");
        }
 }
 
-sub Manpage($$)
-{
-       my ($self,$ctx) = @_;
-
-       my $path = output::add_dir_str($ctx->{BASEDIR}, $ctx->{MANPAGE});
-       push (@{$self->{manpages}}, $path);
-}
-
 sub ProtoHeader($$)
 {
        my ($self,$ctx) = @_;
 
-       my $target = "";
-       my $comment = "Creating ";
-
-       my $priv = undef;
-       my $pub = undef;
+       my $priv = output::add_dir_str($ctx->{BASEDIR}, $ctx->{PRIVATE_PROTO_HEADER});
+       $self->output("PROTO_HEADERS += $priv\n");
 
-       if (defined($ctx->{PRIVATE_PROTO_HEADER})) {
-               $priv = output::add_dir_str($ctx->{BASEDIR}, $ctx->{PRIVATE_PROTO_HEADER});
-               $target .= $priv;
-               $comment .= $priv;
-               if (defined($ctx->{PUBLIC_PROTO_HEADER})) {
-                       $comment .= " and ";
-                       $target.= " ";
-               }
-               push (@{$self->{proto_headers}}, $priv);
-       } else {
-               $ctx->{PRIVATE_PROTO_HEADER} = $ctx->{PUBLIC_PROTO_HEADER};
-               $priv = output::add_dir_str($ctx->{BASEDIR}, $ctx->{PRIVATE_PROTO_HEADER});
-       }
-
-       if (defined($ctx->{PUBLIC_PROTO_HEADER})) {
-               $pub = output::add_dir_str($ctx->{BASEDIR}, $ctx->{PUBLIC_PROTO_HEADER});
-               $comment .= $pub;
-               $target .= $pub;
-               push (@{$self->{proto_headers}}, $pub);
-       } else {
-               $ctx->{PUBLIC_PROTO_HEADER} = $ctx->{PRIVATE_PROTO_HEADER};
-               $pub = output::add_dir_str($ctx->{BASEDIR}, $ctx->{PUBLIC_PROTO_HEADER});
-       }
-
-       $self->output("$pub: $ctx->{MK_FILE} \$($ctx->{NAME}_OBJ_LIST:.o=.c) \$(srcdir)/script/mkproto.pl\n");
-       $self->output("\t\@echo \"$comment\"\n");
-       $self->output("\t\@\$(PERL) \$(srcdir)/script/mkproto.pl --srcdir=\$(srcdir) --builddir=\$(builddir) --private=$priv --public=$pub \$($ctx->{NAME}_OBJ_LIST)\n\n");
+       $self->output("$priv: $ctx->{MK_FILE} \$($ctx->{NAME}_OBJ_LIST:.o=.c) \$(srcdir)/script/mkproto.pl\n");
+       $self->output("\t\@echo \"Creating \$@\"\n");
+       $self->output("\t\@mkdir -p \$(\@D)\n");
+       $self->output("\t\@\$(PERL) \$(srcdir)/script/mkproto.pl --srcdir=\$(srcdir) --builddir=\$(builddir) --all=\$@ \$($ctx->{NAME}_OBJ_LIST)\n\n");
 }
 
 sub write($$)
 {
        my ($self, $file) = @_;
 
-       $self->output("MANPAGES = " . array2oneperline($self->{manpages})."\n");
-       $self->output("BIN_PROGS = " . array2oneperline($self->{bin_progs}) . "\n");
-       $self->output("SBIN_PROGS = " . array2oneperline($self->{sbin_progs}) . "\n");
-       $self->output("STATIC_LIBS = " . array2oneperline($self->{static_libs}) . "\n");
-       $self->output("SHARED_LIBS = " . array2oneperline($self->{shared_libs}) . "\n");
-       $self->output("PYTHON_DSOS = " . array2oneperline($self->{python_dsos}) . "\n");
-       $self->output("PYTHON_PYS = " . array2oneperline($self->{python_pys}) . "\n");
-       $self->output("PUBLIC_HEADERS = " . array2oneperline($self->{headers}) . "\n");
-       $self->output("PC_FILES = " . array2oneperline($self->{pc_files}) . "\n");
        $self->output("ALL_OBJS = " . array2oneperline($self->{all_objs}) . "\n");
-       $self->output("PROTO_HEADERS = " . array2oneperline($self->{proto_headers}) .  "\n");
-       $self->output("PLUGINS = " . array2oneperline($self->{plugins}) . "\n");
 
        $self->_prepare_mk_files();
 
        $self->output($self->{mkfile});
 
-       if ($self->{automatic_deps}) {
-               $self->output("
-ifneq (\$(MAKECMDGOALS),clean)
-ifneq (\$(MAKECMDGOALS),distclean)
-ifneq (\$(MAKECMDGOALS),realdistclean)
-ifneq (\$(SKIP_DEP_FILES),yes)
--include \$(DEP_FILES)
-endif
-endif
-endif
-endif
-
-ifneq (\$(SKIP_DEP_FILES),yes)
-clean::
-       \@echo Removing dependency files
-       \@find . -name '*.d' -o -name '*.hd' | xargs rm -f
-endif
-");
-       } else {
-               $self->output("include \$(srcdir)/static_deps.mk\n");
-       }
-
        open(MAKEFILE,">$file") || die ("Can't open $file\n");
        print MAKEFILE $self->{output};
        close(MAKEFILE);
@@ -454,4 +356,51 @@ endif
        print __FILE__.": creating $file\n";
 }
 
+my $sort_available = eval "use sort 'stable'; return 1;";
+$sort_available = 0 unless defined($sort_available);
+
+sub by_path {
+       return  1 if($a =~ m#^\-I/#);
+       return -1 if($b =~ m#^\-I/#);
+       return  0;
+}
+
+sub CFlags($$)
+{
+       my ($self, $key) = @_;
+
+       my $srcdir = $self->{config}->{srcdir};
+       my $builddir = $self->{config}->{builddir};
+
+       my $src_ne_build = ($srcdir ne $builddir) ? 1 : 0;
+
+       return unless defined ($key->{OBJ_LIST});
+       return unless defined ($key->{FINAL_CFLAGS});
+       return unless (@{$key->{FINAL_CFLAGS}} > 0);
+
+       my @sorted_cflags = @{$key->{FINAL_CFLAGS}};
+       if ($sort_available) {
+               @sorted_cflags = sort by_path @{$key->{FINAL_CFLAGS}};
+       }
+
+       # Rewrite CFLAGS so that both the source and the build
+       # directories are in the path.
+       my @cflags = ();
+       foreach my $flag (@sorted_cflags) {
+               if($src_ne_build) {
+                               if($flag =~ m#^-I([^/].*$)#) {
+                                       my $dir = $1;
+                                       $dir =~ s#^\$\((?:src|build)dir\)/?##;
+                               push(@cflags, "-I$builddir/$dir", "-I$srcdir/$dir");
+                                       next;
+                               }
+               }
+               push(@cflags, $flag);
+       }
+       
+       my $cflags = join(' ', @cflags);
+
+       $self->output("\$(patsubst %.ho,%.d,\$(key->{NAME}_OBJ_LIST:.o=.d)) \$($key->{NAME}_OBJ_LIST): CFLAGS+= $cflags\n");
+}
+
 1;
index ff9afe8e8c9f09d459bd0c7e86160070ab3a1f91..4ae4a62cf4991ff50c5dc9a83331f18abaa5b510 100644 (file)
@@ -101,9 +101,6 @@ sub generate_merged_obj($)
                $lib->{MERGED_OBJNAME} = lc($link_name).".o";
                $lib->{RESULT_MERGED_OBJ} = $lib->{OUTPUT_MERGED_OBJ} = "bin/mergedobj/$lib->{MERGED_OBJNAME}";
                $lib->{TARGET_MERGED_OBJ} = $lib->{RESULT_MERGED_OBJ};
-       } else {
-               $lib->{TARGET_MERGED_OBJ} = "";
-               $lib->{RESULT_MERGED_OBJ} = "";
        }
 }
 
@@ -124,10 +121,6 @@ sub generate_static_library($)
                $lib->{TARGET_STATIC_LIBRARY} = $lib->{RESULT_STATIC_LIBRARY};
                $lib->{STATICDIR} = 'bin/static';
                $lib->{OUTPUT_STATIC_LIBRARY} = "-l".lc($link_name);
-       } else {
-               $lib->{RESULT_STATIC_LIBRARY} = "";
-               $lib->{TARGET_STATIC_LIBRARY} = "";
-               $lib->{OUTPUT_STATIC_LIBRARY} = "";
        }
 }
 
index 7858ee2cf0a13e54e48db48fb00ac0b557c70490..783e31d1ae622267ba55ed65a59f891d8157fb49 100644 (file)
@@ -92,7 +92,7 @@ static NTSTATUS cldapd_add_socket(struct cldapd_server *cldapd, struct loadparm_
        NTSTATUS status;
 
        /* listen for unicasts on the CLDAP port (389) */
-       cldapsock = cldap_socket_init(cldapd, cldapd->task->event_ctx);
+       cldapsock = cldap_socket_init(cldapd, cldapd->task->event_ctx, lp_iconv_convenience(cldapd->task->lp_ctx));
        NT_STATUS_HAVE_NO_MEMORY(cldapsock);
 
        socket_address = socket_address_from_strings(cldapsock, cldapsock->sock->backend_name, 
index 3dfc6819b7c09bbdcd02da250cc6305e43a6fed7..e84f2364d40f183791f8b3052688bee7a82a8481 100644 (file)
@@ -409,10 +409,12 @@ static NTSTATUS odb_ctdb_open_file_pending(struct odb_lock *lck, void *private)
 /*
   remove a opendb entry
 */
-static NTSTATUS odb_ctdb_close_file(struct odb_lock *lck, void *file_handle)
+static NTSTATUS odb_ctdb_close_file(struct odb_lock *lck, void *file_handle,
+                                   const char **_delete_path)
 {
        struct odb_context *odb = lck->odb;
        struct opendb_file file;
+       const char *delete_path = NULL;
        int i;
        NTSTATUS status;
 
@@ -448,6 +450,15 @@ static NTSTATUS odb_ctdb_close_file(struct odb_lock *lck, void *file_handle)
        file.num_pending = 0;
 
        file.num_entries--;
+
+       if (file.num_entries == 0 && file.delete_on_close) {
+               delete_path = talloc_strdup(lck, file.path);
+               NT_STATUS_HAVE_NO_MEMORY(delete_path);
+       }
+
+       if (_delete_path) {
+               *_delete_path = delete_path;
+       }
        
        return odb_push_record(lck, &file);
 }
@@ -531,6 +542,25 @@ static NTSTATUS odb_ctdb_rename(struct odb_lock *lck, const char *path)
        return odb_push_record(lck, &file);
 }
 
+/*
+  get the path of an open file
+*/
+static NTSTATUS odb_ctdb_get_path(struct odb_lock *lck, const char **path)
+{
+       struct opendb_file file;
+       NTSTATUS status;
+
+       *path = NULL;
+
+       status = odb_pull_record(lck, &file);
+       /* we don't ignore NT_STATUS_OBJECT_NAME_NOT_FOUND here */
+       NT_STATUS_NOT_OK_RETURN(status);
+
+       *path = file.path;
+
+       return NT_STATUS_OK;
+}
+
 /*
   update delete on close flag on an open file
 */
@@ -552,20 +582,20 @@ static NTSTATUS odb_ctdb_set_delete_on_close(struct odb_lock *lck, bool del_on_c
   people still have the file open
 */
 static NTSTATUS odb_ctdb_get_delete_on_close(struct odb_context *odb, 
-                                           DATA_BLOB *key, bool *del_on_close, 
-                                           int *open_count, char **path)
+                                           DATA_BLOB *key, bool *del_on_close)
 {
        NTSTATUS status;
        struct opendb_file file;
        struct odb_lock *lck;
 
+       (*del_on_close) = false;
+
        lck = odb_lock(odb, odb, key);
        NT_STATUS_HAVE_NO_MEMORY(lck);
 
        status = odb_pull_record(lck, &file);
        if (NT_STATUS_EQUAL(NT_STATUS_OBJECT_NAME_NOT_FOUND, status)) {
                talloc_free(lck);
-               (*del_on_close) = false;
                return NT_STATUS_OK;
        }
        if (!NT_STATUS_IS_OK(status)) {
@@ -574,16 +604,6 @@ static NTSTATUS odb_ctdb_get_delete_on_close(struct odb_context *odb,
        }
 
        (*del_on_close) = file.delete_on_close;
-       if (open_count != NULL) {
-               (*open_count) = file.num_entries;
-       }
-       if (path != NULL) {
-               *path = talloc_strdup(odb, file.path);
-               NT_STATUS_HAVE_NO_MEMORY(*path);
-               if (file.num_entries == 1 && file.entries[0].delete_on_close) {
-                       (*del_on_close) = true;
-               }
-       }
 
        talloc_free(lck);
 
@@ -652,6 +672,7 @@ static const struct opendb_ops opendb_ctdb_ops = {
        .odb_close_file          = odb_ctdb_close_file,
        .odb_remove_pending      = odb_ctdb_remove_pending,
        .odb_rename              = odb_ctdb_rename,
+       .odb_get_path            = odb_ctdb_get_path,
        .odb_set_delete_on_close = odb_ctdb_set_delete_on_close,
        .odb_get_delete_on_close = odb_ctdb_get_delete_on_close,
        .odb_can_open            = odb_ctdb_can_open,
index b609b4f52c89b193ed400899ca27fc73cbc9b430..5ba441375c5d6f4d61cb69d8f170c72f55691661 100644 (file)
@@ -78,6 +78,8 @@ SMB_EXT_LIB_FROM_PKGCONFIG(LIBLDB, ldb >= 0.9.1,
                        AC_DEFINE_UNQUOTED(LDB_MODULESDIR, "${LDB_MODULESDIR}" , [ldb Modules directory])
                fi
                ])
+               ldbdir=lib/ldb
+               AC_SUBST(ldbdir)
                m4_include(lib/ldb/sqlite3.m4)
                m4_include(lib/ldb/libldb.m4)
                SMB_INCLUDE_MK(lib/ldb/config.mk)
@@ -226,3 +228,12 @@ AC_FOREACH([AC_Var], m4_defn([_AC_SUBST_VARS]), [
 AC_Var = $AC_Var])
 $MAKE_SETTINGS
 CEOF
+
+if test $USESHARED = true
+then
+       echo "To run binaries without installing, set the following environment variable:"
+       echo "$ac_cv_LIB_PATH_VAR=$builddir/bin/shared"
+fi
+
+echo
+echo "To build Samba, run $ac_cv_path_MAKE"
index bee1eac480b3993d25aa652d2bb1e3894d6882e8..ace5e0edaf820286379491102d0a7b5c0058e59e 100644 (file)
@@ -469,8 +469,8 @@ NTTIME samdb_result_allow_password_change(struct ldb_context *sam_ldb,
 }
 
 /*
-  construct the force_password_change field from the PwdLastSet attribute and the 
-  domain password settings
+  construct the force_password_change field from the PwdLastSet
+  attribute, the userAccountControl and the domain password settings
 */
 NTTIME samdb_result_force_password_change(struct ldb_context *sam_ldb, 
                                          TALLOC_CTX *mem_ctx, 
@@ -478,10 +478,12 @@ NTTIME samdb_result_force_password_change(struct ldb_context *sam_ldb,
                                          struct ldb_message *msg)
 {
        uint64_t attr_time = samdb_result_uint64(msg, "pwdLastSet", 0);
-       uint32_t user_flags = samdb_result_uint64(msg, "userAccountControl", 0);
+       uint32_t userAccountControl = samdb_result_uint64(msg, "userAccountControl", 0);
        int64_t maxPwdAge;
 
-       if (user_flags & UF_DONT_EXPIRE_PASSWD) {
+       /* Machine accounts don't expire, and there is a flag for 'no expiry' */
+       if (!(userAccountControl & UF_NORMAL_ACCOUNT)
+           || (userAccountControl & UF_DONT_EXPIRE_PASSWD)) {
                return 0x7FFFFFFFFFFFFFFFULL;
        }
 
@@ -596,11 +598,30 @@ struct samr_LogonHours samdb_result_logon_hours(TALLOC_CTX *mem_ctx, struct ldb_
 
 /*
   pull a set of account_flags from a result set. 
+
+  This requires that the attributes: 
+   pwdLastSet
+   userAccountControl
+  be included in 'msg'
 */
-uint16_t samdb_result_acct_flags(struct ldb_message *msg, const char *attr)
+uint32_t samdb_result_acct_flags(struct ldb_context *sam_ctx, TALLOC_CTX *mem_ctx, 
+                                struct ldb_message *msg, struct ldb_dn *domain_dn)
 {
-       uint_t userAccountControl = ldb_msg_find_attr_as_uint(msg, attr, 0);
-       return samdb_uf2acb(userAccountControl);
+       uint32_t userAccountControl = ldb_msg_find_attr_as_uint(msg, "userAccountControl", 0);
+       uint32_t acct_flags = samdb_uf2acb(userAccountControl); 
+       NTTIME must_change_time;
+       NTTIME now;
+       
+       must_change_time = samdb_result_force_password_change(sam_ctx, mem_ctx, 
+                                                             domain_dn, msg);
+       
+       /* Test account expire time */
+       unix_to_nt_time(&now, time(NULL));
+       /* check for expired password */
+       if (must_change_time < now) {
+               acct_flags |= ACB_PW_EXPIRED;
+       }
+       return acct_flags;
 }
 
 
index 17752fbbbd30df295e952baa3b1ee02ff74c25a1..fb8cd4f5031a6d263831b8bf88759aa9fe58e086 100644 (file)
@@ -5,8 +5,7 @@ mkinclude samdb/ldb_modules/config.mk
 ################################################
 # Start SUBSYSTEM SAMDB
 [SUBSYSTEM::SAMDB]
-PUBLIC_PROTO_HEADER = samdb/samdb_proto.h
-PUBLIC_HEADERS = samdb/samdb.h
+PRIVATE_PROTO_HEADER = samdb/samdb_proto.h
 PUBLIC_DEPENDENCIES = HEIMDAL_KRB5 
 PRIVATE_DEPENDENCIES = LIBNDR NDR_MISC NDR_DRSUAPI NDR_DRSBLOBS NSS_WRAPPER \
                                           auth_system_session LDAP_ENCODE LIBCLI_AUTH LIBNDR \
@@ -17,8 +16,11 @@ OBJ_FILES = \
                samdb/cracknames.o \
                repl/replicated_objects.o
 
+
+PUBLIC_HEADERS += dsdb/samdb/samdb.h
+
 [SUBSYSTEM::SAMDB_COMMON]
-PUBLIC_PROTO_HEADER = common/proto.h
+PRIVATE_PROTO_HEADER = common/proto.h
 PRIVATE_DEPENDENCIES = LIBLDB
 OBJ_FILES = \
                common/sidmap.o \
@@ -26,14 +28,16 @@ OBJ_FILES = \
                common/util.o
 
 [SUBSYSTEM::SAMDB_SCHEMA]
-PUBLIC_PROTO_HEADER = schema/proto.h
-PUBLIC_HEADERS = schema/schema.h
+PRIVATE_PROTO_HEADER = schema/proto.h
 PRIVATE_DEPENDENCIES = SAMDB_COMMON NDR_DRSUAPI NDR_DRSBLOBS
 OBJ_FILES = \
                schema/schema_init.o \
                schema/schema_syntax.o \
                schema/schema_constructed.o \
 
+
+PUBLIC_HEADERS += dsdb/schema/schema.h
+
 #######################
 # Start SUBSYSTEM DREPL_SRV
 [MODULE::DREPL_SRV]
index 178149a8865d335db6252c9f2344519e73590ca8..905cd4a995d5916a8d81e2eea32b487886e3f3a1 100644 (file)
@@ -396,6 +396,7 @@ static int samldb_fill_group_object(struct ldb_module *module, const struct ldb_
                                                    struct ldb_message **ret_msg)
 {
        int ret;
+       unsigned int group_type;
        char *name;
        struct ldb_message *msg2;
        struct ldb_dn *dom_dn;
@@ -452,6 +453,26 @@ static int samldb_fill_group_object(struct ldb_module *module, const struct ldb_
                }
        }
        
+       if (ldb_msg_find_element(msg2, "sAMAccountType") != NULL) {
+               ldb_asprintf_errstring(module->ldb, "sAMAccountType must not be specified");
+               talloc_free(mem_ctx);
+               return LDB_ERR_UNWILLING_TO_PERFORM;
+       }
+       group_type = samdb_result_uint(msg2, "groupType", 0);
+       if (group_type == 0) {
+               ldb_asprintf_errstring(module->ldb, "groupType invalid");
+               talloc_free(mem_ctx);
+               return LDB_ERR_UNWILLING_TO_PERFORM;
+       } else {
+               unsigned int account_type = samdb_gtype2atype(group_type);
+               ret = samdb_msg_add_uint(module->ldb, msg2, msg2,
+                                        "sAMAccountType",
+                                        account_type);
+               if (ret != LDB_SUCCESS) {
+                       return ret;
+               }
+       }
+
        /* Manage SID allocation, conflicts etc */
        ret = samldb_handle_sid(module, mem_ctx, msg2, dom_dn); 
 
@@ -473,6 +494,7 @@ static int samldb_fill_user_or_computer_object(struct ldb_module *module, const
        const char *rdn_name;
        TALLOC_CTX *mem_ctx = talloc_new(msg);
        const char *errstr;
+       unsigned int user_account_control;
        if (!mem_ctx) {
                return LDB_ERR_OPERATIONS_ERROR;
        }
@@ -485,36 +507,15 @@ static int samldb_fill_user_or_computer_object(struct ldb_module *module, const
                return LDB_ERR_OPERATIONS_ERROR;
        }
 
-       if (samdb_find_attribute(module->ldb, msg, "objectclass", "computer") != NULL) {
-
-               ret = samdb_copy_template(module->ldb, msg2, 
-                                         "computer",
-                                         &errstr);
-               if (ret) {
-                       ldb_asprintf_errstring(module->ldb, 
-                                              "samldb_fill_user_or_computer_object: "
-                                              "Error copying computer template: %s",
-                                              errstr);
-                       talloc_free(mem_ctx);
-                       return ret;
-               }
-       } else {
-               ret = samdb_copy_template(module->ldb, msg2, 
-                                         "user",
-                                         &errstr);
-               if (ret) {
-                       ldb_asprintf_errstring(module->ldb, 
-                                              "samldb_fill_user_or_computer_object: Error copying user template: %s\n",
-                                              errstr);
-                       talloc_free(mem_ctx);
-                       return ret;
-               }
-               /* readd user objectclass */
-               ret = samdb_find_or_add_value(module->ldb, msg2, "objectclass", "user");
-               if (ret) {
-                       talloc_free(mem_ctx);
-                       return ret;
-               }
+       ret = samdb_copy_template(module->ldb, msg2, 
+                                 "user",
+                                 &errstr);
+       if (ret) {
+               ldb_asprintf_errstring(module->ldb, 
+                                      "samldb_fill_user_or_computer_object: Error copying user template: %s\n",
+                                      errstr);
+               talloc_free(mem_ctx);
+               return ret;
        }
 
        rdn_name = ldb_dn_get_rdn_name(msg2->dn);
@@ -545,14 +546,30 @@ static int samldb_fill_user_or_computer_object(struct ldb_module *module, const
                }
        }
 
-       /*
-         TODO: useraccountcontrol: setting value 0 gives 0x200 for users
-       */
+       if (ldb_msg_find_element(msg2, "sAMAccountType") != NULL) {
+               ldb_asprintf_errstring(module->ldb, "sAMAccountType must not be specified");
+               talloc_free(mem_ctx);
+               return LDB_ERR_UNWILLING_TO_PERFORM;
+       }
+       user_account_control = samdb_result_uint(msg2, "userAccountControl", 0);
+       if (user_account_control == 0) {
+               ldb_asprintf_errstring(module->ldb, "userAccountControl invalid");
+               talloc_free(mem_ctx);
+               return LDB_ERR_UNWILLING_TO_PERFORM;
+       } else {
+               unsigned int account_type = samdb_uf2atype(user_account_control);
+               ret = samdb_msg_add_uint(module->ldb, msg2, msg2,
+                                        "sAMAccountType",
+                                        account_type);
+               if (ret != LDB_SUCCESS) {
+                       return ret;
+               }
+       }
 
        /* Manage SID allocation, conflicts etc */
        ret = samldb_handle_sid(module, mem_ctx, msg2, dom_dn); 
 
-       /* TODO: objectCategory, userAccountControl, badPwdCount, codePage, countryCode, badPasswordTime, lastLogoff, lastLogon, pwdLastSet, primaryGroupID, accountExpires, logonCount */
+       /* TODO: userAccountControl, badPwdCount, codePage, countryCode, badPasswordTime, lastLogoff, lastLogon, pwdLastSet, primaryGroupID, accountExpires, logonCount */
 
        if (ret == 0) {
                *ret_msg = msg2;
@@ -689,7 +706,7 @@ static int samldb_add(struct ldb_module *module, struct ldb_request *req)
        }
 
        /* is user or computer? */
-       if ((samdb_find_attribute(module->ldb, msg, "objectclass", "user") != NULL) ||
+       if ((samdb_find_attribute(module->ldb, msg, "objectclass", "user") != NULL) || 
            (samdb_find_attribute(module->ldb, msg, "objectclass", "computer") != NULL)) {
                /*  add all relevant missing objects */
                ret = samldb_fill_user_or_computer_object(module, msg, &msg2);
@@ -745,6 +762,53 @@ static int samldb_add(struct ldb_module *module, struct ldb_request *req)
        return ret;
 }
 
+/* modify */
+static int samldb_modify(struct ldb_module *module, struct ldb_request *req)
+{
+       struct ldb_message *msg;
+       struct ldb_message_element *el, *el2;
+       int ret;
+       unsigned int group_type, user_account_control, account_type;
+       if (ldb_msg_find_element(req->op.mod.message, "sAMAccountType") != NULL) {
+               ldb_asprintf_errstring(module->ldb, "sAMAccountType must not be specified");
+               return LDB_ERR_UNWILLING_TO_PERFORM;
+       }
+
+       el = ldb_msg_find_element(req->op.mod.message, "groupType");
+       if (el && el->flags & (LDB_FLAG_MOD_ADD|LDB_FLAG_MOD_REPLACE) && el->num_values == 1) {
+               req->op.mod.message = msg = ldb_msg_copy_shallow(req, req->op.mod.message);
+
+               group_type = strtoul((const char *)el->values[0].data, NULL, 0);
+               account_type =  samdb_gtype2atype(group_type);
+               ret = samdb_msg_add_uint(module->ldb, msg, msg,
+                                        "sAMAccountType",
+                                        account_type);
+               if (ret != LDB_SUCCESS) {
+                       return ret;
+               }
+               el2 = ldb_msg_find_element(msg, "sAMAccountType");
+               el2->flags = LDB_FLAG_MOD_REPLACE;
+       }
+
+       el = ldb_msg_find_element(req->op.mod.message, "userAccountControl");
+       if (el && el->flags & (LDB_FLAG_MOD_ADD|LDB_FLAG_MOD_REPLACE) && el->num_values == 1) {
+               req->op.mod.message = msg = ldb_msg_copy_shallow(req, req->op.mod.message);
+
+               user_account_control = strtoul((const char *)el->values[0].data, NULL, 0);
+               account_type = samdb_uf2atype(user_account_control);
+               ret = samdb_msg_add_uint(module->ldb, msg, msg,
+                                        "sAMAccountType",
+                                        account_type);
+               if (ret != LDB_SUCCESS) {
+                       return ret;
+               }
+               el2 = ldb_msg_find_element(msg, "sAMAccountType");
+               el2->flags = LDB_FLAG_MOD_REPLACE;
+       }
+       return ldb_next_request(module, req);
+}
+
+
 static int samldb_init(struct ldb_module *module)
 {
        return ldb_next_init(module);
@@ -754,4 +818,5 @@ _PUBLIC_ const struct ldb_module_ops ldb_samldb_module_ops = {
        .name          = "samldb",
        .init_context  = samldb_init,
        .add           = samldb_add,
+       .modify        = samldb_modify
 };
index e970d4cd4c01032eaadb21376760da0558940f6b..aa0565cd7a21e7a45ae501f8ae491201c16b6a11 100644 (file)
@@ -21,5 +21,5 @@ PATH_FLAGS = -DCONFIGFILE=\"$(CONFIGFILE)\" \
 
 dynconfig.o: dynconfig.c Makefile
        @echo Compiling $<
-       @$(CC) $(CFLAGS) `$(PERL) $(srcdir)/script/cflags.pl $@` $(CPPFLAGS) $(PICFLAG) \
-               $(PATH_FLAGS) -c $(FIRST_PREREQ) -o $@
+       @$(CC) $(CFLAGS) $(CPPFLAGS) $(PICFLAG) \
+               $(PATH_FLAGS) -c $< -o $@
index ff226e5b46c0d05463ae79c7a858ed0a97be5e38..9a17e581e3f650f1646b5ac05e33e1eea9cdf0b8 100644 (file)
@@ -1168,8 +1168,8 @@ NTSTATUS kdc_hdb_ldb_create(TALLOC_CTX *mem_ctx,
 krb5_error_code hdb_ldb_create(krb5_context context, struct HDB **db, const char *arg)
 {
        NTSTATUS nt_status;
-       /* The global kdc_mem_ctx, Disgusting, ugly hack, but it means one less private hook */
-       nt_status = kdc_hdb_ldb_create(kdc_mem_ctx, global_loadparm
+       /* The global kdc_mem_ctx and kdc_lp_ctx, Disgusting, ugly hack, but it means one less private hook */
+       nt_status = kdc_hdb_ldb_create(kdc_mem_ctx, kdc_lp_ctx
                                       context, db, arg);
 
        if (NT_STATUS_IS_OK(nt_status)) {
index 52ee4758625ae975adae437d26892c27e44a006b..92a5dc26e0adb460e1cf49de6ca569c05e7c0369 100644 (file)
 #include "param/param.h"
 
 
-/* Disgusting hack to get a mem_ctx into the hdb plugin, when used as a keytab */
+/* Disgusting hack to get a mem_ctx and lp_ctx into the hdb plugin, when 
+ * used as a keytab */
 TALLOC_CTX *kdc_mem_ctx;
+struct loadparm_context *kdc_lp_ctx;
 
 /* hold all the info needed to send a reply */
 struct kdc_reply {
@@ -648,6 +650,7 @@ static void kdc_task_init(struct task_server *task)
        krb5_kdc_windc_init(kdc->smb_krb5_context->krb5_context);
 
        kdc_mem_ctx = kdc->smb_krb5_context;
+       kdc_lp_ctx = task->lp_ctx;
 
        /* start listening on the configured network interfaces */
        status = kdc_startup_interfaces(kdc, task->lp_ctx, ifaces);
index 3a1f9bd34efab3632df3f2694eb482e41d73501a..9be15115d13cd88f991cb33c93ffc197150f0e9e 100644 (file)
@@ -30,6 +30,7 @@ struct kdc_server;
 struct socket_address;
 
 extern TALLOC_CTX *kdc_mem_ctx;
+extern struct loadparm_context *kdc_lp_ctx;
 
 bool kpasswdd_process(struct kdc_server *kdc,
                      TALLOC_CTX *mem_ctx, 
index 949d64fcf11f0ed3751e7d01d3c19fecff0e9138..52b23608aa7e403846355e4be88c67c2b747f35b 100644 (file)
@@ -30,6 +30,7 @@
  */
 
 #include       "miniMpr.h"
+#include "param/param.h"
 
 /************************************ Code ************************************/
 #if !BLD_APPWEB
@@ -49,6 +50,12 @@ void *mprMemCtx(void)
        return mpr_ctx;
 }
 
+/* return the loadparm context being used for all ejs variables */
+struct loadparm_context *mprLpCtx(void)
+{
+       return global_loadparm;
+}
+
 void mprFree(void *ptr)
 {
        talloc_free(ptr);
index 836fdab9f216ad81879bd7fb534e4a109c4b1cb8..15ce30c8df9d52eef3d723ee41d888fe197465dc 100644 (file)
@@ -272,6 +272,8 @@ extern int          mprMemcpy(char *dest, int destMax, const char *src, int nbytes);
 
 extern void mprSetCtx(void *ctx);
 extern void *mprMemCtx(void);
+struct loadparm_context;
+extern struct loadparm_context *mprLpCtx(void);
 
 /* This function needs to be provided by anyone using ejs */
 void ejs_exception(const char *reason);
index a118636c5205b7d8eb04d185dab3757ba2261ae8..d059bdf49b53e658c92ae070081c9cf64a58fbfd 100644 (file)
@@ -22,17 +22,23 @@ mkinclude crypto/config.mk
 OBJ_FILES = compression/mszip.o
 
 [SUBSYSTEM::GENCACHE]
-PUBLIC_HEADERS = gencache/gencache.h
 OBJ_FILES = gencache/gencache.o
 PRIVATE_DEPENDENCIES = TDB_WRAP
 
+
+PUBLIC_HEADERS += lib/gencache/gencache.h
+
 [SUBSYSTEM::LDB_WRAP]
-PUBLIC_HEADERS = ldb_wrap.h
 OBJ_FILES = ldb_wrap.o
 PUBLIC_DEPENDENCIES = LIBLDB
 PRIVATE_DEPENDENCIES = LDBSAMBA UTIL_LDB
 
+
+PUBLIC_HEADERS += lib/ldb_wrap.h
+
 [SUBSYSTEM::TDB_WRAP]
-PUBLIC_HEADERS = tdb_wrap.h
 OBJ_FILES = tdb_wrap.o
 PUBLIC_DEPENDENCIES = LIBTDB
+
+
+PUBLIC_HEADERS += lib/tdb_wrap.h
index 4f0c80c79d1b3f98bac1333538f4514fb1b1f3fe..2766784c52ea381f4ba294662bb71e0bf2ed212c 100644 (file)
@@ -5,9 +5,11 @@ OBJ_FILES = \
                iconv.o \
                charcnv.o \
                util_unistr.o
-PUBLIC_HEADERS = charset.h
-PUBLIC_PROTO_HEADER = charset_proto.h
+PRIVATE_PROTO_HEADER = charset_proto.h
 PUBLIC_DEPENDENCIES = ICONV
 PRIVATE_DEPENDENCIES = DYNCONFIG
 # End SUBSYSTEM CHARSET
 ################################################
+
+
+PUBLIC_HEADERS += lib/charset/charset.h
index e0e1aed222d3c8787d151f64c7ea4ba317ba061e..9b87f498006d2c4ef442e3f144c7c54e3c878517 100644 (file)
@@ -123,6 +123,7 @@ _PUBLIC_ int strcasecmp_m(const char *s1, const char *s2)
 {
        codepoint_t c1=0, c2=0;
        size_t size1, size2;
+       struct smb_iconv_convenience *iconv_convenience = lp_iconv_convenience(global_loadparm);
 
        /* handle null ptr comparisons to simplify the use in qsort */
        if (s1 == s2) return 0;
@@ -130,8 +131,8 @@ _PUBLIC_ int strcasecmp_m(const char *s1, const char *s2)
        if (s2 == NULL) return 1;
 
        while (*s1 && *s2) {
-               c1 = next_codepoint(lp_iconv_convenience(global_loadparm), s1, &size1);
-               c2 = next_codepoint(lp_iconv_convenience(global_loadparm), s2, &size2);
+               c1 = next_codepoint(iconv_convenience, s1, &size1);
+               c2 = next_codepoint(iconv_convenience, s2, &size2);
 
                s1 += size1;
                s2 += size2;
@@ -207,6 +208,7 @@ _PUBLIC_ int strncasecmp_m(const char *s1, const char *s2, size_t n)
 {
        codepoint_t c1=0, c2=0;
        size_t size1, size2;
+       struct smb_iconv_convenience *iconv_convenience = lp_iconv_convenience(global_loadparm);
 
        /* handle null ptr comparisons to simplify the use in qsort */
        if (s1 == s2) return 0;
@@ -216,8 +218,8 @@ _PUBLIC_ int strncasecmp_m(const char *s1, const char *s2, size_t n)
        while (*s1 && *s2 && n) {
                n--;
 
-               c1 = next_codepoint(lp_iconv_convenience(global_loadparm), s1, &size1);
-               c2 = next_codepoint(lp_iconv_convenience(global_loadparm), s2, &size2);
+               c1 = next_codepoint(iconv_convenience, s1, &size1);
+               c2 = next_codepoint(iconv_convenience, s2, &size2);
 
                s1 += size1;
                s2 += size2;
@@ -480,6 +482,7 @@ _PUBLIC_ char *strlower_talloc(TALLOC_CTX *ctx, const char *src)
 {
        size_t size=0;
        char *dest;
+       struct smb_iconv_convenience *iconv_convenience = lp_iconv_convenience(global_loadparm);
 
        /* this takes advantage of the fact that upper/lower can't
           change the length of a character by more than 1 byte */
@@ -490,12 +493,12 @@ _PUBLIC_ char *strlower_talloc(TALLOC_CTX *ctx, const char *src)
 
        while (*src) {
                size_t c_size;
-               codepoint_t c = next_codepoint(lp_iconv_convenience(global_loadparm), src, &c_size);
+               codepoint_t c = next_codepoint(iconv_convenience, src, &c_size);
                src += c_size;
 
                c = tolower_w(c);
 
-               c_size = push_codepoint(lp_iconv_convenience(global_loadparm), dest+size, c);
+               c_size = push_codepoint(iconv_convenience, dest+size, c);
                if (c_size == -1) {
                        talloc_free(dest);
                        return NULL;
@@ -520,6 +523,7 @@ _PUBLIC_ char *strupper_talloc(TALLOC_CTX *ctx, const char *src)
 {
        size_t size=0;
        char *dest;
+       struct smb_iconv_convenience *iconv_convenience = lp_iconv_convenience(global_loadparm);
        
        if (!src) {
                return NULL;
@@ -534,12 +538,12 @@ _PUBLIC_ char *strupper_talloc(TALLOC_CTX *ctx, const char *src)
 
        while (*src) {
                size_t c_size;
-               codepoint_t c = next_codepoint(lp_iconv_convenience(global_loadparm), src, &c_size);
+               codepoint_t c = next_codepoint(iconv_convenience, src, &c_size);
                src += c_size;
 
                c = toupper_w(c);
 
-               c_size = push_codepoint(lp_iconv_convenience(global_loadparm), dest+size, c);
+               c_size = push_codepoint(iconv_convenience, dest+size, c);
                if (c_size == -1) {
                        talloc_free(dest);
                        return NULL;
@@ -563,6 +567,7 @@ _PUBLIC_ char *strupper_talloc(TALLOC_CTX *ctx, const char *src)
 _PUBLIC_ void strlower_m(char *s)
 {
        char *d;
+       struct smb_iconv_convenience *iconv_convenience;
 
        /* this is quite a common operation, so we want it to be
           fast. We optimise for the ascii case, knowing that all our
@@ -576,12 +581,14 @@ _PUBLIC_ void strlower_m(char *s)
        if (!*s)
                return;
 
+       iconv_convenience = lp_iconv_convenience(global_loadparm);
+
        d = s;
 
        while (*s) {
                size_t c_size, c_size2;
-               codepoint_t c = next_codepoint(lp_iconv_convenience(global_loadparm), s, &c_size);
-               c_size2 = push_codepoint(lp_iconv_convenience(global_loadparm), d, tolower_w(c));
+               codepoint_t c = next_codepoint(iconv_convenience, s, &c_size);
+               c_size2 = push_codepoint(iconv_convenience, d, tolower_w(c));
                if (c_size2 > c_size) {
                        DEBUG(0,("FATAL: codepoint 0x%x (0x%x) expanded from %d to %d bytes in strlower_m\n",
                                 c, tolower_w(c), (int)c_size, (int)c_size2));
@@ -599,6 +606,7 @@ _PUBLIC_ void strlower_m(char *s)
 _PUBLIC_ void strupper_m(char *s)
 {
        char *d;
+       struct smb_iconv_convenience *iconv_convenience;
 
        /* this is quite a common operation, so we want it to be
           fast. We optimise for the ascii case, knowing that all our
@@ -612,12 +620,14 @@ _PUBLIC_ void strupper_m(char *s)
        if (!*s)
                return;
 
+       iconv_convenience = lp_iconv_convenience(global_loadparm);
+
        d = s;
 
        while (*s) {
                size_t c_size, c_size2;
-               codepoint_t c = next_codepoint(lp_iconv_convenience(global_loadparm), s, &c_size);
-               c_size2 = push_codepoint(lp_iconv_convenience(global_loadparm), d, toupper_w(c));
+               codepoint_t c = next_codepoint(iconv_convenience, s, &c_size);
+               c_size2 = push_codepoint(iconv_convenience, d, toupper_w(c));
                if (c_size2 > c_size) {
                        DEBUG(0,("FATAL: codepoint 0x%x (0x%x) expanded from %d to %d bytes in strupper_m\n",
                                 c, toupper_w(c), (int)c_size, (int)c_size2));
index a1f876d56a8a8b3bed07dca80d4c95de5a066a7a..87014d4d5389503a3d005318e4d68651e089f027 100644 (file)
@@ -4,10 +4,11 @@ OBJ_FILES = credentials.o
 PUBLIC_DEPENDENCIES = CREDENTIALS LIBPOPT
 
 [SUBSYSTEM::POPT_SAMBA]
-PUBLIC_HEADERS = popt_common.h 
 OBJ_FILES = popt_common.o
 PUBLIC_DEPENDENCIES = LIBPOPT
 
+PUBLIC_HEADERS += lib/cmdline/popt_common.h 
+
 [SUBSYSTEM::POPT_CREDENTIALS]
 PRIVATE_PROTO_HEADER = popt_credentials.h
 OBJ_FILES = popt_credentials.o
index 910cf3738f6cf3738de98f701d6e5dfde754e777..225a23c634ac23177c08fe8144dfccfffe4b065e 100644 (file)
@@ -32,11 +32,12 @@ INIT_FUNCTION = s4_events_standard_init
 # Start SUBSYSTEM LIBEVENTS
 [SUBSYSTEM::LIBEVENTS]
 OBJ_FILES = events.o events_timed.o events_signal.o
-PUBLIC_HEADERS = events.h events_internal.h
 PUBLIC_DEPENDENCIES = LIBTALLOC LIBSAMBA-UTIL
 # End SUBSYSTEM LIBEVENTS
 ##############################
 
+PUBLIC_HEADERS += $(addprefix lib/events/, events.h events_internal.h)
+
 [PYTHON::swig_events]
 SWIG_FILE = events.i
 PRIVATE_DEPENDENCIES = LIBEVENTS
index d6980f341a6fde3db3de5d2ae89ede36207ee66a..81fd1e9b9566dcebf3d4ea4a1f45e8df94ec4e10 100644 (file)
@@ -147,12 +147,14 @@ PUBLIC_DEPENDENCIES = \
                LIBTALLOC
 PRIVATE_DEPENDENCIES = \
                SOCKET_WRAPPER
-MANPAGE = man/ldb.3
-PUBLIC_HEADERS = include/ldb.h include/ldb_errors.h
 #
 # End SUBSYSTEM ldb
 ################################################
 
+PUBLIC_HEADERS += $(ldbdir)/include/ldb.h $(ldbdir)/include/ldb_errors.h
+
+MANPAGES += $(ldbdir)/man/ldb.3
+
 ################################################
 # Start BINARY ldbtest
 [BINARY::ldbtest]
@@ -167,7 +169,6 @@ PRIVATE_DEPENDENCIES = \
 # Start BINARY oLschema2ldif
 [BINARY::oLschema2ldif]
 INSTALLDIR = BINDIR
-MANPAGE = man/oLschema2ldif.1
 OBJ_FILES= \
                tools/convert.o \
                tools/oLschema2ldif.o
@@ -176,11 +177,12 @@ PRIVATE_DEPENDENCIES = \
 # End BINARY oLschema2ldif
 ################################################
 
+MANPAGES += $(ldbdir)/man/oLschema2ldif.1
+
 ################################################
 # Start BINARY  ad2oLschema
 [BINARY::ad2oLschema]
 INSTALLDIR = BINDIR
-MANPAGE = man/ad2oLschema.1
 OBJ_FILES= \
                tools/convert.o \
                tools/ad2oLschema.o
@@ -189,6 +191,7 @@ PRIVATE_DEPENDENCIES = \
 # End BINARY ad2oLschema
 ################################################
 
+MANPAGES += $(ldbdir)/man/ad2oLschema.1
 
 mkinclude tools/config.mk
 mkinclude ldb_ildap/config.mk
index 2e54920c17eaa7f25ea1906bc26af47cf1a21e7a..2e13a774b987f01ec1fbf603327694668048bb53 100644 (file)
@@ -290,7 +290,7 @@ char *ldb_filter_from_tree(TALLOC_CTX *mem_ctx, struct ldb_parse_tree *tree);
    2254 (Section 4). This function also escapes any non-printable
    characters.
 
-   \param ctx the memory context to allocate the return string in.
+   \param mem_ctx the memory context to allocate the return string in.
    \param val the (potentially) binary data to be encoded
 
    \return the encoded data as a null terminated string
@@ -886,7 +886,7 @@ int ldb_search_default_callback(struct ldb_context *ldb, void *context, struct l
   \param attrs the search attributes for the query (pass NULL if none required)
   \param controls an array of controls
   \param context the callback function context
-  \param the callback function to handle the async replies
+  \param callback the callback function to handle the async replies
 
   \return result code (LDB_SUCCESS on success, or a failure code)
 */
@@ -911,7 +911,7 @@ int ldb_build_search_req(struct ldb_request **ret_req,
   \param message contains the entry to be added 
   \param controls an array of controls
   \param context the callback function context
-  \param the callback function to handle the async replies
+  \param callback the callback function to handle the async replies
 
   \return result code (LDB_SUCCESS on success, or a failure code)
 */
@@ -933,7 +933,7 @@ int ldb_build_add_req(struct ldb_request **ret_req,
   \param message contains the entry to be modified
   \param controls an array of controls
   \param context the callback function context
-  \param the callback function to handle the async replies
+  \param callback the callback function to handle the async replies
 
   \return result code (LDB_SUCCESS on success, or a failure code)
 */
@@ -955,7 +955,7 @@ int ldb_build_mod_req(struct ldb_request **ret_req,
   \param dn the DN to be deleted
   \param controls an array of controls
   \param context the callback function context
-  \param the callback function to handle the async replies
+  \param callback the callback function to handle the async replies
 
   \return result code (LDB_SUCCESS on success, or a failure code)
 */
@@ -978,7 +978,7 @@ int ldb_build_del_req(struct ldb_request **ret_req,
   \param newdn the new DN
   \param controls an array of controls
   \param context the callback function context
-  \param the callback function to handle the async replies
+  \param callback the callback function to handle the async replies
 
   \return result code (LDB_SUCCESS on success, or a failure code)
 */
@@ -997,7 +997,7 @@ int ldb_build_rename_req(struct ldb_request **ret_req,
 
   \param req the request struct where to add the control
   \param oid the object identifier of the control as string
-  \param ciritical whether the control should be critical or not
+  \param critical whether the control should be critical or not
   \param data a talloc pointer to the control specific data
 
   \return result code (LDB_SUCCESS on success, or a failure code)
@@ -1137,7 +1137,7 @@ int ldb_extended_default_callback(struct ldb_context *ldb, void *context, struct
   it needs to be NULL or a valid talloc pointer! talloc_get_type() will be used on it  
   \param controls an array of controls
   \param context the callback function context
-  \param the callback function to handle the async replies
+  \param callback the callback function to handle the async replies
 
   \return result code (LDB_SUCCESS on success, or a failure code)
 */
@@ -1226,6 +1226,7 @@ int ldb_valid_attr_name(const char *s);
 /*
   ldif manipulation functions
 */
+
 /**
    Write an LDIF message
 
@@ -1418,8 +1419,8 @@ bool ldb_dn_is_null(struct ldb_dn *dn);
    This function compares to attribute names. Note that this is a
    case-insensitive comparison.
 
-   \param attr1 the first attribute name to compare
-   \param attr2 the second attribute name to compare
+   \param a the first attribute name to compare
+   \param b the second attribute name to compare
 
    \return 0 if the attribute names are the same, or only differ in
    case; non-zero if there are any differences
@@ -1562,6 +1563,7 @@ int ldb_msg_check_string_attribute(const struct ldb_message *msg,
    This function performs basic sanity / integrity checks on an
    ldb_message.
 
+   \param ldb context in which to perform the checks
    \param msg the message to check
 
    \return LDB_SUCCESS if the message is OK, or a non-zero error code
index 336100c4f0a8bbfad118e67f2016f89b98301c0b..da4c52f77831583ee794cd9f5a6ba4cbff413933 100644 (file)
@@ -547,6 +547,43 @@ PyObject *PyExc_LdbError;
     talloc_free($1);
 };
 
+%typemap(in,numinputs=1) ldb_msg *add_msg {
+    int dict_pos, msg_pos;
+    PyObject *key, *value;
+    ldb_msg_element *msgel;
+
+    if (PyDict_Check($input)) {
+        $1 = ldb_msg_new(NULL);
+        $1->elements = talloc_zero_array($1, struct ldb_message_element, PyDict_Size($input));
+        msg_pos = dict_pos = 0;
+        while (PyDict_Next($input, &dict_pos, &key, &value)) {
+            if (!strcmp(PyString_AsString(key), "dn")) {
+                /* using argp0 (magic SWIG value) here is a hack */
+                if (ldb_dn_from_pyobject($1, value, argp1, &$1->dn) != 0) {
+                    SWIG_exception(SWIG_TypeError, "unable to import dn object");
+                }
+            } else {
+                msgel = ldb_msg_element_from_pyobject($1->elements, value, 0, PyString_AsString(key));
+                if (msgel == NULL) {
+                    SWIG_exception(SWIG_TypeError, "unable to import element");
+                }
+                memcpy(&$1->elements[msg_pos], msgel, sizeof(*msgel));
+                msg_pos++;
+            }
+        }
+
+        if ($1->dn == NULL) {
+            SWIG_exception(SWIG_TypeError, "no dn set");
+        }
+
+        $1->num_elements = msg_pos;
+    } else {
+        if (SWIG_ConvertPtr($input, (void **)&$1, SWIGTYPE_p_ldb_message, 0) != 0) {
+            SWIG_exception(SWIG_TypeError, "unable to convert ldb message");
+        }
+    }
+}
+
 /* Top-level ldb operations */
 typedef struct ldb_context {
     %extend {
@@ -604,53 +641,6 @@ typedef struct ldb_context {
         struct ldb_control **parse_control_strings(TALLOC_CTX *mem_ctx, 
                                                    const char * const*control_strings);
         ldb_error add(ldb_msg *add_msg);
-        ldb_error add(PyObject *py_msg) 
-        {
-            ldb_error ret;
-            int dict_pos, msg_pos;
-            PyObject *key, *value;
-            ldb_msg_element *msgel;
-            ldb_msg *msg = NULL;
-
-            if (PyDict_Check(py_msg)) {
-                msg = ldb_msg_new(NULL);
-                msg->elements = talloc_zero_array(msg, struct ldb_message_element, PyDict_Size(py_msg));
-                msg_pos = dict_pos = 0;
-                while (PyDict_Next(py_msg, &dict_pos, &key, &value)) {
-                    if (!strcmp(PyString_AsString(key), "dn")) {
-                        if (ldb_dn_from_pyobject(msg, value, $self, &msg->dn) != 0) {
-                            return LDB_ERR_OTHER;
-                        }
-                    } else {
-                        msgel = ldb_msg_element_from_pyobject(msg->elements, value, 0, PyString_AsString(key));
-                        if (msgel == NULL) {
-                            SWIG_exception(SWIG_TypeError, "unable to import element");
-                            return LDB_ERR_OTHER;
-                        }
-                        memcpy(&msg->elements[msg_pos], msgel, sizeof(*msgel));
-                        msg_pos++;
-                    }
-                }
-
-                if (msg->dn == NULL) {
-                    SWIG_exception(SWIG_TypeError, "no dn set");
-                    return LDB_ERR_OTHER;
-                }
-
-                msg->num_elements = msg_pos;
-            } else {
-                if (SWIG_ConvertPtr(py_msg, (void **)&msg, SWIGTYPE_p_ldb_message, 0) != 0)
-                    return LDB_ERR_OTHER;
-            }
-
-            ret = ldb_add($self, msg);
-
-            talloc_free(msg);
-            return ret;
-
-            fail:
-            return LDB_ERR_OTHER;
-        }
         ldb_error modify(ldb_msg *message);
         ldb_dn *get_config_basedn();
         ldb_dn *get_root_basedn();
index 995b584f51f97b8a0e5fd093db1731f926922b61..79958a86eba121d6f7dc5dc9bfde6ea806757c18 100644 (file)
@@ -816,8 +816,8 @@ _PUBLIC_ const struct ldb_backend_ops ldb_ldap_backend_ops = {
        .connect_fn = ildb_connect
 };
 
-_PUBLIC_ const struct ldb_backend_ops ldb_ildap_backend_ops = {
-       .name = "ildap",
+_PUBLIC_ const struct ldb_backend_ops ldb_ldapi_backend_ops = {
+       .name = "ldapi",
        .connect_fn = ildb_connect
 };
 
index 51022e5930e2e2980e574636f0281481c973c2ce..7886778b3a79238b535aa122af35a9cabcdd24fc 100644 (file)
@@ -3113,52 +3113,6 @@ SWIGINTERN ldb_error ldb_search_ex(ldb *self,TALLOC_CTX *mem_ctx,ldb_dn *base,en
             *OUT = res;
             return ret;
         }
-SWIGINTERN ldb_error ldb_add__SWIG_1(ldb *self,PyObject *py_msg){
-            ldb_error ret;
-            int dict_pos, msg_pos;
-            PyObject *key, *value;
-            ldb_msg_element *msgel;
-            ldb_msg *msg = NULL;
-
-            if (PyDict_Check(py_msg)) {
-                msg = ldb_msg_new(NULL);
-                msg->elements = talloc_zero_array(msg, struct ldb_message_element, PyDict_Size(py_msg));
-                msg_pos = dict_pos = 0;
-                while (PyDict_Next(py_msg, &dict_pos, &key, &value)) {
-                    if (!strcmp(PyString_AsString(key), "dn")) {
-                        if (ldb_dn_from_pyobject(msg, value, self, &msg->dn) != 0) {
-                            return 80;
-                        }
-                    } else {
-                        msgel = ldb_msg_element_from_pyobject(msg->elements, value, 0, PyString_AsString(key));
-                        if (msgel == NULL) {
-                            SWIG_exception(SWIG_TypeError, "unable to import element");
-                            return 80;
-                        }
-                        memcpy(&msg->elements[msg_pos], msgel, sizeof(*msgel));
-                        msg_pos++;
-                    }
-                }
-
-                if (msg->dn == NULL) {
-                    SWIG_exception(SWIG_TypeError, "no dn set");
-                    return 80;
-                }
-
-                msg->num_elements = msg_pos;
-            } else {
-                if (SWIG_ConvertPtr(py_msg, (void **)&msg, SWIGTYPE_p_ldb_message, 0) != 0)
-                    return 80;
-            }
-
-            ret = ldb_add(self, msg);
-
-            talloc_free(msg);
-            return ret;
-
-            fail:
-            return 80;
-        }
 SWIGINTERN PyObject *ldb_schema_format_value(ldb *self,char const *element_name,PyObject *val){
                const struct ldb_schema_attribute *a;
                struct ldb_val old_val;
@@ -4733,27 +4687,61 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_Ldb_add__SWIG_0(PyObject *SWIGUNUSEDPARM(self), int nobjs, PyObject **swig_obj) {
+SWIGINTERN PyObject *_wrap_Ldb_add(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
   PyObject *resultobj = 0;
   ldb *arg1 = (ldb *) 0 ;
   ldb_msg *arg2 = (ldb_msg *) 0 ;
   ldb_error result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  void *argp2 = 0 ;
-  int res2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  char *  kwnames[] = {
+    (char *) "self",(char *) "add_msg", NULL 
+  };
   
-  if ((nobjs < 2) || (nobjs > 2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_context, 0 |  0 );
+  if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Ldb_add",kwnames,&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_context, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Ldb_add" "', argument " "1"" of type '" "ldb *""'"); 
   }
   arg1 = (ldb *)(argp1);
-  res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_ldb_message, 0 |  0 );
-  if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Ldb_add" "', argument " "2"" of type '" "ldb_msg *""'"); 
+  {
+    int dict_pos, msg_pos;
+    PyObject *key, *value;
+    ldb_msg_element *msgel;
+    
+    if (PyDict_Check(obj1)) {
+      arg2 = ldb_msg_new(NULL);
+      arg2->elements = talloc_zero_array(arg2, struct ldb_message_element, PyDict_Size(obj1));
+      msg_pos = dict_pos = 0;
+      while (PyDict_Next(obj1, &dict_pos, &key, &value)) {
+        if (!strcmp(PyString_AsString(key), "dn")) {
+          /* using argp0 (magic SWIG value) here is a hack */
+          if (ldb_dn_from_pyobject(arg2, value, argp1, &arg2->dn) != 0) {
+            SWIG_exception(SWIG_TypeError, "unable to import dn object");
+          }
+        } else {
+          msgel = ldb_msg_element_from_pyobject(arg2->elements, value, 0, PyString_AsString(key));
+          if (msgel == NULL) {
+            SWIG_exception(SWIG_TypeError, "unable to import element");
+          }
+          memcpy(&arg2->elements[msg_pos], msgel, sizeof(*msgel));
+          msg_pos++;
+        }
+      }
+      
+      if (arg2->dn == NULL) {
+        SWIG_exception(SWIG_TypeError, "no dn set");
+      }
+      
+      arg2->num_elements = msg_pos;
+    } else {
+      if (SWIG_ConvertPtr(obj1, (void **)&arg2, SWIGTYPE_p_ldb_message, 0) != 0) {
+        SWIG_exception(SWIG_TypeError, "unable to convert ldb message");
+      }
+    }
   }
-  arg2 = (ldb_msg *)(argp2);
   if (arg1 == NULL)
   SWIG_exception(SWIG_ValueError, 
     "ldb context must be non-NULL");
@@ -4772,64 +4760,6 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_Ldb_add__SWIG_1(PyObject *SWIGUNUSEDPARM(self), int nobjs, PyObject **swig_obj) {
-  PyObject *resultobj = 0;
-  ldb *arg1 = (ldb *) 0 ;
-  PyObject *arg2 = (PyObject *) 0 ;
-  ldb_error result;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  
-  if ((nobjs < 2) || (nobjs > 2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_context, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Ldb_add" "', argument " "1"" of type '" "ldb *""'"); 
-  }
-  arg1 = (ldb *)(argp1);
-  arg2 = swig_obj[1];
-  if (arg1 == NULL)
-  SWIG_exception(SWIG_ValueError, 
-    "ldb context must be non-NULL");
-  result = ldb_add__SWIG_1(arg1,arg2);
-  if (result != 0) {
-    PyErr_SetObject(PyExc_LdbError, Py_BuildValue((char *)"(i,s)", result, ldb_strerror(result)));
-    SWIG_fail;
-  }
-  resultobj = Py_None;
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_Ldb_add(PyObject *self, PyObject *args) {
-  int argc;
-  PyObject *argv[3];
-  
-  if (!(argc = SWIG_Python_UnpackTuple(args,"Ldb_add",0,2,argv))) SWIG_fail;
-  --argc;
-  if (argc == 2) {
-    int _v = 0;
-    {
-      void *vptr = 0;
-      int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_ldb_message, 0);
-      _v = SWIG_CheckState(res);
-    }
-    if (!_v) goto check_1;
-    return _wrap_Ldb_add__SWIG_0(self, argc, argv);
-  }
-check_1:
-  
-  if (argc == 2) {
-    return _wrap_Ldb_add__SWIG_1(self, argc, argv);
-  }
-  
-fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'Ldb_add'.\n  Possible C/C++ prototypes are:\n""    add(ldb *,ldb_msg *)\n""    add(ldb *,PyObject *)\n");
-  return NULL;
-}
-
-
 SWIGINTERN PyObject *_wrap_Ldb_modify(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
   PyObject *resultobj = 0;
   ldb *arg1 = (ldb *) 0 ;
@@ -5729,7 +5659,7 @@ static PyMethodDef SwigMethods[] = {
         { (char *)"Ldb_delete", (PyCFunction) _wrap_Ldb_delete, METH_VARARGS | METH_KEYWORDS, NULL},
         { (char *)"Ldb_rename", (PyCFunction) _wrap_Ldb_rename, METH_VARARGS | METH_KEYWORDS, NULL},
         { (char *)"Ldb_parse_control_strings", (PyCFunction) _wrap_Ldb_parse_control_strings, METH_VARARGS | METH_KEYWORDS, NULL},
-        { (char *)"Ldb_add", _wrap_Ldb_add, METH_VARARGS, NULL},
+        { (char *)"Ldb_add", (PyCFunction) _wrap_Ldb_add, METH_VARARGS | METH_KEYWORDS, NULL},
         { (char *)"Ldb_modify", (PyCFunction) _wrap_Ldb_modify, METH_VARARGS | METH_KEYWORDS, NULL},
         { (char *)"Ldb_get_config_basedn", (PyCFunction)_wrap_Ldb_get_config_basedn, METH_O, NULL},
         { (char *)"Ldb_get_root_basedn", (PyCFunction)_wrap_Ldb_get_root_basedn, METH_O, NULL},
index c4de8e8da8b376ee5dd4f1127c3962d76e543db6..65c044c0f4127c2ef0cf230854904adbc69660e2 100644 (file)
@@ -119,7 +119,8 @@ static int rdn_name_add(struct ldb_module *module, struct ldb_request *req)
                                      "RDN mismatch on %s: %s (%s)", 
                                      ldb_dn_get_linearized(msg->dn), rdn_name, rdn_val.data);
                        talloc_free(down_req);
-                       return LDB_ERR_OPERATIONS_ERROR;
+                       /* Match AD's error here */
+                       return LDB_ERR_INVALID_DN_SYNTAX;
                }
        }
 
index bf6c5f963c4f1992c0bbb77d23b0dba62e81ac8d..02ad84ae25d0ffa5ea6085623831ce0e3f300891 100644 (file)
@@ -17,10 +17,11 @@ OBJ_FILES = \
                ldbadd.o
 PRIVATE_DEPENDENCIES = \
                LIBLDB_CMDLINE LIBCLI_RESOLVE
-MANPAGE = ../man/ldbadd.1
 # End BINARY ldbadd
 ################################################
 
+MANPAGES += $(ldbdir)/man/ldbadd.1
+
 ################################################
 # Start BINARY ldbdel
 [BINARY::ldbdel]
@@ -29,10 +30,11 @@ OBJ_FILES= \
                ldbdel.o
 PRIVATE_DEPENDENCIES = \
                LIBLDB_CMDLINE
-MANPAGE = ../man/ldbdel.1
 # End BINARY ldbdel
 ################################################
 
+MANPAGES += $(ldbdir)/man/ldbdel.1
+
 ################################################
 # Start BINARY ldbmodify
 [BINARY::ldbmodify]
@@ -41,10 +43,11 @@ OBJ_FILES= \
                ldbmodify.o
 PRIVATE_DEPENDENCIES = \
                LIBLDB_CMDLINE
-MANPAGE = ../man/ldbmodify.1
 # End BINARY ldbmodify
 ################################################
 
+MANPAGES += $(ldbdir)/man/ldbmodify.1
+
 ################################################
 # Start BINARY ldbsearch
 [BINARY::ldbsearch]
@@ -53,10 +56,11 @@ OBJ_FILES= \
                ldbsearch.o
 PRIVATE_DEPENDENCIES = \
                LIBLDB_CMDLINE 
-MANPAGE = ../man/ldbsearch.1
 # End BINARY ldbsearch
 ################################################
 
+MANPAGES += $(ldbdir)/man/ldbsearch.1
+
 ################################################
 # Start BINARY ldbedit
 [BINARY::ldbedit]
@@ -65,10 +69,11 @@ OBJ_FILES= \
                ldbedit.o
 PRIVATE_DEPENDENCIES = \
                LIBLDB_CMDLINE
-MANPAGE = ../man/ldbedit.1
 # End BINARY ldbedit
 ################################################
 
+MANPAGES += $(ldbdir)/man/ldbedit.1
+
 ################################################
 # Start BINARY ldbrename
 [BINARY::ldbrename]
@@ -77,8 +82,9 @@ OBJ_FILES= \
                ldbrename.o
 PRIVATE_DEPENDENCIES = \
                LIBLDB_CMDLINE
-MANPAGE = ../man/ldbrename.1
 # End BINARY ldbrename
 ################################################
 
+MANPAGES += $(ldbdir)/man/ldbrename.1
+
 
index b46f7c3ee7a2fa1cac6985f5b920efce6e3a6036..81b0ef36fd00d92b2a46cde857d4e7f1b51ae771 100644 (file)
@@ -1,7 +1,8 @@
 ##############################
 # Start SUBSYSTEM NSS_WRAPPER
 [SUBSYSTEM::NSS_WRAPPER]
-PUBLIC_HEADERS = nss_wrapper.h
 OBJ_FILES = nss_wrapper.o
 # End SUBSYSTEM NSS_WRAPPER
 ##############################
+
+PUBLIC_HEADERS += lib/nss_wrapper/nss_wrapper.h
index 7a9c8fcff167d83c75611884334862e297a9aabb..b2d7ce202e44672d0ad3c97de09452c1baa714e4 100644 (file)
@@ -36,10 +36,11 @@ OBJ_FILES = \
 PUBLIC_DEPENDENCIES = \
                LIBSAMBA-UTIL CHARSET TDR_REGF LIBLDB \
                RPC_NDR_WINREG LDB_WRAP
-PUBLIC_HEADERS = registry.h hive.h patchfile.h
 # End MODULE registry_ldb
 ################################################
 
+PUBLIC_HEADERS += $(addprefix lib/registry/, registry.h hive.h patchfile.h)
+
 [SUBSYSTEM::registry_common]
 PUBLIC_DEPENDENCIES = registry
 OBJ_FILES = tools/common.o
@@ -52,10 +53,11 @@ INSTALLDIR = BINDIR
 OBJ_FILES = tools/regdiff.o
 PRIVATE_DEPENDENCIES = \
                LIBSAMBA-CONFIG registry LIBPOPT POPT_SAMBA POPT_CREDENTIALS
-MANPAGE = man/regdiff.1
 # End BINARY regdiff
 ################################################
 
+MANPAGES += lib/registry/man/regdiff.1
+
 ################################################
 # Start BINARY regpatch
 [BINARY::regpatch]
@@ -64,10 +66,11 @@ OBJ_FILES = tools/regpatch.o
 PRIVATE_DEPENDENCIES = \
                LIBSAMBA-CONFIG registry LIBPOPT POPT_SAMBA POPT_CREDENTIALS \
                registry_common
-MANPAGE = man/regpatch.1
 # End BINARY regpatch
 ################################################
 
+MANPAGES += lib/registry/man/regpatch.1
+
 ################################################
 # Start BINARY regshell
 [BINARY::regshell]
@@ -76,10 +79,11 @@ OBJ_FILES = tools/regshell.o
 PRIVATE_DEPENDENCIES = \
                LIBSAMBA-CONFIG LIBPOPT registry POPT_SAMBA POPT_CREDENTIALS \
                SMBREADLINE registry_common
-MANPAGE = man/regshell.1
 # End BINARY regshell
 ################################################
 
+MANPAGES += lib/registry/man/regshell.1
+
 ################################################
 # Start BINARY regtree
 [BINARY::regtree]
@@ -88,10 +92,11 @@ OBJ_FILES = tools/regtree.o
 PRIVATE_DEPENDENCIES = \
                LIBSAMBA-CONFIG LIBPOPT registry POPT_SAMBA POPT_CREDENTIALS \
                registry_common
-MANPAGE = man/regtree.1
 # End BINARY regtree
 ################################################
 
+MANPAGES += lib/registry/man/regtree.1
+
 [SUBSYSTEM::torture_registry]
 PRIVATE_DEPENDENCIES = registry
 PRIVATE_PROTO_HEADER = tests/proto.h
index 5d56a30b3e14edaacfcaf4c80801cae9adaca9df..ad6a6421abb45e92c27f65f5c1514761f9704e3c 100644 (file)
@@ -22,6 +22,7 @@
 #include "includes.h"
 #include "hive.h"
 #include "system/filesys.h"
+#include "param/param.h"
 
 /** Open a registry file/host/etc */
 _PUBLIC_ WERROR reg_open_hive(TALLOC_CTX *parent_ctx, const char *location,
@@ -52,7 +53,7 @@ _PUBLIC_ WERROR reg_open_hive(TALLOC_CTX *parent_ctx, const char *location,
 
        if (!strncmp(peek, "regf", 4)) {
                close(fd);
-               return reg_open_regf_file(parent_ctx, location, lp_ctx, root);
+               return reg_open_regf_file(parent_ctx, location, lp_iconv_convenience(lp_ctx), root);
        } else if (!strncmp(peek, "TDB file", 8)) {
                close(fd);
                return reg_open_ldb_file(parent_ctx, location, session_info,
index 6d9a69c7c5dfcfac208132917e8d074460bdb7d6..87f335663d1e36cd2aff64dd95b8aa47ba76496a 100644 (file)
@@ -188,7 +188,7 @@ WERROR hive_key_flush(struct hive_key *key);
 WERROR reg_open_directory(TALLOC_CTX *parent_ctx,
                          const char *location, struct hive_key **key);
 WERROR reg_open_regf_file(TALLOC_CTX *parent_ctx,
-                         const char *location, struct loadparm_context *lp_ctx,
+                         const char *location, struct smb_iconv_convenience *iconv_convenience,
                          struct hive_key **key);
 WERROR reg_open_ldb_file(TALLOC_CTX *parent_ctx, const char *location,
                         struct auth_session_info *session_info,
@@ -200,6 +200,7 @@ WERROR reg_open_ldb_file(TALLOC_CTX *parent_ctx, const char *location,
 WERROR reg_create_directory(TALLOC_CTX *parent_ctx,
                            const char *location, struct hive_key **key);
 WERROR reg_create_regf_file(TALLOC_CTX *parent_ctx,
+                           struct smb_iconv_convenience *iconv_convenience,
                            const char *location,
                            int major_version,
                            struct hive_key **key);
index 31b78d82463aaf9e6eb72112b5e943b6b15778dd..a764ca6235322885b4d4049f4a0cfb2d66f41d72 100644 (file)
@@ -36,7 +36,9 @@ struct ldb_key_data
        int subkey_count, value_count;
 };
 
-static void reg_ldb_unpack_value(TALLOC_CTX *mem_ctx, struct ldb_message *msg,
+static void reg_ldb_unpack_value(TALLOC_CTX *mem_ctx, 
+                                struct smb_iconv_convenience *iconv_convenience,
+                                struct ldb_message *msg,
                                 const char **name, uint32_t *type,
                                 DATA_BLOB *data)
 {
@@ -57,7 +59,7 @@ static void reg_ldb_unpack_value(TALLOC_CTX *mem_ctx, struct ldb_message *msg,
        {
        case REG_SZ:
        case REG_EXPAND_SZ:
-               data->length = convert_string_talloc(mem_ctx, lp_iconv_convenience(global_loadparm), CH_UTF8, CH_UTF16,
+               data->length = convert_string_talloc(mem_ctx, iconv_convenience, CH_UTF8, CH_UTF16,
                                                     val->data, val->length,
                                                     (void **)&data->data);
                break;
@@ -281,7 +283,7 @@ static WERROR ldb_get_value_by_id(TALLOC_CTX *mem_ctx, struct hive_key *k,
        if (idx >= kd->value_count)
                return WERR_NO_MORE_ITEMS;
 
-       reg_ldb_unpack_value(mem_ctx, kd->values[idx],
+       reg_ldb_unpack_value(mem_ctx, lp_iconv_convenience(global_loadparm), kd->values[idx],
                             name, data_type, data);
 
        return WERR_OK;
@@ -310,7 +312,7 @@ static WERROR ldb_get_value(TALLOC_CTX *mem_ctx, struct hive_key *k,
        if (res->count == 0)
                return WERR_BADFILE;
 
-       reg_ldb_unpack_value(mem_ctx, res->msgs[0], NULL, data_type, data);
+       reg_ldb_unpack_value(mem_ctx, lp_iconv_convenience(global_loadparm), res->msgs[0], NULL, data_type, data);
 
        return WERR_OK;
 }
@@ -696,7 +698,9 @@ static WERROR ldb_get_key_info(TALLOC_CTX *mem_ctx,
 
                        if (max_valbufsize != NULL) {
                                DATA_BLOB data;
-                               reg_ldb_unpack_value(mem_ctx, kd->values[i], NULL, 
+                               reg_ldb_unpack_value(mem_ctx, 
+                                                    lp_iconv_convenience(global_loadparm),
+                                                    kd->values[i], NULL, 
                                                     NULL, &data);
                                *max_valbufsize = MAX(*max_valbufsize, data.length);
                                talloc_free(data.data);
index a4579010cd0a5189d510c1f024c9f53e6024b3f2..687fd4b91b2c4e9da621616f77845bdb1135b323 100644 (file)
@@ -27,6 +27,7 @@
 
 
 _PUBLIC_ WERROR reg_preg_diff_load(int fd,
+                                  struct smb_iconv_convenience *iconv_convenience, 
                                   const struct reg_diff_callbacks *callbacks,
                                   void *callback_data);
 
@@ -273,6 +274,7 @@ _PUBLIC_ WERROR reg_generate_diff(struct registry_context *ctx1,
  * Load diff file
  */
 _PUBLIC_ WERROR reg_diff_load(const char *filename,
+                             struct smb_iconv_convenience *iconv_convenience,
                              const struct reg_diff_callbacks *callbacks,
                              void *callback_data)
 {
@@ -305,10 +307,10 @@ _PUBLIC_ WERROR reg_diff_load(const char *filename,
 #endif
        if (strncmp(hdr, "PReg", 4) == 0) {
                /* Must be a GPO Registry.pol file */
-               return reg_preg_diff_load(fd, callbacks, callback_data);
+               return reg_preg_diff_load(fd, iconv_convenience, callbacks, callback_data);
        } else {
                /* Must be a normal .REG file */
-               return reg_dotreg_diff_load(fd, lp_iconv_convenience(global_loadparm), callbacks, callback_data);
+               return reg_dotreg_diff_load(fd, iconv_convenience, callbacks, callback_data);
        }
 }
 
@@ -442,5 +444,6 @@ _PUBLIC_ WERROR reg_diff_apply(struct registry_context *ctx, const char *filenam
        callbacks.del_all_values = reg_diff_apply_del_all_values;
        callbacks.done = NULL;
 
-       return reg_diff_load(filename, &callbacks, ctx);
+       return reg_diff_load(filename, lp_iconv_convenience(global_loadparm), 
+                            &callbacks, ctx);
 }
index 08a977d9cdc65d6b9258c4d5990868bcdbe56273..9289390685296b030e3c4e91cd0e4568711559a6 100644 (file)
@@ -43,6 +43,7 @@ WERROR reg_generate_diff(struct registry_context *ctx1,
                         const struct reg_diff_callbacks *callbacks,
                         void *callback_data);
 WERROR reg_dotreg_diff_save(TALLOC_CTX *ctx, const char *filename,
+                           struct smb_iconv_convenience *iconv_convenience,
                            struct reg_diff_callbacks **callbacks,
                            void **callback_data);
 WERROR reg_generate_diff_key(struct registry_key *oldkey,
index 46ea7c0008bce1f2be05449c0e8968e19317bd6f..6de642ecb810a0667cd012786e50be57bbdf0286 100644 (file)
@@ -101,6 +101,7 @@ static WERROR reg_dotreg_diff_del_all_values(void *callback_data,
  * Save registry diff
  */
 _PUBLIC_ WERROR reg_dotreg_diff_save(TALLOC_CTX *ctx, const char *filename,
+                                    struct smb_iconv_convenience *iconv_convenience,
                                     struct reg_diff_callbacks **callbacks,
                                     void **callback_data)
 {
@@ -109,7 +110,7 @@ _PUBLIC_ WERROR reg_dotreg_diff_save(TALLOC_CTX *ctx, const char *filename,
        data = talloc_zero(ctx, struct dotreg_data);
        *callback_data = data;
 
-       data->iconv_convenience = lp_iconv_convenience(global_loadparm);
+       data->iconv_convenience = iconv_convenience;
 
        if (filename) {
                data->fd = open(filename, O_CREAT, 0755);
index 9cc9a5dec2e69bc2fdabc41c9302ff5fed2e1437..0d39e67450f82baba5b003f9ed0fba50287fa891 100644 (file)
@@ -29,14 +29,14 @@ struct preg_data {
        int fd;
 };
 
-static WERROR preg_read_utf16(int fd, char *c)
+static WERROR preg_read_utf16(struct smb_iconv_convenience *ic, int fd, char *c)
 {
        uint16_t v;
 
        if (read(fd, &v, 2) < 2) {
                return WERR_GENERAL_FAILURE;
        }
-       push_codepoint(lp_iconv_convenience(global_loadparm), c, v);
+       push_codepoint(ic, c, v);
        return WERR_OK;
 }
 
@@ -123,6 +123,7 @@ _PUBLIC_ WERROR reg_preg_diff_save(TALLOC_CTX *ctx, const char *filename,
  * Load diff file
  */
 _PUBLIC_ WERROR reg_preg_diff_load(int fd,
+                                  struct smb_iconv_convenience *iconv_convenience, 
                                   const struct reg_diff_callbacks *callbacks,
                                   void *callback_data)
 {
@@ -162,7 +163,7 @@ _PUBLIC_ WERROR reg_preg_diff_load(int fd,
        while(1) {
                uint32_t value_type, length;
 
-               if (!W_ERROR_IS_OK(preg_read_utf16(fd, buf_ptr))) {
+               if (!W_ERROR_IS_OK(preg_read_utf16(iconv_convenience, fd, buf_ptr))) {
                        break;
                }
                if (*buf_ptr != '[') {
@@ -173,7 +174,7 @@ _PUBLIC_ WERROR reg_preg_diff_load(int fd,
 
                /* Get the path */
                buf_ptr = buf;
-               while (W_ERROR_IS_OK(preg_read_utf16(fd, buf_ptr)) &&
+               while (W_ERROR_IS_OK(preg_read_utf16(iconv_convenience, fd, buf_ptr)) &&
                       *buf_ptr != ';' && buf_ptr-buf < buf_size) {
                        buf_ptr++;
                }
@@ -181,7 +182,7 @@ _PUBLIC_ WERROR reg_preg_diff_load(int fd,
 
                /* Get the name */
                buf_ptr = buf;
-               while (W_ERROR_IS_OK(preg_read_utf16(fd, buf_ptr)) &&
+               while (W_ERROR_IS_OK(preg_read_utf16(iconv_convenience, fd, buf_ptr)) &&
                       *buf_ptr != ';' && buf_ptr-buf < buf_size) {
                        buf_ptr++;
                }
@@ -195,7 +196,7 @@ _PUBLIC_ WERROR reg_preg_diff_load(int fd,
                }
                /* Read past delimiter */
                buf_ptr = buf;
-               if (!(W_ERROR_IS_OK(preg_read_utf16(fd, buf_ptr)) &&
+               if (!(W_ERROR_IS_OK(preg_read_utf16(iconv_convenience, fd, buf_ptr)) &&
                    *buf_ptr == ';') && buf_ptr-buf < buf_size) {
                        DEBUG(0, ("Error in PReg file.\n"));
                        ret = WERR_GENERAL_FAILURE;
@@ -209,7 +210,7 @@ _PUBLIC_ WERROR reg_preg_diff_load(int fd,
                }
                /* Read past delimiter */
                buf_ptr = buf;
-               if (!(W_ERROR_IS_OK(preg_read_utf16(fd, buf_ptr)) &&
+               if (!(W_ERROR_IS_OK(preg_read_utf16(iconv_convenience, fd, buf_ptr)) &&
                    *buf_ptr == ';') && buf_ptr-buf < buf_size) {
                        DEBUG(0, ("Error in PReg file.\n"));
                        ret = WERR_GENERAL_FAILURE;
@@ -227,7 +228,7 @@ _PUBLIC_ WERROR reg_preg_diff_load(int fd,
 
                /* Check if delimiter is in place (whine if it isn't) */
                buf_ptr = buf;
-               if (!(W_ERROR_IS_OK(preg_read_utf16(fd, buf_ptr)) &&
+               if (!(W_ERROR_IS_OK(preg_read_utf16(iconv_convenience, fd, buf_ptr)) &&
                    *buf_ptr == ']') && buf_ptr-buf < buf_size) {
                        DEBUG(0, ("Warning: Missing ']' in PReg file, expected ']', got '%c' 0x%x.\n",
                                *buf_ptr, *buf_ptr));
index 6a35799a7e12200f4d761ca105e4308cde1c45ef..a192f3be4ddc14c656435552d22ce3b0ed7d356a 100644 (file)
@@ -1908,7 +1908,9 @@ static WERROR regf_save_hbin(struct regf_data *regf)
        return WERR_OK;
 }
 
-WERROR reg_create_regf_file(TALLOC_CTX *parent_ctx, const char *location,
+WERROR reg_create_regf_file(TALLOC_CTX *parent_ctx, 
+                           struct smb_iconv_convenience *iconv_convenience,
+                           const char *location,
                            int minor_version, struct hive_key **key)
 {
        struct regf_data *regf;
@@ -1919,7 +1921,7 @@ WERROR reg_create_regf_file(TALLOC_CTX *parent_ctx, const char *location,
 
        regf = (struct regf_data *)talloc_zero(NULL, struct regf_data);
 
-       regf->iconv_convenience = lp_iconv_convenience(global_loadparm);
+       regf->iconv_convenience = iconv_convenience;
 
        W_ERROR_HAVE_NO_MEMORY(regf);
 
@@ -1995,7 +1997,7 @@ WERROR reg_create_regf_file(TALLOC_CTX *parent_ctx, const char *location,
 }
 
 WERROR reg_open_regf_file(TALLOC_CTX *parent_ctx, const char *location, 
-                         struct loadparm_context *lp_ctx, struct hive_key **key)
+                         struct smb_iconv_convenience *iconv_convenience, struct hive_key **key)
 {
        struct regf_data *regf;
        struct regf_hdr *regf_hdr;
@@ -2004,7 +2006,7 @@ WERROR reg_open_regf_file(TALLOC_CTX *parent_ctx, const char *location,
 
        regf = (struct regf_data *)talloc_zero(NULL, struct regf_data);
 
-       regf->iconv_convenience = lp_iconv_convenience(lp_ctx);
+       regf->iconv_convenience = iconv_convenience;
 
        W_ERROR_HAVE_NO_MEMORY(regf);
 
index 915782694f61de5bc9b83fa9bd99e0d34aa99c30..1e56f125c5d168eac047c08a69328aff48881181 100644 (file)
@@ -25,6 +25,7 @@
 #include "torture/torture.h"
 #include "librpc/gen_ndr/winreg.h"
 #include "system/filesys.h"
+#include "param/param.h"
 
 static bool test_del_nonexistant_key(struct torture_context *tctx,
                                     const void *test_data)
@@ -386,7 +387,8 @@ static bool hive_setup_regf(struct torture_context *tctx, void **data)
 
        rmdir(dirname);
 
-       error = reg_create_regf_file(tctx, dirname, 5, &key);
+       error = reg_create_regf_file(tctx, lp_iconv_convenience(tctx->lp_ctx),
+                                    dirname, 5, &key);
        if (!W_ERROR_IS_OK(error)) {
                fprintf(stderr, "Unable to create new regf file\n");
                return false;
index 406eaeea3df4f168697c4ce4f83f1bb72c88a1d8..c94380efd2b0be46febaedbb11a81f953df77b32 100644 (file)
@@ -126,7 +126,7 @@ int main(int argc, const char **argv)
 
        poptFreeContext(pc);
 
-       error = reg_dotreg_diff_save(ctx, outputfile, &callbacks,
+       error = reg_dotreg_diff_save(ctx, outputfile, lp_iconv_convenience(cmdline_lp_ctx), &callbacks,
                                     &callback_data);
        if (!W_ERROR_IS_OK(error)) {
                fprintf(stderr, "Problem saving registry diff to '%s': %s\n",
index 30f39ac6cb4b92c75a9e0b3ff0da402b147c5f8f..c989835a8d37b29cee7e63451be470f2a4dd6194 100644 (file)
@@ -10,6 +10,7 @@ VPATH = @libreplacedir@
 srcdir = @srcdir@
 builddir = @builddir@
 INSTALL = @INSTALL@
+LIBS = @LIBS@
 
 .PHONY: test all showflags install installcheck clean distclean realdistclean
 
@@ -25,6 +26,7 @@ showflags:
        @echo '  CC     = $(CC)'
        @echo '  CFLAGS = $(CFLAGS)'
        @echo '  LDFLAGS= $(LDFLAGS)'
+       @echo '  LIBS   = $(LIBS)'
 
 install: all
        mkdir -p $(libdir)
@@ -38,10 +40,10 @@ test: all
 
 installcheck: install test
 
-TEST_OBJS = test/testsuite.o test/os2_delete.o test/strptime.o
+TEST_OBJS = 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)
+       $(CC) -o testsuite $(TEST_OBJS) -L. -lreplace $(LDFLAGS) $(LIBS)
 
 .c.o:
        @echo Compiling $*.c
index beeb77e15204a6d7bb7f0b22bfe3003d2218a06b..f5e054f4767379ef98714c306638cf8003c9917e 100644 (file)
@@ -3,6 +3,8 @@ AC_INIT(replace.c)
 AC_CONFIG_SRCDIR([replace.c])
 AC_CONFIG_HEADER(config.h)
 
+CFLAGS="$CFLAGS -I$srcdir"
+
 AC_LIBREPLACE_ALL_CHECKS
 
 if test "$ac_cv_prog_gcc" = yes; then
index 053657475d8fa0214bedecabc773a19d116f7e7a..f6f0ec080c2e48ef085635c04c6af7d87c61753d 100644 (file)
 
 void rep_freeifaddrs(struct ifaddrs *ifp)
 {
-       free(ifp->ifa_name);
-       free(ifp->ifa_addr);
-       free(ifp->ifa_netmask);
-       free(ifp->ifa_dstaddr);
-       if (ifp->ifa_next != NULL)
+       if (ifp != NULL) {
+               free(ifp->ifa_name);
+               free(ifp->ifa_addr);
+               free(ifp->ifa_netmask);
+               free(ifp->ifa_dstaddr);
                freeifaddrs(ifp->ifa_next);
-       free(ifp);
+               free(ifp);
+       }
 }
 
 static struct sockaddr *sockaddr_dup(struct sockaddr *sa)
@@ -109,38 +110,33 @@ int rep_getifaddrs(struct ifaddrs **ifap)
 
        /* Loop through interfaces, looking for given IP address */
        for (i=n-1; i>=0; i--) {
-               if (ioctl(fd, SIOCGIFADDR, &ifr[i]) != 0) {
+               if (ioctl(fd, SIOCGIFFLAGS, &ifr[i]) == -1) {
                        freeifaddrs(*ifap);
+                       return -1;
                }
 
                curif = calloc(1, sizeof(struct ifaddrs));
-               if (lastif == NULL) {
-                       *ifap = curif;
-               } else {
-                       lastif->ifa_next = curif;
-               }
-
                curif->ifa_name = strdup(ifr[i].ifr_name);
-               curif->ifa_addr = sockaddr_dup(&ifr[i].ifr_addr);
+               curif->ifa_flags = ifr[i].ifr_flags;
                curif->ifa_dstaddr = NULL;
                curif->ifa_data = NULL;
                curif->ifa_next = NULL;
-               curif->ifa_netmask = NULL;
 
-               if (ioctl(fd, SIOCGIFFLAGS, &ifr[i]) != 0) {
-                       freeifaddrs(*ifap);
-                       return -1;
-               }  
-
-               curif->ifa_flags = ifr[i].ifr_flags;
-
-               if (ioctl(fd, SIOCGIFNETMASK, &ifr[i]) != 0) {
-                       freeifaddrs(*ifap);
-                       return -1;
-               }  
+               curif->ifa_addr = NULL;
+               if (ioctl(fd, SIOCGIFADDR, &ifr[i]) != -1) {
+                       curif->ifa_addr = sockaddr_dup(&ifr[i].ifr_addr);
+               }
 
-               curif->ifa_netmask = sockaddr_dup(&ifr[i].ifr_addr);
+               curif->ifa_netmask = NULL;
+               if (ioctl(fd, SIOCGIFNETMASK, &ifr[i]) != -1) {
+                       curif->ifa_netmask = sockaddr_dup(&ifr[i].ifr_addr);
+               }
 
+               if (lastif == NULL) {
+                       *ifap = curif;
+               } else {
+                       lastif->ifa_next = curif;
+               }
                lastif = curif;
        }
 
@@ -363,32 +359,3 @@ int rep_getifaddrs(struct ifaddrs **ifap)
        return -1;
 }
 #endif
-
-#ifdef AUTOCONF_TEST
-/* this is the autoconf driver to test getifaddrs() */
-
- int main()
-{
-       struct ifaddrs *ifs = NULL;
-       int ret;
-       
-       ret = getifaddrs(&ifs);
-       if (ret != 0) {
-               perror("getifaddrs() failed");
-               return 1;
-       }
-
-       while (ifs) {
-               printf("%-10s ", ifs->ifa_name);
-               if (ifs->ifa_addr != NULL && 
-                   ifs->ifa_addr->sa_family == AF_INET) {
-                       printf("IP=%s ", inet_ntoa(((struct sockaddr_in *)ifs->ifa_addr)->sin_addr));
-                       if (ifs->ifa_netmask != NULL)
-                               printf("NETMASK=%s", inet_ntoa(((struct sockaddr_in *)ifs->ifa_netmask)->sin_addr));
-               }
-               printf("\n");
-               ifs = ifs->ifa_next;
-       }
-       return 0;
-}
-#endif
index dd2a95cb815b1ba13006c9df8659d00644566603..6cca155de3721cc7dc540d42b2ed9530133bb6ec 100644 (file)
@@ -49,7 +49,11 @@ AC_TRY_RUN([
 #define AUTOCONF_TEST 1
 #define SOCKET_WRAPPER_NOT_REPLACE
 #include "$libreplacedir/replace.c"
-#include "$libreplacedir/getifaddrs.c"],
+#include "$libreplacedir/inet_ntop.c"
+#include "$libreplacedir/snprintf.c"
+#include "$libreplacedir/getifaddrs.c"
+#define getifaddrs_test main
+#include "$libreplacedir/test/getifaddrs.c"],
            libreplace_cv_HAVE_IFACE_GETIFADDRS=yes,libreplace_cv_HAVE_IFACE_GETIFADDRS=no,libreplace_cv_HAVE_IFACE_GETIFADDRS=cross)])
 if test x"$libreplace_cv_HAVE_IFACE_GETIFADDRS" = x"yes"; then
     iface=yes;AC_DEFINE(HAVE_IFACE_GETIFADDRS,1,[Whether iface getifaddrs is available])
@@ -67,10 +71,15 @@ AC_TRY_RUN([
 #undef _XOPEN_SOURCE_EXTENDED
 #define SOCKET_WRAPPER_NOT_REPLACE
 #include "$libreplacedir/replace.c"
-#include "$libreplacedir/getifaddrs.c"],
+#include "$libreplacedir/inet_ntop.c"
+#include "$libreplacedir/snprintf.c"
+#include "$libreplacedir/getifaddrs.c"
+#define getifaddrs_test main
+#include "$libreplacedir/test/getifaddrs.c"],
            libreplace_cv_HAVE_IFACE_AIX=yes,libreplace_cv_HAVE_IFACE_AIX=no,libreplace_cv_HAVE_IFACE_AIX=cross)])
 if test x"$libreplace_cv_HAVE_IFACE_AIX" = x"yes"; then
     iface=yes;AC_DEFINE(HAVE_IFACE_AIX,1,[Whether iface AIX is available])
+       old_LIBS="$old_LIBS $LIBS"
 fi
 fi
 
@@ -83,10 +92,15 @@ AC_TRY_RUN([
 #define AUTOCONF_TEST 1
 #define SOCKET_WRAPPER_NOT_REPLACE
 #include "$libreplacedir/replace.c"
-#include "$libreplacedir/getifaddrs.c"],
+#include "$libreplacedir/inet_ntop.c"
+#include "$libreplacedir/snprintf.c"
+#include "$libreplacedir/getifaddrs.c"
+#define getifaddrs_test main
+#include "$libreplacedir/test/getifaddrs.c"],
            libreplace_cv_HAVE_IFACE_IFCONF=yes,libreplace_cv_HAVE_IFACE_IFCONF=no,libreplace_cv_HAVE_IFACE_IFCONF=cross)])
 if test x"$libreplace_cv_HAVE_IFACE_IFCONF" = x"yes"; then
     iface=yes;AC_DEFINE(HAVE_IFACE_IFCONF,1,[Whether iface ifconf is available])
+       old_LIBS="$old_LIBS $LIBS"
 fi
 fi
 
@@ -98,10 +112,15 @@ AC_TRY_RUN([
 #define AUTOCONF_TEST 1
 #define SOCKET_WRAPPER_NOT_REPLACE
 #include "$libreplacedir/replace.c"
-#include "$libreplacedir/getifaddrs.c"],
+#include "$libreplacedir/inet_ntop.c"
+#include "$libreplacedir/snprintf.c"
+#include "$libreplacedir/getifaddrs.c"
+#define getifaddrs_test main
+#include "$libreplacedir/test/getifaddrs.c"],
            libreplace_cv_HAVE_IFACE_IFREQ=yes,libreplace_cv_HAVE_IFACE_IFREQ=no,libreplace_cv_HAVE_IFACE_IFREQ=cross)])
 if test x"$libreplace_cv_HAVE_IFACE_IFREQ" = x"yes"; then
     iface=yes;AC_DEFINE(HAVE_IFACE_IFREQ,1,[Whether iface ifreq is available])
+       old_LIBS="$old_LIBS $LIBS"
 fi
 fi
 
diff --git a/source4/lib/replace/test/getifaddrs.c b/source4/lib/replace/test/getifaddrs.c
new file mode 100644 (file)
index 0000000..8b00ac2
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+ * Unix SMB/CIFS implementation.
+ *
+ * libreplace getifaddrs test
+ *
+ * Copyright (C) Michael Adam <obnox@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/>.
+ */
+
+#ifndef AUTOCONF_TEST
+#include "replace.h"
+#include "system/network.h"
+#endif
+
+#ifdef HAVE_INET_NTOP
+#define rep_inet_ntop inet_ntop
+#endif
+
+static const char *format_sockaddr(struct sockaddr *addr,
+                                  char *addrstring,
+                                  socklen_t addrlen)
+{
+       const char *result = NULL;
+
+       if (addr->sa_family == AF_INET) {
+               result = rep_inet_ntop(AF_INET,
+                                      &((struct sockaddr_in *)addr)->sin_addr,
+                                      addrstring,
+                                      addrlen);
+#ifdef HAVE_STRUCT_SOCKADDR_IN6
+       } else if (addr->sa_family == AF_INET6) {
+               result = rep_inet_ntop(AF_INET6,
+                                      &((struct sockaddr_in6 *)addr)->sin6_addr,
+                                      addrstring,
+                                      addrlen);
+#endif
+       }
+       return result;
+}
+
+int getifaddrs_test(void)
+{
+       struct ifaddrs *ifs = NULL;
+       struct ifaddrs *ifs_head = NULL;
+       int ret;
+
+       ret = getifaddrs(&ifs);
+       ifs_head = ifs;
+       if (ret != 0) {
+               fprintf(stderr, "getifaddrs() failed: %s\n", strerror(errno));
+               return 1;
+       }
+
+       while (ifs) {
+               printf("%-10s ", ifs->ifa_name);
+               if (ifs->ifa_addr != NULL) {
+                       char addrstring[INET6_ADDRSTRLEN];
+                       const char *result;
+
+                       result = format_sockaddr(ifs->ifa_addr,
+                                                addrstring,
+                                                sizeof(addrstring));
+                       if (result != NULL) {
+                               printf("IP=%s ", addrstring);
+                       }
+
+                       if (ifs->ifa_netmask != NULL) {
+                               result = format_sockaddr(ifs->ifa_netmask,
+                                                        addrstring,
+                                                        sizeof(addrstring));
+                               if (result != NULL) {
+                                       printf("NETMASK=%s", addrstring);
+                               }
+                       } else {
+                               printf("AF=%d ", ifs->ifa_addr->sa_family);
+                       }
+               } else {
+                       printf("<no address>");
+               }
+
+               printf("\n");
+               ifs = ifs->ifa_next;
+       }
+
+       freeifaddrs(ifs_head);
+
+       return 0;
+}
index c9f330100555d39bbe205948d4cfea21357a768d..b53836036562b1df0ab99928184226108ff271e3 100644 (file)
@@ -856,21 +856,18 @@ static int test_strptime(void)
        return libreplace_test_strptime();
 }
 
+extern int getifaddrs_test(void);
+
 static int test_getifaddrs(void)
 {
-       struct ifaddrs *ifa;
-       int ret;
 
        printf("test: getifaddrs\n");
 
-       ret = getifaddrs(&ifa);
-       if (ret != 0) {
+       if (getifaddrs_test() != 0) {
                printf("failure: getifaddrs\n");
                return false;
        }
 
-       freeifaddrs(ifa);
-
        printf("success: getifaddrs\n");
        return true;
 }
index 4c5cf9434855e563b71dae5ee9539c8a095d519d..cc52a998015610ddbd1dc7c87259ac7ac0f7b0f0 100644 (file)
@@ -1,8 +1,9 @@
 ##############################
 # Start SUBSYSTEM SOCKET_WRAPPER
 [SUBSYSTEM::SOCKET_WRAPPER]
-PUBLIC_HEADERS = socket_wrapper.h
 OBJ_FILES = socket_wrapper.o
 PRIVATE_DEPENDENCIES = EXT_SOCKET
 # End SUBSYSTEM SOCKET_WRAPPER
 ##############################
+
+PUBLIC_HEADERS += lib/socket_wrapper/socket_wrapper.h
index af1b590c988ccaf5a93071e8d50384614cd82e26..33241ffac7d5b3ec5e6e3a4d1f4db3540bd6d7b2 100644 (file)
@@ -1,6 +1,8 @@
 [LIBRARY::LIBTALLOC]
 OUTPUT_TYPE = STATIC_LIBRARY
 OBJ_FILES = talloc.o
-MANPAGE = talloc.3
 CFLAGS = -Ilib/talloc
-PUBLIC_HEADERS = talloc.h
+
+
+MANPAGES += $(tallocdir)/talloc.3
+PUBLIC_HEADERS += $(tallocdir)/talloc.h
index 89d6af90430b88751611b4cb5db8cc99a3720bb2..c69804fa13b7f1227cdae868d75177b124a1bc77 100644 (file)
@@ -7,11 +7,12 @@ OBJ_FILES = \
        common/open.o common/traverse.o common/freelist.o \
        common/error.o common/transaction.o
 CFLAGS = -Ilib/tdb/include
-PUBLIC_HEADERS = include/tdb.h
 #
 # End SUBSYSTEM ldb
 ################################################
 
+PUBLIC_HEADERS += $(tdbdir)/include/tdb.h
+
 ################################################
 # Start BINARY tdbtool
 [BINARY::tdbtool]
index b8473e5ba8376f326c0cdba1945835b6143bf2f1..eb3cde9bdf9d5709919e1633de1e7321dc8a08e2 100644 (file)
@@ -1,6 +1,7 @@
 [SUBSYSTEM::TDR]
 CFLAGS = -Ilib/tdr
-PUBLIC_HEADERS = tdr.h
-PUBLIC_PROTO_HEADER = tdr_proto.h
+PRIVATE_PROTO_HEADER = tdr_proto.h
 PUBLIC_DEPENDENCIES = LIBTALLOC LIBSAMBA-UTIL
 OBJ_FILES = tdr.o
+
+PUBLIC_HEADERS += lib/tdr/tdr.h
index f3e6cd7acf802b89ad233df6ce2f3b56b9cfb5a7..16a0357df83b8744560e604748bf64277bb7f064 100644 (file)
@@ -1,15 +1,6 @@
 [SUBSYSTEM::LIBSAMBA-UTIL]
 #VERSION = 0.0.1
 #SO_VERSION = 0
-PUBLIC_HEADERS = util.h \
-                                attr.h \
-                                byteorder.h \
-                                data_blob.h \
-                                debug.h \
-                                mutex.h \
-                                safe_string.h \
-                                time.h \
-                                xfile.h
 OBJ_FILES = xfile.o \
                debug.o \
                fault.o \
@@ -33,11 +24,22 @@ PUBLIC_DEPENDENCIES = \
                SOCKET_WRAPPER EXT_NSL \
                CHARSET EXECINFO
 
+PUBLIC_HEADERS += $(addprefix lib/util/, util.h \
+                                attr.h \
+                                byteorder.h \
+                                data_blob.h \
+                                debug.h \
+                                mutex.h \
+                                safe_string.h \
+                                time.h \
+                                xfile.h)
+
 [SUBSYSTEM::ASN1_UTIL]
-PUBLIC_PROTO_HEADER = asn1_proto.h
-PUBLIC_HEADERS = asn1.h
+PRIVATE_PROTO_HEADER = asn1_proto.h
 OBJ_FILES = asn1.o
 
+PUBLIC_HEADERS += lib/util/asn1.h
+
 [SUBSYSTEM::UNIX_PRIVS]
 PRIVATE_PROTO_HEADER = unix_privs.h
 OBJ_FILES = unix_privs.o
@@ -45,7 +47,7 @@ OBJ_FILES = unix_privs.o
 ################################################
 # Start SUBSYSTEM WRAP_XATTR
 [SUBSYSTEM::WRAP_XATTR]
-PUBLIC_PROTO_HEADER = wrap_xattr.h
+PRIVATE_PROTO_HEADER = wrap_xattr.h
 OBJ_FILES = \
                wrap_xattr.o
 PUBLIC_DEPENDENCIES = XATTR
@@ -54,13 +56,13 @@ PUBLIC_DEPENDENCIES = XATTR
 ################################################
 
 [SUBSYSTEM::UTIL_TDB]
-PUBLIC_PROTO_HEADER = util_tdb.h
+PRIVATE_PROTO_HEADER = util_tdb.h
 OBJ_FILES = \
                util_tdb.o
 PUBLIC_DEPENDENCIES = LIBTDB
 
 [SUBSYSTEM::UTIL_LDB]
-PUBLIC_PROTO_HEADER = util_ldb.h
+PRIVATE_PROTO_HEADER = util_ldb.h
 OBJ_FILES = \
                        util_ldb.o
 PUBLIC_DEPENDENCIES = LIBLDB
index 6cea0a08f06e2e41e5af1cc1e21275e5bf5e9878..61d3fe8c9451c7f963c29eedd72fafb0b377f7c3 100644 (file)
@@ -1,7 +1,6 @@
 #################################
 # Start SUBSYSTEM LIBCLI_AUTH
 [SUBSYSTEM::LIBCLI_AUTH]
-PUBLIC_HEADERS = credentials.h
 PRIVATE_PROTO_HEADER = proto.h
 OBJ_FILES = credentials.o \
                session.o \
@@ -12,3 +11,6 @@ PUBLIC_DEPENDENCIES = \
                LIBSAMBA-CONFIG
 # End SUBSYSTEM LIBCLI_AUTH
 #################################
+
+
+PUBLIC_HEADERS += libcli/auth/credentials.h
index 7c8d40e608addf2424d7114aafecb58c87ae6e30..d10eeb8ffd7e7e4f36bdc53aca76e7e4a4444e76 100644 (file)
@@ -241,7 +241,8 @@ static void cldap_socket_handler(struct event_context *ev, struct fd_event *fde,
   then operations will use that event context
 */
 struct cldap_socket *cldap_socket_init(TALLOC_CTX *mem_ctx, 
-                                      struct event_context *event_ctx)
+                                      struct event_context *event_ctx,
+                                      struct smb_iconv_convenience *iconv_convenience)
 {
        struct cldap_socket *cldap;
        NTSTATUS status;
@@ -270,6 +271,7 @@ struct cldap_socket *cldap_socket_init(TALLOC_CTX *mem_ctx,
 
        cldap->send_queue = NULL;
        cldap->incoming.handler = NULL;
+       cldap->iconv_convenience = iconv_convenience;
        
        return cldap;
 
@@ -618,7 +620,7 @@ NTSTATUS cldap_netlogon_recv(struct cldap_request *req,
        data = search.out.response->attributes[0].values;
 
        ndr_err = ndr_pull_union_blob_all(data, mem_ctx, 
-                                         lp_iconv_convenience(global_loadparm),
+                                         req->cldap->iconv_convenience,
                                          &io->out.netlogon,
                                          io->in.version & 0xF,
                                          (ndr_pull_flags_fn_t)ndr_pull_nbt_cldap_netlogon);
@@ -714,7 +716,7 @@ NTSTATUS cldap_netlogon_reply(struct cldap_socket *cldap,
        DATA_BLOB blob;
 
        ndr_err = ndr_push_union_blob(&blob, tmp_ctx, 
-                                     lp_iconv_convenience(global_loadparm),
+                                     cldap->iconv_convenience,
                                      netlogon, version & 0xF,
                                     (ndr_push_flags_fn_t)ndr_push_nbt_cldap_netlogon);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
index 7a222e06524a8c015dc5fe38bc44409cd8d4f0fb..eb0191d0f4589bfad6e6fbb38a0578de8f80f587 100644 (file)
@@ -73,6 +73,7 @@ struct cldap_request {
 struct cldap_socket {
        struct socket_context *sock;
        struct event_context *event_ctx;
+       struct smb_iconv_convenience *iconv_convenience;
 
        /* the fd event */
        struct fd_event *fde;
@@ -111,7 +112,8 @@ struct cldap_search {
 };
 
 struct cldap_socket *cldap_socket_init(TALLOC_CTX *mem_ctx, 
-                                      struct event_context *event_ctx);
+                                      struct event_context *event_ctx, 
+                                      struct smb_iconv_convenience *iconv_convenience);
 NTSTATUS cldap_set_incoming_handler(struct cldap_socket *cldap,
                                    void (*handler)(struct cldap_socket *, struct ldap_message *, 
                                                    struct socket_address *),
index e4b6c71c8c71ebe3e76a108ca8467a6258ee94e6..d3a3beaaa980a5669b0e427511aeb5f2bc56042a 100644 (file)
@@ -3,11 +3,13 @@ mkinclude ldap/config.mk
 mkinclude security/config.mk
 
 [SUBSYSTEM::LIBSAMBA-ERRORS]
-PUBLIC_HEADERS = util/error.h util/ntstatus.h util/doserr.h util/werror.h
 OBJ_FILES = util/doserr.o \
                    util/errormap.o \
                    util/nterr.o \
 
+
+PUBLIC_HEADERS += $(addprefix libcli/, util/error.h util/ntstatus.h util/doserr.h util/werror.h)
+
 [SUBSYSTEM::LIBCLI_LSA]
 PRIVATE_PROTO_HEADER = util/clilsa.h
 OBJ_FILES = util/clilsa.o
@@ -68,10 +70,11 @@ PUBLIC_DEPENDENCIES = LIBCLI_NBT LIBNDR LIBCLI_RESOLVE
 
 [SUBSYSTEM::LIBCLI_CLDAP]
 OBJ_FILES = cldap/cldap.o
-PUBLIC_HEADERS = cldap/cldap.h
 PUBLIC_DEPENDENCIES = LIBCLI_LDAP
 PRIVATE_DEPENDENCIES = LIBSAMBA-UTIL LIBLDB
 
+PUBLIC_HEADERS += libcli/cldap/cldap.h
+
 [SUBSYSTEM::LIBCLI_WREPL]
 PRIVATE_PROTO_HEADER = wrepl/winsrepl_proto.h
 OBJ_FILES = \
@@ -102,8 +105,7 @@ OBJ_FILES = \
 PUBLIC_DEPENDENCIES = LIBCLI_NBT MESSAGING
 
 [SUBSYSTEM::LIBCLI_SMB]
-PUBLIC_HEADERS = libcli.h
-PUBLIC_PROTO_HEADER = libcli_proto.h
+PRIVATE_PROTO_HEADER = libcli_proto.h
 OBJ_FILES = clireadwrite.o \
                cliconnect.o \
                clifile.o \
@@ -115,6 +117,9 @@ PUBLIC_DEPENDENCIES = LIBCLI_RAW LIBSAMBA-ERRORS LIBCLI_AUTH \
        LIBCLI_SMB_COMPOSITE LIBCLI_NBT LIBSECURITY LIBCLI_RESOLVE \
        LIBCLI_DGRAM LIBCLI_SMB2 LIBCLI_FINDDCS samba-socket
 
+
+PUBLIC_HEADERS += libcli/libcli.h
+
 [SUBSYSTEM::LIBCLI_RAW]
 PRIVATE_PROTO_HEADER = raw/raw_proto.h
 PRIVATE_DEPENDENCIES = LIBCLI_COMPOSITE LP_RESOLVE gensec LIBCLI_RESOLVE LIBSECURITY LIBNDR
index 7d6f5627c518343ad748a466ff885d15cd023ffb..130d8ae870949df276fca6d4a419ac32ed0bc1f8 100644 (file)
@@ -158,7 +158,8 @@ static void dgm_socket_handler(struct event_context *ev, struct fd_event *fde,
   then operations will use that event context
 */
 struct nbt_dgram_socket *nbt_dgram_socket_init(TALLOC_CTX *mem_ctx, 
-                                             struct event_context *event_ctx)
+                                             struct event_context *event_ctx,
+                                             struct smb_iconv_convenience *iconv_convenience)
 {
        struct nbt_dgram_socket *dgmsock;
        NTSTATUS status;
@@ -187,7 +188,7 @@ struct nbt_dgram_socket *nbt_dgram_socket_init(TALLOC_CTX *mem_ctx,
        dgmsock->send_queue = NULL;
        dgmsock->incoming.handler = NULL;
        dgmsock->mailslot_handlers = NULL;
-       dgmsock->iconv_convenience = lp_iconv_convenience(global_loadparm);
+       dgmsock->iconv_convenience = iconv_convenience;
        
        return dgmsock;
 
index 4645840971c3e36f9db776cb17d791d332097e80..707cca8cc53a7bda769bc9b3956e598fd4ae269a 100644 (file)
@@ -93,7 +93,8 @@ NTSTATUS dgram_set_incoming_handler(struct nbt_dgram_socket *dgmsock,
                                                    struct socket_address *),
                                    void *private);
 struct nbt_dgram_socket *nbt_dgram_socket_init(TALLOC_CTX *mem_ctx, 
-                                              struct event_context *event_ctx);
+                                              struct event_context *event_ctx,
+                                              struct smb_iconv_convenience *);
 
 const char *dgram_mailslot_name(struct nbt_dgram_packet *packet);
 struct dgram_mailslot_handler *dgram_mailslot_find(struct nbt_dgram_socket *dgmsock,
index 606809751eb5fd4ea83efd604298ee5d0531c856..56f931ce191b675578da3ca8f49e93449b95f50b 100644 (file)
@@ -28,6 +28,7 @@
 #include "libcli/libcli.h"
 #include "libcli/resolve/resolve.h"
 #include "libcli/finddcs.h"
+#include "param/param.h"
 
 struct finddcs_state {
        struct composite_context *ctx;
@@ -40,6 +41,8 @@ struct finddcs_state {
        struct nbtd_getdcname r;
        struct nbt_name_status node_status;
 
+       struct smb_iconv_convenience *iconv_convenience;
+
        int num_dcs;
        struct nbt_dc_name *dcs;
        uint16_t nbt_port;
@@ -66,6 +69,7 @@ struct composite_context *finddcs_send(TALLOC_CTX *mem_ctx,
                                       const char *domain_name,
                                       int name_type,
                                       struct dom_sid *domain_sid,
+                                      struct smb_iconv_convenience *iconv_convenience,
                                       struct resolve_context *resolve_ctx,
                                       struct event_context *event_ctx,
                                       struct messaging_context *msg_ctx)
@@ -86,6 +90,7 @@ struct composite_context *finddcs_send(TALLOC_CTX *mem_ctx,
        state->nbt_port = nbt_port;
        state->my_netbios_name = talloc_strdup(state, my_netbios_name);
        state->domain_name = talloc_strdup(state, domain_name);
+       state->iconv_convenience = iconv_convenience;
        if (composite_nomem(state->domain_name, c)) return c;
 
        if (domain_sid) {
@@ -195,7 +200,8 @@ static void fallback_node_status(struct finddcs_state *state)
        state->node_status.in.timeout = 1;
        state->node_status.in.retries = 2;
 
-       nbtsock = nbt_name_socket_init(state, state->ctx->event_ctx);
+       nbtsock = nbt_name_socket_init(state, state->ctx->event_ctx, 
+                                      state->iconv_convenience);
        if (composite_nomem(nbtsock, state->ctx)) return;
        
        name_req = nbt_name_status_send(nbtsock, &state->node_status);
@@ -253,6 +259,7 @@ NTSTATUS finddcs(TALLOC_CTX *mem_ctx,
                 uint16_t nbt_port,
                 const char *domain_name, int name_type, 
                 struct dom_sid *domain_sid,
+                struct smb_iconv_convenience *iconv_convenience,
                 struct resolve_context *resolve_ctx,
                 struct event_context *event_ctx,
                 struct messaging_context *msg_ctx,
@@ -262,7 +269,9 @@ NTSTATUS finddcs(TALLOC_CTX *mem_ctx,
                                                   my_netbios_name,
                                                   nbt_port,
                                                   domain_name, name_type,
-                                                  domain_sid, resolve_ctx,
+                                                  domain_sid, 
+                                                  iconv_convenience,
+                                                  resolve_ctx,
                                                   event_ctx, msg_ctx);
        return finddcs_recv(c, mem_ctx, num_dcs, dcs);
 }
index 239ee1f1614639461b1deb54a606d51cf5e15cbc..bcdedd34409289069b8f014947f28a6c1cf602c4 100644 (file)
@@ -1,6 +1,5 @@
 [SUBSYSTEM::LIBCLI_LDAP]
-PUBLIC_PROTO_HEADER = ldap_proto.h
-PUBLIC_HEADERS = ldap.h
+PRIVATE_PROTO_HEADER = ldap_proto.h
 OBJ_FILES = ldap.o \
                ldap_client.o \
                ldap_bind.o \
@@ -11,8 +10,9 @@ PUBLIC_DEPENDENCIES = LIBSAMBA-ERRORS LIBEVENTS LIBPACKET
 PRIVATE_DEPENDENCIES = LIBCLI_COMPOSITE samba-socket NDR_SAMR LIBTLS ASN1_UTIL \
                                           LDAP_ENCODE LIBNDR LP_RESOLVE gensec
 
+PUBLIC_HEADERS += libcli/ldap/ldap.h
 
 [SUBSYSTEM::LDAP_ENCODE]
-PUBLIC_PROTO_HEADER = ldap_ndr.h
+PRIVATE_PROTO_HEADER = ldap_ndr.h
 OBJ_FILES = ldap_ndr.o
 # FIXME PRIVATE_DEPENDENCIES = LIBLDB
index c95d99db5408b821d3dacd6a8b506ba86c7116d2..bc85d87b895fa6926e301cc9ce15ca38738590bf 100644 (file)
@@ -94,6 +94,7 @@ 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;
index 8bfe746294ef1d99f2ec2e7f835c37d91a752ce4..95a1643efc42e0068c9d7fc30f208c587573f6d5 100644 (file)
@@ -190,7 +190,7 @@ static void nbt_name_socket_recv(struct nbt_name_socket *nbtsock)
        }
 
        /* parse the request */
-       ndr_err = ndr_pull_struct_blob(&blob, packet, lp_iconv_convenience(global_loadparm), packet,
+       ndr_err = ndr_pull_struct_blob(&blob, packet, nbtsock->iconv_convenience, packet,
                                       (ndr_pull_flags_fn_t)ndr_pull_nbt_name_packet);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                status = ndr_map_error2ntstatus(ndr_err);
@@ -309,7 +309,8 @@ static void nbt_name_socket_handler(struct event_context *ev, struct fd_event *f
   then operations will use that event context
 */
 _PUBLIC_ struct nbt_name_socket *nbt_name_socket_init(TALLOC_CTX *mem_ctx, 
-                                            struct event_context *event_ctx)
+                                            struct event_context *event_ctx,
+                                            struct smb_iconv_convenience *iconv_convenience)
 {
        struct nbt_name_socket *nbtsock;
        NTSTATUS status;
@@ -338,6 +339,7 @@ _PUBLIC_ struct nbt_name_socket *nbt_name_socket_init(TALLOC_CTX *mem_ctx,
        nbtsock->num_pending = 0;
        nbtsock->incoming.handler = NULL;
        nbtsock->unexpected.handler = NULL;
+       nbtsock->iconv_convenience = iconv_convenience;
 
        nbtsock->fde = event_add_fd(nbtsock->event_ctx, nbtsock, 
                                    socket_get_fd(nbtsock->sock), 0,
@@ -395,7 +397,7 @@ struct nbt_name_request *nbt_name_request_send(struct nbt_name_socket *nbtsock,
        talloc_set_destructor(req, nbt_name_request_destructor);        
 
        ndr_err = ndr_push_struct_blob(&req->encoded, req, 
-                                      lp_iconv_convenience(global_loadparm),
+                                      req->nbtsock->iconv_convenience,
                                       request,
                                       (ndr_push_flags_fn_t)ndr_push_nbt_name_packet);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) goto failed;
@@ -444,7 +446,7 @@ NTSTATUS nbt_name_reply_send(struct nbt_name_socket *nbtsock,
        }
 
        ndr_err = ndr_push_struct_blob(&req->encoded, req, 
-                                      lp_iconv_convenience(global_loadparm),
+                                      req->nbtsock->iconv_convenience,
                                       request,
                                       (ndr_push_flags_fn_t)ndr_push_nbt_name_packet);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
index 55cb3ef305a8e8f250e57836c09ec4bebcf6fa9b..5a33d9cffc3faecf7a2194d2896acee0a7894674 100644 (file)
@@ -22,6 +22,7 @@
 #include "includes.h"
 #include "libcli/raw/libcliraw.h"
 #include "system/filesys.h"
+#include "param/param.h"
 
 #define SETUP_REQUEST_SESSION(cmd, wct, buflen) do { \
        req = smbcli_request_setup_session(session, cmd, wct, buflen); \
@@ -51,6 +52,9 @@ struct smbcli_session *smbcli_session_init(struct smbcli_transport *transport,
        }
        session->pid = (uint16_t)getpid();
        session->vuid = UID_FIELD_INVALID;
+       session->options.lanman_auth = lp_client_lanman_auth(global_loadparm);
+       session->options.ntlmv2_auth = lp_client_ntlmv2_auth(global_loadparm);
+       session->options.plaintext_auth = lp_client_plaintext_auth(global_loadparm);
        
        capabilities = transport->negotiate.capabilities;
 
index 8fcb8bb48c7e06692ec4f29247c3e774b2907a68..eaa02e10472782f5dfb59938bcbcac75ea504a3d 100644 (file)
@@ -33,6 +33,7 @@ struct sock_connect_state {
        const char *host_name;
        int num_ports;
        uint16_t *ports;
+       const char *socket_options;
        struct smbcli_socket *result;
 };
 
@@ -80,6 +81,7 @@ struct composite_context *smbcli_sock_connect_send(TALLOC_CTX *mem_ctx,
        for (i=0;ports[i];i++) {
                state->ports[i] = atoi(ports[i]);
        }
+       state->socket_options = lp_socket_options(global_loadparm);
 
        ctx = socket_connect_multi_send(state, host_addr,
                                        state->num_ports, state->ports,
@@ -108,7 +110,7 @@ static void smbcli_sock_connect_recv_conn(struct composite_context *ctx)
        if (!composite_is_ok(state->ctx)) return;
 
        state->ctx->status =
-               socket_set_option(sock, lp_socket_options(global_loadparm), NULL);
+               socket_set_option(sock, state->socket_options, NULL);
        if (!composite_is_ok(state->ctx)) return;
 
 
index 7111649fc17450eb6f5f20b2c5d5228dad764593..0578a9eab1ab6c7a20452082324ca7e3a0e1ded2 100644 (file)
@@ -186,6 +186,12 @@ struct smbcli_session {
 
        /* the spnego context if we use extented security */
        struct gensec_security *gensec;
+
+       struct smbcli_session_options {
+               uint_t lanman_auth:1;
+               uint_t ntlmv2_auth:1;
+               uint_t plaintext_auth:1;
+       } options;
 };
 
 /* 
index c8d4ab2df3a77b97dc532b1e070ac0e350e37d2f..2e2eb05397fc64668320f5ef00abdab54fd650ed 100644 (file)
@@ -29,6 +29,7 @@
 struct resolve_bcast_data {
        struct interface *ifaces;
        uint16_t nbt_port;
+       int nbt_timeout;
 };
 
 /**
@@ -62,7 +63,7 @@ struct composite_context *resolve_name_bcast_send(TALLOC_CTX *mem_ctx,
        }
        address_list[count] = NULL;
 
-       c = resolve_name_nbtlist_send(mem_ctx, event_ctx, name, address_list, data->ifaces, data->nbt_port, true, false);
+       c = resolve_name_nbtlist_send(mem_ctx, event_ctx, name, address_list, data->ifaces, data->nbt_port, data->nbt_timeout, true, false);
        talloc_free(address_list);
 
        return c;       
@@ -84,22 +85,25 @@ NTSTATUS resolve_name_bcast(struct nbt_name *name,
                            TALLOC_CTX *mem_ctx,
                            struct interface *ifaces,
                            uint16_t nbt_port,
+                           int nbt_timeout,
                            const char **reply_addr)
 {
        struct resolve_bcast_data *data = talloc(mem_ctx, struct resolve_bcast_data);
        struct composite_context *c;
        data->ifaces = talloc_reference(data, ifaces);
        data->nbt_port = nbt_port;
+       data->nbt_timeout = nbt_timeout;
        
        c = resolve_name_bcast_send(mem_ctx, NULL, data, name);
        return resolve_name_bcast_recv(c, mem_ctx, reply_addr);
 }
 
-bool resolve_context_add_bcast_method(struct resolve_context *ctx, struct interface *ifaces, uint16_t nbt_port)
+bool resolve_context_add_bcast_method(struct resolve_context *ctx, struct interface *ifaces, uint16_t nbt_port, int nbt_timeout)
 {
        struct resolve_bcast_data *data = talloc(ctx, struct resolve_bcast_data);
        data->ifaces = ifaces;
        data->nbt_port = nbt_port;
+       data->nbt_timeout = nbt_timeout;
        return resolve_context_add_method(ctx, resolve_name_bcast_send, resolve_name_bcast_recv, data);
 }
 
@@ -107,5 +111,5 @@ bool resolve_context_add_bcast_method_lp(struct resolve_context *ctx, struct loa
 {
        struct interface *ifaces;
        load_interfaces(ctx, lp_interfaces(lp_ctx), &ifaces);
-       return resolve_context_add_bcast_method(ctx, ifaces, lp_nbt_port(lp_ctx));
+       return resolve_context_add_bcast_method(ctx, ifaces, lp_nbt_port(lp_ctx), lp_parm_int(lp_ctx, NULL, "nbt", "timeout", 1));
 }
index e1452c09d2cc8519d3d73359eeeb0359ad39e60f..887bdd7ecf7376568c5d32b5e95d453c7fb9164f 100644 (file)
@@ -102,6 +102,7 @@ struct composite_context *resolve_name_nbtlist_send(TALLOC_CTX *mem_ctx,
                                                    const char **address_list,
                                                    struct interface *ifaces,
                                                    uint16_t nbt_port,
+                                                   int nbt_timeout,
                                                    bool broadcast,
                                                    bool wins_lookup)
 {
@@ -140,7 +141,8 @@ struct composite_context *resolve_name_nbtlist_send(TALLOC_CTX *mem_ctx,
                return c;
        }
 
-       state->nbtsock = nbt_name_socket_init(state, event_ctx);
+       state->nbtsock = nbt_name_socket_init(state, event_ctx, 
+                                             lp_iconv_convenience(global_loadparm));
        if (composite_nomem(state->nbtsock, c)) return c;
 
        /* count the address_list size */
@@ -161,7 +163,7 @@ struct composite_context *resolve_name_nbtlist_send(TALLOC_CTX *mem_ctx,
 
                state->io_queries[i].in.broadcast   = broadcast;
                state->io_queries[i].in.wins_lookup = wins_lookup;
-               state->io_queries[i].in.timeout     = lp_parm_int(global_loadparm, NULL, "nbt", "timeout", 1);
+               state->io_queries[i].in.timeout     = nbt_timeout;
                state->io_queries[i].in.retries     = 2;
 
                state->queries[i] = nbt_name_query_send(state->nbtsock, &state->io_queries[i]);
@@ -201,12 +203,14 @@ NTSTATUS resolve_name_nbtlist(struct nbt_name *name,
                              const char **address_list,
                              struct interface *ifaces, 
                              uint16_t nbt_port,
+                             int nbt_timeout,
                              bool broadcast, bool wins_lookup,
                              const char **reply_addr)
 {
        struct composite_context *c = resolve_name_nbtlist_send(mem_ctx, NULL, 
                                                                name, address_list, 
                                                                ifaces, nbt_port,
+                                                               nbt_timeout,
                                                                broadcast, wins_lookup);
        return resolve_name_nbtlist_recv(c, mem_ctx, reply_addr);
 }
index 78624ad81aa4d0198fcfa6d661bdbaf4253416d7..3ec180f3322ca0c1f0698b9e95ca1899d85da6be 100644 (file)
@@ -29,6 +29,7 @@ struct resolve_wins_data {
        const char **address_list;
        struct interface *ifaces;
        uint16_t nbt_port;
+       int nbt_timeout;
 };
 
 /**
@@ -42,7 +43,7 @@ struct composite_context *resolve_name_wins_send(
 {
        struct resolve_wins_data *wins_data = talloc_get_type(userdata, struct resolve_wins_data);
        if (wins_data->address_list == NULL) return NULL;
-       return resolve_name_nbtlist_send(mem_ctx, event_ctx, name, wins_data->address_list, wins_data->ifaces, wins_data->nbt_port, false, true);
+       return resolve_name_nbtlist_send(mem_ctx, event_ctx, name, wins_data->address_list, wins_data->ifaces, wins_data->nbt_port, wins_data->nbt_timeout, false, true);
 }
 
 /*
@@ -62,6 +63,7 @@ NTSTATUS resolve_name_wins(struct nbt_name *name,
                            const char **address_list,
                            struct interface *ifaces,
                            uint16_t nbt_port,
+                           int nbt_timeout,
                            const char **reply_addr)
 {
        struct composite_context *c;
@@ -69,16 +71,18 @@ NTSTATUS resolve_name_wins(struct nbt_name *name,
        wins_data->address_list = address_list;
        wins_data->ifaces = ifaces;
        wins_data->nbt_port = nbt_port;
+       wins_data->nbt_timeout = nbt_timeout;
        c = resolve_name_wins_send(mem_ctx, NULL, wins_data, name);
        return resolve_name_wins_recv(c, mem_ctx, reply_addr);
 }
 
-bool resolve_context_add_wins_method(struct resolve_context *ctx, const char **address_list, struct interface *ifaces, uint16_t nbt_port)
+bool resolve_context_add_wins_method(struct resolve_context *ctx, const char **address_list, struct interface *ifaces, uint16_t nbt_port, int nbt_timeout)
 {
        struct resolve_wins_data *wins_data = talloc(ctx, struct resolve_wins_data);
        wins_data->address_list = str_list_copy(wins_data, address_list);
        wins_data->ifaces = talloc_reference(wins_data, ifaces);
        wins_data->nbt_port = nbt_port;
+       wins_data->nbt_timeout = nbt_timeout;
        return resolve_context_add_method(ctx, resolve_name_wins_send, resolve_name_wins_recv,
                                          wins_data);
 }
@@ -87,5 +91,5 @@ bool resolve_context_add_wins_method_lp(struct resolve_context *ctx, struct load
 {
        struct interface *ifaces;
        load_interfaces(ctx, lp_interfaces(lp_ctx), &ifaces);
-       return resolve_context_add_wins_method(ctx, lp_wins_server_list(lp_ctx), ifaces, lp_nbt_port(lp_ctx));
+       return resolve_context_add_wins_method(ctx, lp_wins_server_list(lp_ctx), ifaces, lp_nbt_port(lp_ctx), lp_parm_int(lp_ctx, NULL, "nbt", "timeout", 1));
 }
index e4312794c9236eddfc9935d898c55831970526c3..d8d7481270fbb573367e2fc8c49a171dc2c76fde 100644 (file)
@@ -150,7 +150,7 @@ struct composite_context *smb_composite_fetchfile_send(struct smb_composite_fetc
        state->connect->in.options      = io->in.options;
 
        state->creq = smb_composite_connect_send(state->connect, state, 
-                                                lp_resolve_context(global_loadparm), event_ctx);
+                                                io->in.resolve_ctx, event_ctx);
        if (state->creq == NULL) goto failed;
 
        state->creq->async.private_data = c;
index f5a976958d3a8cd304f75439def05b8478c67f64..75a2a579a26fd2e3db676ad99012a8e89fdac113 100644 (file)
@@ -226,11 +226,11 @@ static NTSTATUS session_setup_nt1(struct composite_context *c,
        DATA_BLOB names_blob = NTLMv2_generate_names_blob(state, lp_iconv_convenience(global_loadparm), session->transport->socket->hostname, lp_workgroup(global_loadparm));
        DATA_BLOB session_key;
        int flags = CLI_CRED_NTLM_AUTH;
-       if (lp_client_lanman_auth(global_loadparm)) {
+       if (session->options.lanman_auth) {
                flags |= CLI_CRED_LANMAN_AUTH;
        }
 
-       if (lp_client_ntlmv2_auth(global_loadparm)) {
+       if (session->options.ntlmv2_auth) {
                flags |= CLI_CRED_NTLMv2_AUTH;
        }
 
@@ -263,7 +263,7 @@ static NTSTATUS session_setup_nt1(struct composite_context *c,
                set_user_session_key(session, &session_key);
                
                data_blob_free(&session_key);
-       } else if (lp_client_plaintext_auth(global_loadparm)) {
+       } else if (session->options.plaintext_auth) {
                state->setup.nt1.in.password1 = data_blob_talloc(state, password, strlen(password));
                state->setup.nt1.in.password2 = data_blob(NULL, 0);
        } else {
@@ -293,11 +293,11 @@ static NTSTATUS session_setup_old(struct composite_context *c,
        DATA_BLOB names_blob = NTLMv2_generate_names_blob(state, lp_iconv_convenience(global_loadparm), session->transport->socket->hostname, lp_workgroup(global_loadparm));
        DATA_BLOB session_key;
        int flags = 0;
-       if (lp_client_lanman_auth(global_loadparm)) {
+       if (session->options.lanman_auth) {
                flags |= CLI_CRED_LANMAN_AUTH;
        }
 
-       if (lp_client_ntlmv2_auth(global_loadparm)) {
+       if (session->options.ntlmv2_auth) {
                flags |= CLI_CRED_NTLMv2_AUTH;
        }
 
@@ -324,7 +324,7 @@ static NTSTATUS session_setup_old(struct composite_context *c,
                set_user_session_key(session, &session_key);
                
                data_blob_free(&session_key);
-       } else if (lp_client_plaintext_auth(global_loadparm)) {
+       } else if (session->options.plaintext_auth) {
                state->setup.old.in.password = data_blob_talloc(state, password, strlen(password));
        } else {
                /* could match windows client and return 'cannot logon from this workstation', but it just confuses everybody */
index 964ffb09367be293fd48edac651fd9c7f541dc8c..e7e131869c95decb5e59583ea823fca05a282e32 100644 (file)
@@ -56,6 +56,7 @@ struct smb_composite_fetchfile {
                const char *workgroup;
                const char *filename;
                struct smbcli_options options;
+               struct resolve_context *resolve_ctx;
        } in;
        struct {
                uint8_t *data;
index 827230b113912af612e2202525864cf2afbe853e..e4e366873f0798057ab08dc5ad2fffa85ccce611 100644 (file)
@@ -46,7 +46,8 @@
 
 /* Function prototypes */
 struct nbt_name_socket *nbt_name_socket_init(TALLOC_CTX *mem_ctx, 
-                                            struct event_context *event_ctx);
+                                            struct event_context *event_ctx,
+                         struct smb_iconv_convenience *iconv_convenience);
 
 enum nbt_name_type {
        NBT_NAME_CLIENT=0x00,
index 6c1b5013592cf30b009a5d9dd6addf4a58af8330..f67e6dd0e3bf666bc86f3867abf6609b52a2cd00 100644 (file)
@@ -2469,12 +2469,13 @@ SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags)
 #define SWIGTYPE_p_p_char swig_types[10]
 #define SWIGTYPE_p_short swig_types[11]
 #define SWIGTYPE_p_signed_char swig_types[12]
-#define SWIGTYPE_p_unsigned_char swig_types[13]
-#define SWIGTYPE_p_unsigned_int swig_types[14]
-#define SWIGTYPE_p_unsigned_long_long swig_types[15]
-#define SWIGTYPE_p_unsigned_short swig_types[16]
-static swig_type_info *swig_types[18];
-static swig_module_info swig_module = {swig_types, 17, 0, 0, 0, 0};
+#define SWIGTYPE_p_smb_iconv_convenience swig_types[13]
+#define SWIGTYPE_p_unsigned_char swig_types[14]
+#define SWIGTYPE_p_unsigned_int swig_types[15]
+#define SWIGTYPE_p_unsigned_long_long swig_types[16]
+#define SWIGTYPE_p_unsigned_short swig_types[17]
+static swig_type_info *swig_types[19];
+static swig_module_info swig_module = {swig_types, 18, 0, 0, 0, 0};
 #define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
 #define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
 
@@ -2918,17 +2919,21 @@ SWIGINTERN PyObject *_wrap_nbt_name_socket_init(PyObject *SWIGUNUSEDPARM(self),
   PyObject *resultobj = 0;
   TALLOC_CTX *arg1 = (TALLOC_CTX *) 0 ;
   struct event_context *arg2 = (struct event_context *) 0 ;
+  struct smb_iconv_convenience *arg3 = (struct smb_iconv_convenience *) 0 ;
   struct nbt_name_socket *result = 0 ;
   void *argp2 = 0 ;
   int res2 = 0 ;
+  void *argp3 = 0 ;
+  int res3 = 0 ;
   PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
   char *  kwnames[] = {
-    (char *) "event_ctx", NULL 
+    (char *) "event_ctx",(char *) "iconv_convenience", NULL 
   };
   
   arg2 = event_context_init(NULL);
   arg1 = NULL;
-  if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|O:nbt_name_socket_init",kwnames,&obj0)) SWIG_fail;
+  if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OO:nbt_name_socket_init",kwnames,&obj0,&obj1)) SWIG_fail;
   if (obj0) {
     res2 = SWIG_ConvertPtr(obj0, &argp2,SWIGTYPE_p_event_context, 0 |  0 );
     if (!SWIG_IsOK(res2)) {
@@ -2936,7 +2941,14 @@ SWIGINTERN PyObject *_wrap_nbt_name_socket_init(PyObject *SWIGUNUSEDPARM(self),
     }
     arg2 = (struct event_context *)(argp2);
   }
-  result = (struct nbt_name_socket *)nbt_name_socket_init(arg1,arg2);
+  if (obj1) {
+    res3 = SWIG_ConvertPtr(obj1, &argp3,SWIGTYPE_p_smb_iconv_convenience, 0 |  0 );
+    if (!SWIG_IsOK(res3)) {
+      SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "nbt_name_socket_init" "', argument " "3"" of type '" "struct smb_iconv_convenience *""'"); 
+    }
+    arg3 = (struct smb_iconv_convenience *)(argp3);
+  }
+  result = (struct nbt_name_socket *)nbt_name_socket_init(arg1,arg2,arg3);
   resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_nbt_name_socket, 0 |  0 );
   return resultobj;
 fail:
@@ -4135,6 +4147,7 @@ static swig_type_info _swigt__p_nbt_name_socket = {"_p_nbt_name_socket", "struct
 static swig_type_info _swigt__p_p_char = {"_p_p_char", "char **", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_short = {"_p_short", "short *|int_least16_t *|int16_t *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_signed_char = {"_p_signed_char", "signed char *|int_least8_t *|int_fast8_t *|int8_t *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_smb_iconv_convenience = {"_p_smb_iconv_convenience", "struct smb_iconv_convenience *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_unsigned_char = {"_p_unsigned_char", "unsigned char *|uint_least8_t *|uint_fast8_t *|uint8_t *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_unsigned_int = {"_p_unsigned_int", "uintptr_t *|uint_least32_t *|uint_fast32_t *|uint32_t *|unsigned int *|uint_fast16_t *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_unsigned_long_long = {"_p_unsigned_long_long", "uint_least64_t *|uint_fast64_t *|uint64_t *|unsigned long long *|uintmax_t *", 0, 0, (void*)0, 0};
@@ -4154,6 +4167,7 @@ static swig_type_info *swig_type_initial[] = {
   &_swigt__p_p_char,
   &_swigt__p_short,
   &_swigt__p_signed_char,
+  &_swigt__p_smb_iconv_convenience,
   &_swigt__p_unsigned_char,
   &_swigt__p_unsigned_int,
   &_swigt__p_unsigned_long_long,
@@ -4173,6 +4187,7 @@ static swig_cast_info _swigc__p_nbt_name_socket[] = {  {&_swigt__p_nbt_name_sock
 static swig_cast_info _swigc__p_p_char[] = {  {&_swigt__p_p_char, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_short[] = {  {&_swigt__p_short, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_signed_char[] = {  {&_swigt__p_signed_char, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_smb_iconv_convenience[] = {  {&_swigt__p_smb_iconv_convenience, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_unsigned_char[] = {  {&_swigt__p_unsigned_char, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_unsigned_int[] = {  {&_swigt__p_unsigned_int, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_unsigned_long_long[] = {  {&_swigt__p_unsigned_long_long, 0, 0, 0},{0, 0, 0, 0}};
@@ -4192,6 +4207,7 @@ static swig_cast_info *swig_cast_initial[] = {
   _swigc__p_p_char,
   _swigc__p_short,
   _swigc__p_signed_char,
+  _swigc__p_smb_iconv_convenience,
   _swigc__p_unsigned_char,
   _swigc__p_unsigned_int,
   _swigc__p_unsigned_long_long,
index d027e883960bb15e50df4465fb4ca99769fb553c..3e7793c0c7113750ad31765e518aed8d878b548e 100644 (file)
@@ -102,7 +102,7 @@ static NTSTATUS wrepl_finish_recv(void *private, DATA_BLOB packet_blob_in)
        blob.length = packet_blob_in.length - 4;
        
        /* we have a full request - parse it */
-       ndr_err = ndr_pull_struct_blob(&blob, req->packet, lp_iconv_convenience(global_loadparm), req->packet,
+       ndr_err = ndr_pull_struct_blob(&blob, req->packet, wrepl_socket->iconv_convenience, req->packet,
                                       (ndr_pull_flags_fn_t)ndr_pull_wrepl_packet);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                NTSTATUS status = ndr_map_error2ntstatus(ndr_err);
@@ -163,7 +163,8 @@ static int wrepl_socket_destructor(struct wrepl_socket *sock)
   operations will use that event context
 */
 struct wrepl_socket *wrepl_socket_init(TALLOC_CTX *mem_ctx, 
-                                      struct event_context *event_ctx)
+                                      struct event_context *event_ctx,
+                                      struct smb_iconv_convenience *iconv_convenience)
 {
        struct wrepl_socket *wrepl_socket;
        NTSTATUS status;
@@ -178,6 +179,8 @@ struct wrepl_socket *wrepl_socket_init(TALLOC_CTX *mem_ctx,
        }
        if (!wrepl_socket->event.ctx) goto failed;
 
+       wrepl_socket->iconv_convenience = iconv_convenience;
+
        status = socket_create("ip", SOCKET_TYPE_STREAM, &wrepl_socket->sock, 0);
        if (!NT_STATUS_IS_OK(status)) goto failed;
 
@@ -308,6 +311,14 @@ static void wrepl_connect_handler(struct composite_context *creq)
        composite_done(result);
 }
 
+const char *wrepl_best_ip(struct loadparm_context *lp_ctx, const char *peer_ip)
+{
+       struct interface *ifaces;
+       load_interfaces(lp_ctx, lp_interfaces(lp_ctx), &ifaces);
+       return iface_best_ip(ifaces, peer_ip);
+}
+
+
 /*
   connect a wrepl_socket to a WINS server
 */
@@ -331,12 +342,6 @@ struct composite_context *wrepl_connect_send(struct wrepl_socket *wrepl_socket,
        state->result           = result;
        state->wrepl_socket     = wrepl_socket;
 
-       if (!our_ip) {
-               struct interface *ifaces;
-               load_interfaces(state, lp_interfaces(global_loadparm), &ifaces);
-               our_ip = iface_best_ip(ifaces, peer_ip);
-       }
-
        us = socket_address_from_strings(state, wrepl_socket->sock->backend_name, 
                                         our_ip, 0);
        if (composite_nomem(us, result)) return result;
@@ -493,7 +498,7 @@ struct wrepl_request *wrepl_request_send(struct wrepl_socket *wrepl_socket,
        }
 
        wrap.packet = *packet;
-       ndr_err = ndr_push_struct_blob(&blob, req, lp_iconv_convenience(global_loadparm), &wrap, 
+       ndr_err = ndr_push_struct_blob(&blob, req, wrepl_socket->iconv_convenience, &wrap, 
                                       (ndr_push_flags_fn_t)ndr_push_wrepl_wrap);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                status = ndr_map_error2ntstatus(ndr_err);
index 52b0bee69e853d84f7f0f7af404ac7090e7550fd..f33e63119d574b5a6a1affe557d7f9e96f20c09f 100644 (file)
@@ -49,6 +49,8 @@ struct wrepl_socket {
 
        /* remember if we need to free the wrepl_socket at the end of wrepl_socket_dead() */
        bool free_skipped;
+
+       struct smb_iconv_convenience *iconv_convenience;
 };
 
 struct wrepl_send_ctrl {
index a72ae5b51fe34152c6fe3186cd069c203dbd3178..c35b7decc4929dca7bb733d3830d4f5cf8ca2444 100644 (file)
@@ -1,9 +1,5 @@
 [SUBSYSTEM::LIBSAMBA-NET]
 PRIVATE_PROTO_HEADER = libnet_proto.h
-PUBLIC_HEADERS = libnet.h libnet_join.h libnet_lookup.h libnet_passwd.h \
-                                libnet_rpc.h libnet_share.h libnet_time.h \
-                                libnet_user.h libnet_site.h libnet_vampire.h \
-                                userinfo.h userman.h
 OBJ_FILES = \
                libnet.o \
                libnet_passwd.o \
@@ -29,6 +25,12 @@ OBJ_FILES = \
                prereq_domain.o
 PUBLIC_DEPENDENCIES = CREDENTIALS dcerpc dcerpc_samr RPC_NDR_LSA RPC_NDR_SRVSVC RPC_NDR_DRSUAPI LIBCLI_COMPOSITE LIBCLI_RESOLVE LIBCLI_FINDDCS LIBCLI_CLDAP LIBCLI_FINDDCS gensec_schannel LIBCLI_AUTH LIBNDR SMBPASSWD
 
+PUBLIC_HEADERS += $(addprefix libnet/, libnet.h libnet_join.h libnet_lookup.h libnet_passwd.h \
+                                libnet_rpc.h libnet_share.h libnet_time.h \
+                                libnet_user.h libnet_site.h libnet_vampire.h \
+                                userinfo.h userman.h)
+
+
 [PYTHON::swig_net]
 PRIVATE_DEPENDENCIES = LIBSAMBA-NET
 SWIG_FILE = net.i
index c9185c749b4bf0181b0a58437a6f1c2f07dfcfa4..c4f9cabb1166411c0284a3a119c7c7e9fc78b9c4 100644 (file)
@@ -747,7 +747,8 @@ static void becomeDC_send_cldap(struct libnet_BecomeDC_state *s)
        s->cldap.io.in.acct_control     = -1;
        s->cldap.io.in.version          = 6;
 
-       s->cldap.sock = cldap_socket_init(s, s->libnet->event_ctx);
+       s->cldap.sock = cldap_socket_init(s, s->libnet->event_ctx, 
+                                         lp_iconv_convenience(s->libnet->lp_ctx));
        if (composite_nomem(s->cldap.sock, c)) return;
 
        req = cldap_netlogon_send(s->cldap.sock, &s->cldap.io);
index 409cc7575b624cf2818f74a4d96f03b57203ada6..cab4d9e73f76173fa48c21a6cb53e08c40e2dbeb 100644 (file)
@@ -197,7 +197,8 @@ struct composite_context* libnet_LookupDCs_send(struct libnet_context *ctx,
 
        c = finddcs_send(mem_ctx, lp_netbios_name(ctx->lp_ctx), lp_nbt_port(ctx->lp_ctx),
                         io->in.domain_name, io->in.name_type,
-                        NULL, ctx->resolve_ctx, ctx->event_ctx, msg_ctx);
+                        NULL, lp_iconv_convenience(ctx->lp_ctx), 
+                        ctx->resolve_ctx, ctx->event_ctx, msg_ctx);
        return c;
 }
 
index 9db949486540f1625430721545b526f4b5db922a..dabd23a5bee7594249327f564ec0f4b7e3673fd5 100644 (file)
@@ -55,7 +55,7 @@ NTSTATUS libnet_FindSite(TALLOC_CTX *ctx, struct libnet_JoinSite *r)
        search.in.acct_control = -1;
        search.in.version = 6;
 
-       cldap = cldap_socket_init(tmp_ctx, NULL);
+       cldap = cldap_socket_init(tmp_ctx, NULL, lp_iconv_convenience(global_loadparm));
        status = cldap_netlogon(cldap, tmp_ctx, &search);
        if (!NT_STATUS_IS_OK(status)) {
                /*
index 415912e34dcd2573b832d43d31fbc0f8bfcd1ce3..5d346ac166fdd0c0df20c31f3fe049f8e81be822 100644 (file)
@@ -267,7 +267,8 @@ static void unbecomeDC_send_cldap(struct libnet_UnbecomeDC_state *s)
        s->cldap.io.in.acct_control     = -1;
        s->cldap.io.in.version          = 6;
 
-       s->cldap.sock = cldap_socket_init(s, s->libnet->event_ctx);
+       s->cldap.sock = cldap_socket_init(s, s->libnet->event_ctx,
+                                         lp_iconv_convenience(s->libnet->lp_ctx));
        if (composite_nomem(s->cldap.sock, c)) return;
 
        req = cldap_netlogon_send(s->cldap.sock, &s->cldap.io);
index d5ccf34a57ac67b8dd8560dec4d4874351acaf7f..678c7a226e601ce96f1c21913bcceb500b18156f 100644 (file)
@@ -534,7 +534,7 @@ static NTSTATUS set_user_changes(TALLOC_CTX *mem_ctx, struct usermod_change *mod
        SET_FIELD_NTTIME(r->in, user, mod, acct_expiry, USERMOD_FIELD_ACCT_EXPIRY);
 
        /* account flags change */
-       SET_FIELD_UINT32(r->in, user, mod, acct_flags, USERMOD_FIELD_ACCT_FLAGS);
+       SET_FIELD_ACCT_FLAGS(r->in, user, mod, acct_flags, USERMOD_FIELD_ACCT_FLAGS);
 
        return NT_STATUS_OK;
 }
index ece06f08fc0b6261b68655fdc413f6a31745771d..94aa38464f649eaf982599d7fe97132ce9381e19 100644 (file)
@@ -91,6 +91,14 @@ struct libnet_ModifyUser {
                mod->fields |= flag; \
        }
 
+#define SET_FIELD_ACCT_FLAGS(new, current, mod, field, flag) \
+       if (new.field) { \
+               if (current->field != new.field) {      \
+                       mod->field = new.field;         \
+                       mod->fields |= flag;            \
+               }                                       \
+       }
+
 
 struct libnet_UserInfo {
        struct {
index 2fdef41b2af308580a735c2dc56f408408650ee2..7abc693960e6369055ff18424603b5ccb285c3ae 100644 (file)
@@ -4,8 +4,7 @@
 VERSION = 0.0.1
 SO_VERSION = 0
 PC_FILE = ndr.pc
-PUBLIC_HEADERS = ndr/libndr.h
-PUBLIC_PROTO_HEADER = ndr/libndr_proto.h
+PRIVATE_PROTO_HEADER = ndr/libndr_proto.h
 OBJ_FILES = \
                ndr/ndr.o \
                ndr/ndr_basic.o \
@@ -16,6 +15,8 @@ PUBLIC_DEPENDENCIES = LIBSAMBA-ERRORS LIBTALLOC LIBSAMBA-UTIL CHARSET EXT_NSL \
 # End SUBSYSTEM LIBNDR
 ################################################
 
+PUBLIC_HEADERS += librpc/ndr/libndr.h
+
 #################################
 # Start BINARY ndrdump
 [BINARY::ndrdump]
@@ -29,11 +30,12 @@ PRIVATE_DEPENDENCIES = \
                POPT_SAMBA \
                NDR_TABLE \
                LIBSAMBA-ERRORS
-MANPAGE = tools/ndrdump.1
 # FIXME: ndrdump shouldn't have to depend on RPC...
 # End BINARY ndrdump
 #################################
 
+MANPAGES += librpc/tools/ndrdump.1
+
 ################################################
 # Start SUBSYSTEM NDR_COMPRESSION
 [SUBSYSTEM::NDR_COMPRESSION]
@@ -46,9 +48,10 @@ PUBLIC_DEPENDENCIES = LIBCOMPRESSION LIBSAMBA-ERRORS LIBNDR
 
 [SUBSYSTEM::NDR_SECURITY]
 OBJ_FILES = gen_ndr/ndr_security.o ndr/ndr_sec_helper.o 
-PUBLIC_HEADERS = gen_ndr/security.h
 PUBLIC_DEPENDENCIES = NDR_MISC LIBSECURITY
 
+PUBLIC_HEADERS += librpc/gen_ndr/security.h
+
 [SUBSYSTEM::NDR_AUDIOSRV]
 OBJ_FILES = gen_ndr/ndr_audiosrv.o
 PUBLIC_DEPENDENCIES = LIBNDR
@@ -79,18 +82,20 @@ PUBLIC_DEPENDENCIES = LIBNDR NDR_SECURITY
 
 [SUBSYSTEM::NDR_MISC]
 OBJ_FILES = gen_ndr/ndr_misc.o ndr/ndr_misc.o
-PUBLIC_HEADERS = gen_ndr/misc.h gen_ndr/ndr_misc.h
 PUBLIC_DEPENDENCIES = LIBNDR
 
+PUBLIC_HEADERS += librpc/gen_ndr/misc.h librpc/gen_ndr/ndr_misc.h
+
 [SUBSYSTEM::NDR_ROT]
 OBJ_FILES = gen_ndr/ndr_rot.o
 PUBLIC_DEPENDENCIES = LIBNDR NDR_ORPC
 
 [SUBSYSTEM::NDR_LSA]
 OBJ_FILES = gen_ndr/ndr_lsa.o
-PUBLIC_HEADERS = gen_ndr/lsa.h
 PUBLIC_DEPENDENCIES = LIBNDR NDR_SECURITY
 
+PUBLIC_HEADERS += librpc/gen_ndr/lsa.h
+
 [SUBSYSTEM::NDR_DFS]
 OBJ_FILES = gen_ndr/ndr_dfs.o
 PUBLIC_DEPENDENCIES = LIBNDR NDR_MISC
@@ -125,9 +130,10 @@ PUBLIC_DEPENDENCIES = LIBNDR NDR_SECURITY
 
 [SUBSYSTEM::NDR_SAMR]
 OBJ_FILES = gen_ndr/ndr_samr.o
-PUBLIC_HEADERS = gen_ndr/samr.h gen_ndr/ndr_samr.h gen_ndr/ndr_samr_c.h
 PUBLIC_DEPENDENCIES = LIBNDR NDR_MISC NDR_LSA NDR_SECURITY
 
+PUBLIC_HEADERS += $(addprefix librpc/, gen_ndr/samr.h gen_ndr/ndr_samr.h gen_ndr/ndr_samr_c.h)
+
 [SUBSYSTEM::NDR_NFS4ACL]
 OBJ_FILES = gen_ndr/ndr_nfs4acl.o
 PUBLIC_DEPENDENCIES = LIBNDR NDR_MISC NDR_SECURITY
@@ -150,14 +156,16 @@ PUBLIC_DEPENDENCIES = LIBNDR NDR_SVCCTL NDR_SECURITY
 
 [SUBSYSTEM::NDR_SVCCTL]
 OBJ_FILES = gen_ndr/ndr_svcctl.o
-PUBLIC_HEADERS = gen_ndr/ndr_svcctl.h gen_ndr/svcctl.h
 PUBLIC_DEPENDENCIES = LIBNDR NDR_MISC
 
+PUBLIC_HEADERS += $(addprefix librpc/, gen_ndr/ndr_svcctl.h gen_ndr/svcctl.h)
+
 [SUBSYSTEM::NDR_ATSVC]
 OBJ_FILES = gen_ndr/ndr_atsvc.o
-PUBLIC_HEADERS = gen_ndr/atsvc.h gen_ndr/ndr_atsvc.h
 PUBLIC_DEPENDENCIES = LIBNDR
 
+PUBLIC_HEADERS += $(addprefix librpc/, gen_ndr/atsvc.h gen_ndr/ndr_atsvc.h)
+
 [SUBSYSTEM::NDR_EVENTLOG]
 OBJ_FILES = gen_ndr/ndr_eventlog.o
 PUBLIC_DEPENDENCIES = LIBNDR NDR_LSA
@@ -232,9 +240,10 @@ PUBLIC_DEPENDENCIES = LIBNDR
 
 [SUBSYSTEM::NDR_NETLOGON]
 OBJ_FILES = gen_ndr/ndr_netlogon.o
-PUBLIC_HEADERS = gen_ndr/netlogon.h
 PUBLIC_DEPENDENCIES = LIBNDR NDR_SAMR NDR_LSA NDR_SECURITY
 
+PUBLIC_HEADERS += $(addprefix librpc/, gen_ndr/netlogon.h)
+
 [SUBSYSTEM::NDR_TRKWKS]
 OBJ_FILES = gen_ndr/ndr_trkwks.o
 PUBLIC_DEPENDENCIES = LIBNDR
@@ -265,24 +274,32 @@ PUBLIC_DEPENDENCIES = LIBNDR NDR_NBT
 
 [SUBSYSTEM::NDR_NBT]
 OBJ_FILES = gen_ndr/ndr_nbt.o
-PUBLIC_HEADERS = gen_ndr/nbt.h
 PUBLIC_DEPENDENCIES = LIBNDR NDR_MISC NDR_NBT_BUF NDR_SVCCTL NDR_SECURITY
 
+PUBLIC_HEADERS += librpc/gen_ndr/nbt.h
+
 [SUBSYSTEM::NDR_WINSREPL]
 OBJ_FILES = gen_ndr/ndr_winsrepl.o
 PUBLIC_DEPENDENCIES = LIBNDR NDR_NBT
 
 [SUBSYSTEM::NDR_WINBIND]
 OBJ_FILES = gen_ndr/ndr_winbind.o
-PUBLIC_HEADERS = gen_ndr/winbind.h
 PUBLIC_DEPENDENCIES = LIBNDR NDR_NETLOGON
 
-mkinclude ../heimdal_build/perl_path_wrapper.sh ../librpc/idl-deps.pl librpc/idl/*.idl|
+PUBLIC_HEADERS += librpc/gen_ndr/winbind.h
+
+librpc/idl-deps:
+       ./librpc/idl-deps.pl librpc/idl/*.idl >$@
+
+clean:: 
+       rm -f librpc/idl-deps
+
+include librpc/idl-deps
 
 librpc/gen_ndr/tables.c: $(IDL_NDR_PARSE_H_FILES)
-       @echo Generating librpc/gen_ndr/tables.c
-       @$(PERL) $(srcdir)/librpc/tables.pl --output=librpc/gen_ndr/tables.c $(IDL_NDR_PARSE_H_FILES) > librpc/gen_ndr/tables.x
-       mv librpc/gen_ndr/tables.x librpc/gen_ndr/tables.c
+       @echo Generating $@
+       @$(PERL) $(srcdir)/librpc/tables.pl --output=$@ $^ > librpc/gen_ndr/tables.x
+       @mv librpc/gen_ndr/tables.x $@
 
 [SUBSYSTEM::NDR_TABLE]
 OBJ_FILES = ndr/ndr_table.o gen_ndr/tables.o
@@ -364,14 +381,16 @@ PUBLIC_DEPENDENCIES = dcerpc NDR_SRVSVC
 
 [SUBSYSTEM::RPC_NDR_SVCCTL]
 OBJ_FILES = gen_ndr/ndr_svcctl_c.o
-PUBLIC_HEADERS = gen_ndr/ndr_svcctl_c.h
 PUBLIC_DEPENDENCIES = dcerpc NDR_SVCCTL
 
+PUBLIC_HEADERS += librpc/gen_ndr/ndr_svcctl_c.h
+
 [SUBSYSTEM::dcerpc_atsvc]
 OBJ_FILES = gen_ndr/ndr_atsvc_c.o
-PUBLIC_HEADERS = gen_ndr/ndr_atsvc_c.h
 PUBLIC_DEPENDENCIES = dcerpc NDR_ATSVC
 
+PUBLIC_HEADERS += librpc/gen_ndr/ndr_atsvc_c.h
+
 [SUBSYSTEM::RPC_NDR_EVENTLOG]
 OBJ_FILES = gen_ndr/ndr_eventlog_c.o
 PUBLIC_DEPENDENCIES = dcerpc NDR_EVENTLOG
@@ -451,7 +470,8 @@ PUBLIC_DEPENDENCIES = dcerpc NDR_KEYSVC
 [SUBSYSTEM::NDR_DCERPC]
 OBJ_FILES = gen_ndr/ndr_dcerpc.o
 PUBLIC_DEPENDENCIES = LIBNDR NDR_MISC
-PUBLIC_HEADERS = gen_ndr/dcerpc.h gen_ndr/ndr_dcerpc.h
+
+PUBLIC_HEADERS += $(addprefix librpc/, gen_ndr/dcerpc.h gen_ndr/ndr_dcerpc.h)
 
 ################################################
 # Start SUBSYSTEM dcerpc
@@ -459,10 +479,7 @@ PUBLIC_HEADERS = gen_ndr/dcerpc.h gen_ndr/ndr_dcerpc.h
 VERSION = 0.0.1
 SO_VERSION = 0
 PC_FILE = dcerpc.pc
-PUBLIC_HEADERS = rpc/dcerpc.h \
-                       gen_ndr/mgmt.h gen_ndr/ndr_mgmt.h gen_ndr/ndr_mgmt_c.h \
-                       gen_ndr/epmapper.h gen_ndr/ndr_epmapper.h gen_ndr/ndr_epmapper_c.h
-PUBLIC_PROTO_HEADER = rpc/dcerpc_proto.h
+PRIVATE_PROTO_HEADER = rpc/dcerpc_proto.h
 OBJ_FILES = \
                rpc/dcerpc.o \
                rpc/dcerpc_auth.o \
@@ -484,6 +501,11 @@ PUBLIC_DEPENDENCIES = CREDENTIALS
 # End SUBSYSTEM dcerpc
 ################################################
 
+PUBLIC_HEADERS += $(addprefix librpc/, rpc/dcerpc.h \
+                       gen_ndr/mgmt.h gen_ndr/ndr_mgmt.h gen_ndr/ndr_mgmt_c.h \
+                       gen_ndr/epmapper.h gen_ndr/ndr_epmapper.h gen_ndr/ndr_epmapper_c.h)
+
+
 [MODULE::RPC_EJS_ECHO]
 INIT_FUNCTION = ejs_init_rpcecho
 OBJ_FILES = gen_ndr/ndr_echo_ejs.o
index 48bc565fff51212f686b386172c0a5fcb1ae9361..6929e86e61f26e2a7f17e1baf3ffb999d212e9e2 100644 (file)
@@ -42,8 +42,8 @@ import "security.idl";
 
        typedef struct {
                NTSTATUS status;
-               utf8string homedir;
-               utf8string shell;
+               [charset(UTF8),string] uint8 homedir[];
+               [charset(UTF8),string] uint8 shell[];
        } unixinfo_GetPWUidInfo;
 
        /******************/
index b19a5d71604663dea2e386e401d5d3884c939b72..a379398f19772cc7b72c64c9e1038d1aafe35a64 100644 (file)
@@ -351,7 +351,7 @@ static NTSTATUS ncacn_push_request_sign(struct dcerpc_connection *c,
        /* non-signed packets are simpler */
        if (!c->security_state.auth_info || 
            !c->security_state.generic_state) {
-               return ncacn_push_auth(blob, mem_ctx, pkt, c->security_state.auth_info);
+               return ncacn_push_auth(blob, mem_ctx, c->iconv_convenience, pkt, c->security_state.auth_info);
        }
 
        ndr = ndr_push_init_ctx(mem_ctx, c->iconv_convenience);
@@ -750,7 +750,7 @@ struct composite_context *dcerpc_bind_send(struct dcerpc_pipe *p,
        pkt.u.bind.auth_info = data_blob(NULL, 0);
 
        /* construct the NDR form of the packet */
-       c->status = ncacn_push_auth(&blob, c, &pkt,
+       c->status = ncacn_push_auth(&blob, c, p->conn->iconv_convenience, &pkt,
                                    p->conn->security_state.auth_info);
        if (!composite_is_ok(c)) return c;
 
@@ -813,7 +813,7 @@ NTSTATUS dcerpc_auth3(struct dcerpc_connection *c,
        pkt.u.auth3.auth_info = data_blob(NULL, 0);
 
        /* construct the NDR form of the packet */
-       status = ncacn_push_auth(&blob, mem_ctx, &pkt, c->security_state.auth_info);
+       status = ncacn_push_auth(&blob, mem_ctx, c->iconv_convenience, &pkt, c->security_state.auth_info);
        if (!NT_STATUS_IS_OK(status)) {
                return status;
        }
@@ -1646,7 +1646,7 @@ struct composite_context *dcerpc_alter_context_send(struct dcerpc_pipe *p,
        pkt.u.alter.auth_info = data_blob(NULL, 0);
 
        /* construct the NDR form of the packet */
-       c->status = ncacn_push_auth(&blob, mem_ctx, &pkt,
+       c->status = ncacn_push_auth(&blob, mem_ctx, p->conn->iconv_convenience, &pkt,
                                    p->conn->security_state.auth_info);
        if (!composite_is_ok(c)) return c;
 
index 4e5d049d660323293fe394e1c6db988aa5b7baa7..b8128baf43243bc584a3fcd14688346b5a5be49b 100644 (file)
@@ -50,13 +50,14 @@ const struct ndr_interface_call *dcerpc_iface_find_call(const struct ndr_interfa
    push a ncacn_packet into a blob, potentially with auth info
 */
 NTSTATUS ncacn_push_auth(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, 
+                        struct smb_iconv_convenience *iconv_convenience,
                          struct ncacn_packet *pkt,
                          struct dcerpc_auth *auth_info)
 {
        struct ndr_push *ndr;
        enum ndr_err_code ndr_err;
 
-       ndr = ndr_push_init_ctx(mem_ctx, lp_iconv_convenience(global_loadparm));
+       ndr = ndr_push_init_ctx(mem_ctx, iconv_convenience);
        if (!ndr) {
                return NT_STATUS_NO_MEMORY;
        }
index 45426c31ba4353b2a12b99a2ea9b64d07f1ab74e..205a5442092adea2eefec67eb02a38a5e0f8d656 100644 (file)
@@ -73,7 +73,9 @@ NTSTATUS nbtd_dgram_setup(struct nbtd_interface *iface, const char *bind_address
 
        if (strcmp("0.0.0.0", iface->netmask) != 0) {
                /* listen for broadcasts on port 138 */
-               bcast_dgmsock = nbt_dgram_socket_init(iface, nbtsrv->task->event_ctx);
+               bcast_dgmsock = nbt_dgram_socket_init(iface, 
+                                                     nbtsrv->task->event_ctx,
+                                                     lp_iconv_convenience(nbtsrv->task->lp_ctx));
                if (!bcast_dgmsock) {
                        talloc_free(tmp_ctx);
                        return NT_STATUS_NO_MEMORY;
@@ -100,7 +102,8 @@ NTSTATUS nbtd_dgram_setup(struct nbtd_interface *iface, const char *bind_address
        }
 
        /* listen for unicasts on port 138 */
-       iface->dgmsock = nbt_dgram_socket_init(iface, nbtsrv->task->event_ctx);
+       iface->dgmsock = nbt_dgram_socket_init(iface, nbtsrv->task->event_ctx,
+                                              lp_iconv_convenience(nbtsrv->task->lp_ctx));
        if (!iface->dgmsock) {
                talloc_free(tmp_ctx);
                return NT_STATUS_NO_MEMORY;
index 486acfbad535f8a24c7640c6b8f3c86a9d556068..e59475051b4b4c2b03613ef044f57d8966810f0b 100644 (file)
@@ -130,7 +130,7 @@ static NTSTATUS nbtd_add_socket(struct nbtd_server *nbtsrv,
                struct nbt_name_socket *bcast_nbtsock;
 
                /* listen for broadcasts on port 137 */
-               bcast_nbtsock = nbt_name_socket_init(iface, nbtsrv->task->event_ctx);
+               bcast_nbtsock = nbt_name_socket_init(iface, nbtsrv->task->event_ctx, lp_iconv_convenience(nbtsrv->task->lp_ctx));
                if (!bcast_nbtsock) {
                        talloc_free(iface);
                        return NT_STATUS_NO_MEMORY;
@@ -156,7 +156,8 @@ static NTSTATUS nbtd_add_socket(struct nbtd_server *nbtsrv,
        }
 
        /* listen for unicasts on port 137 */
-       iface->nbtsock = nbt_name_socket_init(iface, nbtsrv->task->event_ctx);
+       iface->nbtsock = nbt_name_socket_init(iface, nbtsrv->task->event_ctx, 
+                                             lp_iconv_convenience(nbtsrv->task->lp_ctx));
        if (!iface->nbtsock) {
                talloc_free(iface);
                return NT_STATUS_NO_MEMORY;
index 94d32488eb95487457690b1f7c69565889743381..23aa3fb6687290de637a9941ff64d4b6eb9357af 100644 (file)
@@ -45,6 +45,7 @@ struct notify_context {
        struct notify_array *array;
        int seqnum;
        struct sys_notify_context *sys_notify_ctx;
+       struct smb_iconv_convenience *iconv_convenience;
 };
 
 
@@ -107,6 +108,7 @@ struct notify_context *notify_init(TALLOC_CTX *mem_ctx, struct server_id server,
        notify->messaging_ctx = messaging_ctx;
        notify->list = NULL;
        notify->array = NULL;
+       notify->iconv_convenience = lp_iconv_convenience(lp_ctx);
        notify->seqnum = tdb_get_seqnum(notify->w->tdb);
 
        talloc_set_destructor(notify, notify_destructor);
@@ -171,7 +173,7 @@ static NTSTATUS notify_load(struct notify_context *notify)
        blob.data = dbuf.dptr;
        blob.length = dbuf.dsize;
 
-       ndr_err = ndr_pull_struct_blob(&blob, notify->array, lp_iconv_convenience(global_loadparm),
+       ndr_err = ndr_pull_struct_blob(&blob, notify->array, notify->iconv_convenience,
                                       notify->array,
                                       (ndr_pull_flags_fn_t)ndr_pull_notify_array);
        free(dbuf.dptr);
@@ -220,7 +222,7 @@ static NTSTATUS notify_save(struct notify_context *notify)
        tmp_ctx = talloc_new(notify);
        NT_STATUS_HAVE_NO_MEMORY(tmp_ctx);
 
-       ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, lp_iconv_convenience(global_loadparm), notify->array,
+       ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, notify->iconv_convenience, notify->array,
                                       (ndr_push_flags_fn_t)ndr_push_notify_array);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                talloc_free(tmp_ctx);
@@ -256,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, lp_iconv_convenience(global_loadparm), &ev,
+       ndr_err = ndr_pull_struct_blob(data, tmp_ctx, notify->iconv_convenience, &ev,
                                      (ndr_pull_flags_fn_t)ndr_pull_notify_event);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                talloc_free(tmp_ctx);
@@ -555,7 +557,7 @@ static void notify_send(struct notify_context *notify, struct notify_entry *e,
 
        tmp_ctx = talloc_new(notify);
 
-       ndr_err = ndr_push_struct_blob(&data, tmp_ctx, lp_iconv_convenience(global_loadparm), &ev, (ndr_push_flags_fn_t)ndr_push_notify_event);
+       ndr_err = ndr_push_struct_blob(&data, tmp_ctx, notify->iconv_convenience, &ev, (ndr_push_flags_fn_t)ndr_push_notify_event);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                talloc_free(tmp_ctx);
                return;
index 36144d0406b09a20cb1c1d62f6ce5323e91be0f7..6c1a9c070ae82426afd6d946512d3ae10c149e2b 100644 (file)
@@ -118,9 +118,10 @@ _PUBLIC_ NTSTATUS odb_open_file_pending(struct odb_lock *lck, void *private)
 /*
   remove a opendb entry
 */
-_PUBLIC_ NTSTATUS odb_close_file(struct odb_lock *lck, void *file_handle)
+_PUBLIC_ NTSTATUS odb_close_file(struct odb_lock *lck, void *file_handle,
+                                const char **delete_path)
 {
-       return ops->odb_close_file(lck, file_handle);
+       return ops->odb_close_file(lck, file_handle, delete_path);
 }
 
 
@@ -141,6 +142,14 @@ _PUBLIC_ NTSTATUS odb_rename(struct odb_lock *lck, const char *path)
        return ops->odb_rename(lck, path);
 }
 
+/*
+  get back the path of an open file
+*/
+_PUBLIC_ NTSTATUS odb_get_path(struct odb_lock *lck, const char **path)
+{
+       return ops->odb_get_path(lck, path);
+}
+
 /*
   update delete on close flag on an open file
 */
@@ -154,10 +163,9 @@ _PUBLIC_ NTSTATUS odb_set_delete_on_close(struct odb_lock *lck, bool del_on_clos
   people still have the file open
 */
 _PUBLIC_ NTSTATUS odb_get_delete_on_close(struct odb_context *odb, 
-                                         DATA_BLOB *key, bool *del_on_close, 
-                                         int *open_count, char **path)
+                                         DATA_BLOB *key, bool *del_on_close)
 {
-       return ops->odb_get_delete_on_close(odb, key, del_on_close, open_count, path);
+       return ops->odb_get_delete_on_close(odb, key, del_on_close);
 }
 
 
index 9591bcf6b9b38817b34cd0262488fabf952d6131..69a7f718ba6d4d14398fbfa415769696eabe71d0 100644 (file)
@@ -32,13 +32,14 @@ struct opendb_ops {
                                  uint32_t open_disposition, bool break_to_none,
                                  uint32_t oplock_level, uint32_t *oplock_granted);
        NTSTATUS (*odb_open_file_pending)(struct odb_lock *lck, void *private);
-       NTSTATUS (*odb_close_file)(struct odb_lock *lck, void *file_handle);
+       NTSTATUS (*odb_close_file)(struct odb_lock *lck, void *file_handle,
+                                  const char **delete_path);
        NTSTATUS (*odb_remove_pending)(struct odb_lock *lck, void *private);
        NTSTATUS (*odb_rename)(struct odb_lock *lck, const char *path);
+       NTSTATUS (*odb_get_path)(struct odb_lock *lck, const char **path);
        NTSTATUS (*odb_set_delete_on_close)(struct odb_lock *lck, bool del_on_close);
        NTSTATUS (*odb_get_delete_on_close)(struct odb_context *odb, 
-                                           DATA_BLOB *key, bool *del_on_close, 
-                                           int *open_count, char **path);
+                                           DATA_BLOB *key, bool *del_on_close);
        NTSTATUS (*odb_can_open)(struct odb_lock *lck,
                                 uint32_t stream_id, uint32_t share_access,
                                 uint32_t access_mask, bool delete_on_close,
index fe5a0a886422ac0efa3a5bdf52b79fde12942bc3..47b35f594c61d24b4c9651b18c113dd251ba5d40 100644 (file)
@@ -376,8 +376,26 @@ static NTSTATUS odb_tdb_open_can_internal(struct odb_context *odb,
           exclusive oplocks afterwards. */
        for (i=0;i<file->num_entries;i++) {
                if (file->entries[i].oplock_level == OPLOCK_EXCLUSIVE) {
+                       bool oplock_return = OPLOCK_BREAK_TO_LEVEL_II;
+                       /* if this is an attribute only access
+                        * it doesn't conflict with an EXCLUSIVE oplock
+                        * but we'll not grant the oplock below
+                        */
+                       attrs_only = access_attributes_only(access_mask,
+                                                           open_disposition,
+                                                           break_to_none);
+                       if (attrs_only) {
+                               break;
+                       }
+                       /*
+                        * send an oplock break to the holder of the
+                        * oplock and tell caller to retry later
+                        */
+                       if (break_to_none) {
+                               oplock_return = OPLOCK_BREAK_TO_NONE;
+                       }
                        odb_oplock_break_send(odb, &file->entries[i],
-                                             OPLOCK_BREAK_TO_NONE);
+                                             oplock_return);
                        return NT_STATUS_OPLOCK_NOT_GRANTED;
                }
        }
@@ -449,8 +467,8 @@ static NTSTATUS odb_tdb_open_file(struct odb_lock *lck,
                                e.oplock_level  = OPLOCK_EXCLUSIVE;
                                *oplock_granted = EXCLUSIVE_OPLOCK_RETURN;
                        } else {
-                               e.oplock_level  = OPLOCK_NONE;
-                               *oplock_granted = NO_OPLOCK_RETURN;
+                               e.oplock_level  = OPLOCK_LEVEL_II;
+                               *oplock_granted = LEVEL_II_OPLOCK_RETURN;
                        }
                } else if (oplock_level == OPLOCK_BATCH) {
                        if (file.num_entries == 0) {
@@ -509,10 +527,12 @@ static NTSTATUS odb_tdb_open_file_pending(struct odb_lock *lck, void *private)
 /*
   remove a opendb entry
 */
-static NTSTATUS odb_tdb_close_file(struct odb_lock *lck, void *file_handle)
+static NTSTATUS odb_tdb_close_file(struct odb_lock *lck, void *file_handle,
+                                  const char **_delete_path)
 {
        struct odb_context *odb = lck->odb;
        struct opendb_file file;
+       const char *delete_path = NULL;
        int i;
        NTSTATUS status;
 
@@ -548,7 +568,16 @@ static NTSTATUS odb_tdb_close_file(struct odb_lock *lck, void *file_handle)
        file.num_pending = 0;
 
        file.num_entries--;
-       
+
+       if (file.num_entries == 0 && file.delete_on_close) {
+               delete_path = talloc_strdup(lck, file.path);
+               NT_STATUS_HAVE_NO_MEMORY(delete_path);
+       }
+
+       if (_delete_path) {
+               *_delete_path = delete_path;
+       }
+
        return odb_push_record(lck, &file);
 }
 
@@ -684,6 +713,25 @@ static NTSTATUS odb_tdb_rename(struct odb_lock *lck, const char *path)
        return odb_push_record(lck, &file);
 }
 
+/*
+  get the path of an open file
+*/
+static NTSTATUS odb_tdb_get_path(struct odb_lock *lck, const char **path)
+{
+       struct opendb_file file;
+       NTSTATUS status;
+
+       *path = NULL;
+
+       status = odb_pull_record(lck, &file);
+       /* we don't ignore NT_STATUS_OBJECT_NAME_NOT_FOUND here */
+       NT_STATUS_NOT_OK_RETURN(status);
+
+       *path = file.path;
+
+       return NT_STATUS_OK;
+}
+
 /*
   update delete on close flag on an open file
 */
@@ -705,20 +753,20 @@ static NTSTATUS odb_tdb_set_delete_on_close(struct odb_lock *lck, bool del_on_cl
   people still have the file open
 */
 static NTSTATUS odb_tdb_get_delete_on_close(struct odb_context *odb, 
-                                           DATA_BLOB *key, bool *del_on_close, 
-                                           int *open_count, char **path)
+                                           DATA_BLOB *key, bool *del_on_close)
 {
        NTSTATUS status;
        struct opendb_file file;
        struct odb_lock *lck;
 
+       (*del_on_close) = false;
+
        lck = odb_lock(odb, odb, key);
        NT_STATUS_HAVE_NO_MEMORY(lck);
 
        status = odb_pull_record(lck, &file);
        if (NT_STATUS_EQUAL(NT_STATUS_OBJECT_NAME_NOT_FOUND, status)) {
                talloc_free(lck);
-               (*del_on_close) = false;
                return NT_STATUS_OK;
        }
        if (!NT_STATUS_IS_OK(status)) {
@@ -727,16 +775,6 @@ static NTSTATUS odb_tdb_get_delete_on_close(struct odb_context *odb,
        }
 
        (*del_on_close) = file.delete_on_close;
-       if (open_count != NULL) {
-               (*open_count) = file.num_entries;
-       }
-       if (path != NULL) {
-               *path = talloc_strdup(odb, file.path);
-               NT_STATUS_HAVE_NO_MEMORY(*path);
-               if (file.num_entries == 1 && file.entries[0].delete_on_close) {
-                       (*del_on_close) = true;
-               }
-       }
 
        talloc_free(lck);
 
@@ -783,6 +821,7 @@ static const struct opendb_ops opendb_tdb_ops = {
        .odb_close_file          = odb_tdb_close_file,
        .odb_remove_pending      = odb_tdb_remove_pending,
        .odb_rename              = odb_tdb_rename,
+       .odb_get_path            = odb_tdb_get_path,
        .odb_set_delete_on_close = odb_tdb_set_delete_on_close,
        .odb_get_delete_on_close = odb_tdb_get_delete_on_close,
        .odb_can_open            = odb_tdb_can_open,
index dbc1a4c2770fd76f14df10f4b28a12d0289f76fa..0f8e88eaa6b6a6a645a77e63aa5d422dc5345abe 100644 (file)
@@ -80,13 +80,14 @@ OBJ_FILES = \
 ################################################
 # Start SUBSYSTEM NTVFS
 [SUBSYSTEM::ntvfs]
-PUBLIC_HEADERS = ntvfs.h
 PRIVATE_PROTO_HEADER = ntvfs_proto.h
 OBJ_FILES = \
                ntvfs_base.o \
                ntvfs_generic.o \
                ntvfs_interface.o \
                ntvfs_util.o
+
+PUBLIC_HEADERS += ntvfs/ntvfs.h
 #
 # End SUBSYSTEM NTVFS
 ################################################
index a01352f60cff54cf5064e5d9d850d85e799b5edf..adf4c1ac185080f4a8f7a7d629aeea9dd6e29de9 100644 (file)
@@ -50,29 +50,10 @@ struct pvfs_file *pvfs_find_fd(struct pvfs_state *pvfs,
 */
 static int pvfs_dir_handle_destructor(struct pvfs_file_handle *h)
 {
-       int open_count;
-       char *path = NULL;
-
-       if (h->name->stream_name == NULL && 
-           pvfs_delete_on_close_set(h->pvfs, h, &open_count, &path) &&
-           open_count == 1) {
-               NTSTATUS status;
-               status = pvfs_xattr_unlink_hook(h->pvfs, path);
-               if (!NT_STATUS_IS_OK(status)) {
-                       DEBUG(0,("Warning: xattr unlink hook failed for '%s' - %s\n",
-                                path, nt_errstr(status)));
-               }
-               if (rmdir(path) != 0) {
-                       DEBUG(0,("pvfs_dir_handle_destructor: failed to rmdir '%s' - %s\n", 
-                                path, strerror(errno)));
-               }
-       }
-
-       talloc_free(path);
-
        if (h->have_opendb_entry) {
                struct odb_lock *lck;
                NTSTATUS status;
+               const char *delete_path = NULL;
 
                lck = odb_lock(h, h->pvfs->odb_context, &h->odb_locking_key);
                if (lck == NULL) {
@@ -80,12 +61,24 @@ static int pvfs_dir_handle_destructor(struct pvfs_file_handle *h)
                        return 0;
                }
 
-               status = odb_close_file(lck, h);
+               status = odb_close_file(lck, h, &delete_path);
                if (!NT_STATUS_IS_OK(status)) {
-                       DEBUG(0,("Unable to remove opendb entry for '%s' - %s\n", 
+                       DEBUG(0,("Unable to remove opendb entry for '%s' - %s\n",
                                 h->name->full_name, nt_errstr(status)));
                }
 
+               if (h->name->stream_name == NULL && delete_path) {
+                       status = pvfs_xattr_unlink_hook(h->pvfs, delete_path);
+                       if (!NT_STATUS_IS_OK(status)) {
+                               DEBUG(0,("Warning: xattr unlink hook failed for '%s' - %s\n",
+                                        delete_path, nt_errstr(status)));
+                       }
+                       if (rmdir(delete_path) != 0) {
+                               DEBUG(0,("pvfs_dir_handle_destructor: failed to rmdir '%s' - %s\n",
+                                        delete_path, strerror(errno)));
+                       }
+               }
+
                talloc_free(lck);
        }
 
@@ -151,8 +144,8 @@ static NTSTATUS pvfs_open_setup_eas_acl(struct pvfs_state *pvfs,
   form the lock context used for opendb locking. Note that we must
   zero here to take account of possible padding on some architectures
 */
-static NTSTATUS pvfs_locking_key(struct pvfs_filename *name, 
-                                TALLOC_CTX *mem_ctx, DATA_BLOB *key)
+NTSTATUS pvfs_locking_key(struct pvfs_filename *name,
+                         TALLOC_CTX *mem_ctx, DATA_BLOB *key)
 {
        struct {
                dev_t device;
@@ -410,9 +403,6 @@ cleanup_delete:
 */
 static int pvfs_handle_destructor(struct pvfs_file_handle *h)
 {
-       int open_count;
-       char *path = NULL;
-
        /* the write time is no longer sticky */
        if (h->sticky_write_time) {
                NTSTATUS status;
@@ -441,32 +431,10 @@ static int pvfs_handle_destructor(struct pvfs_file_handle *h)
                h->fd = -1;
        }
 
-       if (h->name->stream_name == NULL && 
-           h->open_completed &&
-           pvfs_delete_on_close_set(h->pvfs, h, &open_count, &path) &&
-           open_count == 1) {
-               NTSTATUS status;
-               status = pvfs_xattr_unlink_hook(h->pvfs, path);
-               if (!NT_STATUS_IS_OK(status)) {
-                       DEBUG(0,("Warning: xattr unlink hook failed for '%s' - %s\n",
-                                path, nt_errstr(status)));
-               }
-               if (unlink(path) != 0) {
-                       DEBUG(0,("pvfs_close: failed to delete '%s' - %s\n", 
-                                path, strerror(errno)));
-               } else {
-                       notify_trigger(h->pvfs->notify_context, 
-                                      NOTIFY_ACTION_REMOVED, 
-                                      FILE_NOTIFY_CHANGE_FILE_NAME,
-                                      path);
-               }
-       }
-
-       talloc_free(path);
-
        if (h->have_opendb_entry) {
                struct odb_lock *lck;
                NTSTATUS status;
+               const char *delete_path = NULL;
 
                lck = odb_lock(h, h->pvfs->odb_context, &h->odb_locking_key);
                if (lck == NULL) {
@@ -474,12 +442,30 @@ static int pvfs_handle_destructor(struct pvfs_file_handle *h)
                        return 0;
                }
 
-               status = odb_close_file(lck, h);
+               status = odb_close_file(lck, h, &delete_path);
                if (!NT_STATUS_IS_OK(status)) {
                        DEBUG(0,("Unable to remove opendb entry for '%s' - %s\n", 
                                 h->name->full_name, nt_errstr(status)));
                }
 
+               if (h->name->stream_name == NULL &&
+                   h->open_completed && delete_path) {
+                       status = pvfs_xattr_unlink_hook(h->pvfs, delete_path);
+                       if (!NT_STATUS_IS_OK(status)) {
+                               DEBUG(0,("Warning: xattr unlink hook failed for '%s' - %s\n",
+                                        delete_path, nt_errstr(status)));
+                       }
+                       if (unlink(delete_path) != 0) {
+                               DEBUG(0,("pvfs_close: failed to delete '%s' - %s\n",
+                                        delete_path, strerror(errno)));
+                       } else {
+                               notify_trigger(h->pvfs->notify_context,
+                                              NOTIFY_ACTION_REMOVED,
+                                              FILE_NOTIFY_CHANGE_FILE_NAME,
+                                              delete_path);
+                       }
+               }
+
                talloc_free(lck);
        }
 
@@ -574,7 +560,7 @@ static NTSTATUS pvfs_create_file(struct pvfs_state *pvfs,
                status = pvfs_locking_key(parent, req, &locking_key);
                NT_STATUS_NOT_OK_RETURN(status);
                status = odb_get_delete_on_close(pvfs->odb_context, &locking_key, 
-                                                &del_on_close, NULL, NULL);
+                                                &del_on_close);
                NT_STATUS_NOT_OK_RETURN(status);
                if (del_on_close) {
                        return NT_STATUS_DELETE_PENDING;
@@ -1738,14 +1724,13 @@ NTSTATUS pvfs_can_stat(struct pvfs_state *pvfs,
 /*
   determine if delete on close is set on 
 */
-bool pvfs_delete_on_close_set(struct pvfs_state *pvfs, struct pvfs_file_handle *h, 
-                             int *open_count, char **path)
+bool pvfs_delete_on_close_set(struct pvfs_state *pvfs, struct pvfs_file_handle *h)
 {
        NTSTATUS status;
        bool del_on_close;
 
        status = odb_get_delete_on_close(pvfs->odb_context, &h->odb_locking_key, 
-                                        &del_on_close, open_count, path);
+                                        &del_on_close);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(1,("WARNING: unable to determine delete on close status for open file\n"));
                return false;
index 8d23d707a430d11398ec5440fa7ab672c43513f5..6bc21e5e3e90a507b101cc9deb3cdc68e9121564 100644 (file)
@@ -368,7 +368,7 @@ NTSTATUS pvfs_qfileinfo(struct ntvfs_module_context *ntvfs,
        }
 
        /* update the file information */
-       status = pvfs_resolve_name_fd(pvfs, h->fd, h->name);
+       status = pvfs_resolve_name_handle(pvfs, h);
        if (!NT_STATUS_IS_OK(status)) {
                return status;
        }
@@ -380,7 +380,7 @@ NTSTATUS pvfs_qfileinfo(struct ntvfs_module_context *ntvfs,
        switch (info->generic.level) {
        case RAW_FILEINFO_STANDARD_INFO:
        case RAW_FILEINFO_STANDARD_INFORMATION:
-               if (pvfs_delete_on_close_set(pvfs, h, NULL, NULL)) {
+               if (pvfs_delete_on_close_set(pvfs, h)) {
                        info->standard_info.out.delete_pending = 1;
                        info->standard_info.out.nlink--;
                }
@@ -388,7 +388,7 @@ NTSTATUS pvfs_qfileinfo(struct ntvfs_module_context *ntvfs,
 
        case RAW_FILEINFO_ALL_INFO:
        case RAW_FILEINFO_ALL_INFORMATION:
-               if (pvfs_delete_on_close_set(pvfs, h, NULL, NULL)) {
+               if (pvfs_delete_on_close_set(pvfs, h)) {
                        info->all_info.out.delete_pending = 1;
                        info->all_info.out.nlink--;
                }
@@ -407,7 +407,7 @@ NTSTATUS pvfs_qfileinfo(struct ntvfs_module_context *ntvfs,
                break;
 
        case RAW_FILEINFO_SMB2_ALL_INFORMATION:
-               if (pvfs_delete_on_close_set(pvfs, h, NULL, NULL)) {
+               if (pvfs_delete_on_close_set(pvfs, h)) {
                        info->all_info2.out.delete_pending = 1;
                        info->all_info2.out.nlink--;
                }
index 5693e793141c7e51854092e5085eb34037bb66ab..29b2d030059a2ca5e8a110de8c0cc559308e2f7f 100644 (file)
 /*
   do a file rename, and send any notify triggers
 */
-NTSTATUS pvfs_do_rename(struct pvfs_state *pvfs, const struct pvfs_filename *name1, 
+NTSTATUS pvfs_do_rename(struct pvfs_state *pvfs,
+                       struct odb_lock *lck,
+                       const struct pvfs_filename *name1,
                        const char *name2)
 {
        const char *r1, *r2;
        uint32_t mask;
+       NTSTATUS status;
 
        if (rename(name1->full_name, name2) == -1) {
                return pvfs_map_errno(pvfs, errno);
        }
 
+       status = odb_rename(lck, name2);
+       NT_STATUS_NOT_OK_RETURN(status);
+
        if (name1->dos.attrib & FILE_ATTRIBUTE_DIRECTORY) {
                mask = FILE_NOTIFY_CHANGE_DIR_NAME;
        } else {
@@ -134,12 +140,12 @@ static const char *pvfs_resolve_wildcard_component(TALLOC_CTX *mem_ctx,
   resolve a wildcard rename pattern.
 */
 static const char *pvfs_resolve_wildcard(TALLOC_CTX *mem_ctx, 
+                                        struct smb_iconv_convenience *iconv_convenience,
                                         const char *fname, 
                                         const char *pattern)
 {
        const char *base1, *base2;
        const char *ext1, *ext2;
-       struct smb_iconv_convenience *iconv_convenience = lp_iconv_convenience(global_loadparm);
        char *p;
 
        /* break into base part plus extension */
@@ -180,6 +186,84 @@ static const char *pvfs_resolve_wildcard(TALLOC_CTX *mem_ctx,
        return talloc_asprintf(mem_ctx, "%s.%s", base1, ext1);
 }
 
+/*
+  retry an rename after a sharing violation
+*/
+static void pvfs_retry_rename(struct pvfs_odb_retry *r,
+                             struct ntvfs_module_context *ntvfs,
+                             struct ntvfs_request *req,
+                             void *_io,
+                             void *private_data,
+                             enum pvfs_wait_notice reason)
+{
+       union smb_rename *io = talloc_get_type(_io, union smb_rename);
+       NTSTATUS status = NT_STATUS_INTERNAL_ERROR;
+
+       talloc_free(r);
+
+       switch (reason) {
+       case PVFS_WAIT_CANCEL:
+/*TODO*/
+               status = NT_STATUS_CANCELLED;
+               break;
+       case PVFS_WAIT_TIMEOUT:
+               /* if it timed out, then give the failure
+                  immediately */
+/*TODO*/
+               status = NT_STATUS_SHARING_VIOLATION;
+               break;
+       case PVFS_WAIT_EVENT:
+
+               /* try the open again, which could trigger another retry setup
+                  if it wants to, so we have to unmark the async flag so we
+                  will know if it does a second async reply */
+               req->async_states->state &= ~NTVFS_ASYNC_STATE_ASYNC;
+
+               status = pvfs_rename(ntvfs, req, io);
+               if (req->async_states->state & NTVFS_ASYNC_STATE_ASYNC) {
+                       /* the 2nd try also replied async, so we don't send
+                          the reply yet */
+                       return;
+               }
+
+               /* re-mark it async, just in case someone up the chain does
+                  paranoid checking */
+               req->async_states->state |= NTVFS_ASYNC_STATE_ASYNC;
+               break;
+       }
+
+       /* send the reply up the chain */
+       req->async_states->status = status;
+       req->async_states->send_fn(req);
+}
+
+/*
+  setup for a rename retry after a sharing violation
+  or a non granted oplock
+*/
+static NTSTATUS pvfs_rename_setup_retry(struct ntvfs_module_context *ntvfs,
+                                       struct ntvfs_request *req,
+                                       union smb_rename *io,
+                                       struct odb_lock *lck,
+                                       NTSTATUS status)
+{
+       struct pvfs_state *pvfs = ntvfs->private_data;
+       struct timeval end_time;
+
+       if (NT_STATUS_EQUAL(status, NT_STATUS_SHARING_VIOLATION)) {
+               end_time = timeval_add(&req->statistics.request_time,
+                                      0, pvfs->sharing_violation_delay);
+       } else if (NT_STATUS_EQUAL(status, NT_STATUS_OPLOCK_NOT_GRANTED)) {
+               end_time = timeval_add(&req->statistics.request_time,
+                                      pvfs->oplock_break_timeout, 0);
+       } else {
+               return NT_STATUS_INTERNAL_ERROR;
+       }
+
+       return pvfs_odb_retry_setup(ntvfs, req, lck, end_time, io, NULL,
+                                   pvfs_retry_rename);
+}
+
 /*
   rename one file from a wildcard set
 */
@@ -196,7 +280,7 @@ static NTSTATUS pvfs_rename_one(struct pvfs_state *pvfs,
        NTSTATUS status;
 
        /* resolve the wildcard pattern for this name */
-       fname2 = pvfs_resolve_wildcard(mem_ctx, fname1, fname2);
+       fname2 = pvfs_resolve_wildcard(mem_ctx, lp_iconv_convenience(pvfs->ntvfs->ctx->lp_ctx), fname1, fname2);
        if (fname2 == NULL) {
                return NT_STATUS_NO_MEMORY;
        }
@@ -237,11 +321,7 @@ static NTSTATUS pvfs_rename_one(struct pvfs_state *pvfs,
                return NT_STATUS_NO_MEMORY;
        }
 
-       status = pvfs_do_rename(pvfs, name1, fname2);
-
-       if (NT_STATUS_IS_OK(status)) {
-               status = odb_rename(lck, fname2);
-       }
+       status = pvfs_do_rename(pvfs, lck, name1, fname2);
 
 failed:
        talloc_free(mem_ctx);
@@ -354,14 +434,25 @@ static NTSTATUS pvfs_rename_mv(struct ntvfs_module_context *ntvfs,
        }
 
        status = pvfs_can_rename(pvfs, req, name1, &lck);
+       /*
+        * on a sharing violation we need to retry when the file is closed by
+        * the other user, or after 1 second
+        * on a non granted oplock we need to retry when the file is closed by
+        * the other user, or after 30 seconds
+        */
+       if ((NT_STATUS_EQUAL(status, NT_STATUS_SHARING_VIOLATION) ||
+            NT_STATUS_EQUAL(status, NT_STATUS_OPLOCK_NOT_GRANTED)) &&
+           (req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) {
+               return pvfs_rename_setup_retry(pvfs->ntvfs, req, ren, lck, status);
+       }
+
        if (!NT_STATUS_IS_OK(status)) {
-               talloc_free(lck);
                return status;
        }
 
-       status = pvfs_do_rename(pvfs, name1, name2->full_name);
-       if (NT_STATUS_IS_OK(status)) {
-               status = odb_rename(lck, name2->full_name);
+       status = pvfs_do_rename(pvfs, lck, name1, name2->full_name);
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
        }
        
        return NT_STATUS_OK;
@@ -377,6 +468,7 @@ static NTSTATUS pvfs_rename_nt(struct ntvfs_module_context *ntvfs,
        struct pvfs_state *pvfs = ntvfs->private_data;
        NTSTATUS status;
        struct pvfs_filename *name1, *name2;
+       struct odb_lock *lck = NULL;
 
        switch (ren->ntrename.in.flags) {
        case RENAME_FLAG_RENAME:
@@ -422,7 +514,18 @@ static NTSTATUS pvfs_rename_nt(struct ntvfs_module_context *ntvfs,
                return status;
        }
 
-       status = pvfs_can_rename(pvfs, req, name1, NULL);
+       status = pvfs_can_rename(pvfs, req, name1, &lck);
+       /*
+        * on a sharing violation we need to retry when the file is closed by
+        * the other user, or after 1 second
+        * on a non granted oplock we need to retry when the file is closed by
+        * the other user, or after 30 seconds
+        */
+       if ((NT_STATUS_EQUAL(status, NT_STATUS_SHARING_VIOLATION) ||
+            NT_STATUS_EQUAL(status, NT_STATUS_OPLOCK_NOT_GRANTED)) &&
+           (req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) {
+               return pvfs_rename_setup_retry(pvfs->ntvfs, req, ren, lck, status);
+       }
        if (!NT_STATUS_IS_OK(status)) {
                return status;
        }
@@ -431,7 +534,7 @@ static NTSTATUS pvfs_rename_nt(struct ntvfs_module_context *ntvfs,
        case RENAME_FLAG_RENAME:
                status = pvfs_access_check_parent(pvfs, req, name2, SEC_DIR_ADD_FILE);
                NT_STATUS_NOT_OK_RETURN(status);
-               status = pvfs_do_rename(pvfs, name1, name2->full_name);
+               status = pvfs_do_rename(pvfs, lck, name1, name2->full_name);
                NT_STATUS_NOT_OK_RETURN(status);
                break;
 
index cf74816391ebeebbe7abb08682448cf82807a804..325bc74f8f00180cc764747bcc60d61509284e1b 100644 (file)
@@ -265,8 +265,15 @@ static NTSTATUS pvfs_unix_path(struct pvfs_state *pvfs, const char *cifs_name,
                                   of a name */
                                return NT_STATUS_ILLEGAL_CHARACTER;
                        }
-                       if (p > p_start && p[1] == 0) {
-                               *p = 0;
+                       if (p > p_start && (p[1] == '\\' || p[1] == '\0')) {
+                               /* see if it is definately a "\\" or
+                                * a trailing "\". If it is then fail here,
+                                * and let the next layer up try again after
+                                * pvfs_reduce_name() if it wants to. This is
+                                * much more efficient on average than always
+                                * scanning for these separately
+                                */
+                               return NT_STATUS_OBJECT_PATH_SYNTAX_BAD;
                        } else {
                                *p = '/';
                        }
@@ -329,14 +336,15 @@ static NTSTATUS pvfs_unix_path(struct pvfs_state *pvfs, const char *cifs_name,
   reduce a name that contains .. components or repeated \ separators
   return NULL if it can't be reduced
 */
-static NTSTATUS pvfs_reduce_name(TALLOC_CTX *mem_ctx, const char **fname, uint_t flags)
+static NTSTATUS pvfs_reduce_name(TALLOC_CTX *mem_ctx, 
+                                struct smb_iconv_convenience *iconv_convenience, 
+                                const char **fname, uint_t flags)
 {
        codepoint_t c;
        size_t c_size, len;
        int i, num_components, err_count;
        char **components;
        char *p, *s, *ret;
-       struct smb_iconv_convenience *iconv_convenience = lp_iconv_convenience(global_loadparm);
 
        s = talloc_strdup(mem_ctx, *fname);
        if (s == NULL) return NT_STATUS_NO_MEMORY;
@@ -398,7 +406,7 @@ static NTSTATUS pvfs_reduce_name(TALLOC_CTX *mem_ctx, const char **fname, uint_t
                if (ISDOTDOT(components[i])) {
                        if (i < 1) return NT_STATUS_OBJECT_PATH_SYNTAX_BAD;
                        memmove(&components[i-1], &components[i+1], 
-                               sizeof(char *)*(num_components-(i+1)));
+                               sizeof(char *)*(num_components-i));
                        i -= 2;
                        continue;
                }
@@ -471,7 +479,7 @@ NTSTATUS pvfs_resolve_name(struct pvfs_state *pvfs, TALLOC_CTX *mem_ctx,
 
        if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_PATH_SYNTAX_BAD)) {
                /* it might contain .. components which need to be reduced */
-               status = pvfs_reduce_name(*name, &cifs_name, flags);
+               status = pvfs_reduce_name(*name, lp_iconv_convenience(pvfs->ntvfs->ctx->lp_ctx), &cifs_name, flags);
                if (!NT_STATUS_IS_OK(status)) {
                        return status;
                }
@@ -615,6 +623,86 @@ NTSTATUS pvfs_resolve_name_fd(struct pvfs_state *pvfs, int fd,
        return pvfs_fill_dos_info(pvfs, name, fd);
 }
 
+/*
+  fill in the pvfs_filename info for an open file, given the current
+  info for a (possibly) non-open file. This is used by places that need
+  to update the pvfs_filename stat information, and the path
+  after a possible rename on a different handle.
+*/
+NTSTATUS pvfs_resolve_name_handle(struct pvfs_state *pvfs,
+                                 struct pvfs_file_handle *h)
+{
+       NTSTATUS status;
+
+       if (h->have_opendb_entry) {
+               struct odb_lock *lck;
+               const char *name = NULL;
+
+               lck = odb_lock(h, h->pvfs->odb_context, &h->odb_locking_key);
+               if (lck == NULL) {
+                       DEBUG(0,("%s: failed to lock file '%s' in opendb\n",
+                                __FUNCTION__, h->name->full_name));
+                       /* we were supposed to do a blocking lock, so something
+                          is badly wrong! */
+                       return NT_STATUS_INTERNAL_DB_CORRUPTION;
+               }
+
+               status = odb_get_path(lck, &name);
+               if (NT_STATUS_IS_OK(status)) {
+                       /*
+                        * This relies an the fact that
+                        * renames of open files are only
+                        * allowed by setpathinfo() and setfileinfo()
+                        * and there're only renames within the same
+                        * directory supported
+                        */
+                       if (strcmp(h->name->full_name, name) != 0) {
+                               const char *orig_dir;
+                               const char *new_file;
+                               const char *new_orig;
+                               char *delim;
+
+                               delim = strrchr(name, '/');
+                               if (!delim) {
+                                       talloc_free(lck);
+                                       return NT_STATUS_INTERNAL_ERROR;
+                               }
+
+                               new_file = delim + 1;
+                               delim = strrchr(h->name->original_name, '\\');
+                               if (delim) {
+                                       delim[0] = '\0';
+                                       orig_dir = h->name->original_name;
+                                       new_orig = talloc_asprintf(h->name, "%s\\%s",
+                                                                  orig_dir, new_file);
+                                       if (!new_orig) {
+                                               talloc_free(lck);
+                                               return NT_STATUS_NO_MEMORY;
+                                       }
+                               } else {
+                                       new_orig = talloc_strdup(h->name, new_file);
+                                       if (!new_orig) {
+                                               talloc_free(lck);
+                                               return NT_STATUS_NO_MEMORY;
+                                       }
+                               }
+
+                               talloc_free(h->name->original_name);
+                               talloc_free(h->name->full_name);
+                               h->name->full_name = talloc_steal(h->name, name);
+                               h->name->original_name = new_orig;
+                       }
+               }
+
+               talloc_free(lck);
+       }
+
+       status = pvfs_resolve_name_fd(pvfs, h->fd, h->name);
+       NT_STATUS_NOT_OK_RETURN(status);
+
+       return NT_STATUS_OK;
+}
+
 
 /*
   resolve the parent of a given name
index da1e31e63904bc397c0cf230c9ea4c8ff2b610cb..ad47fe90c9bf643ae3e01c5a1b64d984e2aca4cc 100644 (file)
@@ -82,11 +82,13 @@ static uint32_t pvfs_setfileinfo_access(union smb_setfileinfo *info)
 static NTSTATUS pvfs_setfileinfo_rename(struct pvfs_state *pvfs, 
                                        struct ntvfs_request *req, 
                                        struct pvfs_filename *name,
+                                       DATA_BLOB *odb_locking_key,
                                        union smb_setfileinfo *info)
 {
        NTSTATUS status;
        struct pvfs_filename *name2;
        char *new_name, *p;
+       struct odb_lock *lck = NULL;
 
        /* renames are only allowed within a directory */
        if (strchr_m(info->rename_information.in.new_name, '\\') &&
@@ -94,11 +96,6 @@ static NTSTATUS pvfs_setfileinfo_rename(struct pvfs_state *pvfs,
                return NT_STATUS_NOT_SUPPORTED;
        }
 
-       if (name->dos.attrib & FILE_ATTRIBUTE_DIRECTORY) {
-               /* don't allow this for now */
-               return NT_STATUS_FILE_IS_A_DIRECTORY;
-       }
-
        /* don't allow stream renames for now */
        if (name->stream_name) {
                return NT_STATUS_INVALID_PARAMETER;
@@ -168,7 +165,15 @@ static NTSTATUS pvfs_setfileinfo_rename(struct pvfs_state *pvfs,
                return status;
        }
 
-       status = pvfs_do_rename(pvfs, name, name2->full_name);
+       lck = odb_lock(req, pvfs->odb_context, odb_locking_key);
+       if (lck == NULL) {
+               DEBUG(0,("Unable to lock opendb for can_stat\n"));
+               return NT_STATUS_INTERNAL_DB_CORRUPTION;
+       }
+
+       status = pvfs_do_rename(pvfs, lck, name, name2->full_name);
+       talloc_free(lck);
+       NT_STATUS_NOT_OK_RETURN(status);
        if (NT_STATUS_IS_OK(status)) {
                name->full_name = talloc_steal(name, name2->full_name);
                name->original_name = talloc_steal(name, name2->original_name);
@@ -289,7 +294,7 @@ NTSTATUS pvfs_setfileinfo(struct ntvfs_module_context *ntvfs,
        }
 
        /* update the file information */
-       status = pvfs_resolve_name_fd(pvfs, h->fd, h->name);
+       status = pvfs_resolve_name_handle(pvfs, h);
        if (!NT_STATUS_IS_OK(status)) {
                return status;
        }
@@ -391,7 +396,8 @@ NTSTATUS pvfs_setfileinfo(struct ntvfs_module_context *ntvfs,
 
        case RAW_SFILEINFO_RENAME_INFORMATION:
        case RAW_SFILEINFO_RENAME_INFORMATION_SMB2:
-               return pvfs_setfileinfo_rename(pvfs, req, h->name, 
+               return pvfs_setfileinfo_rename(pvfs, req, h->name,
+                                              &h->odb_locking_key,
                                               info);
 
        case RAW_SFILEINFO_SEC_DESC:
@@ -565,6 +571,7 @@ NTSTATUS pvfs_setpathinfo(struct ntvfs_module_context *ntvfs,
        uint32_t access_needed;
        uint32_t change_mask = 0;
        struct odb_lock *lck = NULL;
+       DATA_BLOB odb_locking_key;
 
        /* resolve the cifs name to a posix name */
        status = pvfs_resolve_name(pvfs, req, info->generic.in.file.path, 
@@ -696,8 +703,12 @@ NTSTATUS pvfs_setpathinfo(struct ntvfs_module_context *ntvfs,
 
        case RAW_SFILEINFO_RENAME_INFORMATION:
        case RAW_SFILEINFO_RENAME_INFORMATION_SMB2:
-               return pvfs_setfileinfo_rename(pvfs, req, name, 
-                                              info);
+               status = pvfs_locking_key(name, name, &odb_locking_key);
+               NT_STATUS_NOT_OK_RETURN(status);
+               status = pvfs_setfileinfo_rename(pvfs, req, name,
+                                                &odb_locking_key, info);
+               NT_STATUS_NOT_OK_RETURN(status);
+               return NT_STATUS_OK;
 
        case RAW_SFILEINFO_DISPOSITION_INFO:
        case RAW_SFILEINFO_DISPOSITION_INFORMATION:
index 39090bf702af4b05e598b5bcb3180b1407116a31..b66d252a45a8bbe0775d17a5f4fa31f306545e5d 100644 (file)
@@ -140,7 +140,7 @@ _PUBLIC_ NTSTATUS pvfs_xattr_ndr_save(struct pvfs_state *pvfs,
        NTSTATUS status;
        enum ndr_err_code ndr_err;
 
-       ndr_err = ndr_push_struct_blob(&blob, mem_ctx, lp_iconv_convenience(global_loadparm), p, (ndr_push_flags_fn_t)push_fn);
+       ndr_err = ndr_push_struct_blob(&blob, mem_ctx, lp_iconv_convenience(pvfs->ntvfs->ctx->lp_ctx), p, (ndr_push_flags_fn_t)push_fn);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                talloc_free(mem_ctx);
                return ndr_map_error2ntstatus(ndr_err);
index 3fa710415b822c9829b848e9d9b523f69b345cf6..093c15abab6d3a2a9d16bac61a3ed30bfba747af 100644 (file)
@@ -244,11 +244,6 @@ static void inotify_handler(struct event_context *ev, struct fd_event *fde,
 static NTSTATUS inotify_setup(struct sys_notify_context *ctx)
 {
        struct inotify_private *in;
-
-       if (!lp_parm_bool(global_loadparm, NULL, "notify", "inotify", true)) {
-               return NT_STATUS_INVALID_SYSTEM_SERVICE;
-       }
-
        in = talloc(ctx, struct inotify_private);
        NT_STATUS_HAVE_NO_MEMORY(in);
        in->fd = inotify_init();
@@ -339,6 +334,10 @@ static NTSTATUS inotify_watch(struct sys_notify_context *ctx,
        /* maybe setup the inotify fd */
        if (ctx->private_data == NULL) {
                NTSTATUS status;
+               if (!lp_parm_bool(global_loadparm, NULL, "notify", "inotify", true)) {
+                       return NT_STATUS_INVALID_SYSTEM_SERVICE;
+               }
+
                status = inotify_setup(ctx);
                NT_STATUS_NOT_OK_RETURN(status);
        }
index c3f50b13feadc4733881b890d7e66c625dda73df..f43c9d8a1bdb5dea058fdb5bf3151ac01aa00c32 100644 (file)
@@ -6,19 +6,21 @@ OBJ_FILES = loadparm.o \
                        ../lib/version.o
 PUBLIC_DEPENDENCIES = LIBSAMBA-UTIL 
 PRIVATE_DEPENDENCIES = DYNCONFIG LIBREPLACE_EXT CHARSET
-PUBLIC_PROTO_HEADER = proto.h
-PUBLIC_HEADERS = param.h
+PRIVATE_PROTO_HEADER = proto.h
+
+PUBLIC_HEADERS += param/param.h
 
 #################################
 # Start SUBSYSTEM share
 [SUBSYSTEM::share]
-PUBLIC_HEADERS = share.h
-PUBLIC_PROTO_HEADER = share_proto.h
+PRIVATE_PROTO_HEADER = share_proto.h
 OBJ_FILES = share.o
 PRIVATE_DEPENDENCIES = LIBSAMBA-UTIL
 # End SUBSYSTEM share
 #################################
 
+PUBLIC_HEADERS += param/share.h
+
 ################################################
 # Start MODULE share_classic
 [MODULE::share_classic]
index 2327000fc917d1fdb8d4bffd2556e753db294a6d..b86e3ad2342db1003ca812177121633e8e981ed3 100644 (file)
@@ -259,11 +259,8 @@ int param_use(struct loadparm_context *lp_ctx, struct param_context *ctx)
                                struct loadparm_service *service = 
                                                        lp_service(lp_ctx, section->name);
                                if (service == NULL)
-                                       service = lp_add_service(lp_ctx, &sDefault, section->name);
-                               lp_do_service_parameter(lp_ctx, 
-                                                       service,
-                                                       param->key,
-                                                       param->value);
+                                       service = lp_add_service(lp_ctx, lp_default_service(lp_ctx), section->name);
+                               lp_do_service_parameter(lp_ctx, service, param->key, param->value);
                        }
                }
        }
index bad90fc74a975abfa162757f02700fc91b9c27f9..d94ab92ac942aae1c31e87a35cbc817cc8a77017 100644 (file)
@@ -224,44 +224,11 @@ struct loadparm_service
 };
 
 
-/* This is a default service used to prime a services structure */
-struct loadparm_service sDefault = {
-       .szService = NULL,
-       .szPath = NULL,
-       .szCopy = NULL,
-       .szInclude = NULL,
-       .szPrintername = NULL,
-       .szHostsallow = NULL,
-       .szHostsdeny = NULL,
-       .comment = NULL,
-       .volume = NULL,
-       .fstype = NULL,
-       .ntvfs_handler = NULL,
-       .iMaxPrintJobs = 1000,
-       .iMaxConnections = 0,
-       .iCSCPolicy = 0,
-       .bAvailable = true,
-       .bBrowseable = true,
-       .bRead_only = true,
-       .bPrint_ok = false,
-       .bMap_system = false,
-       .bMap_hidden = false,
-       .bMap_archive = true,
-       .bStrictLocking = true,
-       .iCreate_mask = 0744,
-       .iCreate_force_mode = 0000,
-       .iDir_mask = 0755,
-       .iDir_force_mode = 0000,
-       .copymap = NULL,
-       .bMSDfsRoot = false,
-       .bStrictSync = false,
-       .bCIFileSystem = false,
-};
-
 struct loadparm_context *global_loadparm = NULL;
 
 #define NUMPARAMETERS (sizeof(parm_table) / sizeof(struct parm_struct))
 
+
 /* prototypes for the special type handlers */
 static bool handle_include(struct loadparm_context *lp_ctx,
                           const char *pszParmValue, char **ptr);
@@ -521,11 +488,13 @@ static struct parm_struct parm_table[] = {
        {NULL, P_BOOL, P_NONE, 0, NULL, NULL}
 };
 
+
 /* local variables */
 struct loadparm_context {
        const char *szConfigFile;
        struct loadparm_global *globals;
        struct loadparm_service **services;
+       struct loadparm_service *sDefault;
        int iNumServices;
        struct loadparm_service *currentService;
        bool bInGlobalSection;
@@ -540,6 +509,10 @@ struct loadparm_context {
 };
 
 
+struct loadparm_service *lp_default_service(struct loadparm_context *lp_ctx)
+{
+       return lp_ctx->sDefault;
+}
 
 /*
   return the parameter table
@@ -619,15 +592,13 @@ static const char *lp_string(const char *s)
  int fn_name(struct loadparm_context *lp_ctx) {return lp_ctx->globals->var_name;}
 
 #define FN_LOCAL_STRING(fn_name,val) \
- const char *fn_name(struct loadparm_service *service) {return(lp_string((const char *)((service != NULL && service->val != NULL) ? service->val : sDefault.val)));}
-#define FN_LOCAL_CONST_STRING(fn_name,val) \
- const char *fn_name(struct loadparm_service *service) {return (const char *)(service != NULL && service->val != NULL) ? service->val : sDefault.val;}
+ const char *fn_name(struct loadparm_service *service, struct loadparm_service *sDefault) {return(lp_string((const char *)((service != NULL && service->val != NULL) ? service->val : sDefault->val)));}
 #define FN_LOCAL_LIST(fn_name,val) \
- const char **fn_name(struct loadparm_service *service) {return(const char **)(service != NULL && service->val != NULL? service->val : sDefault.val);}
+ const char **fn_name(struct loadparm_service *service, struct loadparm_service *sDefault) {return(const char **)(service != NULL && service->val != NULL? service->val : sDefault->val);}
 #define FN_LOCAL_BOOL(fn_name,val) \
- bool fn_name(struct loadparm_service *service) {return((service != NULL)? service->val : sDefault.val);}
+ bool fn_name(struct loadparm_service *service, struct loadparm_service *sDefault) {return((service != NULL)? service->val : sDefault->val);}
 #define FN_LOCAL_INTEGER(fn_name,val) \
- int fn_name(struct loadparm_service *service) {return((service != NULL)? service->val : sDefault.val);}
+ int fn_name(struct loadparm_service *service, struct loadparm_service *sDefault) {return((service != NULL)? service->v