Changes from nate for gzip'ed sup

This commit is contained in:
brezak 1993-08-04 17:46:14 +00:00
parent 53c3f682d7
commit 3e9304df33
9 changed files with 295 additions and 21 deletions

View File

@ -23,7 +23,10 @@
.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
.\" HISTORY
.\" $Log: sup.1,v $
.\" Revision 1.1.1.1 1993/05/21 14:52:16 cgd
.\" Revision 1.2 1993/08/04 17:46:14 brezak
.\" Changes from nate for gzip'ed sup
.\"
.\" Revision 1.1.1.1 1993/05/21 14:52:16 cgd
.\" initial import of CMU's SUP to NetBSD
.\"
.\" Revision 1.4 92/08/11 12:08:40 mrt
@ -308,6 +311,26 @@ flag and the
.B old
supfile option.
.TP
.B -z
Normally sup transfers files directly without any
other processing, but with the
.B -z
flag, or the
.B compress
supfile option, sup will compress the file
before sending it across the network and
uncompress it and restore all the correct
file attributes at the recieving end.
.TP
.B -Z
The
.B -Z
flag overrides and disables the
.B -z
flag and the
.B compress
supfile option.
.TP
.B -v
Normally,
.I sup

View File

@ -34,8 +34,15 @@
* 13-Sep-92 Mary Thompson (mrt) at Carnegie-Mellon University
* Changed name of DEFDIR from /usr/cs to /usr.
*
* 7-July-93 Nate Williams at Montana State University
* Modified SUP to use gzip based compression when sending files
* across the network to save BandWidth
*
* $Log: sup.h,v $
* Revision 1.1.1.1 1993/05/21 14:52:18 cgd
* Revision 1.2 1993/08/04 17:46:15 brezak
* Changes from nate for gzip'ed sup
*
* Revision 1.1.1.1 1993/05/21 14:52:18 cgd
* initial import of CMU's SUP to NetBSD
*
* Revision 1.10 92/08/11 12:06:42 mrt
@ -94,7 +101,7 @@
/* PGMVERSION is defined separately in each program */
extern char scmversion[]; /* string version of scm */
#define PROTOVERSION 7 /* version of network protocol */
#define PROTOVERSION 8 /* version of network protocol */
#define SCANVERSION 2 /* version of scan file format */
/* TCP servers for name server and file server */

View File

