]> git.wh0rd.org - dump.git/commitdiff
Added -F script option to restore.
authorStelian Pop <stelian@popies.net>
Wed, 18 Jul 2001 12:54:06 +0000 (12:54 +0000)
committerStelian Pop <stelian@popies.net>
Wed, 18 Jul 2001 12:54:06 +0000 (12:54 +0000)
CHANGES
TODO
compat/include/system.h [new file with mode: 0644]
compat/lib/Makefile.in
compat/lib/system.c [new file with mode: 0644]
dump/dump.8.in
dump/tape.c
restore/main.c
restore/restore.8.in
restore/restore.h
restore/tape.c

diff --git a/CHANGES b/CHANGES
index 2565decb6dcdd5d97f0a707dba84cc1a0774a491..3740d568e193a267e2adda650a0a9fee9787eb7d 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,4 @@
-$Id: CHANGES,v 1.121 2001/07/18 11:46:31 stelian Exp $
+$Id: CHANGES,v 1.122 2001/07/18 12:54:06 stelian Exp $
 
 Changes between versions 0.4b22 and 0.4b23 (released ????????????)
 ==================================================================
 
 Changes between versions 0.4b22 and 0.4b23 (released ????????????)
 ==================================================================
@@ -29,6 +29,12 @@ Changes between versions 0.4b22 and 0.4b23 (released ????????????)
 7.     Fixed a bug in reading the operator typed file/tape path for
        the next volume in restore.
 
 7.     Fixed a bug in reading the operator typed file/tape path for
        the next volume in restore.
 
+8.     Implemented a "-F script" option to restore which permits the
+       user to specify a script which will be launched at the
+       beginning of each tape, useful for automatic programming of
+       tape changers for example. See the restore man page for the
+       script parameters and return codes.
+
 Changes between versions 0.4b21 and 0.4b22 (released May 12, 2001)
 ==================================================================
 
 Changes between versions 0.4b21 and 0.4b22 (released May 12, 2001)
 ==================================================================
 
diff --git a/TODO b/TODO
index d98b59fa8b7f0063391717ba8584840dac969ede..11347c173c1b4142bf9e4a56660e2843362f0d80 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,4 +1,4 @@
-$Id: TODO,v 1.19 2001/05/10 20:55:09 stelian Exp $
+$Id: TODO,v 1.20 2001/07/18 12:54:06 stelian Exp $
 
 Need to verify:
 ---------------
 
 Need to verify:
 ---------------
@@ -50,12 +50,10 @@ All others:
 
 10.    Better readline completition in restore (escape spaces etc).
 
 
 10.    Better readline completition in restore (escape spaces etc).
 
-11.    Implement a -F option for restore.
-
-12.    Dump compiled with RedHat's 7.0 gcc seems to hang for some
+11.    Dump compiled with RedHat's 7.0 gcc seems to hang for some
        people. When compiled with kgcc all the problems disappear.
        Will the RedHat's 7.1 gcc resolve this ?
 
        people. When compiled with kgcc all the problems disappear.
        Will the RedHat's 7.1 gcc resolve this ?
 
-13.    Dump uses /dev/tty for reporting some messages. When invoked
+12.    Dump uses /dev/tty for reporting some messages. When invoked
        from a script, /dev/tty may not exist. Why not using just
        stderr ?
        from a script, /dev/tty may not exist. Why not using just
        stderr ?
diff --git a/compat/include/system.h b/compat/include/system.h
new file mode 100644 (file)
index 0000000..f27c7c3
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ *     Ported to Linux's Second Extended File System as part of the
+ *     dump and restore backup suit
+ *     Remy Card <card@Linux.EU.Org>, 1994-1997
+ *     Stelian Pop <pop@noos.fr>, 1999-2000
+ *     Stelian Pop <pop@noos.fr> - Alcôve <www.alcove.fr>, 2000
+ */
+
+/*-
+ * Copyright (c) 1980, 1991, 1993
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $Id: system.h,v 1.1 2001/07/18 12:54:06 stelian Exp $
+ */
+
+#ifndef _SYSTEM_H_
+#define _SYSTEM_H_
+
+int system_command(const char *command, const char *device, int volnum);
+
+#endif
index 42239c96a767a2d58c6f8259adf2ba410ed0f5e9..12d09cbecaf1bccc0740e3cea1ce14177dcfdb35 100644 (file)
@@ -1,4 +1,4 @@
-# $Id: Makefile.in,v 1.4 2000/08/20 19:41:24 stelian Exp $
+# $Id: Makefile.in,v 1.5 2001/07/18 12:54:06 stelian Exp $
 
 top_srcdir=    @top_srcdir@
 srcdir=                @srcdir@
 
 top_srcdir=    @top_srcdir@
 srcdir=                @srcdir@
