s3-selftest: use nss_wrapper.pl as "add user to group" and "delete user from group...
[ira/wip.git] / source3 / script / tests / selftest.sh
index 15e48b00efbc466c09dc859357d7ba80de3f2945..956c5af77bd7489bea796509824990b68ef919bc 100755 (executable)
@@ -1,17 +1,44 @@
 #!/bin/sh
 
-if [ $# != 3 ]; then
-       echo "$0 <directory> <all | quick> <smbtorture4>"
+if [ $# -lt 2 ]; then
+       echo "$0 <directory> <all | quick> [-t <smbtorture4>] [-s <shrdir>] " \
+            "[-c <custom conf>]"
        exit 1
 fi
 
-SMBTORTURE4=$3
-SUBTESTS=$2
+##
+## Setup the required args
+##
+DIRECTORY=$1; shift;
+SUBTESTS=$1; shift;
+
+##
+## Parse oprtional args
+##
+while getopts s:c:t: f
+do
+    case $f in
+       t)      SMBTORTURE4=$OPTARG;;
+       s)      ALT_SHRDIR_ARG=$OPTARG;;
+       c)      CUSTOM_CONF_ARG=$OPTARG;;
+    esac
+done
+
+echo "Running selftest with the following"
+echo "Selftest Directory: $DIRECTORY"
+echo "Subtests to Run: $SUBTESTS"
+echo "smbtorture4 Path: $SMBTORTURE4"
+echo "Alternative Share Dir: $ALT_SHRDIR_ARG"
+echo "Custom Configuration: $CUSTOM_CONF_ARG"
+
+if [ $CUSTOM_CONF_ARG ]; then
+    INCLUDE_CUSTOM_CONF="include = $CUSTOM_CONF_ARG"
+fi
 
 ##
 ## create the test directory
 ##
-PREFIX=`echo $1 | sed s+//+/+`
+PREFIX=`echo $DIRECTORY | sed s+//+/+`
 mkdir -p $PREFIX || exit $?
 OLD_PWD=`pwd`
 cd $PREFIX || exit $?
@@ -38,7 +65,6 @@ 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
@@ -69,20 +95,24 @@ 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"
+if [ $SMBTORTURE4 ]; then
+    SAMBA4BINDIR=`dirname $SMBTORTURE4`
 fi
-echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH"
-export LD_LIBRARY_PATH
 
-SAMBA4BINDIR=`dirname $SMBTORTURE4`
 SAMBA4SHAREDDIR="$SAMBA4BINDIR/shared"
 
 export SAMBA4SHAREDDIR
 export SMBTORTURE4
 
+if [ -z "$LIB_PATH_VAR" ] ; then
+       echo "Warning: LIB_PATH_VAR not set. Using best guess LD_LIBRARY_PATH." >&2
+       LIB_PATH_VAR=LD_LIBRARY_PATH
+       export LIB_PATH_VAR
+fi
+
+eval $LIB_PATH_VAR=$BINDIR:$SAMBA4SHAREDDIR:\$$LIB_PATH_VAR
+export $LIB_PATH_VAR
+
 ##
 ## verify that we were built with --enable-socket-wrapper
 ##
