3 # Simple test that a DB from a backup file cannot be untarred and started
4 # manually (you have to run the samba-tool 'backup restore' command instead).
16 DBPATH=$PREFIX/start-backup
19 . `dirname $0`/../../../testprogs/blackbox/subunit.sh
23 $PYTHON $BINDIR/samba-tool domain provision \
24 --domain=FOO --realm=foo.example.com --use-ntvfs \
25 --targetdir=$DBPATH --option="pid directory = $DBPATH"
30 # manually add the backup marker that the backup cmd usually adds
32 -H tdb://$DBPATH/private/sam.ldb <<EOF
36 backupDate: who-knows-when
44 # start samba in interactive mode (if we don't, samba daemonizes and so the
45 # command's exit status is always zero (success), regardless of whether
46 # samba actually starts up or not). However, this means if this assertion
47 # were ever to fail (i.e. samba DOES startup from a backup file), then the
48 # test case would just hang. So we use a max-run-time of 5 secs so that
49 # samba will self-destruct in the bad case (max_runtime_handler() returns
50 # zero/success in this case, which allows us to tell the good case from the
52 OPTS="--maximum-runtime=5 -i"
54 # redirect logs to stderr (which we'll then redirect to stdout so we can
55 # capture it in a bash variable)
56 OPTS="$OPTS --debug-stderr"
58 # start samba and capture the debug output
59 OUTPUT=$($BINDIR/samba --configfile=$DBPATH/etc/smb.conf $OPTS 2>&1)
60 if [ $? -eq 0 ] ; then
61 echo "ERROR: Samba should not have started successfully"
65 # check the reason we're failing is because prime_ldb_databases() is
66 # detecting that this is a backup DB (and not some other reason)
67 echo "$OUTPUT" | grep "failed to start: Database is a backup"
70 # setup a DB and manually mark it as being a "backup"
71 testit "provision" do_provision
72 testit "add-backup-marker" add_backup_marker
74 # check that Samba won't start using this DB (because it's a backup)
75 testit "start-samba-backup" start_backup