@@ -7,8 +7,8 @@ srcdir=         @srcdir@
 
 INC=           -I$(top_srcdir)/compat/include
 CFLAGS=                @CCOPTS@ -pipe $(OPT) $(GINC) $(INC) $(DEFS)
 
 INC=           -I$(top_srcdir)/compat/include
 CFLAGS=                @CCOPTS@ -pipe $(OPT) $(GINC) $(INC) $(DEFS)
-SRCS=          compaterr.c fstab.c compatglob.c bylabel.c
-OBJS=          compaterr.o fstab.o compatglob.o bylabel.o
+SRCS=          compaterr.c fstab.c compatglob.c bylabel.c system.c
+OBJS=          compaterr.o fstab.o compatglob.o bylabel.o system.o
 LIB=           libcompat.a
 
 all::          $(LIB)
 LIB=           libcompat.a
 
 all::          $(LIB)
diff --git a/compat/lib/system.c b/compat/lib/system.c
new file mode 100644 (file)
index 0000000..3f94008
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ *     Ported to Linux's Second Extended File System as part of the
+ *     dump and restore backup suit
+ *     Remy Card <card@Linux.EU.Org>, 1994-1997
+ *     Stelian Pop <pop@noos.fr>, 1999-2000
+ *     Stelian Pop <pop@noos.fr> - Alcôve <www.alcove.fr>, 2000
+ */
+
+/*-
+ * Copyright (c) 1980, 1991, 1993
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static const char rcsid[] =
+       "$Id: system.c,v 1.1 2001/07/18 12:54:06 stelian Exp $";
+#endif /* not lint */
+
+#include <config.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+/*
+ * Executes the command in a shell.
+ * Returns -1 if an error occured, the exit status of
+ * the command on success.
+ */
+int system_command(const char *command, const char *device, int volnum) {
+       int pid, status;
+       char commandstr[4096];
+
+       pid = fork();
+       if (pid == -1) {
+               perror("  DUMP: unable to fork");
+               return -1;
+       }
+       if (pid == 0) {
+               setuid(getuid());
+               setgid(getgid());
+#if OLD_STYLE_FSCRIPT
+               snprintf(commandstr, sizeof(commandstr), "%s", command);
+#else
+               snprintf(commandstr, sizeof(commandstr), "%s %s %d", command, device, volnum);
+#endif
+               commandstr[sizeof(commandstr) - 1] = '\0';
+               execl("/bin/sh", "sh", "-c", commandstr, NULL);
+               perror("unable to execute shell");
+               exit(-1);
+       }
+       do {
+               if (waitpid(pid, &status, 0) == -1) {
+                       if (errno != EINTR) {
+                               perror("waitpid error");
+                               return -1;
+                       }
+               } else {
+                       if (WIFEXITED(status))
+                               return WEXITSTATUS(status);
+                       else
+                               return -1;
+               }
+       } while(1);
+}
+
index 21761d56575cf1a64a62a6e124ca2b53637ff84a..5a1dc751b9a7a72758e70fcb924ee4e928ce3e3d 100644 (file)
@@ -30,7 +30,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\"    $Id: dump.8.in,v 1.27 2001/07/18 09:50:48 stelian Exp $
+.\"    $Id: dump.8.in,v 1.28 2001/07/18 12:54:06 stelian Exp $
 .\"
 .Dd __DATE__
 .Dt DUMP 8
 .\"
 .Dd __DATE__
 .Dt DUMP 8
@@ -202,7 +202,7 @@ The script must return 0 if
 .Nm
 should continue without asking the user to change the tape, 1 if 
 .Nm
 .Nm
 should continue without asking the user to change the tape, 1 if 
 .Nm
