update to newest rdist from berkeley (via uunet). No security fixes, but
general cleanup.
This commit is contained in:
parent
080c5b9220
commit
a5bfdf7812
|
@ -1,5 +1,5 @@
|
|||
# from: @(#)Makefile 5.11 (Berkeley) 3/12/91
|
||||
# $Id: Makefile,v 1.2 1993/07/31 15:17:49 mycroft Exp $
|
||||
# $Id: Makefile,v 1.3 1994/03/07 05:05:16 cgd Exp $
|
||||
|
||||
PROG= rdist
|
||||
CFLAGS+=-I${.CURDIR}
|
||||
|
@ -9,4 +9,7 @@ BINOWN= root
|
|||
BINMODE=4555
|
||||
CLEANFILES=y.tab.h
|
||||
|
||||
LDADD= -lcompat
|
||||
DPADD= ${LIBCOMPAT}
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 1983 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 1983, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -30,23 +30,26 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)defs.h 5.9 (Berkeley) 8/27/90
|
||||
* $Id: defs.h,v 1.4 1993/12/04 02:11:23 jtc Exp $
|
||||
* from: @(#)defs.h 8.1 (Berkeley) 6/9/93
|
||||
* $Id: defs.h,v 1.5 1994/03/07 05:05:20 cgd Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/dir.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/file.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <dirent.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <pwd.h>
|
||||
#include <grp.h>
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "pathnames.h"
|
||||
|
||||
/*
|
||||
|
@ -148,11 +151,31 @@ extern struct passwd *pw; /* pointer to static area used by getpwent */
|
|||
extern struct group *gr; /* pointer to static area used by getgrent */
|
||||
extern char host[]; /* host name of master copy */
|
||||
extern char buf[]; /* general purpose buffer */
|
||||
extern int errno; /* system error number */
|
||||
|
||||
char *makestr();
|
||||
struct namelist *makenl();
|
||||
struct subcmd *makesubcmd();
|
||||
struct namelist *lookup();
|
||||
struct namelist *expand();
|
||||
char *exptilde();
|
||||
int any __P((int, char *));
|
||||
char *colon __P((char *));
|
||||
void cleanup __P((int));
|
||||
void define __P((char *));
|
||||
void docmds __P((char **, int, char **));
|
||||
void error __P((const char *, ...));
|
||||
int except __P((char *));
|
||||
struct namelist *
|
||||
expand __P((struct namelist *, int));
|
||||
char *exptilde __P((char [], char *));
|
||||
void fatal __P((const char *, ...));
|
||||
int inlist __P((struct namelist *, char *));
|
||||
void insert __P((char *,
|
||||
struct namelist *, struct namelist *, struct subcmd *));
|
||||
void install __P((char *, char *, int, int));
|
||||
void log __P((FILE *, const char *, ...));
|
||||
struct namelist *
|
||||
lookup __P((char *, int, struct namelist *));
|
||||
void lostconn __P((int));
|
||||
struct namelist *
|
||||
makenl __P((char *));
|
||||
struct subcmd *
|
||||
makesubcmd __P((int));
|
||||
void prnames __P((struct namelist *));
|
||||
void server __P((void));
|
||||
void yyerror __P((char *));
|
||||
int yyparse __P((void));
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 1983 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 1983, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -32,8 +32,8 @@
|
|||
*/
|
||||
|
||||
#ifndef lint
|
||||
/*static char sccsid[] = "from: @(#)docmd.c 5.8 (Berkeley) 3/1/91";*/
|
||||
static char rcsid[] = "$Id: docmd.c,v 1.5 1994/01/23 06:31:35 cgd Exp $";
|
||||
/* from: static char sccsid[] = "@(#)docmd.c 8.1 (Berkeley) 6/9/93"; */
|
||||
static char *rcsid = "$Id: docmd.c,v 1.6 1994/03/07 05:05:26 cgd Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include "defs.h"
|
||||
|
@ -44,11 +44,21 @@ FILE *lfp; /* log file for recording files updated */
|
|||
struct subcmd *subcmds; /* list of sub-commands for current cmd */
|
||||
jmp_buf env;
|
||||
|
||||
void cleanup(), lostconn();
|
||||
static int makeconn __P((char *));
|
||||
static int okname __P((char *));
|
||||
static void closeconn __P((void));
|
||||
static void cmptime __P((char *));
|
||||
static void doarrow __P((char **,
|
||||
struct namelist *, char *, struct subcmd *));
|
||||
static void dodcolon __P((char **,
|
||||
struct namelist *, char *, struct subcmd *));
|
||||
static void notify __P((char *, char *, struct namelist *, time_t));
|
||||
static void rcmptime __P((struct stat *));
|
||||
|
||||
/*
|
||||
* Do the commands in cmds (initialized by yyparse).
|
||||
*/
|
||||
void
|
||||
docmds(dhosts, argc, argv)
|
||||
char **dhosts;
|
||||
int argc;
|
||||
|
@ -104,6 +114,7 @@ docmds(dhosts, argc, argv)
|
|||
/*
|
||||
* Process commands for sending files to other machines.
|
||||
*/
|
||||
static void
|
||||
doarrow(filev, files, rhost, cmds)
|
||||
char **filev;
|
||||
struct namelist *files;
|
||||
|
@ -184,6 +195,7 @@ done:
|
|||
/*
|
||||
* Create a connection to the rdist server on the machine rhost.
|
||||
*/
|
||||
static int
|
||||
makeconn(rhost)
|
||||
char *rhost;
|
||||
{
|
||||
|
@ -243,11 +255,11 @@ makeconn(rhost)
|
|||
return(0);
|
||||
cp = buf;
|
||||
if (read(rem, cp, 1) != 1)
|
||||
lostconn();
|
||||
lostconn(0);
|
||||
if (*cp == 'V') {
|
||||
do {
|
||||
if (read(rem, cp, 1) != 1)
|
||||
lostconn();
|
||||
lostconn(0);
|
||||
} while (*cp++ != '\n' && cp < &buf[BUFSIZ]);
|
||||
*--cp = '\0';
|
||||
cp = buf;
|
||||
|
@ -257,8 +269,13 @@ makeconn(rhost)
|
|||
if (*cp == '\0' && n == VERSION)
|
||||
return(1);
|
||||
error("connection failed: version numbers don't match (local %d, remote %d)\n", VERSION, n);
|
||||
} else
|
||||
} else {
|
||||
error("connection failed: version numbers don't match\n");
|
||||
error("got unexpected input:");
|
||||
do {
|
||||
error("%c", *cp);
|
||||
} while (*cp != '\n' && read(rem, cp, 1) == 1);
|
||||
}
|
||||
closeconn();
|
||||
return(0);
|
||||
}
|
||||
|
@ -266,6 +283,7 @@ makeconn(rhost)
|
|||
/*
|
||||
* Signal end of previous connection.
|
||||
*/
|
||||
static void
|
||||
closeconn()
|
||||
{
|
||||
if (debug)
|
||||
|
@ -279,14 +297,16 @@ closeconn()
|
|||
}
|
||||
|
||||
void
|
||||
lostconn()
|
||||
lostconn(signo)
|
||||
int signo;
|
||||
{
|
||||
if (iamremote)
|
||||
cleanup();
|
||||
cleanup(0);
|
||||
log(lfp, "rdist: lost connection\n");
|
||||
longjmp(env, 1);
|
||||
}
|
||||
|
||||
static int
|
||||
okname(name)
|
||||
register char *name;
|
||||
{
|
||||
|
@ -314,6 +334,7 @@ extern char target[], *tp;
|
|||
/*
|
||||
* Process commands for comparing files to time stamp files.
|
||||
*/
|
||||
static void
|
||||
dodcolon(filev, files, stamp, cmds)
|
||||
char **filev;
|
||||
struct namelist *files;
|
||||
|
@ -339,7 +360,7 @@ dodcolon(filev, files, stamp, cmds)
|
|||
return;
|
||||
}
|
||||
if (debug)
|
||||
printf("%s: %d\n", stamp, stb.st_mtime);
|
||||
printf("%s: %ld\n", stamp, stb.st_mtime);
|
||||
|
||||
subcmds = cmds;
|
||||
lastmod = stb.st_mtime;
|
||||
|
@ -379,6 +400,7 @@ dodcolon(filev, files, stamp, cmds)
|
|||
/*
|
||||
* Compare the mtime of file to the list of time stamps.
|
||||
*/
|
||||
static void
|
||||
cmptime(name)
|
||||
char *name;
|
||||
{
|
||||
|
@ -427,11 +449,12 @@ cmptime(name)
|
|||
log(tfp, "new: %s\n", name);
|
||||
}
|
||||
|
||||
static void
|
||||
rcmptime(st)
|
||||
struct stat *st;
|
||||
{
|
||||
register DIR *d;
|
||||
register struct dirent *dp;
|
||||
register struct direct *dp;
|
||||
register char *cp;
|
||||
char *otp;
|
||||
int len;
|
||||
|
@ -470,14 +493,15 @@ rcmptime(st)
|
|||
* rhost == NULL if we are mailing a list of changes compared to at time
|
||||
* stamp file.
|
||||
*/
|
||||
static void
|
||||
notify(file, rhost, to, lmod)
|
||||
char *file, *rhost;
|
||||
register struct namelist *to;
|
||||
time_t lmod;
|
||||
{
|
||||
register int fd, len;
|
||||
FILE *pf, *popen();
|
||||
struct stat stb;
|
||||
FILE *pf;
|
||||
|
||||
if ((options & VERIFY) || to == NULL)
|
||||
return;
|
||||
|
@ -547,6 +571,7 @@ notify(file, rhost, to, lmod)
|
|||
/*
|
||||
* Return true if name is in the list.
|
||||
*/
|
||||
int
|
||||
inlist(list, file)
|
||||
struct namelist *list;
|
||||
char *file;
|
||||
|
@ -562,6 +587,7 @@ inlist(list, file)
|
|||
/*
|
||||
* Return TRUE if file is in the exception list.
|
||||
*/
|
||||
int
|
||||
except(file)
|
||||
char *file;
|
||||
{
|
||||
|
@ -580,7 +606,8 @@ except(file)
|
|||
return(1);
|
||||
continue;
|
||||
}
|
||||
if (regexec(regcomp(nl->n_name), file) > 0)
|
||||
re_comp(nl->n_name);
|
||||
if (re_exec(file) > 0)
|
||||
return(1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 1983 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 1983, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -32,8 +32,8 @@
|
|||
*/
|
||||
|
||||
#ifndef lint
|
||||
/*static char sccsid[] = "from: @(#)expand.c 5.6 (Berkeley) 6/1/90";*/
|
||||
static char rcsid[] = "$Id: expand.c,v 1.4 1993/12/04 02:11:33 jtc Exp $";
|
||||
/* from: static char sccsid[] = "@(#)expand.c 8.1 (Berkeley) 6/9/93"; */
|
||||
static char *rcsid = "$Id: expand.c,v 1.5 1994/03/07 05:05:28 cgd Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include "defs.h"
|
||||
|
@ -58,11 +58,20 @@ int expany; /* any expansions done? */
|
|||
char *entp;
|
||||
char **sortbase;
|
||||
|
||||
static int argcmp();
|
||||
|
||||
#define sort() qsort((char *)sortbase, &eargv[eargc] - sortbase, \
|
||||
sizeof(*sortbase), argcmp), sortbase = &eargv[eargc]
|
||||
|
||||
static void Cat __P((char *, char *));
|
||||
static void addpath __P((int));
|
||||
static int amatch __P((char *, char *));
|
||||
static int argcmp __P((const void *, const void *));
|
||||
static int execbrc __P((char *, char *));
|
||||
static void expsh __P((char *));
|
||||
static void expstr __P((char *));
|
||||
static int match __P((char *, char *));
|
||||
static void matchdir __P((char *));
|
||||
static int smatch __P((char *, char *));
|
||||
|
||||
/*
|
||||
* Take a list of names and expand any macros, etc.
|
||||
* wh = E_VARS if expanding variables.
|
||||
|
@ -131,6 +140,7 @@ expand(list, wh)
|
|||
return(list);
|
||||
}
|
||||
|
||||
static void
|
||||
expstr(s)
|
||||
char *s;
|
||||
{
|
||||
|
@ -231,18 +241,19 @@ expstr(s)
|
|||
sort();
|
||||
}
|
||||
|
||||
static
|
||||
static int
|
||||
argcmp(a1, a2)
|
||||
char **a1, **a2;
|
||||
const void *a1, *a2;
|
||||
{
|
||||
|
||||
return (strcmp(*a1, *a2));
|
||||
return (strcmp(*(char **)a1, *(char **)a2));
|
||||
}
|
||||
|
||||
/*
|
||||
* If there are any Shell meta characters in the name,
|
||||
* expand into a list, after searching directory
|
||||
*/
|
||||
static void
|
||||
expsh(s)
|
||||
char *s;
|
||||
{
|
||||
|
@ -280,11 +291,12 @@ endit:
|
|||
*pathp = '\0';
|
||||
}
|
||||
|
||||
static void
|
||||
matchdir(pattern)
|
||||
char *pattern;
|
||||
{
|
||||
struct stat stb;
|
||||
register struct dirent *dp;
|
||||
register struct direct *dp;
|
||||
DIR *dirp;
|
||||
|
||||
dirp = opendir(path);
|
||||
|
@ -320,6 +332,7 @@ patherr2:
|
|||
yyerror(path);
|
||||
}
|
||||
|
||||
static int
|
||||
execbrc(p, s)
|
||||
char *p, *s;
|
||||
{
|
||||
|
@ -399,6 +412,7 @@ doit:
|
|||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
match(s, p)
|
||||
char *s, *p;
|
||||
{
|
||||
|
@ -416,6 +430,7 @@ match(s, p)
|
|||
return (c);
|
||||
}
|
||||
|
||||
static int
|
||||
amatch(s, p)
|
||||
register char *s, *p;
|
||||
{
|
||||
|
@ -504,6 +519,7 @@ slash:
|
|||
}
|
||||
}
|
||||
|
||||
static int
|
||||
smatch(s, p)
|
||||
register char *s, *p;
|
||||
{
|
||||
|
@ -562,6 +578,7 @@ smatch(s, p)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
Cat(s1, s2)
|
||||
register char *s1, *s2;
|
||||
{
|
||||
|
@ -582,8 +599,9 @@ Cat(s1, s2)
|
|||
;
|
||||
}
|
||||
|
||||
static void
|
||||
addpath(c)
|
||||
char c;
|
||||
int c;
|
||||
{
|
||||
|
||||
if (pathp >= lastpathp)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
%{
|
||||
/*
|
||||
* Copyright (c) 1983 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 1983, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -33,8 +33,8 @@
|
|||
*/
|
||||
|
||||
#ifndef lint
|
||||
/*static char sccsid[] = "from: @(#)gram.y 5.6 (Berkeley) 6/1/90";*/
|
||||
static char rcsid[] = "$Id: gram.y,v 1.2 1993/08/01 18:09:44 mycroft Exp $";
|
||||
/* from: static char sccsid[] = "@(#)gram.y 8.1 (Berkeley) 6/9/93"; */
|
||||
static char *rcsid = "$Id: gram.y,v 1.3 1994/03/07 05:05:30 cgd Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include "defs.h"
|
||||
|
@ -44,6 +44,8 @@ struct cmd *last_cmd;
|
|||
struct namelist *last_n;
|
||||
struct subcmd *last_sc;
|
||||
|
||||
static char *makestr __P((char *));
|
||||
|
||||
%}
|
||||
|
||||
%term EQUAL 1
|
||||
|
@ -162,13 +164,11 @@ cmd: INSTALL options opt_namelist SM = {
|
|||
}
|
||||
| PATTERN namelist SM = {
|
||||
struct namelist *nl;
|
||||
#ifdef nope
|
||||
char *cp, *re_comp();
|
||||
|
||||
for (nl = $2; nl != NULL; nl = nl->n_next)
|
||||
if ((cp = re_comp(nl->n_name)) != NULL)
|
||||
yyerror(cp);
|
||||
#endif
|
||||
$1->sc_args = expand($2, E_VARS);
|
||||
$$ = $1;
|
||||
}
|
||||
|
@ -201,6 +201,7 @@ opt_namelist: /* VOID */ = {
|
|||
int yylineno = 1;
|
||||
extern FILE *fin;
|
||||
|
||||
int
|
||||
yylex()
|
||||
{
|
||||
static char yytext[INMAX];
|
||||
|
@ -351,6 +352,7 @@ again:
|
|||
return(c);
|
||||
}
|
||||
|
||||
int
|
||||
any(c, str)
|
||||
register int c;
|
||||
register char *str;
|
||||
|
@ -364,6 +366,7 @@ any(c, str)
|
|||
/*
|
||||
* Insert or append ARROW command to list of hosts to be updated.
|
||||
*/
|
||||
void
|
||||
insert(label, files, hosts, subcmds)
|
||||
char *label;
|
||||
struct namelist *files, *hosts;
|
||||
|
@ -414,6 +417,7 @@ insert(label, files, hosts, subcmds)
|
|||
* Append DCOLON command to the end of the command list since these are always
|
||||
* executed in the order they appear in the distfile.
|
||||
*/
|
||||
void
|
||||
append(label, files, stamp, subcmds)
|
||||
char *label;
|
||||
struct namelist *files;
|
||||
|
@ -442,12 +446,11 @@ append(label, files, stamp, subcmds)
|
|||
/*
|
||||
* Error printing routine in parser.
|
||||
*/
|
||||
void
|
||||
yyerror(s)
|
||||
char *s;
|
||||
{
|
||||
extern int yychar;
|
||||
|
||||
nerrs++;
|
||||
++nerrs;
|
||||
fflush(stdout);
|
||||
fprintf(stderr, "rdist: line %d: %s\n", yylineno, s);
|
||||
}
|
||||
|
@ -455,7 +458,7 @@ yyerror(s)
|
|||
/*
|
||||
* Return a copy of the string.
|
||||
*/
|
||||
char *
|
||||
static char *
|
||||
makestr(str)
|
||||
char *str;
|
||||
{
|
||||
|
@ -490,11 +493,9 @@ makenl(name)
|
|||
* Make a sub command for lists of variables, commands, etc.
|
||||
*/
|
||||
struct subcmd *
|
||||
makesubcmd(type, name)
|
||||
makesubcmd(type)
|
||||
int type;
|
||||
register char *name;
|
||||
{
|
||||
register char *cp;
|
||||
register struct subcmd *sc;
|
||||
|
||||
sc = ALLOC(subcmd);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 1983 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 1983, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -32,8 +32,8 @@
|
|||
*/
|
||||
|
||||
#ifndef lint
|
||||
/*static char sccsid[] = "from: @(#)lookup.c 5.5 (Berkeley) 6/1/90";*/
|
||||
static char rcsid[] = "$Id: lookup.c,v 1.2 1993/08/01 18:09:43 mycroft Exp $";
|
||||
/* from: static char sccsid[] = "@(#)lookup.c 8.1 (Berkeley) 6/9/93"; */
|
||||
static char *rcsid = "$Id: lookup.c,v 1.3 1994/03/07 05:05:33 cgd Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include "defs.h"
|
||||
|
@ -54,6 +54,7 @@ static struct syment *hashtab[HASHSIZE];
|
|||
/*
|
||||
* Define a variable from a command line argument.
|
||||
*/
|
||||
void
|
||||
define(name)
|
||||
char *name;
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 1983 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 1983, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -32,14 +32,14 @@
|
|||
*/
|
||||
|
||||
#ifndef lint
|
||||
char copyright[] =
|
||||
"@(#) Copyright (c) 1983 Regents of the University of California.\n\
|
||||
All rights reserved.\n";
|
||||
static char copyright[] =
|
||||
"@(#) Copyright (c) 1983, 1993\n\
|
||||
The Regents of the University of California. All rights reserved.\n";
|
||||
#endif /* not lint */
|
||||
|
||||
#ifndef lint
|
||||
/*static char sccsid[] = "from: @(#)main.c 5.6 (Berkeley) 8/27/90";*/
|
||||
static char rcsid[] = "$Id: main.c,v 1.3 1994/01/23 06:31:38 cgd Exp $";
|
||||
/* from: static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/9/93"; */
|
||||
static char *rcsid = "$Id: main.c,v 1.4 1994/03/07 05:05:35 cgd Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include "defs.h"
|
||||
|
@ -73,6 +73,10 @@ int groupid; /* user's group ID */
|
|||
struct passwd *pw; /* pointer to static area used by getpwent */
|
||||
struct group *gr; /* pointer to static area used by getgrent */
|
||||
|
||||
static void usage __P((void));
|
||||
static void docmdargs __P((int, char *[]));
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
|
@ -216,6 +220,7 @@ main(argc, argv)
|
|||
exit(nerrs != 0);
|
||||
}
|
||||
|
||||
static void
|
||||
usage()
|
||||
{
|
||||
printf("Usage: rdist [-nqbhirvwyD] [-f distfile] [-d var=value] [-m host] [file ...]\n");
|
||||
|
@ -226,6 +231,7 @@ usage()
|
|||
/*
|
||||
* rcp like interface for distributing files.
|
||||
*/
|
||||
static void
|
||||
docmdargs(nargs, args)
|
||||
int nargs;
|
||||
char *args[];
|
||||
|
@ -281,6 +287,7 @@ docmdargs(nargs, args)
|
|||
/*
|
||||
* Print a list of NAME blocks (mostly for debugging).
|
||||
*/
|
||||
void
|
||||
prnames(nl)
|
||||
register struct namelist *nl;
|
||||
{
|
||||
|
@ -292,13 +299,30 @@ prnames(nl)
|
|||
printf(")\n");
|
||||
}
|
||||
|
||||
/*VARARGS*/
|
||||
warn(fmt, a1, a2,a3)
|
||||
#if __STDC__
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
|
||||
void
|
||||
#if __STDC__
|
||||
warn(const char *fmt, ...)
|
||||
#else
|
||||
warn(fmt, va_alist)
|
||||
char *fmt;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
extern int yylineno;
|
||||
|
||||
fprintf(stderr, "rdist: line %d: Warning: ", yylineno);
|
||||
fprintf(stderr, fmt, a1, a2, a3);
|
||||
fputc('\n', stderr);
|
||||
va_list ap;
|
||||
#if __STDC__
|
||||
va_start(ap, fmt);
|
||||
#else
|
||||
va_start(ap);
|
||||
#endif
|
||||
(void)fprintf(stderr, "rdist: line %d: Warning: ", yylineno);
|
||||
(void)vfprintf(stderr, fmt, ap);
|
||||
(void)fprintf(stderr, "\n");
|
||||
va_end(ap);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 1989 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 1989, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -30,8 +30,8 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)pathnames.h 5.4 (Berkeley) 8/27/90
|
||||
* $Id: pathnames.h,v 1.2 1993/08/01 18:09:48 mycroft Exp $
|
||||
* from: @(#)pathnames.h 8.1 (Berkeley) 6/9/93
|
||||
* $Id: pathnames.h,v 1.3 1994/03/07 05:05:39 cgd Exp $
|
||||
*/
|
||||
|
||||
#include <paths.h>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
.\" Copyright (c) 1985, 1990 The Regents of the University of California.
|
||||
.\" All rights reserved.
|
||||
.\" Copyright (c) 1985, 1990, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
|
@ -29,10 +29,10 @@
|
|||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" from: @(#)rdist.1 6.11 (Berkeley) 7/27/91
|
||||
.\" $Id: rdist.1,v 1.4 1994/01/11 18:28:40 jtc Exp $
|
||||
.\" from: @(#)rdist.1 8.2 (Berkeley) 12/30/93
|
||||
.\" $Id: rdist.1,v 1.5 1994/03/07 05:05:43 cgd Exp $
|
||||
.\"
|
||||
.Dd July 27, 1991
|
||||
.Dd December 30, 1993
|
||||
.Dt RDIST 1
|
||||
.Os BSD 4.3
|
||||
.Sh NAME
|
||||
|
@ -43,7 +43,7 @@
|
|||
.Op Fl nqbRhivwy
|
||||
.Op Fl f Ar distfile
|
||||
.Op Fl d Ar var=value
|
||||
.Op Fl m host
|
||||
.Op Fl m Ar host
|
||||
.Op Ar name ...
|
||||
.Nm rdist
|
||||
.Op Fl nqbRhivwy
|
||||
|
@ -140,12 +140,12 @@ link itself.
|
|||
.It Fl i
|
||||
Ignore unresolved links.
|
||||
.Nm Rdist
|
||||
will normally try to maintain the link structure of files being transferred
|
||||
will normally try to maintain the link structure of files being transfered
|
||||
and warn the user if all the links cannot be found.
|
||||
.It Fl m Ar host
|
||||
Limit which machines are to be updated. Multiple
|
||||
.Fl m
|
||||
arguments can be given to limit updates to a subset of the hosts listed the
|
||||
arguments can be given to limit updates to a subset of the hosts listed in the
|
||||
.Ar distfile .
|
||||
.It Fl n
|
||||
Print the commands without executing them. This option is
|
||||
|
@ -288,7 +288,7 @@ unless the destination name is of the format ``login@host".
|
|||
The
|
||||
.Ic notify
|
||||
command is used to mail the list of files updated (and any errors
|
||||
that may have occurred) to the listed names.
|
||||
that may have occured) to the listed names.
|
||||
If no `@' appears in the name, the destination host is appended to
|
||||
the name
|
||||
(e.g., name1@host, name2@host, ...).
|
||||
|
@ -352,8 +352,8 @@ FILES = ( /bin /lib /usr/bin /usr/games
|
|||
\t/usr/include/{*.h,{stand,sys,vax*,pascal,machine}/*.h}
|
||||
\t/usr/lib /usr/man/man? /usr/ucb /usr/local/rdist )
|
||||
|
||||
EXLIB = ( Mail.rc aliases aliases.db crontab dshrc sendmail.cf
|
||||
\tsendmail.fc sendmail.hf sendmail.st uucp vfont )
|
||||
EXLIB = ( Mail.rc aliases aliases.dir aliases.pag crontab dshrc
|
||||
\tsendmail.cf sendmail.fc sendmail.hf sendmail.st uucp vfont )
|
||||
|
||||
${FILES} -> ${HOSTS}
|
||||
\tinstall -R ;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 1983 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 1983, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -32,10 +32,11 @@
|
|||
*/
|
||||
|
||||
#ifndef lint
|
||||
/*static char sccsid[] = "from: @(#)server.c 5.15 (Berkeley) 3/1/91";*/
|
||||
static char rcsid[] = "$Id: server.c,v 1.4 1993/12/04 02:11:38 jtc Exp $";
|
||||
/* from: static char sccsid[] = "@(#)server.c 8.1 (Berkeley) 6/9/93"; */
|
||||
static char *rcsid = "$Id: server.c,v 1.5 1994/03/07 05:05:46 cgd Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/wait.h>
|
||||
#include "defs.h"
|
||||
|
||||
#define ack() (void) write(rem, "\0\n", 2)
|
||||
|
@ -52,8 +53,22 @@ int oumask; /* old umask for creating files */
|
|||
|
||||
extern FILE *lfp; /* log file for mailing changes */
|
||||
|
||||
void cleanup();
|
||||
struct linkbuf *savelink();
|
||||
static int chkparent __P((char *));
|
||||
static void clean __P((char *));
|
||||
static void comment __P((char *));
|
||||
static void dospecial __P((char *));
|
||||
static int fchog __P((int, char *, char *, char *, int));
|
||||
static void hardlink __P((char *));
|
||||
static void note __P((const char *, ...));
|
||||
static void query __P((char *));
|
||||
static void recvf __P((char *, int));
|
||||
static void removeit __P((struct stat *));
|
||||
static int response __P((void));
|
||||
static void rmchk __P((int));
|
||||
static struct linkbuf *
|
||||
savelink __P((struct stat *));
|
||||
static void sendf __P((char *, int));
|
||||
static int update __P((char *, int, struct stat *));
|
||||
|
||||
/*
|
||||
* Server routine to read requests and process them.
|
||||
|
@ -62,6 +77,7 @@ struct linkbuf *savelink();
|
|||
* Vname - Verify if file out of date or not
|
||||
* Qname - Query if file exists. Return mtime & size if it does.
|
||||
*/
|
||||
void
|
||||
server()
|
||||
{
|
||||
char cmdbuf[BUFSIZ];
|
||||
|
@ -88,7 +104,7 @@ server()
|
|||
}
|
||||
do {
|
||||
if (read(rem, cp, 1) != 1)
|
||||
cleanup();
|
||||
cleanup(0);
|
||||
} while (*cp++ != '\n' && cp < &cmdbuf[BUFSIZ]);
|
||||
*--cp = '\0';
|
||||
cp = cmdbuf;
|
||||
|
@ -210,6 +226,7 @@ server()
|
|||
* destdir = 1 if destination should be a directory
|
||||
* (i.e., more than one source is being copied to the same destination).
|
||||
*/
|
||||
void
|
||||
install(src, dest, destdir, opts)
|
||||
char *src, *dest;
|
||||
int destdir, opts;
|
||||
|
@ -280,6 +297,7 @@ install(src, dest, destdir, opts)
|
|||
* Transfer the file or directory in target[].
|
||||
* rname is the name of the file on the remote host.
|
||||
*/
|
||||
static void
|
||||
sendf(rname, opts)
|
||||
char *rname;
|
||||
int opts;
|
||||
|
@ -289,7 +307,7 @@ sendf(rname, opts)
|
|||
int sizerr, f, u, len;
|
||||
off_t i;
|
||||
DIR *d;
|
||||
struct dirent *dp;
|
||||
struct direct *dp;
|
||||
char *otp, *cp;
|
||||
extern struct subcmd *subcmds;
|
||||
static char user[15], group[15];
|
||||
|
@ -314,14 +332,14 @@ sendf(rname, opts)
|
|||
log(lfp, "%s: no password entry for uid %d \n",
|
||||
target, stb.st_uid);
|
||||
pw = NULL;
|
||||
sprintf(user, ":%d", stb.st_uid);
|
||||
(void)sprintf(user, ":%lu", stb.st_uid);
|
||||
}
|
||||
if (gr == NULL || gr->gr_gid != stb.st_gid)
|
||||
if ((gr = getgrgid(stb.st_gid)) == NULL) {
|
||||
log(lfp, "%s: no name for group %d\n",
|
||||
target, stb.st_gid);
|
||||
gr = NULL;
|
||||
sprintf(group, ":%d", stb.st_gid);
|
||||
(void)sprintf(group, ":%lu", stb.st_gid);
|
||||
}
|
||||
if (u == 1) {
|
||||
if (opts & VERIFY) {
|
||||
|
@ -398,7 +416,7 @@ sendf(rname, opts)
|
|||
return;
|
||||
}
|
||||
}
|
||||
(void) sprintf(buf, "K%o %o %ld %ld %s %s %s\n", opts,
|
||||
(void) sprintf(buf, "K%o %o %qd %ld %s %s %s\n", opts,
|
||||
stb.st_mode & 07777, stb.st_size, stb.st_mtime,
|
||||
protoname(), protogroup(), rname);
|
||||
if (debug)
|
||||
|
@ -447,11 +465,11 @@ sendf(rname, opts)
|
|||
}
|
||||
}
|
||||
|
||||
if ((f = open(target, 0)) < 0) {
|
||||
if ((f = open(target, O_RDONLY, 0)) < 0) {
|
||||
error("%s: %s\n", target, strerror(errno));
|
||||
return;
|
||||
}
|
||||
(void) sprintf(buf, "R%o %o %ld %ld %s %s %s\n", opts,
|
||||
(void) sprintf(buf, "R%o %o %qd %ld %s %s %s\n", opts,
|
||||
stb.st_mode & 07777, stb.st_size, stb.st_mtime,
|
||||
protoname(), protogroup(), rname);
|
||||
if (debug)
|
||||
|
@ -498,12 +516,11 @@ dospecial:
|
|||
}
|
||||
}
|
||||
|
||||
struct linkbuf *
|
||||
static struct linkbuf *
|
||||
savelink(stp)
|
||||
struct stat *stp;
|
||||
{
|
||||
struct linkbuf *lp;
|
||||
int found = 0;
|
||||
|
||||
for (lp = ihead; lp != NULL; lp = lp->nextp)
|
||||
if (lp->inum == stp->st_ino && lp->devnum == stp->st_dev) {
|
||||
|
@ -533,6 +550,7 @@ savelink(stp)
|
|||
* Returns 0 if no update, 1 if remote doesn't exist, 2 if out of date
|
||||
* and 3 if comparing binaries to determine if out of date.
|
||||
*/
|
||||
static int
|
||||
update(rname, opts, stp)
|
||||
char *rname;
|
||||
int opts;
|
||||
|
@ -556,7 +574,7 @@ again:
|
|||
cp = s = buf;
|
||||
do {
|
||||
if (read(rem, cp, 1) != 1)
|
||||
lostconn();
|
||||
lostconn(0);
|
||||
} while (*cp++ != '\n' && cp < &buf[BUFSIZ]);
|
||||
|
||||
switch (*s++) {
|
||||
|
@ -632,6 +650,7 @@ again:
|
|||
* Y\n - exists and its a directory or symbolic link
|
||||
* ^Aerror message\n
|
||||
*/
|
||||
static void
|
||||
query(name)
|
||||
char *name;
|
||||
{
|
||||
|
@ -651,7 +670,7 @@ query(name)
|
|||
|
||||
switch (stb.st_mode & S_IFMT) {
|
||||
case S_IFREG:
|
||||
(void) sprintf(buf, "Y%ld %ld\n", stb.st_size, stb.st_mtime);
|
||||
(void) sprintf(buf, "Y%qd %ld\n", stb.st_size, stb.st_mtime);
|
||||
(void) write(rem, buf, strlen(buf));
|
||||
break;
|
||||
|
||||
|
@ -667,6 +686,7 @@ query(name)
|
|||
*tp = '\0';
|
||||
}
|
||||
|
||||
static void
|
||||
recvf(cmd, type)
|
||||
char *cmd;
|
||||
int type;
|
||||
|
@ -760,7 +780,7 @@ recvf(cmd, type)
|
|||
errno = ENOTDIR;
|
||||
} else if (errno == ENOENT && (mkdir(target, mode) == 0 ||
|
||||
chkparent(target) == 0 && mkdir(target, mode) == 0)) {
|
||||
if (chog(target, owner, group, mode) == 0)
|
||||
if (fchog(-1, target, owner, group, mode) == 0)
|
||||
ack();
|
||||
return;
|
||||
}
|
||||
|
@ -790,7 +810,7 @@ recvf(cmd, type)
|
|||
cp = buf;
|
||||
for (i = 0; i < size; i += j) {
|
||||
if ((j = read(rem, cp, size - i)) <= 0)
|
||||
cleanup();
|
||||
cleanup(0);
|
||||
cp += j;
|
||||
}
|
||||
*cp = '\0';
|
||||
|
@ -801,7 +821,7 @@ recvf(cmd, type)
|
|||
if (symlink(buf, new) < 0) {
|
||||
if (errno != ENOENT || chkparent(new) < 0 ||
|
||||
symlink(buf, new) < 0)
|
||||
goto badn;
|
||||
goto badnew1;
|
||||
}
|
||||
mode &= 0777;
|
||||
if (opts & COMPARE) {
|
||||
|
@ -822,7 +842,7 @@ recvf(cmd, type)
|
|||
if ((f = creat(new, mode)) < 0) {
|
||||
if (errno != ENOENT || chkparent(new) < 0 ||
|
||||
(f = creat(new, mode)) < 0)
|
||||
goto badn;
|
||||
goto badnew1;
|
||||
}
|
||||
|
||||
ack();
|
||||
|
@ -839,7 +859,7 @@ recvf(cmd, type)
|
|||
if (j <= 0) {
|
||||
(void) close(f);
|
||||
(void) unlink(new);
|
||||
cleanup();
|
||||
cleanup(0);
|
||||
}
|
||||
amt -= j;
|
||||
cp += j;
|
||||
|
@ -852,70 +872,62 @@ recvf(cmd, type)
|
|||
wrerr++;
|
||||
}
|
||||
}
|
||||
(void) close(f);
|
||||
if (response() < 0) {
|
||||
err();
|
||||
(void) unlink(new);
|
||||
return;
|
||||
}
|
||||
if (wrerr) {
|
||||
error("%s:%s: %s\n", host, new, strerror(errno));
|
||||
(void) unlink(new);
|
||||
return;
|
||||
goto badnew2;
|
||||
}
|
||||
if (wrerr)
|
||||
goto badnew1;
|
||||
if (opts & COMPARE) {
|
||||
FILE *f1, *f2;
|
||||
int c;
|
||||
|
||||
if ((f1 = fopen(target, "r")) == NULL)
|
||||
goto badt;
|
||||
goto badtarget;
|
||||
if ((f2 = fopen(new, "r")) == NULL) {
|
||||
badn:
|
||||
error("%s:%s: %s\n", host, new, strerror(errno));
|
||||
(void) unlink(new);
|
||||
return;
|
||||
badnew1: error("%s:%s: %s\n", host, new, strerror(errno));
|
||||
goto badnew2;
|
||||
}
|
||||
while ((c = getc(f1)) == getc(f2))
|
||||
if (c == EOF) {
|
||||
(void) fclose(f1);
|
||||
(void) fclose(f2);
|
||||
(void) unlink(new);
|
||||
ack();
|
||||
return;
|
||||
goto badnew2;
|
||||
}
|
||||
(void) fclose(f1);
|
||||
(void) fclose(f2);
|
||||
if (opts & VERIFY) {
|
||||
differ:
|
||||
(void) unlink(new);
|
||||
buf[0] = '\0';
|
||||
differ: buf[0] = '\0';
|
||||
(void) sprintf(buf + 1, "need to update: %s\n",target);
|
||||
(void) write(rem, buf, strlen(buf + 1) + 1);
|
||||
return;
|
||||
goto badnew2;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Set last modified time
|
||||
*/
|
||||
tvp[0].tv_sec = stb.st_atime; /* old atime from target */
|
||||
tvp[0].tv_sec = time(0);
|
||||
tvp[0].tv_usec = 0;
|
||||
tvp[1].tv_sec = mtime;
|
||||
tvp[1].tv_usec = 0;
|
||||
if (utimes(new, tvp) < 0) {
|
||||
note("%s:utimes failed %s: %s\n", host, new, strerror(errno));
|
||||
}
|
||||
if (chog(new, owner, group, mode) < 0) {
|
||||
if (utimes(new, tvp) < 0)
|
||||
note("%s: utimes failed %s: %s\n", host, new, strerror(errno));
|
||||
|
||||
if (fchog(f, new, owner, group, mode) < 0) {
|
||||
badnew2: (void) close(f);
|
||||
(void) unlink(new);
|
||||
return;
|
||||
}
|
||||
fixup:
|
||||
if (rename(new, target) < 0) {
|
||||
badt:
|
||||
error("%s:%s: %s\n", host, target, strerror(errno));
|
||||
(void) close(f);
|
||||
|
||||
fixup: if (rename(new, target) < 0) {
|
||||
badtarget: error("%s:%s: %s\n", host, target, strerror(errno));
|
||||
(void) unlink(new);
|
||||
return;
|
||||
}
|
||||
|
||||
if (opts & COMPARE) {
|
||||
buf[0] = '\0';
|
||||
(void) sprintf(buf + 1, "updated %s\n", target);
|
||||
|
@ -927,6 +939,7 @@ badt:
|
|||
/*
|
||||
* Creat a hard link to existing file.
|
||||
*/
|
||||
static void
|
||||
hardlink(cmd)
|
||||
char *cmd;
|
||||
{
|
||||
|
@ -984,6 +997,7 @@ hardlink(cmd)
|
|||
/*
|
||||
* Check to see if parent directory exists and create one if not.
|
||||
*/
|
||||
static int
|
||||
chkparent(name)
|
||||
char *name;
|
||||
{
|
||||
|
@ -1011,7 +1025,9 @@ chkparent(name)
|
|||
/*
|
||||
* Change owner, group and mode of file.
|
||||
*/
|
||||
chog(file, owner, group, mode)
|
||||
static int
|
||||
fchog(fd, file, owner, group, mode)
|
||||
int fd;
|
||||
char *file, *owner, *group;
|
||||
int mode;
|
||||
{
|
||||
|
@ -1061,12 +1077,11 @@ chog(file, owner, group, mode)
|
|||
mode &= ~02000;
|
||||
gid = -1;
|
||||
}
|
||||
ok:
|
||||
if (chown(file, uid, gid) < 0 ||
|
||||
(mode & 07000) && chmod(file, mode) < 0) {
|
||||
note("%s: chown or chmod failed: file %s: %s",
|
||||
host, file, strerror(errno));
|
||||
}
|
||||
ok: if (fd != -1 && fchown(fd, uid, gid) < 0 || chown(file, uid, gid) < 0)
|
||||
note("%s: %s chown: %s", host, file, strerror(errno));
|
||||
else if (mode & 07000 &&
|
||||
(fd != -1 && fchmod(fd, mode) < 0 || chmod(file, mode) < 0))
|
||||
note("%s: %s chmod: %s", host, file, strerror(errno));
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
@ -1074,6 +1089,7 @@ ok:
|
|||
* Check for files on the machine being updated that are not on the master
|
||||
* machine and remove them.
|
||||
*/
|
||||
static void
|
||||
rmchk(opts)
|
||||
int opts;
|
||||
{
|
||||
|
@ -1096,7 +1112,7 @@ rmchk(opts)
|
|||
cp = s = buf;
|
||||
do {
|
||||
if (read(rem, cp, 1) != 1)
|
||||
lostconn();
|
||||
lostconn(0);
|
||||
} while (*cp++ != '\n' && cp < &buf[BUFSIZ]);
|
||||
|
||||
switch (*s++) {
|
||||
|
@ -1141,7 +1157,7 @@ rmchk(opts)
|
|||
(void) fwrite(s, 1, cp - s, lfp);
|
||||
}
|
||||
if (buf[0] == '\2')
|
||||
lostconn();
|
||||
lostconn(0);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -1155,11 +1171,12 @@ rmchk(opts)
|
|||
* Check the current directory (initialized by the 'T' command to server())
|
||||
* for extraneous files and remove them.
|
||||
*/
|
||||
static void
|
||||
clean(cp)
|
||||
register char *cp;
|
||||
{
|
||||
DIR *d;
|
||||
register struct dirent *dp;
|
||||
register struct direct *dp;
|
||||
struct stat stb;
|
||||
char *otp;
|
||||
int len, opts;
|
||||
|
@ -1202,7 +1219,7 @@ clean(cp)
|
|||
cp = buf;
|
||||
do {
|
||||
if (read(rem, cp, 1) != 1)
|
||||
cleanup();
|
||||
cleanup(0);
|
||||
} while (*cp++ != '\n' && cp < &buf[BUFSIZ]);
|
||||
*--cp = '\0';
|
||||
cp = buf;
|
||||
|
@ -1227,11 +1244,12 @@ clean(cp)
|
|||
* Remove a file or directory (recursively) and send back an acknowledge
|
||||
* or an error message.
|
||||
*/
|
||||
static void
|
||||
removeit(stp)
|
||||
struct stat *stp;
|
||||
{
|
||||
DIR *d;
|
||||
struct dirent *dp;
|
||||
struct direct *dp;
|
||||
register char *cp;
|
||||
struct stat stb;
|
||||
char *otp;
|
||||
|
@ -1295,6 +1313,7 @@ removed:
|
|||
/*
|
||||
* Execute a shell command to handle special cases.
|
||||
*/
|
||||
static void
|
||||
dospecial(cmd)
|
||||
char *cmd;
|
||||
{
|
||||
|
@ -1362,78 +1381,117 @@ dospecial(cmd)
|
|||
ack();
|
||||
}
|
||||
|
||||
/*VARARGS2*/
|
||||
log(fp, fmt, a1, a2, a3)
|
||||
#if __STDC__
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
|
||||
void
|
||||
#if __STDC__
|
||||
log(FILE *fp, const char *fmt, ...)
|
||||
#else
|
||||
log(fp, fmt, va_alist)
|
||||
FILE *fp;
|
||||
char *fmt;
|
||||
int a1, a2, a3;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list ap;
|
||||
#if __STDC__
|
||||
va_start(ap, fmt);
|
||||
#else
|
||||
va_start(ap);
|
||||
#endif
|
||||
/* Print changes locally if not quiet mode */
|
||||
if (!qflag)
|
||||
printf(fmt, a1, a2, a3);
|
||||
(void)vprintf(fmt, ap);
|
||||
|
||||
/* Save changes (for mailing) if really updating files */
|
||||
if (!(options & VERIFY) && fp != NULL)
|
||||
fprintf(fp, fmt, a1, a2, a3);
|
||||
(void)vfprintf(fp, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
/*VARARGS1*/
|
||||
error(fmt, a1, a2, a3)
|
||||
void
|
||||
#if __STDC__
|
||||
error(const char *fmt, ...)
|
||||
#else
|
||||
error(fmt, va_alist)
|
||||
char *fmt;
|
||||
int a1, a2, a3;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
static FILE *fp;
|
||||
va_list ap;
|
||||
#if __STDC__
|
||||
va_start(ap, fmt);
|
||||
#else
|
||||
va_start(ap);
|
||||
#endif
|
||||
|
||||
++nerrs;
|
||||
if (!fp && !(fp = fdopen(rem, "w")))
|
||||
return;
|
||||
if (iamremote) {
|
||||
(void)fprintf(fp, "%crdist: ", 0x01);
|
||||
(void)fprintf(fp, fmt, a1, a2, a3);
|
||||
(void)vfprintf(fp, fmt, ap);
|
||||
fflush(fp);
|
||||
}
|
||||
else {
|
||||
fflush(stdout);
|
||||
(void)fprintf(stderr, "rdist: ");
|
||||
(void)fprintf(stderr, fmt, a1, a2, a3);
|
||||
(void)vfprintf(stderr, fmt, ap);
|
||||
fflush(stderr);
|
||||
}
|
||||
if (lfp != NULL) {
|
||||
(void)fprintf(lfp, "rdist: ");
|
||||
(void)fprintf(lfp, fmt, a1, a2, a3);
|
||||
(void)vfprintf(lfp, fmt, ap);
|
||||
fflush(lfp);
|
||||
}
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
/*VARARGS1*/
|
||||
fatal(fmt, a1, a2,a3)
|
||||
void
|
||||
#if __STDC__
|
||||
fatal(const char *fmt, ...)
|
||||
#else
|
||||
fatal(fmt, va_alist)
|
||||
char *fmt;
|
||||
int a1, a2, a3;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
static FILE *fp;
|
||||
va_list ap;
|
||||
#if __STDC__
|
||||
va_start(ap, fmt);
|
||||
#else
|
||||
va_start(ap);
|
||||
#endif
|
||||
|
||||
++nerrs;
|
||||
if (!fp && !(fp = fdopen(rem, "w")))
|
||||
return;
|
||||
if (iamremote) {
|
||||
(void)fprintf(fp, "%crdist: ", 0x02);
|
||||
(void)fprintf(fp, fmt, a1, a2, a3);
|
||||
(void)vfprintf(fp, fmt, ap);
|
||||
fflush(fp);
|
||||
}
|
||||
else {
|
||||
fflush(stdout);
|
||||
(void)fprintf(stderr, "rdist: ");
|
||||
(void)fprintf(stderr, fmt, a1, a2, a3);
|
||||
(void)vfprintf(stderr, fmt, ap);
|
||||
fflush(stderr);
|
||||
}
|
||||
if (lfp != NULL) {
|
||||
(void)fprintf(lfp, "rdist: ");
|
||||
(void)fprintf(lfp, fmt, a1, a2, a3);
|
||||
(void)vfprintf(lfp, fmt, ap);
|
||||
fflush(lfp);
|
||||
}
|
||||
cleanup();
|
||||
cleanup(0);
|
||||
}
|
||||
|
||||
static int
|
||||
response()
|
||||
{
|
||||
char *cp, *s;
|
||||
|
@ -1445,7 +1503,7 @@ response()
|
|||
cp = s = resp;
|
||||
do {
|
||||
if (read(rem, cp, 1) != 1)
|
||||
lostconn();
|
||||
lostconn(0);
|
||||
} while (*cp++ != '\n' && cp < &resp[BUFSIZ]);
|
||||
|
||||
switch (*s++) {
|
||||
|
@ -1476,7 +1534,7 @@ response()
|
|||
(void) fwrite(s, 1, cp - s, lfp);
|
||||
}
|
||||
if (resp[0] == '\2')
|
||||
lostconn();
|
||||
lostconn(0);
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
|
@ -1485,25 +1543,41 @@ response()
|
|||
* Remove temporary files and do any cleanup operations before exiting.
|
||||
*/
|
||||
void
|
||||
cleanup()
|
||||
cleanup(signo)
|
||||
int signo;
|
||||
{
|
||||
(void) unlink(tempfile);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
note(fmt, a1, a2, a3)
|
||||
static void
|
||||
#if __STDC__
|
||||
note(const char *fmt, ...)
|
||||
#else
|
||||
note(fmt, va_alist)
|
||||
char *fmt;
|
||||
int a1, a2, a3;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
static char buf[BUFSIZ];
|
||||
sprintf(buf, fmt, a1, a2, a3);
|
||||
va_list ap;
|
||||
#if __STDC__
|
||||
va_start(ap, fmt);
|
||||
#else
|
||||
va_start(ap);
|
||||
#endif
|
||||
(void)vsnprintf(buf, sizeof(buf), fmt, ap);
|
||||
va_end(ap);
|
||||
comment(buf);
|
||||
}
|
||||
|
||||
static void
|
||||
comment(s)
|
||||
char *s;
|
||||
char *s;
|
||||
{
|
||||
char c = '\3';
|
||||
char c;
|
||||
|
||||
c = '\3';
|
||||
write(rem, &c, 1);
|
||||
write(rem, s, strlen(s));
|
||||
c = '\n';
|
||||
|
|
Loading…
Reference in New Issue