@@ -113,8 +143,23 @@ 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 an alternate shrdir if one was specified.
+##
+if [ $ALT_SHRDIR_ARG ]; then
+    ALT_SHRDIR=`echo $ALT_SHRDIR_ARG | sed s+//+/+`
+    mkdir -p $ALT_SHRDIR || exit $?
+    OLD_PWD=`pwd`
+    cd $ALT_SHRDIR || exit $?
+    SHRDIR=`pwd`
+    cd $OLD_PWD
+    /bin/rm -rf $SHRDIR/*
+else
+    SHRDIR=$PREFIX_ABS/tmp
+    mkdir -p $SHRDIR
+fi
+chmod 777 $SHRDIR
 
 ##
 ## Create the common config include file with the basic settings
@@ -150,6 +195,7 @@ cat >$SAMBA4CONFFILE<<EOF
        interfaces = $TORTURE_INTERFACES
        panic action = $SCRIPTDIR/gdb_backtrace %PID% %PROG%
        include = $COMMONCONFFILE
+       modules dir = $SRCDIR/bin/modules
 EOF
 
 cat >$SERVERCONFFILE<<EOF
@@ -160,15 +206,23 @@ cat >$SERVERCONFFILE<<EOF
        panic action = $SCRIPTDIR/gdb_backtrace %d %\$(MAKE_TEST_BINARY)
        include = $COMMONCONFFILE
 
+       state directory = $LOCKDIR
+       cache directory = $LOCKDIR
+
        passdb backend = tdbsam
 
        domain master = yes
        domain logons = yes
+       lanman auth = 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
+       add user script =               $PERL $SRCDIR/../lib/nss_wrapper/nss_wrapper.pl --passwd_path $NSS_WRAPPER_PASSWD --type passwd --action add --name %u
+       add group script =              $PERL $SRCDIR/../lib/nss_wrapper/nss_wrapper.pl --group_path  $NSS_WRAPPER_GROUP  --type group  --action add --name %g
+       add user to group script =      $PERL $SRCDIR/../lib/nss_wrapper/nss_wrapper.pl --group_path  $NSS_WRAPPER_GROUP  --type member --action add --name %g --member %u --passwd_path $NSS_WRAPPER_PASSWD
+       add machine script =            $PERL $SRCDIR/../lib/nss_wrapper/nss_wrapper.pl --passwd_path $NSS_WRAPPER_PASSWD --type passwd --action add --name %u
+       delete user script =            $PERL $SRCDIR/../lib/nss_wrapper/nss_wrapper.pl --passwd_path $NSS_WRAPPER_PASSWD --type passwd --action delete --name %u
+       delete group script =           $PERL $SRCDIR/../lib/nss_wrapper/nss_wrapper.pl --group_path  $NSS_WRAPPER_GROUP  --type group  --action delete --name %g
+       delete user from group script = $PERL $SRCDIR/../lib/nss_wrapper/nss_wrapper.pl --group_path  $NSS_WRAPPER_GROUP  --type member --action delete --name %g --member %u --passwd_path $NSS_WRAPPER_PASSWD
 
        kernel oplocks = no
        kernel change notify = no
@@ -183,15 +237,19 @@ cat >$SERVERCONFFILE<<EOF
 
 #      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
+       vfs objects = $BINDIR/xattr_tdb.so $BINDIR/streams_depot.so
+
+       #Include user defined custom parameters if set
+       $INCLUDE_CUSTOM_CONF
+
+[tmp]
+       path = $SHRDIR
 [hideunread]
        copy = tmp
        hide unreadable = yes
@@ -201,7 +259,15 @@ cat >$SERVERCONFFILE<<EOF
 [print1]
        copy = tmp
        printable = yes
-       printing = test
+       printing = vlp
+       print command = $BINDIR/vlp tdbfile=$LOCKDIR/vlp.tdb print %p %s
+       lpq command = $BINDIR/vlp tdbfile=$LOCKDIR/vlp.tdb lpq %p
+       lp rm command = $BINDIR/vlp tdbfile=$LOCKDIR/vlp.tdb lprm %p %j
+       lp pause command = $BINDIR/vlp tdbfile=$LOCKDIR/vlp.tdb lppause %p %j
+       lp resume command = $BINDIR/vlp tdbfile=$LOCKDIR/vlp.tdb lpresume %p %j
+       queue pause command = $BINDIR/vlp tdbfile=$LOCKDIR/vlp.tdb queuepause %p
+       queue resume command = $BINDIR/vlp tdbfile=$LOCKDIR/vlp.tdb queueresume %p
+
 [print2]
        copy = print1
 [print3]
@@ -215,6 +281,7 @@ EOF
 ##
 
 cat >$NSS_WRAPPER_PASSWD<<EOF
+root:x:65533:65532:root gecos:$PREFIX_ABS:/bin/false
 nobody:x:65534:65533:nobody gecos:$PREFIX_ABS:/bin/false
 $USERNAME:x:$USERID:$GROUPID:$USERNAME gecos:$PREFIX_ABS:/bin/false
 EOF
@@ -229,7 +296,7 @@ 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
+       bin/smbpasswd -c $SERVERCONFFILE -L -s -a $USERNAME >/dev/null || exit 1
 
 echo "DONE";
 
@@ -262,7 +329,7 @@ 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"
+TORTURE4_OPTIONS="$TORTURE4_OPTIONS --option=torture:localdir=$SHRDIR"
 export TORTURE4_OPTIONS
 
 if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then