-/* $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
* Rewritten for VAX.
*
*/
+#include "supcdefs.h"
+#include "supextern.h"
unsigned int atoo(ap)
char *ap;
-/* $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
* 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;
*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 */
*itoa(&unk[sizeof(unkmsg)-1],cod) = '\0';
return(unk);
+#else
+ return strerror(cod);
+#endif
}
-/* $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
#include <ctype.h>
#include <libc.h>
#include <setjmp.h>
+#include <stdlib.h>
+#include <unistd.h>
static jmp_buf sjbuf;
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;
}
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;
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;
#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;
case '[':
ok = 0;
lc = 077777;
- while (cc = *p++) {
+ while ((cc = *p++) != 0) {
if (cc == ']') {
if (ok) break;
return (0);
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, "");
}
BUFFER[bufcnt++] = ep;
while (*s1) *ep++ = *s1++;
- while (*ep++ = *s2++);
+ while ((*ep++ = *s2++) != '\0')
+ continue;
}
static int addpath(c)
static int gethdir(home)
char *home;
{
- struct passwd *getpwnam();
register struct passwd *pp = getpwnam(home);
if (pp == 0)
-/* $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
*/
#include <stdio.h>
-int filecopy();
+#include "supcdefs.h"
+#include "supextern.h"
int ffilecopy (here,there)
FILE *here, *there;
-/* $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
*/
#define BUFFERSIZE 10240
+#include "supcdefs.h"
+#include "supextern.h"
int filecopy (here,there)
int here,there;
-/* $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
/*
**********************************************************************
* 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.
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*);
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();
/* 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 */
-/* $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
* 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.
#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;
{
opened++;
}
-#if __STDC__
+void
+#ifdef __STDC__
logquit(int retval,char *fmt,...)
#else
/*VARARGS*//*ARGSUSED*/
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 *);
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*/
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
(void) fflush (stderr);
}
-#if __STDC__
+void
+#ifdef __STDC__
loginfo(char *fmt,...)
#else
/*VARARGS*//*ARGSUSED*/
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
-/* $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
*/
/**********************************************************************
* 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]
*
*/
/*
*/
#include <libc.h>
-#include "sup.h"
+#include "supcdefs.h"
+#include "supextern.h"
#include "supmsg.h"
/*********************************************
-/* $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
*
* 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;
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 */
-/* $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
* 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;
{
/* 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 */
-/* $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
*
**********************************************************************
* 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);
-/* $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
*
**********************************************************************
* 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.
#include <signal.h>
#include <fcntl.h>
#include <sys/wait.h>
-#include <varargs.h>
+
+#include "supcdefs.h"
+#include "supextern.h"
#ifndef __STDC__
#ifndef const
#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);
}
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);
}
{
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 */
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));
}
/*
-/* $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
*
**********************************************************************
*/
-char *malloc();
+#include "supcdefs.h"
+#include "supextern.h"
+
char *salloc(p)
char *p;
-/* $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
*
**********************************************************************
* 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.
#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 ***
/*************************************************
*** 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;
{
return (nextrel);
}
+int
getrelease (release)
char *release;
{
return (TRUE);
}
+void
makescanlists ()
{
TREELIST *tl;
(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;
makescan ((char *)NULL,(char *)NULL);
}
-static
-scanone (t)
+static int
+scanone (t, v)
register TREE *t;
+void *v;
{
register TREE *newt;
return (SCMOK);
}
+void
getscanlists ()
{
TREELIST *tl,*stl;
}
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;
{
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);
}
}
-static
+static void
doscan (listfile)
char *listfile;
{
char buf[STRINGLENGTH];
- int listone ();
upgT = NULL;
flagsT = NULL;
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);
Tfree (&rsymT);
}
-static
+static void
readlistfile (fname)
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;
(void) fclose (f);
}
-static
+static void
expTinsert (p,t,flags,exec)
char *p;
TREE **t;
}
}
-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) {
listname (fullname,&statbuf);
}
-static
+static void
listname (name,st)
register char *name;
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;
}
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;
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;
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;
{
(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);
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;
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;
*** 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];
}
}
-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;
(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;
{
-/* $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
* 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.
#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>
#else
#include <varargs.h>
#endif
-#include "sup.h"
+#include "supcdefs.h"
+#include "supextern.h"
#ifndef INADDR_NONE
#define INADDR_NONE 0xffffffff /* -1 return */
#endif
extern int errno;
-static char *myhost ();
char scmversion[] = "4.3 BSD";
+extern int silent;
/*************************
*** M A C R O S ***
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;
{
return (SCMOK);
}
+int
service ()
{
struct sockaddr_in from;
return (SCMOK);
}
+int
serviceprep () /* kill temp socket in daemon */
{
if (sock >= 0) {
return (SCMOK);
}
+int
servicekill () /* kill net file in daemon's parent */
{
if (netfile >= 0) {
return (SCMOK);
}
+int
serviceend () /* kill net file after use in daemon */
{
if (netfile >= 0) {
*** F O R C L I E N T ***
***************************************************/
-dobackoff (t,b)
+int dobackoff (t,b)
int *t,*b;
{
struct timeval tt;
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;
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));
return (SCMOK);
}
+int
requestend () /* end connection to server */
{
(void) readflush ();
return (0);
}
-#if __STDC__
+#ifdef __STDC__
int scmerr (int errno,char *fmt,...)
#else
/*VARARGS*//*ARGSUSED*/
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)
-/* $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
*
**********************************************************************
* 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.
#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;
*** 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 */
} 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;
return (SCMOK);
}
-static
+static int
writeblock (count,data) /* write data block */
int count;
char *data;
return (x);
}
+int
writemsg (msg) /* write start of message */
int msg;
{
return (writedata(sizeof(int),(char *)&x));
}
+int
writemend () /* write end of message */
{
register int count;
return (writedata (count, data));
}
+int
writeint (i) /* write int as data block */
int i;
{
return (writeblock(sizeof(int),(char *)&x));
}
+int
writestring (p) /* write string as data block */
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;
return (x);
}
+int
writemnull (msg) /* write message with no data */
int msg;
{
return (x);
}
+int
writemint (msg,i) /* write message of one int */
int msg,i;
{
return (x);
}
+int
writemstr (msg,p) /* write message of one string */
int msg;
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;
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 */
{
return (SCMEOF);
}
+int
readmend ()
{
register int x;
return (x);
}
+int
readskip () /* skip over one input block */
{
register int x;
return (SCMOK);
}
+int
readfile (f) /* read data block into open file */
int f;
{
return (x);
}
+int
readmnull (msg) /* read null message */
int msg;
{
return (x);
}
+int
readmint (msg,buf) /* read int message */
int msg,*buf;
{
*** C R O S S P A T C H ***
**********************************/
+void
crosspatch ()
{
fd_set ibits, obits, xbits;
-/* $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
* 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;
}
char *skipover (string,charset)
-unsigned char *string, *charset;
+char *string, *charset;
{
register unsigned char *setp,*strp;
-/* $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
*
**********************************************************************
* 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.
#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;
{
return(th);
}
-Static
+Static void
Tbalance (t)
TREE **t;
{
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++;
/* 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);
}
-/* $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
* 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.
*
#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
-/* $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
* 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.
#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>
#include "supmsg.h"
extern int errno;
-extern uid_t getuid();
-extern gid_t getgid();
-
extern int PGMVERSION;
/*******************************************
#define CFKEEP 01000
#define CFURELSUF 02000
#define CFCOMPRESS 04000
+#define CFSILENT 10000
/*************************
*** M A C R O S ***
-/* $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
* 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).
*
#define SYS_rpause (-5)
#endif
#endif
+#include "supextern.h"
/*********************************************
*** G L O B A L V A R I A B L E S ***
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
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 */
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;
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 */
(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);
#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;
case 'X':
xpatchflag = TRUE;
break;
+ case 'S':
+ silent = TRUE;
+ break;
case 's':
sysflag = TRUE;
break;
}
}
-char *init (argc,argv)
+static char *init (argc,argv)
int argc;
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
int (*oldsigsys)();
#endif
#endif /* MACH */
- char *fmttime();
sysflag = FALSE; /* not system upgrade */
timeflag = FALSE; /* don't print times */
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;
}
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;
}
}
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);
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)
-/* $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
* 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.
*
*/
#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 */
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) {
}
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) {
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++;
* 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;
/*** 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)
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;
(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);
}
* 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;
(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);
(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);
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)
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;
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;
* 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 */
}
/* prepare the target, if necessary */
-prepare (name,mode,newp,statp)
+int prepare (name,mode,newp,statp)
char *name;
int mode,*newp;
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;
}
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);
}
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);
}
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);
}
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);
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 # */
if (x != SCMOK)
goaway ("Can't skip file transfer");
}
- return (TRUE);
+ if (true)
+ return (TRUE);
}
if (fromf >= 0) { /* read file */
x = filecopy (fromf,tof);
/*** Finish connection with file server ***/
-finishup (x)
+void finishup (x)
int x;
{
char tname[STRINGLENGTH],fname[STRINGLENGTH];
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);
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*/
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);
if (!dontjump)
longjmp (sjbuf,TRUE);
}
-#if __STDC__
+
+void
+#ifdef __STDC__
goaway (char *fmt,...)
#else
/*VARARGS*//*ARGSUSED*/
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;
-/* $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
* 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.
**********************************************************************
*/
-#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 */
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);
return (((len&HASHMASK)<<HASHBITS)|(((int)c)&HASHMASK));
}
-static
+static void
Linsert (table,name,number)
LIST **table;
char *name;
return (l);
}
-ugconvert (uname,gname,uid,gid,mode)
+void ugconvert (uname,gname,uid,gid,mode)
char *uname,*gname;
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;
*** 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*/
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
(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);
}
}
-/* $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
* 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.
*/
#include "supcdefs.h"
+#include "supextern.h"
extern COLLECTION *firstC; /* collection list pointer */
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");
-/* $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
* 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.
*
*/
#include "supcdefs.h"
+#include "supextern.h"
#ifdef lint
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");
}
}
-parsecoll(c,collname,args)
+int parsecoll(c,collname,args)
COLLECTION *c;
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);
int
putwhen(fname, tstamp)
char *fname;
- long tstamp;
+ time_t tstamp;
{
FILE *fp;
if ((fp = fopen(fname, "w")) == NULL)
-/* $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
/*
**********************************************************************
* 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]
--- /dev/null
+/* $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));
-/* $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
* 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
* 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.
*
#include <setjmp.h>
#include <pwd.h>
#include <grp.h>
+#include <fcntl.h>
#if __STDC__
#include <stdarg.h>
#else
#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
#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;
/*
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 */
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 */
(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 ();
(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 ();
}
(void) servicekill (); /* parent */
if (pid > 0) nchildren++;
- (void) sigsetmask(signalmask);
+ (void) sigprocmask(SIG_SETMASK, &oset, NULL);
}
}
chldsig(snum)
int snum;
{
- union wait w;
+ int w;
while (wait3((int *) &w, WNOHANG, (struct rusage *)0) > 0) {
if (nchildren) nchildren--;
*** 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;
argv++;
while (clienthost == NULL && argc > 0 && argv[0][0] == '-') {
switch (argv[0][1]) {
+ case 'S':
+ silent = TRUE;
+ break;
case 'l':
live = TRUE;
break;
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);
*** A N S W E R R E Q U E S T ***
*****************************************/
+void
answer ()
{
time_t starttime;
lockfd = -1;
starttime = time ((time_t *)NULL);
if (!setjmp (sjbuf)) {
- signon ();
- setup ();
+ srvsignon ();
+ srvsetup ();
docrypt ();
- login ();
+ srvlogin ();
if (xpatch) {
int fd;
listfiles ();
sendfiles ();
}
- finishup (starttime);
+ srvfinishup (starttime);
if (collname) free (collname);
if (basedir) free (basedir);
if (prefix) free (prefix);
*** S I G N O N C L I E N T ***
*****************************************/
-signon ()
+void
+srvsignon ()
{
register int x;
*** 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;
}
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);
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;
(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;
(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;
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;
}
/* 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) {
}
lockfd = x;
}
+#endif
setupack = FSETUPOK;
x = msgsetupack ();
if (x != SCMOK) goaway ("Error sending setup reply to client");
}
+void
/** Test data encryption **/
docrypt ()
{
char buf[STRINGLENGTH];
register FILE *f;
struct stat sbuf;
- extern int link_nofollow(), local_file();
if (!xpatch) {
(void) sprintf (buf,FILECRYPT,collname);
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
*** 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 ();
*** M A K E N A M E L I S T ***
*****************************************/
+void
listfiles ()
{
- int denyone();
register int x;
refuseT = NULL;
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;
*** S E N D F I L E S ***
*********************************/
+void
sendfiles ()
{
- int sendone(),senddir(),sendfile();
register TREELIST *tl;
register int x;
}
}
#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)
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 */
#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);
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);
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);
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);
}
*** 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;
*** 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);
return (h);
}
+void
Hinsert (table,num1,num2,name,tree)
HASH **table;
int num1,num2;
char *namep,*passwordp;
int fileuid,filegid;
{
- char *okpassword ();
char *group,*account,*pswdp;
struct passwd *pwd;
struct group *grp;
#if CMUCS
int *grps;
#endif /* CMUCS */
- char *p;
+ char *p = NULL;
if (namep == NULL) {
pwd = getpwuid (fileuid);
return (NULL);
}
-#if __STDC__
+void
+#ifdef __STDC__
goaway (char *fmt,...)
#else
/*VARARGS*//*ARGSUSED*/
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, " [");
/*
* 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
}
/*
-/* $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
* 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"
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;
*/
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));
}
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 ();
}
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;
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 ();
*/
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);
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 ();
}
*/
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));
}
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 {
*/
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);
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 ();
-/* $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
* 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.
*
-/* $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
*
**********************************************************************
* 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
#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
*** 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 ***
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 */
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) {
ctime (&scantime));
(void) fflush (stdout);
}
- while (c = firstC) {
+ while ((c = firstC) != NULL) {
firstC = firstC->Cnext;
free (c->Cname);
free (c->Cbase);
*** I N I T I A L I Z A T I O N ***
*****************************************/
+void
usage ()
{
fprintf (stderr,"Usage: supscan [ -v ] collection [ basedir ]\n");
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;
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);
}
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);
}
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;
}
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;
}
(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;
c->Cnext = NULL;
return (c);
}
-#if __STDC__
+
+void
+#ifdef __STDC__
goaway (char *fmt,...)
#else
/*VARARGS*//*ARGSUSED*/
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
-.\" $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.
.\" 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
-/* $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
* to redistribute these changes.
*/
/*
- **********************************************************************
- * 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]
- *
**********************************************************************
*/
-/* $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
* 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
{
FILE fakebuf;
- fakebuf._flag = _IOSTRG+_IOWRT; /* no _IOWRT: avoid stdio bug */
+ fakebuf._flag = STRFLAG;
fakebuf._ptr = s;
fakebuf._cnt = 32767;
_doprnt(fmt, args, &fakebuf);
{
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);