diff options
Diffstat (limited to 'usr.bin/sup')
34 files changed, 1005 insertions, 1336 deletions
diff --git a/usr.bin/sup/src/atoo.c b/usr.bin/sup/src/atoo.c index 83925d6abbf..79e21e5fee6 100644 --- a/usr.bin/sup/src/atoo.c +++ b/usr.bin/sup/src/atoo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: atoo.c,v 1.2 1996/06/26 05:39:37 deraadt Exp $ */ +/* $OpenBSD: atoo.c,v 1.3 1997/04/01 07:34:57 todd Exp $ */ /* * Copyright (c) 1991 Carnegie Mellon University @@ -39,6 +39,8 @@ * Rewritten for VAX. * */ +#include "supcdefs.h" +#include "supextern.h" unsigned int atoo(ap) char *ap; diff --git a/usr.bin/sup/src/errmsg.c b/usr.bin/sup/src/errmsg.c index b947180bdbc..44f6b1c71ee 100644 --- a/usr.bin/sup/src/errmsg.c +++ b/usr.bin/sup/src/errmsg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: errmsg.c,v 1.2 1996/06/26 05:39:39 deraadt Exp $ */ +/* $OpenBSD: errmsg.c,v 1.3 1997/04/01 07:34:59 todd Exp $ */ /* * Copyright (c) 1991 Carnegie Mellon University @@ -33,9 +33,11 @@ * BBN uses a negative OR zero value. */ -extern int errno; -extern int sys_nerr; -extern char *sys_errlist[]; +#include "supcdefs.h" +#include "supextern.h" + +#if !defined(__NetBSD__) && !defined(__OpenBSD__) +static char *itoa __P((char *, unsigned)); static char *itoa(p,n) char *p; @@ -46,10 +48,15 @@ unsigned n; *p++ = (n%10)+'0'; return(p); } +#endif char *errmsg(cod) int cod; { +#if !defined(__NetBSD__) && !defined(__OpenBSD__) + extern int errno; + extern int sys_nerr; + extern char *sys_errlist[]; static char unkmsg[] = "Unknown error "; static char unk[sizeof(unkmsg)+11]; /* trust us */ @@ -62,4 +69,7 @@ int cod; *itoa(&unk[sizeof(unkmsg)-1],cod) = '\0'; return(unk); +#else + return strerror(cod); +#endif } diff --git a/usr.bin/sup/src/expand.c b/usr.bin/sup/src/expand.c index a379567c395..0317ac86bd3 100644 --- a/usr.bin/sup/src/expand.c +++ b/usr.bin/sup/src/expand.c @@ -1,4 +1,4 @@ -/* $OpenBSD: expand.c,v 1.3 1997/01/17 07:13:20 millert Exp $ */ +/* $OpenBSD: expand.c,v 1.4 1997/04/01 07:35:01 todd Exp $ */ /* * Copyright (c) 1991 Carnegie Mellon University @@ -72,6 +72,8 @@ #include <ctype.h> #include <libc.h> #include <setjmp.h> +#include <stdlib.h> +#include <unistd.h> static jmp_buf sjbuf; @@ -85,14 +87,25 @@ static char **BUFFER; /* pointer to the buffer */ static int BUFSIZE; /* maximum number in buffer */ static int bufcnt; /* current number in buffer */ -static void glob(); -static void matchdir(); -static int execbrc(); -static int match(); -static int amatch(); -static void addone(); -static int addpath(); -static int gethdir(); +#define fixit(a) (a[0] ? a : ".") + +#ifndef __P +#ifdef __STDC__ +#define __P(a) a +#else +#define __P(a) () +#endif +#endif + +int expand __P((char *, char **, int)); +static void glob __P((char *)); +static void matchdir __P((char *)); +static int execbrc __P((char *, char *)); +static int match __P((char *, char *)); +static int amatch __P((char *, char *)); +static void addone __P((char *, char *)); +static int addpath __P((int)); +static int gethdir __P((char *)); int expand(spec, buffer, bufsize) register char *spec; @@ -136,7 +149,7 @@ static void glob(as) } while (*cs == 0 || strchr(globchars, *cs) == 0) { if (*cs == 0) { - if (lstat(path, &stb) >= 0) addone(path, ""); + if (lstat(fixit(path), &stb) >= 0) addone(path, ""); goto endit; } if (addpath(*cs++)) goto endit; @@ -152,7 +165,7 @@ static void glob(as) return; } /* this should not be an lstat */ - if (stat(path, &stb) >= 0 && (stb.st_mode&S_IFMT) == S_IFDIR) + if (stat(fixit(path), &stb) >= 0 && (stb.st_mode&S_IFMT) == S_IFDIR) matchdir(cs); endit: pathp = spathp; @@ -170,11 +183,11 @@ static void matchdir(pattern) #endif DIR *dirp; - dirp = opendir(path); + dirp = opendir(fixit(path)); if (dirp == NULL) return; while ((dp = readdir(dirp)) != NULL) { -#ifdef HAS_POSIX_DIR +#if defined(HAS_POSIX_DIR) && !defined(__SVR4) if (dp->d_fileno == 0) continue; #else if (dp->d_ino == 0) continue; @@ -282,7 +295,7 @@ static int amatch(s, p) case '[': ok = 0; lc = 077777; - while (cc = *p++) { + while ((cc = *p++) != 0) { if (cc == ']') { if (ok) break; return (0); @@ -322,7 +335,7 @@ slash: while (*s) if (addpath(*s++)) goto pathovfl; if (addpath('/')) goto pathovfl; - if (stat(path, &stb) >= 0 && + if (stat(fixit(path), &stb) >= 0 && (stb.st_mode&S_IFMT) == S_IFDIR) if (*p == 0) addone(path, ""); @@ -352,7 +365,8 @@ static void addone(s1, s2) } BUFFER[bufcnt++] = ep; while (*s1) *ep++ = *s1++; - while (*ep++ = *s2++); + while ((*ep++ = *s2++) != '\0') + continue; } static int addpath(c) @@ -368,7 +382,6 @@ static int addpath(c) static int gethdir(home) char *home; { - struct passwd *getpwnam(); register struct passwd *pp = getpwnam(home); if (pp == 0) diff --git a/usr.bin/sup/src/ffilecopy.c b/usr.bin/sup/src/ffilecopy.c index 1546b3da204..b135f524a36 100644 --- a/usr.bin/sup/src/ffilecopy.c +++ b/usr.bin/sup/src/ffilecopy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ffilecopy.c,v 1.4 1996/12/04 08:21:00 niklas Exp $ */ +/* $OpenBSD: ffilecopy.c,v 1.5 1997/04/01 07:35:03 todd Exp $ */ /* * Copyright (c) 1991 Carnegie Mellon University @@ -47,7 +47,8 @@ */ #include <stdio.h> -int filecopy(); +#include "supcdefs.h" +#include "supextern.h" int ffilecopy (here,there) FILE *here, *there; diff --git a/usr.bin/sup/src/filecopy.c b/usr.bin/sup/src/filecopy.c index 081fa84b6b6..cbbdb91e729 100644 --- a/usr.bin/sup/src/filecopy.c +++ b/usr.bin/sup/src/filecopy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: filecopy.c,v 1.2 1996/06/26 05:39:41 deraadt Exp $ */ +/* $OpenBSD: filecopy.c,v 1.3 1997/04/01 07:35:05 todd Exp $ */ /* * Copyright (c) 1991 Carnegie Mellon University @@ -54,6 +54,8 @@ */ #define BUFFERSIZE 10240 +#include "supcdefs.h" +#include "supextern.h" int filecopy (here,there) int here,there; diff --git a/usr.bin/sup/src/libc.h b/usr.bin/sup/src/libc.h index 4486cb090d2..6b94ed8b318 100644 --- a/usr.bin/sup/src/libc.h +++ b/usr.bin/sup/src/libc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: libc.h,v 1.2 1996/06/26 05:39:41 deraadt Exp $ */ +/* $OpenBSD: libc.h,v 1.3 1997/04/01 07:35:06 todd Exp $ */ /* * Copyright (c) 1991 Carnegie Mellon University @@ -27,43 +27,6 @@ /* ********************************************************************** * HISTORY - * $Log: libc.h,v $ - * Revision 1.2 1996/06/26 05:39:41 deraadt - * rcsid - * - * Revision 1.1 1995/12/16 11:46:46 deraadt - * add sup to the tree - * - * Revision 1.1.1.1 1993/05/21 14:52:17 cgd - * initial import of CMU's SUP to NetBSD - * - * Revision 1.7 89/04/03 11:10:45 vanryzin - * Changed definition of qsort for c++ to indicate the procedure - * passed to qsort has parameters. Since we were unsure if ANSI C - * could handle the syntax I placed the new definition within #if - * defined(c_plusplus) conditionals. This may not be necessary - * and perhaps should be fixed at a later time. - * [89/04/03 vanryzin] - * - * Revision 1.6 89/02/05 15:55:57 gm0w - * Added extern char *errmsg(). - * [89/02/04 gm0w] - * - * Revision 1.5 89/01/20 15:34:40 gm0w - * Moved all of the STDC changes to other existing include files - * back into this one. Added non-STDC extern declarations for - * all functions without int return values to match those defined - * by STDC. Added include of sysent.h. Removed obsolete cdate - * extern declaration. - * [88/12/17 gm0w] - * - * Revision 1.4 88/12/22 16:58:56 mja - * Correct __STDC__ parameter type for getenv(). - * [88/12/20 dld] - * - * Revision 1.3 88/12/14 23:31:42 mja - * Made file reentrant. Added declarations for __STDC__. - * [88/01/06 jjk] * * 30-Apr-88 Glenn Marcy (gm0w) at Carnegie-Mellon University * Added pathof() extern. @@ -123,9 +86,6 @@ extern FILE *fwantwrite(); extern char* foldup(char*, const char*); extern char* folddown(char*, const char*); extern char* sindex(const char*, const char*); -extern char* skipto(const char*, const char*); -extern char* skipover(const char*, const char*); -extern char* nxtarg(char**, const char*); extern char _argbreak; extern char* getstr(const char*, char*, char*); extern int getstab(const char*, const char**, const char*); @@ -156,9 +116,7 @@ extern unsigned int gethex(const char*, unsigned int, unsigned int, unsigned int); extern unsigned int hexarg(const char**, const char*, const char*, unsigned int, unsigned int, unsigned int); -extern unsigned int atoo(const char*); extern unsigned int atoh(const char*); -extern char *salloc(const char*); extern char *concat(const char*, int, ...); #else /* __STDC__ */ extern char *foldup(), *folddown(); @@ -196,7 +154,9 @@ extern long atot(); /* 4.3 BSD standard library routines; taken from man(3) */ #if defined(__STDC__) +#if 0 typedef int (*PFI)(); +#endif #if defined(c_plusplus) typedef int (*PFI2)(...); #endif /* c_plusplus */ diff --git a/usr.bin/sup/src/log.c b/usr.bin/sup/src/log.c index e5fc0541bd0..c09d498ed89 100644 --- a/usr.bin/sup/src/log.c +++ b/usr.bin/sup/src/log.c @@ -1,4 +1,4 @@ -/* $OpenBSD: log.c,v 1.2 1996/06/26 05:39:42 deraadt Exp $ */ +/* $OpenBSD: log.c,v 1.3 1997/04/01 07:35:08 todd Exp $ */ /* * Copyright (c) 1992 Carnegie Mellon University @@ -28,24 +28,6 @@ * Logging support for SUP ********************************************************************** * HISTORY - * $Log: log.c,v $ - * Revision 1.2 1996/06/26 05:39:42 deraadt - * rcsid - * - * Revision 1.1 1995/12/16 11:46:47 deraadt - * add sup to the tree - * - * Revision 1.1.1.1 1993/05/21 14:52:17 cgd - * initial import of CMU's SUP to NetBSD - * - * Revision 1.5 92/08/11 12:03:43 mrt - * Brad's delinting and variable argument list usage - * changes. Added copyright. - * - * Revision 1.3 89/08/15 15:30:37 bww - * Updated to use v*printf() in place of _doprnt(). - * From "[89/04/19 mja]" at CMU. - * [89/08/15 bww] * * 27-Dec-87 Glenn Marcy (gm0w) at Carnegie-Mellon University * Added check to allow logopen() to be called multiple times. @@ -59,20 +41,12 @@ #include <stdio.h> #include <sys/syslog.h> #include <c.h> -#if __STDC__ -#include <stdarg.h> -#else -#include <varargs.h> -#endif -#include "sup.h" - -#ifdef lint -/*VARARGS1*//*ARGSUSED*/ -static void quit(status) {}; -#endif /* lint */ +#include "supcdefs.h" +#include "supextern.h" static int opened = 0; +void logopen(program) char *program; { @@ -81,7 +55,8 @@ char *program; opened++; } -#if __STDC__ +void +#ifdef __STDC__ logquit(int retval,char *fmt,...) #else /*VARARGS*//*ARGSUSED*/ @@ -89,16 +64,15 @@ logquit(va_alist) va_dcl #endif { -#if !__STDC__ - int retval; - char *fmt; -#endif char buf[STRINGLENGTH]; va_list ap; -#if __STDC__ +#ifdef __STDC__ va_start(ap,fmt); #else + int retval; + char *fmt; + va_start(ap); retval = va_arg(ap,int); fmt = va_arg(ap,char *); @@ -110,10 +84,11 @@ va_dcl closelog (); exit (retval); } - quit (retval,"SUP: %s\n",buf); + quit (retval,"SUP: %s\n", buf); } -#if __STDC__ +void +#ifdef __STDC__ logerr(char *fmt,...) #else /*VARARGS*//*ARGSUSED*/ @@ -121,15 +96,14 @@ logerr(va_alist) va_dcl #endif { -#if !__STDC__ - char *fmt; -#endif char buf[STRINGLENGTH]; va_list ap; -#if __STDC__ +#ifdef __STDC__ va_start(ap,fmt); #else + char *fmt; + va_start(ap); fmt = va_arg(ap,char *); #endif @@ -143,7 +117,8 @@ va_dcl (void) fflush (stderr); } -#if __STDC__ +void +#ifdef __STDC__ loginfo(char *fmt,...) #else /*VARARGS*//*ARGSUSED*/ @@ -151,15 +126,14 @@ loginfo(va_alist) va_dcl #endif { -#if !__STDC__ - char *fmt; -#endif char buf[STRINGLENGTH]; va_list ap; -#if __STDC__ +#ifdef __STDC__ va_start(ap,fmt); #else + char *fmt; + va_start(ap); fmt = va_arg(ap,char *); #endif diff --git a/usr.bin/sup/src/netcryptvoid.c b/usr.bin/sup/src/netcryptvoid.c index 00ce0482aa0..4d1786e24a4 100644 --- a/usr.bin/sup/src/netcryptvoid.c +++ b/usr.bin/sup/src/netcryptvoid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: netcryptvoid.c,v 1.2 1996/06/26 05:39:43 deraadt Exp $ */ +/* $OpenBSD: netcryptvoid.c,v 1.3 1997/04/01 07:35:10 todd Exp $ */ /* * Copyright (c) 1992 Carnegie Mellon University @@ -26,19 +26,6 @@ */ /********************************************************************** * HISTORY - * $Log: netcryptvoid.c,v $ - * Revision 1.2 1996/06/26 05:39:43 deraadt - * rcsid - * - * Revision 1.1 1995/12/16 11:46:47 deraadt - * add sup to the tree - * - * Revision 1.1.1.1 1993/05/21 14:52:17 cgd - * initial import of CMU's SUP to NetBSD - * - * Revision 2.2 92/09/09 22:04:34 mrt - * Created. - * [92/09/09 mrt] * */ /* @@ -55,7 +42,8 @@ */ #include <libc.h> -#include "sup.h" +#include "supcdefs.h" +#include "supextern.h" #include "supmsg.h" /********************************************* diff --git a/usr.bin/sup/src/nxtarg.c b/usr.bin/sup/src/nxtarg.c index 2999be38614..147cdf7e1fb 100644 --- a/usr.bin/sup/src/nxtarg.c +++ b/usr.bin/sup/src/nxtarg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nxtarg.c,v 1.2 1996/06/26 05:39:44 deraadt Exp $ */ +/* $OpenBSD: nxtarg.c,v 1.3 1997/04/01 07:35:12 todd Exp $ */ /* * Copyright (c) 1991 Carnegie Mellon University @@ -54,9 +54,10 @@ * * Originally from klg (Ken Greer); IUS/SUS UNIX. */ +#include "supcdefs.h" +#include "supextern.h" char _argbreak; -char *skipto(); char *nxtarg (q,brk) char **q,*brk; @@ -67,7 +68,7 @@ char **q,*brk; while (*front && (*front == ' ' || *front == '\t')) front++; /* find break character at end */ if (brk == 0) brk = " "; - back = skipto (front,brk); + back = skipto ((unsigned char *) front,(unsigned char *) brk); _argbreak = *back; *q = (*back ? back+1 : back); /* next arg start loc */ /* elim trailing blanks and tabs */ diff --git a/usr.bin/sup/src/path.c b/usr.bin/sup/src/path.c index fd2d21a7699..8becc2e50fa 100644 --- a/usr.bin/sup/src/path.c +++ b/usr.bin/sup/src/path.c @@ -1,4 +1,4 @@ -/* $OpenBSD: path.c,v 1.2 1996/06/26 05:39:44 deraadt Exp $ */ +/* $OpenBSD: path.c,v 1.3 1997/04/01 07:35:13 todd Exp $ */ /* * Copyright (c) 1991 Carnegie Mellon University @@ -58,7 +58,10 @@ * If you want to be cute, you can also resolve ".."s at that time. * */ +#include "supcdefs.h" +#include "supextern.h" +void path (original,direc,file) char *original,*direc,*file; { @@ -69,7 +72,7 @@ char *original,*direc,*file; /* copy and note the end */ p = original; y = direc; - while (*y++ = *p++) ; /* copy string */ + while ((*y++ = *p++) != '\0') ; /* copy string */ /* y now points to first char after null */ --y; /* y now points to null */ --y; /* y now points to last char of string before null */ diff --git a/usr.bin/sup/src/quit.c b/usr.bin/sup/src/quit.c index d1089ec00cc..7d8bcf827dd 100644 --- a/usr.bin/sup/src/quit.c +++ b/usr.bin/sup/src/quit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: quit.c,v 1.2 1996/06/26 05:39:45 deraadt Exp $ */ +/* $OpenBSD: quit.c,v 1.3 1997/04/01 07:35:15 todd Exp $ */ /* * Copyright (c) 1991 Carnegie Mellon University @@ -37,35 +37,35 @@ * ********************************************************************** * HISTORY - * $Log: quit.c,v $ - * Revision 1.2 1996/06/26 05:39:45 deraadt - * rcsid - * - * Revision 1.1 1995/12/16 11:46:49 deraadt - * add sup to the tree - * - * Revision 1.1.1.1 1993/05/21 14:52:17 cgd - * initial import of CMU's SUP to NetBSD - * - * Revision 1.2 88/12/13 13:52:41 gm0w - * Rewritten to use varargs. - * [88/12/13 gm0w] * ********************************************************************** */ #include <stdio.h> -#include <varargs.h> +#include "supcdefs.h" +#include "supextern.h" -quit (status, fmt, va_alist) -int status; -char *fmt; +void +#ifdef __STDC__ +quit (int status, char * fmt, ...) +#else +quit (va_alist) va_dcl +#endif { va_list args; +#ifdef __STDC__ + va_start(args, fmt); +#else + int status; + char *fmt; - fflush(stdout); va_start(args); + status = va_arg(args, int); + fmt = va_arg(args, char *); +#endif + + fflush(stdout); (void) vfprintf(stderr, fmt, args); va_end(args); exit(status); diff --git a/usr.bin/sup/src/run.c b/usr.bin/sup/src/run.c index 995ebf5f158..c243a05dd2e 100644 --- a/usr.bin/sup/src/run.c +++ b/usr.bin/sup/src/run.c @@ -1,4 +1,4 @@ -/* $OpenBSD: run.c,v 1.3 1996/12/22 03:26:04 tholo Exp $ */ +/* $OpenBSD: run.c,v 1.4 1997/04/01 07:35:16 todd Exp $ */ /* * Copyright (c) 1991 Carnegie Mellon University @@ -49,30 +49,6 @@ * ********************************************************************** * HISTORY - * $Log: run.c,v $ - * Revision 1.3 1996/12/22 03:26:04 tholo - * Deal with _POSIX_SAVED_IDS when relinquishing privileges - * - * Revision 1.2 1996/06/26 05:39:45 deraadt - * rcsid - * - * Revision 1.1 1995/12/16 11:46:49 deraadt - * add sup to the tree - * - * Revision 1.2 1995/06/24 16:21:33 christos - * - Don't use system(3) to fork processes. It is a big security hole. - * - Encode the filenames in the scan files using strvis(3), so filenames - * that contain newlines or other weird characters don't break the scanner. - * - * Revision 1.1.1.1 1993/05/21 14:52:17 cgd - * initial import of CMU's SUP to NetBSD - * - * Revision 1.1 89/10/14 19:53:39 rvb - * Initial revision - * - * Revision 1.2 89/08/03 14:36:46 mja - * Update run() and runp() to use <varargs.h>. - * [89/04/19 mja] * * 23-Sep-86 Glenn Marcy (gm0w) at Carnegie-Mellon University * Merged old runv and runvp modules. @@ -109,7 +85,9 @@ #include <signal.h> #include <fcntl.h> #include <sys/wait.h> -#include <varargs.h> + +#include "supcdefs.h" +#include "supextern.h" #ifndef __STDC__ #ifndef const @@ -117,17 +95,30 @@ #endif #endif -static int dorun(); +static int dorun __P((char *, char **, int)); -int run (name,va_alist) -char *name; +int +#ifdef __STDC__ +run(char *name, ...) +#else +run(va_alist) va_dcl +#endif { int val; va_list ap; + char **argv; +#ifdef __STDC__ + va_start(ap, name); +#else + char *name; va_start(ap); - val = runv (name,ap); + name = va_arg(ap, char *); +#endif + + argv = va_arg(ap, char **); + val = runv (name, argv); va_end(ap); return(val); } @@ -138,15 +129,28 @@ char *name,**argv; return (dorun (name, argv, 0)); } -int runp (name,va_alist) -char *name; +int +#ifdef __STDC__ +runp(char *name, ...) +#else +runp (va_alist) va_dcl +#endif { int val; va_list ap; + char **argv; +#ifdef __STDC__ + va_start(ap, name); +#else + char *name; va_start(ap); - val = runvp (name,ap); + name = va_arg(ap, char *); +#endif + + argv = va_arg(ap, char **); + val = runvp (name, argv); va_end(ap); return (val); } @@ -164,10 +168,8 @@ int usepath; { int wpid; register int pid; - struct sigvec ignoresig,intsig,quitsig; - union wait status; - int execvp(), execv(); - int (*execrtn)() = usepath ? execvp : execv; + struct sigaction ignoresig,intsig,quitsig; + int status; if ((pid = vfork()) == -1) return(-1); /* no more process's, so exit with error */ @@ -177,30 +179,33 @@ int usepath; setgid (getgid()); seteuid (getuid()); setuid (getuid()); - (*execrtn) (name,argv); + if (usepath) + execvp(name,argv); + else + execv(name,argv); fprintf (stderr,"run: can't exec %s\n",name); _exit (0377); } - ignoresig.sv_handler = SIG_IGN; /* ignore INT and QUIT signals */ - ignoresig.sv_mask = 0; - ignoresig.sv_onstack = 0; - sigvec (SIGINT,&ignoresig,&intsig); - sigvec (SIGQUIT,&ignoresig,&quitsig); + ignoresig.sa_handler = SIG_IGN; /* ignore INT and QUIT signals */ + sigemptyset(&ignoresig.sa_mask); + ignoresig.sa_flags = 0; + sigaction (SIGINT,&ignoresig,&intsig); + sigaction (SIGQUIT,&ignoresig,&quitsig); do { - wpid = wait3 (&status.w_status, WUNTRACED, 0); + wpid = wait3 (&status, WUNTRACED, 0); if (WIFSTOPPED (status)) { kill (0,SIGTSTP); wpid = 0; } } while (wpid != pid && wpid != -1); - sigvec (SIGINT,&intsig,0); /* restore signals */ - sigvec (SIGQUIT,&quitsig,0); + sigaction (SIGINT,&intsig,0); /* restore signals */ + sigaction (SIGQUIT,&quitsig,0); - if (WIFSIGNALED (status) || status.w_retcode == 0377) + if (WIFSIGNALED (status) || WEXITSTATUS(status) == 0377) return (-1); - return (status.w_retcode); + return (WEXITSTATUS(status)); } /* diff --git a/usr.bin/sup/src/salloc.c b/usr.bin/sup/src/salloc.c index 9e7d88e9cc5..0fa988545ea 100644 --- a/usr.bin/sup/src/salloc.c +++ b/usr.bin/sup/src/salloc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: salloc.c,v 1.2 1996/06/26 05:39:46 deraadt Exp $ */ +/* $OpenBSD: salloc.c,v 1.3 1997/04/01 07:35:18 todd Exp $ */ /* * Copyright (c) 1991 Carnegie Mellon University @@ -35,7 +35,9 @@ * ********************************************************************** */ -char *malloc(); +#include "supcdefs.h" +#include "supextern.h" + char *salloc(p) char *p; diff --git a/usr.bin/sup/src/scan.c b/usr.bin/sup/src/scan.c index 0df6de17d7c..6e64bd47c26 100644 --- a/usr.bin/sup/src/scan.c +++ b/usr.bin/sup/src/scan.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scan.c,v 1.5 1997/01/17 07:18:04 millert Exp $ */ +/* $OpenBSD: scan.c,v 1.6 1997/04/01 07:35:20 todd Exp $ */ /* * Copyright (c) 1992 Carnegie Mellon University @@ -29,41 +29,6 @@ * ********************************************************************** * HISTORY - * $Log: scan.c,v $ - * Revision 1.5 1997/01/17 07:18:04 millert - * more r?index -> strr?chr - * - * Revision 1.4 1996/07/31 11:11:24 niklas - * Better use time_t instead of long when dealing with times - * - * Revision 1.3 1996/06/26 05:39:46 deraadt - * rcsid - * - * Revision 1.2 1996/04/17 17:24:13 dm - * Shouldn't visually encode execute commands, only file names. - * - * Revision 1.1 1995/12/16 11:46:50 deraadt - * add sup to the tree - * - * Revision 1.4 1995/10/29 23:54:45 christos - * - runio fails when result != 0 not only < 0 - * - print vis-encoded file in the scanner. - * - * Revision 1.3 1995/06/24 16:21:42 christos - * - Don't use system(3) to fork processes. It is a big security hole. - * - Encode the filenames in the scan files using strvis(3), so filenames - * that contain newlines or other weird characters don't break the scanner. - * - * Revision 1.2 1994/01/03 14:47:25 brezak - * Change <sys/dir.h> to <dirent.h> - * - * Revision 1.1.1.1 1993/05/21 14:52:17 cgd - * initial import of CMU's SUP to NetBSD - * - * Revision 1.8 92/08/11 12:04:28 mrt - * Brad's changes: delinted, added forward declarations of static - * functions.Added Copyright. - * [92/07/24 mrt] * * 18-Mar-88 Glenn Marcy (gm0w) at Carnegie-Mellon University * Added host=<hostfile> support to releases file. @@ -127,7 +92,9 @@ #include <sys/dir.h> #endif #include <sys/file.h> -#include "sup.h" +#include <unistd.h> +#include "supcdefs.h" +#include "supextern.h" /************************* *** M A C R O S *** @@ -205,29 +172,32 @@ extern int candorcs; /************************************************* *** STATIC R O U T I N E S *** *************************************************/ +static void passdelim __P((char **, int )); +static char *parserelease __P((TREELIST **, char *, char *)); +static int scanone __P((TREE *, void *)); +static void makescan __P((char *, char *)); +static void getscan __P((char *, char *)); +static void doscan __P((char *)); +static void readlistfile __P((char *)); +static void expTinsert __P((char *, TREE **, int, char *)); +static int listone __P((TREE *, void *)); +static void listentry __P((char *, char *, char *, int)); +static void listname __P((char *, struct stat *)); +static void listdir __P((char *, int)); +static int omitanyone __P((TREE *, void *)); +static int anyglob __P((char *, char *)); +static int getscanfile __P((char *)); +static void chkscanfile __P((char *)); +static void makescanfile __P((char *)); +static int recordone __P((TREE *, void *)); +static int recordexec __P((TREE *, void *)); -static makescan(); -static getscan(); -static doscan(); -static readlistfile(); -static expTinsert(); -static listone(); -static listentry(); -static listname(); -static listdir(); -static omitanyone(); -static anyglob(); -static int getscanfile(); -static chkscanfile(); -static makescanfile(); -static recordone(); -static recordexec(); /************************************************* *** L I S T S C A N R O U T I N E S *** *************************************************/ -static +static void passdelim (ptr,delim) /* skip over delimiter */ char **ptr,delim; { @@ -299,6 +269,7 @@ char *relname,*args; return (nextrel); } +int getrelease (release) char *release; { @@ -357,6 +328,7 @@ char *release; return (TRUE); } +void makescanlists () { TREELIST *tl; @@ -369,7 +341,7 @@ makescanlists () (void) sprintf (buf,FILERELEASES,collname); f = fopen (buf,"r"); if (f != NULL) { - while (p = fgets (buf,sizeof(buf),f)) { + while ((p = fgets (buf,sizeof(buf),f)) != NULL) { q = strchr (p,'\n'); if (q) *q = 0; if (strchr ("#;:",*p)) continue; @@ -392,9 +364,10 @@ makescanlists () makescan ((char *)NULL,(char *)NULL); } -static -scanone (t) +static int +scanone (t, v) register TREE *t; +void *v; { register TREE *newt; @@ -409,6 +382,7 @@ register TREE *t; return (SCMOK); } +void getscanlists () { TREELIST *tl,*stl; @@ -425,10 +399,10 @@ getscanlists () } listT = NULL; for (tl = listTL; tl != NULL; tl = tl->TLnext) - (void) Tprocess (tl->TLtree,scanone); + (void) Tprocess (tl->TLtree, scanone, NULL); } -static +static void makescan (listfile,scanfile) char *listfile,*scanfile; { @@ -439,12 +413,10 @@ char *listfile,*scanfile; Tfree (&listT); /* free file list tree */ } -static +static void getscan (listfile,scanfile) char *listfile,*scanfile; { - struct tm *utc_time; - listT = NULL; if (!getscanfile(scanfile)) { /* check for pre-scanned file list */ scantime = time ((time_t *)NULL); @@ -452,12 +424,11 @@ char *listfile,*scanfile; } } -static +static void doscan (listfile) char *listfile; { char buf[STRINGLENGTH]; - int listone (); upgT = NULL; flagsT = NULL; @@ -470,7 +441,7 @@ doscan (listfile) listfile = FILELISTDEF; (void) sprintf (buf,FILELIST,collname,listfile); readlistfile (buf); /* get contents of list file */ - (void) Tprocess (upgT,listone); /* build list of files specified */ + (void) Tprocess (upgT,listone, NULL); /* build list of files specified */ cdprefix ((char *)NULL); Tfree (&upgT); Tfree (&flagsT); @@ -481,7 +452,7 @@ doscan (listfile) Tfree (&rsymT); } -static +static void readlistfile (fname) char *fname; { @@ -489,15 +460,15 @@ char *fname; register char *q,*r; register FILE *f; register int ltn,n,i,flags; - register TREE **t; + register TREE **t = NULL; register LISTTYPE lt; char *speclist[SPECNUMBER]; f = fopen (fname,"r"); if (f == NULL) goaway ("Can't read list file %s",fname); cdprefix (prefix); - while (p = fgets (buf,sizeof(buf),f)) { - if (q = strchr (p,'\n')) *q = '\0'; + while ((p = fgets (buf,sizeof(buf),f)) != NULL) { + if ((q = strchr (p,'\n')) != NULL) *q = '\0'; if (strchr ("#;:",*p)) continue; q = nxtarg (&p," \t"); if (*q == '\0') continue; @@ -577,7 +548,7 @@ char *fname; (void) fclose (f); } -static +static void expTinsert (p,t,flags,exec) char *p; TREE **t; @@ -601,22 +572,22 @@ char *exec; } } -static -listone (t) /* expand and add one name from upgrade list */ +static int +listone (t, v) /* expand and add one name from upgrade list */ TREE *t; +void *v; { listentry(t->Tname,t->Tname,(char *)NULL,(t->Tflags&FALWAYS) != 0); return (SCMOK); } -static +static void listentry(name,fullname,updir,always) register char *name, *fullname, *updir; int always; { struct stat statbuf; int link = 0; - int omitanyone (); if (Tlookup (refuseT,fullname)) return; if (!always) { @@ -679,7 +650,7 @@ int always; listname (fullname,&statbuf); } -static +static void listname (name,st) register char *name; register struct stat *st; @@ -691,7 +662,7 @@ register struct stat *st; new = st->st_ctime > lasttime; if (newonly && !new) { for (tl = listTL; tl != NULL; tl = tl->TLnext) - if (ts = Tsearch (tl->TLtree,name)) + if ((ts = Tsearch (tl->TLtree,name)) != NULL) ts->Tflags &= ~FNEW; return; } @@ -701,15 +672,15 @@ 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)) != NULL) t->Tflags |= ts->Tflags; - if (ts = Tsearch (execT,name)) { + if ((ts = Tsearch (execT,name)) != NULL) { t->Texec = ts->Texec; ts->Texec = NULL; } } -static +static void listdir (name,always) /* expand directory */ char *name; int always; @@ -733,13 +704,13 @@ int always; p += 2; while (*p == '/') p++; } - while (*newp++ = *p++) ; /* copy string */ + while ((*newp++ = *p++) != '\0') ; /* copy string */ --newp; /* trailing null */ while (newp > newname && newp[-1] == '/') --newp; /* trailing / */ *newp = 0; if (strcmp (newname,".") == 0) newname[0] = 0; /* "." ==> "" */ - while (dentry=readdir(dirp)) { + while ((dentry=readdir(dirp)) != NULL) { if (dentry->d_ino == 0) continue; if (strcmp(dentry->d_name,".") == 0) continue; if (strcmp(dentry->d_name,"..") == 0) continue; @@ -755,17 +726,18 @@ int always; closedir (dirp); } -static -omitanyone (t,filename) +static int +omitanyone (t,fv) TREE *t; -char **filename; +void *fv; { - if (anyglob (t->Tname,*filename)) + char *filename = fv; + if (anyglob (t->Tname,filename)) return (SCMERR); return (SCMOK); } -static +static int anyglob (pattern,match) char *pattern,*match; { @@ -857,7 +829,7 @@ char *scanfile; (void) fclose (f); return (FALSE); } - if (q = strchr (p,'\n')) *q = '\0'; + if ((q = strchr (p,'\n')) != NULL) *q = '\0'; if (*p++ != 'V') { (void) fclose (f); return (FALSE); @@ -873,7 +845,7 @@ char *scanfile; return (TRUE); } notwanted = FALSE; - while (p = fgets (buf,sizeof(buf),f)) { + while ((p = fgets (buf,sizeof(buf),f)) != NULL) { q = strchr (p,'\n'); if (q) *q = 0; ts.Tflags = 0; @@ -912,7 +884,7 @@ char *scanfile; ts.Tflags |= FNEW; else if (newonly) { for (tl = listTL; tl != NULL; tl = tl->TLnext) - if (tmp = Tsearch (tl->TLtree,fname)) + if ((tmp = Tsearch (tl->TLtree,fname)) != NULL) tmp->Tflags &= ~FNEW; notwanted = TRUE; continue; @@ -935,7 +907,7 @@ char *scanfile; *** W R I T E S C A N F I L E *** *******************************************/ -static chkscanfile (scanfile) +static void chkscanfile (scanfile) char *scanfile; { char tname[STRINGLENGTH], fname[STRINGLENGTH]; @@ -953,13 +925,12 @@ char *scanfile; } } -static makescanfile (scanfile) +static void makescanfile (scanfile) char *scanfile; { char tname[STRINGLENGTH],fname[STRINGLENGTH]; struct timeval tbuf[2]; FILE *scanF; /* output file for scanned file list */ - int recordone (); if (scanfile == NULL) scanfile = FILESCANDEF; @@ -979,34 +950,36 @@ char *scanfile; (void) utimes (fname,tbuf); } -static -recordone (t,scanF) +static int +recordone (t,v) TREE *t; -FILE **scanF; +void *v; { - int recordexec (); + FILE *scanF = v; char fname[MAXPATHLEN*4+1]; - if (t->Tflags&FBACKUP) fprintf (*scanF,"B"); - if (t->Tflags&FNOACCT) fprintf (*scanF,"N"); + if (t->Tflags&FBACKUP) fprintf (scanF,"B"); + if (t->Tflags&FNOACCT) fprintf (scanF,"N"); strvis(fname, t->Tname, VIS_WHITE); - fprintf (*scanF,"%o %d %d %s\n", + fprintf (scanF,"%o %d %d %s\n", t->Tmode,t->Tctime,t->Tmtime,fname); - (void) Tprocess (t->Texec,recordexec,*scanF); + (void) Tprocess (t->Texec,recordexec, scanF); return (SCMOK); } -static -recordexec (t,scanF) +static int +recordexec (t,v) TREE *t; -FILE **scanF; +void *v; { + FILE *scanF = v; char fname[MAXPATHLEN*4+1]; strcpy(fname, t->Tname); - fprintf(*scanF,"X%s\n",fname); + fprintf(scanF,"X%s\n",fname); return (SCMOK); } +void cdprefix (prefix) char *prefix; { diff --git a/usr.bin/sup/src/scm.c b/usr.bin/sup/src/scm.c index d3a01f83d84..bd108827807 100644 --- a/usr.bin/sup/src/scm.c +++ b/usr.bin/sup/src/scm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scm.c,v 1.3 1996/08/04 12:58:26 deraadt Exp $ */ +/* $OpenBSD: scm.c,v 1.4 1997/04/01 07:35:22 todd Exp $ */ /* * Copyright (c) 1992 Carnegie Mellon University @@ -69,42 +69,6 @@ * 2-Oct-92 Mary Thompson (mrt) at Carnegie-Mellon University * Added conditional declarations of INADDR_NONE and INADDR_LOOPBACK * since Tahoe version of <netinet/in.h> does not define them. - * - * $Log: scm.c,v $ - * Revision 1.3 1996/08/04 12:58:26 deraadt - * ftp bounce protection - * - * Revision 1.2 1996/06/26 05:39:47 deraadt - * rcsid - * - * Revision 1.1 1995/12/16 11:46:51 deraadt - * add sup to the tree - * - * Revision 1.2 1995/06/03 21:21:51 christos - * Changes to write ascii timestamps in the when files. - * Looked into making it 64 bit clean, but it is hopeless. - * Added little program to convert from the old timestamp files - * into the new ones. - * - * Revision 1.1.1.1 1993/05/21 14:52:17 cgd - * initial import of CMU's SUP to NetBSD - * - * Revision 1.13 92/08/11 12:05:35 mrt - * Added changes from stump: - * Allow for multiple interfaces, and for numeric addresses. - * Changed to use builtin port for the "supfiledbg" - * service when getservbyname() cannot find it. - * Added forward static declatations, delinted. - * Updated variable argument usage. - * [92/08/08 mrt] - * - * Revision 1.12 92/02/08 19:01:11 mja - * Add (struct sockaddr *) casts for HC 2.1. - * [92/02/08 18:59:09 mja] - * - * Revision 1.11 89/08/03 19:49:03 mja - * Updated to use v*printf() in place of _doprnt(). - * [89/04/19 mja] * * 11-Feb-88 Glenn Marcy (gm0w) at Carnegie-Mellon University * Moved sleep into computeBackoff, renamed to dobackoff. @@ -188,6 +152,9 @@ #include <sys/time.h> #include <sys/socket.h> #include <sys/ioctl.h> +#ifndef SIOCGIFCONF +#include <sys/sockio.h> +#endif #include <netinet/in.h> #include <arpa/inet.h> #include <net/if.h> @@ -197,7 +164,8 @@ #else #include <varargs.h> #endif -#include "sup.h" +#include "supcdefs.h" +#include "supextern.h" #ifndef INADDR_NONE #define INADDR_NONE 0xffffffff /* -1 return */ @@ -207,9 +175,9 @@ #endif extern int errno; -static char *myhost (); char scmversion[] = "4.3 BSD"; +extern int silent; /************************* *** M A C R O S *** @@ -232,15 +200,15 @@ static struct in_addr remoteaddr; /* remote host address */ static char *remotename = NULL; /* remote host name */ static int swapmode; /* byte-swapping needed on server? */ -#if __STDC__ -int scmerr(int,char *,...); -#endif + +static char *myhost __P((void)); /*************************************************** *** C O N N E C T I O N R O U T I N E S *** *** F O R S E R V E R *** ***************************************************/ +int servicesetup (server) /* listen for clients */ char *server; { @@ -278,6 +246,7 @@ char *server; return (SCMOK); } +int service () { struct sockaddr_in from; @@ -309,6 +278,7 @@ again: return (SCMOK); } +int serviceprep () /* kill temp socket in daemon */ { if (sock >= 0) { @@ -318,6 +288,7 @@ serviceprep () /* kill temp socket in daemon */ return (SCMOK); } +int servicekill () /* kill net file in daemon's parent */ { if (netfile >= 0) { @@ -331,6 +302,7 @@ servicekill () /* kill net file in daemon's parent */ return (SCMOK); } +int serviceend () /* kill net file after use in daemon */ { if (netfile >= 0) { @@ -349,7 +321,7 @@ serviceend () /* kill net file after use in daemon */ *** F O R C L I E N T *** ***************************************************/ -dobackoff (t,b) +int dobackoff (t,b) int *t,*b; { struct timeval tt; @@ -366,11 +338,13 @@ int *t,*b; s = *t; *t -= s; } - (void) scmerr (-1,"Will retry in %d seconds",s); + if (!silent) + (void) scmerr (-1,"Will retry in %d seconds",s); sleep (s); return (1); } +int request (server,hostname,retry) /* connect to server */ char *server; char *hostname; @@ -390,8 +364,9 @@ int *retry; else return (scmerr (-1,"Can't find %s server description", server)); - (void) scmerr (-1,"%s/tcp: unknown service: using port %d", - server,port); + if (!silent) + (void) scmerr (-1,"%s/tcp: unknown service: using port %d", + server,port); } else port = sp->s_port; (void) bzero ((char *)&sin,sizeof(sin)); @@ -426,6 +401,7 @@ int *retry; return (SCMOK); } +int requestend () /* end connection to server */ { (void) readflush (); @@ -546,7 +522,7 @@ char *name; return (0); } -#if __STDC__ +#ifdef __STDC__ int scmerr (int errno,char *fmt,...) #else /*VARARGS*//*ARGSUSED*/ @@ -554,24 +530,24 @@ int scmerr (va_alist) va_dcl #endif { -#if !__STDC__ + va_list ap; +#ifdef __STDC__ + va_start(ap,fmt); +#else int errno; char *fmt; + + va_start(ap); + errno = va_arg(ap,int); + fmt = va_arg(ap,char *); #endif - va_list ap; (void) fflush (stdout); if (progpid > 0) fprintf (stderr,"%s %d: ",program,progpid); else fprintf (stderr,"%s: ",program); -#if __STDC__ - va_start(ap,fmt); -#else - va_start(ap); - errno = va_arg(ap,int); - fmt = va_arg(ap,char *); -#endif + vfprintf(stderr, fmt, ap); va_end(ap); if (errno >= 0) diff --git a/usr.bin/sup/src/scmio.c b/usr.bin/sup/src/scmio.c index 6c4f4f3ff6d..4d02d51a0ee 100644 --- a/usr.bin/sup/src/scmio.c +++ b/usr.bin/sup/src/scmio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scmio.c,v 1.2 1996/06/26 05:39:47 deraadt Exp $ */ +/* $OpenBSD: scmio.c,v 1.3 1997/04/01 07:35:24 todd Exp $ */ /* * Copyright (c) 1992 Carnegie Mellon University @@ -110,27 +110,6 @@ * ********************************************************************** * HISTORY - * $Log: scmio.c,v $ - * Revision 1.2 1996/06/26 05:39:47 deraadt - * rcsid - * - * Revision 1.1 1995/12/16 11:46:52 deraadt - * add sup to the tree - * - * Revision 1.2 1993/05/24 17:57:26 brezak - * Remove netcrypt.c. Remove unneeded files. Cleanup make. - * - * Revision 1.1.1.1 1993/05/21 14:52:17 cgd - * initial import of CMU's SUP to NetBSD - * - * Revision 1.7 92/09/09 22:04:41 mrt - * Removed the data encryption routines from here to netcrypt.c - * [92/09/09 mrt] - * - * Revision 1.6 92/08/11 12:05:57 mrt - * Brad's changes: Delinted,Added forward declarations of - * static functions. Added copyright. - * [92/07/24 mrt] * * 27-Dec-87 Glenn Marcy (gm0w) at Carnegie-Mellon University * Added crosspatch support. @@ -174,7 +153,8 @@ #include <sys/stat.h> #include <sys/file.h> #include <sys/time.h> -#include "sup.h" +#include "supcdefs.h" +#include "supextern.h" #include "supmsg.h" extern int errno; @@ -195,7 +175,6 @@ extern int errno; *** G L O B A L V A R I A B L E S *** *********************************************/ -extern int scmerr (); /* error printing routine */ extern int netfile; /* network file descriptor */ int scmdebug; /* scm debug flag */ @@ -212,12 +191,17 @@ struct buf { } buffers[2]; struct buf *bufptr; /* buffer pointer */ +static int writedata __P((int, char *)); +static int writeblock __P((int, char *)); +static int readdata __P((int, char *)); +static int readcount __P((int *)); + /*********************************************** *** O U T P U T T O N E T W O R K *** ***********************************************/ -static +static int writedata (count,data) /* write raw data to network */ int count; char *data; @@ -264,7 +248,7 @@ char *data; return (SCMOK); } -static +static int writeblock (count,data) /* write data block */ int count; char *data; @@ -277,6 +261,7 @@ char *data; return (x); } +int writemsg (msg) /* write start of message */ int msg; { @@ -293,6 +278,7 @@ int msg; return (writedata(sizeof(int),(char *)&x)); } +int writemend () /* write end of message */ { register int count; @@ -314,6 +300,7 @@ writemend () /* write end of message */ return (writedata (count, data)); } +int writeint (i) /* write int as data block */ int i; { @@ -324,6 +311,7 @@ int i; return (writeblock(sizeof(int),(char *)&x)); } +int writestring (p) /* write string as data block */ char *p; { @@ -347,11 +335,12 @@ char *p; return (writeblock(len,p)); } +int writefile (f) /* write open file as a data block */ int f; { char buf[FILEXFER]; - register int number,sum,filesize,x; + register int number = 0,sum = 0,filesize,x; int y; struct stat statbuf; @@ -386,6 +375,7 @@ int f; return (x); } +int writemnull (msg) /* write message with no data */ int msg; { @@ -395,6 +385,7 @@ int msg; return (x); } +int writemint (msg,i) /* write message of one int */ int msg,i; { @@ -405,6 +396,7 @@ int msg,i; return (x); } +int writemstr (msg,p) /* write message of one string */ int msg; char *p; @@ -420,7 +412,7 @@ char *p; *** I N P U T F R O M N E T W O R K *** *************************************************/ -static +static int readdata (count,data) /* read raw data from network */ int count; char *data; @@ -518,17 +510,19 @@ int *count; int y; x = readdata (sizeof(int),(char *)&y); if (x != SCMOK) return (x); - x = readdata (-sizeof(int),(char *)&y); + x = readdata (- ((int)(sizeof(int))),(char *)&y); if (x != SCMOK) return (x); *count = byteswap(y); return (SCMOK); } +int readflush () { return (readdata (0, (char *)NULL)); } +int readmsg (msg) /* read header for expected message */ int msg; /* if message is unexpected, send back SCMHUH */ { @@ -553,6 +547,7 @@ int msg; /* if message is unexpected, send back SCMHUH */ return (SCMEOF); } +int readmend () { register int x; @@ -564,6 +559,7 @@ readmend () return (x); } +int readskip () /* skip over one input block */ { register int x; @@ -638,6 +634,7 @@ register char **buf; return (SCMOK); } +int readfile (f) /* read data block into open file */ int f; { @@ -668,6 +665,7 @@ int f; return (x); } +int readmnull (msg) /* read null message */ int msg; { @@ -677,6 +675,7 @@ int msg; return (x); } +int readmint (msg,buf) /* read int message */ int msg,*buf; { @@ -702,6 +701,7 @@ char **buf; *** C R O S S P A T C H *** **********************************/ +void crosspatch () { fd_set ibits, obits, xbits; diff --git a/usr.bin/sup/src/skipto.c b/usr.bin/sup/src/skipto.c index 2b071b1c36e..0cabbf7864a 100644 --- a/usr.bin/sup/src/skipto.c +++ b/usr.bin/sup/src/skipto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: skipto.c,v 1.2 1996/06/26 05:39:48 deraadt Exp $ */ +/* $OpenBSD: skipto.c,v 1.3 1997/04/01 07:35:26 todd Exp $ */ /* * Copyright (c) 1991 Carnegie Mellon University @@ -52,11 +52,14 @@ * and partly due to popular usage of this function. */ -static unsigned char tab[256] = { +#include "supcdefs.h" +#include "supextern.h" + +static char tab[256] = { 0}; char *skipto (string,charset) -unsigned char *string, *charset; +char *string, *charset; { register unsigned char *setp,*strp; @@ -68,7 +71,7 @@ unsigned char *string, *charset; } char *skipover (string,charset) -unsigned char *string, *charset; +char *string, *charset; { register unsigned char *setp,*strp; diff --git a/usr.bin/sup/src/stree.c b/usr.bin/sup/src/stree.c index 0e2287d9e79..4a7d7413aca 100644 --- a/usr.bin/sup/src/stree.c +++ b/usr.bin/sup/src/stree.c @@ -1,4 +1,4 @@ -/* $OpenBSD: stree.c,v 1.3 1997/01/17 07:13:21 millert Exp $ */ +/* $OpenBSD: stree.c,v 1.4 1997/04/01 07:35:27 todd Exp $ */ /* * Copyright (c) 1992 Carnegie Mellon University @@ -29,29 +29,6 @@ * ********************************************************************** * HISTORY - * $Log: stree.c,v $ - * Revision 1.3 1997/01/17 07:13:21 millert - * r?index -> strr?chr - * - * Revision 1.2 1996/06/26 05:39:48 deraadt - * rcsid - * - * Revision 1.1 1995/12/16 11:46:53 deraadt - * add sup to the tree - * - * Revision 1.1.1.1 1993/05/21 14:52:17 cgd - * initial import of CMU's SUP to NetBSD - * - * Revision 1.4 92/08/11 12:06:32 mrt - * Added copyright. Delinted - * [92/08/10 mrt] - * - * - * Revision 1.3 89/08/15 15:30:57 bww - * Changed code in Tlookup to Tsearch for each subpart of path. - * Added indent formatting code to Tprint. - * From "[89/06/24 gm0w]" at CMU. - * [89/08/15 bww] * * 20-May-87 Glenn Marcy (gm0w) at Carnegie-Mellon University * Added code to please lint. @@ -68,14 +45,27 @@ #include <libc.h> #include <c.h> #include <sys/param.h> -#include "sup.h" +#include "supcdefs.h" +#include "supextern.h" + +#define Static static /* comment for debugging */ + +Static TREE *Tmake __P((char *)); +Static TREE *Trotll __P((TREE *, TREE *)); +Static TREE *Trotlh __P((TREE *, TREE *)); +Static TREE *Trothl __P((TREE *, TREE *)); +Static TREE *Trothh __P((TREE *, TREE *)); +Static void Tbalance __P((TREE **)); +Static TREE *Tinsertavl __P((TREE **, char *, int, int *)); +Static int Tsubprocess __P((TREE *, int, int (*f )(TREE *, void *), void *)); +Static int Tprintone __P((TREE *, void *)); -#define Static /* static /* comment for debugging */ /************************************************************* *** T R E E P R O C E S S I N G R O U T I N E S *** *************************************************************/ +void Tfree (t) register TREE **t; { @@ -174,7 +164,7 @@ register TREE *tp,*th; return(th); } -Static +Static void Tbalance (t) TREE **t; { @@ -301,8 +291,8 @@ Static int Tsubprocess (t,reverse,f,argp) TREE *t; int reverse; -int (*f)(); -int *argp; +int (*f) __P((TREE *, void *)); +void *argp; { register int x = SCMOK; process_level++; @@ -324,42 +314,44 @@ int *argp; /* VARARGS2 */ int Trprocess (t,f,args) TREE *t; -int (*f)(); -int args; +int (*f) __P((TREE *, void *)); +void *args; { if (t == NULL) return (SCMOK); process_level = 0; - return (Tsubprocess (t,TRUE,f,&args)); + return (Tsubprocess (t,TRUE,f,args)); } /* VARARGS2 */ int Tprocess (t,f,args) TREE *t; -int (*f)(); -int args; +int (*f) __P((TREE *, void *)); +void *args; { if (t == NULL) return (SCMOK); process_level = 0; - return (Tsubprocess (t,FALSE,f,&args)); + return (Tsubprocess (t,FALSE,f,args)); } Static -int Tprintone (t) +int Tprintone (t, v) TREE *t; +void *v; { int i; for (i = 0; i < (process_level*2); i++) (void) putchar(' '); - printf ("Node at %X name '%s' flags %o hi %X lo %X\n",t,t->Tname,t->Tflags,t->Thi,t->Tlo); + printf ("Node at %p name '%s' flags %o hi %p lo %p\n",t,t->Tname,t->Tflags,t->Thi,t->Tlo); return (SCMOK); } +void Tprint (t,p) /* print tree -- for debugging */ TREE *t; char *p; { printf ("%s\n",p); - (void) Tprocess (t,Tprintone); + (void) Tprocess (t,Tprintone, NULL); printf ("End of tree\n"); (void) fflush (stdout); } diff --git a/usr.bin/sup/src/sup.h b/usr.bin/sup/src/sup.h index ecdc27bc6c0..e44d5d39059 100644 --- a/usr.bin/sup/src/sup.h +++ b/usr.bin/sup/src/sup.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sup.h,v 1.2 1996/06/26 05:39:50 deraadt Exp $ */ +/* $OpenBSD: sup.h,v 1.3 1997/04/01 07:35:29 todd Exp $ */ /* * Copyright (c) 1992 Carnegie Mellon University @@ -40,38 +40,6 @@ * Modified SUP to use gzip based compression when sending files * across the network to save BandWidth * - * $Log: sup.h,v $ - * Revision 1.2 1996/06/26 05:39:50 deraadt - * rcsid - * - * Revision 1.1 1995/12/16 11:46:55 deraadt - * add sup to the tree - * - * Revision 1.3 1995/06/03 21:21:54 christos - * Changes to write ascii timestamps in the when files. - * Looked into making it 64 bit clean, but it is hopeless. - * Added little program to convert from the old timestamp files - * into the new ones. - * - * 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 - * Added definition for DEBUGFPORTNUM, the debugging port number. - * Changed so that last and when file names could include - * the relase name if any. - * [92/07/23 mrt] - * - * Revision 1.9 91/04/29 14:39:03 mja - * Reduce MAXCHILDREN from 8 to 3. - * - * Revision 1.8 89/08/23 14:55:30 gm0w - * Moved coll.dir from supservers to supfiles. - * [89/08/23 gm0w] - * * 18-Mar-88 Glenn Marcy (gm0w) at Carnegie-Mellon University * Added host=<hostfile> support to releases file. * @@ -266,8 +234,8 @@ typedef struct tliststruct TREELIST; #define MAXCHILDREN 3 /* maximum number of children allowed to sup at the same time */ -/* scm and stree external declarations */ -char *remotehost(); -TREE *Tinsert(),*Tsearch(),*Tlookup(); -long getwhen(); -int putwhen(); +#ifdef __STDC__ +# include <stdarg.h> +#else +# include <varargs.h> +#endif diff --git a/usr.bin/sup/src/supcdefs.h b/usr.bin/sup/src/supcdefs.h index 7e49c6a0c42..83a95b8b112 100644 --- a/usr.bin/sup/src/supcdefs.h +++ b/usr.bin/sup/src/supcdefs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: supcdefs.h,v 1.3 1996/07/31 11:11:26 niklas Exp $ */ +/* $OpenBSD: supcdefs.h,v 1.4 1997/04/01 07:35:30 todd Exp $ */ /* * Copyright (c) 1992 Carnegie Mellon University @@ -33,31 +33,6 @@ * 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.3 1996/07/31 11:11:26 niklas - * Better use time_t instead of long when dealing with times - * - * Revision 1.2 1996/06/26 05:39:50 deraadt - * rcsid - * - * Revision 1.1 1995/12/16 11:46:55 deraadt - * add sup to the tree - * - * 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 - * Added CFURELSUF - use-release-suffix flag - * Made rpause code conditional on MACH rather than CMUCS - * [92/07/26 mrt] - * - * Revision 1.5 92/02/08 18:23:57 mja - * Added CFKEEP flag. - * [92/01/17 vdelvecc] * * 10-Feb-88 Glenn Marcy (gm0w) at Carnegie-Mellon University * Added timeout for backoff. @@ -77,6 +52,9 @@ #include <setjmp.h> #include <pwd.h> #include <grp.h> +#include <fcntl.h> +#include <stdlib.h> +#include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/time.h> @@ -91,9 +69,6 @@ #include "supmsg.h" extern int errno; -extern uid_t getuid(); -extern gid_t getgid(); - extern int PGMVERSION; /******************************************* @@ -132,6 +107,7 @@ typedef struct collstruct COLLECTION; #define CFKEEP 01000 #define CFURELSUF 02000 #define CFCOMPRESS 04000 +#define CFSILENT 10000 /************************* *** M A C R O S *** diff --git a/usr.bin/sup/src/supcmain.c b/usr.bin/sup/src/supcmain.c index 93f790a2ca8..8a9b9fc9a7e 100644 --- a/usr.bin/sup/src/supcmain.c +++ b/usr.bin/sup/src/supcmain.c @@ -1,4 +1,4 @@ -/* $OpenBSD: supcmain.c,v 1.4 1997/01/17 07:18:06 millert Exp $ */ +/* $OpenBSD: supcmain.c,v 1.5 1997/04/01 07:35:32 todd Exp $ */ /* * Copyright (c) 1992 Carnegie Mellon University @@ -175,45 +175,6 @@ * Modified SUP to use gzip based compression when sending files * across the network to save BandWidth * - * $Log: supcmain.c,v $ - * Revision 1.4 1997/01/17 07:18:06 millert - * more r?index -> strr?chr - * - * Revision 1.3 1996/07/31 11:11:27 niklas - * Better use time_t instead of long when dealing with times - * - * Revision 1.2 1996/06/26 05:39:51 deraadt - * rcsid - * - * Revision 1.1 1995/12/16 11:46:56 deraadt - * add sup to the tree - * - * Revision 1.4 1995/09/16 19:01:25 glass - * if the function returns nothing, declare it void - * - * 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 - * initial import of CMU's SUP to NetBSD - * - * Revision 1.6 92/08/11 12:06:59 mrt - * Merged in Brad's changes. Made resource pausing code conditional - * on MACH, rather than CMUCS. Fixed some calls to sprintf to - * return void. - * [92/08/09 mrt] - * - * Revision 1.5 92/02/08 19:01:18 mja - * Correct oldsigsys type when ANSI C. - * [92/02/08 18:59:47 mja] - * - * Revision 1.4 92/02/08 18:24:01 mja - * Added -k and -K switches. - * [92/01/17 vdelvecc] - * * 27-Dec-87 Glenn Marcy (gm0w) at Carnegie-Mellon University * Added crosspatch support (is currently ignored). * @@ -342,6 +303,7 @@ #define SYS_rpause (-5) #endif #endif +#include "supextern.h" /********************************************* *** G L O B A L V A R I A B L E S *** @@ -355,6 +317,7 @@ COLLECTION *firstC,*thisC; /* collection list pointer */ extern int dontjump; /* disable longjmp */ extern int scmdebug; /* SCM debugging flag */ +int silent; /* Silent run, print only errors */ int sysflag; /* system upgrade flag */ int timeflag; /* print times flag */ #if MACH @@ -363,19 +326,24 @@ int rpauseflag; /* don't disable resource pausing */ int xpatchflag; /* crosspatched with remote system */ int portdebug; /* network debugging ports */ +int main __P((int, char **)); +static int checkcoll __P((TREE *, void *)); +static void doswitch __P((char *, TREE **, int *, int *)); +static char *init __P((int, char **)); + /************************************* *** M A I N R O U T I N E *** *************************************/ -main (argc,argv) +int +main (argc, argv) int argc; char **argv; { - char *init (); char *progname,*supfname; - int restart,sfdev,sfino,sfmtime; + int restart,sfdev = 0,sfino = 0, sfmtime = 0; struct stat sbuf; - struct sigvec ignvec,oldvec; + struct sigaction ign; /* initialize global variables */ pgmversion = PGMVERSION; /* export version number */ @@ -387,8 +355,9 @@ char **argv; supfname = init (argc,argv); restart = -1; /* don't make restart checks */ if (*progname == '/' && *supfname == '/') { - if (stat (supfname,&sbuf) < 0) + if (stat (supfname,&sbuf) < 0) { logerr ("Can't stat supfile %s",supfname); + } else { sfdev = sbuf.st_dev; sfino = sbuf.st_ino; @@ -401,10 +370,10 @@ char **argv; prtime (); } else { /* ignore network pipe signals */ - ignvec.sv_handler = SIG_IGN; - ignvec.sv_onstack = 0; - ignvec.sv_mask = 0; - (void) sigvec (SIGPIPE,&ignvec,&oldvec); + ign.sa_handler = SIG_IGN; + ign.sa_flags = 0; + sigemptyset(&ign.sa_mask); + (void) sigaction (SIGPIPE,&ign,NULL); getnams (); /* find unknown repositories */ for (thisC = firstC; thisC; thisC = thisC->Cnext) { getcoll (); /* upgrade each collection */ @@ -424,15 +393,16 @@ char **argv; (void) endgrent (); /* close /etc/group */ if (restart == 1) { int fd; - loginfo ("SUP Restarting %s with new supfile %s", - progname,supfname); + if (!silent) + loginfo("SUP Restarting %s with new supfile %s", + progname,supfname); for (fd = getdtablesize (); fd > 3; fd--) (void) close (fd); execv (progname,argv); logquit (1,"Restart failed"); } } - while (thisC = firstC) { + while ((thisC = firstC) != NULL) { firstC = firstC->Cnext; free (thisC->Cname); Tfree (&thisC->Chtree); @@ -461,7 +431,7 @@ char **argv; #define Twant Tuid #define Tcount Tgid -void doswitch (argp,collTp,oflagsp,aflagsp) +static void doswitch (argp,collTp,oflagsp,aflagsp) char *argp; register TREE **collTp; int *oflagsp,*aflagsp; @@ -509,6 +479,9 @@ int *oflagsp,*aflagsp; case 'X': xpatchflag = TRUE; break; + case 'S': + silent = TRUE; + break; case 's': sysflag = TRUE; break; @@ -581,7 +554,7 @@ int *oflagsp,*aflagsp; } } -char *init (argc,argv) +static char *init (argc,argv) int argc; char **argv; { @@ -595,7 +568,6 @@ char **argv; register TREE *t; TREE *collT; /* collections we are interested in */ time_t timenow; /* startup time */ - int checkcoll (); int oflags,aflags; int cwant; #ifdef MACH @@ -605,7 +577,6 @@ char **argv; int (*oldsigsys)(); #endif #endif /* MACH */ - char *fmttime(); sysflag = FALSE; /* not system upgrade */ timeflag = FALSE; /* don't print times */ @@ -664,7 +635,7 @@ char **argv; firstC = NULL; lastC = NULL; bogus = FALSE; - while (p = fgets (buf,STRINGLENGTH,f)) { + while ((p = fgets (buf,STRINGLENGTH,f)) != NULL) { q = strchr (p,'\n'); if (q) *q = '\0'; if (strchr ("#;:",*p)) continue; @@ -690,7 +661,7 @@ char **argv; } c->Cflags |= oflags; c->Cflags &= ~aflags; - if (t = Tsearch (collT,c->Cname)) { + if ((t = Tsearch (collT,c->Cname)) != NULL) { c->Cflags |= t->Toflags; c->Cflags &= ~t->Taflags; } @@ -707,7 +678,7 @@ char **argv; } if (bogus) logquit (1,"Aborted due to supfile errors"); if (f != stdin) (void) fclose (f); - if (cwant) (void) Tprocess (collT,checkcoll); + if (cwant) (void) Tprocess (collT,checkcoll, NULL); Tfree (&collT); if (firstC == NULL) logquit (1,"No collections to upgrade"); timenow = time ((time_t *)NULL); @@ -717,13 +688,16 @@ char **argv; p = "system software"; else (void) sprintf (p = buf,"file %s",supfname); - loginfo ("SUP %d.%d (%s) for %s at %s",PROTOVERSION,PGMVERSION, - scmversion,p,fmttime (timenow)); + if (!silent) + loginfo ("SUP %d.%d (%s) for %s at %s",PROTOVERSION,PGMVERSION, + scmversion,p,fmttime (timenow)); return (salloc (supfname)); } -checkcoll (t) +static int +checkcoll (t, dummy) register TREE *t; +void *dummy; { if (!t->Twant) return (SCMOK); if (t->Tcount == 0) diff --git a/usr.bin/sup/src/supcmeat.c b/usr.bin/sup/src/supcmeat.c index 08053d88248..550919b8c66 100644 --- a/usr.bin/sup/src/supcmeat.c +++ b/usr.bin/sup/src/supcmeat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: supcmeat.c,v 1.4 1997/01/17 07:18:07 millert Exp $ */ +/* $OpenBSD: supcmeat.c,v 1.5 1997/04/01 07:35:33 todd Exp $ */ /* * Copyright (c) 1992 Carnegie Mellon University @@ -33,96 +33,6 @@ * Modified SUP to use gzip based compression when sending files * across the network to save BandWidth * - * $Log: supcmeat.c,v $ - * Revision 1.4 1997/01/17 07:18:07 millert - * more r?index -> strr?chr - * - * Revision 1.3 1996/07/31 11:11:28 niklas - * Better use time_t instead of long when dealing with times - * - * Revision 1.2 1996/06/26 05:39:51 deraadt - * rcsid - * - * Revision 1.1 1995/12/16 11:46:56 deraadt - * add sup to the tree - * - * Revision 1.6 1995/10/29 23:54:47 christos - * - runio fails when result != 0 not only < 0 - * - print vis-encoded file in the scanner. - * - * Revision 1.5 1995/06/24 16:21:48 christos - * - Don't use system(3) to fork processes. It is a big security hole. - * - Encode the filenames in the scan files using strvis(3), so filenames - * that contain newlines or other weird characters don't break the scanner. - * - * Revision 1.4 1995/06/03 21:21:56 christos - * Changes to write ascii timestamps in the when files. - * Looked into making it 64 bit clean, but it is hopeless. - * Added little program to convert from the old timestamp files - * into the new ones. - * - * 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 - * initial import of CMU's SUP to NetBSD - * - * Revision 1.16 92/09/09 22:04:51 mrt - * Really added bww's recvone changes this time. - * Added code to support non-crypting version of sup. - * [92/09/01 mrt] - * - * Revision 1.15 92/08/11 12:07:09 mrt - * Added support to add release to FILEWHEN name. - * Updated variable arguemnt list usage - bww - * Updated recvone() to take a va_list - bww - * Changed conditional for rpausing code from CMUCS to MACH - * [92/07/24 mrt] - * - * Revision 1.14 92/02/08 18:24:12 mja - * Only apply "keep" mode when local file is strictly newer - * otherwise allow update as before if necessary. - * [92/02/08 18:09:00 mja] - * - * Added support for -k (keep) option to needone(). Rewrote and - * commented other parts of needone(). - * [92/01/17 vdelvecc] - * - * Revision 1.13 91/05/16 14:49:41 ern - * Add timestap to fileserver. - * Drop day of the week from 5 messages. - * [91/05/16 14:47:53 ern] - * - * Revision 1.12 89/08/23 14:55:44 gm0w - * Changed msgf routines to msg routines. - * [89/08/23 gm0w] - * - * Revision 1.11 89/08/03 19:49:10 mja - * Updated to use v*printf() in place of _doprnt(). - * [89/04/19 mja] - * - * Revision 1.10 89/06/18 14:41:27 gm0w - * Fixed up some notify messages of errors to use "SUP:" prefix. - * [89/06/18 gm0w] - * - * Revision 1.9 89/06/10 15:12:17 gm0w - * Changed to always use rename to install targets. This breaks hard - * links and recreates those known to sup, other links will be orphaned. - * [89/06/10 gm0w] - * - * Revision 1.8 89/05/24 15:04:23 gm0w - * Added code to check for EINVAL from FSPARAM ioctl for disk - * space check failures when the ioctl is not implemented. - * [89/05/24 gm0w] - * - * Revision 1.7 89/01/16 18:22:28 gm0w - * Changed needone() to check that mode of files match before - * setting update if times also match. - * [89/01/16 gm0w] - * * 10-Feb-88 Glenn Marcy (gm0w) at Carnegie-Mellon University * Added timeout to backoff. * @@ -151,12 +61,8 @@ */ #include "supcdefs.h" +#include "supextern.h" #include <sys/wait.h> -#if __STDC__ -#include <stdarg.h> -#else -#include <varargs.h> -#endif TREE *lastT; /* last filenames in collection */ jmp_buf sjbuf; /* jump location for network errors */ @@ -168,22 +74,27 @@ extern COLLECTION *thisC; /* collection list pointer */ extern int rpauseflag; /* don't disable resource pausing */ extern int portdebug; /* network debugging ports */ -#if __STDC__ -int done(int,char *,...); -int goaway(char *,...); -#endif - /************************************************* *** U P G R A D E C O L L E C T I O N *** *************************************************/ +static int needone __P((TREE *, void *)); +static int recvone __P((TREE *, va_list)); +static int denyone __P((TREE *, void *)); +static int deleteone __P((TREE *, void *)); +static int linkone __P((TREE *, void *)); +static int execone __P((TREE *, void *)); +static int finishone __P((TREE *, void *)); + + /* The next two routines define the fsm to support multiple fileservers * per collection. */ -getonehost (t,state) +int getonehost (t,v) register TREE *t; -int *state; +void *v; { + long *state = v; if (t->Tflags != *state) return (SCMOK); if (*state != 0 && t->Tmode == SCMEOF) { @@ -199,9 +110,10 @@ int *state; } TREE *getcollhost (tout,backoff,state,nhostsp) -int *tout,*backoff,*state,*nhostsp; +int *tout,*backoff,*nhostsp; +long *state; { - static int laststate = 0; + static long laststate = 0; static int nhosts = 0; if (*state != laststate) { @@ -209,7 +121,7 @@ int *tout,*backoff,*state,*nhostsp; laststate = *state; nhosts = 0; } - if (Tprocess (thisC->Chtree,getonehost,*state) == SCMEOF) { + if (Tprocess (thisC->Chtree, getonehost, state) == SCMEOF) { if (*state != 0 && nhosts == 0 && !dobackoff (tout,backoff)) return (NULL); nhosts++; @@ -228,11 +140,12 @@ int *tout,*backoff,*state,*nhostsp; * host machine. */ -getcoll () +void getcoll (void) { register TREE *t; register int x; - int tout,backoff,state,nhosts; + int tout,backoff,nhosts; + long state; collname = thisC->Cname; tout = thisC->Ctimeout; @@ -333,11 +246,11 @@ int *tout; /*** Tell file server what to connect to ***/ -setup (t) +int setup (t) register TREE *t; { char relsufix[STRINGLENGTH]; - register int f,x; + register int x; struct stat sbuf; if (chdir (thisC->Cbase) < 0) @@ -418,11 +331,12 @@ register TREE *t; goaway ("Unrecognized file server setup status %d",setupack); } /* NOTREACHED */ + return FALSE; } /*** Tell file server what account to use ***/ -int login () +void login (void) { char buf[STRINGLENGTH]; register int f,x; @@ -431,17 +345,33 @@ int login () (void) sprintf (buf,FILELOCK,collname); f = open (buf,O_RDONLY,0); if (f >= 0) { - if (flock (f,(LOCK_EX|LOCK_NB)) < 0) { - if (errno != EWOULDBLOCK) + +#if defined(LOCK_EX) +# define TESTLOCK(f) flock(f, LOCK_EX|LOCK_NB) +# define SHARELOCK(f) flock(f, LOCK_SH|LOCK_NB) +# define WAITLOCK(f) flock(f, LOCK_EX) +#elif defined(F_LOCK) +# define TESTLOCK(f) lockf(f, F_TLOCK, 0) +# define SHARELOCK(f) 1 +# define WAITLOCK(f) lockf(f, F_LOCK, 0) +#else +# define TESTLOCK(f) (close(f), f = -1, 1) +# define SHARELOCK(f) 1 +# define WAITLOCK(f) 1 +#endif + if (TESTLOCK(f) < 0) { + if (errno != EWOULDBLOCK && errno != EAGAIN) { + (void) close(f); goaway ("Can't lock collection %s",collname); - if (flock (f,(LOCK_SH|LOCK_NB)) < 0) { + } + if (SHARELOCK(f) < 0) { (void) close (f); - if (errno == EWOULDBLOCK) + if (errno == EWOULDBLOCK && errno != EAGAIN) goaway ("Collection %s is locked by another sup",collname); goaway ("Can't lock collection %s",collname); } vnotify ("SUP Waiting for exclusive access lock\n"); - if (flock (f,LOCK_EX) < 0) { + if (WAITLOCK(f) < 0) { (void) close (f); goaway ("Can't lock collection %s",collname); } @@ -490,9 +420,8 @@ int login () * which are no longer on the repository. */ -int listfiles () +void listfiles () { - int needone(), denyone(), deleteone(); char buf[STRINGLENGTH]; char relsufix[STRINGLENGTH]; register char *p,*q; @@ -507,7 +436,7 @@ int listfiles () (void) sprintf (buf,FILELAST,collname,relsufix); f = fopen (buf,"r"); if (f) { - while (p = fgets (buf,STRINGLENGTH,f)) { + while ((p = fgets (buf,STRINGLENGTH,f)) != NULL) { if (q = strchr (p,'\n')) *q = '\0'; if (strchr ("#;:",*p)) continue; (void) Tinsert (&lastT,p,FALSE); @@ -518,7 +447,7 @@ int listfiles () (void) sprintf (buf,FILEREFUSE,collname); f = fopen (buf,"r"); if (f) { - while (p = fgets (buf,STRINGLENGTH,f)) { + while ((p = fgets (buf,STRINGLENGTH,f)) != NULL) { if (q = strchr (p,'\n')) *q = '\0'; if (strchr ("#;:",*p)) continue; (void) Tinsert (&refuseT,p,FALSE); @@ -535,7 +464,7 @@ int listfiles () goaway ("Error reading file list from file server"); if (thisC->Cprefix) (void) chdir (thisC->Cprefix); needT = NULL; - (void) Tprocess (listT,needone); + (void) Tprocess (listT,needone, NULL); Tfree (&listT); x = msgneed (); if (x != SCMOK) @@ -546,15 +475,16 @@ int listfiles () if (x != SCMOK) goaway ("Error reading denied files list from file server"); if (thisC->Cflags&CFVERBOSE) - (void) Tprocess (denyT,denyone); + (void) Tprocess (denyT,denyone, NULL); Tfree (&denyT); if (thisC->Cflags&(CFALL|CFDELETE|CFOLD)) - (void) Trprocess (lastT,deleteone); + (void) Trprocess (lastT,deleteone, NULL); Tfree (&refuseT); } -needone (t) +static int needone (t, dummy) register TREE *t; +void *dummy; { register TREE *newt; register int exists, fetch; @@ -601,15 +531,17 @@ register TREE *t; return (SCMOK); } -denyone (t) +static int denyone (t, v) register TREE *t; +void *v; { vnotify ("SUP: Access denied to %s\n",t->Tname); return (SCMOK); } -deleteone (t) +static int deleteone (t, v) TREE *t; +void *v; { struct stat sbuf; register int x; @@ -705,10 +637,9 @@ TREE *t; * badly and best just stop the program as soon as possible. */ -recvfiles () +void recvfiles (void) { register int x; - int recvone (); int recvmore; /* Does the protocol support compression */ @@ -736,7 +667,7 @@ recvfiles () } /* prepare the target, if necessary */ -prepare (name,mode,newp,statp) +int prepare (name,mode,newp,statp) char *name; int mode,*newp; struct stat *statp; @@ -788,16 +719,18 @@ struct stat *statp; return (TRUE); } -recvone (t,ap) +static int +recvone (t, ap) register TREE *t; va_list ap; { - register int x; + int x = 0; int new; struct stat sbuf; - int linkone (),execone (); - int *recvmore = va_arg(ap,int *); + int *recvmore; + recvmore = va_arg(ap, int *); + va_end(ap); /* check for end of file list */ if (t == NULL) { *recvmore = FALSE; @@ -840,7 +773,7 @@ va_list ap; } if ((t->Tmode&S_IFMT) == S_IFREG) (void) Tprocess (t->Tlink,linkone,t->Tname); - (void) Tprocess (t->Texec,execone); + (void) Tprocess (t->Texec,execone, NULL); return (SCMOK); } @@ -1021,21 +954,22 @@ register struct stat *statp; return (FALSE); } -linkone (t,fname) /* link to file already received */ +static int linkone (t,fv) /* link to file already received */ register TREE *t; -register char **fname; +void *fv; { + register char *fname = fv; struct stat fbuf,sbuf; register char *name = t->Tname; int new,x; char *type; - if (stat(*fname,&fbuf) < 0) { /* source file */ + if (stat(fname,&fbuf) < 0) { /* source file */ if (thisC->Cflags&CFLIST) { - vnotify ("SUP Would link %s to %s\n",name,*fname); + vnotify ("SUP Would link %s to %s\n",name,fname); return (SCMOK); } - notify ("SUP: Can't link %s to missing file %s\n",name,*fname); + notify ("SUP: Can't link %s to missing file %s\n",name,fname); thisC->Cnogood = TRUE; return (SCMOK); } @@ -1048,27 +982,28 @@ register char **fname; fbuf.st_dev == sbuf.st_dev && fbuf.st_ino == sbuf.st_ino) return (SCMOK); if (thisC->Cflags&CFLIST) { - vnotify ("SUP Would link %s to %s\n",name,*fname); + vnotify ("SUP Would link %s to %s\n",name,fname); return (SCMOK); } (void) unlink (name); type = ""; - if ((x = link (*fname,name)) < 0) { + if ((x = link (fname,name)) < 0) { type = "symbolic "; - x = symlink (*fname,name); + x = symlink (fname,name); } if (x < 0 || lstat(name,&sbuf) < 0) { notify ("SUP: Unable to create %slink %s\n",type,name); return (TRUE); } - vnotify ("SUP Created %slink %s to %s\n",type,name,*fname); + vnotify ("SUP Created %slink %s to %s\n",type,name,fname); return (SCMOK); } -execone (t) /* execute command for file */ +static int execone (t, v) /* execute command for file */ register TREE *t; +void *v; { - union wait w; + int w; if (thisC->Cflags&CFLIST) { vnotify ("SUP Would execute %s\n",t->Tname); @@ -1080,18 +1015,18 @@ register TREE *t; } vnotify ("SUP Executing %s\n",t->Tname); - w.w_status = system (t->Tname); - if (WIFEXITED(w) && w.w_retcode != 0) { + w = system (t->Tname); + if (WIFEXITED(w) && WEXITSTATUS(w) != 0) { notify ("SUP: Execute command returned failure status %#o\n", - w.w_retcode); + WEXITSTATUS(w)); thisC->Cnogood = TRUE; } else if (WIFSIGNALED(w)) { notify ("SUP: Execute command killed by signal %d\n", - w.w_termsig); + WTERMSIG(w)); thisC->Cnogood = TRUE; } else if (WIFSTOPPED(w)) { notify ("SUP: Execute command stopped by signal %d\n", - w.w_stopsig); + WSTOPSIG(w)); thisC->Cnogood = TRUE; } return (SCMOK); @@ -1104,7 +1039,7 @@ char *from; /* 0 if reading from network */ register int fromf,tof,istemp,x; char dpart[STRINGLENGTH],fpart[STRINGLENGTH]; char tname[STRINGLENGTH]; - struct stat sbuf; + static int true = 1; static int thispid = 0; /* process id # */ @@ -1170,7 +1105,8 @@ char *from; /* 0 if reading from network */ if (x != SCMOK) goaway ("Can't skip file transfer"); } - return (TRUE); + if (true) + return (TRUE); } if (fromf >= 0) { /* read file */ x = filecopy (fromf,tof); @@ -1295,7 +1231,7 @@ char *from; /* 0 if reading from network */ /*** Finish connection with file server ***/ -finishup (x) +void finishup (x) int x; { char tname[STRINGLENGTH],fname[STRINGLENGTH]; @@ -1303,7 +1239,6 @@ int x; char collrelname[STRINGLENGTH]; time_t tloc; FILE *finishfile; /* record of all filenames */ - int f,finishone(); if ((thisC->Cflags&CFURELSUF) && release) { (void) sprintf (relsufix,".%s",release); @@ -1392,16 +1327,18 @@ int x; Tfree (&lastT); } -finishone (t,finishfile) +int finishone (t,fv) TREE *t; -FILE **finishfile; +void *fv; { + FILE *finishfile = fv; if ((thisC->Cflags&CFDELETE) == 0 || (t->Tflags&FUPDATE)) - fprintf (*finishfile,"%s\n",t->Tname); + fprintf (finishfile,"%s\n",t->Tname); return (SCMOK); } -#if __STDC__ +void +#ifdef __STDC__ done (int value,char *fmt,...) #else /*VARARGS*//*ARGSUSED*/ @@ -1409,21 +1346,21 @@ done (va_alist) va_dcl #endif { -#if !__STDC__ - int value; - char *fmt; -#endif char buf[STRINGLENGTH]; va_list ap; - (void) netcrypt ((char *)NULL); -#if __STDC__ +#ifdef __STDC__ va_start(ap,fmt); #else + int value; + char *fmt; + va_start(ap); value = va_arg(ap,int); fmt = va_arg(ap,char *); #endif + (void) netcrypt ((char *)NULL); + if (fmt) vsnprintf(buf, sizeof(buf), fmt, ap); va_end(ap); @@ -1441,7 +1378,9 @@ va_dcl if (!dontjump) longjmp (sjbuf,TRUE); } -#if __STDC__ + +void +#ifdef __STDC__ goaway (char *fmt,...) #else /*VARARGS*//*ARGSUSED*/ @@ -1449,19 +1388,19 @@ goaway (va_alist) va_dcl #endif { -#if !__STDC__ - register char *fmt; -#endif char buf[STRINGLENGTH]; va_list ap; - (void) netcrypt ((char *)NULL); -#if __STDC__ +#ifdef __STDC__ va_start(ap,fmt); #else + register char *fmt; + va_start(ap); fmt = va_arg(ap,char *); #endif + + (void) netcrypt ((char *)NULL); if (fmt) { vsnprintf(buf, sizeof(buf), fmt, ap); goawayreason = buf; diff --git a/usr.bin/sup/src/supcmisc.c b/usr.bin/sup/src/supcmisc.c index c71a67a196e..140f8fdb743 100644 --- a/usr.bin/sup/src/supcmisc.c +++ b/usr.bin/sup/src/supcmisc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: supcmisc.c,v 1.3 1996/07/31 11:11:29 niklas Exp $ */ +/* $OpenBSD: supcmisc.c,v 1.4 1997/04/01 07:35:35 todd Exp $ */ /* * Copyright (c) 1992 Carnegie Mellon University @@ -28,34 +28,6 @@ * sup misc. routines, include list processing. ********************************************************************** * HISTORY - * $Log: supcmisc.c,v $ - * Revision 1.3 1996/07/31 11:11:29 niklas - * Better use time_t instead of long when dealing with times - * - * Revision 1.2 1996/06/26 05:39:52 deraadt - * rcsid - * - * Revision 1.1 1995/12/16 11:46:57 deraadt - * add sup to the tree - * - * Revision 1.2 1995/06/03 21:21:57 christos - * Changes to write ascii timestamps in the when files. - * Looked into making it 64 bit clean, but it is hopeless. - * Added little program to convert from the old timestamp files - * into the new ones. - * - * Revision 1.1.1.1 1993/05/21 14:52:18 cgd - * initial import of CMU's SUP to NetBSD - * - * Revision 1.5 92/08/11 12:07:22 mrt - * Added release to FILEWHEN name. - * Brad's changes: delinted and updated variable arguement usage. - * [92/07/26 mrt] - * - * Revision 1.3 89/08/15 15:31:28 bww - * Updated to use v*printf() in place of _doprnt(). - * From "[89/04/19 mja]" at CMU. - * [89/08/15 bww] * * 27-Dec-87 Glenn Marcy (gm0w) at Carnegie-Mellon University * Fixed bug in ugconvert() which left pw uninitialized. @@ -67,12 +39,8 @@ ********************************************************************** */ -#if __STDC__ -#include <stdarg.h> -#else -#include <varargs.h> -#endif #include "supcdefs.h" +#include "supextern.h" struct liststruct { /* uid and gid lists */ char *Lname; /* name */ @@ -90,20 +58,21 @@ static LIST *uidL[LISTSIZE]; /* uid and gid lists */ static LIST *gidL[LISTSIZE]; extern COLLECTION *thisC; /* collection list pointer */ -#if __STDC__ -int notify (char *, ...); -#endif + +static int Lhash __P((char *)); +static void Linsert __P((LIST **, char *, int)); +static LIST *Llookup __P((LIST **, char *)); /************************************************* *** P R I N T U P D A T E T I M E S *** *************************************************/ +void prtime () { char buf[STRINGLENGTH]; char relsufix[STRINGLENGTH]; time_t twhen; - int f; if ((thisC->Cflags&CFURELSUF) && thisC->Crelease) (void) sprintf (relsufix,".%s",thisC->Crelease); @@ -173,7 +142,7 @@ char *name; return (((len&HASHMASK)<<HASHBITS)|(((int)c)&HASHMASK)); } -static +static void Linsert (table,name,number) LIST **table; char *name; @@ -201,7 +170,7 @@ char *name; return (l); } -ugconvert (uname,gname,uid,gid,mode) +void ugconvert (uname,gname,uid,gid,mode) char *uname,*gname; int *uid,*gid,*mode; { @@ -219,18 +188,18 @@ int *uid,*gid,*mode; first = FALSE; } pw = NULL; - if (u = Llookup (uidL,uname)) + if ((u = Llookup (uidL,uname)) != NULL) *uid = u->Lnumber; - else if (pw = getpwnam (uname)) { + else if ((pw = getpwnam (uname)) != NULL) { Linsert (uidL,salloc(uname),pw->pw_uid); *uid = pw->pw_uid; } if (u || pw) { - if (g = Llookup (gidL,gname)) { + if ((g = Llookup (gidL,gname)) != NULL) { *gid = g->Lnumber; return; } - if (gr = getgrnam (gname)) { + if ((gr = getgrnam (gname)) != NULL) { Linsert (gidL,salloc(gname),gr->gr_gid); *gid = gr->gr_gid; return; @@ -261,7 +230,8 @@ int *uid,*gid,*mode; *** U T I L I T Y R O U T I N E S *** *********************************************/ -#if __STDC__ +void +#ifdef __STDC__ notify (char *fmt,...) /* record error message */ #else /*VARARGS*//*ARGSUSED*/ @@ -269,18 +239,17 @@ notify (va_alist) /* record error message */ va_dcl #endif { -#if !__STDC__ - char *fmt; -#endif char buf[STRINGLENGTH]; char collrelname[STRINGLENGTH]; time_t tloc; static FILE *noteF = NULL; /* mail program on pipe */ va_list ap; -#if __STDC__ +#ifdef __STDC__ va_start(ap,fmt); #else + char *fmt; + va_start(ap); fmt = va_arg(ap,char *); #endif @@ -317,19 +286,23 @@ va_dcl (void) fflush (noteF); } +void lockout (on) /* lock out interrupts */ int on; { - register int x; - static int lockmask; + static sigset_t oset; + sigset_t nset; if (on) { - x = sigmask (SIGHUP) | sigmask (SIGINT) | - sigmask (SIGQUIT) | sigmask (SIGTERM); - lockmask = sigblock (x); + sigemptyset(&nset); + sigaddset(&nset, SIGHUP); + sigaddset(&nset, SIGINT); + sigaddset(&nset, SIGTERM); + sigaddset(&nset, SIGQUIT); + (void) sigprocmask(SIG_BLOCK, &nset, &oset); } else { - (void) sigsetmask (lockmask); + (void) sigprocmask(SIG_SETMASK, &oset, NULL); } } diff --git a/usr.bin/sup/src/supcname.c b/usr.bin/sup/src/supcname.c index 88a96af6fa3..a4ddfc5a342 100644 --- a/usr.bin/sup/src/supcname.c +++ b/usr.bin/sup/src/supcname.c @@ -1,4 +1,4 @@ -/* $OpenBSD: supcname.c,v 1.3 1997/01/17 07:18:08 millert Exp $ */ +/* $OpenBSD: supcname.c,v 1.4 1997/04/01 07:35:36 todd Exp $ */ /* * Copyright (c) 1992 Carnegie Mellon University @@ -28,25 +28,6 @@ * sup client name server interface ********************************************************************** * HISTORY - * $Log: supcname.c,v $ - * Revision 1.3 1997/01/17 07:18:08 millert - * more r?index -> strr?chr - * - * Revision 1.2 1996/06/26 05:39:53 deraadt - * rcsid - * - * Revision 1.1 1995/12/16 11:46:58 deraadt - * add sup to the tree - * - * Revision 1.2 1995/09/16 19:12:14 glass - * if the function returns nothing, declare it void - * - * Revision 1.1.1.1 1993/05/21 14:52:18 cgd - * initial import of CMU's SUP to NetBSD - * - * Revision 1.4 92/08/11 12:07:32 mrt - * Added copyright. - * [92/08/10 mrt] * * 21-Dec-87 Glenn Marcy (gm0w) at Carnegie-Mellon University * Changed to no longer use a name server. @@ -68,6 +49,7 @@ */ #include "supcdefs.h" +#include "supextern.h" extern COLLECTION *firstC; /* collection list pointer */ @@ -94,7 +76,7 @@ void getnams () f = fopen (buf,"r"); if (f == NULL) logquit (1,"Can't open %s",buf); while ((p = fgets (buf,STRINGLENGTH,f)) != NULL) { - if (q = strchr (p,'\n')) *q = '\0'; + if ((q = strchr (p,'\n')) != NULL) *q = '\0'; if (strchr ("#;:",*p)) continue; q = nxtarg (&p,"= \t"); p = skipover (p," \t"); diff --git a/usr.bin/sup/src/supcparse.c b/usr.bin/sup/src/supcparse.c index 21dd7f7c212..fb9b4a4c28a 100644 --- a/usr.bin/sup/src/supcparse.c +++ b/usr.bin/sup/src/supcparse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: supcparse.c,v 1.2 1996/06/26 05:39:53 deraadt Exp $ */ +/* $OpenBSD: supcparse.c,v 1.3 1997/04/01 07:35:38 todd Exp $ */ /* * Copyright (c) 1992 Carnegie Mellon University @@ -33,37 +33,6 @@ * Modified SUP to use gzip based compression when sending files * across the network to save BandWidth * - * $Log: supcparse.c,v $ - * Revision 1.2 1996/06/26 05:39:53 deraadt - * rcsid - * - * Revision 1.1 1995/12/16 11:46:58 deraadt - * add sup to the tree - * - * Revision 1.4 1995/06/09 04:33:34 christos - * fixed bug related to the ascii `when' files previous fix, where the -t - * option would fail to read the timestamp files. - * - * 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 - * Added use-rel-suffix option corresponding to -u switch. - * [92/07/26 mrt] - * - * Revision 1.5 92/02/08 18:24:19 mja - * Added "keep" supfile option, corresponding to -k switch. - * [92/01/17 vdelvecc] - * - * Revision 1.4 91/05/16 14:49:50 ern - * Change default timeout from none to 3 hours so we don't accumalute - * processes running sups to dead hosts especially for users. - * [91/05/16 14:49:21 ern] - * - * * 10-Feb-88 Glenn Marcy (gm0w) at Carnegie-Mellon University * Added timeout to backoff. * @@ -77,6 +46,7 @@ */ #include "supcdefs.h" +#include "supextern.h" #ifdef lint @@ -96,26 +66,28 @@ struct option { char *op_name; OPTION op_enum; } options[] = { - "host", OHOST, - "base", OBASE, - "hostbase", OHOSTBASE, - "prefix", OPREFIX, - "release", ORELEASE, - "notify", ONOTIFY, - "login", OLOGIN, - "password", OPASSWORD, - "crypt", OCRYPT, - "backup", OBACKUP, - "delete", ODELETE, - "execute", OEXECUTE, - "old", OOLD, - "timeout", OTIMEOUT, - "keep", OKEEP, - "use-rel-suffix", OURELSUF, - "compress", OCOMPRESS + { "host", OHOST }, + { "base", OBASE }, + { "hostbase", OHOSTBASE }, + { "prefix", OPREFIX }, + { "release", ORELEASE }, + { "notify", ONOTIFY }, + { "login", OLOGIN }, + { "password", OPASSWORD }, + { "crypt", OCRYPT }, + { "backup", OBACKUP }, + { "delete", ODELETE }, + { "execute", OEXECUTE }, + { "old", OOLD }, + { "timeout", OTIMEOUT }, + { "keep", OKEEP }, + { "use-rel-suffix", OURELSUF }, + { "compress", OCOMPRESS } }; -passdelim (ptr,delim) /* skip over delimiter */ +static void passdelim __P((char **, int )); + +static void passdelim (ptr,delim) /* skip over delimiter */ char **ptr,delim; { *ptr = skipover (*ptr, " \t"); @@ -125,7 +97,7 @@ char **ptr,delim; } } -parsecoll(c,collname,args) +int parsecoll(c,collname,args) COLLECTION *c; char *collname,*args; { @@ -243,14 +215,14 @@ char *collname,*args; } -long +time_t getwhen(collection, relsuffix) char *collection, *relsuffix; { char buf[STRINGLENGTH]; char *ep; FILE *fp; - long tstamp; + time_t tstamp; (void) sprintf (buf,FILEWHEN,collection,relsuffix); @@ -273,7 +245,7 @@ getwhen(collection, relsuffix) int putwhen(fname, tstamp) char *fname; - long tstamp; + time_t tstamp; { FILE *fp; if ((fp = fopen(fname, "w")) == NULL) diff --git a/usr.bin/sup/src/supcvers.c b/usr.bin/sup/src/supcvers.c index e928c427d71..5d408b13dd6 100644 --- a/usr.bin/sup/src/supcvers.c +++ b/usr.bin/sup/src/supcvers.c @@ -1,4 +1,4 @@ -/* $OpenBSD: supcvers.c,v 1.2 1996/06/26 05:39:53 deraadt Exp $ */ +/* $OpenBSD: supcvers.c,v 1.3 1997/04/01 07:35:39 todd Exp $ */ /* * Copyright (c) 1992 Carnegie Mellon University @@ -27,23 +27,6 @@ /* ********************************************************************** * HISTORY - * $Log: supcvers.c,v $ - * Revision 1.2 1996/06/26 05:39:53 deraadt - * rcsid - * - * Revision 1.1 1995/12/16 11:46:59 deraadt - * add sup to the tree - * - * Revision 1.1.1.1 1993/05/21 14:52:19 cgd - * initial import of CMU's SUP to NetBSD - * - * Revision 1.8 92/08/11 12:07:51 mrt - * Added use-rel-suffix option. Picked up STUMP changes. - * [V7.26] - * - * Revision 1.7 92/02/08 18:24:23 mja - * Support for -k/-K and "keep" option. [V7.25] - * [92/01/17 vdelvecc] * * 27-Dec-87 Glenn Marcy (gm0w) at Carnegie-Mellon University * Added crosspatch support. Removed nameserver support. [V7.24] diff --git a/usr.bin/sup/src/supextern.h b/usr.bin/sup/src/supextern.h new file mode 100644 index 00000000000..d1a13d941e2 --- /dev/null +++ b/usr.bin/sup/src/supextern.h @@ -0,0 +1,178 @@ +/* $OpenBSD: supextern.h,v 1.1 1997/04/01 07:35:41 todd Exp $ */ + +#ifndef __P +#ifdef __STDC__ +#define __P(a) a +#else +#define __P(a) () +#endif +#endif + +/* atoo.c */ +unsigned int atoo __P((char *)); + +#if 0 +/* ci.c */ +int ci __P((char *, FILE *, int, CIENTRY *, char *, char *)); +#endif + +/* errmsg.c */ +char *errmsg __P((int)); + +/* expand.c */ +int expand __P((char *, char **, int)); + +/* ffilecopy.c */ +int ffilecopy __P((FILE *, FILE *)); + +/* filecopy.c */ +int filecopy __P((int, int )); + +/* log.c */ +void logopen __P((char *)); +void logquit __P((int, char *, ...)); +void logerr __P((char *, ...)); +void loginfo __P((char *, ...)); + +/* netcryptvoid.c */ +int netcrypt __P((char *)); +int getcryptbuf __P((int)); +void decode __P((char *, char *, int)); +void encode __P((char *, char *, int)); + +/* nxtarg.c */ +char *nxtarg __P((char **, char *)); + +/* path.c */ +void path __P((char *, char *, char *)); + +/* quit.c */ +void quit __P((int, char *, ...)); + +/* run.c */ +int run __P((char *, ...)); +int runv __P((char *, char **)); +int runp __P((char *, ...)); +int runvp __P((char *, char **)); +int runio __P((char *const[], const char *, const char *, const char *)); + +/* salloc.c */ +char *salloc __P((char *)); + +/* scan.c */ +int getrelease __P((char *)); +void makescanlists __P((void)); +void getscanlists __P((void)); +void cdprefix __P((char *)); + +/* scm.c */ +int servicesetup __P((char *)); +int service __P((void)); +int serviceprep __P((void)); +int servicekill __P((void)); +int serviceend __P((void)); +int dobackoff __P((int *, int *)); +int request __P((char *, char *, int *)); +int requestend __P((void)); +char *remotehost __P((void)); +int thishost __P((char *)); +int samehost __P((void)); +int matchhost __P((char *)); +int scmerr __P((int, char *, ...)); +int byteswap __P((int)); + +/* scmio.c */ +int writemsg __P((int)); +int writemend __P((void)); +int writeint __P((int)); +int writestring __P((char *)); +int writefile __P((int)); +int writemnull __P((int)); +int writemint __P((int, int )); +int writemstr __P((int, char *)); +int prereadcount __P((int *)); +int readflush __P((void)); +int readmsg __P((int)); +int readmend __P((void)); +int readskip __P((void)); +int readint __P((int *)); +int readstring __P((char **)); +int readfile __P((int)); +int readmnull __P((int)); +int readmint __P((int, int *)); +int readmstr __P((int, char **)); +void crosspatch __P((void)); + +/* skipto.c */ +char *skipto __P((char *, char *)); +char *skipover __P((char *, char *)); + +/* stree.c */ +void Tfree __P((TREE **)); +TREE *Tinsert __P((TREE **, char *, int)); +TREE *Tsearch __P((TREE *, char *)); +TREE *Tlookup __P((TREE *, char *)); +int Trprocess __P((TREE *, int (*)(TREE *, void *), void *)); +int Tprocess __P((TREE *, int (*)(TREE *, void *), void *)); +void Tprint __P((TREE *, char *)); + +/* supcmeat.c */ +int getonehost __P((TREE *, void *)); +TREE *getcollhost __P((int *, int *, long *, int *)); +void getcoll __P((void)); +int signon __P((TREE *, int, int *)); +int setup __P((TREE *)); +void login __P((void)); +void listfiles __P((void)); +void recvfiles __P((void)); +int prepare __P((char *, int, int *, struct stat *)); +int recvdir __P((TREE *, int, struct stat *)); +int recvsym __P((TREE *, int, struct stat *)); +int recvreg __P((TREE *, int, struct stat *)); +int copyfile __P((char *, char *)); +void finishup __P((int)); +void done __P((int, char *, ...)); +void goaway __P((char *, ...)); + +/* supcmisc.c */ +void prtime __P((void)); +int establishdir __P((char *)); +int estabd __P((char *, char *)); +void ugconvert __P((char *, char *, int *, int *, int *)); +void notify __P((char *, ...)); +void lockout __P((int)); +char *fmttime __P((time_t)); + +/* supcname.c */ +void getnams __P((void)); + +/* supcparse.c */ +int parsecoll __P((COLLECTION *, char *, char *)); +time_t getwhen __P((char *, char *)); +int putwhen __P((char *, time_t)); + +/* supmsg.c */ +int msgsignon __P((void)); +int msgsignonack __P((void)); +int msgsetup __P((void)); +int msgsetupack __P((void)); +int msgcrypt __P((void)); +int msgcryptok __P((void)); +int msglogin __P((void)); +int msglogack __P((void)); +int msgrefuse __P((void)); +int msglist __P((void)); +int msgneed __P((void)); +int msgdeny __P((void)); +int msgsend __P((void)); +int msgrecv __P((int (*)(TREE *, va_list), ...)); +int msgdone __P((void)); +int msggoaway __P((void)); +int msgxpatch __P((void)); +int msgcompress __P((void)); + +/* vprintf.c */ +int vprintf __P((const char *, va_list)); +int vfprintf __P((FILE *, const char *, va_list)); +int vsprintf __P((char *, const char *, va_list)); +int vsnprintf __P((char *, size_t, const char *, va_list)); diff --git a/usr.bin/sup/src/supfilesrv.c b/usr.bin/sup/src/supfilesrv.c index 6c96a48a6c8..50a6711430c 100644 --- a/usr.bin/sup/src/supfilesrv.c +++ b/usr.bin/sup/src/supfilesrv.c @@ -1,4 +1,4 @@ -/* $OpenBSD: supfilesrv.c,v 1.6 1997/01/17 07:18:10 millert Exp $ */ +/* $OpenBSD: supfilesrv.c,v 1.7 1997/04/01 07:35:43 todd Exp $ */ /* * Copyright (c) 1992 Carnegie Mellon University @@ -24,14 +24,16 @@ * any improvements or extensions that they make and grant Carnegie Mellon * the rights to redistribute these changes. * + */ /* * supfilesrv -- SUP File Server * - * Usage: supfilesrv [-l] [-P] [-N] [-R] + * Usage: supfilesrv [-l] [-P] [-N] [-R] [-S] * -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 + * -S "Operate silently" -- Only print error messages * ********************************************************************** * HISTORY @@ -43,119 +45,6 @@ * Modified SUP to use gzip based compression when sending files * across the network to save BandWidth * - * $Log: supfilesrv.c,v $ - * Revision 1.6 1997/01/17 07:18:10 millert - * more r?index -> strr?chr - * - * Revision 1.5 1996/12/22 03:26:05 tholo - * Deal with _POSIX_SAVED_IDS when relinquishing privileges - * - * Revision 1.4 1996/07/31 11:11:31 niklas - * Better use time_t instead of long when dealing with times - * - * Revision 1.3 1996/06/26 05:39:54 deraadt - * rcsid - * - * Revision 1.2 1996/06/10 20:45:35 deraadt - * hack: print hostname connection failed with - * - * Revision 1.1 1995/12/16 11:46:59 deraadt - * add sup to the tree - * - * Revision 1.8 1995/10/29 23:54:49 christos - * - runio fails when result != 0 not only < 0 - * - print vis-encoded file in the scanner. - * - * Revision 1.7 1995/06/24 16:21:55 christos - * - Don't use system(3) to fork processes. It is a big security hole. - * - Encode the filenames in the scan files using strvis(3), so filenames - * that contain newlines or other weird characters don't break the scanner. - * - * Revision 1.6 1995/06/03 21:22:00 christos - * Changes to write ascii timestamps in the when files. - * Looked into making it 64 bit clean, but it is hopeless. - * Added little program to convert from the old timestamp files - * into the new ones. - * - * 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... - * - * Revision 1.2 1993/05/24 17:57:31 brezak - * Remove netcrypt.c. Remove unneeded files. Cleanup make. - * - * Revision 1.20 92/09/09 22:05:00 mrt - * Added Brad's change to make sendfile take a va_list. - * Added support in login to accept an non-encrypted login - * message if no user or password is being sent. This supports - * a non-crypting version of sup. Also fixed to skip leading - * white space from crypts in host files. - * [92/09/01 mrt] - * - * Revision 1.19 92/08/11 12:07:59 mrt - * Made maxchildren a patchable variable, which can be set by the - * command line switch -C or else defaults to the MAXCHILDREN - * defined in sup.h. Added most of Brad's STUMP changes. - * Increased PGMVERSION to 12 to reflect substantial changes. - * [92/07/28 mrt] - * - * Revision 1.18 90/12/25 15:15:39 ern - * Yet another rewrite of the logging code. Make up the text we will write - * and then get in, write it and get out. - * Also set error on write-to-full-disk if the logging is for recording - * server is busy. - * [90/12/25 15:15:15 ern] - * - * Revision 1.17 90/05/07 09:31:13 dlc - * Sigh, some more fixes to the new "crypt" file handling code. First, - * just because the "crypt" file is in a local file system does not mean - * it can be trusted. We have to check for hard links to root owned - * files whose contents could be interpretted as a crypt key. For - * checking this fact, the new routine stat_info_ok() was added. This - * routine also makes other sanity checks, such as owner only permission, - * the file is a regular file, etc. Also, even if the uid/gid of th - * "crypt" file is not going to be used, still use its contents in order - * to cause fewer surprises to people supping out of a shared file system - * such as AFS. - * [90/05/07 dlc] - * - * Revision 1.16 90/04/29 04:21:08 dlc - * Fixed logic bug in docrypt() which would not get the stat information - * from the crypt file if the crypt key had already been set from a - * "host" file. - * [90/04/29 dlc] - * - * Revision 1.15 90/04/18 19:51:27 dlc - * Added the new routines local_file(), link_nofollow() for use in - * dectecting whether a file is located in a local file system. These - * routines probably should have been in another module, but only - * supfilesrv needs to do the check and none of its other modules seemed - * appropriate. Note, the implementation should be changed once we have - * direct kernel support, for example the fstatfs(2) system call, for - * detecting the type of file system a file resides. Also, I changed - * the routines which read the crosspatch crypt file or collection crypt - * file to save the uid and gid from the stat information obtained via - * the local_file() call (when the file is local) at the same time the - * crypt key is read. This change disallows non-local files for the - * crypt key to plug a security hole involving the usage of the uid/gid - * of the crypt file to define who the the file server should run as. If - * the saved uid/gid are both valid, then the server will set its uid/gid - * to these values. - * [90/04/18 dlc] - * - * Revision 1.14 89/08/23 14:56:15 gm0w - * Changed msgf routines to msg routines. - * [89/08/23 gm0w] - * - * Revision 1.13 89/08/03 19:57:33 mja - * Remove setaid() call. - * - * Revision 1.12 89/08/03 19:49:24 mja - * Updated to use v*printf() in place of _doprnt(). - * [89/04/19 mja] - * * 11-Sep-88 Glenn Marcy (gm0w) at Carnegie-Mellon University * Added code to record release name in logfile. * @@ -257,6 +146,7 @@ #include <setjmp.h> #include <pwd.h> #include <grp.h> +#include <fcntl.h> #if __STDC__ #include <stdarg.h> #else @@ -267,7 +157,12 @@ #include <sys/wait.h> #include <sys/stat.h> #include <sys/file.h> +#include <sys/mount.h> +#ifndef HAS_POSIX_DIR #include <sys/dir.h> +#else +#include <dirent.h> +#endif #if MACH #include <sys/ioctl.h> #endif @@ -280,18 +175,22 @@ #define ACCESS_CODE_OK 0 #define ACCESS_CODE_BADPASSWORD (-2) #endif CMUCS -#include "sup.h" +#ifdef __linux__ +#include <sys/vfs.h> +#include <linux/nfs_fs.h> +#endif + +#ifdef __SVR4 +# include <sys/mkdev.h> +# include <sys/statvfs.h> +#endif + +#include "supcdefs.h" +#include "supextern.h" #define MSGFILE #include "supmsg.h" -#ifdef lint -/*VARARGS1*//*ARGSUSED*/ -static void quit(status) {}; -#endif /* lint */ - extern int errno; -uid_t getuid (); - int maxchildren; /* @@ -336,6 +235,7 @@ int progpid = -1; /* and process id */ jmp_buf sjbuf; /* jump location for network errors */ TREELIST *listTL; /* list of trees to upgrade */ +int silent; /* -S flag */ int live; /* -l flag */ int dbgportsq; /* -P flag */ extern int scmdebug; /* -N flag */ @@ -365,22 +265,50 @@ HASH *uidH[HASHSIZE]; /* for uid and gid lookup */ HASH *gidH[HASHSIZE]; HASH *inodeH[HASHSIZE]; /* for inode lookup for linked file check */ -char *fmttime (); /* time format routine */ -#if __STDC__ -int goaway(char *fmt,...); -#endif + +/* supfilesrv.c */ +int main __P((int, char **)); +void chldsig __P((int)); +void usage __P((void)); +void init __P((int, char **)); +void answer __P((void)); +void srvsignon __P((void)); +void srvsetup __P((void)); +void docrypt __P((void)); +void srvlogin __P((void)); +void listfiles __P((void)); +int denyone __P((TREE *, void *)); +void sendfiles __P((void)); +int sendone __P((TREE *, void *)); +int senddir __P((TREE *, void *)); +int sendfile __P((TREE *, va_list)); +void srvfinishup __P((time_t)); +void Hfree __P((HASH **)); +HASH *Hlookup __P((HASH **, int, int )); +void Hinsert __P((HASH **, int, int, char *, TREE *)); +TREE *linkcheck __P((TREE *, int, int )); +char *uconvert __P((int)); +char *gconvert __P((int)); +char *changeuid __P((char *, char *, int, int )); +void goaway __P((char *, ...)); +char *fmttime __P((time_t)); +int local_file __P((int, struct stat *)); +int stat_info_ok __P((struct stat *, struct stat *)); +int link_nofollow __P((int)); +int link_nofollow __P((int)); /************************************* *** M A I N R O U T I N E *** *************************************/ +int main (argc,argv) int argc; char **argv; { - register int x,pid,signalmask; - struct sigvec chldvec,ignvec,oldvec; - void chldsig(); + register int x,pid; + sigset_t nset, oset; + struct sigaction chld,ign; time_t tloc; /* initialize global variables */ @@ -408,16 +336,16 @@ char **argv; (void) serviceend (); exit (0); } - ignvec.sv_handler = SIG_IGN; - ignvec.sv_onstack = 0; - ignvec.sv_mask = 0; - (void) sigvec (SIGHUP,&ignvec,&oldvec); - (void) sigvec (SIGINT,&ignvec,&oldvec); - (void) sigvec (SIGPIPE,&ignvec,&oldvec); - chldvec.sv_handler = chldsig; - chldvec.sv_mask = 0; - chldvec.sv_onstack = 0; - (void) sigvec (SIGCHLD,&chldvec,&oldvec); + ign.sa_handler = SIG_IGN; + sigemptyset(&ign.sa_mask); + ign.sa_flags = 0; + (void) sigaction (SIGHUP,&ign,NULL); + (void) sigaction (SIGINT,&ign,NULL); + (void) sigaction (SIGPIPE,&ign,NULL); + chld.sa_handler = chldsig; + sigemptyset(&chld.sa_mask); + chld.sa_flags = 0; + (void) sigaction (SIGCHLD,&chld,NULL); nchildren = 0; for (;;) { x = service (); @@ -426,7 +354,9 @@ char **argv; (void) servicekill (); continue; } - signalmask = sigblock(sigmask(SIGCHLD)); + sigemptyset(&nset); + sigaddset(&nset, SIGCHLD); + sigprocmask(SIG_BLOCK, &nset, &oset); if ((pid = fork()) == 0) { /* server process */ (void) serviceprep (); answer (); @@ -435,7 +365,7 @@ char **argv; } (void) servicekill (); /* parent */ if (pid > 0) nchildren++; - (void) sigsetmask(signalmask); + (void) sigprocmask(SIG_SETMASK, &oset, NULL); } } @@ -447,7 +377,7 @@ void chldsig(snum) int snum; { - union wait w; + int w; while (wait3((int *) &w, WNOHANG, (struct rusage *)0) > 0) { if (nchildren) nchildren--; @@ -458,11 +388,13 @@ chldsig(snum) *** I N I T I A L I Z A T I O N *** *****************************************/ +void usage () { quit (1,"Usage: supfilesrv [ -l | -P | -N | -C <max children> | -H <host> <user> <cryptfile> <supargs> ]\n"); } +void init (argc,argv) int argc; char **argv; @@ -489,6 +421,9 @@ char **argv; argv++; while (clienthost == NULL && argc > 0 && argv[0][0] == '-') { switch (argv[0][1]) { + case 'S': + silent = TRUE; + break; case 'l': live = TRUE; break; @@ -542,7 +477,7 @@ char **argv; f = fopen (cryptkey,"r"); if (f == NULL) quit (1,"Unable to open cryptfile %s\n",cryptkey); - if (p = fgets (buf,STRINGLENGTH,f)) { + if ((p = fgets (buf,STRINGLENGTH,f)) != NULL) { if (q = strchr (p,'\n')) *q = '\0'; if (*p == '\0') quit (1,"No cryptkey found in %s\n",cryptkey); @@ -620,6 +555,7 @@ char **argv; *** A N S W E R R E Q U E S T *** *****************************************/ +void answer () { time_t starttime; @@ -639,10 +575,10 @@ answer () lockfd = -1; starttime = time ((time_t *)NULL); if (!setjmp (sjbuf)) { - signon (); - setup (); + srvsignon (); + srvsetup (); docrypt (); - login (); + srvlogin (); if (xpatch) { int fd; @@ -664,7 +600,7 @@ answer () listfiles (); sendfiles (); } - finishup (starttime); + srvfinishup (starttime); if (collname) free (collname); if (basedir) free (basedir); if (prefix) free (prefix); @@ -694,7 +630,8 @@ answer () *** S I G N O N C L I E N T *** *****************************************/ -signon () +void +srvsignon () { register int x; @@ -711,7 +648,8 @@ signon () *** E X C H A N G E S E T U P I N F O R M A T I O N *** *****************************************************************/ -setup () +void +srvsetup () { register int x; char *p,*q; @@ -733,13 +671,12 @@ setup () } if (xpatch) { register struct passwd *pw; - extern int link_nofollow(), local_file(); if ((pw = getpwnam (xuser)) == NULL) { setupack = FSETUPSAME; (void) msgsetupack (); if (protver >= 6) longjmp (sjbuf,TRUE); - goaway ("User not found"); + goaway ("User `%s' not found",xuser); } (void) free (xuser); xuser = salloc (pw->pw_dir); @@ -758,7 +695,7 @@ setup () if ((f = fopen (buf,"r")) != NULL) { struct stat fsbuf; - while (p = fgets (buf,STRINGLENGTH,f)) { + while ((p = fgets (buf,STRINGLENGTH,f)) != NULL) { q = strchr (p,'\n'); if (q) *q = 0; if (strchr ("#;:",*p)) continue; @@ -811,7 +748,7 @@ setup () (void) sprintf (buf,FILEDIRS,DEFDIR); f = fopen (buf,"r"); if (f) { - while (p = fgets (buf,STRINGLENGTH,f)) { + while ((p = fgets (buf,STRINGLENGTH,f)) != NULL) { q = strchr (p,'\n'); if (q) *q = 0; if (strchr ("#;:",*p)) continue; @@ -834,7 +771,7 @@ setup () (void) sprintf (buf,FILEPREFIX,collname); f = fopen (buf,"r"); if (f) { - while (p = fgets (buf,STRINGLENGTH,f)) { + while ((p = fgets (buf,STRINGLENGTH,f)) != NULL) { q = strchr (p,'\n'); if (q) *q = 0; if (strchr ("#;:",*p)) continue; @@ -879,7 +816,7 @@ setup () f = fopen (buf,"r"); if (f) { int hostok = FALSE; - while (p = fgets (buf,STRINGLENGTH,f)) { + while ((p = fgets (buf,STRINGLENGTH,f)) != NULL) { int not; q = strchr (p,'\n'); if (q) *q = 0; @@ -906,6 +843,7 @@ setup () } /* try to lock collection */ (void) sprintf (buf,FILELOCK,collname); +#ifdef LOCK_SH x = open (buf,O_RDONLY,0); if (x >= 0) { if (flock (x,(LOCK_SH|LOCK_NB)) < 0) { @@ -919,11 +857,13 @@ setup () } lockfd = x; } +#endif setupack = FSETUPOK; x = msgsetupack (); if (x != SCMOK) goaway ("Error sending setup reply to client"); } +void /** Test data encryption **/ docrypt () { @@ -932,7 +872,6 @@ docrypt () char buf[STRINGLENGTH]; register FILE *f; struct stat sbuf; - extern int link_nofollow(), local_file(); if (!xpatch) { (void) sprintf (buf,FILECRYPT,collname); @@ -948,7 +887,8 @@ docrypt () if (cryptkey == NULL && (p = fgets (buf,STRINGLENGTH,f))) { - if (q = strchr (p,'\n')) *q = '\0'; + if ((q = strchr (p,'\n')) != NULL) + *q = '\0'; if (*p) cryptkey = salloc (buf); } if (local_file(fileno(f), &fsbuf) > 0 @@ -982,10 +922,10 @@ docrypt () *** C O N N E C T T O P R O P E R A C C O U N T *** ***************************************************************/ -login () +void +srvlogin () { - char *changeuid (); - register int x,fileuid,filegid; + register int x,fileuid = -1,filegid = -1; (void) netcrypt (PSWDCRYPT); /* encrypt acct name and password */ x = msglogin (); @@ -1034,9 +974,9 @@ login () *** M A K E N A M E L I S T *** *****************************************/ +void listfiles () { - int denyone(); register int x; refuseT = NULL; @@ -1053,22 +993,24 @@ listfiles () if (x != SCMOK) goaway ("Error reading needed files list from client"); denyT = NULL; - (void) Tprocess (needT,denyone); + (void) Tprocess (needT,denyone, NULL); Tfree (&needT); x = msgdeny (); if (x != SCMOK) goaway ("Error sending denied files list to client"); Tfree (&denyT); } -denyone (t) + +int +denyone (t, v) register TREE *t; +void *v; { register TREELIST *tl; register char *name = t->Tname; register int update = (t->Tflags&FUPDATE) != 0; struct stat sbuf; register TREE *tlink; - TREE *linkcheck (); char slinkname[STRINGLENGTH]; register int x; @@ -1121,9 +1063,9 @@ register TREE *t; *** S E N D F I L E S *** *********************************/ +void sendfiles () { - int sendone(),senddir(),sendfile(); register TREELIST *tl; register int x; @@ -1148,12 +1090,12 @@ sendfiles () } } #endif - (void) Tprocess (tl->TLtree,sendone); + (void) Tprocess (tl->TLtree,sendone,NULL); } /* send directories in reverse order */ for (tl = listTL; tl != NULL; tl = tl->TLnext) { cdprefix (tl->TLprefix); - (void) Trprocess (tl->TLtree,senddir); + (void) Trprocess (tl->TLtree,senddir,NULL); } x = msgsend (); if (x != SCMOK) @@ -1164,16 +1106,13 @@ sendfiles () goaway ("Error sending file to client"); } -sendone (t) +int +sendone (t, v) TREE *t; +void *v; { register int x,fd; - register int fdtmp; - char temp_file[STRINGLENGTH], rcs_file[STRINGLENGTH]; - union wait status; - char *uconvert(),*gconvert(); - int sendfile (); - int ac; + char temp_file[STRINGLENGTH]; char *av[50]; /* More than enough */ if ((t->Tflags&FNEEDED) == 0) /* only send needed files */ @@ -1219,34 +1158,34 @@ TREE *t; #endif av[ac++] = t->Tname; av[ac++] = NULL; - status.w_status = runio(av, - NULL, - rcs_file, - "/dev/null"); + status = runio(av, NULL, rcs_file, + "/dev/null"); /*loginfo("using rcs mode \n");*/ - if (status.w_status < 0 || status.w_retcode) { + if (status < 0 || WEXITSTATUS(status)) { /* Just in case */ unlink(rcs_file); - if (status.w_status < 0) { - goaway ("We died trying to run cvs or rcs"); + if (status < 0) { + goaway ("We died trying to run cvs or rcs on %s", rcs_file); t->Tmode = 0; } else { - /*logerr("rcs command failed = %d\n", - status.w_retcode);*/ +#if 0 + logerr("rcs command failed = %d\n", + WEXITSTATUS(status)); +#endif t->Tflags |= FUPDATE; } } else if (docompress) { tmpnam(temp_file); av[0] = "gzip"; - av[1] = "-c"; + av[1] = "-cf"; av[2] = NULL; if (runio(av, rcs_file, temp_file, NULL) != 0) { /* Just in case */ unlink(temp_file); unlink(rcs_file); - goaway ("We died trying to gzip a file"); + goaway ("We died trying to gzip %s", rcs_file); t->Tmode = 0; } fd = open (temp_file,O_RDONLY,0); @@ -1260,12 +1199,12 @@ TREE *t; if (docompress) { tmpnam(temp_file); av[0] = "gzip"; - av[1] = "-c"; + av[1] = "-cf"; av[2] = NULL; if (runio(av, t->Tname, temp_file, NULL) != 0) { /* Just in case */ unlink(temp_file); - goaway ("We died trying to run gzip"); + goaway ("We died trying to run gzip %s", t->Tname); t->Tmode = 0; } fd = open (temp_file,O_RDONLY,0); @@ -1287,16 +1226,16 @@ TREE *t; if (dorcs) unlink(rcs_file); #endif - if (x != SCMOK) goaway ("Error sending file to client"); + if (x != SCMOK) goaway ("Error sending file %s to client", t->Tname); return (SCMOK); } -senddir (t) +int +senddir (t, v) TREE *t; +void *v; { register int x; - char *uconvert(),*gconvert(); - int sendfile (); if ((t->Tflags&FNEEDED) == 0) /* only send needed files */ return (SCMOK); @@ -1308,20 +1247,22 @@ TREE *t; t->Tuser = salloc (uconvert (t->Tuid)); t->Tgroup = salloc (gconvert (t->Tgid)); x = msgrecv (sendfile,0); - if (x != SCMOK) goaway ("Error sending file to client"); + if (x != SCMOK) goaway ("Error sending file %s to client", t->Tname); return (SCMOK); } -sendfile (t,ap) -register TREE *t; +int +sendfile (t, ap) +TREE *t; va_list ap; { - register int x; - int fd = va_arg(ap,int); + register int x, fd; + + fd = va_arg(ap,int); if ((t->Tmode&S_IFMT) != S_IFREG || listonly || (t->Tflags&FUPDATE)) return (SCMOK); x = writefile (fd); - if (x != SCMOK) goaway ("Error sending file to client"); + if (x != SCMOK) goaway ("Error sending file %s to client", t->Tname); (void) close (fd); return (SCMOK); } @@ -1330,13 +1271,13 @@ va_list ap; *** E N D C O N N E C T I O N *** *****************************************/ -finishup (starttime) +void +srvfinishup (starttime) time_t starttime; { register int x = SCMOK; char tmpbuf[BUFSIZ], *p, lognam[STRINGLENGTH]; int logfd; - struct stat sbuf; time_t finishtime; char *releasename; @@ -1404,13 +1345,14 @@ time_t starttime; *** H A S H T A B L E R O U T I N E S *** ***************************************************/ +void Hfree (table) HASH **table; { register HASH *h; register int i; for (i = 0; i < HASHSIZE; i++) - while (h = table[i]) { + while ((h = table[i]) != NULL) { table[i] = h->Hnext; if (h->Hname) free (h->Hname); free ((char *)h); @@ -1428,6 +1370,7 @@ int num1,num2; return (h); } +void Hinsert (table,num1,num2,name,tree) HASH **table; int num1,num2; @@ -1495,7 +1438,6 @@ char *changeuid (namep,passwordp,fileuid,filegid) char *namep,*passwordp; int fileuid,filegid; { - char *okpassword (); char *group,*account,*pswdp; struct passwd *pwd; struct group *grp; @@ -1509,7 +1451,7 @@ int fileuid,filegid; #if CMUCS int *grps; #endif /* CMUCS */ - char *p; + char *p = NULL; if (namep == NULL) { pwd = getpwuid (fileuid); @@ -1676,7 +1618,8 @@ int fileuid,filegid; return (NULL); } -#if __STDC__ +void +#ifdef __STDC__ goaway (char *fmt,...) #else /*VARARGS*//*ARGSUSED*/ @@ -1684,19 +1627,19 @@ goaway (va_alist) va_dcl #endif { -#if !__STDC__ - register char *fmt; -#endif char buf[STRINGLENGTH]; va_list ap; - (void) netcrypt ((char *)NULL); -#if __STDC__ +#ifdef __STDC__ va_start(ap,fmt); #else + register char *fmt; + va_start(ap); fmt = va_arg(ap,char *); #endif + (void) netcrypt ((char *)NULL); + vsnprintf(buf, sizeof(buf), fmt, ap); va_end(ap); strcat(buf, " ["); @@ -1824,16 +1767,42 @@ struct stat *sinfo; /* * Verify the file is not in NFS. - * - * Our current implementation and Sun OS 3.x use major device - * 255 for NFS files; Sun OS 4.x seems to use 130 (I have only - * determined this empirically -- DLC). Without a fstatfs() + */ + +#ifdef __SVR4 + { + struct statvfs sf; + + if (fstatvfs(handle, &sf) == -1) + return(-1); + return strcmp(sf.f_basetype, "nfs") != 0; + } +#elif defined(__NetBSD__) || defined(__OpenBSD__) + { + struct statfs sf; + if (fstatfs(handle, &sf) == -1) + return(-1); + return strcmp(sf.f_fstypename, "nfs") != 0; + } +#elif defined(__linux__) + { + struct statfs sf; + + if (fstatfs(handle, &sf) == -1) + return(-1); + return sf.f_type != NFS_SUPER_MAGIC; + } +#else + /* + * Sun OS 3.x use major device 255 for NFS files; + * Sun OS 4.x seems to use 130 (I have only determined + * this empirically -- DLC). Without a fstatfs() * system call, this will have to do for now. */ - if (major(sb.st_dev) == 255 || major(sb.st_dev) == 130) - return(0); - return(1); + return !(major(sb.st_dev) == 255 || major(sb.st_dev) == 130); + +#endif } /* diff --git a/usr.bin/sup/src/supmsg.c b/usr.bin/sup/src/supmsg.c index a962041917e..1f70d8d0159 100644 --- a/usr.bin/sup/src/supmsg.c +++ b/usr.bin/sup/src/supmsg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: supmsg.c,v 1.3 1996/07/31 11:11:33 niklas Exp $ */ +/* $OpenBSD: supmsg.c,v 1.4 1997/04/01 07:35:45 todd Exp $ */ /* * Copyright (c) 1992 Carnegie Mellon University @@ -31,52 +31,16 @@ * 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.3 1996/07/31 11:11:33 niklas - * Better use time_t instead of long when dealing with times - * - * Revision 1.2 1996/06/26 05:39:55 deraadt - * rcsid - * - * Revision 1.1 1995/12/16 11:47:00 deraadt - * add sup to the tree - * - * 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 - * Moved PFI definition under __STDC__ conditional since it - * is already defined in libc.h in this case. - * [92/09/01 mrt] - * - * Revision 2.3 92/08/11 12:08:12 mrt - * Added copyright - * [92/08/10 mrt] - * Brad's changes: Delinted, Incorporated updated variable - * argument list usage from old msgxfer.c - * [92/07/24 mrt] - * - * Revision 2.2 89/08/23 15:02:56 gm0w - * Created from separate message modules. - * [89/08/14 gm0w] * ********************************************************************** */ #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> -#if __STDC__ -#include <stdarg.h> -#else -#include <varargs.h> -#endif #include <libc.h> #include <c.h> -#include "sup.h" +#include "supcdefs.h" +#include "supextern.h" #define MSGSUBR #define MSGFILE #include "supmsg.h" @@ -89,6 +53,12 @@ extern int pgmversion; /* my program version */ extern char *scmver; /* scm version of partner */ extern int fspid; /* process id of fileserver */ +static int refuseone __P((TREE *, void *)); +static int listone __P((TREE *, void *)); +static int needone __P((TREE *, void *)); +static int denyone __P((TREE *, void *)); +static int writeone __P((TREE *, void *)); + int msgsignon () { register int x; @@ -277,8 +247,9 @@ int msglogack () */ extern TREE *refuseT; /* tree of files to refuse */ -static int refuseone (t) +static int refuseone (t, v) register TREE *t; +void *v; { return (writestring (t->Tname)); } @@ -299,7 +270,7 @@ int msgrefuse () if (x == SCMOK) x = readmend (); } else { x = writemsg (MSGREFUSE); - if (x == SCMOK) x = Tprocess (refuseT,refuseone); + if (x == SCMOK) x = Tprocess (refuseT,refuseone, NULL); if (x == SCMOK) x = writestring ((char *)NULL); if (x == SCMOK) x = writemend (); } @@ -312,8 +283,9 @@ int msgrefuse () extern TREE *listT; /* tree of files to list */ extern time_t scantime; /* time that collection was scanned */ -static int listone (t) +static int listone (t, v) register TREE *t; +void *v; { register int x; @@ -329,7 +301,7 @@ int msglist () register int x; if (server) { x = writemsg (MSGLIST); - if (x == SCMOK) x = Tprocess (listT,listone); + if (x == SCMOK) x = Tprocess (listT,listone, NULL); if (x == SCMOK) x = writestring ((char *)NULL); if (x == SCMOK) x = writeint ((int)scantime); if (x == SCMOK) x = writemend (); @@ -363,8 +335,9 @@ int msglist () */ extern TREE *needT; /* tree of files to need */ -static int needone (t) +static int needone (t, v) register TREE *t; +void *v; { register int x; x = writestring (t->Tname); @@ -393,7 +366,7 @@ int msgneed () if (x == SCMOK) x = readmend (); } else { x = writemsg (MSGNEED); - if (x == SCMOK) x = Tprocess (needT,needone); + if (x == SCMOK) x = Tprocess (needT,needone, NULL); if (x == SCMOK) x = writestring ((char *)NULL); if (x == SCMOK) x = writemend (); } @@ -405,8 +378,9 @@ int msgneed () */ extern TREE *denyT; /* tree of files to deny */ -static int denyone (t) +static int denyone (t, v) register TREE *t; +void *v; { return (writestring (t->Tname)); } @@ -416,7 +390,7 @@ int msgdeny () register int x; if (server) { x = writemsg (MSGDENY); - if (x == SCMOK) x = Tprocess (denyT,denyone); + if (x == SCMOK) x = Tprocess (denyT,denyone, NULL); if (x == SCMOK) x = writestring ((char *)NULL); if (x == SCMOK) x = writemend (); } else { @@ -449,33 +423,32 @@ int msgsend () */ extern TREE *upgradeT; /* pointer to file being upgraded */ -static int writeone (t) +static int writeone (t, v) register TREE *t; +void *v; { return (writestring (t->Tname)); } -#if __STDC__ -int msgrecv (PFI xferfile,...) +#ifdef __STDC__ +int msgrecv (int (*xferfile)(TREE *, va_list),...) #else /*VARARGS*//*ARGSUSED*/ int msgrecv (va_alist) va_dcl #endif { -#if !__STDC__ - typedef int (*PFI)(); - PFI xferfile; -#endif va_list args; register int x; register TREE *t = upgradeT; -#if __STDC__ +#ifdef __STDC__ va_start(args,xferfile); #else + int (*xferfile)(TREE *, void *); + va_start(args); - xferfile = va_arg(args, PFI); + xferfile = va_arg(args, int (*)(TREE *, void *)); #endif if (server) { x = writemsg (MSGRECV); @@ -494,9 +467,9 @@ va_dcl if (x == SCMOK) x = writestring (t->Tuser); if (x == SCMOK) x = writestring (t->Tgroup); if (x == SCMOK) x = writeint (t->Tmtime); - if (x == SCMOK) x = Tprocess (t->Tlink,writeone); + if (x == SCMOK) x = Tprocess (t->Tlink,writeone, NULL); if (x == SCMOK) x = writestring ((char *)NULL); - if (x == SCMOK) x = Tprocess (t->Texec,writeone); + if (x == SCMOK) x = Tprocess (t->Texec,writeone, NULL); if (x == SCMOK) x = writestring ((char *)NULL); if (x == SCMOK) x = (*xferfile) (t,args); if (x == SCMOK) x = writemend (); diff --git a/usr.bin/sup/src/supmsg.h b/usr.bin/sup/src/supmsg.h index 5c8c3578e6a..a1c07d99c0f 100644 --- a/usr.bin/sup/src/supmsg.h +++ b/usr.bin/sup/src/supmsg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: supmsg.h,v 1.3 1996/07/31 11:11:34 niklas Exp $ */ +/* $OpenBSD: supmsg.h,v 1.4 1997/04/01 07:35:47 todd Exp $ */ /* * Copyright (c) 1992 Carnegie Mellon University @@ -34,30 +34,6 @@ * Modified SUP to use gzip based compression when sending files * across the network to save BandWidth * - * $Log: supmsg.h,v $ - * Revision 1.3 1996/07/31 11:11:34 niklas - * Better use time_t instead of long when dealing with times - * - * Revision 1.2 1996/06/26 05:39:56 deraadt - * rcsid - * - * Revision 1.1 1995/12/16 11:47:01 deraadt - * add sup to the tree - * - * 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 - * Added copyright. - * [92/08/10 mrt] - * - * Revision 1.6 89/08/23 14:56:42 gm0w - * Changed MSGF to MSG constants. - * [89/08/23 gm0w] - * * 27-Dec-87 Glenn Marcy (gm0w) at Carnegie-Mellon University * Added crosspatch support. Removed nameserver support. * diff --git a/usr.bin/sup/src/supscan.c b/usr.bin/sup/src/supscan.c index a46c384c2cd..216e9042bb4 100644 --- a/usr.bin/sup/src/supscan.c +++ b/usr.bin/sup/src/supscan.c @@ -1,4 +1,4 @@ -/* $OpenBSD: supscan.c,v 1.4 1997/01/17 07:18:11 millert Exp $ */ +/* $OpenBSD: supscan.c,v 1.5 1997/04/01 07:35:49 todd Exp $ */ /* * Copyright (c) 1992 Carnegie Mellon University @@ -40,55 +40,6 @@ * ********************************************************************** * HISTORY - * $Log: supscan.c,v $ - * Revision 1.4 1997/01/17 07:18:11 millert - * more r?index -> strr?chr - * - * Revision 1.3 1996/07/31 11:11:35 niklas - * Better use time_t instead of long when dealing with times - * - * Revision 1.2 1996/06/26 05:39:56 deraadt - * rcsid - * - * Revision 1.1 1995/12/16 11:47:01 deraadt - * add sup to the tree - * - * Revision 1.1.1.1 1993/05/21 14:52:19 cgd - * initial import of CMU's SUP to NetBSD - * - * Revision 1.14 92/08/11 12:08:30 mrt - * Picked up Brad's deliniting and variable argument changes - * [92/08/10 mrt] - * - * Revision 1.13 92/02/08 18:04:44 dlc - * Once again revised localhost(). Do not use gethostbyname() at - * all, but assume that the host names in the coll.host file are at - * least a prefix of the fully qualified name. Modcoll (and related - * scripts) will maintain this fact. - * [92/02/08 dlc] - * - * Revision 1.12 91/08/17 23:35:31 dlc - * Changes to localhost() function: - * - Use host name in kernel for local host name; assume it is - * fully qualified. - * - If gethostbyname() of host to see if we are the repository - * fails, with TRY_AGAIN or NO_RECOVERY, then use the "host" - * parameter. Print a diagnostic in this case. - * [91/08/17 dlc] - * - * Revision 1.11 90/04/04 10:53:01 dlc - * Changed localhost to retry getting the local host name 4 times with - * 30 second sleep intervals before aborting; after 4 tries, things are - * probably too messed up for the supscan to do anything useful - * [90/04/04 dlc] - * - * Revision 1.10 89/08/03 19:49:33 mja - * Updated to use v*printf() in place of _doprnt(). - * [89/04/19 mja] - * - * Revision 1.9 89/06/18 14:41:37 gm0w - * Fixed up some notify messages of errors to use "SUP:" prefix. - * [89/06/18 gm0w] * * 13-May-88 Glenn Marcy (gm0w) at Carnegie-Mellon University * Changed goaway to longjmp back to top-level to scan next @@ -138,12 +89,8 @@ #endif #include <sys/time.h> #include <sys/types.h> -#include "sup.h" - -#ifdef lint -/*VARARGS1*//*ARGSUSED*/ -static void quit(status) {}; -#endif /* lint */ +#include "supcdefs.h" +#include "supextern.h" #define PGMVERSION 6 @@ -151,13 +98,13 @@ static void quit(status) {}; *** D A T A S T R U C T U R E S *** *******************************************/ -struct collstruct { /* one per collection to be upgraded */ +struct scan_collstruct { /* one per collection to be upgraded */ char *Cname; /* collection name */ char *Cbase; /* local base directory */ char *Cprefix; /* local collection pathname prefix */ - struct collstruct *Cnext; /* next collection */ + struct scan_collstruct *Cnext; /* next collection */ }; -typedef struct collstruct COLLECTION; +typedef struct scan_collstruct SCAN_COLLECTION; /********************************************* *** G L O B A L V A R I A B L E S *** @@ -165,12 +112,12 @@ typedef struct collstruct COLLECTION; int trace; /* -v flag */ -COLLECTION *firstC; /* collection list pointer */ +SCAN_COLLECTION *firstC; /* collection list pointer */ char *collname; /* collection name */ char *basedir; /* base directory name */ char *prefix; /* collection pathname prefix */ time_t lasttime = 0; /* time of last upgrade */ -time_t scantime; /* time of this scan */ +time_t scantime; /* time of this scan */ int newonly = FALSE; /* new files only */ jmp_buf sjbuf; /* jump location for errors */ @@ -178,15 +125,27 @@ TREELIST *listTL; /* list of all files specified by <coll>.list */ TREE *listT; /* final list of files in collection */ TREE *refuseT = NULL; /* list of all files specified by <coll>.list */ + +void usage __P((void)); +void init __P((int, char **)); +static SCAN_COLLECTION *getscancoll __P((char *, char *, char *)); +int localhost __P((char *)); +int main __P((int, char **)); + /************************************* *** M A I N R O U T I N E *** *************************************/ +int main (argc,argv) int argc; char **argv; { - register COLLECTION *c; + SCAN_COLLECTION *c; +#if __GNUC__ + /* Avoid longjmp clobbering */ + (void) &c; +#endif init (argc,argv); /* process arguments */ for (c = firstC; c; c = c->Cnext) { @@ -208,7 +167,7 @@ char **argv; ctime (&scantime)); (void) fflush (stdout); } - while (c = firstC) { + while ((c = firstC) != NULL) { firstC = firstC->Cnext; free (c->Cname); free (c->Cbase); @@ -222,6 +181,7 @@ char **argv; *** I N I T I A L I Z A T I O N *** *****************************************/ +void usage () { fprintf (stderr,"Usage: supscan [ -v ] collection [ basedir ]\n"); @@ -230,15 +190,16 @@ usage () exit (1); } +void init (argc,argv) int argc; char **argv; { char buf[STRINGLENGTH],fbuf[STRINGLENGTH],*p,*q; FILE *f; - COLLECTION **c, *getcoll(); + SCAN_COLLECTION **c; int fflag,sflag; - char *filename; + char *filename = NULL; trace = FALSE; fflag = FALSE; @@ -285,7 +246,7 @@ char **argv; collname = nxtarg (&p," \t="); p = skipover (p," \t="); if (!localhost (p)) continue; - *c = getcoll(filename,salloc (collname), + *c = getscancoll(filename,salloc (collname), (char *)NULL); if (*c) c = &((*c)->Cnext); } @@ -297,13 +258,13 @@ char **argv; c = &firstC; if ((f = fopen (filename,"r")) == NULL) quit (1,"supscan: Unable to open %s\n",filename); - while (p = fgets (buf,STRINGLENGTH,f)) { + while ((p = fgets (buf,STRINGLENGTH,f)) != NULL) { q = strchr (p,'\n'); if (q) *q = 0; if (strchr ("#;:",*p)) continue; q = nxtarg (&p," \t="); p = skipover (p," \t="); - *c = getcoll(filename,salloc (q),salloc (p)); + *c = getscancoll(filename,salloc (q),salloc (p)); if (*c) c = &((*c)->Cnext); } (void) fclose (f); @@ -311,21 +272,21 @@ char **argv; } if (argc < 2 || argc > 3) usage (); - firstC = getcoll(filename,salloc (argv[1]), + firstC = getscancoll(filename,salloc (argv[1]), argc > 2 ? salloc (argv[2]) : (char *)NULL); } -COLLECTION * -getcoll(filename, collname, basedir) +static SCAN_COLLECTION * +getscancoll(filename, collname, basedir) register char *filename,*collname,*basedir; { char buf[STRINGLENGTH],*p,*q; FILE *f; - COLLECTION *c; + SCAN_COLLECTION *c; if (basedir == NULL) { - if (f = fopen (filename,"r")) { - while (p = fgets (buf,STRINGLENGTH,f)) { + if ((f = fopen (filename,"r")) != NULL) { + while ((p = fgets (buf,STRINGLENGTH,f)) != NULL) { q = strchr (p,'\n'); if (q) *q = 0; if (strchr ("#;:",*p)) continue; @@ -350,8 +311,8 @@ register char *filename,*collname,*basedir; } prefix = NULL; (void) sprintf (buf,FILEPREFIX,collname); - if (f = fopen (buf,"r")) { - while (p = fgets (buf,STRINGLENGTH,f)) { + if ((f = fopen (buf,"r")) != NULL) { + while ((p = fgets (buf,STRINGLENGTH,f)) != NULL) { q = strchr (p,'\n'); if (q) *q = 0; if (strchr ("#;:",*p)) continue; @@ -365,7 +326,7 @@ register char *filename,*collname,*basedir; } (void) fclose (f); } - if ((c = (COLLECTION *) malloc (sizeof(COLLECTION))) == NULL) + if ((c = (SCAN_COLLECTION *) malloc (sizeof(SCAN_COLLECTION))) == NULL) quit (1,"supscan: can't malloc collection structure\n"); c->Cname = collname; c->Cbase = basedir; @@ -373,7 +334,9 @@ register char *filename,*collname,*basedir; c->Cnext = NULL; return (c); } -#if __STDC__ + +void +#ifdef __STDC__ goaway (char *fmt,...) #else /*VARARGS*//*ARGSUSED*/ @@ -381,14 +344,13 @@ goaway (va_alist) va_dcl #endif { -#if !__STDC__ - char *fmt; -#endif va_list ap; -#if __STDC__ +#ifdef __STDC__ va_start(ap,fmt); #else + char *fmt; + va_start(ap); fmt = va_arg(ap,char *); #endif diff --git a/usr.bin/sup/src/supservers.8 b/usr.bin/sup/src/supservers.8 index 102034630cc..99cd0677651 100644 --- a/usr.bin/sup/src/supservers.8 +++ b/usr.bin/sup/src/supservers.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: supservers.8,v 1.2 1996/06/26 05:39:57 deraadt Exp $ +.\" $OpenBSD: supservers.8,v 1.3 1997/04/01 07:35:50 todd Exp $ .\" .\" Copyright (c) 1992 Carnegie Mellon University .\" All Rights Reserved. @@ -24,15 +24,6 @@ .\" the rights to redistribute these changes. .\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .\" HISTORY -.\" $Log: supservers.8,v $ -.\" Revision 1.2 1996/06/26 05:39:57 deraadt -.\" rcsid -.\" -.\" Revision 1.1 1995/12/16 11:47:02 deraadt -.\" add sup to the tree -.\" -.\" Revision 1.1.1.1 1993/05/21 14:52:16 cgd -.\" initial import of CMU's SUP to NetBSD .\" .\" Revision 1.3 92/08/11 12:08:50 mrt .\" Documented -C switch diff --git a/usr.bin/sup/src/sysent.h b/usr.bin/sup/src/sysent.h index 7ec9cccaa03..f34fbbaa514 100644 --- a/usr.bin/sup/src/sysent.h +++ b/usr.bin/sup/src/sysent.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sysent.h,v 1.2 1996/06/26 05:39:57 deraadt Exp $ */ +/* $OpenBSD: sysent.h,v 1.3 1997/04/01 07:35:52 todd Exp $ */ /* * Copyright (c) 1991 Carnegie Mellon University @@ -26,32 +26,6 @@ */ /* ********************************************************************** - * HISTORY - * $Log: sysent.h,v $ - * Revision 1.2 1996/06/26 05:39:57 deraadt - * rcsid - * - * Revision 1.1 1995/12/16 11:47:02 deraadt - * add sup to the tree - * - * Revision 1.1.1.1 1993/05/21 14:52:19 cgd - * initial import of CMU's SUP to NetBSD - * - * Revision 2.4 89/12/05 16:02:00 mrt - * Removed include of sys/features.h as it is no longer - * exported or needed. - * [89/12/05 mrt] - * - * Revision 2.3 89/01/20 15:44:24 gm0w - * Added externs to the non-STDC case for functions that do not - * have int return values. - * [88/12/17 gm0w] - * - * Revision 2.2 88/12/14 23:35:52 mja - * Created. - * [88/01/06 jjk] - * - ********************************************************************** */ #ifndef _SYSENT_H_ diff --git a/usr.bin/sup/src/vprintf.c b/usr.bin/sup/src/vprintf.c index f7b84d9ec2c..4ed153efa47 100644 --- a/usr.bin/sup/src/vprintf.c +++ b/usr.bin/sup/src/vprintf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vprintf.c,v 1.2 1996/06/26 05:39:58 deraadt Exp $ */ +/* $OpenBSD: vprintf.c,v 1.3 1997/04/01 07:35:53 todd Exp $ */ /* * Copyright (c) 1991 Carnegie Mellon University @@ -28,44 +28,17 @@ * varargs versions of printf routines * ********************************************************************** - * HISTORY - * $Log: vprintf.c,v $ - * Revision 1.2 1996/06/26 05:39:58 deraadt - * rcsid - * - * Revision 1.1 1995/12/16 11:47:03 deraadt - * add sup to the tree - * - * Revision 1.1.1.1 1993/05/21 14:52:19 cgd - * initial import of CMU's SUP to NetBSD - * - * Revision 2.5 89/09/08 18:15:55 mbj - * Use _doprnt() for the Multimax (an "old" architecture). - * [89/09/08 mbj] - * - * Revision 2.4 89/08/03 14:40:10 mja - * Add vsnprintf() routine. - * [89/07/12 mja] - * - * Terminate vsprintf() string with null byte. - * [89/04/21 mja] - * - * Change to use new hidden name for _doprnt on MIPS. - * [89/04/18 mja] - * - * Revision 2.3 89/06/10 14:13:43 gm0w - * Added putc of NULL byte to vsprintf. - * [89/06/10 gm0w] - * - * Revision 2.2 88/12/13 13:53:17 gm0w - * From Brad White. - * [88/12/13 gm0w] - ************************************************************ */ #include <stdio.h> #include <varargs.h> +#ifdef _IOSTRG +#define STRFLAG (_IOSTRG|_IOWRT) /* no _IOWRT: avoid stdio bug */ +#else +#define STRFLAG (_IOREAD) /* XXX: Assume svr4 stdio */ +#endif + #ifdef DOPRINT_VA /* * system provides _doprnt_va routine @@ -106,7 +79,7 @@ vsprintf(s, fmt, args) { FILE fakebuf; - fakebuf._flag = _IOSTRG+_IOWRT; /* no _IOWRT: avoid stdio bug */ + fakebuf._flag = STRFLAG; fakebuf._ptr = s; fakebuf._cnt = 32767; _doprnt(fmt, args, &fakebuf); @@ -123,9 +96,10 @@ vsnprintf(s, n, fmt, args) { FILE fakebuf; - fakebuf._flag = _IOSTRG+_IOWRT; /* no _IOWRT: avoid stdio bug */ + fakebuf._flag = STRFLAG; fakebuf._ptr = s; fakebuf._cnt = n-1; + fakebuf._file = -1; _doprnt(fmt, args, &fakebuf); fakebuf._cnt++; putc('\0', &fakebuf); |