From 89f4cfb26310d8f44a3727af1bed70b8c52b4e09 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 18 Feb 2008 23:20:08 +0100 Subject: Fix dependency on popt. (This used to be commit dd854adc7a203f18228195a080bfa8075b0cd170) --- source4/torture/config.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source4/torture/config.mk b/source4/torture/config.mk index a1975a6caf..cc9340e6b9 100644 --- a/source4/torture/config.mk +++ b/source4/torture/config.mk @@ -11,7 +11,8 @@ OBJ_FILES = \ PUBLIC_DEPENDENCIES = \ LIBSAMBA-CONFIG \ LIBSAMBA-UTIL \ - LIBTALLOC + LIBTALLOC \ + LIBPOPT [SUBSYSTEM::TORTURE_UTIL] OBJ_FILES = util_smb.o util_provision.o -- cgit From 0f3836238e34f96426ed88cd7dc85a9c0d216188 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 18 Feb 2008 23:27:55 +0100 Subject: Fix local tests. (This used to be commit 60f2eb404628f9903bbb839a9aaead89c7a5736f) --- source4/selftest/samba4_tests.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source4/selftest/samba4_tests.sh b/source4/selftest/samba4_tests.sh index d86c46432e..6beff6f279 100755 --- a/source4/selftest/samba4_tests.sh +++ b/source4/selftest/samba4_tests.sh @@ -50,8 +50,9 @@ plansmbtorturetest() { name=$1 env=$2 shift 2 + other_args="$*" modname=`normalize_testname $name` - cmdline="$VALGRIND $smb4torture $* $name" + cmdline="$VALGRIND $smb4torture $other_args $name" plantest "$modname" "$env" $cmdline } @@ -236,7 +237,7 @@ done # Local tests for t in `$smb4torture --list | grep "^LOCAL-" | xargs`; do - plansmbtorturetest "$t" none $VALGRIND $smb4torture ncalrpc: "$*" + plansmbtorturetest "$t" none ncalrpc: "$*" done if test -f $samba4bindir/tdbtorture -- cgit From 0fbf1de763ed0a90fb9e73c563cf7025c4bffb62 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 19 Feb 2008 09:36:56 +1100 Subject: Explain that these OIDs are DNs Andrew Bartlett (This used to be commit 69af290c91c61cdaf821750d0d2dddf9cb1b8255) --- source4/dsdb/samdb/ldb_modules/normalise.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source4/dsdb/samdb/ldb_modules/normalise.c b/source4/dsdb/samdb/ldb_modules/normalise.c index efc9bb29e8..7e3b63a145 100644 --- a/source4/dsdb/samdb/ldb_modules/normalise.c +++ b/source4/dsdb/samdb/ldb_modules/normalise.c @@ -105,6 +105,7 @@ static int normalise_search_callback(struct ldb_context *ldb, void *context, str if (!attribute) { continue; } + /* Look to see if this attributeSyntax is a DN */ if ((strcmp(attribute->attributeSyntax_oid, "2.5.5.1") != 0) && (strcmp(attribute->attributeSyntax_oid, "2.5.5.7") != 0)) { continue; -- cgit From c455774d9330fc1903a701a2042e29f68b8227f8 Mon Sep 17 00:00:00 2001 From: Julien Kerihuel Date: Tue, 19 Feb 2008 01:55:01 +0100 Subject: Add INCLUDE command to pidl. (This used to be commit 8a8ed4fae849a2cc565a1ff77b2208a4cd6b1edb) --- .../pidl/lib/Parse/Pidl/Wireshark/Conformance.pm | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/source4/pidl/lib/Parse/Pidl/Wireshark/Conformance.pm b/source4/pidl/lib/Parse/Pidl/Wireshark/Conformance.pm index a240bbf9cd..43604cb51a 100644 --- a/source4/pidl/lib/Parse/Pidl/Wireshark/Conformance.pm +++ b/source4/pidl/lib/Parse/Pidl/Wireshark/Conformance.pm @@ -74,6 +74,10 @@ Change description for the specified header field. `field' is the hf name of the Code to insert when generating the specified dissector. @HF@ and @PARAM@ will be substituted. +=item I filename + +Include conformance data from the specified filename in the dissector. + =item I hf_name "true string" "false string" Override the text shown when a bitmap boolean value is enabled or disabled. @@ -331,6 +335,20 @@ sub handle_ett_field push (@{$data->{ett}}, $ett); } +sub handle_include +{ + my $pos = shift @_; + my $data = shift @_; + my $fn = shift @_; + + unless(defined($fn)) { + error($pos, "incomplete INCLUDE command"); + return; + }; + + ReadConformance($fn, $data); +} + my %field_handlers = ( TYPE => \&handle_type, NOEMIT => \&handle_noemit, @@ -343,7 +361,8 @@ my %field_handlers = ( STRIP_PREFIX => \&handle_strip_prefix, PROTOCOL => \&handle_protocol, FIELD_DESCRIPTION => \&handle_fielddescription, - IMPORT => \&handle_import + IMPORT => \&handle_import, + INCLUDE => \&handle_include ); sub ReadConformance($$) -- cgit From 35dd0b0f4ad6ab0d9365d2858b60bf82e4877bda Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 19 Feb 2008 02:02:48 +0100 Subject: Add test for INCLUDE command. (This used to be commit d1aa25249d64513f785430cab7437b5c7ca8db27) --- source4/pidl/lib/Parse/Pidl/Wireshark/Conformance.pm | 4 ++-- source4/pidl/tests/wireshark-conf.pl | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/source4/pidl/lib/Parse/Pidl/Wireshark/Conformance.pm b/source4/pidl/lib/Parse/Pidl/Wireshark/Conformance.pm index 43604cb51a..5c37b4a0c4 100644 --- a/source4/pidl/lib/Parse/Pidl/Wireshark/Conformance.pm +++ b/source4/pidl/lib/Parse/Pidl/Wireshark/Conformance.pm @@ -330,7 +330,7 @@ sub handle_ett_field unless(defined($ett)) { error($pos, "incomplete ETT_FIELD command"); return; - }; + } push (@{$data->{ett}}, $ett); } @@ -344,7 +344,7 @@ sub handle_include unless(defined($fn)) { error($pos, "incomplete INCLUDE command"); return; - }; + } ReadConformance($fn, $data); } diff --git a/source4/pidl/tests/wireshark-conf.pl b/source4/pidl/tests/wireshark-conf.pl index c06ac16de4..9da5c7d1ed 100755 --- a/source4/pidl/tests/wireshark-conf.pl +++ b/source4/pidl/tests/wireshark-conf.pl @@ -5,7 +5,7 @@ use strict; use warnings; -use Test::More tests => 48; +use Test::More tests => 49; use FindBin qw($RealBin); use lib "$RealBin"; use Util; @@ -35,7 +35,6 @@ test_warnings("nofile:1: Unknown command `foobar'\n", test_warnings("nofile:1: incomplete HF_RENAME command\n", sub { parse_conf("HF_RENAME\n"); }); - is_deeply(parse_conf("HF_RENAME foo bar\n")->{hf_renames}->{foo}, { OLDNAME => "foo", NEWNAME => "bar", POS => {FILE => "nofile", LINE => 1}, USED => 0}); @@ -47,6 +46,9 @@ test_warnings("nofile:1: incomplete MANUAL command\n", is_deeply(parse_conf("MANUAL foo\n"), { manual => {foo => 1}}); +test_errors("nofile:1: incomplete INCLUDE command\n", + sub { parse_conf("INCLUDE\n"); } ); + test_warnings("nofile:1: incomplete FIELD_DESCRIPTION command\n", sub { parse_conf("FIELD_DESCRIPTION foo\n"); }); -- cgit From a71c3714323b6dce2fbeea68c2d007c223467f26 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 19 Feb 2008 02:44:31 +0100 Subject: Add framework for Kvm test. (This used to be commit e4efbb2906f4f3876986e21c12b58791c3526bed) --- source4/selftest/selftest.pl | 14 ++++++++--- source4/selftest/target/Kvm.pm | 55 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 source4/selftest/target/Kvm.pm diff --git a/source4/selftest/selftest.pl b/source4/selftest/selftest.pl index aab2ca8f07..b6ce643eb3 100755 --- a/source4/selftest/selftest.pl +++ b/source4/selftest/selftest.pl @@ -13,7 +13,7 @@ selftest - Samba test runner selftest --help -selftest [--srcdir=DIR] [--builddir=DIR] [--target=samba4|samba3|win] [--socket-wrapper] [--quick] [--exclude=FILE] [--include=FILE] [--one] [--prefix=prefix] [--immediate] [--testlist=FILE] [TESTS] +selftest [--srcdir=DIR] [--builddir=DIR] [--target=samba4|samba3|win|kvm] [--socket-wrapper] [--quick] [--exclude=FILE] [--include=FILE] [--one] [--prefix=prefix] [--immediate] [--testlist=FILE] [TESTS] =head1 DESCRIPTION @@ -43,7 +43,7 @@ Change directory to run tests in. Default is 'st'. Show errors as soon as they happen rather than at the end of the test run. -=item I<--target samba4|samba3|win> +=item I<--target samba4|samba3|win|kvm> Specify test target against which to run. Default is 'samba4'. @@ -280,7 +280,7 @@ Usage: $Script [OPTIONS] PREFIX Generic options: --help this help page - --target=samba4|samba3|win Samba version to target + --target=samba[34]|win|kvm Samba version to target --testlist=FILE file to read available tests from Paths: @@ -301,6 +301,9 @@ Samba4 Specific: Samba3 Specific: --bindir=PATH path to binaries +Kvm Specific: + --image=PATH path to KVM image + Behaviour: --quick run quick overall test --one abort when the first test fails @@ -334,6 +337,7 @@ my $result = GetOptions ( 'resetup-environment' => \$opt_resetup_env, 'bindir:s' => \$opt_bindir, 'format=s' => \$opt_format, + 'image=s' => \$opt_image, 'testlist=s' => \@testlists ); @@ -442,6 +446,10 @@ if ($opt_target eq "samba4") { $testenv_default = "dc"; require target::Windows; $target = new Windows(); +} elsif ($opt_target eq "kvm") { + require target::Kvm; + die("No image specified") unless ($opt_image); + $target = new Kvm($opt_image); } sub read_test_regexes($) diff --git a/source4/selftest/target/Kvm.pm b/source4/selftest/target/Kvm.pm new file mode 100644 index 0000000000..533fb302d0 --- /dev/null +++ b/source4/selftest/target/Kvm.pm @@ -0,0 +1,55 @@ +#!/usr/bin/perl +# Start a KVM machine and run a number of tests against it. +# Copyright (C) 2005-2008 Jelmer Vernooij +# Published under the GNU GPL, v3 or later. + +package Kvm; + +use strict; +use Cwd qw(abs_path); +use FindBin qw($RealBin); +use POSIX; + +sub new($$$$) { + my ($classname, $image) = @_; + my $self = { + image => $image + }; + bless $self; + return $self; +} + +sub teardown_env($$) +{ + my ($self, $envvars) = @_; + + return 0; +} + +sub getlog_env($$) +{ + my ($self, $envvars) = @_; + + return ""; +} + +sub check_env($$) +{ + my ($self, $envvars) = @_; + + return 1; +} + +sub setup_env($$$) +{ + my ($self, $envname, $path) = @_; + + die("No implemented yet"); +} + +sub stop($) +{ + my ($self) = @_; +} + +1; -- cgit From 12e08782b3bef67395d9508fed9487d0217174d6 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 19 Feb 2008 03:29:03 +0100 Subject: Add Kvm start code. (This used to be commit 6308c134b225dfa8574aa1370a7874ed6e572ccc) --- source4/selftest/config.mk | 3 +++ source4/selftest/target/Kvm.pm | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/source4/selftest/config.mk b/source4/selftest/config.mk index 7f8f211588..ff470df527 100644 --- a/source4/selftest/config.mk +++ b/source4/selftest/config.mk @@ -10,6 +10,9 @@ SELFTEST = $(LD_LIBPATH_OVERRIDE) $(PERL) $(srcdir)/selftest/selftest.pl --prefi test:: everything $(SELFTEST) $(DEFAULT_TEST_OPTIONS) --immediate $(TESTS) +kvmtest:: everything + $(SELFTEST) $(DEFAULT_TEST_OPTIONS) --target=kvm --image=$(KVM_IMAGE) + testone:: everything $(SELFTEST) $(DEFAULT_TEST_OPTIONS) --one $(TESTS) diff --git a/source4/selftest/target/Kvm.pm b/source4/selftest/target/Kvm.pm index 533fb302d0..efd4fa2f7a 100644 --- a/source4/selftest/target/Kvm.pm +++ b/source4/selftest/target/Kvm.pm @@ -40,16 +40,39 @@ sub check_env($$) return 1; } +sub start($) +{ + my ($self) = @_; + + my $pidfile = "kvm.pid"; + + system("kvm $ENV{KVM_OPTIONS} -daemonize -pidfile $pidfile -net user -vnc unix:kvm.vnc -snapshot $self->{image}"); + + open(PID, $pidfile); + $self->{pid} = ; + close(PID); +} + sub setup_env($$$) { my ($self, $envname, $path) = @_; + if ($envname eq "dc") { + unless (defined($self->{pid})) { + $self->start(); + } + } elsif ($envname eq "member") { + return undef; + } + die("No implemented yet"); } sub stop($) { my ($self) = @_; + + kill $self->{pid}; } 1; -- cgit From 9368ea67cdbb0d1fe5ef2258cc7e8c20c66e6ecd Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 19 Feb 2008 03:57:30 +0100 Subject: Fix CFLAGS (caused problems on hosts without libgssapi installed on the system). (This used to be commit f6760fd161f568ef13a841a0210f130160a16c01) --- source4/build/smb_build/output.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source4/build/smb_build/output.pm b/source4/build/smb_build/output.pm index 83be28e740..ff9afe8e8c 100644 --- a/source4/build/smb_build/output.pm +++ b/source4/build/smb_build/output.pm @@ -185,7 +185,7 @@ sub create_output($$) merge_array(\$part->{FINAL_CFLAGS}, $part->{CPPFLAGS}); merge_array(\$part->{FINAL_CFLAGS}, $part->{CFLAGS}); - foreach (@{$part->{UNIQUE_DEPENDENCIES_COMPILE}}) { + foreach (@{$part->{UNIQUE_DEPENDENCIES_ALL}}) { my $elem = $depend->{$_}; next if $elem == $part; -- cgit From 5842df9d0fb71430d1bcda1c4c748589b38ecb00 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 19 Feb 2008 14:44:10 +1100 Subject: To partially simplfy our gcov handling, move to the new --coverage option. Andrew Bartlett (This used to be commit 7e49f75ee21adec321e0935c9cd4c2a96d7ef6d1) --- source4/torture/config.mk | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/source4/torture/config.mk b/source4/torture/config.mk index 7ab4658dc1..32085400b7 100644 --- a/source4/torture/config.mk +++ b/source4/torture/config.mk @@ -369,21 +369,20 @@ MANPAGE = man/locktest.1 # End BINARY locktest ################################# -GCOV_CFLAGS = -ftest-coverage -fprofile-arcs -GCOV_LDFLAGS = $(GCOV_CFLAGS) -lgcov +GCOV_FLAGS = --coverage COV_TARGET = test COV_VARS = \ - CFLAGS="$(CFLAGS) $(GCOV_CFLAGS)" \ - BNLD_FLAGS="$(BNLD_FLAGS) $(GCOV_LDFLAGS)" \ - SHLD_FLAGS="$(SHLD_FLAGS) $(GCOV_LDFLAGS)" \ - MDLD_FLAGS="$(MDLD_FLAGS) $(GCOV_LDFLAGS)" \ - HOSTCC_FLAGS="$(HOSTCC_FLAGS) $(GCOV_CFLAGS)" \ - HOSTLD_FLAGS="$(HOSTLD_FLAGS) $(GCOV_LDFLAGS)" + CFLAGS="$(CFLAGS) $(GCOV_FLAGS)" \ + BNLD_FLAGS="$(BNLD_FLAGS) $(GCOV_FLAGS)" \ + SHLD_FLAGS="$(SHLD_FLAGS) $(GCOV_FLAGS)" \ + MDLD_FLAGS="$(MDLD_FLAGS) $(GCOV_FLAGS)" \ + HOSTCC_FLAGS="$(HOSTCC_FLAGS) $(GCOV_FLAGS)" \ + HOSTLD_FLAGS="$(HOSTLD_FLAGS) $(GCOV_FLAGS)" test_cov: - @$(MAKE) $(COV_TARGET) $(COV_VARS) + -$(MAKE) $(COV_TARGET) $(COV_VARS) gcov: test_cov for I in $(sort $(dir $(ALL_OBJS))); \ @@ -395,10 +394,12 @@ lcov-split: @$(MAKE) $(COV_TARGET) $(COV_VARS) \ TEST_OPTIONS="--analyse-cmd=\"lcov --base-directory `pwd` --directory . --capture --output-file samba.info -t\"" -rm heimdal/lib/*/{lex,parse}.{gcda,gcno} + -rm lib/policy/*/{lex,parse}.{gcda,gcno} genhtml -o coverage samba.info lcov: test_cov -rm heimdal/lib/*/{lex,parse}.{gcda,gcno} + -rm lib/policy/*/{lex,parse}.{gcda,gcno} lcov --base-directory `pwd` --directory . --capture --output-file samba.info genhtml -o coverage samba.info -- cgit From 33f63de66bb16c4ca96255a17975268a7d958281 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 19 Feb 2008 04:44:30 +0100 Subject: kvm fixes. (This used to be commit 3a5e2f9ba3131a2a264e21640db8bea255fe9ea3) --- source4/selftest/selftest.pl | 1 + source4/selftest/target/Kvm.pm | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/source4/selftest/selftest.pl b/source4/selftest/selftest.pl index b6ce643eb3..8647dee9d2 100755 --- a/source4/selftest/selftest.pl +++ b/source4/selftest/selftest.pl @@ -144,6 +144,7 @@ my $opt_expected_failures = undef; my @opt_exclude = (); my @opt_include = (); my $opt_verbose = 0; +my $opt_image = undef; my $opt_testenv = 0; my $ldap = undef; my $opt_analyse_cmd = undef; diff --git a/source4/selftest/target/Kvm.pm b/source4/selftest/target/Kvm.pm index efd4fa2f7a..74b726d183 100644 --- a/source4/selftest/target/Kvm.pm +++ b/source4/selftest/target/Kvm.pm @@ -46,7 +46,9 @@ sub start($) my $pidfile = "kvm.pid"; - system("kvm $ENV{KVM_OPTIONS} -daemonize -pidfile $pidfile -net user -vnc unix:kvm.vnc -snapshot $self->{image}"); + my $opts = ($ENV{KVM_OPTIONS} or ""); + + system("kvm $opts -daemonize -pidfile $pidfile -vnc unix:kvm.vnc -snapshot $self->{image}"); open(PID, $pidfile); $self->{pid} = ; -- cgit From 4e445f5f70e1a3c73e5e0e5c3f9c0d914e51b1d6 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 19 Feb 2008 13:38:59 +0100 Subject: Fix quicktest. (This used to be commit 668f27bdaad505f0119ed6ad6a7089914c4f3310) --- source4/samba4-quick | 64 ++++++++++++++++++++++++++-------------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/source4/samba4-quick b/source4/samba4-quick index 796435ee16..aec9098854 100644 --- a/source4/samba4-quick +++ b/source4/samba4-quick @@ -1,32 +1,32 @@ -BASE-UNLINK -BASE-ATTR -BASE-DELETE -BASE-TCON -BASE-OPEN -BASE-CHKPATH -RAW-QFSINFO -RAW-QFILEINFO -RAW-SFILEINFO -RAW-MKDIR -RAW-SEEK -RAW-OPEN -RAW-WRITE -RAW-UNLINK -RAW-READ -RAW-CLOSE -RAW-IOCTL -RAW-RENAME -RAW-EAS -RAW-STREAMS -BASE-OPEN -RPC-ALTERCONTEXT -RPC-JOIN -RPC-ECHO -RPC-SCHANNEL -RPC-NETLOGON -RPC-UNIXINFO -RPC-HANDLES -RPC-ALTERCONTEXT -RPC-JOIN -RPC-HANDLES -RPC-ECHO +base.unlink +base.attr +base.delete +base.tcon +base.open +base.chkpath +raw.qfsinfo +raw.qfileinfo +raw.sfileinfo +raw.mkdir +raw.seek +raw.open +raw.write +raw.unlink +raw.read +raw.close +raw.ioctl +raw.rename +raw.eas +raw.streams +base.open +rpc.altercontext +rpc.join +rpc.echo +rpc.schannel +rpc.netlogon +rpc.unixinfo +rpc.handles +rpc.altercontext +rpc.join +rpc.handles +rpc.echo -- cgit From 7d5987c2e035d1661f25294c26e3d81ba44def90 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 19 Feb 2008 13:39:27 +0100 Subject: Remove uses of global_loadparm. (This used to be commit 138aaef0781e0754cc17b3ffdaa6062ba70c0c6a) --- source4/dsdb/schema/schema.h | 2 ++ source4/dsdb/schema/schema_init.c | 14 +++++++------- source4/dsdb/schema/schema_syntax.c | 17 +++++++++-------- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/source4/dsdb/schema/schema.h b/source4/dsdb/schema/schema.h index 1379ddee9f..bb34235465 100644 --- a/source4/dsdb/schema/schema.h +++ b/source4/dsdb/schema/schema.h @@ -149,6 +149,8 @@ struct dsdb_schema { struct dsdb_attribute *attributes; struct dsdb_class *classes; + + struct smb_iconv_convenience *iconv_convenience; }; #include "dsdb/schema/proto.h" diff --git a/source4/dsdb/schema/schema_init.c b/source4/dsdb/schema/schema_init.c index 6a7463951e..bec6d5d9ef 100644 --- a/source4/dsdb/schema/schema_init.c +++ b/source4/dsdb/schema/schema_init.c @@ -88,8 +88,7 @@ WERROR dsdb_load_oid_mappings_ldb(struct dsdb_schema *schema, TALLOC_CTX *mem_ctx = talloc_new(schema); W_ERROR_HAVE_NO_MEMORY(mem_ctx); - ndr_err = ndr_pull_struct_blob(prefixMap, mem_ctx, lp_iconv_convenience(global_loadparm), &pfm, - (ndr_pull_flags_fn_t)ndr_pull_prefixMapBlob); + ndr_err = ndr_pull_struct_blob(prefixMap, mem_ctx, schema->iconv_convenience, &pfm, (ndr_pull_flags_fn_t)ndr_pull_prefixMapBlob); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { NTSTATUS nt_status = ndr_map_error2ntstatus(ndr_err); talloc_free(mem_ctx); @@ -181,8 +180,7 @@ WERROR dsdb_get_oid_mappings_ldb(const struct dsdb_schema *schema, pfm.reserved = 0; pfm.ctr.dsdb = *ctr; - ndr_err = ndr_push_struct_blob(prefixMap, mem_ctx, lp_iconv_convenience(global_loadparm), &pfm, - (ndr_push_flags_fn_t)ndr_push_prefixMapBlob); + ndr_err = ndr_push_struct_blob(prefixMap, mem_ctx, schema->iconv_convenience, &pfm, (ndr_push_flags_fn_t)ndr_push_prefixMapBlob); talloc_free(ctr); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { NTSTATUS nt_status = ndr_map_error2ntstatus(ndr_err); @@ -628,7 +626,7 @@ static struct drsuapi_DsReplicaAttribute *dsdb_find_object_attr_name(struct dsdb } \ if (_a && _a->value_ctr.num_values >= 1) { \ ssize_t _ret; \ - _ret = convert_string_talloc(mem_ctx, lp_iconv_convenience(global_loadparm), CH_UTF16, CH_UNIX, \ + _ret = convert_string_talloc(mem_ctx, s->iconv_convenience, CH_UTF16, CH_UNIX, \ _a->value_ctr.values[0].blob->data, \ _a->value_ctr.values[0].blob->length, \ (void **)discard_const(&(p)->elem)); \ @@ -665,7 +663,7 @@ static struct drsuapi_DsReplicaAttribute *dsdb_find_object_attr_name(struct dsdb struct drsuapi_DsReplicaObjectIdentifier3 _id3; \ enum ndr_err_code _ndr_err; \ _ndr_err = ndr_pull_struct_blob_all(_a->value_ctr.values[0].blob, \ - mem_ctx, lp_iconv_convenience(global_loadparm), &_id3,\ + mem_ctx, s->iconv_convenience, &_id3,\ (ndr_pull_flags_fn_t)ndr_pull_drsuapi_DsReplicaObjectIdentifier3);\ if (!NDR_ERR_CODE_IS_SUCCESS(_ndr_err)) { \ NTSTATUS _nt_status = ndr_map_error2ntstatus(_ndr_err); \ @@ -727,7 +725,7 @@ static struct drsuapi_DsReplicaAttribute *dsdb_find_object_attr_name(struct dsdb && _a->value_ctr.values[0].blob->length == 16) { \ enum ndr_err_code _ndr_err; \ _ndr_err = ndr_pull_struct_blob_all(_a->value_ctr.values[0].blob, \ - mem_ctx, lp_iconv_convenience(global_loadparm), &(p)->elem, \ + mem_ctx, s->iconv_convenience, &(p)->elem, \ (ndr_pull_flags_fn_t)ndr_pull_GUID); \ if (!NDR_ERR_CODE_IS_SUCCESS(_ndr_err)) { \ NTSTATUS _nt_status = ndr_map_error2ntstatus(_ndr_err); \ @@ -1157,6 +1155,8 @@ WERROR dsdb_attach_schema_from_ldif_file(struct ldb_context *ldb, const char *pf goto nomem; } + schema->iconv_convenience = ldb_get_opaque(ldb, "loadparm"); + /* * load the prefixMap attribute from pf */ diff --git a/source4/dsdb/schema/schema_syntax.c b/source4/dsdb/schema/schema_syntax.c index 2c133b6424..beacfc49c2 100644 --- a/source4/dsdb/schema/schema_syntax.c +++ b/source4/dsdb/schema/schema_syntax.c @@ -767,7 +767,8 @@ static WERROR dsdb_syntax_UNICODE_drsuapi_to_ldb(const struct dsdb_schema *schem return WERR_FOOBAR; } - ret = convert_string_talloc(out->values, lp_iconv_convenience(global_loadparm), CH_UTF16, CH_UNIX, + ret = convert_string_talloc(out->values, schema->iconv_convenience, + CH_UTF16, CH_UNIX, in->value_ctr.values[i].blob->data, in->value_ctr.values[i].blob->length, (void **)&str); @@ -809,7 +810,7 @@ static WERROR dsdb_syntax_UNICODE_ldb_to_drsuapi(const struct dsdb_schema *schem out->value_ctr.values[i].blob = &blobs[i]; - ret = convert_string_talloc(blobs, lp_iconv_convenience(global_loadparm), CH_UNIX, CH_UTF16, + ret = convert_string_talloc(blobs, schema->iconv_convenience, CH_UNIX, CH_UTF16, in->values[i].data, in->values[i].length, (void **)&blobs[i].data); @@ -851,7 +852,7 @@ static WERROR dsdb_syntax_DN_drsuapi_to_ldb(const struct dsdb_schema *schema, } ndr_err = ndr_pull_struct_blob_all(in->value_ctr.values[i].blob, - out->values, lp_iconv_convenience(global_loadparm), &id3, + out->values, schema->iconv_convenience, &id3, (ndr_pull_flags_fn_t)ndr_pull_drsuapi_DsReplicaObjectIdentifier3); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { NTSTATUS status = ndr_map_error2ntstatus(ndr_err); @@ -898,7 +899,7 @@ static WERROR dsdb_syntax_DN_ldb_to_drsuapi(const struct dsdb_schema *schema, ZERO_STRUCT(id3); id3.dn = (const char *)in->values[i].data; - ndr_err = ndr_push_struct_blob(&blobs[i], blobs, lp_iconv_convenience(global_loadparm), &id3, (ndr_push_flags_fn_t)ndr_push_drsuapi_DsReplicaObjectIdentifier3); + ndr_err = ndr_push_struct_blob(&blobs[i], blobs, schema->iconv_convenience, &id3, (ndr_push_flags_fn_t)ndr_push_drsuapi_DsReplicaObjectIdentifier3); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { NTSTATUS status = ndr_map_error2ntstatus(ndr_err); return ntstatus_to_werror(status); @@ -939,7 +940,7 @@ static WERROR dsdb_syntax_DN_BINARY_drsuapi_to_ldb(const struct dsdb_schema *sch } ndr_err = ndr_pull_struct_blob_all(in->value_ctr.values[i].blob, - out->values, lp_iconv_convenience(global_loadparm), &id3b, + out->values, schema->iconv_convenience, &id3b, (ndr_pull_flags_fn_t)ndr_pull_drsuapi_DsReplicaObjectIdentifier3Binary); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { NTSTATUS status = ndr_map_error2ntstatus(ndr_err); @@ -997,7 +998,7 @@ static WERROR dsdb_syntax_DN_BINARY_ldb_to_drsuapi(const struct dsdb_schema *sch id3b.dn = (const char *)in->values[i].data; id3b.binary = data_blob(NULL, 0); - ndr_err = ndr_push_struct_blob(&blobs[i], blobs, lp_iconv_convenience(global_loadparm), &id3b, + ndr_err = ndr_push_struct_blob(&blobs[i], blobs, schema->iconv_convenience, &id3b, (ndr_push_flags_fn_t)ndr_push_drsuapi_DsReplicaObjectIdentifier3Binary); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { NTSTATUS status = ndr_map_error2ntstatus(ndr_err); @@ -1043,7 +1044,7 @@ static WERROR dsdb_syntax_PRESENTATION_ADDRESS_drsuapi_to_ldb(const struct dsdb_ return WERR_FOOBAR; } - ret = convert_string_talloc(out->values, lp_iconv_convenience(global_loadparm), CH_UTF16, CH_UNIX, + ret = convert_string_talloc(out->values, schema->iconv_convenience, CH_UTF16, CH_UNIX, in->value_ctr.values[i].blob->data+4, in->value_ctr.values[i].blob->length-4, (void **)&str); @@ -1086,7 +1087,7 @@ static WERROR dsdb_syntax_PRESENTATION_ADDRESS_ldb_to_drsuapi(const struct dsdb_ out->value_ctr.values[i].blob = &blobs[i]; - ret = convert_string_talloc(blobs, lp_iconv_convenience(global_loadparm), CH_UNIX, CH_UTF16, + ret = convert_string_talloc(blobs, schema->iconv_convenience, CH_UNIX, CH_UTF16, in->values[i].data, in->values[i].length, (void **)&data); -- cgit From 97c77cffade1b99f8c1345c8516a856644f40b01 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 19 Feb 2008 14:12:05 +0100 Subject: Avoid use of global_loadparm. (This used to be commit e6751a3ca40d968f084642229845a729bd916222) --- source4/torture/rpc/samsync.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/source4/torture/rpc/samsync.c b/source4/torture/rpc/samsync.c index 1f7f9f463e..865ebf9fd2 100644 --- a/source4/torture/rpc/samsync.c +++ b/source4/torture/rpc/samsync.c @@ -398,7 +398,7 @@ static bool samsync_handle_policy(TALLOC_CTX *mem_ctx, struct samsync_state *sam return true; } -static bool samsync_handle_user(TALLOC_CTX *mem_ctx, struct samsync_state *samsync_state, +static bool samsync_handle_user(struct torture_context *tctx, TALLOC_CTX *mem_ctx, struct samsync_state *samsync_state, int database_id, struct netr_DELTA_ENUM *delta) { uint32_t rid = delta->delta_id_union.rid; @@ -548,7 +548,7 @@ static bool samsync_handle_user(TALLOC_CTX *mem_ctx, struct samsync_state *samsy data.data = user->user_private_info.SensitiveData; data.length = user->user_private_info.DataLength; creds_arcfour_crypt(samsync_state->creds, data.data, data.length); - ndr_err = ndr_pull_struct_blob(&data, mem_ctx, lp_iconv_convenience(global_loadparm), &keys, (ndr_pull_flags_fn_t)ndr_pull_netr_USER_KEYS); + ndr_err = ndr_pull_struct_blob(&data, mem_ctx, lp_iconv_convenience(tctx->lp_ctx), &keys, (ndr_pull_flags_fn_t)ndr_pull_netr_USER_KEYS); if (NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { if (keys.keys.keys2.lmpassword.length == 16) { sam_rid_crypt(rid, keys.keys.keys2.lmpassword.pwd.hash, lm_hash.hash, 0); @@ -1101,8 +1101,9 @@ static bool samsync_handle_account(TALLOC_CTX *mem_ctx, struct samsync_state *sa /* try a netlogon DatabaseSync */ -static bool test_DatabaseSync(struct samsync_state *samsync_state, - TALLOC_CTX *mem_ctx) +static bool test_DatabaseSync(struct torture_context *tctx, + struct samsync_state *samsync_state, + TALLOC_CTX *mem_ctx) { NTSTATUS status; TALLOC_CTX *loop_ctx, *delta_ctx, *trustdom_ctx; @@ -1162,7 +1163,7 @@ static bool test_DatabaseSync(struct samsync_state *samsync_state, } break; case NETR_DELTA_USER: - if (!samsync_handle_user(delta_ctx, samsync_state, + if (!samsync_handle_user(tctx, delta_ctx, samsync_state, r.in.database_id, &r.out.delta_enum_array->delta_enum[d])) { printf("Failed to handle DELTA_USER\n"); ret = false; @@ -1611,7 +1612,7 @@ bool torture_rpc_samsync(struct torture_context *torture) ret = false; } - if (!test_DatabaseSync(samsync_state, mem_ctx)) { + if (!test_DatabaseSync(torture, samsync_state, mem_ctx)) { printf("DatabaseSync failed\n"); ret = false; } -- cgit From 8fce27ad018c2a1db048d9e7c89881f877ea3a73 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 19 Feb 2008 14:13:14 +0100 Subject: samba3rpc: Remove use of global_loadparm. (This used to be commit b3d084170e01fc678f9be6c280c52763ead52959) --- source4/torture/rpc/samba3rpc.c | 73 ++++++++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 31 deletions(-) diff --git a/source4/torture/rpc/samba3rpc.c b/source4/torture/rpc/samba3rpc.c index b08cd05bdb..779a28e126 100644 --- a/source4/torture/rpc/samba3rpc.c +++ b/source4/torture/rpc/samba3rpc.c @@ -806,6 +806,7 @@ static bool join3(struct smbcli_state *cli, */ static bool auth2(struct smbcli_state *cli, + struct loadparm_context *lp_ctx, struct cli_credentials *wks_cred) { TALLOC_CTX *mem_ctx; @@ -829,7 +830,7 @@ static bool auth2(struct smbcli_state *cli, net_pipe = dcerpc_pipe_init(mem_ctx, cli->transport->socket->event.ctx, - lp_iconv_convenience(global_loadparm)); + lp_iconv_convenience(lp_ctx)); if (net_pipe == NULL) { d_printf("dcerpc_pipe_init failed\n"); goto done; @@ -1204,7 +1205,7 @@ bool torture_netlogon_samba3(struct torture_context *torture) int j; - if (!auth2(cli, wks_creds)) { + if (!auth2(cli, torture->lp_ctx, wks_creds)) { d_printf("auth2 failed\n"); goto done; } @@ -1283,7 +1284,7 @@ static bool test_join3(struct torture_context *tctx, cmdline_credentials, cli_credentials_get_domain(wks_creds), CRED_SPECIFIED); - if (!auth2(cli, wks_creds)) { + if (!auth2(cli, tctx->lp_ctx, wks_creds)) { d_printf("auth2 failed\n"); goto done; } @@ -1381,6 +1382,7 @@ bool torture_samba3_sessionkey(struct torture_context *torture) */ static NTSTATUS pipe_bind_smb(TALLOC_CTX *mem_ctx, + struct loadparm_context *lp_ctx, struct smbcli_tree *tree, const char *pipe_name, const struct ndr_interface_table *iface, @@ -1391,7 +1393,7 @@ static NTSTATUS pipe_bind_smb(TALLOC_CTX *mem_ctx, if (!(result = dcerpc_pipe_init( mem_ctx, tree->session->transport->socket->event.ctx, - lp_iconv_convenience(global_loadparm)))) { + lp_iconv_convenience(lp_ctx)))) { return NT_STATUS_NO_MEMORY; } @@ -1507,7 +1509,9 @@ static struct dom_sid *name2sid(TALLOC_CTX *mem_ctx, * Find out the user SID on this connection */ -static struct dom_sid *whoami(TALLOC_CTX *mem_ctx, struct smbcli_tree *tree) +static struct dom_sid *whoami(TALLOC_CTX *mem_ctx, + struct loadparm_context *lp_ctx, + struct smbcli_tree *tree) { struct dcerpc_pipe *lsa; struct lsa_GetUserName r; @@ -1515,7 +1519,7 @@ static struct dom_sid *whoami(TALLOC_CTX *mem_ctx, struct smbcli_tree *tree) struct lsa_StringPointer authority_name_p; struct dom_sid *result; - status = pipe_bind_smb(mem_ctx, tree, "\\pipe\\lsarpc", + status = pipe_bind_smb(mem_ctx, lp_ctx, tree, "\\pipe\\lsarpc", &ndr_table_lsarpc, &lsa); if (!NT_STATUS_IS_OK(status)) { d_printf("(%s) Could not bind to LSA: %s\n", @@ -1631,7 +1635,7 @@ bool torture_samba3_rpc_getusername(struct torture_context *torture) goto done; } - if (!(user_sid = whoami(mem_ctx, cli->tree))) { + if (!(user_sid = whoami(mem_ctx, torture->lp_ctx, cli->tree))) { d_printf("(%s) whoami on auth'ed connection failed\n", __location__); ret = false; @@ -1658,7 +1662,7 @@ bool torture_samba3_rpc_getusername(struct torture_context *torture) goto done; } - if (!(user_sid = whoami(mem_ctx, cli->tree))) { + if (!(user_sid = whoami(mem_ctx, torture->lp_ctx, cli->tree))) { d_printf("(%s) whoami on anon connection failed\n", __location__); ret = false; @@ -1732,7 +1736,7 @@ bool torture_samba3_rpc_getusername(struct torture_context *torture) goto done; } - if (!(user_sid = whoami(mem_ctx, tree))) { + if (!(user_sid = whoami(mem_ctx, torture->lp_ctx, tree))) { d_printf("(%s) whoami on user connection failed\n", __location__); ret = false; @@ -1870,8 +1874,8 @@ bool torture_samba3_rpc_srvsvc(struct torture_context *torture) return false; } - status = pipe_bind_smb(mem_ctx, cli->tree, "\\pipe\\srvsvc", - &ndr_table_srvsvc, &p); + status = pipe_bind_smb(mem_ctx, torture->lp_ctx, cli->tree, + "\\pipe\\srvsvc", &ndr_table_srvsvc, &p); if (!NT_STATUS_IS_OK(status)) { d_printf("(%s) could not bind to srvsvc pipe: %s\n", __location__, nt_errstr(status)); @@ -2007,6 +2011,7 @@ bool torture_samba3_rpc_randomauth2(struct torture_context *torture) } static struct security_descriptor *get_sharesec(TALLOC_CTX *mem_ctx, + struct loadparm_context *lp_ctx, struct smbcli_session *sess, const char *sharename) { @@ -2028,7 +2033,7 @@ static struct security_descriptor *get_sharesec(TALLOC_CTX *mem_ctx, return NULL; } - status = pipe_bind_smb(mem_ctx, tree, "\\pipe\\srvsvc", + status = pipe_bind_smb(mem_ctx, lp_ctx, tree, "\\pipe\\srvsvc", &ndr_table_srvsvc, &p); if (!NT_STATUS_IS_OK(status)) { d_printf("(%s) could not bind to srvsvc pipe: %s\n", @@ -2060,6 +2065,7 @@ static struct security_descriptor *get_sharesec(TALLOC_CTX *mem_ctx, } static NTSTATUS set_sharesec(TALLOC_CTX *mem_ctx, + struct loadparm_context *lp_ctx, struct smbcli_session *sess, const char *sharename, struct security_descriptor *sd) @@ -2083,7 +2089,7 @@ static NTSTATUS set_sharesec(TALLOC_CTX *mem_ctx, return NT_STATUS_UNSUCCESSFUL; } - status = pipe_bind_smb(mem_ctx, tree, "\\pipe\\srvsvc", + status = pipe_bind_smb(mem_ctx, lp_ctx, tree, "\\pipe\\srvsvc", &ndr_table_srvsvc, &p); if (!NT_STATUS_IS_OK(status)) { d_printf("(%s) could not bind to srvsvc pipe: %s\n", @@ -2115,6 +2121,7 @@ static NTSTATUS set_sharesec(TALLOC_CTX *mem_ctx, } bool try_tcon(TALLOC_CTX *mem_ctx, + struct loadparm_context *lp_ctx, struct security_descriptor *orig_sd, struct smbcli_session *session, const char *sharename, const struct dom_sid *user_sid, @@ -2162,7 +2169,7 @@ bool try_tcon(TALLOC_CTX *mem_ctx, return false; } - status = set_sharesec(mem_ctx, session, sharename, sd); + status = set_sharesec(mem_ctx, lp_ctx, session, sharename, sd); if (!NT_STATUS_IS_OK(status)) { d_printf("custom set_sharesec failed: %s\n", nt_errstr(status)); @@ -2193,7 +2200,7 @@ bool try_tcon(TALLOC_CTX *mem_ctx, done: smbcli_rmdir(rmdir_tree, "sharesec_testdir"); - status = set_sharesec(mem_ctx, session, sharename, orig_sd); + status = set_sharesec(mem_ctx, lp_ctx, session, sharename, orig_sd); if (!NT_STATUS_IS_OK(status)) { d_printf("custom set_sharesec failed: %s\n", nt_errstr(status)); @@ -2225,25 +2232,25 @@ bool torture_samba3_rpc_sharesec(struct torture_context *torture) return false; } - if (!(user_sid = whoami(mem_ctx, cli->tree))) { + if (!(user_sid = whoami(mem_ctx, torture->lp_ctx, cli->tree))) { d_printf("whoami failed\n"); talloc_free(mem_ctx); return false; } - sd = get_sharesec(mem_ctx, cli->session, torture_setting_string(torture, - "share", NULL)); + sd = get_sharesec(mem_ctx, torture->lp_ctx, cli->session, + torture_setting_string(torture, "share", NULL)); - ret &= try_tcon(mem_ctx, sd, cli->session, + ret &= try_tcon(mem_ctx, torture->lp_ctx, sd, cli->session, torture_setting_string(torture, "share", NULL), user_sid, 0, NT_STATUS_ACCESS_DENIED, NT_STATUS_OK); - ret &= try_tcon(mem_ctx, sd, cli->session, + ret &= try_tcon(mem_ctx, torture->lp_ctx, sd, cli->session, torture_setting_string(torture, "share", NULL), user_sid, SEC_FILE_READ_DATA, NT_STATUS_OK, NT_STATUS_MEDIA_WRITE_PROTECTED); - ret &= try_tcon(mem_ctx, sd, cli->session, + ret &= try_tcon(mem_ctx, torture->lp_ctx, sd, cli->session, torture_setting_string(torture, "share", NULL), user_sid, SEC_FILE_ALL, NT_STATUS_OK, NT_STATUS_OK); @@ -2273,7 +2280,7 @@ bool torture_samba3_rpc_lsa(struct torture_context *torture) return false; } - status = pipe_bind_smb(mem_ctx, cli->tree, "\\lsarpc", + status = pipe_bind_smb(mem_ctx, torture->lp_ctx, cli->tree, "\\lsarpc", &ndr_table_lsarpc, &p); if (!NT_STATUS_IS_OK(status)) { d_printf("(%s) pipe_bind_smb failed: %s\n", __location__, @@ -2356,7 +2363,8 @@ static NTSTATUS get_servername(TALLOC_CTX *mem_ctx, struct smbcli_tree *tree, } -static NTSTATUS find_printers(TALLOC_CTX *ctx, struct smbcli_tree *tree, +static NTSTATUS find_printers(TALLOC_CTX *ctx, struct loadparm_context *lp_ctx, + struct smbcli_tree *tree, const char ***printers, int *num_printers) { TALLOC_CTX *mem_ctx; @@ -2372,7 +2380,8 @@ static NTSTATUS find_printers(TALLOC_CTX *ctx, struct smbcli_tree *tree, return NT_STATUS_NO_MEMORY; } - status = pipe_bind_smb(mem_ctx, tree, "\\srvsvc", &ndr_table_srvsvc, + status = pipe_bind_smb(mem_ctx, lp_ctx, + tree, "\\srvsvc", &ndr_table_srvsvc, &p); if (!NT_STATUS_IS_OK(status)) { d_printf("could not bind to srvsvc pipe\n"); @@ -2560,7 +2569,7 @@ bool torture_samba3_rpc_spoolss(struct torture_context *torture) return false; } - if (!NT_STATUS_IS_OK(find_printers(mem_ctx, cli->tree, + if (!NT_STATUS_IS_OK(find_printers(mem_ctx, torture->lp_ctx, cli->tree, &printers, &num_printers))) { talloc_free(mem_ctx); return false; @@ -2572,7 +2581,7 @@ bool torture_samba3_rpc_spoolss(struct torture_context *torture) return true; } - status = pipe_bind_smb(mem_ctx, cli->tree, "\\spoolss", + status = pipe_bind_smb(mem_ctx, torture->lp_ctx, cli->tree, "\\spoolss", &ndr_table_spoolss, &p); if (!NT_STATUS_IS_OK(status)) { d_printf("(%s) pipe_bind_smb failed: %s\n", __location__, @@ -2746,7 +2755,7 @@ bool torture_samba3_rpc_wkssvc(struct torture_context *torture) return false; } - status = pipe_bind_smb(mem_ctx, cli->tree, "\\wkssvc", + status = pipe_bind_smb(mem_ctx, torture->lp_ctx, cli->tree, "\\wkssvc", &ndr_table_wkssvc, &p); if (!NT_STATUS_IS_OK(status)) { d_printf("(%s) pipe_bind_smb failed: %s\n", __location__, @@ -2995,6 +3004,7 @@ bool torture_samba3_rpc_winreg(struct torture_context *torture) } static NTSTATUS get_shareinfo(TALLOC_CTX *mem_ctx, + struct loadparm_context *lp_ctx, struct smbcli_state *cli, const char *share, struct srvsvc_NetShareInfo502 **info) @@ -3006,7 +3016,7 @@ static NTSTATUS get_shareinfo(TALLOC_CTX *mem_ctx, if (!(p = dcerpc_pipe_init(cli, cli->transport->socket->event.ctx, - lp_iconv_convenience(global_loadparm)))) { + lp_iconv_convenience(lp_ctx)))) { status = NT_STATUS_NO_MEMORY; goto fail; } @@ -3176,7 +3186,8 @@ static NTSTATUS torture_samba3_createshare(struct smbcli_state *cli, return status; } -static NTSTATUS torture_samba3_deleteshare(struct smbcli_state *cli, +static NTSTATUS torture_samba3_deleteshare(struct torture_context *torture, + struct smbcli_state *cli, const char *sharename) { struct dcerpc_pipe *p; @@ -3301,7 +3312,7 @@ bool torture_samba3_regconfig(struct torture_context *torture) goto done; } - status = get_shareinfo(torture, cli, "blubber", &i); + status = get_shareinfo(torture, torture->lp_ctx, cli, "blubber", &i); if (!NT_STATUS_IS_OK(status)) { torture_warning(torture, "get_shareinfo failed: " "%s\n", nt_errstr(status)); @@ -3314,7 +3325,7 @@ bool torture_samba3_regconfig(struct torture_context *torture) goto done; } - status = torture_samba3_deleteshare(cli, "blubber"); + status = torture_samba3_deleteshare(torture, cli, "blubber"); if (!NT_STATUS_IS_OK(status)) { torture_warning(torture, "torture_samba3_deleteshare failed: " "%s\n", nt_errstr(status)); -- cgit From cfd818cd45092d6fe11cb1e36f4a3cb90fb0a7fa Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 19 Feb 2008 14:13:27 +0100 Subject: No longer ignore torture/util.h; it's static now. (This used to be commit cebb68440540114531e89b774d7437d1d05a1b56) --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index b0786b66d6..6076ddc9cd 100644 --- a/.gitignore +++ b/.gitignore @@ -115,7 +115,6 @@ source/smb_server/smb2/smb2_proto.h source/smbd/process_model_proto.h source/smbd/service_proto.h source/torture/proto.h -source/torture/util.h source/torture/auth/proto.h source/torture/basic/proto.h source/torture/ldap/proto.h -- cgit From b617f58cc39ffb5e7f775b88887bcf9112b1ded1 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 19 Feb 2008 14:25:20 +0100 Subject: Fix accidently introduced bug - thanks metze. (This used to be commit d0dfdab85ac751c62b0a6d6e6b1ff128940098ed) --- source4/dsdb/schema/schema_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source4/dsdb/schema/schema_init.c b/source4/dsdb/schema/schema_init.c index bec6d5d9ef..30d0adeda7 100644 --- a/source4/dsdb/schema/schema_init.c +++ b/source4/dsdb/schema/schema_init.c @@ -1155,7 +1155,7 @@ WERROR dsdb_attach_schema_from_ldif_file(struct ldb_context *ldb, const char *pf goto nomem; } - schema->iconv_convenience = ldb_get_opaque(ldb, "loadparm"); + schema->iconv_convenience = lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")); /* * load the prefixMap attribute from pf -- cgit From 87f611ed69b2ba16d2a36ed439a685a36a49937c Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 19 Feb 2008 15:12:57 +0100 Subject: Start and kill kvm instance properly. (This used to be commit 78e49765a2ec5fac485dbf56143716e151b4b562) --- source4/selftest/config.mk | 3 +++ source4/selftest/selftest.pl | 2 +- source4/selftest/target/Kvm.pm | 45 +++++++++++++++++++++++++++++------------- 3 files changed, 35 insertions(+), 15 deletions(-) diff --git a/source4/selftest/config.mk b/source4/selftest/config.mk index ff470df527..306a11469c 100644 --- a/source4/selftest/config.mk +++ b/source4/selftest/config.mk @@ -13,6 +13,9 @@ test:: everything kvmtest:: everything $(SELFTEST) $(DEFAULT_TEST_OPTIONS) --target=kvm --image=$(KVM_IMAGE) +kvmquicktest:: everything + $(SELFTEST) $(DEFAULT_TEST_OPTIONS) --quick --target=kvm --image=$(KVM_IMAGE) + testone:: everything $(SELFTEST) $(DEFAULT_TEST_OPTIONS) --one $(TESTS) diff --git a/source4/selftest/selftest.pl b/source4/selftest/selftest.pl index 8647dee9d2..a989d1a851 100755 --- a/source4/selftest/selftest.pl +++ b/source4/selftest/selftest.pl @@ -303,7 +303,7 @@ Samba3 Specific: --bindir=PATH path to binaries Kvm Specific: - --image=PATH path to KVM image + --image=PATH path to KVM image Behaviour: --quick run quick overall test diff --git a/source4/selftest/target/Kvm.pm b/source4/selftest/target/Kvm.pm index 74b726d183..7fa7e02184 100644 --- a/source4/selftest/target/Kvm.pm +++ b/source4/selftest/target/Kvm.pm @@ -11,9 +11,9 @@ use FindBin qw($RealBin); use POSIX; sub new($$$$) { - my ($classname, $image) = @_; + my ($classname, $dc_image) = @_; my $self = { - image => $image + dc_image => $dc_image, }; bless $self; return $self; @@ -23,6 +23,10 @@ sub teardown_env($$) { my ($self, $envvars) = @_; + print "Killing kvm instance $envvars->{KVM_PID}\n"; + + kill 9, $envvars->{KVM_PID}; + return 0; } @@ -37,22 +41,26 @@ sub check_env($$) { my ($self, $envvars) = @_; + # FIXME: Check whether $self->{pid} is still running + return 1; } -sub start($) +sub start($$$) { - my ($self) = @_; + my ($self, $path, $image) = @_; - my $pidfile = "kvm.pid"; + my $pidfile = "$path/kvm.pid"; my $opts = ($ENV{KVM_OPTIONS} or ""); - system("kvm $opts -daemonize -pidfile $pidfile -vnc unix:kvm.vnc -snapshot $self->{image}"); + system("kvm $opts -daemonize -pidfile $pidfile -vnc unix:$path/kvm.vnc -snapshot $image"); open(PID, $pidfile); - $self->{pid} = ; + =~ /([0-9]+)/; + my ($pid) = $1; close(PID); + return $pid; } sub setup_env($$$) @@ -60,21 +68,30 @@ sub setup_env($$$) my ($self, $envname, $path) = @_; if ($envname eq "dc") { - unless (defined($self->{pid})) { - $self->start(); + $self->{dc_pid} = $self->start($path, $self->{dc_image}); + if ($envname eq "dc") { + return { + KVM_PID => $self->{dc_pid}, + USERNAME => "Administrator", + PASSWORD => "penguin", + DOMAIN => "SAMBA", + REALM => "SAMBA", + SERVER => "", + SERVER_IP => "", + NETBIOSNAME => "", + NETBIOSALIAS => "", + }; + } else { + return undef; } - } elsif ($envname eq "member") { + } else { return undef; } - - die("No implemented yet"); } sub stop($) { my ($self) = @_; - - kill $self->{pid}; } 1; -- cgit From 7a3f15ff8a4b32c0a9f0114fc8208ddfcde796ce Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 19 Feb 2008 14:44:50 +0100 Subject: lsa.idl: use strlen_m_term() in lsa_StringLarge to support NULL strings metze (This used to be commit bdd8d9ebdf184ee3e23a8de92fa4dec7123a8824) --- source4/librpc/idl/lsa.idl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source4/librpc/idl/lsa.idl b/source4/librpc/idl/lsa.idl index bc5ccaa78a..64fb2336bb 100644 --- a/source4/librpc/idl/lsa.idl +++ b/source4/librpc/idl/lsa.idl @@ -23,7 +23,7 @@ import "security.idl"; typedef [public] struct { [value(2*strlen_m(string))] uint16 length; - [value(2*(strlen_m(string)+1))] uint16 size; + [value(2*strlen_m_term(string))] uint16 size; [charset(UTF16),size_is(size/2),length_is(length/2)] uint16 *string; } lsa_StringLarge; -- cgit From 611f0152a198e1a5c209b2ca5aad6b121dca9442 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 19 Feb 2008 14:47:22 +0100 Subject: lsa.idl: strlen_m*() also for the lsa_AsciiString* versions We already did this before b994f899b42d294c0418bdc82660a2f7510667d6. This is needed to handle NULL strings, where strlen() would crash... Maybe we should add a strlen_a() and strlen_a_term() later... metze (This used to be commit c388efab13d1be2086a99e6615fa348c4cdc4594) --- source4/librpc/idl/lsa.idl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source4/librpc/idl/lsa.idl b/source4/librpc/idl/lsa.idl index 64fb2336bb..3159a7d16d 100644 --- a/source4/librpc/idl/lsa.idl +++ b/source4/librpc/idl/lsa.idl @@ -33,14 +33,14 @@ import "security.idl"; } lsa_Strings; typedef [public] struct { - [value(strlen(string))] uint16 length; - [value(strlen(string))] uint16 size; + [value(strlen_m(string))] uint16 length; + [value(strlen_m(string))] uint16 size; [charset(DOS),size_is(size),length_is(length)] uint8 *string; } lsa_AsciiString; typedef [public] struct { - [value(strlen(string))] uint16 length; - [value(strlen(string)+1)] uint16 size; + [value(strlen_m(string))] uint16 length; + [value(strlen_m_term(string))] uint16 size; [charset(DOS),size_is(size),length_is(length)] uint8 *string; } lsa_AsciiStringLarge; -- cgit From fc840f3810124d1b83afea172d3940dd54ab42f7 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 14 Feb 2008 16:07:04 +0100 Subject: drsblobs.idl: don't use asclstr metze (This used to be commit f42cc9134004597eff19e477d3ed0693d5e6fef6) --- source4/librpc/idl/drsblobs.idl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source4/librpc/idl/drsblobs.idl b/source4/librpc/idl/drsblobs.idl index 1e80597f4a..27f3a99551 100644 --- a/source4/librpc/idl/drsblobs.idl +++ b/source4/librpc/idl/drsblobs.idl @@ -85,7 +85,8 @@ interface drsblobs { * w2k3 uses version 1 */ typedef [public,gensize] struct { - asclstr dns_name; + [value(strlen(dns_name)+1)] uint32 __dns_name_size; + [charset(DOS)] uint8 dns_name[__dns_name_size]; } repsFromTo1OtherInfo; typedef [public,gensize,flag(NDR_PAHEX)] struct { -- cgit From 4473a07fb3118b4e5197f05c5b930c3eb828a94a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 19 Feb 2008 11:57:32 +0100 Subject: winreg.idl: get rid of initshutdown_String and use lsa_StringLarge metze (This used to be commit 1ccea2a260de83b2e3137f762716ae67070c7024) --- source4/librpc/idl/winreg.idl | 14 +++++++++++--- source4/torture/rpc/winreg.c | 15 ++++++--------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/source4/librpc/idl/winreg.idl b/source4/librpc/idl/winreg.idl index b489e86c38..5e5d5542b6 100644 --- a/source4/librpc/idl/winreg.idl +++ b/source4/librpc/idl/winreg.idl @@ -2,7 +2,7 @@ winreg interface definition */ -import "lsa.idl", "initshutdown.idl", "security.idl"; +import "lsa.idl", "security.idl"; [ uuid("338cd001-2244-31f1-aaaa-900038001003"), @@ -302,7 +302,11 @@ import "lsa.idl", "initshutdown.idl", "security.idl"; /* Function: 0x18 */ WERROR winreg_InitiateSystemShutdown( [in,unique] uint16 *hostname, - [in,unique] initshutdown_String *message, + /* + * Note: lsa_String and winreg_String both result + * in WERR_INVALID_PARAM + */ + [in,unique] lsa_StringLarge *message, [in] uint32 timeout, [in] uint8 force_apps, [in] uint8 reboot @@ -358,7 +362,11 @@ import "lsa.idl", "initshutdown.idl", "security.idl"; /* Function: 0x1e */ WERROR winreg_InitiateSystemShutdownEx( [in,unique] uint16 *hostname, - [in,unique] initshutdown_String *message, + /* + * Note: lsa_String and winreg_String both result + * in WERR_INVALID_PARAM + */ + [in,unique] lsa_StringLarge *message, [in] uint32 timeout, [in] uint8 force_apps, [in] uint8 reboot, diff --git a/source4/torture/rpc/winreg.c b/source4/torture/rpc/winreg.c index d77295605f..4695733671 100644 --- a/source4/torture/rpc/winreg.c +++ b/source4/torture/rpc/winreg.c @@ -38,12 +38,9 @@ #define TEST_SID "S-1-5-21-1234567890-1234567890-1234567890-500" -static void init_initshutdown_String(TALLOC_CTX *mem_ctx, - struct initshutdown_String *name, - const char *s) +static void init_lsa_StringLarge(struct lsa_StringLarge *name, const char *s) { - name->name = talloc(mem_ctx, struct initshutdown_String_sub); - name->name->name = s; + name->string = s; } static void init_winreg_String(struct winreg_String *name, const char *s) @@ -1636,8 +1633,8 @@ static bool test_InitiateSystemShutdown(struct torture_context *tctx, uint16_t hostname = 0x0; r.in.hostname = &hostname; - r.in.message = talloc(tctx, struct initshutdown_String); - init_initshutdown_String(tctx, r.in.message, "spottyfood"); + r.in.message = talloc(tctx, struct lsa_StringLarge); + init_lsa_StringLarge(r.in.message, "spottyfood"); r.in.force_apps = 1; r.in.timeout = 30; r.in.reboot = 1; @@ -1660,8 +1657,8 @@ static bool test_InitiateSystemShutdownEx(struct torture_context *tctx, uint16_t hostname = 0x0; r.in.hostname = &hostname; - r.in.message = talloc(tctx, struct initshutdown_String); - init_initshutdown_String(tctx, r.in.message, "spottyfood"); + r.in.message = talloc(tctx, struct lsa_StringLarge); + init_lsa_StringLarge(r.in.message, "spottyfood"); r.in.force_apps = 1; r.in.timeout = 30; r.in.reboot = 1; -- cgit From 665a7aafd13aed42a80beaf344dc87f7b753aeea Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 19 Feb 2008 14:58:33 +0100 Subject: initshutdown.idl: get rid of initshutdown_String and use lsa_StringLarge metze (This used to be commit d9303cb08324db5ceb89f69a1a71cc3e16fdf250) --- source4/librpc/idl/initshutdown.idl | 25 ++++++++++++------------- source4/torture/rpc/initshutdown.c | 13 ++++++------- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/source4/librpc/idl/initshutdown.idl b/source4/librpc/idl/initshutdown.idl index 868e48e28a..ac30be70dd 100644 --- a/source4/librpc/idl/initshutdown.idl +++ b/source4/librpc/idl/initshutdown.idl @@ -4,6 +4,8 @@ initshutdown interface definition */ +import "lsa.idl"; + [ uuid("894de0c0-0d55-11d3-a322-00c04fa321a1"), version(1.0), @@ -12,20 +14,13 @@ helpstring("Init shutdown service") ] interface initshutdown { - typedef struct { - [value(strlen_m_term(name))] uint32 name_size; - [flag(STR_LEN4|STR_NOTERM)] string name; - } initshutdown_String_sub; - - typedef [public] struct { - [value(strlen_m(name->name)*2)] uint16 name_len; - [value(strlen_m_term(name->name)*2)] uint16 name_size; - initshutdown_String_sub *name; - } initshutdown_String; - WERROR initshutdown_Init( [in,unique] uint16 *hostname, - [in,unique] initshutdown_String *message, + /* + * Note: lsa_String and winreg_String both result + * in WERR_INVALID_PARAM + */ + [in,unique] lsa_StringLarge *message, [in] uint32 timeout, [in] uint8 force_apps, [in] uint8 reboot @@ -37,7 +32,11 @@ WERROR initshutdown_InitEx( [in,unique] uint16 *hostname, - [in,unique] initshutdown_String *message, + /* + * Note: lsa_String and winreg_String both result + * in WERR_INVALID_PARAM + */ + [in,unique] lsa_StringLarge *message, [in] uint32 timeout, [in] uint8 force_apps, [in] uint8 reboot, diff --git a/source4/torture/rpc/initshutdown.c b/source4/torture/rpc/initshutdown.c index 9f6f1735ee..92fec5be0c 100644 --- a/source4/torture/rpc/initshutdown.c +++ b/source4/torture/rpc/initshutdown.c @@ -24,10 +24,9 @@ #include "librpc/gen_ndr/ndr_initshutdown_c.h" #include "torture/rpc/rpc.h" -static void init_initshutdown_String(TALLOC_CTX *mem_ctx, struct initshutdown_String *name, const char *s) +static void init_lsa_StringLarge(struct lsa_StringLarge *name, const char *s) { - name->name = talloc(mem_ctx, struct initshutdown_String_sub); - name->name->name = s; + name->string = s; } @@ -58,8 +57,8 @@ static bool test_Init(struct torture_context *tctx, uint16_t hostname = 0x0; r.in.hostname = &hostname; - r.in.message = talloc(tctx, struct initshutdown_String); - init_initshutdown_String(tctx, r.in.message, "spottyfood"); + r.in.message = talloc(tctx, struct lsa_StringLarge); + init_lsa_StringLarge(r.in.message, "spottyfood"); r.in.force_apps = 1; r.in.timeout = 30; r.in.reboot = 1; @@ -80,8 +79,8 @@ static bool test_InitEx(struct torture_context *tctx, uint16_t hostname = 0x0; r.in.hostname = &hostname; - r.in.message = talloc(tctx, struct initshutdown_String); - init_initshutdown_String(tctx, r.in.message, "spottyfood"); + r.in.message = talloc(tctx, struct lsa_StringLarge); + init_lsa_StringLarge(r.in.message, "spottyfood"); r.in.force_apps = 1; r.in.timeout = 30; r.in.reboot = 1; -- cgit From d3e182098a69a20035ee5eb0e9ab453dfdcb9c8b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 19 Feb 2008 16:28:32 +0100 Subject: Start dhcp server for kvm machine. (This used to be commit a54507dbd6bfaafb42eb95ec8a57897096b19583) --- source4/selftest/selftest.pl | 2 + source4/selftest/target/Kvm.pm | 84 ++++++++++++++++++++++++++++++++++-------- 2 files changed, 70 insertions(+), 16 deletions(-) diff --git a/source4/selftest/selftest.pl b/source4/selftest/selftest.pl index a989d1a851..1672209bef 100755 --- a/source4/selftest/selftest.pl +++ b/source4/selftest/selftest.pl @@ -448,6 +448,8 @@ if ($opt_target eq "samba4") { require target::Windows; $target = new Windows(); } elsif ($opt_target eq "kvm") { + die("Kvm tests will not run with socket wrapper enabled.") + if ($opt_socket_wrapper); require target::Kvm; die("No image specified") unless ($opt_image); $target = new Kvm($opt_image); diff --git a/source4/selftest/target/Kvm.pm b/source4/selftest/target/Kvm.pm index 7fa7e02184..1037f23c59 100644 --- a/source4/selftest/target/Kvm.pm +++ b/source4/selftest/target/Kvm.pm @@ -19,6 +19,39 @@ sub new($$$$) { return $self; } +sub write_kvm_ifup($$$) +{ + my ($self, $path, $ip_prefix) = @_; + open(SCRIPT, ">$path/kvm-ifup"); + + print SCRIPT <<__EOF__; +#!/bin/sh + +PREFIX=$ip_prefix + +/sbin/ifconfig \$1 \$PREFIX.1 up + +cat <$path/udhcpd.conf +interface \$1 +start \$PREFIX.20 +end \$PREFIX.20 +max_leases 1 +lease_file $path/udhcpd.leases +pidfile $path/udhcpd.pid +EOF + +touch $path/udhcpd.leases + +/usr/sbin/udhcpd $path/udhcpd.conf + +exit 0 +__EOF__ + close(SCRIPT); + chmod(0755, "$path/kvm-ifup"); + + return ("$path/kvm-ifup", "$path/udhcpd.pid", "$ip_prefix.20"); +} + sub teardown_env($$) { my ($self, $envvars) = @_; @@ -27,6 +60,9 @@ sub teardown_env($$) kill 9, $envvars->{KVM_PID}; + print "Killing dhcpd instance $envvars->{DHCPD_PID}\n"; + kill 9, $envvars->{DHCPD_PID}; + return 0; } @@ -46,21 +82,30 @@ sub check_env($$) return 1; } +sub read_pidfile($) +{ + my ($path) = @_; + + open(PID, $path); + =~ /([0-9]+)/; + my ($pid) = $1; + close(PID); + return $pid; +} + sub start($$$) { my ($self, $path, $image) = @_; my $pidfile = "$path/kvm.pid"; - my $opts = ($ENV{KVM_OPTIONS} or ""); + my $opts = ($ENV{KVM_OPTIONS} or "-nographic"); - system("kvm $opts -daemonize -pidfile $pidfile -vnc unix:$path/kvm.vnc -snapshot $image"); + my ($ifup_script, $dhcpd_pidfile, $ip_address) = $self->write_kvm_ifup($path, "192.168.9"); - open(PID, $pidfile); - =~ /([0-9]+)/; - my ($pid) = $1; - close(PID); - return $pid; + system("kvm $opts -daemonize -pidfile $pidfile -snapshot $image -net nic -net tap,script=$ifup_script"); + + return (read_pidfile($pidfile), read_pidfile($dhcpd_pidfile), $ip_address); } sub setup_env($$$) @@ -68,18 +113,25 @@ sub setup_env($$$) my ($self, $envname, $path) = @_; if ($envname eq "dc") { - $self->{dc_pid} = $self->start($path, $self->{dc_image}); + ($self->{dc_pid}, $self->{dc_dhcpd_pid}, $self->{dc_ip}) = $self->start($path, $self->{dc_image}); + + sub choose_var($$) { + my ($name, $default) = @_; + return defined($ENV{"KVM_DC_$name"})?$ENV{"KVM_DC_$name"}:$default; + } + if ($envname eq "dc") { return { KVM_PID => $self->{dc_pid}, - USERNAME => "Administrator", - PASSWORD => "penguin", - DOMAIN => "SAMBA", - REALM => "SAMBA", - SERVER => "", - SERVER_IP => "", - NETBIOSNAME => "", - NETBIOSALIAS => "", + DHCPD_PID => $self->{dc_dhcpd_pid}, + USERNAME => choose_var("USERNAME", "Administrator"), + PASSWORD => choose_var("PASSWORD", "penguin"), + DOMAIN => choose_var("DOMAIN", "SAMBA"), + REALM => choose_var("REALM", "SAMBA"), + SERVER => choose_var("SERVER", "DC"), + SERVER_IP => $self->{dc_ip}, + NETBIOSNAME => choose_var("NETBIOSNAME", "DC"), + NETBIOSALIAS => choose_var("NETBIOSALIAS", "DC"), }; } else { return undef; -- cgit From a31a2f082f26785967d8cb302ca940e76d513ac6 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 19 Feb 2008 16:49:29 +0100 Subject: Allow connecting to screen. (This used to be commit a021408c9d78260b9abf7ebec4230b7958033a38) --- source4/selftest/config.mk | 4 ++-- source4/selftest/target/Kvm.pm | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/source4/selftest/config.mk b/source4/selftest/config.mk index 306a11469c..4e9d31b684 100644 --- a/source4/selftest/config.mk +++ b/source4/selftest/config.mk @@ -11,10 +11,10 @@ test:: everything $(SELFTEST) $(DEFAULT_TEST_OPTIONS) --immediate $(TESTS) kvmtest:: everything - $(SELFTEST) $(DEFAULT_TEST_OPTIONS) --target=kvm --image=$(KVM_IMAGE) + $(SELFTEST) $(DEFAULT_TEST_OPTIONS) --immediate --target=kvm --image=$(KVM_IMAGE) kvmquicktest:: everything - $(SELFTEST) $(DEFAULT_TEST_OPTIONS) --quick --target=kvm --image=$(KVM_IMAGE) + $(SELFTEST) $(DEFAULT_TEST_OPTIONS) --immediate --quick --target=kvm --image=$(KVM_IMAGE) testone:: everything $(SELFTEST) $(DEFAULT_TEST_OPTIONS) --one $(TESTS) diff --git a/source4/selftest/target/Kvm.pm b/source4/selftest/target/Kvm.pm index 1037f23c59..7799cb7ec0 100644 --- a/source4/selftest/target/Kvm.pm +++ b/source4/selftest/target/Kvm.pm @@ -99,7 +99,7 @@ sub start($$$) my $pidfile = "$path/kvm.pid"; - my $opts = ($ENV{KVM_OPTIONS} or "-nographic"); + my $opts = (defined($ENV{KVM_OPTIONS})?$ENV{KVM_OPTIONS}:"-nographic"); my ($ifup_script, $dhcpd_pidfile, $ip_address) = $self->write_kvm_ifup($path, "192.168.9"); -- cgit From dd4ffd868b59f12a190af49eadfece34a395b34d Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Sun, 17 Feb 2008 22:57:04 +0100 Subject: Fix paths for talloc into unpacked directory (rsync commands). Michael (This used to be commit 2839d7f67a0d3ed5b4841bf3c12ce73972636b88) --- source4/lib/talloc/web/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source4/lib/talloc/web/index.html b/source4/lib/talloc/web/index.html index e53e8960a8..90f6577b2d 100644 --- a/source4/lib/talloc/web/index.html +++ b/source4/lib/talloc/web/index.html @@ -35,8 +35,8 @@ svn. To fetch via svn use the following command: To fetch via rsync use this command:
-  rsync -Pavz samba.org::ftp/unpacked/samba4/source/lib/talloc .
-  rsync -Pavz samba.org::ftp/unpacked/samba4/source/lib/libreplace .
+  rsync -Pavz samba.org::ftp/unpacked/samba_4_0_test/source/lib/talloc .
+  rsync -Pavz samba.org::ftp/unpacked/samba_4_0_test/source/lib/libreplace .
 

-- cgit From c65cded541ff123ee6d126f757f541961e9ad717 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 18 Feb 2008 22:49:32 +0100 Subject: Adapt source code checkout information to git repo in talloc website. Michael (This used to be commit 254be79799acc69db88a5500a2f755c84553f8ef) --- source4/lib/talloc/web/index.html | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/source4/lib/talloc/web/index.html b/source4/lib/talloc/web/index.html index 90f6577b2d..628030ad4c 100644 --- a/source4/lib/talloc/web/index.html +++ b/source4/lib/talloc/web/index.html @@ -24,12 +24,13 @@ bugzilla bug tracking system.

Download

-You can download the latest release either via rsync or anonymous -svn. To fetch via svn use the following command: +You can download the latest release either via rsync or git. +To fetch via git use the following command:
-  svn co svn://svnanon.samba.org/samba/branches/SAMBA_4_0/source/lib/talloc talloc
-  svn co svn://svnanon.samba.org/samba/branches/SAMBA_4_0/source/lib/replace libreplace
+  git-clone git://git.samba.org/samba.git samba
+  cd samba
+  git checkout -b samba4 origin/v4-0-test
 
To fetch via rsync use this command: -- cgit From c05b9ef58a79b09a1f9b6332bf2989af6db8ee26 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 19 Feb 2008 16:49:58 +0100 Subject: Fix a typo. Michael (This used to be commit 39499a3346b49a3c50cb1ebb1393a62c614cf056) --- source4/build/m4/check_path.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source4/build/m4/check_path.m4 b/source4/build/m4/check_path.m4 index 1dacd956ea..08a858ebb2 100644 --- a/source4/build/m4/check_path.m4 +++ b/source4/build/m4/check_path.m4 @@ -132,7 +132,7 @@ AC_SUBST(modulesdir) selftest_prefix="./st" AC_SUBST(selftest_prefix) AC_ARG_WITH(selftest-prefix, -[ --with-selftest-prefix=DIR The prefix where make test will be runned ($selftest_prefix)], +[ --with-selftest-prefix=DIR The prefix where make test will be run ($selftest_prefix)], [ case "$withval" in yes|no) AC_MSG_WARN([--with-selftest-prefix called without argument - will use default]) -- cgit From 7f11952199af28797d49e42e1a336275412538c8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 19 Feb 2008 17:23:38 +0100 Subject: Allow loading kvm snapshots. (This used to be commit 8ef295bb9cba4a47ff19894364e9d5f4dc15a935) --- source4/selftest/target/Kvm.pm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source4/selftest/target/Kvm.pm b/source4/selftest/target/Kvm.pm index 7799cb7ec0..b1ad8fcefa 100644 --- a/source4/selftest/target/Kvm.pm +++ b/source4/selftest/target/Kvm.pm @@ -101,9 +101,13 @@ sub start($$$) my $opts = (defined($ENV{KVM_OPTIONS})?$ENV{KVM_OPTIONS}:"-nographic"); + if (defined($ENV{KVM_SNAPSHOT})) { + $opts .= " -loadvm $ENV{KVM_SNAPSHOT}"; + } + my ($ifup_script, $dhcpd_pidfile, $ip_address) = $self->write_kvm_ifup($path, "192.168.9"); - system("kvm $opts -daemonize -pidfile $pidfile -snapshot $image -net nic -net tap,script=$ifup_script"); + system("kvm $opts -monitor unix:$path/kvm.monitor,server,nowait -daemonize -pidfile $pidfile -snapshot $image -net nic -net tap,script=$ifup_script"); return (read_pidfile($pidfile), read_pidfile($dhcpd_pidfile), $ip_address); } -- cgit From 5233e43ec7e96afb905f026309b0894178c96499 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 19 Feb 2008 17:25:42 +0100 Subject: Remove relict SAMBA_CONFIGURE_CPPFLAGS from lib/replace. Michael (This used to be commit d10cbb533c18a6d74160477d34a81bbd4cd6c7c8) --- source4/lib/replace/getifaddrs.m4 | 3 --- 1 file changed, 3 deletions(-) diff --git a/source4/lib/replace/getifaddrs.m4 b/source4/lib/replace/getifaddrs.m4 index 297a82d0c3..4259d1a7a3 100644 --- a/source4/lib/replace/getifaddrs.m4 +++ b/source4/lib/replace/getifaddrs.m4 @@ -43,8 +43,6 @@ iface=no; # look for a method of finding the list of network interfaces iface=no; AC_CACHE_CHECK([for iface getifaddrs],samba_cv_HAVE_IFACE_GETIFADDRS,[ -SAVE_CPPFLAGS="$CPPFLAGS" -CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS}" AC_TRY_RUN([ #define NO_CONFIG_H 1 #define HAVE_IFACE_GETIFADDRS 1 @@ -52,7 +50,6 @@ AC_TRY_RUN([ #include "$libreplacedir/replace.c" #include "$libreplacedir/getifaddrs.c"], samba_cv_HAVE_IFACE_GETIFADDRS=yes,samba_cv_HAVE_IFACE_GETIFADDRS=no,samba_cv_HAVE_IFACE_GETIFADDRS=cross)]) -CPPFLAGS="$SAVE_CPPFLAGS" if test x"$samba_cv_HAVE_IFACE_GETIFADDRS" = x"yes"; then iface=yes;AC_DEFINE(HAVE_IFACE_GETIFADDRS,1,[Whether iface getifaddrs is available]) else -- cgit From dbb79b683338a26d8c5d4f66efec4eae6987688c Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 19 Feb 2008 17:26:02 +0100 Subject: Add kvm name. (This used to be commit 228710e2656f8635697cdf4b7ce0c931683fbf86) --- source4/selftest/target/Kvm.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source4/selftest/target/Kvm.pm b/source4/selftest/target/Kvm.pm index b1ad8fcefa..253f3b53af 100644 --- a/source4/selftest/target/Kvm.pm +++ b/source4/selftest/target/Kvm.pm @@ -107,7 +107,7 @@ sub start($$$) my ($ifup_script, $dhcpd_pidfile, $ip_address) = $self->write_kvm_ifup($path, "192.168.9"); - system("kvm $opts -monitor unix:$path/kvm.monitor,server,nowait -daemonize -pidfile $pidfile -snapshot $image -net nic -net tap,script=$ifup_script"); + system("kvm -name \"Samba 4 Test Subject\" $opts -monitor unix:$path/kvm.monitor,server,nowait -daemonize -pidfile $pidfile -snapshot $image -net nic -net tap,script=$ifup_script"); return (read_pidfile($pidfile), read_pidfile($dhcpd_pidfile), $ip_address); } -- cgit From 95b294f75b05b31cace3818b85b5bf1b8d4722f2 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 19 Feb 2008 18:03:02 +0100 Subject: Only set "interfaces = " line for client when necessary. (This used to be commit 89fd6e9d0c3d0cb2fa3b8109e82f377cd7877a2e) --- source4/selftest/selftest.pl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source4/selftest/selftest.pl b/source4/selftest/selftest.pl index 1672209bef..c17e790f63 100755 --- a/source4/selftest/selftest.pl +++ b/source4/selftest/selftest.pl @@ -533,11 +533,13 @@ sub write_clientconf($$) if (defined($vars->{WINBINDD_SOCKET_DIR})) { print CF "\twinbindd socket directory = $vars->{WINBINDD_SOCKET_DIR}\n"; } + if ($opt_socket_wrapper) { + print CF "\tinterfaces = $interfaces\n"; + } print CF " private dir = $prefix_abs/client/private js include = $srcdir_abs/scripting/libjs name resolve order = bcast - interfaces = $interfaces panic action = $srcdir_abs/script/gdb_backtrace \%PID\% \%PROG\% max xmit = 32K notify:inotify = false -- cgit From c2941c9f0b8a48e4ab190c087b7f32c64d76aa8e Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 19 Feb 2008 21:51:09 +0100 Subject: Initial work on vde support. (This used to be commit 9b0dcac0bd805c3e1741448167b461c3fa0e33fd) --- source4/selftest/selftest.pl | 2 +- source4/selftest/target/Kvm.pm | 26 ++++++++++++++++++++------ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/source4/selftest/selftest.pl b/source4/selftest/selftest.pl index c17e790f63..996b982e06 100755 --- a/source4/selftest/selftest.pl +++ b/source4/selftest/selftest.pl @@ -452,7 +452,7 @@ if ($opt_target eq "samba4") { if ($opt_socket_wrapper); require target::Kvm; die("No image specified") unless ($opt_image); - $target = new Kvm($opt_image); + $target = new Kvm($opt_image, undef); } sub read_test_regexes($) diff --git a/source4/selftest/target/Kvm.pm b/source4/selftest/target/Kvm.pm index 253f3b53af..3b17a2909c 100644 --- a/source4/selftest/target/Kvm.pm +++ b/source4/selftest/target/Kvm.pm @@ -11,9 +11,10 @@ use FindBin qw($RealBin); use POSIX; sub new($$$$) { - my ($classname, $dc_image) = @_; + my ($classname, $dc_image, $vdesocket) = @_; my $self = { dc_image => $dc_image, + vdesocket => $vdesocket, }; bless $self; return $self; @@ -60,8 +61,10 @@ sub teardown_env($$) kill 9, $envvars->{KVM_PID}; - print "Killing dhcpd instance $envvars->{DHCPD_PID}\n"; - kill 9, $envvars->{DHCPD_PID}; + if (defined($envvars->{DHCPD_PID})) { + print "Killing dhcpd instance $envvars->{DHCPD_PID}\n"; + kill 9, $envvars->{DHCPD_PID}; + } return 0; } @@ -105,11 +108,22 @@ sub start($$$) $opts .= " -loadvm $ENV{KVM_SNAPSHOT}"; } - my ($ifup_script, $dhcpd_pidfile, $ip_address) = $self->write_kvm_ifup($path, "192.168.9"); + my $netopts; + my $dhcp_pid; + my $ip_address; + + if ($self->{vdesocket}) { + $netopts = "vde,socket=$self->{vdesocket}"; + } else { + my $ifup_script, $dhcpd_pidfile; + ($ifup_script, $dhcpd_pidfile, $ip_address) = $self->write_kvm_ifup($path, "192.168.9"); + $netopts = "tap,script=$ifup_script"; + $dhcp_pid = read_pidfile($dhcpd_pidfile); + } - system("kvm -name \"Samba 4 Test Subject\" $opts -monitor unix:$path/kvm.monitor,server,nowait -daemonize -pidfile $pidfile -snapshot $image -net nic -net tap,script=$ifup_script"); + system("kvm -name \"Samba 4 Test Subject\" $opts -monitor unix:$path/kvm.monitor,server,nowait -daemonize -pidfile $pidfile -snapshot $image -net nic -net $netopts"); - return (read_pidfile($pidfile), read_pidfile($dhcpd_pidfile), $ip_address); + return (read_pidfile($pidfile), $dhcp_pid, $ip_address); } sub setup_env($$$) -- cgit From 1507b886f8093f38cf84d62236fb076395557b4d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 19 Feb 2008 22:04:26 +0100 Subject: Add VDE switch management functions. (This used to be commit 5ad9bc7dd9b8a3b37e0acd77eaecc5ee71d7b422) --- source4/selftest/selftest.pl | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/source4/selftest/selftest.pl b/source4/selftest/selftest.pl index 996b982e06..aa4423c7e2 100755 --- a/source4/selftest/selftest.pl +++ b/source4/selftest/selftest.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl # Bootstrap Samba and run a number of tests against it. -# Copyright (C) 2005-2007 Jelmer Vernooij +# Copyright (C) 2005-2008 Jelmer Vernooij # Published under the GNU GPL, v3 or later. =pod @@ -455,6 +455,31 @@ if ($opt_target eq "samba4") { $target = new Kvm($opt_image, undef); } +# +# Start a Virtual Distributed Ethernet Switch +# Returns the pid of the switch. +# +sub start_vde_switch($) +{ + my ($path) = @_; + + system("vde_switch --pidfile $path/vde.pid --sock $path/vde.sock --daemon"); + + open(PID, "$path/vde.pid"); + =~ /([0-9]+)/; + my $pid = $1; + close(PID); + + return $pid; +} + +# Stop a Virtual Distributed Ethernet Switch +sub stop_vde_switch($) +{ + my ($pid) = @_; + kill 9, $pid; +} + sub read_test_regexes($) { my ($name) = @_; -- cgit From 836bab841cff78c40714048f8024535cb7a147f9 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 19 Feb 2008 23:00:43 +0100 Subject: Add configure test for vdeplug library. (This used to be commit 89590d7dfe0735093a4a5b66eeed9276df043ac9) --- source4/build/smb_build/summary.pm | 3 +++ source4/lib/socket_wrapper/config.m4 | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/source4/build/smb_build/summary.pm b/source4/build/smb_build/summary.pm index 4ea1ad525e..a6557fb1fe 100644 --- a/source4/build/smb_build/summary.pm +++ b/source4/build/smb_build/summary.pm @@ -53,6 +53,9 @@ sub show($$) showitem($output, "using libblkid", ["BLKID"]); showitem($output, "using iconv", ["ICONV"]); showitem($output, "using pam", ["PAM"]); + if (enabled($config->{developer})) { + showitem($output, "using VDE", ["VDEPLUG"]); + } showitem($output, "python bindings", ["LIBPYTHON"]); showisexternal($output, "popt", "LIBPOPT"); showisexternal($output, "talloc", "LIBTALLOC"); diff --git a/source4/lib/socket_wrapper/config.m4 b/source4/lib/socket_wrapper/config.m4 index f3ffb895a9..8ff91075bb 100644 --- a/source4/lib/socket_wrapper/config.m4 +++ b/source4/lib/socket_wrapper/config.m4 @@ -20,3 +20,10 @@ fi AC_SUBST(DEFAULT_TEST_OPTIONS) AC_SUBST(HAVE_SOCKET_WRAPPER) AC_SUBST(SOCKET_WRAPPER_OBJS) + +# Look for the vdeplug library +AC_CHECK_HEADERS(libvdeplug.h) +if test x"$ac_cv_header_libvdeplug_h" = xyes; then + AC_DEFINE(HAVE_VDEPLUG, 1, [Whether the VDE plug library is available]) + SMB_EXT_LIB(VDEPLUG,[-lvdeplug],[],[],[]) +fi -- cgit From 15b86081cd2df734479fcaf92a482c7896bef605 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 19 Feb 2008 23:53:04 +0100 Subject: Factor out IP marshalling into separate function. (This used to be commit 2548c2a1e7dab8abc00f8f49374a08cc0b427552) --- source4/lib/socket_wrapper/socket_wrapper.c | 79 ++++++++++++++++------------- 1 file changed, 43 insertions(+), 36 deletions(-) diff --git a/source4/lib/socket_wrapper/socket_wrapper.c b/source4/lib/socket_wrapper/socket_wrapper.c index 574d8ec5e4..644365a665 100644 --- a/source4/lib/socket_wrapper/socket_wrapper.c +++ b/source4/lib/socket_wrapper/socket_wrapper.c @@ -1,5 +1,5 @@ /* - * Copyright (C) Jelmer Vernooij 2005 + * Copyright (C) Jelmer Vernooij 2005,2008 * Copyright (C) Stefan Metzmacher 2006 * * All rights reserved. @@ -212,7 +212,6 @@ struct socket_info static struct socket_info *sockets; - const char *socket_wrapper_dir(void) { const char *s = getenv("SOCKET_WRAPPER_DIR"); @@ -908,40 +907,31 @@ static int swrap_get_pcap_fd(const char *fname) return fd; } -static void swrap_dump_packet(struct socket_info *si, const struct sockaddr *addr, - enum swrap_packet_type type, - const void *buf, size_t len) +static struct swrap_packet *swrap_marshall_packet(struct socket_info *si, + const struct sockaddr *addr, + enum swrap_packet_type type, + const void *buf, size_t len, + size_t *packet_len) { const struct sockaddr_in *src_addr; const struct sockaddr_in *dest_addr; - const char *file_name; unsigned long tcp_seq = 0; unsigned long tcp_ack = 0; unsigned char tcp_ctl = 0; int unreachable = 0; - struct timeval tv; - struct swrap_packet *packet; - size_t packet_len = 0; - int fd; - file_name = socket_wrapper_pcap_file(); - if (!file_name) { - return; - } + struct timeval tv; switch (si->family) { case AF_INET: -#ifdef HAVE_IPV6 - case AF_INET6: -#endif break; default: - return; + return NULL; } switch (type) { case SWRAP_CONNECT_SEND: - if (si->type != SOCK_STREAM) return; + if (si->type != SOCK_STREAM) return NULL; src_addr = (const struct sockaddr_in *)si->myname; dest_addr = (const struct sockaddr_in *)addr; @@ -955,7 +945,7 @@ static void swrap_dump_packet(struct socket_info *si, const struct sockaddr *add break; case SWRAP_CONNECT_RECV: - if (si->type != SOCK_STREAM) return; + if (si->type != SOCK_STREAM) return NULL; dest_addr = (const struct sockaddr_in *)si->myname; src_addr = (const struct sockaddr_in *)addr; @@ -969,7 +959,7 @@ static void swrap_dump_packet(struct socket_info *si, const struct sockaddr *add break; case SWRAP_CONNECT_UNREACH: - if (si->type != SOCK_STREAM) return; + if (si->type != SOCK_STREAM) return NULL; dest_addr = (const struct sockaddr_in *)si->myname; src_addr = (const struct sockaddr_in *)addr; @@ -983,7 +973,7 @@ static void swrap_dump_packet(struct socket_info *si, const struct sockaddr *add break; case SWRAP_CONNECT_ACK: - if (si->type != SOCK_STREAM) return; + if (si->type != SOCK_STREAM) return NULL; src_addr = (const struct sockaddr_in *)si->myname; dest_addr = (const struct sockaddr_in *)addr; @@ -995,7 +985,7 @@ static void swrap_dump_packet(struct socket_info *si, const struct sockaddr *add break; case SWRAP_ACCEPT_SEND: - if (si->type != SOCK_STREAM) return; + if (si->type != SOCK_STREAM) return NULL; dest_addr = (const struct sockaddr_in *)si->myname; src_addr = (const struct sockaddr_in *)addr; @@ -1009,7 +999,7 @@ static void swrap_dump_packet(struct socket_info *si, const struct sockaddr *add break; case SWRAP_ACCEPT_RECV: - if (si->type != SOCK_STREAM) return; + if (si->type != SOCK_STREAM) return NULL; src_addr = (const struct sockaddr_in *)si->myname; dest_addr = (const struct sockaddr_in *)addr; @@ -1023,7 +1013,7 @@ static void swrap_dump_packet(struct socket_info *si, const struct sockaddr *add break; case SWRAP_ACCEPT_ACK: - if (si->type != SOCK_STREAM) return; + if (si->type != SOCK_STREAM) return NULL; dest_addr = (const struct sockaddr_in *)si->myname; src_addr = (const struct sockaddr_in *)addr; @@ -1051,10 +1041,9 @@ static void swrap_dump_packet(struct socket_info *si, const struct sockaddr *add src_addr = (const struct sockaddr_in *)si->peername; if (si->type == SOCK_DGRAM) { - swrap_dump_packet(si, si->peername, + return swrap_marshall_packet(si, si->peername, SWRAP_SENDTO_UNREACH, - buf, len); - return; + buf, len, packet_len); } tcp_seq = si->io.pck_rcv; @@ -1068,7 +1057,7 @@ static void swrap_dump_packet(struct socket_info *si, const struct sockaddr *add src_addr = (const struct sockaddr_in *)si->peername; if (si->type == SOCK_DGRAM) { - return; + return NULL; } tcp_seq = si->io.pck_rcv; @@ -1094,7 +1083,7 @@ static void swrap_dump_packet(struct socket_info *si, const struct sockaddr *add src_addr = (const struct sockaddr_in *)si->peername; if (si->type == SOCK_DGRAM) { - return; + return NULL; } tcp_seq = si->io.pck_rcv; @@ -1128,7 +1117,7 @@ static void swrap_dump_packet(struct socket_info *si, const struct sockaddr *add break; case SWRAP_CLOSE_SEND: - if (si->type != SOCK_STREAM) return; + if (si->type != SOCK_STREAM) return NULL; src_addr = (const struct sockaddr_in *)si->myname; dest_addr = (const struct sockaddr_in *)si->peername; @@ -1142,7 +1131,7 @@ static void swrap_dump_packet(struct socket_info *si, const struct sockaddr *add break; case SWRAP_CLOSE_RECV: - if (si->type != SOCK_STREAM) return; + if (si->type != SOCK_STREAM) return NULL; dest_addr = (const struct sockaddr_in *)si->myname; src_addr = (const struct sockaddr_in *)si->peername; @@ -1156,7 +1145,7 @@ static void swrap_dump_packet(struct socket_info *si, const struct sockaddr *add break; case SWRAP_CLOSE_ACK: - if (si->type != SOCK_STREAM) return; + if (si->type != SOCK_STREAM) return NULL; src_addr = (const struct sockaddr_in *)si->myname; dest_addr = (const struct sockaddr_in *)si->peername; @@ -1167,15 +1156,33 @@ static void swrap_dump_packet(struct socket_info *si, const struct sockaddr *add break; default: - return; + return NULL; } swrapGetTimeOfDay(&tv); - packet = swrap_packet_init(&tv, src_addr, dest_addr, si->type, + return swrap_packet_init(&tv, src_addr, dest_addr, si->type, (const unsigned char *)buf, len, tcp_seq, tcp_ack, tcp_ctl, unreachable, - &packet_len); + packet_len); +} + +static void swrap_dump_packet(struct socket_info *si, + const struct sockaddr *addr, + enum swrap_packet_type type, + const void *buf, size_t len) +{ + const char *file_name; + struct swrap_packet *packet; + size_t packet_len = 0; + int fd; + + file_name = socket_wrapper_pcap_file(); + if (!file_name) { + return; + } + + packet = swrap_marshall_packet(si, addr, type, buf, len, &packet_len); if (!packet) { return; } -- cgit From 71bc5acead0e16473273eb8741373e865b6d2c44 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 20 Feb 2008 01:37:53 +0100 Subject: Allow ldb backends without init function, use init function-less ldb modules. (This used to be commit 141ee91272fb4dafca0149f679e17721b6a3011e) --- source4/lib/ldb/Makefile.in | 2 +- source4/lib/ldb/common/ldb.c | 9 +++++++++ source4/lib/ldb/common/ldb_modules.c | 9 +++++++-- source4/lib/ldb/ldb.mk | 2 +- source4/lib/ldb/tests/sample_module.c | 9 ++------- 5 files changed, 20 insertions(+), 11 deletions(-) diff --git a/source4/lib/ldb/Makefile.in b/source4/lib/ldb/Makefile.in index 756beb1fed..d88f82b726 100644 --- a/source4/lib/ldb/Makefile.in +++ b/source4/lib/ldb/Makefile.in @@ -125,7 +125,7 @@ realdistclean:: distclean check:: test @PYTHON_CHECK_TARGET@ -check-soloading: sample_module.$(SHLIBEXT) +check-soloading: sample.$(SHLIBEXT) LDB_MODULES_PATH=$(builddir) $(srcdir)/tests/test-soloading.sh test:: all check-soloading diff --git a/source4/lib/ldb/common/ldb.c b/source4/lib/ldb/common/ldb.c index 87f791cb38..ffda705a0b 100644 --- a/source4/lib/ldb/common/ldb.c +++ b/source4/lib/ldb/common/ldb.c @@ -135,6 +135,15 @@ int ldb_connect_backend(struct ldb_context *ldb, const char *url, const char *op } } + if (fn == NULL) { + char *symbol_name = talloc_asprintf(ldb, "ldb_%s_connect", backend); + if (symbol_name == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + fn = ldb_dso_load_symbol(ldb, backend, symbol_name); + talloc_free(symbol_name); + } + talloc_free(backend); if (fn == NULL) { diff --git a/source4/lib/ldb/common/ldb_modules.c b/source4/lib/ldb/common/ldb_modules.c index 18070bdb86..2dae40ddb0 100644 --- a/source4/lib/ldb/common/ldb_modules.c +++ b/source4/lib/ldb/common/ldb_modules.c @@ -257,8 +257,13 @@ int ldb_load_modules_list(struct ldb_context *ldb, const char **module_list, str } if (ops == NULL) { - ops = ldb_dso_load_symbol(ldb, module_list[i], - "ldb_module_ops"); + char *symbol_name = talloc_asprintf(ldb, "ldb_%s_module_ops", + module_list[i]); + if (symbol_name == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + ops = ldb_dso_load_symbol(ldb, module_list[i], symbol_name); + talloc_free(symbol_name); } if (ops == NULL) { diff --git a/source4/lib/ldb/ldb.mk b/source4/lib/ldb/ldb.mk index 6119f085d8..cc920178bc 100644 --- a/source4/lib/ldb/ldb.mk +++ b/source4/lib/ldb/ldb.mk @@ -31,7 +31,7 @@ lib/libldb.a: $(OBJS) ar -rv $@ $(OBJS) @-ranlib $@ -sample_module.$(SHLIBEXT): tests/sample_module.o +sample.$(SHLIBEXT): tests/sample_module.o $(MDLD) $(MDLD_FLAGS) -o $@ tests/sample_module.o bin/ldbadd: tools/ldbadd.o tools/cmdline.o $(LIBS) diff --git a/source4/lib/ldb/tests/sample_module.c b/source4/lib/ldb/tests/sample_module.c index 8ab1d33146..1a9e72c907 100644 --- a/source4/lib/ldb/tests/sample_module.c +++ b/source4/lib/ldb/tests/sample_module.c @@ -32,12 +32,7 @@ int sample_add(struct ldb_module *mod, struct ldb_request *req) return ldb_next_request(mod, req); } -static const struct ldb_module_ops sample_ops = { - .name = "sample_module", +const struct ldb_module_ops ldb_sample_module_ops = { + .name = "sample", .add = sample_add, }; - -int init_module(void) -{ - return ldb_register_module(&sample_ops); -} -- cgit From 16109a40c0abd8c30a5eb9bf9ef692bfae9dfc7d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 20 Feb 2008 01:54:32 +0100 Subject: Use struct-based rather than function-based initialization for ldb modules everywhere. (This used to be commit 85c96a325867f7bcdb412ebc53f8a47dbf7cd89b) --- source4/dsdb/samdb/ldb_modules/anr.c | 8 +---- source4/dsdb/samdb/ldb_modules/dsdb_cache.c | 7 +--- source4/dsdb/samdb/ldb_modules/extended_dn.c | 7 +--- source4/dsdb/samdb/ldb_modules/instancetype.c | 8 +---- source4/dsdb/samdb/ldb_modules/kludge_acl.c | 7 +--- source4/dsdb/samdb/ldb_modules/linked_attributes.c | 7 +--- source4/dsdb/samdb/ldb_modules/local_password.c | 8 +---- source4/dsdb/samdb/ldb_modules/naming_fsmo.c | 7 +--- source4/dsdb/samdb/ldb_modules/normalise.c | 7 +--- source4/dsdb/samdb/ldb_modules/objectclass.c | 8 +---- source4/dsdb/samdb/ldb_modules/objectguid.c | 8 +---- source4/dsdb/samdb/ldb_modules/partition.c | 7 +--- source4/dsdb/samdb/ldb_modules/password_hash.c | 8 +---- source4/dsdb/samdb/ldb_modules/pdc_fsmo.c | 7 +--- source4/dsdb/samdb/ldb_modules/proxy.c | 7 +--- source4/dsdb/samdb/ldb_modules/ranged_results.c | 7 +--- source4/dsdb/samdb/ldb_modules/repl_meta_data.c | 7 +--- source4/dsdb/samdb/ldb_modules/rootdse.c | 8 +---- source4/dsdb/samdb/ldb_modules/samba3sam.c | 17 ++-------- source4/dsdb/samdb/ldb_modules/samldb.c | 8 +---- source4/dsdb/samdb/ldb_modules/schema.c | 7 +--- source4/dsdb/samdb/ldb_modules/schema_fsmo.c | 7 +--- source4/dsdb/samdb/ldb_modules/show_deleted.c | 7 +--- source4/dsdb/samdb/ldb_modules/simple_ldap_map.c | 38 ++++------------------ source4/dsdb/samdb/ldb_modules/subtree_delete.c | 7 +--- source4/dsdb/samdb/ldb_modules/subtree_rename.c | 7 +--- source4/dsdb/samdb/ldb_modules/update_keytab.c | 7 +--- source4/lib/ldb/ldb_map/ldb_map.c | 38 +--------------------- source4/lib/ldb/ldb_map/ldb_map.h | 17 ++++++++-- source4/lib/ldb/ldb_map/ldb_map_private.h | 7 ---- source4/lib/ldb/modules/asq.c | 8 +---- source4/lib/ldb/modules/operational.c | 7 +--- source4/lib/ldb/modules/paged_results.c | 8 +---- source4/lib/ldb/modules/paged_searches.c | 8 +---- source4/lib/ldb/modules/rdn_name.c | 8 +---- source4/lib/ldb/modules/skel.c | 7 +--- source4/lib/ldb/modules/sort.c | 7 +--- source4/nbt_server/wins/wins_ldb.c | 9 +---- 38 files changed, 56 insertions(+), 306 deletions(-) diff --git a/source4/dsdb/samdb/ldb_modules/anr.c b/source4/dsdb/samdb/ldb_modules/anr.c index 908d9b088c..dd730c9b01 100644 --- a/source4/dsdb/samdb/ldb_modules/anr.c +++ b/source4/dsdb/samdb/ldb_modules/anr.c @@ -295,13 +295,7 @@ static int anr_search(struct ldb_module *module, struct ldb_request *req) return ldb_next_request(module, req); } -static const struct ldb_module_ops anr_ops = { +const struct ldb_module_ops ldb_anr_module_ops = { .name = "anr", .search = anr_search }; - -int ldb_anr_init(void) -{ - return ldb_register_module(&anr_ops); -} - diff --git a/source4/dsdb/samdb/ldb_modules/dsdb_cache.c b/source4/dsdb/samdb/ldb_modules/dsdb_cache.c index 4ca8bbf463..e73803ab38 100644 --- a/source4/dsdb/samdb/ldb_modules/dsdb_cache.c +++ b/source4/dsdb/samdb/ldb_modules/dsdb_cache.c @@ -36,12 +36,7 @@ static int dsdb_cache_init(struct ldb_module *module) return ldb_next_init(module); } -static const struct ldb_module_ops dsdb_cache_ops = { +const struct ldb_module_ops ldb_dsdb_cache_module_ops = { .name = "dsdb_cache", .init_context = dsdb_cache_init }; - -int dsdb_cache_module_init(void) -{ - return ldb_register_module(&dsdb_cache_ops); -} diff --git a/source4/dsdb/samdb/ldb_modules/extended_dn.c b/source4/dsdb/samdb/ldb_modules/extended_dn.c index 802f86570b..85b99800e9 100644 --- a/source4/dsdb/samdb/ldb_modules/extended_dn.c +++ b/source4/dsdb/samdb/ldb_modules/extended_dn.c @@ -362,13 +362,8 @@ static int extended_init(struct ldb_module *module) return ldb_next_init(module); } -static const struct ldb_module_ops extended_dn_ops = { +const struct ldb_module_ops ldb_extended_dn_module_ops = { .name = "extended_dn", .search = extended_search, .init_context = extended_init }; - -int ldb_extended_dn_init(void) -{ - return ldb_register_module(&extended_dn_ops); -} diff --git a/source4/dsdb/samdb/ldb_modules/instancetype.c b/source4/dsdb/samdb/ldb_modules/instancetype.c index 65df294e90..c0f8852503 100644 --- a/source4/dsdb/samdb/ldb_modules/instancetype.c +++ b/source4/dsdb/samdb/ldb_modules/instancetype.c @@ -118,13 +118,7 @@ static int instancetype_add(struct ldb_module *module, struct ldb_request *req) return ret; } -static const struct ldb_module_ops instancetype_ops = { +const struct ldb_module_ops ldb_instancetype_module_ops = { .name = "instancetype", .add = instancetype_add, }; - - -int ldb_instancetype_init(void) -{ - return ldb_register_module(&instancetype_ops); -} diff --git a/source4/dsdb/samdb/ldb_modules/kludge_acl.c b/source4/dsdb/samdb/ldb_modules/kludge_acl.c index ea33548b91..6395ebe2ed 100644 --- a/source4/dsdb/samdb/ldb_modules/kludge_acl.c +++ b/source4/dsdb/samdb/ldb_modules/kludge_acl.c @@ -471,7 +471,7 @@ done: return ldb_next_init(module); } -static const struct ldb_module_ops kludge_acl_ops = { +const struct ldb_module_ops ldb_kludge_acl_module_ops = { .name = "kludge_acl", .search = kludge_acl_search, .add = kludge_acl_change, @@ -481,8 +481,3 @@ static const struct ldb_module_ops kludge_acl_ops = { .extended = kludge_acl_change, .init_context = kludge_acl_init }; - -int ldb_kludge_acl_init(void) -{ - return ldb_register_module(&kludge_acl_ops); -} diff --git a/source4/dsdb/samdb/ldb_modules/linked_attributes.c b/source4/dsdb/samdb/ldb_modules/linked_attributes.c index b3fdffe566..d6e9d3da4f 100644 --- a/source4/dsdb/samdb/ldb_modules/linked_attributes.c +++ b/source4/dsdb/samdb/ldb_modules/linked_attributes.c @@ -915,7 +915,7 @@ static int linked_attributes_wait(struct ldb_handle *handle, enum ldb_wait_type } } -static const struct ldb_module_ops linked_attributes_ops = { +const struct ldb_module_ops ldb_linked_attributes_module_ops = { .name = "linked_attributes", .add = linked_attributes_add, .modify = linked_attributes_modify, @@ -923,8 +923,3 @@ static const struct ldb_module_ops linked_attributes_ops = { .rename = linked_attributes_rename, .wait = linked_attributes_wait, }; - -int ldb_linked_attributes_init(void) -{ - return ldb_register_module(&linked_attributes_ops); -} diff --git a/source4/dsdb/samdb/ldb_modules/local_password.c b/source4/dsdb/samdb/ldb_modules/local_password.c index 350434df51..f34acd5349 100644 --- a/source4/dsdb/samdb/ldb_modules/local_password.c +++ b/source4/dsdb/samdb/ldb_modules/local_password.c @@ -843,16 +843,10 @@ static int local_password_wait(struct ldb_handle *handle, enum ldb_wait_type typ } } -static const struct ldb_module_ops local_password_ops = { +const struct ldb_module_ops ldb_local_password_module_ops = { .name = "local_password", .add = local_password_add, .modify = local_password_modify, .search = local_password_search, .wait = local_password_wait }; - - -int local_password_module_init(void) -{ - return ldb_register_module(&local_password_ops); -} diff --git a/source4/dsdb/samdb/ldb_modules/naming_fsmo.c b/source4/dsdb/samdb/ldb_modules/naming_fsmo.c index d6b6a24287..94bef197e9 100644 --- a/source4/dsdb/samdb/ldb_modules/naming_fsmo.c +++ b/source4/dsdb/samdb/ldb_modules/naming_fsmo.c @@ -117,12 +117,7 @@ static int naming_fsmo_init(struct ldb_module *module) return ldb_next_init(module); } -static const struct ldb_module_ops naming_fsmo_ops = { +const struct ldb_module_ops ldb_naming_fsmo_module_ops = { .name = "naming_fsmo", .init_context = naming_fsmo_init }; - -int naming_fsmo_module_init(void) -{ - return ldb_register_module(&naming_fsmo_ops); -} diff --git a/source4/dsdb/samdb/ldb_modules/normalise.c b/source4/dsdb/samdb/ldb_modules/normalise.c index 7e3b63a145..2a713a52ff 100644 --- a/source4/dsdb/samdb/ldb_modules/normalise.c +++ b/source4/dsdb/samdb/ldb_modules/normalise.c @@ -156,12 +156,7 @@ static int normalise_search(struct ldb_module *module, struct ldb_request *req) } -static const struct ldb_module_ops normalise_ops = { +const struct ldb_module_ops ldb_normalise_module_ops = { .name = "normalise", .search = normalise_search, }; - -int ldb_normalise_init(void) -{ - return ldb_register_module(&normalise_ops); -} diff --git a/source4/dsdb/samdb/ldb_modules/objectclass.c b/source4/dsdb/samdb/ldb_modules/objectclass.c index 737475ca78..98eeed7cde 100644 --- a/source4/dsdb/samdb/ldb_modules/objectclass.c +++ b/source4/dsdb/samdb/ldb_modules/objectclass.c @@ -1153,16 +1153,10 @@ static int objectclass_wait(struct ldb_handle *handle, enum ldb_wait_type type) } } -static const struct ldb_module_ops objectclass_ops = { +const struct ldb_module_ops ldb_objectclass_module_ops = { .name = "objectclass", .add = objectclass_add, .modify = objectclass_modify, .rename = objectclass_rename, .wait = objectclass_wait }; - -int ldb_objectclass_init(void) -{ - return ldb_register_module(&objectclass_ops); -} - diff --git a/source4/dsdb/samdb/ldb_modules/objectguid.c b/source4/dsdb/samdb/ldb_modules/objectguid.c index bf57f5c21b..99dc46bc1f 100644 --- a/source4/dsdb/samdb/ldb_modules/objectguid.c +++ b/source4/dsdb/samdb/ldb_modules/objectguid.c @@ -247,14 +247,8 @@ static int objectguid_modify(struct ldb_module *module, struct ldb_request *req) return ret; } -static const struct ldb_module_ops objectguid_ops = { +const struct ldb_module_ops ldb_objectguid_module_ops = { .name = "objectguid", .add = objectguid_add, .modify = objectguid_modify, }; - - -int objectguid_module_init(void) -{ - return ldb_register_module(&objectguid_ops); -} diff --git a/source4/dsdb/samdb/ldb_modules/partition.c b/source4/dsdb/samdb/ldb_modules/partition.c index 61b64441a7..62dd0da8a1 100644 --- a/source4/dsdb/samdb/ldb_modules/partition.c +++ b/source4/dsdb/samdb/ldb_modules/partition.c @@ -1030,7 +1030,7 @@ static int partition_wait(struct ldb_handle *handle, enum ldb_wait_type type) } } -static const struct ldb_module_ops partition_ops = { +const struct ldb_module_ops ldb_partition_module_ops = { .name = "partition", .init_context = partition_init, .search = partition_search, @@ -1045,8 +1045,3 @@ static const struct ldb_module_ops partition_ops = { .del_transaction = partition_del_trans, .wait = partition_wait }; - -int ldb_partition_init(void) -{ - return ldb_register_module(&partition_ops); -} diff --git a/source4/dsdb/samdb/ldb_modules/password_hash.c b/source4/dsdb/samdb/ldb_modules/password_hash.c index 57c053d961..380045c1cf 100644 --- a/source4/dsdb/samdb/ldb_modules/password_hash.c +++ b/source4/dsdb/samdb/ldb_modules/password_hash.c @@ -2044,15 +2044,9 @@ static int password_hash_wait(struct ldb_handle *handle, enum ldb_wait_type type } } -static const struct ldb_module_ops password_hash_ops = { +const struct ldb_module_ops ldb_password_hash_module_ops = { .name = "password_hash", .add = password_hash_add, .modify = password_hash_modify, .wait = password_hash_wait }; - - -int password_hash_module_init(void) -{ - return ldb_register_module(&password_hash_ops); -} diff --git a/source4/dsdb/samdb/ldb_modules/pdc_fsmo.c b/source4/dsdb/samdb/ldb_modules/pdc_fsmo.c index 0f3293ed1d..270e79ecd8 100644 --- a/source4/dsdb/samdb/ldb_modules/pdc_fsmo.c +++ b/source4/dsdb/samdb/ldb_modules/pdc_fsmo.c @@ -115,12 +115,7 @@ static int pdc_fsmo_init(struct ldb_module *module) return ldb_next_init(module); } -static const struct ldb_module_ops pdc_fsmo_ops = { +const struct ldb_module_ops ldb_pdc_fsmo_module_ops = { .name = "pdc_fsmo", .init_context = pdc_fsmo_init }; - -int pdc_fsmo_module_init(void) -{ - return ldb_register_module(&pdc_fsmo_ops); -} diff --git a/source4/dsdb/samdb/ldb_modules/proxy.c b/source4/dsdb/samdb/ldb_modules/proxy.c index 37ee7f9fce..a7704ef413 100644 --- a/source4/dsdb/samdb/ldb_modules/proxy.c +++ b/source4/dsdb/samdb/ldb_modules/proxy.c @@ -331,12 +331,7 @@ static int proxy_request(struct ldb_module *module, struct ldb_request *req) } } -static const struct ldb_module_ops proxy_ops = { +const struct ldb_module_ops ldb_proxy_module_ops = { .name = "proxy", .request = proxy_request }; - -int proxy_module_init(void) -{ - return ldb_register_module(&proxy_ops); -} diff --git a/source4/dsdb/samdb/ldb_modules/ranged_results.c b/source4/dsdb/samdb/ldb_modules/ranged_results.c index c527afc6db..c6ebea1044 100644 --- a/source4/dsdb/samdb/ldb_modules/ranged_results.c +++ b/source4/dsdb/samdb/ldb_modules/ranged_results.c @@ -201,12 +201,7 @@ static int rr_search(struct ldb_module *module, struct ldb_request *req) return ldb_next_request(module, req); } -static const struct ldb_module_ops rr_ops = { +const struct ldb_module_ops ldb_ranged_results_module_ops = { .name = "ranged_results", .search = rr_search, }; - -int ldb_ranged_results_init(void) -{ - return ldb_register_module(&rr_ops); -} diff --git a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c index 441dbc9598..9184a8c0b2 100644 --- a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c +++ b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c @@ -1579,15 +1579,10 @@ static int replmd_wait(struct ldb_handle *handle, enum ldb_wait_type type) } } -static const struct ldb_module_ops replmd_ops = { +const struct ldb_module_ops ldb_repl_meta_data_module_ops = { .name = "repl_meta_data", .add = replmd_add, .modify = replmd_modify, .extended = replmd_extended, .wait = replmd_wait }; - -int repl_meta_data_module_init(void) -{ - return ldb_register_module(&replmd_ops); -} diff --git a/source4/dsdb/samdb/ldb_modules/rootdse.c b/source4/dsdb/samdb/ldb_modules/rootdse.c index 02f43d7076..80173084ec 100644 --- a/source4/dsdb/samdb/ldb_modules/rootdse.c +++ b/source4/dsdb/samdb/ldb_modules/rootdse.c @@ -386,15 +386,9 @@ static int rootdse_init(struct ldb_module *module) return ldb_next_init(module); } -static const struct ldb_module_ops rootdse_ops = { +const struct ldb_module_ops ldb_rootdse_module_ops = { .name = "rootdse", .init_context = rootdse_init, .search = rootdse_search, .request = rootdse_request }; - -int rootdse_module_init(void) -{ - return ldb_register_module(&rootdse_ops); -} - diff --git a/source4/dsdb/samdb/ldb_modules/samba3sam.c b/source4/dsdb/samdb/ldb_modules/samba3sam.c index 3a666b5380..4b1d432932 100644 --- a/source4/dsdb/samdb/ldb_modules/samba3sam.c +++ b/source4/dsdb/samdb/ldb_modules/samba3sam.c @@ -925,21 +925,8 @@ static int samba3sam_init(struct ldb_module *module) return ldb_next_init(module); } -static struct ldb_module_ops samba3sam_ops = { +const struct ldb_module_ops ldb_samba3sam_module_ops = { + LDB_MAP_OPS .name = "samba3sam", .init_context = samba3sam_init, }; - -/* the init function */ -int ldb_samba3sam_module_init(void) -{ - struct ldb_module_ops ops = ldb_map_get_ops(); - samba3sam_ops.add = ops.add; - samba3sam_ops.modify = ops.modify; - samba3sam_ops.del = ops.del; - samba3sam_ops.rename = ops.rename; - samba3sam_ops.search = ops.search; - samba3sam_ops.wait = ops.wait; - - return ldb_register_module(&samba3sam_ops); -} diff --git a/source4/dsdb/samdb/ldb_modules/samldb.c b/source4/dsdb/samdb/ldb_modules/samldb.c index baf419c750..44776f5956 100644 --- a/source4/dsdb/samdb/ldb_modules/samldb.c +++ b/source4/dsdb/samdb/ldb_modules/samldb.c @@ -750,14 +750,8 @@ static int samldb_init(struct ldb_module *module) return ldb_next_init(module); } -static const struct ldb_module_ops samldb_ops = { +const struct ldb_module_ops ldb_samldb_module_ops = { .name = "samldb", .init_context = samldb_init, .add = samldb_add, }; - - -int samldb_module_init(void) -{ - return ldb_register_module(&samldb_ops); -} diff --git a/source4/dsdb/samdb/ldb_modules/schema.c b/source4/dsdb/samdb/ldb_modules/schema.c index 525193ac8c..b6eb5ffb84 100644 --- a/source4/dsdb/samdb/ldb_modules/schema.c +++ b/source4/dsdb/samdb/ldb_modules/schema.c @@ -1221,7 +1221,7 @@ static int schema_init(struct ldb_module *module) return LDB_SUCCESS; } -static const struct ldb_module_ops schema_ops = { +const struct ldb_module_ops ldb_schema_module_ops = { .name = "schema", .init_context = schema_init, .add = schema_add, @@ -1230,8 +1230,3 @@ static const struct ldb_module_ops schema_ops = { .rename = schema_rename, .wait = schema_wait }; - -int ldb_schema_init(void) -{ - return ldb_register_module(&schema_ops); -} diff --git a/source4/dsdb/samdb/ldb_modules/schema_fsmo.c b/source4/dsdb/samdb/ldb_modules/schema_fsmo.c index f9dd131fd4..9c87747527 100644 --- a/source4/dsdb/samdb/ldb_modules/schema_fsmo.c +++ b/source4/dsdb/samdb/ldb_modules/schema_fsmo.c @@ -255,12 +255,7 @@ static int schema_fsmo_init(struct ldb_module *module) return ldb_next_init(module); } -static const struct ldb_module_ops schema_fsmo_ops = { +const struct ldb_module_ops ldb_schema_fsmo_module_ops = { .name = "schema_fsmo", .init_context = schema_fsmo_init }; - -int schema_fsmo_module_init(void) -{ - return ldb_register_module(&schema_fsmo_ops); -} diff --git a/source4/dsdb/samdb/ldb_modules/show_deleted.c b/source4/dsdb/samdb/ldb_modules/show_deleted.c index 19fa63fb6e..5e6b967b47 100644 --- a/source4/dsdb/samdb/ldb_modules/show_deleted.c +++ b/source4/dsdb/samdb/ldb_modules/show_deleted.c @@ -194,13 +194,8 @@ static int show_deleted_init(struct ldb_module *module) return ldb_next_init(module); } -static const struct ldb_module_ops show_deleted_ops = { +const struct ldb_module_ops ldb_show_deleted_module_ops = { .name = "show_deleted", .search = show_deleted_search, .init_context = show_deleted_init }; - -int ldb_show_deleted_init(void) -{ - return ldb_register_module(&show_deleted_ops); -} diff --git a/source4/dsdb/samdb/ldb_modules/simple_ldap_map.c b/source4/dsdb/samdb/ldb_modules/simple_ldap_map.c index acf2fd622c..dbb58856a0 100644 --- a/source4/dsdb/samdb/ldb_modules/simple_ldap_map.c +++ b/source4/dsdb/samdb/ldb_modules/simple_ldap_map.c @@ -793,42 +793,16 @@ static int entryuuid_sequence_number(struct ldb_module *module, struct ldb_reque return LDB_SUCCESS; } -static struct ldb_module_ops entryuuid_ops = { +const struct ldb_module_ops ldb_entryuuid_module_ops = { .name = "entryuuid", .init_context = entryuuid_init, - .sequence_number = entryuuid_sequence_number + .sequence_number = entryuuid_sequence_number, + LDB_MAP_OPS }; -static struct ldb_module_ops nsuniqueid_ops = { +const struct ldb_module_ops ldb_nsuniqueid_module_ops = { .name = "nsuniqueid", .init_context = nsuniqueid_init, - .sequence_number = entryuuid_sequence_number + .sequence_number = entryuuid_sequence_number, + LDB_MAP_OPS }; - -/* the init function */ -int ldb_simple_ldap_map_module_init(void) -{ - int ret; - struct ldb_module_ops ops = ldb_map_get_ops(); - entryuuid_ops.add = ops.add; - entryuuid_ops.modify = ops.modify; - entryuuid_ops.del = ops.del; - entryuuid_ops.rename = ops.rename; - entryuuid_ops.search = ops.search; - entryuuid_ops.wait = ops.wait; - ret = ldb_register_module(&entryuuid_ops); - - if (ret) { - return ret; - } - - nsuniqueid_ops.add = ops.add; - nsuniqueid_ops.modify = ops.modify; - nsuniqueid_ops.del = ops.del; - nsuniqueid_ops.rename = ops.rename; - nsuniqueid_ops.search = ops.search; - nsuniqueid_ops.wait = ops.wait; - ret = ldb_register_module(&nsuniqueid_ops); - - return ret; -} diff --git a/source4/dsdb/samdb/ldb_modules/subtree_delete.c b/source4/dsdb/samdb/ldb_modules/subtree_delete.c index e84bf60b32..56ae7b239a 100644 --- a/source4/dsdb/samdb/ldb_modules/subtree_delete.c +++ b/source4/dsdb/samdb/ldb_modules/subtree_delete.c @@ -247,13 +247,8 @@ static int subtree_delete_wait(struct ldb_handle *handle, enum ldb_wait_type typ } } -static const struct ldb_module_ops subtree_delete_ops = { +const struct ldb_module_ops ldb_subtree_delete_module_ops = { .name = "subtree_delete", .del = subtree_delete, .wait = subtree_delete_wait, }; - -int ldb_subtree_delete_init(void) -{ - return ldb_register_module(&subtree_delete_ops); -} diff --git a/source4/dsdb/samdb/ldb_modules/subtree_rename.c b/source4/dsdb/samdb/ldb_modules/subtree_rename.c index 0964c3fdcd..bf8124e253 100644 --- a/source4/dsdb/samdb/ldb_modules/subtree_rename.c +++ b/source4/dsdb/samdb/ldb_modules/subtree_rename.c @@ -264,13 +264,8 @@ static int subtree_rename_wait(struct ldb_handle *handle, enum ldb_wait_type typ } } -static const struct ldb_module_ops subtree_rename_ops = { +const struct ldb_module_ops ldb_subtree_rename_module_ops = { .name = "subtree_rename", .rename = subtree_rename, .wait = subtree_rename_wait, }; - -int ldb_subtree_rename_init(void) -{ - return ldb_register_module(&subtree_rename_ops); -} diff --git a/source4/dsdb/samdb/ldb_modules/update_keytab.c b/source4/dsdb/samdb/ldb_modules/update_keytab.c index a18efd757a..614f05f752 100644 --- a/source4/dsdb/samdb/ldb_modules/update_keytab.c +++ b/source4/dsdb/samdb/ldb_modules/update_keytab.c @@ -199,7 +199,7 @@ static int update_kt_init(struct ldb_module *module) return ldb_next_init(module); } -static const struct ldb_module_ops update_kt_ops = { +const struct ldb_module_ops ldb_update_keytab_module_ops = { .name = "update_keytab", .init_context = update_kt_init, .add = update_kt_add, @@ -209,8 +209,3 @@ static const struct ldb_module_ops update_kt_ops = { .end_transaction = update_kt_end_trans, .del_transaction = update_kt_del_trans, }; - -int ldb_update_kt_init(void) -{ - return ldb_register_module(&update_kt_ops); -} diff --git a/source4/lib/ldb/ldb_map/ldb_map.c b/source4/lib/ldb/ldb_map/ldb_map.c index 9582f36130..9c189feb11 100644 --- a/source4/lib/ldb/ldb_map/ldb_map.c +++ b/source4/lib/ldb/ldb_map/ldb_map.c @@ -1186,7 +1186,7 @@ static int map_wait_all(struct ldb_handle *handle) } /* Wait for pending requests to finish. */ -static int map_wait(struct ldb_handle *handle, enum ldb_wait_type type) +int map_wait(struct ldb_handle *handle, enum ldb_wait_type type) { if (type == LDB_WAIT_ALL) { return map_wait_all(handle); @@ -1199,16 +1199,6 @@ static int map_wait(struct ldb_handle *handle, enum ldb_wait_type type) /* Module initialization * ===================== */ -/* Provided module operations */ -static const struct ldb_module_ops map_ops = { - .name = "ldb_map", - .add = map_add, - .modify = map_modify, - .del = map_delete, - .rename = map_rename, - .search = map_search, - .wait = map_wait, -}; /* Builtin mappings for DNs and objectClasses */ static const struct ldb_map_attribute builtin_attribute_maps[] = { @@ -1344,12 +1334,6 @@ static int map_init_maps(struct ldb_module *module, struct ldb_map_context *data return LDB_SUCCESS; } -/* Copy the list of provided module operations. */ -_PUBLIC_ struct ldb_module_ops ldb_map_get_ops(void) -{ - return map_ops; -} - /* Initialize global private data. */ _PUBLIC_ int ldb_map_init(struct ldb_module *module, const struct ldb_map_attribute *attrs, const struct ldb_map_objectclass *ocls, @@ -1393,23 +1377,3 @@ _PUBLIC_ int ldb_map_init(struct ldb_module *module, const struct ldb_map_attrib return LDB_SUCCESS; } - -/* Usage note for initialization of this module: - * - * ldb_map is meant to be used from a different module that sets up - * the mappings and gets registered in ldb. - * - * 'ldb_map_init' initializes the private data of this module and - * stores the attribute and objectClass maps in there. It also looks - * up the '@MAP' special DN so requests can be redirected to the - * remote partition. - * - * This function should be called from the 'init_context' op of the - * module using ldb_map. - * - * 'ldb_map_get_ops' returns a copy of ldb_maps module operations. - * - * It should be called from the initialize function of the using - * module, which should then override the 'init_context' op with a - * function making the appropriate calls to 'ldb_map_init'. - */ diff --git a/source4/lib/ldb/ldb_map/ldb_map.h b/source4/lib/ldb/ldb_map/ldb_map.h index ef4da4e654..e40bb9cd7e 100644 --- a/source4/lib/ldb/ldb_map/ldb_map.h +++ b/source4/lib/ldb/ldb_map/ldb_map.h @@ -155,8 +155,19 @@ int ldb_map_init(struct ldb_module *module, const struct ldb_map_attribute *attr const char *add_objectclass, const char *name); -/* get copy of map_ops */ -struct ldb_module_ops -ldb_map_get_ops(void); +int map_add(struct ldb_module *module, struct ldb_request *req); +int map_search(struct ldb_module *module, struct ldb_request *req); +int map_rename(struct ldb_module *module, struct ldb_request *req); +int map_delete(struct ldb_module *module, struct ldb_request *req); +int map_modify(struct ldb_module *module, struct ldb_request *req); +int map_wait(struct ldb_handle *handle, enum ldb_wait_type type); + +#define LDB_MAP_OPS \ + .add = map_add, \ + .modify = map_modify, \ + .del = map_delete, \ + .rename = map_rename, \ + .search = map_search, \ + .wait = map_wait, #endif /* __LDB_MAP_H__ */ diff --git a/source4/lib/ldb/ldb_map/ldb_map_private.h b/source4/lib/ldb/ldb_map/ldb_map_private.h index 2c35097069..58a9f2704e 100644 --- a/source4/lib/ldb/ldb_map/ldb_map_private.h +++ b/source4/lib/ldb/ldb_map/ldb_map_private.h @@ -98,20 +98,13 @@ int map_subtree_collect_remote_simple(struct ldb_module *module, void *mem_ctx, /* The following definitions come from lib/ldb/modules/ldb_map_inbound.c */ int map_add_do_remote(struct ldb_handle *handle); int map_add_do_local(struct ldb_handle *handle); -int map_add(struct ldb_module *module, struct ldb_request *req); int map_modify_do_remote(struct ldb_handle *handle); int map_modify_do_local(struct ldb_handle *handle); -int map_modify(struct ldb_module *module, struct ldb_request *req); int map_delete_do_remote(struct ldb_handle *handle); int map_delete_do_local(struct ldb_handle *handle); -int map_delete(struct ldb_module *module, struct ldb_request *req); int map_rename_do_remote(struct ldb_handle *handle); int map_rename_do_fixup(struct ldb_handle *handle); int map_rename_do_local(struct ldb_handle *handle); -int map_rename(struct ldb_module *module, struct ldb_request *req); - -/* The following definitions come from lib/ldb/modules/ldb_map_outbound.c */ -int map_search(struct ldb_module *module, struct ldb_request *req); diff --git a/source4/lib/ldb/modules/asq.c b/source4/lib/ldb/modules/asq.c index b6a8594166..eb27263b16 100644 --- a/source4/lib/ldb/modules/asq.c +++ b/source4/lib/ldb/modules/asq.c @@ -473,15 +473,9 @@ static int asq_init(struct ldb_module *module) return ldb_next_init(module); } - -static const struct ldb_module_ops asq_ops = { +const struct ldb_module_ops ldb_asq_module_ops = { .name = "asq", .search = asq_search, .wait = asq_wait, .init_context = asq_init }; - -int ldb_asq_init(void) -{ - return ldb_register_module(&asq_ops); -} diff --git a/source4/lib/ldb/modules/operational.c b/source4/lib/ldb/modules/operational.c index 45f23aa0c1..7dc4ae08c3 100644 --- a/source4/lib/ldb/modules/operational.c +++ b/source4/lib/ldb/modules/operational.c @@ -304,13 +304,8 @@ static int operational_init(struct ldb_module *ctx) return ldb_next_init(ctx); } -static const struct ldb_module_ops operational_ops = { +const struct ldb_module_ops ldb_operational_module_ops = { .name = "operational", .search = operational_search, .init_context = operational_init }; - -int ldb_operational_init(void) -{ - return ldb_register_module(&operational_ops); -} diff --git a/source4/lib/ldb/modules/paged_results.c b/source4/lib/ldb/modules/paged_results.c index ee1bbe0335..b62b1f92cb 100644 --- a/source4/lib/ldb/modules/paged_results.c +++ b/source4/lib/ldb/modules/paged_results.c @@ -549,15 +549,9 @@ static int paged_request_init(struct ldb_module *module) return ldb_next_init(module); } -static const struct ldb_module_ops paged_ops = { +const struct ldb_module_ops ldb_paged_results_module_ops = { .name = "paged_results", .search = paged_search, .wait = paged_wait, .init_context = paged_request_init }; - -int ldb_paged_results_init(void) -{ - return ldb_register_module(&paged_ops); -} - diff --git a/source4/lib/ldb/modules/paged_searches.c b/source4/lib/ldb/modules/paged_searches.c index fd580a3c4a..88ebd13921 100644 --- a/source4/lib/ldb/modules/paged_searches.c +++ b/source4/lib/ldb/modules/paged_searches.c @@ -455,15 +455,9 @@ static int ps_init(struct ldb_module *module) return ldb_next_init(module); } -static const struct ldb_module_ops ps_ops = { +const struct ldb_module_ops ldb_pages_searches_module_ops = { .name = "paged_searches", .search = ps_search, .wait = ps_wait, .init_context = ps_init }; - -int ldb_paged_searches_init(void) -{ - return ldb_register_module(&ps_ops); -} - diff --git a/source4/lib/ldb/modules/rdn_name.c b/source4/lib/ldb/modules/rdn_name.c index 1a0ddbb3c4..c4de8e8da8 100644 --- a/source4/lib/ldb/modules/rdn_name.c +++ b/source4/lib/ldb/modules/rdn_name.c @@ -326,15 +326,9 @@ static int rdn_name_wait(struct ldb_handle *handle, enum ldb_wait_type type) return rdn_name_wait_once(handle); } -static const struct ldb_module_ops rdn_name_ops = { +const struct ldb_module_ops ldb_rdn_name_module_ops = { .name = "rdn_name", .add = rdn_name_add, .rename = rdn_name_rename, .wait = rdn_name_wait }; - - -int ldb_rdn_name_init(void) -{ - return ldb_register_module(&rdn_name_ops); -} diff --git a/source4/lib/ldb/modules/skel.c b/source4/lib/ldb/modules/skel.c index 5400c502f1..0cd29ac4b7 100644 --- a/source4/lib/ldb/modules/skel.c +++ b/source4/lib/ldb/modules/skel.c @@ -116,7 +116,7 @@ static int skel_init(struct ldb_module *module) return ldb_next_init(module); } -static const struct ldb_module_ops skel_ops = { +const struct ldb_module_ops ldb_skel_module_ops = { .name = "skel", .init_context = skel_init, .search = skel_search, @@ -129,8 +129,3 @@ static const struct ldb_module_ops skel_ops = { .end_transaction = skel_end_trans, .del_transaction = skel_del_trans, }; - -int ldb_skel_init(void) -{ - return ldb_register_module(&skel_ops); -} diff --git a/source4/lib/ldb/modules/sort.c b/source4/lib/ldb/modules/sort.c index 89b9a4fb19..746befa559 100644 --- a/source4/lib/ldb/modules/sort.c +++ b/source4/lib/ldb/modules/sort.c @@ -450,14 +450,9 @@ static int server_sort_init(struct ldb_module *module) return ldb_next_init(module); } -static const struct ldb_module_ops server_sort_ops = { +const struct ldb_module_ops ldb_server_sort_module_ops = { .name = "server_sort", .search = server_sort_search, .wait = server_sort_wait, .init_context = server_sort_init }; - -int ldb_sort_init(void) -{ - return ldb_register_module(&server_sort_ops); -} diff --git a/source4/nbt_server/wins/wins_ldb.c b/source4/nbt_server/wins/wins_ldb.c index 47aa415667..04468556ef 100644 --- a/source4/nbt_server/wins/wins_ldb.c +++ b/source4/nbt_server/wins/wins_ldb.c @@ -112,16 +112,9 @@ failed: return LDB_ERR_OTHER; } -static const struct ldb_module_ops wins_ldb_ops = { +const struct ldb_module_ops ldb_wins_ldb_module_ops = { .name = "wins_ldb", .add = wins_ldb_verify, .modify = wins_ldb_verify, .init_context = wins_ldb_init }; - - -/* the init function */ -int wins_ldb_module_init(void) -{ - return ldb_register_module(&wins_ldb_ops); -} -- cgit From e3661a6181a7fbeffb02745adda509c01779d5ca Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 20 Feb 2008 01:56:55 +0100 Subject: Use function-based initialization for ildap backend. (This used to be commit 46e5027f56722fbe19af36aad1ab03ea1c862f43) --- source4/lib/ldb/ldb_ildap/ldb_ildap.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/source4/lib/ldb/ldb_ildap/ldb_ildap.c b/source4/lib/ldb/ldb_ildap/ldb_ildap.c index a834e912d4..8ad6830c43 100644 --- a/source4/lib/ldb/ldb_ildap/ldb_ildap.c +++ b/source4/lib/ldb/ldb_ildap/ldb_ildap.c @@ -811,9 +811,6 @@ failed: return -1; } -int ldb_ildap_init(void) -{ - return ldb_register_backend("ldap", ildb_connect) + - ldb_register_backend("ldapi", ildb_connect) + - ldb_register_backend("ldaps", ildb_connect); -} +ldb_connect_fn ldb_ldap_connect = ildb_connect; +ldb_connect_fn ldb_ldapi_connect = ildb_connect; +ldb_connect_fn ldb_ldaps_connect = ildb_connect; -- cgit From 995788536e5ba7b3a0e67e377a9769b279d0b8ae Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 20 Feb 2008 02:57:07 +0100 Subject: Remove more function-based inits. (This used to be commit b1a7810f3e70f9a831d9b8e85d531e448072adaf) --- source4/lib/ldb/common/ldb.c | 59 +++++++++++++++++++++------ source4/lib/ldb/common/ldb_modules.c | 66 ++++++++++--------------------- source4/lib/ldb/include/ldb_private.h | 37 +++++++++++------ source4/lib/ldb/ldb_ildap/ldb_ildap.c | 18 +++++++-- source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c | 8 ++-- source4/lib/ldb/ldb_tdb/ldb_tdb.c | 8 ++-- 6 files changed, 118 insertions(+), 78 deletions(-) diff --git a/source4/lib/ldb/common/ldb.c b/source4/lib/ldb/common/ldb.c index ffda705a0b..ce69256c69 100644 --- a/source4/lib/ldb/common/ldb.c +++ b/source4/lib/ldb/common/ldb.c @@ -56,20 +56,51 @@ struct ldb_context *ldb_init(void *mem_ctx) return ldb; } -struct ldb_backend { - const char *name; - ldb_connect_fn connect_fn; - struct ldb_backend *prev, *next; +static struct backends_list_entry { + struct ldb_backend_ops *ops; + struct backends_list_entry *prev, *next; } *ldb_backends = NULL; +#ifndef STATIC_LIBLDB_BACKENDS + +#ifdef HAVE_LDB_LDAP +#define LDAP_INIT &ldb_ldap_backend_ops, \ + &ldb_ildap_backend_ops, \ + &ldb_ldaps_backend_ops, +#else +#define LDAP_INIT +#endif + +#ifdef HAVE_LDB_SQLITE3 +#define SQLITE3_INIT &ldb_sqlite3_backend_ops, +#else +#define SQLITE3_INIT +#endif + +#define STATIC_LIBLDB_BACKENDS \ + LDAP_INIT \ + SQLITE3_INIT \ + &ldb_tdb_backend_ops, \ + NULL +#endif + +const static struct ldb_backend_ops *builtin_backends[] = { + STATIC_LIBLDB_BACKENDS +}; static ldb_connect_fn ldb_find_backend(const char *url) { - struct ldb_backend *backend; + struct backends_list_entry *backend; + int i; + + for (i = 0; builtin_backends[i]; i++) { + if (strncmp(builtin_backends[i]->name, url, strlen(builtin_backends[i]->name)) == 0) + return builtin_backends[i]->connect_fn; + } for (backend = ldb_backends; backend; backend = backend->next) { - if (strncmp(backend->name, url, strlen(backend->name)) == 0) { - return backend->connect_fn; + if (strncmp(backend->ops->name, url, strlen(backend->ops->name)) == 0) { + return backend->ops->connect_fn; } } @@ -81,7 +112,8 @@ static ldb_connect_fn ldb_find_backend(const char *url) */ int ldb_register_backend(const char *url_prefix, ldb_connect_fn connectfn) { - struct ldb_backend *backend = talloc(talloc_autofree_context(), struct ldb_backend); + struct ldb_backend_ops *backend = talloc(talloc_autofree_context(), struct ldb_backend_ops); + struct backends_list_entry *entry = talloc(talloc_autofree_context(), struct backends_list_entry); if (ldb_find_backend(url_prefix)) { return LDB_SUCCESS; @@ -91,7 +123,8 @@ int ldb_register_backend(const char *url_prefix, ldb_connect_fn connectfn) backend->name = talloc_strdup(backend, url_prefix); backend->connect_fn = connectfn; - DLIST_ADD(ldb_backends, backend); + entry->ops = backend; + DLIST_ADD(ldb_backends, entry); return LDB_SUCCESS; } @@ -136,11 +169,15 @@ int ldb_connect_backend(struct ldb_context *ldb, const char *url, const char *op } if (fn == NULL) { - char *symbol_name = talloc_asprintf(ldb, "ldb_%s_connect", backend); + struct ldb_backend_ops *ops; + char *symbol_name = talloc_asprintf(ldb, "ldb_%s_backend_ops", backend); if (symbol_name == NULL) { return LDB_ERR_OPERATIONS_ERROR; } - fn = ldb_dso_load_symbol(ldb, backend, symbol_name); + ops = ldb_dso_load_symbol(ldb, backend, symbol_name); + if (ops != NULL) { + fn = ops->connect_fn; + } talloc_free(symbol_name); } diff --git a/source4/lib/ldb/common/ldb_modules.c b/source4/lib/ldb/common/ldb_modules.c index 2dae40ddb0..7da7b9ba34 100644 --- a/source4/lib/ldb/common/ldb_modules.c +++ b/source4/lib/ldb/common/ldb_modules.c @@ -126,9 +126,30 @@ static struct ops_list_entry { struct ops_list_entry *next; } *registered_modules = NULL; +#ifndef STATIC_LIBLDB_MODULES + +#define STATIC_LIBLDB_MODULES \ + ldb_operational_module_ops, \ + ldb_rdn_name_module_ops, \ + ldb_paged_results_module_ops, \ + ldb_sort_module_ops, \ + ldb_asq_module_ops, \ + NULL +#endif + +const static struct ldb_module_ops *builtin_modules[] = { + STATIC_LIBLDB_MODULES +}; + static const struct ldb_module_ops *ldb_find_module_ops(const char *name) { struct ops_list_entry *e; + int i; + + for (i = 0; builtin_modules[i]; i++) { + if (strcmp(builtin_modules[i]->name, name) == 0) + return builtin_modules[i]; + } for (e = registered_modules; e; e = e->next) { if (strcmp(e->ops->name, name) == 0) @@ -138,51 +159,6 @@ static const struct ldb_module_ops *ldb_find_module_ops(const char *name) return NULL; } -#ifndef STATIC_LIBLDB_MODULES - -#ifdef HAVE_LDB_LDAP -#define LDAP_INIT ldb_ldap_init, -#else -#define LDAP_INIT -#endif - -#ifdef HAVE_LDB_SQLITE3 -#define SQLITE3_INIT ldb_sqlite3_init, -#else -#define SQLITE3_INIT -#endif - -#define STATIC_LIBLDB_MODULES \ - LDAP_INIT \ - SQLITE3_INIT \ - ldb_tdb_init, \ - ldb_operational_init, \ - ldb_rdn_name_init, \ - ldb_paged_results_init, \ - ldb_sort_init, \ - ldb_asq_init, \ - NULL -#endif - -int ldb_global_init(void) -{ - int (*static_init_fns[])(void) = { STATIC_LIBLDB_MODULES }; - - static int initialized = 0; - int ret = 0, i; - - if (initialized) - return 0; - - initialized = 1; - - for (i = 0; static_init_fns[i]; i++) { - if (static_init_fns[i]() == -1) - ret = -1; - } - - return ret; -} int ldb_register_module(const struct ldb_module_ops *ops) { diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index d9f2defdc9..d2dcc675a5 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -41,6 +41,8 @@ struct ldb_context; struct ldb_module_ops; +struct ldb_backend_ops; + /* basic module structure */ struct ldb_module { struct ldb_module *prev, *next; @@ -70,9 +72,16 @@ struct ldb_module_ops { int (*sequence_number)(struct ldb_module *, struct ldb_request *); }; + typedef int (*ldb_connect_fn) (struct ldb_context *ldb, const char *url, unsigned int flags, const char *options[], struct ldb_module **module); + +struct ldb_backend_ops { + const char *name; + ldb_connect_fn connect_fn; +}; + const char *ldb_default_modules_dir(void); /* @@ -170,17 +179,23 @@ void ldb_debug_set(struct ldb_context *ldb, enum ldb_debug_level level, /* The following definitions come from lib/ldb/common/ldb_ldif.c */ int ldb_should_b64_encode(const struct ldb_val *val); -int ldb_objectclass_init(void); -int ldb_operational_init(void); -int ldb_paged_results_init(void); -int ldb_rdn_name_init(void); -int ldb_schema_init(void); -int ldb_asq_init(void); -int ldb_sort_init(void); -int ldb_ldap_init(void); -int ldb_ildap_init(void); -int ldb_tdb_init(void); -int ldb_sqlite3_init(void); +extern const struct ldb_module_ops ldb_objectclass_module_ops; +extern const struct ldb_module_ops ldb_operational_module_ops; +extern const struct ldb_module_ops ldb_paged_results_module_ops; +extern const struct ldb_module_ops ldb_rdn_name_module_ops; +extern const struct ldb_module_ops ldb_schema_module_ops; +extern const struct ldb_module_ops ldb_asq_module_ops; +extern const struct ldb_module_ops ldb_sort_module_ops; +extern const struct ldb_module_ops ldb_ldap_module_ops; +extern const struct ldb_module_ops ldb_ildap_module_ops; +extern const struct ldb_module_ops ldb_tdb_module_ops; +extern const struct ldb_module_ops ldb_sqlite3_module_ops; + +extern const struct ldb_backend_ops ldb_tdb_backend_ops; +extern const struct ldb_backend_ops ldb_sqlite3_backend_ops; +extern const struct ldb_backend_ops ldb_ldap_backend_ops; +extern const struct ldb_backend_ops ldb_ildap_backend_ops; +extern const struct ldb_backend_ops ldb_ldaps_backend_ops; int ldb_match_msg(struct ldb_context *ldb, const struct ldb_message *msg, diff --git a/source4/lib/ldb/ldb_ildap/ldb_ildap.c b/source4/lib/ldb/ldb_ildap/ldb_ildap.c index 8ad6830c43..fb7100e3c1 100644 --- a/source4/lib/ldb/ldb_ildap/ldb_ildap.c +++ b/source4/lib/ldb/ldb_ildap/ldb_ildap.c @@ -811,6 +811,18 @@ failed: return -1; } -ldb_connect_fn ldb_ldap_connect = ildb_connect; -ldb_connect_fn ldb_ldapi_connect = ildb_connect; -ldb_connect_fn ldb_ldaps_connect = ildb_connect; +const struct ldb_backend_ops ldb_ldap_backend_ops { + .name = "ldap", + .connect_fn = ildb_connect +}; + +const struct ldb_backend_ops ldb_ildap_backend_ops { + .name = "ildap", + .connect_fn = ildb_connect +}; + +const struct ldb_backend_ops ldb_ldaps_backend_ops { + .name = "ldaps", + .connect_fn = ildb_connect +}; + diff --git a/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c b/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c index 1ec3b1aabd..8742e257f3 100644 --- a/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c +++ b/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c @@ -1903,7 +1903,7 @@ failed: return -1; } -int ldb_sqlite3_init(void) -{ - return ldb_register_backend("sqlite3", lsqlite3_connect); -} +const struct ldb_backend_ops ldb_sqlite3_backend_ops = { + .name = "sqlite3", + .connect_fn = lsqlite3_connect +}; diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb.c b/source4/lib/ldb/ldb_tdb/ldb_tdb.c index 45a8109584..11d6c30710 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_tdb.c +++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.c @@ -1107,7 +1107,7 @@ static int ltdb_connect(struct ldb_context *ldb, const char *url, return 0; } -int ldb_tdb_init(void) -{ - return ldb_register_backend("tdb", ltdb_connect); -} +const struct ldb_backend_ops ldb_tdb_backend_ops = { + .name = "tdb", + .connect_fn = ltdb_connect +}; -- cgit From 84f69645c2050434963de9eacf0f61e712d74879 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 20 Feb 2008 03:21:38 +0100 Subject: Require at least talloc 1.2.0. (This used to be commit e464a344bc11587abc5c663bc8d6471eeb314959) --- source4/configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source4/configure.ac b/source4/configure.ac index 1c17126f4a..b609b4f52c 100644 --- a/source4/configure.ac +++ b/source4/configure.ac @@ -35,7 +35,7 @@ AC_CONFIG_FILES(auth/gensec/gensec.pc) AC_CONFIG_FILES(param/samba-config.pc) AC_CONFIG_FILES(librpc/dcerpc_samr.pc) -SMB_EXT_LIB_FROM_PKGCONFIG(LIBTALLOC, talloc >= 1.1.0, +SMB_EXT_LIB_FROM_PKGCONFIG(LIBTALLOC, talloc >= 1.2.0, [], [ m4_include(lib/talloc/libtalloc.m4) -- cgit From 0020793515ade04f3ef5754717490e2eb2ca6bb9 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 20 Feb 2008 03:40:44 +0100 Subject: Fix static module list generation for ldb. (This used to be commit 92c1c0e9137f0845cac6cc96bf78711b6aaffe21) --- source4/build/smb_build/header.pm | 10 ++++++++-- source4/lib/ldb/common/ldb.c | 1 - source4/lib/ldb/config.mk | 19 +++++++++---------- source4/lib/ldb/ldb_ildap/config.mk | 1 - source4/lib/ldb/modules/paged_searches.c | 2 +- source4/lib/ldb/nssldb/ldb-nss.c | 5 ----- source4/lib/ldb/tools/ad2oLschema.c | 2 -- source4/lib/ldb/tools/cmdline.c | 2 -- source4/lib/ldb/tools/ldbadd.c | 2 -- source4/lib/ldb/tools/ldbdel.c | 2 -- source4/lib/ldb/tools/ldbedit.c | 2 -- source4/lib/ldb/tools/ldbmodify.c | 2 -- source4/lib/ldb/tools/ldbrename.c | 2 -- source4/lib/ldb/tools/ldbsearch.c | 2 -- source4/lib/ldb/tools/ldbtest.c | 2 -- source4/lib/ldb/tools/oLschema2ldif.c | 2 -- source4/scripting/ejs/smbscript.c | 2 -- source4/smbd/server.c | 2 -- source4/torture/smbtorture.c | 2 -- source4/utils/net/net.c | 2 -- 20 files changed, 18 insertions(+), 48 deletions(-) diff --git a/source4/build/smb_build/header.pm b/source4/build/smb_build/header.pm index 93240f1d17..c2bdbaf4c8 100644 --- a/source4/build/smb_build/header.pm +++ b/source4/build/smb_build/header.pm @@ -44,8 +44,14 @@ sub _prepare_build_h($) $DEFINE->{VAL} .= "\t$_, \\\n"; unless (/{/) { my $fn = $key->{INIT_FUNCTION_TYPE}; - $fn =~ s/\(\*\)/$_/; - $output .= "$fn;\n"; + my $n = $_; + if ($fn =~ /\(\*\)/) { + $fn =~ s/\(\*\)/$n/; + $output .= "$fn;\n"; + } else { + $n =~ s/\&//; + $output .= "$fn $n;\n"; + } } } diff --git a/source4/lib/ldb/common/ldb.c b/source4/lib/ldb/common/ldb.c index ce69256c69..5f2e5e3ffc 100644 --- a/source4/lib/ldb/common/ldb.c +++ b/source4/lib/ldb/common/ldb.c @@ -282,7 +282,6 @@ int ldb_connect(struct ldb_context *ldb, const char *url, unsigned int flags, co int ret; const char *url2; /* We seem to need to do this here, or else some utilities don't get ldb backends */ - ldb_global_init(); ldb->flags = flags; diff --git a/source4/lib/ldb/config.mk b/source4/lib/ldb/config.mk index 0e7caa381f..b44a317a70 100644 --- a/source4/lib/ldb/config.mk +++ b/source4/lib/ldb/config.mk @@ -3,7 +3,7 @@ [MODULE::ldb_asq] PRIVATE_DEPENDENCIES = LIBTALLOC CFLAGS = -Ilib/ldb/include -INIT_FUNCTION = ldb_asq_init +INIT_FUNCTION = &ldb_asq_module_ops SUBSYSTEM = LIBLDB OBJ_FILES = \ modules/asq.o @@ -15,7 +15,7 @@ OBJ_FILES = \ [MODULE::ldb_server_sort] PRIVATE_DEPENDENCIES = LIBTALLOC CFLAGS = -Ilib/ldb/include -INIT_FUNCTION = ldb_sort_init +INIT_FUNCTION = &ldb_server_sort_module_ops SUBSYSTEM = LIBLDB OBJ_FILES = \ modules/sort.o @@ -25,7 +25,7 @@ OBJ_FILES = \ ################################################ # Start MODULE ldb_paged_results [MODULE::ldb_paged_results] -INIT_FUNCTION = ldb_paged_results_init +INIT_FUNCTION = &ldb_paged_results_module_ops CFLAGS = -Ilib/ldb/include PRIVATE_DEPENDENCIES = LIBTALLOC SUBSYSTEM = LIBLDB @@ -37,7 +37,7 @@ OBJ_FILES = \ ################################################ # Start MODULE ldb_paged_results [MODULE::ldb_paged_searches] -INIT_FUNCTION = ldb_paged_searches_init +INIT_FUNCTION = &ldb_paged_searches_module_ops CFLAGS = -Ilib/ldb/include PRIVATE_DEPENDENCIES = LIBTALLOC SUBSYSTEM = LIBLDB @@ -52,7 +52,7 @@ OBJ_FILES = \ SUBSYSTEM = LIBLDB CFLAGS = -Ilib/ldb/include PRIVATE_DEPENDENCIES = LIBTALLOC -INIT_FUNCTION = ldb_operational_init +INIT_FUNCTION = &ldb_operational_module_ops OBJ_FILES = \ modules/operational.o # End MODULE ldb_operational @@ -64,7 +64,7 @@ OBJ_FILES = \ SUBSYSTEM = LIBLDB CFLAGS = -Ilib/ldb/include PRIVATE_DEPENDENCIES = LIBTALLOC -INIT_FUNCTION = ldb_rdn_name_init +INIT_FUNCTION = &ldb_rdn_name_module_ops OBJ_FILES = \ modules/rdn_name.o # End MODULE ldb_rdn_name @@ -88,7 +88,7 @@ OBJ_FILES = \ SUBSYSTEM = LIBLDB CFLAGS = -Ilib/ldb/include PRIVATE_DEPENDENCIES = LIBTALLOC -INIT_FUNCTION = ldb_skel_init +INIT_FUNCTION = &ldb_skel_module_ops OBJ_FILES = modules/skel.o # End MODULE ldb_skel ################################################ @@ -99,7 +99,7 @@ OBJ_FILES = modules/skel.o SUBSYSTEM = LIBLDB CFLAGS = -Ilib/ldb/include PRIVATE_DEPENDENCIES = LIBTALLOC SQLITE3 LIBTALLOC -INIT_FUNCTION = ldb_sqlite3_init +INIT_FUNCTION = &ldb_sqlite3_module_ops OBJ_FILES = \ ldb_sqlite3/ldb_sqlite3.o # End MODULE ldb_sqlite3 @@ -110,7 +110,6 @@ OBJ_FILES = \ [MODULE::ldb_tdb] SUBSYSTEM = LIBLDB CFLAGS = -Ilib/ldb/include -Ilib/ldb/ldb_tdb -INIT_FUNCTION = ldb_tdb_init OBJ_FILES = \ ldb_tdb/ldb_tdb.o \ ldb_tdb/ldb_search.o \ @@ -131,7 +130,7 @@ SO_VERSION = 0 OUTPUT_TYPE = SHARED_LIBRARY CFLAGS = -Ilib/ldb/include PC_FILE = ldb.pc -INIT_FUNCTION_TYPE = int (*) (void) +INIT_FUNCTION_TYPE = extern const struct ldb_module_ops OBJ_FILES = \ common/ldb.o \ common/ldb_ldif.o \ diff --git a/source4/lib/ldb/ldb_ildap/config.mk b/source4/lib/ldb/ldb_ildap/config.mk index 01d9ec88ff..3062dc886f 100644 --- a/source4/lib/ldb/ldb_ildap/config.mk +++ b/source4/lib/ldb/ldb_ildap/config.mk @@ -5,7 +5,6 @@ SUBSYSTEM = LIBLDB CFLAGS = -Ilib/ldb/include OUTPUT_TYPE = SHARED_LIBRARY PRIVATE_DEPENDENCIES = LIBTALLOC LIBCLI_LDAP CREDENTIALS -INIT_FUNCTION = ldb_ildap_init ALIASES = ldapi ldaps ldap OBJ_FILES = \ ldb_ildap.o diff --git a/source4/lib/ldb/modules/paged_searches.c b/source4/lib/ldb/modules/paged_searches.c index 88ebd13921..7406e91c9d 100644 --- a/source4/lib/ldb/modules/paged_searches.c +++ b/source4/lib/ldb/modules/paged_searches.c @@ -455,7 +455,7 @@ static int ps_init(struct ldb_module *module) return ldb_next_init(module); } -const struct ldb_module_ops ldb_pages_searches_module_ops = { +const struct ldb_module_ops ldb_paged_searches_module_ops = { .name = "paged_searches", .search = ps_search, .wait = ps_wait, diff --git a/source4/lib/ldb/nssldb/ldb-nss.c b/source4/lib/ldb/nssldb/ldb-nss.c index 199212dbbf..e256f41a4d 100644 --- a/source4/lib/ldb/nssldb/ldb-nss.c +++ b/source4/lib/ldb/nssldb/ldb-nss.c @@ -45,11 +45,6 @@ NSS_STATUS _ldb_nss_init(void) _ldb_nss_ctx->pid = mypid; - ret = ldb_global_init(); - if (ret != 0) { - goto failed; - } - _ldb_nss_ctx->ldb = ldb_init(_ldb_nss_ctx); if (_ldb_nss_ctx->ldb == NULL) { goto failed; diff --git a/source4/lib/ldb/tools/ad2oLschema.c b/source4/lib/ldb/tools/ad2oLschema.c index dec8a5f972..67b16dd06e 100644 --- a/source4/lib/ldb/tools/ad2oLschema.c +++ b/source4/lib/ldb/tools/ad2oLschema.c @@ -656,8 +656,6 @@ static struct schema_conv process_convert(struct ldb_context *ldb, enum convert_ const char *target_str; enum convert_target target; - ldb_global_init(); - ctx = talloc_new(NULL); ldb = ldb_init(ctx); diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index 8ee1994615..c9c77c4e47 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -80,8 +80,6 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, { NULL } }; - ldb_global_init(); - #if (_SAMBA_BUILD_ >= 4) r = ldb_register_samba_handlers(ldb); if (r != 0) { diff --git a/source4/lib/ldb/tools/ldbadd.c b/source4/lib/ldb/tools/ldbadd.c index d34193b86c..4ee66c4fc0 100644 --- a/source4/lib/ldb/tools/ldbadd.c +++ b/source4/lib/ldb/tools/ldbadd.c @@ -88,8 +88,6 @@ int main(int argc, const char **argv) int i, ret=0, count=0; struct ldb_cmdline *options; - ldb_global_init(); - ldb = ldb_init(NULL); options = ldb_cmdline_process(ldb, argc, argv, usage); diff --git a/source4/lib/ldb/tools/ldbdel.c b/source4/lib/ldb/tools/ldbdel.c index fcd0978779..184172b22b 100644 --- a/source4/lib/ldb/tools/ldbdel.c +++ b/source4/lib/ldb/tools/ldbdel.c @@ -77,8 +77,6 @@ int main(int argc, const char **argv) int ret = 0, i; struct ldb_cmdline *options; - ldb_global_init(); - ldb = ldb_init(NULL); options = ldb_cmdline_process(ldb, argc, argv, usage); diff --git a/source4/lib/ldb/tools/ldbedit.c b/source4/lib/ldb/tools/ldbedit.c index ed98a6d615..a9fd064bf8 100644 --- a/source4/lib/ldb/tools/ldbedit.c +++ b/source4/lib/ldb/tools/ldbedit.c @@ -279,8 +279,6 @@ int main(int argc, const char **argv) const char *expression = "(|(objectClass=*)(distinguishedName=*))"; const char * const * attrs = NULL; - ldb_global_init(); - ldb = ldb_init(NULL); options = ldb_cmdline_process(ldb, argc, argv, usage); diff --git a/source4/lib/ldb/tools/ldbmodify.c b/source4/lib/ldb/tools/ldbmodify.c index ed12380095..dd6206b824 100644 --- a/source4/lib/ldb/tools/ldbmodify.c +++ b/source4/lib/ldb/tools/ldbmodify.c @@ -89,8 +89,6 @@ int main(int argc, const char **argv) int i, ret=LDB_SUCCESS; struct ldb_cmdline *options; - ldb_global_init(); - ldb = ldb_init(NULL); options = ldb_cmdline_process(ldb, argc, argv, usage); diff --git a/source4/lib/ldb/tools/ldbrename.c b/source4/lib/ldb/tools/ldbrename.c index c160e87ee4..b36310a500 100644 --- a/source4/lib/ldb/tools/ldbrename.c +++ b/source4/lib/ldb/tools/ldbrename.c @@ -56,8 +56,6 @@ int main(int argc, const char **argv) struct ldb_cmdline *options; struct ldb_dn *dn1, *dn2; - ldb_global_init(); - ldb = ldb_init(NULL); options = ldb_cmdline_process(ldb, argc, argv, usage); diff --git a/source4/lib/ldb/tools/ldbsearch.c b/source4/lib/ldb/tools/ldbsearch.c index 24ceb30963..e25bd19965 100644 --- a/source4/lib/ldb/tools/ldbsearch.c +++ b/source4/lib/ldb/tools/ldbsearch.c @@ -276,8 +276,6 @@ int main(int argc, const char **argv) int ret = -1; const char *expression = "(|(objectClass=*)(distinguishedName=*))"; - ldb_global_init(); - ldb = ldb_init(NULL); options = ldb_cmdline_process(ldb, argc, argv, usage); diff --git a/source4/lib/ldb/tools/ldbtest.c b/source4/lib/ldb/tools/ldbtest.c index 5c21dd3830..57a7848733 100644 --- a/source4/lib/ldb/tools/ldbtest.c +++ b/source4/lib/ldb/tools/ldbtest.c @@ -393,8 +393,6 @@ int main(int argc, const char **argv) TALLOC_CTX *mem_ctx = talloc_new(NULL); struct ldb_context *ldb; - ldb_global_init(); - ldb = ldb_init(mem_ctx); options = ldb_cmdline_process(ldb, argc, argv, usage); diff --git a/source4/lib/ldb/tools/oLschema2ldif.c b/source4/lib/ldb/tools/oLschema2ldif.c index 7b5f1b835c..1846a2c852 100644 --- a/source4/lib/ldb/tools/oLschema2ldif.c +++ b/source4/lib/ldb/tools/oLschema2ldif.c @@ -560,8 +560,6 @@ static void usage(void) struct ldb_cmdline *options; FILE *in = stdin; FILE *out = stdout; - ldb_global_init(); - ctx = talloc_new(NULL); ldb_ctx = ldb_init(ctx); diff --git a/source4/scripting/ejs/smbscript.c b/source4/scripting/ejs/smbscript.c index a4f2e1cd43..9ed4aa490f 100644 --- a/source4/scripting/ejs/smbscript.c +++ b/source4/scripting/ejs/smbscript.c @@ -61,8 +61,6 @@ int main(int argc, const char **argv) lp_load(lp_ctx, dyn_CONFIGFILE); } - ldb_global_init(); - gensec_init(lp_ctx); mprSetCtx(mem_ctx); diff --git a/source4/smbd/server.c b/source4/smbd/server.c index c256eed96c..dd63ca1eca 100644 --- a/source4/smbd/server.c +++ b/source4/smbd/server.c @@ -282,8 +282,6 @@ static int binary_smbd_main(const char *binary_name, int argc, const char *argv[ exit(1); } - ldb_global_init(); /* FIXME: */ - share_init(); gensec_init(cmdline_lp_ctx); /* FIXME: */ diff --git a/source4/torture/smbtorture.c b/source4/torture/smbtorture.c index 371ddc7297..4eeea73003 100644 --- a/source4/torture/smbtorture.c +++ b/source4/torture/smbtorture.c @@ -615,8 +615,6 @@ int main(int argc,char *argv[]) alarm(max_runtime); } - ldb_global_init(); - if (extra_module != NULL) { init_module_fn fn = load_module(talloc_autofree_context(), poptGetOptArg(pc)); diff --git a/source4/utils/net/net.c b/source4/utils/net/net.c index 2c95e9033d..e0865c4416 100644 --- a/source4/utils/net/net.c +++ b/source4/utils/net/net.c @@ -182,8 +182,6 @@ static int binary_net(int argc, const char **argv) dcerpc_init(); - ldb_global_init(); - mem_ctx = talloc_init("net_context"); ctx = talloc(mem_ctx, struct net_context); if (!ctx) { -- cgit From 39a817d310964f8e9a63cfb096b3ad24fa03bd5e Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 20 Feb 2008 04:33:43 +0100 Subject: Fix use of some modules (needed _PUBLIC_). (This used to be commit ce332130ea77159832da23bab760fa26921719e2) --- source4/build/smb_build/makefile.pm | 3 +- source4/dsdb/samdb/ldb_modules/anr.c | 2 +- source4/dsdb/samdb/ldb_modules/config.mk | 57 ++++++++++------------ source4/dsdb/samdb/ldb_modules/dsdb_cache.c | 2 +- source4/dsdb/samdb/ldb_modules/extended_dn.c | 2 +- source4/dsdb/samdb/ldb_modules/instancetype.c | 2 +- source4/dsdb/samdb/ldb_modules/kludge_acl.c | 2 +- source4/dsdb/samdb/ldb_modules/linked_attributes.c | 2 +- source4/dsdb/samdb/ldb_modules/local_password.c | 2 +- source4/dsdb/samdb/ldb_modules/naming_fsmo.c | 2 +- source4/dsdb/samdb/ldb_modules/normalise.c | 2 +- source4/dsdb/samdb/ldb_modules/objectclass.c | 2 +- source4/dsdb/samdb/ldb_modules/objectguid.c | 2 +- source4/dsdb/samdb/ldb_modules/partition.c | 4 +- source4/dsdb/samdb/ldb_modules/password_hash.c | 2 +- source4/dsdb/samdb/ldb_modules/pdc_fsmo.c | 2 +- source4/dsdb/samdb/ldb_modules/proxy.c | 2 +- source4/dsdb/samdb/ldb_modules/repl_meta_data.c | 2 +- source4/dsdb/samdb/ldb_modules/rootdse.c | 2 +- source4/dsdb/samdb/ldb_modules/samba3sam.c | 2 +- source4/dsdb/samdb/ldb_modules/samldb.c | 2 +- source4/dsdb/samdb/ldb_modules/schema.c | 2 +- source4/dsdb/samdb/ldb_modules/schema_fsmo.c | 2 +- source4/dsdb/samdb/ldb_modules/show_deleted.c | 2 +- source4/dsdb/samdb/ldb_modules/simple_ldap_map.c | 4 +- source4/dsdb/samdb/ldb_modules/update_keytab.c | 2 +- source4/lib/ldb/ldb_ildap/ldb_ildap.c | 6 +-- source4/lib/ldb/ldb_ldap/ldb_ldap.c | 20 +++++--- source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c | 2 +- source4/lib/ldb/modules/paged_searches.c | 2 +- source4/lib/ldb/tests/sample_module.c | 2 +- source4/lib/util/attr.h | 2 - source4/lib/util/util.h | 3 +- source4/nbt_server/config.mk | 2 +- source4/nbt_server/wins/wins_ldb.c | 2 +- 35 files changed, 79 insertions(+), 74 deletions(-) diff --git a/source4/build/smb_build/makefile.pm b/source4/build/smb_build/makefile.pm index d11e761ce1..22b813b946 100644 --- a/source4/build/smb_build/makefile.pm +++ b/source4/build/smb_build/makefile.pm @@ -160,7 +160,8 @@ sub SharedModule($$) $self->_prepare_list($ctx, "DEPEND_LIST"); $self->_prepare_list($ctx, "LINK_FLAGS"); - if (defined($ctx->{INIT_FUNCTION}) and $ctx->{TYPE} ne "PYTHON") { + if (defined($ctx->{INIT_FUNCTION}) and $ctx->{TYPE} ne "PYTHON" and + $ctx->{INIT_FUNCTION_TYPE} =~ /\(\*\)/) { my $init_fn = $ctx->{INIT_FUNCTION_TYPE}; $init_fn =~ s/\(\*\)/init_module/; my $proto_fn = $ctx->{INIT_FUNCTION_TYPE}; diff --git a/source4/dsdb/samdb/ldb_modules/anr.c b/source4/dsdb/samdb/ldb_modules/anr.c index dd730c9b01..1252c9ee42 100644 --- a/source4/dsdb/samdb/ldb_modules/anr.c +++ b/source4/dsdb/samdb/ldb_modules/anr.c @@ -295,7 +295,7 @@ static int anr_search(struct ldb_module *module, struct ldb_request *req) return ldb_next_request(module, req); } -const struct ldb_module_ops ldb_anr_module_ops = { +_PUBLIC_ const struct ldb_module_ops ldb_anr_module_ops = { .name = "anr", .search = anr_search }; diff --git a/source4/dsdb/samdb/ldb_modules/config.mk b/source4/dsdb/samdb/ldb_modules/config.mk index dc407fbd8a..de93b5638d 100644 --- a/source4/dsdb/samdb/ldb_modules/config.mk +++ b/source4/dsdb/samdb/ldb_modules/config.mk @@ -4,7 +4,7 @@ SUBSYSTEM = LIBLDB OUTPUT_TYPE = SHARED_LIBRARY PRIVATE_DEPENDENCIES = LIBTALLOC LIBNDR NDR_MISC -INIT_FUNCTION = objectguid_module_init +INIT_FUNCTION = objectguid_module_module_ops OBJ_FILES = \ objectguid.o # End MODULE ldb_objectguid @@ -17,7 +17,7 @@ SUBSYSTEM = LIBLDB OUTPUT_TYPE = SHARED_LIBRARY PRIVATE_DEPENDENCIES = SAMDB LIBTALLOC LIBNDR NDR_MISC NDR_DRSUAPI \ NDR_DRSBLOBS LIBNDR -INIT_FUNCTION = repl_meta_data_module_init +INIT_FUNCTION = repl_meta_data_module_module_ops OBJ_FILES = \ repl_meta_data.o # End MODULE ldb_repl_meta_data @@ -29,7 +29,7 @@ OBJ_FILES = \ SUBSYSTEM = LIBLDB OUTPUT_TYPE = SHARED_LIBRARY PRIVATE_DEPENDENCIES = SAMDB LIBTALLOC -INIT_FUNCTION = dsdb_cache_module_init +INIT_FUNCTION = dsdb_cache_module_module_ops OBJ_FILES = \ dsdb_cache.o # End MODULE ldb_dsdb_cache @@ -41,7 +41,7 @@ OBJ_FILES = \ SUBSYSTEM = LIBLDB OUTPUT_TYPE = SHARED_LIBRARY PRIVATE_DEPENDENCIES = SAMDB LIBTALLOC -INIT_FUNCTION = schema_fsmo_module_init +INIT_FUNCTION = schema_fsmo_module_module_ops OBJ_FILES = \ schema_fsmo.o # End MODULE ldb_schema_fsmo @@ -53,7 +53,7 @@ OBJ_FILES = \ SUBSYSTEM = LIBLDB OUTPUT_TYPE = SHARED_LIBRARY PRIVATE_DEPENDENCIES = SAMDB LIBTALLOC -INIT_FUNCTION = naming_fsmo_module_init +INIT_FUNCTION = naming_fsmo_module_module_ops OBJ_FILES = \ naming_fsmo.o # End MODULE ldb_naming_fsmo @@ -65,7 +65,7 @@ OBJ_FILES = \ SUBSYSTEM = LIBLDB OUTPUT_TYPE = SHARED_LIBRARY PRIVATE_DEPENDENCIES = SAMDB LIBTALLOC -INIT_FUNCTION = pdc_fsmo_module_init +INIT_FUNCTION = pdc_fsmo_module_module_ops OBJ_FILES = \ pdc_fsmo.o # End MODULE ldb_pdc_fsmo @@ -77,7 +77,7 @@ OBJ_FILES = \ SUBSYSTEM = LIBLDB OUTPUT_TYPE = SHARED_LIBRARY PRIVATE_DEPENDENCIES = LIBTALLOC LDAP_ENCODE NDR_MISC SAMDB -INIT_FUNCTION = samldb_module_init +INIT_FUNCTION = samldb_module_module_ops OBJ_FILES = \ samldb.o # @@ -89,7 +89,7 @@ OBJ_FILES = \ [MODULE::ldb_samba3sam] SUBSYSTEM = LIBLDB OUTPUT_TYPE = SHARED_LIBRARY -INIT_FUNCTION = ldb_samba3sam_module_init +INIT_FUNCTION = &ldb_samba3sam_module_module_ops PRIVATE_DEPENDENCIES = LIBTALLOC ldb_map SMBPASSWD NSS_WRAPPER LIBSECURITY \ NDR_SECURITY OBJ_FILES = \ @@ -103,7 +103,7 @@ OBJ_FILES = \ [MODULE::ldb_simple_ldap_map] SUBSYSTEM = LIBLDB OUTPUT_TYPE = SHARED_LIBRARY -INIT_FUNCTION = ldb_simple_ldap_map_module_init +INIT_FUNCTION = &ldb_simple_ldap_map_module_module_ops PRIVATE_DEPENDENCIES = LIBTALLOC ldb_map LIBNDR NDR_MISC ENABLE = YES ALIASES = entryuuid nsuniqueid @@ -117,7 +117,7 @@ OBJ_FILES = \ # # Start MODULE ldb_proxy # [MODULE::ldb_proxy] # SUBSYSTEM = LIBLDB -# INIT_FUNCTION = proxy_module_init +# INIT_FUNCTION = proxy_module_module_ops # OBJ_FILES = \ # proxy.o # @@ -131,7 +131,7 @@ OBJ_FILES = \ SUBSYSTEM = LIBLDB PRIVATE_DEPENDENCIES = LIBTALLOC SAMDB OUTPUT_TYPE = SHARED_LIBRARY -INIT_FUNCTION = rootdse_module_init +INIT_FUNCTION = rootdse_module_module_ops OBJ_FILES = \ rootdse.o # @@ -143,7 +143,7 @@ OBJ_FILES = \ [MODULE::ldb_password_hash] SUBSYSTEM = LIBLDB OUTPUT_TYPE = SHARED_LIBRARY -INIT_FUNCTION = password_hash_module_init +INIT_FUNCTION = password_hash_module_module_ops OBJ_FILES = password_hash.o PRIVATE_DEPENDENCIES = HEIMDAL_HDB_KEYS LIBTALLOC HEIMDAL_KRB5 LDAP_ENCODE \ LIBCLI_AUTH NDR_DRSBLOBS KERBEROS SAMDB @@ -157,7 +157,7 @@ PRIVATE_DEPENDENCIES = HEIMDAL_HDB_KEYS LIBTALLOC HEIMDAL_KRB5 LDAP_ENCODE \ PRIVATE_DEPENDENCIES = LIBTALLOC LIBNDR SAMDB OUTPUT_TYPE = SHARED_LIBRARY SUBSYSTEM = LIBLDB -INIT_FUNCTION = local_password_module_init +INIT_FUNCTION = local_password_module_module_ops OBJ_FILES = local_password.o # # End MODULE ldb_local_password @@ -169,7 +169,7 @@ OBJ_FILES = local_password.o PRIVATE_DEPENDENCIES = LIBTALLOC LIBSECURITY SAMDB OUTPUT_TYPE = SHARED_LIBRARY SUBSYSTEM = LIBLDB -INIT_FUNCTION = ldb_kludge_acl_init +INIT_FUNCTION = &ldb_kludge_acl_module_ops OBJ_FILES = \ kludge_acl.o # @@ -182,7 +182,7 @@ OBJ_FILES = \ SUBSYSTEM = LIBLDB OUTPUT_TYPE = SHARED_LIBRARY PRIVATE_DEPENDENCIES = LIBTALLOC LIBNDR LIBSECURITY SAMDB -INIT_FUNCTION = ldb_extended_dn_init +INIT_FUNCTION = &ldb_extended_dn_module_ops OBJ_FILES = \ extended_dn.o # @@ -195,7 +195,7 @@ OBJ_FILES = \ SUBSYSTEM = LIBLDB OUTPUT_TYPE = SHARED_LIBRARY PRIVATE_DEPENDENCIES = LIBTALLOC -INIT_FUNCTION = ldb_show_deleted_init +INIT_FUNCTION = &ldb_show_deleted_module_ops OBJ_FILES = \ show_deleted.o # @@ -208,7 +208,7 @@ OBJ_FILES = \ SUBSYSTEM = LIBLDB OUTPUT_TYPE = SHARED_LIBRARY PRIVATE_DEPENDENCIES = LIBTALLOC SAMDB -INIT_FUNCTION = ldb_partition_init +INIT_FUNCTION = &ldb_partition_module_ops OBJ_FILES = \ partition.o # @@ -221,7 +221,7 @@ OBJ_FILES = \ SUBSYSTEM = LIBLDB OUTPUT_TYPE = SHARED_LIBRARY PRIVATE_DEPENDENCIES = LIBTALLOC LIBLDB -INIT_FUNCTION = ldb_schema_init +INIT_FUNCTION = &ldb_schema_module_ops OBJ_FILES = \ schema.o schema_syntax.o # @@ -235,7 +235,7 @@ SUBSYSTEM = LIBLDB OUTPUT_TYPE = SHARED_LIBRARY PRIVATE_DEPENDENCIES = LIBTALLOC CREDENTIALS #Also depends on credentials, but that would loop -INIT_FUNCTION = ldb_update_kt_init +INIT_FUNCTION = &ldb_update_kt_module_ops OBJ_FILES = \ update_keytab.o # @@ -245,7 +245,7 @@ OBJ_FILES = \ ################################################ # Start MODULE ldb_objectclass [MODULE::ldb_objectclass] -INIT_FUNCTION = ldb_objectclass_init +INIT_FUNCTION = &ldb_objectclass_module_ops OUTPUT_TYPE = SHARED_LIBRARY CFLAGS = -Ilib/ldb/include PRIVATE_DEPENDENCIES = LIBTALLOC LIBSECURITY NDR_SECURITY SAMDB @@ -258,8 +258,7 @@ OBJ_FILES = \ ################################################ # Start MODULE ldb_subtree_rename [MODULE::ldb_subtree_rename] -INIT_FUNCTION = ldb_subtree_rename_init -OUTPUT_TYPE = SHARED_LIBRARY +INIT_FUNCTION = &ldb_subtree_rename_module_ops CFLAGS = -Ilib/ldb/include PRIVATE_DEPENDENCIES = LIBTALLOC SUBSYSTEM = LIBLDB @@ -271,8 +270,7 @@ OBJ_FILES = \ ################################################ # Start MODULE ldb_subtree_rename [MODULE::ldb_subtree_delete] -INIT_FUNCTION = ldb_subtree_delete_init -OUTPUT_TYPE = SHARED_LIBRARY +INIT_FUNCTION = &ldb_subtree_delete_module_ops CFLAGS = -Ilib/ldb/include PRIVATE_DEPENDENCIES = LIBTALLOC SUBSYSTEM = LIBLDB @@ -284,7 +282,7 @@ OBJ_FILES = \ ################################################ # Start MODULE ldb_linked_attributes [MODULE::ldb_linked_attributes] -INIT_FUNCTION = ldb_linked_attributes_init +INIT_FUNCTION = &ldb_linked_attributes_module_ops CFLAGS = -Ilib/ldb/include OUTPUT_TYPE = SHARED_LIBRARY PRIVATE_DEPENDENCIES = LIBTALLOC SAMDB @@ -297,9 +295,8 @@ OBJ_FILES = \ ################################################ # Start MODULE ldb_ranged_results [MODULE::ldb_ranged_results] -INIT_FUNCTION = ldb_ranged_results_init +INIT_FUNCTION = &ldb_ranged_results_module_ops CFLAGS = -Ilib/ldb/include -OUTPUT_TYPE = SHARED_LIBRARY PRIVATE_DEPENDENCIES = LIBTALLOC SUBSYSTEM = LIBLDB OBJ_FILES = \ @@ -310,7 +307,7 @@ OBJ_FILES = \ ################################################ # Start MODULE ldb_anr [MODULE::ldb_anr] -INIT_FUNCTION = ldb_anr_init +INIT_FUNCTION = &ldb_anr_module_ops CFLAGS = -Ilib/ldb/include OUTPUT_TYPE = SHARED_LIBRARY PRIVATE_DEPENDENCIES = LIBTALLOC LIBSAMBA-UTIL SAMDB @@ -323,7 +320,7 @@ OBJ_FILES = \ ################################################ # Start MODULE ldb_normalise [MODULE::ldb_normalise] -INIT_FUNCTION = ldb_normalise_init +INIT_FUNCTION = &ldb_normalise_module_ops CFLAGS = -Ilib/ldb/include OUTPUT_TYPE = SHARED_LIBRARY PRIVATE_DEPENDENCIES = LIBTALLOC LIBSAMBA-UTIL SAMDB @@ -336,7 +333,7 @@ OBJ_FILES = \ ################################################ # Start MODULE ldb_instancetype [MODULE::ldb_instancetype] -INIT_FUNCTION = ldb_instancetype_init +INIT_FUNCTION = &ldb_instancetype_module_ops CFLAGS = -Ilib/ldb/include OUTPUT_TYPE = SHARED_LIBRARY PRIVATE_DEPENDENCIES = LIBTALLOC diff --git a/source4/dsdb/samdb/ldb_modules/dsdb_cache.c b/source4/dsdb/samdb/ldb_modules/dsdb_cache.c index e73803ab38..e60605dce1 100644 --- a/source4/dsdb/samdb/ldb_modules/dsdb_cache.c +++ b/source4/dsdb/samdb/ldb_modules/dsdb_cache.c @@ -36,7 +36,7 @@ static int dsdb_cache_init(struct ldb_module *module) return ldb_next_init(module); } -const struct ldb_module_ops ldb_dsdb_cache_module_ops = { +_PUBLIC_ const struct ldb_module_ops ldb_dsdb_cache_module_ops = { .name = "dsdb_cache", .init_context = dsdb_cache_init }; diff --git a/source4/dsdb/samdb/ldb_modules/extended_dn.c b/source4/dsdb/samdb/ldb_modules/extended_dn.c index 85b99800e9..84bf5e4843 100644 --- a/source4/dsdb/samdb/ldb_modules/extended_dn.c +++ b/source4/dsdb/samdb/ldb_modules/extended_dn.c @@ -362,7 +362,7 @@ static int extended_init(struct ldb_module *module) return ldb_next_init(module); } -const struct ldb_module_ops ldb_extended_dn_module_ops = { +_PUBLIC_ const struct ldb_module_ops ldb_extended_dn_module_ops = { .name = "extended_dn", .search = extended_search, .init_context = extended_init diff --git a/source4/dsdb/samdb/ldb_modules/instancetype.c b/source4/dsdb/samdb/ldb_modules/instancetype.c index c0f8852503..fd5aa5e18a 100644 --- a/source4/dsdb/samdb/ldb_modules/instancetype.c +++ b/source4/dsdb/samdb/ldb_modules/instancetype.c @@ -118,7 +118,7 @@ static int instancetype_add(struct ldb_module *module, struct ldb_request *req) return ret; } -const struct ldb_module_ops ldb_instancetype_module_ops = { +_PUBLIC_ const struct ldb_module_ops ldb_instancetype_module_ops = { .name = "instancetype", .add = instancetype_add, }; diff --git a/source4/dsdb/samdb/ldb_modules/kludge_acl.c b/source4/dsdb/samdb/ldb_modules/kludge_acl.c index 6395ebe2ed..e3e1f7ac88 100644 --- a/source4/dsdb/samdb/ldb_modules/kludge_acl.c +++ b/source4/dsdb/samdb/ldb_modules/kludge_acl.c @@ -471,7 +471,7 @@ done: return ldb_next_init(module); } -const struct ldb_module_ops ldb_kludge_acl_module_ops = { +_PUBLIC_ const struct ldb_module_ops ldb_kludge_acl_module_ops = { .name = "kludge_acl", .search = kludge_acl_search, .add = kludge_acl_change, diff --git a/source4/dsdb/samdb/ldb_modules/linked_attributes.c b/source4/dsdb/samdb/ldb_modules/linked_attributes.c index d6e9d3da4f..8685c722aa 100644 --- a/source4/dsdb/samdb/ldb_modules/linked_attributes.c +++ b/source4/dsdb/samdb/ldb_modules/linked_attributes.c @@ -915,7 +915,7 @@ static int linked_attributes_wait(struct ldb_handle *handle, enum ldb_wait_type } } -const struct ldb_module_ops ldb_linked_attributes_module_ops = { +_PUBLIC_ const struct ldb_module_ops ldb_linked_attributes_module_ops = { .name = "linked_attributes", .add = linked_attributes_add, .modify = linked_attributes_modify, diff --git a/source4/dsdb/samdb/ldb_modules/local_password.c b/source4/dsdb/samdb/ldb_modules/local_password.c index f34acd5349..dfa98ef0af 100644 --- a/source4/dsdb/samdb/ldb_modules/local_password.c +++ b/source4/dsdb/samdb/ldb_modules/local_password.c @@ -843,7 +843,7 @@ static int local_password_wait(struct ldb_handle *handle, enum ldb_wait_type typ } } -const struct ldb_module_ops ldb_local_password_module_ops = { +_PUBLIC_ const struct ldb_module_ops ldb_local_password_module_ops = { .name = "local_password", .add = local_password_add, .modify = local_password_modify, diff --git a/source4/dsdb/samdb/ldb_modules/naming_fsmo.c b/source4/dsdb/samdb/ldb_modules/naming_fsmo.c index 94bef197e9..084540f68d 100644 --- a/source4/dsdb/samdb/ldb_modules/naming_fsmo.c +++ b/source4/dsdb/samdb/ldb_modules/naming_fsmo.c @@ -117,7 +117,7 @@ static int naming_fsmo_init(struct ldb_module *module) return ldb_next_init(module); } -const struct ldb_module_ops ldb_naming_fsmo_module_ops = { +_PUBLIC_ const struct ldb_module_ops ldb_naming_fsmo_module_ops = { .name = "naming_fsmo", .init_context = naming_fsmo_init }; diff --git a/source4/dsdb/samdb/ldb_modules/normalise.c b/source4/dsdb/samdb/ldb_modules/normalise.c index 2a713a52ff..695393d4e8 100644 --- a/source4/dsdb/samdb/ldb_modules/normalise.c +++ b/source4/dsdb/samdb/ldb_modules/normalise.c @@ -156,7 +156,7 @@ static int normalise_search(struct ldb_module *module, struct ldb_request *req) } -const struct ldb_module_ops ldb_normalise_module_ops = { +_PUBLIC_ const struct ldb_module_ops ldb_normalise_module_ops = { .name = "normalise", .search = normalise_search, }; diff --git a/source4/dsdb/samdb/ldb_modules/objectclass.c b/source4/dsdb/samdb/ldb_modules/objectclass.c index 98eeed7cde..e63ad4de56 100644 --- a/source4/dsdb/samdb/ldb_modules/objectclass.c +++ b/source4/dsdb/samdb/ldb_modules/objectclass.c @@ -1153,7 +1153,7 @@ static int objectclass_wait(struct ldb_handle *handle, enum ldb_wait_type type) } } -const struct ldb_module_ops ldb_objectclass_module_ops = { +_PUBLIC_ const struct ldb_module_ops ldb_objectclass_module_ops = { .name = "objectclass", .add = objectclass_add, .modify = objectclass_modify, diff --git a/source4/dsdb/samdb/ldb_modules/objectguid.c b/source4/dsdb/samdb/ldb_modules/objectguid.c index 99dc46bc1f..f62839389d 100644 --- a/source4/dsdb/samdb/ldb_modules/objectguid.c +++ b/source4/dsdb/samdb/ldb_modules/objectguid.c @@ -247,7 +247,7 @@ static int objectguid_modify(struct ldb_module *module, struct ldb_request *req) return ret; } -const struct ldb_module_ops ldb_objectguid_module_ops = { +_PUBLIC_ const struct ldb_module_ops ldb_objectguid_module_ops = { .name = "objectguid", .add = objectguid_add, .modify = objectguid_modify, diff --git a/source4/dsdb/samdb/ldb_modules/partition.c b/source4/dsdb/samdb/ldb_modules/partition.c index 62dd0da8a1..78b5a09f78 100644 --- a/source4/dsdb/samdb/ldb_modules/partition.c +++ b/source4/dsdb/samdb/ldb_modules/partition.c @@ -87,7 +87,7 @@ static struct ldb_module *make_module_for_next_request(TALLOC_CTX *mem_ctx, struct ldb_module *module) { struct ldb_module *current; - static const struct ldb_module_ops ops; /* zero */ +_PUBLIC_ static const struct ldb_module_ops ops; /* zero */ current = talloc_zero(mem_ctx, struct ldb_module); if (current == NULL) { return module; @@ -1030,7 +1030,7 @@ static int partition_wait(struct ldb_handle *handle, enum ldb_wait_type type) } } -const struct ldb_module_ops ldb_partition_module_ops = { +_PUBLIC_ const struct ldb_module_ops ldb_partition_module_ops = { .name = "partition", .init_context = partition_init, .search = partition_search, diff --git a/source4/dsdb/samdb/ldb_modules/password_hash.c b/source4/dsdb/samdb/ldb_modules/password_hash.c index 380045c1cf..aa64700f2f 100644 --- a/source4/dsdb/samdb/ldb_modules/password_hash.c +++ b/source4/dsdb/samdb/ldb_modules/password_hash.c @@ -2044,7 +2044,7 @@ static int password_hash_wait(struct ldb_handle *handle, enum ldb_wait_type type } } -const struct ldb_module_ops ldb_password_hash_module_ops = { +_PUBLIC_ const struct ldb_module_ops ldb_password_hash_module_ops = { .name = "password_hash", .add = password_hash_add, .modify = password_hash_modify, diff --git a/source4/dsdb/samdb/ldb_modules/pdc_fsmo.c b/source4/dsdb/samdb/ldb_modules/pdc_fsmo.c index 270e79ecd8..09d56d77c9 100644 --- a/source4/dsdb/samdb/ldb_modules/pdc_fsmo.c +++ b/source4/dsdb/samdb/ldb_modules/pdc_fsmo.c @@ -115,7 +115,7 @@ static int pdc_fsmo_init(struct ldb_module *module) return ldb_next_init(module); } -const struct ldb_module_ops ldb_pdc_fsmo_module_ops = { +_PUBLIC_ const struct ldb_module_ops ldb_pdc_fsmo_module_ops = { .name = "pdc_fsmo", .init_context = pdc_fsmo_init }; diff --git a/source4/dsdb/samdb/ldb_modules/proxy.c b/source4/dsdb/samdb/ldb_modules/proxy.c index a7704ef413..0d065425ca 100644 --- a/source4/dsdb/samdb/ldb_modules/proxy.c +++ b/source4/dsdb/samdb/ldb_modules/proxy.c @@ -331,7 +331,7 @@ static int proxy_request(struct ldb_module *module, struct ldb_request *req) } } -const struct ldb_module_ops ldb_proxy_module_ops = { +_PUBLIC_ const struct ldb_module_ops ldb_proxy_module_ops = { .name = "proxy", .request = proxy_request }; diff --git a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c index 9184a8c0b2..dd5faf837a 100644 --- a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c +++ b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c @@ -1579,7 +1579,7 @@ static int replmd_wait(struct ldb_handle *handle, enum ldb_wait_type type) } } -const struct ldb_module_ops ldb_repl_meta_data_module_ops = { +_PUBLIC_ const struct ldb_module_ops ldb_repl_meta_data_module_ops = { .name = "repl_meta_data", .add = replmd_add, .modify = replmd_modify, diff --git a/source4/dsdb/samdb/ldb_modules/rootdse.c b/source4/dsdb/samdb/ldb_modules/rootdse.c index 80173084ec..3235b24ef9 100644 --- a/source4/dsdb/samdb/ldb_modules/rootdse.c +++ b/source4/dsdb/samdb/ldb_modules/rootdse.c @@ -386,7 +386,7 @@ static int rootdse_init(struct ldb_module *module) return ldb_next_init(module); } -const struct ldb_module_ops ldb_rootdse_module_ops = { +_PUBLIC_ const struct ldb_module_ops ldb_rootdse_module_ops = { .name = "rootdse", .init_context = rootdse_init, .search = rootdse_search, diff --git a/source4/dsdb/samdb/ldb_modules/samba3sam.c b/source4/dsdb/samdb/ldb_modules/samba3sam.c index 4b1d432932..88b04b1bb6 100644 --- a/source4/dsdb/samdb/ldb_modules/samba3sam.c +++ b/source4/dsdb/samdb/ldb_modules/samba3sam.c @@ -925,7 +925,7 @@ static int samba3sam_init(struct ldb_module *module) return ldb_next_init(module); } -const struct ldb_module_ops ldb_samba3sam_module_ops = { +_PUBLIC_ const struct ldb_module_ops ldb_samba3sam_module_ops = { LDB_MAP_OPS .name = "samba3sam", .init_context = samba3sam_init, diff --git a/source4/dsdb/samdb/ldb_modules/samldb.c b/source4/dsdb/samdb/ldb_modules/samldb.c index 44776f5956..178149a886 100644 --- a/source4/dsdb/samdb/ldb_modules/samldb.c +++ b/source4/dsdb/samdb/ldb_modules/samldb.c @@ -750,7 +750,7 @@ static int samldb_init(struct ldb_module *module) return ldb_next_init(module); } -const struct ldb_module_ops ldb_samldb_module_ops = { +_PUBLIC_ const struct ldb_module_ops ldb_samldb_module_ops = { .name = "samldb", .init_context = samldb_init, .add = samldb_add, diff --git a/source4/dsdb/samdb/ldb_modules/schema.c b/source4/dsdb/samdb/ldb_modules/schema.c index b6eb5ffb84..ff9530ca92 100644 --- a/source4/dsdb/samdb/ldb_modules/schema.c +++ b/source4/dsdb/samdb/ldb_modules/schema.c @@ -1221,7 +1221,7 @@ static int schema_init(struct ldb_module *module) return LDB_SUCCESS; } -const struct ldb_module_ops ldb_schema_module_ops = { +_PUBLIC_ const struct ldb_module_ops ldb_schema_module_ops = { .name = "schema", .init_context = schema_init, .add = schema_add, diff --git a/source4/dsdb/samdb/ldb_modules/schema_fsmo.c b/source4/dsdb/samdb/ldb_modules/schema_fsmo.c index 9c87747527..729fd15202 100644 --- a/source4/dsdb/samdb/ldb_modules/schema_fsmo.c +++ b/source4/dsdb/samdb/ldb_modules/schema_fsmo.c @@ -255,7 +255,7 @@ static int schema_fsmo_init(struct ldb_module *module) return ldb_next_init(module); } -const struct ldb_module_ops ldb_schema_fsmo_module_ops = { +_PUBLIC_ const struct ldb_module_ops ldb_schema_fsmo_module_ops = { .name = "schema_fsmo", .init_context = schema_fsmo_init }; diff --git a/source4/dsdb/samdb/ldb_modules/show_deleted.c b/source4/dsdb/samdb/ldb_modules/show_deleted.c index 5e6b967b47..361cf226dc 100644 --- a/source4/dsdb/samdb/ldb_modules/show_deleted.c +++ b/source4/dsdb/samdb/ldb_modules/show_deleted.c @@ -194,7 +194,7 @@ static int show_deleted_init(struct ldb_module *module) return ldb_next_init(module); } -const struct ldb_module_ops ldb_show_deleted_module_ops = { +_PUBLIC_ const struct ldb_module_ops ldb_show_deleted_module_ops = { .name = "show_deleted", .search = show_deleted_search, .init_context = show_deleted_init diff --git a/source4/dsdb/samdb/ldb_modules/simple_ldap_map.c b/source4/dsdb/samdb/ldb_modules/simple_ldap_map.c index dbb58856a0..3f4c19d285 100644 --- a/source4/dsdb/samdb/ldb_modules/simple_ldap_map.c +++ b/source4/dsdb/samdb/ldb_modules/simple_ldap_map.c @@ -793,14 +793,14 @@ static int entryuuid_sequence_number(struct ldb_module *module, struct ldb_reque return LDB_SUCCESS; } -const struct ldb_module_ops ldb_entryuuid_module_ops = { +_PUBLIC_ const struct ldb_module_ops ldb_entryuuid_module_ops = { .name = "entryuuid", .init_context = entryuuid_init, .sequence_number = entryuuid_sequence_number, LDB_MAP_OPS }; -const struct ldb_module_ops ldb_nsuniqueid_module_ops = { +_PUBLIC_ const struct ldb_module_ops ldb_nsuniqueid_module_ops = { .name = "nsuniqueid", .init_context = nsuniqueid_init, .sequence_number = entryuuid_sequence_number, diff --git a/source4/dsdb/samdb/ldb_modules/update_keytab.c b/source4/dsdb/samdb/ldb_modules/update_keytab.c index 614f05f752..54362dcfd4 100644 --- a/source4/dsdb/samdb/ldb_modules/update_keytab.c +++ b/source4/dsdb/samdb/ldb_modules/update_keytab.c @@ -199,7 +199,7 @@ static int update_kt_init(struct ldb_module *module) return ldb_next_init(module); } -const struct ldb_module_ops ldb_update_keytab_module_ops = { +_PUBLIC_ const struct ldb_module_ops ldb_update_keytab_module_ops = { .name = "update_keytab", .init_context = update_kt_init, .add = update_kt_add, diff --git a/source4/lib/ldb/ldb_ildap/ldb_ildap.c b/source4/lib/ldb/ldb_ildap/ldb_ildap.c index fb7100e3c1..995b584f51 100644 --- a/source4/lib/ldb/ldb_ildap/ldb_ildap.c +++ b/source4/lib/ldb/ldb_ildap/ldb_ildap.c @@ -811,17 +811,17 @@ failed: return -1; } -const struct ldb_backend_ops ldb_ldap_backend_ops { +_PUBLIC_ const struct ldb_backend_ops ldb_ldap_backend_ops = { .name = "ldap", .connect_fn = ildb_connect }; -const struct ldb_backend_ops ldb_ildap_backend_ops { +_PUBLIC_ const struct ldb_backend_ops ldb_ildap_backend_ops = { .name = "ildap", .connect_fn = ildb_connect }; -const struct ldb_backend_ops ldb_ldaps_backend_ops { +_PUBLIC_ const struct ldb_backend_ops ldb_ldaps_backend_ops = { .name = "ldaps", .connect_fn = ildb_connect }; diff --git a/source4/lib/ldb/ldb_ldap/ldb_ldap.c b/source4/lib/ldb/ldb_ldap/ldb_ldap.c index d897350c2f..3f6ff3fd5b 100644 --- a/source4/lib/ldb/ldb_ldap/ldb_ldap.c +++ b/source4/lib/ldb/ldb_ldap/ldb_ldap.c @@ -826,9 +826,17 @@ failed: return -1; } -int ldb_ldap_init(void) -{ - return ldb_register_backend("ldap", lldb_connect) + - ldb_register_backend("ldapi", lldb_connect) + - ldb_register_backend("ldaps", lldb_connect); -} +_PUBLIC_ struct ldb_backend_ops ldb_ldap_backend_ops = { + .name = "ldap", + .connect_fn = lldb_connect +}; + +_PUBLIC_ struct ldb_backend_ops ldb_ldapi_backend_ops = { + .name = "ldapi", + .connect_fn = lldb_connect +}; + +_PUBLIC_ struct ldb_backend_ops ldb_ldaps_backend_ops = { + .name = "ldaps", + .connect_fn = lldb_connect +}; diff --git a/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c b/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c index 8742e257f3..214e7eec5f 100644 --- a/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c +++ b/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c @@ -1903,7 +1903,7 @@ failed: return -1; } -const struct ldb_backend_ops ldb_sqlite3_backend_ops = { +_PUBLIC_ const struct ldb_backend_ops ldb_sqlite3_backend_ops = { .name = "sqlite3", .connect_fn = lsqlite3_connect }; diff --git a/source4/lib/ldb/modules/paged_searches.c b/source4/lib/ldb/modules/paged_searches.c index 7406e91c9d..40e87f70d6 100644 --- a/source4/lib/ldb/modules/paged_searches.c +++ b/source4/lib/ldb/modules/paged_searches.c @@ -455,7 +455,7 @@ static int ps_init(struct ldb_module *module) return ldb_next_init(module); } -const struct ldb_module_ops ldb_paged_searches_module_ops = { +_PUBLIC_ const struct ldb_module_ops ldb_paged_searches_module_ops = { .name = "paged_searches", .search = ps_search, .wait = ps_wait, diff --git a/source4/lib/ldb/tests/sample_module.c b/source4/lib/ldb/tests/sample_module.c index 1a9e72c907..98d8e865dd 100644 --- a/source4/lib/ldb/tests/sample_module.c +++ b/source4/lib/ldb/tests/sample_module.c @@ -32,7 +32,7 @@ int sample_add(struct ldb_module *mod, struct ldb_request *req) return ldb_next_request(mod, req); } -const struct ldb_module_ops ldb_sample_module_ops = { +_PUBLIC_ const struct ldb_module_ops ldb_sample_module_ops = { .name = "sample", .add = sample_add, }; diff --git a/source4/lib/util/attr.h b/source4/lib/util/attr.h index 8f6c4f5d8a..f64b272a67 100644 --- a/source4/lib/util/attr.h +++ b/source4/lib/util/attr.h @@ -29,13 +29,11 @@ /** Feel free to add definitions for other compilers here. */ #endif -#ifndef _PUBLIC_ #ifdef HAVE_VISIBILITY_ATTR # define _PUBLIC_ __attribute__((visibility("default"))) #else # define _PUBLIC_ #endif -#endif #ifndef _DEPRECATED_ #if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1 ) diff --git a/source4/lib/util/util.h b/source4/lib/util/util.h index 9e106052f2..550b60c625 100644 --- a/source4/lib/util/util.h +++ b/source4/lib/util/util.h @@ -21,6 +21,8 @@ #ifndef _SAMBA_UTIL_H_ #define _SAMBA_UTIL_H_ +#include "util/attr.h" + #include "charset/charset.h" /* for TALLOC_CTX */ @@ -36,7 +38,6 @@ struct smbsrv_tcon; extern const char *logfile; extern const char *panic_action; -#include "util/attr.h" #include "util/time.h" #include "util/data_blob.h" #include "util/xfile.h" diff --git a/source4/nbt_server/config.mk b/source4/nbt_server/config.mk index 68ef56c11e..9285044768 100644 --- a/source4/nbt_server/config.mk +++ b/source4/nbt_server/config.mk @@ -17,7 +17,7 @@ PUBLIC_DEPENDENCIES = \ [MODULE::ldb_wins_ldb] SUBSYSTEM = LIBLDB OUTPUT_TYPE = SHARED_LIBRARY -INIT_FUNCTION = wins_ldb_module_init +INIT_FUNCTION = &ldb_wins_ldb_module_ops OBJ_FILES = \ wins/wins_ldb.o PRIVATE_DEPENDENCIES = \ diff --git a/source4/nbt_server/wins/wins_ldb.c b/source4/nbt_server/wins/wins_ldb.c index 04468556ef..02ea306243 100644 --- a/source4/nbt_server/wins/wins_ldb.c +++ b/source4/nbt_server/wins/wins_ldb.c @@ -112,7 +112,7 @@ failed: return LDB_ERR_OTHER; } -const struct ldb_module_ops ldb_wins_ldb_module_ops = { +_PUBLIC_ const struct ldb_module_ops ldb_wins_ldb_module_ops = { .name = "wins_ldb", .add = wins_ldb_verify, .modify = wins_ldb_verify, -- cgit From 1c1781b2c4a09080a19f834ba947d0410b2141f7 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 20 Feb 2008 19:20:13 +1100 Subject: Simpler specification of CFLAGS and LDFLAGS By being more consistant in applying CFLAGS and LDFLAGS (in particular) to every invocation, we make it simpler to enable gcov code coverage, both in the build system and on the build farm. Andrew Bartlett (This used to be commit 8c2f658a9688f0c51d2f3b948dc3213b65c7b77f) --- source4/Makefile | 4 ++-- source4/build/m4/check_ld.m4 | 17 ++++++++++------- source4/build/smb_build/makefile.pm | 4 ++-- source4/torture/config.mk | 10 ++-------- 4 files changed, 16 insertions(+), 19 deletions(-) diff --git a/source4/Makefile b/source4/Makefile index ea98b5e469..1fddfefce3 100644 --- a/source4/Makefile +++ b/source4/Makefile @@ -14,10 +14,10 @@ SETUPDIR = $(datadir)/setup NCALRPCDIR = $(localstatedir)/ncalrpc BNLD = $(LD) -BNLD_FLAGS = $(LDFLAGS) +BNLD_FLAGS = $(LDFLAGS) $(SYS_LDFLAGS) HOSTCC_FLAGS = -D_SAMBA_HOSTCC_ $(CFLAGS) -HOSTLD_FLAGS = $(LDFLAGS) +HOSTLD_FLAGS = $(LDFLAGS) $(SYS_LDFLAGS) default: all diff --git a/source4/build/m4/check_ld.m4 b/source4/build/m4/check_ld.m4 index 3b69057a69..0d0742e5d2 100644 --- a/source4/build/m4/check_ld.m4 +++ b/source4/build/m4/check_ld.m4 @@ -13,6 +13,7 @@ LD="" AC_SUBST(BLDSHARED) AC_SUBST(LD) +AC_SUBST(SYS_LDFLAGS) AC_SUBST(LDFLAGS) # Assume non-shared by default and override below @@ -32,13 +33,13 @@ AC_MSG_CHECKING([whether to try to build shared libraries on $host_os]) case "$host_os" in *linux*) BLDSHARED="true" - LDFLAGS="$LDFLAGS -Wl,--export-dynamic" + SYS_LDFLAGS="-Wl,--export-dynamic" ;; *solaris*) BLDSHARED="true" if test "${GCC}" = "yes"; then if test "${ac_cv_prog_gnu_ld}" = "yes"; then - LDFLAGS="$LDFLAGS -Wl,-E" + SYS_LDFLAGS="-Wl,-E" fi fi ;; @@ -47,26 +48,26 @@ case "$host_os" in ;; *netbsd* | *freebsd* | *dragonfly* ) BLDSHARED="true" - LDFLAGS="$LDFLAGS -Wl,--export-dynamic" + SYS_LDFLAGS="-Wl,--export-dynamic" ;; *openbsd*) BLDSHARED="true" - LDFLAGS="$LDFLAGS -Wl,-Bdynamic" + SYS_LDFLAGS="-Wl,-Bdynamic" ;; *irix*) BLDSHARED="true" ;; *aix*) BLDSHARED="true" - LDFLAGS="$LDFLAGS -Wl,-brtl,-bexpall,-bbigtoc" + SYS_LDFLAGS="-Wl,-brtl,-bexpall,-bbigtoc" ;; *hpux*) # Use special PIC flags for the native HP-UX compiler. BLDSHARED="true" # I hope this is correct if test "$host_cpu" = "ia64"; then - LDFLAGS="$LDFLAGS -Wl,-E,+b/usr/local/lib/hpux32:/usr/lib/hpux32" + SYS_LDFLAGS="-Wl,-E,+b/usr/local/lib/hpux32:/usr/lib/hpux32" else - LDFLAGS="$LDFLAGS -Wl,-E,+b/usr/local/lib:/usr/lib" + SYS_LDFLAGS="-Wl,-E,+b/usr/local/lib:/usr/lib" fi ;; *osf*) @@ -86,6 +87,8 @@ AC_MSG_CHECKING([LD]) AC_MSG_RESULT([$LD]) AC_MSG_CHECKING([LDFLAGS]) AC_MSG_RESULT([$LDFLAGS]) +AC_MSG_CHECKING([SYS_LDFLAGS]) +AC_MSG_RESULT([$SYS_LDFLAGS]) AC_SUBST(HOSTLD) diff --git a/source4/build/smb_build/makefile.pm b/source4/build/smb_build/makefile.pm index d11e761ce1..498b619001 100644 --- a/source4/build/smb_build/makefile.pm +++ b/source4/build/smb_build/makefile.pm @@ -187,7 +187,7 @@ __EOD__ $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}: \$($ctx->{NAME}_DEPEND_LIST) \$($ctx->{NAME}_FULL_OBJ_LIST) $init_obj \@echo Linking \$\@ \@mkdir -p $ctx->{SHAREDDIR} - \@\$(MDLD) \$(MDLD_FLAGS) \$(INTERN_LDFLAGS) -o \$\@ \$(INSTALL_LINK_FLAGS) \\ + \@\$(MDLD) \$(LDFLAGS) \$(MDLD_FLAGS) \$(INTERN_LDFLAGS) -o \$\@ \$(INSTALL_LINK_FLAGS) \\ \$($ctx->{NAME}\_FULL_OBJ_LIST) $init_obj \\ \$($ctx->{NAME}_LINK_FLAGS) __EOD__ @@ -242,7 +242,7 @@ sub SharedLibrary($$) $ctx->{RESULT_SHARED_LIBRARY}: \$($ctx->{NAME}_DEPEND_LIST) \$($ctx->{NAME}_FULL_OBJ_LIST) \@echo Linking \$\@ \@mkdir -p $ctx->{SHAREDDIR} - \@\$(SHLD) \$(SHLD_FLAGS) \$(INTERN_LDFLAGS) -o \$\@ \$(INSTALL_LINK_FLAGS) \\ + \@\$(SHLD) \$(LDFLAGS) \$(SHLD_FLAGS) \$(INTERN_LDFLAGS) -o \$\@ \$(INSTALL_LINK_FLAGS) \\ \$($ctx->{NAME}\_FULL_OBJ_LIST) \\ \$($ctx->{NAME}_LINK_FLAGS) \\ $soarg$lns diff --git a/source4/torture/config.mk b/source4/torture/config.mk index 82e32e1ece..626349a45d 100644 --- a/source4/torture/config.mk +++ b/source4/torture/config.mk @@ -370,17 +370,11 @@ MANPAGE = man/locktest.1 # End BINARY locktest ################################# -GCOV_FLAGS = --coverage - COV_TARGET = test COV_VARS = \ - CFLAGS="$(CFLAGS) $(GCOV_FLAGS)" \ - BNLD_FLAGS="$(BNLD_FLAGS) $(GCOV_FLAGS)" \ - SHLD_FLAGS="$(SHLD_FLAGS) $(GCOV_FLAGS)" \ - MDLD_FLAGS="$(MDLD_FLAGS) $(GCOV_FLAGS)" \ - HOSTCC_FLAGS="$(HOSTCC_FLAGS) $(GCOV_FLAGS)" \ - HOSTLD_FLAGS="$(HOSTLD_FLAGS) $(GCOV_FLAGS)" + CFLAGS="$(CFLAGS) --coverage" \ + LDFLAGS="$(LDFLAGS) --coverage" test_cov: -$(MAKE) $(COV_TARGET) $(COV_VARS) -- cgit From 62e849d918e76ac27096999792c46e3230b0663a Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 1 Feb 2008 20:03:05 +0100 Subject: NetBSD needs LD_LIBRARY_PATH (cherry picked from commit d64b19e77aa499c1ee1aaf788ddf3d6fd36253e4) (This used to be commit 4c77550d80b0cfc80bc2cac500fc27e0c43dad64) --- source4/lib/replace/libreplace_ld.m4 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source4/lib/replace/libreplace_ld.m4 b/source4/lib/replace/libreplace_ld.m4 index 2aec698967..f0d10c1e3e 100644 --- a/source4/lib/replace/libreplace_ld.m4 +++ b/source4/lib/replace/libreplace_ld.m4 @@ -289,6 +289,9 @@ AC_DEFUN([AC_LIBREPLACE_RUNTIME_LIB_PATH_VAR], *linux*) LIB_PATH_VAR=LD_LIBRARY_PATH ;; + *netbsd*) + LIB_PATH_VAR=LD_LIBRARY_PATH + ;; *solaris*) LIB_PATH_VAR=LD_LIBRARY_PATH ;; -- cgit From db2447a7a2b1d39a6849b53f7864e9283daacb6a Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 1 Feb 2008 14:23:56 +0100 Subject: NetBSD does not support AI_ADDRCONFIG (cherry picked from commit fb3f7f4046fa195baf5116598772d9016238637f) (This used to be commit e8f3653414c12fb752c096d848dc962008d90439) --- source4/lib/replace/system/network.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/source4/lib/replace/system/network.h b/source4/lib/replace/system/network.h index 53bef66d48..d09e3f71f8 100644 --- a/source4/lib/replace/system/network.h +++ b/source4/lib/replace/system/network.h @@ -163,8 +163,15 @@ void rep_freeifaddrs(struct ifaddrs *); #endif #ifndef AI_ADDRCONFIG +/* + * logic copied from AI_NUMERICHOST + */ +#if defined(HAVE_STRUCT_ADDRINFO) && defined(HAVE_GETADDRINFO) +#define AI_ADDRCONFIG 0 +#else #define AI_ADDRCONFIG 0x0020 #endif +#endif #ifndef AI_NUMERICSERV /* -- cgit From 1ce345ef97cc7c737aa678b332f39d630688248a Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 20 Feb 2008 10:51:26 +0100 Subject: Fix nbt tests. (This used to be commit 7bbe48af5568ffc4e4873692316673fd974ef4ef) --- source4/selftest/samba4_tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source4/selftest/samba4_tests.sh b/source4/selftest/samba4_tests.sh index 6beff6f279..c57ec4d6bd 100755 --- a/source4/selftest/samba4_tests.sh +++ b/source4/selftest/samba4_tests.sh @@ -294,7 +294,7 @@ plantest "wbinfo -a against member server with domain creds" member $VALGRIND $s NBT_TESTS=`$smb4torture --list | grep "^NBT-" | xargs` for t in $NBT_TESTS; do - plansmbtorturetest "$t" dc //\$SERVER/_none_ $f -U\$USERNAME%\$PASSWORD + plansmbtorturetest "$t" dc //\$SERVER/_none_ -U\$USERNAME%\$PASSWORD done WB_OPTS="--option=\"torture:strict mode=yes\"" -- cgit From 845664e94b7bc98f6e93be6d7ff2a141d9d9e192 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 20 Feb 2008 11:32:56 +0100 Subject: Avoid python2.2-specific types. (This used to be commit d45c6b5574ea732d25e9180c83f1fa807ebe57ba) --- source4/scripting/python/config.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source4/scripting/python/config.m4 b/source4/scripting/python/config.m4 index 908efd1588..2142cd9abd 100644 --- a/source4/scripting/python/config.m4 +++ b/source4/scripting/python/config.m4 @@ -54,7 +54,7 @@ fi if test x$PYTHON != x then - DISTUTILS_CFLAGS=`$PYTHON -c "from distutils import sysconfig; print '-I%s -I%s %s' % (sysconfig.get_python_inc(), sysconfig.get_python_inc(plat_specific=True), sysconfig.get_config_var('CFLAGS'))"` + DISTUTILS_CFLAGS=`$PYTHON -c "from distutils import sysconfig; print '-I%s -I%s %s' % (sysconfig.get_python_inc(), sysconfig.get_python_inc(plat_specific=1), sysconfig.get_config_var('CFLAGS'))"` DISTUTILS_LDFLAGS=`$PYTHON -c "from distutils import sysconfig; print '%s %s -lpython%s -L%s' % (sysconfig.get_config_var('LIBS'), sysconfig.get_config_var('SYSLIBS'), sysconfig.get_config_var('VERSION'), sysconfig.get_config_var('LIBPL'))"` TRY_LINK_PYTHON($DISTUTILS_LDFLAGS, $DISTUTILS_CFLAGS) fi -- cgit From 7d7b74feb272a4cc00f68d1a343d14d17ff19fe6 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 20 Feb 2008 12:17:18 +0100 Subject: Allow building ldb as static library again \o/ (This used to be commit a57adcfdd32fa9516eb092f7568e213347c583d7) --- source4/lib/ldb/config.mk | 1 - 1 file changed, 1 deletion(-) diff --git a/source4/lib/ldb/config.mk b/source4/lib/ldb/config.mk index b44a317a70..6027acd0c7 100644 --- a/source4/lib/ldb/config.mk +++ b/source4/lib/ldb/config.mk @@ -127,7 +127,6 @@ PRIVATE_DEPENDENCIES = \ [LIBRARY::LIBLDB] VERSION = 0.0.1 SO_VERSION = 0 -OUTPUT_TYPE = SHARED_LIBRARY CFLAGS = -Ilib/ldb/include PC_FILE = ldb.pc INIT_FUNCTION_TYPE = extern const struct ldb_module_ops -- cgit From 8f57595c18a51161db93cd05730be37bcb850a17 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 20 Feb 2008 12:43:37 +0100 Subject: libreplace: change samba_cv_ to libreplace_cv_ in getifaddrs.m4 Michael (This used to be commit acab9def2a1e3460bef8baae6efc66d9dfad6eac) --- source4/lib/replace/getifaddrs.m4 | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/source4/lib/replace/getifaddrs.m4 b/source4/lib/replace/getifaddrs.m4 index 4259d1a7a3..4cf86d89cc 100644 --- a/source4/lib/replace/getifaddrs.m4 +++ b/source4/lib/replace/getifaddrs.m4 @@ -7,7 +7,7 @@ AC_CHECK_MEMBERS([struct sockaddr.sa_len], [#include ]) dnl test for getifaddrs and freeifaddrs -AC_CACHE_CHECK([for getifaddrs and freeifaddrs],samba_cv_HAVE_GETIFADDRS,[ +AC_CACHE_CHECK([for getifaddrs and freeifaddrs],libreplace_cv_HAVE_GETIFADDRS,[ AC_TRY_COMPILE([ #include #if STDC_HEADERS @@ -24,8 +24,8 @@ struct ifaddrs *ifp = NULL; int ret = getifaddrs (&ifp); freeifaddrs(ifp); ], -samba_cv_HAVE_GETIFADDRS=yes,samba_cv_HAVE_GETIFADDRS=no)]) -if test x"$samba_cv_HAVE_GETIFADDRS" = x"yes"; then +libreplace_cv_HAVE_GETIFADDRS=yes,libreplace_cv_HAVE_GETIFADDRS=no)]) +if test x"$libreplace_cv_HAVE_GETIFADDRS" = x"yes"; then AC_DEFINE(HAVE_GETIFADDRS,1,[Whether the system has getifaddrs]) AC_DEFINE(HAVE_FREEIFADDRS,1,[Whether the system has freeifaddrs]) AC_DEFINE(HAVE_STRUCT_IFADDRS,1,[Whether struct ifaddrs is available]) @@ -42,15 +42,15 @@ iface=no; ################## # look for a method of finding the list of network interfaces iface=no; -AC_CACHE_CHECK([for iface getifaddrs],samba_cv_HAVE_IFACE_GETIFADDRS,[ +AC_CACHE_CHECK([for iface getifaddrs],libreplace_cv_HAVE_IFACE_GETIFADDRS,[ AC_TRY_RUN([ #define NO_CONFIG_H 1 #define HAVE_IFACE_GETIFADDRS 1 #define AUTOCONF_TEST 1 #include "$libreplacedir/replace.c" #include "$libreplacedir/getifaddrs.c"], - samba_cv_HAVE_IFACE_GETIFADDRS=yes,samba_cv_HAVE_IFACE_GETIFADDRS=no,samba_cv_HAVE_IFACE_GETIFADDRS=cross)]) -if test x"$samba_cv_HAVE_IFACE_GETIFADDRS" = x"yes"; then + 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]) else LIBREPLACEOBJ="${LIBREPLACEOBJ} getifaddrs.o" @@ -58,39 +58,39 @@ fi if test $iface = no; then -AC_CACHE_CHECK([for iface AIX],samba_cv_HAVE_IFACE_AIX,[ +AC_CACHE_CHECK([for iface AIX],libreplace_cv_HAVE_IFACE_AIX,[ AC_TRY_RUN([ #define HAVE_IFACE_AIX 1 #define AUTOCONF_TEST 1 #undef _XOPEN_SOURCE_EXTENDED #include "$libreplacedir/getifaddrs.c"], - samba_cv_HAVE_IFACE_AIX=yes,samba_cv_HAVE_IFACE_AIX=no,samba_cv_HAVE_IFACE_AIX=cross)]) -if test x"$samba_cv_HAVE_IFACE_AIX" = x"yes"; then + 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]) fi fi if test $iface = no; then -AC_CACHE_CHECK([for iface ifconf],samba_cv_HAVE_IFACE_IFCONF,[ +AC_CACHE_CHECK([for iface ifconf],libreplace_cv_HAVE_IFACE_IFCONF,[ AC_TRY_RUN([ #define HAVE_IFACE_IFCONF 1 #define AUTOCONF_TEST 1 #include "$libreplacedir/getifaddrs.c"], - samba_cv_HAVE_IFACE_IFCONF=yes,samba_cv_HAVE_IFACE_IFCONF=no,samba_cv_HAVE_IFACE_IFCONF=cross)]) -if test x"$samba_cv_HAVE_IFACE_IFCONF" = x"yes"; then + 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]) fi fi if test $iface = no; then -AC_CACHE_CHECK([for iface ifreq],samba_cv_HAVE_IFACE_IFREQ,[ +AC_CACHE_CHECK([for iface ifreq],libreplace_cv_HAVE_IFACE_IFREQ,[ AC_TRY_RUN([ #define HAVE_IFACE_IFREQ 1 #define AUTOCONF_TEST 1 #include "$libreplacedir/getifaddrs.c"], - samba_cv_HAVE_IFACE_IFREQ=yes,samba_cv_HAVE_IFACE_IFREQ=no,samba_cv_HAVE_IFACE_IFREQ=cross)]) -if test x"$samba_cv_HAVE_IFACE_IFREQ" = x"yes"; then + 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]) fi fi -- cgit From 7f3913659f150ca7020177ab85f9c36b908807a9 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 20 Feb 2008 12:46:20 +0100 Subject: libreplace: change samba_cv_ to libreplace_cv_ in getpass.m4. Michael (This used to be commit d3b3d3ec9ff64108b4cd5b7c912ab4ea207256cb) --- source4/lib/replace/getpass.m4 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/source4/lib/replace/getpass.m4 b/source4/lib/replace/getpass.m4 index c4da9aae59..b93817f9d3 100644 --- a/source4/lib/replace/getpass.m4 +++ b/source4/lib/replace/getpass.m4 @@ -1,22 +1,22 @@ -AC_CHECK_FUNC(getpass, samba_cv_HAVE_GETPASS=yes) -AC_CHECK_FUNC(getpassphrase, samba_cv_HAVE_GETPASSPHRASE=yes) -if test x"$samba_cv_HAVE_GETPASS" = x"yes" -a x"$samba_cv_HAVE_GETPASSPHRASE" = x"yes"; then +AC_CHECK_FUNC(getpass, libreplace_cv_HAVE_GETPASS=yes) +AC_CHECK_FUNC(getpassphrase, libreplace_cv_HAVE_GETPASSPHRASE=yes) +if test x"$libreplace_cv_HAVE_GETPASS" = x"yes" -a x"$libreplace_cv_HAVE_GETPASSPHRASE" = x"yes"; then AC_DEFINE(REPLACE_GETPASS_BY_GETPASSPHRASE, 1, [getpass returns <9 chars where getpassphrase returns <265 chars]) AC_DEFINE(REPLACE_GETPASS,1,[Whether getpass should be replaced]) LIBREPLACEOBJ="${LIBREPLACEOBJ} getpass.o" else -AC_CACHE_CHECK([whether getpass should be replaced],samba_cv_REPLACE_GETPASS,[ +AC_CACHE_CHECK([whether getpass should be replaced],libreplace_cv_REPLACE_GETPASS,[ SAVE_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS -I$libreplacedir/" AC_TRY_COMPILE([ #include "confdefs.h" #define NO_CONFIG_H #include "$libreplacedir/getpass.c" -],[],samba_cv_REPLACE_GETPASS=yes,samba_cv_REPLACE_GETPASS=no) +],[],libreplace_cv_REPLACE_GETPASS=yes,libreplace_cv_REPLACE_GETPASS=no) CPPFLAGS="$SAVE_CPPFLAGS" ]) -if test x"$samba_cv_REPLACE_GETPASS" = x"yes"; then +if test x"$libreplace_cv_REPLACE_GETPASS" = x"yes"; then AC_DEFINE(REPLACE_GETPASS,1,[Whether getpass should be replaced]) LIBREPLACEOBJ="${LIBREPLACEOBJ} getpass.o" fi -- cgit From ab665b0b0553f7909a217373d0690d99bd80d2db Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 20 Feb 2008 12:49:30 +0100 Subject: libreplace: change samba_cv_ to libreplace_cv_ in system/config.m4. Michael (This used to be commit 00c173bfba9c659750bf231fbd9278dd38aa8bfc) --- source4/lib/replace/system/config.m4 | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/source4/lib/replace/system/config.m4 b/source4/lib/replace/system/config.m4 index 1c05733126..66c2bd652a 100644 --- a/source4/lib/replace/system/config.m4 +++ b/source4/lib/replace/system/config.m4 @@ -18,7 +18,7 @@ AC_CHECK_HEADERS(sys/capability.h) case "$host_os" in *linux*) -AC_CACHE_CHECK([for broken RedHat 7.2 system header files],samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS,[ +AC_CACHE_CHECK([for broken RedHat 7.2 system header files],libreplace_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS,[ AC_TRY_COMPILE([ #ifdef HAVE_SYS_VFS_H #include @@ -29,14 +29,14 @@ AC_TRY_COMPILE([ ],[ int i; ], - samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=no, - samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=yes + libreplace_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=no, + libreplace_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=yes )]) -if test x"$samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS" = x"yes"; then +if test x"$libreplace_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS" = x"yes"; then AC_DEFINE(BROKEN_REDHAT_7_SYSTEM_HEADERS,1,[Broken RedHat 7.2 system header files]) fi -AC_CACHE_CHECK([for broken RHEL5 sys/capability.h],samba_cv_BROKEN_RHEL5_SYS_CAP_HEADER,[ +AC_CACHE_CHECK([for broken RHEL5 sys/capability.h],libreplace_cv_BROKEN_RHEL5_SYS_CAP_HEADER,[ AC_TRY_COMPILE([ #ifdef HAVE_SYS_CAPABILITY_H #include @@ -45,10 +45,10 @@ AC_TRY_COMPILE([ ],[ __s8 i; ], - samba_cv_BROKEN_RHEL5_SYS_CAP_HEADER=no, - samba_cv_BROKEN_RHEL5_SYS_CAP_HEADER=yes + libreplace_cv_BROKEN_RHEL5_SYS_CAP_HEADER=no, + libreplace_cv_BROKEN_RHEL5_SYS_CAP_HEADER=yes )]) -if test x"$samba_cv_BROKEN_RHEL5_SYS_CAP_HEADER" = x"yes"; then +if test x"$libreplace_cv_BROKEN_RHEL5_SYS_CAP_HEADER" = x"yes"; then AC_DEFINE(BROKEN_RHEL5_SYS_CAP_HEADER,1,[Broken RHEL5 sys/capability.h]) fi ;; -- cgit From 2c134f3cd5de1851c8cb5900b830cca25892d735 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 20 Feb 2008 12:53:07 +0100 Subject: libreplace: change samba_cv_ to libreplace_cv_ in libreplace.m4. Michael (This used to be commit 83387ecccfe95b80525bf53c5fc9e945ffee10ec) --- source4/lib/replace/libreplace.m4 | 72 +++++++++++++++++++-------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index 6d1d6b8afc..2e0cd34f4a 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -85,10 +85,10 @@ AC_INCLUDES_DEFAULT #endif] ) -AC_CACHE_CHECK([for working mmap],samba_cv_HAVE_MMAP,[ +AC_CACHE_CHECK([for working mmap],libreplace_cv_HAVE_MMAP,[ AC_TRY_RUN([#include "$libreplacedir/test/shared_mmap.c"], - samba_cv_HAVE_MMAP=yes,samba_cv_HAVE_MMAP=no,samba_cv_HAVE_MMAP=cross)]) -if test x"$samba_cv_HAVE_MMAP" = x"yes"; then + libreplace_cv_HAVE_MMAP=yes,libreplace_cv_HAVE_MMAP=no,libreplace_cv_HAVE_MMAP=cross)]) +if test x"$libreplace_cv_HAVE_MMAP" = x"yes"; then AC_DEFINE(HAVE_MMAP,1,[Whether mmap works]) fi @@ -120,7 +120,7 @@ if test x"$libreplace_cv_USABLE_NET_IF_H" = x"yes";then AC_DEFINE(HAVE_NET_IF_H, 1, usability of net/if.h) fi -AC_CACHE_CHECK([for broken inet_ntoa],samba_cv_REPLACE_INET_NTOA,[ +AC_CACHE_CHECK([for broken inet_ntoa],libreplace_cv_REPLACE_INET_NTOA,[ AC_TRY_RUN([ #include #include @@ -133,8 +133,8 @@ main() { struct in_addr ip; ip.s_addr = 0x12345678; if (strcmp(inet_ntoa(ip),"18.52.86.120") && strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(0); } exit(1);}], - samba_cv_REPLACE_INET_NTOA=yes,samba_cv_REPLACE_INET_NTOA=no,samba_cv_REPLACE_INET_NTOA=cross)]) -if test x"$samba_cv_REPLACE_INET_NTOA" = x"yes"; then + libreplace_cv_REPLACE_INET_NTOA=yes,libreplace_cv_REPLACE_INET_NTOA=no,libreplace_cv_REPLACE_INET_NTOA=cross)]) +if test x"$libreplace_cv_REPLACE_INET_NTOA" = x"yes"; then AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced]) fi @@ -182,7 +182,7 @@ AC_HAVE_DECL(setresuid, [#include ]) AC_HAVE_DECL(setresgid, [#include ]) AC_HAVE_DECL(errno, [#include ]) -AC_CACHE_CHECK([for secure mkstemp],samba_cv_HAVE_SECURE_MKSTEMP,[ +AC_CACHE_CHECK([for secure mkstemp],libreplace_cv_HAVE_SECURE_MKSTEMP,[ AC_TRY_RUN([#include #include #include @@ -197,10 +197,10 @@ main() { if ((st.st_mode & 0777) != 0600) exit(1); exit(0); }], -samba_cv_HAVE_SECURE_MKSTEMP=yes, -samba_cv_HAVE_SECURE_MKSTEMP=no, -samba_cv_HAVE_SECURE_MKSTEMP=cross)]) -if test x"$samba_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then +libreplace_cv_HAVE_SECURE_MKSTEMP=yes, +libreplace_cv_HAVE_SECURE_MKSTEMP=no, +libreplace_cv_HAVE_SECURE_MKSTEMP=cross)]) +if test x"$libreplace_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then AC_DEFINE(HAVE_SECURE_MKSTEMP,1,[Whether mkstemp is secure]) fi @@ -209,7 +209,7 @@ AC_CHECK_HEADERS(stdio.h strings.h) AC_CHECK_DECLS([snprintf, vsnprintf, asprintf, vasprintf]) AC_CHECK_FUNCS(snprintf vsnprintf asprintf vasprintf) -AC_CACHE_CHECK([for C99 vsnprintf],samba_cv_HAVE_C99_VSNPRINTF,[ +AC_CACHE_CHECK([for C99 vsnprintf],libreplace_cv_HAVE_C99_VSNPRINTF,[ AC_TRY_RUN([ #include #include @@ -243,43 +243,43 @@ void foo(const char *format, ...) { } main() { foo("hello"); } ], -samba_cv_HAVE_C99_VSNPRINTF=yes,samba_cv_HAVE_C99_VSNPRINTF=no,samba_cv_HAVE_C99_VSNPRINTF=cross)]) -if test x"$samba_cv_HAVE_C99_VSNPRINTF" = x"yes"; then +libreplace_cv_HAVE_C99_VSNPRINTF=yes,libreplace_cv_HAVE_C99_VSNPRINTF=no,libreplace_cv_HAVE_C99_VSNPRINTF=cross)]) +if test x"$libreplace_cv_HAVE_C99_VSNPRINTF" = x"yes"; then AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Whether there is a C99 compliant vsnprintf]) fi dnl VA_COPY -AC_CACHE_CHECK([for va_copy],samba_cv_HAVE_VA_COPY,[ +AC_CACHE_CHECK([for va_copy],libreplace_cv_HAVE_VA_COPY,[ AC_TRY_LINK([#include va_list ap1,ap2;], [va_copy(ap1,ap2);], -samba_cv_HAVE_VA_COPY=yes,samba_cv_HAVE_VA_COPY=no)]) -if test x"$samba_cv_HAVE_VA_COPY" = x"yes"; then +libreplace_cv_HAVE_VA_COPY=yes,libreplace_cv_HAVE_VA_COPY=no)]) +if test x"$libreplace_cv_HAVE_VA_COPY" = x"yes"; then AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available]) fi -if test x"$samba_cv_HAVE_VA_COPY" != x"yes"; then -AC_CACHE_CHECK([for __va_copy],samba_cv_HAVE___VA_COPY,[ +if test x"$libreplace_cv_HAVE_VA_COPY" != x"yes"; then +AC_CACHE_CHECK([for __va_copy],libreplace_cv_HAVE___VA_COPY,[ AC_TRY_LINK([#include va_list ap1,ap2;], [__va_copy(ap1,ap2);], -samba_cv_HAVE___VA_COPY=yes,samba_cv_HAVE___VA_COPY=no)]) -if test x"$samba_cv_HAVE___VA_COPY" = x"yes"; then +libreplace_cv_HAVE___VA_COPY=yes,libreplace_cv_HAVE___VA_COPY=no)]) +if test x"$libreplace_cv_HAVE___VA_COPY" = x"yes"; then AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available]) fi fi dnl __FUNCTION__ macro -AC_CACHE_CHECK([for __FUNCTION__ macro],samba_cv_HAVE_FUNCTION_MACRO,[ +AC_CACHE_CHECK([for __FUNCTION__ macro],libreplace_cv_HAVE_FUNCTION_MACRO,[ AC_TRY_COMPILE([#include ], [printf("%s\n", __FUNCTION__);], -samba_cv_HAVE_FUNCTION_MACRO=yes,samba_cv_HAVE_FUNCTION_MACRO=no)]) -if test x"$samba_cv_HAVE_FUNCTION_MACRO" = x"yes"; then +libreplace_cv_HAVE_FUNCTION_MACRO=yes,libreplace_cv_HAVE_FUNCTION_MACRO=no)]) +if test x"$libreplace_cv_HAVE_FUNCTION_MACRO" = x"yes"; then AC_DEFINE(HAVE_FUNCTION_MACRO,1,[Whether there is a __FUNCTION__ macro]) else dnl __func__ macro - AC_CACHE_CHECK([for __func__ macro],samba_cv_HAVE_func_MACRO,[ + AC_CACHE_CHECK([for __func__ macro],libreplace_cv_HAVE_func_MACRO,[ AC_TRY_COMPILE([#include ], [printf("%s\n", __func__);], - samba_cv_HAVE_func_MACRO=yes,samba_cv_HAVE_func_MACRO=no)]) - if test x"$samba_cv_HAVE_func_MACRO" = x"yes"; then + libreplace_cv_HAVE_func_MACRO=yes,libreplace_cv_HAVE_func_MACRO=no)]) + if test x"$libreplace_cv_HAVE_func_MACRO" = x"yes"; then AC_DEFINE(HAVE_func_MACRO,1,[Whether there is a __func__ macro]) fi fi @@ -302,7 +302,7 @@ eprintf("bla", "bar"); ], AC_DEFINE(HAVE__VA_ARGS__MACRO, 1, [Whether the __VA_ARGS__ macro is available])) -AC_CACHE_CHECK([for sig_atomic_t type],samba_cv_sig_atomic_t, [ +AC_CACHE_CHECK([for sig_atomic_t type],libreplace_cv_sig_atomic_t, [ AC_TRY_COMPILE([ #include #if STDC_HEADERS @@ -310,30 +310,30 @@ AC_CACHE_CHECK([for sig_atomic_t type],samba_cv_sig_atomic_t, [ #include #endif #include ],[sig_atomic_t i = 0], - samba_cv_sig_atomic_t=yes,samba_cv_sig_atomic_t=no)]) -if test x"$samba_cv_sig_atomic_t" = x"yes"; then + libreplace_cv_sig_atomic_t=yes,libreplace_cv_sig_atomic_t=no)]) +if test x"$libreplace_cv_sig_atomic_t" = x"yes"; then AC_DEFINE(HAVE_SIG_ATOMIC_T_TYPE,1,[Whether we have the atomic_t variable type]) fi -AC_CACHE_CHECK([for O_DIRECT flag to open(2)],samba_cv_HAVE_OPEN_O_DIRECT,[ +AC_CACHE_CHECK([for O_DIRECT flag to open(2)],libreplace_cv_HAVE_OPEN_O_DIRECT,[ AC_TRY_COMPILE([ #include #ifdef HAVE_FCNTL_H #include #endif], [int fd = open("/dev/null", O_DIRECT);], -samba_cv_HAVE_OPEN_O_DIRECT=yes,samba_cv_HAVE_OPEN_O_DIRECT=no)]) -if test x"$samba_cv_HAVE_OPEN_O_DIRECT" = x"yes"; then +libreplace_cv_HAVE_OPEN_O_DIRECT=yes,libreplace_cv_HAVE_OPEN_O_DIRECT=no)]) +if test x"$libreplace_cv_HAVE_OPEN_O_DIRECT" = x"yes"; then AC_DEFINE(HAVE_OPEN_O_DIRECT,1,[Whether the open(2) accepts O_DIRECT]) fi dnl Check if the C compiler understands volatile (it should, being ANSI). -AC_CACHE_CHECK([that the C compiler understands volatile],samba_cv_volatile, [ +AC_CACHE_CHECK([that the C compiler understands volatile],libreplace_cv_volatile, [ AC_TRY_COMPILE([#include ],[volatile int i = 0], - samba_cv_volatile=yes,samba_cv_volatile=no)]) -if test x"$samba_cv_volatile" = x"yes"; then + libreplace_cv_volatile=yes,libreplace_cv_volatile=no)]) +if test x"$libreplace_cv_volatile" = x"yes"; then AC_DEFINE(HAVE_VOLATILE, 1, [Whether the C compiler understands volatile]) fi -- cgit From 5e0f8cabee6ea9528e1bba6c0d3edc7014fb5922 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 20 Feb 2008 19:34:45 +0100 Subject: Make all auth module init functions public, since they are compiled with -fvisibility=hidden. Not doing this causes failures on Mac OS X. (This used to be commit 675bab738085cb5a9f17c1f159fbd97c4daafed2) --- source4/auth/auth_anonymous.c | 2 +- source4/auth/auth_developer.c | 2 +- source4/auth/auth_sam.c | 2 +- source4/auth/auth_unix.c | 2 +- source4/auth/auth_winbind.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/source4/auth/auth_anonymous.c b/source4/auth/auth_anonymous.c index bcab918347..38c13d4b65 100644 --- a/source4/auth/auth_anonymous.c +++ b/source4/auth/auth_anonymous.c @@ -63,7 +63,7 @@ static const struct auth_operations anonymous_auth_ops = { .check_password = anonymous_check_password }; -NTSTATUS auth_anonymous_init(void) +_PUBLIC_ NTSTATUS auth_anonymous_init(void) { NTSTATUS ret; diff --git a/source4/auth/auth_developer.c b/source4/auth/auth_developer.c index 57eb752ac8..0da947b68d 100644 --- a/source4/auth/auth_developer.c +++ b/source4/auth/auth_developer.c @@ -186,7 +186,7 @@ static const struct auth_operations fixed_challenge_auth_ops = { .check_password = fixed_challenge_check_password }; -NTSTATUS auth_developer_init(void) +_PUBLIC_ NTSTATUS auth_developer_init(void) { NTSTATUS ret; diff --git a/source4/auth/auth_sam.c b/source4/auth/auth_sam.c index 0885d8265a..9189640150 100644 --- a/source4/auth/auth_sam.c +++ b/source4/auth/auth_sam.c @@ -425,7 +425,7 @@ static const struct auth_operations sam_ops = { .check_password = authsam_check_password }; -NTSTATUS auth_sam_init(void) +_PUBLIC_ NTSTATUS auth_sam_init(void) { NTSTATUS ret; diff --git a/source4/auth/auth_unix.c b/source4/auth/auth_unix.c index 62fb42935a..20e198701d 100644 --- a/source4/auth/auth_unix.c +++ b/source4/auth/auth_unix.c @@ -829,7 +829,7 @@ static const struct auth_operations unix_ops = { .check_password = authunix_check_password }; -NTSTATUS auth_unix_init(void) +_PUBLIC_ NTSTATUS auth_unix_init(void) { NTSTATUS ret; diff --git a/source4/auth/auth_winbind.c b/source4/auth/auth_winbind.c index 89ae3195df..2f8074d3cb 100644 --- a/source4/auth/auth_winbind.c +++ b/source4/auth/auth_winbind.c @@ -260,7 +260,7 @@ static const struct auth_operations winbind_ops = { .check_password = winbind_check_password }; -NTSTATUS auth_winbind_init(void) +_PUBLIC_ NTSTATUS auth_winbind_init(void) { NTSTATUS ret; -- cgit From 39a6495c86679d5e970012a0d1f5cd375e56450c Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 20 Feb 2008 19:40:20 +0100 Subject: Make more module init functions public, since they are compiled with -fvisibility=hidden. Not doing this causes failures on Mac OS X. (This used to be commit da1a9438bd89569077ef1eaa9dc977b5f9d62836) --- source4/auth/gensec/gensec_gssapi.c | 2 +- source4/auth/gensec/gensec_krb5.c | 2 +- source4/auth/gensec/schannel.c | 2 +- source4/auth/gensec/spnego.c | 2 +- source4/auth/ntlmssp/ntlmssp.c | 2 +- source4/lib/events/events_select.c | 2 +- source4/lib/events/events_standard.c | 2 +- source4/lib/socket/socket_ip.c | 4 ++-- source4/lib/socket/socket_unix.c | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/source4/auth/gensec/gensec_gssapi.c b/source4/auth/gensec/gensec_gssapi.c index 87fa47646b..8361b115d7 100644 --- a/source4/auth/gensec/gensec_gssapi.c +++ b/source4/auth/gensec/gensec_gssapi.c @@ -1463,7 +1463,7 @@ static const struct gensec_security_ops gensec_gssapi_sasl_krb5_security_ops = { .priority = GENSEC_GSSAPI }; -NTSTATUS gensec_gssapi_init(void) +_PUBLIC_ NTSTATUS gensec_gssapi_init(void) { NTSTATUS ret; diff --git a/source4/auth/gensec/gensec_krb5.c b/source4/auth/gensec/gensec_krb5.c index 5cd0de1ceb..d9addcaa3c 100644 --- a/source4/auth/gensec/gensec_krb5.c +++ b/source4/auth/gensec/gensec_krb5.c @@ -775,7 +775,7 @@ static const struct gensec_security_ops gensec_krb5_security_ops = { .priority = GENSEC_KRB5 }; -NTSTATUS gensec_krb5_init(void) +_PUBLIC_ NTSTATUS gensec_krb5_init(void) { NTSTATUS ret; diff --git a/source4/auth/gensec/schannel.c b/source4/auth/gensec/schannel.c index 42db959380..96e3478982 100644 --- a/source4/auth/gensec/schannel.c +++ b/source4/auth/gensec/schannel.c @@ -274,7 +274,7 @@ static const struct gensec_security_ops gensec_schannel_security_ops = { .priority = GENSEC_SCHANNEL }; -NTSTATUS gensec_schannel_init(void) +_PUBLIC_ NTSTATUS gensec_schannel_init(void) { NTSTATUS ret; ret = gensec_register(&gensec_schannel_security_ops); diff --git a/source4/auth/gensec/spnego.c b/source4/auth/gensec/spnego.c index 782aa44c75..f593d17d4b 100644 --- a/source4/auth/gensec/spnego.c +++ b/source4/auth/gensec/spnego.c @@ -1042,7 +1042,7 @@ static const struct gensec_security_ops gensec_spnego_security_ops = { .priority = GENSEC_SPNEGO }; -NTSTATUS gensec_spnego_init(void) +_PUBLIC_ NTSTATUS gensec_spnego_init(void) { NTSTATUS ret; ret = gensec_register(&gensec_spnego_security_ops); diff --git a/source4/auth/ntlmssp/ntlmssp.c b/source4/auth/ntlmssp/ntlmssp.c index 4f5822567a..8901488004 100644 --- a/source4/auth/ntlmssp/ntlmssp.c +++ b/source4/auth/ntlmssp/ntlmssp.c @@ -425,7 +425,7 @@ static const struct gensec_security_ops gensec_ntlmssp_security_ops = { }; -NTSTATUS gensec_ntlmssp_init(void) +_PUBLIC_ NTSTATUS gensec_ntlmssp_init(void) { NTSTATUS ret; diff --git a/source4/lib/events/events_select.c b/source4/lib/events/events_select.c index 3f9eeb5617..f4b7e4e5eb 100644 --- a/source4/lib/events/events_select.c +++ b/source4/lib/events/events_select.c @@ -300,7 +300,7 @@ bool events_select_init(void) } #if _SAMBA_BUILD_ -NTSTATUS s4_events_select_init(void) +_PUBLIC_ NTSTATUS s4_events_select_init(void) { if (!events_select_init()) { return NT_STATUS_INTERNAL_ERROR; diff --git a/source4/lib/events/events_standard.c b/source4/lib/events/events_standard.c index 5e529d66ab..7b945b154d 100644 --- a/source4/lib/events/events_standard.c +++ b/source4/lib/events/events_standard.c @@ -602,7 +602,7 @@ bool events_standard_init(void) } #if _SAMBA_BUILD_ -NTSTATUS s4_events_standard_init(void) +_PUBLIC_ NTSTATUS s4_events_standard_init(void) { if (!events_standard_init()) { return NT_STATUS_INTERNAL_ERROR; diff --git a/source4/lib/socket/socket_ip.c b/source4/lib/socket/socket_ip.c index e61b6d82fc..bca0aab924 100644 --- a/source4/lib/socket/socket_ip.c +++ b/source4/lib/socket/socket_ip.c @@ -540,7 +540,7 @@ static const struct socket_ops ipv4_ops = { .fn_get_fd = ip_get_fd }; -const struct socket_ops *socket_ipv4_ops(enum socket_type type) +_PUBLIC_ const struct socket_ops *socket_ipv4_ops(enum socket_type type) { return &ipv4_ops; } @@ -977,7 +977,7 @@ static const struct socket_ops ipv6_tcp_ops = { .fn_get_fd = ip_get_fd }; -const struct socket_ops *socket_ipv6_ops(enum socket_type type) +_PUBLIC_ const struct socket_ops *socket_ipv6_ops(enum socket_type type) { return &ipv6_tcp_ops; } diff --git a/source4/lib/socket/socket_unix.c b/source4/lib/socket/socket_unix.c index cac4b8e913..af7d2bb79f 100644 --- a/source4/lib/socket/socket_unix.c +++ b/source4/lib/socket/socket_unix.c @@ -414,7 +414,7 @@ static const struct socket_ops unixdom_ops = { .fn_get_fd = unixdom_get_fd }; -const struct socket_ops *socket_unixdom_ops(enum socket_type type) +_PUBLIC_ const struct socket_ops *socket_unixdom_ops(enum socket_type type) { return &unixdom_ops; } -- cgit From 910a1cafdf253255510d3aff7cc2385da43331dd Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 20 Feb 2008 20:05:51 +0100 Subject: Support dlopen(NULL, ...) on HPUX. (This used to be commit 53c70b5f77a3b9abaab783590e66278129173d5f) --- source4/lib/replace/dlfcn.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source4/lib/replace/dlfcn.c b/source4/lib/replace/dlfcn.c index 42848848e8..3b109d7e40 100644 --- a/source4/lib/replace/dlfcn.c +++ b/source4/lib/replace/dlfcn.c @@ -35,6 +35,8 @@ void *rep_dlopen(const char *name, int flags) #endif { #ifdef HAVE_SHL_LOAD + if (name == NULL) + return PROG_HANDLE; return (void *)shl_load(name, flags, 0); #else return NULL; -- cgit From 49b3a4829325967df9d1e616ad32e5379ce6cf5d Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 21 Feb 2008 09:53:11 +1100 Subject: Until the new ldb changes land, make ldb_wait set the error string. This makes it easier to track down which module only returned and error code, but not the error string. Andrew Bartlett (This used to be commit c4d502f68fbd5d5bc2ac5bb6369950379c9176fc) --- source4/lib/ldb/common/ldb.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source4/lib/ldb/common/ldb.c b/source4/lib/ldb/common/ldb.c index 87f791cb38..5601a33191 100644 --- a/source4/lib/ldb/common/ldb.c +++ b/source4/lib/ldb/common/ldb.c @@ -463,11 +463,17 @@ static int ldb_autotransaction_request(struct ldb_context *ldb, struct ldb_reque int ldb_wait(struct ldb_handle *handle, enum ldb_wait_type type) { + int ret; if (!handle) { return LDB_SUCCESS; } - return handle->module->ops->wait(handle, type); + ret = handle->module->ops->wait(handle, type); + if (!ldb_errstring(handle->module->ldb)) { + /* Set a default error string, to place the blame somewhere */ + ldb_asprintf_errstring(handle->module->ldb, "error waiting on module %s: %s (%d)", handle->module->ops->name, ldb_strerror(ret), ret); + } + return ret; } /* set the specified timeout or, if timeout is 0 set the default timeout */ -- cgit From 0b1a24681e6b41129e05a9612610fade27aecd4d Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 21 Feb 2008 10:43:13 +1100 Subject: Be consistant about --ldap-backend-type Make the EJS provision and the selftest scripts both use the new syntax for speicifying the ldap backend type. Andrew Bartlett (This used to be commit b1d2584277304be3f2a640465cbf6b2a3ec571cc) --- source4/selftest/target/Samba4.pm | 3 ++- source4/setup/provision | 16 ++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/source4/selftest/target/Samba4.pm b/source4/selftest/target/Samba4.pm index 563aca876e..11d4c85aee 100644 --- a/source4/selftest/target/Samba4.pm +++ b/source4/selftest/target/Samba4.pm @@ -729,9 +729,10 @@ nogroup:x:65534:nobody if ($self->{ldap} eq "openldap") { ($ret->{SLAPD_CONF}, $ret->{OPENLDAP_PIDFILE}) = $self->mk_openldap($ldapdir, $configuration) or die("Unable to create openldap directories"); + push (@provision_options, "--ldap-backend-type=openldap"); } elsif ($self->{ldap} eq "fedora-ds") { ($ret->{FEDORA_DS_DIR}, $ret->{FEDORA_DS_PIDFILE}) = $self->mk_fedora_ds($ldapdir, $configuration) or die("Unable to create fedora ds directories"); - push (@provision_options, "--ldap-module=nsuniqueid"); + push (@provision_options, "--ldap-backend-type=fedora-ds"); push (@provision_options, "'--aci=aci:: KHRhcmdldGF0dHIgPSAiKiIpICh2ZXJzaW9uIDMuMDthY2wgImZ1bGwgYWNjZXNzIHRvIGFsbCBieSBhbGwiO2FsbG93IChhbGwpKHVzZXJkbiA9ICJsZGFwOi8vL2FueW9uZSIpOykK'"); } diff --git a/source4/setup/provision b/source4/setup/provision index 9e135cddbb..328754fd9c 100755 --- a/source4/setup/provision +++ b/source4/setup/provision @@ -35,7 +35,7 @@ options = GetOptions(ARGV, 'partitions-only', 'ldap-base', 'ldap-backend=s', - 'ldap-module=s', + 'ldap-backend-type=s', 'aci=s'); if (options == undefined) { @@ -88,7 +88,7 @@ provision [options] --partitions-only Configure Samba's partitions, but do not modify them (ie, join a BDC) --ldap-base output only an LDIF file, suitable for creating an LDAP baseDN --ldap-backend LDAPSERVER LDAP server to use for this provision - --ldap-module MODULE LDB mapping module to use for the LDAP backend + --ldap-backend-type TYPE OpenLDAP or Fedora DS --aci ACI An arbitary LDIF fragment, particularly useful to loading a backend ACI value into a target LDAP server You must provide at least a realm and domain @@ -124,7 +124,7 @@ for (r in options) { var blank = (options["blank"] != undefined); var ldapbackend = (options["ldap-backend"] != undefined); -var ldapmodule = (options["ldap-module"] != undefined); +var ldapbackendtype = options["ldap-backend-type"]; var partitions_only = (options["partitions-only"] != undefined); var paths = provision_default_paths(subobj); if (options["aci"] != undefined) { @@ -139,9 +139,13 @@ if (ldapbackend) { if (options["ldap-backend"] == "ldapi") { subobj.LDAPBACKEND = subobj.LDAPI_URI; } - if (!ldapmodule) { + if (ldapbackendtype == undefined) { + + } else if (ldapbackendtype == "openldap") { subobj.LDAPMODULE = "normalise,entryuuid"; subobj.TDB_MODULES_LIST = ""; + } else if (ldapbackendtype == "fedora-ds") { + subobj.LDAPMODULE = "nsuniqueid"; } subobj.BACKEND_MOD = subobj.LDAPMODULE + ",paged_searches"; subobj.DOMAINDN_LDB = subobj.LDAPBACKEND; @@ -183,8 +187,8 @@ if (partitions_only) { if (ldapbackend) { message("--ldap-backend='%s' \\\n", subobj.LDAPBACKEND); } - if (ldapmodule) { - message("--ldap-module='%s' \\\n", + subobj.LDAPMODULE); + if (ldapbackendtype != undefined) { + message("--ldap-backend-type='%s' \\\n", + ldapbackendtype); } message("--aci='" + subobj.ACI + "' \\\n") } -- cgit From c9290a86dd0bddba23ec43527ab52503b962963d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 21 Feb 2008 01:04:18 +0100 Subject: Never assume -fvisibility=hidden for modules unless explicitly specified (consistent with what we do for other subsystems/libraries). (This used to be commit e8751e513d5f9b30e518104bbc23bcbd203818a6) --- source4/build/smb_build/input.pm | 8 -------- 1 file changed, 8 deletions(-) diff --git a/source4/build/smb_build/input.pm b/source4/build/smb_build/input.pm index da90e9db48..8c9a6efacc 100644 --- a/source4/build/smb_build/input.pm +++ b/source4/build/smb_build/input.pm @@ -233,14 +233,6 @@ sub check($$$$$) my ($INPUT, $enabled, $subsys_ot, $lib_ot, $module_ot) = @_; foreach my $part (values %$INPUT) { - unless (defined($part->{STANDARD_VISIBILITY})) { - if ($part->{TYPE} eq "MODULE" or $part->{TYPE} eq "BINARY") { - $part->{STANDARD_VISIBILITY} = "hidden"; - } else { - $part->{STANDARD_VISIBILITY} = "default"; - } - } - unless (defined($part->{PUBLIC_HEADERS})) { $part->{PUBLIC_HEADERS} = []; } -- cgit From 14a2c4c84bc84a203caf7a8b143fbe49c714b1f9 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 21 Feb 2008 01:20:12 +0100 Subject: Remove kinit with pkinit failure from known failures list again. (This used to be commit 157deac27d01dc61952601ffd2655c8161418ac7) --- source4/samba4-knownfail | 1 - 1 file changed, 1 deletion(-) diff --git a/source4/samba4-knownfail b/source4/samba4-knownfail index 651111221f..18fb4b914b 100644 --- a/source4/samba4-knownfail +++ b/source4/samba4-knownfail @@ -34,6 +34,5 @@ rpc.netlogon.*.GetTrustPasswords base.charset.*.Testing partial surrogate .*net.api.delshare.* # DelShare isn't implemented yet rap.*netservergetinfo -kinit with pkinit # fails with: salt type 3 not supported samba4.blackbox.provision.py.reprovision # Fails with entry already exists local.torture.provision -- cgit From ee6f838d3a5aaa54b105249391aae89803901a2e Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 21 Feb 2008 01:22:20 +0100 Subject: Make setup/provision the name of the python provision script now that that is the default. (This used to be commit a0a05c5a3d614d0f2936ecfcab5273a2ef7d61a8) --- source4/selftest/target/Samba4.pm | 4 +- source4/setup/provision | 368 ++++++++++++++---------------- source4/setup/provision.js | 198 ++++++++++++++++ source4/setup/provision.py | 170 -------------- source4/setup/tests/blackbox_provision.sh | 6 +- 5 files changed, 373 insertions(+), 373 deletions(-) create mode 100755 source4/setup/provision.js delete mode 100755 source4/setup/provision.py diff --git a/source4/selftest/target/Samba4.pm b/source4/selftest/target/Samba4.pm index 11d4c85aee..37e3cbe354 100644 --- a/source4/selftest/target/Samba4.pm +++ b/source4/selftest/target/Samba4.pm @@ -676,10 +676,10 @@ nogroup:x:65534:nobody push (@provision_options, "NSS_WRAPPER_GROUP=\"$nsswrap_group\""); if (defined($ENV{PROVISION_EJS})) { push (@provision_options, "$self->{bindir}/smbscript"); - push (@provision_options, "$self->{setupdir}/provision"); + push (@provision_options, "$self->{setupdir}/provision.js"); } else { push (@provision_options, "$self->{bindir}/smbpython"); - push (@provision_options, "$self->{setupdir}/provision.py"); + push (@provision_options, "$self->{setupdir}/provision"); } push (@provision_options, split(' ', $configuration)); push (@provision_options, "--host-name=$netbiosname"); diff --git a/source4/setup/provision b/source4/setup/provision index 328754fd9c..033d2491f2 100755 --- a/source4/setup/provision +++ b/source4/setup/provision @@ -1,198 +1,170 @@ -#!/bin/sh -exec smbscript "$0" ${1+"$@"} -/* - provision a Samba4 server - Copyright Andrew Tridgell 2005 - Released under the GNU GPL v2 or later -*/ - -options = GetOptions(ARGV, - "POPT_AUTOHELP", - "POPT_COMMON_SAMBA", - "POPT_COMMON_VERSION", - "POPT_COMMON_CREDENTIALS", - 'realm=s', - 'domain=s', - 'domain-guid=s', - 'domain-sid=s', - 'policy-guid=s', - 'host-name=s', - 'host-ip=s', - 'host-guid=s', - 'invocationid=s', - 'adminpass=s', - 'krbtgtpass=s', - 'machinepass=s', - 'dnspass=s', - 'root=s', - 'nobody=s', - 'nogroup=s', - 'wheel=s', - 'users=s', - 'quiet', - 'blank', - 'server-role=s', - 'partitions-only', - 'ldap-base', - 'ldap-backend=s', - 'ldap-backend-type=s', - 'aci=s'); - -if (options == undefined) { - println("Failed to parse options"); - return -1; -} - -libinclude("base.js"); -libinclude("provision.js"); - -/* - print a message if quiet is not set -*/ -function message() -{ - if (options["quiet"] == undefined) { - print(vsprintf(arguments)); - } -} - -/* - show some help -*/ -function ShowHelp() -{ - print(" -Samba4 provisioning - -provision [options] - --realm REALM set realm - --domain DOMAIN set domain - --domain-guid GUID set domainguid (otherwise random) - --domain-sid SID set domainsid (otherwise random) - --host-name HOSTNAME set hostname - --host-ip IPADDRESS set ipaddress - --host-guid GUID set hostguid (otherwise random) - --policy-guid GUID set group policy guid (otherwise random) - --invocationid GUID set invocationid (otherwise random) - --adminpass PASSWORD choose admin password (otherwise random) - --krbtgtpass PASSWORD choose krbtgt password (otherwise random) - --machinepass PASSWORD choose machine password (otherwise random) - --root USERNAME choose 'root' unix username - --nobody USERNAME choose 'nobody' user - --nogroup GROUPNAME choose 'nogroup' group - --wheel GROUPNAME choose 'wheel' privileged group - --users GROUPNAME choose 'users' group - --quiet Be quiet - --blank do not add users or groups, just the structure - --server-role ROLE Set server role to provision for (default standalone) - --partitions-only Configure Samba's partitions, but do not modify them (ie, join a BDC) - --ldap-base output only an LDIF file, suitable for creating an LDAP baseDN - --ldap-backend LDAPSERVER LDAP server to use for this provision - --ldap-backend-type TYPE OpenLDAP or Fedora DS - --aci ACI An arbitary LDIF fragment, particularly useful to loading a backend ACI value into a target LDAP server -You must provide at least a realm and domain - -"); - exit(1); -} - -if (options['host-name'] == undefined) { - options['host-name'] = hostname(); -} - -/* - main program -*/ -if (options["realm"] == undefined || - options["domain"] == undefined || - options["host-name"] == undefined) { - ShowHelp(); -} - -/* cope with an initially blank smb.conf */ -var lp = loadparm_init(); -lp.set("realm", options.realm); -lp.set("workgroup", options.domain); -lp.set("server role", options["server-role"]); -lp.reload(); - -var subobj = provision_guess(); -for (r in options) { - var key = strupper(join("", split("-", r))); - subobj[key] = options[r]; -} - -var blank = (options["blank"] != undefined); -var ldapbackend = (options["ldap-backend"] != undefined); -var ldapbackendtype = options["ldap-backend-type"]; -var partitions_only = (options["partitions-only"] != undefined); -var paths = provision_default_paths(subobj); -if (options["aci"] != undefined) { - message("set ACI: %s\n", subobj["ACI"]); -} - -message("set DOMAIN SID: %s\n", subobj["DOMAINSID"]); - -provision_fix_subobj(subobj, paths); - -if (ldapbackend) { - if (options["ldap-backend"] == "ldapi") { - subobj.LDAPBACKEND = subobj.LDAPI_URI; - } - if (ldapbackendtype == undefined) { - - } else if (ldapbackendtype == "openldap") { - subobj.LDAPMODULE = "normalise,entryuuid"; - subobj.TDB_MODULES_LIST = ""; - } else if (ldapbackendtype == "fedora-ds") { - subobj.LDAPMODULE = "nsuniqueid"; - } - subobj.BACKEND_MOD = subobj.LDAPMODULE + ",paged_searches"; - subobj.DOMAINDN_LDB = subobj.LDAPBACKEND; - subobj.CONFIGDN_LDB = subobj.LDAPBACKEND; - subobj.SCHEMADN_LDB = subobj.LDAPBACKEND; - message("LDAP module: %s on backend: %s\n", subobj.LDAPMODULE, subobj.LDAPBACKEND); -} - -if (!provision_validate(subobj, message)) { - return -1; -} - -var system_session = system_session(); -var creds = options.get_credentials(); -message("Provisioning for %s in realm %s\n", subobj.DOMAIN, subobj.REALM); -message("Using administrator password: %s\n", subobj.ADMINPASS); -if (partitions_only) { - provision_become_dc(subobj, message, false, paths, system_session); -} else { - provision(subobj, message, blank, paths, system_session, creds, ldapbackend); - provision_dns(subobj, message, paths, system_session, creds); - message("To reproduce this provision, run with:\n"); -/* There has to be a better way than this... */ - message("--realm='%s' --domain='%s' \\\n", subobj.REALM_CONF, subobj.DOMAIN_CONF); - if (subobj.DOMAINGUID != undefined) { - message("--domain-guid='%s' \\\n", subobj.DOMAINGUID); - } - if (subobj.HOSTGUID != undefined) { - message("--host-guid='%s' \\\n", subobj.HOSTGUID); - } - message("--policy-guid='%s' --host-name='%s' --host-ip='%s' \\\n", subobj.POLICYGUID, subobj.HOSTNAME, subobj.HOSTIP); - if (subobj.INVOCATIONID != undefined) { - message("--invocationid='%s' \\\n", subobj.INVOCATIONID); - } - message("--adminpass='%s' --krbtgtpass='%s' \\\n", subobj.ADMINPASS, subobj.KRBTGTPASS); - message("--machinepass='%s' --dnspass='%s' \\\n", subobj.MACHINEPASS, subobj.DNSPASS); - message("--root='%s' --nobody='%s' --nogroup='%s' \\\n", subobj.ROOT, subobj.NOBODY, subobj.NOGROUP); - message("--wheel='%s' --users='%s' --server-role='%s' \\\n", subobj.WHEEL, subobj.USERS, subobj.SERVERROLE); - if (ldapbackend) { - message("--ldap-backend='%s' \\\n", subobj.LDAPBACKEND); - } - if (ldapbackendtype != undefined) { - message("--ldap-backend-type='%s' \\\n", + ldapbackendtype); - } - message("--aci='" + subobj.ACI + "' \\\n") -} - - -message("All OK\n"); -return 0; +#!/usr/bin/python +# +# Unix SMB/CIFS implementation. +# provision a Samba4 server +# Copyright (C) Jelmer Vernooij 2007-2008 +# Copyright (C) Andrew Bartlett 2008 +# +# Based on the original in EJS: +# Copyright (C) Andrew Tridgell 2005 +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +import getopt +import optparse +import os, sys + +import samba + +from auth import system_session +import samba.getopt as options +import param +from samba.provision import (provision, + provision_paths_from_lp, + FILL_FULL, FILL_NT4SYNC, + FILL_DRS) + +parser = optparse.OptionParser("provision [options]") +sambaopts = options.SambaOptions(parser) +parser.add_option_group(sambaopts) +parser.add_option_group(options.VersionOptions(parser)) +credopts = options.CredentialsOptions(parser) +parser.add_option_group(credopts) +parser.add_option("--setupdir", type="string", metavar="DIR", + help="directory with setup files") +parser.add_option("--realm", type="string", metavar="REALM", help="set realm") +parser.add_option("--domain", type="string", metavar="DOMAIN", + help="set domain") +parser.add_option("--domain-guid", type="string", metavar="GUID", + help="set domainguid (otherwise random)") +parser.add_option("--domain-sid", type="string", metavar="SID", + help="set domainsid (otherwise random)") +parser.add_option("--policy-guid", type="string", metavar="GUID", + help="set policy guid") +parser.add_option("--host-name", type="string", metavar="HOSTNAME", + help="set hostname") +parser.add_option("--host-ip", type="string", metavar="IPADDRESS", + help="set ipaddress") +parser.add_option("--host-guid", type="string", metavar="GUID", + help="set hostguid (otherwise random)") +parser.add_option("--invocationid", type="string", metavar="GUID", + help="set invocationid (otherwise random)") +parser.add_option("--adminpass", type="string", metavar="PASSWORD", + help="choose admin password (otherwise random)") +parser.add_option("--krbtgtpass", type="string", metavar="PASSWORD", + help="choose krbtgt password (otherwise random)") +parser.add_option("--machinepass", type="string", metavar="PASSWORD", + help="choose machine password (otherwise random)") +parser.add_option("--dnspass", type="string", metavar="PASSWORD", + help="choose dns password (otherwise random)") +parser.add_option("--root", type="string", metavar="USERNAME", + help="choose 'root' unix username") +parser.add_option("--nobody", type="string", metavar="USERNAME", + help="choose 'nobody' user") +parser.add_option("--nogroup", type="string", metavar="GROUPNAME", + help="choose 'nogroup' group") +parser.add_option("--wheel", type="string", metavar="GROUPNAME", + help="choose 'wheel' privileged group") +parser.add_option("--users", type="string", metavar="GROUPNAME", + help="choose 'users' group") +parser.add_option("--quiet", help="Be quiet", action="store_true") +parser.add_option("--blank", action="store_true", + help="do not add users or groups, just the structure") +parser.add_option("--ldap-backend", type="string", metavar="LDAPSERVER", + help="LDAP server to use for this provision") +parser.add_option("--ldap-backend-type", type="choice", metavar="LDAP-BACKEND-TYPE", + help="LDB mapping module to use for the LDAP backend", + choices=["fedora-ds", "openldap"]) +parser.add_option("--aci", type="string", metavar="ACI", + help="An arbitary LDIF fragment, particularly useful to loading a backend ACI value into a target LDAP server. You must provide at least a realm and domain") +parser.add_option("--server-role", type="choice", metavar="ROLE", + choices=["domain controller", "member server"], + help="Set server role to provision for (default standalone)") +parser.add_option("--partitions-only", + help="Configure Samba's partitions, but do not modify them (ie, join a BDC)", action="store_true") +parser.add_option("--targetdir", type="string", metavar="DIR", + help="Set target directory") + +opts = parser.parse_args()[0] + +def message(text): + """print a message if quiet is not set.""" + if not opts.quiet: + print text + +if opts.realm is None or opts.domain is None: + if opts.realm is None: + print >>sys.stderr, "No realm set" + if opts.domain is None: + print >>sys.stderr, "No domain set" + parser.print_usage() + sys.exit(1) + +# cope with an initially blank smb.conf +private_dir = None +lp = sambaopts.get_loadparm() +if opts.targetdir is not None: + if not os.path.exists(opts.targetdir): + os.mkdir(opts.targetdir) + private_dir = os.path.join(opts.targetdir, "private") + if not os.path.exists(private_dir): + os.mkdir(private_dir) + lp.set("private dir", os.path.abspath(private_dir)) + lp.set("lock dir", os.path.abspath(opts.targetdir)) +lp.set("realm", opts.realm) +lp.set("workgroup", opts.domain) +lp.set("server role", opts.server_role or "domain controller") + +if opts.aci is not None: + print "set ACI: %s" % opts.aci + +paths = provision_paths_from_lp(lp, opts.realm.lower()) +if sambaopts.get_loadparm_path() is not None: + paths.smbconf = sambaopts.get_loadparm_path() + +creds = credopts.get_credentials() + +setup_dir = opts.setupdir +if setup_dir is None: + setup_dir = "setup" + +samdb_fill = FILL_FULL +if opts.blank: + samdb_fill = FILL_NT4SYNC +elif opts.partitions_only: + samdb_fill = FILL_DRS + +provision(lp, setup_dir, message, paths, + system_session(), creds, + samdb_fill=samdb_fill, realm=opts.realm, + domainguid=opts.domain_guid, domainsid=opts.domain_sid, + policyguid=opts.policy_guid, hostname=opts.host_name, + hostip=opts.host_ip, hostguid=opts.host_guid, + invocationid=opts.invocationid, adminpass=opts.adminpass, + krbtgtpass=opts.krbtgtpass, machinepass=opts.machinepass, + dnspass=opts.dnspass, root=opts.root, nobody=opts.nobody, + nogroup=opts.nogroup, wheel=opts.wheel, users=opts.users, + aci=opts.aci, serverrole=opts.server_role, + ldap_backend=opts.ldap_backend, + ldap_backend_type=opts.ldap_backend_type) + +message("To reproduce this provision, run with:") +def shell_escape(arg): + if " " in arg: + return '"%s"' % arg + return arg +message(" ".join([shell_escape(arg) for arg in sys.argv])) + +message("All OK") diff --git a/source4/setup/provision.js b/source4/setup/provision.js new file mode 100755 index 0000000000..328754fd9c --- /dev/null +++ b/source4/setup/provision.js @@ -0,0 +1,198 @@ +#!/bin/sh +exec smbscript "$0" ${1+"$@"} +/* + provision a Samba4 server + Copyright Andrew Tridgell 2005 + Released under the GNU GPL v2 or later +*/ + +options = GetOptions(ARGV, + "POPT_AUTOHELP", + "POPT_COMMON_SAMBA", + "POPT_COMMON_VERSION", + "POPT_COMMON_CREDENTIALS", + 'realm=s', + 'domain=s', + 'domain-guid=s', + 'domain-sid=s', + 'policy-guid=s', + 'host-name=s', + 'host-ip=s', + 'host-guid=s', + 'invocationid=s', + 'adminpass=s', + 'krbtgtpass=s', + 'machinepass=s', + 'dnspass=s', + 'root=s', + 'nobody=s', + 'nogroup=s', + 'wheel=s', + 'users=s', + 'quiet', + 'blank', + 'server-role=s', + 'partitions-only', + 'ldap-base', + 'ldap-backend=s', + 'ldap-backend-type=s', + 'aci=s'); + +if (options == undefined) { + println("Failed to parse options"); + return -1; +} + +libinclude("base.js"); +libinclude("provision.js"); + +/* + print a message if quiet is not set +*/ +function message() +{ + if (options["quiet"] == undefined) { + print(vsprintf(arguments)); + } +} + +/* + show some help +*/ +function ShowHelp() +{ + print(" +Samba4 provisioning + +provision [options] + --realm REALM set realm + --domain DOMAIN set domain + --domain-guid GUID set domainguid (otherwise random) + --domain-sid SID set domainsid (otherwise random) + --host-name HOSTNAME set hostname + --host-ip IPADDRESS set ipaddress + --host-guid GUID set hostguid (otherwise random) + --policy-guid GUID set group policy guid (otherwise random) + --invocationid GUID set invocationid (otherwise random) + --adminpass PASSWORD choose admin password (otherwise random) + --krbtgtpass PASSWORD choose krbtgt password (otherwise random) + --machinepass PASSWORD choose machine password (otherwise random) + --root USERNAME choose 'root' unix username + --nobody USERNAME choose 'nobody' user + --nogroup GROUPNAME choose 'nogroup' group + --wheel GROUPNAME choose 'wheel' privileged group + --users GROUPNAME choose 'users' group + --quiet Be quiet + --blank do not add users or groups, just the structure + --server-role ROLE Set server role to provision for (default standalone) + --partitions-only Configure Samba's partitions, but do not modify them (ie, join a BDC) + --ldap-base output only an LDIF file, suitable for creating an LDAP baseDN + --ldap-backend LDAPSERVER LDAP server to use for this provision + --ldap-backend-type TYPE OpenLDAP or Fedora DS + --aci ACI An arbitary LDIF fragment, particularly useful to loading a backend ACI value into a target LDAP server +You must provide at least a realm and domain + +"); + exit(1); +} + +if (options['host-name'] == undefined) { + options['host-name'] = hostname(); +} + +/* + main program +*/ +if (options["realm"] == undefined || + options["domain"] == undefined || + options["host-name"] == undefined) { + ShowHelp(); +} + +/* cope with an initially blank smb.conf */ +var lp = loadparm_init(); +lp.set("realm", options.realm); +lp.set("workgroup", options.domain); +lp.set("server role", options["server-role"]); +lp.reload(); + +var subobj = provision_guess(); +for (r in options) { + var key = strupper(join("", split("-", r))); + subobj[key] = options[r]; +} + +var blank = (options["blank"] != undefined); +var ldapbackend = (options["ldap-backend"] != undefined); +var ldapbackendtype = options["ldap-backend-type"]; +var partitions_only = (options["partitions-only"] != undefined); +var paths = provision_default_paths(subobj); +if (options["aci"] != undefined) { + message("set ACI: %s\n", subobj["ACI"]); +} + +message("set DOMAIN SID: %s\n", subobj["DOMAINSID"]); + +provision_fix_subobj(subobj, paths); + +if (ldapbackend) { + if (options["ldap-backend"] == "ldapi") { + subobj.LDAPBACKEND = subobj.LDAPI_URI; + } + if (ldapbackendtype == undefined) { + + } else if (ldapbackendtype == "openldap") { + subobj.LDAPMODULE = "normalise,entryuuid"; + subobj.TDB_MODULES_LIST = ""; + } else if (ldapbackendtype == "fedora-ds") { + subobj.LDAPMODULE = "nsuniqueid"; + } + subobj.BACKEND_MOD = subobj.LDAPMODULE + ",paged_searches"; + subobj.DOMAINDN_LDB = subobj.LDAPBACKEND; + subobj.CONFIGDN_LDB = subobj.LDAPBACKEND; + subobj.SCHEMADN_LDB = subobj.LDAPBACKEND; + message("LDAP module: %s on backend: %s\n", subobj.LDAPMODULE, subobj.LDAPBACKEND); +} + +if (!provision_validate(subobj, message)) { + return -1; +} + +var system_session = system_session(); +var creds = options.get_credentials(); +message("Provisioning for %s in realm %s\n", subobj.DOMAIN, subobj.REALM); +message("Using administrator password: %s\n", subobj.ADMINPASS); +if (partitions_only) { + provision_become_dc(subobj, message, false, paths, system_session); +} else { + provision(subobj, message, blank, paths, system_session, creds, ldapbackend); + provision_dns(subobj, message, paths, system_session, creds); + message("To reproduce this provision, run with:\n"); +/* There has to be a better way than this... */ + message("--realm='%s' --domain='%s' \\\n", subobj.REALM_CONF, subobj.DOMAIN_CONF); + if (subobj.DOMAINGUID != undefined) { + message("--domain-guid='%s' \\\n", subobj.DOMAINGUID); + } + if (subobj.HOSTGUID != undefined) { + message("--host-guid='%s' \\\n", subobj.HOSTGUID); + } + message("--policy-guid='%s' --host-name='%s' --host-ip='%s' \\\n", subobj.POLICYGUID, subobj.HOSTNAME, subobj.HOSTIP); + if (subobj.INVOCATIONID != undefined) { + message("--invocationid='%s' \\\n", subobj.INVOCATIONID); + } + message("--adminpass='%s' --krbtgtpass='%s' \\\n", subobj.ADMINPASS, subobj.KRBTGTPASS); + message("--machinepass='%s' --dnspass='%s' \\\n", subobj.MACHINEPASS, subobj.DNSPASS); + message("--root='%s' --nobody='%s' --nogroup='%s' \\\n", subobj.ROOT, subobj.NOBODY, subobj.NOGROUP); + message("--wheel='%s' --users='%s' --server-role='%s' \\\n", subobj.WHEEL, subobj.USERS, subobj.SERVERROLE); + if (ldapbackend) { + message("--ldap-backend='%s' \\\n", subobj.LDAPBACKEND); + } + if (ldapbackendtype != undefined) { + message("--ldap-backend-type='%s' \\\n", + ldapbackendtype); + } + message("--aci='" + subobj.ACI + "' \\\n") +} + + +message("All OK\n"); +return 0; diff --git a/source4/setup/provision.py b/source4/setup/provision.py deleted file mode 100755 index 033d2491f2..0000000000 --- a/source4/setup/provision.py +++ /dev/null @@ -1,170 +0,0 @@ -#!/usr/bin/python -# -# Unix SMB/CIFS implementation. -# provision a Samba4 server -# Copyright (C) Jelmer Vernooij 2007-2008 -# Copyright (C) Andrew Bartlett 2008 -# -# Based on the original in EJS: -# Copyright (C) Andrew Tridgell 2005 -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# - -import getopt -import optparse -import os, sys - -import samba - -from auth import system_session -import samba.getopt as options -import param -from samba.provision import (provision, - provision_paths_from_lp, - FILL_FULL, FILL_NT4SYNC, - FILL_DRS) - -parser = optparse.OptionParser("provision [options]") -sambaopts = options.SambaOptions(parser) -parser.add_option_group(sambaopts) -parser.add_option_group(options.VersionOptions(parser)) -credopts = options.CredentialsOptions(parser) -parser.add_option_group(credopts) -parser.add_option("--setupdir", type="string", metavar="DIR", - help="directory with setup files") -parser.add_option("--realm", type="string", metavar="REALM", help="set realm") -parser.add_option("--domain", type="string", metavar="DOMAIN", - help="set domain") -parser.add_option("--domain-guid", type="string", metavar="GUID", - help="set domainguid (otherwise random)") -parser.add_option("--domain-sid", type="string", metavar="SID", - help="set domainsid (otherwise random)") -parser.add_option("--policy-guid", type="string", metavar="GUID", - help="set policy guid") -parser.add_option("--host-name", type="string", metavar="HOSTNAME", - help="set hostname") -parser.add_option("--host-ip", type="string", metavar="IPADDRESS", - help="set ipaddress") -parser.add_option("--host-guid", type="string", metavar="GUID", - help="set hostguid (otherwise random)") -parser.add_option("--invocationid", type="string", metavar="GUID", - help="set invocationid (otherwise random)") -parser.add_option("--adminpass", type="string", metavar="PASSWORD", - help="choose admin password (otherwise random)") -parser.add_option("--krbtgtpass", type="string", metavar="PASSWORD", - help="choose krbtgt password (otherwise random)") -parser.add_option("--machinepass", type="string", metavar="PASSWORD", - help="choose machine password (otherwise random)") -parser.add_option("--dnspass", type="string", metavar="PASSWORD", - help="choose dns password (otherwise random)") -parser.add_option("--root", type="string", metavar="USERNAME", - help="choose 'root' unix username") -parser.add_option("--nobody", type="string", metavar="USERNAME", - help="choose 'nobody' user") -parser.add_option("--nogroup", type="string", metavar="GROUPNAME", - help="choose 'nogroup' group") -parser.add_option("--wheel", type="string", metavar="GROUPNAME", - help="choose 'wheel' privileged group") -parser.add_option("--users", type="string", metavar="GROUPNAME", - help="choose 'users' group") -parser.add_option("--quiet", help="Be quiet", action="store_true") -parser.add_option("--blank", action="store_true", - help="do not add users or groups, just the structure") -parser.add_option("--ldap-backend", type="string", metavar="LDAPSERVER", - help="LDAP server to use for this provision") -parser.add_option("--ldap-backend-type", type="choice", metavar="LDAP-BACKEND-TYPE", - help="LDB mapping module to use for the LDAP backend", - choices=["fedora-ds", "openldap"]) -parser.add_option("--aci", type="string", metavar="ACI", - help="An arbitary LDIF fragment, particularly useful to loading a backend ACI value into a target LDAP server. You must provide at least a realm and domain") -parser.add_option("--server-role", type="choice", metavar="ROLE", - choices=["domain controller", "member server"], - help="Set server role to provision for (default standalone)") -parser.add_option("--partitions-only", - help="Configure Samba's partitions, but do not modify them (ie, join a BDC)", action="store_true") -parser.add_option("--targetdir", type="string", metavar="DIR", - help="Set target directory") - -opts = parser.parse_args()[0] - -def message(text): - """print a message if quiet is not set.""" - if not opts.quiet: - print text - -if opts.realm is None or opts.domain is None: - if opts.realm is None: - print >>sys.stderr, "No realm set" - if opts.domain is None: - print >>sys.stderr, "No domain set" - parser.print_usage() - sys.exit(1) - -# cope with an initially blank smb.conf -private_dir = None -lp = sambaopts.get_loadparm() -if opts.targetdir is not None: - if not os.path.exists(opts.targetdir): - os.mkdir(opts.targetdir) - private_dir = os.path.join(opts.targetdir, "private") - if not os.path.exists(private_dir): - os.mkdir(private_dir) - lp.set("private dir", os.path.abspath(private_dir)) - lp.set("lock dir", os.path.abspath(opts.targetdir)) -lp.set("realm", opts.realm) -lp.set("workgroup", opts.domain) -lp.set("server role", opts.server_role or "domain controller") - -if opts.aci is not None: - print "set ACI: %s" % opts.aci - -paths = provision_paths_from_lp(lp, opts.realm.lower()) -if sambaopts.get_loadparm_path() is not None: - paths.smbconf = sambaopts.get_loadparm_path() - -creds = credopts.get_credentials() - -setup_dir = opts.setupdir -if setup_dir is None: - setup_dir = "setup" - -samdb_fill = FILL_FULL -if opts.blank: - samdb_fill = FILL_NT4SYNC -elif opts.partitions_only: - samdb_fill = FILL_DRS - -provision(lp, setup_dir, message, paths, - system_session(), creds, - samdb_fill=samdb_fill, realm=opts.realm, - domainguid=opts.domain_guid, domainsid=opts.domain_sid, - policyguid=opts.policy_guid, hostname=opts.host_name, - hostip=opts.host_ip, hostguid=opts.host_guid, - invocationid=opts.invocationid, adminpass=opts.adminpass, - krbtgtpass=opts.krbtgtpass, machinepass=opts.machinepass, - dnspass=opts.dnspass, root=opts.root, nobody=opts.nobody, - nogroup=opts.nogroup, wheel=opts.wheel, users=opts.users, - aci=opts.aci, serverrole=opts.server_role, - ldap_backend=opts.ldap_backend, - ldap_backend_type=opts.ldap_backend_type) - -message("To reproduce this provision, run with:") -def shell_escape(arg): - if " " in arg: - return '"%s"' % arg - return arg -message(" ".join([shell_escape(arg) for arg in sys.argv])) - -message("All OK") diff --git a/source4/setup/tests/blackbox_provision.sh b/source4/setup/tests/blackbox_provision.sh index 57b11eae5f..0aed7bb8b7 100755 --- a/source4/setup/tests/blackbox_provision.sh +++ b/source4/setup/tests/blackbox_provision.sh @@ -27,11 +27,11 @@ testit() { return $status } -testit "simple" $PYTHON ./setup/provision.py $CONFIGURATION --domain=FOO --realm=foo.example.com --targetdir=$PREFIX/simple +testit "simple" $PYTHON ./setup/provision $CONFIGURATION --domain=FOO --realm=foo.example.com --targetdir=$PREFIX/simple reprovision() { - $PYTHON ./setup/provision.py $CONFIGURATION --domain=FOO --realm=foo.example.com --targetdir="$PREFIX/reprovision" - $PYTHON ./setup/provision.py $CONFIGURATION --domain=FOO --realm=foo.example.com --targetdir="$PREFIX/reprovision" + $PYTHON ./setup/provision $CONFIGURATION --domain=FOO --realm=foo.example.com --targetdir="$PREFIX/reprovision" + $PYTHON ./setup/provision $CONFIGURATION --domain=FOO --realm=foo.example.com --targetdir="$PREFIX/reprovision" } testit "reprovision" reprovision -- cgit From 2ca1aeb59be0267858c9cd46a04d37d982b79990 Mon Sep 17 00:00:00 2001 From: Kai Blin Date: Sun, 17 Feb 2008 20:25:13 +0100 Subject: loadparm: Add configuration settings for idmap. Default behaviour for "idmap trusted only" is "False", meaning idmap creates ID mappings for all SIDs. If set to "True", idmap will create SID mappings for trusted users only. "idmap database" allows to set the database idmap uses, defaulting to idmap,ldb (This used to be commit ed8178b110abcde95e5b18cfb22957c53fd3febd) --- source4/param/loadparm.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source4/param/loadparm.c b/source4/param/loadparm.c index e850d82193..bad90fc74a 100644 --- a/source4/param/loadparm.c +++ b/source4/param/loadparm.c @@ -91,6 +91,7 @@ struct loadparm_global char *szPasswdChat; char *szShareBackend; char *szSAM_URL; + char *szIDMAP_URL; char *szSECRETS_URL; char *szSPOOLSS_URL; char *szWINS_CONFIG_URL; @@ -119,6 +120,7 @@ struct loadparm_global char *szTemplateShell; char *szTemplateHomedir; int bWinbindSealedPipes; + int bIdmapTrustedOnly; char *swat_directory; int tls_enabled; char *tls_keyfile; @@ -384,6 +386,7 @@ static struct parm_struct parm_table[] = { {"obey pam restrictions", P_BOOL, P_GLOBAL, GLOBAL_VAR(bObeyPamRestrictions), NULL, NULL}, {"password server", P_LIST, P_GLOBAL, GLOBAL_VAR(szPasswordServers), NULL, NULL}, {"sam database", P_STRING, P_GLOBAL, GLOBAL_VAR(szSAM_URL), NULL, NULL}, + {"idmap database", P_STRING, P_GLOBAL, GLOBAL_VAR(szIDMAP_URL), NULL, NULL}, {"secrets database", P_STRING, P_GLOBAL, GLOBAL_VAR(szSECRETS_URL), NULL, NULL}, {"spoolss database", P_STRING, P_GLOBAL, GLOBAL_VAR(szSPOOLSS_URL), NULL, NULL}, {"wins config database", P_STRING, P_GLOBAL, GLOBAL_VAR(szWINS_CONFIG_URL), NULL, NULL}, @@ -513,6 +516,7 @@ static struct parm_struct parm_table[] = { {"winbind sealed pipes", P_BOOL, P_GLOBAL, GLOBAL_VAR(bWinbindSealedPipes), NULL, NULL }, {"template shell", P_STRING, P_GLOBAL, GLOBAL_VAR(szTemplateShell), NULL, NULL }, {"template homedir", P_STRING, P_GLOBAL, GLOBAL_VAR(szTemplateHomedir), NULL, NULL }, + {"idmap trusted only", P_BOOL, P_GLOBAL, GLOBAL_VAR(bIdmapTrustedOnly), NULL, NULL}, {NULL, P_BOOL, P_NONE, 0, NULL, NULL} }; @@ -642,6 +646,7 @@ _PUBLIC_ FN_GLOBAL_STRING(lp_tls_crlfile, tls_crlfile) _PUBLIC_ FN_GLOBAL_STRING(lp_tls_dhpfile, tls_dhpfile) _PUBLIC_ FN_GLOBAL_STRING(lp_share_backend, szShareBackend) _PUBLIC_ FN_GLOBAL_STRING(lp_sam_url, szSAM_URL) +_PUBLIC_ FN_GLOBAL_STRING(lp_idmap_url, szIDMAP_URL) _PUBLIC_ FN_GLOBAL_STRING(lp_secrets_url, szSECRETS_URL) _PUBLIC_ FN_GLOBAL_STRING(lp_spoolss_url, szSPOOLSS_URL) _PUBLIC_ FN_GLOBAL_STRING(lp_wins_config_url, szWINS_CONFIG_URL) @@ -651,6 +656,7 @@ _PUBLIC_ FN_GLOBAL_CONST_STRING(lp_winbindd_socket_directory, szWinbinddSocketDi _PUBLIC_ FN_GLOBAL_CONST_STRING(lp_template_shell, szTemplateShell) _PUBLIC_ FN_GLOBAL_CONST_STRING(lp_template_homedir, szTemplateHomedir) _PUBLIC_ FN_GLOBAL_BOOL(lp_winbind_sealed_pipes, bWinbindSealedPipes) +_PUBLIC_ FN_GLOBAL_BOOL(lp_idmap_trusted_only, bIdmapTrustedOnly) _PUBLIC_ FN_GLOBAL_STRING(lp_private_dir, szPrivateDir) _PUBLIC_ FN_GLOBAL_STRING(lp_serverstring, szServerString) _PUBLIC_ FN_GLOBAL_STRING(lp_lockdir, szLockDir) @@ -2305,6 +2311,7 @@ struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx) lp_do_global_parameter(lp_ctx, "auth methods:standalone", "anonymous sam_ignoredomain"); lp_do_global_parameter(lp_ctx, "private dir", dyn_PRIVATE_DIR); lp_do_global_parameter(lp_ctx, "sam database", "sam.ldb"); + lp_do_global_parameter(lp_ctx, "idmap database", "idmap.ldb"); lp_do_global_parameter(lp_ctx, "secrets database", "secrets.ldb"); lp_do_global_parameter(lp_ctx, "spoolss database", "spoolss.ldb"); lp_do_global_parameter(lp_ctx, "wins config database", "wins_config.ldb"); @@ -2380,6 +2387,7 @@ struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx) lp_do_global_parameter(lp_ctx, "winbindd socket directory", dyn_WINBINDD_SOCKET_DIR); lp_do_global_parameter(lp_ctx, "template shell", "/bin/false"); lp_do_global_parameter(lp_ctx, "template homedir", "/home/%WORKGROUP%/%ACCOUNTNAME%"); + lp_do_global_parameter(lp_ctx, "idmap trusted only", "False"); lp_do_global_parameter(lp_ctx, "client signing", "Yes"); lp_do_global_parameter(lp_ctx, "server signing", "auto"); -- cgit From 895874d9663ccb95883579d145018ec8a8add9c8 Mon Sep 17 00:00:00 2001 From: Kai Blin Date: Mon, 18 Feb 2008 14:33:58 +0100 Subject: idmap: Handle uid->SID mapping (This used to be commit 6ac6de8476ba036eb041e054bc37e4503dc2fde8) --- .gitignore | 1 + source4/scripting/libjs/provision.js | 4 + source4/scripting/python/samba/provision.py | 24 ++ source4/setup/idmap_init.ldif | 5 + source4/winbind/config.mk | 11 + source4/winbind/idmap.c | 415 ++++++++++++++++++++++++++++ source4/winbind/idmap.h | 33 +++ source4/winbind/wb_server.c | 6 + source4/winbind/wb_server.h | 2 + source4/winbind/wb_uid2sid.c | 15 +- 10 files changed, 511 insertions(+), 5 deletions(-) create mode 100644 source4/setup/idmap_init.ldif create mode 100644 source4/winbind/idmap.c create mode 100644 source4/winbind/idmap.h diff --git a/.gitignore b/.gitignore index 6076ddc9cd..f75f698c65 100644 --- a/.gitignore +++ b/.gitignore @@ -129,6 +129,7 @@ source/utils/net/net_proto.h source/web_server/proto.h source/winbind/wb_helper.h source/winbind/wb_proto.h +source/winbind/idmap_proto.h source/wrepl_server/wrepl_server_proto.h tags source/auth/credentials/credentials_krb5_proto.h diff --git a/source4/scripting/libjs/provision.js b/source4/scripting/libjs/provision.js index dc9eae8e72..3ba93debf9 100644 --- a/source4/scripting/libjs/provision.js +++ b/source4/scripting/libjs/provision.js @@ -389,6 +389,7 @@ function provision_default_paths(subobj) paths.smbconf = lp.filename() paths.shareconf = lp.get("private dir") + "/" + "share.ldb"; paths.samdb = lp.get("sam database"); + paths.idmapdb = lp.get("idmap database"); paths.secrets = lp.get("secrets database"); paths.templates = lp.get("private dir") + "/" + "templates.ldb"; paths.keytab = "secrets.keytab"; @@ -679,6 +680,9 @@ function provision(subobj, message, blank, paths, session_info, credentials, lda message("Setting up templates into " + paths.templates + "\n"); setup_ldb("provision_templates.ldif", info, paths.templates); + message("Setting up " + paths.idmapdb +"\n"); + setup_ldb("idmap_init.ldif", info, paths.idmapdb); + message("Setting up sam.ldb partitions\n"); /* Also wipes the database */ setup_ldb("provision_partitions.ldif", info, paths.samdb); diff --git a/source4/scripting/python/samba/provision.py b/source4/scripting/python/samba/provision.py index 3e88b68509..e3c47ff4a2 100644 --- a/source4/scripting/python/samba/provision.py +++ b/source4/scripting/python/samba/provision.py @@ -59,6 +59,7 @@ class ProvisionPaths: self.hkpd = None self.hkpt = None self.samdb = None + self.idmapdb = None self.secrets = None self.keytab = None self.dns_keytab = None @@ -202,6 +203,7 @@ def provision_paths_from_lp(lp, dnsdomain): paths.shareconf = os.path.join(private_dir, "share.ldb") paths.samdb = os.path.join(private_dir, lp.get("sam database") or "samdb.ldb") + paths.idmapdb = os.path.join(private_dir, lp.get("idmap database") or "idmap.ldb") paths.secrets = os.path.join(private_dir, lp.get("secrets database") or "secrets.ldb") paths.templates = os.path.join(private_dir, "templates.ldb") paths.dns = os.path.join(private_dir, dnsdomain + ".zone") @@ -471,6 +473,24 @@ def setup_registry(path, setup_path, session_info, credentials, lp): assert os.path.exists(provision_reg) reg.diff_apply(provision_reg) +def setup_idmapdb(path, setup_path, session_info, credentials, lp): + """Setup the idmap database. + + :param path: path to the idmap database + :param setup_path: Function that returns a path to a setup file + :param session_info: Session information + :param credentials: Credentials + :param lp: Loadparm context + """ + if os.path.exists(path): + os.unlink(path) + + idmap_ldb = Ldb(path, session_info=session_info, credentials=credentials, + lp=lp) + + idmap_ldb.erase() + idmap_ldb.load_ldif_file_add(setup_path("idmap_init.ldif")) + return idmap_ldb def setup_samdb_rootdse(samdb, setup_path, schemadn, domaindn, hostname, dnsdomain, realm, rootdn, configdn, netbiosname, @@ -844,6 +864,10 @@ def provision(lp, setup_dir, message, paths, session_info, setup_templatesdb(paths.templates, setup_path, session_info=session_info, credentials=credentials, lp=lp) + message("Setting up idmap db") + setup_idmapdb(paths.idmapdb, setup_path, session_info=session_info, + credentials=credentials, lp=lp) + samdb = setup_samdb(paths.samdb, setup_path, session_info=session_info, credentials=credentials, lp=lp, schemadn=schemadn, configdn=configdn, domaindn=domaindn, diff --git a/source4/setup/idmap_init.ldif b/source4/setup/idmap_init.ldif new file mode 100644 index 0000000000..a397cfd0d2 --- /dev/null +++ b/source4/setup/idmap_init.ldif @@ -0,0 +1,5 @@ +dn: CN=CONFIG +cn: CONFIG +lowerBound: 10000 +upperBound: 20000 + diff --git a/source4/winbind/config.mk b/source4/winbind/config.mk index da5b71f2ae..2567d617da 100644 --- a/source4/winbind/config.mk +++ b/source4/winbind/config.mk @@ -37,6 +37,7 @@ OBJ_FILES = \ wb_sam_logon.o PRIVATE_DEPENDENCIES = \ WB_HELPER \ + IDMAP \ NDR_WINBIND \ process_model \ RPC_NDR_LSA \ @@ -56,3 +57,13 @@ OBJ_FILES = \ PUBLIC_DEPENDENCIES = RPC_NDR_LSA dcerpc_samr # End SUBSYSTEM WB_HELPER ################################################ + +################################################ +# Start SUBYSTEM IDMAP +[SUBSYSTEM::IDMAP] +PRIVATE_PROTO_HEADER = idmap_proto.h +OBJ_FILES = \ + idmap.o +PUBLIC_DEPENDENCIES = SAMDB_COMMON +# End SUBSYSTEM IDMAP +################################################ diff --git a/source4/winbind/idmap.c b/source4/winbind/idmap.c new file mode 100644 index 0000000000..b14885213e --- /dev/null +++ b/source4/winbind/idmap.c @@ -0,0 +1,415 @@ +/* + Unix SMB/CIFS implementation. + + Map SIDs to uids/gids and back + + Copyright (C) Kai Blin 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 . +*/ + +#include "includes.h" +#include "auth/auth.h" +#include "librpc/gen_ndr/lsa.h" +#include "librpc/gen_ndr/samr.h" +#include "librpc/gen_ndr/ndr_security.h" +#include "lib/ldb/include/ldb.h" +#include "lib/ldb/include/ldb_errors.h" +#include "lib/ldb_wrap.h" +#include "param/param.h" +#include "winbind/idmap.h" +#include "libcli/security/proto.h" +#include "libcli/ldap/ldap_ndr.h" + +/** + * Get uid/gid bounds from idmap database + * + * \param idmap_ctx idmap context to use + * \param low lower uid/gid bound is stored here + * \param high upper uid/gid bound is stored here + * \return 0 on success, nonzero on failure + */ +static int idmap_get_bounds(struct idmap_context *idmap_ctx, uint32_t *low, + uint32_t *high) +{ + int ret = -1; + struct ldb_context *ldb = idmap_ctx->ldb_ctx; + struct ldb_dn *dn; + struct ldb_result *res = NULL; + TALLOC_CTX *tmp_ctx = talloc_new(idmap_ctx); + uint32_t lower_bound = (uint32_t) -1; + uint32_t upper_bound = (uint32_t) -1; + + dn = ldb_dn_new(tmp_ctx, ldb, "CN=CONFIG"); + if (dn == NULL) goto failed; + + ret = ldb_search(ldb, dn, LDB_SCOPE_BASE, NULL, NULL, &res); + if (ret != LDB_SUCCESS) goto failed; + + talloc_steal(tmp_ctx, res); + + if (res->count != 1) { + ret = -1; + goto failed; + } + + lower_bound = ldb_msg_find_attr_as_uint(res->msgs[0], "lowerBound", -1); + if (lower_bound != (uint32_t) -1) { + ret = LDB_SUCCESS; + } else { + ret = -1; + goto failed; + } + + upper_bound = ldb_msg_find_attr_as_uint(res->msgs[0], "upperBound", -1); + if (upper_bound != (uint32_t) -1) { + ret = LDB_SUCCESS; + } else { + ret = -1; + } + +failed: + talloc_free(tmp_ctx); + *low = lower_bound; + *high = upper_bound; + return ret; +} + +/** + * Add a dom_sid structure to a ldb_message + * \param idmap_ctx idmap context to use + * \param mem_ctx talloc context to use + * \param ldb_message ldb message to add dom_sid to + * \param attr_name name of the attribute to store the dom_sid in + * \param sid dom_sid to store + * \return 0 on success, an ldb error code on failure. + */ +static int idmap_msg_add_dom_sid(struct idmap_context *idmap_ctx, + TALLOC_CTX *mem_ctx, struct ldb_message *msg, + const char *attr_name, const struct dom_sid *sid) +{ + struct ldb_val val; + enum ndr_err_code ndr_err; + + ndr_err = ndr_push_struct_blob(&val, mem_ctx, + lp_iconv_convenience(idmap_ctx->lp_ctx), + sid, + (ndr_push_flags_fn_t)ndr_push_dom_sid); + + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + return -1; + } + + return ldb_msg_add_value(msg, attr_name, &val, NULL); +} + +/** + * Get a dom_sid structure from a ldb message. + * + * \param mem_ctx talloc context to allocate dom_sid memory in + * \param msg ldb_message to get dom_sid from + * \param attr_name key that has the dom_sid as data + * \return dom_sid structure on success, NULL on failure + */ +static struct dom_sid *idmap_msg_get_dom_sid(TALLOC_CTX *mem_ctx, + struct ldb_message *msg, const char *attr_name) +{ + struct dom_sid *sid; + const struct ldb_val *val; + enum ndr_err_code ndr_err; + + val = ldb_msg_find_ldb_val(msg, attr_name); + if (val == NULL) { + return NULL; + } + + sid = talloc(mem_ctx, struct dom_sid); + if (sid == NULL) { + return NULL; + } + + ndr_err = ndr_pull_struct_blob(val, sid, NULL, sid, + (ndr_pull_flags_fn_t)ndr_pull_dom_sid); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(sid); + return NULL; + } + + return sid; +} + +/** + * Initialize idmap context + * + * talloc_free to close. + * + * \param mem_ctx talloc context to use. + * \return allocated idmap_context on success, NULL on error + */ +struct idmap_context *idmap_init(TALLOC_CTX *mem_ctx, + struct loadparm_context *lp_ctx) +{ + struct idmap_context *idmap_ctx; + + idmap_ctx = talloc(mem_ctx, struct idmap_context); + if (idmap_ctx == NULL) { + return NULL; + } + + idmap_ctx->lp_ctx = lp_ctx; + + idmap_ctx->ldb_ctx = ldb_wrap_connect(mem_ctx, lp_ctx, + lp_idmap_url(lp_ctx), + system_session(mem_ctx, lp_ctx), + NULL, 0, NULL); + if (idmap_ctx->ldb_ctx == NULL) { + return NULL; + } + + return idmap_ctx; +} + +/** + * Convert a uid to the corresponding SID + * + * \param idmap_ctx idmap context to use + * \param mem_ctx talloc context the memory for the struct dom_sid is allocated + * from. + * \param uid Unix uid to map to a SID + * \param sid Pointer that will take the struct dom_sid pointer if the mapping + * succeeds. + * \return NT_STATUS_OK on success, NT_STATUS_NONE_MAPPED if mapping not + * possible or some other NTSTATUS that is more descriptive on failure. + */ + +NTSTATUS idmap_uid_to_sid(struct idmap_context *idmap_ctx, TALLOC_CTX *mem_ctx, + const uid_t uid, struct dom_sid **sid) +{ + int ret; + NTSTATUS status = NT_STATUS_NONE_MAPPED; + struct ldb_context *ldb = idmap_ctx->ldb_ctx; + struct ldb_message *msg; + struct ldb_result *res = NULL; + int trans = -1; + uid_t low, high; + char *sid_string, *uid_string; + struct dom_sid *unix_users_sid, *new_sid; + TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx); + + ret = ldb_search_exp_fmt(ldb, tmp_ctx, &res, NULL, LDB_SCOPE_SUBTREE, + NULL, "(&(objectClass=sidMap)(uidNumber=%u))", + uid); + if (ret != LDB_SUCCESS) { + DEBUG(1, ("Search failed: %s\n", ldb_errstring(ldb))); + status = NT_STATUS_NONE_MAPPED; + goto failed; + } + + if (res->count == 1) { + *sid = idmap_msg_get_dom_sid(mem_ctx, res->msgs[0], + "objectSid"); + if (*sid == NULL) { + DEBUG(1, ("Failed to get sid from db: %u\n", ret)); + status = NT_STATUS_NONE_MAPPED; + goto failed; + } + talloc_free(tmp_ctx); + return NT_STATUS_OK; + } + + DEBUG(6, ("uid not found in idmap db, trying to allocate SID.\n")); + + trans = ldb_transaction_start(ldb); + if (trans != LDB_SUCCESS) { + status = NT_STATUS_NONE_MAPPED; + goto failed; + } + + /* Now redo the search to make sure noone added a mapping for that SID + * while we weren't looking.*/ + ret = ldb_search_exp_fmt(ldb, tmp_ctx, &res, NULL, LDB_SCOPE_SUBTREE, + NULL, "(&(objectClass=sidMap)(uidNumber=%u))", + uid); + if (ret != LDB_SUCCESS) { + DEBUG(1, ("Search failed: %s\n", ldb_errstring(ldb))); + status = NT_STATUS_NONE_MAPPED; + goto failed; + } + + if (res->count > 0) { + DEBUG(1, ("sidMap modified while trying to add a mapping.\n")); + status = NT_STATUS_RETRY; + goto failed; + } + + ret = idmap_get_bounds(idmap_ctx, &low, &high); + if (ret != LDB_SUCCESS) { + DEBUG(1, ("Failed to get id bounds from db: %u\n", ret)); + status = NT_STATUS_NONE_MAPPED; + goto failed; + } + + if (uid >= low && uid <= high) { + /* An existing user would have been mapped before */ + status = NT_STATUS_NO_SUCH_USER; + goto failed; + } + + /* For local users, we just create a rid = uid +1, so root doesn't end + * up with a 0 rid */ + unix_users_sid = dom_sid_parse_talloc(tmp_ctx, "S-1-22-1"); + if (unix_users_sid == NULL) { + status = NT_STATUS_NO_MEMORY; + goto failed; + } + + new_sid = dom_sid_add_rid(mem_ctx, unix_users_sid, uid + 1); + if (new_sid == NULL) { + status = NT_STATUS_NO_MEMORY; + goto failed; + } + + sid_string = dom_sid_string(tmp_ctx, new_sid); + if (sid_string == NULL) { + status = NT_STATUS_NO_MEMORY; + goto failed; + } + + uid_string = talloc_asprintf(tmp_ctx, "%u", uid); + if (uid_string == NULL) { + status = NT_STATUS_NO_MEMORY; + goto failed; + } + + msg = ldb_msg_new(tmp_ctx); + if (msg == NULL) { + status = NT_STATUS_NO_MEMORY; + goto failed; + } + + msg->dn = ldb_dn_new_fmt(tmp_ctx, ldb, "CN=%s", sid_string); + if (msg->dn == NULL) { + status = NT_STATUS_NO_MEMORY; + goto failed; + } + + ret = ldb_msg_add_string(msg, "uidNumber", uid_string); + if (ret != LDB_SUCCESS) { + status = NT_STATUS_NONE_MAPPED; + goto failed; + } + + ret = idmap_msg_add_dom_sid(idmap_ctx, tmp_ctx, msg, "objectSid", + new_sid); + if (ret != LDB_SUCCESS) { + status = NT_STATUS_NONE_MAPPED; + goto failed; + } + + ret = ldb_msg_add_string(msg, "objectClass", "sidMap"); + if (ret != LDB_SUCCESS) { + status = NT_STATUS_NONE_MAPPED; + goto failed; + } + + ret = ldb_msg_add_string(msg, "cn", sid_string); + if (ret != LDB_SUCCESS) { + status = NT_STATUS_NONE_MAPPED; + goto failed; + } + + ret = ldb_add(ldb, msg); + if (ret != LDB_SUCCESS) { + status = NT_STATUS_NONE_MAPPED; + goto failed; + } + + trans = ldb_transaction_commit(ldb); + if (trans != LDB_SUCCESS) { + status = NT_STATUS_NONE_MAPPED; + goto failed; + } + + *sid = new_sid; + talloc_free(tmp_ctx); + return NT_STATUS_OK; + +failed: + if (trans == LDB_SUCCESS) ldb_transaction_cancel(ldb); + talloc_free(tmp_ctx); + return status; +} + +/** + * Map a Unix gid to the corresponding SID + * + * \todo Create a SID from the S-1-22-2 range for unmapped groups + * + * \param idmap_ctx idmap context to use + * \param mem_ctx talloc context the memory for the struct dom_sid is allocated + * from. + * \param gid Unix gid to map to a SID + * \param sid Pointer that will take the struct dom_sid pointer if mapping + * succeeds. + * \return NT_STATUS_OK on success, NT_STATUS_NONE_MAPPED if mapping not + * possible or some other NTSTATUS that is more descriptive on failure. + */ +NTSTATUS idmap_gid_to_sid(struct idmap_context *idmap_ctx, TALLOC_CTX *mem_ctx, + const gid_t gid, struct dom_sid **sid) +{ + return NT_STATUS_NONE_MAPPED; +} + +/** + * Map a SID to a Unix uid. + * + * If no mapping exists, a new mapping will be created. + * + * \todo Create mappings for users not from our primary domain. + * + * \param idmap_ctx idmap context to use + * \param mem_ctx talloc context to use + * \param sid SID to map to a Unix uid + * \param uid pointer to receive the mapped uid + * \return NT_STATUS_OK on success, NT_STATUS_INVALID_SID if the sid is not from + * a trusted domain and idmap trusted only = true, NT_STATUS_NONE_MAPPED if the + * mapping failed. + */ +NTSTATUS idmap_sid_to_uid(struct idmap_context *idmap_ctx, TALLOC_CTX *mem_ctx, + const struct dom_sid *sid, uid_t *uid) +{ + return NT_STATUS_NONE_MAPPED; +} + +/** + * Map a SID to a Unix gid. + * + * If no mapping exist, a new mapping will be created. + * + * \todo Create mappings for groups not from our primary domain. + * + * \param idmap_ctx idmap context to use + * \param mem_ctx talloc context to use + * \param sid SID to map to a Unix gid + * \param gid pointer to receive the mapped gid + * \return NT_STATUS_OK on success, NT_STATUS_INVALID_SID if the sid is not from + * a trusted domain and idmap trusted only = true, NT_STATUS_NONE_MAPPED if the + * mapping failed. + */ +NTSTATUS idmap_sid_to_gid(struct idmap_context *idmap_ctx, TALLOC_CTX *mem_ctx, + const struct dom_sid *sid, gid_t *gid) +{ + return NT_STATUS_NONE_MAPPED; +} + diff --git a/source4/winbind/idmap.h b/source4/winbind/idmap.h new file mode 100644 index 0000000000..8781819be0 --- /dev/null +++ b/source4/winbind/idmap.h @@ -0,0 +1,33 @@ +/* + Unix SMB/CIFS implementation. + + Map SIDs to uids/gids and back + + Copyright (C) Kai Blin 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 . +*/ + +#ifndef _IDMAP_H_ +#define _IDMAP_H_ + +struct idmap_context { + struct loadparm_context *lp_ctx; + struct ldb_context *ldb_ctx; +}; + +#include "winbind/idmap_proto.h" + +#endif + diff --git a/source4/winbind/wb_server.c b/source4/winbind/wb_server.c index 9b303f3615..99191f3c6c 100644 --- a/source4/winbind/wb_server.c +++ b/source4/winbind/wb_server.c @@ -149,6 +149,12 @@ static void winbind_task_init(struct task_server *task) return; } + service->idmap_ctx = idmap_init(service, task->lp_ctx); + if (service->idmap_ctx == NULL) { + task_server_terminate(task, "Failed to load idmap database"); + return; + } + /* setup the unprivileged samba3 socket */ listen_socket = talloc(service, struct wbsrv_listen_socket); if (!listen_socket) goto nomem; diff --git a/source4/winbind/wb_server.h b/source4/winbind/wb_server.h index f3cfc18565..ce972932f5 100644 --- a/source4/winbind/wb_server.h +++ b/source4/winbind/wb_server.h @@ -21,6 +21,7 @@ #include "nsswitch/winbind_nss_config.h" #include "nsswitch/winbind_struct_protocol.h" +#include "winbind/idmap.h" #include "libnet/libnet.h" #define WINBINDD_SAMBA3_SOCKET "pipe" @@ -33,6 +34,7 @@ struct wbsrv_service { const struct dom_sid *primary_sid; struct wbsrv_domain *domains; + struct idmap_context *idmap_ctx; }; struct wbsrv_samconn { diff --git a/source4/winbind/wb_uid2sid.c b/source4/winbind/wb_uid2sid.c index d7a909fda2..e81d2e4671 100644 --- a/source4/winbind/wb_uid2sid.c +++ b/source4/winbind/wb_uid2sid.c @@ -3,7 +3,7 @@ Command backend for wbinfo -U - Copyright (C) Kai Blin 2007 + Copyright (C) Kai Blin 2007-2008 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,6 +25,7 @@ #include "smbd/service_task.h" #include "winbind/wb_helper.h" #include "libcli/security/proto.h" +#include "winbind/idmap.h" struct uid2sid_state { struct composite_context *ctx; @@ -50,10 +51,14 @@ struct composite_context *wb_uid2sid_send(TALLOC_CTX *mem_ctx, result->private_data = state; state->service = service; - /* FIXME: This is a stub so far. - * We cheat by just using the uid as RID with the domain SID.*/ - state->sid = dom_sid_add_rid(result, service->primary_sid, uid); - if (composite_nomem(state->sid, state->ctx)) return result; + state->ctx->status = idmap_uid_to_sid(service->idmap_ctx, mem_ctx, uid, + &state->sid); + if (NT_STATUS_EQUAL(state->ctx->status, NT_STATUS_RETRY)) { + state->ctx->status = idmap_uid_to_sid(service->idmap_ctx, + mem_ctx, uid, + &state->sid); + } + if (!composite_is_ok(state->ctx)) return result; composite_done(state->ctx); return result; -- cgit From 9c7f714962bdfe280baed42ed6a1e35a422a0267 Mon Sep 17 00:00:00 2001 From: Kai Blin Date: Mon, 18 Feb 2008 14:30:17 +0100 Subject: idmap: Handle gid->SID mapping (This used to be commit 6f2d95030cd7b4b22d1b75d15b76881449eda697) --- source4/winbind/idmap.c | 157 ++++++++++++++++++++++++++++++++++++++++++- source4/winbind/wb_gid2sid.c | 13 ++-- 2 files changed, 163 insertions(+), 7 deletions(-) diff --git a/source4/winbind/idmap.c b/source4/winbind/idmap.c index b14885213e..af026a4d5c 100644 --- a/source4/winbind/idmap.c +++ b/source4/winbind/idmap.c @@ -354,8 +354,6 @@ failed: /** * Map a Unix gid to the corresponding SID * - * \todo Create a SID from the S-1-22-2 range for unmapped groups - * * \param idmap_ctx idmap context to use * \param mem_ctx talloc context the memory for the struct dom_sid is allocated * from. @@ -368,7 +366,160 @@ failed: NTSTATUS idmap_gid_to_sid(struct idmap_context *idmap_ctx, TALLOC_CTX *mem_ctx, const gid_t gid, struct dom_sid **sid) { - return NT_STATUS_NONE_MAPPED; + int ret; + NTSTATUS status = NT_STATUS_NONE_MAPPED; + struct ldb_context *ldb = idmap_ctx->ldb_ctx; + struct ldb_message *msg; + struct ldb_result *res = NULL; + int trans = -1; + gid_t low, high; + char *sid_string, *gid_string; + struct dom_sid *unix_groups_sid, *new_sid; + TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx); + + ret = ldb_search_exp_fmt(ldb, tmp_ctx, &res, NULL, LDB_SCOPE_SUBTREE, + NULL, "(&(objectClass=sidMap)(gidNumber=%u))", gid); + if (ret != LDB_SUCCESS) { + DEBUG(1, ("Search failed: %s\n", ldb_errstring(ldb))); + status = NT_STATUS_NONE_MAPPED; + goto failed; + } + + if (res->count == 1) { + *sid = idmap_msg_get_dom_sid(mem_ctx, res->msgs[0], + "objectSid"); + if (*sid == NULL) { + DEBUG(1, ("Failed to get sid from db: %u\n", ret)); + status = NT_STATUS_NONE_MAPPED; + goto failed; + } + /* No change, so cancel the transaction */ + ldb_transaction_cancel(ldb); + talloc_free(tmp_ctx); + return NT_STATUS_OK; + } + + DEBUG(6, ("gid not found in idmap db, trying to allocate SID.\n")); + + trans = ldb_transaction_start(ldb); + if (trans != LDB_SUCCESS) { + status = NT_STATUS_NONE_MAPPED; + goto failed; + } + + /* Now redo the search to make sure noone added a mapping for that SID + * while we weren't looking.*/ + ret = ldb_search_exp_fmt(ldb, tmp_ctx, &res, NULL, LDB_SCOPE_SUBTREE, + NULL, "(&(objectClass=sidMap)(gidNumber=%u))", + gid); + if (ret != LDB_SUCCESS) { + DEBUG(1, ("Search failed: %s\n", ldb_errstring(ldb))); + status = NT_STATUS_NONE_MAPPED; + goto failed; + } + + if (res->count > 0) { + DEBUG(1, ("sidMap modified while trying to add a mapping.\n")); + status = NT_STATUS_RETRY; + goto failed; + } + + ret = idmap_get_bounds(idmap_ctx, &low, &high); + if (ret != LDB_SUCCESS) { + DEBUG(1, ("Failed to get id bounds from db: %u\n", ret)); + status = NT_STATUS_NONE_MAPPED; + goto failed; + } + + if (gid >= low && gid <= high) { + /* An existing group would have been mapped before */ + status = NT_STATUS_NO_SUCH_USER; + goto failed; + } + + /* For local groups, we just create a rid = gid +1, so root doesn't end + * up with a 0 rid */ + unix_groups_sid = dom_sid_parse_talloc(tmp_ctx, "S-1-22-2"); + if (unix_groups_sid == NULL) { + status = NT_STATUS_NO_MEMORY; + goto failed; + } + + new_sid = dom_sid_add_rid(mem_ctx, unix_groups_sid, gid + 1); + if (new_sid == NULL) { + status = NT_STATUS_NO_MEMORY; + goto failed; + } + + sid_string = dom_sid_string(tmp_ctx, new_sid); + if (sid_string == NULL) { + status = NT_STATUS_NO_MEMORY; + goto failed; + } + + gid_string = talloc_asprintf(tmp_ctx, "%u", gid); + if (gid_string == NULL) { + status = NT_STATUS_NO_MEMORY; + goto failed; + } + + msg = ldb_msg_new(tmp_ctx); + if (msg == NULL) { + status = NT_STATUS_NO_MEMORY; + goto failed; + } + + msg->dn = ldb_dn_new_fmt(tmp_ctx, ldb, "CN=%s", sid_string); + if (msg->dn == NULL) { + status = NT_STATUS_NO_MEMORY; + goto failed; + } + + ret = ldb_msg_add_string(msg, "gidNumber", gid_string); + if (ret != LDB_SUCCESS) { + status = NT_STATUS_NONE_MAPPED; + goto failed; + } + + ret = idmap_msg_add_dom_sid(idmap_ctx, tmp_ctx, msg, "objectSid", + new_sid); + if (ret != LDB_SUCCESS) { + status = NT_STATUS_NONE_MAPPED; + goto failed; + } + + ret = ldb_msg_add_string(msg, "objectClass", "sidMap"); + if (ret != LDB_SUCCESS) { + status = NT_STATUS_NONE_MAPPED; + goto failed; + } + + ret = ldb_msg_add_string(msg, "cn", sid_string); + if (ret != LDB_SUCCESS) { + status = NT_STATUS_NONE_MAPPED; + goto failed; + } + + ret = ldb_add(ldb, msg); + if (ret != LDB_SUCCESS) { + status = NT_STATUS_NONE_MAPPED; + goto failed; + } + + trans = ldb_transaction_commit(ldb); + if (trans != LDB_SUCCESS) { + status = NT_STATUS_NONE_MAPPED; + goto failed; + } + + *sid = new_sid; + talloc_free(tmp_ctx); + return NT_STATUS_OK; + +failed: + if (trans == LDB_SUCCESS) ldb_transaction_cancel(ldb); + talloc_free(tmp_ctx); + return status; } /** diff --git a/source4/winbind/wb_gid2sid.c b/source4/winbind/wb_gid2sid.c index 5c0b87118d..f2577029aa 100644 --- a/source4/winbind/wb_gid2sid.c +++ b/source4/winbind/wb_gid2sid.c @@ -25,6 +25,7 @@ #include "smbd/service_task.h" #include "winbind/wb_helper.h" #include "libcli/security/proto.h" +#include "winbind/idmap.h" struct gid2sid_state { struct composite_context *ctx; @@ -50,10 +51,14 @@ struct composite_context *wb_gid2sid_send(TALLOC_CTX *mem_ctx, result->private_data = state; state->service = service; - /* FIXME: This is a stub so far. - * We cheat by just using the gid as RID with the domain SID.*/ - state->sid = dom_sid_add_rid(result, service->primary_sid, gid); - if (composite_nomem(state->sid, state->ctx)) return result; + state->ctx->status = idmap_gid_to_sid(service->idmap_ctx, mem_ctx, gid, + &state->sid); + if (NT_STATUS_EQUAL(state->ctx->status, NT_STATUS_RETRY)) { + state->ctx->status = idmap_gid_to_sid(service->idmap_ctx, + mem_ctx, gid, + &state->sid); + } + if (!composite_is_ok(state->ctx)) return result; composite_done(state->ctx); return result; -- cgit From 705abe2cb3bc67f4e225ed38f32f77a2b433abc8 Mon Sep 17 00:00:00 2001 From: Kai Blin Date: Mon, 18 Feb 2008 18:53:12 +0100 Subject: idmap: Handle SID->uid (This used to be commit 4037ca6b9cf14219b4a4475399a51db01c655da6) --- source4/winbind/idmap.c | 257 ++++++++++++++++++++++++++++++++++++++++++- source4/winbind/wb_sid2uid.c | 15 ++- 2 files changed, 264 insertions(+), 8 deletions(-) diff --git a/source4/winbind/idmap.c b/source4/winbind/idmap.c index af026a4d5c..53276114dd 100644 --- a/source4/winbind/idmap.c +++ b/source4/winbind/idmap.c @@ -527,7 +527,7 @@ failed: * * If no mapping exists, a new mapping will be created. * - * \todo Create mappings for users not from our primary domain. + * \todo Check if SIDs can be resolved if lp_idmap_trusted_only() == true * * \param idmap_ctx idmap context to use * \param mem_ctx talloc context to use @@ -540,7 +540,260 @@ failed: NTSTATUS idmap_sid_to_uid(struct idmap_context *idmap_ctx, TALLOC_CTX *mem_ctx, const struct dom_sid *sid, uid_t *uid) { - return NT_STATUS_NONE_MAPPED; + int ret; + NTSTATUS status = NT_STATUS_NONE_MAPPED; + struct ldb_context *ldb = idmap_ctx->ldb_ctx; + struct ldb_dn *dn; + struct ldb_message *hwm_msg, *map_msg; + struct ldb_result *res = NULL; + int trans; + uid_t low, high, hwm, new_uid; + char *sid_string, *uid_string, *hwm_string; + bool hwm_entry_exists; + TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx); + + ret = ldb_search_exp_fmt(ldb, tmp_ctx, &res, NULL, LDB_SCOPE_SUBTREE, + NULL, "(&(objectClass=sidMap)(objectSid=%s))", + ldap_encode_ndr_dom_sid(tmp_ctx, sid)); + if (ret != LDB_SUCCESS) { + DEBUG(1, ("Search failed: %s\n", ldb_errstring(ldb))); + status = NT_STATUS_NONE_MAPPED; + goto failed; + } + + if (res->count == 1) { + new_uid = ldb_msg_find_attr_as_uint(res->msgs[0], "uidNumber", + -1); + if (new_uid == (uid_t) -1) { + DEBUG(1, ("Invalid uid mapping.\n")); + status = NT_STATUS_NONE_MAPPED; + goto failed; + } + *uid = new_uid; + talloc_free(tmp_ctx); + return NT_STATUS_OK; + } + + DEBUG(6, ("No existing mapping found, attempting to create one.\n")); + + trans = ldb_transaction_start(ldb); + if (trans != LDB_SUCCESS) { + status = NT_STATUS_NONE_MAPPED; + goto failed; + } + + /* Redo the search to make sure noone changed the mapping while we + * weren't looking */ + ret = ldb_search_exp_fmt(ldb, tmp_ctx, &res, NULL, LDB_SCOPE_SUBTREE, + NULL, "(&(objectClass=sidMap)(objectSid=%s))", + ldap_encode_ndr_dom_sid(tmp_ctx, sid)); + if (ret != LDB_SUCCESS) { + DEBUG(1, ("Search failed: %s\n", ldb_errstring(ldb))); + status = NT_STATUS_NONE_MAPPED; + goto failed; + } + + if (res->count > 0) { + DEBUG(1, ("Database changed while trying to add a sidmap.\n")); + status = NT_STATUS_RETRY; + goto failed; + } + + /*FIXME: if lp_idmap_trusted_only() == true, check if SID can be + * resolved here. */ + + ret = idmap_get_bounds(idmap_ctx, &low, &high); + if (ret != LDB_SUCCESS) { + status = NT_STATUS_NONE_MAPPED; + goto failed; + } + + dn = ldb_dn_new(tmp_ctx, ldb, "CN=CONFIG"); + if (dn == NULL) { + status = NT_STATUS_NO_MEMORY; + goto failed; + } + + ret = ldb_search(ldb, dn, LDB_SCOPE_BASE, NULL, NULL, &res); + if (ret != LDB_SUCCESS) { + DEBUG(1, ("Search failed: %s\n", ldb_errstring(ldb))); + status = NT_STATUS_NONE_MAPPED; + goto failed; + } + + talloc_steal(tmp_ctx, res); + + if (res->count != 1) { + DEBUG(1, ("No CN=CONFIG record, idmap database is broken.\n")); + status = NT_STATUS_NONE_MAPPED; + goto failed; + } + + hwm = ldb_msg_find_attr_as_uint(res->msgs[0], "uidNumber", -1); + if (hwm == (uid_t)-1) { + hwm = low; + hwm_entry_exists = false; + } else { + hwm_entry_exists = true; + } + + if (hwm > high) { + DEBUG(1, ("Out of uids to allocate.\n")); + status = NT_STATUS_NONE_MAPPED; + goto failed; + } + + hwm_msg = ldb_msg_new(tmp_ctx); + if (hwm_msg == NULL) { + DEBUG(1, ("Out of memory when creating ldb_message\n")); + status = NT_STATUS_NO_MEMORY; + goto failed; + } + + hwm_msg->dn = dn; + + new_uid = hwm; + hwm++; + + hwm_string = talloc_asprintf(tmp_ctx, "%u", hwm); + if (hwm_string == NULL) { + status = NT_STATUS_NO_MEMORY; + goto failed; + } + + sid_string = dom_sid_string(tmp_ctx, sid); + if (sid_string == NULL) { + status = NT_STATUS_NO_MEMORY; + goto failed; + } + + uid_string = talloc_asprintf(tmp_ctx, "%u", new_uid); + if (uid_string == NULL) { + status = NT_STATUS_NO_MEMORY; + goto failed; + } + + if (hwm_entry_exists) { + struct ldb_message_element *els; + struct ldb_val *vals; + + /* We're modifying the entry, not just adding a new one. */ + els = talloc_array(tmp_ctx, struct ldb_message_element, 2); + if (els == NULL) { + status = NT_STATUS_NO_MEMORY; + goto failed; + } + + vals = talloc_array(tmp_ctx, struct ldb_val, 2); + if (els == NULL) { + status = NT_STATUS_NO_MEMORY; + goto failed; + } + + hwm_msg->num_elements = 2; + hwm_msg->elements = els; + + els[0].num_values = 1; + els[0].values = &vals[0]; + els[0].flags = LDB_FLAG_MOD_DELETE; + els[0].name = talloc_strdup(tmp_ctx, "uidNumber"); + if (els[0].name == NULL) { + status = NT_STATUS_NO_MEMORY; + goto failed; + } + + els[1].num_values = 1; + els[1].values = &vals[1]; + els[1].flags = LDB_FLAG_MOD_ADD; + els[1].name = els[0].name; + + vals[0].data = (uint8_t *)uid_string; + vals[0].length = strlen(uid_string); + vals[1].data = (uint8_t *)hwm_string; + vals[1].length = strlen(hwm_string); + } else { + ret = ldb_msg_add_empty(hwm_msg, "uidNumber", LDB_FLAG_MOD_ADD, + NULL); + if (ret != LDB_SUCCESS) { + status = NT_STATUS_NONE_MAPPED; + goto failed; + } + + ret = ldb_msg_add_string(hwm_msg, "uidNumber", hwm_string); + if (ret != LDB_SUCCESS) + { + status = NT_STATUS_NONE_MAPPED; + goto failed; + } + } + + ret = ldb_modify(ldb, hwm_msg); + if (ret != LDB_SUCCESS) { + DEBUG(1, ("Updating the uid high water mark failed: %s\n", + ldb_errstring(ldb))); + status = NT_STATUS_NONE_MAPPED; + goto failed; + } + + map_msg = ldb_msg_new(tmp_ctx); + if (map_msg == NULL) { + status = NT_STATUS_NO_MEMORY; + goto failed; + } + + map_msg->dn = ldb_dn_new_fmt(tmp_ctx, ldb, "CN=%s", sid_string); + if (map_msg->dn == NULL) { + status = NT_STATUS_NO_MEMORY; + goto failed; + } + + ret = ldb_msg_add_string(map_msg, "uidNumber", uid_string); + if (ret != LDB_SUCCESS) { + status = NT_STATUS_NONE_MAPPED; + goto failed; + } + + ret = idmap_msg_add_dom_sid(idmap_ctx, tmp_ctx, map_msg, "objectSid", + sid); + if (ret != LDB_SUCCESS) { + status = NT_STATUS_NONE_MAPPED; + goto failed; + } + + ret = ldb_msg_add_string(map_msg, "objectClass", "sidMap"); + if (ret != LDB_SUCCESS) { + status = NT_STATUS_NONE_MAPPED; + goto failed; + } + + ret = ldb_msg_add_string(map_msg, "cn", sid_string); + if (ret != LDB_SUCCESS) { + status = NT_STATUS_NONE_MAPPED; + goto failed; + } + + ret = ldb_add(ldb, map_msg); + if (ret != LDB_SUCCESS) { + DEBUG(1, ("Adding a sidmap failed: %s\n", ldb_errstring(ldb))); + status = NT_STATUS_NONE_MAPPED; + goto failed; + } + + trans = ldb_transaction_commit(ldb); + if (trans != LDB_SUCCESS) { + DEBUG(1, ("Transaction failed: %s\n", ldb_errstring(ldb))); + status = NT_STATUS_NONE_MAPPED; + goto failed; + } + + *uid = new_uid; + talloc_free(tmp_ctx); + return NT_STATUS_OK; + +failed: + if (trans == LDB_SUCCESS) ldb_transaction_cancel(ldb); + talloc_free(tmp_ctx); + return status; } /** diff --git a/source4/winbind/wb_sid2uid.c b/source4/winbind/wb_sid2uid.c index 449596ef38..0de45fdea9 100644 --- a/source4/winbind/wb_sid2uid.c +++ b/source4/winbind/wb_sid2uid.c @@ -3,7 +3,7 @@ Map a SID to a uid - Copyright (C) Kai Blin 2007 + Copyright (C) Kai Blin 2007-2008 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,6 +25,7 @@ #include "smbd/service_task.h" #include "winbind/wb_helper.h" #include "libcli/security/proto.h" +#include "winbind/idmap.h" struct sid2uid_state { struct composite_context *ctx; @@ -50,11 +51,13 @@ struct composite_context *wb_sid2uid_send(TALLOC_CTX *mem_ctx, result->private_data = state; state->service = service; - /*FIXME: This is a stub so far. */ - state->ctx->status = dom_sid_split_rid(result, sid, NULL, &state->uid); - if(!composite_is_ok(state->ctx)) return result; - - DEBUG(5, ("Rid is %d\n", state->uid)); + state->ctx->status = idmap_sid_to_uid(service->idmap_ctx, state, sid, + &state->uid); + if (NT_STATUS_EQUAL(state->ctx->status, NT_STATUS_RETRY)) { + state->ctx->status = idmap_sid_to_uid(service->idmap_ctx, state, + sid, &state->uid); + } + if (!composite_is_ok(state->ctx)) return result; composite_done(state->ctx); return result; -- cgit From 99b311449f494c0318127dc9140c4a22bb932884 Mon Sep 17 00:00:00 2001 From: Kai Blin Date: Mon, 18 Feb 2008 23:47:30 +0100 Subject: idmap: Handle SID->gid (This used to be commit 78d22a28eca4dd89f629dbe75287e9ac3940606b) --- source4/winbind/idmap.c | 257 ++++++++++++++++++++++++++++++++++++++++++- source4/winbind/wb_sid2gid.c | 11 +- 2 files changed, 263 insertions(+), 5 deletions(-) diff --git a/source4/winbind/idmap.c b/source4/winbind/idmap.c index 53276114dd..3372ad51ee 100644 --- a/source4/winbind/idmap.c +++ b/source4/winbind/idmap.c @@ -801,7 +801,7 @@ failed: * * If no mapping exist, a new mapping will be created. * - * \todo Create mappings for groups not from our primary domain. + * \todo Check if SID resolve when lp_idmap_trusted_only() == true * * \param idmap_ctx idmap context to use * \param mem_ctx talloc context to use @@ -814,6 +814,259 @@ failed: NTSTATUS idmap_sid_to_gid(struct idmap_context *idmap_ctx, TALLOC_CTX *mem_ctx, const struct dom_sid *sid, gid_t *gid) { - return NT_STATUS_NONE_MAPPED; + int ret; + NTSTATUS status = NT_STATUS_NONE_MAPPED; + struct ldb_context *ldb = idmap_ctx->ldb_ctx; + struct ldb_dn *dn; + struct ldb_message *hwm_msg, *map_msg; + struct ldb_result *res = NULL; + int trans = -1; + gid_t low, high, hwm, new_gid; + char *sid_string, *gid_string, *hwm_string; + bool hwm_entry_exists; + TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx); + + ret = ldb_search_exp_fmt(ldb, tmp_ctx, &res, NULL, LDB_SCOPE_SUBTREE, + NULL, "(&(objectClass=sidMap)(objectSid=%s))", + ldap_encode_ndr_dom_sid(tmp_ctx, sid)); + if (ret != LDB_SUCCESS) { + DEBUG(1, ("Search failed: %s\n", ldb_errstring(ldb))); + status = NT_STATUS_NONE_MAPPED; + goto failed; + } + + if (res->count == 1) { + new_gid = ldb_msg_find_attr_as_uint(res->msgs[0], "gidNumber", + -1); + if (new_gid == (gid_t) -1) { + DEBUG(1, ("Invalid gid mapping.\n")); + status = NT_STATUS_NONE_MAPPED; + goto failed; + } + *gid = new_gid; + talloc_free(tmp_ctx); + return NT_STATUS_OK; + } + + DEBUG(6, ("No existing mapping found, attempting to create one.\n")); + + trans = ldb_transaction_start(ldb); + if (trans != LDB_SUCCESS) { + status = NT_STATUS_NONE_MAPPED; + goto failed; + } + + /* Redo the search to make sure noone changed the mapping while we + * weren't looking */ + ret = ldb_search_exp_fmt(ldb, tmp_ctx, &res, NULL, LDB_SCOPE_SUBTREE, + NULL, "(&(objectClass=sidMap)(objectSid=%s))", + ldap_encode_ndr_dom_sid(tmp_ctx, sid)); + if (ret != LDB_SUCCESS) { + DEBUG(1, ("Search failed: %s\n", ldb_errstring(ldb))); + status = NT_STATUS_NONE_MAPPED; + goto failed; + } + + if (res->count > 0) { + DEBUG(1, ("Database changed while trying to add a sidmap.\n")); + status = NT_STATUS_RETRY; + goto failed; + } + + /*FIXME: if lp_idmap_trusted_only() == true, check if SID can be + * resolved here. */ + + ret = idmap_get_bounds(idmap_ctx, &low, &high); + if (ret != LDB_SUCCESS) { + status = NT_STATUS_NONE_MAPPED; + goto failed; + } + + dn = ldb_dn_new(tmp_ctx, ldb, "CN=CONFIG"); + if (dn == NULL) { + status = NT_STATUS_NO_MEMORY; + goto failed; + } + + ret = ldb_search(ldb, dn, LDB_SCOPE_BASE, NULL, NULL, &res); + if (ret != LDB_SUCCESS) { + DEBUG(1, ("Search failed: %s\n", ldb_errstring(ldb))); + status = NT_STATUS_NONE_MAPPED; + goto failed; + } + + talloc_steal(tmp_ctx, res); + + if (res->count != 1) { + DEBUG(1, ("No CN=CONFIG record, idmap database is broken.\n")); + status = NT_STATUS_NONE_MAPPED; + goto failed; + } + + hwm = ldb_msg_find_attr_as_uint(res->msgs[0], "gidNumber", -1); + if (hwm == (gid_t)-1) { + hwm = low; + hwm_entry_exists = false; + } else { + hwm_entry_exists = true; + } + + if (hwm > high) { + DEBUG(1, ("Out of gids to allocate.\n")); + status = NT_STATUS_NONE_MAPPED; + goto failed; + } + + hwm_msg = ldb_msg_new(tmp_ctx); + if (hwm_msg == NULL) { + DEBUG(1, ("Out of memory when creating ldb_message\n")); + status = NT_STATUS_NO_MEMORY; + goto failed; + } + + hwm_msg->dn = dn; + + new_gid = hwm; + hwm++; + + hwm_string = talloc_asprintf(tmp_ctx, "%u", hwm); + if (hwm_string == NULL) { + status = NT_STATUS_NO_MEMORY; + goto failed; + } + + sid_string = dom_sid_string(tmp_ctx, sid); + if (sid_string == NULL) { + status = NT_STATUS_NO_MEMORY; + goto failed; + } + + gid_string = talloc_asprintf(tmp_ctx, "%u", new_gid); + if (gid_string == NULL) { + status = NT_STATUS_NO_MEMORY; + goto failed; + } + + if (hwm_entry_exists) { + struct ldb_message_element *els; + struct ldb_val *vals; + + /* We're modifying the entry, not just adding a new one. */ + els = talloc_array(tmp_ctx, struct ldb_message_element, 2); + if (els == NULL) { + status = NT_STATUS_NO_MEMORY; + goto failed; + } + + vals = talloc_array(tmp_ctx, struct ldb_val, 2); + if (els == NULL) { + status = NT_STATUS_NO_MEMORY; + goto failed; + } + + hwm_msg->num_elements = 2; + hwm_msg->elements = els; + + els[0].num_values = 1; + els[0].values = &vals[0]; + els[0].flags = LDB_FLAG_MOD_DELETE; + els[0].name = talloc_strdup(tmp_ctx, "gidNumber"); + if (els[0].name == NULL) { + status = NT_STATUS_NO_MEMORY; + goto failed; + } + + els[1].num_values = 1; + els[1].values = &vals[1]; + els[1].flags = LDB_FLAG_MOD_ADD; + els[1].name = els[0].name; + + vals[0].data = (uint8_t *)gid_string; + vals[0].length = strlen(gid_string); + vals[1].data = (uint8_t *)hwm_string; + vals[1].length = strlen(hwm_string); + } else { + ret = ldb_msg_add_empty(hwm_msg, "gidNumber", LDB_FLAG_MOD_ADD, + NULL); + if (ret != LDB_SUCCESS) { + status = NT_STATUS_NONE_MAPPED; + goto failed; + } + + ret = ldb_msg_add_string(hwm_msg, "gidNumber", hwm_string); + if (ret != LDB_SUCCESS) + { + status = NT_STATUS_NONE_MAPPED; + goto failed; + } + } + + ret = ldb_modify(ldb, hwm_msg); + if (ret != LDB_SUCCESS) { + DEBUG(1, ("Updating the gid high water mark failed: %s\n", + ldb_errstring(ldb))); + status = NT_STATUS_NONE_MAPPED; + goto failed; + } + + map_msg = ldb_msg_new(tmp_ctx); + if (map_msg == NULL) { + status = NT_STATUS_NO_MEMORY; + goto failed; + } + + map_msg->dn = ldb_dn_new_fmt(tmp_ctx, ldb, "CN=%s", sid_string); + if (map_msg->dn == NULL) { + status = NT_STATUS_NO_MEMORY; + goto failed; + } + + ret = ldb_msg_add_string(map_msg, "gidNumber", gid_string); + if (ret != LDB_SUCCESS) { + status = NT_STATUS_NONE_MAPPED; + goto failed; + } + + ret = idmap_msg_add_dom_sid(idmap_ctx, tmp_ctx, map_msg, "objectSid", + sid); + if (ret != LDB_SUCCESS) { + status = NT_STATUS_NONE_MAPPED; + goto failed; + } + + ret = ldb_msg_add_string(map_msg, "objectClass", "sidMap"); + if (ret != LDB_SUCCESS) { + status = NT_STATUS_NONE_MAPPED; + goto failed; + } + + ret = ldb_msg_add_string(map_msg, "cn", sid_string); + if (ret != LDB_SUCCESS) { + status = NT_STATUS_NONE_MAPPED; + goto failed; + } + + ret = ldb_add(ldb, map_msg); + if (ret != LDB_SUCCESS) { + DEBUG(1, ("Adding a sidmap failed: %s\n", ldb_errstring(ldb))); + status = NT_STATUS_NONE_MAPPED; + goto failed; + } + + trans = ldb_transaction_commit(ldb); + if (trans != LDB_SUCCESS) { + DEBUG(1, ("Transaction failed: %s\n", ldb_errstring(ldb))); + status = NT_STATUS_NONE_MAPPED; + goto failed; + } + + *gid = new_gid; + talloc_free(tmp_ctx); + return NT_STATUS_OK; + +failed: + if (trans == LDB_SUCCESS) ldb_transaction_cancel(ldb); + talloc_free(tmp_ctx); + return status; } diff --git a/source4/winbind/wb_sid2gid.c b/source4/winbind/wb_sid2gid.c index 8cb5608b2f..12129226be 100644 --- a/source4/winbind/wb_sid2gid.c +++ b/source4/winbind/wb_sid2gid.c @@ -25,6 +25,7 @@ #include "smbd/service_task.h" #include "winbind/wb_helper.h" #include "libcli/security/proto.h" +#include "winbind/idmap.h" struct sid2gid_state { struct composite_context *ctx; @@ -50,9 +51,13 @@ struct composite_context *wb_sid2gid_send(TALLOC_CTX *mem_ctx, result->private_data = state; state->service = service; - /*FIXME: This is a stub so far. */ - state->ctx->status = dom_sid_split_rid(result, sid, NULL, &state->gid); - if(!composite_is_ok(state->ctx)) return result; + state->ctx->status = idmap_sid_to_gid(service->idmap_ctx, state, sid, + &state->gid); + if (NT_STATUS_EQUAL(state->ctx->status, NT_STATUS_RETRY)) { + state->ctx->status = idmap_sid_to_gid(service->idmap_ctx, state, + sid, &state->gid); + } + if (!composite_is_ok(state->ctx)) return result; composite_done(state->ctx); return result; -- cgit From 52623b627ddcaf50347d5cb75c2f2490e73dfe29 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 15 Feb 2008 14:56:35 +0100 Subject: samr.idl: windows uses lsa_AsciiStringLarge in QueryDisplayInfo Tested with nt4 and w2k3. metze (This used to be commit 24ec069751ef8db1211c50e7ca1e527adaa6432c) --- source4/librpc/idl/samr.idl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source4/librpc/idl/samr.idl b/source4/librpc/idl/samr.idl index 2dc33fa9b9..3a11ab752c 100644 --- a/source4/librpc/idl/samr.idl +++ b/source4/librpc/idl/samr.idl @@ -960,7 +960,7 @@ import "misc.idl", "lsa.idl", "security.idl"; typedef struct { uint32 idx; - lsa_AsciiString account_name; + lsa_AsciiStringLarge account_name; } samr_DispEntryAscii; typedef struct { -- cgit From 9f4f4968317c92efee5db5b13f31cb5811c22e9f Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 19 Feb 2008 16:40:48 +0100 Subject: srvsvc.idl: don't use STR_LEN4 anymore metze (This used to be commit 8c7509bd684ccdabcdb9ad9f75f3dd693ee9c416) --- source4/librpc/idl/srvsvc.idl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/source4/librpc/idl/srvsvc.idl b/source4/librpc/idl/srvsvc.idl index 66c52fa43f..8ef49413bc 100644 --- a/source4/librpc/idl/srvsvc.idl +++ b/source4/librpc/idl/srvsvc.idl @@ -1127,7 +1127,16 @@ import "security.idl", "svcctl.idl"; /* srvsvc_NetDisk */ /**************************/ typedef struct { - [flag(STR_LEN4)] string disk; + /* + * In theory this should be: + * [charset(UTF16),string] uint16 annotation[3] + * But midl treats this as: + * [charset(UTF16),string] uint16 annotation[] + * and pidl doesn't support this yet + */ + [value(0)] uint32 __disk_offset; + [value(strlen(disk)+1)] uint32 __disk_length; + [charset(UTF16)] uint16 disk[__disk_length]; } srvsvc_NetDiskInfo0; typedef struct { -- cgit From 37deca2d41d74faa7abe060a21340263bd6d66f7 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 21 Feb 2008 14:16:02 +0100 Subject: Avoid use of global_loadparm. (This used to be commit c5a95bbe0ce55c29e135a9c6058bf192ec3bb546) --- source4/auth/gensec/gensec_gssapi.c | 2 +- source4/auth/gensec/gensec_krb5.c | 4 +++- source4/auth/kerberos/kerberos.h | 4 ++++ source4/auth/kerberos/kerberos_pac.c | 11 ++++++++--- source4/kdc/hdb-ldb.c | 10 ++++++---- source4/lib/tdr/tdr.c | 2 +- source4/torture/auth/pac.c | 34 ++++++++++++++++++++++++++-------- source4/torture/rap/rap.c | 29 +++++++++++++++++------------ source4/torture/rpc/samba3rpc.c | 7 ++++--- 9 files changed, 70 insertions(+), 33 deletions(-) diff --git a/source4/auth/gensec/gensec_gssapi.c b/source4/auth/gensec/gensec_gssapi.c index 8361b115d7..d8cdb90197 100644 --- a/source4/auth/gensec/gensec_gssapi.c +++ b/source4/auth/gensec/gensec_gssapi.c @@ -1298,7 +1298,7 @@ static NTSTATUS gensec_gssapi_session_info(struct gensec_security *gensec_securi } /* decode and verify the pac */ - nt_status = kerberos_pac_logon_info(mem_ctx, &logon_info, pac_blob, + nt_status = kerberos_pac_logon_info(mem_ctx, lp_iconv_convenience(gensec_security->lp_ctx), &logon_info, pac_blob, gensec_gssapi_state->smb_krb5_context->krb5_context, NULL, keyblock, principal, authtime, NULL); krb5_free_principal(gensec_gssapi_state->smb_krb5_context->krb5_context, principal); diff --git a/source4/auth/gensec/gensec_krb5.c b/source4/auth/gensec/gensec_krb5.c index d9addcaa3c..88432c7f89 100644 --- a/source4/auth/gensec/gensec_krb5.c +++ b/source4/auth/gensec/gensec_krb5.c @@ -617,7 +617,9 @@ static NTSTATUS gensec_krb5_session_info(struct gensec_security *gensec_security } /* decode and verify the pac */ - nt_status = kerberos_pac_logon_info(gensec_krb5_state, &logon_info, pac, + nt_status = kerberos_pac_logon_info(gensec_krb5_state, + lp_iconv_convenience(gensec_security->lp_ctx), + &logon_info, pac, gensec_krb5_state->smb_krb5_context->krb5_context, NULL, gensec_krb5_state->keyblock, client_principal, diff --git a/source4/auth/kerberos/kerberos.h b/source4/auth/kerberos/kerberos.h index bafd58a048..8585aa321b 100644 --- a/source4/auth/kerberos/kerberos.h +++ b/source4/auth/kerberos/kerberos.h @@ -111,6 +111,7 @@ krb5_error_code principal_from_credentials(TALLOC_CTX *parent_ctx, struct smb_krb5_context *smb_krb5_context, krb5_principal *princ); NTSTATUS kerberos_decode_pac(TALLOC_CTX *mem_ctx, + struct smb_iconv_convenience *iconv_convenience, struct PAC_DATA **pac_data_out, DATA_BLOB blob, krb5_context context, @@ -120,6 +121,7 @@ NTSTATUS kerberos_decode_pac(TALLOC_CTX *mem_ctx, time_t tgs_authtime, krb5_error_code *k5ret); NTSTATUS kerberos_pac_logon_info(TALLOC_CTX *mem_ctx, + struct smb_iconv_convenience *iconv_convenience, struct PAC_LOGON_INFO **logon_info, DATA_BLOB blob, krb5_context context, @@ -129,12 +131,14 @@ NTSTATUS kerberos_decode_pac(TALLOC_CTX *mem_ctx, time_t tgs_authtime, krb5_error_code *k5ret); krb5_error_code kerberos_encode_pac(TALLOC_CTX *mem_ctx, + struct smb_iconv_convenience *iconv_convenience, struct PAC_DATA *pac_data, krb5_context context, const krb5_keyblock *krbtgt_keyblock, const krb5_keyblock *service_keyblock, DATA_BLOB *pac); krb5_error_code kerberos_create_pac(TALLOC_CTX *mem_ctx, + struct smb_iconv_convenience *iconv_convenience, struct auth_serversupplied_info *server_info, krb5_context context, const krb5_keyblock *krbtgt_keyblock, diff --git a/source4/auth/kerberos/kerberos_pac.c b/source4/auth/kerberos/kerberos_pac.c index c46e06bc72..e485f75302 100644 --- a/source4/auth/kerberos/kerberos_pac.c +++ b/source4/auth/kerberos/kerberos_pac.c @@ -66,6 +66,7 @@ static krb5_error_code check_pac_checksum(TALLOC_CTX *mem_ctx, } NTSTATUS kerberos_decode_pac(TALLOC_CTX *mem_ctx, + struct smb_iconv_convenience *iconv_convenience, struct PAC_DATA **pac_data_out, DATA_BLOB blob, krb5_context context, @@ -86,7 +87,6 @@ static krb5_error_code check_pac_checksum(TALLOC_CTX *mem_ctx, struct PAC_LOGON_NAME *logon_name = NULL; struct PAC_DATA *pac_data; struct PAC_DATA_RAW *pac_data_raw; - struct smb_iconv_convenience *iconv_convenience = lp_iconv_convenience(global_loadparm); DATA_BLOB *srv_sig_blob = NULL; DATA_BLOB *kdc_sig_blob = NULL; @@ -340,6 +340,7 @@ static krb5_error_code check_pac_checksum(TALLOC_CTX *mem_ctx, } _PUBLIC_ NTSTATUS kerberos_pac_logon_info(TALLOC_CTX *mem_ctx, + struct smb_iconv_convenience *iconv_convenience, struct PAC_LOGON_INFO **logon_info, DATA_BLOB blob, krb5_context context, @@ -352,7 +353,9 @@ _PUBLIC_ NTSTATUS kerberos_pac_logon_info(TALLOC_CTX *mem_ctx, NTSTATUS nt_status; struct PAC_DATA *pac_data; int i; - nt_status = kerberos_decode_pac(mem_ctx, &pac_data, + nt_status = kerberos_decode_pac(mem_ctx, + iconv_convenience, + &pac_data, blob, context, krbtgt_keyblock, @@ -423,6 +426,7 @@ static krb5_error_code make_pac_checksum(TALLOC_CTX *mem_ctx, } krb5_error_code kerberos_encode_pac(TALLOC_CTX *mem_ctx, + struct smb_iconv_convenience *iconv_convenience, struct PAC_DATA *pac_data, krb5_context context, const krb5_keyblock *krbtgt_keyblock, @@ -437,7 +441,6 @@ static krb5_error_code make_pac_checksum(TALLOC_CTX *mem_ctx, struct PAC_SIGNATURE_DATA *kdc_checksum = NULL; struct PAC_SIGNATURE_DATA *srv_checksum = NULL; int i; - struct smb_iconv_convenience *iconv_convenience = lp_iconv_convenience(global_loadparm); /* First, just get the keytypes filled in (and lengths right, eventually) */ for (i=0; i < pac_data->num_buffers; i++) { @@ -528,6 +531,7 @@ static krb5_error_code make_pac_checksum(TALLOC_CTX *mem_ctx, krb5_error_code kerberos_create_pac(TALLOC_CTX *mem_ctx, + struct smb_iconv_convenience *iconv_convenience, struct auth_serversupplied_info *server_info, krb5_context context, const krb5_keyblock *krbtgt_keyblock, @@ -640,6 +644,7 @@ static krb5_error_code make_pac_checksum(TALLOC_CTX *mem_ctx, unix_to_nt_time(&LOGON_NAME->logon_time, tgs_authtime); ret = kerberos_encode_pac(mem_ctx, + iconv_convenience, pac_data, context, krbtgt_keyblock, diff --git a/source4/kdc/hdb-ldb.c b/source4/kdc/hdb-ldb.c index 51726a03c3..d8877655c9 100644 --- a/source4/kdc/hdb-ldb.c +++ b/source4/kdc/hdb-ldb.c @@ -180,6 +180,7 @@ static void hdb_ldb_free_entry(krb5_context context, hdb_entry_ex *entry_ex) } static krb5_error_code LDB_message2entry_keys(krb5_context context, + struct smb_iconv_convenience *iconv_convenience, TALLOC_CTX *mem_ctx, struct ldb_message *msg, unsigned int userAccountControl, @@ -213,7 +214,7 @@ static krb5_error_code LDB_message2entry_keys(krb5_context context, /* supplementalCredentials if present */ if (sc_val) { - ndr_err = ndr_pull_struct_blob_all(sc_val, mem_ctx, lp_iconv_convenience(global_loadparm), &scb, + ndr_err = ndr_pull_struct_blob_all(sc_val, mem_ctx, iconv_convenience, &scb, (ndr_pull_flags_fn_t)ndr_pull_supplementalCredentialsBlob); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { dump_data(0, sc_val->data, sc_val->length); @@ -250,7 +251,7 @@ static krb5_error_code LDB_message2entry_keys(krb5_context context, talloc_steal(mem_ctx, blob.data); /* TODO: use ndr_pull_struct_blob_all(), when the ndr layer handles it correct with relative pointers */ - ndr_err = ndr_pull_struct_blob(&blob, mem_ctx, lp_iconv_convenience(global_loadparm), &_pkb, + ndr_err = ndr_pull_struct_blob(&blob, mem_ctx, iconv_convenience, &_pkb, (ndr_pull_flags_fn_t)ndr_pull_package_PrimaryKerberosBlob); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { krb5_set_error_string(context, "LDB_message2entry_keys: could not parse package_PrimaryKerberosBlob"); @@ -393,6 +394,7 @@ static krb5_error_code LDB_message2entry(krb5_context context, HDB *db, krb5_boolean is_computer = FALSE; const char *dnsdomain = ldb_msg_find_attr_as_string(realm_ref_msg, "dnsRoot", NULL); char *realm = strupper_talloc(mem_ctx, dnsdomain); + struct loadparm_context *lp_ctx = ldb_get_opaque((struct ldb_context *)db->hdb_db, "loadparm"); struct ldb_dn *domain_dn = samdb_result_dn((struct ldb_context *)db->hdb_db, mem_ctx, realm_ref_msg, @@ -481,7 +483,7 @@ static krb5_error_code LDB_message2entry(krb5_context context, HDB *db, entry_ex->entry.flags.ok_as_delegate = 1; } - if (lp_parm_bool(global_loadparm, NULL, "kdc", "require spn for service", true)) { + if (lp_parm_bool(lp_ctx, NULL, "kdc", "require spn for service", true)) { if (!is_computer && !ldb_msg_find_attr_as_string(msg, "servicePrincipalName", NULL)) { entry_ex->entry.flags.server = 0; } @@ -544,7 +546,7 @@ static krb5_error_code LDB_message2entry(krb5_context context, HDB *db, entry_ex->entry.generation = NULL; /* Get keys from the db */ - ret = LDB_message2entry_keys(context, private, msg, userAccountControl, entry_ex); + ret = LDB_message2entry_keys(context, lp_iconv_convenience(lp_ctx), private, msg, userAccountControl, entry_ex); if (ret) { /* Could be bougus data in the entry, or out of memory */ goto out; diff --git a/source4/lib/tdr/tdr.c b/source4/lib/tdr/tdr.c index f75cac9810..2ad099174d 100644 --- a/source4/lib/tdr/tdr.c +++ b/source4/lib/tdr/tdr.c @@ -154,7 +154,7 @@ NTSTATUS tdr_pull_charset(struct tdr_pull *tdr, TALLOC_CTX *ctx, const char **v, TDR_PULL_NEED_BYTES(tdr, el_size*length); - ret = convert_string_talloc(ctx, lp_iconv_convenience(global_loadparm), chset, CH_UNIX, tdr->data.data+tdr->offset, el_size*length, discard_const_p(void *, v)); + ret = convert_string_talloc(ctx, tdr->iconv_convenience, chset, CH_UNIX, tdr->data.data+tdr->offset, el_size*length, discard_const_p(void *, v)); if (ret == -1) { return NT_STATUS_INVALID_PARAMETER; diff --git a/source4/torture/auth/pac.c b/source4/torture/auth/pac.c index efb36e3ef8..68bbd3483a 100644 --- a/source4/torture/auth/pac.c +++ b/source4/torture/auth/pac.c @@ -112,7 +112,9 @@ static bool torture_pac_self_check(struct torture_context *tctx) } /* OK, go ahead and make a PAC */ - ret = kerberos_create_pac(mem_ctx, server_info, + ret = kerberos_create_pac(mem_ctx, + lp_iconv_convenience(tctx->lp_ctx), + server_info, smb_krb5_context->krb5_context, &krbtgt_keyblock, &server_keyblock, @@ -137,7 +139,9 @@ static bool torture_pac_self_check(struct torture_context *tctx) dump_data(10,tmp_blob.data,tmp_blob.length); /* Now check that we can read it back */ - nt_status = kerberos_decode_pac(mem_ctx, &pac_data, + nt_status = kerberos_decode_pac(mem_ctx, + lp_iconv_convenience(tctx->lp_ctx), + &pac_data, tmp_blob, smb_krb5_context->krb5_context, &krbtgt_keyblock, @@ -159,7 +163,9 @@ static bool torture_pac_self_check(struct torture_context *tctx) } /* Now check that we can read it back */ - nt_status = kerberos_pac_logon_info(mem_ctx, &logon_info, + nt_status = kerberos_pac_logon_info(mem_ctx, + lp_iconv_convenience(tctx->lp_ctx), + &logon_info, tmp_blob, smb_krb5_context->krb5_context, &krbtgt_keyblock, @@ -367,7 +373,9 @@ static bool torture_pac_saved_check(struct torture_context *tctx) } /* Decode and verify the signaure on the PAC */ - nt_status = kerberos_decode_pac(mem_ctx, &pac_data, + nt_status = kerberos_decode_pac(mem_ctx, + lp_iconv_convenience(tctx->lp_ctx), + &pac_data, tmp_blob, smb_krb5_context->krb5_context, &krbtgt_keyblock, @@ -386,7 +394,9 @@ static bool torture_pac_saved_check(struct torture_context *tctx) } /* Parse the PAC again, for the logon info this time */ - nt_status = kerberos_pac_logon_info(mem_ctx, &logon_info, + nt_status = kerberos_pac_logon_info(mem_ctx, + lp_iconv_convenience(tctx->lp_ctx), + &logon_info, tmp_blob, smb_krb5_context->krb5_context, &krbtgt_keyblock, @@ -442,6 +452,7 @@ static bool torture_pac_saved_check(struct torture_context *tctx) } ret = kerberos_encode_pac(mem_ctx, + lp_iconv_convenience(tctx->lp_ctx), pac_data, smb_krb5_context->krb5_context, &krbtgt_keyblock, @@ -493,6 +504,7 @@ static bool torture_pac_saved_check(struct torture_context *tctx) } ret = kerberos_create_pac(mem_ctx, + lp_iconv_convenience(tctx->lp_ctx), server_info_out, smb_krb5_context->krb5_context, &krbtgt_keyblock, @@ -565,7 +577,9 @@ static bool torture_pac_saved_check(struct torture_context *tctx) } /* Break the auth time, to ensure we check this vital detail (not setting this caused all the pain in the first place... */ - nt_status = kerberos_decode_pac(mem_ctx, &pac_data, + nt_status = kerberos_decode_pac(mem_ctx, + lp_iconv_convenience(tctx->lp_ctx), + &pac_data, tmp_blob, smb_krb5_context->krb5_context, &krbtgt_keyblock, @@ -601,7 +615,9 @@ static bool torture_pac_saved_check(struct torture_context *tctx) smb_get_krb5_error_message(smb_krb5_context->krb5_context, ret, mem_ctx))); } - nt_status = kerberos_decode_pac(mem_ctx, &pac_data, + nt_status = kerberos_decode_pac(mem_ctx, + lp_iconv_convenience(tctx->lp_ctx), + &pac_data, tmp_blob, smb_krb5_context->krb5_context, &krbtgt_keyblock, @@ -619,7 +635,9 @@ static bool torture_pac_saved_check(struct torture_context *tctx) /* Finally... Bugger up the signature, and check we fail the checksum */ tmp_blob.data[tmp_blob.length - 2]++; - nt_status = kerberos_decode_pac(mem_ctx, &pac_data, + nt_status = kerberos_decode_pac(mem_ctx, + lp_iconv_convenience(tctx->lp_ctx), + &pac_data, tmp_blob, smb_krb5_context->krb5_context, &krbtgt_keyblock, diff --git a/source4/torture/rap/rap.c b/source4/torture/rap/rap.c index 71689786e8..8bdd6a8ddd 100644 --- a/source4/torture/rap/rap.c +++ b/source4/torture/rap/rap.c @@ -189,14 +189,16 @@ static NTSTATUS rap_pull_string(TALLOC_CTX *mem_ctx, struct ndr_pull *ndr, return NT_STATUS_OK; } -static NTSTATUS rap_cli_do_call(struct smbcli_tree *tree, struct rap_call *call) +static NTSTATUS rap_cli_do_call(struct smbcli_tree *tree, + struct smb_iconv_convenience *iconv_convenience, + struct rap_call *call) { NTSTATUS result; DATA_BLOB param_blob; struct ndr_push *params; struct smb_trans2 trans; - params = ndr_push_init_ctx(call, lp_iconv_convenience(global_loadparm)); + params = ndr_push_init_ctx(call, iconv_convenience); if (params == NULL) return NT_STATUS_NO_MEMORY; @@ -231,11 +233,11 @@ static NTSTATUS rap_cli_do_call(struct smbcli_tree *tree, struct rap_call *call) return result; call->ndr_pull_param = ndr_pull_init_blob(&trans.out.params, call, - lp_iconv_convenience(global_loadparm)); + iconv_convenience); call->ndr_pull_param->flags = RAPNDR_FLAGS; call->ndr_pull_data = ndr_pull_init_blob(&trans.out.data, call, - lp_iconv_convenience(global_loadparm)); + iconv_convenience); call->ndr_pull_data->flags = RAPNDR_FLAGS; return result; @@ -243,6 +245,7 @@ static NTSTATUS rap_cli_do_call(struct smbcli_tree *tree, struct rap_call *call) static NTSTATUS smbcli_rap_netshareenum(struct smbcli_tree *tree, + struct smb_iconv_convenience *iconv_convenience, TALLOC_CTX *mem_ctx, struct rap_NetShareEnum *r) { @@ -268,7 +271,7 @@ static NTSTATUS smbcli_rap_netshareenum(struct smbcli_tree *tree, break; } - result = rap_cli_do_call(tree, call); + result = rap_cli_do_call(tree, iconv_convenience, call); if (!NT_STATUS_IS_OK(result)) goto done; @@ -322,7 +325,7 @@ static bool test_netshareenum(struct torture_context *tctx, r.in.bufsize = 8192; torture_assert_ntstatus_ok(tctx, - smbcli_rap_netshareenum(cli->tree, tctx, &r), ""); + smbcli_rap_netshareenum(cli->tree, lp_iconv_convenience(tctx->lp_ctx), tctx, &r), ""); for (i=0; itree, tctx, &r), ""); + smbcli_rap_netserverenum2(cli->tree, lp_iconv_convenience(tctx->lp_ctx), tctx, &r), ""); for (i=0; itree, tctx, &r), ""); + torture_assert_ntstatus_ok(tctx, smbcli_rap_netservergetinfo(cli->tree, lp_iconv_convenience(tctx->lp_ctx), tctx, &r), ""); r.in.level = 1; - torture_assert_ntstatus_ok(tctx, smbcli_rap_netservergetinfo(cli->tree, tctx, &r), ""); + torture_assert_ntstatus_ok(tctx, smbcli_rap_netservergetinfo(cli->tree, lp_iconv_convenience(tctx->lp_ctx), tctx, &r), ""); return res; } @@ -522,7 +527,7 @@ bool torture_rap_scan(struct torture_context *torture, struct smbcli_state *cli) struct rap_call *call = new_rap_cli_call(torture, callno); NTSTATUS result; - result = rap_cli_do_call(cli->tree, call); + result = rap_cli_do_call(cli->tree, lp_iconv_convenience(torture->lp_ctx), call); if (!NT_STATUS_EQUAL(result, NT_STATUS_INVALID_PARAMETER)) continue; diff --git a/source4/torture/rpc/samba3rpc.c b/source4/torture/rpc/samba3rpc.c index 779a28e126..f62fa8742b 100644 --- a/source4/torture/rpc/samba3rpc.c +++ b/source4/torture/rpc/samba3rpc.c @@ -2337,6 +2337,7 @@ bool torture_samba3_rpc_lsa(struct torture_context *torture) } static NTSTATUS get_servername(TALLOC_CTX *mem_ctx, struct smbcli_tree *tree, + struct smb_iconv_convenience *iconv_convenience, char **name) { struct rap_WserverGetInfo r; @@ -2346,7 +2347,7 @@ static NTSTATUS get_servername(TALLOC_CTX *mem_ctx, struct smbcli_tree *tree, r.in.level = 0; r.in.bufsize = 0xffff; - status = smbcli_rap_netservergetinfo(tree, mem_ctx, &r); + status = smbcli_rap_netservergetinfo(tree, iconv_convenience, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -2561,7 +2562,7 @@ bool torture_samba3_rpc_spoolss(struct torture_context *torture) return false; } - status = get_servername(mem_ctx, cli->tree, &servername); + status = get_servername(mem_ctx, cli->tree, lp_iconv_convenience(torture->lp_ctx), &servername); if (!NT_STATUS_IS_OK(status)) { d_fprintf(stderr, "(%s) get_servername returned %s\n", __location__, nt_errstr(status)); @@ -2747,7 +2748,7 @@ bool torture_samba3_rpc_wkssvc(struct torture_context *torture) return false; } - status = get_servername(mem_ctx, cli->tree, &servername); + status = get_servername(mem_ctx, cli->tree, lp_iconv_convenience(torture->lp_ctx), &servername); if (!NT_STATUS_IS_OK(status)) { d_fprintf(stderr, "(%s) get_servername returned %s\n", __location__, nt_errstr(status)); -- cgit From 921b17648456027b6b46a582aa1d13024a5e9a90 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 21 Feb 2008 14:50:57 +0100 Subject: Remove more uses of global_loadparm. (This used to be commit 47d05ecf6fef66c90994f666b8c63e2e7b5a6cd8) --- source4/kdc/pac-glue.c | 11 +++++++---- source4/libcli/auth/smbencrypt.c | 6 ++++-- source4/libcli/dgram/browse.c | 6 +++--- source4/libcli/dgram/dgramsocket.c | 5 +++-- source4/libcli/dgram/libdgram.h | 1 + source4/libcli/dgram/netlogon.c | 6 +++--- source4/libcli/dgram/ntlogon.c | 6 +++--- source4/libcli/nbt/nbtname.c | 4 ++-- source4/libcli/raw/clitransport.c | 5 +++-- source4/libcli/smb_composite/fetchfile.c | 4 ++-- source4/libcli/smb_composite/smb_composite.h | 1 + source4/torture/raw/composite.c | 1 + 12 files changed, 33 insertions(+), 23 deletions(-) diff --git a/source4/kdc/pac-glue.c b/source4/kdc/pac-glue.c index 5f3a718abd..637f39aa74 100644 --- a/source4/kdc/pac-glue.c +++ b/source4/kdc/pac-glue.c @@ -47,6 +47,7 @@ void samba_kdc_plugin_fini(void *ptr) static krb5_error_code make_pac(krb5_context context, TALLOC_CTX *mem_ctx, + struct smb_iconv_convenience *iconv_convenience, struct auth_serversupplied_info *server_info, krb5_pac *pac) { @@ -73,7 +74,7 @@ static krb5_error_code make_pac(krb5_context context, logon_info.info->info3 = *info3; - ndr_err = ndr_push_struct_blob(&pac_out, mem_ctx, lp_iconv_convenience(global_loadparm), &logon_info, + ndr_err = ndr_push_struct_blob(&pac_out, mem_ctx, iconv_convenience, &logon_info, (ndr_push_flags_fn_t)ndr_push_PAC_LOGON_INFO_CTR); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { nt_status = ndr_map_error2ntstatus(ndr_err); @@ -113,6 +114,7 @@ krb5_error_code samba_kdc_get_pac(void *priv, struct hdb_ldb_private *private = talloc_get_type(client->ctx, struct hdb_ldb_private); TALLOC_CTX *mem_ctx = talloc_named(private, 0, "samba_get_pac context"); unsigned int userAccountControl; + struct smb_iconv_convenience *iconv_convenience = lp_iconv_convenience(global_loadparm); if (!mem_ctx) { return ENOMEM; @@ -138,7 +140,7 @@ krb5_error_code samba_kdc_get_pac(void *priv, return ENOMEM; } - ret = make_pac(context, mem_ctx, server_info, pac); + ret = make_pac(context, mem_ctx, iconv_convenience, server_info, pac); talloc_free(mem_ctx); return ret; @@ -164,6 +166,7 @@ krb5_error_code samba_kdc_reget_pac(void *priv, krb5_context context, struct PAC_LOGON_INFO_CTR logon_info; union netr_Validation validation; struct auth_serversupplied_info *server_info_out; + struct smb_iconv_convenience *iconv_convenience = lp_iconv_convenience(global_loadparm); TALLOC_CTX *mem_ctx = talloc_named(private, 0, "samba_get_pac context"); @@ -190,7 +193,7 @@ krb5_error_code samba_kdc_reget_pac(void *priv, krb5_context context, return ENOMEM; } - ndr_err = ndr_pull_struct_blob(&pac_in, mem_ctx, lp_iconv_convenience(global_loadparm), &logon_info, + ndr_err = ndr_pull_struct_blob(&pac_in, mem_ctx, iconv_convenience, &logon_info, (ndr_pull_flags_fn_t)ndr_pull_PAC_LOGON_INFO_CTR); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err) || !logon_info.info) { nt_status = ndr_map_error2ntstatus(ndr_err); @@ -213,7 +216,7 @@ krb5_error_code samba_kdc_reget_pac(void *priv, krb5_context context, /* We will compleatly regenerate this pac */ krb5_pac_free(context, *pac); - ret = make_pac(context, mem_ctx, server_info_out, pac); + ret = make_pac(context, mem_ctx, iconv_convenience, server_info_out, pac); talloc_free(mem_ctx); return ret; diff --git a/source4/libcli/auth/smbencrypt.c b/source4/libcli/auth/smbencrypt.c index 4ccf568d8c..c5223db63f 100644 --- a/source4/libcli/auth/smbencrypt.c +++ b/source4/libcli/auth/smbencrypt.c @@ -125,6 +125,8 @@ bool ntv2_owf_gen(const uint8_t owf[16], HMACMD5Context ctx; TALLOC_CTX *mem_ctx = talloc_init("ntv2_owf_gen for %s\\%s", domain_in, user_in); + struct smb_iconv_convenience *iconv_convenience = lp_iconv_convenience(global_loadparm); + if (!mem_ctx) { return false; } @@ -151,14 +153,14 @@ bool ntv2_owf_gen(const uint8_t owf[16], } } - user_byte_len = push_ucs2_talloc(mem_ctx, lp_iconv_convenience(global_loadparm), &user, user_in); + user_byte_len = push_ucs2_talloc(mem_ctx, iconv_convenience, &user, user_in); if (user_byte_len == (ssize_t)-1) { DEBUG(0, ("push_uss2_talloc() for user returned -1 (probably talloc() failure)\n")); talloc_free(mem_ctx); return false; } - domain_byte_len = push_ucs2_talloc(mem_ctx, lp_iconv_convenience(global_loadparm), &domain, domain_in); + domain_byte_len = push_ucs2_talloc(mem_ctx, iconv_convenience, &domain, domain_in); if (domain_byte_len == (ssize_t)-1) { DEBUG(0, ("push_ucs2_talloc() for domain returned -1 (probably talloc() failure)\n")); talloc_free(mem_ctx); diff --git a/source4/libcli/dgram/browse.c b/source4/libcli/dgram/browse.c index eb19555d15..14d8278635 100644 --- a/source4/libcli/dgram/browse.c +++ b/source4/libcli/dgram/browse.c @@ -38,7 +38,7 @@ NTSTATUS dgram_mailslot_browse_send(struct nbt_dgram_socket *dgmsock, DATA_BLOB blob; TALLOC_CTX *tmp_ctx = talloc_new(dgmsock); - ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, lp_iconv_convenience(global_loadparm), request, + ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, dgmsock->iconv_convenience, request, (ndr_push_flags_fn_t)ndr_push_nbt_browse_packet); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { talloc_free(tmp_ctx); @@ -66,7 +66,7 @@ NTSTATUS dgram_mailslot_browse_reply(struct nbt_dgram_socket *dgmsock, struct nbt_name myname; struct socket_address *dest; - ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, lp_iconv_convenience(global_loadparm), reply, + ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, dgmsock->iconv_convenience, reply, (ndr_push_flags_fn_t)ndr_push_nbt_browse_packet); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { talloc_free(tmp_ctx); @@ -99,7 +99,7 @@ NTSTATUS dgram_mailslot_browse_parse(struct dgram_mailslot_handler *dgmslot, DATA_BLOB data = dgram_mailslot_data(dgram); enum ndr_err_code ndr_err; - ndr_err = ndr_pull_struct_blob(&data, mem_ctx, lp_iconv_convenience(global_loadparm), pkt, + ndr_err = ndr_pull_struct_blob(&data, mem_ctx, dgmslot->dgmsock->iconv_convenience, pkt, (ndr_pull_flags_fn_t)ndr_pull_nbt_browse_packet); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { NTSTATUS status = ndr_map_error2ntstatus(ndr_err); diff --git a/source4/libcli/dgram/dgramsocket.c b/source4/libcli/dgram/dgramsocket.c index 032d9de67b..7d6f5627c5 100644 --- a/source4/libcli/dgram/dgramsocket.c +++ b/source4/libcli/dgram/dgramsocket.c @@ -72,7 +72,7 @@ static void dgm_socket_recv(struct nbt_dgram_socket *dgmsock) } /* 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, dgmsock->iconv_convenience, packet, (ndr_pull_flags_fn_t)ndr_pull_nbt_dgram_packet); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { status = ndr_map_error2ntstatus(ndr_err); @@ -187,6 +187,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); return dgmsock; @@ -229,7 +230,7 @@ NTSTATUS nbt_dgram_send(struct nbt_dgram_socket *dgmsock, req->dest = dest; if (talloc_reference(req, dest) == NULL) goto failed; - ndr_err = ndr_push_struct_blob(&req->encoded, req, lp_iconv_convenience(global_loadparm), packet, + ndr_err = ndr_push_struct_blob(&req->encoded, req, dgmsock->iconv_convenience, packet, (ndr_push_flags_fn_t)ndr_push_nbt_dgram_packet); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { status = ndr_map_error2ntstatus(ndr_err); diff --git a/source4/libcli/dgram/libdgram.h b/source4/libcli/dgram/libdgram.h index 6d4cdb2bdf..4645840971 100644 --- a/source4/libcli/dgram/libdgram.h +++ b/source4/libcli/dgram/libdgram.h @@ -40,6 +40,7 @@ struct nbt_dgram_request { struct nbt_dgram_socket { struct socket_context *sock; struct event_context *event_ctx; + struct smb_iconv_convenience *iconv_convenience; /* the fd event */ struct fd_event *fde; diff --git a/source4/libcli/dgram/netlogon.c b/source4/libcli/dgram/netlogon.c index 670af4ea63..5c7dedc7bb 100644 --- a/source4/libcli/dgram/netlogon.c +++ b/source4/libcli/dgram/netlogon.c @@ -41,7 +41,7 @@ NTSTATUS dgram_mailslot_netlogon_send(struct nbt_dgram_socket *dgmsock, TALLOC_CTX *tmp_ctx = talloc_new(dgmsock); ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, - lp_iconv_convenience(global_loadparm), + dgmsock->iconv_convenience, request, (ndr_push_flags_fn_t)ndr_push_nbt_netlogon_packet); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { @@ -76,7 +76,7 @@ NTSTATUS dgram_mailslot_netlogon_reply(struct nbt_dgram_socket *dgmsock, struct socket_address *dest; ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, - lp_iconv_convenience(global_loadparm), + dgmsock->iconv_convenience, reply, (ndr_push_flags_fn_t)ndr_push_nbt_netlogon_packet); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { @@ -114,7 +114,7 @@ NTSTATUS dgram_mailslot_netlogon_parse(struct dgram_mailslot_handler *dgmslot, DATA_BLOB data = dgram_mailslot_data(dgram); enum ndr_err_code ndr_err; - ndr_err = ndr_pull_struct_blob(&data, mem_ctx, lp_iconv_convenience(global_loadparm), netlogon, + ndr_err = ndr_pull_struct_blob(&data, mem_ctx, dgmslot->dgmsock->iconv_convenience, netlogon, (ndr_pull_flags_fn_t)ndr_pull_nbt_netlogon_packet); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { NTSTATUS status = ndr_map_error2ntstatus(ndr_err); diff --git a/source4/libcli/dgram/ntlogon.c b/source4/libcli/dgram/ntlogon.c index 98aad1af8c..7b26ed7c00 100644 --- a/source4/libcli/dgram/ntlogon.c +++ b/source4/libcli/dgram/ntlogon.c @@ -41,7 +41,7 @@ NTSTATUS dgram_mailslot_ntlogon_send(struct nbt_dgram_socket *dgmsock, DATA_BLOB blob; TALLOC_CTX *tmp_ctx = talloc_new(dgmsock); - ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, lp_iconv_convenience(global_loadparm), + ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, dgmsock->iconv_convenience, request, (ndr_push_flags_fn_t)ndr_push_nbt_ntlogon_packet); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { @@ -75,7 +75,7 @@ NTSTATUS dgram_mailslot_ntlogon_reply(struct nbt_dgram_socket *dgmsock, struct nbt_name myname; struct socket_address *dest; - ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, lp_iconv_convenience(global_loadparm), reply, + ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, dgmsock->iconv_convenience, reply, (ndr_push_flags_fn_t)ndr_push_nbt_ntlogon_packet); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { talloc_free(tmp_ctx); @@ -113,7 +113,7 @@ NTSTATUS dgram_mailslot_ntlogon_parse(struct dgram_mailslot_handler *dgmslot, DATA_BLOB data = dgram_mailslot_data(dgram); enum ndr_err_code ndr_err; - ndr_err = ndr_pull_struct_blob(&data, mem_ctx, lp_iconv_convenience(global_loadparm), ntlogon, + ndr_err = ndr_pull_struct_blob(&data, mem_ctx, dgmslot->dgmsock->iconv_convenience, ntlogon, (ndr_pull_flags_fn_t)ndr_pull_nbt_ntlogon_packet); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { NTSTATUS status = ndr_map_error2ntstatus(ndr_err); diff --git a/source4/libcli/nbt/nbtname.c b/source4/libcli/nbt/nbtname.c index 142dad0296..ae9f3f6b05 100644 --- a/source4/libcli/nbt/nbtname.c +++ b/source4/libcli/nbt/nbtname.c @@ -381,11 +381,11 @@ _PUBLIC_ NTSTATUS nbt_name_dup(TALLOC_CTX *mem_ctx, struct nbt_name *name, struc /** push a nbt name into a blob */ -_PUBLIC_ NTSTATUS nbt_name_to_blob(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, struct nbt_name *name) +_PUBLIC_ NTSTATUS nbt_name_to_blob(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, DATA_BLOB *blob, struct nbt_name *name) { enum ndr_err_code ndr_err; - ndr_err = ndr_push_struct_blob(blob, mem_ctx, lp_iconv_convenience(global_loadparm), name, (ndr_push_flags_fn_t)ndr_push_nbt_name); + ndr_err = ndr_push_struct_blob(blob, mem_ctx, iconv_convenience, name, (ndr_push_flags_fn_t)ndr_push_nbt_name); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { return ndr_map_error2ntstatus(ndr_err); } diff --git a/source4/libcli/raw/clitransport.c b/source4/libcli/raw/clitransport.c index 288f0612de..5c14e9f9b8 100644 --- a/source4/libcli/raw/clitransport.c +++ b/source4/libcli/raw/clitransport.c @@ -164,14 +164,15 @@ struct smbcli_request *smbcli_transport_connect_send(struct smbcli_transport *tr DATA_BLOB calling_blob, called_blob; TALLOC_CTX *tmp_ctx = talloc_new(transport); NTSTATUS status; + struct smb_iconv_convenience *iconv_convenience = lp_iconv_convenience(global_loadparm); status = nbt_name_dup(transport, called, &transport->called); if (!NT_STATUS_IS_OK(status)) goto failed; - status = nbt_name_to_blob(tmp_ctx, &calling_blob, calling); + status = nbt_name_to_blob(tmp_ctx, iconv_convenience, &calling_blob, calling); if (!NT_STATUS_IS_OK(status)) goto failed; - status = nbt_name_to_blob(tmp_ctx, &called_blob, called); + status = nbt_name_to_blob(tmp_ctx, iconv_convenience, &called_blob, called); if (!NT_STATUS_IS_OK(status)) goto failed; /* allocate output buffer */ diff --git a/source4/libcli/smb_composite/fetchfile.c b/source4/libcli/smb_composite/fetchfile.c index c7d02e323c..e4312794c9 100644 --- a/source4/libcli/smb_composite/fetchfile.c +++ b/source4/libcli/smb_composite/fetchfile.c @@ -147,8 +147,8 @@ struct composite_context *smb_composite_fetchfile_send(struct smb_composite_fetc state->connect->in.fallback_to_anonymous = false; state->connect->in.workgroup = io->in.workgroup; - lp_smbcli_options(global_loadparm, &state->connect->in.options); - + state->connect->in.options = io->in.options; + state->creq = smb_composite_connect_send(state->connect, state, lp_resolve_context(global_loadparm), event_ctx); if (state->creq == NULL) goto failed; diff --git a/source4/libcli/smb_composite/smb_composite.h b/source4/libcli/smb_composite/smb_composite.h index a732617f80..964ffb0936 100644 --- a/source4/libcli/smb_composite/smb_composite.h +++ b/source4/libcli/smb_composite/smb_composite.h @@ -55,6 +55,7 @@ struct smb_composite_fetchfile { struct cli_credentials *credentials; const char *workgroup; const char *filename; + struct smbcli_options options; } in; struct { uint8_t *data; diff --git a/source4/torture/raw/composite.c b/source4/torture/raw/composite.c index 0367110ddc..7238a2fd46 100644 --- a/source4/torture/raw/composite.c +++ b/source4/torture/raw/composite.c @@ -161,6 +161,7 @@ static bool test_fetchfile(struct smbcli_state *cli, struct torture_context *tct io2.in.credentials = cmdline_credentials; io2.in.workgroup = lp_workgroup(tctx->lp_ctx); io2.in.filename = fname; + lp_smbcli_options(tctx->lp_ctx, &io2.in.options); printf("testing parallel fetchfile with %d ops\n", torture_numops); -- cgit From d9f8232c34a695df04a5240e270dd7ffc3101c0e Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 21 Feb 2008 15:21:45 +0100 Subject: Remove more uses of global_loadparm. (This used to be commit 230355d2e6e27918dff40823eb238904c7a1870e) --- source4/kdc/hdb-ldb.c | 3 ++- source4/kdc/kdc.h | 1 + source4/kdc/pac-glue.c | 8 +++----- source4/ntvfs/posix/pvfs_rename.c | 14 ++++++++------ source4/ntvfs/posix/pvfs_resolve.c | 5 +++-- source4/torture/basic/utable.c | 6 +++--- source4/torture/rap/rap.c | 14 +++++++------- 7 files changed, 27 insertions(+), 24 deletions(-) diff --git a/source4/kdc/hdb-ldb.c b/source4/kdc/hdb-ldb.c index d8877655c9..2143d26cde 100644 --- a/source4/kdc/hdb-ldb.c +++ b/source4/kdc/hdb-ldb.c @@ -430,6 +430,7 @@ static krb5_error_code LDB_message2entry(krb5_context context, HDB *db, } private->entry_ex = entry_ex; + private->iconv_convenience = lp_iconv_convenience(lp_ctx); talloc_set_destructor(private, hdb_ldb_destrutor); @@ -546,7 +547,7 @@ static krb5_error_code LDB_message2entry(krb5_context context, HDB *db, entry_ex->entry.generation = NULL; /* Get keys from the db */ - ret = LDB_message2entry_keys(context, lp_iconv_convenience(lp_ctx), private, msg, userAccountControl, entry_ex); + ret = LDB_message2entry_keys(context, private->iconv_convenience, private, msg, userAccountControl, entry_ex); if (ret) { /* Could be bougus data in the entry, or out of memory */ goto out; diff --git a/source4/kdc/kdc.h b/source4/kdc/kdc.h index 9d031b8f7d..78276183c2 100644 --- a/source4/kdc/kdc.h +++ b/source4/kdc/kdc.h @@ -51,6 +51,7 @@ struct kdc_server { struct hdb_ldb_private { struct ldb_context *samdb; + struct smb_iconv_convenience *iconv_convenience; struct ldb_message *msg; struct ldb_message *realm_ref_msg; hdb_entry_ex *entry_ex; diff --git a/source4/kdc/pac-glue.c b/source4/kdc/pac-glue.c index 637f39aa74..cf55618a06 100644 --- a/source4/kdc/pac-glue.c +++ b/source4/kdc/pac-glue.c @@ -114,7 +114,6 @@ krb5_error_code samba_kdc_get_pac(void *priv, struct hdb_ldb_private *private = talloc_get_type(client->ctx, struct hdb_ldb_private); TALLOC_CTX *mem_ctx = talloc_named(private, 0, "samba_get_pac context"); unsigned int userAccountControl; - struct smb_iconv_convenience *iconv_convenience = lp_iconv_convenience(global_loadparm); if (!mem_ctx) { return ENOMEM; @@ -140,7 +139,7 @@ krb5_error_code samba_kdc_get_pac(void *priv, return ENOMEM; } - ret = make_pac(context, mem_ctx, iconv_convenience, server_info, pac); + ret = make_pac(context, mem_ctx, private->iconv_convenience, server_info, pac); talloc_free(mem_ctx); return ret; @@ -166,7 +165,6 @@ krb5_error_code samba_kdc_reget_pac(void *priv, krb5_context context, struct PAC_LOGON_INFO_CTR logon_info; union netr_Validation validation; struct auth_serversupplied_info *server_info_out; - struct smb_iconv_convenience *iconv_convenience = lp_iconv_convenience(global_loadparm); TALLOC_CTX *mem_ctx = talloc_named(private, 0, "samba_get_pac context"); @@ -193,7 +191,7 @@ krb5_error_code samba_kdc_reget_pac(void *priv, krb5_context context, return ENOMEM; } - ndr_err = ndr_pull_struct_blob(&pac_in, mem_ctx, iconv_convenience, &logon_info, + ndr_err = ndr_pull_struct_blob(&pac_in, mem_ctx, private->iconv_convenience, &logon_info, (ndr_pull_flags_fn_t)ndr_pull_PAC_LOGON_INFO_CTR); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err) || !logon_info.info) { nt_status = ndr_map_error2ntstatus(ndr_err); @@ -216,7 +214,7 @@ krb5_error_code samba_kdc_reget_pac(void *priv, krb5_context context, /* We will compleatly regenerate this pac */ krb5_pac_free(context, *pac); - ret = make_pac(context, mem_ctx, iconv_convenience, server_info_out, pac); + ret = make_pac(context, mem_ctx, private->iconv_convenience, server_info_out, pac); talloc_free(mem_ctx); return ret; diff --git a/source4/ntvfs/posix/pvfs_rename.c b/source4/ntvfs/posix/pvfs_rename.c index 3b9842db7f..ea12f49333 100644 --- a/source4/ntvfs/posix/pvfs_rename.c +++ b/source4/ntvfs/posix/pvfs_rename.c @@ -89,6 +89,7 @@ NTSTATUS pvfs_do_rename(struct pvfs_state *pvfs, const struct pvfs_filename *nam resolve a wildcard rename pattern. This works on one component of the name */ static const char *pvfs_resolve_wildcard_component(TALLOC_CTX *mem_ctx, + struct smb_iconv_convenience *iconv_convenience, const char *fname, const char *pattern) { @@ -108,16 +109,16 @@ static const char *pvfs_resolve_wildcard_component(TALLOC_CTX *mem_ctx, while (*p2) { codepoint_t c1, c2; size_t c_size1, c_size2; - c1 = next_codepoint(lp_iconv_convenience(global_loadparm), p1, &c_size1); - c2 = next_codepoint(lp_iconv_convenience(global_loadparm), p2, &c_size2); + c1 = next_codepoint(iconv_convenience, p1, &c_size1); + c2 = next_codepoint(iconv_convenience, p2, &c_size2); if (c2 == '?') { - d += push_codepoint(lp_iconv_convenience(global_loadparm), d, c1); + d += push_codepoint(iconv_convenience, d, c1); } else if (c2 == '*') { memcpy(d, p1, strlen(p1)); d += strlen(p1); break; } else { - d += push_codepoint(lp_iconv_convenience(global_loadparm), d, c2); + d += push_codepoint(iconv_convenience, d, c2); } p1 += c_size1; @@ -138,6 +139,7 @@ static const char *pvfs_resolve_wildcard(TALLOC_CTX *mem_ctx, { 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 */ @@ -165,8 +167,8 @@ static const char *pvfs_resolve_wildcard(TALLOC_CTX *mem_ctx, return NULL; } - base1 = pvfs_resolve_wildcard_component(mem_ctx, base1, base2); - ext1 = pvfs_resolve_wildcard_component(mem_ctx, ext1, ext2); + base1 = pvfs_resolve_wildcard_component(mem_ctx, iconv_convenience, base1, base2); + ext1 = pvfs_resolve_wildcard_component(mem_ctx, iconv_convenience, ext1, ext2); if (base1 == NULL || ext1 == NULL) { return NULL; } diff --git a/source4/ntvfs/posix/pvfs_resolve.c b/source4/ntvfs/posix/pvfs_resolve.c index 949fa131a4..cf74816391 100644 --- a/source4/ntvfs/posix/pvfs_resolve.c +++ b/source4/ntvfs/posix/pvfs_resolve.c @@ -336,12 +336,13 @@ static NTSTATUS pvfs_reduce_name(TALLOC_CTX *mem_ctx, const char **fname, uint_t 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; for (num_components=1, p=s; *p; p += c_size) { - c = next_codepoint(lp_iconv_convenience(global_loadparm), p, &c_size); + c = next_codepoint(iconv_convenience, p, &c_size); if (c == '\\') num_components++; } @@ -353,7 +354,7 @@ static NTSTATUS pvfs_reduce_name(TALLOC_CTX *mem_ctx, const char **fname, uint_t components[0] = s; for (i=0, p=s; *p; p += c_size) { - c = next_codepoint(lp_iconv_convenience(global_loadparm), p, &c_size); + c = next_codepoint(iconv_convenience, p, &c_size); if (c == '\\') { *p = 0; components[++i] = p+1; diff --git a/source4/torture/basic/utable.c b/source4/torture/basic/utable.c index 112cf323a1..2b222d7c6e 100644 --- a/source4/torture/basic/utable.c +++ b/source4/torture/basic/utable.c @@ -98,7 +98,7 @@ bool torture_utable(struct torture_context *tctx, } -static char *form_name(int c) +static char *form_name(struct smb_iconv_convenience *iconv_convenience, int c) { static fstring fname; uint8_t c2[4]; @@ -109,7 +109,7 @@ static char *form_name(int c) p = fname+strlen(fname); SSVAL(c2, 0, c); - len = convert_string(lp_iconv_convenience(global_loadparm), CH_UTF16, CH_UNIX, + len = convert_string(iconv_convenience, CH_UTF16, CH_UNIX, c2, 2, p, sizeof(fname)-strlen(fname)); p[len] = 0; @@ -139,7 +139,7 @@ bool torture_casetable(struct torture_context *tctx, torture_comment(tctx, "%04x (%c)\n", c, isprint(c)?c:'.'); - fname = form_name(c); + fname = form_name(lp_iconv_convenience(tctx->lp_ctx), c); fnum = smbcli_nt_create_full(cli->tree, fname, 0, #if 0 SEC_RIGHT_MAXIMUM_ALLOWED, diff --git a/source4/torture/rap/rap.c b/source4/torture/rap/rap.c index 8bdd6a8ddd..edc74ee23e 100644 --- a/source4/torture/rap/rap.c +++ b/source4/torture/rap/rap.c @@ -73,7 +73,7 @@ struct rap_call { #define RAPNDR_FLAGS (LIBNDR_FLAG_NOALIGN|LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM); -static struct rap_call *new_rap_cli_call(TALLOC_CTX *mem_ctx, uint16_t callno) +static struct rap_call *new_rap_cli_call(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, uint16_t callno) { struct rap_call *call; @@ -88,10 +88,10 @@ static struct rap_call *new_rap_cli_call(TALLOC_CTX *mem_ctx, uint16_t callno) call->paramdesc = NULL; call->datadesc = NULL; - call->ndr_push_param = ndr_push_init_ctx(mem_ctx, lp_iconv_convenience(global_loadparm)); + call->ndr_push_param = ndr_push_init_ctx(mem_ctx, iconv_convenience); call->ndr_push_param->flags = RAPNDR_FLAGS; - call->ndr_push_data = ndr_push_init_ctx(mem_ctx, lp_iconv_convenience(global_loadparm)); + call->ndr_push_data = ndr_push_init_ctx(mem_ctx, iconv_convenience); call->ndr_push_data->flags = RAPNDR_FLAGS; return call; @@ -253,7 +253,7 @@ static NTSTATUS smbcli_rap_netshareenum(struct smbcli_tree *tree, NTSTATUS result = NT_STATUS_UNSUCCESSFUL; int i; - call = new_rap_cli_call(tree, RAP_WshareEnum); + call = new_rap_cli_call(tree, iconv_convenience, RAP_WshareEnum); if (call == NULL) return NT_STATUS_NO_MEMORY; @@ -345,7 +345,7 @@ static NTSTATUS smbcli_rap_netserverenum2(struct smbcli_tree *tree, NTSTATUS result = NT_STATUS_UNSUCCESSFUL; int i; - call = new_rap_cli_call(mem_ctx, RAP_NetServerEnum2); + call = new_rap_cli_call(mem_ctx, iconv_convenience, RAP_NetServerEnum2); if (call == NULL) return NT_STATUS_NO_MEMORY; @@ -451,7 +451,7 @@ _PUBLIC_ NTSTATUS smbcli_rap_netservergetinfo(struct smbcli_tree *tree, struct rap_call *call; NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - if (!(call = new_rap_cli_call(mem_ctx, RAP_WserverGetInfo))) { + if (!(call = new_rap_cli_call(mem_ctx, iconv_convenience, RAP_WserverGetInfo))) { return NT_STATUS_NO_MEMORY; } @@ -524,7 +524,7 @@ bool torture_rap_scan(struct torture_context *torture, struct smbcli_state *cli) int callno; for (callno = 0; callno < 0xffff; callno++) { - struct rap_call *call = new_rap_cli_call(torture, callno); + struct rap_call *call = new_rap_cli_call(torture, lp_iconv_convenience(torture->lp_ctx), callno); NTSTATUS result; result = rap_cli_do_call(cli->tree, lp_iconv_convenience(torture->lp_ctx), call); -- cgit From ede79ae482b16c3cea65d3019bc1a68f07354e89 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 21 Feb 2008 15:38:35 +0100 Subject: Remove more uses of global_loadparm. (This used to be commit 58a5b1de2b093fe642eb11d76d12db0edf60c25c) --- source4/lib/util/ms_fnmatch.c | 15 ++++++++------- source4/ntvfs/posix/pvfs_shortname.c | 6 +++++- source4/torture/rpc/samba3rpc.c | 18 +++++++++++------- source4/torture/rpc/samlogon.c | 11 +++++++---- 4 files changed, 31 insertions(+), 19 deletions(-) diff --git a/source4/lib/util/ms_fnmatch.c b/source4/lib/util/ms_fnmatch.c index 1fb57b07a4..5e04ec1f4b 100644 --- a/source4/lib/util/ms_fnmatch.c +++ b/source4/lib/util/ms_fnmatch.c @@ -64,8 +64,9 @@ static int ms_fnmatch_core(const char *p, const char *n, codepoint_t c, c2; int i; size_t size, size_n; + struct smb_iconv_convenience *iconv_convenience = lp_iconv_convenience(global_loadparm); - while ((c = next_codepoint(lp_iconv_convenience(global_loadparm), p, &size))) { + while ((c = next_codepoint(iconv_convenience, p, &size))) { p += size; switch (c) { @@ -75,7 +76,7 @@ static int ms_fnmatch_core(const char *p, const char *n, return null_match(p); } for (i=0; n[i]; i += size_n) { - next_codepoint(lp_iconv_convenience(global_loadparm), n+i, &size_n); + next_codepoint(iconv_convenience, n+i, &size_n); if (ms_fnmatch_core(p, n+i, max_n+1, ldot) == 0) { return 0; } @@ -94,7 +95,7 @@ static int ms_fnmatch_core(const char *p, const char *n, return -1; } for (i=0; n[i]; i += size_n) { - next_codepoint(lp_iconv_convenience(global_loadparm), n+i, &size_n); + next_codepoint(iconv_convenience, n+i, &size_n); if (ms_fnmatch_core(p, n+i, max_n+1, ldot) == 0) return 0; if (n+i == ldot) { if (ms_fnmatch_core(p, n+i+size_n, max_n+1, ldot) == 0) return 0; @@ -110,7 +111,7 @@ static int ms_fnmatch_core(const char *p, const char *n, if (! *n) { return -1; } - next_codepoint(lp_iconv_convenience(global_loadparm), n, &size_n); + next_codepoint(iconv_convenience, n, &size_n); n += size_n; break; @@ -124,7 +125,7 @@ static int ms_fnmatch_core(const char *p, const char *n, break; } if (! *n) return null_match(p); - next_codepoint(lp_iconv_convenience(global_loadparm), n, &size_n); + next_codepoint(iconv_convenience, n, &size_n); n += size_n; break; @@ -134,12 +135,12 @@ static int ms_fnmatch_core(const char *p, const char *n, return 0; } if (*n != '.') return -1; - next_codepoint(lp_iconv_convenience(global_loadparm), n, &size_n); + next_codepoint(iconv_convenience, n, &size_n); n += size_n; break; default: - c2 = next_codepoint(lp_iconv_convenience(global_loadparm), n, &size_n); + c2 = next_codepoint(iconv_convenience, n, &size_n); if (c != c2 && codepoint_cmpi(c, c2) != 0) { return -1; } diff --git a/source4/ntvfs/posix/pvfs_shortname.c b/source4/ntvfs/posix/pvfs_shortname.c index 083a281819..923887debd 100644 --- a/source4/ntvfs/posix/pvfs_shortname.c +++ b/source4/ntvfs/posix/pvfs_shortname.c @@ -104,6 +104,8 @@ struct pvfs_mangle_context { /* this is used to reverse the base 36 mapping */ unsigned char base_reverse[256]; + + struct smb_iconv_convenience *iconv_convenience; }; @@ -388,7 +390,7 @@ static bool is_legal_name(struct pvfs_mangle_context *ctx, const char *name) { while (*name) { size_t c_size; - codepoint_t c = next_codepoint(lp_iconv_convenience(global_loadparm), name, &c_size); + codepoint_t c = next_codepoint(ctx->iconv_convenience, name, &c_size); if (c == INVALID_CODEPOINT) { return false; } @@ -613,6 +615,8 @@ NTSTATUS pvfs_mangle_init(struct pvfs_state *pvfs) return NT_STATUS_NO_MEMORY; } + ctx->iconv_convenience = lp_iconv_convenience(pvfs->ntvfs->ctx->lp_ctx); + /* by default have a max of 512 entries in the cache. */ ctx->cache_size = lp_parm_int(pvfs->ntvfs->ctx->lp_ctx, NULL, "mangle", "cachesize", 512); diff --git a/source4/torture/rpc/samba3rpc.c b/source4/torture/rpc/samba3rpc.c index f62fa8742b..9e46993bad 100644 --- a/source4/torture/rpc/samba3rpc.c +++ b/source4/torture/rpc/samba3rpc.c @@ -2355,7 +2355,7 @@ static NTSTATUS get_servername(TALLOC_CTX *mem_ctx, struct smbcli_tree *tree, memcpy(servername, r.out.info.info0.name, 16); servername[16] = '\0'; - if (pull_ascii_talloc(mem_ctx, lp_iconv_convenience(global_loadparm), + if (pull_ascii_talloc(mem_ctx, iconv_convenience, name, servername) < 0) { return NT_STATUS_NO_MEMORY; } @@ -3067,6 +3067,7 @@ static NTSTATUS get_shareinfo(TALLOC_CTX *mem_ctx, static NTSTATUS get_hklm_handle(TALLOC_CTX *mem_ctx, struct smbcli_state *cli, + struct smb_iconv_convenience *iconv_convenience, struct dcerpc_pipe **pipe_p, struct policy_handle **handle) { @@ -3084,7 +3085,7 @@ static NTSTATUS get_hklm_handle(TALLOC_CTX *mem_ctx, if (!(p = dcerpc_pipe_init(result, cli->transport->socket->event.ctx, - lp_iconv_convenience(global_loadparm)))) { + iconv_convenience))) { status = NT_STATUS_NO_MEMORY; goto fail; } @@ -3129,6 +3130,7 @@ static NTSTATUS get_hklm_handle(TALLOC_CTX *mem_ctx, } static NTSTATUS torture_samba3_createshare(struct smbcli_state *cli, + struct smb_iconv_convenience *iconv_convenience, const char *sharename) { struct dcerpc_pipe *p; @@ -3143,7 +3145,7 @@ static NTSTATUS torture_samba3_createshare(struct smbcli_state *cli, mem_ctx = talloc_new(cli); NT_STATUS_HAVE_NO_MEMORY(mem_ctx); - status = get_hklm_handle(mem_ctx, cli, &p, &hklm); + status = get_hklm_handle(mem_ctx, cli, iconv_convenience, &p, &hklm); if (!NT_STATUS_IS_OK(status)) { d_printf("get_hklm_handle failed: %s\n", nt_errstr(status)); goto fail; @@ -3200,7 +3202,8 @@ static NTSTATUS torture_samba3_deleteshare(struct torture_context *torture, mem_ctx = talloc_new(cli); NT_STATUS_HAVE_NO_MEMORY(mem_ctx); - status = get_hklm_handle(cli, cli, &p, &hklm); + status = get_hklm_handle(cli, cli, lp_iconv_convenience(torture->lp_ctx), + &p, &hklm); if (!NT_STATUS_IS_OK(status)) { d_printf("get_hklm_handle failed: %s\n", nt_errstr(status)); goto fail; @@ -3227,6 +3230,7 @@ static NTSTATUS torture_samba3_deleteshare(struct torture_context *torture, } static NTSTATUS torture_samba3_setconfig(struct smbcli_state *cli, + struct loadparm_context *lp_ctx, const char *sharename, const char *parameter, const char *value) @@ -3239,7 +3243,7 @@ static NTSTATUS torture_samba3_setconfig(struct smbcli_state *cli, DATA_BLOB val; NTSTATUS status; - status = get_hklm_handle(cli, cli, &p, &hklm); + status = get_hklm_handle(cli, cli, lp_iconv_convenience(lp_ctx), &p, &hklm); if (!NT_STATUS_IS_OK(status)) { d_printf("get_hklm_handle failed: %s\n", nt_errstr(status)); return status;; @@ -3299,14 +3303,14 @@ bool torture_samba3_regconfig(struct torture_context *torture) return false; } - status = torture_samba3_createshare(cli, "blubber"); + status = torture_samba3_createshare(cli, lp_iconv_convenience(torture->lp_ctx), "blubber"); if (!NT_STATUS_IS_OK(status)) { torture_warning(torture, "torture_samba3_createshare failed: " "%s\n", nt_errstr(status)); goto done; } - status = torture_samba3_setconfig(cli, "blubber", "comment", comment); + status = torture_samba3_setconfig(cli, torture->lp_ctx, "blubber", "comment", comment); if (!NT_STATUS_IS_OK(status)) { torture_warning(torture, "torture_samba3_setconfig failed: " "%s\n", nt_errstr(status)); diff --git a/source4/torture/rpc/samlogon.c b/source4/torture/rpc/samlogon.c index 7fd5199908..89352ba8c4 100644 --- a/source4/torture/rpc/samlogon.c +++ b/source4/torture/rpc/samlogon.c @@ -64,6 +64,7 @@ struct samlogon_state { NTSTATUS expected_error; bool old_password; /* Allow an old password to be accepted or rejected without error, as well as session key bugs */ DATA_BLOB chall; + struct smb_iconv_convenience *iconv_convenience; }; /* @@ -1158,7 +1159,7 @@ static bool test_plaintext(struct samlogon_state *samlogon_state, enum ntlm_brea ZERO_STRUCT(user_session_key); if ((push_ucs2_talloc(samlogon_state->mem_ctx, - lp_iconv_convenience(global_loadparm), + samlogon_state->iconv_convenience, &unicodepw, samlogon_state->password)) == -1) { DEBUG(0, ("push_ucs2_allocate failed!\n")); exit(1); @@ -1169,7 +1170,7 @@ static bool test_plaintext(struct samlogon_state *samlogon_state, enum ntlm_brea password = strupper_talloc(samlogon_state->mem_ctx, samlogon_state->password); if ((convert_string_talloc(samlogon_state->mem_ctx, - lp_iconv_convenience(global_loadparm), + samlogon_state->iconv_convenience, CH_UNIX, CH_DOS, password, strlen(password)+1, (void**)&dospw)) == -1) { @@ -1310,6 +1311,7 @@ static const struct ntlm_tests { try a netlogon SamLogon */ static bool test_SamLogon(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, + struct torture_context *tctx, struct creds_CredentialState *creds, const char *comment, const char *account_domain, const char *account_name, @@ -1340,6 +1342,7 @@ static bool test_SamLogon(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, samlogon_state.chall = data_blob_talloc(fn_ctx, NULL, 8); samlogon_state.parameter_control = parameter_control; samlogon_state.old_password = old_password; + samlogon_state.iconv_convenience = lp_iconv_convenience(tctx->lp_ctx); generate_random_buffer(samlogon_state.chall.data, 8); samlogon_state.r_flags.in.server_name = talloc_asprintf(fn_ctx, "\\\\%s", dcerpc_server_name(p)); @@ -1792,7 +1795,7 @@ bool torture_rpc_samlogon(struct torture_context *torture) } if (usercreds[ci].network_login) { - if (!test_SamLogon(p, mem_ctx, creds, + if (!test_SamLogon(p, mem_ctx, torture, creds, usercreds[ci].comment, usercreds[ci].domain, usercreds[ci].username, @@ -1825,7 +1828,7 @@ bool torture_rpc_samlogon(struct torture_context *torture) } if (usercreds[0].network_login) { - if (!test_SamLogon(p, mem_ctx, creds, + if (!test_SamLogon(p, mem_ctx, torture, creds, usercreds[0].comment, usercreds[0].domain, usercreds[0].username, -- cgit From 263a77c5618daddb0c1e4f0ad0a922bca55faf0d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 21 Feb 2008 15:45:32 +0100 Subject: Remove more uses of global_loadparm. (This used to be commit a1715b1f48ba44bd94844418cc9299649aaf1a5e) --- source4/auth/auth_util.c | 2 +- source4/kdc/hdb-ldb.c | 1 + source4/kdc/kdc.h | 1 + source4/kdc/pac-glue.c | 2 +- source4/libcli/auth/smbencrypt.c | 5 +++-- source4/libcli/smb_composite/sesssetup.c | 4 ++-- source4/nsswitch/wbinfo.c | 2 +- source4/torture/rpc/netlogon.c | 2 +- source4/torture/rpc/samba3rpc.c | 3 ++- source4/torture/rpc/samlogon.c | 4 ++-- source4/torture/rpc/schannel.c | 2 +- source4/winbind/wb_pam_auth.c | 1 + 12 files changed, 17 insertions(+), 12 deletions(-) diff --git a/source4/auth/auth_util.c b/source4/auth/auth_util.c index b1f0e60507..5d2bc6bac0 100644 --- a/source4/auth/auth_util.c +++ b/source4/auth/auth_util.c @@ -144,7 +144,7 @@ NTSTATUS encrypt_user_info(TALLOC_CTX *mem_ctx, struct auth_context *auth_contex chall_blob = data_blob_talloc(mem_ctx, challenge, 8); if (lp_client_ntlmv2_auth(auth_context->lp_ctx)) { - DATA_BLOB names_blob = NTLMv2_generate_names_blob(mem_ctx, lp_netbios_name(auth_context->lp_ctx), lp_workgroup(auth_context->lp_ctx)); + DATA_BLOB names_blob = NTLMv2_generate_names_blob(mem_ctx, lp_iconv_convenience(auth_context->lp_ctx), lp_netbios_name(auth_context->lp_ctx), lp_workgroup(auth_context->lp_ctx)); DATA_BLOB lmv2_response, ntlmv2_response, lmv2_session_key, ntlmv2_session_key; if (!SMBNTLMv2encrypt_hash(user_info_temp, diff --git a/source4/kdc/hdb-ldb.c b/source4/kdc/hdb-ldb.c index 2143d26cde..ff226e5b46 100644 --- a/source4/kdc/hdb-ldb.c +++ b/source4/kdc/hdb-ldb.c @@ -431,6 +431,7 @@ static krb5_error_code LDB_message2entry(krb5_context context, HDB *db, private->entry_ex = entry_ex; private->iconv_convenience = lp_iconv_convenience(lp_ctx); + private->netbios_name = lp_netbios_name(lp_ctx); talloc_set_destructor(private, hdb_ldb_destrutor); diff --git a/source4/kdc/kdc.h b/source4/kdc/kdc.h index 78276183c2..3a1f9bd34e 100644 --- a/source4/kdc/kdc.h +++ b/source4/kdc/kdc.h @@ -55,4 +55,5 @@ struct hdb_ldb_private { struct ldb_message *msg; struct ldb_message *realm_ref_msg; hdb_entry_ex *entry_ex; + const char *netbios_name; }; diff --git a/source4/kdc/pac-glue.c b/source4/kdc/pac-glue.c index cf55618a06..a99cf6ded8 100644 --- a/source4/kdc/pac-glue.c +++ b/source4/kdc/pac-glue.c @@ -127,7 +127,7 @@ krb5_error_code samba_kdc_get_pac(void *priv, } nt_status = authsam_make_server_info(mem_ctx, private->samdb, - lp_netbios_name(global_loadparm), + private->netbios_name, private->msg, private->realm_ref_msg, data_blob(NULL, 0), diff --git a/source4/libcli/auth/smbencrypt.c b/source4/libcli/auth/smbencrypt.c index c5223db63f..cefb55e205 100644 --- a/source4/libcli/auth/smbencrypt.c +++ b/source4/libcli/auth/smbencrypt.c @@ -100,7 +100,7 @@ _PUBLIC_ bool E_deshash(const char *passwd, uint8_t p16[16]) /* Password must be converted to DOS charset - null terminated, uppercase. */ push_string(lp_iconv_convenience(global_loadparm), dospwd, passwd, sizeof(dospwd), STR_ASCII|STR_UPPER|STR_TERMINATE); - /* Only the fisrt 14 chars are considered, password need not be null terminated. */ + /* Only the first 14 chars are considered, password need not be null terminated. */ E_P16((const uint8_t *)dospwd, p16); if (strlen(dospwd) > 14) { @@ -296,12 +296,13 @@ void SMBsesskeygen_lm_sess_key(const uint8_t lm_hash[16], } DATA_BLOB NTLMv2_generate_names_blob(TALLOC_CTX *mem_ctx, + struct smb_iconv_convenience *iconv_convenience, const char *hostname, const char *domain) { DATA_BLOB names_blob = data_blob_talloc(mem_ctx, NULL, 0); - msrpc_gen(mem_ctx, lp_iconv_convenience(global_loadparm), &names_blob, + msrpc_gen(mem_ctx, iconv_convenience, &names_blob, "aaa", NTLMSSP_NAME_TYPE_DOMAIN, domain, NTLMSSP_NAME_TYPE_SERVER, hostname, diff --git a/source4/libcli/smb_composite/sesssetup.c b/source4/libcli/smb_composite/sesssetup.c index ce7bcc143e..f5a976958d 100644 --- a/source4/libcli/smb_composite/sesssetup.c +++ b/source4/libcli/smb_composite/sesssetup.c @@ -223,7 +223,7 @@ static NTSTATUS session_setup_nt1(struct composite_context *c, NTSTATUS nt_status; struct sesssetup_state *state = talloc_get_type(c->private_data, struct sesssetup_state); const char *password = cli_credentials_get_password(io->in.credentials); - DATA_BLOB names_blob = NTLMv2_generate_names_blob(state, session->transport->socket->hostname, lp_workgroup(global_loadparm)); + 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)) { @@ -290,7 +290,7 @@ static NTSTATUS session_setup_old(struct composite_context *c, NTSTATUS nt_status; struct sesssetup_state *state = talloc_get_type(c->private_data, struct sesssetup_state); const char *password = cli_credentials_get_password(io->in.credentials); - DATA_BLOB names_blob = NTLMv2_generate_names_blob(state, session->transport->socket->hostname, lp_workgroup(global_loadparm)); + 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)) { diff --git a/source4/nsswitch/wbinfo.c b/source4/nsswitch/wbinfo.c index b2748833e6..7ead27939e 100644 --- a/source4/nsswitch/wbinfo.c +++ b/source4/nsswitch/wbinfo.c @@ -837,7 +837,7 @@ static bool wbinfo_auth_crap(struct loadparm_context *lp_ctx, char *username) server_chal = data_blob(request.data.auth_crap.chal, 8); /* Pretend this is a login to 'us', for blob purposes */ - names_blob = NTLMv2_generate_names_blob(mem_ctx, lp_netbios_name(lp_ctx), lp_workgroup(lp_ctx)); + names_blob = NTLMv2_generate_names_blob(mem_ctx, lp_iconv_convenience(lp_ctx), lp_netbios_name(lp_ctx), lp_workgroup(lp_ctx)); if (!SMBNTLMv2encrypt(mem_ctx, name_user, name_domain, pass, &server_chal, &names_blob, diff --git a/source4/torture/rpc/netlogon.c b/source4/torture/rpc/netlogon.c index a13172b695..5b92ce1382 100644 --- a/source4/torture/rpc/netlogon.c +++ b/source4/torture/rpc/netlogon.c @@ -532,7 +532,7 @@ bool test_netlogon_ops(struct dcerpc_pipe *p, struct torture_context *tctx, chal = data_blob_const(ninfo.challenge, sizeof(ninfo.challenge)); - names_blob = NTLMv2_generate_names_blob(tctx, cli_credentials_get_workstation(credentials), + names_blob = NTLMv2_generate_names_blob(tctx, lp_iconv_convenience(tctx->lp_ctx), cli_credentials_get_workstation(credentials), cli_credentials_get_domain(credentials)); status = cli_credentials_get_ntlm_response(cmdline_credentials, tctx, diff --git a/source4/torture/rpc/samba3rpc.c b/source4/torture/rpc/samba3rpc.c index 9e46993bad..1386f61c2b 100644 --- a/source4/torture/rpc/samba3rpc.c +++ b/source4/torture/rpc/samba3rpc.c @@ -985,7 +985,8 @@ static bool schan(struct smbcli_state *cli, generate_random_buffer(chal.data, chal.length); names_blob = NTLMv2_generate_names_blob( - mem_ctx, cli_credentials_get_workstation(user_creds), + mem_ctx, lp_iconv_convenience(lp_ctx), + cli_credentials_get_workstation(user_creds), cli_credentials_get_domain(user_creds)); status = cli_credentials_get_ntlm_response( user_creds, mem_ctx, &flags, chal, names_blob, diff --git a/source4/torture/rpc/samlogon.c b/source4/torture/rpc/samlogon.c index 89352ba8c4..aba7147716 100644 --- a/source4/torture/rpc/samlogon.c +++ b/source4/torture/rpc/samlogon.c @@ -592,7 +592,7 @@ static bool test_lmv2_ntlmv2_broken(struct samlogon_state *samlogon_state, DATA_BLOB lmv2_response = data_blob(NULL, 0); DATA_BLOB lmv2_session_key = data_blob(NULL, 0); DATA_BLOB ntlmv2_session_key = data_blob(NULL, 0); - DATA_BLOB names_blob = NTLMv2_generate_names_blob(samlogon_state->mem_ctx, TEST_MACHINE_NAME, lp_workgroup(global_loadparm)); + DATA_BLOB names_blob = NTLMv2_generate_names_blob(samlogon_state->mem_ctx, samlogon_state->iconv_convenience, TEST_MACHINE_NAME, lp_workgroup(global_loadparm)); uint8_t lm_session_key[8]; uint8_t user_session_key[16]; @@ -740,7 +740,7 @@ static bool test_lmv2_ntlm_broken(struct samlogon_state *samlogon_state, DATA_BLOB lmv2_response = data_blob(NULL, 0); DATA_BLOB lmv2_session_key = data_blob(NULL, 0); DATA_BLOB ntlmv2_session_key = data_blob(NULL, 0); - DATA_BLOB names_blob = NTLMv2_generate_names_blob(samlogon_state->mem_ctx, lp_netbios_name(global_loadparm), lp_workgroup(global_loadparm)); + DATA_BLOB names_blob = NTLMv2_generate_names_blob(samlogon_state->mem_ctx, samlogon_state->iconv_convenience, lp_netbios_name(global_loadparm), lp_workgroup(global_loadparm)); DATA_BLOB ntlm_response = data_blob_talloc(samlogon_state->mem_ctx, NULL, 24); DATA_BLOB ntlm_session_key = data_blob_talloc(samlogon_state->mem_ctx, NULL, 16); diff --git a/source4/torture/rpc/schannel.c b/source4/torture/rpc/schannel.c index cb9b8be2c9..5a91366980 100644 --- a/source4/torture/rpc/schannel.c +++ b/source4/torture/rpc/schannel.c @@ -64,7 +64,7 @@ bool test_netlogon_ex_ops(struct dcerpc_pipe *p, struct torture_context *tctx, chal = data_blob_const(ninfo.challenge, sizeof(ninfo.challenge)); - names_blob = NTLMv2_generate_names_blob(tctx, cli_credentials_get_workstation(credentials), + names_blob = NTLMv2_generate_names_blob(tctx, lp_iconv_convenience(tctx->lp_ctx), cli_credentials_get_workstation(credentials), cli_credentials_get_domain(credentials)); status = cli_credentials_get_ntlm_response(cmdline_credentials, tctx, diff --git a/source4/winbind/wb_pam_auth.c b/source4/winbind/wb_pam_auth.c index a34f3fbdd0..0073e3fdf8 100644 --- a/source4/winbind/wb_pam_auth.c +++ b/source4/winbind/wb_pam_auth.c @@ -258,6 +258,7 @@ struct composite_context *wb_cmd_pam_auth_send(TALLOC_CTX *mem_ctx, names_blob = NTLMv2_generate_names_blob( mem_ctx, + lp_iconv_convenience(service->task->lp_ctx), cli_credentials_get_workstation(credentials), cli_credentials_get_domain(credentials)); -- cgit From e36b159e8c3d8b41823c09a612938cbf1b6e544b Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 21 Feb 2008 15:51:40 +0100 Subject: ldb_sqlite: fix the build metze (This used to be commit 14c8e3101cc3b0138a551afdf3a94f4bb11bb21d) --- source4/lib/ldb/config.mk | 1 - source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/source4/lib/ldb/config.mk b/source4/lib/ldb/config.mk index 6027acd0c7..d6980f341a 100644 --- a/source4/lib/ldb/config.mk +++ b/source4/lib/ldb/config.mk @@ -99,7 +99,6 @@ OBJ_FILES = modules/skel.o SUBSYSTEM = LIBLDB CFLAGS = -Ilib/ldb/include PRIVATE_DEPENDENCIES = LIBTALLOC SQLITE3 LIBTALLOC -INIT_FUNCTION = &ldb_sqlite3_module_ops OBJ_FILES = \ ldb_sqlite3/ldb_sqlite3.o # End MODULE ldb_sqlite3 diff --git a/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c b/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c index 214e7eec5f..8742e257f3 100644 --- a/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c +++ b/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c @@ -1903,7 +1903,7 @@ failed: return -1; } -_PUBLIC_ const struct ldb_backend_ops ldb_sqlite3_backend_ops = { +const struct ldb_backend_ops ldb_sqlite3_backend_ops = { .name = "sqlite3", .connect_fn = lsqlite3_connect }; -- cgit From 141f4b8f838f750b979eeef11743244008bfa339 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 21 Feb 2008 15:54:31 +0100 Subject: selftest: fix --socket-wrapper-pcap metze (This used to be commit f5ff4a571cdf7d00d065f4a4996880020f1f459f) --- source4/selftest/selftest.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source4/selftest/selftest.pl b/source4/selftest/selftest.pl index aa4423c7e2..73d03f3d4c 100755 --- a/source4/selftest/selftest.pl +++ b/source4/selftest/selftest.pl @@ -204,7 +204,7 @@ sub getlog_env($); sub setup_pcap($) { - my ($state, $name) = @_; + my ($name) = @_; return unless ($opt_socket_wrapper_pcap); return unless defined($ENV{SOCKET_WRAPPER_PCAP_DIR}); -- cgit From 48307b54f95395fbd201d92d738b482f80cd15ef Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 21 Feb 2008 16:01:19 +0100 Subject: Remove more uses of global_loadparm. (This used to be commit 3430cc60972b94d0d238bc39f473feed96949c5d) --- source4/lib/registry/patchfile.c | 4 +++- source4/lib/registry/patchfile_dotreg.c | 10 ++++++++-- source4/lib/registry/registry.h | 7 +++---- source4/lib/registry/tests/generic.c | 14 +++++++------- source4/lib/registry/tools/regshell.c | 7 ++++--- source4/lib/registry/tools/regtree.c | 2 +- source4/lib/registry/util.c | 18 ++++++++++++------ source4/torture/rpc/samba3rpc.c | 3 ++- 8 files changed, 40 insertions(+), 25 deletions(-) diff --git a/source4/lib/registry/patchfile.c b/source4/lib/registry/patchfile.c index fa1367bbd2..a4579010cd 100644 --- a/source4/lib/registry/patchfile.c +++ b/source4/lib/registry/patchfile.c @@ -23,6 +23,7 @@ #include "lib/registry/patchfile.h" #include "lib/registry/registry.h" #include "system/filesys.h" +#include "param/param.h" _PUBLIC_ WERROR reg_preg_diff_load(int fd, @@ -30,6 +31,7 @@ _PUBLIC_ WERROR reg_preg_diff_load(int fd, void *callback_data); _PUBLIC_ WERROR reg_dotreg_diff_load(int fd, + struct smb_iconv_convenience *iconv_convenience, const struct reg_diff_callbacks *callbacks, void *callback_data); @@ -306,7 +308,7 @@ _PUBLIC_ WERROR reg_diff_load(const char *filename, return reg_preg_diff_load(fd, callbacks, callback_data); } else { /* Must be a normal .REG file */ - return reg_dotreg_diff_load(fd, callbacks, callback_data); + return reg_dotreg_diff_load(fd, lp_iconv_convenience(global_loadparm), callbacks, callback_data); } } diff --git a/source4/lib/registry/patchfile_dotreg.c b/source4/lib/registry/patchfile_dotreg.c index ebcafc92af..46ea7c0008 100644 --- a/source4/lib/registry/patchfile_dotreg.c +++ b/source4/lib/registry/patchfile_dotreg.c @@ -26,6 +26,7 @@ #include "lib/registry/patchfile.h" #include "lib/registry/registry.h" #include "system/filesys.h" +#include "param/param.h" /** * @file @@ -36,6 +37,7 @@ struct dotreg_data { int fd; + struct smb_iconv_convenience *iconv_convenience; }; static WERROR reg_dotreg_diff_add_key(void *_data, const char *key_name) @@ -64,7 +66,7 @@ static WERROR reg_dotreg_diff_set_value(void *_data, const char *path, fdprintf(data->fd, "\"%s\"=%s:%s\n", value_name, str_regtype(value_type), - reg_val_data_string(NULL, value_type, value)); + reg_val_data_string(NULL, data->iconv_convenience, value_type, value)); return WERR_OK; } @@ -107,6 +109,8 @@ _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); + if (filename) { data->fd = open(filename, O_CREAT, 0755); if (data->fd == -1) { @@ -135,6 +139,7 @@ _PUBLIC_ WERROR reg_dotreg_diff_save(TALLOC_CTX *ctx, const char *filename, * Load diff file */ _PUBLIC_ WERROR reg_dotreg_diff_load(int fd, + struct smb_iconv_convenience *iconv_convenience, const struct reg_diff_callbacks *callbacks, void *callback_data) { @@ -239,7 +244,8 @@ _PUBLIC_ WERROR reg_dotreg_diff_load(int fd, q++; } - reg_string_to_val(line, q?p:"REG_SZ", q?q:p, + reg_string_to_val(line, iconv_convenience, + q?p:"REG_SZ", q?q:p, &value_type, &value); error = callbacks->set_value(callback_data, curkey, line, diff --git a/source4/lib/registry/registry.h b/source4/lib/registry/registry.h index fac9180378..5e0b971a1d 100644 --- a/source4/lib/registry/registry.h +++ b/source4/lib/registry/registry.h @@ -254,11 +254,10 @@ WERROR reg_create_key(TALLOC_CTX *mem_ctx, /* Utility functions */ const char *str_regtype(int type); -char *reg_val_data_string(TALLOC_CTX *mem_ctx, uint32_t type, - const DATA_BLOB data); -char *reg_val_description(TALLOC_CTX *mem_ctx, const char *name, +char *reg_val_data_string(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, uint32_t type, const DATA_BLOB data); +char *reg_val_description(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, const char *name, uint32_t type, const DATA_BLOB data); -bool reg_string_to_val(TALLOC_CTX *mem_ctx, const char *type_str, +bool reg_string_to_val(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, const char *type_str, const char *data_str, uint32_t *type, DATA_BLOB *data); WERROR reg_open_key_abs(TALLOC_CTX *mem_ctx, struct registry_context *handle, const char *name, struct registry_key **result); diff --git a/source4/lib/registry/tests/generic.c b/source4/lib/registry/tests/generic.c index 25a89793bd..145e599504 100644 --- a/source4/lib/registry/tests/generic.c +++ b/source4/lib/registry/tests/generic.c @@ -45,7 +45,7 @@ static bool test_reg_val_data_string_dword(struct torture_context *ctx) uint32_t d = 0x20; DATA_BLOB db = { (uint8_t *)&d, sizeof(d) }; torture_assert_str_equal(ctx, "0x20", - reg_val_data_string(ctx, REG_DWORD, db), + reg_val_data_string(ctx, lp_iconv_convenience(ctx->lp_ctx), REG_DWORD, db), "dword failed"); return true; } @@ -56,11 +56,11 @@ static bool test_reg_val_data_string_sz(struct torture_context *ctx) db.length = convert_string_talloc(ctx, lp_iconv_convenience(ctx->lp_ctx), CH_UNIX, CH_UTF16, "bla", 3, (void **)&db.data); torture_assert_str_equal(ctx, "bla", - reg_val_data_string(ctx, REG_SZ, db), + reg_val_data_string(ctx, lp_iconv_convenience(ctx->lp_ctx), REG_SZ, db), "sz failed"); db.length = 4; torture_assert_str_equal(ctx, "bl", - reg_val_data_string(ctx, REG_SZ, db), + reg_val_data_string(ctx, lp_iconv_convenience(ctx->lp_ctx), REG_SZ, db), "sz failed"); return true; } @@ -70,7 +70,7 @@ static bool test_reg_val_data_string_binary(struct torture_context *ctx) uint8_t x[] = { 0x1, 0x2, 0x3, 0x4 }; DATA_BLOB db = { x, 4 }; torture_assert_str_equal(ctx, "01020304", - reg_val_data_string(ctx, REG_BINARY, db), + reg_val_data_string(ctx, lp_iconv_convenience(ctx->lp_ctx), REG_BINARY, db), "binary failed"); return true; } @@ -80,7 +80,7 @@ static bool test_reg_val_data_string_empty(struct torture_context *ctx) { DATA_BLOB db = { NULL, 0 }; torture_assert_str_equal(ctx, "", - reg_val_data_string(ctx, REG_BINARY, db), + reg_val_data_string(ctx, lp_iconv_convenience(ctx->lp_ctx), REG_BINARY, db), "empty failed"); return true; } @@ -93,7 +93,7 @@ static bool test_reg_val_description(struct torture_context *ctx) strlen("stationary traveller"), (void **)&data.data); torture_assert_str_equal(ctx, "camel = REG_SZ : stationary traveller", - reg_val_description(ctx, "camel", REG_SZ, data), + reg_val_description(ctx, lp_iconv_convenience(ctx->lp_ctx), "camel", REG_SZ, data), "reg_val_description failed"); return true; } @@ -107,7 +107,7 @@ static bool test_reg_val_description_nullname(struct torture_context *ctx) strlen("west berlin"), (void **)&data.data); torture_assert_str_equal(ctx, " = REG_SZ : west berlin", - reg_val_description(ctx, NULL, REG_SZ, data), + reg_val_description(ctx, lp_iconv_convenience(ctx->lp_ctx), NULL, REG_SZ, data), "description with null name failed"); return true; } diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index d5c506ab31..58f64cb049 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -141,7 +141,8 @@ static WERROR cmd_set(struct regshell_context *ctx, int argc, char **argv) return WERR_INVALID_PARAM; } - if (!reg_string_to_val(ctx, argv[2], argv[3], &val.data_type, + if (!reg_string_to_val(ctx, lp_iconv_convenience(cmdline_lp_ctx), + argv[2], argv[3], &val.data_type, &val.data)) { fprintf(stderr, "Unable to interpret data\n"); return WERR_INVALID_PARAM; @@ -199,7 +200,7 @@ static WERROR cmd_print(struct regshell_context *ctx, int argc, char **argv) } printf("%s\n%s\n", str_regtype(value_type), - reg_val_data_string(ctx, value_type, value_data)); + reg_val_data_string(ctx, lp_iconv_convenience(cmdline_lp_ctx), value_type, value_data)); return WERR_OK; } @@ -233,7 +234,7 @@ static WERROR cmd_ls(struct regshell_context *ctx, int argc, char **argv) &data_type, &data)); i++) { printf("V \"%s\" %s %s\n", name, str_regtype(data_type), - reg_val_data_string(ctx, data_type, data)); + reg_val_data_string(ctx, lp_iconv_convenience(cmdline_lp_ctx), data_type, data)); } return WERR_OK; diff --git a/source4/lib/registry/tools/regtree.c b/source4/lib/registry/tools/regtree.c index 0f47d8f8dd..424d3515e0 100644 --- a/source4/lib/registry/tools/regtree.c +++ b/source4/lib/registry/tools/regtree.c @@ -82,7 +82,7 @@ static void print_tree(int level, struct registry_key *p, int j; char *desc; for(j = 0; j < level+1; j++) putchar(' '); - desc = reg_val_description(mem_ctx, valuename, + desc = reg_val_description(mem_ctx, lp_iconv_convenience(cmdline_lp_ctx), valuename, value_type, value_data); printf("%s\n", desc); } diff --git a/source4/lib/registry/util.c b/source4/lib/registry/util.c index a251ae49a5..68efd56a86 100644 --- a/source4/lib/registry/util.c +++ b/source4/lib/registry/util.c @@ -51,7 +51,9 @@ _PUBLIC_ const char *str_regtype(int type) return "Unknown"; } -_PUBLIC_ char *reg_val_data_string(TALLOC_CTX *mem_ctx, uint32_t type, +_PUBLIC_ char *reg_val_data_string(TALLOC_CTX *mem_ctx, + struct smb_iconv_convenience *iconv_convenience, + uint32_t type, const DATA_BLOB data) { char *ret = NULL; @@ -62,7 +64,7 @@ _PUBLIC_ char *reg_val_data_string(TALLOC_CTX *mem_ctx, uint32_t type, switch (type) { case REG_EXPAND_SZ: case REG_SZ: - convert_string_talloc(mem_ctx, lp_iconv_convenience(global_loadparm), CH_UTF16, CH_UNIX, + convert_string_talloc(mem_ctx, iconv_convenience, CH_UTF16, CH_UNIX, data.data, data.length, (void **)&ret); return ret; @@ -85,16 +87,20 @@ _PUBLIC_ char *reg_val_data_string(TALLOC_CTX *mem_ctx, uint32_t type, } /** Generate a string that describes a registry value */ -_PUBLIC_ char *reg_val_description(TALLOC_CTX *mem_ctx, const char *name, +_PUBLIC_ char *reg_val_description(TALLOC_CTX *mem_ctx, + struct smb_iconv_convenience *iconv_convenience, + const char *name, uint32_t data_type, const DATA_BLOB data) { return talloc_asprintf(mem_ctx, "%s = %s : %s", name?name:"", str_regtype(data_type), - reg_val_data_string(mem_ctx, data_type, data)); + reg_val_data_string(mem_ctx, iconv_convenience, data_type, data)); } -_PUBLIC_ bool reg_string_to_val(TALLOC_CTX *mem_ctx, const char *type_str, +_PUBLIC_ bool reg_string_to_val(TALLOC_CTX *mem_ctx, + struct smb_iconv_convenience *iconv_convenience, + const char *type_str, const char *data_str, uint32_t *type, DATA_BLOB *data) { @@ -118,7 +124,7 @@ _PUBLIC_ bool reg_string_to_val(TALLOC_CTX *mem_ctx, const char *type_str, { case REG_SZ: case REG_EXPAND_SZ: - data->length = convert_string_talloc(mem_ctx, lp_iconv_convenience(global_loadparm), CH_UNIX, CH_UTF16, + data->length = convert_string_talloc(mem_ctx, iconv_convenience, CH_UNIX, CH_UTF16, data_str, strlen(data_str), (void **)&data->data); break; diff --git a/source4/torture/rpc/samba3rpc.c b/source4/torture/rpc/samba3rpc.c index 1386f61c2b..95252e7397 100644 --- a/source4/torture/rpc/samba3rpc.c +++ b/source4/torture/rpc/samba3rpc.c @@ -3269,7 +3269,8 @@ static NTSTATUS torture_samba3_setconfig(struct smbcli_state *cli, goto done; } - if (!reg_string_to_val(hklm, "REG_SZ", value, &type, &val)) { + if (!reg_string_to_val(hklm, lp_iconv_convenience(lp_ctx), "REG_SZ", + value, &type, &val)) { d_printf("(%s) reg_string_to_val failed\n", __location__); goto done; } -- cgit From 426e7fef1f080f22a10e89cebae58a40db8bc77f Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 21 Feb 2008 16:10:07 +0100 Subject: Remove extra whitespace, use public variable in IDL. (This used to be commit bf08b682586f6b9a17d4ec3934836be957ef955c) --- source4/lib/charset/charcnv.c | 2 +- source4/librpc/idl/drsblobs.idl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source4/lib/charset/charcnv.c b/source4/lib/charset/charcnv.c index 54a0676599..0465be689e 100644 --- a/source4/lib/charset/charcnv.c +++ b/source4/lib/charset/charcnv.c @@ -677,7 +677,7 @@ _PUBLIC_ codepoint_t next_codepoint(struct smb_iconv_convenience *ic, with codepoints above 64k */ olen = 2; outbuf = (char *)buf; - smb_iconv(descriptor, &str, &ilen, &outbuf, &olen); + smb_iconv(descriptor, &str, &ilen, &outbuf, &olen); if (olen == 2) { olen = 4; outbuf = (char *)buf; diff --git a/source4/librpc/idl/drsblobs.idl b/source4/librpc/idl/drsblobs.idl index 27f3a99551..eaea6aa30e 100644 --- a/source4/librpc/idl/drsblobs.idl +++ b/source4/librpc/idl/drsblobs.idl @@ -91,7 +91,7 @@ interface drsblobs { typedef [public,gensize,flag(NDR_PAHEX)] struct { /* this includes the 8 bytes of the repsFromToBlob header */ - [value(ndr_size_repsFromTo1(r, ndr->flags)+8)] uint32 blobsize; + [value(ndr_size_repsFromTo1(this, ndr->flags)+8)] uint32 blobsize; uint32 consecutive_sync_failures; NTTIME_1sec last_success; NTTIME_1sec last_attempt; -- cgit From 840933cd4eaca75ebb4d63928023e7d1d24f4a8c Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 21 Feb 2008 17:56:33 +0100 Subject: Try and fix getifaddrs check on irix: dont't try to include config.h The missing header file is judged "catastrophic" on irix. Michael (cherry picked from commit 5778c90819a5a5cee38be690f442c571f3a6a051) (This used to be commit 0d4522a06d4465f6eadbdf14381c9e08cf7e1dc9) --- source4/lib/replace/getifaddrs.m4 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source4/lib/replace/getifaddrs.m4 b/source4/lib/replace/getifaddrs.m4 index 4cf86d89cc..5d5edf1cbd 100644 --- a/source4/lib/replace/getifaddrs.m4 +++ b/source4/lib/replace/getifaddrs.m4 @@ -60,6 +60,7 @@ fi if test $iface = no; then AC_CACHE_CHECK([for iface AIX],libreplace_cv_HAVE_IFACE_AIX,[ AC_TRY_RUN([ +#define NO_CONFIG_H 1 #define HAVE_IFACE_AIX 1 #define AUTOCONF_TEST 1 #undef _XOPEN_SOURCE_EXTENDED @@ -74,6 +75,7 @@ fi if test $iface = no; then AC_CACHE_CHECK([for iface ifconf],libreplace_cv_HAVE_IFACE_IFCONF,[ AC_TRY_RUN([ +#define NO_CONFIG_H 1 #define HAVE_IFACE_IFCONF 1 #define AUTOCONF_TEST 1 #include "$libreplacedir/getifaddrs.c"], @@ -86,6 +88,7 @@ fi if test $iface = no; then AC_CACHE_CHECK([for iface ifreq],libreplace_cv_HAVE_IFACE_IFREQ,[ AC_TRY_RUN([ +#define NO_CONFIG_H 1 #define HAVE_IFACE_IFREQ 1 #define AUTOCONF_TEST 1 #include "$libreplacedir/getifaddrs.c"], -- cgit From c513546cda3d453748c88589b83015489fc6f14f Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 21 Feb 2008 18:16:10 +0100 Subject: libreplace: fix compile errors in getifaddrs.c Michael (cherry picked from commit 22cdd4cb507022d9c670b7d5cbc8d357b0b91637) (This used to be commit 4da2d999a28c8fd3e93480194a153cf6a10de986) --- source4/lib/replace/getifaddrs.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/source4/lib/replace/getifaddrs.c b/source4/lib/replace/getifaddrs.c index 4037d647d7..f12062bd8e 100644 --- a/source4/lib/replace/getifaddrs.c +++ b/source4/lib/replace/getifaddrs.c @@ -81,7 +81,6 @@ int rep_getifaddrs(struct ifaddrs **ifap) char buff[8192]; int fd, i, n; struct ifreq *ifr=NULL; - int total = 0; struct in_addr ipaddr; struct in_addr nmask; char *iname; @@ -106,7 +105,7 @@ int rep_getifaddrs(struct ifaddrs **ifap) n = ifc.ifc_len / sizeof(struct ifreq); /* Loop through interfaces, looking for given IP address */ - for (i=n-1;i>=0 && total < max_interfaces;i--) { + for (i=n-1; i>=0; i--) { if (ioctl(fd, SIOCGIFADDR, &ifr[i]) != 0) { freeifaddrs(*ifap); } @@ -166,11 +165,10 @@ int rep_getifaddrs(struct ifaddrs **ifap) char buff[8192]; int fd, i, n; struct ifreq *ifr=NULL; - int total = 0; struct in_addr ipaddr; struct in_addr nmask; char *iname; - struct ifaddrs *curif; + struct ifaddrs *curif, *lastif; *ifap = NULL; @@ -201,7 +199,7 @@ int rep_getifaddrs(struct ifaddrs **ifap) /* Loop through interfaces */ - for (i = 0; i Date: Fri, 22 Feb 2008 00:24:11 +0100 Subject: Add missing initalizations of lastif in rep_getifaddr implementations. Michael (cherry picked from commit 65710e752f72070cb911867ff9f31f91904ca5c0) (This used to be commit 5bd613a2cda5d287706f2ce72f4ee08a7fa45b72) --- source4/lib/replace/getifaddrs.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/source4/lib/replace/getifaddrs.c b/source4/lib/replace/getifaddrs.c index f12062bd8e..60049caa99 100644 --- a/source4/lib/replace/getifaddrs.c +++ b/source4/lib/replace/getifaddrs.c @@ -84,7 +84,8 @@ int rep_getifaddrs(struct ifaddrs **ifap) struct in_addr ipaddr; struct in_addr nmask; char *iname; - struct ifaddrs *curif, *lastif; + struct ifaddrs *curif; + struct ifaddrs *lastif = NULL; *ifap = NULL; @@ -168,7 +169,8 @@ int rep_getifaddrs(struct ifaddrs **ifap) struct in_addr ipaddr; struct in_addr nmask; char *iname; - struct ifaddrs *curif, *lastif; + struct ifaddrs *curif; + struct ifaddrs *lastif = NULL; *ifap = NULL; @@ -268,7 +270,8 @@ int rep_getifaddrs(struct ifaddrs **ifap) struct in_addr ipaddr; struct in_addr nmask; char *iname; - struct ifaddrs *curif, *lastif; + struct ifaddrs *curif; + struct ifaddrs *lastif = NULL; *ifap = NULL; -- cgit From c2f92013c3304bf49622f7e0d5658f768898a4f1 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 22 Feb 2008 00:27:00 +0100 Subject: Fix linked list of ifaddrs in implementations of rep_getifaddrs. Produce proper list instead of one-node-loop. Michael (cherry picked from commit ec9f4f5066ba7a8bf3af931fd4969590140c0b2b) (This used to be commit 744d5ba7adab65a9774a18eb42b7090f49e423f2) --- source4/lib/replace/getifaddrs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source4/lib/replace/getifaddrs.c b/source4/lib/replace/getifaddrs.c index 60049caa99..37cd950e09 100644 --- a/source4/lib/replace/getifaddrs.c +++ b/source4/lib/replace/getifaddrs.c @@ -115,7 +115,7 @@ int rep_getifaddrs(struct ifaddrs **ifap) if (lastif == NULL) { *ifap = curif; } else { - lastif->ifa_next = (*ifap); + lastif->ifa_next = curif; } curif->ifa_name = strdup(ifr[i].ifr_name); @@ -208,7 +208,7 @@ int rep_getifaddrs(struct ifaddrs **ifap) if (lastif == NULL) { *ifap = curif; } else { - lastif->ifa_next = (*ifap); + lastif->ifa_next = curif; } strioctl.ic_cmd = SIOCGIFFLAGS; @@ -306,7 +306,7 @@ int rep_getifaddrs(struct ifaddrs **ifap) if (lastif == NULL) { *ifap = curif; } else { - lastif->ifa_next = (*ifap); + lastif->ifa_next = curif; } curif->ifa_name = strdup(ifr->ifr_name); -- cgit From 88c919c14af3b5e5cb9524ce3bb778b7c7bc6c72 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 22 Feb 2008 00:34:41 +0100 Subject: libreplace: fix creation of conftest files for getifaddrs tests. Add missing includes of replace.c and defines of SOCKET_WRAPPER_NOT_REPLACE. Michael (cherry picked from commit 26e6ebc7090b5742deb67805d85d809cafb4543d) (This used to be commit e00c6513e05afe91d4c419287283b34e931a161c) --- source4/lib/replace/getifaddrs.m4 | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/source4/lib/replace/getifaddrs.m4 b/source4/lib/replace/getifaddrs.m4 index 5d5edf1cbd..dd2a95cb81 100644 --- a/source4/lib/replace/getifaddrs.m4 +++ b/source4/lib/replace/getifaddrs.m4 @@ -44,9 +44,10 @@ iface=no; iface=no; AC_CACHE_CHECK([for iface getifaddrs],libreplace_cv_HAVE_IFACE_GETIFADDRS,[ AC_TRY_RUN([ -#define NO_CONFIG_H 1 #define HAVE_IFACE_GETIFADDRS 1 +#define NO_CONFIG_H 1 #define AUTOCONF_TEST 1 +#define SOCKET_WRAPPER_NOT_REPLACE #include "$libreplacedir/replace.c" #include "$libreplacedir/getifaddrs.c"], libreplace_cv_HAVE_IFACE_GETIFADDRS=yes,libreplace_cv_HAVE_IFACE_GETIFADDRS=no,libreplace_cv_HAVE_IFACE_GETIFADDRS=cross)]) @@ -60,10 +61,12 @@ fi if test $iface = no; then AC_CACHE_CHECK([for iface AIX],libreplace_cv_HAVE_IFACE_AIX,[ AC_TRY_RUN([ -#define NO_CONFIG_H 1 #define HAVE_IFACE_AIX 1 +#define NO_CONFIG_H 1 #define AUTOCONF_TEST 1 #undef _XOPEN_SOURCE_EXTENDED +#define SOCKET_WRAPPER_NOT_REPLACE +#include "$libreplacedir/replace.c" #include "$libreplacedir/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 @@ -75,9 +78,11 @@ fi if test $iface = no; then AC_CACHE_CHECK([for iface ifconf],libreplace_cv_HAVE_IFACE_IFCONF,[ AC_TRY_RUN([ -#define NO_CONFIG_H 1 #define HAVE_IFACE_IFCONF 1 +#define NO_CONFIG_H 1 #define AUTOCONF_TEST 1 +#define SOCKET_WRAPPER_NOT_REPLACE +#include "$libreplacedir/replace.c" #include "$libreplacedir/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 @@ -88,9 +93,11 @@ fi if test $iface = no; then AC_CACHE_CHECK([for iface ifreq],libreplace_cv_HAVE_IFACE_IFREQ,[ AC_TRY_RUN([ -#define NO_CONFIG_H 1 #define HAVE_IFACE_IFREQ 1 +#define NO_CONFIG_H 1 #define AUTOCONF_TEST 1 +#define SOCKET_WRAPPER_NOT_REPLACE +#include "$libreplacedir/replace.c" #include "$libreplacedir/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 -- cgit From bf7d3b6ef440d61a8d65001f99c7526bb830f5d3 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 22 Feb 2008 10:42:22 +0100 Subject: libreplace: Fix comment originating from old samba source. Michael (This used to be commit 0440bcfe6359ca4842f473b1ca799cad9f1c6c96) --- source4/lib/replace/getifaddrs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source4/lib/replace/getifaddrs.c b/source4/lib/replace/getifaddrs.c index 37cd950e09..a6f06e545f 100644 --- a/source4/lib/replace/getifaddrs.c +++ b/source4/lib/replace/getifaddrs.c @@ -363,7 +363,7 @@ int rep_getifaddrs(struct ifaddrs **ifap) #endif #ifdef AUTOCONF_TEST -/* this is the autoconf driver to test get_interfaces() */ +/* this is the autoconf driver to test getifaddrs() */ int main() { -- cgit From 3fa76092e6cc48098f8da56452446791d09c76b5 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 22 Feb 2008 14:08:13 +0100 Subject: Happy New Year 2008! :-) metze (This used to be commit a601ecff4e8cbf71de9f140ee2faa0b75d695559) --- source4/smbd/server.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source4/smbd/server.c b/source4/smbd/server.c index dd63ca1eca..fdeb541576 100644 --- a/source4/smbd/server.c +++ b/source4/smbd/server.c @@ -253,7 +253,7 @@ static int binary_smbd_main(const char *binary_name, int argc, const char *argv[ umask(0); DEBUG(0,("%s version %s started.\n", binary_name, SAMBA_VERSION_STRING)); - DEBUGADD(0,("Copyright Andrew Tridgell and the Samba Team 1992-2007\n")); + DEBUGADD(0,("Copyright Andrew Tridgell and the Samba Team 1992-2008\n")); if (sizeof(uint16_t) < 2 || sizeof(uint32_t) < 4 || sizeof(uint64_t) < 8) { DEBUG(0,("ERROR: Samba is not configured correctly for the word size on your machine\n")); -- cgit From e9b0056586f6e57d4d1243c5622c568497e04d38 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 22 Feb 2008 13:53:05 +0100 Subject: libreplace: don't use socketwrapper for getifaddrs() implementations. Michael (cherry picked from commit 85eec1d1d6b674294c50eb912fbe7d5a1dd42909) (This used to be commit a83db886e50b6ceeb71d93bf86fb5e0964b8d45f) --- source4/lib/replace/getifaddrs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source4/lib/replace/getifaddrs.c b/source4/lib/replace/getifaddrs.c index a6f06e545f..053657475d 100644 --- a/source4/lib/replace/getifaddrs.c +++ b/source4/lib/replace/getifaddrs.c @@ -19,6 +19,8 @@ along with this program. If not, see . */ +#define SOCKET_WRAPPER_NOT_REPLACE + #include "replace.h" #include "system/network.h" -- cgit From bd95d6d5dbd27e2b904f7907ef39766159d0afcf Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 23 Feb 2008 10:26:52 +0100 Subject: Respect the return value of asprintf This removes tons of warnings warning: ignoring return value of 'fwrite', declared with attribute warn_unused_result for me. Lots of that kind left though :-) (This used to be commit ba29219ea243cc217ab3522b036a82ff8dfeedc8) --- source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm index ef3eb3dbcf..a959dc84f6 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm @@ -775,8 +775,7 @@ sub ParseElementPrint($$$$) $self->pidl("for ($counter=0;$counter<$length;$counter++) {"); $self->indent; $self->pidl("char *idx_$l->{LEVEL_INDEX}=NULL;"); - $self->pidl("asprintf(&idx_$l->{LEVEL_INDEX}, \"[\%d]\", $counter);"); - $self->pidl("if (idx_$l->{LEVEL_INDEX}) {"); + $self->pidl("if (asprintf(&idx_$l->{LEVEL_INDEX}, \"[\%d]\", $counter) != -1) {"); $self->indent; $var_name = get_array_element($var_name, $counter); -- cgit From a622f80c658bb1d0639e9ebe3a2be7093f15ffc6 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sun, 24 Feb 2008 00:13:36 +0100 Subject: BASE-DEFER_OPEN: add torture:sharedelays option to run this test faster metze (This used to be commit 877cc375d0523cb31324a5d611e73d666e7a9a78) --- source4/torture/basic/base.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/source4/torture/basic/base.c b/source4/torture/basic/base.c index aa729ec0df..42d7ddaaa1 100644 --- a/source4/torture/basic/base.c +++ b/source4/torture/basic/base.c @@ -633,6 +633,13 @@ static bool run_deferopen(struct torture_context *tctx, struct smbcli_state *cli int retries=4; int i = 0; bool correct = true; + int nsec; + int msec; + double sec; + + nsec = torture_setting_int(tctx, "sharedelay", 1000000); + msec = nsec / 1000; + sec = ((double)nsec) / ((double) 1000000); if (retries <= 0) { torture_comment(tctx, "failed to connect\n"); @@ -657,9 +664,10 @@ static bool run_deferopen(struct torture_context *tctx, struct smbcli_state *cli } if (NT_STATUS_EQUAL(smbcli_nt_error(cli->tree),NT_STATUS_SHARING_VIOLATION)) { double e = timeval_elapsed(&tv); - if (e < 0.5 || e > 1.5) { - torture_comment(tctx,"Timing incorrect %.2f violation\n", - e); + if (e < (0.5 * sec) || e > (1.5 * sec)) { + torture_comment(tctx,"Timing incorrect %.2f violation 1 sec == %.2f\n", + e, sec); + return false; } } } while (NT_STATUS_EQUAL(smbcli_nt_error(cli->tree),NT_STATUS_SHARING_VIOLATION)); @@ -671,13 +679,13 @@ static bool run_deferopen(struct torture_context *tctx, struct smbcli_state *cli torture_comment(tctx, "pid %u open %d\n", (unsigned)getpid(), i); - sleep(10); + msleep(10 * msec); i++; if (NT_STATUS_IS_ERR(smbcli_close(cli->tree, fnum))) { torture_comment(tctx,"Failed to close %s, error=%s\n", fname, smbcli_errstr(cli->tree)); return false; } - sleep(2); + msleep(2 * msec); } if (NT_STATUS_IS_ERR(smbcli_unlink(cli->tree, fname))) { -- cgit From 77054b42bdfcd077ede8a5c29aead2807f016ecc Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 25 Feb 2008 07:42:38 +0100 Subject: selftest: we pass the BASE-DEFER_OPEN test We just need to pass the same sharedelay time to smbtorture as we use for smbd. metze (This used to be commit 3b78dc7ab2f8e3faffa2eb3ae2462c133e368be3) --- source4/samba4-skip | 2 -- source4/selftest/samba4_tests.sh | 5 +++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/source4/samba4-skip b/source4/samba4-skip index e3d2b182d1..541738ecc4 100644 --- a/source4/samba4-skip +++ b/source4/samba4-skip @@ -1,4 +1,3 @@ -base.defer_open base.delaywrite raw.composite raw.oplock @@ -18,7 +17,6 @@ base.smb smb2.notify smb2.scan ntvfs.cifs.base.charset -ntvfs.cifs.base.defer_open ntvfs.cifs.base.delaywrite ntvfs.cifs.base.iometer ntvfs.cifs.base.casetable diff --git a/source4/selftest/samba4_tests.sh b/source4/selftest/samba4_tests.sh index c57ec4d6bd..32386e5b9e 100755 --- a/source4/selftest/samba4_tests.sh +++ b/source4/selftest/samba4_tests.sh @@ -216,12 +216,13 @@ done plantest "rpc.echo on ncacn_np over smb2" dc $smb4torture ncacn_np:"\$SERVER[smb2]" -U"\$USERNAME"%"\$PASSWORD" -W \$DOMAIN RPC-ECHO "$*" # Tests against the NTVFS POSIX backend +NTVFSARGS="--option=torture:sharedelay=100000" smb2=`$smb4torture --list | grep "^SMB2-" | xargs` raw=`$smb4torture --list | grep "^RAW-" | xargs` base=`$smb4torture --list | grep "^BASE-" | xargs` for t in $base $raw $smb2; do - plansmbtorturetest "$t" dc $ADDARGS //\$SERVER/tmp -U"\$USERNAME"%"\$PASSWORD" + plansmbtorturetest "$t" dc $ADDARGS //\$SERVER/tmp -U"\$USERNAME"%"\$PASSWORD" $NTVFSARGS done rap=`$smb4torture --list | grep "^RAP-" | xargs` @@ -231,7 +232,7 @@ done # Tests against the NTVFS CIFS backend for t in $base $raw; do - plantest "ntvfs.cifs.`normalize_testname $t`" dc $VALGRIND $smb4torture //\$NETBIOSNAME/cifs -U"\$USERNAME"%"\$PASSWORD" $t + plantest "ntvfs.cifs.`normalize_testname $t`" dc $VALGRIND $smb4torture //\$NETBIOSNAME/cifs -U"\$USERNAME"%"\$PASSWORD" $NTVFSARGS $t done # Local tests -- cgit From a64bd41601b9b50075e95ca50510f04cd2bb8454 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 23 Feb 2008 11:51:23 +0100 Subject: RAW-OPLOCK: fix typo (send oplock releases on the correct connection) metze (This used to be commit f6ecf59c7555917374fc9e5430034815fd4cd245) --- source4/torture/raw/oplock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source4/torture/raw/oplock.c b/source4/torture/raw/oplock.c index 952088e46c..5ece01c505 100644 --- a/source4/torture/raw/oplock.c +++ b/source4/torture/raw/oplock.c @@ -914,7 +914,7 @@ static bool test_raw_oplock_batch10(struct torture_context *tctx, struct smbcli_ CHECK_VAL(break_info.failures, 0); CHECK_VAL(io.ntcreatex.out.oplock_level, 0); - smbcli_oplock_handler(cli2->transport, oplock_handler_ack_to_levelII, cli1->tree); + smbcli_oplock_handler(cli2->transport, oplock_handler_ack_to_levelII, cli2->tree); io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | NTCREATEX_FLAGS_REQUEST_OPLOCK | -- cgit From 5dc8d3ed8b5a5e263a74f880f6fb1d88d27bd5c6 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 23 Feb 2008 11:51:43 +0100 Subject: RAW-OPLOCK: remove unused var (This used to be commit 6820da44828172769d9fdfa161acf762e3937a88) --- source4/torture/raw/oplock.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/source4/torture/raw/oplock.c b/source4/torture/raw/oplock.c index 5ece01c505..3edd0c6820 100644 --- a/source4/torture/raw/oplock.c +++ b/source4/torture/raw/oplock.c @@ -1058,7 +1058,7 @@ static bool test_raw_oplock_batch12(struct torture_context *tctx, struct smbcli_ bool ret = true; union smb_open io; union smb_setfileinfo sfi; - uint16_t fnum=0, fnum2=0; + uint16_t fnum=0; if (!torture_setup_dir(cli1, BASEDIR)) { return false; @@ -1118,7 +1118,6 @@ static bool test_raw_oplock_batch12(struct torture_context *tctx, struct smbcli_ CHECK_VAL(break_info.level, 0); smbcli_close(cli1->tree, fnum); - smbcli_close(cli2->tree, fnum2); done: smb_raw_exit(cli1->session); -- cgit From fb6f52261a4cdbc529c04e28b29f82a8cbb9640f Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 21 Feb 2008 08:59:21 +0100 Subject: pvfs_wait: 'private' -> 'private_data' and use talloc_get_type() metze (This used to be commit 16a7d0cc37614fc41245fdcdf3b5a4a4a421f31d) --- source4/ntvfs/posix/pvfs_wait.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/source4/ntvfs/posix/pvfs_wait.c b/source4/ntvfs/posix/pvfs_wait.c index 989985a033..838a801567 100644 --- a/source4/ntvfs/posix/pvfs_wait.c +++ b/source4/ntvfs/posix/pvfs_wait.c @@ -31,7 +31,7 @@ struct pvfs_wait { struct pvfs_wait *next, *prev; struct pvfs_state *pvfs; void (*handler)(void *, enum pvfs_wait_notice); - void *private; + void *private_data; int msg_type; struct messaging_context *msg_ctx; struct event_context *ev; @@ -45,20 +45,23 @@ struct pvfs_wait { previous ntvfs handlers in the chain (such as security context) */ NTSTATUS pvfs_async_setup(struct ntvfs_module_context *ntvfs, - struct ntvfs_request *req, void *private) + struct ntvfs_request *req, void *private_data) { - struct pvfs_wait *pwait = private; - pwait->handler(pwait->private, pwait->reason); + struct pvfs_wait *pwait = talloc_get_type(private_data, + struct pvfs_wait); + pwait->handler(pwait->private_data, pwait->reason); return NT_STATUS_OK; } /* receive a completion message for a wait */ -static void pvfs_wait_dispatch(struct messaging_context *msg, void *private, uint32_t msg_type, +static void pvfs_wait_dispatch(struct messaging_context *msg, + void *private_data, uint32_t msg_type, struct server_id src, DATA_BLOB *data) { - struct pvfs_wait *pwait = private; + struct pvfs_wait *pwait = talloc_get_type(private_data, + struct pvfs_wait); struct ntvfs_request *req; void *p = NULL; @@ -70,7 +73,7 @@ static void pvfs_wait_dispatch(struct messaging_context *msg, void *private, uin pp = (void **)data->data; p = *pp; } - if (p == NULL || p != pwait->private) { + if (p == NULL || p != pwait->private_data) { return; } @@ -91,9 +94,11 @@ static void pvfs_wait_dispatch(struct messaging_context *msg, void *private, uin receive a timeout on a message wait */ static void pvfs_wait_timeout(struct event_context *ev, - struct timed_event *te, struct timeval t, void *private) + struct timed_event *te, struct timeval t, + void *private_data) { - struct pvfs_wait *pwait = talloc_get_type(private, struct pvfs_wait); + struct pvfs_wait *pwait = talloc_get_type(private_data, + struct pvfs_wait); struct ntvfs_request *req = pwait->req; pwait->reason = PVFS_WAIT_TIMEOUT; @@ -131,7 +136,7 @@ void *pvfs_wait_message(struct pvfs_state *pvfs, int msg_type, struct timeval end_time, void (*fn)(void *, enum pvfs_wait_notice), - void *private) + void *private_data) { struct pvfs_wait *pwait; @@ -140,7 +145,7 @@ void *pvfs_wait_message(struct pvfs_state *pvfs, return NULL; } - pwait->private = private; + pwait->private_data = private_data; pwait->handler = fn; pwait->msg_ctx = pvfs->ntvfs->ctx->msg_ctx; pwait->ev = pvfs->ntvfs->ctx->event_ctx; -- cgit From a0a0d4a5d0c24729a26a37ff54caa665de9149a2 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 21 Feb 2008 09:02:17 +0100 Subject: pvfs_wait: use struct pvfs_wait * instead of void * metze (This used to be commit 3b70331536d2402814db13a9f1f226a39373313a) --- source4/ntvfs/posix/pvfs_lock.c | 2 +- source4/ntvfs/posix/pvfs_notify.c | 8 +++++--- source4/ntvfs/posix/pvfs_open.c | 2 +- source4/ntvfs/posix/pvfs_wait.c | 12 ++++++------ source4/ntvfs/posix/vfs_posix.h | 2 ++ 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/source4/ntvfs/posix/pvfs_lock.c b/source4/ntvfs/posix/pvfs_lock.c index b9bb58c71d..df85b2b775 100644 --- a/source4/ntvfs/posix/pvfs_lock.c +++ b/source4/ntvfs/posix/pvfs_lock.c @@ -53,7 +53,7 @@ struct pvfs_pending_lock { struct pvfs_file *f; struct ntvfs_request *req; int pending_lock; - void *wait_handle; + struct pvfs_wait *wait_handle; struct timeval end_time; }; diff --git a/source4/ntvfs/posix/pvfs_notify.c b/source4/ntvfs/posix/pvfs_notify.c index 210f949395..06d2bc8e0c 100644 --- a/source4/ntvfs/posix/pvfs_notify.c +++ b/source4/ntvfs/posix/pvfs_notify.c @@ -268,9 +268,11 @@ NTSTATUS pvfs_notify(struct ntvfs_module_context *ntvfs, /* if the buffer is empty then start waiting */ if (f->notify_buffer->num_changes == 0) { - void *wait_handle = - pvfs_wait_message(pvfs, req, -1, timeval_zero(), - pvfs_notify_end, f->notify_buffer); + struct pvfs_wait *wait_handle; + wait_handle = pvfs_wait_message(pvfs, req, -1, + timeval_zero(), + pvfs_notify_end, + f->notify_buffer); NT_STATUS_HAVE_NO_MEMORY(wait_handle); talloc_steal(req, wait_handle); return NT_STATUS_OK; diff --git a/source4/ntvfs/posix/pvfs_open.c b/source4/ntvfs/posix/pvfs_open.c index 8558f0476a..3ccd239523 100644 --- a/source4/ntvfs/posix/pvfs_open.c +++ b/source4/ntvfs/posix/pvfs_open.c @@ -756,7 +756,7 @@ struct pvfs_open_retry { struct ntvfs_module_context *ntvfs; struct ntvfs_request *req; union smb_open *io; - void *wait_handle; + struct pvfs_wait *wait_handle; DATA_BLOB odb_locking_key; }; diff --git a/source4/ntvfs/posix/pvfs_wait.c b/source4/ntvfs/posix/pvfs_wait.c index 838a801567..291250befd 100644 --- a/source4/ntvfs/posix/pvfs_wait.c +++ b/source4/ntvfs/posix/pvfs_wait.c @@ -131,12 +131,12 @@ static int pvfs_wait_destructor(struct pvfs_wait *pwait) if msg_type == -1 then no message is registered, and it is assumed that the caller handles any messaging setup needed */ -void *pvfs_wait_message(struct pvfs_state *pvfs, - struct ntvfs_request *req, - int msg_type, - struct timeval end_time, - void (*fn)(void *, enum pvfs_wait_notice), - void *private_data) +struct pvfs_wait *pvfs_wait_message(struct pvfs_state *pvfs, + struct ntvfs_request *req, + int msg_type, + struct timeval end_time, + void (*fn)(void *, enum pvfs_wait_notice), + void *private_data) { struct pvfs_wait *pwait; diff --git a/source4/ntvfs/posix/vfs_posix.h b/source4/ntvfs/posix/vfs_posix.h index a660da329a..84c456dcfe 100644 --- a/source4/ntvfs/posix/vfs_posix.h +++ b/source4/ntvfs/posix/vfs_posix.h @@ -28,6 +28,8 @@ #include "ntvfs/common/ntvfs_common.h" #include "dsdb/samdb/samdb.h" +struct pvfs_wait; + /* this is the private structure for the posix vfs backend. It is used to hold per-connection (per tree connect) state information */ struct pvfs_state { -- cgit From 1cd2008aa49d38792f273bb28922d33b5b9b0066 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 21 Feb 2008 19:59:13 +0100 Subject: pvfs: pass NULL to pvfs_can_*() when no odb_lock is needed by the caller metze (This used to be commit e585e2306334bd919f567f53d8d08903dfdfb102) --- source4/ntvfs/posix/pvfs_rename.c | 11 ++++++----- source4/ntvfs/posix/pvfs_setfileinfo.c | 4 +--- source4/ntvfs/posix/pvfs_unlink.c | 6 ++---- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/source4/ntvfs/posix/pvfs_rename.c b/source4/ntvfs/posix/pvfs_rename.c index ea12f49333..5693e79314 100644 --- a/source4/ntvfs/posix/pvfs_rename.c +++ b/source4/ntvfs/posix/pvfs_rename.c @@ -192,8 +192,8 @@ static NTSTATUS pvfs_rename_one(struct pvfs_state *pvfs, { struct pvfs_filename *name1, *name2; TALLOC_CTX *mem_ctx = talloc_new(req); + struct odb_lock *lck = NULL; NTSTATUS status; - struct odb_lock *lck, *lck2; /* resolve the wildcard pattern for this name */ fname2 = pvfs_resolve_wildcard(mem_ctx, fname1, fname2); @@ -216,6 +216,7 @@ static NTSTATUS pvfs_rename_one(struct pvfs_state *pvfs, status = pvfs_can_rename(pvfs, req, name1, &lck); if (!NT_STATUS_IS_OK(status)) { + talloc_free(lck); goto failed; } @@ -223,7 +224,7 @@ static NTSTATUS pvfs_rename_one(struct pvfs_state *pvfs, status = pvfs_resolve_partial(pvfs, mem_ctx, dir_path, fname2, &name2); if (NT_STATUS_IS_OK(status)) { - status = pvfs_can_delete(pvfs, req, name2, &lck2); + status = pvfs_can_delete(pvfs, req, name2, NULL); if (!NT_STATUS_IS_OK(status)) { goto failed; } @@ -311,7 +312,7 @@ static NTSTATUS pvfs_rename_mv(struct ntvfs_module_context *ntvfs, struct pvfs_state *pvfs = ntvfs->private_data; NTSTATUS status; struct pvfs_filename *name1, *name2; - struct odb_lock *lck; + struct odb_lock *lck = NULL; /* resolve the cifs name to a posix name */ status = pvfs_resolve_name(pvfs, req, ren->rename.in.pattern1, @@ -354,6 +355,7 @@ static NTSTATUS pvfs_rename_mv(struct ntvfs_module_context *ntvfs, status = pvfs_can_rename(pvfs, req, name1, &lck); if (!NT_STATUS_IS_OK(status)) { + talloc_free(lck); return status; } @@ -375,7 +377,6 @@ 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; switch (ren->ntrename.in.flags) { case RENAME_FLAG_RENAME: @@ -421,7 +422,7 @@ static NTSTATUS pvfs_rename_nt(struct ntvfs_module_context *ntvfs, return status; } - status = pvfs_can_rename(pvfs, req, name1, &lck); + status = pvfs_can_rename(pvfs, req, name1, NULL); if (!NT_STATUS_IS_OK(status)) { return status; } diff --git a/source4/ntvfs/posix/pvfs_setfileinfo.c b/source4/ntvfs/posix/pvfs_setfileinfo.c index 9c78699edb..fbbb8c2d4b 100644 --- a/source4/ntvfs/posix/pvfs_setfileinfo.c +++ b/source4/ntvfs/posix/pvfs_setfileinfo.c @@ -142,8 +142,6 @@ static NTSTATUS pvfs_setfileinfo_rename(struct pvfs_state *pvfs, /* if the destination exists, then check the rename is allowed */ if (name2->exists) { - struct odb_lock *lck; - if (strcmp(name2->full_name, name->full_name) == 0) { /* rename to same name is null-op */ return NT_STATUS_OK; @@ -153,7 +151,7 @@ static NTSTATUS pvfs_setfileinfo_rename(struct pvfs_state *pvfs, return NT_STATUS_OBJECT_NAME_COLLISION; } - status = pvfs_can_delete(pvfs, req, name2, &lck); + status = pvfs_can_delete(pvfs, req, name2, NULL); if (NT_STATUS_EQUAL(status, NT_STATUS_SHARING_VIOLATION)) { return NT_STATUS_ACCESS_DENIED; } diff --git a/source4/ntvfs/posix/pvfs_unlink.c b/source4/ntvfs/posix/pvfs_unlink.c index ef56d99fb5..d6e60b59d3 100644 --- a/source4/ntvfs/posix/pvfs_unlink.c +++ b/source4/ntvfs/posix/pvfs_unlink.c @@ -33,7 +33,6 @@ static NTSTATUS pvfs_unlink_stream(struct pvfs_state *pvfs, uint16_t attrib) { NTSTATUS status; - struct odb_lock *lck; if (!name->stream_exists) { return NT_STATUS_OBJECT_NAME_NOT_FOUND; @@ -45,7 +44,7 @@ static NTSTATUS pvfs_unlink_stream(struct pvfs_state *pvfs, return status; } - status = pvfs_can_delete(pvfs, req, name, &lck); + status = pvfs_can_delete(pvfs, req, name, NULL); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -64,7 +63,6 @@ static NTSTATUS pvfs_unlink_one(struct pvfs_state *pvfs, { struct pvfs_filename *name; NTSTATUS status; - struct odb_lock *lck; /* get a pvfs_filename object */ status = pvfs_resolve_partial(pvfs, req, @@ -80,7 +78,7 @@ static NTSTATUS pvfs_unlink_one(struct pvfs_state *pvfs, return status; } - status = pvfs_can_delete(pvfs, req, name, &lck); + status = pvfs_can_delete(pvfs, req, name, NULL); if (!NT_STATUS_IS_OK(status)) { talloc_free(name); return status; -- cgit From f56ff422a525fc6fdf04de8e2ce5c5fa4c097629 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 21 Feb 2008 20:01:25 +0100 Subject: pvfs: handle SHARING_VIOLATION and OPLOCK_NOT_GRANTED in pvfs_can_delete/rename() If the caller asks for the odb_lock return it also if we return NT_STATUS_SHARING_VIOLATION or NT_STATUS_OPLOCK_NOT_GRANTED so that the caller can add the pending notification. metze (This used to be commit daab9cb11eb540fae7ec3c024a586f5fd02cfc71) --- source4/ntvfs/posix/pvfs_open.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/source4/ntvfs/posix/pvfs_open.c b/source4/ntvfs/posix/pvfs_open.c index 3ccd239523..0d97b3d629 100644 --- a/source4/ntvfs/posix/pvfs_open.c +++ b/source4/ntvfs/posix/pvfs_open.c @@ -1447,7 +1447,19 @@ NTSTATUS pvfs_can_delete(struct pvfs_state *pvfs, status = pvfs_access_check_simple(pvfs, req, name, SEC_STD_DELETE); } - if (!NT_STATUS_IS_OK(status)) { + /* + * if it's a sharing violation or we got no oplock + * only keep the lock if the caller requested access + * to the lock + */ + if (NT_STATUS_EQUAL(status, NT_STATUS_SHARING_VIOLATION) || + NT_STATUS_EQUAL(status, NT_STATUS_OPLOCK_NOT_GRANTED)) { + if (lckp) { + *lckp = lck; + } else { + talloc_free(lck); + } + } else if (!NT_STATUS_IS_OK(status)) { talloc_free(lck); *lckp = lck; } else if (lckp != NULL) { @@ -1487,7 +1499,19 @@ NTSTATUS pvfs_can_rename(struct pvfs_state *pvfs, 0, SEC_STD_DELETE); - if (!NT_STATUS_IS_OK(status)) { + /* + * if it's a sharing violation or we got no oplock + * only keep the lock if the caller requested access + * to the lock + */ + if (NT_STATUS_EQUAL(status, NT_STATUS_SHARING_VIOLATION) || + NT_STATUS_EQUAL(status, NT_STATUS_OPLOCK_NOT_GRANTED)) { + if (lckp) { + *lckp = lck; + } else { + talloc_free(lck); + } + } else if (!NT_STATUS_IS_OK(status)) { talloc_free(lck); *lckp = lck; } else if (lckp != NULL) { -- cgit From 6f077d4017e6df9e070b1c3ea85b7afacf3437cd Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 21 Feb 2008 19:56:36 +0100 Subject: pvfs_open: unify talloc behavior in pvfs_can_delete/rename/stat() And also handle NULL for lckp in the error path without crashing. metze (This used to be commit 04eb1be0c67317067ee0ca70c731fef958cd513c) --- source4/ntvfs/posix/pvfs_open.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/source4/ntvfs/posix/pvfs_open.c b/source4/ntvfs/posix/pvfs_open.c index 0d97b3d629..3a8b17ab16 100644 --- a/source4/ntvfs/posix/pvfs_open.c +++ b/source4/ntvfs/posix/pvfs_open.c @@ -1461,8 +1461,10 @@ NTSTATUS pvfs_can_delete(struct pvfs_state *pvfs, } } else if (!NT_STATUS_IS_OK(status)) { talloc_free(lck); - *lckp = lck; - } else if (lckp != NULL) { + if (lckp) { + *lckp = NULL; + } + } else if (lckp) { *lckp = lck; } @@ -1513,8 +1515,10 @@ NTSTATUS pvfs_can_rename(struct pvfs_state *pvfs, } } else if (!NT_STATUS_IS_OK(status)) { talloc_free(lck); - *lckp = lck; - } else if (lckp != NULL) { + if (lckp) { + *lckp = NULL; + } + } else if (lckp) { *lckp = lck; } @@ -1549,6 +1553,10 @@ NTSTATUS pvfs_can_stat(struct pvfs_state *pvfs, NTCREATEX_SHARE_ACCESS_WRITE, 0, 0); + if (!NT_STATUS_IS_OK(status)) { + talloc_free(lck); + } + return status; } -- cgit From 63b15441f4a5f636a079fa5407b2e97a8b99b6e2 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 21 Feb 2008 20:12:46 +0100 Subject: pvfs_unlink: pass down a struct pvfs_filename to pvfs_unlink_one() metze (This used to be commit 43ec7fa2d898ce306557ea9092b6412bcc2f97ec) --- source4/ntvfs/posix/pvfs_unlink.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/source4/ntvfs/posix/pvfs_unlink.c b/source4/ntvfs/posix/pvfs_unlink.c index d6e60b59d3..101dd75de6 100644 --- a/source4/ntvfs/posix/pvfs_unlink.c +++ b/source4/ntvfs/posix/pvfs_unlink.c @@ -58,34 +58,23 @@ static NTSTATUS pvfs_unlink_stream(struct pvfs_state *pvfs, */ static NTSTATUS pvfs_unlink_one(struct pvfs_state *pvfs, struct ntvfs_request *req, - const char *unix_path, - const char *fname, uint32_t attrib) + struct pvfs_filename *name, + uint32_t attrib) { - struct pvfs_filename *name; NTSTATUS status; - /* get a pvfs_filename object */ - status = pvfs_resolve_partial(pvfs, req, - unix_path, fname, &name); - if (!NT_STATUS_IS_OK(status)) { - return status; - } - /* make sure its matches the given attributes */ status = pvfs_match_attrib(pvfs, name, attrib, 0); if (!NT_STATUS_IS_OK(status)) { - talloc_free(name); return status; } status = pvfs_can_delete(pvfs, req, name, NULL); if (!NT_STATUS_IS_OK(status)) { - talloc_free(name); return status; } if (name->dos.attrib & FILE_ATTRIBUTE_DIRECTORY) { - talloc_free(name); return NT_STATUS_FILE_IS_A_DIRECTORY; } @@ -108,8 +97,6 @@ static NTSTATUS pvfs_unlink_one(struct pvfs_state *pvfs, name->full_name); } - talloc_free(name); - return status; } @@ -156,6 +143,7 @@ NTSTATUS pvfs_unlink(struct ntvfs_module_context *ntvfs, } status = NT_STATUS_NO_SUCH_FILE; + talloc_free(name); ofs = 0; @@ -166,10 +154,20 @@ NTSTATUS pvfs_unlink(struct ntvfs_module_context *ntvfs, return NT_STATUS_OBJECT_NAME_INVALID; } - status = pvfs_unlink_one(pvfs, req, pvfs_list_unix_path(dir), fname, unl->unlink.in.attrib); + /* get a pvfs_filename object */ + status = pvfs_resolve_partial(pvfs, req, + pvfs_list_unix_path(dir), + fname, &name); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + status = pvfs_unlink_one(pvfs, req, name, unl->unlink.in.attrib); if (NT_STATUS_IS_OK(status)) { total_deleted++; } + + talloc_free(name); } if (total_deleted > 0) { -- cgit From a56bd4fa82bcb5c586f182e8123f2fc41b12e41d Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 22 Feb 2008 09:23:53 +0100 Subject: pvfs_unlink: pass down union smb_unlink completely to sub functions metze (This used to be commit 8301189e94be850494482e8c064b2400a5d11157) --- source4/ntvfs/posix/pvfs_unlink.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/source4/ntvfs/posix/pvfs_unlink.c b/source4/ntvfs/posix/pvfs_unlink.c index 101dd75de6..8dbf9ee724 100644 --- a/source4/ntvfs/posix/pvfs_unlink.c +++ b/source4/ntvfs/posix/pvfs_unlink.c @@ -29,8 +29,8 @@ */ static NTSTATUS pvfs_unlink_stream(struct pvfs_state *pvfs, struct ntvfs_request *req, - struct pvfs_filename *name, - uint16_t attrib) + union smb_unlink *unl, + struct pvfs_filename *name) { NTSTATUS status; @@ -39,7 +39,8 @@ static NTSTATUS pvfs_unlink_stream(struct pvfs_state *pvfs, } /* make sure its matches the given attributes */ - status = pvfs_match_attrib(pvfs, name, attrib, 0); + status = pvfs_match_attrib(pvfs, name, + unl->unlink.in.attrib, 0); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -58,13 +59,14 @@ static NTSTATUS pvfs_unlink_stream(struct pvfs_state *pvfs, */ static NTSTATUS pvfs_unlink_one(struct pvfs_state *pvfs, struct ntvfs_request *req, - struct pvfs_filename *name, - uint32_t attrib) + union smb_unlink *unl, + struct pvfs_filename *name) { NTSTATUS status; /* make sure its matches the given attributes */ - status = pvfs_match_attrib(pvfs, name, attrib, 0); + status = pvfs_match_attrib(pvfs, name, + unl->unlink.in.attrib, 0); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -133,7 +135,7 @@ NTSTATUS pvfs_unlink(struct ntvfs_module_context *ntvfs, } if (name->stream_name) { - return pvfs_unlink_stream(pvfs, req, name, unl->unlink.in.attrib); + return pvfs_unlink_stream(pvfs, req, unl, name); } /* get list of matching files */ @@ -162,7 +164,7 @@ NTSTATUS pvfs_unlink(struct ntvfs_module_context *ntvfs, return status; } - status = pvfs_unlink_one(pvfs, req, name, unl->unlink.in.attrib); + status = pvfs_unlink_one(pvfs, req, unl, name); if (NT_STATUS_IS_OK(status)) { total_deleted++; } -- cgit From d5414cdc63b797a47fcbd1f55df98c7dd850ffa6 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 22 Feb 2008 09:28:51 +0100 Subject: pvfs_unlink: move !name->stream_exists into the caller metze (This used to be commit e01554e1617dc3c08a4ed6b4e016fd627f529ef9) --- source4/ntvfs/posix/pvfs_unlink.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source4/ntvfs/posix/pvfs_unlink.c b/source4/ntvfs/posix/pvfs_unlink.c index 8dbf9ee724..2b96a5032c 100644 --- a/source4/ntvfs/posix/pvfs_unlink.c +++ b/source4/ntvfs/posix/pvfs_unlink.c @@ -34,10 +34,6 @@ static NTSTATUS pvfs_unlink_stream(struct pvfs_state *pvfs, { NTSTATUS status; - if (!name->stream_exists) { - return NT_STATUS_OBJECT_NAME_NOT_FOUND; - } - /* make sure its matches the given attributes */ status = pvfs_match_attrib(pvfs, name, unl->unlink.in.attrib, 0); @@ -135,6 +131,10 @@ NTSTATUS pvfs_unlink(struct ntvfs_module_context *ntvfs, } if (name->stream_name) { + if (!name->stream_exists) { + return NT_STATUS_OBJECT_NAME_NOT_FOUND; + } + return pvfs_unlink_stream(pvfs, req, unl, name); } -- cgit From 0634c12abb634034fcaf842647c2bc09a92bfd68 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 22 Feb 2008 09:30:51 +0100 Subject: pvfs_unlink: add a fast path for the non wildcard case metze (This used to be commit 83e6c99f78990b6b1df520bdee14b9f931ad0420) --- source4/ntvfs/posix/pvfs_unlink.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source4/ntvfs/posix/pvfs_unlink.c b/source4/ntvfs/posix/pvfs_unlink.c index 2b96a5032c..72649e646d 100644 --- a/source4/ntvfs/posix/pvfs_unlink.c +++ b/source4/ntvfs/posix/pvfs_unlink.c @@ -138,6 +138,10 @@ NTSTATUS pvfs_unlink(struct ntvfs_module_context *ntvfs, return pvfs_unlink_stream(pvfs, req, unl, name); } + if (!name->has_wildcard) { + return pvfs_unlink_one(pvfs, req, unl, name); + } + /* get list of matching files */ status = pvfs_list_start(pvfs, name, req, &dir); if (!NT_STATUS_IS_OK(status)) { -- cgit From 58745900d30cbfa8729ce99e7110cfc5e4a78c2a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 22 Feb 2008 09:37:22 +0100 Subject: pvfs_unlink: splitup the logic into generic and file specific functions metze (This used to be commit 7572afdc2635bdf9afbe1eda3c7498d0b5201db3) --- source4/ntvfs/posix/pvfs_unlink.c | 45 ++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/source4/ntvfs/posix/pvfs_unlink.c b/source4/ntvfs/posix/pvfs_unlink.c index 72649e646d..0763a4e48c 100644 --- a/source4/ntvfs/posix/pvfs_unlink.c +++ b/source4/ntvfs/posix/pvfs_unlink.c @@ -51,27 +51,13 @@ static NTSTATUS pvfs_unlink_stream(struct pvfs_state *pvfs, /* - unlink one file + unlink a file */ -static NTSTATUS pvfs_unlink_one(struct pvfs_state *pvfs, - struct ntvfs_request *req, - union smb_unlink *unl, - struct pvfs_filename *name) +static NTSTATUS pvfs_unlink_file(struct pvfs_state *pvfs, + struct pvfs_filename *name) { NTSTATUS status; - /* make sure its matches the given attributes */ - status = pvfs_match_attrib(pvfs, name, - unl->unlink.in.attrib, 0); - if (!NT_STATUS_IS_OK(status)) { - return status; - } - - status = pvfs_can_delete(pvfs, req, name, NULL); - if (!NT_STATUS_IS_OK(status)) { - return status; - } - if (name->dos.attrib & FILE_ATTRIBUTE_DIRECTORY) { return NT_STATUS_FILE_IS_A_DIRECTORY; } @@ -98,6 +84,31 @@ static NTSTATUS pvfs_unlink_one(struct pvfs_state *pvfs, return status; } +/* + unlink one file +*/ +static NTSTATUS pvfs_unlink_one(struct pvfs_state *pvfs, + struct ntvfs_request *req, + union smb_unlink *unl, + struct pvfs_filename *name) +{ + NTSTATUS status; + + /* make sure its matches the given attributes */ + status = pvfs_match_attrib(pvfs, name, + unl->unlink.in.attrib, 0); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + status = pvfs_can_delete(pvfs, req, name, NULL); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + return pvfs_unlink_file(pvfs, name); +} + /* delete a file - the dirtype specifies the file types to include in the search. The name can contain CIFS wildcards, but rarely does (except with OS/2 clients) -- cgit From 599901c139e99dca26f267439c14119e6c3f2092 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 22 Feb 2008 09:41:41 +0100 Subject: pvfs_unlink: move stream logic into pvfs_unlink_one() metze (This used to be commit 438032e12f3040fbb58488ca537e4d8da39b6124) --- source4/ntvfs/posix/pvfs_unlink.c | 42 ++++++++------------------------------- 1 file changed, 8 insertions(+), 34 deletions(-) diff --git a/source4/ntvfs/posix/pvfs_unlink.c b/source4/ntvfs/posix/pvfs_unlink.c index 0763a4e48c..bda4014bee 100644 --- a/source4/ntvfs/posix/pvfs_unlink.c +++ b/source4/ntvfs/posix/pvfs_unlink.c @@ -24,32 +24,6 @@ #include "system/dir.h" -/* - unlink a stream - */ -static NTSTATUS pvfs_unlink_stream(struct pvfs_state *pvfs, - struct ntvfs_request *req, - union smb_unlink *unl, - struct pvfs_filename *name) -{ - NTSTATUS status; - - /* make sure its matches the given attributes */ - status = pvfs_match_attrib(pvfs, name, - unl->unlink.in.attrib, 0); - if (!NT_STATUS_IS_OK(status)) { - return status; - } - - status = pvfs_can_delete(pvfs, req, name, NULL); - if (!NT_STATUS_IS_OK(status)) { - return status; - } - - return pvfs_stream_delete(pvfs, name, -1); -} - - /* unlink a file */ @@ -106,6 +80,14 @@ static NTSTATUS pvfs_unlink_one(struct pvfs_state *pvfs, return status; } + if (name->stream_name) { + if (!name->stream_exists) { + return NT_STATUS_OBJECT_NAME_NOT_FOUND; + } + + return pvfs_stream_delete(pvfs, name, -1); + } + return pvfs_unlink_file(pvfs, name); } @@ -141,14 +123,6 @@ NTSTATUS pvfs_unlink(struct ntvfs_module_context *ntvfs, return NT_STATUS_FILE_IS_A_DIRECTORY; } - if (name->stream_name) { - if (!name->stream_exists) { - return NT_STATUS_OBJECT_NAME_NOT_FOUND; - } - - return pvfs_unlink_stream(pvfs, req, unl, name); - } - if (!name->has_wildcard) { return pvfs_unlink_one(pvfs, req, unl, name); } -- cgit From 27e322bb4d5a25a2a1ebc5df36690590d86e3afd Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 22 Feb 2008 10:18:13 +0100 Subject: opendb: add odb_get_key() function to get the key back from a struct odb_lock metze (This used to be commit 11f35a2a4d383b506ced35ba06120f9531bac70c) --- source4/cluster/ctdb/opendb_ctdb.c | 11 +++++++++++ source4/ntvfs/common/opendb.c | 4 ++++ source4/ntvfs/common/opendb.h | 1 + source4/ntvfs/common/opendb_tdb.c | 7 +++++++ 4 files changed, 23 insertions(+) diff --git a/source4/cluster/ctdb/opendb_ctdb.c b/source4/cluster/ctdb/opendb_ctdb.c index aaab3aa55d..f056e21716 100644 --- a/source4/cluster/ctdb/opendb_ctdb.c +++ b/source4/cluster/ctdb/opendb_ctdb.c @@ -133,6 +133,16 @@ static struct odb_lock *odb_ctdb_lock(TALLOC_CTX *mem_ctx, return lck; } +static DATA_BLOB odb_ctdb_get_key(TALLOC_CTX *mem_ctx, struct odb_lock *lck) +{ + /* + * as this file will went away and isn't used yet, + * copy the implementation from the tdb backend + * --metze + */ + return data_blob_const(NULL, 0); +} + /* determine if two odb_entry structures conflict @@ -610,6 +620,7 @@ static NTSTATUS odb_ctdb_can_open(struct odb_lock *lck, static const struct opendb_ops opendb_ctdb_ops = { .odb_init = odb_ctdb_init, .odb_lock = odb_ctdb_lock, + .odb_get_key = odb_ctdb_get_key, .odb_open_file = odb_ctdb_open_file, .odb_open_file_pending = odb_ctdb_open_file_pending, .odb_close_file = odb_ctdb_close_file, diff --git a/source4/ntvfs/common/opendb.c b/source4/ntvfs/common/opendb.c index 4826ca5c26..f12f23817d 100644 --- a/source4/ntvfs/common/opendb.c +++ b/source4/ntvfs/common/opendb.c @@ -81,6 +81,10 @@ _PUBLIC_ struct odb_lock *odb_lock(TALLOC_CTX *mem_ctx, return ops->odb_lock(mem_ctx, odb, file_key); } +_PUBLIC_ DATA_BLOB odb_get_key(TALLOC_CTX *mem_ctx, struct odb_lock *lck) +{ + return ops->odb_get_key(mem_ctx, lck); +} /* register an open file in the open files database. This implements the share_access diff --git a/source4/ntvfs/common/opendb.h b/source4/ntvfs/common/opendb.h index 231ae3d7de..5472cea418 100644 --- a/source4/ntvfs/common/opendb.h +++ b/source4/ntvfs/common/opendb.h @@ -24,6 +24,7 @@ struct opendb_ops { struct ntvfs_context *ntvfs_ctx); struct odb_lock *(*odb_lock)(TALLOC_CTX *mem_ctx, struct odb_context *odb, DATA_BLOB *file_key); + DATA_BLOB (*odb_get_key)(TALLOC_CTX *mem_ctx, struct odb_lock *lck); NTSTATUS (*odb_open_file)(struct odb_lock *lck, void *file_handle, uint32_t stream_id, uint32_t share_access, uint32_t access_mask, bool delete_on_close, diff --git a/source4/ntvfs/common/opendb_tdb.c b/source4/ntvfs/common/opendb_tdb.c index abd9ca708b..469cf28374 100644 --- a/source4/ntvfs/common/opendb_tdb.c +++ b/source4/ntvfs/common/opendb_tdb.c @@ -134,6 +134,12 @@ static struct odb_lock *odb_tdb_lock(TALLOC_CTX *mem_ctx, return lck; } +static DATA_BLOB odb_tdb_get_key(TALLOC_CTX *mem_ctx, struct odb_lock *lck) +{ + return data_blob_talloc(mem_ctx, lck->key.dptr, lck->key.dsize); +} + + /* determine if two odb_entry structures conflict @@ -609,6 +615,7 @@ static NTSTATUS odb_tdb_can_open(struct odb_lock *lck, static const struct opendb_ops opendb_tdb_ops = { .odb_init = odb_tdb_init, .odb_lock = odb_tdb_lock, + .odb_get_key = odb_tdb_get_key, .odb_open_file = odb_tdb_open_file, .odb_open_file_pending = odb_tdb_open_file_pending, .odb_close_file = odb_tdb_close_file, -- cgit From 6cb9c1c61d8087457420a56f5296662417a25bd4 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 21 Feb 2008 12:20:31 +0100 Subject: opendb: send also the oplock break level on MSG_NTVFS_OPLOCK_BREAK metze (This used to be commit 49402007f6e9e02a29792344c088e40d1a9b7acf) --- source4/ntvfs/common/opendb.h | 4 ++++ source4/ntvfs/common/opendb_tdb.c | 28 +++++++++++++++++++++++----- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/source4/ntvfs/common/opendb.h b/source4/ntvfs/common/opendb.h index 5472cea418..ccf6db27a0 100644 --- a/source4/ntvfs/common/opendb.h +++ b/source4/ntvfs/common/opendb.h @@ -43,6 +43,10 @@ struct opendb_ops { uint32_t access_mask); }; +struct opendb_oplock_break { + void *file_handle; + uint8_t level; +}; void odb_set_ops(const struct opendb_ops *new_ops); void odb_tdb_init_ops(void); diff --git a/source4/ntvfs/common/opendb_tdb.c b/source4/ntvfs/common/opendb_tdb.c index 469cf28374..25f37f5e26 100644 --- a/source4/ntvfs/common/opendb_tdb.c +++ b/source4/ntvfs/common/opendb_tdb.c @@ -259,12 +259,28 @@ static NTSTATUS odb_push_record(struct odb_lock *lck, struct opendb_file *file) /* send an oplock break to a client */ -static NTSTATUS odb_oplock_break_send(struct odb_context *odb, struct opendb_entry *e) +static NTSTATUS odb_oplock_break_send(struct odb_context *odb, + struct opendb_entry *e, + uint8_t level) { + NTSTATUS status; + struct opendb_oplock_break op_break; + DATA_BLOB blob; + + ZERO_STRUCT(op_break); + /* tell the server handling this open file about the need to send the client a break */ - return messaging_send_ptr(odb->ntvfs_ctx->msg_ctx, e->server, - MSG_NTVFS_OPLOCK_BREAK, e->file_handle); + op_break.file_handle = e->file_handle; + op_break.level = level; + + blob = data_blob_const(&op_break, sizeof(op_break)); + + status = messaging_send(odb->ntvfs_ctx->msg_ctx, e->server, + MSG_NTVFS_OPLOCK_BREAK, &blob); + NT_STATUS_NOT_OK_RETURN(status); + + return NT_STATUS_OK; } /* @@ -318,7 +334,8 @@ static NTSTATUS odb_tdb_open_file(struct odb_lock *lck, void *file_handle, break request and suspending this call until the break is acknowledged or the file is closed */ - odb_oplock_break_send(odb, &file.entries[i]); + odb_oplock_break_send(odb, &file.entries[i], + OPLOCK_BREAK_TO_LEVEL_II/*TODO*/); return NT_STATUS_OPLOCK_NOT_GRANTED; } } @@ -342,7 +359,8 @@ static NTSTATUS odb_tdb_open_file(struct odb_lock *lck, void *file_handle, exclusive oplocks afterwards. */ for (i=0;i Date: Thu, 21 Feb 2008 16:12:27 +0100 Subject: opendb: add odb_update_oplock() call metze (This used to be commit df576d69c6981a4879a0e9447069fcfacb3588db) --- source4/cluster/ctdb/opendb_ctdb.c | 16 +++++++++++++- source4/ntvfs/common/opendb.c | 6 +++++ source4/ntvfs/common/opendb.h | 2 ++ source4/ntvfs/common/opendb_tdb.c | 45 ++++++++++++++++++++++++++++++++++++-- 4 files changed, 66 insertions(+), 3 deletions(-) diff --git a/source4/cluster/ctdb/opendb_ctdb.c b/source4/cluster/ctdb/opendb_ctdb.c index f056e21716..86dc1f50f1 100644 --- a/source4/cluster/ctdb/opendb_ctdb.c +++ b/source4/cluster/ctdb/opendb_ctdb.c @@ -450,6 +450,19 @@ static NTSTATUS odb_ctdb_close_file(struct odb_lock *lck, void *file_handle) return odb_push_record(lck, &file); } +/* + update the oplock level of the client +*/ +static NTSTATUS odb_ctdb_update_oplock(struct odb_lock *lck, void *file_handle, + uint32_t oplock_level) +{ + /* + * as this file will went away and isn't used yet, + * copy the implementation from the tdb backend + * --metze + */ + return NT_STATUS_FOOBAR; +} /* remove a pending opendb entry @@ -628,7 +641,8 @@ static const struct opendb_ops opendb_ctdb_ops = { .odb_rename = odb_ctdb_rename, .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 + .odb_can_open = odb_ctdb_can_open, + .odb_update_oplock = odb_ctdb_update_oplock }; diff --git a/source4/ntvfs/common/opendb.c b/source4/ntvfs/common/opendb.c index f12f23817d..4ac10806e1 100644 --- a/source4/ntvfs/common/opendb.c +++ b/source4/ntvfs/common/opendb.c @@ -170,3 +170,9 @@ _PUBLIC_ NTSTATUS odb_can_open(struct odb_lock *lck, { return ops->odb_can_open(lck, share_access, create_options, access_mask); } + +_PUBLIC_ NTSTATUS odb_update_oplock(struct odb_lock *lck, void *file_handle, + uint32_t oplock_level) +{ + return ops->odb_update_oplock(lck, file_handle, oplock_level); +} diff --git a/source4/ntvfs/common/opendb.h b/source4/ntvfs/common/opendb.h index ccf6db27a0..c34a07d6fa 100644 --- a/source4/ntvfs/common/opendb.h +++ b/source4/ntvfs/common/opendb.h @@ -41,6 +41,8 @@ struct opendb_ops { NTSTATUS (*odb_can_open)(struct odb_lock *lck, uint32_t share_access, uint32_t create_options, uint32_t access_mask); + NTSTATUS (*odb_update_oplock)(struct odb_lock *lck, void *file_handle, + uint32_t oplock_level); }; struct opendb_oplock_break { diff --git a/source4/ntvfs/common/opendb_tdb.c b/source4/ntvfs/common/opendb_tdb.c index 25f37f5e26..3d4a760e2e 100644 --- a/source4/ntvfs/common/opendb_tdb.c +++ b/source4/ntvfs/common/opendb_tdb.c @@ -2,7 +2,8 @@ Unix SMB/CIFS implementation. Copyright (C) Andrew Tridgell 2004 - + Copyright (C) Stefan Metzmacher 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 @@ -463,6 +464,45 @@ static NTSTATUS odb_tdb_close_file(struct odb_lock *lck, void *file_handle) return odb_push_record(lck, &file); } +/* + update the oplock level of the client +*/ +static NTSTATUS odb_tdb_update_oplock(struct odb_lock *lck, void *file_handle, + uint32_t oplock_level) +{ + struct odb_context *odb = lck->odb; + struct opendb_file file; + int i; + NTSTATUS status; + + status = odb_pull_record(lck, &file); + NT_STATUS_NOT_OK_RETURN(status); + + /* find the entry, and update it */ + for (i=0;intvfs_ctx->server_id, &file.entries[i].server)) { + file.entries[i].oplock_level = oplock_level; + break; + } + } + + if (i == file.num_entries) { + return NT_STATUS_UNSUCCESSFUL; + } + + /* send any pending notifications, removing them once sent */ + for (i=0;intvfs_ctx->msg_ctx, + file.pending[i].server, + MSG_PVFS_RETRY_OPEN, + file.pending[i].notify_ptr); + } + file.num_pending = 0; + + return odb_push_record(lck, &file); +} + /* remove a pending opendb entry @@ -641,7 +681,8 @@ static const struct opendb_ops opendb_tdb_ops = { .odb_rename = odb_tdb_rename, .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 + .odb_can_open = odb_tdb_can_open, + .odb_update_oplock = odb_tdb_update_oplock }; -- cgit