-dump should continue but ask the user to change the tape. 
+should continue but ask the user to change the tape. 
 Any other exit code will cause
 .Nm
 to abort.
 Any other exit code will cause
 .Nm
 to abort.
index 984fe07fdde4e80965c1e8321571119cb6419a01..5666b39329d2e774ae52ee64e9c40eeec40f1a85 100644 (file)
@@ -41,7 +41,7 @@
 
 #ifndef lint
 static const char rcsid[] =
 
 #ifndef lint
 static const char rcsid[] =
-       "$Id: tape.c,v 1.49 2001/07/18 09:50:48 stelian Exp $";
+       "$Id: tape.c,v 1.50 2001/07/18 12:54:06 stelian Exp $";
 #endif /* not lint */
 
 #include <config.h>
 #endif /* not lint */
 
 #include <config.h>
@@ -52,6 +52,7 @@ static const char rcsid[] =
 #include <signal.h>
 #include <stdio.h>
 #include <compaterr.h>
 #include <signal.h>
 #include <stdio.h>
 #include <compaterr.h>
+#include <system.h>
 #ifdef __STDC__
 #include <stdlib.h>
 #include <string.h>
 #ifdef __STDC__
 #include <stdlib.h>
 #include <string.h>
@@ -116,7 +117,6 @@ static      void enslave __P((void));
 static void flushtape __P((void));
 static void killall __P((void));
 static void rollforward __P((void));
 static void flushtape __P((void));
 static void killall __P((void));
 static void rollforward __P((void));
