#ifndef lint
static char RCSid[] =
-"$Id: child.c,v 1.1 1996/02/03 12:12:09 dm Exp $";
+"$Id: child.c,v 1.2 1996/03/05 03:15:56 dm Exp $";
static char sccsid[] = "@(#)docmd.c 5.1 (Berkeley) 6/6/85";
#ifndef lint
static char RCSid[] =
-"$Id: client.c,v 1.1 1996/02/03 12:12:11 dm Exp $";
+"$Id: client.c,v 1.2 1996/03/05 03:15:57 dm Exp $";
static char sccsid[] = "@(#)client.c";
int len;
int didupdate = 0;
+ /*
+ * Don't descend into directory
+ */
+ if (IS_ON(opts, DO_NODESCEND))
+ return(0);
+
+ if ((d = opendir(target)) == NULL) {
+ error("%s: opendir failed: %s", target, SYSERR);
+ return(-1);
+ }
+
/*
* Send recvdir command in recvit() format.
*/
if (response() < 0)
return(-1);
- /*
- * Don't descend into directory
- */
- if (IS_ON(opts, DO_NODESCEND))
- return(0);
-
if (IS_ON(opts, DO_REMOVE))
if (rmchk(opts) > 0)
++didupdate;
- if ((d = opendir(target)) == NULL) {
- error("%s: opendir failed: %s", target, SYSERR);
- return(-1);
- }
-
optarget = ptarget;
len = ptarget - target;
while (dp = readdir(d)) {
#ifndef lint
static char RCSid[] =
-"$Id: common.c,v 1.1 1996/02/03 12:12:12 dm Exp $";
+"$Id: common.c,v 1.2 1996/03/05 03:15:58 dm Exp $";
static char sccsid[] = "@(#)common.c";
int proto_version = -1; /* Protocol version */
int rtimeout = RTIMEOUT; /* Response time out */
jmp_buf finish_jmpbuf; /* Finish() jmp buffer */
+int setjmp_ok = FALSE; /* setjmp()/longjmp() status */
char **realargv; /* Real main() argv */
int realargc; /* Real main() argc */
opt_t options = 0; /* Global install options */
* There's no valid finish_jmpbuf for the rdist master parent.
*/
if (!do_fork || amchild || isserver) {
+
+ if (!setjmp_ok) {
+#ifdef DEBUG_SETJMP
+ error("attemping longjmp() without target");
+ abort();
+#else
+ exit(1);
+#endif
+ }
+
longjmp(finish_jmpbuf, 1);
/*NOTREACHED*/
error("Unexpected failure of longjmp() in finish()");
*/
/*
- * $Id: config-data.h,v 1.1 1996/02/03 12:12:14 dm Exp $
+ * $Id: config-data.h,v 1.2 1996/03/05 03:15:59 dm Exp $
* @(#)configdata.h
*/
*/
/*
- * $Id: config-def.h,v 1.1 1996/02/03 12:12:15 dm Exp $
+ * $Id: config-def.h,v 1.2 1996/03/05 03:16:00 dm Exp $
* @(#)configdef.h
*/
*/
/*
- * $Id: config.h,v 1.1 1996/02/03 12:12:16 dm Exp $
+ * $Id: config.h,v 1.2 1996/03/05 03:16:01 dm Exp $
* @(#)config.h
*/
* don't have the old rdist, then uncomment the "#undef" line.
*/
#ifndef _PATH_OLDRDIST
-#define _PATH_OLDRDIST "/usr/bin/oldrdist" /* Enable compat */
+#define _PATH_OLDRDIST "/usr/ucb/oldrdist" /* Enable compat */
#endif
/*#undef _PATH_OLDRDIST*/ /* Disable compat */
*/
/*
- * $Id: defs.h,v 1.2 1996/02/03 12:12:18 dm Exp $
+ * $Id: defs.h,v 1.3 1996/03/05 03:16:01 dm Exp $
* @(#)defs.h 5.2 (Berkeley) 3/20/86
*/
extern int rem_r; /* Remote file descriptor, reading */
extern int rem_w; /* Remote file descriptor, writing */
extern int rtimeout; /* Response time out in seconds */
+extern int setjmp_ok; /* setjmp/longjmp flag */
extern UID_T userid; /* User ID of rdist user */
extern jmp_buf finish_jmpbuf; /* Setjmp buffer for finish() */
extern struct group *gr; /* pointer to static area used by getgrent */
#ifndef lint
static char RCSid[] =
-"$Id: distopt.c,v 1.1 1996/02/03 12:12:20 dm Exp $";
+"$Id: distopt.c,v 1.2 1996/03/05 03:16:02 dm Exp $";
static char sccsid[] = "@(#)distopt.c";
{ DO_QUIET, "quiet" },
{ DO_REMOVE, "remove" },
{ DO_SAVETARGETS, "savetargets" },
+ { DO_SPARSE, "sparse" },
{ DO_VERIFY, "verify" },
{ DO_WHOLE, "whole" },
{ DO_YOUNGER, "younger" },
#ifndef lint
static char RCSid[] =
-"$Id: docmd.c,v 1.2 1996/02/03 12:12:22 dm Exp $";
+"$Id: docmd.c,v 1.3 1996/03/05 03:16:03 dm Exp $";
static char sccsid[] = "@(#)docmd.c 5.1 (Berkeley) 6/6/85";
char *rhost;
int didupdate = 0;
+ if (setjmp_ok) {
+ error("reentrant call to doarrow");
+ abort();
+ }
+
if (!cmd) {
debugmsg(DM_MISC, "doarrow() NULL cmd parameter");
return;
}
if (setjmp(finish_jmpbuf)) {
+ setjmp_ok = FALSE;
debugmsg(DM_MISC, "setjmp to finish_jmpbuf");
markfailed(cmd, cmds);
return;
}
+ setjmp_ok = TRUE;
if (!makeconn(rhost)) {
+ setjmp_ok = FALSE;
markfailed(cmd, cmds);
return;
}
}
ihead = NULL;
}
+ setjmp_ok = FALSE;
}
okname(name)
#ifndef lint
static char RCSid[] =
-"$Id: expand.c,v 1.2 1996/02/03 12:12:23 dm Exp $";
+"$Id: expand.c,v 1.3 1996/03/05 03:16:04 dm Exp $";
static char sccsid[] = "@(#)expand.c 5.2 (Berkeley) 3/28/86";
#ifndef lint
static char RCSid[] =
-"$Id: gram.y,v 1.2 1996/02/03 12:12:26 dm Exp $";
+"$Id: gram.y,v 1.3 1996/03/05 03:16:05 dm Exp $";
static char *sccsid = "@(#)gram.y 5.2 (Berkeley) 85/06/21";
*/
#ifndef lint
static char RCSid[] =
-"$Id: isexec.c,v 1.1 1996/02/03 12:12:27 dm Exp $";
+"$Id: isexec.c,v 1.2 1996/03/05 03:16:06 dm Exp $";
static char sccsid[] = "@(#)client.c";
#ifndef lint
static char RCSid[] =
-"$Id: lookup.c,v 1.2 1996/02/03 12:12:29 dm Exp $";
+"$Id: lookup.c,v 1.3 1996/03/05 03:16:07 dm Exp $";
static char sccsid[] = "@(#)lookup.c 5.1 (Berkeley) 6/6/85";
#ifndef lint
static char RCSid[] =
-"$Id: message.c,v 1.1 1996/02/03 12:12:32 dm Exp $";
+"$Id: message.c,v 1.2 1996/03/05 03:16:08 dm Exp $";
static char sccsid[] = "@(#)common.c";
*/
/*
- * $Id: os-openbsd.h,v 1.1 1996/02/03 12:12:33 dm Exp $
+ * $Id: os-openbsd.h,v 1.2 1996/03/05 03:16:09 dm Exp $
*/
/*
* Determine what routines we have to get filesystem info.
*/
#define FSI_TYPE FSI_GETFSSTAT
-#define FSTYPENAME 1
+#ifndef FSTYPENAME
+#define FSTYPENAME 1 /* For OpenBSD 1.x */
+#endif
/*
* Type of non-blocking I/O.
*/
/*
- * $Id: pathnames.h,v 1.2 1996/02/03 12:12:35 dm Exp $
+ * $Id: pathnames.h,v 1.3 1996/03/05 03:16:09 dm Exp $
* @(#)pathnames.h 5.4 (Berkeley) 8/27/90
*/
--- /dev/null
+/*
+ * Copyright (c) 1983 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
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * $Id: paths.h,v 1.1 1996/03/05 03:20:21 dm Exp $
+ * @(#)paths.h
+ */
+
+/*
+ * This file should be used for those systems without their own
+ * <paths.h> system include file.
+ */
+
+#ifndef _PATH_SENDMAIL
+#define _PATH_SENDMAIL "/usr/lib/sendmail"
+#endif
+#ifndef _PATH_TMP
+#define _PATH_TMP "/tmp"
+#endif
+#ifndef _PATH_DEVNULL
+#define _PATH_DEVNULL "/dev/null"
+#endif
+#ifndef _PATH_BSHELL
+#define _PATH_BSHELL "/bin/sh"
+#endif
+
+#ifndef _PATH_REMSH
+#define _PATH_REMSH "/usr/ucb/rsh" /* Remote shell */
+#endif
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: rdist.1,v 1.2 1996/02/03 12:12:37 dm Exp $
+.\" $Id: rdist.1,v 1.3 1996/03/05 03:16:10 dm Exp $
.\" @(#)rdist.1 6.6 (Berkeley) 5/13/86
.\"
-.TH RDIST 1 "March 14, 1994"
+.TH RDIST 1 "January 29, 1996"
.UC 6
.SH NAME
rdist \- remote file distribution client program
.B file
to
.B file.OLD.
+.IP \fBsparse\fR
+Enable checking for sparse (aka \fIwholely\fR) files. One of the most
+common types of sparse files are those produced by
+.B ndbm(3).
+This option adds some additional processing overhead so it should
+only be enabled for targets likely to contain sparse files.
.RE
.TP
.B "\-p \fI<rdistd-path>\fR"
#ifndef lint
static char RCSid[] =
-"$Id: rdist.c,v 1.1 1996/02/03 12:12:38 dm Exp $";
+"$Id: rdist.c,v 1.2 1996/03/05 03:16:11 dm Exp $";
static char sccsid[] = "@(#)main.c 5.1 (Berkeley) 6/6/85";
#ifndef lint
static char RCSid[] =
-"$Id: rshrcmd.c,v 1.1 1996/02/03 12:12:40 dm Exp $";
+"$Id: rshrcmd.c,v 1.2 1996/03/05 03:16:12 dm Exp $";
#endif
#include "defs.h"
#ifndef lint
static char RCSid[] =
-"$Id: setargs.c,v 1.1 1996/02/03 12:12:43 dm Exp $";
+"$Id: setargs.c,v 1.2 1996/03/05 03:16:13 dm Exp $";
static char sccsid[] = "@(#)setargs.c";
#ifndef lint
static char RCSid[] =
-"$Id: signal.c,v 1.1 1996/02/03 12:12:44 dm Exp $";
+"$Id: signal.c,v 1.2 1996/03/05 03:16:13 dm Exp $";
static char sccsid[] = "@(#)signal.c";
#define __myTYPES_H__
/*
- * $Id: types.h,v 1.1 1996/02/03 12:12:45 dm Exp $
+ * $Id: types.h,v 1.2 1996/03/05 03:16:15 dm Exp $
*/
/*
#define DO_CHKSYM 0x020000
#define DO_NUMCHKGROUP 0x040000
#define DO_NUMCHKOWNER 0x080000
+#define DO_SPARSE 0x100000
/*
* Dist option information
*/
/*
- * $Id: version.h,v 1.1 1996/02/03 12:12:47 dm Exp $
+ * $Id: version.h,v 1.2 1996/03/05 03:16:15 dm Exp $
*/
/*
/*
* Patch level
*/
-#define PATCHLEVEL 1
+#define PATCHLEVEL 2
/*
* Distribution status
#ifndef lint
static char RCSid[] =
-"$Id: filesys.c,v 1.1 1996/02/03 12:12:57 dm Exp $";
+"$Id: filesys.c,v 1.2 1996/03/05 03:16:17 dm Exp $";
static char sccsid[] = "@(#)filesys.c";
if ((mnt = (mntent_t *) getmntpt(path, statbuf, isvalid)) == NULL)
return(-1);
- if (strcmp(mnt->me_type, METYPE_NFS) == 0)
+ /*
+ * We treat "cachefs" just like NFS
+ */
+ if ((strcmp(mnt->me_type, METYPE_NFS) == 0) ||
+ (strcmp(mnt->me_type, "cachefs") == 0))
return(1);
return(0);
*/
/*
- * $Id: filesys.h,v 1.1 1996/02/03 12:12:58 dm Exp $
+ * $Id: filesys.h,v 1.2 1996/03/05 03:16:18 dm Exp $
* @(#)filesys.h
*/
#ifndef lint
static char RCSid[] =
-"$Id: message.c,v 1.1 1996/02/03 12:12:59 dm Exp $";
+"$Id: message.c,v 1.2 1996/03/05 03:16:18 dm Exp $";
static char sccsid[] = "@(#)common.c";
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: rdistd.1,v 1.1 1996/02/03 12:13:01 dm Exp $
+.\" $Id: rdistd.1,v 1.2 1996/03/05 03:16:19 dm Exp $
.\" @(#)rdistd.8 6.6 (Berkeley) 5/13/86
.\"
.TH RDISTD 8 "June 21, 1992"
#ifndef lint
static char RCSid[] =
-"$Id: rdistd.c,v 1.1 1996/02/03 12:13:02 dm Exp $";
+"$Id: rdistd.c,v 1.2 1996/03/05 03:16:20 dm Exp $";
static char sccsid[] = "@(#)rdistd.c";
*/
#ifndef lint
static char RCSid[] =
-"$Id: server.c,v 1.1 1996/02/03 12:13:03 dm Exp $";
+"$Id: server.c,v 1.2 1996/03/05 03:16:21 dm Exp $";
static char sccsid[] = "@(#)server.c 5.3 (Berkeley) 6/7/86";
static char last_group[128];
static char last_owner[128];
static GID_T last_gid = (GID_T)-2;
+ static UID_T last_uid = (UID_T)-2;
+ static GID_T last_primegid;
extern char *locuser;
register int i;
UID_T uid;
if (userid == 0) { /* running as root; take anything */
if (*owner == ':') {
uid = (UID_T) atoi(owner + 1);
- } else if (pw == NULL || strcmp(owner, last_owner) != 0) {
+ } else if (last_uid == (UID_T)-2 ||
+ strcmp(owner, last_owner) != 0) {
if ((pw = getpwnam(owner)) == NULL) {
if (mode != -1 && IS_ON(mode, S_ISUID)) {
message(MT_NOTICE,
"%s: unknown login name \"%s\"",
target, owner);
} else {
- uid = pw->pw_uid;
+ uid = last_uid = pw->pw_uid;
+ primegid = last_primegid = pw->pw_gid;
strcpy(last_owner, owner);
}
} else {
- uid = pw->pw_uid;
- primegid = pw->pw_gid;
+ uid = last_uid;
+ primegid = last_primegid;
}
if (*group == ':') {
gid = (GID_T) atoi(group + 1);
return(savefile);
}
+/*
+ * See if buf is all zeros (sparse check)
+ */
+static int iszeros (buf, size)
+ char *buf;
+ off_t size;
+{
+ while (size > 0) {
+ if (*buf != CNULL)
+ return(0);
+ buf++;
+ size--;
+ }
+
+ return(1);
+}
+
+
/*
* Receive a file
*/
time_t atime;
off_t size;
{
- int f, wrerr, olderrno;
+ int f, wrerr, olderrno, lastwashole = 0, wassparse = 0;
off_t i;
register char *cp;
char *savefile = NULL;
amt = BUFSIZ;
if (i + amt > size)
amt = size - i;
- if (wrerr == 0 && xwrite(f, buf, amt) != amt) {
+ if (IS_ON(opts, DO_SPARSE) && iszeros(buf, amt)) {
+ if (lseek (f, amt, SEEK_CUR) < 0L) {
+ olderrno = errno;
+ wrerr++;
+ }
+ lastwashole = 1;
+ wassparse++;
+ } else {
+ if (wrerr == 0 && xwrite(f, buf, amt) != amt) {
+ olderrno = errno;
+ wrerr++;
+ }
+ lastwashole = 0;
+ }
+ }
+
+ if (lastwashole) {
+#if defined(HAVE_FTRUNCATE)
+ if (write (f, "", 1) != 1 || ftruncate (f, size) < 0)
+#else
+ /* Seek backwards one character and write a null. */
+ if (lseek (f, (off_t) -1, SEEK_CUR) < 0L
+ || write (f, "", 1) != 1)
+#endif
+ {
olderrno = errno;
wrerr++;
}
(void) unlink(new);
return;
}
+
if (wrerr) {
error("%s: Write error: %s", new, strerror(olderrno));
(void) close(f);
}
}
+ if (wassparse)
+ message (MT_NOTICE, "%s: was sparse", target);
+
if (IS_ON(opts, DO_COMPARE))
message(MT_REMOTE|MT_CHANGE, "%s: updated", target);
else
register int n;
extern jmp_buf finish_jmpbuf;
- if (setjmp(finish_jmpbuf))
+ if (setjmp(finish_jmpbuf)) {
+ setjmp_ok = FALSE;
return;
+ }
+ setjmp_ok = TRUE;
(void) signal(SIGHUP, sighandler);
(void) signal(SIGINT, sighandler);
(void) signal(SIGQUIT, sighandler);
(void) sendcmd(S_VERSION, NULL);
if (remline(cmdbuf, sizeof(cmdbuf), TRUE) < 0) {
+ setjmp_ok = FALSE;
error("server: expected control record");
return;
}
if (cmdbuf[0] != S_VERSION || !isdigit(cmdbuf[1])) {
+ setjmp_ok = FALSE;
error("Expected version command, received: \"%s\".", cmdbuf);
return;
}
proto_version = atoi(&cmdbuf[1]);
if (proto_version != VERSION) {
+ setjmp_ok = FALSE;
error("Protocol version %d is not supported.", proto_version);
return;
}
*/
for ( ; ; ) {
n = remline(cp = cmdbuf, sizeof(cmdbuf), TRUE);
- if (n == -1) /* EOF */
+ if (n == -1) { /* EOF */
+ setjmp_ok = FALSE;
return;
+ }
if (n == 0) {
error("server: expected control record");
continue;
case C_FERRMSG: /* Fatal error message */
if (cp && *cp)
message(MT_FERROR|MT_NOREMOTE, "%s", cp);
+ setjmp_ok = FALSE;
return;
default: