-$Id: CHANGES,v 1.220 2003/03/07 09:15:44 stelian Exp $
+$Id: CHANGES,v 1.221 2003/03/26 10:58:19 stelian Exp $
Changes between versions 0.4b33 and 0.4b34 (released ?????????????????)
=======================================================================
Thanks to Jin-su Ahn <jsahn@ee.snu.ac.kr> for reporting the
bug and providing the fix.
+10. Fixed open and creation modes and permissions for QFA and
+ table-of-contents files in dump and restore. Thanks to
+ Philippe Troin <phil@fifi.org> for the patch.
+
+11. Fixed the archive file descriptor handling enabling it to be 0.
+ This can happen in some cases when shell redirections are used.
+ Thanks to Philippe Troin <phil@fifi.org> for the patch.
+
+12. Delayed the opening of archive file until after suid had been
+ dropped (fixing a possible security issue if dump is suid).
+ Thanks to Philippe Troin <phil@fifi.org> for the patch.
+
+13. Fixed the 'S' command handling in the rmt client part.
+ Thanks to Philippe Troin <phil@fifi.org> for the patch.
+
+14. Modified the end-of-tape script handling to print out statistics
+ (and stop the timer) before launching the eot script. Also, the eot
+ script does not get run anymore when using -M (which makes sense) or
+ when multiple tapes are listed on the command line
+ (-f tape0,tape1,tapen) (which also makes sense).
+ Thanks to Philippe Troin <phil@fifi.org> for the patch.
+
Changes between versions 0.4b32 and 0.4b33 (released February 10, 2003)
=======================================================================
#ifndef lint
static const char rcsid[] =
- "$Id: dumprmt.c,v 1.25 2003/02/12 11:02:29 stelian Exp $";
+ "$Id: dumprmt.c,v 1.26 2003/03/26 10:58:22 stelian Exp $";
#endif /* not lint */
#include <config.h>
if (rmtstate != TS_OPEN)
return (NULL);
- rmtcall("status", "S\n");
+ i = rmtcall("status", "S");
+ if (i < 0) return NULL;
+ if (i != (int)sizeof(mts)) {
+ msg("mtget sizes different between host (%d) "
+ "and remote tape (%d)", sizeof(mts), i);
+ for ( /* empty */; i > 0; --i)
+ rmtgetb();
+ return NULL;
+ }
for (i = 0, cp = (char *)&mts; i < (int)sizeof(mts); i++)
*cp++ = rmtgetb();
return (&mts);
* Stelian Pop <stelian@popies.net>, 1999-2000
* Stelian Pop <stelian@popies.net> - AlcĂ´ve <www.alcove.com>, 2000-2002
*
- * $Id: dump.h,v 1.42 2003/01/10 14:42:50 stelian Exp $
+ * $Id: dump.h,v 1.43 2003/03/26 10:58:22 stelian Exp $
*/
/*-
extern char lastlevel; /* dump level of previous dump */
extern char level; /* dump level of this dump */
extern int Afile; /* archive file descriptor */
+extern int AfileActive; /* Afile flag */
extern int bzipflag; /* compression is done using bzlib */
extern int uflag; /* update flag */
extern int mflag; /* dump metadata only if possible flag */
#ifndef lint
static const char rcsid[] =
- "$Id: main.c,v 1.82 2003/03/07 09:15:50 stelian Exp $";
+ "$Id: main.c,v 1.83 2003/03/26 10:58:22 stelian Exp $";
#endif /* not lint */
#include <config.h>
char lastlevel; /* dump level of previous dump */
char level; /* dump level of this dump */
int bzipflag; /* compression is done using bzlib */
-int Afile = 0; /* archive file descriptor */
+int Afile = -1; /* archive file descriptor */
+int AfileActive = 1;/* Afile flag */
int uflag; /* update flag */
int mflag; /* dump metadata only if possible */
int Mflag; /* multi-volume flag */
case 'A': /* archive file */
Apath = optarg;
- if ((Afile = open(Apath, O_RDWR|O_CREAT|O_TRUNC,
- S_IRUSR | S_IWUSR)) < 0) {
- msg("Cannot open %s for writing: %s\n",
- optarg, strerror(errno));
- msg("The ENTIRE dump is aborted.\n");
- exit(X_STARTUP);
- }
- memset(volinfo, 0, TP_NINOS * sizeof(dump_ino_t));
break;
case 'a': /* `auto-size', Write to EOM. */
#endif
}
(void)setuid(getuid()); /* rmthost() is the only reason to be setuid */
+ if (Apath && (Afile = open(Apath, O_WRONLY|O_CREAT|O_TRUNC,
+ S_IRUSR | S_IWUSR | S_IRGRP |
+ S_IWGRP | S_IROTH | S_IWOTH)) < 0) {
+ msg("Cannot open %s for writing: %s\n",
+ optarg, strerror(errno));
+ msg("The ENTIRE dump is aborted.\n");
+ exit(X_STARTUP);
+ }
if (signal(SIGHUP, SIG_IGN) != SIG_IGN)
signal(SIGHUP, sig);
#ifdef USE_QFA
if (tapepos) {
msg("writing QFA positions to %s\n", gTapeposfile);
- if ((gTapeposfd = open(gTapeposfile, O_RDWR|O_CREAT|O_TRUNC, S_IRUSR | S_IWUSR)) < 0)
+ if ((gTapeposfd = open(gTapeposfile,
+ O_WRONLY|O_CREAT|O_TRUNC,
+ S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP
+ | S_IROTH | S_IWOTH)) < 0)
quit("can't open tapeposfile\n");
/* print QFA-file header */
snprintf(gTps, sizeof(gTps), "%s\n%s\n%ld\n\n", QFA_MAGIC, QFA_VERSION, (unsigned long)spcl.c_date);
tend_writing = time(NULL);
spcl.c_type = TS_END;
- if (Afile) {
+ if (Afile >= 0) {
volinfo[1] = ROOTINO;
memcpy(spcl.c_inos, volinfo, TP_NINOS * sizeof(dump_ino_t));
spcl.c_flags |= DR_INODEINFO;
spcl.c_tapea, tapekb, rate);
}
- if (Afile)
+ if (Afile >= 0)
msg("Archiving dump to %s\n", Apath);
broadcast("DUMP IS DONE!\7\7\n");
#ifndef lint
static const char rcsid[] =
- "$Id: tape.c,v 1.72 2003/01/10 10:52:48 stelian Exp $";
+ "$Id: tape.c,v 1.73 2003/03/26 10:58:22 stelian Exp $";
#endif /* not lint */
#include <config.h>
extern int cartridge;
char *nexttape;
extern pid_t rshpid;
-int eot_code = 1;
long long tapea_bytes = 0; /* bytes_written at start of current volume */
static int magtapeout; /* output is really a tape */
*(union u_spcl *)(*(nextblock)) = *(union u_spcl *)dp;
/* Need to write it to the archive file */
- if (Afile < 0 && isspcl && (spcl.c_type == TS_END))
- Afile = -Afile;
- if (Afile > 0) {
+ if (! AfileActive && isspcl && (spcl.c_type == TS_END))
+ AfileActive = 1;
+ if (AfileActive && Afile >= 0) {
/* When we dump an inode which is not a directory,
* it means we ended the archive contents */
if (isspcl && (spcl.c_type == TS_INODE) &&
((spcl.c_dinode.di_mode & S_IFMT) != IFDIR))
- Afile = -Afile;
+ AfileActive = 0;
else {
union u_spcl tmp;
tmp = *(union u_spcl *)dp;
(void) close(f);
}
}
- eot_code = 1;
- if (eot_script && spcl.c_type != TS_END) {
- msg("Launching %s\n", eot_script);
- eot_code = system_command(eot_script, tape, tapeno);
- }
- if (eot_code != 0 && eot_code != 1) {
- msg("Dump aborted by the end of tape script\n");
- dumpabort(0);
- }
}
return do_stats();
}
void
close_rewind(void)
{
+ int eot_code = 1;
(void)trewind();
- if (nexttape || Mflag || (eot_code == 0) )
+ if (nexttape || Mflag)
+ return;
+ if (eot_script) {
+ msg("Launching %s\n", eot_script);
+ eot_code = system_command(eot_script, tape, tapeno);
+ }
+ if (eot_code != 0 && eot_code != 1) {
+ msg("Dump aborted by the end of tape script\n");
+ dumpabort(0);
+ }
+ if (eot_code == 0)
return;
if (!nogripe) {
msg("Change Volumes: Mount volume #%d\n", tapeno+1);
#ifndef lint
static const char rcsid[] =
- "$Id: main.c,v 1.42 2002/11/15 09:25:41 stelian Exp $";
+ "$Id: main.c,v 1.43 2003/03/26 10:58:22 stelian Exp $";
#endif /* not lint */
#include <config.h>
static void usage __P((void));
static void use_stdin __P((const char *));
+#define FORCED_UMASK (077)
+
int
main(int argc, char *argv[])
{
char *p, name[MAXPATHLEN];
FILE *filelist = NULL;
char fname[MAXPATHLEN];
+ mode_t orig_umask;
#ifdef DEBUG_QFA
time_t tistart, tiend, titaken;
#endif
#endif /* USE_QFA */
/* Temp files should *not* be readable. We set permissions later. */
- (void) umask(077);
+ orig_umask = umask(FORCED_UMASK);
filesys[0] = '\0';
#if defined(__linux__) || defined(sunos)
__progname = argv[0];
#endif
setup();
msg("writing QFA positions to %s\n", gTapeposfile);
- if ((gTapeposfd = open(gTapeposfile, O_RDWR|O_CREAT, S_IRUSR|S_IWUSR)) < 0)
+ (void) umask(orig_umask);
+ if ((gTapeposfd = open(gTapeposfile, O_WRONLY|O_CREAT|O_TRUNC,
+ S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP
+ |S_IROTH|S_IWOTH)) < 0)
errx(1, "can't create tapeposfile\n");
+ (void) umask(FORCED_UMASK);
/* print QFA-file header */
sprintf(gTps, "%s\n%s\n%ld\n\n", QFA_MAGIC, QFA_VERSION,(unsigned long)spcl.c_date);
if (write(gTapeposfd, gTps, strlen(gTps)) != (ssize_t)strlen(gTps))