-static int system_command __P((const char *, const char *, int));
 
 /*
  * Concurrent dump mods (Caltech) - disk block reading and tape writing
 
 /*
  * Concurrent dump mods (Caltech) - disk block reading and tape writing
@@ -462,48 +462,6 @@ flushtape(void)
        timeest();
 }
 
        timeest();
 }
 
-/*
- * Executes the command in a shell.
- * Returns -1 if an error occured, the exit status of
- * the command on success.
- */
-int system_command(const char *command, const char *device, int volnum) {
-       int pid, status;
-       char commandstr[4096];
-
-       pid = fork();
-       if (pid == -1) {
-               perror("  DUMP: unable to fork");
-               return -1;
-       }
-       if (pid == 0) {
-               setuid(getuid());
-               setgid(getgid());
-#if OLD_STYLE_FSCRIPT
-               snprintf(commandstr, sizeof(commandstr), "%s", command);
-#else
-               snprintf(commandstr, sizeof(commandstr), "%s %s %d", command, device, volnum);
-#endif
-               commandstr[sizeof(commandstr) - 1] = '\0';
-               execl("/bin/sh", "sh", "-c", commandstr, NULL);
-               perror("  DUMP: unable to execute shell");
-               exit(-1);
-       }
-       do {
-               if (waitpid(pid, &status, 0) == -1) {
-                       if (errno != EINTR) {
-                               perror("  DUMP: waitpid error");
-                               return -1;
-                       }
-               } else {
-                       if (WIFEXITED(status))
-                               return WEXITSTATUS(status);
-                       else
-                               return -1;
-               }
-       } while(1);
-}
-
 time_t
 trewind(void)
 {
 time_t
 trewind(void)
 {
index 2a261f6f1bc80088200d444a76472aadbb2e3a5b..5892252a5ba75b97e8a6df6b3eb62923b50a37f3 100644 (file)
@@ -41,7 +41,7 @@
 
 #ifndef lint
 static const char rcsid[] =
 
 #ifndef lint
 static const char rcsid[] =
-       "$Id: main.c,v 1.24 2001/04/27 15:22:47 stelian Exp $";
+       "$Id: main.c,v 1.25 2001/07/18 12:54:06 stelian Exp $";
 #endif /* not lint */
 
 #include <config.h>
 #endif /* not lint */
 
 #include <config.h>
@@ -99,6 +99,7 @@ int   compare_ignore_not_found;
 int    compare_errors;
 char   filesys[NAMELEN];
 static const char *stdin_opt = NULL;
 int    compare_errors;
 char   filesys[NAMELEN];
 static const char *stdin_opt = NULL;
+char   *bot_script = NULL;
 
 #ifdef __linux__
 char   *__progname;
 
 #ifdef __linux__
 char   *__progname;
@@ -145,7 +146,7 @@ main(int argc, char *argv[])
                ;                                                               
        obsolete(&argc, &argv);
        while ((ch = getopt(argc, argv, 
                ;                                                               
        obsolete(&argc, &argv);
        while ((ch = getopt(argc, argv, 
-               "b:CcdD:f:hi"
+               "b:CcdD:f:F:hi"
 #ifdef KERBEROS
                "k"
 #endif
 #ifdef KERBEROS
                "k"
 #endif
@@ -182,6 +183,9 @@ main(int argc, char *argv[])
                                use_stdin("-f");
                        inputdev = optarg;
                        break;
                                use_stdin("-f");
                        inputdev = optarg;
                        break;
+               case 'F':
+                       bot_script = optarg;
+                       break;
                case 'h':
                        hflag = 0;
                        break;
                case 'h':
                        hflag = 0;
                        break;
@@ -501,12 +505,12 @@ usage(void)
 
        (void)fprintf(stderr,
          "usage:\t%s%s\n\t%s%s\n\t%s%s\n\t%s%s\n\t%s%s\n\t%s%s\n",
 
        (void)fprintf(stderr,
          "usage:\t%s%s\n\t%s%s\n\t%s%s\n\t%s%s\n\t%s%s\n\t%s%s\n",
-         __progname, " -C [-c" kerbflag "Mvy] [-b blocksize] [-D filesystem] [-f file] [-s fileno]",
-         __progname, " -i [-ch" kerbflag "mMuvy] [-b blocksize] [-f file] " qfaflag "[-s fileno]",
-         __progname, " -r [-c" kerbflag "Muvy] [-b blocksize] [-f file] [-s fileno] [-T directory]",
-         __progname, " -R [-c" kerbflag "Muvy] [-b blocksize] [-f file] [-s fileno] [-T directory]",
-         __progname, " -t [-ch" kerbflag "Muvy] [-b blocksize] [-f file] " qfaflag "[-s fileno] [-X filelist] [file ...]",
-         __progname, " -x [-ch" kerbflag "mMuvy] [-b blocksize] [-f file] " qfaflag "[-s fileno] [-X filelist] [file ...]");
+         __progname, " -C [-c" kerbflag "Mvy] [-b blocksize] [-D filesystem] [-f file] [-F script ] [-s fileno]",
+         __progname, " -i [-ch" kerbflag "mMuvy] [-b blocksize] [-f file] [-F script] " qfaflag "[-s fileno]",
+         __progname, " -r [-c" kerbflag "Muvy] [-b blocksize] [-f file] [-F script] [-s fileno] [-T directory]",
+         __progname, " -R [-c" kerbflag "Muvy] [-b blocksize] [-f file] [-F script] [-s fileno] [-T directory]",
+         __progname, " -t [-ch" kerbflag "Muvy] [-b blocksize] [-f file] [-F script] " qfaflag "[-s fileno] [-X filelist] [file ...]",
+         __progname, " -x [-ch" kerbflag "mMuvy] [-b blocksize] [-f file] [-F script] " qfaflag "[-s fileno] [-X filelist] [file ...]");
        exit(1);
 }
 
        exit(1);
 }
 
@@ -543,6 +547,7 @@ obsolete(int *argcp, char **argvp[])
                case 'b':
                case 'D':
                case 'f':
                case 'b':
                case 'D':
                case 'f':
+               case 'F':
                case 'Q':
                case 's':
                case 'T':
                case 'Q':
                case 's':
                case 'T':
index 0c208596eb53029aaa8ad247519cb361c9f4c1bc..7faa54a3291dca41001e47025f59276f72699f4e 100644 (file)
@@ -29,7 +29,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\"    $Id: restore.8.in,v 1.14 2001/04/24 15:04:59 stelian Exp $
+.\"    $Id: restore.8.in,v 1.15 2001/07/18 12:54:06 stelian Exp $
 .\"
 .Dd __DATE__
 .Dt RESTORE 8
 .\"
 .Dd __DATE__
 .Dt RESTORE 8
@@ -44,6 +44,7 @@
 .Op Fl b Ar blocksize
 .Op Fl D Ar filesystem
 .Op Fl f Ar file
 .Op Fl b Ar blocksize
 .Op Fl D Ar filesystem
 .Op Fl f Ar file
+.Op Fl F Ar script
 .Op Fl s Ar fileno
 .Op Fl T Ar directory
 .Nm restore
 .Op Fl s Ar fileno
 .Op Fl T Ar directory
 .Nm restore
@@ -51,6 +52,7 @@
 .Op Fl chkmMNuvy
 .Op Fl b Ar blocksize
 .Op Fl f Ar file
 .Op Fl chkmMNuvy
 .Op Fl b Ar blocksize
 .Op Fl f Ar file
+.Op Fl F Ar script
 .Op Fl Q Ar file
 .Op Fl s Ar fileno
 .Op Fl T Ar directory
 .Op Fl Q Ar file
 .Op Fl s Ar fileno
 .Op Fl T Ar directory
@@ -59,6 +61,7 @@
 .Op Fl ckMNuvy
 .Op Fl b Ar blocksize
 .Op Fl f Ar file
 .Op Fl ckMNuvy
 .Op Fl b Ar blocksize
 .Op Fl f Ar file
+.Op Fl F Ar script
 .Op Fl s Ar fileno
 .Op Fl T Ar directory
 .Nm restore
 .Op Fl s Ar fileno
 .Op Fl T Ar directory
 .Nm restore
@@ -66,6 +69,7 @@
 .Op Fl ckMNuvy
 .Op Fl b Ar blocksize
 .Op Fl f Ar file
 .Op Fl ckMNuvy
 .Op Fl b Ar blocksize
 .Op Fl f Ar file
+.Op Fl F Ar script
 .Op Fl s Ar fileno
 .Op Fl T Ar directory
 .Nm restore
 .Op Fl s Ar fileno
 .Op Fl T Ar directory
 .Nm restore
@@ -73,6 +77,7 @@
 .Op Fl chkMNuvy
 .Op Fl b Ar blocksize
 .Op Fl f Ar file
 .Op Fl chkMNuvy
 .Op Fl b Ar blocksize
 .Op Fl f Ar file
+.Op Fl F Ar script
 .Op Fl Q Ar file
 .Op Fl s Ar fileno
 .Op Fl T Ar directory
 .Op Fl Q Ar file
 .Op Fl s Ar fileno
 .Op Fl T Ar directory
@@ -83,6 +88,7 @@
 .Op Fl chkmMNuvy
 .Op Fl b Ar blocksize
 .Op Fl f Ar file
 .Op Fl chkmMNuvy
 .Op Fl b Ar blocksize
 .Op Fl f Ar file
+.Op Fl F Ar script
 .Op Fl Q Ar file
 .Op Fl s Ar fileno
 .Op Fl T Ar directory
 .Op Fl Q Ar file
 .Op Fl s Ar fileno
 .Op Fl T Ar directory
@@ -336,6 +342,21 @@ or
 reads from the named file on the remote host using
 .Xr rmt 8 .
 .Pp
 reads from the named file on the remote host using
 .Xr rmt 8 .
 .Pp
+.It Fl F Ar script
+Run script at the beginning of each tape. The device name and the
+current volume number are passed on the command line.
+The script must return 0 if 
+.Nm
+should continue without asking the user to change the tape, 1 if 
+.Nm
+should continue but ask the user to change the tape. 
+Any other exit code will cause
+.Nm
+to abort.
+For security reasons,
+.Nm
+reverts back to the real user ID and the real group ID before 
+running the script.
 .It Fl k
 Use Kerberos authentication when contacting the remote tape server.
 (Only available if this options was enabled when
 .It Fl k
 Use Kerberos authentication when contacting the remote tape server.
 (Only available if this options was enabled when
index dba1ddcdf6a4f2cff466e3ad4af89a2a0ee1810d..0ae65ba8829e613134f30a985988c7d05751ee3e 100644 (file)
@@ -5,7 +5,7 @@
  *     Stelian Pop <pop@noos.fr>, 1999-2000
  *     Stelian Pop <pop@noos.fr> - Alcôve <www.alcove.fr>, 2000
  *
  *     Stelian Pop <pop@noos.fr>, 1999-2000
  *     Stelian Pop <pop@noos.fr> - Alcôve <www.alcove.fr>, 2000
  *
- *     $Id: restore.h,v 1.15 2001/04/10 12:46:53 stelian Exp $
+ *     $Id: restore.h,v 1.16 2001/07/18 12:54:06 stelian Exp $
  */
 
 /*
  */
 
 /*
@@ -62,6 +62,7 @@ extern int    uflag;          /* unlink symlink targets */
 extern int     vflag;          /* print out actions taken */
 extern int     yflag;          /* always try to recover from tape errors */
 extern int     zflag;          /* tape is in compressed format */
 extern int     vflag;          /* print out actions taken */
 extern int     yflag;          /* always try to recover from tape errors */
 extern int     zflag;          /* tape is in compressed format */
+extern char*   bot_script;     /* beginning of tape script */
 /*
  * Global variables
  */
 /*
  * Global variables
  */
index f7a8a10211379408d6e58d4b5d2f5668b911fd78..a8616a1069eaf3b7a90635bc523c6b4a716fffd6 100644 (file)
 
 #ifndef lint
 static const char rcsid[] =
 
 #ifndef lint
 static const char rcsid[] =
-       "$Id: tape.c,v 1.41 2001/07/18 11:46:31 stelian Exp $";
+       "$Id: tape.c,v 1.42 2001/07/18 12:54:06 stelian Exp $";
 #endif /* not lint */
 
 #include <config.h>
 #include <compatlfs.h>
 #include <errno.h>
 #include <compaterr.h>
 #endif /* not lint */
 
 #include <config.h>
 #include <compatlfs.h>
 #include <errno.h>
 #include <compaterr.h>
+#include <system.h>
 #include <setjmp.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <setjmp.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -257,10 +258,18 @@ newcomprbuf(int size)
 void
 setup(void)
 {
 void
 setup(void)
 {
-       int i, j, *ip;
+       int i, j, *ip, bot_code;
        struct STAT stbuf;
 
        Vprintf(stdout, "Verify tape and initialize maps\n");
        struct STAT stbuf;
 
        Vprintf(stdout, "Verify tape and initialize maps\n");
+       if (bot_script) {
+               msg("Launching %s\n", bot_script);
+               bot_code = system_command(bot_script, magtape, 1);
+               if (bot_code != 0 && bot_code != 1) {
+                       msg("Restore aborted by the beginning of tape script\n");
+                       exit(1);
+               }
+       }
 #ifdef RRESTORE
        if (host)
                mt = rmtopen(magtape, 0);
 #ifdef RRESTORE
        if (host)
                mt = rmtopen(magtape, 0);
@@ -374,7 +383,7 @@ getvol(long nextvol)
        union u_spcl tmpspcl;
 #      define tmpbuf tmpspcl.s_spcl
        char buf[TP_BSIZE];
        union u_spcl tmpspcl;
 #      define tmpbuf tmpspcl.s_spcl
        char buf[TP_BSIZE];
-       int haderror = 0;
+       int haderror = 0, bot_code;
 
        if (nextvol == 1) {
                tapesread = 0;
 
        if (nextvol == 1) {
                tapesread = 0;
@@ -438,7 +447,15 @@ again:
                snprintf(magtape, MAXPATHLEN, "%s%03ld", magtapeprefix, newvol);
                magtape[MAXPATHLEN - 1] = '\0';
        }
                snprintf(magtape, MAXPATHLEN, "%s%03ld", magtapeprefix, newvol);
                magtape[MAXPATHLEN - 1] = '\0';
        }
-       if (!Mflag || haderror) {
+       if (bot_script && !haderror) {
+               msg("Launching %s\n", bot_script);
+               bot_code = system_command(bot_script, magtape, newvol);
+               if (bot_code != 0 && bot_code != 1) {
+                       msg("Restore aborted by the beginning of tape script\n");
+                       exit(1);
+               }
+       }
+       if (haderror || (bot_code && !Mflag)) {
                haderror = 0;
                fprintf(stderr, "Mount tape volume %ld\n", (long)newvol);
                fprintf(stderr, "Enter ``none'' if there are no more tapes\n");
                haderror = 0;
                fprintf(stderr, "Mount tape volume %ld\n", (long)newvol);
                fprintf(stderr, "Enter ``none'' if there are no more tapes\n");