@ -28,8 +28,15 @@
*
**********************************************************************
* HISTORY
* 7-July-93 Nate Williams at Montana State University
* Modified SUP to use gzip based compression when sending files
* across the network to save BandWidth
*
* $Log: supcdefs.h,v $
* Revision 1.1.1.1 1993/05/21 14:52:18 cgd
* Revision 1.2 1993/08/04 17:46:16 brezak
* Changes from nate for gzip'ed sup
*
* Revision 1.1.1.1 1993/05/21 14:52:18 cgd
* initial import of CMU's SUP to NetBSD
*
* Revision 1.6 92/08/11 12:06:52 mrt
@ -114,6 +121,7 @@ typedef struct collstruct COLLECTION;
#define CFVERBOSE 00400
#define CFKEEP 01000
#define CFURELSUF 02000
#define CFCOMPRESS 04000
/*************************
*** M A C R O S ***

View File

@ -168,8 +168,16 @@
*
**********************************************************************
* HISTORY
*
* 7-July-93 Nate Williams at Montana State University
* Modified SUP to use gzip based compression when sending files
* across the network to save BandWidth
*
* $Log: supcmain.c,v $
* Revision 1.2 1993/05/24 17:57:28 brezak
* Revision 1.3 1993/08/04 17:46:17 brezak
* Changes from nate for gzip'ed sup
*
* Revision 1.2 1993/05/24 17:57:28 brezak
* Remove netcrypt.c. Remove unneeded files. Cleanup make.
*
* Revision 1.1.1.1 1993/05/21 14:52:18 cgd
@ -545,6 +553,12 @@ int *oflagsp,*aflagsp;
case 'v':
oflags |= CFVERBOSE;
break;
case 'z':
oflags |= CFCOMPRESS;
break;
case 'Z':
oflags &= ~CFCOMPRESS;
break;
}
argp++;
}

View File

@ -26,8 +26,16 @@
* sup "meat" routines
**********************************************************************
* HISTORY
*
* 7-July-93 Nate Williams at Montana State University
* Modified SUP to use gzip based compression when sending files
* across the network to save BandWidth
*
* $Log: supcmeat.c,v $
* Revision 1.2 1993/05/24 18:57:50 brezak
* Revision 1.3 1993/08/04 17:46:18 brezak
* Changes from nate for gzip'ed sup
*
* Revision 1.2 1993/05/24 18:57:50 brezak
* Use /var/tmp for NetBSD
*
* Revision 1.1.1.1 1993/05/21 14:52:18 cgd
@ -124,6 +132,8 @@
TREE *lastT; /* last filenames in collection */
jmp_buf sjbuf; /* jump location for network errors */
int dontjump; /* flag to void sjbuf */
int cancompress=FALSE; /* Can we do compression? */
int docompress=FALSE; /* Do we do compression? */
extern COLLECTION *thisC; /* collection list pointer */
extern int rpauseflag; /* don't disable resource pausing */
@ -280,6 +290,10 @@ int *tout;
t->Tmode = SCMEOF;
return (TRUE);
}
/* If protocol is > 7 then try compression */
if (protver > 7) {
cancompress = TRUE;
}
return (FALSE);
}
@ -671,6 +685,16 @@ recvfiles ()
int recvone ();
int recvmore;
/* Does the protocol support compression */
if (cancompress) {
/* Check for compression on sending files */
docompress = (thisC->Cflags&CFCOMPRESS);
x = msgcompress();
if ( x != SCMOK)
goaway ("Error sending compression check to server");
if (docompress)
vnotify("SUP Using compressed file transfer\n");
}
recvmore = TRUE;
upgradeT = NULL;
do {
@ -1054,6 +1078,7 @@ char *from; /* 0 if reading from network */
register int fromf,tof,istemp,x;
char dpart[STRINGLENGTH],fpart[STRINGLENGTH];
char tname[STRINGLENGTH];
char sys_com[STRINGLENGTH];
struct stat sbuf;
static int thispid = 0; /* process id # */
@ -1107,7 +1132,8 @@ char *from; /* 0 if reading from network */
if (tof >= 0) break;
istemp = FALSE;
/* give up: try to create output file */
tof = open (to,(O_WRONLY|O_CREAT|O_TRUNC),0600);
if (!docompress)
tof = open (to,(O_WRONLY|O_CREAT|O_TRUNC),0600);
if (tof >= 0) break;
/* no luck */
notify ("SUP: Can't create %s or temp file for it\n",to);
@ -1186,6 +1212,23 @@ char *from; /* 0 if reading from network */
lockout (FALSE);
return (FALSE);
}
/* uncompress it first */
if (docompress) {
sprintf(sys_com, "gunzip < %s > %s\n", tname, to);
/* Uncompress it onto the destination */
if (system(sys_com) < 0) {
notify ("SUP: Error in uncompressing file %s\n",
to);
(void) unlink (tname);
/* Just in case */
(void) unlink (to);
lockout (FALSE);
return (TRUE);
}
(void) unlink (tname);
lockout (FALSE);
return (FALSE);
}
/* move to destination */
if (rename (tname,to) == 0) {
(void) unlink (tname);

View File

@ -26,8 +26,16 @@
* sup collection parsing routines
**********************************************************************
* HISTORY
*
* 7-July-93 Nate Williams at Montana State University
* Modified SUP to use gzip based compression when sending files
* across the network to save BandWidth
*
* $Log: supcparse.c,v $
* Revision 1.1.1.1 1993/05/21 14:52:18 cgd
* Revision 1.2 1993/08/04 17:46:20 brezak
* Changes from nate for gzip'ed sup
*
* Revision 1.1.1.1 1993/05/21 14:52:18 cgd
* initial import of CMU's SUP to NetBSD
*
* Revision 1.6 92/08/11 12:07:38 mrt
@ -68,7 +76,8 @@ extern char _argbreak; /* break character from nxtarg */
typedef enum { /* supfile options */
OHOST, OBASE, OHOSTBASE, OPREFIX, ORELEASE,
ONOTIFY, OLOGIN, OPASSWORD, OCRYPT,
OBACKUP, ODELETE, OEXECUTE, OOLD, OTIMEOUT, OKEEP, OURELSUF
OBACKUP, ODELETE, OEXECUTE, OOLD, OTIMEOUT, OKEEP, OURELSUF,
OCOMPRESS
} OPTION;
struct option {
@ -90,7 +99,8 @@ struct option {
"old", OOLD,
"timeout", OTIMEOUT,
"keep", OKEEP,
"use-rel-suffix", OURELSUF
"use-rel-suffix", OURELSUF,
"compress", OCOMPRESS
};
passdelim (ptr,delim) /* skip over delimiter */
@ -207,6 +217,9 @@ char *collname,*args;
case OURELSUF:
c->Cflags |= CFURELSUF;
break;
case OCOMPRESS:
c->Cflags |= CFCOMPRESS;
break;
case OTIMEOUT:
passdelim (&args,'=');
arg = nxtarg (&args," \t");

View File

@ -25,10 +25,11 @@
/*
* supfilesrv -- SUP File Server
*
* Usage: supfilesrv [-l] [-P] [-N]
* Usage: supfilesrv [-l] [-P] [-N] [-R]
* -l "live" -- don't fork daemon
* -P "debug ports" -- use debugging network ports
* -N "debug network" -- print debugging messages for network i/o
* -R "RCS mode" -- if file is an rcs file, use co to get contents
*
**********************************************************************
* HISTORY
@ -36,9 +37,13 @@
* Changed name of sup program in xpatch from /usr/cs/bin/sup to
* /usr/bin/sup for exported version of sup.
*
* 7-July-93 Nate Williams at Montana State University
* Modified SUP to use gzip based compression when sending files
* across the network to save BandWidth
*
* $Log: supfilesrv.c,v $
* Revision 1.4 1993/06/22 17:20:23 brezak
* Close misbehaving connections instead of exiting.
* Revision 1.5 1993/08/04 17:46:21 brezak
* Changes from nate for gzip'ed sup
*
* Revision 1.3 1993/06/05 21:32:17 cgd
* use daemon() to put supfilesrv into daemon mode...
@ -301,16 +306,26 @@ int live; /* -l flag */
int dbgportsq; /* -P flag */
extern int scmdebug; /* -N flag */
extern int netfile;
#ifdef RCS
int candorcs; /* -R flag */
int dorcs = FALSE;
#endif
char *clienthost; /* host name of client */
int nchildren; /* number of children that exist */
char *prefix; /* collection pathname prefix */
char *release; /* collection release name */
char *cryptkey; /* encryption key if non-null */
#ifdef CVS
char *cvs_root; /* RCS root */
#endif
char *rcs_branch; /* RCS branch name */
int lockfd; /* descriptor of lock file */
/* global variables for scan functions */
int trace = FALSE; /* directory scan trace */
int cancompress = FALSE; /* Can we compress files */
int docompress = FALSE; /* Do we compress files */
HASH *uidH[HASHSIZE]; /* for uid and gid lookup */
HASH *gidH[HASHSIZE];
@ -421,6 +436,9 @@ char **argv;
int maxsleep;
register FILE *f;
#ifdef RCS
candorcs = FALSE;
#endif
live = FALSE;
dbgportsq = FALSE;
scmdebug = 0;
@ -457,6 +475,11 @@ char **argv;
argc -= 2;
argv += 2;
break;
#ifdef RCS
case 'R':
candorcs = TRUE;
break;
#endif
default:
fprintf (stderr,"Unknown flag %s ignored\n",argv[0]);
break;
@ -568,6 +591,10 @@ answer ()
basedir = NULL;
prefix = NULL;
release = NULL;
rcs_branch = NULL;
#ifdef CVS
cvs_root = NULL;
#endif
goawayreason = NULL;
donereason = NULL;
lockfd = -1;
@ -583,7 +610,7 @@ answer ()
x = msgxpatch ();
if (x != SCMOK)
exit (0);
xargv[0] = "/usr/bin/sup";
xargv[0] = "sup";
xargv[1] = "-X";
xargv[xargc] = (char *)NULL;
(void) dup2 (netfile,0);
@ -592,7 +619,7 @@ answer ()
fd = getdtablesize ();
while (--fd > 2)
(void) close (fd);
execv (xargv[0],xargv);
execvp (xargv[0],xargv);
exit (0);
}
listfiles ();
@ -603,6 +630,10 @@ answer ()
if (basedir) free (basedir);
if (prefix) free (prefix);
if (release) free (release);
if (rcs_branch) free (rcs_branch);
#ifdef CVS
if (cvs_root) free (cvs_root);
#endif
if (goawayreason) {
if (donereason == goawayreason)
donereason = NULL;
@ -650,6 +681,9 @@ setup ()
struct stat sbuf;
register TREELIST *tl;
if (protver > 7) {
cancompress = TRUE;
}
x = msgsetup ();
if (x != SCMOK) goaway ("Error reading setup request from client");
if (protver < 4) {
@ -722,6 +756,15 @@ setup ()
goaway ("Error sending setup reply to client");
return;
}
#ifdef RCS
if (candorcs && release != NULL &&
(strncmp(release, "RCS.", 4) == 0)) {
rcs_branch = salloc(&release[4]);
free(release);
release = salloc("RCS");
dorcs = TRUE;
}
#endif
if (release == NULL)
release = salloc (DEFRELEASE);
if (basedir == NULL || *basedir == '\0') {
@ -1045,9 +1088,27 @@ sendfiles ()
register TREELIST *tl;
register int x;
/* Does the protocol support compression */
if (cancompress) {
/* Check for compression on sending files */
x = msgcompress();
if ( x != SCMOK)
goaway ("Error sending compression check to server");
}
/* send all files */
for (tl = listTL; tl != NULL; tl = tl->TLnext) {
cdprefix (tl->TLprefix);
#ifdef CVS
if (candorcs) {
cvs_root = getcwd(NULL, 256);
if (access("CVSROOT", F_OK) < 0)
dorcs = FALSE;
else {
loginfo("is a CVSROOT \"%s\"\n", cvs_root);
dorcs = TRUE;
}
}
#endif
(void) Tprocess (tl->TLtree,sendone);
}
/* send directories in reverse order */
@ -1068,6 +1129,9 @@ sendone (t)
TREE *t;
{
register int x,fd;
register int fdtmp;
char sys_com[STRINGLENGTH], temp_file[STRINGLENGTH], rcs_file[STRINGLENGTH];
union wait status;
char *uconvert(),*gconvert();
int sendfile ();
@ -1076,13 +1140,80 @@ TREE *t;
if ((t->Tmode&S_IFMT) == S_IFDIR) /* send no directories this pass */
return (SCMOK);
x = msgsend ();
if (x != SCMOK) goaway ("Error reading receive file request from client");
if (x != SCMOK) goaway ("Error reading receive file request from clien
t");
upgradeT = t; /* upgrade file pointer */
fd = -1; /* no open file */
if ((t->Tmode&S_IFMT) == S_IFREG) {
if (!listonly && (t->Tflags&FUPDATE) == 0) {
fd = open (t->Tname,O_RDONLY,0);
if (fd < 0) t->Tmode = 0;
#ifdef RCS
if (dorcs) {
char rcs_release[STRINGLENGTH];
tmpnam(rcs_file);
if (strcmp(&t->Tname[strlen(t->Tname)-2], ",v") == 0) {
t->Tname[strlen(t->Tname)-2] = '\0';
if (rcs_branch != NULL)
#ifdef CVS
sprintf(rcs_release, "-r %s", rcs_branch);
#else
sprintf(rcs_release, "-r%s", rcs_branch);
#endif
else
rcs_release[0] = '\0';
#ifdef CVS
sprintf(sys_com, "cvs -d %s -r -l -Q co -p %s %s > %s\n", cvs_root, rcs_release, t->Tname, rcs_file);
#else
sprintf(sys_com, "co -q -p %s %s > %s 2> /dev/null\n", rcs_release, t->Tname, rcs_file);
#endif
/*loginfo("using rcs mode \"%s\"\n", sys_com);*/
status.w_status = system(sys_com);
if (status.w_status < 0 || status.w_retcode) {
/* Just in case */
unlink(rcs_file);
if (status.w_status < 0) {
goaway ("We died trying to \"%s\"", sys_com);
t->Tmode = 0;
}
else {
/*logerr("rcs command failed \"%s\" = %d\n",
sys_com, status.w_retcode);*/
t->Tflags |= FUPDATE;
}
}
else if (docompress) {
tmpnam(temp_file);
sprintf(sys_com, "gzip -c < %s > %s\n", rcs_file, temp_file);
if (system(sys_com) < 0) {
/* Just in case */
unlink(temp_file);
unlink(rcs_file);
goaway ("We died trying to \"%s\"", sys_com);
t->Tmode = 0;
}
fd = open (temp_file,O_RDONLY,0);
}
else
fd = open (rcs_file,O_RDONLY,0);
}
}
#endif
if (fd == -1) {
if (docompress) {
tmpnam(temp_file);
sprintf(sys_com, "gzip -c < %s > %s\n", t->Tname, temp_file);
if (system(sys_com) < 0) {
/* Just in case */
unlink(temp_file);
goaway ("We died trying to \"%s\"", sys_com);
t->Tmode = 0;
}
fd = open (temp_file,O_RDONLY,0);
}
else
fd = open (t->Tname,O_RDONLY,0);
}
if (fd < 0 && (t->Tflags&FUPDATE) == 0) t->Tmode = 0;
}
if (t->Tmode) {
t->Tuser = salloc (uconvert (t->Tuid));
@ -1090,6 +1221,12 @@ TREE *t;
}
}
x = msgrecv (sendfile,fd);
if (docompress)
unlink(temp_file);
#ifdef RCS
if (dorcs)
unlink(rcs_file);
#endif
if (x != SCMOK) goaway ("Error sending file to client");
return (SCMOK);
}
@ -1125,7 +1262,7 @@ va_list ap;
return (SCMOK);
x = writefile (fd);
if (x != SCMOK) goaway ("Error sending file to client");
(void) close (fd);
(void) close (fd);
return (SCMOK);
}

View File

@ -25,8 +25,16 @@
/*
**********************************************************************
* HISTORY
*
* 7-July-93 Nate Williams at Montana State University
* Modified SUP to use gzip based compression when sending files
* across the network to save BandWidth
*
* $Log: supmsg.c,v $
* Revision 1.1.1.1 1993/05/21 14:52:19 cgd
* Revision 1.2 1993/08/04 17:46:23 brezak
* Changes from nate for gzip'ed sup
*
* Revision 1.1.1.1 1993/05/21 14:52:19 cgd
* initial import of CMU's SUP to NetBSD
*
* Revision 2.4 92/09/09 22:05:17 mrt
@ -600,3 +608,15 @@ int msgxpatch ()
}
return (x);
}
/*
* Compression check protocol message
*/
extern int docompress; /* Compress file before sending? */
int msgcompress ()
{
if (server)
return (readmint (MSGCOMPRESS,&docompress));
return (writemint (MSGCOMPRESS, docompress));
}

View File

@ -27,8 +27,16 @@
*
**********************************************************************
* HISTORY
*
* 7-July-93 Nate Williams at Montana State University
* Modified SUP to use gzip based compression when sending files
* across the network to save BandWidth
*
* $Log: supmsg.h,v $
* Revision 1.1.1.1 1993/05/21 14:52:19 cgd
* Revision 1.2 1993/08/04 17:46:24 brezak
* Changes from nate for gzip'ed sup
*
* Revision 1.1.1.1 1993/05/21 14:52:19 cgd
* initial import of CMU's SUP to NetBSD
*
* Revision 1.7 92/08/11 12:08:20 mrt
@ -82,6 +90,7 @@
#define MSGRECV (114)
#define MSGDONE (115)
#define MSGXPATCH (117)
#define MSGCOMPRESS (118)
/* MSGSETUPACK data codes - setupack */
#define FSETUPOK (999)