diff options
author | peter <peter@FreeBSD.org> | 1995-12-26 05:03:11 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 1995-12-26 05:03:11 +0000 |
commit | 0f0c1319be7a6a44be1d4618b57bb658be4021e0 (patch) | |
tree | ad3e96caee4fc9d4abc6511e1a60451468df6953 /usr.sbin/sup/lib | |
parent | 7c00e461f5543b11fe323d3703b7842fe708842d (diff) | |
download | FreeBSD-src-0f0c1319be7a6a44be1d4618b57bb658be4021e0.zip FreeBSD-src-0f0c1319be7a6a44be1d4618b57bb658be4021e0.tar.gz |
Apply ports/net/sup/patches/patch-aa...
Diffstat (limited to 'usr.sbin/sup/lib')
-rw-r--r-- | usr.sbin/sup/lib/ffilecopy.c | 4 | ||||
-rw-r--r-- | usr.sbin/sup/lib/libc.h | 29 | ||||
-rw-r--r-- | usr.sbin/sup/lib/log.c | 12 | ||||
-rw-r--r-- | usr.sbin/sup/lib/run.c | 14 | ||||
-rw-r--r-- | usr.sbin/sup/lib/scan.c | 80 | ||||
-rw-r--r-- | usr.sbin/sup/lib/scm.c | 58 | ||||
-rw-r--r-- | usr.sbin/sup/lib/scmio.c | 58 | ||||
-rw-r--r-- | usr.sbin/sup/lib/stree.c | 7 | ||||
-rw-r--r-- | usr.sbin/sup/lib/sup.h | 11 | ||||
-rw-r--r-- | usr.sbin/sup/lib/supmsg.c | 22 | ||||
-rw-r--r-- | usr.sbin/sup/lib/supmsg.h | 6 | ||||
-rw-r--r-- | usr.sbin/sup/lib/vprintf.c | 12 |
12 files changed, 245 insertions, 68 deletions
diff --git a/usr.sbin/sup/lib/ffilecopy.c b/usr.sbin/sup/lib/ffilecopy.c index 4cb4262..edef883 100644 --- a/usr.sbin/sup/lib/ffilecopy.c +++ b/usr.sbin/sup/lib/ffilecopy.c @@ -58,7 +58,7 @@ FILE *here, *there; if (fflush (there) == EOF) /* flush pending output */ return (EOF); -#ifdef __386BSD__ +#ifdef __FreeBSD__ if ((here->_r) > 0) { /* flush buffered input */ i = write (therefile, here->_p, here->_r); if (i != here->_r) return (EOF); @@ -76,7 +76,7 @@ FILE *here, *there; i = filecopy (herefile, therefile); /* fast file copy */ if (i < 0) return (EOF); -#ifdef __386BSD__ +#ifdef __FreeBSD__ (here->_flags) |= __SEOF; /* indicate EOF */ #else (here->_flag) |= _IOEOF; /* indicate EOF */ diff --git a/usr.sbin/sup/lib/libc.h b/usr.sbin/sup/lib/libc.h index 108f701..03d7d05 100644 --- a/usr.sbin/sup/lib/libc.h +++ b/usr.sbin/sup/lib/libc.h @@ -26,6 +26,11 @@ ********************************************************************** * HISTORY * $Log: libc.h,v $ + * Revision 1.1.1.1 1995/12/26 04:54:47 peter + * Import the unmodified version of the sup that we are using. + * The heritage of this version is not clear. It appears to be NetBSD + * derived from some time ago. + * * Revision 1.1.1.1 1993/08/21 00:46:33 jkh * Current sup with compression support. * @@ -81,6 +86,10 @@ #ifndef _LIBC_H_ #define _LIBC_H_ 1 +#if defined(__hpux) +#define __P(x) x +#endif + #ifndef _TYPES_ #include <sys/types.h> #endif /* _TYPES_ */ @@ -195,6 +204,26 @@ typedef int (*PFI)(); #if defined(c_plusplus) typedef int (*PFI2)(...); #endif /* c_plusplus */ + +#if defined(__hpux) +extern int utimes(char *, struct timeval *); + +#ifndef LOCK_SH +#define LOCK_SH 1 +#endif +#ifndef LOCK_EX +#define LOCK_EX 2 +#endif +#ifndef LOCK_NB +#define LOCK_NB 4 +#endif +#ifndef LOCK_UN +#define LOCK_UN 8 +#endif + +extern int flock(int, int); +#endif /* __hpux */ + #if 0 extern void abort(void); extern int abs(int); diff --git a/usr.sbin/sup/lib/log.c b/usr.sbin/sup/lib/log.c index 4879cf7..2974b4a 100644 --- a/usr.sbin/sup/lib/log.c +++ b/usr.sbin/sup/lib/log.c @@ -27,6 +27,11 @@ ********************************************************************** * HISTORY * $Log: log.c,v $ + * Revision 1.1.1.1 1995/12/26 04:54:47 peter + * Import the unmodified version of the sup that we are using. + * The heritage of this version is not clear. It appears to be NetBSD + * derived from some time ago. + * * Revision 1.1.1.1 1993/08/21 00:46:33 jkh * Current sup with compression support. * @@ -52,8 +57,13 @@ */ #include <stdio.h> +#ifdef __hpux +#include <syslog.h> +#include <stdlib.h> +#else #include <sys/syslog.h> #include <c.h> +#endif #if __STDC__ #include <stdarg.h> #else @@ -72,7 +82,7 @@ logopen(program) char *program; { if (opened) return; - openlog(program,LOG_PID,LOG_DAEMON); + openlog(program,LOG_PID,LOG_LOCAL1); opened++; } diff --git a/usr.sbin/sup/lib/run.c b/usr.sbin/sup/lib/run.c index 9072ebe..0e9a581 100644 --- a/usr.sbin/sup/lib/run.c +++ b/usr.sbin/sup/lib/run.c @@ -47,6 +47,11 @@ ********************************************************************** * HISTORY * $Log: run.c,v $ + * Revision 1.1.1.1 1995/12/26 04:54:47 peter + * Import the unmodified version of the sup that we are using. + * The heritage of this version is not clear. It appears to be NetBSD + * derived from some time ago. + * * Revision 1.1.1.1 1993/08/21 00:46:33 jkh * Current sup with compression support. * @@ -95,6 +100,7 @@ #include <signal.h> #include <sys/wait.h> #include <varargs.h> +#define MAXARGS 100 static int dorun(); @@ -123,10 +129,14 @@ va_dcl { int val; va_list ap; - + char *args[MAXARGS]; + int argno=0; + va_start(ap); - val = runvp (name,ap); + while (argno < MAXARGS + && (args[argno++] = va_arg(ap, char *)) != (char *)0); va_end(ap); + val = runvp (name,args); return (val); } diff --git a/usr.sbin/sup/lib/scan.c b/usr.sbin/sup/lib/scan.c index e68bcdd..9547ab6 100644 --- a/usr.sbin/sup/lib/scan.c +++ b/usr.sbin/sup/lib/scan.c @@ -28,6 +28,11 @@ ********************************************************************** * HISTORY * $Log: scan.c,v $ + * Revision 1.1.1.1 1995/12/26 04:54:47 peter + * Import the unmodified version of the sup that we are using. + * The heritage of this version is not clear. It appears to be NetBSD + * derived from some time ago. + * * Revision 1.1.1.1 1993/08/21 00:46:33 jkh * Current sup with compression support. * @@ -122,13 +127,13 @@ static char *options[] = { typedef enum { /* <collection>/list file lines */ LUPGRADE, LOMIT, LBACKUP, LEXECUTE, LINCLUDE, LNOACCT, LOMITANY, LALWAYS, - LSYMLINK, LRSYMLINK + LSYMLINK, LRSYMLINK, LRENAME } LISTTYPE; static char *ltname[] = { "upgrade", "omit", "backup", "execute", "include", "noaccount", "omitany", "always", - "symlink", "rsymlink", + "symlink", "rsymlink", "rename", 0 }; @@ -365,9 +370,11 @@ register TREE *t; if (newonly && (t->Tflags&FNEW) == 0) return (SCMOK); - newt = Tinsert (&listT,t->Tname,FALSE); + newt = Tinsert (&listT,t->Tname,t->Tflags&FRENAME ? TRUE : FALSE); if (newt == NULL) return (SCMOK); + if(t->Tnewname) + newt->Tnewname = salloc(t->Tnewname); newt->Tmode = t->Tmode; newt->Tflags = t->Tflags; newt->Tmtime = t->Tmtime; @@ -473,6 +480,10 @@ char *fname; case LUPGRADE: t = &upgT; break; + case LRENAME: + t = &flagsT; + flags = FRENAME; + break; case LBACKUP: t = &flagsT; flags = FBACKUP; @@ -522,7 +533,7 @@ char *fname; if (*q == 0) _argbreak = ')'; else - expTinsert (q,&execT,0,r); + expTinsert (q,&execT,0,r,NULL); } while (_argbreak != ')'); continue; } @@ -533,22 +544,37 @@ char *fname; while (*(q=nxtarg(&p," \t"))) { if (lt == LOMITANY) (void) Tinsert (t,q,FALSE); + else if( lt == LRENAME ) + if(*(r=nxtarg(&p," \t"))) + { + expTinsert (q,t,flags,(char *)NULL,r); + /* + * Omit the file it is being + * renamed to, to avoid confusion + */ + expTinsert (r,&omitT,0, + (char *)NULL, (char *)NULL); + } + else + printf("Rename %s without destination " + "file. Skipping...\n", q); else - expTinsert (q,t,flags,(char *)NULL); + expTinsert (q,t,flags,(char *)NULL,(char *)NULL); } } (void) fclose (f); } static -expTinsert (p,t,flags,exec) +expTinsert (p,t,flags,exec, q) char *p; +char *q; TREE **t; int flags; char *exec; { register int n, i; - register TREE *newt; + register TREE *newt, *ts; char *speclist[SPECNUMBER]; char buf[STRINGLENGTH]; @@ -557,18 +583,25 @@ char *exec; newt = Tinsert (t,speclist[i],TRUE); newt->Tflags |= flags; if (exec) { - (void) sprintf (buf,exec,speclist[i]); + if((ts = Tsearch(flagsT, speclist[i])) + && ts->Tflags&FRENAME) + (void) sprintf (buf,exec,ts->Tnewname); + else + (void) sprintf (buf,exec,speclist[i]); (void) Tinsert (&newt->Texec,buf,FALSE); } + if (q) + newt->Tnewname = salloc(q); free (speclist[i]); } } static -listone (t) /* expand and add one name from upgrade list */ +listone(t) /* expand and add one name from upgrade list */ TREE *t; { - listentry(t->Tname,t->Tname,(char *)NULL,(t->Tflags&FALWAYS) != 0); + listentry(t->Tname,t->Tname,(char *)NULL, + (t->Tflags&FALWAYS) != 0); return (SCMOK); } @@ -644,8 +677,11 @@ register struct stat *st; t->Tctime = st->st_ctime; t->Tmtime = st->st_mtime; if (new) t->Tflags |= FNEW; - if (ts = Tsearch (flagsT,name)) + if (ts = Tsearch (flagsT,name)){ t->Tflags |= ts->Tflags; + if(t->Tflags&FRENAME) + t->Tnewname = salloc(ts->Tnewname); + } if (ts = Tsearch (execT,name)) { t->Texec = ts->Texec; ts->Texec = NULL; @@ -831,6 +867,10 @@ char *scanfile; p++; ts.Tflags |= FNOACCT; } + if (*p == 'R') { + p++; + ts.Tflags |= FRENAME; + } if ((q = index (p,' ')) == NULL) goaway ("scanfile format inconsistant"); *q++ = '\0'; @@ -845,6 +885,15 @@ char *scanfile; goaway ("scanfile format inconsistant"); *q++ = 0; ts.Tmtime = atoi (p); + p = q; + ts.Tnewname = NULL; + if (ts.Tflags & FRENAME){ + if ((q = index (p,' ')) == NULL) + goaway ("scanfile format inconsistant"); + *q++ = '\0'; + ts.Tnewname = salloc(q); + q = p; + } if (ts.Tctime > lasttime) ts.Tflags |= FNEW; else if (newonly) { @@ -863,6 +912,7 @@ char *scanfile; t->Tflags = ts.Tflags; t->Tctime = ts.Tctime; t->Tmtime = ts.Tmtime; + t->Tnewname = ts.Tnewname; } (void) fclose (f); return (TRUE); @@ -925,8 +975,14 @@ FILE **scanF; if (t->Tflags&FBACKUP) fprintf (*scanF,"B"); if (t->Tflags&FNOACCT) fprintf (*scanF,"N"); - fprintf (*scanF,"%o %d %d %s\n", + if (t->Tflags&FRENAME) fprintf (*scanF,"R"); + + fprintf (*scanF,"%o %d %d", t->Tmode,t->Tctime,t->Tmtime,t->Tname); + if ( t->Tflags&FRENAME) + fprintf (*scanF," %s %s\n",t->Tname, t->Tnewname); + else + fprintf (*scanF," %s\n", t->Tname); (void) Tprocess (t->Texec,recordexec,*scanF); return (SCMOK); } diff --git a/usr.sbin/sup/lib/scm.c b/usr.sbin/sup/lib/scm.c index 5d71bcc..9b793e2 100644 --- a/usr.sbin/sup/lib/scm.c +++ b/usr.sbin/sup/lib/scm.c @@ -69,6 +69,11 @@ * since Tahoe version of <netinet/in.h> does not define them. * * $Log: scm.c,v $ + * Revision 1.1.1.1 1995/12/26 04:54:47 peter + * Import the unmodified version of the sup that we are using. + * The heritage of this version is not clear. It appears to be NetBSD + * derived from some time ago. + * * Revision 1.2 1994/06/20 06:04:04 rgrimes * Humm.. they did a lot of #if __STDC__ but failed to properly prototype * the code. Also fixed one bad argument to a wait3 call. @@ -208,7 +213,7 @@ char scmversion[] = "4.3 BSD"; * PROTOTYPES */ #if __STDC__ -int scmerr __P((int, char *,...)); +int scmerr __P((int, FILE *, char *,...)); #endif /************************* *** M A C R O S *** @@ -245,31 +250,31 @@ char *server; int one = 1; if (myhost () == NULL) - return (scmerr (-1,"Local hostname not known")); + return (scmerr (-1, stderr, "Local hostname not known")); if ((sp = getservbyname(server,"tcp")) == 0) { if (strcmp(server, FILEPORT) == 0) port = htons((u_short)FILEPORTNUM); else if (strcmp(server, DEBUGFPORT) == 0) port = htons((u_short)DEBUGFPORTNUM); else - return (scmerr (-1,"Can't find %s server description",server)); - (void) scmerr (-1,"%s/tcp: unknown service: using port %d", + return (scmerr (-1, stderr, "Can't find %s server description",server)); + (void) scmerr (-1, stderr, "%s/tcp: unknown service: using port %d", server,port); } else port = sp->s_port; endservent (); sock = socket (AF_INET,SOCK_STREAM,0); if (sock < 0) - return (scmerr (errno,"Can't create socket for connections")); + return (scmerr (errno, stderr, "Can't create socket for connections")); if (setsockopt (sock,SOL_SOCKET,SO_REUSEADDR,(char *)&one,sizeof(int)) < 0) - (void) scmerr (errno,"Can't set SO_REUSEADDR socket option"); + (void) scmerr (errno, stderr, "Can't set SO_REUSEADDR socket option"); (void) bzero ((char *)&sin,sizeof(sin)); sin.sin_family = AF_INET; sin.sin_port = port; if (bind (sock,(struct sockaddr *)&sin,sizeof(sin)) < 0) - return (scmerr (errno,"Can't bind socket for connections")); + return (scmerr (errno, stderr, "Can't bind socket for connections")); if (listen (sock,NCONNECTS) < 0) - return (scmerr (errno,"Can't listen on socket")); + return (scmerr (errno, stderr, "Can't listen on socket")); return (SCMOK); } @@ -284,16 +289,16 @@ service () netfile = accept (sock,(struct sockaddr *)&from,&len); } while (netfile < 0 && errno == EINTR); if (netfile < 0) - return (scmerr (errno,"Can't accept connections")); + return (scmerr (errno, stderr, "Can't accept connections")); remoteaddr = from.sin_addr; if (read(netfile,(char *)&x,sizeof(int)) != sizeof(int)) - return (scmerr (errno,"Can't transmit data on connection")); + return (scmerr (errno, stderr, "Can't transmit data on connection")); if (x == 0x01020304) swapmode = 0; else if (x == 0x04030201) swapmode = 1; else - return (scmerr (-1,"Unexpected byteswap mode %x",x)); + return (scmerr (-1, stderr, "Unexpected byteswap mode %x",x)); return (SCMOK); } @@ -354,7 +359,7 @@ int *t,*b; s = *t; *t -= s; } - (void) scmerr (-1,"Will retry in %d seconds",s); + (void) scmerr (-1, stdout, "Will retry in %d seconds",s); sleep (s); return (1); } @@ -376,9 +381,9 @@ int *retry; else if (strcmp(server, DEBUGFPORT) == 0) port = htons((u_short)DEBUGFPORTNUM); else - return (scmerr (-1,"Can't find %s server description", + return (scmerr (-1, stderr, "Can't find %s server description", server)); - (void) scmerr (-1,"%s/tcp: unknown service: using port %d", + (void) scmerr (-1, stderr, "%s/tcp: unknown service: using port %d", server,port); } else port = sp->s_port; @@ -387,7 +392,7 @@ int *retry; sin.sin_addr.s_addr = inet_addr (hostname); if (sin.sin_addr.s_addr == (u_long) INADDR_NONE) { if ((h = gethostbyname (hostname)) == NULL) - return (scmerr (-1,"Can't find host entry for %s", + return (scmerr (-1, stderr, "Can't find host entry for %s", hostname)); hostname = h->h_name; (void) bcopy (h->h_addr,(char *)&sin.sin_addr,h->h_length); @@ -397,11 +402,11 @@ int *retry; for (;;) { netfile = socket (AF_INET,SOCK_STREAM,0); if (netfile < 0) - return (scmerr (errno,"Can't create socket")); + return (scmerr (errno, stderr, "Can't create socket")); tin = sin; if (connect(netfile,(struct sockaddr *)&tin,sizeof(tin)) >= 0) break; - (void) scmerr (errno,"Can't connect to server for %s",server); + (void) scmerr (errno, stderr, "Can't connect to server for %s",server); (void) close(netfile); if (!dobackoff (retry,&backoff)) return (SCMERR); @@ -522,6 +527,8 @@ char *name; struct hostent *h; struct in_addr addr; char **ap; + if(!strcmp(name,"*")) + return (1); if ((addr.s_addr = inet_addr(name)) != (u_long) INADDR_NONE) return (addr.s_addr == remoteaddr.s_addr); if ((h = gethostbyname (name)) == 0) @@ -535,7 +542,7 @@ char *name; } #if __STDC__ -int scmerr (int errno,char *fmt,...) +int scmerr (int errno,FILE *filedes,char *fmt,...) #else /*VARARGS*//*ARGSUSED*/ int scmerr (va_alist) @@ -544,15 +551,16 @@ va_dcl { #if !__STDC__ int errno; + FILE *filedes; char *fmt; #endif va_list ap; - (void) fflush (stdout); + (void) fflush (filedes); if (progpid > 0) - fprintf (stderr,"%s %d: ",program,progpid); + fprintf (filedes,"%s %d: ",program,progpid); else - fprintf (stderr,"%s: ",program); + fprintf (filedes,"%s: ",program); #if __STDC__ va_start(ap,fmt); #else @@ -560,13 +568,13 @@ va_dcl errno = va_arg(ap,int); fmt = va_arg(ap,char *); #endif - vfprintf(stderr, fmt, ap); + vfprintf(filedes, fmt, ap); va_end(ap); if (errno >= 0) - fprintf (stderr,": %s\n",errmsg(errno)); + fprintf (filedes,": %s\n",errmsg(errno)); else - fprintf (stderr,"\n"); - (void) fflush (stderr); + fprintf (filedes,"\n"); + (void) fflush (filedes); return (SCMERR); } diff --git a/usr.sbin/sup/lib/scmio.c b/usr.sbin/sup/lib/scmio.c index cde2c9f..713ceef 100644 --- a/usr.sbin/sup/lib/scmio.c +++ b/usr.sbin/sup/lib/scmio.c @@ -109,6 +109,11 @@ ********************************************************************** * HISTORY * $Log: scmio.c,v $ + * Revision 1.1.1.1 1995/12/26 04:54:47 peter + * Import the unmodified version of the sup that we are using. + * The heritage of this version is not clear. It appears to be NetBSD + * derived from some time ago. + * * Revision 1.1.1.1 1993/08/21 00:46:33 jkh * Current sup with compression support. * @@ -249,13 +254,13 @@ char *data; } if (x <= 0) { if (errno == EPIPE) - return (scmerr (-1,"Network write timed out")); + return (scmerr (-1,stderr,"Network write timed out")); if (errno) - return (scmerr (errno,"Write error on network")); - return (scmerr (-1,"Write retries failed")); + return (scmerr (errno,stderr,"Write error on network")); + return (scmerr (-1,stderr,"Write retries failed")); } if (x != count) - return (scmerr (-1,"Write error on network returned %d on write of %d",x,count)); + return (scmerr (-1,stderr,"Write error on network returned %d on write of %d",x,count)); return (SCMOK); } @@ -280,7 +285,7 @@ int msg; if (scmdebug > 1) loginfo ("SCM Writing message %d",msg); if (bufptr) - return (scmerr (-1,"Buffering already enabled")); + return (scmerr (-1,stderr,"Buffering already enabled")); bufptr = buffers; bufptr->b_ptr = bufptr->b_data; bufptr->b_cnt = 0; @@ -298,7 +303,7 @@ writemend () /* write end of message */ x = writedata (sizeof(int),(char *)&x); if (x != SCMOK) return (x); if (bufptr == NULL) - return (scmerr (-1,"Buffering already disabled")); + return (scmerr (-1,stderr,"Buffering already disabled")); if (bufptr->b_cnt == 0) { bufptr = NULL; return (SCMOK); @@ -351,7 +356,7 @@ int f; struct stat statbuf; if (fstat(f,&statbuf) < 0) - return (scmerr (errno,"Can't access open file for message")); + return (scmerr (errno,stderr,"Can't access open file for message")); filesize = statbuf.st_size; y = byteswap(filesize); x = writedata (sizeof(int),(char *)&y); @@ -375,9 +380,9 @@ int f; } while (x == SCMOK && number > 0); } if (sum != filesize) - return (scmerr (-1,"File size error on output message")); + return (scmerr (-1,stderr,"File size error on output message")); if (number < 0) - return (scmerr (errno,"Read error on file output message")); + return (scmerr (errno,stderr,"Read error on file output message")); return (x); } @@ -431,7 +436,7 @@ char *data; if (count < 0) { if (bufptr + count < buffer) - return (scmerr (-1,"No space in buffer %d",count)); + return (scmerr (-1,stderr,"No space in buffer %d",count)); bufptr += count; bufcnt -= count; bcopy (data,bufptr,-count); @@ -463,16 +468,21 @@ char *data; tries = 0; for (;;) { imask = 1 << netfile; +#if defined(__hpux) + if (select(32,&imask,(int *)0,(int *)0,&timout) < 0) +#else if (select(32,(fd_set *)&imask,(fd_set *)0,(fd_set *)0,&timout) < 0) +#endif imask = 1; errno = 0; if (imask) x = read (netfile,p,n); else - return (scmerr (-1,"Timeout on network input")); + return (scmerr (-1,stderr,"Timeout on network input")); if (x > 0) break; if (x == 0) - return (scmerr (-1,"Premature EOF on network input")); + return (scmerr (-1,stderr,"Premature EOF on network " + "input")); if (errno) break; if (++tries > RETRIES) break; if (scmdebug > 0) @@ -480,8 +490,8 @@ char *data; } if (x < 0) { if (errno) - return (scmerr (errno,"Read error on network")); - return (scmerr (-1,"Read retries failed")); + return (scmerr (errno,stderr,"Read error on network")); + return (scmerr (-1,stderr,"Read retries failed")); } p += x; n -= x; @@ -538,7 +548,7 @@ int msg; /* if message is unexpected, send back SCMHUH */ /* check for MSGGOAWAY in case he noticed problems first */ if (m != MSGGOAWAY) - return (scmerr (-1,"Received unexpected message %d",m)); + return (scmerr (-1,stderr,"Received unexpected message %d",m)); (void) netcrypt ((char *)NULL); (void) readstring (&goawayreason); (void) readmend (); @@ -555,7 +565,7 @@ readmend () x = readdata (sizeof(int),(char *)&y); y = byteswap(y); if (x == SCMOK && y != ENDCOUNT) - return (scmerr (-1,"Error reading end of message")); + return (scmerr (-1,stderr,"Error reading end of message")); return (x); } @@ -567,7 +577,7 @@ readskip () /* skip over one input block */ x = readcount (&n); if (x != SCMOK) return (x); if (n < 0) - return (scmerr (-1,"Invalid message count %d",n)); + return (scmerr (-1,stderr,"Invalid message count %d",n)); while (x == SCMOK && n > 0) { x = readdata (XFERSIZE(n),buf); n -= XFERSIZE(n); @@ -583,9 +593,9 @@ int *buf; x = readcount (&y); if (x != SCMOK) return (x); if (y < 0) - return (scmerr (-1,"Invalid message count %d",y)); + return (scmerr (-1,stderr,"Invalid message count %d",y)); if (y != sizeof(int)) - return (scmerr (-1,"Size error for int message is %d",y)); + return (scmerr (-1,stderr,"Size error for int message is %d",y)); x = readdata (sizeof(int),(char *)&y); (*buf) = byteswap(y); if (scmdebug > 2) @@ -609,11 +619,11 @@ register char **buf; return (SCMOK); } if (count < 0) - return (scmerr (-1,"Invalid message count %d",count)); + return (scmerr (-1,stderr,"Invalid message count %d",count)); if (scmdebug > 3) loginfo ("SCM Reading string count %d",count); if ((p = (char *)malloc ((unsigned)count+1)) == NULL) - return (scmerr (-1,"Can't malloc %d bytes for string",count)); + return (scmerr (-1,stderr,"Can't malloc %d bytes for string",count)); if (cryptflag) { x = getcryptbuf (count+1); if (x == SCMOK) x = readdata (count,cryptbuf); @@ -647,7 +657,7 @@ int f; x = readcount (&count); if (x != SCMOK) return (x); if (count < 0) - return (scmerr (-1,"Invalid message count %d",count)); + return (scmerr (-1,stderr,"Invalid message count %d",count)); while (x == SCMOK && count > 0) { if (cryptflag) { x = readdata (XFERSIZE(count),cryptbuf); @@ -709,7 +719,11 @@ crosspatch () FD_ZERO (&xbits); FD_SET (0,&ibits); FD_SET (netfile,&ibits); +#if defined(__hpux) + if ((c = select(16, (int *)&ibits, (int *)&obits, (int *)&xbits, +#else if ((c = select(16, &ibits, &obits, &xbits, +#endif (struct timeval *)NULL)) < 1) { if (c == -1) { if (errno == EINTR) { diff --git a/usr.sbin/sup/lib/stree.c b/usr.sbin/sup/lib/stree.c index 0170b3b..5b09430 100644 --- a/usr.sbin/sup/lib/stree.c +++ b/usr.sbin/sup/lib/stree.c @@ -28,6 +28,11 @@ ********************************************************************** * HISTORY * $Log: stree.c,v $ + * Revision 1.1.1.1 1995/12/26 04:54:47 peter + * Import the unmodified version of the sup that we are using. + * The heritage of this version is not clear. It appears to be NetBSD + * derived from some time ago. + * * Revision 1.1.1.1 1993/08/21 00:46:34 jkh * Current sup with compression support. * @@ -77,6 +82,7 @@ register TREE **t; Tfree (&((*t)->Tlo)); Tfree (&((*t)->Thi)); if ((*t)->Tname) free ((*t)->Tname); + if ((*t)->Tnewname) free ((*t)->Tnewname); if ((*t)->Tuser) free ((*t)->Tuser); if ((*t)->Tgroup) free ((*t)->Tgroup); free (*(char **)t); @@ -90,6 +96,7 @@ char *p; register TREE *t; t = (TREE *) malloc (sizeof (TREE)); t->Tname = (p == NULL) ? NULL : salloc (p); + t->Tnewname = NULL; t->Tflags = 0; t->Tuid = 0; t->Tgid = 0; diff --git a/usr.sbin/sup/lib/sup.h b/usr.sbin/sup/lib/sup.h index 0b5f07e..12f03c3 100644 --- a/usr.sbin/sup/lib/sup.h +++ b/usr.sbin/sup/lib/sup.h @@ -39,6 +39,11 @@ * across the network to save BandWidth * * $Log: sup.h,v $ + * Revision 1.1.1.1 1995/12/26 04:54:47 peter + * Import the unmodified version of the sup that we are using. + * The heritage of this version is not clear. It appears to be NetBSD + * derived from some time ago. + * * Revision 1.1.1.1 1993/08/21 00:46:34 jkh * Current sup with compression support. * @@ -101,8 +106,8 @@ /* PGMVERSION is defined separately in each program */ extern char scmversion[]; /* string version of scm */ -#define PROTOVERSION 8 /* version of network protocol */ -#define SCANVERSION 2 /* version of scan file format */ +#define PROTOVERSION 9 /* version of network protocol */ +#define SCANVERSION 3 /* version of scan file format */ /* TCP servers for name server and file server */ #define FILEPORT "supfilesrv" @@ -182,6 +187,7 @@ extern char scmversion[]; /* string version of scm */ struct treestruct { /* fields for file information */ char *Tname; /* path component name */ + char *Tnewname; /* Used for renameing files */ int Tflags; /* flags of file */ int Tmode; /* st_mode of file */ char *Tuser; /* owner of file */ @@ -220,6 +226,7 @@ typedef struct tliststruct TREELIST; #define FBACKUP 02 /* backup of file is allowed */ #define FNOACCT 04 /* don't set file information */ #define FUPDATE 010 /* only set file information */ +#define FRENAME 020 /* Rename this file while updating */ #define FNEEDED 0100000 /* file needed for upgrade */ /* version 3 compatability */ diff --git a/usr.sbin/sup/lib/supmsg.c b/usr.sbin/sup/lib/supmsg.c index 3894910..b12c945 100644 --- a/usr.sbin/sup/lib/supmsg.c +++ b/usr.sbin/sup/lib/supmsg.c @@ -31,6 +31,11 @@ * across the network to save BandWidth * * $Log: supmsg.c,v $ + * Revision 1.1.1.1 1995/12/26 04:54:47 peter + * Import the unmodified version of the sup that we are using. + * The heritage of this version is not clear. It appears to be NetBSD + * derived from some time ago. + * * Revision 1.1.1.1 1993/08/21 00:46:35 jkh * Current sup with compression support. * @@ -299,6 +304,7 @@ int msgrefuse () * list files message */ extern TREE *listT; /* tree of files to list */ +extern TREE *renameT; /* tree of rename target files */ extern long scantime; /* time that collection was scanned */ static int listone (t) @@ -307,6 +313,8 @@ register TREE *t; register int x; x = writestring (t->Tname); + if ( protver > 8 ) + if (x == SCMOK) x = writestring (t->Tnewname); if (x == SCMOK) x = writeint ((int)t->Tmode); if (x == SCMOK) x = writeint ((int)t->Tflags); if (x == SCMOK) x = writeint (t->Tmtime); @@ -323,19 +331,25 @@ int msglist () if (x == SCMOK) x = writeint ((int)scantime); if (x == SCMOK) x = writemend (); } else { - char *name; + char *name, *newname = NULL; int mode,flags,mtime; register TREE *t; x = readmsg (MSGLIST); if (x == SCMOK) x = readstring (&name); while (x == SCMOK) { if (name == NULL) break; - x = readint (&mode); + if (protver > 8){ + x = readstring (&newname); + if (x == SCMOK) x = readint (&mode); + } + else + x = readint (&mode); if (x == SCMOK) x = readint (&flags); if (x == SCMOK) x = readint (&mtime); if (x != SCMOK) break; t = Tinsert (&listT,name,TRUE); free (name); + t->Tnewname = newname; t->Tmode = mode; t->Tflags = flags; t->Tmtime = mtime; @@ -474,6 +488,8 @@ va_dcl return (x); } if (x == SCMOK) x = writestring (t->Tname); + if (protver > 8) + if (x == SCMOK) x = writestring (t->Tnewname); if (x == SCMOK) x = writeint (t->Tmode); if (t->Tmode == 0) { if (x == SCMOK) x = writemend (); @@ -499,6 +515,8 @@ va_dcl if (x == SCMOK) x = (*xferfile) (NULL,args); return (x); } + if (protver > 8) + if (x == SCMOK) x = readstring (&t->Tnewname); if (x == SCMOK) x = readint (&t->Tmode); if (t->Tmode == 0) { x = readmend (); diff --git a/usr.sbin/sup/lib/supmsg.h b/usr.sbin/sup/lib/supmsg.h index b30ea9a..e6185c4 100644 --- a/usr.sbin/sup/lib/supmsg.h +++ b/usr.sbin/sup/lib/supmsg.h @@ -33,6 +33,11 @@ * across the network to save BandWidth * * $Log: supmsg.h,v $ + * Revision 1.1.1.1 1995/12/26 04:54:47 peter + * Import the unmodified version of the sup that we are using. + * The heritage of this version is not clear. It appears to be NetBSD + * derived from some time ago. + * * Revision 1.1.1.1 1993/08/21 00:46:35 jkh * Current sup with compression support. * @@ -170,6 +175,7 @@ EXTERN TREE *refuseT; /* tree of files to refuse */ /* msglist */ EXTERN TREE *listT; /* tree of files to list */ +EXTERN TREE *renameT; /* tree of file rename targets */ EXTERN long scantime; /* time that collection was scanned */ /* msgneed */ diff --git a/usr.sbin/sup/lib/vprintf.c b/usr.sbin/sup/lib/vprintf.c index 235a5f1..2c1a309 100644 --- a/usr.sbin/sup/lib/vprintf.c +++ b/usr.sbin/sup/lib/vprintf.c @@ -28,6 +28,11 @@ ********************************************************************** * HISTORY * $Log: vprintf.c,v $ + * Revision 1.1.1.1 1995/12/26 04:54:47 peter + * Import the unmodified version of the sup that we are using. + * The heritage of this version is not clear. It appears to be NetBSD + * derived from some time ago. + * * Revision 1.1.1.1 1993/08/21 00:46:35 jkh * Current sup with compression support. * @@ -118,9 +123,16 @@ vsnprintf(s, n, fmt, args) { FILE fakebuf; +#ifdef __hpux + fakebuf._flag = _IODUMMY+_IOWRT;/* no _IOWRT: avoid stdio bug */ + fakebuf._base = fakebuf._ptr = s; + fakebuf._cnt = n-1; + fakebuf.__fileL = fakebuf.__fileH = 0xff; +#else fakebuf._flag = _IOSTRG+_IOWRT; /* no _IOWRT: avoid stdio bug */ fakebuf._ptr = s; fakebuf._cnt = n-1; +#endif _doprnt(fmt, args, &fakebuf); fakebuf._cnt++; putc('\0', &fakebuf); |