wmi-1.3.16 from opsview.com
This commit is contained in:
Executable
+36
@@ -0,0 +1,36 @@
|
||||
#!/bin/sh
|
||||
|
||||
FULLBUILD=$1
|
||||
shift 1
|
||||
PIDL_EXTRA_ARGS="$*"
|
||||
|
||||
[ -d librpc/gen_ndr ] || mkdir -p librpc/gen_ndr || exit 1
|
||||
|
||||
PIDL="$PERL $srcdir/pidl/pidl --outputdir librpc/gen_ndr --header --ndr-parser --server --client --dcom-proxy --com-header --swig -- $PIDL_EXTRA_ARGS"
|
||||
|
||||
if [ x$FULLBUILD = xFULL ]; then
|
||||
echo Rebuilding all idl files in librpc/idl
|
||||
$PIDL $srcdir/librpc/idl/*.idl || exit 1
|
||||
exit 0
|
||||
fi
|
||||
|
||||
list=""
|
||||
|
||||
for f in $srcdir/librpc/idl/*.idl ; do
|
||||
basename=`basename $f .idl`
|
||||
ndr="librpc/gen_ndr/ndr_$basename.c"
|
||||
# blergh - most shells don't have the -nt function
|
||||
if [ -f $ndr ]; then
|
||||
if [ x`find $srcdir/librpc/idl/ "(" -name $basename.idl -o -name ${basename}_*.inc ")" -a -newer $ndr` != x ]; then
|
||||
list="$list $f"
|
||||
fi
|
||||
else
|
||||
list="$list $f"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "x$list" != x ]; then
|
||||
$PIDL $list || exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
Executable
+161
@@ -0,0 +1,161 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# Create ejs interfaces for structures in a C header file
|
||||
#
|
||||
|
||||
use File::Basename;
|
||||
use Data::Dumper;
|
||||
|
||||
#
|
||||
# Generate parse tree for header file
|
||||
#
|
||||
|
||||
my $file = shift;
|
||||
require smb_interfaces;
|
||||
my $parser = new smb_interfaces;
|
||||
$header = $parser->parse($file);
|
||||
|
||||
#
|
||||
# Make second pass over tree to make it easier to process.
|
||||
#
|
||||
|
||||
sub flatten_structs($) {
|
||||
my $obj = shift;
|
||||
my $s = { %$obj };
|
||||
|
||||
# Map NAME, STRUCT_NAME and UNION_NAME elements into a more likeable
|
||||
# property.
|
||||
|
||||
if (defined($obj->{STRUCT_NAME}) or defined($obj->{UNION_NAME})) {
|
||||
|
||||
$s->{TYPE_DEFINED} = defined($obj->{STRUCT_NAME}) ? $obj->{STRUCT_NAME}
|
||||
: $obj->{UNION_NAME};
|
||||
|
||||
delete $s->{STRUCT_NAME};
|
||||
delete $s->{UNION_NAME};
|
||||
}
|
||||
|
||||
# Create a new list of structure fields with flattened names
|
||||
|
||||
foreach my $elt (@{$obj->{DATA}}) {
|
||||
foreach my $name (@{$elt->{NAME}}) {
|
||||
my $new_elt = { %$elt };
|
||||
$new_elt->{NAME} = $name;
|
||||
# $new_elt->{PARENT} = $s;
|
||||
push(@{$s->{FIELDS}}, flatten_structs($new_elt));
|
||||
}
|
||||
}
|
||||
|
||||
delete $s->{DATA};
|
||||
|
||||
return $s;
|
||||
}
|
||||
|
||||
@newheader = map { flatten_structs($_) } @{$header};
|
||||
|
||||
#
|
||||
# Generate implementation
|
||||
#
|
||||
|
||||
my $basename = basename($file, ".h");
|
||||
stat "libcli/gen_raw" || mkdir("libcli/gen_raw") || die("mkdir");
|
||||
|
||||
open(FILE, ">libcli/gen_raw/ejs_${basename}.c");
|
||||
|
||||
print FILE "/* EJS wrapper functions auto-generated by build_smb_interfaces.pl */\n\n";
|
||||
|
||||
print FILE "#include \"includes.h\"\n";
|
||||
print FILE "#include \"scripting/ejs/smbcalls.h\"\n";
|
||||
print FILE "#include \"lib/appweb/ejs/ejs.h\"\n";
|
||||
print FILE "#include \"scripting/ejs/ejsrpc.h\"\n"; # TODO: remove this
|
||||
print FILE "\n";
|
||||
|
||||
sub transfer_element($$$) {
|
||||
my $dir = shift;
|
||||
my $prefix = shift;
|
||||
my $elt = shift;
|
||||
|
||||
$type = $elt->{TYPE};
|
||||
$type =~ s/_t$//;
|
||||
|
||||
print FILE "\tNDR_CHECK(ejs_${dir}_$type(ejs, v, \"$prefix.$elt->{NAME}\"));\n";
|
||||
}
|
||||
|
||||
sub transfer_struct($$) {
|
||||
my $dir = shift;
|
||||
my $struct = shift;
|
||||
|
||||
foreach my $field (@{$struct->{FIELDS}}) {
|
||||
next if $dir eq "pull" and $field->{NAME} eq "out";
|
||||
next if $dir eq "push" and $field->{NAME} eq "in";
|
||||
|
||||
if ($field->{TYPE} eq "struct") {
|
||||
foreach $subfield (@{$field->{FIELDS}}) {
|
||||
transfer_element($dir, $field->{NAME}, $subfield);
|
||||
}
|
||||
} else {
|
||||
transfer_element($dir, $struct->{NAME}, $field);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Top level call functions
|
||||
|
||||
foreach my $s (@newheader) {
|
||||
|
||||
if ($s->{TYPE} eq "struct") {
|
||||
|
||||
# Push/pull top level struct
|
||||
|
||||
print FILE "NTSTATUS ejs_pull_$s->{TYPE_DEFINED}(struct ejs_rpc *ejs, struct MprVar *v, struct $s->{TYPE_DEFINED} *r)\n";
|
||||
print FILE "{\n";
|
||||
|
||||
transfer_struct("pull", $s);
|
||||
|
||||
print FILE "\n\treturn NT_STATUS_OK;\n";
|
||||
print FILE "}\n\n";
|
||||
|
||||
print FILE "NTSTATUS ejs_push_$s->{TYPE_DEFINED}(struct ejs_rpc *ejs, struct MprVar *v, const struct $s->{TYPE_DEFINED} *r)\n";
|
||||
print FILE "{\n";
|
||||
|
||||
transfer_struct("push", $s);
|
||||
|
||||
print FILE "\n\treturn NT_STATUS_OK;\n";
|
||||
print FILE "}\n\n";
|
||||
|
||||
# Function call
|
||||
|
||||
print FILE "static int ejs_$s->{TYPE_DEFINED}(int eid, int argc, struct MprVar **argv)\n";
|
||||
print FILE "{\n";
|
||||
print FILE "\treturn ejs_raw_call(eid, argc, argv, (ejs_pull_function_t)ejs_pull_$s->{TYPE_DEFINED}, (ejs_push_function_t)ejs_push_$s->{TYPE_DEFINED});\n";
|
||||
print FILE "}\n\n";
|
||||
|
||||
} else {
|
||||
|
||||
# Top level union
|
||||
|
||||
foreach my $arm (@{$s->{FIELDS}}) {
|
||||
|
||||
# Push/pull union arm
|
||||
|
||||
print FILE "NTSTATUS ejs_pull_$s->{TYPE_DEFINED}_$arm->{NAME}(struct ejs_rpc *ejs, struct MprVar *v, union $s->{TYPE_DEFINED} *r)\n";
|
||||
print FILE "{\n";
|
||||
|
||||
transfer_struct("pull", $arm);
|
||||
|
||||
print FILE "\n\treturn NT_STATUS_OK;\n";
|
||||
print FILE "}\n\n";
|
||||
|
||||
print FILE "NTSTATUS ejs_push_$s->{TYPE_DEFINED}_$arm->{NAME}(struct ejs_rpc *ejs, struct MprVar *v, const union $s->{TYPE_DEFINED} *r)\n";
|
||||
print FILE "{\n";
|
||||
|
||||
transfer_struct("push", $arm);
|
||||
|
||||
print FILE "\n\treturn NT_STATUS_OK;\n";
|
||||
print FILE "}\n\n";
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
close(FILE);
|
||||
@@ -0,0 +1,40 @@
|
||||
#! /usr/bin/env perl -w
|
||||
eval 'exec /usr/bin/env perl -S $0 ${1+"$@"}'
|
||||
if 0; #$running_under_some_shell
|
||||
|
||||
use strict;
|
||||
use File::Find ();
|
||||
use File::Path qw(mkpath);
|
||||
use Cwd 'abs_path';
|
||||
|
||||
# Set the variable $File::Find::dont_use_nlink if you're using AFS,
|
||||
# since AFS cheats.
|
||||
|
||||
# for the convenience of &wanted calls, including -eval statements:
|
||||
use vars qw/*name *dir *prune/;
|
||||
*name = *File::Find::name;
|
||||
*dir = *File::Find::dir;
|
||||
*prune = *File::Find::prune;
|
||||
my $builddir = abs_path($ENV{samba_builddir});
|
||||
my $srcdir = abs_path($ENV{samba_srcdir});
|
||||
sub wanted;
|
||||
|
||||
|
||||
|
||||
# Traverse desired filesystems
|
||||
File::Find::find({wanted => \&wanted, no_chdir => 1}, $srcdir);
|
||||
exit;
|
||||
|
||||
|
||||
sub wanted {
|
||||
my ($dev,$ino,$mode,$nlink,$uid,$gid,$newdir);
|
||||
|
||||
if ((($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_)) &&
|
||||
(-d _) && (($newdir = abs_path($_)) !~ /$builddir/))
|
||||
{
|
||||
$newdir =~ s!$srcdir!$builddir!;
|
||||
mkpath($newdir);
|
||||
print("Creating $newdir\n");
|
||||
}
|
||||
}
|
||||
|
||||
Executable
+27
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
# This is a hack to allow per target cflags. It isn't very elegant, but it
|
||||
# is the most portable idea we have come up with yet
|
||||
# tridge@samba.org, July 2005
|
||||
# jelmer@samba.org, March 2006
|
||||
use strict;
|
||||
|
||||
my $target = shift;
|
||||
|
||||
sub check_flags($)
|
||||
{
|
||||
my ($name)=@_;
|
||||
open (IN, "extra_cflags.txt");
|
||||
while (<IN> =~ /^([^:]+): (.*)$/) {
|
||||
next unless (grep(/^$target$/, (split / /, $1)));
|
||||
$_ = $2;
|
||||
s/^CFLAGS\+=//;
|
||||
print "$_ ";
|
||||
}
|
||||
close(IN);
|
||||
print "\n";
|
||||
}
|
||||
|
||||
check_flags($target);
|
||||
|
||||
exit 0;
|
||||
+124
@@ -0,0 +1,124 @@
|
||||
#!/usr/bin/perl
|
||||
# Script that finds macros in a configure script that are not
|
||||
# used in a set of C files.
|
||||
# Copyright Jelmer Vernooij <jelmer@samba.org>, GPL
|
||||
#
|
||||
# Usage: ./$ARGV[0] configure.in [c-files...]
|
||||
|
||||
use strict;
|
||||
|
||||
sub autoconf_parse($$$$)
|
||||
{
|
||||
my $in = shift;
|
||||
my $defines = shift;
|
||||
my $functions = shift;
|
||||
my $headers = shift;
|
||||
|
||||
open(IN, $in) or die("Can't open $in");
|
||||
|
||||
my $ln = 0;
|
||||
|
||||
foreach(<IN>) {
|
||||
$ln++;
|
||||
|
||||
if(/AC_DEFINE\(([^,]+),/) {
|
||||
$defines->{$1} = "$in:$ln";
|
||||
}
|
||||
|
||||
if(/AC_CHECK_FUNCS\(\[*(.[^],)]+)/) {
|
||||
foreach(split / /, $1) {
|
||||
$functions->{$_} = "$in:$ln";
|
||||
}
|
||||
}
|
||||
|
||||
if(/AC_CHECK_FUNC\(([^,)]+)/) {
|
||||
$functions->{$1} = "$in:$ln";
|
||||
}
|
||||
|
||||
if(/AC_CHECK_HEADERS\(\[*([^],)]+)/) {
|
||||
foreach(split / /, $1) {
|
||||
$headers->{$_} = "$in:$ln";
|
||||
}
|
||||
}
|
||||
|
||||
if(/AC_CHECK_HEADER\(([^,)]+)/) {
|
||||
$headers->{$1} = "$in:$ln";
|
||||
}
|
||||
|
||||
if(/sinclude\(([^,]+)\)/) {
|
||||
autoconf_parse($1, $defines, $functions, $headers);
|
||||
}
|
||||
}
|
||||
|
||||
close IN;
|
||||
}
|
||||
|
||||
# Return the symbols and headers used by a C file
|
||||
sub cfile_parse($$$)
|
||||
{
|
||||
my $in = shift;
|
||||
my $symbols = shift;
|
||||
my $headers = shift;
|
||||
|
||||
open(FI, $in) or die("Can't open $in");
|
||||
my $ln = 0;
|
||||
my $line;
|
||||
while($line = <FI>) {
|
||||
$ln++;
|
||||
$_ = $line;
|
||||
if (/\#([ \t]*)include ["<]([^">]+)/) {
|
||||
$headers->{$2} = "$in:$ln";
|
||||
}
|
||||
|
||||
$_ = $line;
|
||||
while(/([A-Za-z0-9_]+)/g) {
|
||||
$symbols->{$1} = "$in:$ln";
|
||||
}
|
||||
}
|
||||
close FI;
|
||||
}
|
||||
|
||||
my %ac_defines = ();
|
||||
my %ac_func_checks = ();
|
||||
my %ac_headers = ();
|
||||
my %symbols = ();
|
||||
my %headers = ();
|
||||
|
||||
if (scalar(@ARGV) <= 1) {
|
||||
print("Usage: configure_find_unused.pl configure.in [CFILE...]\n");
|
||||
exit 0;
|
||||
}
|
||||
|
||||
autoconf_parse(shift(@ARGV), \%ac_defines, \%ac_func_checks, \%ac_headers);
|
||||
cfile_parse($_, \%symbols, \%headers) foreach(@ARGV);
|
||||
|
||||
(keys %ac_defines) or warn("No defines found in configure.in file, parse error?");
|
||||
|
||||
foreach (keys %ac_defines) {
|
||||
if (not defined($symbols{$_})) {
|
||||
print "$ac_defines{$_}: Autoconf-defined $_ is unused\n";
|
||||
}
|
||||
}
|
||||
|
||||
(keys %ac_func_checks) or warn("No function checks found in configure.in file, parse error?");
|
||||
|
||||
foreach (keys %ac_func_checks) {
|
||||
my $def = "HAVE_".uc($_);
|
||||
if (not defined($symbols{$_})) {
|
||||
print "$ac_func_checks{$_}: Autoconf-checked function `$_' is unused\n";
|
||||
} elsif (not defined($symbols{$def})) {
|
||||
print "$ac_func_checks{$_}: Autoconf-define `$def' for function `$_' is unused\n";
|
||||
}
|
||||
}
|
||||
|
||||
(keys %ac_headers) or warn("No headers found in configure.in file, parse error?");
|
||||
|
||||
foreach (keys %ac_headers) {
|
||||
my $def = "HAVE_".uc($_);
|
||||
$def =~ s/[\/\.]/_/g;
|
||||
if (not defined($headers{$_})) {
|
||||
print "$ac_headers{$_}: Autoconf-checked header `$_' is unused\n";
|
||||
} elsif (not defined($symbols{$def})) {
|
||||
print "$ac_headers{$_}: Autoconf-define `$def' for header `$_' is unused\n";
|
||||
}
|
||||
}
|
||||
Executable
+50
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Filter out arcs in a dotty graph that are at or below a certain
|
||||
# node. This is useful for visualising parts of the dependency graph.
|
||||
#
|
||||
|
||||
# Command line stuff
|
||||
|
||||
import sys, sre
|
||||
|
||||
if len(sys.argv) != 2:
|
||||
print 'Usage: depfilter.py NODE'
|
||||
sys.exit(1)
|
||||
|
||||
top = sys.argv[1]
|
||||
|
||||
# Read in dot file
|
||||
|
||||
lines = sys.stdin.readlines()
|
||||
|
||||
graph = {}
|
||||
|
||||
for arc in lines[1:-1]:
|
||||
match = sre.search('"(.*)" -> "(.*)"', arc)
|
||||
n1, n2 = match.group(1), match.group(2)
|
||||
if not graph.has_key(n1):
|
||||
graph[n1] = []
|
||||
graph[n1].append(n2)
|
||||
|
||||
# Create subset of 'graph' rooted at 'top'
|
||||
|
||||
subgraph = {}
|
||||
|
||||
def add_deps(node):
|
||||
if graph.has_key(node) and not subgraph.has_key(node):
|
||||
subgraph[node] = graph[node]
|
||||
for n in graph[node]:
|
||||
add_deps(n)
|
||||
|
||||
add_deps(top)
|
||||
|
||||
# Generate output
|
||||
|
||||
print lines[0],
|
||||
|
||||
for key, value in subgraph.items():
|
||||
for n in value:
|
||||
print '\t"%s" -> "%s"' % (key, n)
|
||||
|
||||
print lines[-1],
|
||||
Executable
+2
@@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
grep '{".*P_[GL]' param/loadparm.c | sed -e 's/&.*$//g' -e 's/",.*P_LOCAL.*$/ S/' -e 's/",.*P_GLOBAL.*$/ G/' -e 's/^ .*{"//g' | sort -f
|
||||
Executable
+38
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/perl
|
||||
# Script that reads in C files and prints defines that are used nowhere in the
|
||||
# code
|
||||
|
||||
# Arguments: C and H files
|
||||
# Copyright Jelmer Vernooij <jelmer@samba.org>, GPL
|
||||
|
||||
use strict;
|
||||
|
||||
my %defined;
|
||||
my %used;
|
||||
my %files;
|
||||
|
||||
my $tmp;
|
||||
while($tmp = shift) {
|
||||
$files{$tmp} = $tmp;
|
||||
open(FI, $tmp);
|
||||
my $ln = 0;
|
||||
while(<FI>) {
|
||||
$ln++;
|
||||
my $line = $_;
|
||||
my $cur = "";
|
||||
if(/^#define ([A-Za-z0-9_]+)/) {
|
||||
$defined{$1} = "$tmp:$ln";
|
||||
$cur = $1;
|
||||
}
|
||||
|
||||
$_ = $line;
|
||||
while(/([A-Za-z0-9_]+)/sgm) {
|
||||
if($cur ne $1) { $used{$1} = "$tmp:$ln"; }
|
||||
}
|
||||
}
|
||||
close FI;
|
||||
}
|
||||
|
||||
foreach(keys %defined) {
|
||||
if(!$used{$_}) { print "$defined{$_}: Macro `$_' is unused\n"; }
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
#!/usr/bin/perl
|
||||
# Script that reads in Makefile.in and outputs the names of all
|
||||
# used but undefined vars and all defined but unused vars
|
||||
# Copyright Jelmer Vernooij <jelmer@samba.org>
|
||||
|
||||
# Arguments:
|
||||
# 1: Makefile.in
|
||||
#
|
||||
|
||||
my %references;
|
||||
my %defines;
|
||||
|
||||
# First, make a list of defines in configure
|
||||
$in = shift;
|
||||
|
||||
open(IN, $in);
|
||||
while(<IN>) {
|
||||
my $line = $_;
|
||||
while($line =~ /^\b([a-zA-Z0-9_][a-zA-Z0-9_]*)\b[ \t]*=.*/sgm) {
|
||||
$defines{$1} = 1;
|
||||
}
|
||||
while($line =~ /\$\(([a-zA-Z0-9_][a-zA-Z0-9_]*)\)/sgm) {
|
||||
$references{$1} = 1;
|
||||
}
|
||||
}
|
||||
close IN;
|
||||
|
||||
print "##### DEFINED BUT UNUSED: #####\n";
|
||||
foreach(%defines) {
|
||||
# print $_." defined\n";
|
||||
|
||||
if ($_ != 1) {
|
||||
if ($references{$_} != 1) {
|
||||
print $_."\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print "##### USED BUT UNDEFINED: #####\n";
|
||||
foreach(%references) {
|
||||
if ($_ != 1) {
|
||||
if ($defines{$_} != 1) {
|
||||
print $_."\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable
+37
@@ -0,0 +1,37 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# this script finds unused lp_*() functions
|
||||
#
|
||||
# use it like this:
|
||||
#
|
||||
# user@host:~/samba/source>./script/find_unused_options.sh
|
||||
#
|
||||
|
||||
LIST_GLOBAL=`grep '^FN_GLOBAL' param/loadparm.c |sed -e's/^FN_GLOBAL.*(\(.*\).*,.*\(&Globals\..*\)).*/\1:\2/'`
|
||||
|
||||
LIST_LOCAL=`grep '^FN_LOCAL' param/loadparm.c |sed -e's/^FN_LOCAL.*(\(.*\).*,[ ]*\(.*\)).*/\1:\2/'`
|
||||
|
||||
CFILES=`find . -name "*.c"`
|
||||
|
||||
for i in $LIST_GLOBAL;do
|
||||
key=`echo $i|cut -d ':' -f1`
|
||||
val=`echo $i|cut -d ':' -f2`
|
||||
|
||||
found=`grep "$key[ ]*()" $CFILES`
|
||||
if test -z "$found"; then
|
||||
echo "Not Used Global: $key() -> $val"
|
||||
fi
|
||||
done
|
||||
|
||||
for i in $LIST_LOCAL;do
|
||||
key=`echo $i|cut -d ':' -f1`
|
||||
val=`echo $i|cut -d ':' -f2`
|
||||
|
||||
found=`grep "$key[ ]*(" $CFILES`
|
||||
|
||||
if test -z "$found"; then
|
||||
echo "Not Used LOCAL: $key() -> $val"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "# do a 'make clean;make everything' before removing anything!"
|
||||
Executable
+70
@@ -0,0 +1,70 @@
|
||||
#!/usr/bin/perl -w
|
||||
# find a list of fns and variables in the code that could be static
|
||||
# usually called with something like this:
|
||||
# findstatic.pl `find . -name "*.o"`
|
||||
# Andrew Tridgell <tridge@samba.org>
|
||||
|
||||
use strict;
|
||||
|
||||
# use nm to find the symbols
|
||||
my($saved_delim) = $/;
|
||||
undef $/;
|
||||
my($syms) = `nm -o @ARGV`;
|
||||
$/ = $saved_delim;
|
||||
|
||||
my(@lines) = split(/\n/s, $syms);
|
||||
|
||||
my(%def);
|
||||
my(%undef);
|
||||
my(%stype);
|
||||
|
||||
my(%typemap) = (
|
||||
"T" => "function",
|
||||
"C" => "uninitialised variable",
|
||||
"D" => "initialised variable"
|
||||
);
|
||||
|
||||
|
||||
# parse the symbols into defined and undefined
|
||||
for (my($i)=0; $i <= $#{@lines}; $i++) {
|
||||
my($line) = $lines[$i];
|
||||
if ($line =~ /(.*):[a-f0-9]* ([TCD]) (.*)/) {
|
||||
my($fname) = $1;
|
||||
my($symbol) = $3;
|
||||
push(@{$def{$fname}}, $symbol);
|
||||
$stype{$symbol} = $2;
|
||||
}
|
||||
if ($line =~ /(.*):\s* U (.*)/) {
|
||||
my($fname) = $1;
|
||||
my($symbol) = $2;
|
||||
push(@{$undef{$fname}}, $symbol);
|
||||
}
|
||||
}
|
||||
|
||||
# look for defined symbols that are never referenced outside the place they
|
||||
# are defined
|
||||
foreach my $f (keys %def) {
|
||||
print "Checking $f\n";
|
||||
my($found_one) = 0;
|
||||
foreach my $s (@{$def{$f}}) {
|
||||
my($found) = 0;
|
||||
foreach my $f2 (keys %undef) {
|
||||
if ($f2 ne $f) {
|
||||
foreach my $s2 (@{$undef{$f2}}) {
|
||||
if ($s2 eq $s) {
|
||||
$found = 1;
|
||||
$found_one = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($found == 0) {
|
||||
my($t) = $typemap{$stype{$s}};
|
||||
print " '$s' is unique to $f ($t)\n";
|
||||
}
|
||||
}
|
||||
if ($found_one == 0) {
|
||||
print " all symbols in '$f' are unused (main program?)\n";
|
||||
}
|
||||
}
|
||||
|
||||
Executable
+87
@@ -0,0 +1,87 @@
|
||||
#!/bin/sh
|
||||
|
||||
BASENAME=`basename $0`
|
||||
|
||||
if [ -n "$VALGRIND" -o -n "$SMBD_VALGRIND" ]; then
|
||||
echo "${BASENAME}: Not running debugger under valgrind"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# we want everything on stderr, so the program is not disturbed
|
||||
exec 1>&2
|
||||
|
||||
BASENAME=`basename $0`
|
||||
UNAME=`uname`
|
||||
|
||||
PID=$1
|
||||
BINARY=$2
|
||||
|
||||
test x"${PID}" = x"" && {
|
||||
echo "Usage: ${BASENAME} <pid> [<binary>]"
|
||||
exit 1
|
||||
}
|
||||
|
||||
DB_LIST="gdb"
|
||||
case "${UNAME}" in
|
||||
#
|
||||
# on Tru64 we need to try ladebug first
|
||||
# because gdb crashes itself...
|
||||
#
|
||||
OSF1)
|
||||
DB_LIST="ladebug ${DB_LIST}"
|
||||
;;
|
||||
esac
|
||||
|
||||
for DB in ${DB_LIST}; do
|
||||
DB_BIN=`which ${DB} 2>/dev/null`
|
||||
test x"${DB_BIN}" != x"" && {
|
||||
break
|
||||
}
|
||||
done
|
||||
|
||||
test x"${DB_BIN}" = x"" && {
|
||||
echo "${BASENAME}: ERROR: No debugger found."
|
||||
exit 1
|
||||
}
|
||||
|
||||
#
|
||||
# we first try to use /proc/${PID}/exe
|
||||
# then fallback to the binary from the commandline
|
||||
# then we search for the commandline argument with
|
||||
# 'which'
|
||||
#
|
||||
test -f "/proc/${PID}/exe" && BINARY="/proc/${PID}/exe"
|
||||
test x"${BINARY}" = x"" && BINARY="/proc/${PID}/exe"
|
||||
test -f "${BINARY}" || BINARY=`which ${BINARY}`
|
||||
|
||||
test -f "${BINARY}" || {
|
||||
echo "${BASENAME}: ERROR: Cannot find binary '${BINARY}'."
|
||||
exit 1
|
||||
}
|
||||
|
||||
echo "${BASENAME}: Trying to use ${DB_BIN} on ${BINARY} on PID ${PID}"
|
||||
|
||||
BATCHFILE_PRE=/tmp/gdb_backtrace_pre.$$
|
||||
BATCHFILE_MAIN=/tmp/gdb_backtrace_main.$$
|
||||
case "${DB}" in
|
||||
ladebug)
|
||||
cat << EOF > ${BATCHFILE_PRE}
|
||||
set \$stoponattach
|
||||
EOF
|
||||
|
||||
cat << EOF > ${BATCHFILE_MAIN}
|
||||
where
|
||||
quit
|
||||
EOF
|
||||
${DB_BIN} -c "${BATCHFILE_MAIN}" -i "${BATCHFILE_PRE}" -pid "${PID}" "${BINARY}"
|
||||
;;
|
||||
gdb)
|
||||
cat << EOF > ${BATCHFILE_MAIN}
|
||||
set height 1000
|
||||
bt full
|
||||
quit
|
||||
EOF
|
||||
${DB_BIN} -x "${BATCHFILE_MAIN}" "${BINARY}" "${PID}"
|
||||
;;
|
||||
esac
|
||||
/bin/rm -f ${BATCHFILE_PRE} ${BATCHFILE_MAIN}
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
|
||||
add a usefull tool to test the gdb_backtrace script
|
||||
|
||||
just compile it with
|
||||
cc -g -o gdb_backtrace_test gdb_backtrace_test.c
|
||||
|
||||
and run it in the same directory where your gdb_backtrace script is.
|
||||
|
||||
2006 - Stefan Metzmacher <metze@samba.org>
|
||||
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
|
||||
static const char *prog;
|
||||
|
||||
static void sig_fault(int sig)
|
||||
{
|
||||
int ret;
|
||||
char cmdstr[200];
|
||||
|
||||
snprintf(cmdstr, sizeof(cmdstr),
|
||||
"./gdb_backtrace %u %s",
|
||||
getpid(), prog);
|
||||
printf("sig_fault start: %s\n", cmdstr);
|
||||
ret = system(cmdstr);
|
||||
printf("sig_fault end: %d\n", ret);
|
||||
}
|
||||
|
||||
int main(int argc, const char **argv)
|
||||
{
|
||||
prog = argv[0];
|
||||
|
||||
signal(SIGABRT, sig_fault);
|
||||
|
||||
abort();
|
||||
return 0;
|
||||
}
|
||||
Executable
+40
@@ -0,0 +1,40 @@
|
||||
#!/bin/sh
|
||||
|
||||
INSTALLPERMS=$1
|
||||
BASEDIR=$2
|
||||
BINDIR=$3
|
||||
LIBDIR=$4
|
||||
VARDIR=$5
|
||||
shift
|
||||
shift
|
||||
shift
|
||||
shift
|
||||
shift
|
||||
|
||||
for p in $*; do
|
||||
p2=`basename $p`
|
||||
echo Installing $p as $BINDIR/$p2
|
||||
if [ -f $BINDIR/$p2 ]; then
|
||||
rm -f $BINDIR/$p2.old
|
||||
mv $BINDIR/$p2 $BINDIR/$p2.old
|
||||
fi
|
||||
cp $p $BINDIR/
|
||||
chmod $INSTALLPERMS $BINDIR/$p2
|
||||
|
||||
# this is a special case, mount needs this in a specific location
|
||||
if [ $p2 = smbmount ]; then
|
||||
ln -sf $BINDIR/$p2 /sbin/mount.smbfs
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
cat << EOF
|
||||
======================================================================
|
||||
The binaries are installed. You may restore the old binaries (if there
|
||||
were any) using the command "make revert". You may uninstall the binaries
|
||||
using the command "make uninstallbin" or "make uninstall" to uninstall
|
||||
binaries, man pages and shell scripts.
|
||||
======================================================================
|
||||
EOF
|
||||
|
||||
exit 0
|
||||
Executable
+23
@@ -0,0 +1,23 @@
|
||||
#!/bin/sh
|
||||
#fist version March 2002, Herb Lewis
|
||||
|
||||
DATDIR=$1
|
||||
SRCDIR=$2/
|
||||
|
||||
echo Installing dat files in $DATDIR
|
||||
|
||||
for f in $SRCDIR/codepages/*.dat; do
|
||||
FNAME=$DATDIR/`basename $f`
|
||||
echo $FNAME
|
||||
cp $f $FNAME || echo Cannot install $FNAME. Does $USER have privileges?
|
||||
chmod 0644 $FNAME
|
||||
done
|
||||
|
||||
cat << EOF
|
||||
======================================================================
|
||||
The dat files have been installed.
|
||||
======================================================================
|
||||
EOF
|
||||
|
||||
exit 0
|
||||
|
||||
Executable
+17
@@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
|
||||
while ( test -n "$1" ); do
|
||||
if [ ! -d $1 ]; then
|
||||
mkdir -p $1
|
||||
fi
|
||||
|
||||
if [ ! -d $1 ]; then
|
||||
echo Failed to make directory $1
|
||||
exit 1
|
||||
fi
|
||||
|
||||
shift;
|
||||
done
|
||||
|
||||
|
||||
|
||||
Executable
+105
@@ -0,0 +1,105 @@
|
||||
#!/usr/bin/perl
|
||||
# Copyright (C) 2006 Jelmer Vernooij
|
||||
use strict;
|
||||
use File::Basename;
|
||||
|
||||
my $includedir = shift;
|
||||
|
||||
|
||||
sub read_headermap($)
|
||||
{
|
||||
my ($fn) = @_;
|
||||
my %map = ();
|
||||
my $ln = 0;
|
||||
open(MAP, "<headermap.txt");
|
||||
while(<MAP>) {
|
||||
$ln++;
|
||||
s/#.*$//g;
|
||||
next if (/^\s*$/);
|
||||
if (! /^(.*): (.*)$/) {
|
||||
print STDERR "headermap.txt:$ln: Malformed line\n";
|
||||
next;
|
||||
}
|
||||
$map{$1} = $2;
|
||||
}
|
||||
|
||||
close(MAP);
|
||||
|
||||
return %map;
|
||||
}
|
||||
|
||||
my %map = read_headermap("headermap.txt");
|
||||
|
||||
sub findmap($)
|
||||
{
|
||||
$_ = shift;
|
||||
s/^\.\///g;
|
||||
|
||||
if (! -f $_ && -f "lib/$_") { $_ = "lib/$_"; }
|
||||
|
||||
return $map{$_};
|
||||
}
|
||||
|
||||
sub rewrite_include($$)
|
||||
{
|
||||
my ($pos,$d) = @_;
|
||||
|
||||
my $n = findmap($d);
|
||||
return $n if $n;
|
||||
return $d;
|
||||
}
|
||||
|
||||
sub install_header($$)
|
||||
{
|
||||
my ($src,$dst) = @_;
|
||||
|
||||
my $lineno = 0;
|
||||
|
||||
open(IN, "<$src");
|
||||
open(OUT, ">$dst");
|
||||
|
||||
while (<IN>) {
|
||||
$lineno++;
|
||||
if (/^#include \"(.*)\"/) {
|
||||
print OUT "#include <" . rewrite_include("$src:$lineno", $1) . ">\n";
|
||||
} else {
|
||||
print OUT $_;
|
||||
}
|
||||
}
|
||||
|
||||
close(OUT);
|
||||
close(IN);
|
||||
}
|
||||
|
||||
foreach my $p (@ARGV)
|
||||
{
|
||||
my $p2 = findmap($p);
|
||||
unless ($p2) {
|
||||
die("Unable to map $p");
|
||||
}
|
||||
print "Installing $p as $includedir/$p2\n";
|
||||
|
||||
my $dirname = dirname($p2);
|
||||
|
||||
if (! -d "$includedir/$dirname") {
|
||||
mkdir("$includedir/$dirname", 0777);
|
||||
}
|
||||
|
||||
if ( -f "$includedir/$p2" ) {
|
||||
unlink("$includedir/$p2.old");
|
||||
rename("$includedir/$p2", "$includedir/$p2.old");
|
||||
}
|
||||
|
||||
install_header($p,"$includedir/$p2");
|
||||
}
|
||||
|
||||
print <<EOF;
|
||||
======================================================================
|
||||
The headers are installed. You may restore the old headers (if there
|
||||
were any) using the command "make revert". You may uninstall the headers
|
||||
using the command "make uninstallheader" or "make uninstall" to uninstall
|
||||
binaries, man pages and shell scripts.
|
||||
======================================================================
|
||||
EOF
|
||||
|
||||
exit 0;
|
||||
@@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
|
||||
SERVICESDIR=$1
|
||||
SRCDIR=$2
|
||||
|
||||
echo Installing JSON-RPC services in $SERVICESDIR
|
||||
|
||||
cd $SRCDIR/../services || exit 1
|
||||
|
||||
mkdir -p $SERVICESDIR || exit 1
|
||||
|
||||
installdir() {
|
||||
for f in $*; do
|
||||
dname=`dirname $f`
|
||||
echo "Installing $f in $dname"
|
||||
test -d $SERVICESDIR/$dname || mkdir -p $SERVICESDIR/$dname || exit 1
|
||||
cp $f $SERVICESDIR/$dname/ || exit 1
|
||||
chmod 0644 $SERVICESDIR/$f || exit 1
|
||||
done
|
||||
}
|
||||
|
||||
installdir `find . -name '*.esp'`
|
||||
|
||||
cat << EOF
|
||||
======================================================================
|
||||
The JSON-RPC services have been installed.
|
||||
======================================================================
|
||||
EOF
|
||||
|
||||
|
||||
exit 0
|
||||
|
||||
Executable
+30
@@ -0,0 +1,30 @@
|
||||
#!/bin/sh
|
||||
|
||||
LIBDIR=$1
|
||||
SHLIBEXT=$2
|
||||
|
||||
shift
|
||||
shift
|
||||
|
||||
for p in $*; do
|
||||
p2=`basename $p`
|
||||
lnname=`echo $p2 | sed -e "s/\.$SHLIBEXT.*/.$SHLIBEXT/"`
|
||||
echo Installing $p as $LIBDIR/$p2
|
||||
if [ -f $LIBDIR/$p2 ]; then
|
||||
rm -f $LIBDIR/$p2.old
|
||||
mv $LIBDIR/$p2 $LIBDIR/$p2.old
|
||||
fi
|
||||
cp $p $LIBDIR/
|
||||
ln -sf $p2 $LIBDIR/$lnname
|
||||
done
|
||||
|
||||
cat << EOF
|
||||
======================================================================
|
||||
The shared libraries are installed. You may restore the old libraries (if there
|
||||
were any) using the command "make revert". You may uninstall the libraries
|
||||
using the command "make uninstalllib" or "make uninstall" to uninstall
|
||||
binaries, man pages and shell scripts.
|
||||
======================================================================
|
||||
EOF
|
||||
|
||||
exit 0
|
||||
Executable
+30
@@ -0,0 +1,30 @@
|
||||
#!/bin/sh
|
||||
|
||||
MANDIR=$1
|
||||
shift 1
|
||||
MANPAGES=$*
|
||||
|
||||
for I in $MANPAGES
|
||||
do
|
||||
SECTION=`echo $I | grep -o '.$'`
|
||||
DIR="$MANDIR/man$SECTION"
|
||||
if [ ! -d "$DIR" ]
|
||||
then
|
||||
mkdir "$DIR"
|
||||
fi
|
||||
|
||||
BASE=`basename $I`
|
||||
|
||||
echo "Installing manpage \"$BASE\" in $DIR"
|
||||
cp $I $DIR
|
||||
done
|
||||
|
||||
cat << EOF
|
||||
======================================================================
|
||||
The man pages have been installed. You may uninstall them using the command
|
||||
the command "make uninstallman" or make "uninstall" to uninstall binaries,
|
||||
man pages and shell scripts.
|
||||
======================================================================
|
||||
EOF
|
||||
|
||||
exit 0
|
||||
Executable
+26
@@ -0,0 +1,26 @@
|
||||
#!/bin/sh
|
||||
# install miscellaneous files
|
||||
|
||||
SRCDIR="$1"
|
||||
JSDIR="$2"
|
||||
SETUPDIR="$3"
|
||||
BINDIR="$4"
|
||||
|
||||
cd $SRCDIR || exit 1
|
||||
|
||||
echo "Installing js libs"
|
||||
mkdir -p $JSDIR || exit 1
|
||||
cp scripting/libjs/*.js $JSDIR || exit 1
|
||||
|
||||
echo "Installing setup templates"
|
||||
mkdir -p $SETUPDIR || exit 1
|
||||
cp setup/*.ldif $SETUPDIR || exit 1
|
||||
cp setup/*.zone $SETUPDIR || exit 1
|
||||
cp setup/*.conf $SETUPDIR || exit 1
|
||||
|
||||
echo "Installing script tools"
|
||||
mkdir -p "$BINDIR"
|
||||
rm -f scripting/bin/*~
|
||||
cp scripting/bin/* $BINDIR/ || exit 1
|
||||
|
||||
exit 0
|
||||
Executable
+33
@@ -0,0 +1,33 @@
|
||||
#!/bin/sh
|
||||
|
||||
INSTALLPERMS=$1
|
||||
LIBDIR=$2
|
||||
shift
|
||||
shift
|
||||
shift
|
||||
|
||||
if [ ! -d $LIBDIR ]; then
|
||||
mkdir $LIBDIR
|
||||
if [ ! -d $LIBDIR ]; then
|
||||
echo Failed to make directory $LIBDIR
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
for p in $*; do
|
||||
p2=`basename $p`
|
||||
echo Installing $p as $LIBDIR/$p2
|
||||
cp -f $p $LIBDIR/
|
||||
chmod $INSTALLPERMS $LIBDIR/$p2
|
||||
done
|
||||
|
||||
|
||||
cat << EOF
|
||||
======================================================================
|
||||
The modules are installed. You may uninstall the modules using the
|
||||
command "make uninstallmodules" or "make uninstall" to uninstall
|
||||
binaries, man pages, shell scripts and modules.
|
||||
======================================================================
|
||||
EOF
|
||||
|
||||
exit 0
|
||||
Executable
+16
@@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
# install miscellaneous files
|
||||
|
||||
SRCDIR="$1"
|
||||
PKGCONFIGDIR="$2"
|
||||
shift
|
||||
shift
|
||||
|
||||
cd $SRCDIR || exit 1
|
||||
|
||||
for I in $*
|
||||
do
|
||||
cp $I $PKGCONFIGDIR
|
||||
done
|
||||
|
||||
exit 0
|
||||
Executable
+47
@@ -0,0 +1,47 @@
|
||||
#!/bin/sh
|
||||
# this script courtesy of James_K._Foote.PARC@xerox.com
|
||||
# 5 July 96 Dan.Shearer@UniSA.Edu.Au Don't hardcode script names, get from Make
|
||||
|
||||
INSTALLPERMS=$1
|
||||
BINDIR=$2
|
||||
|
||||
shift
|
||||
shift
|
||||
|
||||
echo Installing scripts in $BINDIR
|
||||
|
||||
for d in $BINDIR; do
|
||||
if [ ! -d $d ]; then
|
||||
mkdir $d
|
||||
if [ ! -d $d ]; then
|
||||
echo Failed to make directory $d
|
||||
echo Have you run installbin first?
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
for p in $*; do
|
||||
p2=`basename $p`
|
||||
echo Installing $BINDIR/$p2
|
||||
if [ -f $BINDIR/$p2 ]; then
|
||||
rm -f $BINDIR/$p2.old
|
||||
mv $BINDIR/$p2 $BINDIR/$p2.old
|
||||
fi
|
||||
cp $p $BINDIR/
|
||||
chmod $INSTALLPERMS $BINDIR/$p2
|
||||
if [ ! -f $BINDIR/$p2 ]; then
|
||||
echo Cannot copy $p2... does $USER have privileges?
|
||||
fi
|
||||
done
|
||||
|
||||
cat << EOF
|
||||
======================================================================
|
||||
The scripts have been installed. You may uninstall them using
|
||||
the command "make uninstallscripts" or "make install" to install binaries,
|
||||
man pages and shell scripts. You may recover the previous version (if any
|
||||
by "make revert".
|
||||
======================================================================
|
||||
EOF
|
||||
|
||||
exit 0
|
||||
Executable
+38
@@ -0,0 +1,38 @@
|
||||
#!/bin/sh
|
||||
|
||||
SWATDIR=$1
|
||||
SRCDIR=$2
|
||||
|
||||
echo Installing swat files in $SWATDIR
|
||||
|
||||
cd $SRCDIR/../swat || exit 1
|
||||
|
||||
mkdir -p $SWATDIR || exit 1
|
||||
|
||||
installdir() {
|
||||
for f in $*; do
|
||||
dname=`dirname $f`
|
||||
echo "Installing $f in $dname"
|
||||
test -d $SWATDIR/$dname || mkdir -p $SWATDIR/$dname || exit 1
|
||||
cp $f $SWATDIR/$dname/ || exit 1
|
||||
chmod 0644 $SWATDIR/$f || exit 1
|
||||
done
|
||||
}
|
||||
|
||||
installdir `find . -name '*.html'`
|
||||
installdir `find . -name '*.js'`
|
||||
installdir `find . -name '*.esp'`
|
||||
installdir `find . -name '*.css'`
|
||||
installdir `find . -name '*.png'`
|
||||
installdir `find . -name '*.ico'`
|
||||
installdir `find . -name '*.gif'`
|
||||
installdir `find . -name '*.ejs'`
|
||||
|
||||
cat << EOF
|
||||
======================================================================
|
||||
The swat files have been installed.
|
||||
======================================================================
|
||||
EOF
|
||||
|
||||
exit 0
|
||||
|
||||
Executable
+18
@@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
|
||||
INSTALLPERMS=$1
|
||||
TORTUREDIR=$2
|
||||
shift
|
||||
shift
|
||||
|
||||
for p in $*; do
|
||||
p2=`dirname $p`
|
||||
base=`basename $p`
|
||||
DESTDIR=$TORTUREDIR/`basename $p2`
|
||||
mkdir -p $DESTDIR
|
||||
echo Installing $p as $DESTDIR/$base
|
||||
cp -f $p $DESTDIR/
|
||||
chmod $INSTALLPERMS $DESTDIR/$base
|
||||
done
|
||||
|
||||
exit 0
|
||||
Executable
+28
@@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
|
||||
LEX="$1"
|
||||
SRC="$2"
|
||||
DEST="$3"
|
||||
|
||||
dir=`dirname $SRC`
|
||||
file=`basename $SRC`
|
||||
base=`basename $SRC .l`
|
||||
if [ -z "$LEX" ]; then
|
||||
echo "lex not found - not regenerating $DEST"
|
||||
exit;
|
||||
fi
|
||||
if [ -r $DEST ]; then
|
||||
if [ x`find $SRC -newer $DEST -print` != x$SRC ]; then
|
||||
exit;
|
||||
fi
|
||||
fi
|
||||
TOP=`pwd`
|
||||
if cd $dir && $LEX $file; then
|
||||
if [ -r $base.yy.c ];then
|
||||
# we must guarantee that config.h comes first
|
||||
echo "#include \"config.h\"" > $base.c
|
||||
sed '/^#/ s|$base.yy\.c|$DEST|' $base.yy.c >> $base.c
|
||||
rm -f $base.yy.c
|
||||
fi
|
||||
fi
|
||||
cd $TOP
|
||||
Executable
+150
@@ -0,0 +1,150 @@
|
||||
#!/usr/bin/perl -w
|
||||
# find a list of #include lines in C code that might not be needed
|
||||
# usually called with something like this:
|
||||
# minimal_includes.pl `find . -name "*.c"`
|
||||
# Andrew Tridgell <tridge@samba.org>
|
||||
|
||||
use strict;
|
||||
use Data::Dumper;
|
||||
use Getopt::Long;
|
||||
|
||||
my $opt_help = 0;
|
||||
my $opt_remove = 0;
|
||||
|
||||
#####################################################################
|
||||
# write a string into a file
|
||||
sub FileSave($$)
|
||||
{
|
||||
my($filename) = shift;
|
||||
my($v) = shift;
|
||||
local(*FILE);
|
||||
open(FILE, ">$filename") || die "can't open $filename";
|
||||
print FILE $v;
|
||||
close(FILE);
|
||||
}
|
||||
|
||||
sub load_lines($)
|
||||
{
|
||||
my $fname = shift;
|
||||
my @lines = split(/^/m, `cat $fname`);
|
||||
return @lines;
|
||||
}
|
||||
|
||||
sub save_lines($$)
|
||||
{
|
||||
my $fname = shift;
|
||||
my $lines = shift;
|
||||
my $data = join('', @{$lines});
|
||||
FileSave($fname, $data);
|
||||
}
|
||||
|
||||
sub test_compile($)
|
||||
{
|
||||
my $fname = shift;
|
||||
my $obj;
|
||||
if ($fname =~ s/(.*)\.c$/$1.o/) {
|
||||
$obj = "$1.o";
|
||||
} else {
|
||||
return "NOT A C FILE";
|
||||
}
|
||||
unlink($obj);
|
||||
my $ret = `make $obj 2>&1`;
|
||||
if (!unlink("$obj")) {
|
||||
return "COMPILE FAILED";
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
sub test_include($$$$)
|
||||
{
|
||||
my $fname = shift;
|
||||
my $lines = shift;
|
||||
my $i = shift;
|
||||
my $original = shift;
|
||||
my $line = $lines->[$i];
|
||||
|
||||
$lines->[$i] = "";
|
||||
save_lines("_testcompile.c", $lines);
|
||||
|
||||
my $out = test_compile("_testcompile.c");
|
||||
$out =~ s/_testcompile.c/$fname/g;
|
||||
|
||||
if ($out eq $original) {
|
||||
if ($opt_remove) {
|
||||
print "$fname: removing $line\n";
|
||||
save_lines($fname, $lines);
|
||||
return;
|
||||
}
|
||||
print "$fname: might be able to remove $line\n";
|
||||
}
|
||||
|
||||
$lines->[$i] = $line;
|
||||
unlink("_testcompile.c");
|
||||
}
|
||||
|
||||
sub process_file($)
|
||||
{
|
||||
my $fname = shift;
|
||||
my @lines = load_lines($fname);
|
||||
my $num_lines = $#lines;
|
||||
|
||||
my $original = test_compile($fname);
|
||||
|
||||
if ($original eq "COMPILE FAILED") {
|
||||
print "Failed to compile $fname\n";
|
||||
return;
|
||||
}
|
||||
|
||||
print "Processing $fname (with $num_lines lines)\n";
|
||||
|
||||
my $if_level = 0;
|
||||
|
||||
for (my $i=0;$i<=$num_lines;$i++) {
|
||||
my $line = $lines[$i];
|
||||
if ($line =~ /^\#\s*if/) {
|
||||
$if_level++;
|
||||
}
|
||||
if ($line =~ /^\#\s*endif/) {
|
||||
$if_level--;
|
||||
}
|
||||
if ($if_level == 0 &&
|
||||
$line =~ /^\#\s*include/ &&
|
||||
!($line =~ /needed/)) {
|
||||
test_include($fname, \@lines, $i, $original);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#########################################
|
||||
# display help text
|
||||
sub ShowHelp()
|
||||
{
|
||||
print "
|
||||
minimise includes
|
||||
Copyright (C) tridge\@samba.org
|
||||
|
||||
Usage: minimal_includes.pl [options] <C files....>
|
||||
|
||||
Options:
|
||||
--help show help
|
||||
--remove remove includes, don't just list them
|
||||
";
|
||||
}
|
||||
|
||||
|
||||
# main program
|
||||
GetOptions (
|
||||
'h|help|?' => \$opt_help,
|
||||
'remove' => \$opt_remove,
|
||||
);
|
||||
|
||||
if ($opt_help) {
|
||||
ShowHelp();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
for (my $i=0;$i<=$#ARGV;$i++) {
|
||||
my $fname = $ARGV[$i];
|
||||
process_file($fname);
|
||||
}
|
||||
Executable
+38
@@ -0,0 +1,38 @@
|
||||
#! /bin/sh
|
||||
# mkinstalldirs --- make directory hierarchy
|
||||
# Author: Noah Friedman <friedman@prep.ai.mit.edu>
|
||||
# Created: 1993-05-16
|
||||
# Public domain
|
||||
|
||||
errstatus=0
|
||||
|
||||
for file
|
||||
do
|
||||
set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
|
||||
shift
|
||||
|
||||
pathcomp=
|
||||
for d
|
||||
do
|
||||
pathcomp="$pathcomp$d"
|
||||
case "$pathcomp" in
|
||||
-* ) pathcomp=./$pathcomp ;;
|
||||
esac
|
||||
|
||||
if test ! -d "$pathcomp"; then
|
||||
echo "mkdir $pathcomp" 1>&2
|
||||
|
||||
mkdir "$pathcomp" || lasterr=$?
|
||||
|
||||
if test ! -d "$pathcomp"; then
|
||||
errstatus=$lasterr
|
||||
fi
|
||||
fi
|
||||
|
||||
pathcomp="$pathcomp/"
|
||||
done
|
||||
done
|
||||
|
||||
exit $errstatus
|
||||
|
||||
# mkinstalldirs ends here
|
||||
Executable
+255
@@ -0,0 +1,255 @@
|
||||
#!/usr/bin/perl
|
||||
# Simple script for generating prototypes for C functions
|
||||
# Written by Jelmer Vernooij
|
||||
# based on the original mkproto.sh by Andrew Tridgell
|
||||
|
||||
use strict;
|
||||
|
||||
# don't use warnings module as it is not portable enough
|
||||
# use warnings;
|
||||
|
||||
use Getopt::Long;
|
||||
use File::Basename;
|
||||
use File::Path;
|
||||
|
||||
#####################################################################
|
||||
# read a file into a string
|
||||
|
||||
my $public_file = undef;
|
||||
my $private_file = undef;
|
||||
my $public_define = undef;
|
||||
my $private_define = undef;
|
||||
my $_public = "";
|
||||
my $_private = "";
|
||||
my $public_data = \$_public;
|
||||
my $private_data = \$_private;
|
||||
my $builddir = undef;
|
||||
my $srcdir = undef;
|
||||
|
||||
sub public($)
|
||||
{
|
||||
my ($d) = @_;
|
||||
$$public_data .= $d;
|
||||
}
|
||||
|
||||
sub private($)
|
||||
{
|
||||
my ($d) = @_;
|
||||
$$private_data .= $d;
|
||||
}
|
||||
|
||||
sub usage()
|
||||
{
|
||||
print "Usage: mkproto.pl [options] [c files]\n";
|
||||
print "OPTIONS:\n";
|
||||
print " --public=FILE Write prototypes for public functions to FILE\n";
|
||||
print " --private=FILE Write prototypes for private functions to FILE\n";
|
||||
print " --define=DEF Use DEF to check whether header was already included\n";
|
||||
print " --public-define=DEF Same as --define, but just for public header\n";
|
||||
print " --private-define=DEF Same as --define, but just for private header\n";
|
||||
print " --srcdir=path Read files relative to this directory\n";
|
||||
print " --builddir=path Write file relative to this directory\n";
|
||||
print " --help Print this help message\n\n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
GetOptions(
|
||||
'public=s' => sub { my ($f,$v) = @_; $public_file = $v; },
|
||||
'private=s' => sub { my ($f,$v) = @_; $private_file = $v; },
|
||||
'define=s' => sub {
|
||||
my ($f,$v) = @_;
|
||||
$public_define = $v;
|
||||
$private_define = "$v\_PRIVATE";
|
||||
},
|
||||
'public-define=s' => \$public_define,
|
||||
'private-define=s' => \$private_define,
|
||||
'srcdir=s' => sub { my ($f,$v) = @_; $srcdir = $v; },
|
||||
'builddir=s' => sub { my ($f,$v) = @_; $builddir = $v; },
|
||||
'help' => \&usage
|
||||
) or exit(1);
|
||||
|
||||
if (not defined($public_define) and defined($public_file)) {
|
||||
$public_define = ".." . uc($public_file) . "__";
|
||||
$public_define =~ tr{./}{__};
|
||||
} elsif (not defined($public_define)) {
|
||||
$public_define = '_PROTO_H_';
|
||||
}
|
||||
|
||||
if (not defined($private_define) and defined($private_file)) {
|
||||
$private_define = "__" . uc($private_file) . "__";
|
||||
$private_define =~ tr{./}{__};
|
||||
} elsif (not defined($public_define)) {
|
||||
$public_define = '_PROTO_H_';
|
||||
}
|
||||
|
||||
if ((defined($private_file) and defined($public_file) and ($private_file eq $public_file)) or
|
||||
(not defined($private_file) and not defined($public_file))) {
|
||||
$private_data = $public_data;
|
||||
}
|
||||
|
||||
sub file_load($)
|
||||
{
|
||||
my($filename) = shift;
|
||||
local(*INPUTFILE);
|
||||
open(INPUTFILE, $filename) || return undef;
|
||||
my($saved_delim) = $/;
|
||||
undef $/;
|
||||
my($data) = <INPUTFILE>;
|
||||
close(INPUTFILE);
|
||||
$/ = $saved_delim;
|
||||
return $data;
|
||||
}
|
||||
|
||||
sub print_header($$)
|
||||
{
|
||||
my ($file, $header_name) = @_;
|
||||
$file->("#ifndef $header_name\n");
|
||||
$file->("#define $header_name\n\n");
|
||||
$file->("#undef _PRINTF_ATTRIBUTE\n");
|
||||
$file->("#define _PRINTF_ATTRIBUTE(a1, a2) PRINTF_ATTRIBUTE(a1, a2)\n");
|
||||
$file->("/* This file was automatically generated by mkproto.pl. DO NOT EDIT */\n\n");
|
||||
}
|
||||
|
||||
sub print_footer($$)
|
||||
{
|
||||
my ($file, $header_name) = @_;
|
||||
$file->("#undef _PRINTF_ATTRIBUTE\n");
|
||||
$file->("#define _PRINTF_ATTRIBUTE(a1, a2)\n");
|
||||
$file->("\n#endif /* $header_name */\n\n");
|
||||
}
|
||||
|
||||
sub handle_loadparm($$)
|
||||
{
|
||||
my ($file,$line) = @_;
|
||||
|
||||
if ($line =~ /^_PUBLIC_ FN_(GLOBAL|LOCAL)_(CONST_STRING|STRING|BOOL|bool|CHAR|INTEGER|LIST)\((\w+),.*\)/o) {
|
||||
my $scope = $1;
|
||||
my $type = $2;
|
||||
my $name = $3;
|
||||
|
||||
my %tmap = (
|
||||
"BOOL" => "BOOL ",
|
||||
"bool" => "bool ",
|
||||
"CONST_STRING" => "const char *",
|
||||
"STRING" => "const char *",
|
||||
"INTEGER" => "int ",
|
||||
"CHAR" => "char ",
|
||||
"LIST" => "const char **",
|
||||
);
|
||||
|
||||
my %smap = (
|
||||
"GLOBAL" => "void",
|
||||
"LOCAL" => "int "
|
||||
);
|
||||
|
||||
$file->("$tmap{$type}$name($smap{$scope});\n");
|
||||
}
|
||||
}
|
||||
|
||||
sub process_file($$$)
|
||||
{
|
||||
my ($public_file, $private_file, $filename) = @_;
|
||||
|
||||
$filename =~ s/\.o$/\.c/g;
|
||||
|
||||
if (!open(FH, "< $builddir/$filename")) {
|
||||
open(FH, "< $srcdir/$filename") || die "Failed to open $filename";
|
||||
}
|
||||
|
||||
$private_file->("\n/* The following definitions come from $filename */\n\n");
|
||||
|
||||
while (my $line = <FH>) {
|
||||
my $target = \&private;
|
||||
my $is_public = 0;
|
||||
|
||||
# these are ordered for maximum speed
|
||||
next if ($line =~ /^\s/);
|
||||
|
||||
next unless ($line =~ /\(/);
|
||||
|
||||
next if ($line =~ /^\/|[;]/);
|
||||
|
||||
if ($line =~ /^_PUBLIC_ FN_/) {
|
||||
handle_loadparm($public_file, $line);
|
||||
next;
|
||||
}
|
||||
|
||||
if ($line =~ /^_PUBLIC_[\t ]/) {
|
||||
$target = \&public;
|
||||
$is_public = 1;
|
||||
}
|
||||
|
||||
next unless ( $is_public || $line =~ /
|
||||
^void|^BOOL|^bool|^int|^struct|^char|^const|^\w+_[tT]\s|^uint|^unsigned|^long|
|
||||
^NTSTATUS|^ADS_STATUS|^enum\s.*\(|^DATA_BLOB|^WERROR|^XFILE|^FILE|^DIR|
|
||||
^double|^TDB_CONTEXT|^TDB_DATA|^TALLOC_CTX|^NTTIME|^FN_|^init_module|
|
||||
^GtkWidget|^GType|^smb_ucs2_t|^krb5_error_code
|
||||
/xo);
|
||||
|
||||
next if ($line =~ /^int\s*main/);
|
||||
|
||||
if ( $line =~ /\(.*\)\s*$/o ) {
|
||||
chomp $line;
|
||||
$target->("$line;\n");
|
||||
next;
|
||||
}
|
||||
|
||||
$target->($line);
|
||||
|
||||
while ($line = <FH>) {
|
||||
if ($line =~ /\)\s*$/o) {
|
||||
chomp $line;
|
||||
$target->("$line;\n");
|
||||
last;
|
||||
}
|
||||
$target->($line);
|
||||
}
|
||||
}
|
||||
|
||||
close(FH);
|
||||
}
|
||||
|
||||
|
||||
print_header(\&public, $public_define);
|
||||
if ($public_file ne $private_file) {
|
||||
print_header(\&private, $private_define);
|
||||
|
||||
private("/* this file contains prototypes for functions that " .
|
||||
"are private \n * to this subsystem or library. These functions " .
|
||||
"should not be \n * used outside this particular subsystem! */\n\n");
|
||||
|
||||
public("/* this file contains prototypes for functions that " .
|
||||
"are part of \n * the public API of this subsystem or library. */\n\n");
|
||||
|
||||
}
|
||||
|
||||
public("#ifndef _PUBLIC_\n#define _PUBLIC_\n#endif\n\n");
|
||||
|
||||
process_file(\&public, \&private, $_) foreach (@ARGV);
|
||||
print_footer(\&public, $public_define);
|
||||
if ($public_file ne $private_file) {
|
||||
print_footer(\&private, $private_define);
|
||||
}
|
||||
|
||||
if (not defined($public_file)) {
|
||||
print STDOUT $$public_data;
|
||||
}
|
||||
|
||||
if (not defined($private_file) and defined($public_file)) {
|
||||
print STDOUT $$private_data;
|
||||
}
|
||||
|
||||
my $old_public_data = file_load($public_file);
|
||||
my $old_private_data = file_load($private_file);
|
||||
|
||||
mkpath(dirname($public_file), 0, 0755);
|
||||
open(PUBLIC, ">$public_file") or die("Can't open `$public_file': $!");
|
||||
print PUBLIC "$$public_data";
|
||||
close(PUBLIC);
|
||||
|
||||
if ($public_file ne $private_file) {
|
||||
mkpath(dirname($private_file), 0, 0755);
|
||||
open(PRIVATE, ">$private_file") or die("Can't open `$private_file': $!");
|
||||
print PRIVATE "$$private_data";
|
||||
close(PRIVATE);
|
||||
}
|
||||
Executable
+168
@@ -0,0 +1,168 @@
|
||||
#!/bin/sh
|
||||
|
||||
VERSION_FILE=$1
|
||||
OUTPUT_FILE=$2
|
||||
|
||||
if test -z "$VERSION_FILE";then
|
||||
VERSION_FILE="VERSION"
|
||||
fi
|
||||
|
||||
if test -z "$OUTPUT_FILE";then
|
||||
OUTPUT_FILE="version.h"
|
||||
fi
|
||||
|
||||
SOURCE_DIR=$3
|
||||
|
||||
SAMBA_VERSION_MAJOR=`sed -n 's/^SAMBA_VERSION_MAJOR=//p' $SOURCE_DIR$VERSION_FILE`
|
||||
SAMBA_VERSION_MINOR=`sed -n 's/^SAMBA_VERSION_MINOR=//p' $SOURCE_DIR$VERSION_FILE`
|
||||
SAMBA_VERSION_RELEASE=`sed -n 's/^SAMBA_VERSION_RELEASE=//p' $SOURCE_DIR$VERSION_FILE`
|
||||
|
||||
SAMBA_VERSION_REVISION=`sed -n 's/^SAMBA_VERSION_REVISION=//p' $SOURCE_DIR$VERSION_FILE`
|
||||
|
||||
SAMBA_VERSION_TP_RELEASE=`sed -n 's/^SAMBA_VERSION_TP_RELEASE=//p' $SOURCE_DIR$VERSION_FILE`
|
||||
SAMBA_VERSION_PRE_RELEASE=`sed -n 's/^SAMBA_VERSION_PRE_RELEASE=//p' $SOURCE_DIR$VERSION_FILE`
|
||||
SAMBA_VERSION_RC_RELEASE=`sed -n 's/^SAMBA_VERSION_RC_RELEASE=//p' $SOURCE_DIR$VERSION_FILE`
|
||||
|
||||
SAMBA_VERSION_IS_SVN_SNAPSHOT=`sed -n 's/^SAMBA_VERSION_IS_SVN_SNAPSHOT=//p' $SOURCE_DIR$VERSION_FILE`
|
||||
|
||||
SAMBA_VERSION_RELEASE_NICKNAME=`sed -n 's/^SAMBA_VERSION_RELEASE_NICKNAME=//p' $SOURCE_DIR$VERSION_FILE`
|
||||
|
||||
SAMBA_VERSION_VENDOR_SUFFIX=`sed -n 's/^SAMBA_VERSION_VENDOR_SUFFIX=//p' $SOURCE_DIR$VERSION_FILE`
|
||||
SAMBA_VERSION_VENDOR_PATCH=`sed -n 's/^SAMBA_VERSION_VENDOR_PATCH=//p' $SOURCE_DIR$VERSION_FILE`
|
||||
|
||||
echo "/* Autogenerated by script/mkversion.sh */" > $OUTPUT_FILE
|
||||
|
||||
echo "#define SAMBA_VERSION_MAJOR ${SAMBA_VERSION_MAJOR}" >> $OUTPUT_FILE
|
||||
echo "#define SAMBA_VERSION_MINOR ${SAMBA_VERSION_MINOR}" >> $OUTPUT_FILE
|
||||
echo "#define SAMBA_VERSION_RELEASE ${SAMBA_VERSION_RELEASE}" >> $OUTPUT_FILE
|
||||
|
||||
|
||||
##
|
||||
## start with "3.0.22"
|
||||
##
|
||||
SAMBA_VERSION_STRING="${SAMBA_VERSION_MAJOR}.${SAMBA_VERSION_MINOR}.${SAMBA_VERSION_RELEASE}"
|
||||
|
||||
|
||||
##
|
||||
## maybe add "3.0.22a" or "4.0.0tp11" or "3.0.22pre1" or "3.0.22rc1"
|
||||
## We do not do pre or rc version on patch/letter releases
|
||||
##
|
||||
if test -n "${SAMBA_VERSION_REVISION}";then
|
||||
SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}${SAMBA_VERSION_REVISION}"
|
||||
echo "#define SAMBA_VERSION_REVISION \"${SAMBA_VERSION_REVISION}\"" >> $OUTPUT_FILE
|
||||
elif test -n "${SAMBA_VERSION_TP_RELEASE}";then
|
||||
SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}tp${SAMBA_VERSION_TP_RELEASE}"
|
||||
echo "#define SAMBA_VERSION_TP_RELEASE ${SAMBA_VERSION_TP_RELEASE}" >> $OUTPUT_FILE
|
||||
elif test -n "${SAMBA_VERSION_PRE_RELEASE}";then
|
||||
## maybe add "3.0.22pre2"
|
||||
SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}pre${SAMBA_VERSION_PRE_RELEASE}"
|
||||
echo "#define SAMBA_VERSION_PRE_RELEASE ${SAMBA_VERSION_PRE_RELEASE}" >> $OUTPUT_FILE
|
||||
elif test -n "${SAMBA_VERSION_RC_RELEASE}";then
|
||||
SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}rc${SAMBA_VERSION_RC_RELEASE}"
|
||||
echo "#define SAMBA_VERSION_RC_RELEASE ${SAMBA_VERSION_RC_RELEASE}" >> $OUTPUT_FILE
|
||||
fi
|
||||
|
||||
##
|
||||
## SVN revision number?
|
||||
##
|
||||
if test x"${SAMBA_VERSION_IS_SVN_SNAPSHOT}" = x"yes";then
|
||||
_SAVE_LANG=${LANG}
|
||||
LANG=""
|
||||
HAVEVER="no"
|
||||
|
||||
if test x"${HAVEVER}" != x"yes";then
|
||||
HAVESVN=no
|
||||
SVN_INFO=`svn info ${SOURCE_DIR} 2>/dev/null`
|
||||
TMP_REVISION=`echo -e "${SVN_INFO}" | grep 'Last Changed Rev.*:' |sed -e 's/Last Changed Rev.*: \([0-9]*\).*/\1/'`
|
||||
if test -n "$TMP_REVISION"; then
|
||||
HAVESVN=yes
|
||||
HAVEVER=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
# if test x"${HAVEVER}" != x"yes";then
|
||||
# svk is stupid and you can't call info in non-interactive mode
|
||||
# this causes the script to hang if svk is present but not being used
|
||||
if false; then
|
||||
HAVESVK=no
|
||||
SVK_INFO=`svk info ${SOURCE_DIR} 2>/dev/null`
|
||||
TMP_REVISION=`echo -e "${SVK_INFO}" | grep 'Last Changed Rev.*:' |sed -e 's/Last Changed Rev.*: \([0-9]*\).*/\1/'`
|
||||
if test -n "$TMP_REVISION"; then
|
||||
HAVESVK=yes
|
||||
HAVEVER=yes
|
||||
fi
|
||||
TMP_MIRRORED_REVISION=`echo -e "${SVK_INFO}" | grep 'Mirrored From:.*samba\.org.*' |sed -e 's/Mirrored From: .* Rev\..* \([0-9]*\).*/\1/'`
|
||||
fi
|
||||
|
||||
if test x"${HAVEVER}" != x"yes";then
|
||||
HAVEBZR=no
|
||||
BZR_INFO=`bzr version-info --check-clean ${SOURCE_DIR} 2>/dev/null`
|
||||
TMP_REVISION=`echo -e "${BZR_INFO}" | grep 'revno:' |sed -e 's/revno: \([0-9]*\).*/\1/'`
|
||||
if test -n "$TMP_REVISION"; then
|
||||
HAVEBZR=yes
|
||||
HAVEVER=yes
|
||||
fi
|
||||
TMP_MIRRORED_REVISION=`echo -e "${BZR_INFO}" | grep 'revision-id: svn-v1:.*@0c0555d6-39d7-0310-84fc-f1cc0bd64818' |sed -e 's/revision-id: svn-v1:\([0-9]*\)@0c0555d6-39d7-0310-84fc-f1cc0bd64818.*/\1/'`
|
||||
TMP_BRANCH_NICK=`echo -e "${BZR_INFO}" | grep 'branch-nick:' |sed -e 's/branch-nick: \(.*\)$/\1/'`
|
||||
TMP_CLEAN_TREE=`echo -e "${BZR_INFO}" | grep 'clean:' |sed -e 's/clean: \([a-zA-Z]*\).*/\1/'`
|
||||
fi
|
||||
|
||||
if test x"${HAVESVN}" = x"yes";then
|
||||
SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}-SVN-build-${TMP_REVISION}"
|
||||
echo "#define SAMBA_VERSION_SVN_REVISION ${TMP_REVISION}" >> $OUTPUT_FILE
|
||||
elif test x"${HAVESVK}" = x"yes";then
|
||||
if test -n "$TMP_MIRRORED_REVISION"; then
|
||||
TMP_SVK_REVISION_STR="${TMP_REVISION}-${USER}@${HOSTNAME}-[SVN-${TMP_MIRRORED_REVISION}]"
|
||||
else
|
||||
TMP_SVK_REVISION_STR="${TMP_REVISION}-${USER}@${HOSTNAME}"
|
||||
fi
|
||||
SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}-SVK-build-${TMP_SVK_REVISION_STR}"
|
||||
elif test x"${HAVEBZR}" = x"yes";then
|
||||
TMP_BZR_REVISION_STR="${TMP_REVISION}"
|
||||
|
||||
if test -n "$TMP_BRANCH_NICK"; then
|
||||
TMP_BZR_REVISION_STR="${TMP_BZR_REVISION_STR}${TMP_MOD_STR}@${TMP_BRANCH_NICK}"
|
||||
fi
|
||||
|
||||
if test -n "$TMP_MIRRORED_REVISION"; then
|
||||
TMP_BZR_REVISION_STR="${TMP_BZR_REVISION_STR}-[SVN-${TMP_MIRRORED_REVISION}]"
|
||||
fi
|
||||
|
||||
if test x"$TMP_CLEAN_TREE" != x"True"; then
|
||||
TMP_BZR_REVISION_STR="${TMP_BZR_REVISION_STR}-[modified]"
|
||||
fi
|
||||
|
||||
SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}-BZR-${TMP_BZR_REVISION_STR}"
|
||||
else
|
||||
SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}-SVN-build-UNKNOWN"
|
||||
fi
|
||||
LANG=${_SAVE_LANG}
|
||||
fi
|
||||
|
||||
echo "#define SAMBA_VERSION_OFFICIAL_STRING \"${SAMBA_VERSION_STRING}\"" >> $OUTPUT_FILE
|
||||
|
||||
##
|
||||
## Add the vendor string if present
|
||||
##
|
||||
if test -n "${SAMBA_VERSION_VENDOR_SUFFIX}";then
|
||||
echo "#define SAMBA_VERSION_VENDOR_SUFFIX ${SAMBA_VERSION_VENDOR_SUFFIX}" >> $OUTPUT_FILE
|
||||
SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}-${SAMBA_VERSION_VENDOR_SUFFIX}"
|
||||
if test -n "${SAMBA_VERSION_VENDOR_PATCH}";then
|
||||
echo "#define SAMBA_VERSION_VENDOR_PATCH ${SAMBA_VERSION_VENDOR_PATCH}" >> $OUTPUT_FILE
|
||||
SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}-${SAMBA_VERSION_VENDOR_PATCH}"
|
||||
fi
|
||||
fi
|
||||
|
||||
##
|
||||
## Add a release nickname
|
||||
##
|
||||
if test -n "${SAMBA_VERSION_RELEASE_NICKNAME}";then
|
||||
echo "#define SAMBA_VERSION_RELEASE_NICKNAME ${SAMBA_VERSION_RELEASE_NICKNAME}" >> $OUTPUT_FILE
|
||||
SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING} (${SAMBA_VERSION_RELEASE_NICKNAME})"
|
||||
fi
|
||||
|
||||
echo "#define SAMBA_VERSION_STRING \"${SAMBA_VERSION_STRING}\"" >> $OUTPUT_FILE
|
||||
|
||||
echo "$0: '$OUTPUT_FILE' created for Samba(\"${SAMBA_VERSION_STRING}\")"
|
||||
|
||||
exit 0
|
||||
Executable
+145
@@ -0,0 +1,145 @@
|
||||
#!/usr/bin/perl
|
||||
# Simple pkg-config implementation in perl
|
||||
# jelmer@samba.org, November 2006
|
||||
|
||||
use strict;
|
||||
use Getopt::Long;
|
||||
|
||||
my @dirs = split(/:/, $ENV{PKG_CONFIG_PATH});
|
||||
|
||||
my $opt_help = 0;
|
||||
my $opt_libs = 0;
|
||||
my $opt_cflags = 0;
|
||||
my $opt_static = 0;
|
||||
|
||||
my $result = GetOptions (
|
||||
'help|h|?' => \$opt_help,
|
||||
'static' => \$opt_static,
|
||||
'libs' => \$opt_libs,
|
||||
'cflags' => \$opt_cflags
|
||||
);
|
||||
|
||||
if (not $result) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ($opt_help) {
|
||||
print "pkg-config replacement in perl\n";
|
||||
print "Copyright (C) 2006 Jelmer Vernooij <jelmer\@samba.org>\n";
|
||||
print "\n";
|
||||
print "Usage: pkg-config [OPTIONS] PACKAGE...\n";
|
||||
print " --help Print this help message\n";
|
||||
print " --static Print flags for static libraries\n";
|
||||
print " --libs Print linker flags\n";
|
||||
print " --cflags Print C compiler flags\n";
|
||||
print "\n";
|
||||
exit(0);
|
||||
}
|
||||
|
||||
sub find_path($)
|
||||
{
|
||||
my $name = shift;
|
||||
foreach my $dir (@dirs) {
|
||||
if (-f "$dir/$name-uninstalled.pc") {
|
||||
return "$dir/$name-uninstalled.pc";
|
||||
}
|
||||
}
|
||||
foreach my $dir (@dirs) {
|
||||
if (-f "$dir/$name.pc" ) {
|
||||
return "$dir/$name.pc";
|
||||
}
|
||||
}
|
||||
die("No such package `$name'");
|
||||
}
|
||||
|
||||
sub ReplaceVars($$)
|
||||
{
|
||||
my ($expr, $vars) = @_;
|
||||
|
||||
$_ = $expr;
|
||||
|
||||
while (/(.*)\${([^}]+)}(.*)/) {
|
||||
$_ = "$1$vars->{$2}$3";
|
||||
}
|
||||
|
||||
return $_;
|
||||
}
|
||||
|
||||
sub Parse($)
|
||||
{
|
||||
my $name = shift;
|
||||
my $path = find_path($name);
|
||||
my %variables = ();
|
||||
my %fields = ();
|
||||
my $lineno = 0;
|
||||
open(IN, "<$path") or die("Unable to open $path: $!");
|
||||
foreach (<IN>) {
|
||||
$lineno+=1;
|
||||
next if (/^#.*/);
|
||||
if (/^([A-Za-z.]+): (.*)$/) {
|
||||
$fields{$1} = ReplaceVars($2, \%variables);
|
||||
} elsif (/^([A-Za-z_]+)=(.*)$/) {
|
||||
$variables{$1} = ReplaceVars($2, \%variables);
|
||||
} elsif (/^[ \t]*$/) {
|
||||
} else {
|
||||
warn("$path:$lineno: parse error");
|
||||
}
|
||||
}
|
||||
close(IN);
|
||||
return \%fields;
|
||||
}
|
||||
|
||||
sub Cflags($)
|
||||
{
|
||||
my $name = shift;
|
||||
my $fields = Parse($name);
|
||||
my @cflags = split(/ /, $fields->{Cflags});
|
||||
foreach (split(/[, ]/, $fields->{Requires})) {
|
||||
push (@cflags, Cflags($_));
|
||||
}
|
||||
return @cflags;
|
||||
}
|
||||
|
||||
sub Libs($)
|
||||
{
|
||||
my $name = shift;
|
||||
my $fields = Parse($name);
|
||||
my @libs = split(/ /, $fields->{Libs});
|
||||
foreach (split(/[, ]/, $fields->{Requires})) {
|
||||
push (@libs, Libs($_));
|
||||
}
|
||||
if ($opt_static) {
|
||||
foreach (split(/[ ,]/, $fields->{"Requires.private"})) {
|
||||
push (@libs, Libs($_));
|
||||
}
|
||||
}
|
||||
return @libs;
|
||||
}
|
||||
|
||||
my @out = ();
|
||||
|
||||
foreach my $pkg (@ARGV)
|
||||
{
|
||||
push (@out, Libs($pkg)) if ($opt_libs);
|
||||
push (@out, Cflags($pkg)) if ($opt_cflags);
|
||||
}
|
||||
|
||||
sub nub
|
||||
{
|
||||
my @list = @_;
|
||||
my @ret = ();
|
||||
my %seen = ();
|
||||
foreach (@list) {
|
||||
next if (defined($seen{$_}));
|
||||
push (@ret, $_);
|
||||
$seen{$_} = 1;
|
||||
}
|
||||
return @ret;
|
||||
}
|
||||
|
||||
if ($#out >= 0) {
|
||||
@out = nub(@out);
|
||||
print join(' ', @out) . "\n";
|
||||
}
|
||||
|
||||
exit 0;
|
||||
Executable
+18
@@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
BINDIR=$1
|
||||
shift
|
||||
|
||||
for p in $*; do
|
||||
p2=`basename $p`
|
||||
if [ -f $BINDIR/$p2.old ]; then
|
||||
echo Restoring $BINDIR/$p2.old
|
||||
mv $BINDIR/$p2 $BINDIR/$p2.new
|
||||
mv $BINDIR/$p2.old $BINDIR/$p2
|
||||
rm -f $BINDIR/$p2.new
|
||||
else
|
||||
echo Not restoring $p
|
||||
fi
|
||||
done
|
||||
|
||||
exit 0
|
||||
|
||||
Executable
+65
@@ -0,0 +1,65 @@
|
||||
#!/usr/bin/perl
|
||||
# Simple subunit parser
|
||||
# (C) 2006 Jelmer Vernooij <jelmer@samba.org>
|
||||
|
||||
use strict;
|
||||
use Getopt::Long;
|
||||
|
||||
my $numtests = 0;
|
||||
my $numfails = 0;
|
||||
my $numskips = 0;
|
||||
my $numsuccess = 0;
|
||||
|
||||
my $opt_help = 0;
|
||||
my $opt_progress = 0;
|
||||
|
||||
my $result = GetOptions (
|
||||
'help|h|?' => \$opt_help,
|
||||
'progress' => \$opt_progress
|
||||
);
|
||||
|
||||
if (not $result) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ($opt_help) {
|
||||
print "subunit output summarizer\n";
|
||||
print "Copyright (C) 2006 Jelmer Vernooij <jelmer\@samba.org>\n";
|
||||
print "\n";
|
||||
print "Usage: subunit-summary [OPTION]\n";
|
||||
print " --help Print this help message\n";
|
||||
print "\n";
|
||||
exit(0);
|
||||
}
|
||||
|
||||
while(<STDIN>) {
|
||||
next unless (/^(.+): (.+?)( \[)?$/);
|
||||
if ($1 eq "test") {
|
||||
$numtests++;
|
||||
} elsif ($1 eq "error") {
|
||||
print "E" if ($opt_progress);
|
||||
} elsif ($1 eq "failure") {
|
||||
$numfails++;
|
||||
print "F" if ($opt_progress);
|
||||
} elsif ($1 eq "success") {
|
||||
$numsuccess++;
|
||||
print "." if ($opt_progress);
|
||||
} elsif ($1 eq "skip") {
|
||||
$numskips++;
|
||||
print "I" if ($opt_progress);
|
||||
} elsif ($1 eq "testsuite") {
|
||||
if ($opt_progress) {
|
||||
if ($numtests) { print "\n"; }
|
||||
print "$2: ";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print "\n" if ($opt_progress);
|
||||
|
||||
printf("%d%%: %d tests, %d succeeded, %d failed, %d skipped\n",
|
||||
($numsuccess / $numtests * 100),
|
||||
$numtests,
|
||||
$numsuccess,
|
||||
$numfails,
|
||||
$numskips);
|
||||
@@ -0,0 +1,4 @@
|
||||
This directory contains test scripts that are useful for running a
|
||||
bunch of tests all at once. I expect it will eventually be hooked into
|
||||
a "make test" framework.
|
||||
|
||||
Executable
+448
@@ -0,0 +1,448 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ $# -lt 1 ]
|
||||
then
|
||||
echo "$0 PREFIX"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
PREFIX=$1
|
||||
|
||||
if test -z "$TLS_ENABLED"; then
|
||||
TLS_ENABLED=false
|
||||
fi
|
||||
|
||||
if test -z "$SHARE_BACKEND"; then
|
||||
SHARE_BACKEND=classic
|
||||
fi
|
||||
|
||||
if test -z "$SMBD_LOGLEVEL"; then
|
||||
SMBD_LOGLEVEL=1
|
||||
fi
|
||||
|
||||
DOMAIN=SAMBADOMAIN
|
||||
USERNAME=administrator
|
||||
REALM=SAMBA.EXAMPLE.COM
|
||||
DNSNAME="samba.example.com"
|
||||
BASEDN="dc=samba,dc=example,dc=com"
|
||||
PASSWORD=penguin
|
||||
AUTH="-U$USERNAME%$PASSWORD"
|
||||
SRCDIR=`pwd`
|
||||
ROOT=$USER
|
||||
SERVER=localhost
|
||||
NETBIOSNAME=localtest
|
||||
if test -z "$ROOT"; then
|
||||
ROOT=$LOGNAME
|
||||
fi
|
||||
if test -z "$ROOT"; then
|
||||
ROOT=`whoami`
|
||||
fi
|
||||
|
||||
oldpwd=`pwd`
|
||||
srcdir=`dirname $0`/../..
|
||||
mkdir -p $PREFIX || exit $?
|
||||
cd $PREFIX
|
||||
PREFIX_ABS=`pwd`
|
||||
export PREFIX_ABS
|
||||
cd $oldpwd
|
||||
|
||||
TEST_DATA_PREFIX=$PREFIX_ABS
|
||||
export TEST_DATA_PREFIX
|
||||
|
||||
TMPDIR=$PREFIX_ABS/tmp
|
||||
ETCDIR=$PREFIX_ABS/etc
|
||||
PIDDIR=$PREFIX_ABS/pid
|
||||
CONFFILE=$ETCDIR/smb.conf
|
||||
KRB5_CONFIG=$ETCDIR/krb5.conf
|
||||
PRIVATEDIR=$PREFIX_ABS/private
|
||||
NCALRPCDIR=$PREFIX_ABS/ncalrpc
|
||||
LOCKDIR=$PREFIX_ABS/lockdir
|
||||
TLSDIR=$PRIVATEDIR/tls
|
||||
DHFILE=$TLSDIR/dhparms.pem
|
||||
CAFILE=$TLSDIR/ca.pem
|
||||
CERTFILE=$TLSDIR/cert.pem
|
||||
KEYFILE=$TLSDIR/key.pem
|
||||
WINBINDD_SOCKET_DIR=$PREFIX_ABS/winbind_socket
|
||||
CONFIGURATION="--configfile=$CONFFILE"
|
||||
LDAPDIR=$PREFIX_ABS/ldap
|
||||
SLAPD_CONF=$LDAPDIR/slapd.conf
|
||||
export CONFIGURATION
|
||||
export CONFFILE
|
||||
export SLAPD_CONF
|
||||
export PIDDIR
|
||||
export AUTH
|
||||
export SERVER
|
||||
export NETBIOSNAME
|
||||
|
||||
rm -rf $PREFIX/*
|
||||
mkdir -p $PRIVATEDIR $ETCDIR $PIDDIR $NCALRPCDIR $LOCKDIR $TMPDIR $TLSDIR $LDAPDIR/db $LDAPDIR/db/bdb-logs $LDAPDIR/db/tmp
|
||||
|
||||
if [ -z "$VALGRIND" ]; then
|
||||
nativeiconv="true"
|
||||
else
|
||||
nativeiconv="false"
|
||||
fi
|
||||
|
||||
cat >$CONFFILE<<EOF
|
||||
[global]
|
||||
iconv:native = $nativeiconv
|
||||
netbios name = $NETBIOSNAME
|
||||
netbios aliases = $SERVER
|
||||
workgroup = $DOMAIN
|
||||
realm = $REALM
|
||||
private dir = $PRIVATEDIR
|
||||
pid directory = $PIDDIR
|
||||
ncalrpc dir = $NCALRPCDIR
|
||||
lock dir = $LOCKDIR
|
||||
share backend = $SHARE_BACKEND
|
||||
setup directory = $SRCDIR/setup
|
||||
js include = $SRCDIR/scripting/libjs
|
||||
winbindd socket directory = $WINBINDD_SOCKET_DIR
|
||||
name resolve order = bcast
|
||||
interfaces = 127.0.0.1/8
|
||||
tls enabled = $TLS_ENABLED
|
||||
tls dh params file = $DHFILE
|
||||
panic action = $SRCDIR/script/gdb_backtrace %PID% %PROG%
|
||||
wins support = yes
|
||||
server role = pdc
|
||||
max xmit = 32K
|
||||
server max protocol = SMB2
|
||||
notify:inotify = false
|
||||
ldb:nosync = true
|
||||
torture:subunitdir = $SRCDIR/bin/torture
|
||||
torture:basedir = $TEST_DATA_PREFIX
|
||||
|
||||
system:anonymous = true
|
||||
#We don't want to pass our self-tests if the PAC code is wrong
|
||||
gensec:require_pac = true
|
||||
|
||||
log level = $SMBD_LOGLEVEL
|
||||
|
||||
[tmp]
|
||||
path = $TMPDIR
|
||||
read only = no
|
||||
ntvfs handler = posix
|
||||
posix:sharedelay = 100000
|
||||
posix:eadb = $LOCKDIR/eadb.tdb
|
||||
|
||||
[cifs]
|
||||
read only = no
|
||||
ntvfs handler = cifs
|
||||
cifs:server = $SERVER
|
||||
cifs:user = $USERNAME
|
||||
cifs:password = $PASSWORD
|
||||
cifs:domain = $DOMAIN
|
||||
cifs:share = tmp
|
||||
|
||||
[simple]
|
||||
path = $TMPDIR
|
||||
read only = no
|
||||
ntvfs handler = simple
|
||||
|
||||
[cifsposixtestshare]
|
||||
read only = no
|
||||
ntvfs handler = cifsposix
|
||||
path = $TMPDIR
|
||||
EOF
|
||||
|
||||
## Override default srahes_config.ldb file
|
||||
rm -f $PRIVATEDIR/share.ldb
|
||||
cat >$PRIVATEDIR/share.ldif<<EOF
|
||||
### Shares basedn
|
||||
dn: @INDEXLIST
|
||||
@IDXATTR: name
|
||||
|
||||
dn: @ATTRIBUTES
|
||||
cn: CASE_INSENSITIVE
|
||||
dc: CASE_INSENSITIVE
|
||||
name: CASE_INSENSITIVE
|
||||
dn: CASE_INSENSITIVE
|
||||
objectClass: CASE_INSENSITIVE
|
||||
|
||||
dn: CN=Shares
|
||||
objectClass: top
|
||||
objectClass: organizationalUnit
|
||||
cn: Shares
|
||||
|
||||
### Default IPC$ Share
|
||||
dn: CN=IPC$,CN=Shares
|
||||
objectClass: top
|
||||
objectClass: share
|
||||
cn: IPC$
|
||||
name: IPC$
|
||||
type: IPC
|
||||
path: /tmp
|
||||
comment: Remote IPC
|
||||
max-connections: -1
|
||||
available: True
|
||||
readonly: True
|
||||
browseable: False
|
||||
ntvfs-handler: default
|
||||
|
||||
### Default ADMIN$ Share
|
||||
dn: CN=ADMIN$,CN=Shares
|
||||
objectClass: top
|
||||
objectClass: share
|
||||
cn: ADMIN$
|
||||
name: ADMIN$
|
||||
type: DISK
|
||||
path: /tmp
|
||||
comment: Remote Admin
|
||||
max-connections: -1
|
||||
available: True
|
||||
readonly: True
|
||||
browseable: False
|
||||
ntvfs-handler: default
|
||||
|
||||
dn: CN=tmp,CN=Shares
|
||||
objectClass: top
|
||||
objectClass: share
|
||||
cn: tmp
|
||||
name: tmp
|
||||
type: DISK
|
||||
path: $TMPDIR
|
||||
comment: Temp Dir for Tests
|
||||
readonly: False
|
||||
ntvfs-handler: posix
|
||||
posix-sharedelay: 100000
|
||||
posix-eadb: $LOCKDIR/eadb.tdb
|
||||
|
||||
dn: CN=cifs,CN=Shares
|
||||
objectClass: top
|
||||
objectClass: share
|
||||
cn: cifs
|
||||
name: cifs
|
||||
type: DISK
|
||||
readonly: False
|
||||
ntvfs-handler: cifs
|
||||
cifs-server: $SERVER
|
||||
cifs-user: $USERNAME
|
||||
cifs-password: $PASSWORD
|
||||
cifs-domain: $DOMAIN
|
||||
cifs-share: tmp
|
||||
EOF
|
||||
|
||||
$srcdir/bin/ldbadd -H $PRIVATEDIR/share.ldb < $PRIVATEDIR/share.ldif >/dev/null || exit 1
|
||||
|
||||
cat >$KRB5_CONFIG<<EOF
|
||||
[libdefaults]
|
||||
default_realm = SAMBA.EXAMPLE.COM
|
||||
dns_lookup_realm = false
|
||||
dns_lookup_kdc = false
|
||||
ticket_lifetime = 24h
|
||||
forwardable = yes
|
||||
|
||||
[realms]
|
||||
SAMBA.EXAMPLE.COM = {
|
||||
kdc = 127.0.0.1:88
|
||||
admin_server = 127.0.0.1:88
|
||||
default_domain = samba.example.com
|
||||
}
|
||||
[domain_realm]
|
||||
.samba.example.com = SAMBA.EXAMPLE.COM
|
||||
EOF
|
||||
export KRB5_CONFIG
|
||||
|
||||
cat >$DHFILE<<EOF
|
||||
-----BEGIN DH PARAMETERS-----
|
||||
MGYCYQC/eWD2xkb7uELmqLi+ygPMKyVcpHUo2yCluwnbPutEueuxrG/Cys8j8wLO
|
||||
svCN/jYNyR2NszOmg7ZWcOC/4z/4pWDVPUZr8qrkhj5MRKJc52MncfaDglvEdJrv
|
||||
YX70obsCAQI=
|
||||
-----END DH PARAMETERS-----
|
||||
|
||||
EOF
|
||||
|
||||
cat >$CAFILE<<EOF
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIICYTCCAcygAwIBAgIE5M7SRDALBgkqhkiG9w0BAQUwZTEdMBsGA1UEChMUU2Ft
|
||||
YmEgQWRtaW5pc3RyYXRpb24xNDAyBgNVBAsTK1NhbWJhIC0gdGVtcG9yYXJ5IGF1
|
||||
dG9nZW5lcmF0ZWQgY2VydGlmaWNhdGUxDjAMBgNVBAMTBVNhbWJhMB4XDTA2MDgw
|
||||
NDA0MzY1MloXDTA4MDcwNDA0MzY1MlowZTEdMBsGA1UEChMUU2FtYmEgQWRtaW5p
|
||||
c3RyYXRpb24xNDAyBgNVBAsTK1NhbWJhIC0gdGVtcG9yYXJ5IGF1dG9nZW5lcmF0
|
||||
ZWQgY2VydGlmaWNhdGUxDjAMBgNVBAMTBVNhbWJhMIGcMAsGCSqGSIb3DQEBAQOB
|
||||
jAAwgYgCgYC3WJ7DNQAVnqiJxhf6Tq4pqNyUIlioDFNnkJZ6ycElhblyDb3vaagO
|
||||
9c+saw3cl/4KGWBZK46HtimRApE6ZriV7yHSB4afVjhnHZvlQVccAuTKJatBpIeb
|
||||
kenOX0boUVXrWWj6VVnseab+5nA+uPZQQHinRLEVhUn72I14YdKJOQIDAQABoyUw
|
||||
IzAMBgNVHRMBAf8EAjAAMBMGA1UdJQQMMAoGCCsGAQUFBwMBMAsGCSqGSIb3DQEB
|
||||
BQOBgQA5IVkBXU2S4i3dSSM9KmdKJinok1IOGNLZYQSyzduuie9vTmGXCQiQppWb
|
||||
oSjZaf/Zn8La8THvm4QfmwruPkTEL956BRyN9hHYwHWZsebJr7DvSrF1Zugd0jFs
|
||||
DZZFfDUSinYEqApdYzMka/GYTSk1Fa31G5TVD56mIdxmVAdC+A==
|
||||
-----END CERTIFICATE-----
|
||||
|
||||
EOF
|
||||
|
||||
cat >$CERTFILE<<EOF
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIICYTCCAcygAwIBAgIE5M7SRDALBgkqhkiG9w0BAQUwZTEdMBsGA1UEChMUU2Ft
|
||||
YmEgQWRtaW5pc3RyYXRpb24xNDAyBgNVBAsTK1NhbWJhIC0gdGVtcG9yYXJ5IGF1
|
||||
dG9nZW5lcmF0ZWQgY2VydGlmaWNhdGUxDjAMBgNVBAMTBVNhbWJhMB4XDTA2MDgw
|
||||
NDA0MzY1MloXDTA4MDcwNDA0MzY1MlowZTEdMBsGA1UEChMUU2FtYmEgQWRtaW5p
|
||||
c3RyYXRpb24xNDAyBgNVBAsTK1NhbWJhIC0gdGVtcG9yYXJ5IGF1dG9nZW5lcmF0
|
||||
ZWQgY2VydGlmaWNhdGUxDjAMBgNVBAMTBVNhbWJhMIGcMAsGCSqGSIb3DQEBAQOB
|
||||
jAAwgYgCgYDKg6pAwCHUMA1DfHDmWhZfd+F0C+9Jxcqvpw9ii9En3E1uflpcol3+
|
||||
S9/6I/uaTmJHZre+DF3dTzb/UOZo0Zem8N+IzzkgoGkFafjXuT3BL5UPY2/H6H+p
|
||||
PqVIRLOmrWImai359YyoKhFyo37Y6HPeU8QcZ+u2rS9geapIWfeuowIDAQABoyUw
|
||||
IzAMBgNVHRMBAf8EAjAAMBMGA1UdJQQMMAoGCCsGAQUFBwMBMAsGCSqGSIb3DQEB
|
||||
BQOBgQAmkN6XxvDnoMkGcWLCTwzxGfNNSVcYr7TtL2aJh285Xw9zaxcm/SAZBFyG
|
||||
LYOChvh6hPU7joMdDwGfbiLrBnMag+BtGlmPLWwp/Kt1wNmrRhduyTQFhN3PP6fz
|
||||
nBr9vVny2FewB2gHmelaPS//tXdxivSXKz3NFqqXLDJjq7P8wA==
|
||||
-----END CERTIFICATE-----
|
||||
|
||||
EOF
|
||||
|
||||
cat >$KEYFILE<<EOF
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIICXQIBAAKBgQDKg6pAwCHUMA1DfHDmWhZfd+F0C+9Jxcqvpw9ii9En3E1uflpc
|
||||
ol3+S9/6I/uaTmJHZre+DF3dTzb/UOZo0Zem8N+IzzkgoGkFafjXuT3BL5UPY2/H
|
||||
6H+pPqVIRLOmrWImai359YyoKhFyo37Y6HPeU8QcZ+u2rS9geapIWfeuowIDAQAB
|
||||
AoGAAqDLzFRR/BF1kpsiUfL4WFvTarCe9duhwj7ORc6fs785qAXuwUYAJ0Uvzmy6
|
||||
HqoGv3t3RfmeHDmjcpPHsbOKnsOQn2MgmthidQlPBMWtQMff5zdoYNUFiPS0XQBq
|
||||
szNW4PRjaA9KkLQVTwnzdXGkBSkn/nGxkaVu7OR3vJOBoo0CQQDO4upypesnbe6p
|
||||
9/xqfZ2uim8IwV1fLlFClV7WlCaER8tsQF4lEi0XSzRdXGUD/dilpY88Nb+xok/X
|
||||
8Z8OvgAXAkEA+pcLsx1gN7kxnARxv54jdzQjC31uesJgMKQXjJ0h75aUZwTNHmZQ
|
||||
vPxi6u62YiObrN5oivkixwFNncT9MxTxVQJBAMaWUm2SjlLe10UX4Zdm1MEB6OsC
|
||||
kVoX37CGKO7YbtBzCfTzJGt5Mwc1DSLA2cYnGJqIfSFShptALlwedot0HikCQAJu
|
||||
jNKEKnbf+TdGY8Q0SKvTebOW2Aeg80YFkaTvsXCdyXrmdQcifw4WdO9KucJiDhSz
|
||||
Y9hVapz7ykEJtFtWjLECQQDIlfc63I5ZpXfg4/nN4IJXUW6AmPVOYIA5215itgki
|
||||
cSlMYli1H9MEXH0pQMGv5Qyd0OYIx2DDg96mZ+aFvqSG
|
||||
-----END RSA PRIVATE KEY-----
|
||||
|
||||
EOF
|
||||
|
||||
cat >$SLAPD_CONF <<EOF
|
||||
loglevel 0
|
||||
|
||||
include $LDAPDIR/ad.schema
|
||||
|
||||
pidfile $PIDDIR/slapd.pid
|
||||
argsfile $LDAPDIR/slapd.args
|
||||
sasl-realm $DNSNAME
|
||||
access to * by * write
|
||||
|
||||
allow update_anon
|
||||
|
||||
authz-regexp
|
||||
uid=([^,]*),cn=$DNSNAME,cn=digest-md5,cn=auth
|
||||
ldap:///$BASEDN??sub?(samAccountName=\$1)
|
||||
|
||||
authz-regexp
|
||||
uid=([^,]*),cn=([^,]*),cn=digest-md5,cn=auth
|
||||
ldap:///$BASEDN??sub?(samAccountName=\$1)
|
||||
|
||||
include $LDAPDIR/modules.conf
|
||||
|
||||
defaultsearchbase "$BASEDN"
|
||||
|
||||
backend bdb
|
||||
database bdb
|
||||
suffix "$BASEDN"
|
||||
rootdn "cn=Manager,$BASEDN"
|
||||
rootpw $PASSWORD
|
||||
directory $LDAPDIR/db
|
||||
index objectClass eq
|
||||
index samAccountName eq
|
||||
index name eq
|
||||
index objectSid eq
|
||||
index objectCategory eq
|
||||
index member eq
|
||||
index uidNumber eq
|
||||
index gidNumber eq
|
||||
index unixName eq
|
||||
index privilege eq
|
||||
index nCName eq pres
|
||||
index lDAPDisplayName eq
|
||||
index subClassOf eq
|
||||
index dnsRoot eq
|
||||
index nETBIOSName eq pres
|
||||
|
||||
overlay syncprov
|
||||
syncprov-checkpoint 100 10
|
||||
syncprov-sessionlog 100
|
||||
|
||||
EOF
|
||||
|
||||
cat > $LDAPDIR/db/DB_CONFIG <<EOF
|
||||
#
|
||||
# Set the database in memory cache size.
|
||||
#
|
||||
set_cachesize 0 524288 0
|
||||
|
||||
|
||||
#
|
||||
# Set database flags (this is a test environment, we don't need to fsync()).
|
||||
#
|
||||
set_flags DB_TXN_NOSYNC
|
||||
|
||||
#
|
||||
# Set log values.
|
||||
#
|
||||
set_lg_regionmax 104857
|
||||
set_lg_max 1048576
|
||||
set_lg_bsize 209715
|
||||
set_lg_dir $LDAPDIR/db/bdb-logs
|
||||
|
||||
|
||||
#
|
||||
# Set temporary file creation directory.
|
||||
#
|
||||
set_tmp_dir $LDAPDIR/db/tmp
|
||||
EOF
|
||||
|
||||
PROVISION_OPTIONS="$CONFIGURATION --host-name=$NETBIOSNAME --host-ip=127.0.0.1"
|
||||
PROVISION_OPTIONS="$PROVISION_OPTIONS --quiet --domain $DOMAIN --realm $REALM"
|
||||
PROVISION_OPTIONS="$PROVISION_OPTIONS --adminpass $PASSWORD --root=$ROOT"
|
||||
PROVISION_OPTIONS="$PROVISION_OPTIONS --simple-bind-dn=cn=Manager,$BASEDN --password=$PASSWORD --root=$ROOT"
|
||||
$srcdir/bin/smbscript $srcdir/setup/provision $PROVISION_OPTIONS
|
||||
|
||||
LDAPI="ldapi://$LDAPDIR/ldapi"
|
||||
LDAPI_ESCAPE="ldapi://"`echo $LDAPDIR/ldapi | sed 's|/|%2F|g'`
|
||||
export LDAPI
|
||||
export LDAPI_ESCAPE
|
||||
|
||||
#This uses the provision we just did, to read out the schema
|
||||
$srcdir/bin/ad2oLschema $CONFIGURATION -H $PRIVATEDIR/sam.ldb -I $srcdir/setup/schema-map-openldap-2.3 -O $LDAPDIR/ad.schema
|
||||
#Now create an LDAP baseDN
|
||||
$srcdir/bin/smbscript $srcdir/setup/provision $PROVISION_OPTIONS --ldap-base
|
||||
|
||||
OLDPATH=$PATH
|
||||
PATH=/usr/local/sbin:/usr/sbin:/sbin:$PATH
|
||||
export PATH
|
||||
|
||||
MODCONF=$LDAPDIR/modules.conf
|
||||
rm -f $MODCONF
|
||||
touch $MODCONF
|
||||
|
||||
slaptest -u -f $SLAPD_CONF > /dev/null 2>&1 || {
|
||||
echo "enabling slapd modules"
|
||||
cat > $MODCONF <<EOF
|
||||
modulepath /usr/lib/ldap
|
||||
moduleload back_bdb
|
||||
EOF
|
||||
}
|
||||
|
||||
if slaptest -u -f $SLAPD_CONF; then
|
||||
slapadd -f $SLAPD_CONF < $PRIVATEDIR/$DNSNAME.ldif || {
|
||||
echo "slapadd failed"
|
||||
}
|
||||
|
||||
slaptest -f $SLAPD_CONF || {
|
||||
echo "slaptest after database load failed"
|
||||
}
|
||||
fi
|
||||
|
||||
PATH=$OLDPATH
|
||||
export PATH
|
||||
|
||||
|
||||
cat >$PRIVATEDIR/wins_config.ldif<<EOF
|
||||
dn: name=TORTURE_6,CN=PARTNERS
|
||||
objectClass: wreplPartner
|
||||
name: TORTURE_6
|
||||
address: 127.0.0.6
|
||||
pullInterval: 0
|
||||
pushChangeCount: 0
|
||||
type: 0x3
|
||||
EOF
|
||||
|
||||
$srcdir/bin/ldbadd -H $PRIVATEDIR/wins_config.ldb < $PRIVATEDIR/wins_config.ldif >/dev/null || exit 1
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
SHARE_BACKEND="ldb"
|
||||
|
||||
. `dirname $0`/mktestsetup.sh
|
||||
Executable
+153
@@ -0,0 +1,153 @@
|
||||
#!/bin/sh
|
||||
# Bootstrap Samba and run a number of tests against it.
|
||||
|
||||
if [ $# -lt 1 ]
|
||||
then
|
||||
echo "$0 PREFIX TESTS"
|
||||
exit
|
||||
fi
|
||||
|
||||
ARG0=$0
|
||||
ARG1=$1
|
||||
ARG2=$2
|
||||
ARG3=$3
|
||||
|
||||
if [ -z "$TORTURE_MAXTIME" ]; then
|
||||
TORTURE_MAXTIME=1200
|
||||
fi
|
||||
|
||||
# disable rpc validation when using valgrind - its way too slow
|
||||
if [ -z "$VALGRIND" ]; then
|
||||
VALIDATE="validate";
|
||||
else
|
||||
VALIDATE="";
|
||||
fi
|
||||
|
||||
OLD_PWD=`pwd`
|
||||
PREFIX=$ARG1
|
||||
PREFIX=`echo $PREFIX | sed s+//+/+`
|
||||
export PREFIX
|
||||
|
||||
# allow selection of the test lists
|
||||
TESTS=$ARG2
|
||||
|
||||
if [ $TESTS = "all" ]; then
|
||||
TLS_ENABLED="yes"
|
||||
else
|
||||
TLS_ENABLED="no"
|
||||
fi
|
||||
export TLS_ENABLED
|
||||
|
||||
LD_LDB_MODULE_PATH=$OLD_PWD/bin/modules/ldb
|
||||
export LD_LDB_MODULE_PATH
|
||||
|
||||
LD_SAMBA_MODULE_PATH=$OLD_PWD/bin/modules
|
||||
export LD_SAMBA_MODULE_PATH
|
||||
|
||||
LD_LIBRARY_PATH=$OLD_PWD/bin/shared:$LD_LIBRARY_PATH
|
||||
export LD_LIBRARY_PATH
|
||||
|
||||
PKG_CONFIG_PATH=$OLD_PWD/bin/pkgconfig:$PKG_CONFIG_PATH
|
||||
export PKG_CONFIG_PATH
|
||||
|
||||
incdir=`dirname $ARG0`
|
||||
echo -n "PROVISIONING..."
|
||||
. $incdir/mktestsetup.sh $PREFIX || exit 1
|
||||
echo "DONE"
|
||||
|
||||
PATH=bin:$PATH
|
||||
export PATH
|
||||
|
||||
DO_SOCKET_WRAPPER=$ARG3
|
||||
if [ x"$DO_SOCKET_WRAPPER" = x"SOCKET_WRAPPER" ];then
|
||||
SOCKET_WRAPPER_DIR="$PREFIX/w"
|
||||
export SOCKET_WRAPPER_DIR
|
||||
echo "SOCKET_WRAPPER_DIR=$SOCKET_WRAPPER_DIR"
|
||||
else
|
||||
echo "NOT USING SOCKET_WRAPPER"
|
||||
fi
|
||||
|
||||
incdir=`dirname $ARG0`
|
||||
. $incdir/test_functions.sh
|
||||
|
||||
#Start slapd before smbd
|
||||
if [ x"$TEST_LDAP" = x"yes" ]; then
|
||||
slapd_start || exit 1;
|
||||
echo -n "LDAP PROVISIONING..."
|
||||
$srcdir/bin/smbscript $srcdir/setup/provision $PROVISION_OPTIONS --ldap-backend=$LDAPI || {
|
||||
echo "LDAP PROVISIONING failed: $srcdir/bin/smbscript $srcdir/setup/provision $PROVISION_OPTIONS --ldap-backend=$LDAPI"
|
||||
exit 1;
|
||||
}
|
||||
#LDAP is slow
|
||||
TORTURE_MAXTIME=`expr $TORTURE_MAXTIME '*' 2`
|
||||
fi
|
||||
|
||||
SMBD_TEST_FIFO="$PREFIX/smbd_test.fifo"
|
||||
export SMBD_TEST_FIFO
|
||||
SMBD_TEST_LOG="$PREFIX/smbd_test.log"
|
||||
export SMBD_TEST_LOG
|
||||
|
||||
SOCKET_WRAPPER_DEFAULT_IFACE=1
|
||||
export SOCKET_WRAPPER_DEFAULT_IFACE
|
||||
smbd_check_or_start
|
||||
|
||||
SOCKET_WRAPPER_DEFAULT_IFACE=6
|
||||
export SOCKET_WRAPPER_DEFAULT_IFACE
|
||||
TORTURE_INTERFACES='127.0.0.6/8,127.0.0.7/8,127.0.0.8/8,127.0.0.9/8,127.0.0.10/8,127.0.0.11/8'
|
||||
TORTURE_OPTIONS="--option=interfaces=$TORTURE_INTERFACES $CONFIGURATION"
|
||||
# ensure any one smbtorture call doesn't run too long
|
||||
TORTURE_OPTIONS="$TORTURE_OPTIONS --maximum-runtime=$TORTURE_MAXTIME"
|
||||
TORTURE_OPTIONS="$TORTURE_OPTIONS --target=samba4"
|
||||
export TORTURE_OPTIONS
|
||||
|
||||
if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then
|
||||
TORTURE_OPTIONS="$TORTURE_OPTIONS --option=torture:progress=no"
|
||||
fi
|
||||
|
||||
START=`date`
|
||||
(
|
||||
# give time for nbt server to register its names
|
||||
echo delaying for nbt name registration
|
||||
sleep 4
|
||||
# This will return quickly when things are up, but be slow if we need to wait for (eg) SSL init
|
||||
bin/nmblookup $CONFIGURATION $SERVER
|
||||
bin/nmblookup $CONFIGURATION -U $SERVER $SERVER
|
||||
bin/nmblookup $CONFIGURATION $SERVER
|
||||
bin/nmblookup $CONFIGURATION -U $SERVER $NETBIOSNAME
|
||||
bin/nmblookup $CONFIGURATION $NETBIOSNAME
|
||||
bin/nmblookup $CONFIGURATION -U $SERVER $NETBIOSNAME
|
||||
|
||||
# start off with 0 failures
|
||||
failed=0
|
||||
export failed
|
||||
totalfailed=0
|
||||
export totalfailed
|
||||
|
||||
. script/tests/tests_$TESTS.sh
|
||||
exit $totalfailed
|
||||
) 9>$SMBD_TEST_FIFO
|
||||
failed=$?
|
||||
|
||||
kill `cat $PIDDIR/smbd.pid`
|
||||
|
||||
if [ "$TEST_LDAP"x = "yesx" ]; then
|
||||
kill `cat $PIDDIR/slapd.pid`
|
||||
fi
|
||||
|
||||
END=`date`
|
||||
echo "START: $START ($ARG0)";
|
||||
echo "END: $END ($ARG0)";
|
||||
|
||||
# if there were any valgrind failures, show them
|
||||
count=`find $PREFIX -name 'valgrind.log*' | wc -l`
|
||||
if [ "$count" != 0 ]; then
|
||||
for f in $PREFIX/valgrind.log*; do
|
||||
if [ -s $f ] && grep -v DWARF2.CFI.reader $f > /dev/null; then
|
||||
echo "VALGRIND FAILURE";
|
||||
failed=`expr $failed + 1`
|
||||
cat $f
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
teststatus $ARG0 $failed
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ $# -lt 4 ]; then
|
||||
cat <<EOF
|
||||
Usage: test_binding_string.sh SERVER USERNAME PASSWORD DOMAIN
|
||||
EOF
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
server="$1"
|
||||
username="$2"
|
||||
password="$3"
|
||||
domain="$4"
|
||||
shift 4
|
||||
|
||||
incdir=`dirname $0`
|
||||
. $incdir/test_functions.sh
|
||||
|
||||
failed=0;
|
||||
for I in "ncacn_np:$server" \
|
||||
"ncacn_ip_tcp:$server" \
|
||||
"ncacn_np:$server[rpcecho]" \
|
||||
"ncacn_np:$server[/pipe/rpcecho]" \
|
||||
"ncacn_np:$server[/pipe/rpcecho,sign,seal]" \
|
||||
"ncacn_np:$server[,sign]" \
|
||||
"ncacn_ip_tcp:$server[,sign]" \
|
||||
"ncalrpc:" \
|
||||
"308FB580-1EB2-11CA-923B-08002B1075A7@ncacn_np:$server" \
|
||||
"308FB580-1EB2-11CA-923B-08002B1075A7@ncacn_ip_tcp:$server"
|
||||
do
|
||||
testit "$I" bin/smbtorture $TORTURE_OPTIONS "$I" -U"$username"%"$password" -W $domain --option=torture:quick=yes RPC-ECHO "$*" || failed=`expr $failed + 1`
|
||||
done
|
||||
|
||||
testok $0 $failed
|
||||
Executable
+79
@@ -0,0 +1,79 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Basic script to make sure that cifsdd can do both local and remote I/O.
|
||||
|
||||
if [ $# -lt 4 ]; then
|
||||
cat <<EOF
|
||||
Usage: test_cifsdd.sh SERVER USERNAME PASSWORD DOMAIN
|
||||
EOF
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
SERVER=$1
|
||||
USERNAME=$2
|
||||
PASSWORD=$3
|
||||
DOMAIN=$4
|
||||
|
||||
DD=bin/cifsdd
|
||||
|
||||
SHARE=tmp
|
||||
DEBUGLEVEL=1
|
||||
|
||||
failed=0
|
||||
|
||||
failtest() {
|
||||
failed=`expr $failed + 1`
|
||||
}
|
||||
|
||||
runcopy() {
|
||||
message="$1"
|
||||
shift
|
||||
|
||||
testit "$message" $VALGRIND $DD $CONFIGURATION --debuglevel=$DEBUGLEVEL -W "$DOMAIN" -U "$USERNAME"%"$PASSWORD" \
|
||||
"$@"
|
||||
}
|
||||
|
||||
compare() {
|
||||
cmp "$1" "$2"
|
||||
}
|
||||
|
||||
incdir=`dirname $0`
|
||||
. $incdir/test_functions.sh
|
||||
|
||||
sourcepath=tempfile.src.$$
|
||||
destpath=tempfile.dst.$$
|
||||
|
||||
# Create a source file with arbitrary contents
|
||||
dd if=$DD of=$sourcepath bs=1024 count=50 > /dev/null
|
||||
|
||||
ls -l $sourcepath
|
||||
|
||||
for bs in 512 4k 48k ; do
|
||||
|
||||
echo "Testing $bs block size ..."
|
||||
|
||||
# Check whether we can do local IO
|
||||
runcopy "Testing local -> local copy" if=$sourcepath of=$destpath bs=$bs || failtest
|
||||
compare $sourcepath $destpath || failtest
|
||||
|
||||
# Check whether we can do a round trip
|
||||
runcopy "Testing local -> remote copy" \
|
||||
if=$sourcepath of=//$SERVER/$SHARE/$sourcepath bs=$bs || failtest
|
||||
runcopy "Testing remote -> local copy" \
|
||||
if=//$SERVER/$SHARE/$sourcepath of=$destpath bs=$bs || failtest
|
||||
compare $sourcepath $destpath || failtest
|
||||
|
||||
# Check that copying within the remote server works
|
||||
runcopy "Testing local -> remote copy" \
|
||||
if=//$SERVER/$SHARE/$sourcepath of=//$SERVER/$SHARE/$sourcepath bs=$bs || failtest
|
||||
runcopy "Testing remote -> remote copy" \
|
||||
if=//$SERVER/$SHARE/$sourcepath of=//$SERVER/$SHARE/$destpath bs=$bs || failtest
|
||||
runcopy "Testing remote -> local copy" \
|
||||
if=//$SERVER/$SHARE/$destpath of=$destpath bs=$bs || failtest
|
||||
compare $sourcepath $destpath || failtest
|
||||
|
||||
done
|
||||
|
||||
rm -f $sourcepath $destpath
|
||||
|
||||
testok $0 $failed
|
||||
Executable
+60
@@ -0,0 +1,60 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ $# -lt 4 ]; then
|
||||
cat <<EOF
|
||||
Usage: test_echo.sh SERVER USERNAME PASSWORD DOMAIN
|
||||
EOF
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
server="$1"
|
||||
username="$2"
|
||||
password="$3"
|
||||
domain="$4"
|
||||
shift 4
|
||||
|
||||
incdir=`dirname $0`
|
||||
. $incdir/test_functions.sh
|
||||
|
||||
transports="ncacn_np ncacn_ip_tcp"
|
||||
if [ $server = "localhost" ]; then
|
||||
transports="ncalrpc $transports"
|
||||
fi
|
||||
if [ $server = "localtest" ]; then
|
||||
transports="ncalrpc $transports"
|
||||
fi
|
||||
|
||||
failed=0
|
||||
for transport in $transports; do
|
||||
for bindoptions in connect spnego spnego,sign spnego,seal $VALIDATE padcheck bigendian bigendian,seal; do
|
||||
for ntlmoptions in \
|
||||
"--option=socket:testnonblock=True --option=torture:quick=yes"; do
|
||||
name="RPC-ECHO on $transport with $bindoptions and $ntlmoptions"
|
||||
testit "$name" bin/smbtorture $TORTURE_OPTIONS $transport:"$server[$bindoptions]" $ntlmoptions -U"$username"%"$password" -W $domain RPC-ECHO "$*" || failed=`expr $failed + 1`
|
||||
done
|
||||
done
|
||||
done
|
||||
|
||||
for transport in $transports; do
|
||||
for bindoptions in sign seal; do
|
||||
for ntlmoptions in \
|
||||
"--option=ntlmssp_client:ntlm2=yes --option=torture:quick=yes" \
|
||||
"--option=ntlmssp_client:ntlm2=no --option=torture:quick=yes" \
|
||||
"--option=ntlmssp_client:ntlm2=yes --option=ntlmssp_client:128bit=no --option=torture:quick=yes" \
|
||||
"--option=ntlmssp_client:ntlm2=no --option=ntlmssp_client:128bit=no --option=torture:quick=yes" \
|
||||
"--option=ntlmssp_client:ntlm2=yes --option=ntlmssp_client:keyexchange=no --option=torture:quick=yes" \
|
||||
"--option=ntlmssp_client:ntlm2=no --option=ntlmssp_client:keyexchange=no --option=torture:quick=yes" \
|
||||
"--option=clientntlmv2auth=yes --option=ntlmssp_client:keyexchange=no --option=torture:quick=yes" \
|
||||
"--option=clientntlmv2auth=yes --option=ntlmssp_client:128bit=no --option=ntlmssp_client:keyexchange=yes --option=torture:quick=yes" \
|
||||
"--option=clientntlmv2auth=yes --option=ntlmssp_client:128bit=no --option=ntlmssp_client:keyexchange=no --option=torture:quick=yes" \
|
||||
; do
|
||||
name="RPC-ECHO on $transport with $bindoptions and $ntlmoptions"
|
||||
testit "$name" bin/smbtorture $TORTURE_OPTIONS $transport:"$server[$bindoptions]" $ntlmoptions -U"$username"%"$password" -W $domain RPC-ECHO "$*" || failed=`expr $failed + 1`
|
||||
done
|
||||
done
|
||||
done
|
||||
|
||||
name="RPC-ECHO on ncacn_np over smb2"
|
||||
testit "$name" bin/smbtorture $TORTURE_OPTIONS ncacn_np:"$server[smb2]" -U"$username"%"$password" -W $domain RPC-ECHO "$*" || failed=`expr $failed + 1`
|
||||
|
||||
testok $0 $failed
|
||||
Executable
+38
@@ -0,0 +1,38 @@
|
||||
#!/bin/sh
|
||||
# test some simple EJS operations
|
||||
|
||||
if [ $# -lt 3 ]; then
|
||||
cat <<EOF
|
||||
Usage: test_ejs.sh DOMAIN USERNAME PASSWORD
|
||||
EOF
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
DOMAIN="$1"
|
||||
USERNAME="$2"
|
||||
PASSWORD="$3"
|
||||
|
||||
incdir=`dirname $0`
|
||||
. $incdir/test_functions.sh
|
||||
|
||||
SCRIPTDIR=../testprogs/ejs
|
||||
DATADIR=../testdata
|
||||
|
||||
PATH=bin:$PATH
|
||||
export PATH
|
||||
|
||||
testit "base.js" $SCRIPTDIR/base.js $CONFIGURATION || failed=`expr $failed + 1`
|
||||
|
||||
for f in samr.js echo.js; do
|
||||
testit "$f" $SCRIPTDIR/$f $CONFIGURATION ncalrpc: -U$USERNAME%$PASSWORD || failed=`expr $failed + 1`
|
||||
done
|
||||
|
||||
testit "ejsnet.js" $SCRIPTDIR/ejsnet.js $CONFIGURATION -U$USERNAME%$PASSWORD $DOMAIN ejstestuser || failed=`expr $failed + 1`
|
||||
|
||||
testit "ldb.js" $SCRIPTDIR/ldb.js `pwd` $CONFIGURATION || failed=`expr $failed + 1`
|
||||
|
||||
testit "samba3sam.js" $SCRIPTDIR/samba3sam.js $CONFIGURATION `pwd` $DATADIR/samba3/ || failed=`expr $failed + 1`
|
||||
|
||||
testit "winreg" scripting/bin/winreg $CONFIGURATION ncalrpc: 'HKLM' -U$USERNAME%$PASSWORD || failed=`expr $failed + 1`
|
||||
|
||||
testok $0 $failed
|
||||
Executable
+215
@@ -0,0 +1,215 @@
|
||||
#!/bin/sh
|
||||
smbd_check_or_start() {
|
||||
if [ -n "$SMBD_TEST_FIFO" ];then
|
||||
if [ -p "$SMBD_TEST_FIFO" ];then
|
||||
return 0;
|
||||
fi
|
||||
|
||||
if [ -n "$SOCKET_WRAPPER_DIR" ];then
|
||||
if [ -d "$SOCKET_WRAPPER_DIR" ]; then
|
||||
rm -f $SOCKET_WRAPPER_DIR/*
|
||||
else
|
||||
mkdir -p $SOCKET_WRAPPER_DIR
|
||||
fi
|
||||
fi
|
||||
|
||||
rm -f $SMBD_TEST_FIFO
|
||||
mkfifo $SMBD_TEST_FIFO
|
||||
|
||||
rm -f $SMBD_TEST_LOG
|
||||
|
||||
echo -n "STARTING SMBD..."
|
||||
((
|
||||
if [ -z "$SMBD_MAXTIME" ]; then
|
||||
SMBD_MAXTIME=5400
|
||||
fi
|
||||
$SMBD_VALGRIND $SRCDIR/bin/smbd --maximum-runtime=$SMBD_MAXTIME -s $CONFFILE -M single -i --leak-report-full < $SMBD_TEST_FIFO > $SMBD_TEST_LOG 2>&1;
|
||||
ret=$?;
|
||||
rm -f $SMBD_TEST_FIFO;
|
||||
if [ -n "$SOCKET_WRAPPER_DIR" -a -d "$SOCKET_WRAPPER_DIR" ]; then
|
||||
rm -f $SOCKET_WRAPPER_DIR/*
|
||||
fi
|
||||
if [ x"$ret" = x"0" ];then
|
||||
echo "smbd exits with status $ret";
|
||||
echo "smbd exits with status $ret" >>$SMBD_TEST_LOG;
|
||||
elif [ x"$ret" = x"137" ];then
|
||||
echo "smbd got SIGXCPU and exits with status $ret!"
|
||||
echo "smbd got SIGXCPU and exits with status $ret!">>$SMBD_TEST_LOG;
|
||||
else
|
||||
echo "smbd failed with status $ret!"
|
||||
echo "smbd failed with status $ret!">>$SMBD_TEST_LOG;
|
||||
fi
|
||||
exit $ret;
|
||||
) || exit $? &) 2>/dev/null || exit $?
|
||||
echo "DONE"
|
||||
fi
|
||||
return 0;
|
||||
}
|
||||
|
||||
smbd_check_only() {
|
||||
if [ -n "$SMBD_TEST_FIFO" ];then
|
||||
if [ -p "$SMBD_TEST_FIFO" ];then
|
||||
return 0;
|
||||
fi
|
||||
return 1;
|
||||
fi
|
||||
return 0;
|
||||
}
|
||||
|
||||
smbd_have_test_log() {
|
||||
if [ -n "$SMBD_TEST_LOG" ];then
|
||||
if [ -r "$SMBD_TEST_LOG" ];then
|
||||
return 0;
|
||||
fi
|
||||
fi
|
||||
return 1;
|
||||
}
|
||||
|
||||
slapd_start() {
|
||||
OLDPATH=$PATH
|
||||
PATH=/usr/local/sbin:/usr/sbin:/sbin:$PATH
|
||||
export PATH
|
||||
# running slapd in the background means it stays in the same process group, so it can be
|
||||
# killed by timelimit
|
||||
slapd -d0 -f $SLAPD_CONF -h $LDAPI_ESCAPE &
|
||||
PATH=$OLDPATH
|
||||
export PATH
|
||||
return $?;
|
||||
}
|
||||
|
||||
testit() {
|
||||
if [ -z "$PREFIX" ]; then
|
||||
PREFIX=test_prefix
|
||||
mkdir -p $PREFIX
|
||||
fi
|
||||
name=$1
|
||||
shift 1
|
||||
cmdline="$*"
|
||||
|
||||
SMBD_IS_UP="no"
|
||||
|
||||
shname=`echo $name | \
|
||||
sed -e 's%[^abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\-]%_%g'`
|
||||
|
||||
UNIQUE_PID=`/bin/sh -c 'echo $$'`
|
||||
TEST_LOG="$PREFIX/test_log.${UNIQUE_PID}"
|
||||
TEST_PCAP="$PREFIX/test_${shname}_${UNIQUE_PID}.pcap"
|
||||
trap "rm -f $TEST_LOG $TEST_PCAP" EXIT
|
||||
|
||||
if [ -n "$SMBD_TEST_LOG" -a -z "$smbd_log_size" ]; then
|
||||
smbd_log_size=`wc -l < $SMBD_TEST_LOG`;
|
||||
fi
|
||||
|
||||
if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then
|
||||
echo "--==--==--==--==--==--==--==--==--==--==--"
|
||||
echo "Running test $name (level 0 stdout)"
|
||||
echo "--==--==--==--==--==--==--==--==--==--==--"
|
||||
date
|
||||
echo "Testing $name"
|
||||
else
|
||||
nf="`expr $failed + $totalfailed`";
|
||||
if [ "$nf" = "0" ]; then
|
||||
echo "Testing $name"
|
||||
else
|
||||
echo "Testing $name ($nf tests failed so far)"
|
||||
fi
|
||||
fi
|
||||
|
||||
smbd_check_only && SMBD_IS_UP="yes"
|
||||
if [ x"$SMBD_IS_UP" != x"yes" ];then
|
||||
if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then
|
||||
echo "SMBD is down! Skipping: $cmdline"
|
||||
echo "=========================================="
|
||||
echo "TEST SKIPPED: $name (reason SMBD is down)"
|
||||
echo "=========================================="
|
||||
else
|
||||
echo "TEST SKIPPED: $name (reason SMBD is down)"
|
||||
fi
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ x"$MAKE_TEST_ENABLE_PCAP" = x"yes" ];then
|
||||
SOCKET_WRAPPER_PCAP_FILE=$TEST_PCAP
|
||||
export SOCKET_WRAPPER_PCAP_FILE
|
||||
fi
|
||||
|
||||
( $cmdline > $TEST_LOG 2>&1 )
|
||||
status=$?
|
||||
# show any additional output from smbd that has happened in this test
|
||||
smbd_have_test_log && {
|
||||
new_log_size=`wc -l < $SMBD_TEST_LOG`;
|
||||
test "$new_log_size" = "$smbd_log_size" || {
|
||||
echo "SMBD OUTPUT:";
|
||||
incr_log_size=`expr $new_log_size - $smbd_log_size`;
|
||||
tail -$incr_log_size $SMBD_TEST_LOG;
|
||||
smbd_log_size=$new_log_size;
|
||||
}
|
||||
}
|
||||
if [ x"$status" != x"0" ]; then
|
||||
echo "TEST OUTPUT:"
|
||||
cat $TEST_LOG;
|
||||
rm -f $TEST_LOG;
|
||||
if [ x"$MAKE_TEST_ENABLE_PCAP" = x"yes" ];then
|
||||
echo "TEST PCAP: $TEST_PCAP"
|
||||
fi
|
||||
if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then
|
||||
echo "=========================================="
|
||||
echo "TEST FAILED: $name (status $status)"
|
||||
echo "=========================================="
|
||||
else
|
||||
echo "TEST FAILED: $cmdline (status $status)"
|
||||
fi
|
||||
trap "" EXIT
|
||||
return 1;
|
||||
fi
|
||||
rm -f $TEST_LOG;
|
||||
if [ x"$MAKE_TEST_KEEP_PCAP" = x"yes" ];then
|
||||
echo "TEST PCAP: $TEST_PCAP"
|
||||
else
|
||||
rm -f $TEST_PCAP;
|
||||
fi
|
||||
if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then
|
||||
echo "ALL OK: $cmdline"
|
||||
echo "=========================================="
|
||||
echo "TEST PASSED: $name"
|
||||
echo "=========================================="
|
||||
fi
|
||||
trap "" EXIT
|
||||
return 0;
|
||||
}
|
||||
|
||||
testok() {
|
||||
name=`basename $1`
|
||||
failed=$2
|
||||
|
||||
if [ x"$failed" = x"0" ];then
|
||||
:
|
||||
else
|
||||
echo "$failed TESTS FAILED or SKIPPED ($name)";
|
||||
fi
|
||||
exit $failed
|
||||
}
|
||||
|
||||
teststatus() {
|
||||
name=`basename $1`
|
||||
failed=$2
|
||||
|
||||
echo "TEST STATUS: $failed failures";
|
||||
test x"$failed" = x"0" || {
|
||||
cat <<EOF
|
||||
************************
|
||||
*** TESTSUITE FAILED ***
|
||||
************************
|
||||
EOF
|
||||
}
|
||||
exit $failed
|
||||
}
|
||||
|
||||
if [ -z "$VALGRIND" ]; then
|
||||
MALLOC_CHECK_=2
|
||||
export MALLOC_CHECK_
|
||||
fi
|
||||
|
||||
# initialise the local failed variable to zero when starting each of the tests
|
||||
failed=0
|
||||
|
||||
Executable
+99
@@ -0,0 +1,99 @@
|
||||
#!/bin/sh
|
||||
# test some simple LDAP and CLDAP operations
|
||||
|
||||
if [ $# -lt 3 ]; then
|
||||
cat <<EOF
|
||||
Usage: test_ldap.sh SERVER USERNAME PASSWORD
|
||||
EOF
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
# see if we support ldaps
|
||||
if grep HAVE_LIBGNUTLS.1 include/config.h > /dev/null &&
|
||||
test -n "$CONFFILE" && grep tls.enabled.=yes $CONFFILE > /dev/null; then
|
||||
PROTOCOLS="ldap ldaps"
|
||||
else
|
||||
PROTOCOLS="ldap"
|
||||
fi
|
||||
|
||||
SERVER="$1"
|
||||
USERNAME="$2"
|
||||
PASSWORD="$3"
|
||||
|
||||
incdir=`dirname $0`
|
||||
. $incdir/test_functions.sh
|
||||
|
||||
for p in $PROTOCOLS; do
|
||||
for options in "" "--option=socket:testnonblock=true" "-U$USERNAME%$PASSWORD --option=socket:testnonblock=true" "-U$USERNAME%$PASSWORD"; do
|
||||
echo "TESTING PROTOCOL $p with options $options"
|
||||
|
||||
testit "RootDSE" bin/ldbsearch $CONFIGURATION $options --basedn='' -H $p://$SERVER -s base DUMMY=x dnsHostName highestCommittedUSN || failed=`expr $failed + 1`
|
||||
|
||||
echo "Getting defaultNamingContext"
|
||||
BASEDN=`bin/ldbsearch $CONFIGURATION $options --basedn='' -H $p://$SERVER -s base DUMMY=x defaultNamingContext | grep defaultNamingContext | awk '{print $2}'`
|
||||
echo "BASEDN is $BASEDN"
|
||||
|
||||
testit "Listing Users" bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER '(objectclass=user)' sAMAccountName || failed=`expr $failed + 1`
|
||||
|
||||
testit "Listing Groups" bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER '(objectclass=group)' sAMAccountName || failed=`expr $failed + 1`
|
||||
|
||||
nentries=`bin/ldbsearch $options -H $p://$SERVER $CONFIGURATION '(|(|(&(!(groupType:1.2.840.113556.1.4.803:=1))(groupType:1.2.840.113556.1.4.803:=2147483648)(groupType:1.2.840.113556.1.4.804:=10))(samAccountType=805306368))(samAccountType=805306369))' sAMAccountName | grep sAMAccountName | wc -l`
|
||||
echo "Found $nentries entries"
|
||||
if [ $nentries -lt 10 ]; then
|
||||
echo "Should have found at least 10 entries"
|
||||
failed=`expr $failed + 1`
|
||||
fi
|
||||
|
||||
echo "Check rootDSE for Controls"
|
||||
nentries=`bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER -s base -b "" '(objectclass=*)' | grep -i supportedControl | wc -l`
|
||||
if [ $nentries -lt 4 ]; then
|
||||
echo "Should have found at least 4 entries"
|
||||
failed=`expr $failed + 1`
|
||||
fi
|
||||
|
||||
echo "Test Paged Results Control"
|
||||
nentries=`bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=paged_results:1:5 '(objectclass=user)' | grep sAMAccountName | wc -l`
|
||||
if [ $nentries -lt 1 ]; then
|
||||
echo "Paged Results Control test returned 0 items"
|
||||
failed=`expr $failed + 1`
|
||||
fi
|
||||
|
||||
echo "Test Server Sort Control"
|
||||
nentries=`bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=server_sort:1:0:sAMAccountName '(objectclass=user)' | grep sAMAccountName | wc -l`
|
||||
if [ $nentries -lt 1 ]; then
|
||||
echo "Server Sort Control test returned 0 items"
|
||||
failed=`expr $failed + 1`
|
||||
fi
|
||||
|
||||
echo "Test Extended DN Control"
|
||||
nentries=`bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=extended_dn:1:0 '(objectclass=user)' | grep sAMAccountName | wc -l`
|
||||
if [ $nentries -lt 1 ]; then
|
||||
echo "Extended DN Control test returned 0 items"
|
||||
failed=`expr $failed + 1`
|
||||
fi
|
||||
|
||||
echo "Test Attribute Scope Query Control"
|
||||
nentries=`bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=asq:1:member -s base -b "CN=Administrators,CN=Builtin,$BASEDN" | grep sAMAccountName | wc -l`
|
||||
if [ $nentries -lt 1 ]; then
|
||||
echo "Attribute Scope Query test returned 0 items"
|
||||
failed=`expr $failed + 1`
|
||||
fi
|
||||
|
||||
done
|
||||
done
|
||||
|
||||
testit "CLDAP" bin/smbtorture $TORTURE_OPTIONS //$SERVER/_none_ LDAP-CLDAP || failed=`expr $failed + 1`
|
||||
|
||||
# only do the ldb tests when not in quick mode - they are quite slow, and ldb
|
||||
# is now pretty well tested by the rest of the quick tests anyway
|
||||
test "$TORTURE_QUICK" = "yes" || {
|
||||
LDBDIR=lib/ldb
|
||||
export LDBDIR
|
||||
testit "ldb tests" $LDBDIR/tests/test-tdb.sh || failed=`expr $failed + 1`
|
||||
}
|
||||
|
||||
SCRIPTDIR=../testprogs/ejs
|
||||
|
||||
testit "ejs ldap test" $SCRIPTDIR/ldap.js $CONFIGURATION $SERVER -U$USERNAME%$PASSWORD || failed=`expr $failed + 1`
|
||||
|
||||
testok $0 $failed
|
||||
Executable
+39
@@ -0,0 +1,39 @@
|
||||
#!/bin/sh
|
||||
|
||||
local_tests="LOCAL-REPLACE LOCAL-TALLOC LOCAL-STRLIST"
|
||||
local_tests="$local_tests LOCAL-IDTREE LOCAL-EVENT"
|
||||
local_tests="$local_tests LOCAL-SOCKET LOCAL-MESSAGING LOCAL-IRPC"
|
||||
local_tests="$local_tests LOCAL-NDR LOCAL-BINDING LOCAL-FILE LOCAL-REGISTRY"
|
||||
local_tests="$local_tests LOCAL-SDDL LOCAL-PAC LOCAL-DBSPEED"
|
||||
local_tests="$local_tests LOCAL-NTLMSSP LOCAL-CRYPTO-MD4"
|
||||
local_tests="$local_tests LOCAL-CRYPTO-MD5 LOCAL-CRYPTO-HMACMD5"
|
||||
local_tests="$local_tests LOCAL-CRYPTO-SHA1 LOCAL-CRYPTO-HMACSHA1"
|
||||
local_tests="$local_tests LOCAL-RESOLVE LOCAL-TORTURE"
|
||||
|
||||
if [ `uname` = "Linux" ]; then
|
||||
# testing against the system iconv only makes sense for our 'reference' iconv
|
||||
# behaviour
|
||||
local_tests="$local_tests LOCAL-ICONV"
|
||||
fi
|
||||
|
||||
if [ $# -lt 0 ]; then
|
||||
cat <<EOF
|
||||
Usage: test_local.sh
|
||||
EOF
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
incdir=`dirname $0`
|
||||
. $incdir/test_functions.sh
|
||||
|
||||
# the local tests doesn't need smbd
|
||||
SMBD_TEST_FIFO=""
|
||||
export SMBD_TEST_FIFO
|
||||
|
||||
failed=0
|
||||
for t in $local_tests; do
|
||||
name="$t"
|
||||
testit "$name" $VALGRIND bin/smbtorture $TORTURE_OPTIONS ncalrpc: $t "$*" || failed=`expr $failed + 1`
|
||||
done
|
||||
|
||||
testok $0 $failed
|
||||
Executable
+35
@@ -0,0 +1,35 @@
|
||||
#!/bin/sh
|
||||
# test some NBT/WINS operations
|
||||
|
||||
if [ $# -lt 1 ]; then
|
||||
cat <<EOF
|
||||
Usage: test_nbt.sh SERVER
|
||||
EOF
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
SERVER="$1"
|
||||
|
||||
incdir=`dirname $0`
|
||||
. $incdir/test_functions.sh
|
||||
|
||||
SCRIPTDIR=../testprogs/ejs
|
||||
|
||||
PATH=bin:$PATH
|
||||
export PATH
|
||||
|
||||
testit "nmblookup -U $SERVER $SERVER" bin/nmblookup $TORTURE_OPTIONS -U $SERVER $SERVER || failed=`expr $failed + 1`
|
||||
testit "nmblookup $SERVER" bin/nmblookup $TORTURE_OPTIONS $SERVER || failed=`expr $failed + 1`
|
||||
|
||||
NBT_TESTS="NBT-REGISTER NBT-WINS"
|
||||
NBT_TESTS="$NBT_TESTS NBT-WINSREPLICATION"
|
||||
# if [ "$TORTURE_QUICK"x != "yes"x ]; then
|
||||
# NBT_TESTS="$NBT_TESTS NBT-WINSREPLICATION-OWNED"
|
||||
# fi
|
||||
NBT_TESTS="$NBT_TESTS NET-API-LOOKUP NET-API-LOOKUPHOST NET-API-LOOKUPPDC"
|
||||
|
||||
for f in $NBT_TESTS; do
|
||||
testit "$f" bin/smbtorture $TORTURE_OPTIONS //$SERVER/_none_ $f || failed=`expr $failed + 1`
|
||||
done
|
||||
|
||||
testok $0 $failed
|
||||
Executable
+40
@@ -0,0 +1,40 @@
|
||||
#!/bin/sh
|
||||
|
||||
# add tests to this list as they start passing, so we test
|
||||
# that they stay passing
|
||||
ncacn_np_tests="NET-API-LOOKUP NET-API-LOOKUPHOST NET-API-LOOKUPPDC NET-API-RPCCONN-BIND NET-API-RPCCONN-SRV NET-API-RPCCONN-DC NET-API-RPCCONN-DCINFO NET-API-LISTSHARES NET-API-CREATEUSER NET-API-DELETEUSER"
|
||||
ncalrpc_tests="NET-API-RPCCONN-SRV NET-API-RPCCONN-DC NET-API-RPCCONN-DCINFO NET-API-LISTSHARES NET-API-CREATEUSER NET-API-DELETEUSER"
|
||||
ncacn_ip_tcp_tests="NET-API-LOOKUP NET-API-LOOKUPHOST NET-API-LOOKUPPDC NET-API-RPCCONN-SRV NET-API-RPCCONN-DC NET-API-RPCCONN-DCINFO NET-API-LISTSHARES NET-API-CREATEUSER NET-API-DELETEUSER"
|
||||
|
||||
if [ $# -lt 4 ]; then
|
||||
cat <<EOF
|
||||
Usage: test_net.sh SERVER USERNAME PASSWORD DOMAIN
|
||||
EOF
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
server="$1"
|
||||
username="$2"
|
||||
password="$3"
|
||||
domain="$4"
|
||||
shift 4
|
||||
|
||||
incdir=`dirname $0`
|
||||
. $incdir/test_functions.sh
|
||||
|
||||
failed=0
|
||||
for bindoptions in seal,padcheck $VALIDATE bigendian; do
|
||||
for transport in ncalrpc ncacn_np ncacn_ip_tcp; do
|
||||
case $transport in
|
||||
ncalrpc) tests=$ncalrpc_tests ;;
|
||||
ncacn_np) tests=$ncacn_np_tests ;;
|
||||
ncacn_ip_tcp) tests=$ncacn_ip_tcp_tests ;;
|
||||
esac
|
||||
for t in $tests; do
|
||||
name="$t on $transport with $bindoptions"
|
||||
testit "$name" $VALGRIND bin/smbtorture $TORTURE_OPTIONS $transport:"$server[$bindoptions]" -U"$username"%"$password" -W $domain $t "$*" || failed=`expr $failed + 1`
|
||||
done
|
||||
done
|
||||
done
|
||||
|
||||
testok $0 $failed
|
||||
Executable
+20
@@ -0,0 +1,20 @@
|
||||
#!/bin/sh
|
||||
if [ ! -n "$PERL" ]
|
||||
then
|
||||
PERL=perl
|
||||
fi
|
||||
|
||||
incdir=`dirname $0`
|
||||
. $incdir/test_functions.sh
|
||||
|
||||
failed=0
|
||||
|
||||
if $PERL -e 'eval require Test::More;' > /dev/null 2>&1; then
|
||||
for f in pidl/tests/*.pl; do
|
||||
testit "$f" $PERL $f || failed=`expr $failed + 1`
|
||||
done
|
||||
else
|
||||
echo "Skipping pidl tests - Test::More not installed"
|
||||
fi
|
||||
|
||||
testok $0 $failed
|
||||
Executable
+77
@@ -0,0 +1,77 @@
|
||||
#!/bin/sh
|
||||
|
||||
# this runs the file serving tests that are expected to pass with the
|
||||
# current posix ntvfs backend
|
||||
|
||||
if [ $# -lt 3 ]; then
|
||||
cat <<EOF
|
||||
Usage: test_posix.sh UNC USERNAME PASSWORD <first> <smbtorture args>
|
||||
EOF
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
unc="$1"
|
||||
username="$2"
|
||||
password="$3"
|
||||
start="$4"
|
||||
shift 4
|
||||
ADDARGS="$*"
|
||||
|
||||
incdir=`dirname $0`
|
||||
. $incdir/test_functions.sh
|
||||
|
||||
#
|
||||
# please don't remove tests here, when you want them to be skipped!
|
||||
# just add them to the skipped line below
|
||||
# this should be the complete list smbtorture offers as BASE-* tests
|
||||
#
|
||||
base="BASE-ATTR BASE-CHARSET BASE-CHKPATH BASE-DEFER_OPEN BASE-DELAYWRITE BASE-DELETE"
|
||||
base="$base BASE-DENY1 BASE-DENY2 BASE-DENY3 BASE-DENYDOS BASE-DIR1 BASE-DIR2"
|
||||
base="$base BASE-DISCONNECT BASE-FDPASS BASE-LOCK "
|
||||
base="$base BASE-MANGLE BASE-NEGNOWAIT BASE-NTDENY1"
|
||||
base="$base BASE-NTDENY2 BASE-OPEN BASE-OPENATTR BASE-PROPERTIES BASE-RENAME BASE-RW1"
|
||||
base="$base BASE-SECLEAK BASE-TCON BASE-TCONDEV BASE-TRANS2 BASE-UNLINK BASE-VUID"
|
||||
base="$base BASE-XCOPY"
|
||||
|
||||
#
|
||||
# please don't remove tests here, when you want them to be skipped!
|
||||
# just add them to the skipped line below
|
||||
# this should be the complete list smbtorture offers as RAW-* tests
|
||||
#
|
||||
raw="RAW-CHKPATH RAW-CLOSE RAW-COMPOSITE RAW-CONTEXT RAW-EAS"
|
||||
raw="$raw RAW-IOCTL RAW-LOCK RAW-MKDIR RAW-MUX RAW-NOTIFY RAW-OPEN RAW-OPLOCK"
|
||||
raw="$raw RAW-QFILEINFO RAW-QFSINFO RAW-READ RAW-RENAME RAW-SEARCH RAW-SEEK"
|
||||
raw="$raw RAW-SFILEINFO RAW-SFILEINFO-BUG RAW-STREAMS RAW-UNLINK RAW-WRITE"
|
||||
|
||||
smb2="SMB2-CONNECT SMB2-GETINFO SMB2-SETINFO SMB2-FIND"
|
||||
|
||||
tests="$base $raw $smb2"
|
||||
|
||||
#
|
||||
# please add tests you want to be skipped here!
|
||||
#
|
||||
skipped="BASE-CHARSET BASE-DEFER_OPEN BASE-DELAYWRITE RAW-COMPOSITE RAW-OPLOCK RAW-ACLS"
|
||||
|
||||
echo "WARNING: Skipping tests $skipped"
|
||||
|
||||
failed=0
|
||||
for t in $tests; do
|
||||
if [ ! -z "$start" -a "$start" != $t ]; then
|
||||
continue;
|
||||
fi
|
||||
skip=0
|
||||
for s in $skipped; do
|
||||
if [ x"$s" = x"$t" ]; then
|
||||
skip=1;
|
||||
break;
|
||||
fi
|
||||
done
|
||||
if [ $skip = 1 ]; then
|
||||
continue;
|
||||
fi
|
||||
start=""
|
||||
name="$t"
|
||||
testit "$name" $VALGRIND bin/smbtorture $TORTURE_OPTIONS $ADDARGS $unc -U"$username"%"$password" $t || failed=`expr $failed + 1`
|
||||
done
|
||||
|
||||
testok $0 $failed
|
||||
Executable
+39
@@ -0,0 +1,39 @@
|
||||
#!/bin/sh
|
||||
# run a quick set of filesystem tests
|
||||
|
||||
if [ $# -lt 3 ]; then
|
||||
cat <<EOF
|
||||
Usage: test_quick.sh UNC USERNAME PASSWORD <first> <smbtorture args>
|
||||
EOF
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
unc="$1"
|
||||
username="$2"
|
||||
password="$3"
|
||||
start="$4"
|
||||
shift 4
|
||||
ADDARGS="$*"
|
||||
|
||||
incdir=`dirname $0`
|
||||
. $incdir/test_functions.sh
|
||||
|
||||
tests="BASE-UNLINK BASE-ATTR BASE-DELETE"
|
||||
tests="$tests BASE-TCON BASE-OPEN"
|
||||
tests="$tests BASE-CHKPATH RAW-QFSINFO RAW-QFILEINFO RAW-SFILEINFO"
|
||||
tests="$tests RAW-MKDIR RAW-SEEK RAW-OPEN RAW-WRITE"
|
||||
tests="$tests RAW-UNLINK RAW-READ RAW-CLOSE RAW-IOCTL RAW-RENAME"
|
||||
tests="$tests RAW-EAS RAW-STREAMS"
|
||||
|
||||
failed=0
|
||||
for t in $tests; do
|
||||
if [ ! -z "$start" -a "$start" != $t ]; then
|
||||
continue;
|
||||
fi
|
||||
start=""
|
||||
name="$t"
|
||||
testit "$name" $VALGRIND bin/smbtorture $TORTURE_OPTIONS $ADDARGS $unc -U"$username"%"$password" $t || failed=`expr $failed + 1`
|
||||
done
|
||||
|
||||
testok $0 $failed
|
||||
|
||||
Executable
+58
@@ -0,0 +1,58 @@
|
||||
#!/bin/sh
|
||||
|
||||
# add tests to this list as they start passing, so we test
|
||||
# that they stay passing
|
||||
ncacn_np_tests="RPC-SPOOLSS RPC-SRVSVC RPC-UNIXINFO RPC-SCHANNEL RPC-JOIN RPC-LSA RPC-ECHO RPC-DSSETUP RPC-ALTERCONTEXT RPC-MULTIBIND RPC-NETLOGON"
|
||||
ncalrpc_tests="RPC-UNIXINFO RPC-SCHANNEL RPC-JOIN RPC-LSA RPC-ECHO RPC-DSSETUP RPC-ALTERCONTEXT RPC-MULTIBIND RPC-NETLOGON"
|
||||
ncacn_ip_tcp_tests="RPC-UNIXINFO RPC-SCHANNEL RPC-JOIN RPC-LSA RPC-ECHO RPC-DSSETUP RPC-ALTERCONTEXT RPC-MULTIBIND RPC-NETLOGON"
|
||||
slow_ncacn_np_tests="RPC-SAMLOGON RPC-SAMR RPC-SAMR-USERS RPC-SAMR-PASSWORDS"
|
||||
slow_ncalrpc_tests="RPC-SAMLOGON RPC-SAMR RPC-SAMR-USERS RPC-SAMR-PASSWORDS"
|
||||
slow_ncacn_ip_tcp_tests="RPC-SAMLOGON RPC-SAMR RPC-SAMR-USERS RPC-SAMR-PASSWORDS"
|
||||
|
||||
if [ $# -lt 4 ]; then
|
||||
cat <<EOF
|
||||
Usage: test_rpc.sh SERVER USERNAME PASSWORD DOMAIN
|
||||
EOF
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
server="$1"
|
||||
username="$2"
|
||||
password="$3"
|
||||
domain="$4"
|
||||
shift 4
|
||||
|
||||
incdir=`dirname $0`
|
||||
. $incdir/test_functions.sh
|
||||
|
||||
failed=0
|
||||
for bindoptions in seal,padcheck $VALIDATE bigendian; do
|
||||
for transport in ncalrpc ncacn_np ncacn_ip_tcp; do
|
||||
case $transport in
|
||||
ncalrpc) tests=$ncalrpc_tests ;;
|
||||
ncacn_np) tests=$ncacn_np_tests ;;
|
||||
ncacn_ip_tcp) tests=$ncacn_ip_tcp_tests ;;
|
||||
esac
|
||||
for t in $tests; do
|
||||
name="$t on $transport with $bindoptions"
|
||||
testit "$name" $VALGRIND bin/smbtorture $TORTURE_OPTIONS $transport:"$server[$bindoptions]" -U"$username"%"$password" -W $domain $t "$*" || failed=`expr $failed + 1`
|
||||
done
|
||||
done
|
||||
done
|
||||
|
||||
for bindoptions in connect $VALIDATE ; do
|
||||
for transport in ncalrpc; do
|
||||
case $transport in
|
||||
ncalrpc) tests=$slow_ncalrpc_tests ;;
|
||||
ncacn_np) tests=$slow_ncacn_np_tests ;;
|
||||
ncacn_ip_tcp) tests=$slow_ncacn_ip_tcp_tests ;;
|
||||
esac
|
||||
for t in $tests; do
|
||||
name="$t on $transport with $bindoptions"
|
||||
testit "$name" $VALGRIND bin/smbtorture $TORTURE_OPTIONS $transport:"$server[$bindoptions]" -U"$username"%"$password" -W $domain $t "$*" || failed=`expr $failed + 1`
|
||||
done
|
||||
done
|
||||
done
|
||||
|
||||
testok $0 $failed
|
||||
|
||||
Executable
+40
@@ -0,0 +1,40 @@
|
||||
#!/bin/sh
|
||||
|
||||
# add tests to this list as they start passing, so we test
|
||||
# that they stay passing
|
||||
ncacn_np_tests="RPC-ALTERCONTEXT RPC-JOIN RPC-ECHO RPC-SCHANNEL RPC-NETLOGON RPC-UNIXINFO"
|
||||
ncacn_ip_tcp_tests="RPC-ALTERCONTEXT RPC-JOIN RPC-ECHO"
|
||||
ncalrpc_tests="RPC-ECHO"
|
||||
|
||||
if [ $# -lt 4 ]; then
|
||||
cat <<EOF
|
||||
Usage: test_rpc_quick.sh SERVER USERNAME PASSWORD DOMAIN
|
||||
EOF
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
server="$1"
|
||||
username="$2"
|
||||
password="$3"
|
||||
domain="$4"
|
||||
shift 4
|
||||
|
||||
incdir=`dirname $0`
|
||||
. $incdir/test_functions.sh
|
||||
|
||||
failed=0
|
||||
for bindoptions in seal,padcheck $VALIDATE bigendian; do
|
||||
for transport in ncalrpc ncacn_np ncacn_ip_tcp; do
|
||||
case $transport in
|
||||
ncalrpc) tests=$ncalrpc_tests ;;
|
||||
ncacn_np) tests=$ncacn_np_tests ;;
|
||||
ncacn_ip_tcp) tests=$ncacn_ip_tcp_tests ;;
|
||||
esac
|
||||
for t in $tests; do
|
||||
name="$t on $transport with $bindoptions"
|
||||
testit "$name" $VALGRIND bin/smbtorture $TORTURE_OPTIONS $transport:"$server[$bindoptions]" -U"$username"%"$password" -W $domain $t "$*" || failed=`expr $failed + 1`
|
||||
done
|
||||
done
|
||||
done
|
||||
|
||||
testok $0 $failed
|
||||
Executable
+15
@@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
PREFIX=$1
|
||||
|
||||
if [ -z "$PREFIX" ]
|
||||
then
|
||||
echo "Usage: test_s3upgrade.sh <prefix>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p $PREFIX
|
||||
rm -f $PREFIX/*
|
||||
|
||||
$VALGRIND bin/smbscript ../testprogs/ejs/samba3sam
|
||||
$VALGRIND bin/smbscript ../testdata/samba3/verify ../testdata/samba3
|
||||
$VALGRIND bin/smbscript setup/upgrade --verify --targetdir=$PREFIX ../testdata/samba3 ../testdata/samba3/smb.conf
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ $# -lt 4 ]; then
|
||||
cat <<EOF
|
||||
Usage: test_session_key.sh SERVER USERNAME PASSWORD DOMAIN NETBIOSNAME
|
||||
EOF
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
server="$1"
|
||||
username="$2"
|
||||
password="$3"
|
||||
domain="$4"
|
||||
netbios_name="$5"
|
||||
shift 5
|
||||
|
||||
incdir=`dirname $0`
|
||||
. $incdir/test_functions.sh
|
||||
|
||||
failed=0
|
||||
transport="ncacn_np"
|
||||
for bindoptions in bigendian seal; do
|
||||
for keyexchange in "yes" "no"; do
|
||||
for ntlm2 in "yes" "no"; do
|
||||
for lm_key in "yes" "no"; do
|
||||
for ntlmoptions in \
|
||||
"-k no --option=usespnego=yes" \
|
||||
"-k no --option=usespnego=yes --option=ntlmssp_client:128bit=no" \
|
||||
"-k no --option=usespnego=yes --option=ntlmssp_client:56bit=yes" \
|
||||
"-k no --option=usespnego=yes --option=ntlmssp_client:56bit=no" \
|
||||
"-k no --option=usespnego=yes --option=ntlmssp_client:128bit=no --option=ntlmssp_client:56bit=yes" \
|
||||
"-k no --option=usespnego=yes --option=ntlmssp_client:128bit=no --option=ntlmssp_client:56bit=no" \
|
||||
"-k no --option=usespnego=yes --option=clientntlmv2auth=yes" \
|
||||
"-k no --option=usespnego=yes --option=clientntlmv2auth=yes --option=ntlmssp_client:128bit=no" \
|
||||
"-k no --option=usespnego=yes --option=clientntlmv2auth=yes --option=ntlmssp_client:128bit=no --option=ntlmssp_client:56bit=yes" \
|
||||
"-k no --option=usespnego=no --option=clientntlmv2auth=yes" \
|
||||
"-k no --option=gensec:spnego=no --option=clientntlmv2auth=yes" \
|
||||
"-k no --option=usespnego=no"; do
|
||||
name="RPC-SECRETS on $transport with $bindoptions with NTLM2:$ntlm2 KEYEX:$keyexchange LM_KEY:$lm_key $ntlmoptions"
|
||||
testit "$name" bin/smbtorture $TORTURE_OPTIONS $transport:"$server[$bindoptions]" --option=ntlmssp_client:keyexchange=$keyexchange --option=ntlmssp_client:ntlm2=$ntlm2 --option=ntlmssp_client:lm_key=$lm_key $ntlmoptions -U"$username"%"$password" -W $domain --option=gensec:target_hostname=$netbios_name RPC-SECRETS "$*" || failed=`expr $failed + 1`
|
||||
done
|
||||
done
|
||||
done
|
||||
done
|
||||
name="RPC-SECRETS on $transport with $bindoptions with Kerberos"
|
||||
testit "$name" bin/smbtorture $TORTURE_OPTIONS $transport:"$server[$bindoptions]" -k yes -U"$username"%"$password" -W $domain "--option=gensec:target_hostname=$netbios_name" RPC-SECRETS "$*" || failed=`expr $failed + 1`
|
||||
name="RPC-SECRETS on $transport with $bindoptions with Kerberos - use target principal"
|
||||
testit "$name" bin/smbtorture $TORTURE_OPTIONS $transport:"$server[$bindoptions]" -k yes -U"$username"%"$password" -W $domain "--option=clientusespnegoprincipal=yes" "--option=gensec:target_hostname=$netbios_name" RPC-SECRETS "$*" || failed=`expr $failed + 1`
|
||||
done
|
||||
name="RPC-SECRETS on $transport with Kerberos - use Samba3 style login"
|
||||
testit "$name" bin/smbtorture $TORTURE_OPTIONS $transport:"$server" -k yes -U"$username"%"$password" -W $domain "--option=gensec:fake_gssapi_krb5=yes" "--option=gensec:gssapi_krb5=no" "--option=gensec:target_hostname=$netbios_name" RPC-SECRETS "$*" || failed=`expr $failed + 1`
|
||||
name="RPC-SECRETS on $transport with Kerberos - use Samba3 style login, use target principal"
|
||||
testit "$name" bin/smbtorture $TORTURE_OPTIONS $transport:"$server" -k yes -U"$username"%"$password" -W $domain "--option=clientusespnegoprincipal=yes" "--option=gensec:fake_gssapi_krb5=yes" "--option=gensec:gssapi_krb5=no" "--option=gensec:target_hostname=$netbios_name" RPC-SECRETS "$*" || failed=`expr $failed + 1`
|
||||
testok $0 $failed
|
||||
Executable
+34
@@ -0,0 +1,34 @@
|
||||
#!/bin/sh
|
||||
# run a quick set of filesystem tests
|
||||
|
||||
if [ $# -lt 3 ]; then
|
||||
cat <<EOF
|
||||
Usage: test_simple.sh UNC USERNAME PASSWORD <first> <smbtorture args>
|
||||
EOF
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
unc="$1"
|
||||
username="$2"
|
||||
password="$3"
|
||||
start="$4"
|
||||
shift 4
|
||||
ADDARGS="$*"
|
||||
|
||||
incdir=`dirname $0`
|
||||
. $incdir/test_functions.sh
|
||||
|
||||
tests="BASE-RW1"
|
||||
|
||||
failed=0
|
||||
for t in $tests; do
|
||||
if [ ! -z "$start" -a "$start" != $t ]; then
|
||||
continue;
|
||||
fi
|
||||
start=""
|
||||
name="$t"
|
||||
testit "$name" $VALGRIND bin/smbtorture $TORTURE_OPTIONS $ADDARGS $unc -U"$username"%"$password" $t || failed=`expr $failed + 1`
|
||||
done
|
||||
|
||||
testok $0 $failed
|
||||
|
||||
Executable
+90
@@ -0,0 +1,90 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ $# -lt 5 ]; then
|
||||
cat <<EOF
|
||||
Usage: test_smbclient.sh SERVER USERNAME PASSWORD DOMAIN PREFIX
|
||||
EOF
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
SERVER=$1
|
||||
USERNAME=$2
|
||||
PASSWORD=$3
|
||||
DOMAIN=$4
|
||||
PREFIX=$5
|
||||
shift 5
|
||||
failed=0
|
||||
|
||||
runcmd() {
|
||||
name="$1"
|
||||
shift
|
||||
testit "$name" $VALGRIND bin/smbclient $CONFIGURATION //$SERVER/tmp -W "$DOMAIN "-U"$USERNAME"%"$PASSWORD" $@
|
||||
}
|
||||
|
||||
incdir=`dirname $0`
|
||||
. $incdir/test_functions.sh
|
||||
|
||||
# Generate random file
|
||||
cat >tmpfile<<EOF
|
||||
foo
|
||||
bar
|
||||
bloe
|
||||
blah
|
||||
EOF
|
||||
|
||||
|
||||
# put that file
|
||||
echo mput tmpfile | runcmd "MPutting file" || failed=`expr $failed + 1`
|
||||
# check file info
|
||||
echo altname tmpfile | runcmd "Getting alternative name" || failed=`expr $failed + 1`
|
||||
# run allinfo on that file
|
||||
echo allinfo tmpfile | runcmd "Checking info on file" || failed=`expr $failed + 1`
|
||||
# get that file
|
||||
mv tmpfile tmpfile-old
|
||||
echo mget tmpfile | runcmd "MGetting file" || failed=`expr $failed + 1`
|
||||
# remove that file
|
||||
echo rm tmpfile | runcmd "Removing file" || failed=`expr $failed + 1`
|
||||
# compare locally
|
||||
testit "Comparing files" diff tmpfile-old tmpfile || failed=`expr $failed + 1`
|
||||
# create directory
|
||||
echo mkdir bla | runcmd "Creating directory" || failed=`expr $failed + 1`
|
||||
# cd to directory
|
||||
echo cd bla | runcmd "Changing directory" || failed=`expr $failed + 1`
|
||||
# cd to top level directory
|
||||
echo cd .. | runcmd "Going back" || failed=`expr $failed + 1`
|
||||
# remove directory
|
||||
echo rmdir bla | runcmd "Removing directory" || failed=`expr $failed + 1`
|
||||
# enable recurse, create nested directory
|
||||
echo "recurse; echo mkdir bla/bloe; exit" | runcmd "Creating nested directory" || failed=`expr $failed + 1`
|
||||
# remove parent directory
|
||||
echo rmdir bla/bloe | runcmd "Removing directory" || failed=`expr $failed + 1`
|
||||
# remove child directory
|
||||
echo rmdir bla | runcmd "Removing directory" || failed=`expr $failed + 1`
|
||||
# run fsinfo
|
||||
echo fsinfo objectid | runcmd "Getting file system info" || failed=`expr $failed + 1`
|
||||
|
||||
# put that file
|
||||
echo put tmpfile | runcmd "Putting file" || failed=`expr $failed + 1`
|
||||
# get that file
|
||||
mv tmpfile tmpfile-old
|
||||
echo get tmpfile | runcmd "Getting file" || failed=`expr $failed + 1`
|
||||
# remove that file
|
||||
echo rm tmpfile | runcmd "Removing file" || failed=`expr $failed + 1`
|
||||
# compare locally
|
||||
testit "Comparing files" diff tmpfile-old tmpfile || failed=`expr $failed + 1`
|
||||
# put that file
|
||||
echo put tmpfile tmpfilex | runcmd "Putting file with different name" || failed=`expr $failed + 1`
|
||||
# get that file
|
||||
echo get tmpfilex | runcmd "Getting file again" || failed=`expr $failed + 1`
|
||||
# compare locally
|
||||
testit "Comparing files" diff tmpfilex tmpfile || failed=`expr $failed + 1`
|
||||
# remove that file
|
||||
echo rm tmpfilex | runcmd "Removing file" || failed=`expr $failed + 1`
|
||||
|
||||
# do some simple operations using old protocol versions
|
||||
echo ls | runcmd "List directory with LANMAN1" -m LANMAN1 || failed=`expr $failed + 1`
|
||||
echo ls | runcmd "List directory with LANMAN2" -m LANMAN2 || failed=`expr $failed + 1`
|
||||
|
||||
rm -f tmpfile tmpfile-old tmpfilex
|
||||
|
||||
testok $0 $failed
|
||||
Executable
+24
@@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ $# -ne 0 ]; then
|
||||
cat <<EOF
|
||||
Usage: test_swig.sh
|
||||
EOF
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
incdir=`dirname $0`
|
||||
. $incdir/test_functions.sh
|
||||
|
||||
failed=0
|
||||
|
||||
export PYTHONPATH=lib/tdb/swig:lib/ldb/swig:scripting/swig:$PYTHONPATH
|
||||
export LD_LIBRARY_PATH=bin:$LD_LIBRARY_PATH
|
||||
|
||||
echo Testing tdb wrappers
|
||||
scripting/swig/torture/torture_tdb.py || failed=`expr $failed + 1`
|
||||
|
||||
echo Testing ldb wrappers
|
||||
scripting/swig/torture/torture_ldb.py || failed=`expr $failed + 1`
|
||||
|
||||
testok $0 $failed
|
||||
Executable
+52
@@ -0,0 +1,52 @@
|
||||
#!/bin/sh
|
||||
|
||||
# tests that should pass against a w2k3 DC, as administrator
|
||||
|
||||
# add tests to this list as they start passing, so we test
|
||||
# that they stay passing
|
||||
ncacn_np_tests="RPC-SCHANNEL RPC-DSSETUP RPC-EPMAPPER RPC-SAMR RPC-WKSSVC RPC-SRVSVC RPC-EVENTLOG RPC-NETLOGON RPC-LSA RPC-SAMLOGON RPC-SAMSYNC RPC-MULTIBIND RPC-WINREG"
|
||||
ncacn_ip_tcp_tests="RPC-SCHANNEL RPC-EPMAPPER RPC-SAMR RPC-NETLOGON RPC-LSA RPC-SAMLOGON RPC-SAMSYNC RPC-MULTIBIND"
|
||||
|
||||
if [ $# -lt 4 ]; then
|
||||
cat <<EOF
|
||||
Usage: test_w2k3.sh SERVER USERNAME PASSWORD DOMAIN REALM
|
||||
EOF
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
server="$1"
|
||||
username="$2"
|
||||
password="$3"
|
||||
domain="$4"
|
||||
realm="$5"
|
||||
shift 5
|
||||
|
||||
incdir=`dirname $0`
|
||||
. $incdir/test_functions.sh
|
||||
|
||||
OPTIONS="-U$username%$password -W $domain --option realm=$realm"
|
||||
|
||||
failed=0
|
||||
|
||||
name="RPC-SPOOLSS on ncacn_np"
|
||||
testit "$name" bin/smbtorture $TORTURE_OPTIONS ncacn_np:"$server" $OPTIONS RPC-SPOOLSS "$*" || failed=`expr $failed + 1`
|
||||
|
||||
for bindoptions in padcheck connect sign seal ntlm,sign ntlm,seal $VALIDATE bigendian; do
|
||||
for transport in ncacn_ip_tcp ncacn_np; do
|
||||
case $transport in
|
||||
ncacn_np) tests=$ncacn_np_tests ;;
|
||||
ncacn_ip_tcp) tests=$ncacn_ip_tcp_tests ;;
|
||||
esac
|
||||
for t in $tests; do
|
||||
name="$t on $transport with $bindoptions"
|
||||
testit "$name" bin/smbtorture $TORTURE_OPTIONS $transport:"$server[$bindoptions]" $OPTIONS $t "$*" || failed=`expr $failed + 1`
|
||||
done
|
||||
done
|
||||
done
|
||||
|
||||
name="RPC-DRSUAPI on ncacn_ip_tcp with seal"
|
||||
testit "$name" bin/smbtorture $TORTURE_OPTIONS ncacn_ip_tcp:"$server[seal]" $OPTIONS RPC-DRSUAPI "$*" || failed=`expr $failed + 1`
|
||||
name="RPC-DRSUAPI on ncacn_ip_tcp with seal,bigendian"
|
||||
testit "$name" bin/smbtorture $TORTURE_OPTIONS ncacn_ip_tcp:"$server[seal,bigendian]" $OPTIONS RPC-DRSUAPI "$*" || failed=`expr $failed + 1`
|
||||
|
||||
testok $0 $failed
|
||||
Executable
+52
@@ -0,0 +1,52 @@
|
||||
#!/bin/sh
|
||||
|
||||
# this runs the file serving tests that are expected to pass with win2003
|
||||
|
||||
if [ $# -lt 3 ]; then
|
||||
cat <<EOF
|
||||
Usage: test_w2k3_file.sh UNC USERNAME PASSWORD <first> <smbtorture args>
|
||||
EOF
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
unc="$1"
|
||||
username="$2"
|
||||
password="$3"
|
||||
start="$4"
|
||||
shift 4
|
||||
ADDARGS="$*"
|
||||
|
||||
incdir=`dirname $0`
|
||||
. $incdir/test_functions.sh
|
||||
|
||||
tests="BASE-FDPASS BASE-LOCK "
|
||||
tests="$tests BASE-UNLINK BASE-ATTR"
|
||||
tests="$tests BASE-DIR1 BASE-DIR2 BASE-VUID"
|
||||
tests="$tests BASE-TCON BASE-TCONDEV BASE-RW1"
|
||||
tests="$tests BASE-DENY3 BASE-XCOPY BASE-OPEN BASE-DENYDOS"
|
||||
tests="$tests BASE-DELETE BASE-PROPERTIES BASE-MANGLE"
|
||||
tests="$tests BASE-CHKPATH BASE-SECLEAK BASE-TRANS2"
|
||||
tests="$tests BASE-NTDENY1 BASE-NTDENY2 BASE-RENAME BASE-OPENATTR"
|
||||
tests="$tests RAW-QFILEINFO RAW-SFILEINFO-BUG RAW-SFILEINFO"
|
||||
tests="$tests RAW-LOCK RAW-MKDIR RAW-SEEK RAW-CONTEXT RAW-MUX RAW-OPEN RAW-WRITE"
|
||||
tests="$tests RAW-UNLINK RAW-READ RAW-CLOSE RAW-IOCTL RAW-CHKPATH RAW-RENAME"
|
||||
tests="$tests RAW-EAS RAW-STREAMS RAW-OPLOCK RAW-NOTIFY BASE-DELAYWRITE"
|
||||
# slowest tests last
|
||||
tests="$tests BASE-DENY1 BASE-DENY2"
|
||||
|
||||
# these tests are known to fail against windows
|
||||
fail="RAW-SEARCH RAW-ACLS RAW-QFSINFO"
|
||||
|
||||
echo "Skipping tests expected to fail: $fail"
|
||||
|
||||
failed=0
|
||||
for t in $tests; do
|
||||
if [ ! -z "$start" -a "$start" != $t ]; then
|
||||
continue;
|
||||
fi
|
||||
start=""
|
||||
name="$t"
|
||||
testit "$name" $VALGRIND bin/smbtorture $TORTURE_OPTIONS $ADDARGS $unc -U"$username"%"$password" $t || failed=`expr $failed + 1`
|
||||
done
|
||||
|
||||
testok $0 $failed
|
||||
Executable
+36
@@ -0,0 +1,36 @@
|
||||
#!/bin/sh
|
||||
|
||||
# A shell script to connect to a windows host over telnet,
|
||||
# setup for a smbtorture test,
|
||||
# run the test,
|
||||
# and remove the previously configured directory and share.
|
||||
# Copyright Brad Henry <brad@samba.org> 2006
|
||||
# Released under the GNU GPL v2 or later.
|
||||
|
||||
# Index variable to count the total number of tests which fail.
|
||||
all_errs=0
|
||||
|
||||
export SMBTORTURE_REMOTE_HOST=`perl -I$WINTEST_DIR $WINTEST_DIR/vm_get_ip.pl`
|
||||
if [ -z $SMBTORTURE_REMOTE_HOST ]; then
|
||||
# Restore snapshot to ensure VM is in a known state, then exit.
|
||||
restore_snapshot "Test failed to get the IP address of the windows host."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
$WINTEST_DIR/wintest_base.sh $SMBTORTURE_REMOTE_HOST $SMBTORTURE_USERNAME \
|
||||
$SMBTORTURE_PASSWORD $SMBTORTURE_WORKGROUP \
|
||||
|| all_errs=`expr $all_errs + $?`
|
||||
|
||||
$WINTEST_DIR/wintest_raw.sh $SMBTORTURE_REMOTE_HOST $SMBTORTURE_USERNAME \
|
||||
$SMBTORTURE_PASSWORD $SMBTORTURE_WORKGROUP \
|
||||
|| all_errs=`expr $all_errs + $?`
|
||||
|
||||
$WINTEST_DIR/wintest_rpc.sh $SMBTORTURE_REMOTE_HOST $SMBTORTURE_USERNAME \
|
||||
$SMBTORTURE_PASSWORD $SMBTORTURE_WORKGROUP \
|
||||
|| all_errs=`expr $all_errs + $?`
|
||||
|
||||
$WINTEST_DIR/wintest_net.sh $SMBTORTURE_REMOTE_HOST $SMBTORTURE_USERNAME \
|
||||
$SMBTORTURE_PASSWORD $SMBTORTURE_WORKGROUP \
|
||||
|| all_errs=`expr $all_errs + $?`
|
||||
|
||||
$WINTEST_DIR/wintest_client.sh || all_errs=`expr $all_errs + $?`
|
||||
Executable
+16
@@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
$SRCDIR/script/tests/test_ejs.sh $DOMAIN $USERNAME $PASSWORD || totalfailed=`expr $totalfailed + $?`
|
||||
$SRCDIR/script/tests/test_ldap.sh $SERVER $USERNAME $PASSWORD || totalfailed=`expr $totalfailed + $?`
|
||||
$SRCDIR/script/tests/test_nbt.sh $SERVER || totalfailed=`expr $totalfailed + $?`
|
||||
$SRCDIR/script/tests/test_quick.sh //$SERVER/cifs $USERNAME $PASSWORD "" || totalfailed=`expr $totalfailed + $?`
|
||||
$SRCDIR/script/tests/test_rpc.sh $SERVER $USERNAME $PASSWORD $DOMAIN || totalfailed=`expr $totalfailed + $?`
|
||||
$SRCDIR/script/tests/test_net.sh $SERVER $USERNAME $PASSWORD $DOMAIN || totalfailed=`expr $totalfailed + $?`
|
||||
$SRCDIR/script/tests/test_session_key.sh $SERVER $USERNAME $PASSWORD $DOMAIN $NETBIOSNAME || totalfailed=`expr $totalfailed + $?`
|
||||
$SRCDIR/script/tests/test_binding_string.sh $SERVER $USERNAME $PASSWORD $DOMAIN || totalfailed=`expr $totalfailed + $?`
|
||||
$SRCDIR/script/tests/test_echo.sh $SERVER $USERNAME $PASSWORD $DOMAIN || totalfailed=`expr $totalfailed + $?`
|
||||
$SRCDIR/script/tests/test_posix.sh //$SERVER/tmp $USERNAME $PASSWORD "" || totalfailed=`expr $totalfailed + $?`
|
||||
$SRCDIR/script/tests/test_local.sh || totalfailed=`expr $totalfailed + $?`
|
||||
$SRCDIR/script/tests/test_pidl.sh || totalfailed=`expr $totalfailed + $?`
|
||||
$SRCDIR/script/tests/test_smbclient.sh $SERVER $USERNAME $PASSWORD $DOMAIN $PREFIX || totalfailed=`expr $totalfailed + $?`
|
||||
$SRCDIR/script/tests/test_cifsdd.sh $SERVER $USERNAME $PASSWORD $DOMAIN || totalfailed=`expr $totalfailed + $?`
|
||||
$SRCDIR/script/tests/test_simple.sh //$SERVER/simple $USERNAME $PASSWORD "" || totalfailed=`expr $totalfailed + $?`
|
||||
Executable
+3
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
$SRCDIR/script/tests/test_smbclient.sh $SERVER $USERNAME $PASSWORD $DOMAIN $PREFIX || totalfailed=`expr $totalfailed + $?`
|
||||
$SRCDIR/script/tests/test_cifsdd.sh $SERVER $USERNAME $PASSWORD $DOMAIN || totalfailed=`expr $totalfailed + $?`
|
||||
Executable
+2
@@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
$SRCDIR/script/tests/test_net.sh $SERVER $USERNAME $PASSWORD $DOMAIN || failed=`expr $failed + $?`
|
||||
Executable
+12
@@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
TORTURE_OPTIONS="$TORTURE_OPTIONS --option=torture:quick=yes"
|
||||
export TORTURE_OPTIONS
|
||||
TORTURE_QUICK="yes"
|
||||
export TORTURE_QUICK
|
||||
|
||||
$SRCDIR/script/tests/test_ejs.sh $DOMAIN $USERNAME $PASSWORD || totalfailed=`expr $totalfailed + $?`
|
||||
$SRCDIR/script/tests/test_ldap.sh $SERVER $USERNAME $PASSWORD || totalfailed=`expr $totalfailed + $?`
|
||||
$SRCDIR/script/tests/test_nbt.sh $SERVER || totalfailed=`expr $totalfailed + $?`
|
||||
$SRCDIR/script/tests/test_quick.sh //$SERVER/cifs $USERNAME $PASSWORD "" || totalfailed=`expr $totalfailed + $?`
|
||||
$SRCDIR/script/tests/test_rpc_quick.sh $SERVER $USERNAME $PASSWORD $DOMAIN || totalfailed=`expr $totalfailed + $?`
|
||||
#$SRCDIR/script/tests/test_cifsposix.sh //$SERVER/cifsposixtestshare $USERNAME $PASSWORD "" || totalfailed=`expr $totalfailed + $?`
|
||||
Executable
+34
@@ -0,0 +1,34 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ `whoami` != "root" ]; then
|
||||
echo "Windows tests will not run without root privilages."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$DO_SOCKET_WRAPPER" = SOCKET_WRAPPER ]; then
|
||||
echo "Windows tests will not run with socket wrapper enabled."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! $WINTESTCONF ]; then
|
||||
echo "Environment variable WINTESTCONF has not been defined."
|
||||
echo "Windows tests will not run unconfigured."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -r $WINTESTCONF ]; then
|
||||
echo "$WINTESTCONF could not be read."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export WINTEST_DIR=$SRCDIR/script/tests/win
|
||||
export TMPDIR=$TMPDIR
|
||||
export NETBIOSNAME=$NETBIOSNAME
|
||||
|
||||
. $WINTESTCONF
|
||||
|
||||
$SRCDIR/script/tests/test_win.sh
|
||||
status=$?
|
||||
|
||||
echo "$0 exits with status $status"
|
||||
exit $status
|
||||
@@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
xterm -e 'echo -e "Welcome to the Samba4 Test environment\n\
|
||||
This matches the client environment used in make test\n\
|
||||
smbd is pid `cat $PIDDIR/smbd.pid`\n\
|
||||
\n\
|
||||
Some useful environment variables:\n\
|
||||
AUTH=$AUTH\n\
|
||||
TORTURE_OPTIONS=$TORTURE_OPTIONS\n\
|
||||
CONFIGURATION=$CONFIGURATION\n\
|
||||
SERVER=$SERVER\n\
|
||||
NETBIOSNAME=$NETBIOSNAME" && bash'
|
||||
@@ -0,0 +1,121 @@
|
||||
This framework uses a VMware Server hosted Windows guest VM to test the
|
||||
behaviour of Windows -> Samba and Samba -> Windows interactions. To setup a
|
||||
Windows host for testing, vm_setup.tar.gz contain some scripts which create
|
||||
an administrative user account, and enable and start the installed telnet
|
||||
service on the Windows host. Optionally, the hostname and workgroup name can
|
||||
also be set. vm_setup.tar.gz is currently located in the SOC/bnh branch of
|
||||
Samba's SVN repository.
|
||||
|
||||
PREREQUISITES
|
||||
|
||||
To use these scripts, VMware Server needs to be running with a Windows guest
|
||||
VM installed, IP addressed, and VMware tools needs to be installed and running
|
||||
on the guest VM. The Windows OS I used to test with was Windows Server 2003,
|
||||
but I think this should work with any version of Windows that has the
|
||||
Microsoft telnet service installed. The VMware Server versions I used for
|
||||
testing was 1.0.0 build-27828, and 1.0.0 build-28343.
|
||||
|
||||
PLEASE NOTE: Due to problems with my original revert_snapshot() code, the initial
|
||||
setup now requires that the VM configuration setting 'When Powering Off' is
|
||||
manually set to 'Revert to snapshot' (snapshot.action="autoRevert" in the
|
||||
guest's .vmx file). This should not be a permanent change, but the original
|
||||
revert_snapshot() code I wrote no longer works and i'm not sure why.
|
||||
|
||||
On the machine that these scripts are running on (this need not be the same
|
||||
machine as the VMware host), the VMware perl scripting api needs to be
|
||||
installed, as well as the vix-perl api. These come with the VMware Server
|
||||
console package.
|
||||
|
||||
After unzipping this file, the libraries are installed by extracting the
|
||||
VMware-vix-e.x.p-<revision number>.tar.gz and
|
||||
VMware-VmPerlAPI-e.x.p-<revision number>.tar.gz archives, and running the
|
||||
vmware-install.pl scripts inside their respective directories.
|
||||
|
||||
On Slackware 10.2, I encountered a problem in that when I tried to use the vix
|
||||
api libraries, I would get the following error:
|
||||
|
||||
SSLLoadSharedLibrary: Failed to load library /<client program directory>/libcrypto.so.0.9.7:/<client program directory>/libcrypto.so.0.9.7: cannot open a shared object file: No such file or directory.
|
||||
|
||||
The fix found on the VMware knowledge base (search http://kb.vmware.com for
|
||||
Doc ID: 1837104) states that it's a known problem with the scripting libraries,
|
||||
and can be resolved by installing VMware Server on the host, which properly
|
||||
sets up the SSL module loader. This is what I would suggest if you encounter
|
||||
this, as it solved the problem for me (I don't have VMware Server actually
|
||||
running on that host though).
|
||||
|
||||
INSTALLATION
|
||||
|
||||
To use these scripts, modify initial_setup.conf to match your environment. The
|
||||
GUEST_HOSTNAME, GUEST_WORKGROUP, HOST_SERVER_NAME, HOST_SERVER_PORT,
|
||||
HOST_USERNAME, and HOST_PASSWORD variables are optional, and are commented out
|
||||
in this release.
|
||||
|
||||
Running initial_setup.sh will:
|
||||
* Get the IP address of the Windows guest VM.
|
||||
* Take a snapshot of the pristine Windows guest.
|
||||
* Copy the windows scripts from the windows-scripts directory on the unix host
|
||||
to the directory on the Windows guest specified by the
|
||||
GUEST_SCRIPT_PATH option. This path will be created on the guest if
|
||||
it does not already exist.
|
||||
* Execute win_setup.wsf on the Windows guest in order to create the
|
||||
administrator account specified by GUEST_USERNAME and GUEST_PASSWORD,
|
||||
enable and start the telnet service, and set the GUEST_HOSTNAME and
|
||||
GUEST_WORKGROUP if configured.
|
||||
* If these operations are successful so far, another snapshot is taken at this
|
||||
point. This is the snapshot which is restored if the tests encounter
|
||||
problems they are unable to recover from.
|
||||
|
||||
These operations leave the Windows guest in a state such that it can be
|
||||
remotely administered with telnet. Specifically, this will allow us to use
|
||||
'make wintest' in Samba 4 to perform smbtorture tests against a Windows host,
|
||||
and perform tests from a Windows client to a Samba server.
|
||||
|
||||
INTEGRATING WITH THE BUILD FARM
|
||||
|
||||
Follow the standard steps to add a host to the build farm. The major
|
||||
difference is that we will need to run these tests as root. To run the
|
||||
Windows tests in the build farm, a .fns file will need to be created for
|
||||
your new host that exports a WINTESTCONF environment variable pointing to a
|
||||
config file used by 'make wintest'. An example of this config file can be
|
||||
found at source/script/tests/win/test_win.conf in the Samba 4 source tree.
|
||||
|
||||
I've also included the bnhtest.fns file that I'm using for my build farm host
|
||||
below, as an example. It was modified from generic.fns.
|
||||
|
||||
action_test_windows() {
|
||||
do_make wintest
|
||||
w_status=$?
|
||||
echo "WINTEST STATUS: $w_status"
|
||||
return $w_status;
|
||||
}
|
||||
|
||||
per_run_hook
|
||||
|
||||
system=`uname`
|
||||
|
||||
export WINTESTCONF="/home/build/win/test_win.conf"
|
||||
|
||||
for compiler in gcc cc icc; do
|
||||
|
||||
# arrgh, "which" gives no err code on solaris
|
||||
path=`which $compiler`
|
||||
if [ -x "$path" ]; then
|
||||
|
||||
if $compiler -v 2>&1 | grep gcc.version > /dev/null; then
|
||||
isgcc=1
|
||||
CFLAGS="-Wall"
|
||||
export CFLAGS
|
||||
else
|
||||
CFLAGS=""
|
||||
export CFLAGS
|
||||
isgcc=0
|
||||
fi
|
||||
if [ $compiler = gcc -o $isgcc = 0 ]; then
|
||||
|
||||
# only attempt samba4 if we have perl
|
||||
if which perl > /dev/null; then
|
||||
test_tree samba4 source $compiler configure build install test_windows test
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
@@ -0,0 +1,359 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
# A perl object to provide a simple, unified method of handling some
|
||||
# VMware Server VM management functions using the perl and VIX API's.
|
||||
# Copyright Brad Henry <brad@samba.org> 2006
|
||||
# Released under the GNU GPL v2 or later.
|
||||
|
||||
# VMware Perl API
|
||||
use VMware::VmPerl;
|
||||
use VMware::VmPerl::VM;
|
||||
use VMware::VmPerl::ConnectParams;
|
||||
|
||||
# VMware C bindings
|
||||
use VMware::Vix::Simple;
|
||||
use VMware::Vix::API::Constants;
|
||||
|
||||
# Create a class to abstract from the Vix and VMPerl APIs.
|
||||
{ package VMHost;
|
||||
my $perl_vm = VMware::VmPerl::VM::new();
|
||||
my $perl_vm_credentials;
|
||||
my $vix_vm;
|
||||
my $vix_vm_host;
|
||||
|
||||
my $err_code = 0;
|
||||
my $err_str = "";
|
||||
|
||||
my $hostname;
|
||||
my $port;
|
||||
my $username;
|
||||
my $password;
|
||||
my $vm_cfg_path;
|
||||
my $guest_admin_username;
|
||||
my $guest_admin_password;
|
||||
|
||||
sub error {
|
||||
my $old_err_code = $err_code;
|
||||
my $old_err_str = $err_str;
|
||||
$err_code = 0;
|
||||
$err_str = "";
|
||||
return ($old_err_code, $old_err_str);
|
||||
}
|
||||
|
||||
# Power on the guest if it isn't already running.
|
||||
# Returns 0 when the guest is already running, and
|
||||
# if not, it waits until it is started.
|
||||
sub start_guest {
|
||||
my $vm_power_state = $perl_vm->get_execution_state();
|
||||
if (!defined($vm_power_state)) {
|
||||
($err_code, $err_str) = $perl_vm->get_last_error();
|
||||
return ($err_code);
|
||||
}
|
||||
if ($vm_power_state == VMware::VmPerl::VM_EXECUTION_STATE_OFF
|
||||
|| $vm_power_state ==
|
||||
VMware::VmPerl::VM_EXECUTION_STATE_SUSPENDED)
|
||||
{
|
||||
if (!$perl_vm->start()) {
|
||||
($err_code, $err_str) =
|
||||
$perl_vm->get_last_error();
|
||||
return ($err_code);
|
||||
}
|
||||
while ($perl_vm->get_tools_last_active() == 0) {
|
||||
sleep(60);
|
||||
}
|
||||
}
|
||||
return ($err_code);
|
||||
}
|
||||
|
||||
sub host_connect {
|
||||
# When called as a method, the first parameter passed is the
|
||||
# name of the method. Called locally, this function will lose
|
||||
# the first parameter.
|
||||
shift @_;
|
||||
($hostname, $port, $username, $password, $vm_cfg_path,
|
||||
$guest_admin_username, $guest_admin_password) = @_;
|
||||
|
||||
# Connect to host using vmperl api.
|
||||
$perl_vm_credentials =
|
||||
VMware::VmPerl::ConnectParams::new($hostname, $port,
|
||||
$username, $password);
|
||||
if (!$perl_vm->connect($perl_vm_credentials, $vm_cfg_path)) {
|
||||
($err_code, $err_str) = $perl_vm->get_last_error();
|
||||
undef $perl_vm;
|
||||
return ($err_code);
|
||||
}
|
||||
|
||||
# Connect to host using vix api.
|
||||
($err_code, $vix_vm_host) =
|
||||
VMware::Vix::Simple::HostConnect(
|
||||
VMware::Vix::Simple::VIX_API_VERSION,
|
||||
VMware::Vix::Simple::VIX_SERVICEPROVIDER_VMWARE_SERVER,
|
||||
$hostname, $port, $username, $password,
|
||||
0, VMware::Vix::Simple::VIX_INVALID_HANDLE);
|
||||
if ($err_code != VMware::Vix::Simple::VIX_OK) {
|
||||
$err_str =
|
||||
VMware::Vix::Simple::GetErrorText($err_code);
|
||||
undef $perl_vm;
|
||||
undef $vix_vm;
|
||||
undef $vix_vm_host;
|
||||
return ($err_code);
|
||||
}
|
||||
|
||||
# Power on our guest os if it isn't already running.
|
||||
$err_code = start_guest();
|
||||
if ($err_code != 0) {
|
||||
my $old_err_str = $err_str;
|
||||
$err_str = "Starting guest power after connect " .
|
||||
"failed: " . $old_err_str;
|
||||
undef $perl_vm;
|
||||
undef $vix_vm;
|
||||
undef $vix_vm_host;
|
||||
return ($err_code);
|
||||
}
|
||||
|
||||
# Open VM.
|
||||
($err_code, $vix_vm) =
|
||||
VMware::Vix::Simple::VMOpen($vix_vm_host, $vm_cfg_path);
|
||||
if ($err_code != VMware::Vix::Simple::VIX_OK) {
|
||||
$err_str =
|
||||
VMware::Vix::Simple::GetErrorText($err_code);
|
||||
undef $perl_vm;
|
||||
undef $vix_vm;
|
||||
undef $vix_vm_host;
|
||||
return ($err_code);
|
||||
}
|
||||
|
||||
# Login to $vix_vm guest OS.
|
||||
$err_code = VMware::Vix::Simple::VMLoginInGuest($vix_vm,
|
||||
$guest_admin_username, $guest_admin_password,
|
||||
0);
|
||||
if ($err_code != VMware::Vix::Simple::VIX_OK) {
|
||||
$err_str =
|
||||
VMware::Vix::Simple::GetErrorText($err_code);
|
||||
undef $perl_vm;
|
||||
undef $vix_vm;
|
||||
undef $vix_vm_host;
|
||||
return ($err_code);
|
||||
}
|
||||
return ($err_code);
|
||||
}
|
||||
|
||||
sub host_disconnect {
|
||||
undef $perl_vm;
|
||||
|
||||
$perl_vm = VMware::VmPerl::VM::new();
|
||||
if (!$perl_vm) {
|
||||
$err_code = 1;
|
||||
$err_str = "Error creating new VmPerl object";
|
||||
}
|
||||
|
||||
undef $vix_vm;
|
||||
VMware::Vix::Simple::HostDisconnect($vix_vm_host);
|
||||
VMware::Vix::Simple::ReleaseHandle($vix_vm_host);
|
||||
return ($err_code);
|
||||
}
|
||||
|
||||
sub host_reconnect {
|
||||
$err_code = host_disconnect();
|
||||
if ($err_code != 0) {
|
||||
my $old_err_str = $err_str;
|
||||
$err_str = "Disconnecting from host failed: " .
|
||||
$old_err_str;
|
||||
return ($err_code);
|
||||
}
|
||||
|
||||
$err_code = host_connect(NULL, $hostname, $port, $username,
|
||||
$password, $vm_cfg_path, $guest_admin_username,
|
||||
$guest_admin_password);
|
||||
if ($err_code != 0) {
|
||||
my $old_err_str = $err_str;
|
||||
$err_str = "Re-connecting to host failed: " .
|
||||
$old_err_str;
|
||||
return ($err_code);
|
||||
}
|
||||
return ($err_code);
|
||||
}
|
||||
|
||||
sub create_snapshot {
|
||||
my $snapshot;
|
||||
|
||||
($err_code, $snapshot) =
|
||||
VMware::Vix::Simple::VMCreateSnapshot($vix_vm,
|
||||
"Snapshot", "Created by vm_setup.pl", 0,
|
||||
VMware::Vix::Simple::VIX_INVALID_HANDLE);
|
||||
|
||||
VMware::Vix::Simple::ReleaseHandle($snapshot);
|
||||
|
||||
if ($err_code != VMware::Vix::Simple::VIX_OK) {
|
||||
$err_str =
|
||||
VMware::Vix::Simple::GetErrorText($err_code);
|
||||
return $err_code;
|
||||
}
|
||||
|
||||
$err_code = host_reconnect();
|
||||
if ($err_code != 0) {
|
||||
my $old_err_str = $err_str;
|
||||
$err_str = "Reconnecting to host after creating " .
|
||||
"snapshot: " . $old_err_str;
|
||||
return ($err_code);
|
||||
}
|
||||
return ($err_code);
|
||||
}
|
||||
|
||||
sub revert_snapshot {
|
||||
# Because of problems with VMRevertToSnapshot(), we have to
|
||||
# rely on the guest having set 'Revert to Snapshot' following
|
||||
# a power-off event.
|
||||
$err_code = VMware::Vix::Simple::VMPowerOff($vix_vm, 0);
|
||||
if ($err_code != VMware::Vix::Simple::VIX_OK) {
|
||||
$err_str =
|
||||
VMware::Vix::Simple::GetErrorText($err_code);
|
||||
return $err_code;
|
||||
}
|
||||
|
||||
# host_reconnect() will power-on a guest in a non-running state.
|
||||
$err_code = host_reconnect();
|
||||
if ($err_code != 0) {
|
||||
my $old_err_str = $err_str;
|
||||
$err_str = "Reconnecting to host after reverting " .
|
||||
"snapshot: " . $old_err_str;
|
||||
return ($err_code);
|
||||
}
|
||||
return ($err_code);
|
||||
}
|
||||
|
||||
# $dest_path must exist. It doesn't get created.
|
||||
sub copy_files_to_guest {
|
||||
shift @_;
|
||||
my (%files) = @_;
|
||||
|
||||
my $src_file;
|
||||
my $dest_file;
|
||||
|
||||
foreach $src_file (keys(%files)) {
|
||||
$dest_file = $files{$src_file};
|
||||
$err_code =
|
||||
VMware::Vix::Simple::VMCopyFileFromHostToGuest(
|
||||
$vix_vm, $src_file, $dest_file, 0,
|
||||
VMware::Vix::Simple::VIX_INVALID_HANDLE);
|
||||
if ($err_code != VMware::Vix::Simple::VIX_OK) {
|
||||
$err_str = "Copying $src_file: " .
|
||||
VMware::Vix::Simple::GetErrorText(
|
||||
$err_code);
|
||||
return $err_code;
|
||||
}
|
||||
}
|
||||
return $err_code;
|
||||
}
|
||||
|
||||
sub copy_to_guest {
|
||||
# Read parameters $src_path, $dest_path.
|
||||
shift @_;
|
||||
my ($src_path, $dest_dir) = @_;
|
||||
|
||||
my $len = length($dest_dir);
|
||||
my $idx = rindex($dest_dir, '\\');
|
||||
if ($idx != ($len - 1)) {
|
||||
$err_code = -1;
|
||||
$err_str = "Destination $dest_dir must be a " .
|
||||
"directory path";
|
||||
return ($err_code);
|
||||
}
|
||||
|
||||
# Create the directory $dest_path on the guest VM filesystem.
|
||||
my $cmd = "cmd.exe ";
|
||||
my $cmd_args = "/C MKDIR " . $dest_dir;
|
||||
$err_code = run_on_guest(NULL, $cmd, $cmd_args);
|
||||
if ( $err_code != 0) {
|
||||
my $old_err_str = $err_str;
|
||||
$err_str = "Creating directory $dest_dir on host: " .
|
||||
$old_err_str;
|
||||
return ($err_code);
|
||||
}
|
||||
|
||||
# If $src_filepath specifies a file, create it in $dest_path
|
||||
# and keep the same name.
|
||||
# If $src_path is a directory, create the files it contains in
|
||||
# $dest_path, keeping the same names.
|
||||
$len = length($src_path);
|
||||
my %files;
|
||||
$idx = rindex($src_path, '/');
|
||||
if ($idx == ($len - 1)) {
|
||||
# $src_path is a directory.
|
||||
if (!opendir (DIR_HANDLE, $src_path)) {
|
||||
$err_code = -1;
|
||||
$err_str = "Error opening directory $src_path";
|
||||
return $err_code;
|
||||
}
|
||||
|
||||
foreach $file (readdir DIR_HANDLE) {
|
||||
my $src_file = $src_path . $file;
|
||||
|
||||
if (!opendir(DIR_HANDLE2, $src_file)) {
|
||||
# We aren't interested in subdirs.
|
||||
my $dest_path = $dest_dir . $file;
|
||||
$files{$src_file} = $dest_path;
|
||||
} else {
|
||||
closedir(DIR_HANDLE2);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
# Strip if preceeding path from $src_path.
|
||||
my $src_file = substr($src_path, ($idx + 1), $len);
|
||||
my $dest_path = $dest_dir . $src_file;
|
||||
|
||||
# Add $src_path => $dest_path to %files.
|
||||
$files{$src_path} = $dest_path;
|
||||
}
|
||||
|
||||
$err_code = copy_files_to_guest(NULL, %files);
|
||||
if ($err_code != 0) {
|
||||
my $old_err_str = $err_str;
|
||||
$err_str = "Copying files to host after " .
|
||||
"populating %files: " . $old_err_str;
|
||||
return ($err_code);
|
||||
}
|
||||
return ($err_code);
|
||||
}
|
||||
|
||||
sub run_on_guest {
|
||||
# Read parameters $cmd, $cmd_args.
|
||||
shift @_;
|
||||
my ($cmd, $cmd_args) = @_;
|
||||
|
||||
$err_code = VMware::Vix::Simple::VMRunProgramInGuest($vix_vm,
|
||||
$cmd, $cmd_args, 0,
|
||||
VMware::Vix::Simple::VIX_INVALID_HANDLE);
|
||||
if ($err_code != VMware::Vix::Simple::VIX_OK) {
|
||||
$err_str = VMware::Vix::Simple::GetErrorText(
|
||||
$err_code);
|
||||
return ($err_code);
|
||||
}
|
||||
|
||||
return ($err_code);
|
||||
}
|
||||
|
||||
sub get_guest_ip {
|
||||
my $guest_ip = $perl_vm->get_guest_info('ip');
|
||||
|
||||
if (!defined($guest_ip)) {
|
||||
($err_code, $err_str) = $perl_vm->get_last_error();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!($guest_ip)) {
|
||||
$err_code = 1;
|
||||
$err_str = "Guest did not set the 'ip' variable";
|
||||
return NULL;
|
||||
}
|
||||
return $guest_ip;
|
||||
}
|
||||
|
||||
sub DESTROY {
|
||||
host_disconnect();
|
||||
undef $perl_vm;
|
||||
undef $vix_vm_host;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@@ -0,0 +1,521 @@
|
||||
# A library of commonly used functions written in expect.
|
||||
# Copyright Brad Henry <brad@samba.org> 2006
|
||||
# Released under the GNU GPL v2 or later.
|
||||
|
||||
# This function maps a drive letter to a share point.
|
||||
proc map_share { remote_prompt share_drive sharepoint username domain password } {
|
||||
set default_err_str "Unknown error in function map_share"
|
||||
set err_str $default_err_str
|
||||
|
||||
set cmd "net use $share_drive $sharepoint $password /USER:$username@$domain\r\n"
|
||||
send $cmd
|
||||
|
||||
expect {
|
||||
"The command completed successfully." {
|
||||
expect_prompt $remote_prompt
|
||||
set err_str "OK"
|
||||
} \
|
||||
"The local device name is already in use." {
|
||||
expect_prompt $remote_prompt
|
||||
set err_str "The device name $share_drive is already in use"
|
||||
} \
|
||||
"The network name cannot be found." {
|
||||
expect_prompt $remote_prompt
|
||||
set err_str "Sharepoint $sharepoint could not be found"
|
||||
} \
|
||||
timeout {
|
||||
set err_str "Function map_share timed out while mapping $share_drive to $sharepoint"
|
||||
}
|
||||
}
|
||||
return $err_str
|
||||
}
|
||||
|
||||
# This function unmaps a drive letter from a share point.
|
||||
proc unmap_share { remote_prompt share_drive } {
|
||||
set default_err_str "Unknown error in function unmap_share"
|
||||
set err_str $default_err_str
|
||||
|
||||
set cmd "net use $share_drive /DELETE\r\n"
|
||||
send $cmd
|
||||
|
||||
expect {
|
||||
"was deleted successfully." {
|
||||
expect_prompt $remote_prompt
|
||||
set err_str "OK"
|
||||
} \
|
||||
"NET HELPMSG 2250" {
|
||||
expect_prompt $remote_prompt
|
||||
set err_str "The network connection could not be found while unmapping $share_drive"
|
||||
} \
|
||||
timeout {
|
||||
set err_str "Function unmap_share timed out while unmapping $share_drive"
|
||||
}
|
||||
}
|
||||
return $err_str
|
||||
}
|
||||
|
||||
# This function uses xcopy to copy a text file from one location on the
|
||||
# remote windows host to another.
|
||||
proc xcopy_file { remote_prompt in_filename out_filename xcopy_options } {
|
||||
set default_err_str "Unknown error in function xcopy_file"
|
||||
set err_str $default_err_str
|
||||
|
||||
set cmd "xcopy $in_filename $out_filename $xcopy_options\r\n"
|
||||
send $cmd
|
||||
|
||||
expect {
|
||||
"(F = file, D = directory)? " {
|
||||
set cmd "F\r\n"
|
||||
send $cmd
|
||||
expect {
|
||||
"1 File(s) copied\r\n\r\n" {
|
||||
expect_prompt $remote_prompt
|
||||
set err_str "OK"
|
||||
} \
|
||||
"0 File(s) copied\r\n\r\n" {
|
||||
expect_prompt $remote_prompt
|
||||
set err_str $default_err_str
|
||||
} \
|
||||
timeout {
|
||||
set err_str "Function xcopy_file has timed out while copying $in_filename"
|
||||
}
|
||||
}
|
||||
} \
|
||||
"1 File(s) copied\r\n\r\n" {
|
||||
expect_prompt $remote_prompt
|
||||
set err_str "OK"
|
||||
} \
|
||||
"0 File(s) copied\r\n\r\n" {
|
||||
expect_prompt $remote_prompt
|
||||
set err_str $default_err_str
|
||||
} \
|
||||
timeout {
|
||||
set err_str "Function xcopy_file timed out while copying $in_filename"
|
||||
}
|
||||
}
|
||||
return $err_str
|
||||
}
|
||||
|
||||
# This function creates a temporary file on the remote windows host.
|
||||
# The file contents are populated by a recursive directory listing of
|
||||
# the windows %HOMEDRIVE%.
|
||||
proc create_tmp_file { remote_prompt filename } {
|
||||
set default_err_str "Unknown error in function create_tmp_file"
|
||||
set err_str $default_err_str
|
||||
|
||||
set cmd "dir %HOMEDRIVE%\\ /S > $filename\r\n"
|
||||
send $cmd
|
||||
expect {
|
||||
$remote_prompt {
|
||||
set err_str "OK"
|
||||
} \
|
||||
timeout {
|
||||
set err_str "Function create_tmp_file timed out while creating $filename"
|
||||
}
|
||||
}
|
||||
return $err_str
|
||||
}
|
||||
|
||||
# This function compares two files on the remote windows host.
|
||||
proc compare_files { remote_prompt file1 file2 } {
|
||||
set default_err_str "Unknown error in function compare_files"
|
||||
set err_str $default_err_str
|
||||
|
||||
set cmd "fc $file1 $file2\r\n"
|
||||
send $cmd
|
||||
expect {
|
||||
"FC: no differences encountered\r\n\r\n\r\n" {
|
||||
expect_prompt $remote_prompt
|
||||
set err_str "OK"
|
||||
} \
|
||||
"\*\*\*\*\* $file1" {
|
||||
expect_prompt $remote_prompt
|
||||
set err_str "Files $file1 and $file2 differ"
|
||||
} \
|
||||
"\*\*\*\*\* $file2" {
|
||||
expect_prompt $remote_prompt
|
||||
set err_str "Files $file1 and $file2 differ"
|
||||
} \
|
||||
timeout {
|
||||
set err_str "Function compare_files timed out while comparing files $file1 and $file2"
|
||||
}
|
||||
}
|
||||
return $err_str
|
||||
}
|
||||
|
||||
# This function deletes a file on the remote windows host.
|
||||
proc delete_file { remote_prompt filename } {
|
||||
set default_err_str "Unknown error in function delete_file"
|
||||
set err_str $default_err_str
|
||||
|
||||
set cmd "del $filename\r\n"
|
||||
send $cmd
|
||||
expect {
|
||||
"Could Not" {
|
||||
expect_prompt $remote_prompt
|
||||
set err_str $default_err_str
|
||||
} \
|
||||
$remote_prompt {
|
||||
set err_str "OK"
|
||||
} \
|
||||
timeout {
|
||||
set err_str "Function delete_file timed oout while deleting $filename"
|
||||
}
|
||||
}
|
||||
return $err_str
|
||||
}
|
||||
|
||||
# This function copies a text file over telnet from the local unix host
|
||||
# to the remote windows host.
|
||||
proc copy_file { remote_prompt in_filename out_filename } {
|
||||
set default_err_str "Unknown error in function copy_file"
|
||||
set err_str $default_err_str
|
||||
|
||||
# The octal ASCII code for Control-Z is 032.
|
||||
set CTRLZ \032
|
||||
|
||||
# Open local file and read contents.
|
||||
set in_file [open $in_filename r]
|
||||
set in_data [read $in_file]
|
||||
|
||||
# Initiate copy on remote host.
|
||||
set cmd "copy con $out_filename\r\n"
|
||||
send $cmd
|
||||
|
||||
# Separate $in_data into lines and send to remote host.
|
||||
set out_data [split $in_data "\n"]
|
||||
foreach out_line $out_data {
|
||||
send $out_line
|
||||
# We might as well do a unix -> windows line conversion.
|
||||
send "\r\n"
|
||||
# Are we overwriting an existing file?
|
||||
# If so, exit so we can handle it.
|
||||
expect {
|
||||
"(Yes/No/All)" {
|
||||
send "NO\r\n"
|
||||
expect_prompt $remote_prompt
|
||||
set err_str "File exists"
|
||||
} \
|
||||
$out_line {
|
||||
set err_str "OK"
|
||||
} \
|
||||
timeout {
|
||||
set err_str "Function copy_file timed out while copying $in_filename"
|
||||
}
|
||||
}
|
||||
if { $err_str != "OK" } {
|
||||
return $err_str
|
||||
} else {
|
||||
set err_str $default_err_str
|
||||
}
|
||||
}
|
||||
|
||||
# ^Z\r to complete the transfer.
|
||||
send $CTRLZ
|
||||
send "\r"
|
||||
expect {
|
||||
"file(s) copied." {
|
||||
set err_str [expect_prompt $remote_prompt]
|
||||
} \
|
||||
$remote_prompt {
|
||||
set err_str $default_err_str
|
||||
} \
|
||||
timeout {
|
||||
expect_prompt $remote_prompt
|
||||
set err_str "Function copy_file timed out while finishing copy of $in_filename"
|
||||
}
|
||||
}
|
||||
return $err_str
|
||||
}
|
||||
|
||||
# This function waits for the command prompt and reports an error on
|
||||
# timeout.
|
||||
proc expect_prompt { remote_prompt } {
|
||||
set default_err_str "Unknown error occurred while waiting for the command prompt"
|
||||
set err_str $default_err_str
|
||||
|
||||
expect {
|
||||
$remote_prompt {
|
||||
set err_str "OK"
|
||||
} \
|
||||
timeout {
|
||||
set err_str "Timeout occurred while waiting for the command prompt"
|
||||
}
|
||||
}
|
||||
return $err_str
|
||||
}
|
||||
|
||||
# This function will create a telnet login shell to $remote_host as $username.
|
||||
# If expected dialogue is not recieved, return with a specific error if one
|
||||
# is recognized. Otherwise return a generic error indicating the function
|
||||
# name.
|
||||
proc telnet_login { remote_prompt remote_host username password } {
|
||||
|
||||
set default_err_str "Unknown error in function telnet_login"
|
||||
set err_str $default_err_str
|
||||
|
||||
set cmd "telnet $remote_host\r"
|
||||
send $cmd
|
||||
expect {
|
||||
"login: " {
|
||||
set err_str "OK"
|
||||
} \
|
||||
"Connection refused" {
|
||||
set err_str "Connection refused"
|
||||
} \
|
||||
"No route to host" {
|
||||
set err_str "No route to host"
|
||||
} \
|
||||
timeout {
|
||||
set err_str "Function telnet_login timed out while waiting for the login prompt"
|
||||
}
|
||||
}
|
||||
if { $err_str != "OK" } {
|
||||
# Return because something unexpected happened.
|
||||
return $err_str
|
||||
} else {
|
||||
# Reset err_str
|
||||
set err_str $default_err_str
|
||||
}
|
||||
|
||||
set cmd "$username\r"
|
||||
send $cmd
|
||||
expect {
|
||||
"password: " {
|
||||
set err_str "OK"
|
||||
} \
|
||||
timeout {
|
||||
set err_str "Function telnet_login timed out while waiting for the password prompt"
|
||||
}
|
||||
}
|
||||
if { $err_str != "OK" } {
|
||||
return $err_str
|
||||
} else {
|
||||
set err_str $default_err_str
|
||||
}
|
||||
|
||||
set cmd "$password\r"
|
||||
send $cmd
|
||||
expect {
|
||||
$remote_prompt {
|
||||
set err_str "OK"
|
||||
} \
|
||||
"Login Failed" {
|
||||
set err_str "Telnet login failed"
|
||||
} \
|
||||
timeout {
|
||||
set err_str "Function telnet_login timed out while waiting for the command prompt"
|
||||
}
|
||||
}
|
||||
return $err_str
|
||||
}
|
||||
|
||||
proc create_directory { remote_prompt sharepath } {
|
||||
|
||||
set default_err_str "Unknown error in function create_directory"
|
||||
set err_str $default_err_str
|
||||
|
||||
set cmd "mkdir $sharepath\r\n"
|
||||
send $cmd
|
||||
expect {
|
||||
"already exists" {
|
||||
expect_prompt $remote_prompt
|
||||
set err_str "Directory already exists"
|
||||
} \
|
||||
$remote_prompt {
|
||||
set err_str "OK"
|
||||
} \
|
||||
timeout {
|
||||
expect_prompt $remote_prompt
|
||||
set err_str "Timeout reached starting create_directory."
|
||||
}
|
||||
}
|
||||
return $err_str
|
||||
}
|
||||
|
||||
proc delete_directory { remote_prompt sharepath } {
|
||||
|
||||
set default_err_str "Unknown error in function delete_directory"
|
||||
set err_str $default_err_str
|
||||
|
||||
set cmd "rmdir /S /Q $sharepath\r\n"
|
||||
send $cmd
|
||||
expect {
|
||||
"Access is denied." {
|
||||
expect_prompt $remote_prompt
|
||||
set err_str "Directory access is denied"
|
||||
} \
|
||||
$remote_prompt {
|
||||
set err_str "OK"
|
||||
} \
|
||||
timeout {
|
||||
expect_prompt $remote_prompt
|
||||
set err_str "Timeout reached in delete_directory"
|
||||
}
|
||||
}
|
||||
return $err_str
|
||||
}
|
||||
|
||||
proc create_share { remote_prompt username sharepath sharename } {
|
||||
|
||||
set default_err_str "Unknown error in function create_share"
|
||||
set err_str $default_err_str
|
||||
|
||||
set cmd "net share $sharename=$sharepath /GRANT:$username,FULL\r\n"
|
||||
send $cmd
|
||||
expect {
|
||||
"was shared successfully." {
|
||||
set err_str [expect_prompt $remote_prompt]
|
||||
} \
|
||||
"NET HELPMSG 2118." {
|
||||
expect_prompt $remote_prompt
|
||||
set err_str "The name has already been shared"
|
||||
} \
|
||||
$remote_prompt {
|
||||
set err_str $default_err_str
|
||||
} \
|
||||
timeout {
|
||||
expect_prompt $remote_prompt
|
||||
set err_str "Timeout reached in create_share"
|
||||
}
|
||||
}
|
||||
return $err_str
|
||||
}
|
||||
|
||||
proc delete_share { remote_prompt sharename } {
|
||||
|
||||
set default_err_str "Unknown error in function delete_share"
|
||||
set err_str $default_err_str
|
||||
|
||||
set cmd "net share $sharename /DELETE\r\n"
|
||||
send $cmd
|
||||
expect {
|
||||
"was deleted successfully." {
|
||||
set err_str [expect_prompt $remote_prompt]
|
||||
} \
|
||||
"does not exist." {
|
||||
expect_prompt $remote_prompt
|
||||
set err_str "The share does not exist"
|
||||
} \
|
||||
$remote_prompt {
|
||||
set err_str $default_err_str
|
||||
} \
|
||||
timeout {
|
||||
expect_prompt $remote_prompt
|
||||
set err_str "Timeout reached in delete_share"
|
||||
}
|
||||
}
|
||||
return $err_str
|
||||
}
|
||||
|
||||
proc delete_hosts_entry { remote_prompt hosts_file_path backup_hosts_filename } {
|
||||
|
||||
set default_err_str "Unknown error in function delete_hosts_entry"
|
||||
set err_str $default_err_str
|
||||
|
||||
set cmd "cd $hosts_file_path\r\n"
|
||||
send $cmd
|
||||
expect {
|
||||
"." {
|
||||
expect_prompt $remote_prompt
|
||||
set err_str $default_err_str
|
||||
} \
|
||||
$remote_prompt {
|
||||
set err_str "OK"
|
||||
} \
|
||||
timeout {
|
||||
expect_prompt $remote_prompt
|
||||
set err_str "Timeout reached in delete_hosts_entry"
|
||||
}
|
||||
}
|
||||
if { $err_str != "OK" } {
|
||||
return $err_str
|
||||
} else {
|
||||
set err_str $default_err_str
|
||||
}
|
||||
|
||||
set cmd "move /Y $backup_hosts_filename hosts\r\n"
|
||||
send $cmd
|
||||
expect {
|
||||
"1 file(s) moved." {
|
||||
set err_str [expect_prompt $remote_prompt]
|
||||
} \
|
||||
"cannot find the file specified." {
|
||||
expect_prompt $remote_prompt
|
||||
set err_str "File not found"
|
||||
} \
|
||||
$remote_prompt {
|
||||
set err_str $default_err_str
|
||||
} \
|
||||
timeout {
|
||||
expect_prompt $remote_prompt
|
||||
set err_str "Function delete_hosts_entry timed out while renaming $backup_hosts_filename"
|
||||
}
|
||||
}
|
||||
return $err_str
|
||||
}
|
||||
|
||||
proc create_hosts_entry { remote_prompt hosts_file_path hostname ip \
|
||||
backup_hosts_filename } {
|
||||
|
||||
set default_err_str "Unknown error in function create_hosts_entry"
|
||||
set err_str $default_err_str
|
||||
|
||||
set cmd "cd $hosts_file_path\r\n"
|
||||
send $cmd
|
||||
expect {
|
||||
"." {
|
||||
expect_prompt $remote_prompt
|
||||
set err_str $default_err_str
|
||||
} \
|
||||
$remote_prompt {
|
||||
set err_str "OK"
|
||||
} \
|
||||
timeout {
|
||||
expect_prompt $remote_prompt
|
||||
set err_str "Timeout reached in create_hosts_entry"
|
||||
}
|
||||
}
|
||||
if { $err_str != "OK" } {
|
||||
return $err_str
|
||||
} else {
|
||||
set err_str $default_err_str
|
||||
}
|
||||
|
||||
set cmd "copy /Y hosts $backup_hosts_filename\r\n"
|
||||
send $cmd
|
||||
expect {
|
||||
"1 file(s) copied." {
|
||||
set err_str [expect_prompt $remote_prompt]
|
||||
} \
|
||||
"cannot find the file specified." {
|
||||
expect_prompt $remote_prompt
|
||||
set err_str "File not found."
|
||||
} \
|
||||
$remote_prompt {
|
||||
set err_str $default_err_str
|
||||
} \
|
||||
timeout {
|
||||
expect_prompt $remote_prompt
|
||||
set err_str "Function create_hosts_entry timed out while copying hosts file"
|
||||
}
|
||||
}
|
||||
if { $err_str != "OK" } {
|
||||
return $err_str
|
||||
} else {
|
||||
set err_str $default_err_str
|
||||
}
|
||||
|
||||
set cmd "echo $ip $hostname #smbtorture host. >> hosts\r\n"
|
||||
send $cmd
|
||||
expect {
|
||||
$remote_prompt {
|
||||
set err_str "OK"
|
||||
} \
|
||||
timeout {
|
||||
expect_prompt $remote_prompt
|
||||
set err_str "Function create_hosts timed out while updating hosts file"
|
||||
}
|
||||
}
|
||||
return $err_str
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
|
||||
# perl needs to know to look in $WINTEST_DIR for VMHost.pm.
|
||||
export PERLLIB=$WINTEST_DIR
|
||||
|
||||
# Command prompt that we are expecting on the windows host.
|
||||
export SMBTORTURE_REMOTE_PROMPT=">"
|
||||
|
||||
# The username and password we will be testing with.
|
||||
# This user will need admin rights on the remote windows host.
|
||||
export SMBTORTURE_USERNAME="tortureuser"
|
||||
export SMBTORTURE_PASSWORD="torturepass"
|
||||
|
||||
# The name of the workgroup we will be using on the remote windows host.
|
||||
export SMBTORTURE_WORKGROUP="SMBTEST"
|
||||
|
||||
# The name of and path to the windows share we'll be testing against.
|
||||
export SMBTORTURE_REMOTE_SHARE_NAME="smbtorture_share"
|
||||
export SMBTORTURE_REMOTE_SHARE_PATH="%HOMEDRIVE%\smbtorture_shared_dir"
|
||||
|
||||
# Default timeout for the expect scripts to wait for a response from the remote.
|
||||
export SMBTORTURE_EXPECT_TIMEOUT=30
|
||||
|
||||
# Path to the local smbtorture binary.
|
||||
export SMBTORTURE_BIN_PATH="bin/smbtorture"
|
||||
|
||||
# Local system hostname and ip address we'll be adding to the remote's
|
||||
# hosts file.
|
||||
export SMBTORTURE_LOCAL_HOSTNAME=$NETBIOSNAME
|
||||
export SMBTORTURE_LOCAL_IP="192.168.100.12"
|
||||
|
||||
# Filename of the windows hosts' unedited hosts file.
|
||||
export REMOTE_BACKUP_HOSTS_FILENAME="hosts.smbtorture"
|
||||
export REMOTE_HOSTS_FILE_PATH="%SYSTEMROOT%\\system32\\drivers\\etc"
|
||||
|
||||
# These coincide with the parameters mktestsetup.sh uses to setup smbd.
|
||||
export SMBTORTURE_LOCAL_USERNAME="administrator"
|
||||
export SMBTORTURE_LOCAL_PASSWORD="penguin"
|
||||
export SMBTORTURE_LOCAL_DOMAIN="SAMBADOMAIN"
|
||||
|
||||
# This is the name of the samba share the windows vm will connect to.
|
||||
export SMBTORTURE_LOCAL_SHARE_NAME="TMP"
|
||||
|
||||
# This is the drive letter which will be used to mount a share on the windows vm.
|
||||
export SMBTORTURE_REMOTE_DRIVE_LETTER="X:"
|
||||
|
||||
# This is the name of the file which will be created on the windows vm
|
||||
# and used for samba server tests.
|
||||
export SMBTORTURE_TMP_FILENAME="smbtorture.tmp"
|
||||
|
||||
# The path to the vmware image config file local to the vmware server.
|
||||
export VM_CFG_PATH="/var/lib/vmware/Virtual Machines/Win2k3-BuildFarm/Win2k3-BuildFarm.vmx"
|
||||
|
||||
# In order to copy files and execute programs on the guest vm,
|
||||
# we need administrator-level credentials to log in with.
|
||||
export GUEST_ADMIN_USERNAME="administrator"
|
||||
export GUEST_ADMIN_PASSWORD="adminpass"
|
||||
|
||||
# These parameters are optional. If not specified, the script tries to access
|
||||
# a local vmware server as the executing user.
|
||||
# logged-in user running the script are used.
|
||||
export HOST_SERVER_NAME="vmhost"
|
||||
export HOST_SERVER_PORT=902
|
||||
export HOST_USERNAME="vmuser"
|
||||
export HOST_PASSWORD="vmpass"
|
||||
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
# A perl script to connect to a VMware server and get the IP address of a VM.
|
||||
# Copyright Brad Henry <brad@samba.org> 2006
|
||||
# Released under the GNU GPL v2 or later.
|
||||
|
||||
use VMHost;
|
||||
|
||||
sub check_error {
|
||||
my $vm = VMHost;
|
||||
my $custom_err_str = "";
|
||||
($vm, $custom_err_str) = @_;
|
||||
|
||||
my ($err_code, $err_str) = $vm->error;
|
||||
if ($err_code != 0) {
|
||||
undef $vm;
|
||||
die $custom_err_str . "Returned $err_code: $err_str.\n";
|
||||
}
|
||||
}
|
||||
|
||||
# Read in parameters from environment.
|
||||
my $vm_cfg_path = $ENV{'VM_CFG_PATH'};
|
||||
my $host_server_name = $ENV{'HOST_SERVER_NAME'};
|
||||
my $host_server_port = $ENV{'HOST_SERVER_PORT'};
|
||||
if (!defined($host_server_port)) {
|
||||
$host_server_port = 902;
|
||||
}
|
||||
|
||||
my $host_username = $ENV{'HOST_USERNAME'};
|
||||
my $host_password = $ENV{'HOST_PASSWORD'};
|
||||
my $guest_admin_username = $ENV{'GUEST_ADMIN_USERNAME'};
|
||||
my $guest_admin_password = $ENV{'GUEST_ADMIN_PASSWORD'};
|
||||
|
||||
my $vm = VMHost;
|
||||
|
||||
$vm->host_connect($host_server_name, $host_server_port, $host_username,
|
||||
$host_password, $vm_cfg_path, $guest_admin_username,
|
||||
$guest_admin_password);
|
||||
check_error($vm, "Error in \$vm->host_connect().\n");
|
||||
|
||||
my $guest_ip = $vm->get_guest_ip();
|
||||
check_error($vm, "Error in \$vm->get_guest_ip().\n");
|
||||
|
||||
print $guest_ip;
|
||||
|
||||
undef $vm;
|
||||
|
||||
exit 0;
|
||||
@@ -0,0 +1,46 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
# A perl script to connect to a VMware server and revert a VM snapshot.
|
||||
# Copyright Brad Henry <brad@samba.org> 2006
|
||||
# Released under the GNU GPL v2 or later.
|
||||
|
||||
use VMHost;
|
||||
|
||||
sub check_error {
|
||||
my $vm = VMHost;
|
||||
my $custom_err_str = "";
|
||||
($vm, $custom_err_str) = @_;
|
||||
|
||||
my ($err_code, $err_str) = $vm->error;
|
||||
if ($err_code != 0) {
|
||||
undef $vm;
|
||||
die $custom_err_str . "Returned $err_code: $err_str.\n";
|
||||
}
|
||||
}
|
||||
|
||||
# Read in parameters from environment.
|
||||
my $vm_cfg_path = $ENV{'VM_CFG_PATH'};
|
||||
my $host_server_name = $ENV{'HOST_SERVER_NAME'};
|
||||
my $host_server_port = $ENV{'HOST_SERVER_PORT'};
|
||||
if (!defined($host_server_port)) {
|
||||
$host_server_port = 902;
|
||||
}
|
||||
|
||||
my $host_username = $ENV{'HOST_USERNAME'};
|
||||
my $host_password = $ENV{'HOST_PASSWORD'};
|
||||
my $guest_admin_username = $ENV{'GUEST_ADMIN_USERNAME'};
|
||||
my $guest_admin_password = $ENV{'GUEST_ADMIN_PASSWORD'};
|
||||
|
||||
my $vm = VMHost;
|
||||
|
||||
$vm->host_connect($host_server_name, $host_server_port, $host_username,
|
||||
$host_password, $vm_cfg_path, $guest_admin_username,
|
||||
$guest_admin_password);
|
||||
check_error($vm, "Error in \$vm->host_connect().\n");
|
||||
|
||||
$vm->revert_snapshot();
|
||||
check_error($vm, "Error in \$vm->revert_snapshot().\n");
|
||||
|
||||
undef $vm;
|
||||
|
||||
exit 0;
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
#!/bin/sh
|
||||
|
||||
. script/tests/test_functions.sh
|
||||
|
||||
. script/tests/win/wintest_functions.sh
|
||||
|
||||
# This variable is defined in the per-hosts .fns file.
|
||||
. $WINTESTCONF
|
||||
|
||||
if [ $# -lt 4 ]; then
|
||||
cat <<EOF
|
||||
Usage: test_net.sh SERVER USERNAME PASSWORD DOMAIN
|
||||
EOF
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
server="$1"
|
||||
username="$2"
|
||||
password="$3"
|
||||
domain="$4"
|
||||
shift 4
|
||||
|
||||
base_tests="BASE-UNLINK BASE-ATTR BASE-DELETE BASE-TCON BASE-OPEN BASE-CHKPATH"
|
||||
|
||||
all_errs=0
|
||||
|
||||
for t in $base_tests; do
|
||||
test_name="$t / WINDOWS SERVER"
|
||||
echo -e "\n$test_name SETUP PHASE"
|
||||
|
||||
setup_share_test
|
||||
|
||||
if [ $err_rtn -ne 0 ]; then
|
||||
# If test setup fails, load VM snapshot and skip test.
|
||||
restore_snapshot "\n$test_name setup failed, skipping test."
|
||||
else
|
||||
echo -e "\n$test_name setup completed successfully."
|
||||
old_errs=$all_errs
|
||||
|
||||
testit "$test_name" $SMBTORTURE_BIN_PATH \
|
||||
-U $username%$password \
|
||||
-W $domain //$server/$SMBTORTURE_REMOTE_SHARE_NAME \
|
||||
$t || all_errs=`expr $all_errs + 1`
|
||||
if [ $old_errs -lt $all_errs ]; then
|
||||
restore_snapshot "\n$test_name failed."
|
||||
else
|
||||
echo -e "\n$test_name CLEANUP PHASE"
|
||||
remove_share_test
|
||||
if [ $err_rtn -ne 0 ]; then
|
||||
# If cleanup fails, restore VM snapshot.
|
||||
restore_snapshot "\n$test_name removal failed."
|
||||
else
|
||||
echo -e "\n$test_name removal completed successfully."
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
testok $0 $all_errs
|
||||
@@ -0,0 +1,95 @@
|
||||
# An expect script to create a temporary file, map a share, copy the file to the share,
|
||||
# and compare the contents of the two files.
|
||||
# Copyright Brad Henry <brad@samba.org> 2006
|
||||
# Released under the GNU GPL v2 or later.
|
||||
|
||||
proc run_test { remote_prompt tmp_filename share_drive host_drive buildhost_ip buildhost_share username domain password } {
|
||||
|
||||
# Create the temp file on the windows host and connect to the samba share.
|
||||
set host_tmpfile "$host_drive\\$tmp_filename"
|
||||
set err_str [create_tmp_file $remote_prompt $host_tmpfile]
|
||||
if { $err_str != "OK" } {
|
||||
return $err_str
|
||||
}
|
||||
|
||||
set buildhost_sharepoint "\\\\$buildhost_ip\\$buildhost_share"
|
||||
set err_str [map_share $remote_prompt $share_drive $buildhost_sharepoint $username $domain $password]
|
||||
if { $err_str != "OK" } {
|
||||
return $err_str
|
||||
}
|
||||
|
||||
# Copy the temp file to the share and compare its contents with the original.
|
||||
set share_tmpfile "$share_drive\\$tmp_filename"
|
||||
set xcopy_options ""
|
||||
set err_str [xcopy_file $remote_prompt $host_tmpfile $share_tmpfile $xcopy_options]
|
||||
if { $err_str != "OK" } {
|
||||
return $err_str
|
||||
}
|
||||
|
||||
set err_str [compare_files $remote_prompt $host_tmpfile $share_tmpfile]
|
||||
if { $err_str != "OK" } {
|
||||
return $err_str
|
||||
}
|
||||
|
||||
# Remove files and unmap share.
|
||||
set err_str [delete_file $remote_prompt $share_tmpfile]
|
||||
if { $err_str != "OK" } {
|
||||
return $err_str
|
||||
}
|
||||
set err_str [delete_file $remote_prompt $host_tmpfile]
|
||||
if { $err_str != "OK" } {
|
||||
return $err_str
|
||||
}
|
||||
|
||||
set err_str [unmap_share $remote_prompt $share_drive]
|
||||
if {$err_str != "OK" } {
|
||||
return $err_str
|
||||
}
|
||||
|
||||
return $err_str
|
||||
}
|
||||
|
||||
# Read parameters.
|
||||
set remote_prompt $env(SMBTORTURE_REMOTE_PROMPT)
|
||||
set remote_host $env(SMBTORTURE_REMOTE_HOST)
|
||||
set username $env(SMBTORTURE_USERNAME)
|
||||
set password $env(SMBTORTURE_PASSWORD)
|
||||
set timeout $env(SMBTORTURE_EXPECT_TIMEOUT)
|
||||
|
||||
set tmp_filename $env(SMBTORTURE_TMP_FILENAME)
|
||||
|
||||
set share_drive $env(SMBTORTURE_REMOTE_DRIVE_LETTER)
|
||||
set host_drive "%HOMEDRIVE%"
|
||||
|
||||
set buildhost_ip $env(SMBTORTURE_LOCAL_IP)
|
||||
set buildhost_share $env(SMBTORTURE_LOCAL_SHARE_NAME)
|
||||
set buildhost_username $env(SMBTORTURE_LOCAL_USERNAME)
|
||||
set buildhost_domain $env(SMBTORTURE_LOCAL_DOMAIN)
|
||||
set buildhost_password $env(SMBTORTURE_LOCAL_PASSWORD)
|
||||
|
||||
set err_val [spawn $env(SHELL)]
|
||||
if {$err_val == 0} {
|
||||
puts stderr "Expect failed while spawning a shell process."
|
||||
exit $err_val
|
||||
}
|
||||
|
||||
set err_str [telnet_login $remote_prompt $remote_host $username $password]
|
||||
if {$err_str != "OK"} {
|
||||
puts stderr "\nFunction telnet_login failed during Samba server testing."
|
||||
puts stderr "Error was: $err_str."
|
||||
exit 1
|
||||
}
|
||||
|
||||
set err_str [run_test $remote_prompt $tmp_filename $share_drive $host_drive $buildhost_ip $buildhost_share $buildhost_username $buildhost_domain $buildhost_password]
|
||||
if {$err_str != "OK"} {
|
||||
puts stderr "\nFunction run_test failed during Samba server testing."
|
||||
puts stderr "Error was: $err_str."
|
||||
|
||||
# Log off from the telnet server.
|
||||
send "exit\r\n"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Log off from the telnet server.
|
||||
send "exit\r\n"
|
||||
exit 0
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
#!/bin/sh
|
||||
|
||||
. script/tests/test_functions.sh
|
||||
|
||||
. script/tests/win/wintest_functions.sh
|
||||
|
||||
# This variable is defined in the per-hosts .fns file.
|
||||
. $WINTESTCONF
|
||||
|
||||
test_name="WINDOWS CLIENT / SAMBA SERVER SHARE"
|
||||
|
||||
cat $WINTEST_DIR/common.exp > $TMPDIR/client_test.exp
|
||||
cat $WINTEST_DIR/wintest_client.exp >> $TMPDIR/client_test.exp
|
||||
|
||||
testit "$test_name" \
|
||||
expect $TMPDIR/client_test.exp || all_errs=`expr $all_errs + 1`
|
||||
|
||||
if [ $all_errs > 0 ]; then
|
||||
# Restore snapshot to ensure VM is in a known state.
|
||||
restore_snapshot "\n$test_name failed."
|
||||
echo "Snapshot restored."
|
||||
fi
|
||||
|
||||
rm -f $TMPDIR/client_test.exp
|
||||
|
||||
testok $0 $all_errs
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Setup the windows environment.
|
||||
# This was the best way I could figure out including library files
|
||||
# for the moment.
|
||||
# I was finding that "cat common.exp wintest_setup.exp | expect -f -"
|
||||
# fails to run, but exits with 0 status something like 1% of the time.
|
||||
|
||||
setup_share_test()
|
||||
{
|
||||
echo -e "\nSetting up windows environment."
|
||||
cat $WINTEST_DIR/common.exp > $TMPDIR/setup.exp
|
||||
cat $WINTEST_DIR/wintest_setup.exp >> $TMPDIR/setup.exp
|
||||
expect $TMPDIR/setup.exp
|
||||
err_rtn=$?
|
||||
rm -f $TMPDIR/setup.exp
|
||||
}
|
||||
|
||||
# Clean up the windows environment after the test has run or failed.
|
||||
remove_share_test()
|
||||
{
|
||||
echo -e "\nCleaning up windows environment."
|
||||
cat $WINTEST_DIR/common.exp > $TMPDIR/remove.exp
|
||||
cat $WINTEST_DIR/wintest_remove.exp >> $TMPDIR/remove.exp
|
||||
expect $TMPDIR/remove.exp
|
||||
err_rtn=$?
|
||||
rm -f $TMPDIR/remove.exp
|
||||
}
|
||||
|
||||
restore_snapshot()
|
||||
{
|
||||
echo -e $1
|
||||
vmrun revertToSnapshot "$VM_CFG_PATH"
|
||||
echo "Snapshot restored."
|
||||
}
|
||||
Executable
+60
@@ -0,0 +1,60 @@
|
||||
#!/bin/sh
|
||||
|
||||
. script/tests/test_functions.sh
|
||||
|
||||
. script/tests/win/wintest_functions.sh
|
||||
|
||||
# This variable is defined in the per-hosts .fns file.
|
||||
. $WINTESTCONF
|
||||
|
||||
if [ $# -lt 4 ]; then
|
||||
cat <<EOF
|
||||
Usage: test_net.sh SERVER USERNAME PASSWORD DOMAIN
|
||||
EOF
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
server="$1"
|
||||
username="$2"
|
||||
password="$3"
|
||||
domain="$4"
|
||||
shift 4
|
||||
|
||||
ncacn_np_tests="NET-API-LOOKUP NET-API-LOOKUPHOST NET-API-RPCCONN-BIND NET-API-RPCCONN-SRV NET-API-RPCCONN-DC NET-API-RPCCONN-DCINFO NET-API-LISTSHARES"
|
||||
#These tests fail on ncacn_np: NET-API-LOOKUPPDC NET-API-CREATEUSER NET-API-DELETEUSER
|
||||
|
||||
ncalrpc_tests="NET-API-RPCCONN-SRV NET-API-RPCCONN-DC NET-API-RPCCONN-DCINFO NET-API-LISTSHARES"
|
||||
#These tests fail on ncalrpc: NET-API-CREATEUSER NET-API-DELETEUSER
|
||||
|
||||
ncacn_ip_tcp_tests="NET-API-LOOKUP NET-API-LOOKUPHOST NET-API-RPCCONN-SRV NET-API-RPCCONN-DC NET-API-RPCCONN-DCINFO NET-API-LISTSHARES"
|
||||
#These tests fail on ncacn_ip_tcp: NET-API-LOOKUPPDC NET-API-CREATEUSER NET-API-DELETEUSER
|
||||
|
||||
bind_options="seal,padcheck bigendian"
|
||||
|
||||
test_type="ncalrpc ncacn_np ncacn_ip_tcp"
|
||||
|
||||
all_errs=0
|
||||
for o in $bind_options; do
|
||||
for transport in $test_type; do
|
||||
case $transport in
|
||||
ncalrpc) net_test=$ncalrpc_tests ;;
|
||||
ncacn_np) net_test=$ncacn_np_tests ;;
|
||||
ncacn_ip_tcp) net_test=$ncacn_ip_tcp_tests ;;
|
||||
esac
|
||||
|
||||
for t in $net_test; do
|
||||
test_name="$t on $transport with $o"
|
||||
old_errs=$all_errs
|
||||
testit "$test_name" $SMBTORTURE_BIN_PATH \
|
||||
-U $username%$password \
|
||||
-W $domain \
|
||||
$transport:$server[$o] \
|
||||
$t || all_errs=`expr $all_errs + 1`
|
||||
if [ $old_errs -lt $all_errs ]; then
|
||||
restore_snapshot "\n$test_name failed."
|
||||
fi
|
||||
done
|
||||
done
|
||||
done
|
||||
|
||||
testok $0 $all_errs
|
||||
Executable
+60
@@ -0,0 +1,60 @@
|
||||
#!/bin/sh
|
||||
|
||||
. script/tests/test_functions.sh
|
||||
|
||||
. script/tests/win/wintest_functions.sh
|
||||
|
||||
# This variable is defined in the per-hosts .fns file.
|
||||
. $WINTESTCONF
|
||||
|
||||
if [ $# -lt 4 ]; then
|
||||
cat <<EOF
|
||||
Usage: test_net.sh SERVER USERNAME PASSWORD DOMAIN
|
||||
EOF
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
server="$1"
|
||||
username="$2"
|
||||
password="$3"
|
||||
domain="$4"
|
||||
shift 4
|
||||
|
||||
raw_tests="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"
|
||||
# This test fails: RAW-QFSINFO
|
||||
|
||||
all_errs=0
|
||||
|
||||
for t in $raw_tests; do
|
||||
test_name="$t / WINDOWS SERVER"
|
||||
echo -e "\n$test_name SETUP PHASE"
|
||||
|
||||
setup_share_test
|
||||
|
||||
if [ $err_rtn -ne 0 ]; then
|
||||
# If test setup fails, load VM snapshot and skip test.
|
||||
restore_snapshot "\n$test_name setup failed, skipping test."
|
||||
else
|
||||
echo -e "\n$test_name setup completed successfully."
|
||||
old_errs=$all_errs
|
||||
|
||||
testit "$test_name" $SMBTORTURE_BIN_PATH \
|
||||
-U $username%$password \
|
||||
-W $domain //$server/$SMBTORTURE_REMOTE_SHARE_NAME \
|
||||
$t || all_errs=`expr $all_errs + 1`
|
||||
if [ $old_errs -lt $all_errs ]; then
|
||||
restore_snapshot "\n$test_name failed."
|
||||
else
|
||||
echo -e "\n$test_name CLEANUP PHASE"
|
||||
remove_share_test
|
||||
if [ $err_rtn -ne 0 ]; then
|
||||
# If cleanup fails, restore VM snapshot.
|
||||
restore_snapshot "\n$test_name removal failed."
|
||||
else
|
||||
echo -e "\n$test_name removal completed successfully."
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
testok $0 $all_errs
|
||||
@@ -0,0 +1,71 @@
|
||||
# An expect script to remove a directory and share which was
|
||||
# previously setup for an smbtorture test.
|
||||
# Copyright Brad Henry <brad@samba.org> 2006
|
||||
# Released under the GNU GPL v2 or later.
|
||||
|
||||
proc remove_test { remote_prompt sharepath sharename hosts_file_path \
|
||||
backup_hosts_filename } {
|
||||
|
||||
set err_str [delete_share $remote_prompt $sharename]
|
||||
if { $err_str != "OK" } {
|
||||
puts stderr "Error in function delete_share: $err_str."
|
||||
puts stderr "Function remove_test will continue."
|
||||
}
|
||||
|
||||
set err_str [delete_directory $remote_prompt $sharepath]
|
||||
if { $err_str != "OK" } {
|
||||
puts stderr "Error in function delete_directory: $err_str."
|
||||
puts stderr "Function remove_test will continue."
|
||||
}
|
||||
|
||||
# Overwrite the current hosts file with the backup we made during setup.
|
||||
set err_str [delete_hosts_entry $remote_prompt $hosts_file_path \
|
||||
$backup_hosts_filename]
|
||||
if { $err_str != "OK" } {
|
||||
puts stderr "Error in function delete_hosts_entry: $err_str."
|
||||
puts stderr "Function remove_test will continue."
|
||||
}
|
||||
return $err_str
|
||||
}
|
||||
|
||||
# read parameters
|
||||
set remote_host $env(SMBTORTURE_REMOTE_HOST)
|
||||
set remote_prompt $env(SMBTORTURE_REMOTE_PROMPT)
|
||||
|
||||
set username $env(SMBTORTURE_USERNAME)
|
||||
set password $env(SMBTORTURE_PASSWORD)
|
||||
|
||||
set timeout $env(SMBTORTURE_EXPECT_TIMEOUT)
|
||||
|
||||
set sharepath $env(SMBTORTURE_REMOTE_SHARE_PATH)
|
||||
set sharename $env(SMBTORTURE_REMOTE_SHARE_NAME)
|
||||
|
||||
set backup_hosts_filename $env(REMOTE_BACKUP_HOSTS_FILENAME)
|
||||
set hosts_file_path $env(REMOTE_HOSTS_FILE_PATH)
|
||||
|
||||
set err_val [spawn $env(SHELL)]
|
||||
if {$err_val == 0} {
|
||||
puts stderr "Expect failed while spawning a shell process."
|
||||
exit $err_val
|
||||
}
|
||||
|
||||
set err_str [telnet_login $remote_prompt $remote_host $username $password]
|
||||
if {$err_str != "OK"} {
|
||||
puts stderr "\nFunction telnet_login failed during cleanup."
|
||||
puts stderr "Error was: $err_str."
|
||||
exit 1
|
||||
}
|
||||
|
||||
set err_str [remove_test $remote_prompt $sharepath $sharename \
|
||||
$hosts_file_path $backup_hosts_filename]
|
||||
if {$err_str != "OK"} {
|
||||
puts stderr "\nFunction remove_test failed."
|
||||
puts stderr "Error was: $err_str."
|
||||
# Log off from the telnet server.
|
||||
send "exit\r\n"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Log off from the telnet server.
|
||||
send "exit\r\n"
|
||||
exit 0
|
||||
Executable
+63
@@ -0,0 +1,63 @@
|
||||
#!/bin/sh
|
||||
|
||||
. script/tests/test_functions.sh
|
||||
|
||||
. script/tests/win/wintest_functions.sh
|
||||
|
||||
# This variable is defined in the per-hosts .fns file.
|
||||
. $WINTESTCONF
|
||||
|
||||
if [ $# -lt 4 ]; then
|
||||
cat <<EOF
|
||||
Usage: test_rpc.sh SERVER USERNAME PASSWORD DOMAIN
|
||||
EOF
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
server="$1"
|
||||
username="$2"
|
||||
password="$3"
|
||||
domain="$4"
|
||||
shift 4
|
||||
|
||||
ncacn_np_tests="RPC-SRVSVC RPC-UNIXINFO RPC-ECHO RPC-DSSETUP RPC-ALTERCONTEXT RPC-MULTIBIND"
|
||||
# These tests fail on ncacn_np: RPC-SPOOLSS RPC-SCHANNEL RPC-JOIN RPC-LSA
|
||||
# RPC-NETLOGON
|
||||
|
||||
ncalrpc_tests="RPC-UNIXINFO RPC-ECHO"
|
||||
# These tests fail on ncalrpc: RPC-SCHANNEL RPC-JOIN RPC-LSA RPC-DSSETUP
|
||||
# RPC-ALTERCONTEXT RPC-MULTIBIND RPC-NETLOGON
|
||||
|
||||
ncacn_ip_tcp_tests="RPC-UNIXINFO RPC-ECHO"
|
||||
# These tests fail on ncacn_ip_tcp: RPC-SCHANNEL RPC-JOIN RPC-LSA RPC-DSSETUP
|
||||
# RPC-ALTERCONTEXT RPC-MULTIBIND RPC-NETLOGON
|
||||
|
||||
bind_options="seal,padcheck bigendian"
|
||||
|
||||
test_type="ncalrpc ncacn_np ncacn_ip_tcp"
|
||||
|
||||
all_errs=0
|
||||
for o in $bind_options; do
|
||||
for transport in $test_type; do
|
||||
case $transport in
|
||||
ncalrpc) rpc_test=$ncalrpc_tests ;;
|
||||
ncacn_np) rpc_test=$ncacn_np_tests ;;
|
||||
ncacn_ip_tcp) rpc_test=$ncacn_ip_tcp_tests ;;
|
||||
esac
|
||||
|
||||
for t in $rpc_test; do
|
||||
test_name="$t on $transport with $o"
|
||||
old_errs=$all_errs
|
||||
testit "$test_name" $SMBTORTURE_BIN_PATH \
|
||||
-U $username%$password \
|
||||
-W $domain \
|
||||
$transport:$server[$o] \
|
||||
$t || all_errs=`expr $all_errs + 1`
|
||||
if [ $old_errs -lt $all_errs ]; then
|
||||
restore_snapshot "\n$test_name failed."
|
||||
fi
|
||||
done
|
||||
done
|
||||
done
|
||||
|
||||
testok $0 $all_errs
|
||||
@@ -0,0 +1,104 @@
|
||||
# An expect script to setup a directory and share for an smbtorture test.
|
||||
# Copyright Brad Henry <brad@samba.org> 2006
|
||||
# Released under the GNU GPL v2 or later.
|
||||
|
||||
proc setup_test { remote_prompt sharepath sharename username local_hostname \
|
||||
local_ip hosts_file_path backup_hosts_filename } {
|
||||
|
||||
# If creating the directory fails, remove, then
|
||||
# re-create the directory.
|
||||
set err_str [create_directory $remote_prompt $sharepath]
|
||||
if { $err_str != "OK" } {
|
||||
if { $err_str != "Directory already exists" } {
|
||||
puts stderr "\nUnexpected error occured in setup_test.\n"
|
||||
puts stderr "Function create_directory returned $err_str."
|
||||
} else {
|
||||
puts stdout "\nDirectory $sharepath exists."
|
||||
}
|
||||
puts stdout "Re-creating directory $sharepath."
|
||||
|
||||
set err_str [delete_directory $remote_prompt $sharepath]
|
||||
if { $err_str != "OK" } {
|
||||
return $err_str
|
||||
}
|
||||
set err_str [create_directory $remote_prompt $sharepath]
|
||||
if { $err_str != "OK" } {
|
||||
return $err_str
|
||||
}
|
||||
}
|
||||
|
||||
# If creating the share fails, remove, then
|
||||
# re-create the share.
|
||||
set err_str [create_share $remote_prompt $username $sharepath \
|
||||
$sharename]
|
||||
if { $err_str != "OK" } {
|
||||
if { $err_str != "The name has already been shared" } {
|
||||
puts stderr "\nUnexpected error occured in setup_test."
|
||||
puts stderr "Function create_share returned $err_str."
|
||||
} else {
|
||||
puts stdout "\nShare $sharename exists."
|
||||
}
|
||||
puts stdout "Re-creating share $sharename."
|
||||
|
||||
set err_str [delete_share $remote_prompt $sharename]
|
||||
if { $err_str != "OK" } {
|
||||
return $err_str
|
||||
}
|
||||
set err_str [create_share $remote_prompt $username $sharepath \
|
||||
$sharename]
|
||||
if { $err_str != "OK" } {
|
||||
return $err_str
|
||||
}
|
||||
}
|
||||
|
||||
# Add a hosts file entry on the windows machine for the smbtorture host.
|
||||
set err_str [create_hosts_entry $remote_prompt $hosts_file_path \
|
||||
$local_hostname $local_ip $backup_hosts_filename]
|
||||
return $err_str
|
||||
}
|
||||
|
||||
# Read parameters.
|
||||
set remote_host $env(SMBTORTURE_REMOTE_HOST)
|
||||
set remote_prompt $env(SMBTORTURE_REMOTE_PROMPT)
|
||||
|
||||
set username $env(SMBTORTURE_USERNAME)
|
||||
set password $env(SMBTORTURE_PASSWORD)
|
||||
|
||||
set timeout $env(SMBTORTURE_EXPECT_TIMEOUT)
|
||||
|
||||
set sharepath $env(SMBTORTURE_REMOTE_SHARE_PATH)
|
||||
set sharename $env(SMBTORTURE_REMOTE_SHARE_NAME)
|
||||
|
||||
set local_hostname $env(SMBTORTURE_LOCAL_HOSTNAME)
|
||||
set local_ip $env(SMBTORTURE_LOCAL_IP)
|
||||
|
||||
set backup_hosts_filename $env(REMOTE_BACKUP_HOSTS_FILENAME)
|
||||
set hosts_file_path $env(REMOTE_HOSTS_FILE_PATH)
|
||||
|
||||
set err_val [spawn $env(SHELL)]
|
||||
if {$err_val == 0} {
|
||||
puts stderr "Expect failed while spawning a shell process."
|
||||
exit $err_val
|
||||
}
|
||||
|
||||
set err_str [telnet_login $remote_prompt $remote_host $username $password]
|
||||
if {$err_str != "OK"} {
|
||||
puts stderr "\nFunction telnet_login failed during setup."
|
||||
puts stderr "Error was: $err_str."
|
||||
exit 1
|
||||
}
|
||||
|
||||
set err_str [setup_test $remote_prompt $sharepath $sharename $username \
|
||||
$local_hostname $local_ip $hosts_file_path \
|
||||
$backup_hosts_filename]
|
||||
if {$err_str != "OK"} {
|
||||
puts stderr "\nFunction setup_test failed during setup."
|
||||
puts stderr "Error was: $err_str."
|
||||
# Log off from the telnet server.
|
||||
send "exit\r\n"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Log off from the telnet server.
|
||||
send "exit\r\n"
|
||||
exit 0
|
||||
Executable
+42
@@ -0,0 +1,42 @@
|
||||
#!/bin/sh
|
||||
#4 July 96 Dan.Shearer@UniSA.edu.au
|
||||
|
||||
INSTALLPERMS=$1
|
||||
BASEDIR=$2
|
||||
BINDIR=$3
|
||||
LIBDIR=$4
|
||||
VARDIR=$5
|
||||
shift
|
||||
shift
|
||||
shift
|
||||
shift
|
||||
shift
|
||||
|
||||
if [ ! -d $BINDIR ]; then
|
||||
echo Directory $BINDIR does not exist!
|
||||
echo Do a "make installbin" or "make install" first.
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for p in $*; do
|
||||
p2=`basename $p`
|
||||
if [ -f $BINDIR/$p2 ]; then
|
||||
echo Removing $BINDIR/$p2
|
||||
rm -f $BINDIR/$p2
|
||||
if [ -f $BINDIR/$p2 ]; then
|
||||
echo Cannot remove $BINDIR/$p2 ... does $USER have privileges?
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
cat << EOF
|
||||
======================================================================
|
||||
The binaries have been uninstalled. You may restore the binaries using
|
||||
the command "make installbin" or "make install" to install binaries,
|
||||
man pages, modules and shell scripts. You can restore a previous
|
||||
version of the binaries (if there were any) using "make revert".
|
||||
======================================================================
|
||||
EOF
|
||||
|
||||
exit 0
|
||||
Executable
+35
@@ -0,0 +1,35 @@
|
||||
#!/bin/sh
|
||||
# based on uninstallbin.sh:
|
||||
# 4 July 96 Dan.Shearer@UniSA.edu.au
|
||||
|
||||
INCLUDEDIR=$1
|
||||
shift
|
||||
|
||||
if [ ! -d $INCLUDEDIR ]; then
|
||||
echo Directory $INCLUDEDIR does not exist!
|
||||
echo Do a "make installbin" or "make install" first.
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for p in $*; do
|
||||
p2=`basename $p`
|
||||
if [ -f $INCLUDEDIR/$p2 ]; then
|
||||
echo Removing $INCLUDEDIR/$p2
|
||||
rm -f $INCLUDEDIR/$p2
|
||||
if [ -f $INCLUDEDIR/$p2 ]; then
|
||||
echo Cannot remove $INCLUDEDIR/$p2 ... does $USER have privileges?
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
cat << EOF
|
||||
======================================================================
|
||||
The headers have been uninstalled. You may restore the headers using
|
||||
the command "make installheader" or "make install" to install binaries,
|
||||
man pages, modules and shell scripts. You can restore a previous
|
||||
version of the headers (if there were any) using "make revert".
|
||||
======================================================================
|
||||
EOF
|
||||
|
||||
exit 0
|
||||
Executable
+35
@@ -0,0 +1,35 @@
|
||||
#!/bin/sh
|
||||
# based on uninstallbin.sh
|
||||
# 4 July 96 Dan.Shearer@UniSA.edu.au
|
||||
|
||||
LIBDIR=$1
|
||||
shift
|
||||
|
||||
if [ ! -d $LIBDIR ]; then
|
||||
echo Directory $LIBDIR does not exist!
|
||||
echo Do a "make installbin" or "make install" first.
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for p in $*; do
|
||||
p2=`basename $p`
|
||||
if [ -f $LIBDIR/$p2 ]; then
|
||||
echo Removing $LIBDIR/$p2
|
||||
rm -f $LIBDIR/$p2
|
||||
if [ -f $LIBDIR/$p2 ]; then
|
||||
echo Cannot remove $LIBDIR/$p2 ... does $USER have privileges?
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
cat << EOF
|
||||
======================================================================
|
||||
The shared libraries have been uninstalled. You may restore the libraries using
|
||||
the command "make installlib" or "make install" to install binaries,
|
||||
man pages, modules and shell scripts. You can restore a previous
|
||||
version of the libraries (if there were any) using "make revert".
|
||||
======================================================================
|
||||
EOF
|
||||
|
||||
exit 0
|
||||
Executable
+27
@@ -0,0 +1,27 @@
|
||||
#!/bin/sh
|
||||
# 4 July 96 Dan.Shearer@UniSA.edu.au
|
||||
# Updated for Samba4 by Jelmer Vernooij
|
||||
|
||||
MANDIR=$1
|
||||
shift 1
|
||||
MANPAGES=$*
|
||||
|
||||
for I in $MANPAGES
|
||||
do
|
||||
SECTION=`echo $I | grep -o '.$'`
|
||||
FNAME=$MANDIR/man$SECTION/$I
|
||||
if test -f $FNAME; then
|
||||
echo Deleting $FNAME
|
||||
rm -f $FNAME
|
||||
test -f $FNAME && echo Cannot remove $FNAME... does $USER have privileges?
|
||||
fi
|
||||
done
|
||||
|
||||
cat << EOF
|
||||
======================================================================
|
||||
The man pages have been uninstalled. You may install them again using
|
||||
the command "make installman" or make "install" to install binaries,
|
||||
man pages and shell scripts.
|
||||
======================================================================
|
||||
EOF
|
||||
exit 0
|
||||
Executable
+37
@@ -0,0 +1,37 @@
|
||||
#!/bin/sh
|
||||
#4 July 96 Dan.Shearer@UniSA.edu.au
|
||||
|
||||
INSTALLPERMS=$1
|
||||
BASEDIR=$2
|
||||
LIBDIR=$3
|
||||
shift
|
||||
shift
|
||||
shift
|
||||
|
||||
if [ ! -d $LIBDIR ]; then
|
||||
echo Directory $LIBDIR does not exist!
|
||||
echo Do a "make installmodules" or "make install" first.
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for p in $*; do
|
||||
p2=`basename $p`
|
||||
if [ -f $LIBDIR/$p2 ]; then
|
||||
echo Removing $LIBDIR/$p2
|
||||
rm -f $LIBDIR/$p2
|
||||
if [ -f $LIBDIR/$p2 ]; then
|
||||
echo Cannot remove $LIBDIR/$p2 ... does $USER have privileges?
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
cat << EOF
|
||||
======================================================================
|
||||
The modules have been uninstalled. You may restore the modules using
|
||||
the command "make installmodules" or "make install" to install
|
||||
binaries, modules, man pages and shell scripts.
|
||||
======================================================================
|
||||
EOF
|
||||
|
||||
exit 0
|
||||
Executable
+36
@@ -0,0 +1,36 @@
|
||||
#!/bin/sh
|
||||
# 5 July 96 Dan.Shearer@UniSA.Edu.Au - almost identical to uninstallbin.sh
|
||||
|
||||
INSTALLPERMS=$1
|
||||
BINDIR=$2
|
||||
|
||||
shift
|
||||
shift
|
||||
|
||||
if [ ! -d $BINDIR ]; then
|
||||
echo Directory $BINDIR does not exist!
|
||||
echo Do a "make installscripts" or "make install" first.
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for p in $*; do
|
||||
p2=`basename $p`
|
||||
if [ -f $BINDIR/$p2 ]; then
|
||||
echo Removing $BINDIR/$p2
|
||||
rm -f $BINDIR/$p2
|
||||
if [ -f $BINDIR/$p2 ]; then
|
||||
echo Cannot remove $BINDIR/$p2 ... does $USER have privileges?
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
cat << EOF
|
||||
======================================================================
|
||||
The scripts have been uninstalled. You may reinstall them using
|
||||
the command "make installscripts" or "make install" to install binaries,
|
||||
man pages and shell scripts. You may recover a previous version (if any
|
||||
with "make revert".
|
||||
======================================================================
|
||||
EOF
|
||||
|
||||
exit 0
|
||||
Executable
+15
@@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
|
||||
TORTUREDIR=$1
|
||||
shift
|
||||
shift
|
||||
|
||||
for p in $*; do
|
||||
p2=`dirname $p`
|
||||
base=`basename $p`
|
||||
DESTDIR=$TORTUREDIR/`basename $p2`
|
||||
echo Removing $DESTDIR/$base
|
||||
rm -f $p $DESTDIR/
|
||||
done
|
||||
|
||||
exit 0
|
||||
Executable
+242
@@ -0,0 +1,242 @@
|
||||
#!/usr/bin/perl
|
||||
# Simple script for updating the prototypes in a C header file
|
||||
#
|
||||
# Copyright (C) 2006 Jelmer Vernooij <jelmer@samba.org>
|
||||
# Published under the GNU GPL
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Getopt::Long;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
update-proto - automatically update prototypes in header files
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
update-proto [OPTIONS] <HEADER> <C-FILE>...
|
||||
|
||||
update-proto [OPTIONS] <HEADER>
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Update-proto makes sure the prototypes in a C header file are current
|
||||
by comparing the existing prototypes in a header with the function definition
|
||||
in the source file. It aims to keep the diff between the original header
|
||||
and generated one as small as possible.
|
||||
|
||||
New prototypes are inserted before any line that contains the following comment:
|
||||
|
||||
/* New prototypes are inserted above this line */
|
||||
|
||||
It will automatically parse C files after it encounters a line that contains:
|
||||
|
||||
/* The following definitions come from FILE */
|
||||
|
||||
When two or more prototypes exist for a function, only the first one
|
||||
will be kept.
|
||||
|
||||
=head1 OPTIONS
|
||||
|
||||
=over 4
|
||||
|
||||
=item I<--verbose|-v>
|
||||
|
||||
Increase verbosity. Currently only two levels of verbosity are used.
|
||||
|
||||
=item I<--help>
|
||||
|
||||
Show list of options
|
||||
|
||||
=back
|
||||
|
||||
=head1 BUGS
|
||||
|
||||
Strange complex functions are not recognized. In particular those
|
||||
created by macros or returning (without typedef) function pointers.
|
||||
|
||||
=head1 LICENSE
|
||||
|
||||
update-proto is licensed under the GNU General Public License L<http://www.gnu.org/licenses/gpl.html>.
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
update-proto was written by Jelmer Vernooij L<jelmer@samba.org>.
|
||||
|
||||
=cut
|
||||
|
||||
sub Usage()
|
||||
{
|
||||
print "Usage: update-proto.pl [OPTIONS] <HEADER> <C-FILE>...\n";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
sub Help()
|
||||
{
|
||||
print "Usage: update-proto.pl [OPTIONS] <HEADER> <C-FILE>...\n";
|
||||
print "Options:\n";
|
||||
print " --help Show this help message\n";
|
||||
print " --verbose Write changes made to standard error\n\n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
my %new_protos = ();
|
||||
|
||||
my $verbose = 0;
|
||||
|
||||
GetOptions(
|
||||
'help|h' => \&Help,
|
||||
'v|verbose' => sub { $verbose += 1; }
|
||||
) or Usage();
|
||||
|
||||
sub count($$)
|
||||
{
|
||||
my ($t, $s) = @_;
|
||||
my $count = 0;
|
||||
while($s =~ s/^(.)//) { $count++ if $1 eq $t; }
|
||||
return $count;
|
||||
}
|
||||
|
||||
my $header = shift @ARGV;
|
||||
|
||||
sub process_file($)
|
||||
{
|
||||
my $file = shift;
|
||||
open (IN, "<$file");
|
||||
while (my $line = <IN>) {
|
||||
$_ = $line;
|
||||
next if /^\s/;
|
||||
next unless /\(/;
|
||||
next if /^\/|[;]|^#|}|^\s*static/;
|
||||
s/\/\*(.*?)\*\///g;
|
||||
my $public = s/_PUBLIC_//g;
|
||||
s/_PRINTF_ATTRIBUTE\([^)]+\)//g;
|
||||
next unless /^(struct\s+\w+|union\s+\w+|\w+)\s+\**\s*(\w+)\s*\((.*)$/;
|
||||
|
||||
my $name = $2;
|
||||
|
||||
next if ($name eq "main");
|
||||
|
||||
# Read continuation lines if any
|
||||
my $prn = 1 + count("(", $3) - count(")", $3);
|
||||
|
||||
while ($prn) {
|
||||
my $l = <IN>;
|
||||
$l or die("EOF while parsing function prototype");
|
||||
$line .= $l;
|
||||
$prn += count("(", $l) - count(")", $l);
|
||||
}
|
||||
|
||||
$line =~ s/\n$//;
|
||||
|
||||
# Strip off possible start of function
|
||||
$line =~ s/{\s*$//g;
|
||||
|
||||
$new_protos{$name} = "$line;";
|
||||
}
|
||||
close(IN);
|
||||
}
|
||||
|
||||
process_file($_) foreach (@ARGV);
|
||||
|
||||
my $added = 0;
|
||||
my $modified = 0;
|
||||
my $deleted = 0;
|
||||
my $kept = 0;
|
||||
|
||||
sub insert_new_protos()
|
||||
{
|
||||
foreach (keys %new_protos) {
|
||||
print "$new_protos{$_}\n";
|
||||
print STDERR "Inserted prototype for `$_'\n" if ($verbose);
|
||||
$added+=1;
|
||||
}
|
||||
%new_protos = ();
|
||||
}
|
||||
|
||||
my $blankline_due = 0;
|
||||
|
||||
open (HDR, "<$header");
|
||||
while (my $line = <HDR>) {
|
||||
if ($line eq "\n") {
|
||||
$blankline_due = 1;
|
||||
$line = <HDR>;
|
||||
}
|
||||
|
||||
# Recognize C files that prototypes came from
|
||||
if ($line =~ /\/\* The following definitions come from (.*) \*\//) {
|
||||
insert_new_protos();
|
||||
if ($blankline_due) {
|
||||
print "\n";
|
||||
$blankline_due = 0;
|
||||
}
|
||||
process_file($1);
|
||||
print "$line";
|
||||
next;
|
||||
}
|
||||
|
||||
if ($blankline_due) {
|
||||
print "\n";
|
||||
$blankline_due = 0;
|
||||
}
|
||||
|
||||
# Insert prototypes that weren't in the header before
|
||||
if ($line =~ /\/\* New prototypes are inserted above this line.*\*\/\s*/) {
|
||||
insert_new_protos();
|
||||
print "$line\n";
|
||||
next;
|
||||
}
|
||||
|
||||
if ($line =~ /^\s*typedef |^\#|^\s*static/) {
|
||||
print "$line";
|
||||
next;
|
||||
}
|
||||
|
||||
$_ = $line;
|
||||
s/\/\*(.*?)\*\///g;
|
||||
my $public = s/_PUBLIC_//g;
|
||||
s/_PRINTF_ATTRIBUTE\([^)]+\)//g;
|
||||
unless (/^(struct\s+\w+|union\s+\w+|\w+)\s+\**\s*(\w+)\s*\((.*)$/) {
|
||||
print "$line";
|
||||
next;
|
||||
}
|
||||
|
||||
# Read continuation lines if any
|
||||
my $prn = 1 + count("(", $3) - count(")", $3);
|
||||
|
||||
while ($prn) {
|
||||
my $l = <HDR>;
|
||||
$l or die("EOF while parsing function prototype");
|
||||
$line .= $l;
|
||||
$prn += count("(", $l) - count(")", $l);
|
||||
}
|
||||
|
||||
my $name = $2;
|
||||
|
||||
# This prototype is for a function that was removed
|
||||
unless (defined($new_protos{$name})) {
|
||||
$deleted+=1;
|
||||
print STDERR "Removed prototype for `$name'\n" if ($verbose);
|
||||
next;
|
||||
}
|
||||
|
||||
my $nline = $line;
|
||||
chop($nline);
|
||||
|
||||
if ($new_protos{$name} ne $nline) {
|
||||
$modified+=1;
|
||||
print STDERR "Updated prototype for `$name'\n" if ($verbose);
|
||||
print "$new_protos{$name}\n";
|
||||
} else {
|
||||
$kept+=1;
|
||||
print STDERR "Prototype for `$name' didn't change\n" if ($verbose > 1);
|
||||
print "$line";
|
||||
}
|
||||
|
||||
delete $new_protos{$name};
|
||||
}
|
||||
close(HDR);
|
||||
|
||||
print STDERR "$added added, $modified modified, $deleted deleted, $kept unchanged.\n";
|
||||
|
||||
1;
|
||||
Executable
+28
@@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
|
||||
YACC="$1"
|
||||
SRC="$2"
|
||||
DEST="$3"
|
||||
|
||||
dir=`dirname $SRC`
|
||||
file=`basename $SRC`
|
||||
base=`basename $SRC .y`
|
||||
if [ -z "$YACC" ]; then
|
||||
echo "yacc not found"
|
||||
exit;
|
||||
fi
|
||||
if [ -r $DEST ]; then
|
||||
if [ x`find $SRC -newer $DEST -print` != x$SRC ]; then
|
||||
exit;
|
||||
fi
|
||||
fi
|
||||
TOP=`pwd`
|
||||
if cd $dir && $YACC -d $file; then
|
||||
if [ -r y.tab.h -a -r y.tab.c ];then
|
||||
echo "move files"
|
||||
sed -e "/^#/!b" -e "s|y\.tab\.h|$base.h|" y.tab.h > $base.h
|
||||
sed '/^#/ s|y\.tab\.c|$base.c|' y.tab.c > $base.c
|
||||
rm -f y.tab.c y.tab.h
|
||||
fi
|
||||
fi
|
||||
cd $TOP
|
||||
Reference in New Issue
Block a user