diff options
Diffstat (limited to 'source3/script')
61 files changed, 4582 insertions, 0 deletions
diff --git a/source3/script/build_env.sh b/source3/script/build_env.sh new file mode 100755 index 0000000000..eb54f37aed --- /dev/null +++ b/source3/script/build_env.sh @@ -0,0 +1,41 @@ +#!/bin/sh + +if [ $# -lt 3 ] +then + echo "Usage: $0 srcdir builddir compiler" + exit 1 +fi + +uname=`uname -a` +date=`date` +srcdir=$1 +builddir=$2 +compiler=$3 + +if [ ! "x$USER" = "x" ]; then + whoami=$USER +else + if [ ! "x$LOGNAME" = "x" ]; then + whoami=$LOGNAME + else + whoami=`whoami || id -un` + fi +fi + +host=`hostname` + +cat <<EOF +/* This file is automatically generated with "make include/build_env.h". DO NOT EDIT */ + +#ifndef _BUILD_ENV_H +#define _BUILD_ENV_H + +#define BUILD_ENV_UNAME "${uname}" +#define BUILD_ENV_DATE "${date}" +#define BUILD_ENV_SRCDIR "${srcdir}" +#define BUILD_ENV_BUILDDIR "${builddir}" +#define BUILD_ENV_USER "${whoami}" +#define BUILD_ENV_HOST "${host}" +#define BUILD_ENV_COMPILER "${compiler}" +#endif /* _BUILD_ENV_H */ +EOF diff --git a/source3/script/build_idl.sh b/source3/script/build_idl.sh new file mode 100755 index 0000000000..7aaddc70c7 --- /dev/null +++ b/source3/script/build_idl.sh @@ -0,0 +1,47 @@ +#!/bin/sh + +PIDL_ARGS="--outputdir librpc/gen_ndr --header --ndr-parser --samba3-ndr-server --samba3-ndr-client --" +PIDL_EXTRA_ARGS="$*" + +oldpwd=`pwd` +cd ${srcdir} + +[ -d librpc/gen_ndr ] || mkdir -p librpc/gen_ndr || exit 1 + +if [ -z "$PIDL" ] ; then + PIDL=pidl +fi + +PIDL="$PIDL ${PIDL_ARGS} ${PIDL_EXTRA_ARGS}" + +## +## Find newer files rather than rebuild all of them +## + +list="" +for f in ${IDL_FILES}; do + basename=`basename $f .idl` + ndr="librpc/gen_ndr/ndr_$basename.c" + + if [ -f $ndr ] && false; then + if [ "x`find librpc/idl/$f -newer $ndr -print`" = "xlibrpc/idl/$f" ]; then + list="$list librpc/idl/$f" + fi + else + list="$list librpc/idl/$f" + fi +done + +## +## generate the ndr stubs +## + +if [ "x$list" != x ]; then + # echo "${PIDL} ${list}" + $PIDL $list || exit 1 +fi + +cd ${oldpwd} + +exit 0 + diff --git a/source3/script/count_80_col.pl b/source3/script/count_80_col.pl new file mode 100755 index 0000000000..8b226228c9 --- /dev/null +++ b/source3/script/count_80_col.pl @@ -0,0 +1,16 @@ +#!/usr/bin/perl -w + +open( INFILE, "$ARGV[0]" ) || die $@; + +$count = 0; +while ( <INFILE> ) { + next if ($_ =~ /^#define/); + $count++ if (length($_) > 80); +} + +close( INFILE ); +print "$ARGV[0]: $count lines > 80 characters\n" if ($count > 0); + +exit( 0 ); + + diff --git a/source3/script/creategroup b/source3/script/creategroup new file mode 100755 index 0000000000..01fb065944 --- /dev/null +++ b/source3/script/creategroup @@ -0,0 +1,27 @@ +#!/bin/sh + +# Example script for 'add group command'. Handle weird NT group +# names. First attempt to create the group directly, if that fails +# then create a random group and print the numeric group id. +# +# Note that this is only an example and assumes /dev/urandom. +# +# Volker + +GROUPNAME="$1" +ITERS=0 + +while ! /usr/sbin/groupadd "$GROUPNAME" > /dev/null 2>&1 +do + # we had difficulties creating that group. Maybe the name was + # too weird, or it already existed. Create a random name. + GROUPNAME=nt-$(dd if=/dev/urandom bs=16 count=1 2>/dev/null | md5sum | cut -b 1-5) + ITERS=$(expr "$ITERS" + 1) + if [ "$ITERS" -gt 10 ] + then + # Too many attempts + exit 1 + fi +done + +getent group | grep ^"$GROUPNAME": | cut -d : -f 3 diff --git a/source3/script/extract_allparms.sh b/source3/script/extract_allparms.sh new file mode 100755 index 0000000000..f16068b3fd --- /dev/null +++ b/source3/script/extract_allparms.sh @@ -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 diff --git a/source3/script/findsmb.in b/source3/script/findsmb.in new file mode 100755 index 0000000000..546cf8ce7b --- /dev/null +++ b/source3/script/findsmb.in @@ -0,0 +1,161 @@ +#!@PERL@ +# +# Prints info on all smb responding machines on a subnet. +# This script needs to be run on a machine without nmbd running and be +# run as root to get correct info from WIN95 clients. +# +# syntax: +# findsmb [-d|-D] [-r] [subnet broadcast address] +# +# with no agrument it will list machines on the current subnet +# +# There will be a "+" in front of the workgroup name for machines that are +# local master browsers for that workgroup. There will be an "*" in front +# of the workgroup name for machines that are the domain master browser for +# that workgroup. +# +# Options: +# +# -d|-D enable debug +# -r add -r option to nmblookup when finding netbios name +# + +$SAMBABIN = "@prefix@/bin"; + +for ($i = 0; $i < 2; $i++) { # test for -d and -r options + $_ = shift; + if (m/-d|-D/) { + $DEBUG = 1; + } elsif (m/-r/) { + $R_OPTION = "-r"; + } +} + +if ($_) { # set broadcast address if it was specified + $BCAST = "-B $_"; +} + + +###################################################################### +# do numeric sort on last field of IP address +sub ipsort +{ + @t1 = split(/\./,$a); + @t2 = split(/\./,$b); + @t1[3] <=> @t2[3]; +} +###################################################################### + +# look for all machines that respond to a name lookup + +open(NMBLOOKUP,"$SAMBABIN/nmblookup $BCAST '*' --debuglevel=0|") || + die("Can't run nmblookup '*'.\n"); + +# get rid of all lines that are not a response IP address, +# strip everything but IP address and sort by last field in address + +@ipaddrs = sort ipsort grep(s/ \*<00>.*$//,<NMBLOOKUP>); + +# print header info +print "\n *=DMB\n"; +print " +=LMB\n"; +print "IP ADDR NETBIOS NAME WORKGROUP/OS/VERSION $BCAST\n"; +print "---------------------------------------------------------------------\n"; + +foreach $ip (@ipaddrs) # loop through each IP address found +{ + $ip =~ s/\n//; # strip newline from IP address + + # find the netbios names registered by each machine + + open(NMBLOOKUP,"$SAMBABIN/nmblookup $R_OPTION -A $ip --debuglevel=0|") || + die("Can't get nmb name list.\n"); + @nmblookup = <NMBLOOKUP>; + close NMBLOOKUP; + + # get the first <00> name + + @name = grep(/<00>/,@nmblookup); + $_ = @name[0]; + + if ($_) { # we have a netbios name + if (/GROUP/) { # is it a group name + ($name, $aliases, $type, $length, @addresses) = + gethostbyaddr(pack('C4',split('\.',$ip)),2); + if (! $name) { # could not get name + $name = "unknown nis name"; + } + } else { + # The Netbios name can contain lot of characters also '<' '>' + # and spaces. The follwing cure inside name space but not + # names starting or ending with spaces + /(.{1,15})\s+<00>\s+/; + $name = $1; + $name =~ s/^\s+//g; + } + + # do an smbclient command on the netbios name. + + if ( "$name" ) { + open(SMB,"$SAMBABIN/smbclient -L $name -I $ip -N --debuglevel=1 2>&1 |") || + die("Can't do smbclient command.\n"); + @smb = <SMB>; + close SMB; + + if ($DEBUG) { # if -d flag print results of nmblookup and smbclient + print "===============================================================\n"; + print @nmblookup; + print @smb; + } + + # look for the OS= string + + @info = grep(/OS=/,@smb); + $_ = @info[0]; + if ($_) { # we found response + s/Domain=|OS=|Server=|\n//g; # strip out descriptions to make line shorter + + } else { # no OS= string in response (WIN95 client) + + # for WIN95 clients get workgroup name from nmblookup response + @name = grep(/<00> - <GROUP>/,@nmblookup); + $_ = @name[0]; + if ($_) { + # Same as before for space and characters + /(.{1,15})\s+<00>\s+/; + $_ = "[$1]"; + } else { + $_ = "Unknown Workgroup"; + } + } + } + + # see if machine registered a local master browser name + if (grep(/<1d>/,@nmblookup)) { + $master = '+'; # indicate local master browser + if (grep(/<1b>/,@nmblookup)) { # how about domain master browser? + $master = '*'; # indicate domain master browser + } + } else { + $master = ' '; # not a browse master + } + + # line up info in 3 columns + + print "$ip".' 'x(16-length($ip))."$name".' 'x(14-length($name))."$master"."$_\n"; + + } else { # no netbios name found + # try getting the host name + ($name, $aliases, $type, $length, @addresses) = + gethostbyaddr(pack('C4',split('\.',$ip)),2); + if (! $name) { # could not get name + $name = "unknown nis name"; + } + if ($DEBUG) { # if -d flag print results of nmblookup + print "===============================================================\n"; + print @nmblookup; + } + print "$ip".' 'x(16-length($ip))."$name\n"; + } +} + diff --git a/source3/script/findstatic.pl b/source3/script/findstatic.pl new file mode 100755 index 0000000000..43a4916435 --- /dev/null +++ b/source3/script/findstatic.pl @@ -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"; + } +} + diff --git a/source3/script/fix_bool.pl b/source3/script/fix_bool.pl new file mode 100755 index 0000000000..c09645de7c --- /dev/null +++ b/source3/script/fix_bool.pl @@ -0,0 +1,19 @@ +#!/usr/bin/perl -w + +open(INFILE, "$ARGV[0]") || die $@; +open(OUTFILE, ">$ARGV[0].new") || die $@; + +while (<INFILE>) { + $_ =~ s/True/true/; + $_ =~ s/False/false/; + print OUTFILE "$_"; +} + +close(INFILE); +close(OUTFILE); + +rename("$ARGV[0].new", "$ARGV[0]") || die @_; + +exit(0); + + diff --git a/source3/script/format_indent.sh b/source3/script/format_indent.sh new file mode 100755 index 0000000000..2af1ab41fa --- /dev/null +++ b/source3/script/format_indent.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +# -npro Do no read the '.indent.pro' files. +# -kr Use K&R formatting rules +# -i8 Set indentation level to 8 spaces. +# -ts8 Set tab size to 8 spaces +# -sob Swallow optional blank lines. +# -l80 Set the maximum line length at 80 characters. +# -ss On one-line for and while statments, force a blank before the semicolon +# -ncs Do not put a space after cast operators. + +indent -npro -kr -i8 -ts8 -sob -l80 -ss -ncs "$@" diff --git a/source3/script/gap.awk b/source3/script/gap.awk new file mode 100644 index 0000000000..11680d10f9 --- /dev/null +++ b/source3/script/gap.awk @@ -0,0 +1,39 @@ +BEGIN { hv["0"] = 0; hv["1"] = 1; hv["2"] = 2; hv["3"] = 3; + hv["4"] = 4; hv["5"] = 5; hv["6"] = 6; hv["7"] = 7; + hv["8"] = 8; hv["9"] = 9; hv["A"] = 10; hv["B"] = 11; + hv["C"] = 12; hv["D"] = 13; hv["E"] = 14; hv["F"] = 15; + hv["a"] = 10; hv["b"] = 11; hv["c"] = 12; hv["d"] = 13; + hv["e"] = 14; hv["f"] = 15; + + first = 0; last = 0; idx = 0; +} + +function tonum(str) +{ + num=0; + cnt=1; + while (cnt <= length(str)) { + num *= 16; + num += hv[substr(str,cnt,1)]; + ++cnt; + } + return num; +} + +{ + u = tonum($1); + if (u - last > 6) + { + if (last) + { + printf (" { 0x%04x, 0x%04x, %5d },\n", + first, last, idx); + idx -= u - last - 1; + } + first = u; + } + last = u; +} + +END { printf (" { 0x%04x, 0x%04x, %5d },\n", + first, last, idx); } diff --git a/source3/script/gaptab.awk b/source3/script/gaptab.awk new file mode 100644 index 0000000000..a309089cd5 --- /dev/null +++ b/source3/script/gaptab.awk @@ -0,0 +1,48 @@ +BEGIN { hv["0"] = 0; hv["1"] = 1; hv["2"] = 2; hv["3"] = 3; + hv["4"] = 4; hv["5"] = 5; hv["6"] = 6; hv["7"] = 7; + hv["8"] = 8; hv["9"] = 9; hv["A"] = 10; hv["B"] = 11; + hv["C"] = 12; hv["D"] = 13; hv["E"] = 14; hv["F"] = 15; + hv["a"] = 10; hv["b"] = 11; hv["c"] = 12; hv["d"] = 13; + hv["e"] = 14; hv["f"] = 15; + + first = 0; last = 0; idx = 0; f = 0; +} + +function tonum(str) +{ + num=0; + cnt=1; + while (cnt <= length(str)) { + num *= 16; + num += hv[substr(str,cnt,1)]; + ++cnt; + } + return num; +} + +function fmt(val) +{ + if (f++ % 8 == 0) + { printf ("\n 0x%02x,", val); } + else + { printf (" 0x%02x,", val); } +} + +{ + u = tonum($1); c = tonum($2); + + if (u - last > 6) + { + if (last) { idx += last - first + 1; } + first = u; + } + else + { + for (m = last+1; m < u; m++) { fmt(0); } + } + + fmt(c); + last = u; +} + +END { print "" } diff --git a/source3/script/gen-8bit-gap.awk b/source3/script/gen-8bit-gap.awk new file mode 100644 index 0000000000..59a1a23be0 --- /dev/null +++ b/source3/script/gen-8bit-gap.awk @@ -0,0 +1,18 @@ +BEGIN { + for (i=0; i<256; i++) { + tbl[sprintf("%02x",i)] = "0x0000"; + } +} + +/^<U([[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]])>[[:space:]]*.x([[:xdigit:]][[:xdigit:]])[:space:]*.*$/ { + tbl[substr($2,3,2)]=sprintf("0x%s",substr($1,3,4)); +} + +END { + for(i=0; i<32; i++) { + for(j=0; j<8; j++) { + printf(" %s,", tbl[sprintf("%02x",i*8+j)]); + } + printf "\n" + } +}
\ No newline at end of file diff --git a/source3/script/gen-8bit-gap.sh.in b/source3/script/gen-8bit-gap.sh.in new file mode 100755 index 0000000000..0ceaa8128b --- /dev/null +++ b/source3/script/gen-8bit-gap.sh.in @@ -0,0 +1,48 @@ +#!/bin/sh +if test $# -ne 2 ; then + echo "Usage: $0 <charmap file> <CHARSET NAME>" + exit 1 +fi + +CHARMAP=$1 +CHARSETNAME=$2 + +echo "/* " +echo " * Conversion table for $CHARSETNAME charset " +echo " * " +echo " * Conversion tables are generated using $CHARMAP table " +echo " * and source/script/gen-8bit-gap.sh script " +echo " * " +echo " * This program is free software; you can redistribute it and/or modify " +echo " * it under the terms of the GNU General Public License as published by " +echo " * the Free Software Foundation; either version 3 of the License, or " +echo " * (at your option) any later version. " +echo " * " +echo " * This program is distributed in the hope that it will be useful," +echo " * but WITHOUT ANY WARRANTY; without even the implied warranty of " +echo " * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the " +echo " * GNU General Public License for more details. " +echo " * " +echo " * You should have received a copy of the GNU General Public License " +echo " * along with this program; if not, see <http://www.gnu.org/licenses/>." +echo " */" + +echo '#include "includes.h"' +echo +echo "static const uint16 to_ucs2[256] = {" +cat "$CHARMAP" | @AWK@ -f @srcdir@/script/gen-8bit-gap.awk +echo "};" +echo +echo "static const struct charset_gap_table from_idx[] = {" +sed -ne 's/^<U\(....\).*/\1/p' \ + "$CHARMAP" | sort -u | @AWK@ -f @srcdir@/script/gap.awk +echo " { 0xffff, 0xffff, 0 }" +echo "};" +echo +echo "static const unsigned char from_ucs2[] = {" +sed -ne 's/^<U\(....\)>[[:space:]]*.x\(..\).*/\1 \2/p' \ + "$CHARMAP" | sort -u | @AWK@ -f @srcdir@/script/gaptab.awk +echo "};" +echo +echo "SMB_GENERATE_CHARSET_MODULE_8_BIT_GAP($CHARSETNAME)" +echo diff --git a/source3/script/installbin.sh.in b/source3/script/installbin.sh.in new file mode 100755 index 0000000000..c607d9e445 --- /dev/null +++ b/source3/script/installbin.sh.in @@ -0,0 +1,34 @@ +#!/bin/sh + +INSTALLPERMS=$1 +DESTDIR=$2 +prefix=`echo $3 | sed 's/\/\//\//g'` +BINDIR=`echo $4 | sed 's/\/\//\//g'` +SBINDIR=@sbindir@ +shift +shift +shift +shift + +for p in $*; do + p2=`basename $p` + echo "Installing $p as $DESTDIR/$BINDIR/$p2 " + if [ -f $DESTDIR/$BINDIR/$p2 ]; then + rm -f $DESTDIR/$BINDIR/$p2.old + mv $DESTDIR/$BINDIR/$p2 $DESTDIR/$BINDIR/$p2.old + fi + cp $p $DESTDIR/$BINDIR/ + chmod $INSTALLPERMS $DESTDIR/$BINDIR/$p2 +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 diff --git a/source3/script/installdat.sh b/source3/script/installdat.sh new file mode 100755 index 0000000000..59bf2f919d --- /dev/null +++ b/source3/script/installdat.sh @@ -0,0 +1,65 @@ +#!/bin/sh +#fist version March 2002, Herb Lewis + +DESTDIR=$1 +DATDIR=`echo $2 | sed 's/\/\//\//g'` +SRCDIR=$3/ +shift +shift +shift + +case $0 in + *uninstall*) + if test ! -d "$DESTDIR/$DATDIR"; then + echo "Directory $DESTDIR/$DATDIR does not exist! " + echo "Do a "make installmsg" or "make install" first. " + exit 1 + fi + mode='uninstall' + ;; + *) mode='install' ;; +esac + +for f in $SRCDIR/codepages/*.dat; do + FNAME="$DESTDIR/$DATDIR/`basename $f`" + if test "$mode" = 'install'; then + echo "Installing $f as $FNAME " + cp "$f" "$FNAME" + if test ! -f "$FNAME"; then + echo "Cannot install $FNAME. Does $USER have privileges? " + exit 1 + fi + chmod 0644 "$FNAME" + elif test "$mode" = 'uninstall'; then + echo "Removing $FNAME " + rm -f "$FNAME" + if test -f "$FNAME"; then + echo "Cannot remove $FNAME. Does $USER have privileges? " + exit 1 + fi + else + echo "Unknown mode, $mode. Script called as $0 " + exit 1 + fi +done + +if test "$mode" = 'install'; then + cat << EOF +====================================================================== +The dat files have been installed. You may uninstall the dat files +using the command "make uninstalldat" or "make uninstall" to uninstall +binaries, man pages, dat files, and shell scripts. +====================================================================== +EOF +else + cat << EOF +====================================================================== +The dat files have been removed. You may restore these files using +the command "make installdat" or "make install" to install binaries, +man pages, modules, dat files, and shell scripts. +====================================================================== +EOF +fi + +exit 0 + diff --git a/source3/script/installdirs.sh b/source3/script/installdirs.sh new file mode 100755 index 0000000000..062b34b8c6 --- /dev/null +++ b/source3/script/installdirs.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +INSTALLPERMS=$1 +DESTDIR=`echo $2 | sed 's/\/\//\//g'` +shift +shift + +for dir in $@; do + DIRNAME=`echo $dir | sed 's/\/\//\//g'` + if [ ! -d $DESTDIR/$DIRNAME ]; then + mkdir -m $INSTALLPERMS -p $DESTDIR/$DIRNAME + fi + + if [ ! -d $DESTDIR/$DIRNAME ]; then + echo "Failed to make directory $DESTDIR/$DIRNAME " + exit 1 + fi +done diff --git a/source3/script/installman.sh b/source3/script/installman.sh new file mode 100755 index 0000000000..ab9bfe506d --- /dev/null +++ b/source3/script/installman.sh @@ -0,0 +1,86 @@ +#!/bin/sh +#5 July 96 Dan.Shearer@unisa.edu.au removed hardcoded values +# +# 13 Aug 2001 Rafal Szczesniak <mimir@spin.ict.pwr.wroc.pl> +# modified to accomodate international man pages (inspired +# by Japanese edition's approach) + +MANDIR=`echo $1 | sed 's/\/\//\//g'` +SRCDIR=$2/ +langs=$3 + +if [ $# -ge 4 ] ; then + GROFF=$4 # sh cmd line, including options +fi + +if test ! -d $SRCDIR../docs/manpages; then + echo "No manpages present. Development version maybe?" + exit 0 +fi + +# Get the configured feature set +test -f "${SRCDIR}/config.log" && \ + eval `grep "^[[:alnum:]]*=.*" "${SRCDIR}/config.log"` + +for lang in $langs; do + if [ "X$lang" = XC ]; then + echo Installing default man pages in $MANDIR/ + lang=. + else + echo Installing \"$lang\" man pages in $MANDIR/lang/$lang + fi + + langdir=$MANDIR/$lang + for d in $MANDIR $langdir $langdir/man1 $langdir/man5 $langdir/man7 $langdir/man8; do + if [ ! -d $d ]; then + mkdir $d + if [ ! -d $d ]; then + echo Failed to make directory $d, does $USER have privileges? + exit 1 + fi + fi + done + + for sect in 1 5 7 8 ; do + for m in $langdir/man$sect ; do + for s in $SRCDIR../docs/manpages/$lang/*$sect; do + MP_BASENAME=`basename $s` + + # Check if this man page if required by the configured feature set + case "${MP_BASENAME}" in + smbsh.1) test -z "${SMBWRAPPER}" && continue ;; + *) ;; + esac + + FNAME="$m/${MP_BASENAME}" + + # Test for writability. Involves + # blowing away existing files. + + if (rm -f $FNAME && touch $FNAME); then + if [ "x$GROFF" = x ] ; then + cp $s $m # Copy raw nroff + else + echo "\t$FNAME" # groff'ing can be slow, give the user + # a warm fuzzy. + $GROFF $s > $FNAME # Process nroff, because man(1) (on + # this system) doesn't . + fi + chmod 0644 $FNAME + else + echo Cannot create $FNAME... does $USER have privileges? + fi + done + done + done +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 + diff --git a/source3/script/installmodules.sh b/source3/script/installmodules.sh new file mode 100755 index 0000000000..f70db003ed --- /dev/null +++ b/source3/script/installmodules.sh @@ -0,0 +1,37 @@ +#!/bin/sh + +INSTALLPERMS=$1 +DESTDIR=$2 +prefix=`echo $3 | sed 's/\/\//\//g'` +LIBDIR=`echo $4 | sed 's/\/\//\//g'` +shift +shift +shift +shift + +for d in $prefix $LIBDIR; do +if [ ! -d $DESTDIR/$d ]; then +mkdir $DESTDIR/$d +if [ ! -d $DESTDIR/$d ]; then + echo Failed to make directory $DESTDIR/$d + exit 1 +fi +fi +done + +# We expect the last component of LIBDIR to be the module type, eg. idmap, +# pdb. By stripping this from the installation name, you can have multiple +# modules of the same name but different types by creating eg. idmap_foo +# and pdb_foo. This makes the most sense for idmap and pdb module, where +# they need to be consistent. +mtype=`basename $LIBDIR` + +for p in $*; do + p2=`basename $p` + name=`echo $p2 | sed -es/${mtype}_//` + echo Installing $p as $DESTDIR/$LIBDIR/$name + cp -f $p $DESTDIR/$LIBDIR/$name + chmod $INSTALLPERMS $DESTDIR/$LIBDIR/$name +done + +exit 0 diff --git a/source3/script/installmsg.sh b/source3/script/installmsg.sh new file mode 100644 index 0000000000..859e4c10cf --- /dev/null +++ b/source3/script/installmsg.sh @@ -0,0 +1,65 @@ +#!/bin/sh +# first version (Sept 2003) written by Shiro Yamada <shiro@miraclelinux.com> +# based on the first verion (March 2002) of installdat.sh written by Herb Lewis + +DESTDIR=$1 +MSGDIR=`echo $2 | sed 's/\/\//\//g'` +SRCDIR=$3/ +shift +shift +shift + +case $0 in + *uninstall*) + if test ! -d "$DESTDIR/$MSGDIR"; then + echo "Directory $DESTDIR/$MSGDIR does not exist! " + echo "Do a "make installmsg" or "make install" first. " + exit 1 + fi + mode='uninstall' + ;; + *) mode='install' ;; +esac + +for f in $SRCDIR/po/*.msg; do + FNAME="$DESTDIR/$MSGDIR/`basename $f`" + if test "$mode" = 'install'; then + echo "Installing $f as $FNAME " + cp "$f" "$FNAME" + if test ! -f "$FNAME"; then + echo "Cannot install $FNAME. Does $USER have privileges? " + exit 1 + fi + chmod 0644 "$FNAME" + elif test "$mode" = 'uninstall'; then + echo "Removing $FNAME " + rm -f "$FNAME" + if test -f "$FNAME"; then + echo "Cannot remove $FNAME. Does $USER have privileges? " + exit 1 + fi + else + echo "Unknown mode, $mode. Script called as $0 " + exit 1 + fi +done + +if test "$mode" = 'install'; then + cat << EOF +============================================================================== +The SWAT msg files have been installed. You may uninstall the msg files using +the command "make uninstallmsg" or "make uninstall" to uninstall binaries, man +pages, msg files, and shell scripts. +============================================================================== +EOF +else + cat << EOF +============================================================================= +The SWAT msg files have been removed. You may restore these files using the +command "make installmsg" or "make install" to install binaries, man pages, +modules, msg files, and shell scripts. +====================================================================== +EOF +fi + +exit 0 diff --git a/source3/script/installscripts.sh b/source3/script/installscripts.sh new file mode 100755 index 0000000000..81608c3682 --- /dev/null +++ b/source3/script/installscripts.sh @@ -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=`echo $2 | sed 's/\/\//\//g'` + +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 diff --git a/source3/script/installswat.sh b/source3/script/installswat.sh new file mode 100755 index 0000000000..40596f3bd8 --- /dev/null +++ b/source3/script/installswat.sh @@ -0,0 +1,296 @@ +#!/bin/sh +#first version March 1998, Andrew Tridgell + +DESTDIR=$1 +SWATDIR=`echo $2 | sed 's/\/\//\//g'` +SRCDIR=$3/ +BOOKDIR="$DESTDIR/$SWATDIR/using_samba" + +case $0 in + *uninstall*) + echo "Removing SWAT from $DESTDIR/$SWATDIR " + echo "Removing the Samba Web Administration Tool " + printf "%s" "Removed " + mode='uninstall' + ;; + *) + echo "Installing SWAT in $DESTDIR/$SWATDIR " + echo "Installing the Samba Web Administration Tool " + printf "%s" "Installing " + mode='install' + ;; +esac + +LANGS=". `cd $SRCDIR../swat/; /bin/echo lang/??`" +echo "langs are `cd $SRCDIR../swat/lang/; /bin/echo ??` " + +if test "$mode" = 'install'; then + for ln in $LANGS; do + SWATLANGDIR="$DESTDIR/$SWATDIR/$ln" + for d in $SWATLANGDIR $SWATLANGDIR/help $SWATLANGDIR/images \ + $SWATLANGDIR/include $SWATLANGDIR/js; do + if [ ! -d $d ]; then + mkdir -p $d + if [ ! -d $d ]; then + echo "Failed to make directory $d, does $USER have privileges? " + exit 1 + fi + fi + done + done +fi + +for ln in $LANGS; do + + # images + for f in $SRCDIR../swat/$ln/images/*.gif; do + if [ ! -f $f ] ; then + continue + fi + FNAME="$DESTDIR/$SWATDIR/$ln/images/`basename $f`" + echo $FNAME + if test "$mode" = 'install'; then + cp "$f" "$FNAME" + if test ! -f "$FNAME"; then + echo "Cannot install $FNAME. Does $USER have privileges? " + exit 1 + fi + chmod 0644 "$FNAME" + elif test "$mode" = 'uninstall'; then + rm -f "$FNAME" + if test -f "$FNAME"; then + echo "Cannot remove $FNAME. Does $USER have privileges? " + exit 1 + fi + else + echo "Unknown mode, $mode. Script called as $0 " + exit 1 + fi + done + + # html help + for f in $SRCDIR../swat/$ln/help/*.html; do + if [ ! -f $f ] ; then + continue + fi + FNAME="$DESTDIR/$SWATDIR/$ln/help/`basename $f`" + echo $FNAME + if test "$mode" = 'install'; then + if [ "x$BOOKDIR" = "x" ]; then + cat $f | sed 's/@BOOKDIR@.*$//' > $FNAME.tmp + else + cat $f | sed 's/@BOOKDIR@//' > $FNAME.tmp + fi + if test ! -f "$FNAME.tmp"; then + echo "Cannot install $FNAME. Does $USER have privileges? " + exit 1 + fi + f=$FNAME.tmp + cp "$f" "$FNAME" + rm -f "$f" + if test ! -f "$FNAME"; then + echo "Cannot install $FNAME. Does $USER have privileges? " + exit 1 + fi + chmod 0644 "$FNAME" + elif test "$mode" = 'uninstall'; then + rm -f "$FNAME" + if test -f "$FNAME"; then + echo "Cannot remove $FNAME. Does $USER have privileges? " + exit 1 + fi + fi + done + + # "server-side" includes + for f in $SRCDIR../swat/$ln/include/*; do + if [ ! -f $f ] ; then + continue + fi + FNAME="$DESTDIR/$SWATDIR/$ln/include/`basename $f`" + echo $FNAME + if test "$mode" = 'install'; then + cp "$f" "$FNAME" + if test ! -f "$FNAME"; then + echo "Cannot install $FNAME. Does $USER have privileges? " + exit 1 + fi + chmod 0644 $FNAME + elif test "$mode" = 'uninstall'; then + rm -f "$FNAME" + if test -f "$FNAME"; then + echo "Cannot remove $FNAME. Does $USER have privileges? " + exit 1 + fi + fi + done + +done + +# Install/ remove html documentation (if html documentation tree is here) + +if [ -d $SRCDIR../docs/htmldocs/ ]; then + + for dir in htmldocs/manpages htmldocs/Samba3-ByExample htmldocs/Samba3-Developers-Guide htmldocs/Samba3-HOWTO + do + + if [ ! -d $SRCDIR../docs/$dir ]; then + continue + fi + + INSTALLDIR="$DESTDIR/$SWATDIR/help/`echo $dir | sed 's/htmldocs\///g'`" + if test ! -d "$INSTALLDIR" -a "$mode" = 'install'; then + mkdir "$INSTALLDIR" + if test ! -d "$INSTALLDIR"; then + echo "Failed to make directory $INSTALLDIR, does $USER have privileges? " + exit 1 + fi + fi + + for f in $SRCDIR../docs/$dir/*.html; do + FNAME=$INSTALLDIR/`basename $f` + echo $FNAME + if test "$mode" = 'install'; then + cp "$f" "$FNAME" + if test ! -f "$FNAME"; then + echo "Cannot install $FNAME. Does $USER have privileges? " + exit 1 + fi + chmod 0644 $FNAME + elif test "$mode" = 'uninstall'; then + rm -f "$FNAME" + if test -f "$FNAME"; then + echo "Cannot remove $FNAME. Does $USER have privileges? " + exit 1 + fi + fi + done + + if test -d "$SRCDIR../docs/$dir/images/"; then + if test ! -d "$INSTALLDIR/images/" -a "$mode" = 'install'; then + mkdir "$INSTALLDIR/images" + if test ! -d "$INSTALLDIR/images/"; then + echo "Failed to make directory $INSTALLDIR/images, does $USER have privileges? " + exit 1 + fi + fi + for f in $SRCDIR../docs/$dir/images/*.png; do + FNAME=$INSTALLDIR/images/`basename $f` + echo $FNAME + if test "$mode" = 'install'; then + cp "$f" "$FNAME" + if test ! -f "$FNAME"; then + echo "Cannot install $FNAME. Does $USER have privileges? " + exit 1 + fi + chmod 0644 $FNAME + elif test "$mode" = 'uninstall'; then + rm -f "$FNAME" + if test -f "$FNAME"; then + echo "Cannot remove $FNAME. Does $USER have privileges? " + exit 1 + fi + fi + done + fi + done +fi + +# Install/ remove Using Samba book (but only if it is there) + +if [ "x$BOOKDIR" != "x" -a -f $SRCDIR../docs/htmldocs/using_samba/toc.html ]; then + + # Create directories + + for d in $BOOKDIR $BOOKDIR/figs ; do + if test ! -d "$d" -a "$mode" = 'install'; then + mkdir $d + if test ! -d "$d"; then + echo "Failed to make directory $d, does $USER have privileges? " + exit 1 + fi + fi + done + + # HTML files + + for f in $SRCDIR../docs/htmldocs/using_samba/*.html; do + FNAME=$BOOKDIR/`basename $f` + echo $FNAME + if test "$mode" = 'install'; then + cp "$f" "$FNAME" + if test ! -f "$FNAME"; then + echo "Cannot install $FNAME. Does $USER have privileges? " + exit 1 + fi + chmod 0644 $FNAME + elif test "$mode" = 'uninstall'; then + rm -f "$FNAME" + if test -f "$FNAME"; then + echo "Cannot remove $FNAME. Does $USER have privileges? " + exit 1 + fi + fi + done + + for f in $SRCDIR../docs/htmldocs/using_samba/*.gif; do + FNAME=$BOOKDIR/`basename $f` + echo $FNAME + if test "$mode" = 'install'; then + cp "$f" "$FNAME" + if test ! -f "$FNAME"; then + echo "Cannot install $FNAME. Does $USER have privileges? " + exit 1 + fi + chmod 0644 $FNAME + elif test "$mode" = 'uninstall'; then + rm -f "$FNAME" + if test -f "$FNAME"; then + echo "Cannot remove $FNAME. Does $USER have privileges? " + exit 1 + fi + fi + done + + # Figures + + for f in $SRCDIR../docs/htmldocs/using_samba/figs/*.gif; do + FNAME=$BOOKDIR/figs/`basename $f` + echo $FNAME + if test "$mode" = 'install'; then + cp "$f" "$FNAME" + if test ! -f "$FNAME"; then + echo "Cannot install $FNAME. Does $USER have privileges? " + exit 1 + fi + chmod 0644 $FNAME + elif test "$mode" = 'uninstall'; then + rm -f "$FNAME" + if test -f "$FNAME"; then + echo "Cannot remove $FNAME. Does $USER have privileges? " + exit 1 + fi + fi + done + +fi + +if test "$mode" = 'install'; then + cat << EOF +====================================================================== +The SWAT files have been installed. Remember to read the documentation +for information on enabling and using SWAT +====================================================================== +EOF +else + cat << EOF +====================================================================== +The SWAT files have been removed. You may restore these files using +the command "make installswat" or "make install" to install binaries, +man pages, modules, SWAT, and shell scripts. +====================================================================== +EOF +fi + +exit 0 + diff --git a/source3/script/linkmodules.sh b/source3/script/linkmodules.sh new file mode 100755 index 0000000000..16a04cc064 --- /dev/null +++ b/source3/script/linkmodules.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +cd "$1" +test -f "$2" || exit 0 + +for I in $3 $4 $5 $6 $7 $8 +do + echo "Linking $I to $2" + ln -s $2 $I +done + +exit 0 diff --git a/source3/script/makeunicodecasemap.awk b/source3/script/makeunicodecasemap.awk new file mode 100644 index 0000000000..8424b6c672 --- /dev/null +++ b/source3/script/makeunicodecasemap.awk @@ -0,0 +1,59 @@ +function reset_vals() { + upperstr = ""; + lowerstr = ""; + flagstr = "0"; +} + +function print_val() { + upperstr = $13; + lowerstr = $14; + if ( upperstr == "" ) + upperstr = strval; + if ( lowerstr == "" ) + lowerstr = strval; + + if ( $3 == "Lu" ) + flagstr = sprintf("%s|%s", flagstr, "UNI_UPPER"); + if ( $3 == "Ll" ) + flagstr = sprintf("%s|%s", flagstr, "UNI_LOWER"); + if ( val >= 48 && val <= 57) + flagstr = sprintf("%s|%s", flagstr, "UNI_DIGIT"); + if ((val >= 48 && val <= 57) || (val >= 65 && val <= 70) || (val >=97 && val <= 102)) + flagstr = sprintf("%s|%s", flagstr, "UNI_XDIGIT"); + if ( val == 32 || (val >=9 && val <= 13)) + flagstr = sprintf("%s|%s", flagstr, "UNI_SPACE"); + if( index(flagstr, "0|") == 1) + flagstr = substr(flagstr, 3, length(flagstr) - 2); + printf("{ 0x%s, 0x%s, %s }, \t\t\t/* %s %s */\n", lowerstr, upperstr, flagstr, strval, $2); + val++; + strval=sprintf("%04X", val); + reset_vals(); +} + +BEGIN { + val=0 + FS=";" + strval=sprintf("%04X", val); + reset_vals(); +} + +{ + if ( $1 == strval ) { + print_val(); + } else { + while ( $1 != strval) { + printf("{ 0x%04X, 0x%04X, 0 }, \t\t\t/* %s NOMAP */\n", val, val, strval); + val++; + strval=sprintf("%04X", val); + } + print_val(); + } +} + +END { + while ( val < 65536 ) { + printf("{ 0x%04X, 0x%04X, 0 }, \t\t\t/* %s NOMAP */\n", val, val, strval); + val++; + strval=sprintf("%04X", val); + } +} diff --git a/source3/script/mkbuildoptions.awk b/source3/script/mkbuildoptions.awk new file mode 100644 index 0000000000..02562cf7b2 --- /dev/null +++ b/source3/script/mkbuildoptions.awk @@ -0,0 +1,270 @@ +BEGIN { + print "/* "; + print " Unix SMB/CIFS implementation."; + print " Build Options for Samba Suite"; + print " Copyright (C) Vance Lankhaar <vlankhaar@linux.ca> 2003"; + print " Copyright (C) Andrew Bartlett <abartlet@samba.org> 2001"; + print " "; + print " This program is free software; you can redistribute it and/or modify"; + print " it under the terms of the GNU General Public License as published by"; + print " the Free Software Foundation; either version 3 of the License, or"; + print " (at your option) any later version."; + print " "; + print " This program is distributed in the hope that it will be useful,"; + print " but WITHOUT ANY WARRANTY; without even the implied warranty of"; + print " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the"; + print " GNU General Public License for more details."; + print " "; + print " You should have received a copy of the GNU General Public License"; + print " along with this program; if not, see <http://www.gnu.org/licenses/>." + print "*/"; + print ""; + print "#include \"includes.h\""; + print "#include \"build_env.h\""; + print "#include \"dynconfig.h\""; + print ""; + print "static void output(bool screen, const char *format, ...) PRINTF_ATTRIBUTE(2,3);"; + print "void build_options(bool screen);"; + print ""; + print ""; + print "/****************************************************************************"; + print "helper function for build_options"; + print "****************************************************************************/"; + print "static void output(bool screen, const char *format, ...)"; + print "{"; + print " char *ptr;"; + print " va_list ap;"; + print " "; + print " va_start(ap, format);"; + print " vasprintf(&ptr,format,ap);"; + print " va_end(ap);"; + print ""; + print " if (screen) {"; + print " d_printf(\"%s\", ptr);"; + print " } else {"; + print " DEBUG(4,(\"%s\", ptr));"; + print " }"; + print " "; + print " SAFE_FREE(ptr);"; + print "}"; + print ""; + print "/****************************************************************************"; + print "options set at build time for the samba suite"; + print "****************************************************************************/"; + print "void build_options(bool screen)"; + print "{"; + print " if ((DEBUGLEVEL < 4) && (!screen)) {"; + print " return;"; + print " }"; + print ""; + print "#ifdef _BUILD_ENV_H"; + print " /* Output information about the build environment */"; + print " output(screen,\"Build environment:\\n\");"; + print " output(screen,\" Built by: %s@%s\\n\",BUILD_ENV_USER,BUILD_ENV_HOST);"; + print " output(screen,\" Built on: %s\\n\",BUILD_ENV_DATE);"; + print ""; + print " output(screen,\" Built using: %s\\n\",BUILD_ENV_COMPILER);"; + print " output(screen,\" Build host: %s\\n\",BUILD_ENV_UNAME);"; + print " output(screen,\" SRCDIR: %s\\n\",BUILD_ENV_SRCDIR);"; + print " output(screen,\" BUILDDIR: %s\\n\",BUILD_ENV_BUILDDIR);"; + print ""; + print " "; + print "#endif"; + print ""; + + print " /* Output various paths to files and directories */"; + print " output(screen,\"\\nPaths:\\n\");"; + + print " output(screen,\" SBINDIR: %s\\n\", get_dyn_SBINDIR());"; + print " output(screen,\" BINDIR: %s\\n\", get_dyn_BINDIR());"; + print " output(screen,\" SWATDIR: %s\\n\", get_dyn_SWATDIR());"; + + print " output(screen,\" CONFIGFILE: %s\\n\", get_dyn_CONFIGFILE());"; + print " output(screen,\" LOGFILEBASE: %s\\n\", get_dyn_LOGFILEBASE());"; + print " output(screen,\" LMHOSTSFILE: %s\\n\",get_dyn_LMHOSTSFILE());"; + + print " output(screen,\" LIBDIR: %s\\n\",get_dyn_LIBDIR());"; + print " output(screen,\" MODULESDIR: %s\\n\",get_dyn_MODULESDIR());"; + print " output(screen,\" SHLIBEXT: %s\\n\",get_dyn_SHLIBEXT());"; + + print " output(screen,\" LOCKDIR: %s\\n\",get_dyn_LOCKDIR());"; + print " output(screen,\" PIDDIR: %s\\n\", get_dyn_PIDDIR());"; + + print " output(screen,\" SMB_PASSWD_FILE: %s\\n\",get_dyn_SMB_PASSWD_FILE());"; + print " output(screen,\" PRIVATE_DIR: %s\\n\",get_dyn_PRIVATE_DIR());"; + print ""; + + +################################################## +# predefine first element of *_ary +# predefine *_i (num of elements in *_ary) + with_ary[0]=""; + with_i=0; + have_ary[0]=""; + have_i=0; + utmp_ary[0]=""; + utmp_i=0; + misc_ary[0]=""; + misc_i=0; + sys_ary[0]=""; + sys_i=0; + headers_ary[0]=""; + headers_i=0; + in_comment = 0; +} + +# capture single line comments +/^\/\* (.*?)\*\// { + last_comment = $0; + next; +} + +# end capture multi-line comments +/(.*?)\*\// { + last_comment = last_comment $0; + in_comment = 0; + next; +} + +# capture middle lines of multi-line comments +in_comment { + last_comment = last_comment $0; + next; +} + +# begin capture multi-line comments +/^\/\* (.*?)/ { + last_comment = $0; + in_comment = 1; + next +} + +################################################## +# if we have an #undef and a last_comment, store it +/^\#undef/ { + split($0,a); + comments_ary[a[2]] = last_comment; + last_comment = ""; +} + +################################################## +# for each line, sort into appropriate section +# then move on + +/^\#undef WITH/ { + with_ary[with_i++] = a[2]; + # we want (I think) to allow --with to show up in more than one place, so no next +} + + +/^\#undef HAVE_UT_UT_/ || /^\#undef .*UTMP/ { + utmp_ary[utmp_i++] = a[2]; + next; +} + +/^\#undef HAVE_SYS_.*?_H$/ { + sys_ary[sys_i++] = a[2]; + next; +} + +/^\#undef HAVE_.*?_H$/ { + headers_ary[headers_i++] = a[2]; + next; +} + +/^\#undef HAVE_/ { + have_ary[have_i++] = a[2]; + next; +} + +/^\#undef/ { + misc_ary[misc_i++] = a[2]; + next; +} + + +################################################## +# simple sort function +function sort(ARRAY, ELEMENTS) { + for (i = 1; i <= ELEMENTS; ++i) { + for (j = i; (j-1) in ARRAY && (j) in ARRAY && ARRAY[j-1] > ARRAY[j]; --j) { + temp = ARRAY[j]; + ARRAY[j] = ARRAY[j-1]; + ARRAY[j-1] = temp; + } + } + return; +} + + +################################################## +# output code from list of defined +# expects: ARRAY an array of things defined +# ELEMENTS number of elements in ARRAY +# TITLE title for section +# returns: nothing +function output(ARRAY, ELEMENTS, TITLE) { + + # add section header + print "\n\t/* Show " TITLE " */"; + print "\toutput(screen, \"\\n " TITLE ":\\n\");\n"; + + + # sort element using bubble sort (slow, but easy) + sort(ARRAY, ELEMENTS); + + # loop through array of defines, outputting code + for (i = 0; i < ELEMENTS; i++) { + print "#ifdef " ARRAY[i]; + + # I don't know which one to use.... + + print "\toutput(screen, \" " ARRAY[i] "\\n\");"; + #printf "\toutput(screen, \" %s\\n %s\\n\\n\");\n", comments_ary[ARRAY[i]], ARRAY[i]; + #printf "\toutput(screen, \" %-35s %s\\n\");\n", ARRAY[i], comments_ary[ARRAY[i]]; + + print "#endif"; + } + return; +} + +END { + ################################################## + # add code to show various options + print "/* Output various other options (as gleaned from include/config.h.in) */"; + output(sys_ary, sys_i, "System Headers"); + output(headers_ary, headers_i, "Headers"); + output(utmp_ary, utmp_i, "UTMP Options"); + output(have_ary, have_i, "HAVE_* Defines"); + output(with_ary, with_i, "--with Options"); + output(misc_ary, misc_i, "Build Options"); + + ################################################## + # add code to display the various type sizes + print " /* Output the sizes of the various types */"; + print " output(screen, \"\\nType sizes:\\n\");"; + print " output(screen, \" sizeof(char): %lu\\n\",(unsigned long)sizeof(char));"; + print " output(screen, \" sizeof(int): %lu\\n\",(unsigned long)sizeof(int));"; + print " output(screen, \" sizeof(long): %lu\\n\",(unsigned long)sizeof(long));"; + print "#if HAVE_LONGLONG" + print " output(screen, \" sizeof(long long): %lu\\n\",(unsigned long)sizeof(long long));"; + print "#endif" + print " output(screen, \" sizeof(uint8): %lu\\n\",(unsigned long)sizeof(uint8));"; + print " output(screen, \" sizeof(uint16): %lu\\n\",(unsigned long)sizeof(uint16));"; + print " output(screen, \" sizeof(uint32): %lu\\n\",(unsigned long)sizeof(uint32));"; + print " output(screen, \" sizeof(short): %lu\\n\",(unsigned long)sizeof(short));"; + print " output(screen, \" sizeof(void*): %lu\\n\",(unsigned long)sizeof(void*));"; + print " output(screen, \" sizeof(size_t): %lu\\n\",(unsigned long)sizeof(size_t));"; + print " output(screen, \" sizeof(off_t): %lu\\n\",(unsigned long)sizeof(off_t));"; + print " output(screen, \" sizeof(ino_t): %lu\\n\",(unsigned long)sizeof(ino_t));"; + print " output(screen, \" sizeof(dev_t): %lu\\n\",(unsigned long)sizeof(dev_t));"; + + ################################################## + # add code to give information about modules + print " output(screen, \"\\nBuiltin modules:\\n\");"; + print " output(screen, \" %s\\n\", STRING_STATIC_MODULES);"; + + print "}"; + +} + diff --git a/source3/script/mkinstalldirs b/source3/script/mkinstalldirs new file mode 100755 index 0000000000..f945dbf2bc --- /dev/null +++ b/source3/script/mkinstalldirs @@ -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 diff --git a/source3/script/mknissmbpasswd.sh b/source3/script/mknissmbpasswd.sh new file mode 100755 index 0000000000..a94c963bdc --- /dev/null +++ b/source3/script/mknissmbpasswd.sh @@ -0,0 +1,31 @@ +#!/bin/sh +# +# Copyright (C) 1998 Benny Holmgren +# +# Script to import smbpasswd file into the smbpasswd NIS+ table. Reads +# from stdin the smbpasswd file. +# +while true +do + read row + if [ -z "$row" ] + then + break + fi + + if [ "`echo $row | cut -c1`" = "#" ] + then + continue + fi + + nistbladm -a \ + name=\"`echo $row | cut -d: -f1`\" \ + uid=\"`echo $row | cut -d: -f2`\" \ + lmpwd=\"`echo $row | cut -d: -f3`\" \ + ntpwd=\"`echo $row | cut -d: -f4`\" \ + acb=\"`echo $row | cut -d: -f5`\" \ + pwdlset_t=\"`echo $row | cut -d: -f6`\" \ + gcos=\"`echo $row | cut -d: -f7`\" \ + home=\"`echo $row | cut -d: -f8`\" \ + shell=\"`echo $row | cut -d: -f9`\" smbpasswd.org_dir.`nisdefaults -d` +done diff --git a/source3/script/mknissmbpwdtbl.sh b/source3/script/mknissmbpwdtbl.sh new file mode 100755 index 0000000000..a9b34ff9a7 --- /dev/null +++ b/source3/script/mknissmbpwdtbl.sh @@ -0,0 +1,42 @@ +#!/bin/sh +# +# Copyright (C) 1998 Benny Holmgren +# +# Creates smbpasswd table and smb group in NIS+ +# + +nistbladm \ + -D access=og=rmcd,nw= -c \ + -s : smbpasswd_tbl \ + name=S,nogw=r \ + uid=S,nogw=r \ + user_rid=S,nogw=r \ + smb_grpid=,nw+r \ + group_rid=,nw+r \ + acb=,nw+r \ + \ + lmpwd=C,nw=,g=r,o=rm \ + ntpwd=C,nw=,g=r,o=rm \ + \ + logon_t=,nw+r \ + logoff_t=,nw+r \ + kick_t=,nw+r \ + pwdlset_t=,nw+r \ + pwdlchg_t=,nw+r \ + pwdmchg_t=,nw+r \ + \ + full_name=,nw+r \ + home_dir=,nw+r \ + dir_drive=,nw+r \ + logon_script=,nw+r \ + profile_path=,nw+r \ + acct_desc=,nw+r \ + workstations=,nw+r \ + \ + hours=,nw+r \ + smbpasswd.org_dir.`nisdefaults -d` + +nisgrpadm -c smb.`nisdefaults -d` + +nischgrp smb.`nisdefaults -d` smbpasswd.org_dir.`nisdefaults -d` + diff --git a/source3/script/mksmbpasswd.sh b/source3/script/mksmbpasswd.sh new file mode 100755 index 0000000000..119a55611e --- /dev/null +++ b/source3/script/mksmbpasswd.sh @@ -0,0 +1,6 @@ +#!/bin/sh +awk 'BEGIN {FS=":" + printf("#\n# SMB password file.\n#\n") + } +{ printf( "%s:%s:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:[UD ]:LCT-00000000:%s\n", $1, $3, $5) } +' diff --git a/source3/script/mksyms.awk b/source3/script/mksyms.awk new file mode 100644 index 0000000000..a30bea4d34 --- /dev/null +++ b/source3/script/mksyms.awk @@ -0,0 +1,76 @@ +# +# mksyms.awk +# +# Extract symbols to export from C-header files. +# output in version-script format for linking shared libraries. +# +# Copyright (C) 2008 Micheal Adam <obnox@samba.org> +# +BEGIN { + inheader=0; + current_file=""; + print "#" + print "# This file is automatically generated with \"make symbols\". DO NOT EDIT " + print "#" + print "{" + print "\tglobal:" +} + +END { + print"" + print "\tlocal: *;" + print "};" +} + +{ + if (FILENAME!=current_file) { + print "\t\t# The following definitions come from",FILENAME + current_file=FILENAME + } + if (inheader) { + if (match($0,"[)][ \t]*[;][ \t]*$")) { + inheader = 0; + } + next; + } +} + +/^static/ || /^[ \t]*typedef/ || !/^[a-zA-Z\_]/ { + next; +} + +/^extern[ \t]+[^()]+[;][ \t]*$/ { + gsub(/[^ \t]+[ \t]+/, ""); + sub(/[;][ \t]*$/, ""); + printf "\t\t%s;\n", $0; + next; +} + +# look for function headers: +{ + gotstart = 0; + if ($0 ~ /^[A-Za-z_][A-Za-z0-9_]+/) { + gotstart = 1; + } + if(!gotstart) { + next; + } +} + +/[_A-Za-z0-9]+[ \t]*[(].*[)][ \t]*;[ \t]*$/ { + sub(/[(].*$/, ""); + gsub(/[^ \t]+[ \t]+/, ""); + gsub(/^[*]/, ""); + printf "\t\t%s;\n",$0; + next; +} + +/[_A-Za-z0-9]+[ \t]*[(]/ { + inheader=1; + sub(/[(].*$/, ""); + gsub(/[^ \t]+[ \t]+/, ""); + gsub(/^[*]/, ""); + printf "\t\t%s;\n",$0; + next; +} + diff --git a/source3/script/mksyms.sh b/source3/script/mksyms.sh new file mode 100755 index 0000000000..51d3fbd999 --- /dev/null +++ b/source3/script/mksyms.sh @@ -0,0 +1,45 @@ +#! /bin/sh + +# +# mksyms.sh +# +# Extract symbols to export from C-header files. +# output in version-script format for linking shared libraries. +# +# This is the shell warpper for the mksyms.awk core script. +# +# Copyright (C) 2008 Micheal Adam <obnox@samba.org> +# + +LANG=C; export LANG +LC_ALL=C; export LC_ALL +LC_COLLATE=C; export LC_COLLATE + +if [ $# -lt 2 ] +then + echo "Usage: $0 awk output_file header_files" + exit 1 +fi + +awk="$1" +shift + +symsfile="$1" +shift +symsfile_tmp="$symsfile.$$.tmp~" + +proto_src="`echo $@ | tr ' ' '\n' | sort | uniq `" + +echo creating $symsfile + +mkdir -p `dirname $symsfile` + +${awk} -f `dirname $0`/mksyms.awk $proto_src > $symsfile_tmp + +if cmp -s $symsfile $symsfile_tmp 2>/dev/null +then + echo "$symsfile unchanged" + rm $symsfile_tmp +else + mv $symsfile_tmp $symsfile +fi diff --git a/source3/script/mkversion.sh b/source3/script/mkversion.sh new file mode 100755 index 0000000000..a55aafcd0c --- /dev/null +++ b/source3/script/mkversion.sh @@ -0,0 +1,145 @@ +#!/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="include/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_GIT_SNAPSHOT=`sed -n 's/^SAMBA_VERSION_IS_GIT_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` + +SAMBA_VERSION_VENDOR_FUNCTION=`sed -n 's/^SAMBA_VERSION_VENDOR_FUNCTION=//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 + +## +## GIT commit details +## +if test x"${SAMBA_VERSION_IS_GIT_SNAPSHOT}" = x"yes";then + _SAVE_LANG=${LANG} + LANG="C" + HAVEVER="no" + + if test x"${HAVEVER}" != x"yes" -a -d "${SOURCE_DIR}../.git";then + HAVEGIT=no + GIT_INFO=`git show --pretty=format:"%h%n%ct%n%H%n%cd" --stat HEAD 2>/dev/null` + GIT_COMMIT_ABBREV=`printf "%s" "${GIT_INFO}" | sed -n 1p` + GIT_COMMIT_TIME=`printf "%s" "${GIT_INFO}" | sed -n 2p` + GIT_COMMIT_FULLREV=`printf "%s" "${GIT_INFO}" | sed -n 3p` + GIT_COMMIT_DATE=`printf "%s" "${GIT_INFO}" | sed -n 4p` + if test -n "${GIT_COMMIT_ABBREV}";then + HAVEGIT=yes + HAVEVER=yes + fi + fi + + if test x"${HAVEGIT}" = x"yes";then + SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}-GIT-${GIT_COMMIT_ABBREV}" + + echo "#define SAMBA_VERSION_GIT_COMMIT_ABBREV \"${GIT_COMMIT_ABBREV}\"" >> $OUTPUT_FILE + echo "#define SAMBA_VERSION_GIT_COMMIT_TIME ${GIT_COMMIT_TIME}" >> $OUTPUT_FILE + echo "#define SAMBA_VERSION_GIT_COMMIT_FULLREV \"${GIT_COMMIT_FULLREV}\"" >> $OUTPUT_FILE + echo "#define SAMBA_VERSION_GIT_COMMIT_DATE \"${GIT_COMMIT_DATE}\"" >> $OUTPUT_FILE + else + SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}-GIT-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_FUNCTION}"; then + echo "#define SAMBA_VERSION_VENDOR_FUNCTION ${SAMBA_VERSION_VENDOR_FUNCTION}" >> $OUTPUT_FILE +fi + +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 + +cat >>$OUTPUT_FILE<<CEOF +#ifdef SAMBA_VERSION_VENDOR_FUNCTION +# define SAMBA_VERSION_STRING SAMBA_VERSION_VENDOR_FUNCTION +#else /* SAMBA_VERSION_VENDOR_FUNCTION */ +# ifdef SAMBA_VERSION_VENDOR_SUFFIX +# ifdef SAMBA_VERSION_VENDOR_PATCH +# define SAMBA_VERSION_STRING SAMBA_VERSION_OFFICIAL_STRING "-" SAMBA_VERSION_VENDOR_SUFFIX "-" SAMBA_VERSION_VENDOR_PATCH +# else /* SAMBA_VERSION_VENDOR_PATCH */ +# define SAMBA_VERSION_STRING SAMBA_VERSION_OFFICIAL_STRING "-" SAMBA_VERSION_VENDOR_SUFFIX +# endif /* SAMBA_VERSION_VENDOR_SUFFIX */ +# else /* SAMBA_VERSION_VENDOR_FUNCTION */ +# define SAMBA_VERSION_STRING SAMBA_VERSION_OFFICIAL_STRING +# endif +#endif +CEOF + +echo "$0: '$OUTPUT_FILE' created for Samba(\"${SAMBA_VERSION_STRING}\")" + +exit 0 diff --git a/source3/script/revert.sh b/source3/script/revert.sh new file mode 100755 index 0000000000..8df5fd2fbd --- /dev/null +++ b/source3/script/revert.sh @@ -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 + diff --git a/source3/script/scancvslog.pl b/source3/script/scancvslog.pl new file mode 100755 index 0000000000..c39f9111c1 --- /dev/null +++ b/source3/script/scancvslog.pl @@ -0,0 +1,112 @@ +#!/usr/bin/perl +require"timelocal.pl"; + +# +# usage scancvslog.pl logfile starttime tag +# +# this will extract all entries from the specified cvs log file +# that have a date later than or equal to starttime and a tag +# value of tag. If starttime is not specified, all entries are +# extracted. If tag is not specified then entries for all +# branches are extracted. starttime must be specified as +# "monthname day, year" +# +# Example to extract all entries for SAMBA_2_2 branch from the +# log file named cvs.log +# +# scancvslog.pl cvs.log "" SAMBA_2_2 +# +# +# To extract all log entries after Jan 10, 1999 (Note month name +# must be spelled out completely). +# +# scancvslog.pl cvs.log "January 10, 1999" +# + +open(INFILE,@ARGV[0]) || die "Unable to open @ARGV[0]\n"; + +%Monthnum = ( + "January", 0, + "February", 1, + "March", 2, + "April", 3, + "May", 4, + "June", 5, + "July", 6, + "August", 7, + "September", 8, + "October", 9, + "November", 10, + "December", 11, + "Jan", 0, + "Feb", 1, + "Mar", 2, + "Apr", 3, + "May", 4, + "Jun", 5, + "Jul", 6, + "Aug", 7, + "Sep", 8, + "Oct", 9, + "Nov", 10, + "Dec", 11 +); + +$Starttime = (@ARGV[1]) ? &make_time(@ARGV[1]) : 0; +$Tagvalue = @ARGV[2]; + +while (&get_entry) { + $_=$Entry[0]; +# get rid of extra white space + s/\s+/ /g; +# get rid of any time string in date + s/ \d\d:\d\d:\d\d/,/; + s/^Date:\s*\w*\s*(\w*)\s*(\w*),\s*(\w*).*/$1 $2 $3/; + $Testtime = &make_time($_); + $Testtag = &get_tag; + if (($Testtime >= $Starttime) && ($Tagvalue eq $Testtag)) { + print join("\n",@Entry),"\n"; + } +} +close(INFILE); + +sub make_time { + $_ = @_[0]; + s/,//; + ($month, $day, $year) = split(" ",$_); + if (($year < 1900)||($day < 1)||($day > 31)||not length($Monthnum{$month})) { + print "Bad date format @_[0]\n"; + print "Date needs to be specified as \"Monthname day, year\"\n"; + print "eg: \"January 10, 1999\"\n"; + exit 1; + } + $year = ($year == 19100) ? 2000 : $year; + $month = $Monthnum{$month}; + $Mytime=&timelocal((0,0,0,$day,$month,$year)); +} + +sub get_tag { + @Mytag = grep (/Tag:/,@Entry); + $_ = @Mytag[0]; + s/^.*Tag:\s*(\w*).*/$1/; + return $_; +} + +sub get_entry { + @Entry=(); + if (not eof(INFILE)) { + while (not eof(INFILE)) { + $_ = <INFILE>; + chomp $_; + next if (not ($_)); + if (/^\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/) { + next if ($#Entry == -1); + push(Entry,$_); + return @Entry; + } else { + push(Entry,$_); + } + } + } + return @Entry; +} diff --git a/source3/script/smbtar b/source3/script/smbtar new file mode 100644 index 0000000000..67a794553c --- /dev/null +++ b/source3/script/smbtar @@ -0,0 +1,165 @@ +#!/bin/sh +# +# smbtar script - front end to smbclient +# +# Authors: Martin.Kraemer <Martin.Kraemer@mch.sni.de> +# and Ricky Poulten (ricky@logcam.co.uk) +# +# (May need to change shell to ksh for HPUX or OSF for better getopts) +# +# sandy nov 3 '98 added -a flag +# +# Richard Sharpe, added -c 'tarmode full' so that we back up all files to +# fix a bug in clitar when a patch was added to stop system and hidden files +# being backed up. + +case $0 in + # when called by absolute path, assume smbclient is in the same directory + /*) + SMBCLIENT="`dirname $0`/smbclient";; + *) # you may need to edit this to show where your smbclient is + SMBCLIENT="smbclient";; +esac + +# These are the default values. You could fill them in if you know what +# you're doing, but beware: better not store a plain text password! +server="" +service="backup" # Default: a service called "backup" +password="" +username=$LOGNAME # Default: same user name as in *nix +verbose="2>/dev/null" # Default: no echo to stdout +log="-d 2" +newer="" +newerarg="" +blocksize="" +blocksizearg="" +clientargs="-c 'tarmode full'" +tarcmd="c" +tarargs="" +cdcmd="\\" +tapefile=${TAPE-tar.out} + +Usage(){ + ex=$1 + shift +echo >&2 "Usage: `basename $0` [<options>] [<include/exclude files>] +Function: backup/restore a Windows PC directories to a local tape file +Options: (Description) (Default) + -r Restore from tape file to PC Save from PC to tapefile + -i Incremental mode Full backup mode + -a Reset archive bit mode Don't reset archive bit + -v Verbose mode: echo command Don't echo anything + -s <server> Specify PC Server $server + -p <password> Specify PC Password $password + -x <share> Specify PC Share $service + -X Exclude mode Include + -N <newer> File for date comparison `set -- $newer; echo $2` + -b <blocksize> Specify tape's blocksize `set -- $blocksize; echo $2` + -d <dir> Specify a directory in share $cdcmd + -l <log> Specify a Samba Log Level `set -- $log; echo $2` + -u <user> Specify User Name $username + -t <tape> Specify Tape device $tapefile +" + echo >&2 "$@" + exit $ex +} + +# echo Params count: $# + +# DEC OSF AKA Digital UNIX does not seem to return a value in OPTIND if +# there are no command line params, so protect us against that ... +if [ $# = 0 ]; then + + Usage 2 "Please enter a command line parameter!" + +fi + +while getopts riavl:b:d:N:s:p:x:u:Xt: c; do + case $c in + r) # [r]estore to Windows (instead of the default "Save from Windows") + tarcmd="x" + ;; + i) # [i]ncremental + tarargs=${tarargs}ga + clientargs="-c 'tarmode inc'" + ;; + a) # [a]rchive + tarargs=${tarargs}a + ;; + l) # specify [l]og file + log="-d $OPTARG" + case "$OPTARG" in + [0-9]*) ;; + *) echo >&2 "$0: Error, log level not numeric: -l $OPTARG" + exit 1 + esac + ;; + d) # specify [d]irectory to change to in server's share + cdcmd="$OPTARG" + ;; + N) # compare with a file, test if [n]ewer + if [ -f $OPTARG ]; then + newer=$OPTARG + newerarg="N" + else + echo >&2 $0: Warning, $OPTARG not found + fi + ;; + X) # Add exclude flag + tarargs=${tarargs}X + ;; + s) # specify [s]erver's share to connect to - this MUST be given. + server="$OPTARG" + ;; + b) # specify [b]locksize + blocksize="$OPTARG" + case "$OPTARG" in + [0-9]*) ;; + *) echo >&2 "$0: Error, block size not numeric: -b $OPTARG" + exit 1 + esac + blocksizearg="b" + ;; + p) # specify [p]assword to use + password="$OPTARG" + ;; + x) # specify windows [s]hare to use + service="$OPTARG" + ;; + t) # specify [t]apefile on local host + tapefile="$OPTARG" + ;; + u) # specify [u]sername for connection + username="$OPTARG" + ;; + v) # be [v]erbose and display what's going on + verbose="" + ;; + '?') # any other switch + Usage 2 "Invalid switch specified - abort." + ;; + esac +done + +shift `expr $OPTIND - 1` + +if [ "$server" = "" ] || [ "$service" = "" ]; then + Usage 1 "No server or no service specified - abort." +fi + +# if the -v switch is set, the echo the current parameters +if [ -z "$verbose" ]; then + echo "server is $server" +# echo "share is $service" + echo "share is $service\\$cdcmd" + echo "tar args is $tarargs" +# echo "password is $password" # passwords should never be sent to screen + echo "tape is $tapefile" + echo "blocksize is $blocksize" +fi + +tarargs=${tarargs}${blocksizearg}${newerarg} + +eval $SMBCLIENT "'\\\\$server\\$service'" "'$password'" -U "'$username'" \ +-E $log -D "'$cdcmd'" ${clientargs} \ +-T${tarcmd}${tarargs} $blocksize $newer $tapefile '${1+"$@"}' $verbose diff --git a/source3/script/strip_trail_ws.pl b/source3/script/strip_trail_ws.pl new file mode 100755 index 0000000000..c2c39e21e3 --- /dev/null +++ b/source3/script/strip_trail_ws.pl @@ -0,0 +1,18 @@ +#!/usr/bin/perl -w + +open( INFILE, "$ARGV[0]" ) || die $@; +open( OUTFILE, ">$ARGV[0].new" ) || die $@; + +while ( <INFILE> ) { + $_ =~ s/[ \t\r]*$//; + print OUTFILE "$_"; +} + +close( INFILE ); +close( OUTFILE ); + +rename( "$ARGV[0].new", "$ARGV[0]" ) || die @_; + +exit( 0 ); + + diff --git a/source3/script/tests/dlopen.sh b/source3/script/tests/dlopen.sh new file mode 100755 index 0000000000..edf44719d3 --- /dev/null +++ b/source3/script/tests/dlopen.sh @@ -0,0 +1,90 @@ +#!/bin/sh +# +# Copyright (C) Nalin Dahyabhai <nalin@redhat.com> 2003 +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, see <http://www.gnu.org/licenses/>. + +tempdir=`mktemp -d /tmp/dlopenXXXXXX` +test -n "$tempdir" || exit 1 +cat >> $tempdir/dlopen.c << _EOF +#include <dlfcn.h> +#include <stdio.h> +#include <limits.h> +#include <sys/stat.h> +/* Simple program to see if dlopen() would succeed. */ +int main(int argc, char **argv) +{ + int i; + struct stat st; + char buf[PATH_MAX]; + for (i = 1; i < argc; i++) { + if (dlopen(argv[i], RTLD_NOW)) { + fprintf(stdout, "dlopen() of \"%s\" succeeded.\n", + argv[i]); + } else { + snprintf(buf, sizeof(buf), "./%s", argv[i]); + if ((stat(buf, &st) == 0) && dlopen(buf, RTLD_NOW)) { + fprintf(stdout, "dlopen() of \"./%s\" " + "succeeded.\n", argv[i]); + } else { + fprintf(stdout, "dlopen() of \"%s\" failed: " + "%s\n", argv[i], dlerror()); + return 1; + } + } + } + return 0; +} +_EOF + +for arg in $@ ; do + case "$arg" in + "") + ;; + -I*|-D*|-f*|-m*|-g*|-O*|-W*) + cflags="$cflags $arg" + ;; + -l*|-L*) + ldflags="$ldflags $arg" + ;; + /*) + modules="$modules $arg" + ;; + *) + modules="$modules $arg" + ;; + esac +done + +${CC:-gcc} $RPM_OPT_FLAGS $CFLAGS -o $tempdir/dlopen $cflags $tempdir/dlopen.c $ldflags -ldl + +retval=0 +for module in $modules ; do + case "$module" in + "") + ;; + /*) + $tempdir/dlopen "$module" + retval=$? + ;; + *) + $tempdir/dlopen ./"$module" + retval=$? + ;; + esac +done + +rm -f $tempdir/dlopen $tempdir/dlopen.c +rmdir $tempdir +exit $retval diff --git a/source3/script/tests/gdb_backtrace b/source3/script/tests/gdb_backtrace new file mode 100755 index 0000000000..826381e900 --- /dev/null +++ b/source3/script/tests/gdb_backtrace @@ -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 | grep '^/'` + 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} diff --git a/source3/script/tests/selftest.sh b/source3/script/tests/selftest.sh new file mode 100755 index 0000000000..15e48b00ef --- /dev/null +++ b/source3/script/tests/selftest.sh @@ -0,0 +1,324 @@ +#!/bin/sh + +if [ $# != 3 ]; then + echo "$0 <directory> <all | quick> <smbtorture4>" + exit 1 +fi + +SMBTORTURE4=$3 +SUBTESTS=$2 + +## +## create the test directory +## +PREFIX=`echo $1 | sed s+//+/+` +mkdir -p $PREFIX || exit $? +OLD_PWD=`pwd` +cd $PREFIX || exit $? +PREFIX_ABS=`pwd` +cd $OLD_PWD + +if [ -z "$TORTURE_MAXTIME" ]; then + TORTURE_MAXTIME=300 +fi +export TORTURE_MAXTIME + +## +## setup the various environment variables we need +## + +WORKGROUP=SAMBA-TEST +SERVER=localhost2 +SERVER_IP=127.0.0.2 +USERNAME=`PATH=/usr/ucb:$PATH whoami` +USERID=`PATH=/usr/ucb:$PATH id | cut -d ' ' -f1 | sed -e 's/uid=\([0-9]*\).*/\1/g'` +GROUPID=`PATH=/usr/ucb:$PATH id | cut -d ' ' -f2 | sed -e 's/gid=\([0-9]*\).*/\1/g'` +PASSWORD=test + +SRCDIR="`dirname $0`/../.." +BINDIR="`pwd`/bin" +SCRIPTDIR=$SRCDIR/script/tests +SHRDIR=$PREFIX_ABS/tmp +LIBDIR=$PREFIX_ABS/lib +PIDDIR=$PREFIX_ABS/pid +CONFFILE=$LIBDIR/client.conf +SAMBA4CONFFILE=$LIBDIR/samba4client.conf +SERVERCONFFILE=$LIBDIR/server.conf +COMMONCONFFILE=$LIBDIR/common.conf +PRIVATEDIR=$PREFIX_ABS/private +LOCKDIR=$PREFIX_ABS/lockdir +LOGDIR=$PREFIX_ABS/logs +SOCKET_WRAPPER_DIR=$PREFIX/sw +CONFIGURATION="--configfile $CONFFILE" +SAMBA4CONFIGURATION="-s $SAMBA4CONFFILE" +NSS_WRAPPER_PASSWD="$PRIVATEDIR/passwd" +NSS_WRAPPER_GROUP="$PRIVATEDIR/group" +WINBINDD_SOCKET_DIR=$PREFIX_ABS/winbindd +WINBINDD_PRIV_PIPE_DIR=$LOCKDIR/winbindd_privileged + +export PREFIX PREFIX_ABS +export CONFIGURATION CONFFILE SAMBA4CONFIGURATION SAMBA4CONFFILE +export PATH SOCKET_WRAPPER_DIR DOMAIN +export PRIVATEDIR LIBDIR PIDDIR LOCKDIR LOGDIR SERVERCONFFILE +export SRCDIR SCRIPTDIR BINDIR +export USERNAME PASSWORD +export WORKGROUP SERVER SERVER_IP +export NSS_WRAPPER_PASSWD NSS_WRAPPER_GROUP +export WINBINDD_SOCKET_DIR WINBINDD_PRIV_PIPE_DIR + +PATH=bin:$PATH +export PATH + +if test x"$LD_LIBRARY_PATH" != x""; then + LD_LIBRARY_PATH="$BINDIR:$LD_LIBRARY_PATH" +else + LD_LIBRARY_PATH="$BINDIR" +fi +echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" +export LD_LIBRARY_PATH + +SAMBA4BINDIR=`dirname $SMBTORTURE4` +SAMBA4SHAREDDIR="$SAMBA4BINDIR/shared" + +export SAMBA4SHAREDDIR +export SMBTORTURE4 + +## +## verify that we were built with --enable-socket-wrapper +## + +if test "x`smbd -b | grep SOCKET_WRAPPER`" = "x"; then + echo "***" + echo "*** You must include --enable-socket-wrapper when compiling Samba" + echo "*** in order to execute 'make test'. Exiting...." + echo "***" + exit 1 +fi + +if test "x`smbd -b | grep NSS_WRAPPER`" = "x"; then + echo "***" + echo "*** You must include --enable-nss-wrapper when compiling Samba" + echo "*** in order to execute 'make test'. Exiting...." + echo "***" + exit 1 +fi + + +## +## create the test directory layout +## +printf "%s" "CREATE TEST ENVIRONMENT IN '$PREFIX'"... +/bin/rm -rf $PREFIX/* +mkdir -p $PRIVATEDIR $LIBDIR $PIDDIR $LOCKDIR $LOGDIR +mkdir -p $SOCKET_WRAPPER_DIR +mkdir -p $WINBINDD_SOCKET_DIR +chmod 755 $WINBINDD_SOCKET_DIR +mkdir -p $PREFIX_ABS/tmp +chmod 777 $PREFIX_ABS/tmp + +## +## Create the common config include file with the basic settings +## + +cat >$COMMONCONFFILE<<EOF + workgroup = $WORKGROUP + + private dir = $PRIVATEDIR + pid directory = $PIDDIR + lock directory = $LOCKDIR + log file = $LOGDIR/log.%m + log level = 0 + + name resolve order = bcast +EOF + +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' + +cat >$CONFFILE<<EOF +[global] + netbios name = TORTURE_6 + interfaces = $TORTURE_INTERFACES + panic action = $SCRIPTDIR/gdb_backtrace %d %\$(MAKE_TEST_BINARY) + include = $COMMONCONFFILE + + passdb backend = tdbsam +EOF + +cat >$SAMBA4CONFFILE<<EOF +[global] + netbios name = TORTURE_6 + interfaces = $TORTURE_INTERFACES + panic action = $SCRIPTDIR/gdb_backtrace %PID% %PROG% + include = $COMMONCONFFILE +EOF + +cat >$SERVERCONFFILE<<EOF +[global] + netbios name = $SERVER + interfaces = $SERVER_IP/8 + bind interfaces only = yes + panic action = $SCRIPTDIR/gdb_backtrace %d %\$(MAKE_TEST_BINARY) + include = $COMMONCONFFILE + + passdb backend = tdbsam + + domain master = yes + domain logons = yes + time server = yes + + add user script = $PERL $SRCDIR/lib/nss_wrapper/nss_wrapper.pl --path $NSS_WRAPPER_PASSWD --type passwd --action add --name %u + add machine script = $PERL $SRCDIR/lib/nss_wrapper/nss_wrapper.pl --path $NSS_WRAPPER_PASSWD --type passwd --action add --name %u + delete user script = $PERL $SRCDIR/lib/nss_wrapper/nss_wrapper.pl --path $NSS_WRAPPER_PASSWD --type passwd --action delete --name %u + + kernel oplocks = no + kernel change notify = no + + syslog = no + printing = bsd + printcap name = /dev/null + + winbindd:socket dir = $WINBINDD_SOCKET_DIR + idmap uid = 100000-200000 + idmap gid = 100000-200000 + +# min receivefile size = 4000 + +[tmp] + path = $PREFIX_ABS/tmp + read only = no + smbd:sharedelay = 100000 + smbd:writetimeupdatedelay = 500000 + map hidden = yes + map system = yes + create mask = 755 + vfs objects = $BINDIR/xattr_tdb.so $BINDIR/streams_xattr.so +[hideunread] + copy = tmp + hide unreadable = yes +[hideunwrite] + copy = tmp + hide unwriteable files = yes +[print1] + copy = tmp + printable = yes + printing = test +[print2] + copy = print1 +[print3] + copy = print1 +[print4] + copy = print1 +EOF + +## +## create a test account +## + +cat >$NSS_WRAPPER_PASSWD<<EOF +nobody:x:65534:65533:nobody gecos:$PREFIX_ABS:/bin/false +$USERNAME:x:$USERID:$GROUPID:$USERNAME gecos:$PREFIX_ABS:/bin/false +EOF + +cat >$NSS_WRAPPER_GROUP<<EOF +nobody:x:65533: +nogroup:x:65534:nobody +$USERNAME-group:x:$GROUPID: +EOF + +MAKE_TEST_BINARY="bin/smbpasswd" +export MAKE_TEST_BINARY + +(echo $PASSWORD; echo $PASSWORD) | \ + bin/smbpasswd -c $CONFFILE -L -s -a $USERNAME >/dev/null || exit 1 + +echo "DONE"; + +MAKE_TEST_BINARY="" + +SERVER_TEST_FIFO="$PREFIX/server_test.fifo" +export SERVER_TEST_FIFO +NMBD_TEST_LOG="$PREFIX/nmbd_test.log" +export NMBD_TEST_LOG +WINBINDD_TEST_LOG="$PREFIX/winbindd_test.log" +export WINBINDD_TEST_LOG +SMBD_TEST_LOG="$PREFIX/smbd_test.log" +export SMBD_TEST_LOG + +# start off with 0 failures +failed=0 +export failed + +. $SCRIPTDIR/test_functions.sh + +SOCKET_WRAPPER_DEFAULT_IFACE=2 +export SOCKET_WRAPPER_DEFAULT_IFACE +samba3_check_or_start + + +# ensure any one smbtorture call doesn't run too long +# and smbtorture will use 127.0.0.6 as source address by default +SOCKET_WRAPPER_DEFAULT_IFACE=6 +export SOCKET_WRAPPER_DEFAULT_IFACE +TORTURE4_OPTIONS="$SAMBA4CONFIGURATION" +TORTURE4_OPTIONS="$TORTURE4_OPTIONS --maximum-runtime=$TORTURE_MAXTIME" +TORTURE4_OPTIONS="$TORTURE4_OPTIONS --target=samba3" +TORTURE4_OPTIONS="$TORTURE4_OPTIONS --option=torture:localdir=$PREFIX_ABS/tmp" +export TORTURE4_OPTIONS + +if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then + TORTURE4_OPTIONS="$TORTURE4_OPTIONS --option=torture:progress=no" +fi + + +## +## ready to go...now loop through the tests +## + +START=`date` +( + # give time for nbt server to register its names + echo "delaying for nbt name registration" + sleep 10 + # This will return quickly when things are up, but be slow if we need to wait for (eg) SSL init + MAKE_TEST_BINARY="bin/nmblookup" + bin/nmblookup $CONFIGURATION -U $SERVER_IP __SAMBA__ + bin/nmblookup $CONFIGURATION __SAMBA__ + bin/nmblookup $CONFIGURATION -U 127.255.255.255 __SAMBA__ + bin/nmblookup $CONFIGURATION -U $SERVER_IP $SERVER + bin/nmblookup $CONFIGURATION $SERVER + # make sure smbd is also up set + echo "wait for smbd" + MAKE_TEST_BINARY="bin/smbclient" + bin/smbclient $CONFIGURATION -L $SERVER_IP -U% -p 139 | head -2 + bin/smbclient $CONFIGURATION -L $SERVER_IP -U% -p 139 | head -2 + MAKE_TEST_BINARY="" + + failed=0 + + . $SCRIPTDIR/tests_$SUBTESTS.sh + exit $failed +) +failed=$? + +samba3_stop_sig_term + +END=`date` +echo "START: $START ($0)"; +echo "END: $END ($0)"; + +# 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 ]; then + echo "VALGRIND FAILURE"; + failed=`expr $failed + 1` + cat $f + fi + done +fi + +sleep 2 +samba3_stop_sig_kill + +teststatus $0 $failed diff --git a/source3/script/tests/test_functions.sh b/source3/script/tests/test_functions.sh new file mode 100644 index 0000000000..407d46aa9e --- /dev/null +++ b/source3/script/tests/test_functions.sh @@ -0,0 +1,333 @@ + +samba3_stop_sig_term() { + RET=0 + kill -USR1 `cat $PIDDIR/timelimit.nmbd.pid` >/dev/null 2>&1 || \ + kill -ALRM `cat $PIDDIR/timelimit.nmbd.pid` || RET=$? + + kill -USR1 `cat $PIDDIR/timelimit.winbindd.pid` >/dev/null 2>&1 || \ + kill -ALRM `cat $PIDDIR/timelimit.winbindd.pid` || RET=$? + + kill -USR1 `cat $PIDDIR/timelimit.smbd.pid` >/dev/null 2>&1 || \ + kill -ALRM `cat $PIDDIR/timelimit.smbd.pid` || RET=$? + + return $RET; +} + +samba3_stop_sig_kill() { + kill -ALRM `cat $PIDDIR/timelimit.nmbd.pid` >/dev/null 2>&1 + kill -ALRM `cat $PIDDIR/timelimit.winbindd.pid` >/dev/null 2>&1 + kill -ALRM `cat $PIDDIR/timelimit.smbd.pid` >/dev/null 2>&1 + return 0; +} + +samba3_check_or_start() { + if [ -n "$SERVER_TEST_FIFO" ];then + + trap samba3_stop_sig_kill INT QUIT + trap samba3_stop_sig_kill TERM + + if [ -p "$SERVER_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 $SERVER_TEST_FIFO + mkfifo $SERVER_TEST_FIFO + + rm -f $NMBD_TEST_LOG + printf "%s" "STARTING NMBD..." + (( + if test x"$NMBD_MAXTIME" = x; then + NMBD_MAXTIME=2700 + fi + MAKE_TEST_BINARY=$BINDIR/nmbd + export MAKE_TEST_BINARY + timelimit $NMBD_MAXTIME $NMBD_VALGRIND $BINDIR/nmbd -F -S --no-process-group -d0 -s $SERVERCONFFILE > $NMBD_TEST_LOG 2>&1 & + TIMELIMIT_NMBD_PID=$! + MAKE_TEST_BINARY= + echo $TIMELIMIT_NMBD_PID > $PIDDIR/timelimit.nmbd.pid + wait $TIMELIMIT_NMBD_PID + ret=$?; + rm -f $SERVER_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 "nmbd exits with status $ret"; + echo "nmbd exits with status $ret" >>$NMBD_TEST_LOG; + elif [ x"$ret" = x"137" ];then + echo "nmbd got SIGXCPU and exits with status $ret!" + echo "nmbd got SIGXCPU and exits with status $ret!">>$NMBD_TEST_LOG; + else + echo "nmbd failed with status $ret!" + echo "nmbd failed with status $ret!">>$NMBD_TEST_LOG; + fi + exit $ret; + ) || exit $? &) 2>/dev/null || exit $? + echo "DONE" + + rm -f $WINBINDD_TEST_LOG + printf "%s" "STARTING WINBINDD..." + (( + if test x"$WINBINDD_MAXTIME" = x; then + WINBINDD_MAXTIME=2700 + fi + MAKE_TEST_BINARY=$BINDIR/winbindd + export MAKE_TEST_BINARY + timelimit $WINBINDD_MAXTIME $WINBINDD_VALGRIND $BINDIR/winbindd -F -S --no-process-group -d0 -s $SERVERCONFFILE > $WINBINDD_TEST_LOG 2>&1 & + TIMELIMIT_WINBINDD_PID=$! + MAKE_TEST_BINARY= + echo $TIMELIMIT_WINBINDD_PID > $PIDDIR/timelimit.winbindd.pid + wait $TIMELIMIT_WINBINDD_PID + ret=$?; + rm -f $SERVER_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 "winbindd exits with status $ret"; + echo "winbindd exits with status $ret" >>$WINBINDD_TEST_LOG; + elif [ x"$ret" = x"137" ];then + echo "winbindd got SIGXCPU and exits with status $ret!" + echo "winbindd got SIGXCPU and exits with status $ret!">>$WINBINDD_TEST_LOG; + else + echo "winbindd failed with status $ret!" + echo "winbindd failed with status $ret!">>$WINBINDD_TEST_LOG; + fi + exit $ret; + ) || exit $? &) 2>/dev/null || exit $? + echo "DONE" + + rm -f $SMBD_TEST_LOG + printf "%s" "STARTING SMBD..." + (( + if test x"$SMBD_MAXTIME" = x; then + SMBD_MAXTIME=2700 + fi + MAKE_TEST_BINARY=$BINDIR/smbd + export MAKE_TEST_BINARY + timelimit $SMBD_MAXTIME $SMBD_VALGRIND $BINDIR/smbd -F -S --no-process-group -d0 -s $SERVERCONFFILE > $SMBD_TEST_LOG 2>&1 & + TIMELIMIT_SMBD_PID=$! + MAKE_TEST_BINARY= + echo $TIMELIMIT_SMBD_PID > $PIDDIR/timelimit.smbd.pid + wait $TIMELIMIT_SMBD_PID + ret=$?; + rm -f $SERVER_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; +} + +samba3_nmbd_test_log() { + if [ -n "$NMBD_TEST_LOG" ];then + if [ -r "$NMBD_TEST_LOG" ];then + return 0; + fi + fi + return 1; +} + +samba3_winbindd_test_log() { + if [ -n "$WINBINDD_TEST_LOG" ];then + if [ -r "$WINBINDD_TEST_LOG" ];then + return 0; + fi + fi + return 1; +} + +samba3_smbd_test_log() { + if [ -n "$SMBD_TEST_LOG" ];then + if [ -r "$SMBD_TEST_LOG" ];then + return 0; + fi + fi + return 1; +} + +samba3_check_only() { + if [ -n "$SERVER_TEST_FIFO" ];then + if [ -p "$SERVER_TEST_FIFO" ];then + return 0; + fi + return 1; + fi + return 0; +} + +testit() { + if [ -z "$PREFIX" ]; then + PREFIX=test_prefix + mkdir -p $PREFIX + fi + name=$1 + shift 1 + binary=$1 + cmdline="$*" + + SERVERS_ARE_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 [ -z "$nmbd_log_size" ]; then + nmbd_log_size=`wc -l < $NMBD_TEST_LOG`; + fi + if [ -z "$winbindd_log_size" ]; then + winbindd_log_size=`wc -l < $WINBINDD_TEST_LOG`; + fi + if [ -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 + echo "Testing $name ($failed)" + fi + + samba3_check_only && SERVERS_ARE_UP="yes" + if [ x"$SERVERS_ARE_UP" != x"yes" ];then + if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then + echo "SERVERS are down! Skipping: $cmdline" + echo "==========================================" + echo "TEST SKIPPED: $name (reason SERVERS are down)" + echo "==========================================" + else + echo "TEST SKIPPED: $name (reason SERVERS are 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 + + MAKE_TEST_BINARY=$binary + export MAKE_TEST_BINARY + ( $cmdline > $TEST_LOG 2>&1 ) + status=$? + MAKE_TEST_BINARY= + # show any additional output from smbd that has happened in this test + samba3_nmbd_test_log && { + new_log_size=`wc -l < $NMBD_TEST_LOG`; + test "$new_log_size" = "$nmbd_log_size" || { + echo "NMBD OUTPUT:"; + incr_log_size=`expr $new_log_size - $nmbd_log_size`; + tail -$incr_log_size $NMBD_TEST_LOG; + nmbd_log_size=$new_log_size; + } + } + samba3_winbindd_test_log && { + new_log_size=`wc -l < $WINBINDD_TEST_LOG`; + test "$new_log_size" = "$winbindd_log_size" || { + echo "WINBINDD OUTPUT:"; + incr_log_size=`expr $new_log_size - $winbindd_log_size`; + tail -$incr_log_size $WINBINDD_TEST_LOG; + winbindd_log_size=$new_log_size; + } + } + samba3_smbd_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 + + if [ x"$failed" = x"0" ];then + echo "TEST STATUS: $failed"; + else + echo "TEST STATUS: $failed"; + fi + exit $failed +} + +if [ -z "$VALGRIND" ]; then + MALLOC_CHECK_=2 + export MALLOC_CHECK_ +fi + diff --git a/source3/script/tests/test_groupmap.sh b/source3/script/tests/test_groupmap.sh new file mode 100755 index 0000000000..46640a9131 --- /dev/null +++ b/source3/script/tests/test_groupmap.sh @@ -0,0 +1,214 @@ +#!/bin/sh +# test groupmap code tridge@samba.org September 2006 +# note that this needs root access to add unix groups, +# so this cannot be run on the build farm + +testone() { + echo $* + $VALGRIND bin/net groupmap $* +} + +tstart() { + TBASE=`date '+%s'` +} + +treport() { + TNOW=`date '+%s'` + echo "Took `expr $TNOW - $TBASE` seconds" + TBASE=$TNOW +} + +rm -f $PREFIX_ABS/var/locks/group_mapping.?db + +NLOCAL=12 +NGROUP=11 +NBUILTIN=10 +DOMSID=`bin/net getlocalsid | awk '{print $6}'` +FORSID="S-1-2-3-4-5" + +echo "DOMSID $DOMSID" +echo "FORSID $FORSID" + +tstart +echo "Creating unix groups" +for i in `seq 1 1 $NLOCAL`; do + unixgroup=testlocal$i; + gid=`expr 30000 + $i`; + groupdel $unixgroup 2> /dev/null + groupadd -g $gid $unixgroup || exit 1 +done +for i in `seq 1 1 $NGROUP`; do + unixgroup=testgrp$i; + gid=`expr 40000 + $i`; + groupdel $unixgroup 2> /dev/null + groupadd -g $gid $unixgroup || exit 1 +done +for i in `seq 1 1 $NBUILTIN`; do + unixgroup=testb$i; + gid=`expr 50000 + $i`; + groupdel $unixgroup 2> /dev/null + groupadd -g $gid $unixgroup || exit 1 +done +date + +treport + +echo "Creating local groups" +for i in `seq 1 1 $NLOCAL`; do + unixgroup=testlocal$i; + ntgroup=ntlgrp$i; + rid=`expr 10000 + $i`; + testone add rid=$rid unixgroup=$unixgroup ntgroup=$ntgroup type=local || exit 1 +done + +echo "trying a duplicate add" +testone add rid=10001 unixgroup=testlocal1 ntgroup=foo type=local && exit 1 + +treport + +echo "Creating domain groups" +for i in `seq 1 1 $NGROUP`; do + unixgroup=testgrp$i; + ntgroup=ntgrp$i; + rid=`expr 20000 + $i`; + testone add rid=$rid unixgroup=$unixgroup ntgroup=$ntgroup type=domain || exit 1 +done + +treport + +echo "Creating builtin groups" +for i in `seq 1 1 $NBUILTIN`; do + unixgroup=testb$i; + ntgroup=ntbgrp$i; + rid=`expr 30000 + $i`; + testone add rid=$rid unixgroup=$unixgroup ntgroup=$ntgroup type=builtin || exit 1 +done + +treport + +echo "Adding domain groups to local groups" +for i in `seq 1 1 $NLOCAL`; do + for j in `seq 1 1 $i`; do + + lrid=`expr 10000 + $i`; + drid=`expr 20000 + $j`; + + testone addmem $DOMSID-$lrid $DOMSID-$drid || exit 1 + ( testone listmem $DOMSID-$lrid | sort -r ) || exit 1 + done +done + +echo "trying a duplicate addmem" +testone addmem $DOMSID-10001 $DOMSID-20001 && exit 1 + +echo "Adding foreign SIDs to local groups" +for i in `seq 1 1 $NLOCAL`; do + for j in `seq 1 1 $i`; do + + lrid=`expr 10000 + $i`; + frid=`expr 70000 + $j`; + + testone addmem $DOMSID-$lrid $FORSID-$frid || exit 1 + ( testone listmem $DOMSID-$lrid | sort -r ) || exit 1 + done +done + +echo "trying a duplicate foreign addmem" +testone addmem $DOMSID-10001 $FORSID-70001 && exit 1 + +treport + +echo "Listing local group memberships of domain groups" +for i in `seq 1 1 $NGROUP`; do + rid=`expr 20000 + $i`; + ( testone memberships $DOMSID-$rid | sort -r ) || exit 1 +done + +echo "Trying memberships on bogus sid" +testone memberships $DOMSID-999999 || exit 1 + +treport + +testone list | sort + +echo "Deleting some domain groups" +for i in `seq 2 2 $NGROUP`; do + drid=`expr 20000 + $i`; + testone delete sid=$DOMSID-$drid || exit 1 +done + +echo "Trying duplicate domain group delete" +testone delete sid=$DOMSID-20002 && exit 1 + +treport + +echo "Deleting some local groups" +for i in `seq 2 4 $NLOCAL`; do + lrid=`expr 10000 + $i`; + testone delete sid=$DOMSID-$lrid || exit 1 +done + +echo "Trying duplicate local group delete" +testone delete sid=$DOMSID-10002 && exit 1 + +treport + +echo "Modifying some domain groups" +for i in `seq 3 2 $NGROUP`; do + drid=`expr 20000 + $i`; + testone modify sid=$DOMSID-$drid comment="newcomment-$i" type=domain || exit 1 +done + +treport + +testone list | sort + +echo "Listing local group memberships" +for i in `seq 1 1 $NLOCAL`; do + rid=`expr 20000 + $i`; + ( testone memberships $DOMSID-$rid | sort -r ) || exit 1 +done + +treport + +echo "Removing some domain groups from local groups" +for i in `seq 1 2 $NLOCAL`; do + for j in `seq 1 3 $i`; do + + lrid=`expr 10000 + $i`; + drid=`expr 20000 + $j`; + + testone delmem $DOMSID-$lrid $DOMSID-$drid || exit 1 + done +done + +echo "Trying duplicate delmem" +testone delmem $DOMSID-10001 $DOMSID-20001 && exit 1 + +treport + +echo "Listing local group memberships" +for i in `seq 1 1 $NLOCAL`; do + rid=`expr 20000 + $i`; + ( testone memberships $DOMSID-$rid | sort -r ) || exit 1 +done + +treport + +echo "Deleting unix groups" +for i in `seq 1 1 $NLOCAL`; do + unixgroup=testlocal$i; + groupdel $unixgroup 2> /dev/null +done +for i in `seq 1 1 $NGROUP`; do + unixgroup=testgrp$i; + groupdel $unixgroup 2> /dev/null +done +for i in `seq 1 1 $NBUILTIN`; do + unixgroup=testb$i; + groupdel $unixgroup 2> /dev/null +done + +treport + +echo "ALL DONE" diff --git a/source3/script/tests/test_local_s3.sh b/source3/script/tests/test_local_s3.sh new file mode 100755 index 0000000000..aed8637abd --- /dev/null +++ b/source3/script/tests/test_local_s3.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +# this runs the file serving tests that are expected to pass with samba3 + +if [ $# != 0 ]; then +cat <<EOF +Usage: test_local_s3.sh +EOF +exit 1; +fi + +incdir=`dirname $0` +. $incdir/test_functions.sh + +failed=0 + +testit "talloctort" $VALGRIND $BINDIR/talloctort || \ + failed=`expr $failed + 1` + +testit "replacetort" $VALGRIND $BINDIR/replacetort || \ + failed=`expr $failed + 1` + +testit "tdbtorture" $VALGRIND $BINDIR/tdbtorture || \ + failed=`expr $failed + 1` + +testit "smbconftort" $VALGRIND $BINDIR/smbconftort $CONFIGURATION || \ + failed=`expr $failed + 1` + +testok $0 $failed diff --git a/source3/script/tests/test_net_misc.sh b/source3/script/tests/test_net_misc.sh new file mode 100755 index 0000000000..0a0636ac8a --- /dev/null +++ b/source3/script/tests/test_net_misc.sh @@ -0,0 +1,50 @@ +#!/bin/sh + +# various tests for the "net" command + +NET="$VALGRIND ${NET:-$BINDIR/net} $CONFIGURATION" + +NETTIME="${NET} time" +NETLOOKUP="${NET} lookup" + +incdir=`dirname $0` +. $incdir/test_functions.sh + +failed=0 + +test_time() +{ + PARAM="$1" + + ${NETTIME} ${PARAM} -S localhost2 +} + +test_lookup() +{ + PARAM="$1" + + ${NETLOOKUP} ${PARAM} +} + +testit "get the time" \ + test_time || \ + failed=`expr $failed + 1` + +testit "get the system time" \ + test_time system || \ + failed=`expr $failed + 1` + +testit "get the time zone" \ + test_time zone || \ + failed=`expr $failed + 1` + +testit "lookup the PDC" \ + test_lookup pdc || \ + failed=`expr $failed + 1` + +testit "lookup the master browser" \ + test_lookup master || \ + failed=`expr $failed + 1` + +testok $0 $failed + diff --git a/source3/script/tests/test_net_registry.sh b/source3/script/tests/test_net_registry.sh new file mode 100755 index 0000000000..5edcb061ee --- /dev/null +++ b/source3/script/tests/test_net_registry.sh @@ -0,0 +1,442 @@ +#!/bin/sh + +# Tests for the "net registry" and "net rpc registry" commands. +# rpc tests are chose by specifying "rpc" as commandline parameter. + +RPC="$1" + +NET="$VALGRIND ${NET:-$BINDIR/net} $CONFIGURATION" + +if test "x${RPC}" = "xrpc" ; then + NETREG="${NET} -U${USERNAME}%${PASSWORD} -I ${SERVER_IP} rpc registry" +else + NETREG="${NET} registry" +fi + +incdir=`dirname $0` +. $incdir/test_functions.sh + +failed=0 + +test_enumerate() +{ + KEY="$1" + + ${NETREG} enumerate ${KEY} +} + +test_getsd() +{ + KEY="$1" + + ${NETREG} getsd ${KEY} +} + +test_enumerate_nonexisting() +{ + KEY="$1" + ${NETREG} enumerate ${KEY} + + if test "x$?" = "x0" ; then + echo "ERROR: enumerate succeeded with key '${KEY}'" + false + else + true + fi +} + +test_enumerate_no_key() +{ + ${NETREG} enumerate + if test "x$?" = "x0" ; then + echo "ERROR: enumerate succeeded without any key spcified" + false + else + true + fi +} + +test_create_existing() +{ + KEY="HKLM" + EXPECTED="createkey opened existing ${KEY}" + + OUTPUT=`${NETREG} createkey ${KEY}` + if test "x$?" = "x0" ; then + if test "$OUTPUT" = "$EXPECTED" ; then + true + else + echo "got '$OUTPUT', expected '$EXPECTED'" + false + fi + else + printf "%s\n" "$OUTPUT" + false + fi +} + +test_createkey() +{ + KEY="$1" + BASEKEY=`dirname $KEY` + SUBKEY=`basename $KEY` + + OUTPUT=`${NETREG} createkey ${KEY}` + if test "x$?" != "x0" ; then + echo "ERROR: createkey ${KEY} failed" + echo "output:" + printf "%s\n" "$OUTPUT" + false + return + fi + + # check enumerate of basekey lists new key: + OUTPUT=`${NETREG} enumerate ${BASEKEY}` + if test "x$?" != "x0" ; then + echo "ERROR: failed to enumerate key '${BASEKEY}'" + echo "output:" + printf "%s\n" "$OUTPUT" + false + return + fi + + EXPECTED="Keyname = ${SUBKEY}" + printf "%s\n" "$OUTPUT" | grep '^Keyname' | grep ${SUBKEY} + if test "x$?" != "x0" ; then + echo "ERROR: did not find expexted '$EXPECTED' in output" + echo "output:" + printf "%s\n" "$OUTPUT" + false + fi + + # check enumerate of new key works: + ${NETREG} enumerate ${KEY} +} + +test_deletekey() +{ + KEY="$1" + BASEKEY=`dirname ${KEY}` + SUBKEY=`basename ${KEY}` + + OUTPUT=`test_createkey "${KEY}"` + if test "x$?" != "x0" ; then + printf "%s\n" "${OUTPUT}" + false + return + fi + + OUTPUT=`${NETREG} deletekey ${KEY}` + if test "x$?" != "x0" ; then + printf "%s\n" "${OUTPUT}" + false + return + fi + + # check enumerate of basekey does not show key anymore: + OUTPUT=`${NETREG} enumerate ${BASEKEY}` + if test "x$?" != "x0" ; then + printf "%s\n" "$OUTPUT" + false + return + fi + + UNEXPECTED="Keyname = ${SUBKEY}" + printf "%s\n" "$OUTPUT" | 'grep ^Keyname' | grep ${SUBKEY} + if test "x$?" = "x0" ; then + echo "ERROR: found '$UNEXPECTED' after delete in output" + echo "output:" + printf "%s\n" "$OUTPUT" + false + fi + + # check enumerate of key itself does not work anymore: + ${NETREG} enumerate ${KEY} + if test "x$?" = "x0" ; then + echo "ERROR: 'enumerate ${KEY}' works after 'deletekey ${KEY}'" + false + else + true + fi +} + +test_deletekey_nonexisting() +{ + KEY="$1" + + OUTPUT=`test_deletekey "${KEY}"` + if test "x$?" != "x0" ; then + printf "%s\n" "${OUTPUT}" + false + return + fi + + ${NETREG} deletekey "${KEY}" + if test "x$?" = "x0" ; then + echo "ERROR: delete after delete succeeded for key '${KEY}'" + false + fi +} + +test_createkey_with_subkey() +{ + KEY="$1" + KEY2=`dirname ${KEY}` + SUBKEYNAME2=`basename ${KEY}` + BASENAME=`dirname ${KEY2}` + SUBKEYNAME1=`basename ${KEY2}` + + OUTPUT=`${NETREG} createkey ${KEY}` + if test "x$?" != "x0" ; then + echo "ERROR: createkey ${KEY} failed" + printf "%s\n" "${OUTPUT}" + false + return + fi + + # check we can enumerate to level key + OUTPUT=`${NETREG} enumerate ${KEY}` + if test "x$?" != "x0" ; then + echo "ERROR: failed to enumerate '${KEY}' after creation" + printf "%s\n" "${OUTPUT}" + false + return + fi + + # clear: + ${NETREG} deletekey ${KEY} && ${NETREG} deletekey ${KEY2} +} + +test_deletekey_with_subkey() +{ + KEY="$1" + KEY2=`dirname ${KEY}` + + OUTPUT=`${NETREG} createkey ${KEY}` + if test "x$?" != "x0" ; then + printf "%s\n" "${OUTPUT}" + false + return + fi + + OUTPUT=`${NETREG} deletekey ${KEY2}` + + if test "x$?" = "x0" ; then + echo "ERROR: delete of key with subkey succeeded" + echo "output:" + printf "%s\n" "$OUTPUT" + false + return + fi + + ${NETREG} deletekey ${KEY} && ${NETREG} deletekey ${KEY2} +} + +test_setvalue() +{ + KEY="$1" + VALNAME="$2" + VALTYPE="$3" + VALVALUE="$4" + + OUTPUT=`test_createkey ${KEY}` + if test "x$?" != "x0" ; then + printf "%s\n" "${OUTPUT}" + false + return + fi + + OUTPUT=`${NETREG} setvalue ${KEY} ${VALNAME} ${VALTYPE} ${VALVALUE}` + if test "x$?" != "x0" ; then + echo "ERROR: failed to set value testval in key ${KEY}" + printf "%s\n" "${OUTPUT}" + false + return + fi + + OUTPUT=`${NETREG} enumerate ${KEY}` + if test "x$?" != "x0" ; then + echo "ERROR: failure calling enumerate for key ${KEY}" + echo output: + printf "%s\n" "${OUTPUT}" + false + return + fi + + printf "%s\n" "$OUTPUT" | { + FOUND=0 + while read LINE ; do + SEARCH1=`echo $LINE | grep '^Valuename' | grep ${VALNAME}` + if test "x$?" = "x0" ; then + read LINE + read LINE + SEARCH2=`echo $LINE | grep '^Value ' | grep ${VALVALUE}` + if test "x$?" = "x0" ; then + FOUND=1 + break + fi + fi + done + + if test "x$FOUND" != "x1" ; then + echo "ERROR: did not find value '${VALNAME}' with enumerate" + echo "enumerate output:" + printf "%s\n" "$OUTPUT" + false + return + fi + } +} + +test_deletevalue() +{ + KEY="$1" + VALNAME="$2" + + ${NETREG} deletevalue ${KEY} ${VALNAME} +} + +test_deletevalue_nonexisting() +{ + KEY="$1" + VALNAME="$2" + + ${NETREG} deletevalue ${KEY} ${VALNAME} + if test "x$?" = "x0" ; then + echo "ERROR: succeeded deleting value ${VALNAME}" + false + else + true + fi +} + +test_setvalue_twice() +{ + KEY="$1" + VALNAME="$2" + VALTYPE1="$3" + VALVALUE1="$4" + VALTYPE2="$5" + VALVALUE2="$6" + + OUTPUT=`test_setvalue ${KEY} ${VALNAME} ${VALTYPE1} ${VALVALUE1}` + if test "x$?" != "x0" ; then + echo "ERROR: first setvalue call failed" + printf "%s\n" "$OUTPUT" + false + return + fi + + ${NETREG} setvalue ${KEY} ${VALNAME} ${VALTYPE2} ${VALVALUE2} +} + +give_administrative_rights() +{ + bin/net -s $SERVERCONFFILE sam createbuiltingroup Administrators + if test "x$?" != "x0" ; then + echo "ERROR: creating builtin group Administrators" + false + return + fi + + bin/net -s $SERVERCONFFILE sam addmem BUILTIN\\Administrators $USERNAME + if test "x$?" != "x0" ; then + echo "ERROR: adding user $USERNAME to BUILTIN\\Administrators" + false + else + true + fi +} + +take_administrative_rights() +{ + bin/net -s $SERVERCONFFILE sam delmem BUILTIN\\Administrators $USERNAME + if test "x$?" != "x0" ; then + echo "ERROR: removing user $USERNAME from BUILTIN\\Administrators" + false + else + true + fi +} + +if test "x${RPC}" = "xrpc" ; then +testit "giving user ${USERNAME} administrative rights" \ + give_administrative_rights || \ + failed=`expr $failed + 1` +fi + +testit "enumerate HKLM" \ + test_enumerate HKLM || \ + failed=`expr $failed + 1` + +testit "enumerate nonexisting hive" \ + test_enumerate_nonexisting XYZ || \ + failed=`expr $failed + 1` + +testit "enumerate without key" \ + test_enumerate_no_key || \ + failed=`expr $failed + 1` + +# skip getsd test for registry currently: it fails +if test "x${RPC}" != "xrpc" ; then +testit "getsd HKLM" \ + test_getsd HKLM || \ + failed=`expr $failed + 1` +fi + +testit "create existing HKLM" \ + test_create_existing || \ + failed=`expr $failed + 1` + +testit "create key" \ + test_createkey HKLM/testkey || \ + failed=`expr $failed + 1` + +testit "delete key" \ + test_deletekey HKLM/testkey || \ + failed=`expr $failed + 1` + +testit "delete^2 key" \ + test_deletekey_nonexisting HKLM/testkey || \ + failed=`expr $failed + 1` + +testit "enumerate nonexisting key" \ + test_enumerate_nonexisting HKLM/testkey || \ + failed=`expr $failed + 1` + +testit "create key with subkey" \ + test_createkey_with_subkey HKLM/testkey/subkey || \ + failed=`expr $failed + 1` + +testit "delete key with subkey" \ + test_deletekey_with_subkey HKLM/testkey/subkey || \ + failed=`expr $failed + 1` + +testit "set value" \ + test_setvalue HKLM/testkey testval sz moin || \ + failed=`expr $failed + 1` + +testit "delete value" \ + test_deletevalue HKLM/testkey testval || \ + failed=`expr $failed + 1` + +testit "delete nonexisting value" \ + test_deletevalue_nonexisting HKLM/testkey testval || \ + failed=`expr $failed + 1` + +testit "set value to different type" \ + test_setvalue_twice HKLM/testkey testval sz moin dword 42 || \ + failed=`expr $failed + 1` + +testit "delete key with value" \ + test_deletekey HKLM/testkey || \ + failed=`expr $failed + 1` + +if test "x${RPC}" = "xrpc" ; then +testit "taking administrative rights from user ${USERNAME}" \ + take_administrative_rights || \ + failed=`expr $failed + 1` +fi + +testok $0 $failed + diff --git a/source3/script/tests/test_net_s3.sh b/source3/script/tests/test_net_s3.sh new file mode 100755 index 0000000000..f7dc2b7e10 --- /dev/null +++ b/source3/script/tests/test_net_s3.sh @@ -0,0 +1,33 @@ +#!/bin/sh + +# tests for the "net" command + +incdir=`dirname $0` +. $incdir/test_functions.sh + +failed=0 + +net_misc() { + echo "RUNNING SUBTESTS net_misc" + $SCRIPTDIR/test_net_misc.sh \ + || failed=`expr $failed + $?` +} + +net_registry() { + echo "RUNNING SUBTESTS net_registry" + $SCRIPTDIR/test_net_registry.sh \ + || failed=`expr $failed + $?` +} + +net_rpc_registry() { + echo "RUNNING SUBTESTS net_rpc_registry" + $SCRIPTDIR/test_net_registry.sh rpc \ + || failed=`expr $failed + $?` +} + +net_misc +net_registry +net_rpc_registry + +testok $0 $failed + diff --git a/source3/script/tests/test_ntlm_auth_s3.sh b/source3/script/tests/test_ntlm_auth_s3.sh new file mode 100755 index 0000000000..6c97f2e650 --- /dev/null +++ b/source3/script/tests/test_ntlm_auth_s3.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +incdir=`dirname $0` +. $incdir/test_functions.sh + +failed=0 + +(/usr/bin/env python --version > /dev/null 2>&1) + +if test $? -ne 0; +then + echo "Python binary not found in path. Skipping ntlm_auth tests." + exit 0 +fi + +testit "ntlm_auth" $VALGRIND $SRCDIR/torture/test_ntlm_auth.py $BINDIR/ntlm_auth --configfile=$CONFFILE || failed=`expr $failed + 1` +# This should work even with NTLMv2 +testit "ntlm_auth" $VALGRIND $SRCDIR/torture/test_ntlm_auth.py $BINDIR/ntlm_auth --configfile=$CONFFILE --client-domain=fOo --server-domain=fOo || failed=`expr $failed + 1` + + +testok $0 $failed diff --git a/source3/script/tests/test_posix_s3.sh b/source3/script/tests/test_posix_s3.sh new file mode 100755 index 0000000000..3e9998666c --- /dev/null +++ b/source3/script/tests/test_posix_s3.sh @@ -0,0 +1,84 @@ +#!/bin/sh + +# this runs the file serving tests that are expected to pass with samba3 + +if [ $# -lt 3 ]; then +cat <<EOF +Usage: test_posix_s3.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 + +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 BASE-SAMBA3ERROR" + +raw="RAW-ACLS 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" +raw="$raw RAW-SAMBA3HIDE RAW-SAMBA3BADPATH RAW-SFILEINFO-RENAME" +raw="$raw RAW-SAMBA3CASEINSENSITIVE RAW-SAMBA3POSIXTIMEDLOCK" +raw="$raw RAW-SAMBA3ROOTDIRFID" + +rpc="RPC-AUTHCONTEXT RPC-BINDSAMBA3 RPC-SAMBA3-SRVSVC RPC-SAMBA3-SHARESEC" +rpc="$rpc RPC-SAMBA3-SPOOLSS RPC-SAMBA3-WKSSVC" +rpc="$rpc RPC-NETLOGSAMBA3 RPC-SAMBA3SESSIONKEY RPC-SAMBA3-GETUSERNAME" + +# NOTE: to enable the UNIX-WHOAMI test, we need to change the default share +# config to allow guest access. I'm not sure whether this would break other +# tests, so leaving it alone for now -- jpeach +unix="UNIX-INFO2" + +tests="$base $raw $rpc $unix" + +if test "x$POSIX_SUBTESTS" != "x" ; then + tests="$POSIX_SUBTESTS" +fi + +skipped="BASE-CHARSET BASE-TCONDEV" +skipped="$skipped RAW-ACLS RAW-COMPOSITE RAW-CONTEXT" +skipped="$skipped RAW-IOCTL" +skipped="$skipped RAW-QFILEINFO RAW-QFSINFO" +skipped="$skipped RAW-SFILEINFO" + +echo "WARNING: Skipping tests $skipped" + +ADDARGS="$ADDARGS --option=torture:sharedelay=100000" +ADDARGS="$ADDARGS --option=torture:writetimeupdatedelay=500000" + +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 $SMBTORTURE4 $TORTURE4_OPTIONS $ADDARGS $unc -U"$username"%"$password" $t || failed=`expr $failed + 1` +done + +testok $0 $failed diff --git a/source3/script/tests/test_smbclient_s3.sh b/source3/script/tests/test_smbclient_s3.sh new file mode 100755 index 0000000000..c10aed0ee6 --- /dev/null +++ b/source3/script/tests/test_smbclient_s3.sh @@ -0,0 +1,87 @@ +#!/bin/sh + +# this runs the file serving tests that are expected to pass with samba3 + +if [ $# -lt 2 ]; then +cat <<EOF +Usage: test_smbclient_s3.sh SERVER SERVER_IP +EOF +exit 1; +fi + +SERVER="$1" +SERVER_IP="$2" +SMBCLIENT="$VALGRIND ${SMBCLIENT:-$BINDIR/smbclient} $CONFIGURATION" +shift 2 +ADDARGS="$*" + +incdir=`dirname $0` +. $incdir/test_functions.sh + +failed=0 + +# Test that a noninteractive smbclient does not prompt +test_noninteractive_no_prompt() +{ + prompt="smb" + + echo du | \ + $SMBCLIENT $CONFIGURATION "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I SERVER_IP $ADDARGS 2>&1 | \ + grep $prompt + + if [ $? = 0 ] ; then + # got a prompt .. fail + echo matched interactive prompt in non-interactive mode + false + else + true + fi +} + +# Test that an interactive smbclient prompts to stdout +test_interactive_prompt_stdout() +{ + prompt="smb" + tmpfile=/tmp/smbclient.in.$$ + + cat > $tmpfile <<EOF +du +quit +EOF + + CLI_FORCE_INTERACTIVE=yes \ + $SMBCLIENT $CONFIGURATION "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP \ + $ADDARGS < $tmpfile 2>/dev/null | \ + grep $prompt + + if [ $? = 0 ] ; then + # got a prompt .. succeed + rm -f $tmpfile + true + else + echo failed to match interactive prompt on stdout + rm -f $tmpfile + false + fi +} + +testit "smbclient -L $SERVER_IP" $SMBCLIENT $CONFIGURATION -L $SERVER_IP -N -p 139 || failed=`expr $failed + 1` +testit "smbclient -L $SERVER -I $SERVER_IP" $SMBCLIENT $CONFIGURATION -L $SERVER -I $SERVER_IP -N -p 139 || failed=`expr $failed + 1` + +testit "noninteractive smbclient does not prompt" \ + test_noninteractive_no_prompt || \ + failed=`expr $failed + 1` + +testit "noninteractive smbclient -l does not prompt" \ + test_noninteractive_no_prompt -l /tmp || \ + failed=`expr $failed + 1` + +testit "interactive smbclient prompts on stdout" \ + test_interactive_prompt_stdout || \ + failed=`expr $failed + 1` + +testit "interactive smbclient -l prompts on stdout" \ + test_interactive_prompt_stdout -l /tmp || \ + failed=`expr $failed + 1` + +testok $0 $failed diff --git a/source3/script/tests/test_smbtorture_s3.sh b/source3/script/tests/test_smbtorture_s3.sh new file mode 100755 index 0000000000..acb641b9fb --- /dev/null +++ b/source3/script/tests/test_smbtorture_s3.sh @@ -0,0 +1,48 @@ +#!/bin/sh + +# this runs the file serving tests that are expected to pass with samba3 + +if [ $# -lt 3 ]; then +cat <<EOF +Usage: test_smbtorture_s3.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="FDPASS LOCK1 LOCK2 LOCK3 LOCK4 LOCK5 LOCK6 LOCK7" +#tests="$tests UNLINK BROWSE ATTR TRANS2 MAXFID TORTURE " +tests="$tests UNLINK BROWSE ATTR TRANS2 TORTURE " +tests="$tests OPLOCK1 OPLOCK2 OPLOCK3" +tests="$tests DIR DIR1 TCON TCONDEV RW1 RW2 RW3" +tests="$tests OPEN XCOPY RENAME DELETE PROPERTIES W2K" +tests="$tests TCON2 IOCTL CHKPATH FDSESS LOCAL-SUBSTITUTE" + +skipped1="RANDOMIPC NEGNOWAIT NBENCH ERRMAPEXTRACT TRANS2SCAN NTTRANSSCAN" +skipped2="DENY1 DENY2 OPENATTR CASETABLE EATEST" +skipped3="MANGLE UTABLE PIPE_NUMBER" +echo "Skipping the following tests:" +echo "$skipped1" +echo "$skipped2" +echo "$skipped3" + +failed=0 +for t in $tests; do + if [ ! -z "$start" -a "$start" != $t ]; then + continue; + fi + start="" + name="$t" + testit "$name" $VALGRIND $BINDIR/smbtorture $unc -U"$username"%"$password" $ADDARGS $t || failed=`expr $failed + 1` +done + +testok $0 $failed diff --git a/source3/script/tests/test_testparm_s3.sh b/source3/script/tests/test_testparm_s3.sh new file mode 100755 index 0000000000..0962ca0764 --- /dev/null +++ b/source3/script/tests/test_testparm_s3.sh @@ -0,0 +1,90 @@ +#!/bin/sh + +# Tests for lp_load() via testparm. +# +# The main purpose (for now) is to test all the special handlers +# and the macro expansions. + +TEMP_CONFFILE=${LIBDIR}/smb.conf.tmp +TESTPARM="$VALGRIND ${TESTPARM:-$BINDIR/testparm} --suppress-prompt --skip-logic-checks" + +incdir=`dirname $0` +. $incdir/test_functions.sh + +failed=0 + +test_include_expand_macro() +{ + MACRO=$1 + rm -f ${TEMP_CONFFILE} + cat >${TEMP_CONFFILE}<<EOF +[global] + include = ${TEMP_CONFFILE}.%${MACRO} +EOF + ${TESTPARM} ${TEMP_CONFFILE} +} + +test_one_global_option() +{ + OPTION=$1 + rm -f ${TEMP_CONFFILE} + cat > ${TEMP_CONFFILE}<<EOF +[global] + ${OPTION} +EOF + ${TESTPARM} ${TEMP_CONFFILE} +} + +test_copy() +{ + rm -f ${TEMP_CONFFILE} + cat > ${TEMP_CONFFILE}<<EOF +[share1] + path = /tmp + read only = no + +[share2] + copy = share1 +EOF + ${TESTPARM} ${TEMP_CONFFILE} +} + + +testit "netbios name" \ + test_one_global_option "netbios name = funky" || \ + failed=`expr ${failed} + 1` + +testit "netbios aliases" \ + test_one_global_option "netbios aliases = funky1 funky2 funky3" || \ + failed=`expr ${failed} + 1` + +testit "netbios scope" \ + test_one_global_option "netbios scope = abc" || \ + failed=`expr ${failed} + 1` + +testit "workgroup" \ + test_one_global_option "workgroup = samba" || \ + failed=`expr ${failed} + 1` + +testit "display charset" \ + test_one_global_option "display charset = UTF8" || \ + failed=`expr ${failed} + 1` + +testit "ldap debug level" \ + test_one_global_option "ldap debug level = 7" || \ + failed=`expr ${failed} + 1` + +for LETTER in U G D I i L N M R T a d h m v w V ; do +testit "include with %${LETTER} macro expansion" \ + test_include_expand_macro "${LETTER}" || \ + failed=`expr ${failed} + 1` +done + +testit "copy" \ + test_copy || \ + failed=`expr ${failed} + 1` + +rm -f ${TEMP_CONFFILE} + +testok $0 ${failed} + diff --git a/source3/script/tests/test_wbinfo_s3.sh b/source3/script/tests/test_wbinfo_s3.sh new file mode 100755 index 0000000000..e3bf1b9e70 --- /dev/null +++ b/source3/script/tests/test_wbinfo_s3.sh @@ -0,0 +1,50 @@ +#!/bin/sh + +if [ $# -lt 4 ]; then +cat <<EOF +Usage: test_wbinfo_s3.sh DOMAIN SERVER USERNAME PASSWORD <wbinfo args> +EOF +exit 1; +fi + +domain="$1" +server="$2" +username="$3" +password="$4" +shift 4 +ADDARGS="$*" + +incdir=`dirname $0` +. $incdir/test_functions.sh + +OLDIFS=$IFS; + +tests="--ping" +tests="$tests:--separator" +tests="$tests:--own-domain" +tests="$tests:--all-domains" +tests="$tests:--trusted-domains" +tests="$tests:--domain-info=BUILTIN" +tests="$tests:--domain-info=$domain" +tests="$tests:--online-status" +tests="$tests:--online-status --domain=BUILTIN" +tests="$tests:--online-status --domain=$domain" +#Didn't pass yet# tests="$tests:--domain-users" +tests="$tests:--domain-groups" +tests="$tests:--name-to-sid=$username" +#Didn't pass yet# tests="$tests:--user-info=$username" +tests="$tests:--user-groups=$username" + +failed=0 + +OLDIFS=$IFS +NEWIFS=$':' +IFS=$NEWIFS +for t in $tests; do + IFS=$OLDIFS + testit "wbinfo $t" $VALGRIND $BINDIR/wbinfo $CONFIGURATION $ADDARGS $t || failed=`expr $failed + 1` + IFS=$NEWIFS +done +IFS=$OLDIFS + +testok $0 $failed diff --git a/source3/script/tests/tests_all.sh b/source3/script/tests/tests_all.sh new file mode 100755 index 0000000000..2b46da0e77 --- /dev/null +++ b/source3/script/tests/tests_all.sh @@ -0,0 +1,94 @@ +local_s3() { + echo "RUNNING TESTS local_s3" + $SCRIPTDIR/test_local_s3.sh \ + || failed=`expr $failed + $?` +} + +smbtorture_s3() { + echo "RUNNING TESTS smbtorture_s3" + $SCRIPTDIR/test_smbtorture_s3.sh \ + //$SERVER_IP/tmp $USERNAME $PASSWORD "" \ + || failed=`expr $failed + $?` +} + +smbtorture_s3_encrypted() { + echo "RUNNING TESTS smbtorture_s3_encrypted" + $SCRIPTDIR/test_smbtorture_s3.sh \ + //$SERVER_IP/tmp $USERNAME $PASSWORD "" "-e" \ + || failed=`expr $failed + $?` +} + +smbclient_s3() { + echo "RUNNING TESTS smbclient_s3" + $SCRIPTDIR/test_smbclient_s3.sh $SERVER $SERVER_IP \ + || failed=`expr $failed + $?` +} + +smbclient_s3_encrypted() { + echo "RUNNING TESTS smbclient_s3_encrypted" + $SCRIPTDIR/test_smbclient_s3.sh $SERVER $SERVER_IP "-e" \ + || failed=`expr $failed + $?` +} + +wbinfo_s3() { + echo "RUNNING TESTS wbinfo_s3" + $SCRIPTDIR/test_wbinfo_s3.sh $WORKGROUP $SERVER $USERNAME $PASSWORD \ + || failed=`expr $failed + $?` +} + +ntlm_auth_s3() { + echo "RUNNING TESTS ntlm_auth_s3" + $SCRIPTDIR/test_ntlm_auth_s3.sh \ + || failed=`expr $failed + $?` +} + +net_s3() { + echo "RUNNING TESTS net_s3" + $SCRIPTDIR/test_net_s3.sh \ + || failed=`expr $failed + $?` +} + +testparm_s3() { + echo "RUNNING TESTS testparm_s3" + $SCRIPTDIR/test_testparm_s3.sh \ + || failed=`expr $failed + $?` +} + +posix_s3() { + echo "RUNNING TESTS posix_s3" + eval "$LIB_PATH_VAR="\$SAMBA4SHAREDDIR:\$$LIB_PATH_VAR"; export $LIB_PATH_VAR" + eval echo "$LIB_PATH_VAR=\$$LIB_PATH_VAR" + if [ -x "$SMBTORTURE4" ]; then + SMBTORTURE4VERSION=`$SMBTORTURE4 --version` + fi + if [ -n "$SMBTORTURE4" -a -n "$SMBTORTURE4VERSION" ];then + echo "Running Tests with Samba4's smbtorture" + echo $SMBTORTURE4VERSION + $SCRIPTDIR/test_posix_s3.sh \ + //$SERVER_IP/tmp $USERNAME $PASSWORD "" \ + || failed=`expr $failed + $?` + else + echo "Skip Tests with Samba4's smbtorture" + echo "Try to compile with --with-smbtorture4-path=PATH to enable" + fi +} + +failed=0 + +if test "x$TESTS" = "x" ; then + local_s3 + smbtorture_s3 + smbtorture_s3_encrypted + smbclient_s3 + smbclient_s3_encrypted + wbinfo_s3 + ntlm_auth_s3 + net_s3 + testparm_s3 + posix_s3 +else + for THIS_TEST in $TESTS; do + $THIS_TEST + done +fi + diff --git a/source3/script/tests/tests_smbclient_s3.sh b/source3/script/tests/tests_smbclient_s3.sh new file mode 100644 index 0000000000..d48a692d4b --- /dev/null +++ b/source3/script/tests/tests_smbclient_s3.sh @@ -0,0 +1 @@ +. $SCRIPTDIR/test_smbclient_s3.sh $SERVER $SERVER_IP diff --git a/source3/script/tests/timelimit.c b/source3/script/tests/timelimit.c new file mode 100644 index 0000000000..886256cb37 --- /dev/null +++ b/source3/script/tests/timelimit.c @@ -0,0 +1,102 @@ +/* run a command with a limited timeout + tridge@samba.org, June 2005 + metze@samba.org, March 2006 + + attempt to be as portable as possible (fighting posix all the way) +*/ +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <unistd.h> +#include <signal.h> +#include <errno.h> +#include <sys/types.h> +#include <sys/wait.h> + +static pid_t child_pid; + +static void usage(void) +{ + printf("usage: timelimit <time> <command>\n"); + printf(" SIGUSR1 - passes SIGTERM to command's process group\n"); + printf(" SIGALRM - passes SIGTERM to command's process group\n"); + printf(" after 5s SIGKILL will be passed and exit(1)\n"); + printf(" SIGTERM - passes SIGTERM to command's process group\n"); + printf(" after 1s SIGKILL will be passed and exit(1)\n"); +} + +static void sig_alrm_kill(int sig) +{ + fprintf(stderr, "\nMaximum time expired in timelimit - killing\n"); + kill(-child_pid, SIGKILL); + exit(1); +} + +static void sig_alrm_term(int sig) +{ + kill(-child_pid, SIGTERM); + alarm(5); + signal(SIGALRM, sig_alrm_kill); +} + +static void sig_term(int sig) +{ + kill(-child_pid, SIGTERM); + alarm(1); + signal(SIGALRM, sig_alrm_kill); +} + +static void sig_usr1(int sig) +{ + kill(-child_pid, SIGTERM); +} + +static void new_process_group(void) +{ + if (setpgid(0,0) == -1) { + perror("setpgid"); + exit(1); + } +} + + +int main(int argc, char *argv[]) +{ + int maxtime, ret=1; + + if (argc < 3) { + usage(); + exit(1); + } + + maxtime = atoi(argv[1]); + + child_pid = fork(); + if (child_pid == 0) { + new_process_group(); + execvp(argv[2], argv+2); + perror(argv[2]); + exit(1); + } + + signal(SIGTERM, sig_term); + signal(SIGINT, sig_term); + signal(SIGQUIT, sig_term); + signal(SIGUSR1, sig_usr1); + signal(SIGALRM, sig_alrm_term); + alarm(maxtime); + + do { + int status; + pid_t pid = wait(&status); + if (pid != -1) { + ret = WEXITSTATUS(status); + } else if (errno == ECHILD) { + break; + } + } while (1); + + kill(-child_pid, SIGKILL); + + exit(ret); +} diff --git a/source3/script/uninstallbin.sh.in b/source3/script/uninstallbin.sh.in new file mode 100755 index 0000000000..8064db8d95 --- /dev/null +++ b/source3/script/uninstallbin.sh.in @@ -0,0 +1,41 @@ +#!/bin/sh +#4 July 96 Dan.Shearer@UniSA.edu.au + +INSTALLPERMS=$1 +DESTDIR=$2 +prefix=`echo $3 | sed 's/\/\//\//g'` +BINDIR=`echo $4 | sed 's/\/\//\//g'` +SBINDIR=@sbindir@ +shift +shift +shift +shift + +if [ ! -d $DESTDIR/$BINDIR ]; then + echo "Directory $DESTDIR/$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 $DESTDIR/$BINDIR/$p2 ]; then + echo "Removing $DESTDIR/$BINDIR/$p2 " + rm -f $DESTDIR/$BINDIR/$p2 + if [ -f $DESTDIR/$BINDIR/$p2 ]; then + echo "Cannot remove $DESTDIR/$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 diff --git a/source3/script/uninstalldat.sh b/source3/script/uninstalldat.sh new file mode 120000 index 0000000000..656142745c --- /dev/null +++ b/source3/script/uninstalldat.sh @@ -0,0 +1 @@ +installdat.sh
\ No newline at end of file diff --git a/source3/script/uninstallman.sh b/source3/script/uninstallman.sh new file mode 100755 index 0000000000..0fea11cd1b --- /dev/null +++ b/source3/script/uninstallman.sh @@ -0,0 +1,37 @@ +#!/bin/sh +#4 July 96 Dan.Shearer@UniSA.edu.au +# +# 13 Aug 2001 Rafal Szczesniak <mimir@spin.ict.pwr.wroc.pl> +# modified to accomodate international man pages (inspired +# by Japanese edition's approach) + + +MANDIR=`echo $1 | sed 's/\/\//\//g'` +SRCDIR=$2 +langs=$3 + +for lang in $langs; do + echo Uninstalling \"$lang\" man pages from $MANDIR/$lang + + for sect in 1 5 7 8 ; do + for m in $MANDIR/$lang/man$sect ; do + for s in $SRCDIR/../docs/manpages/$lang/*$sect; do + FNAME=$m/`basename $s` + if test -f $FNAME; then + echo Deleting $FNAME + rm -f $FNAME + test -f $FNAME && echo Cannot remove $FNAME... does $USER have privileges? + fi + done + done + done +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 diff --git a/source3/script/uninstallmodules.sh b/source3/script/uninstallmodules.sh new file mode 100755 index 0000000000..fc80565cb5 --- /dev/null +++ b/source3/script/uninstallmodules.sh @@ -0,0 +1,39 @@ +#!/bin/sh +#4 July 96 Dan.Shearer@UniSA.edu.au + +INSTALLPERMS=$1 +DESTDIR=$2 +prefix=`echo $3 | sed 's/\/\//\//g'` +LIBDIR=`echo $4 | sed 's/\/\//\//g'` +shift +shift +shift +shift + +if [ ! -d $DESTDIR/$LIBDIR ]; then + echo "Directory $DESTDIR/$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 $DESTDIR/$LIBDIR/$p2 ]; then + echo "Removing $DESTDIR/$LIBDIR/$p2 " + rm -f $DESTDIR/$LIBDIR/$p2 + if [ -f $DESTDIR/$LIBDIR/$p2 ]; then + echo "Cannot remove $DESTDIR/$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 diff --git a/source3/script/uninstallmsg.sh b/source3/script/uninstallmsg.sh new file mode 120000 index 0000000000..c108fa4416 --- /dev/null +++ b/source3/script/uninstallmsg.sh @@ -0,0 +1 @@ +installmsg.sh
\ No newline at end of file diff --git a/source3/script/uninstallscripts.sh b/source3/script/uninstallscripts.sh new file mode 100755 index 0000000000..cf7fd71999 --- /dev/null +++ b/source3/script/uninstallscripts.sh @@ -0,0 +1,36 @@ +#!/bin/sh +# 5 July 96 Dan.Shearer@UniSA.Edu.Au - almost identical to uninstallbin.sh + +INSTALLPERMS=$1 +BINDIR=`echo $2 | sed 's/\/\//\//g'` + +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 diff --git a/source3/script/uninstallswat.sh b/source3/script/uninstallswat.sh new file mode 120000 index 0000000000..0dffe646f0 --- /dev/null +++ b/source3/script/uninstallswat.sh @@ -0,0 +1 @@ +installswat.sh
\ No newline at end of file diff --git a/source3/script/updatesmbpasswd.sh b/source3/script/updatesmbpasswd.sh new file mode 100755 index 0000000000..1d7e0d7332 --- /dev/null +++ b/source3/script/updatesmbpasswd.sh @@ -0,0 +1,14 @@ +#!/bin/sh +nawk 'BEGIN {FS=":"} +{ + if( $0 ~ "^#" ) { + print $0 + } else if( (length($4) == 32) && (($4 ~ "^[0-9A-F]*$") || ($4 ~ "^[X]*$") || ( $4 ~ "^[*]*$"))) { + print $0 + } else { + printf( "%s:%s:%s:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:", $1, $2, $3); + for(i = 4; i <= NF; i++) + printf("%s:", $i) + printf("\n") + } +}' |