From 4530fcd820af41080d820159605880d33fd48476 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 28 Aug 2009 15:01:17 +0200 Subject: tevent: add scripts to extract library symbols (exports file) from headers Michael --- lib/tevent/script/mksyms.awk | 76 ++++++++++++++++++++++++++++++++++++++++++++ lib/tevent/script/mksyms.sh | 45 ++++++++++++++++++++++++++ 2 files changed, 121 insertions(+) create mode 100644 lib/tevent/script/mksyms.awk create mode 100755 lib/tevent/script/mksyms.sh diff --git a/lib/tevent/script/mksyms.awk b/lib/tevent/script/mksyms.awk new file mode 100644 index 0000000000..a30bea4d34 --- /dev/null +++ b/lib/tevent/script/mksyms.awk @@ -0,0 +1,76 @@ +# +# mksyms.awk +# +# Extract symbols to export from C-header files. +# output in version-script format for linking shared libraries. +# +# Copyright (C) 2008 Micheal Adam +# +BEGIN { + inheader=0; + current_file=""; + print "#" + print "# This file is automatically generated with \"make symbols\". DO NOT EDIT " + print "#" + print "{" + print "\tglobal:" +} + +END { + print"" + print "\tlocal: *;" + print "};" +} + +{ + if (FILENAME!=current_file) { + print "\t\t# The following definitions come from",FILENAME + current_file=FILENAME + } + if (inheader) { + if (match($0,"[)][ \t]*[;][ \t]*$")) { + inheader = 0; + } + next; + } +} + +/^static/ || /^[ \t]*typedef/ || !/^[a-zA-Z\_]/ { + next; +} + +/^extern[ \t]+[^()]+[;][ \t]*$/ { + gsub(/[^ \t]+[ \t]+/, ""); + sub(/[;][ \t]*$/, ""); + printf "\t\t%s;\n", $0; + next; +} + +# look for function headers: +{ + gotstart = 0; + if ($0 ~ /^[A-Za-z_][A-Za-z0-9_]+/) { + gotstart = 1; + } + if(!gotstart) { + next; + } +} + +/[_A-Za-z0-9]+[ \t]*[(].*[)][ \t]*;[ \t]*$/ { + sub(/[(].*$/, ""); + gsub(/[^ \t]+[ \t]+/, ""); + gsub(/^[*]/, ""); + printf "\t\t%s;\n",$0; + next; +} + +/[_A-Za-z0-9]+[ \t]*[(]/ { + inheader=1; + sub(/[(].*$/, ""); + gsub(/[^ \t]+[ \t]+/, ""); + gsub(/^[*]/, ""); + printf "\t\t%s;\n",$0; + next; +} + diff --git a/lib/tevent/script/mksyms.sh b/lib/tevent/script/mksyms.sh new file mode 100755 index 0000000000..714d55abae --- /dev/null +++ b/lib/tevent/script/mksyms.sh @@ -0,0 +1,45 @@ +#! /bin/sh + +# +# mksyms.sh +# +# Extract symbols to export from C-header files. +# output in version-script format for linking shared libraries. +# +# This is the shell wrapper for the mksyms.awk core script. +# +# Copyright (C) 2008 Micheal Adam +# + +LANG=C; export LANG +LC_ALL=C; export LC_ALL +LC_COLLATE=C; export LC_COLLATE + +if [ $# -lt 2 ] +then + echo "Usage: $0 awk output_file header_files" + exit 1 +fi + +awk="$1" +shift + +symsfile="$1" +shift +symsfile_tmp="$symsfile.$$.tmp~" + +proto_src="`echo $@ | tr ' ' '\n' | sort | uniq `" + +echo creating $symsfile + +mkdir -p `dirname $symsfile` + +${awk} -f `dirname $0`/mksyms.awk $proto_src > $symsfile_tmp + +if cmp -s $symsfile $symsfile_tmp 2>/dev/null +then + echo "$symsfile unchanged" + rm $symsfile_tmp +else + mv $symsfile_tmp $symsfile +fi -- cgit From ffc72b92078a07d020456028b31fbbdd9e802c54 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 28 Aug 2009 15:08:19 +0200 Subject: tevent: add script to extract signatures from header files. This produces output like the output gcc produces when invoked with the -aux-info switch. Run like this: cat include/tevent.h | ./script/mksigs.pl This simple parser is probably too coarse to handle all possible header files, but it treats tevent.h correctly... Michael --- lib/tevent/script/mksigs.pl | 178 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 178 insertions(+) create mode 100755 lib/tevent/script/mksigs.pl diff --git a/lib/tevent/script/mksigs.pl b/lib/tevent/script/mksigs.pl new file mode 100755 index 0000000000..28a2e747a0 --- /dev/null +++ b/lib/tevent/script/mksigs.pl @@ -0,0 +1,178 @@ +#!/usr/bin/perl + +# mksigs.pl - extract signatures from C headers +# +# Copyright (C) Michael Adam 2009 +# +# 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 . + +# USAGE: cat $header_files | mksigs.pl > $signature_file +# +# The header files to parse are read from stdin. +# The output is in a form as produced by gcc with the -aux-info switch +# and printed to stdout. + +use strict; +use warnings; + +my $in_comment = 0; +my $extern_C_block = 0; + +while (my $LINE = <>) { + # find end of started multi-line-comment + if ($in_comment) { + if ($LINE =~ /^.*?\*\/(.*)$/) { + $LINE = $1; + $in_comment = 0; + } else { + # whole line within comment + next; + } + } + + # strip C++-style comments + $LINE =~ s/^(.*?)\/\/.*$/$1/; + + # strip in-line-comments: + while ($LINE =~ /\/\*.*?\*\//) { + $LINE =~ s/\/\*.*?\*\///; + } + + # find starts of multi-line-comments + if ($LINE =~ /^(.*)\/\*/) { + $in_comment = 1; + $LINE = $1; + } + + # skip empty lines + next if $LINE =~ /^\s*$/; + + # remove leading spaces + $LINE =~ s/^\s*(.*)$/$1/; + + # concatenate lines split with "\" (usually macro defines) + while ($LINE =~ /^(.*?)\s+\\$/) { + my $LINE2 = <>; + $LINE = $1; + $LINE2 =~ s/^\s*(.*)$/$1/; + $LINE .= " " . $LINE2; + } + + # remove all preprocessor directives + next if ($LINE =~ /^#/); + + if ($LINE =~ /^extern\s+"C"\s+\{/) { + $extern_C_block = 1; + next; + } + + if (($LINE =~ /^[^\{]*\}/) and $extern_C_block) { + $extern_C_block = 0; + next; + } + + $LINE =~ s/^extern\s//; + + # concatenate braces stretched over multiple lines + # (from structs or enums) + my $REST = $LINE; + my $braces = 0; + while (($REST =~ /[\{\}]/) or ($braces)) { + while ($REST =~ /[\{\}]/) { + # collect opening + while ($REST =~ /^[^\{\}]*\{(.*)$/) { + $braces++; + $REST = $1; + } + + # collect closing + while ($REST =~ /^[^\{\}]*\}(.*)$/) { + $braces--; + $REST = $1; + } + } + + # concatenate if not balanced + if ($braces) { + if (my $LINE2 = <>) { + $LINE2 =~ s/^\s*(.*)$/$1/; + chomp($LINE); + $LINE .= " " . $LINE2; + chomp $REST; + $REST .= " " . $LINE2; + } else { + print "ERROR: unbalanced braces ($braces)\n"; + last; + } + } + } + + next if ($LINE =~ /^typedef\s/); + next if ($LINE =~ /^enum\s+[^\{\(]+\s+\{/); + next if ($LINE =~ /^struct\s+[^\{\(]+\s+\{.*\}\s*;/); + + # concetenate function prototypes that stretch over multiple lines + $REST = $LINE; + my $parenthesis = 0; + while (($REST =~ /[\(\)]/) or ($parenthesis)) { + while ($REST =~ /[\(\)]/) { + # collect opening + while ($REST =~ /^[^\(\)]*\((.*)$/) { + $parenthesis++; + $REST = $1; + } + + # collect closing + while ($REST =~ /^[^\(\)]*\)(.*)$/) { + $parenthesis--; + $REST = $1; + } + } + + # concatenate if not balanced + if ($parenthesis) { + if (my $LINE2 = <>) { + $LINE2 =~ s/^\s*(.*)$/$1/; + chomp($LINE); + $LINE .= " " . $LINE2; + chomp($REST); + $REST .= " " . $LINE2; + } else { + print "ERROR: unbalanced parantheses ($parenthesis)\n"; + last; + } + } + } + + # remove trailing spaces + $LINE =~ s/(.*?)\s*$/$1/; + + $LINE =~ s/^(.*\))\s+PRINTF_ATTRIBUTE\(.*\);$/$1;/; + + # remove parameter names - slightly too coarse probably + $LINE =~ s/([\s\(]\*?)[_0-9a-zA-Z]+\s*([,\)])/$1$2/g; + + # remedy (void) from last line + $LINE =~ s/\(\)/(void)/g; + + # normalize spaces + $LINE =~ s/\s*\)\s*/)/g; + $LINE =~ s/\s*\(\s*/ (/g; + $LINE =~ s/\s*,\s*/, /g; + + # normalize unsigned + $LINE =~ s/([\s,\(])unsigned([,\)])/$1unsigned int$2/g; + + print $LINE . "\n"; +} -- cgit From 31ee07293420a6faae53ad71e3517a332cd45006 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 28 Aug 2009 15:53:12 +0200 Subject: tevent: add script/abi_checks.sh. check for abi changes without gcc magic. USAGE: abi_checks.sh LIBRARY_NAME header1 [header2 ...] This creates symbol signature lists using the mksyms and mksigs scripts and compares them with the checked in lists. Michael --- lib/tevent/script/abi_checks.sh | 91 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100755 lib/tevent/script/abi_checks.sh diff --git a/lib/tevent/script/abi_checks.sh b/lib/tevent/script/abi_checks.sh new file mode 100755 index 0000000000..c34a659d73 --- /dev/null +++ b/lib/tevent/script/abi_checks.sh @@ -0,0 +1,91 @@ +#!/bin/sh + +# +# abi_checks.sh - check for possible abi changes +# +# Copyright (C) 2009 Micheal Adam +# +# 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 . +# + +# +# USAGE: abi_checks.sh LIBNAME header1 [header2 ...] +# +# This script creates symbol and signature lists from the provided header +# files with the aid of the mksyms.sh and mksigs.pl scripts (saved as +# $LIBNAME.exports.check and $LIBNAME.sigatures.check). It then compares +# the resulting files with the files $LIBNAME.exports and $LIBNME.signatures +# which it expects to find in the current directory. +# + +LANG=C; export LANG +LC_ALL=C; export LC_ALL +LC_COLLATE=C; export LC_COLLATE + +script=$0 +dir_name=$(dirname ${script}) + +if test x"$1" = "x" ; then + echo "USAGE: ${script} libname header [header ...]" + exit 1 +fi + +libname="$1" +shift + +if test x"$1" = "x" ; then + echo "USAGE: ${script} libname header [header ...]" + exit 1 +fi + +headers="$*" + +exports_file=${libname}.exports +exports_file_check=${exports_file}.check +signatures_file=${libname}.signatures +signatures_file_check=${signatures_file}.check + + +${dir_name}/mksyms.sh awk ${exports_file_check} ${headers} 2>&1 > /dev/null + +cat ${headers} | ${dir_name}/mksigs.pl > ${signatures_file_check} 2> /dev/null + +normalize_exports_file() { + filename=$1 + cat ${filename} \ + | sed -e 's/^[ \t]*//g' \ + | sed -e 's/^$//g' \ + | sed -e 's/^#.*$//g' \ + | sort | uniq > ${filename}.sort +} + +normalize_exports_file ${exports_file} +normalize_exports_file ${exports_file_check} + +normalize_exports_file ${signatures_file} +normalize_exports_file ${signatures_file_check} + +diff -u ${exports_file}.sort ${exports_file_check}.sort +if test "x$?" != "x0" ; then + echo "WARNING: possible ABI change detected in exports!" +else + echo "exports check: OK" +fi + +diff -u ${signatures_file}.sort ${signatures_file_check}.sort +if test "x$?" != "x0" ; then + echo "WARNING: possible ABI change detected in signatures!" +else + echo "signatures check: OK" +fi -- cgit From f0e276cff896bb40941357a27c0ff1cd772ba8b4 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 28 Aug 2009 16:04:47 +0200 Subject: tevent: move the original abi_checks script to script/abi_checks_gcc.sh Michael --- lib/tevent/abi_checks.sh | 31 ------------------------------- lib/tevent/script/abi_checks_gcc.sh | 31 +++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 31 deletions(-) delete mode 100755 lib/tevent/abi_checks.sh create mode 100755 lib/tevent/script/abi_checks_gcc.sh diff --git a/lib/tevent/abi_checks.sh b/lib/tevent/abi_checks.sh deleted file mode 100755 index 95182097d5..0000000000 --- a/lib/tevent/abi_checks.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash -make clean - -mkdir abi -ABI_CHECKS="-aux-info abi/\$@.X" -make ABI_CHECK="$ABI_CHECKS" CC="/usr/bin/gcc" - -for i in abi/*.X; do cat $i | grep 'tevent\.h'; done | sort | uniq | awk -F "extern " '{ print $2 }' | sort> abi/signatures - -cat > abi/exports << EOF -{ - global: -EOF -cat abi/signatures | awk -F '(' '{ print $1 }' | awk -F ' ' '{ print " "$NF";" }' | tr -d '*' | sort >> abi/exports -cat >> abi/exports << EOF - - local: *; -}; -EOF - -rm -fr abi/*.X - -diff -u tevent.signatures abi/signatures -if [ "$?" != "0" ]; then - echo "WARNING: Possible ABI Change!!" -fi - -diff -u tevent.exports abi/exports -if [ "$?" != "0" ]; then - echo "WARNING: Export file may be outdated!!" -fi diff --git a/lib/tevent/script/abi_checks_gcc.sh b/lib/tevent/script/abi_checks_gcc.sh new file mode 100755 index 0000000000..95182097d5 --- /dev/null +++ b/lib/tevent/script/abi_checks_gcc.sh @@ -0,0 +1,31 @@ +#!/bin/bash +make clean + +mkdir abi +ABI_CHECKS="-aux-info abi/\$@.X" +make ABI_CHECK="$ABI_CHECKS" CC="/usr/bin/gcc" + +for i in abi/*.X; do cat $i | grep 'tevent\.h'; done | sort | uniq | awk -F "extern " '{ print $2 }' | sort> abi/signatures + +cat > abi/exports << EOF +{ + global: +EOF +cat abi/signatures | awk -F '(' '{ print $1 }' | awk -F ' ' '{ print " "$NF";" }' | tr -d '*' | sort >> abi/exports +cat >> abi/exports << EOF + + local: *; +}; +EOF + +rm -fr abi/*.X + +diff -u tevent.signatures abi/signatures +if [ "$?" != "0" ]; then + echo "WARNING: Possible ABI Change!!" +fi + +diff -u tevent.exports abi/exports +if [ "$?" != "0" ]; then + echo "WARNING: Export file may be outdated!!" +fi -- cgit From 40c670f8cbb4ea5485d4933fba658bb46720aa9d Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 11 Sep 2009 13:39:15 +0200 Subject: tevent: add a make target "make abi_checks" Michael --- lib/tevent/tevent.mk | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/tevent/tevent.mk b/lib/tevent/tevent.mk index 480366e938..7499e5334f 100644 --- a/lib/tevent/tevent.mk +++ b/lib/tevent/tevent.mk @@ -29,6 +29,10 @@ installlibs:: installdirs install:: all installdirs installheaders installlibs $(PYTHON_INSTALL_TARGET) +abi_checks:: + @echo ABI checks: + @./script/abi_checks.sh tevent tevent.h + clean:: rm -f $(TEVENT_SOBASE) $(TEVENT_SONAME) $(TEVENT_SOLIB) $(TEVENT_STLIB) rm -f tevent.pc -- cgit From cf67b1bff784ce7a2371a5d3e3839db96569d7ea Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 11 Sep 2009 13:39:44 +0200 Subject: tevent: remove filese generated by "make abi_checks" in "make clean". Michael --- lib/tevent/tevent.mk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/tevent/tevent.mk b/lib/tevent/tevent.mk index 7499e5334f..8579b2f5bb 100644 --- a/lib/tevent/tevent.mk +++ b/lib/tevent/tevent.mk @@ -36,3 +36,5 @@ abi_checks:: clean:: rm -f $(TEVENT_SOBASE) $(TEVENT_SONAME) $(TEVENT_SOLIB) $(TEVENT_STLIB) rm -f tevent.pc + rm -f tevent.exports.sort tevent.exports.check tevent.exports.check.sort + rm -f tevent.signatures.sort tevent.signatures.check tevent.signatures.check.sort -- cgit From 4fb82727b1258f89aadbf8d320d9aea6ba74d92c Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 11 Sep 2009 14:00:25 +0200 Subject: tevent: add abi_checks to "make test" Michael --- lib/tevent/tevent.mk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/tevent/tevent.mk b/lib/tevent/tevent.mk index 8579b2f5bb..694d082c4a 100644 --- a/lib/tevent/tevent.mk +++ b/lib/tevent/tevent.mk @@ -33,6 +33,8 @@ abi_checks:: @echo ABI checks: @./script/abi_checks.sh tevent tevent.h +test:: abi_checks + clean:: rm -f $(TEVENT_SOBASE) $(TEVENT_SONAME) $(TEVENT_SOLIB) $(TEVENT_STLIB) rm -f tevent.pc -- cgit From 095a11226ea1b23609e62ad803ff6b65cb113405 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 11 Sep 2009 14:54:02 +0200 Subject: tevent:mksyms: allow double pointer return value of functions. Michael --- lib/tevent/script/mksyms.awk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tevent/script/mksyms.awk b/lib/tevent/script/mksyms.awk index a30bea4d34..0d80d9f70b 100644 --- a/lib/tevent/script/mksyms.awk +++ b/lib/tevent/script/mksyms.awk @@ -60,7 +60,7 @@ END { /[_A-Za-z0-9]+[ \t]*[(].*[)][ \t]*;[ \t]*$/ { sub(/[(].*$/, ""); gsub(/[^ \t]+[ \t]+/, ""); - gsub(/^[*]/, ""); + gsub(/^[*]+/, ""); printf "\t\t%s;\n",$0; next; } -- cgit From 1f1a900dd7d2a95a248805cfbbdeed47c666c4b4 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 11 Sep 2009 14:54:30 +0200 Subject: tevent:mksyms: allow characters after closing functions parenthesis. Michael --- lib/tevent/script/mksyms.awk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/tevent/script/mksyms.awk b/lib/tevent/script/mksyms.awk index 0d80d9f70b..ca14da0f21 100644 --- a/lib/tevent/script/mksyms.awk +++ b/lib/tevent/script/mksyms.awk @@ -28,7 +28,7 @@ END { current_file=FILENAME } if (inheader) { - if (match($0,"[)][ \t]*[;][ \t]*$")) { + if (match($0,"[)][^()]*[;][ \t]*$")) { inheader = 0; } next; @@ -57,7 +57,7 @@ END { } } -/[_A-Za-z0-9]+[ \t]*[(].*[)][ \t]*;[ \t]*$/ { +/[_A-Za-z0-9]+[ \t]*[(].*[)][^()]*;[ \t]*$/ { sub(/[(].*$/, ""); gsub(/[^ \t]+[ \t]+/, ""); gsub(/^[*]+/, ""); -- cgit From 1e2393c17829a14ce409091c35fa78b9373c57fb Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 11 Sep 2009 14:55:52 +0200 Subject: tevent:mksigs: ignore struct forward declarations. Michael --- lib/tevent/script/mksigs.pl | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/tevent/script/mksigs.pl b/lib/tevent/script/mksigs.pl index 28a2e747a0..3eb90d99dc 100755 --- a/lib/tevent/script/mksigs.pl +++ b/lib/tevent/script/mksigs.pl @@ -121,6 +121,7 @@ while (my $LINE = <>) { next if ($LINE =~ /^typedef\s/); next if ($LINE =~ /^enum\s+[^\{\(]+\s+\{/); next if ($LINE =~ /^struct\s+[^\{\(]+\s+\{.*\}\s*;/); + next if ($LINE =~ /^struct\s+[a-zA-Z0-9_]+\s*;/); # concetenate function prototypes that stretch over multiple lines $REST = $LINE; -- cgit From aa7748484fa23da36c843115c5624a090d08dbad Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 11 Sep 2009 15:01:46 +0200 Subject: tevent:mksigs: correctly ignode multiline function typedefs by first concatenating multilint parentheses and removing typefes afterwards. Michael --- lib/tevent/script/mksigs.pl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/tevent/script/mksigs.pl b/lib/tevent/script/mksigs.pl index 3eb90d99dc..ab2e18ec52 100755 --- a/lib/tevent/script/mksigs.pl +++ b/lib/tevent/script/mksigs.pl @@ -118,11 +118,6 @@ while (my $LINE = <>) { } } - next if ($LINE =~ /^typedef\s/); - next if ($LINE =~ /^enum\s+[^\{\(]+\s+\{/); - next if ($LINE =~ /^struct\s+[^\{\(]+\s+\{.*\}\s*;/); - next if ($LINE =~ /^struct\s+[a-zA-Z0-9_]+\s*;/); - # concetenate function prototypes that stretch over multiple lines $REST = $LINE; my $parenthesis = 0; @@ -156,6 +151,11 @@ while (my $LINE = <>) { } } + next if ($LINE =~ /^typedef\s/); + next if ($LINE =~ /^enum\s+[^\{\(]+\s+\{/); + next if ($LINE =~ /^struct\s+[^\{\(]+\s+\{.*\}\s*;/); + next if ($LINE =~ /^struct\s+[a-zA-Z0-9_]+\s*;/); + # remove trailing spaces $LINE =~ s/(.*?)\s*$/$1/; -- cgit From 636f8b5e5b4c8c42edb626a6bd7ef497477237d7 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 11 Sep 2009 15:11:16 +0200 Subject: tevent:mksigs: ignore symbols (like _DEPRECATED_) after closing function parentheses Michael --- lib/tevent/script/mksigs.pl | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/tevent/script/mksigs.pl b/lib/tevent/script/mksigs.pl index ab2e18ec52..bd76a04a26 100755 --- a/lib/tevent/script/mksigs.pl +++ b/lib/tevent/script/mksigs.pl @@ -160,6 +160,7 @@ while (my $LINE = <>) { $LINE =~ s/(.*?)\s*$/$1/; $LINE =~ s/^(.*\))\s+PRINTF_ATTRIBUTE\(.*\);$/$1;/; + $LINE =~ s/^(.*\))\s*[a-zA-Z0-9_]+\s*;$/$1;/; # remove parameter names - slightly too coarse probably $LINE =~ s/([\s\(]\*?)[_0-9a-zA-Z]+\s*([,\)])/$1$2/g; -- cgit From 085c07b7431c7b96b30d29e3753dbd5fa71ff9ce Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 11 Sep 2009 15:16:03 +0200 Subject: tevent:mksigs: normalize bool -> _Bool Michael --- lib/tevent/script/mksigs.pl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/tevent/script/mksigs.pl b/lib/tevent/script/mksigs.pl index bd76a04a26..a34950b09a 100755 --- a/lib/tevent/script/mksigs.pl +++ b/lib/tevent/script/mksigs.pl @@ -176,5 +176,8 @@ while (my $LINE = <>) { # normalize unsigned $LINE =~ s/([\s,\(])unsigned([,\)])/$1unsigned int$2/g; + # normalize bool + $LINE =~ s/(\b)bool(\b)/_Bool/g; + print $LINE . "\n"; } -- cgit From f98470e3a4add69858e50ded0c7e01393b314473 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 11 Sep 2009 15:20:34 +0200 Subject: tevent:mksigs: allow PRINTF_ATTRIBUTE(..) macros function types as funcion args Michael --- lib/tevent/script/mksigs.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tevent/script/mksigs.pl b/lib/tevent/script/mksigs.pl index a34950b09a..755cd79603 100755 --- a/lib/tevent/script/mksigs.pl +++ b/lib/tevent/script/mksigs.pl @@ -159,7 +159,7 @@ while (my $LINE = <>) { # remove trailing spaces $LINE =~ s/(.*?)\s*$/$1/; - $LINE =~ s/^(.*\))\s+PRINTF_ATTRIBUTE\(.*\);$/$1;/; + $LINE =~ s/^(.*\))\s+PRINTF_ATTRIBUTE\([^\)]*\)(\s*[;,])/$1$2/; $LINE =~ s/^(.*\))\s*[a-zA-Z0-9_]+\s*;$/$1;/; # remove parameter names - slightly too coarse probably -- cgit From 7165f29aeaf6607bfaab90c4d5e9eca280b4a27d Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 11 Sep 2009 14:57:59 +0200 Subject: tevent:exports: add _tevent_req_cancel and tevent_req_set_cancel_fn. These were added in 45e4be0d96abdc729252df1e97bb9a56302e5a4a Michael --- lib/tevent/tevent.exports | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/tevent/tevent.exports b/lib/tevent/tevent.exports index b1554dff4e..01d547ad85 100644 --- a/lib/tevent/tevent.exports +++ b/lib/tevent/tevent.exports @@ -55,6 +55,8 @@ tevent_timeval_zero; tevent_wakeup_recv; tevent_wakeup_send; + _tevent_req_cancel; + tevent_req_set_cancel_fn; local: *; }; -- cgit From 6b9298191a72c20e0e81298d06871181dd3b7826 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 11 Sep 2009 15:08:37 +0200 Subject: tevent:signatures: add _tevent_req_cancel and tevent_req_set_cancel_fn introduced in 45e4be0d96abdc729252df1e97bb9a56302e5a4a Michael --- lib/tevent/tevent.signatures | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/tevent/tevent.signatures b/lib/tevent/tevent.signatures index 75f43affb2..c752b9e933 100644 --- a/lib/tevent/tevent.signatures +++ b/lib/tevent/tevent.signatures @@ -53,3 +53,5 @@ void tevent_req_set_print_fn (struct tevent_req *, tevent_req_print_fn); void _tevent_schedule_immediate (struct tevent_immediate *, struct tevent_context *, tevent_immediate_handler_t, void *, const char *, const char *); void tevent_set_abort_fn (void (*) (const char *)); void tevent_set_default_backend (const char *); +_Bool _tevent_req_cancel (struct tevent_req *, const char *); +void tevent_req_set_cancel_fn (struct tevent_req *, tevent_req_cancel_fn); -- cgit From 907e05595fdcc4ef77ad627bc0f3732faa59de68 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 11 Sep 2009 14:54:02 +0200 Subject: tdb:mksyms: allow double pointer return value of functions. Michael --- lib/tdb/script/mksyms.awk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tdb/script/mksyms.awk b/lib/tdb/script/mksyms.awk index a30bea4d34..0d80d9f70b 100644 --- a/lib/tdb/script/mksyms.awk +++ b/lib/tdb/script/mksyms.awk @@ -60,7 +60,7 @@ END { /[_A-Za-z0-9]+[ \t]*[(].*[)][ \t]*;[ \t]*$/ { sub(/[(].*$/, ""); gsub(/[^ \t]+[ \t]+/, ""); - gsub(/^[*]/, ""); + gsub(/^[*]+/, ""); printf "\t\t%s;\n",$0; next; } -- cgit From 400f08450b26f38a7dafd1d458542b4d9a8cb19e Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 11 Sep 2009 14:54:30 +0200 Subject: tdb:mksyms: allow characters after closing functions parenthesis. Michael --- lib/tdb/script/mksyms.awk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/tdb/script/mksyms.awk b/lib/tdb/script/mksyms.awk index 0d80d9f70b..ca14da0f21 100644 --- a/lib/tdb/script/mksyms.awk +++ b/lib/tdb/script/mksyms.awk @@ -28,7 +28,7 @@ END { current_file=FILENAME } if (inheader) { - if (match($0,"[)][ \t]*[;][ \t]*$")) { + if (match($0,"[)][^()]*[;][ \t]*$")) { inheader = 0; } next; @@ -57,7 +57,7 @@ END { } } -/[_A-Za-z0-9]+[ \t]*[(].*[)][ \t]*;[ \t]*$/ { +/[_A-Za-z0-9]+[ \t]*[(].*[)][^()]*;[ \t]*$/ { sub(/[(].*$/, ""); gsub(/[^ \t]+[ \t]+/, ""); gsub(/^[*]+/, ""); -- cgit From ecd12bfb382da072595391d5bf11a893d39a0479 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 11 Sep 2009 14:55:52 +0200 Subject: tdb:mksigs: ignore struct forward declarations. Michael --- lib/tdb/script/mksigs.pl | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/tdb/script/mksigs.pl b/lib/tdb/script/mksigs.pl index 28a2e747a0..3eb90d99dc 100755 --- a/lib/tdb/script/mksigs.pl +++ b/lib/tdb/script/mksigs.pl @@ -121,6 +121,7 @@ while (my $LINE = <>) { next if ($LINE =~ /^typedef\s/); next if ($LINE =~ /^enum\s+[^\{\(]+\s+\{/); next if ($LINE =~ /^struct\s+[^\{\(]+\s+\{.*\}\s*;/); + next if ($LINE =~ /^struct\s+[a-zA-Z0-9_]+\s*;/); # concetenate function prototypes that stretch over multiple lines $REST = $LINE; -- cgit From 13bfcd5a93c47c9db8b644560a1bcc398facb136 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 11 Sep 2009 15:01:46 +0200 Subject: tdb:mksigs: correctly ignode multiline function typedefs by first concatenating multilint parentheses and removing typefes afterwards. Michael --- lib/tdb/script/mksigs.pl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/tdb/script/mksigs.pl b/lib/tdb/script/mksigs.pl index 3eb90d99dc..ab2e18ec52 100755 --- a/lib/tdb/script/mksigs.pl +++ b/lib/tdb/script/mksigs.pl @@ -118,11 +118,6 @@ while (my $LINE = <>) { } } - next if ($LINE =~ /^typedef\s/); - next if ($LINE =~ /^enum\s+[^\{\(]+\s+\{/); - next if ($LINE =~ /^struct\s+[^\{\(]+\s+\{.*\}\s*;/); - next if ($LINE =~ /^struct\s+[a-zA-Z0-9_]+\s*;/); - # concetenate function prototypes that stretch over multiple lines $REST = $LINE; my $parenthesis = 0; @@ -156,6 +151,11 @@ while (my $LINE = <>) { } } + next if ($LINE =~ /^typedef\s/); + next if ($LINE =~ /^enum\s+[^\{\(]+\s+\{/); + next if ($LINE =~ /^struct\s+[^\{\(]+\s+\{.*\}\s*;/); + next if ($LINE =~ /^struct\s+[a-zA-Z0-9_]+\s*;/); + # remove trailing spaces $LINE =~ s/(.*?)\s*$/$1/; -- cgit From 25939a627f15b7a21110767d47be0f50f32d3943 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 11 Sep 2009 15:11:16 +0200 Subject: tdb:mksigs: ignore symbols (like _DEPRECATED_) after closing function parentheses Michael --- lib/tdb/script/mksigs.pl | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/tdb/script/mksigs.pl b/lib/tdb/script/mksigs.pl index ab2e18ec52..bd76a04a26 100755 --- a/lib/tdb/script/mksigs.pl +++ b/lib/tdb/script/mksigs.pl @@ -160,6 +160,7 @@ while (my $LINE = <>) { $LINE =~ s/(.*?)\s*$/$1/; $LINE =~ s/^(.*\))\s+PRINTF_ATTRIBUTE\(.*\);$/$1;/; + $LINE =~ s/^(.*\))\s*[a-zA-Z0-9_]+\s*;$/$1;/; # remove parameter names - slightly too coarse probably $LINE =~ s/([\s\(]\*?)[_0-9a-zA-Z]+\s*([,\)])/$1$2/g; -- cgit From cfa4e7ec7540d1100649839a10968303189fe929 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 11 Sep 2009 15:16:03 +0200 Subject: tdb:mksigs: normalize bool -> _Bool Michael --- lib/tdb/script/mksigs.pl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/tdb/script/mksigs.pl b/lib/tdb/script/mksigs.pl index bd76a04a26..a34950b09a 100755 --- a/lib/tdb/script/mksigs.pl +++ b/lib/tdb/script/mksigs.pl @@ -176,5 +176,8 @@ while (my $LINE = <>) { # normalize unsigned $LINE =~ s/([\s,\(])unsigned([,\)])/$1unsigned int$2/g; + # normalize bool + $LINE =~ s/(\b)bool(\b)/_Bool/g; + print $LINE . "\n"; } -- cgit From 55dcf928eb6ce603c5e95a9a80856a4deb33d0c6 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 11 Sep 2009 15:20:34 +0200 Subject: tdb:mksigs: allow PRINTF_ATTRIBUTE(..) macros function types as funcion args Michael --- lib/tdb/script/mksigs.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tdb/script/mksigs.pl b/lib/tdb/script/mksigs.pl index a34950b09a..755cd79603 100755 --- a/lib/tdb/script/mksigs.pl +++ b/lib/tdb/script/mksigs.pl @@ -159,7 +159,7 @@ while (my $LINE = <>) { # remove trailing spaces $LINE =~ s/(.*?)\s*$/$1/; - $LINE =~ s/^(.*\))\s+PRINTF_ATTRIBUTE\(.*\);$/$1;/; + $LINE =~ s/^(.*\))\s+PRINTF_ATTRIBUTE\([^\)]*\)(\s*[;,])/$1$2/; $LINE =~ s/^(.*\))\s*[a-zA-Z0-9_]+\s*;$/$1;/; # remove parameter names - slightly too coarse probably -- cgit From fd554799817d9676708d09aa0d71f44195f1d82e Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 11 Sep 2009 14:54:02 +0200 Subject: talloc:mksyms: allow double pointer return value of functions. Michael --- lib/talloc/script/mksyms.awk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/talloc/script/mksyms.awk b/lib/talloc/script/mksyms.awk index a30bea4d34..0d80d9f70b 100644 --- a/lib/talloc/script/mksyms.awk +++ b/lib/talloc/script/mksyms.awk @@ -60,7 +60,7 @@ END { /[_A-Za-z0-9]+[ \t]*[(].*[)][ \t]*;[ \t]*$/ { sub(/[(].*$/, ""); gsub(/[^ \t]+[ \t]+/, ""); - gsub(/^[*]/, ""); + gsub(/^[*]+/, ""); printf "\t\t%s;\n",$0; next; } -- cgit From e60c775835e45cc912660ec253521a9d7f07874c Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 11 Sep 2009 14:54:30 +0200 Subject: talloc:mksyms: allow characters after closing functions parenthesis. Michael --- lib/talloc/script/mksyms.awk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/talloc/script/mksyms.awk b/lib/talloc/script/mksyms.awk index 0d80d9f70b..ca14da0f21 100644 --- a/lib/talloc/script/mksyms.awk +++ b/lib/talloc/script/mksyms.awk @@ -28,7 +28,7 @@ END { current_file=FILENAME } if (inheader) { - if (match($0,"[)][ \t]*[;][ \t]*$")) { + if (match($0,"[)][^()]*[;][ \t]*$")) { inheader = 0; } next; @@ -57,7 +57,7 @@ END { } } -/[_A-Za-z0-9]+[ \t]*[(].*[)][ \t]*;[ \t]*$/ { +/[_A-Za-z0-9]+[ \t]*[(].*[)][^()]*;[ \t]*$/ { sub(/[(].*$/, ""); gsub(/[^ \t]+[ \t]+/, ""); gsub(/^[*]+/, ""); -- cgit From 7b0e0726310c9b5f89af653ed82266a2f02eb357 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 11 Sep 2009 14:55:52 +0200 Subject: talloc:mksigs: ignore struct forward declarations. Michael --- lib/talloc/script/mksigs.pl | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/talloc/script/mksigs.pl b/lib/talloc/script/mksigs.pl index 28a2e747a0..3eb90d99dc 100755 --- a/lib/talloc/script/mksigs.pl +++ b/lib/talloc/script/mksigs.pl @@ -121,6 +121,7 @@ while (my $LINE = <>) { next if ($LINE =~ /^typedef\s/); next if ($LINE =~ /^enum\s+[^\{\(]+\s+\{/); next if ($LINE =~ /^struct\s+[^\{\(]+\s+\{.*\}\s*;/); + next if ($LINE =~ /^struct\s+[a-zA-Z0-9_]+\s*;/); # concetenate function prototypes that stretch over multiple lines $REST = $LINE; -- cgit From 629ff2b6e2ec7fbd1d1ccac8a7466462aa171d4f Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 11 Sep 2009 15:01:46 +0200 Subject: talloc:mksigs: correctly ignode multiline function typedefs by first concatenating multilint parentheses and removing typefes afterwards. Michael --- lib/talloc/script/mksigs.pl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/talloc/script/mksigs.pl b/lib/talloc/script/mksigs.pl index 3eb90d99dc..ab2e18ec52 100755 --- a/lib/talloc/script/mksigs.pl +++ b/lib/talloc/script/mksigs.pl @@ -118,11 +118,6 @@ while (my $LINE = <>) { } } - next if ($LINE =~ /^typedef\s/); - next if ($LINE =~ /^enum\s+[^\{\(]+\s+\{/); - next if ($LINE =~ /^struct\s+[^\{\(]+\s+\{.*\}\s*;/); - next if ($LINE =~ /^struct\s+[a-zA-Z0-9_]+\s*;/); - # concetenate function prototypes that stretch over multiple lines $REST = $LINE; my $parenthesis = 0; @@ -156,6 +151,11 @@ while (my $LINE = <>) { } } + next if ($LINE =~ /^typedef\s/); + next if ($LINE =~ /^enum\s+[^\{\(]+\s+\{/); + next if ($LINE =~ /^struct\s+[^\{\(]+\s+\{.*\}\s*;/); + next if ($LINE =~ /^struct\s+[a-zA-Z0-9_]+\s*;/); + # remove trailing spaces $LINE =~ s/(.*?)\s*$/$1/; -- cgit From 82404ad3e47010f892dfae8e3633a1a8f5de6630 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 11 Sep 2009 15:11:16 +0200 Subject: talloc:mksigs: ignore symbols (like _DEPRECATED_) after closing function parentheses Michael --- lib/talloc/script/mksigs.pl | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/talloc/script/mksigs.pl b/lib/talloc/script/mksigs.pl index ab2e18ec52..bd76a04a26 100755 --- a/lib/talloc/script/mksigs.pl +++ b/lib/talloc/script/mksigs.pl @@ -160,6 +160,7 @@ while (my $LINE = <>) { $LINE =~ s/(.*?)\s*$/$1/; $LINE =~ s/^(.*\))\s+PRINTF_ATTRIBUTE\(.*\);$/$1;/; + $LINE =~ s/^(.*\))\s*[a-zA-Z0-9_]+\s*;$/$1;/; # remove parameter names - slightly too coarse probably $LINE =~ s/([\s\(]\*?)[_0-9a-zA-Z]+\s*([,\)])/$1$2/g; -- cgit From 56c09d2fb23d652e48d5e9e5dcc6557c1a815a6b Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 11 Sep 2009 15:16:03 +0200 Subject: talloc:mksigs: normalize bool -> _Bool Michael --- lib/talloc/script/mksigs.pl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/talloc/script/mksigs.pl b/lib/talloc/script/mksigs.pl index bd76a04a26..a34950b09a 100755 --- a/lib/talloc/script/mksigs.pl +++ b/lib/talloc/script/mksigs.pl @@ -176,5 +176,8 @@ while (my $LINE = <>) { # normalize unsigned $LINE =~ s/([\s,\(])unsigned([,\)])/$1unsigned int$2/g; + # normalize bool + $LINE =~ s/(\b)bool(\b)/_Bool/g; + print $LINE . "\n"; } -- cgit From ea2b9e0fb1dfd433e2dd054272f4ab8a37378178 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 11 Sep 2009 15:20:34 +0200 Subject: talloc:mksigs: allow PRINTF_ATTRIBUTE(..) macros function types as funcion args Michael --- lib/talloc/script/mksigs.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/talloc/script/mksigs.pl b/lib/talloc/script/mksigs.pl index a34950b09a..755cd79603 100755 --- a/lib/talloc/script/mksigs.pl +++ b/lib/talloc/script/mksigs.pl @@ -159,7 +159,7 @@ while (my $LINE = <>) { # remove trailing spaces $LINE =~ s/(.*?)\s*$/$1/; - $LINE =~ s/^(.*\))\s+PRINTF_ATTRIBUTE\(.*\);$/$1;/; + $LINE =~ s/^(.*\))\s+PRINTF_ATTRIBUTE\([^\)]*\)(\s*[;,])/$1$2/; $LINE =~ s/^(.*\))\s*[a-zA-Z0-9_]+\s*;$/$1;/; # remove parameter names - slightly too coarse probably -- cgit From 64bfa26f99b91a84f9fa241a440b6d7d5a8847ae Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 11 Sep 2009 15:36:34 +0200 Subject: tevent:mksyms: fix spelling... Michael --- lib/tevent/script/mksyms.awk | 2 +- lib/tevent/script/mksyms.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/tevent/script/mksyms.awk b/lib/tevent/script/mksyms.awk index ca14da0f21..94a405ca68 100644 --- a/lib/tevent/script/mksyms.awk +++ b/lib/tevent/script/mksyms.awk @@ -4,7 +4,7 @@ # Extract symbols to export from C-header files. # output in version-script format for linking shared libraries. # -# Copyright (C) 2008 Micheal Adam +# Copyright (C) 2008 Michael Adam # BEGIN { inheader=0; diff --git a/lib/tevent/script/mksyms.sh b/lib/tevent/script/mksyms.sh index 714d55abae..7fb4031e2b 100755 --- a/lib/tevent/script/mksyms.sh +++ b/lib/tevent/script/mksyms.sh @@ -8,7 +8,7 @@ # # This is the shell wrapper for the mksyms.awk core script. # -# Copyright (C) 2008 Micheal Adam +# Copyright (C) 2008 Michael Adam # LANG=C; export LANG -- cgit From 50347d6ac061e735b2dd8874d00c663b9f6aeb59 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 11 Sep 2009 15:36:57 +0200 Subject: s3:mksyms: fix spelling... Michael --- source3/script/mksyms.awk | 2 +- source3/script/mksyms.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source3/script/mksyms.awk b/source3/script/mksyms.awk index a30bea4d34..846a283fe1 100644 --- a/source3/script/mksyms.awk +++ b/source3/script/mksyms.awk @@ -4,7 +4,7 @@ # Extract symbols to export from C-header files. # output in version-script format for linking shared libraries. # -# Copyright (C) 2008 Micheal Adam +# Copyright (C) 2008 Michael Adam # BEGIN { inheader=0; diff --git a/source3/script/mksyms.sh b/source3/script/mksyms.sh index 714d55abae..7fb4031e2b 100755 --- a/source3/script/mksyms.sh +++ b/source3/script/mksyms.sh @@ -8,7 +8,7 @@ # # This is the shell wrapper for the mksyms.awk core script. # -# Copyright (C) 2008 Micheal Adam +# Copyright (C) 2008 Michael Adam # LANG=C; export LANG -- cgit From ee1fe382d662998370e66d08bcebbc153fca7b5a Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 11 Sep 2009 14:54:02 +0200 Subject: talloc:mksyms: allow double pointer return value of functions. Michael --- source3/script/mksyms.awk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source3/script/mksyms.awk b/source3/script/mksyms.awk index 846a283fe1..ab28d5a51c 100644 --- a/source3/script/mksyms.awk +++ b/source3/script/mksyms.awk @@ -60,7 +60,7 @@ END { /[_A-Za-z0-9]+[ \t]*[(].*[)][ \t]*;[ \t]*$/ { sub(/[(].*$/, ""); gsub(/[^ \t]+[ \t]+/, ""); - gsub(/^[*]/, ""); + gsub(/^[*]+/, ""); printf "\t\t%s;\n",$0; next; } -- cgit From 9741cb7638d4da777aa7dfa0eb7618b26795a657 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 11 Sep 2009 14:54:30 +0200 Subject: talloc:mksyms: allow characters after closing functions parenthesis. Michael --- source3/script/mksyms.awk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source3/script/mksyms.awk b/source3/script/mksyms.awk index ab28d5a51c..94a405ca68 100644 --- a/source3/script/mksyms.awk +++ b/source3/script/mksyms.awk @@ -28,7 +28,7 @@ END { current_file=FILENAME } if (inheader) { - if (match($0,"[)][ \t]*[;][ \t]*$")) { + if (match($0,"[)][^()]*[;][ \t]*$")) { inheader = 0; } next; @@ -57,7 +57,7 @@ END { } } -/[_A-Za-z0-9]+[ \t]*[(].*[)][ \t]*;[ \t]*$/ { +/[_A-Za-z0-9]+[ \t]*[(].*[)][^()]*;[ \t]*$/ { sub(/[(].*$/, ""); gsub(/[^ \t]+[ \t]+/, ""); gsub(/^[*]+/, ""); -- cgit From a1cf12e1f69a9c1f062ca12e2981a45f9ea27d37 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 11 Sep 2009 13:23:34 +0200 Subject: s3:dbwrap_ctdb: set dmaster in ctdb_transaction_store() also when updating an existing record not only when creating a record. This matches commit e9194a130327d6b05a8ab90bd976475b0e93b06d from ctdb-master. Michael --- source3/lib/dbwrap_ctdb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source3/lib/dbwrap_ctdb.c b/source3/lib/dbwrap_ctdb.c index e38f76fcf6..07dde1e408 100644 --- a/source3/lib/dbwrap_ctdb.c +++ b/source3/lib/dbwrap_ctdb.c @@ -478,7 +478,6 @@ static int db_ctdb_transaction_store(struct db_ctdb_transaction_handle *h, This is only safe because we are in a transaction and this is a persistent database */ ZERO_STRUCT(header); - header.dmaster = get_my_vnn(); } else { memcpy(&header, rec.dptr, sizeof(struct ctdb_ltdb_header)); rec.dsize -= sizeof(struct ctdb_ltdb_header); @@ -492,6 +491,7 @@ static int db_ctdb_transaction_store(struct db_ctdb_transaction_handle *h, SAFE_FREE(rec.dptr); } + header.dmaster = get_my_vnn(); header.rsn++; if (!h->in_replay) { -- cgit From c6dd2c9552b79c0cf68b91cfa6aed3c399323850 Mon Sep 17 00:00:00 2001 From: Matthieu Patou Date: Fri, 11 Sep 2009 19:57:04 +0400 Subject: s4: Fix parsing of CSDVersion: treat this field as an string null terminated. CDSVersion field contains one utf16 string and then garbage which pertubated the parsing. We use subcontext to clearly define the size of the whole blob and then let the parser to find the real length of the string. This is a fix for bug 6706, many thanks to Gunter for the PIDL guidelines. --- librpc/idl/netlogon.idl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/librpc/idl/netlogon.idl b/librpc/idl/netlogon.idl index 7ffc9f2e08..1cc0f2bc20 100644 --- a/librpc/idl/netlogon.idl +++ b/librpc/idl/netlogon.idl @@ -1287,7 +1287,7 @@ interface netlogon uint32 MinorVersion; uint32 BuildNumber; uint32 PlatformId; - [charset(UTF16)] uint16 CSDVersion[128]; + [subcontext(0),subcontext_size(256)] nstring CSDVersion; uint16 ServicePackMajor; uint16 ServicePackMinor; netr_SuiteMask SuiteMask; -- cgit From 5ad756fad3f10863c5257726b119a7082cb84968 Mon Sep 17 00:00:00 2001 From: Matthias Dieter Wallnöfer Date: Fri, 11 Sep 2009 22:03:45 +0200 Subject: netlogon.idl - rerun "make idl" --- librpc/gen_ndr/ndr_netlogon.c | 24 ++++++++++++++++++++++-- librpc/gen_ndr/netlogon.h | 2 +- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/librpc/gen_ndr/ndr_netlogon.c b/librpc/gen_ndr/ndr_netlogon.c index daba526e65..823c174ba5 100644 --- a/librpc/gen_ndr/ndr_netlogon.c +++ b/librpc/gen_ndr/ndr_netlogon.c @@ -7393,7 +7393,17 @@ static enum ndr_err_code ndr_push_netr_OsVersionInfoEx(struct ndr_push *ndr, int NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->MinorVersion)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->BuildNumber)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->PlatformId)); - NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->CSDVersion, 128, sizeof(uint16_t), CH_UTF16)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + { + struct ndr_push *_ndr_CSDVersion; + NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_CSDVersion, 0, 256)); + NDR_CHECK(ndr_push_string(_ndr_CSDVersion, NDR_SCALARS, r->CSDVersion)); + NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_CSDVersion, 0, 256)); + } + ndr->flags = _flags_save_string; + } NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->ServicePackMajor)); NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->ServicePackMinor)); NDR_CHECK(ndr_push_netr_SuiteMask(ndr, NDR_SCALARS, r->SuiteMask)); @@ -7414,7 +7424,17 @@ static enum ndr_err_code ndr_pull_netr_OsVersionInfoEx(struct ndr_pull *ndr, int NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->MinorVersion)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->BuildNumber)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->PlatformId)); - NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->CSDVersion, 128, sizeof(uint16_t), CH_UTF16)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + { + struct ndr_pull *_ndr_CSDVersion; + NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_CSDVersion, 0, 256)); + NDR_CHECK(ndr_pull_string(_ndr_CSDVersion, NDR_SCALARS, &r->CSDVersion)); + NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_CSDVersion, 0, 256)); + } + ndr->flags = _flags_save_string; + } NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->ServicePackMajor)); NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->ServicePackMinor)); NDR_CHECK(ndr_pull_netr_SuiteMask(ndr, NDR_SCALARS, &r->SuiteMask)); diff --git a/librpc/gen_ndr/netlogon.h b/librpc/gen_ndr/netlogon.h index 0a314e13c5..234ea10ff3 100644 --- a/librpc/gen_ndr/netlogon.h +++ b/librpc/gen_ndr/netlogon.h @@ -930,7 +930,7 @@ struct netr_OsVersionInfoEx { uint32_t MinorVersion; uint32_t BuildNumber; uint32_t PlatformId; - const char *CSDVersion;/* [charset(UTF16)] */ + const char * CSDVersion;/* [subcontext_size(256),subcontext(0),flag(LIBNDR_FLAG_STR_NULLTERM)] */ uint16_t ServicePackMajor; uint16_t ServicePackMinor; uint16_t SuiteMask; -- cgit From 10833f641a33d340c03d01bf25551cd1d0d1ef63 Mon Sep 17 00:00:00 2001 From: Matthias Dieter Wallnöfer Date: Fri, 11 Sep 2009 22:41:58 +0200 Subject: s4:group policies - add the domain controller group policy This patches fixes the last difference between s4 and Windows Server regarding group policy objects: we hadn't the domain controller policy. - Adds the domain controller policy as it is found in the "original" AD - Adds also the right version number in the GPT.INI file for the domain group policy (was missing) --- source4/scripting/python/samba/provision.py | 36 ++++++++++++++++++++++------- source4/setup/provision | 7 ++++-- source4/setup/provision.ldif | 1 + source4/setup/provision_group_policy.ldif | 27 +++++++++++++++++++++- 4 files changed, 60 insertions(+), 11 deletions(-) diff --git a/source4/scripting/python/samba/provision.py b/source4/scripting/python/samba/provision.py index 07dfc62e00..19149e92e2 100644 --- a/source4/scripting/python/samba/provision.py +++ b/source4/scripting/python/samba/provision.py @@ -766,7 +766,7 @@ def setup_samdb_rootdse(samdb, setup_path, names): def setup_self_join(samdb, names, machinepass, dnspass, domainsid, invocationid, setup_path, - policyguid, domainControllerFunctionality): + policyguid, policyguid_dc, domainControllerFunctionality): """Join a host to its own domain.""" assert isinstance(invocationid, str) setup_add_ldif(samdb, setup_path("provision_self_join.ldif"), { @@ -788,6 +788,7 @@ def setup_self_join(samdb, names, setup_add_ldif(samdb, setup_path("provision_group_policy.ldif"), { "POLICYGUID": policyguid, + "POLICYGUID_DC": policyguid_dc, "DNSDOMAIN": names.dnsdomain, "DOMAINSID": str(domainsid), "DOMAINDN": names.domaindn}) @@ -814,7 +815,7 @@ def setup_self_join(samdb, names, def setup_samdb(path, setup_path, session_info, credentials, lp, names, message, - domainsid, domainguid, policyguid, + domainsid, domainguid, policyguid, policyguid_dc, fill, adminpass, krbtgtpass, machinepass, invocationid, dnspass, serverrole, schema=None, ldap_backend=None): @@ -969,7 +970,8 @@ def setup_samdb(path, setup_path, session_info, credentials, lp, "NETBIOSNAME": names.netbiosname, "DEFAULTSITE": names.sitename, "CONFIGDN": names.configdn, - "SERVERDN": names.serverdn + "SERVERDN": names.serverdn, + "POLICYGUID_DC": policyguid_dc }) if fill == FILL_FULL: @@ -988,6 +990,7 @@ def setup_samdb(path, setup_path, session_info, credentials, lp, dnspass=dnspass, machinepass=machinepass, domainsid=domainsid, policyguid=policyguid, + policyguid_dc=policyguid_dc, setup_path=setup_path, domainControllerFunctionality=domainControllerFunctionality) # add the NTDSGUID based SPNs @@ -1017,7 +1020,8 @@ def provision(setup_dir, message, session_info, domain=None, hostname=None, hostip=None, hostip6=None, domainsid=None, adminpass=None, ldapadminpass=None, krbtgtpass=None, domainguid=None, - policyguid=None, invocationid=None, machinepass=None, + policyguid=None, policyguid_dc=None, invocationid=None, + machinepass=None, dnspass=None, root=None, nobody=None, users=None, wheel=None, backup=None, aci=None, serverrole=None, ldap_backend_extra_port=None, ldap_backend_type=None, @@ -1038,6 +1042,8 @@ def provision(setup_dir, message, session_info, if policyguid is None: policyguid = str(uuid.uuid4()) + if policyguid_dc is None: + policyguid_dc = str(uuid.uuid4()) if adminpass is None: adminpass = glue.generate_random_str(12) if krbtgtpass is None: @@ -1157,7 +1163,8 @@ def provision(setup_dir, message, session_info, credentials=credentials, lp=lp, names=names, message=message, domainsid=domainsid, - schema=schema, domainguid=domainguid, policyguid=policyguid, + schema=schema, domainguid=domainguid, + policyguid=policyguid, policyguid_dc=policyguid_dc, fill=samdb_fill, adminpass=adminpass, krbtgtpass=krbtgtpass, invocationid=invocationid, @@ -1177,12 +1184,24 @@ def provision(setup_dir, message, session_info, (paths.smbconf, setup_path("provision.smb.conf.dc"))) assert(paths.sysvol is not None) - policy_path = os.path.join(paths.sysvol, names.dnsdomain, "Policies", + # Set up group policies (domain policy and domain controller policy) + + policy_path = os.path.join(paths.sysvol, names.dnsdomain, "Policies", "{" + policyguid + "}") os.makedirs(policy_path, 0755) - open(os.path.join(policy_path, "GPT.INI"), 'w').write("") + open(os.path.join(policy_path, "GPT.INI"), 'w').write( + "[General]\r\nVersion=65544") os.makedirs(os.path.join(policy_path, "Machine"), 0755) os.makedirs(os.path.join(policy_path, "User"), 0755) + + policy_path_dc = os.path.join(paths.sysvol, names.dnsdomain, "Policies", + "{" + policyguid_dc + "}") + os.makedirs(policy_path_dc, 0755) + open(os.path.join(policy_path_dc, "GPT.INI"), 'w').write( + "[General]\r\nVersion=2") + os.makedirs(os.path.join(policy_path_dc, "Machine"), 0755) + os.makedirs(os.path.join(policy_path_dc, "User"), 0755) + if not os.path.isdir(paths.netlogon): os.makedirs(paths.netlogon, 0755) @@ -1316,7 +1335,8 @@ def provision_become_dc(setup_dir=None, configdn=None, serverdn=None, domain=None, hostname=None, domainsid=None, adminpass=None, krbtgtpass=None, domainguid=None, - policyguid=None, invocationid=None, machinepass=None, + policyguid=None, policyguid_dc=None, invocationid=None, + machinepass=None, dnspass=None, root=None, nobody=None, users=None, wheel=None, backup=None, serverrole=None, ldap_backend=None, ldap_backend_type=None, diff --git a/source4/setup/provision b/source4/setup/provision index 27a33122be..8bf08b9e39 100755 --- a/source4/setup/provision +++ b/source4/setup/provision @@ -53,7 +53,9 @@ parser.add_option("--domain-guid", type="string", metavar="GUID", 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") + help="set guid for domain policy") +parser.add_option("--policy-guid-dc", type="string", metavar="GUID", + help="set guid for domain controller policy") parser.add_option("--invocationid", type="string", metavar="GUID", help="set invocationid (otherwise random)") parser.add_option("--host-name", type="string", metavar="HOSTNAME", @@ -181,7 +183,8 @@ provision(setup_dir, message, session, creds, smbconf=smbconf, targetdir=opts.targetdir, samdb_fill=samdb_fill, realm=opts.realm, domain=opts.domain, domainguid=opts.domain_guid, domainsid=opts.domain_sid, - policyguid=opts.policy_guid, hostname=opts.host_name, + policyguid=opts.policy_guid, policyguid_dc=opts.policy_guid_dc, + hostname=opts.host_name, hostip=opts.host_ip, hostip6=opts.host_ip6, invocationid=opts.invocationid, adminpass=opts.adminpass, krbtgtpass=opts.krbtgtpass, machinepass=opts.machinepass, diff --git a/source4/setup/provision.ldif b/source4/setup/provision.ldif index bd224ee60d..b6ad528205 100644 --- a/source4/setup/provision.ldif +++ b/source4/setup/provision.ldif @@ -34,6 +34,7 @@ description: Default container for domain controllers systemFlags: -1946157056 isCriticalSystemObject: TRUE showInAdvancedViewOnly: FALSE +gPLink: [LDAP://CN={${POLICYGUID_DC}},CN=Policies,CN=System,${DOMAINDN};0] # Joined DC located in "provision_self_join.ldif" diff --git a/source4/setup/provision_group_policy.ldif b/source4/setup/provision_group_policy.ldif index 65ab1eaf5f..00f0bee4cc 100644 --- a/source4/setup/provision_group_policy.ldif +++ b/source4/setup/provision_group_policy.ldif @@ -5,7 +5,7 @@ objectClass: groupPolicyContainer displayName: Default Domain Policy gPCFunctionalityVersion: 2 gPCFileSysPath: \\${DNSDOMAIN}\sysvol\${DNSDOMAIN}\Policies\{${POLICYGUID}} -versionNumber: 65543 +versionNumber: 65544 flags: 0 gPCMachineExtensionNames: [{35378EAC-683F-11D2-A89A-00C04FBBCFA2}{53D6AB1B-248 8-11D1-A28C-00C04FB94F17}][{827D319E-6EAC-11D2-A4EA-00C04F79F83A}{803E14A0-B4 @@ -26,3 +26,28 @@ dn: CN=Machine,CN={${POLICYGUID}},CN=Policies,CN=System,${DOMAINDN} objectClass: top objectClass: container systemFlags: -1946157056 + +dn: CN={${POLICYGUID_DC}},CN=Policies,CN=System,${DOMAINDN} +objectClass: top +objectClass: container +objectClass: groupPolicyContainer +displayName: Default Domain Controllers Policy +gPCFunctionalityVersion: 2 +gPCFileSysPath: \\${DNSDOMAIN}\sysvol\${DNSDOMAIN}\Policies\{${POLICYGUID_DC}} +versionNumber: 2 +flags: 0 +gPCMachineExtensionNames: [{827D319E-6EAC-11D2-A4EA-00C04F79F83A}{803E14A0-B4 + FB-11D0-A0D0-00A0C90F574B}] +nTSecurityDescriptor: O:${DOMAINSID}-512G:${DOMAINSID}-512D:PAI(A;CI;RPWPCCDCLCLORCWOWDSDDTSW;;;${DOMAINSID}-512)(A;CI;RPWPCCDCLCLORCWOWDSDDTSW;;;${DOMAINSID}-519)(A;;RPWPCCDCLCLORCWOWDSDDTSW;;;${DOMAINSID}-512)(A;CIIO;RPWPCCDCLCLORCWOWDSDDTSW;;;CO)(A;CI;RPWPCCDCLCLORCWOWDSDDTSW;;;SY)(A;CI;RPLCLORC;;;AU)(OA;CI;CR;edacfd8f-ffb3-11d1-b41d-00a0c968f939;;AU)(A;CI;RPLCLORC;;;ED)S:AI(OU;CIIDSA;WPWD;;f30e3bc2-9ff0-11d1-b603-0000f80367c1;WD)(OU;CIIOIDSA;WP;f30e3bbe-9ff0-11d1-b603-0000f80367c1;bf967aa5-0de6-11d0-a285-00aa003049e2;WD)(OU;CIIOIDSA;WP;f30e3bbf-9ff0-11d1-b603-0000f80367c1;bf967aa5-0de6-11d0-a285-00aa003049e2;WD) +systemFlags: -1946157056 + +dn: CN=User,CN={${POLICYGUID_DC}},CN=Policies,CN=System,${DOMAINDN} +objectClass: top +objectClass: container +systemFlags: -1946157056 + +dn: CN=Machine,CN={${POLICYGUID_DC}},CN=Policies,CN=System,${DOMAINDN} +objectClass: top +objectClass: container +systemFlags: -1946157056 + -- cgit From df65fc02fb6684d86271c89a21f297fd29b8539c Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 11 Sep 2009 23:49:36 +0200 Subject: ldb: Support running testsuite without installing first. --- source4/lib/ldb/Makefile.in | 5 +++-- source4/lib/ldb/ldb.mk | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/source4/lib/ldb/Makefile.in b/source4/lib/ldb/Makefile.in index 663dea9f80..c1f403d550 100644 --- a/source4/lib/ldb/Makefile.in +++ b/source4/lib/ldb/Makefile.in @@ -23,6 +23,7 @@ PACKAGE_VERSION = @PACKAGE_VERSION@ PYTHON = @PYTHON@ PYTHON_CONFIG = @PYTHON_CONFIG@ ldbdir = $(srcdir) +LIB_PATH_VAR = @LIB_PATH_VAR@ LDB_MODULESDIR = @LDB_MODULESDIR@ @@ -146,10 +147,10 @@ realdistclean:: distclean check:: test @PYTHON_CHECK_TARGET@ check-soloading: sample.$(SHLIBEXT) - LDB_MODULES_PATH=$(builddir) $(srcdir)/tests/test-soloading.sh + $(LIB_PATH_VAR)=lib LDB_MODULES_PATH=$(builddir) $(srcdir)/tests/test-soloading.sh test:: all check-soloading - for t in $(TESTS); do echo STARTING $${t}; $(srcdir)/tests/$${t} || exit 1; done + for t in $(TESTS); do echo STARTING $${t}; $(LIB_PATH_VAR)=lib $(srcdir)/tests/$${t} || exit 1; done valgrindtest:: all for t in $(TESTS); do echo STARTING $${t}; VALGRIND="valgrind -q --db-attach=yes --num-callers=30" $(srcdir)/tests/$${t} || exit 1; done diff --git a/source4/lib/ldb/ldb.mk b/source4/lib/ldb/ldb.mk index 4b73a455c9..e87db64574 100644 --- a/source4/lib/ldb/ldb.mk +++ b/source4/lib/ldb/ldb.mk @@ -74,8 +74,8 @@ install-python:: build-python mkdir -p $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(1, prefix='$(prefix)')"` cp ldb.$(SHLIBEXT) $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(1, prefix='$(prefix)')"` -check-python:: build-python - LD_LIBRARY_PATH=lib PYTHONPATH=.:$(ldbdir) $(PYTHON) $(ldbdir)/tests/python/api.py +check-python:: build-python lib/$(SONAME) + $(LIB_PATH_VAR)=lib PYTHONPATH=.:$(ldbdir) $(PYTHON) $(ldbdir)/tests/python/api.py clean:: rm -f ldb.$(SHLIBEXT) -- cgit From d0c9d5ed8eeafe316856ccb654d2297f0078cbb5 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 11 Sep 2009 23:49:57 +0200 Subject: ldb: Remove references to operational module init function. This module is now part of Samba 4's dsdb subsystem rather than standalone ldb. --- source4/lib/ldb/common/ldb_modules.c | 1 - source4/lib/ldb/include/ldb_private.h | 1 - 2 files changed, 2 deletions(-) diff --git a/source4/lib/ldb/common/ldb_modules.c b/source4/lib/ldb/common/ldb_modules.c index 79a97cabed..206b225ca8 100644 --- a/source4/lib/ldb/common/ldb_modules.c +++ b/source4/lib/ldb/common/ldb_modules.c @@ -785,7 +785,6 @@ int ldb_mod_register_control(struct ldb_module *module, const char *oid) LDB_BACKEND(tdb), \ LDAP_BACKEND \ SQLITE3_BACKEND \ - LDB_MODULE(operational), \ LDB_MODULE(rdn_name), \ LDB_MODULE(paged_results), \ LDB_MODULE(server_sort), \ diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index a70d9c704d..c12f33495b 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -123,7 +123,6 @@ int ldb_connect_backend(struct ldb_context *ldb, const char *url, const char *op 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; -- cgit From 97338168e8c7719d6460dc11ae489ecbb218b31d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 12 Sep 2009 00:49:51 +0200 Subject: repl_meta_data: Fix include path when building with standalone ldb. --- source4/dsdb/samdb/ldb_modules/repl_meta_data.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c index fbcde764cc..b9de04a684 100644 --- a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c +++ b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c @@ -48,7 +48,7 @@ #include "librpc/gen_ndr/ndr_drsblobs.h" #include "param/param.h" #include "libcli/security/dom_sid.h" -#include "dlinklist.h" +#include "lib/util/dlinklist.h" struct replmd_private { struct la_entry *la_list; -- cgit From 9014cb64fd9a1068e731d42fc0ffaf39518d1b84 Mon Sep 17 00:00:00 2001 From: Anatoliy Atanasov Date: Thu, 10 Sep 2009 12:41:48 +0300 Subject: Fix up-to-dateness vector creation. --- source4/rpc_server/drsuapi/getncchanges.c | 91 ++++++++++++++++++++++++++----- 1 file changed, 76 insertions(+), 15 deletions(-) diff --git a/source4/rpc_server/drsuapi/getncchanges.c b/source4/rpc_server/drsuapi/getncchanges.c index 3b908fffbc..3388886105 100644 --- a/source4/rpc_server/drsuapi/getncchanges.c +++ b/source4/rpc_server/drsuapi/getncchanges.c @@ -150,6 +150,71 @@ static WERROR get_nc_changes_build_object(struct drsuapi_DsReplicaObjectListItem return WERR_OK; } +static int replmd_drsuapi_DsReplicaCursor2_compare(const struct drsuapi_DsReplicaCursor2 *c1, + const struct drsuapi_DsReplicaCursor2 *c2) +{ + return GUID_compare(&c1->source_dsa_invocation_id, &c2->source_dsa_invocation_id); +} + +static WERROR get_nc_changes_udv(struct drsuapi_DsReplicaCursor2CtrEx *udv, + struct ldb_message *msg, + struct ldb_context *sam_ctx) +{ + uint32_t it_value; + + it_value = ldb_msg_find_attr_as_uint(msg, "instanceType", 0); + if ((it_value & INSTANCE_TYPE_IS_NC_HEAD) == INSTANCE_TYPE_IS_NC_HEAD) { + const struct ldb_val *ouv_value; + struct drsuapi_DsReplicaCursor2 *tmp_cursor; + uint64_t highest_commited_usn; + NTTIME now; + time_t t = time(NULL); + + int ret = ldb_sequence_number(sam_ctx, LDB_SEQ_HIGHEST_SEQ, &highest_commited_usn); + if (ret != LDB_SUCCESS) { + return WERR_DS_DRA_INTERNAL_ERROR; + } + tmp_cursor = talloc(udv, struct drsuapi_DsReplicaCursor2); + tmp_cursor->source_dsa_invocation_id = *(samdb_ntds_invocation_id(sam_ctx)); + tmp_cursor->highest_usn = highest_commited_usn; + unix_to_nt_time(&now, t); + tmp_cursor->last_sync_success = now; + + ouv_value = ldb_msg_find_ldb_val(msg, "replUpToDateVector"); + if (ouv_value) { + struct replUpToDateVectorBlob ouv; + enum ndr_err_code ndr_err; + + ndr_err = ndr_pull_struct_blob(ouv_value, udv, + lp_iconv_convenience(ldb_get_opaque(sam_ctx, "loadparm")), &ouv, + (ndr_pull_flags_fn_t)ndr_pull_replUpToDateVectorBlob); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + return WERR_DS_DRA_INTERNAL_ERROR; + } + if (ouv.version != 2) { + return WERR_DS_DRA_INTERNAL_ERROR; + } + + udv->count = ouv.ctr.ctr2.count + 1; + udv->cursors = talloc_steal(udv, ouv.ctr.ctr2.cursors); + udv->cursors = talloc_realloc(udv, udv->cursors, struct drsuapi_DsReplicaCursor2, udv->count); + if (!udv->cursors) { + return WERR_DS_DRA_INTERNAL_ERROR; + } + udv->cursors[udv->count - 1] = *tmp_cursor; + + qsort(udv->cursors, udv->count, + sizeof(struct drsuapi_DsReplicaCursor2), + (comparison_fn_t)replmd_drsuapi_DsReplicaCursor2_compare); + } else { + udv->count = 1; + udv->cursors = talloc_steal(udv, tmp_cursor); + } + } + + return WERR_OK; +} + /* drsuapi_DsGetNCChanges */ @@ -164,8 +229,6 @@ WERROR dcesrv_drsuapi_DsGetNCChanges(struct dcesrv_call_state *dce_call, TALLOC_ int i; struct dsdb_schema *schema; struct drsuapi_DsReplicaOIDMapping_Ctr *ctr; - time_t t = time(NULL); - NTTIME now; struct drsuapi_DsReplicaObjectListItemEx *currentObject; NTSTATUS status; DATA_BLOB session_key; @@ -244,6 +307,11 @@ WERROR dcesrv_drsuapi_DsGetNCChanges(struct dcesrv_call_state *dce_call, TALLOC_ r->out.ctr->ctr6.old_highwatermark = r->in.req->req8.highwatermark; r->out.ctr->ctr6.new_highwatermark = r->in.req->req8.highwatermark; + r->out.ctr->ctr6.uptodateness_vector = talloc(mem_ctx, struct drsuapi_DsReplicaCursor2CtrEx); + r->out.ctr->ctr6.uptodateness_vector->version = 2; + r->out.ctr->ctr6.uptodateness_vector->reserved1 = 0; + r->out.ctr->ctr6.uptodateness_vector->reserved2 = 0; + r->out.ctr->ctr6.first_object = talloc(mem_ctx, struct drsuapi_DsReplicaObjectListItemEx); currentObject = r->out.ctr->ctr6.first_object; @@ -263,6 +331,12 @@ WERROR dcesrv_drsuapi_DsGetNCChanges(struct dcesrv_call_state *dce_call, TALLOC_ r->out.ctr->ctr6.first_object = NULL; return werr; } + + werr = get_nc_changes_udv(r->out.ctr->ctr6.uptodateness_vector, site_res->msgs[i], sam_ctx); + if (!W_ERROR_IS_OK(werr)) { + return werr; + } + if (i == (site_res->count-1)) { break; } @@ -270,18 +344,5 @@ WERROR dcesrv_drsuapi_DsGetNCChanges(struct dcesrv_call_state *dce_call, TALLOC_ currentObject = currentObject->next_object; } - r->out.ctr->ctr6.uptodateness_vector = talloc(mem_ctx, struct drsuapi_DsReplicaCursor2CtrEx); - - r->out.ctr->ctr6.uptodateness_vector->version = 2; - r->out.ctr->ctr6.uptodateness_vector->count = 1; - r->out.ctr->ctr6.uptodateness_vector->reserved1 = 0; - r->out.ctr->ctr6.uptodateness_vector->reserved2 = 0; - r->out.ctr->ctr6.uptodateness_vector->cursors = talloc(mem_ctx, struct drsuapi_DsReplicaCursor2); - - r->out.ctr->ctr6.uptodateness_vector->cursors[0].source_dsa_invocation_id = *(samdb_ntds_invocation_id(sam_ctx)); - r->out.ctr->ctr6.uptodateness_vector->cursors[0].highest_usn = r->out.ctr->ctr6.new_highwatermark.highest_usn; - unix_to_nt_time(&now, t); - r->out.ctr->ctr6.uptodateness_vector->cursors[0].last_sync_success = now; - return WERR_OK; } -- cgit From 0ba9a1bd3f2f0b278a86f6e244162b0efa7dd510 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 12 Sep 2009 11:09:10 +1000 Subject: s4-kcc: we should only add to the repsFrom if it doesn't already exist If we already have a repsFrom for a particular DC and naming context then we should not overwrite it, as it contains info on what replication we've already done --- source4/dsdb/common/util.c | 111 ++++++++++++++++++++++++++++++++++++++ source4/dsdb/kcc/kcc_periodic.c | 116 ++++++++++++++++++++++++---------------- 2 files changed, 182 insertions(+), 45 deletions(-) diff --git a/source4/dsdb/common/util.c b/source4/dsdb/common/util.c index 6da02b0b6a..b5005444cc 100644 --- a/source4/dsdb/common/util.c +++ b/source4/dsdb/common/util.c @@ -36,6 +36,7 @@ #include "libcli/ldap/ldap_ndr.h" #include "param/param.h" #include "libcli/auth/libcli_auth.h" +#include "librpc/gen_ndr/ndr_drsblobs.h" /* search the sam for the specified attributes in a specific domain, filter on @@ -2146,3 +2147,113 @@ int dsdb_find_guid_by_dn(struct ldb_context *ldb, talloc_free(tmp_ctx); return LDB_SUCCESS; } + + + +/* + load a repsFromTo blob list for a given partition GUID + attr must be "repsFrom" or "repsTo" + */ +WERROR dsdb_loadreps(struct ldb_context *sam_ctx, TALLOC_CTX *mem_ctx, struct ldb_dn *dn, + const char *attr, struct repsFromToBlob **r, uint32_t *count) +{ + const char *attrs[] = { attr, NULL }; + struct ldb_result *res = NULL; + TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx); + int i; + struct ldb_message_element *el; + + *r = NULL; + *count = 0; + + if (ldb_search(sam_ctx, tmp_ctx, &res, dn, LDB_SCOPE_BASE, attrs, NULL) != LDB_SUCCESS || + res->count < 1) { + DEBUG(0,("dsdb_loadreps: failed to read partition object\n")); + talloc_free(tmp_ctx); + return WERR_DS_DRA_INTERNAL_ERROR; + } + + el = ldb_msg_find_element(res->msgs[0], attr); + if (el == NULL) { + /* it's OK to be empty */ + talloc_free(tmp_ctx); + return WERR_OK; + } + + *count = el->num_values; + *r = talloc_array(mem_ctx, struct repsFromToBlob, *count); + if (*r == NULL) { + talloc_free(tmp_ctx); + return WERR_DS_DRA_INTERNAL_ERROR; + } + + for (i=0; i<(*count); i++) { + enum ndr_err_code ndr_err; + ndr_err = ndr_pull_struct_blob(&el->values[i], + mem_ctx, lp_iconv_convenience(ldb_get_opaque(sam_ctx, "loadparm")), + &(*r)[i], + (ndr_pull_flags_fn_t)ndr_pull_repsFromToBlob); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(tmp_ctx); + return WERR_DS_DRA_INTERNAL_ERROR; + } + } + + talloc_free(tmp_ctx); + + return WERR_OK; +} + +/* + save the repsFromTo blob list for a given partition GUID + attr must be "repsFrom" or "repsTo" + */ +WERROR dsdb_savereps(struct ldb_context *sam_ctx, TALLOC_CTX *mem_ctx, struct ldb_dn *dn, + const char *attr, struct repsFromToBlob *r, uint32_t count) +{ + TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx); + struct ldb_message *msg; + struct ldb_message_element *el; + int i; + + msg = ldb_msg_new(tmp_ctx); + msg->dn = dn; + if (ldb_msg_add_empty(msg, attr, LDB_FLAG_MOD_REPLACE, &el) != LDB_SUCCESS) { + goto failed; + } + + el->values = talloc_array(msg, struct ldb_val, count); + if (!el->values) { + goto failed; + } + + for (i=0; inum_values++; + el->values[i] = v; + } + + if (ldb_modify(sam_ctx, msg) != LDB_SUCCESS) { + DEBUG(0,("Failed to store %s - %s\n", attr, ldb_errstring(sam_ctx))); + goto failed; + } + + talloc_free(tmp_ctx); + + return WERR_OK; + +failed: + talloc_free(tmp_ctx); + return WERR_DS_DRA_INTERNAL_ERROR; +} + + diff --git a/source4/dsdb/kcc/kcc_periodic.c b/source4/dsdb/kcc/kcc_periodic.c index 649efd51ca..3af79d8b89 100644 --- a/source4/dsdb/kcc/kcc_periodic.c +++ b/source4/dsdb/kcc/kcc_periodic.c @@ -35,10 +35,70 @@ #include "param/param.h" /* - * add a repsFrom to all our partitions + * see if a repsFromToBlob is in a list */ +static bool reps_in_list(struct repsFromToBlob *r, struct repsFromToBlob *reps, uint32_t count) +{ + int i; + for (i=0; ictr.ctr1.other_info->dns_name, + reps[i].ctr.ctr1.other_info->dns_name) == 0 && + GUID_compare(&r->ctr.ctr1.source_dsa_obj_guid, + &reps[i].ctr.ctr1.source_dsa_obj_guid) == 0) { + return true; + } + } + return false; +} +/* + * add any missing repsFrom structures to our partitions + */ +static NTSTATUS kccsrv_add_repsFrom(struct kccsrv_service *s, TALLOC_CTX *mem_ctx, + struct repsFromToBlob *reps, uint32_t count) +{ + struct kccsrv_partition *p; + + /* update the repsFrom on all partitions */ + for (p=s->partitions; p; p=p->next) { + struct repsFromToBlob *old_reps; + uint32_t old_count; + WERROR werr; + int i; + bool modified = false; + + werr = dsdb_loadreps(s->samdb, mem_ctx, p->dn, "repsFrom", &old_reps, &old_count); + if (!W_ERROR_IS_OK(werr)) { + DEBUG(0,(__location__ ": Failed to load repsFrom from %s - %s\n", + ldb_dn_get_linearized(p->dn), ldb_errstring(s->samdb))); + return NT_STATUS_INTERNAL_DB_CORRUPTION; + } + + for (i=0; isamdb, mem_ctx, p->dn, "repsFrom", old_reps, old_count); + if (!W_ERROR_IS_OK(werr)) { + DEBUG(0,(__location__ ": Failed to save repsFrom to %s - %s\n", + ldb_dn_get_linearized(p->dn), ldb_errstring(s->samdb))); + return NT_STATUS_INTERNAL_DB_CORRUPTION; + } + } + } + + return NT_STATUS_OK; + +} + /* this is the core of our initial simple KCC We just add a repsFrom entry for all DCs we find that have nTDSDSA @@ -49,9 +109,8 @@ static NTSTATUS kccsrv_simple_update(struct kccsrv_service *s, TALLOC_CTX *mem_c struct ldb_result *res; int ret, i; const char *attrs[] = { "objectGUID", "invocationID", NULL }; - struct ldb_message *msg; - struct ldb_message_element *el; - struct kccsrv_partition *p; + struct repsFromToBlob *reps = NULL; + uint32_t count = 0; ret = ldb_search(s->samdb, mem_ctx, &res, s->config_dn, LDB_SCOPE_SUBTREE, attrs, "objectClass=nTDSDSA"); @@ -60,21 +119,10 @@ static NTSTATUS kccsrv_simple_update(struct kccsrv_service *s, TALLOC_CTX *mem_c return NT_STATUS_INTERNAL_DB_CORRUPTION; } - msg = ldb_msg_new(mem_ctx); - NT_STATUS_HAVE_NO_MEMORY(msg); - - ret = ldb_msg_add_empty(msg, "repsFrom", LDB_FLAG_MOD_REPLACE, &el); - if (ret != LDB_SUCCESS) { - return NT_STATUS_NO_MEMORY; - } - for (i=0; icount; i++) { - struct repsFromToBlob r; struct repsFromTo1 *r1; struct repsFromTo1OtherInfo oi; struct GUID ntds_guid, invocation_id; - struct ldb_val v; - enum ndr_err_code ndr_err; ntds_guid = samdb_result_guid(res->msgs[i], "objectGUID"); if (GUID_compare(&ntds_guid, &s->ntds_guid) == 0) { @@ -84,10 +132,13 @@ static NTSTATUS kccsrv_simple_update(struct kccsrv_service *s, TALLOC_CTX *mem_c invocation_id = samdb_result_guid(res->msgs[i], "invocationID"); - ZERO_STRUCT(r); + reps = talloc_realloc(mem_ctx, reps, struct repsFromToBlob, count+1); + NT_STATUS_HAVE_NO_MEMORY(reps); + + ZERO_STRUCT(reps[count]); ZERO_STRUCT(oi); - r.version = 1; - r1 = &r.ctr.ctr1; + reps[count].version = 1; + r1 = &reps[count].ctr.ctr1; oi.dns_name = talloc_asprintf(mem_ctx, "%s._msdcs.%s", GUID_string(mem_ctx, &ntds_guid), @@ -100,35 +151,10 @@ static NTSTATUS kccsrv_simple_update(struct kccsrv_service *s, TALLOC_CTX *mem_c DRSUAPI_DS_REPLICA_NEIGHBOUR_SYNC_ON_STARTUP | DRSUAPI_DS_REPLICA_NEIGHBOUR_DO_SCHEDULED_SYNCS; memset(r1->schedule, 0x11, sizeof(r1->schedule)); - - - ndr_err = ndr_push_struct_blob(&v, mem_ctx, - lp_iconv_convenience(s->task->lp_ctx), - &r, - (ndr_push_flags_fn_t)ndr_push_repsFromToBlob); - if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - DEBUG(0,(__location__ ": Failed tp push repsFrom blob\n")); - return NT_STATUS_INTERNAL_ERROR; - } - - el->values = talloc_realloc(msg, el->values, struct ldb_val, el->num_values+1); - NT_STATUS_HAVE_NO_MEMORY(el->values); - el->values[el->num_values] = v; - el->num_values++; - } - - /* replace the repsFrom on all partitions */ - for (p=s->partitions; p; p=p->next) { - msg->dn = p->dn; - ret = ldb_modify(s->samdb, msg); - if (ret != LDB_SUCCESS) { - DEBUG(0,(__location__ ": Failed to store repsFrom for %s - %s\n", - ldb_dn_get_linearized(msg->dn), ldb_errstring(s->samdb))); - return NT_STATUS_INTERNAL_ERROR; - } + count++; } - return NT_STATUS_OK; + return kccsrv_add_repsFrom(s, mem_ctx, reps, count); } -- cgit From 94183eb7e617dbfead93b9342bc85ebb27d93903 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 12 Sep 2009 11:10:19 +1000 Subject: s4-repl: we should only update uSNChanged when replication data changes When changing non-replicated attributes we should not update the uSNChanged attribute on the record, otherwise the DRS server will think this record needs replicating. --- source4/dsdb/samdb/ldb_modules/repl_meta_data.c | 68 ++++++++++++++----------- 1 file changed, 39 insertions(+), 29 deletions(-) diff --git a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c index b9de04a684..5000c56d4e 100644 --- a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c +++ b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c @@ -280,7 +280,7 @@ static int replmd_add(struct ldb_module *module, struct ldb_request *req) schema = dsdb_get_schema(ldb); if (!schema) { ldb_debug_set(ldb, LDB_DEBUG_FATAL, - "replmd_modify: no dsdb_schema loaded"); + "replmd_add: no dsdb_schema loaded"); return LDB_ERR_CONSTRAINT_VIOLATION; } @@ -475,10 +475,9 @@ static int replmd_update_rpmd_element(struct ldb_context *ldb, struct ldb_message_element *el, struct replPropertyMetaDataBlob *omd, struct dsdb_schema *schema, - uint64_t seq_num, + uint64_t *seq_num, const struct GUID *our_invocation_id, - NTTIME now, - bool *modified) + NTTIME now) { int i; const struct dsdb_attribute *a; @@ -512,15 +511,25 @@ static int replmd_update_rpmd_element(struct ldb_context *ldb, omd->ctr.ctr1.count++; } + /* Get a new sequence number from the backend. We only do this + * if we have a change that requires a new + * replPropertyMetaData element + */ + if (*seq_num == 0) { + int ret = ldb_sequence_number(ldb, LDB_SEQ_NEXT, seq_num); + if (ret != LDB_SUCCESS) { + return LDB_ERR_OPERATIONS_ERROR; + } + } + md1 = &omd->ctr.ctr1.array[i]; md1->version = 1; md1->attid = a->attributeID_id; md1->originating_change_time = now; md1->originating_invocation_id = *our_invocation_id; - md1->originating_usn = seq_num; - md1->local_usn = seq_num; + md1->originating_usn = *seq_num; + md1->local_usn = *seq_num; - *modified = true; return LDB_SUCCESS; } @@ -530,13 +539,12 @@ static int replmd_update_rpmd_element(struct ldb_context *ldb, * client is based on this object */ static int replmd_update_rpmd(struct ldb_context *ldb, struct ldb_message *msg, - uint64_t seq_num) + uint64_t *seq_num) { const struct ldb_val *omd_value; enum ndr_err_code ndr_err; struct replPropertyMetaDataBlob omd; int i; - bool modified = false; struct dsdb_schema *schema; time_t t = time(NULL); NTTIME now; @@ -590,13 +598,17 @@ static int replmd_update_rpmd(struct ldb_context *ldb, struct ldb_message *msg, for (i=0; inum_elements; i++) { ret = replmd_update_rpmd_element(ldb, msg, &msg->elements[i], &omd, schema, seq_num, - our_invocation_id, now, &modified); + our_invocation_id, now); if (ret != LDB_SUCCESS) { return ret; } } - if (modified) { + /* + * replmd_update_rpmd_element has done an update if the + * seq_num is set + */ + if (*seq_num != 0) { struct ldb_val *md_value; struct ldb_message_element *el; @@ -640,7 +652,7 @@ static int replmd_modify(struct ldb_module *module, struct ldb_request *req) struct ldb_message *msg; int ret; time_t t = time(NULL); - uint64_t seq_num; + uint64_t seq_num = 0; /* do not manipulate our control entries */ if (ldb_dn_is_special(req->op.mod.message->dn)) { @@ -683,27 +695,11 @@ static int replmd_modify(struct ldb_module *module, struct ldb_request *req) * attribute was changed */ - /* Get a sequence number from the backend */ - ret = ldb_sequence_number(ldb, LDB_SEQ_NEXT, &seq_num); - if (ret != LDB_SUCCESS) { - return LDB_ERR_OPERATIONS_ERROR; - } - - ret = replmd_update_rpmd(ldb, msg, seq_num); + ret = replmd_update_rpmd(ldb, msg, &seq_num); if (ret != LDB_SUCCESS) { return ret; } - if (add_time_element(msg, "whenChanged", t) != LDB_SUCCESS) { - talloc_free(ac); - return LDB_ERR_OPERATIONS_ERROR; - } - - if (add_uint64_element(msg, "uSNChanged", seq_num) != LDB_SUCCESS) { - talloc_free(ac); - return LDB_ERR_OPERATIONS_ERROR; - } - /* TODO: * - sort the attributes by attid with replmd_ldb_message_sort() * - replace the old object with the newly constructed one @@ -719,6 +715,20 @@ static int replmd_modify(struct ldb_module *module, struct ldb_request *req) } talloc_steal(down_req, msg); + /* we only change whenChanged and uSNChanged if the seq_num + has changed */ + if (seq_num != 0) { + if (add_time_element(msg, "whenChanged", t) != LDB_SUCCESS) { + talloc_free(ac); + return LDB_ERR_OPERATIONS_ERROR; + } + + if (add_uint64_element(msg, "uSNChanged", seq_num) != LDB_SUCCESS) { + talloc_free(ac); + return LDB_ERR_OPERATIONS_ERROR; + } + } + /* go on with the call chain */ return ldb_next_request(module, down_req); } -- cgit From 5da0a7e1a1ea55554a56d08ca3d3e55825cfedaa Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 12 Sep 2009 11:12:05 +1000 Subject: s4-repl: use common functions to simplify updaterefs.c We now have dsdb_loadreps() and dsdb_savereps() --- source4/rpc_server/drsuapi/updaterefs.c | 112 ++------------------------------ 1 file changed, 4 insertions(+), 108 deletions(-) diff --git a/source4/rpc_server/drsuapi/updaterefs.c b/source4/rpc_server/drsuapi/updaterefs.c index 92027ba455..45244c7801 100644 --- a/source4/rpc_server/drsuapi/updaterefs.c +++ b/source4/rpc_server/drsuapi/updaterefs.c @@ -35,110 +35,6 @@ struct repsTo { struct repsFromToBlob *r; }; -/* - load the repsTo structure for a given partition GUID - */ -static WERROR uref_loadreps(struct ldb_context *sam_ctx, TALLOC_CTX *mem_ctx, struct ldb_dn *dn, - struct repsTo *reps) -{ - const char *attrs[] = { "repsTo", NULL }; - struct ldb_result *res; - TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx); - int i; - struct ldb_message_element *el; - - /* TODO: possibly check in the rootDSE to see that this DN is - * one of our partition roots */ - - if (ldb_search(sam_ctx, tmp_ctx, &res, dn, LDB_SCOPE_BASE, attrs, NULL) != LDB_SUCCESS) { - DEBUG(0,("drsuapi_addref: failed to read partition object\n")); - talloc_free(tmp_ctx); - return WERR_DS_DRA_INTERNAL_ERROR; - } - - ZERO_STRUCTP(reps); - - el = ldb_msg_find_element(res->msgs[0], "repsTo"); - if (el == NULL) { - talloc_free(tmp_ctx); - return WERR_OK; - } - - reps->count = el->num_values; - reps->r = talloc_array(mem_ctx, struct repsFromToBlob, reps->count); - if (reps->r == NULL) { - talloc_free(tmp_ctx); - return WERR_DS_DRA_INTERNAL_ERROR; - } - - for (i=0; icount; i++) { - enum ndr_err_code ndr_err; - ndr_err = ndr_pull_struct_blob(&el->values[i], - mem_ctx, lp_iconv_convenience(ldb_get_opaque(sam_ctx, "loadparm")), - &reps->r[i], - (ndr_pull_flags_fn_t)ndr_pull_repsFromToBlob); - if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - talloc_free(tmp_ctx); - return WERR_DS_DRA_INTERNAL_ERROR; - } - } - - talloc_free(tmp_ctx); - - return WERR_OK; -} - -/* - save the repsTo structure for a given partition GUID - */ -static WERROR uref_savereps(struct ldb_context *sam_ctx, TALLOC_CTX *mem_ctx, struct ldb_dn *dn, - struct repsTo *reps) -{ - TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx); - struct ldb_message *msg; - struct ldb_message_element *el; - int i; - - msg = ldb_msg_new(tmp_ctx); - msg->dn = dn; - if (ldb_msg_add_empty(msg, "repsTo", LDB_FLAG_MOD_REPLACE, &el) != LDB_SUCCESS) { - goto failed; - } - - el->values = talloc_array(msg, struct ldb_val, reps->count); - if (!el->values) { - goto failed; - } - - for (i=0; icount; i++) { - struct ldb_val v; - enum ndr_err_code ndr_err; - - ndr_err = ndr_push_struct_blob(&v, tmp_ctx, lp_iconv_convenience(ldb_get_opaque(sam_ctx, "loadparm")), - &reps->r[i], - (ndr_push_flags_fn_t)ndr_push_repsFromToBlob); - if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - goto failed; - } - - el->num_values++; - el->values[i] = v; - } - - if (ldb_modify(sam_ctx, msg) != LDB_SUCCESS) { - DEBUG(0,("Failed to store repsTo - %s\n", ldb_errstring(sam_ctx))); - goto failed; - } - - talloc_free(tmp_ctx); - - return WERR_OK; - -failed: - talloc_free(tmp_ctx); - return WERR_DS_DRA_INTERNAL_ERROR; -} - /* add a replication destination for a given partition GUID */ @@ -148,7 +44,7 @@ static WERROR uref_add_dest(struct ldb_context *sam_ctx, TALLOC_CTX *mem_ctx, struct repsTo reps; WERROR werr; - werr = uref_loadreps(sam_ctx, mem_ctx, dn, &reps); + werr = dsdb_loadreps(sam_ctx, mem_ctx, dn, "repsTo", &reps.r, &reps.count); if (!W_ERROR_IS_OK(werr)) { return werr; } @@ -162,7 +58,7 @@ static WERROR uref_add_dest(struct ldb_context *sam_ctx, TALLOC_CTX *mem_ctx, reps.r[reps.count].ctr.ctr1 = *dest; reps.count++; - werr = uref_savereps(sam_ctx, mem_ctx, dn, &reps); + werr = dsdb_savereps(sam_ctx, mem_ctx, dn, "repsTo", reps.r, reps.count); if (!W_ERROR_IS_OK(werr)) { return werr; } @@ -180,7 +76,7 @@ static WERROR uref_del_dest(struct ldb_context *sam_ctx, TALLOC_CTX *mem_ctx, WERROR werr; int i; - werr = uref_loadreps(sam_ctx, mem_ctx, dn, &reps); + werr = dsdb_loadreps(sam_ctx, mem_ctx, dn, "repsTo", &reps.r, &reps.count); if (!W_ERROR_IS_OK(werr)) { return werr; } @@ -194,7 +90,7 @@ static WERROR uref_del_dest(struct ldb_context *sam_ctx, TALLOC_CTX *mem_ctx, } } - werr = uref_savereps(sam_ctx, mem_ctx, dn, &reps); + werr = dsdb_savereps(sam_ctx, mem_ctx, dn, "repsTo", reps.r, reps.count); if (!W_ERROR_IS_OK(werr)) { return werr; } -- cgit From bbc0a56da59df8b7cd6f19f99cfaac9c3909779f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 12 Sep 2009 11:14:29 +1000 Subject: s4-drs: fixed the cursor generation to always be filled in We were relying on the uSNChanged>=n search always finding the DN of the root of the partition, but this now doesn't happen very often as we are now restricting when we change uSNChanged. This means we need to always load the replUpToDateVector attribute from the NC root and use it to populate the cursors in the return. --- source4/rpc_server/drsuapi/getncchanges.c | 254 ++++++++++++++++++------------ 1 file changed, 152 insertions(+), 102 deletions(-) diff --git a/source4/rpc_server/drsuapi/getncchanges.c b/source4/rpc_server/drsuapi/getncchanges.c index 3388886105..725a380f89 100644 --- a/source4/rpc_server/drsuapi/getncchanges.c +++ b/source4/rpc_server/drsuapi/getncchanges.c @@ -42,14 +42,17 @@ static WERROR get_nc_changes_build_object(struct drsuapi_DsReplicaObjectListItem struct ldb_context *sam_ctx, struct ldb_dn *ncRoot_dn, struct dsdb_schema *schema, - DATA_BLOB *session_key) + DATA_BLOB *session_key, + uint64_t highest_usn) { const struct ldb_val *md_value; - int i; + int i, n; struct ldb_dn *obj_dn; struct replPropertyMetaDataBlob md; struct dom_sid *sid; uint32_t rid = 0; + enum ndr_err_code ndr_err; + uint32_t *attids; if (ldb_dn_compare(ncRoot_dn, msg->dn) == 0) { obj->is_nc_prefix = true; @@ -61,34 +64,44 @@ static WERROR get_nc_changes_build_object(struct drsuapi_DsReplicaObjectListItem } obj->next_object = NULL; - obj->meta_data_ctr = talloc(obj, struct drsuapi_DsReplicaMetaDataCtr); md_value = ldb_msg_find_ldb_val(msg, "replPropertyMetaData"); - if (md_value) { - enum ndr_err_code ndr_err; - ndr_err = ndr_pull_struct_blob(md_value, obj, - lp_iconv_convenience(ldb_get_opaque(sam_ctx, "loadparm")), &md, - (ndr_pull_flags_fn_t)ndr_pull_replPropertyMetaDataBlob); - if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - return WERR_DS_DRA_INTERNAL_ERROR; - } - - if (md.version != 1) { - return WERR_DS_DRA_INTERNAL_ERROR; - } - - obj->meta_data_ctr->count = md.ctr.ctr1.count; - obj->meta_data_ctr->meta_data = talloc_array(obj, struct drsuapi_DsReplicaMetaData, md.ctr.ctr1.count); - for (i=0; imeta_data_ctr->meta_data[i].originating_change_time = md.ctr.ctr1.array[i].originating_change_time; - obj->meta_data_ctr->meta_data[i].version = md.ctr.ctr1.array[i].version; - obj->meta_data_ctr->meta_data[i].originating_invocation_id = md.ctr.ctr1.array[i].originating_invocation_id; - obj->meta_data_ctr->meta_data[i].originating_usn = md.ctr.ctr1.array[i].originating_usn; - } - } else { - obj->meta_data_ctr->meta_data = talloc(obj, struct drsuapi_DsReplicaMetaData); - obj->meta_data_ctr->count = 0; - ZERO_STRUCT(md); + if (!md_value) { + /* nothing to send */ + return WERR_OK; + } + + ndr_err = ndr_pull_struct_blob(md_value, obj, + lp_iconv_convenience(ldb_get_opaque(sam_ctx, "loadparm")), &md, + (ndr_pull_flags_fn_t)ndr_pull_replPropertyMetaDataBlob); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + return WERR_DS_DRA_INTERNAL_ERROR; + } + + if (md.version != 1) { + return WERR_DS_DRA_INTERNAL_ERROR; } + + obj->meta_data_ctr = talloc(obj, struct drsuapi_DsReplicaMetaDataCtr); + attids = talloc_array(obj, uint32_t, md.ctr.ctr1.count); + + obj->meta_data_ctr->meta_data = talloc_array(obj, struct drsuapi_DsReplicaMetaData, md.ctr.ctr1.count); + for (n=i=0; imeta_data_ctr->meta_data[n].originating_change_time = md.ctr.ctr1.array[i].originating_change_time; + obj->meta_data_ctr->meta_data[n].version = md.ctr.ctr1.array[i].version; + obj->meta_data_ctr->meta_data[n].originating_invocation_id = md.ctr.ctr1.array[i].originating_invocation_id; + obj->meta_data_ctr->meta_data[n].originating_usn = md.ctr.ctr1.array[i].originating_usn; + attids[n] = md.ctr.ctr1.array[i].attid; + n++; + } + if (n == 0) { + /* nothing to send */ + talloc_free(obj->meta_data_ctr); + obj->meta_data_ctr = NULL; + return WERR_OK; + } + obj->meta_data_ctr->count = n; + obj->object.identifier = talloc(obj, struct drsuapi_DsReplicaObjectIdentifier); obj_dn = ldb_msg_find_attr_as_dn(sam_ctx, obj, msg, "distinguishedName"); obj->object.identifier->dn = ldb_dn_get_linearized(obj_dn); @@ -114,18 +127,18 @@ static WERROR get_nc_changes_build_object(struct drsuapi_DsReplicaObjectListItem struct ldb_message_element *el; WERROR werr; - sa = dsdb_attribute_by_attributeID_id(schema, md.ctr.ctr1.array[i].attid); + sa = dsdb_attribute_by_attributeID_id(schema, attids[i]); if (!sa) { - DEBUG(0,("Unable to find attributeID %u in schema\n", md.ctr.ctr1.array[i].attid)); + DEBUG(0,("Unable to find attributeID %u in schema\n", attids[i])); return WERR_DS_DRA_INTERNAL_ERROR; } el = ldb_msg_find_element(msg, sa->lDAPDisplayName); if (el == NULL) { DEBUG(0,("No element '%s' for attributeID %u in message\n", - sa->lDAPDisplayName, md.ctr.ctr1.array[i].attid)); + sa->lDAPDisplayName, attids[i])); ZERO_STRUCT(obj->object.attribute_ctr.attributes[i]); - obj->object.attribute_ctr.attributes[i].attid = md.ctr.ctr1.array[i].attid; + obj->object.attribute_ctr.attributes[i].attid = attids[i]; } else { werr = dsdb_attribute_ldb_to_drsuapi(sam_ctx, schema, el, obj, &obj->object.attribute_ctr.attributes[i]); @@ -156,62 +169,92 @@ static int replmd_drsuapi_DsReplicaCursor2_compare(const struct drsuapi_DsReplic return GUID_compare(&c1->source_dsa_invocation_id, &c2->source_dsa_invocation_id); } -static WERROR get_nc_changes_udv(struct drsuapi_DsReplicaCursor2CtrEx *udv, - struct ldb_message *msg, - struct ldb_context *sam_ctx) +/* + load replUpToDateVector from a DN + */ +static WERROR load_udv(struct ldb_context *sam_ctx, TALLOC_CTX *mem_ctx, + struct ldb_dn *dn, struct replUpToDateVectorBlob *ouv) { - uint32_t it_value; - - it_value = ldb_msg_find_attr_as_uint(msg, "instanceType", 0); - if ((it_value & INSTANCE_TYPE_IS_NC_HEAD) == INSTANCE_TYPE_IS_NC_HEAD) { - const struct ldb_val *ouv_value; - struct drsuapi_DsReplicaCursor2 *tmp_cursor; - uint64_t highest_commited_usn; - NTTIME now; - time_t t = time(NULL); - - int ret = ldb_sequence_number(sam_ctx, LDB_SEQ_HIGHEST_SEQ, &highest_commited_usn); - if (ret != LDB_SUCCESS) { - return WERR_DS_DRA_INTERNAL_ERROR; - } - tmp_cursor = talloc(udv, struct drsuapi_DsReplicaCursor2); - tmp_cursor->source_dsa_invocation_id = *(samdb_ntds_invocation_id(sam_ctx)); - tmp_cursor->highest_usn = highest_commited_usn; - unix_to_nt_time(&now, t); - tmp_cursor->last_sync_success = now; - - ouv_value = ldb_msg_find_ldb_val(msg, "replUpToDateVector"); - if (ouv_value) { - struct replUpToDateVectorBlob ouv; - enum ndr_err_code ndr_err; - - ndr_err = ndr_pull_struct_blob(ouv_value, udv, - lp_iconv_convenience(ldb_get_opaque(sam_ctx, "loadparm")), &ouv, - (ndr_pull_flags_fn_t)ndr_pull_replUpToDateVectorBlob); - if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - return WERR_DS_DRA_INTERNAL_ERROR; - } - if (ouv.version != 2) { - return WERR_DS_DRA_INTERNAL_ERROR; - } + const char *attrs[] = { "replUpToDateVector", NULL }; + struct ldb_result *res = NULL; + TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx); + struct ldb_message_element *el; + enum ndr_err_code ndr_err; + + ZERO_STRUCTP(ouv); + + if (ldb_search(sam_ctx, tmp_ctx, &res, dn, LDB_SCOPE_BASE, attrs, NULL) != LDB_SUCCESS || + res->count < 1) { + DEBUG(0,("load_udv: failed to read partition object\n")); + talloc_free(tmp_ctx); + return WERR_DS_DRA_INTERNAL_ERROR; + } - udv->count = ouv.ctr.ctr2.count + 1; - udv->cursors = talloc_steal(udv, ouv.ctr.ctr2.cursors); - udv->cursors = talloc_realloc(udv, udv->cursors, struct drsuapi_DsReplicaCursor2, udv->count); - if (!udv->cursors) { - return WERR_DS_DRA_INTERNAL_ERROR; - } - udv->cursors[udv->count - 1] = *tmp_cursor; + el = ldb_msg_find_element(res->msgs[0], "replUpToDateVector"); + if (el == NULL || el->num_values < 1) { + talloc_free(tmp_ctx); + ouv->version = 2; + return WERR_OK; + } - qsort(udv->cursors, udv->count, - sizeof(struct drsuapi_DsReplicaCursor2), - (comparison_fn_t)replmd_drsuapi_DsReplicaCursor2_compare); - } else { - udv->count = 1; - udv->cursors = talloc_steal(udv, tmp_cursor); - } + ndr_err = ndr_pull_struct_blob(&el->values[0], + mem_ctx, lp_iconv_convenience(ldb_get_opaque(sam_ctx, "loadparm")), + ouv, + (ndr_pull_flags_fn_t)ndr_pull_replUpToDateVectorBlob); + talloc_free(tmp_ctx); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + DEBUG(0,(__location__ ": Failed to parse replUpToDateVector for %s\n", + ldb_dn_get_linearized(dn))); + return WERR_DS_DRA_INTERNAL_ERROR; + } + + return WERR_OK; + +} + +/* + fill in the cursors return based on the replUpToDateVector for the ncRoot_dn + */ +static WERROR get_nc_changes_udv(struct ldb_context *sam_ctx, + struct ldb_dn *ncRoot_dn, + struct drsuapi_DsReplicaCursor2CtrEx *udv) +{ + WERROR werr; + struct drsuapi_DsReplicaCursor2 *tmp_cursor; + uint64_t highest_commited_usn; + NTTIME now; + time_t t = time(NULL); + int ret; + struct replUpToDateVectorBlob ouv; + + werr = load_udv(sam_ctx, udv, ncRoot_dn, &ouv); + if (!W_ERROR_IS_OK(werr)) { + return werr; + } + + ret = ldb_sequence_number(sam_ctx, LDB_SEQ_HIGHEST_SEQ, &highest_commited_usn); + if (ret != LDB_SUCCESS) { + return WERR_DS_DRA_INTERNAL_ERROR; } + tmp_cursor = talloc(udv, struct drsuapi_DsReplicaCursor2); + tmp_cursor->source_dsa_invocation_id = *(samdb_ntds_invocation_id(sam_ctx)); + tmp_cursor->highest_usn = highest_commited_usn; + unix_to_nt_time(&now, t); + tmp_cursor->last_sync_success = now; + + udv->count = ouv.ctr.ctr2.count + 1; + udv->cursors = talloc_steal(udv, ouv.ctr.ctr2.cursors); + udv->cursors = talloc_realloc(udv, udv->cursors, struct drsuapi_DsReplicaCursor2, udv->count); + if (!udv->cursors) { + return WERR_DS_DRA_INTERNAL_ERROR; + } + udv->cursors[udv->count - 1] = *tmp_cursor; + + qsort(udv->cursors, udv->count, + sizeof(struct drsuapi_DsReplicaCursor2), + (comparison_fn_t)replmd_drsuapi_DsReplicaCursor2_compare); + return WERR_OK; } @@ -229,10 +272,11 @@ WERROR dcesrv_drsuapi_DsGetNCChanges(struct dcesrv_call_state *dce_call, TALLOC_ int i; struct dsdb_schema *schema; struct drsuapi_DsReplicaOIDMapping_Ctr *ctr; - struct drsuapi_DsReplicaObjectListItemEx *currentObject; + struct drsuapi_DsReplicaObjectListItemEx **currentObject; NTSTATUS status; DATA_BLOB session_key; const char *attrs[] = { "*", "parentGUID", NULL }; + WERROR werr; /* * connect to the samdb. TODO: We need to check that the caller @@ -260,9 +304,6 @@ WERROR dcesrv_drsuapi_DsGetNCChanges(struct dcesrv_call_state *dce_call, TALLOC_ return WERR_DS_DRA_BAD_NC; } - DEBUG(4,("DsGetNSChanges with uSNChanged >= %llu\n", - (unsigned long long)r->in.req->req8.highwatermark.highest_usn)); - /* we need the session key for encrypting password attributes */ status = dcesrv_inherited_session_key(dce_call->conn, &session_key); if (!NT_STATUS_IS_OK(status)) { @@ -312,37 +353,46 @@ WERROR dcesrv_drsuapi_DsGetNCChanges(struct dcesrv_call_state *dce_call, TALLOC_ r->out.ctr->ctr6.uptodateness_vector->reserved1 = 0; r->out.ctr->ctr6.uptodateness_vector->reserved2 = 0; - r->out.ctr->ctr6.first_object = talloc(mem_ctx, struct drsuapi_DsReplicaObjectListItemEx); - currentObject = r->out.ctr->ctr6.first_object; + r->out.ctr->ctr6.first_object = NULL; + currentObject = &r->out.ctr->ctr6.first_object; for(i=0; icount; i++) { int uSN; - WERROR werr; + struct drsuapi_DsReplicaObjectListItemEx *obj; + obj = talloc_zero(mem_ctx, struct drsuapi_DsReplicaObjectListItemEx); uSN = ldb_msg_find_attr_as_int(site_res->msgs[i], "uSNChanged", -1); - r->out.ctr->ctr6.object_count++; if (uSN > r->out.ctr->ctr6.new_highwatermark.highest_usn) { r->out.ctr->ctr6.new_highwatermark.highest_usn = uSN; } - werr = get_nc_changes_build_object(currentObject, site_res->msgs[i], sam_ctx, ncRoot_dn, - schema, &session_key); + werr = get_nc_changes_build_object(obj, site_res->msgs[i], sam_ctx, ncRoot_dn, + schema, &session_key, r->in.req->req8.highwatermark.highest_usn); if (!W_ERROR_IS_OK(werr)) { - r->out.ctr->ctr6.first_object = NULL; return werr; } - werr = get_nc_changes_udv(r->out.ctr->ctr6.uptodateness_vector, site_res->msgs[i], sam_ctx); - if (!W_ERROR_IS_OK(werr)) { - return werr; + if (obj->meta_data_ctr == NULL) { + /* no attributes to send */ + talloc_free(obj); + continue; } - if (i == (site_res->count-1)) { - break; - } - currentObject->next_object = talloc_zero(mem_ctx, struct drsuapi_DsReplicaObjectListItemEx); - currentObject = currentObject->next_object; + r->out.ctr->ctr6.object_count++; + + *currentObject = obj; + currentObject = &obj->next_object; } + werr = get_nc_changes_udv(sam_ctx, ncRoot_dn, r->out.ctr->ctr6.uptodateness_vector); + if (!W_ERROR_IS_OK(werr)) { + return werr; + } + + + DEBUG(4,("DsGetNSChanges with uSNChanged >= %llu on %s gave %u objects\n", + (unsigned long long)r->in.req->req8.highwatermark.highest_usn, + ncRoot->dn, r->out.ctr->ctr6.object_count)); + return WERR_OK; } -- cgit