PERFORCE change 93313 for review

Peter Wemm peter at FreeBSD.org
Tue Mar 14 21:58:29 UTC 2006


http://perforce.freebsd.org/chv.cgi?CH=93313

Change 93313 by peter at peter_daintree on 2006/03/14 21:57:49

	IFC @93312

Affected files ...

.. //depot/projects/hammer/contrib/csup/GNUmakefile#2 integrate
.. //depot/projects/hammer/contrib/csup/Makefile#2 integrate
.. //depot/projects/hammer/contrib/csup/TODO#2 integrate
.. //depot/projects/hammer/contrib/csup/config.c#2 integrate
.. //depot/projects/hammer/contrib/csup/config.h#2 integrate
.. //depot/projects/hammer/contrib/csup/csup.1#2 integrate
.. //depot/projects/hammer/contrib/csup/fattr.c#2 integrate
.. //depot/projects/hammer/contrib/csup/globtree.c#2 integrate
.. //depot/projects/hammer/contrib/csup/idcache.c#1 branch
.. //depot/projects/hammer/contrib/csup/idcache.h#1 branch
.. //depot/projects/hammer/contrib/csup/lister.c#2 integrate
.. //depot/projects/hammer/contrib/csup/main.c#2 integrate
.. //depot/projects/hammer/contrib/csup/misc.c#2 integrate
.. //depot/projects/hammer/contrib/csup/misc.h#2 integrate
.. //depot/projects/hammer/contrib/csup/proto.c#2 integrate
.. //depot/projects/hammer/contrib/csup/token.h#2 integrate
.. //depot/projects/hammer/contrib/csup/token.l#2 integrate
.. //depot/projects/hammer/contrib/csup/updater.c#2 integrate
.. //depot/projects/hammer/etc/mtree/BSD.x11-4.dist#13 integrate
.. //depot/projects/hammer/include/stdlib.h#14 integrate
.. //depot/projects/hammer/lib/libc/stdlib/Makefile.inc#15 integrate
.. //depot/projects/hammer/lib/libc/stdlib/Symbol.map#2 integrate
.. //depot/projects/hammer/lib/libc/stdlib/strtonum.3#1 branch
.. //depot/projects/hammer/lib/libc/stdlib/strtonum.c#1 branch
.. //depot/projects/hammer/share/man/man5/Makefile#17 integrate
.. //depot/projects/hammer/share/man/man9/hash.9#1 branch
.. //depot/projects/hammer/sys/amd64/amd64/machdep.c#153 integrate
.. //depot/projects/hammer/sys/boot/i386/libi386/Makefile#18 integrate
.. //depot/projects/hammer/sys/boot/i386/libi386/smbios.c#5 integrate
.. //depot/projects/hammer/sys/fs/fifofs/fifo_vnops.c#34 integrate
.. //depot/projects/hammer/sys/i386/i386/machdep.c#69 integrate
.. //depot/projects/hammer/sys/kern/kern_exit.c#58 integrate
.. //depot/projects/hammer/sys/kern/kern_thread.c#88 integrate
.. //depot/projects/hammer/sys/kern/uipc_mbuf.c#39 integrate
.. //depot/projects/hammer/sys/pc98/pc98/machdep.c#10 integrate
.. //depot/projects/hammer/usr.bin/csup/Makefile#2 integrate
.. //depot/projects/hammer/usr.bin/ktrace/ktrace.c#3 integrate
.. //depot/projects/hammer/usr.sbin/bluetooth/bthidd/bthidd.c#4 integrate
.. //depot/projects/hammer/usr.sbin/bluetooth/bthidd/hid.c#3 integrate

Differences ...

==== //depot/projects/hammer/contrib/csup/GNUmakefile#2 (text) ====

@@ -2,7 +2,7 @@
 # be used elsewhere because it assumes that the target system doesn't
 # support BSD extended file flags.
 #
-# $FreeBSD: src/contrib/csup/GNUmakefile,v 1.1.1.1 2006/03/03 04:11:25 mux Exp $
+# $FreeBSD: src/contrib/csup/GNUmakefile,v 1.1.1.2 2006/03/14 03:51:13 mux Exp $
 #
 
 PREFIX?=/usr/local
@@ -12,8 +12,8 @@
 UNAME=	$(shell uname -s)
 
 SRCS=	attrstack.c config.c detailer.c diff.c fattr.c fixups.c fnmatch.c \
-	globtree.c keyword.c lister.c main.c misc.c mux.c pathcomp.c parse.c \
-	proto.c status.c stream.c threads.c token.c updater.c
+	globtree.c idcache.c keyword.c lister.c main.c misc.c mux.c pathcomp.c \
+	parse.c proto.c status.c stream.c threads.c token.c updater.c
 OBJS=	$(SRCS:.c=.o)
 
 WARNS=	-Wall -W -Wno-unused-parameter -Wmissing-prototypes -Wpointer-arith \
@@ -22,10 +22,10 @@
 	-Wnested-externs -Wredundant-decls -Wno-format-y2k
 
 CFLAGS+= -g -O -pipe -DNDEBUG -I$(PREFIX)/include
-ifeq ($(UNAME), "Linux")
+ifeq ($(UNAME), Linux)
 	CFLAGS+= -D_XOPEN_SOURCE -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
 endif
-ifeq ($(UNAME), "Darwin")
+ifeq ($(UNAME), Darwin)
 	CFLAGS+= -DHAVE_FFLAGS
 endif
 CFLAGS+= $(WARNS)

==== //depot/projects/hammer/contrib/csup/Makefile#2 (text) ====

@@ -1,4 +1,4 @@
-# $FreeBSD: src/contrib/csup/Makefile,v 1.1.1.1 2006/03/03 04:11:25 mux Exp $
+# $FreeBSD: src/contrib/csup/Makefile,v 1.1.1.2 2006/03/14 03:51:13 mux Exp $
 
 PREFIX?=	/usr/local
 BINDIR?=	${PREFIX}/bin
@@ -7,27 +7,9 @@
 UNAME!=		/usr/bin/uname -s
 
 PROG=	csup
-SRCS=	attrstack.c attrstack.h \
-	config.c config.h \
-	detailer.c detailer.h \
-	diff.c diff.h \
-	fattr.c fattr.h fattr_bsd.h \
-	fixups.c fixups.h \
-	fnmatch.c fnmatch.h \
-	globtree.c globtree.h \
-	keyword.c keyword.h \
-	lister.c lister.h \
-	main.c main.h \
-	misc.c misc.h \
-	mux.c mux.h \
-	parse.h parse.y \
-	pathcomp.c pathcomp.h \
-	proto.c proto.h \
-	status.c status.h \
-	stream.c stream.h \
-	threads.c threads.h \
-	token.h token.l \
-	updater.c updater.h
+SRCS=	attrstack.c config.c detailer.c diff.c fattr.c fixups.c fnmatch.c \
+	globtree.c idcache.c keyword.c lister.c main.c misc.c mux.c parse.y \
+	pathcomp.c proto.c status.c stream.c threads.c token.l updater.c
 
 CFLAGS+=	-I. -I${.CURDIR} -g -pthread -DHAVE_FFLAGS -DNDEBUG
 WARNS?=		6

==== //depot/projects/hammer/contrib/csup/TODO#2 (text) ====

@@ -1,4 +1,4 @@
-$FreeBSD: src/contrib/csup/TODO,v 1.1.1.1 2006/03/03 04:11:25 mux Exp $
+$FreeBSD: src/contrib/csup/TODO,v 1.1.1.2 2006/03/14 03:51:13 mux Exp $
 
 BUGS:
 
@@ -9,9 +9,6 @@
   has global variables because of yacc, but I think it should be possible
   to do it better by using YYFUNC_PROTOTYPE or something.  I think it
   should also be possible to completely get rid of the lex file.
-- Some code uses getpwnam() while it should use the thread-safe variant,
-  getpwnam_r().  Same for getpwuid() and getgrgid().  We probably need a
-  UID/GID lookup cache here.
 - The $Log$ CVS keyword is not supported.
 - Add missing support for supfile keywords and add sanity checks for
   some of them.  Also, we're not supposed to choke on unknown keywords
@@ -22,9 +19,9 @@
 
 - Add support for authentication.
 - Add support for shell commands sent by the server.
-- Add missing support for various CVSup options : -k, -d, -D,
-  -a (requires authentication support), -e and -E (requires shell
-  commands support) and the destDir parameter.
+- Add missing support for various CVSup options : -D, -a (requires
+  authentication support), -e and -E (requires shell commands support)
+  and the destDir parameter.
 - For now, this code should build fine on FreeBSD, NetBSD, OpenBSD,
   Linux and Darwin.  Solaris support would also be nice at some point.
 - Implement some new useful options : the ability to generate CVS

==== //depot/projects/hammer/contrib/csup/config.c#2 (text) ====

@@ -23,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/contrib/csup/config.c,v 1.1.1.1 2006/03/03 04:11:26 mux Exp $
+ * $FreeBSD: src/contrib/csup/config.c,v 1.1.1.2 2006/03/14 03:51:13 mux Exp $
  */
 
 #include <sys/types.h>
@@ -53,6 +53,8 @@
 static STAILQ_HEAD(, coll) colls;
 static struct coll *cur_coll;
 static struct coll *defaults;
+static struct coll *ovcoll;
+static int ovmask;
 static const char *cfgfile;
 
 /*
@@ -78,13 +80,14 @@
 	mask = umask(0);
 	umask(mask);
 	defaults->co_umask = mask;
+	ovcoll = override;
+	ovmask = overridemask;
 
 	/* Extract a list of collections from the configuration file. */
 	cur_coll = coll_new(defaults);
 	yyin = fopen(file, "r");
 	if (yyin == NULL) {
-		lprintf(-1, "Cannot open \"%s\": %s\n", file,
-		    strerror(errno));
+		lprintf(-1, "Cannot open \"%s\": %s\n", file, strerror(errno));
 		goto bad;
 	}
 	cfgfile = file;
@@ -101,7 +104,6 @@
 
 	/* Fixup the list of collections. */
 	STAILQ_FOREACH(coll, &config->colls, co_next) {
-		coll_override(coll, override, overridemask);
  		if (coll->co_base == NULL)
 			coll->co_base = xstrdup("/usr/local/etc/cvsup");
 		if (coll->co_colldir == NULL)
@@ -229,13 +231,27 @@
 config_parse_refusefile(struct coll *coll, char *path)
 {
 	struct stream *rd;
-	char *line;
+	char *cp, *line, *pat;
 
 	rd = stream_open_file(path, O_RDONLY);
 	if (rd == NULL)
 		return (0);
-	while ((line = stream_getln(rd, NULL)) != NULL)
-		pattlist_add(coll->co_refusals, line);
+	while ((line = stream_getln(rd, NULL)) != NULL) {
+		pat = line;
+		for (;;) {
+			/* Trim leading whitespace. */
+			pat += strspn(pat, " \t");
+			if (pat[0] == '\0')
+				break;
+			cp = strpbrk(pat, " \t");
+			if (cp != NULL)
+				*cp = '\0';
+			pattlist_add(coll->co_refusals, pat);
+			if (cp == NULL)
+				break;
+			pat = cp + 1;
+		}
+	}
 	if (!stream_eof(rd)) {
 		stream_close(rd);
 		lprintf(-1, "Read failure from \"%s\": %s\n", path,
@@ -417,6 +433,7 @@
 	struct coll *coll;
 
 	cur_coll->co_name = name;
+	coll_override(cur_coll, ovcoll, ovmask);
 	if (cur_coll->co_release == NULL) {
 		lprintf(-1, "Release not specified for collection "
 		    "\"%s\"\n", cur_coll->co_name);
@@ -472,6 +489,8 @@
 		globtree_free(coll->co_dirfilter);
 	if (coll->co_dirfilter != NULL)
 		globtree_free(coll->co_filefilter);
+	if (coll->co_norsync != NULL)
+		globtree_free(coll->co_norsync);
 	if (coll->co_accepts != NULL)
 		pattlist_free(coll->co_accepts);
 	if (coll->co_refusals != NULL)
@@ -483,6 +502,7 @@
 coll_setopt(int opt, char *value)
 {
 	struct coll *coll;
+	int error, mask;
 
 	coll = cur_coll;
 	switch (opt) {
@@ -529,14 +549,14 @@
 		coll->co_listsuffix = value;
 		break;
 	case PT_UMASK:
-		errno = 0;
-		coll->co_umask = strtol(value, NULL, 8);
+		error = asciitoint(value, &mask, 8);
 		free(value);
-		if (errno) {
+		if (error) {
 			lprintf(-1, "Parse error in \"%s\": Invalid "
 			    "umask value\n", cfgfile);
 			exit(1);
 		}
+		coll->co_umask = mask;
 		break;
 	case PT_USE_REL_SUFFIX:
 		coll->co_options |= CO_USERELSUFFIX;
@@ -547,6 +567,9 @@
 	case PT_COMPRESS:
 		coll->co_options |= CO_COMPRESS;
 		break;
+	case PT_NORSYNC:
+		coll->co_options |= CO_NORSYNC;
+		break;
 	}
 }
 

==== //depot/projects/hammer/contrib/csup/config.h#2 (text) ====

@@ -23,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/contrib/csup/config.h,v 1.1.1.1 2006/03/03 04:11:26 mux Exp $
+ * $FreeBSD: src/contrib/csup/config.h,v 1.1.1.2 2006/03/14 03:51:12 mux Exp $
  */
 #ifndef _CONFIG_H_
 #define _CONFIG_H_
@@ -86,6 +86,7 @@
 	struct pattlist *co_refusals;
 	struct globtree *co_dirfilter;
 	struct globtree *co_filefilter;
+	struct globtree *co_norsync;
 	const char *co_colldir;
 	char *co_listsuffix;
 	time_t co_scantime;		/* Set by the detailer thread. */
@@ -101,6 +102,7 @@
 	char *host;
 	struct sockaddr *laddr;
 	socklen_t laddrlen;
+	int deletelim;
 	int socket;
 	struct chan *chan0;
 	struct chan *chan1;

==== //depot/projects/hammer/contrib/csup/csup.1#2 (text) ====

@@ -22,7 +22,7 @@
 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
 .\" $Id: cvsup.1,v 1.70 2003/03/04 18:23:46 jdp Exp $
-.\" $FreeBSD: src/contrib/csup/csup.1,v 1.1.1.1 2006/03/03 04:11:26 mux Exp $
+.\" $FreeBSD: src/contrib/csup/csup.1,v 1.1.1.2 2006/03/14 03:51:12 mux Exp $
 .\"
 .Dd February 1, 2006
 .Os FreeBSD
@@ -32,10 +32,11 @@
 .Nd network distribution package for CVS repositories
 .Sh SYNOPSIS
 .Nm
-.Op Fl 146svzZ
+.Op Fl 146ksvzZ
 .Op Fl A Ar addr
 .Op Fl b Ar base
 .Op Fl c Ar collDir
+.Op Fl d Ar delLimit
 .Op Fl h Ar host
 .Op Fl i Ar pattern
 .Op Fl l Ar lockfile
@@ -123,6 +124,13 @@
 where the information about the collections is maintained.
 The default is
 .Pa sup .
+.It Fl d Ar delLimit
+Specifies the maximum number of files that may be deleted in a
+single update run.
+Any attempt to exceed the limit results in a fatal error.
+This can provide some protection against temporary configuration
+mistakes on the server.
+The default limit is infinity.
 .It Fl h Ar host
 Specifies the server host to contact, overriding any
 .Cm host
@@ -148,6 +156,17 @@
 It is interpreted relative to the collection's prefix directory.
 Slash characters are matched only by explicit slashes in the pattern.
 Leading periods in file name are not treated specially.
+.It Fl k
+Causes
+.Nm
+to keep the temporary copies of any incorrectly edited files, in the
+event of checksum mismatches.
+This option is for debugging, to help determine why the files were
+edited incorrectly.
+Regardless of whether this option is specified, the permanent versions
+of faulty files are replaced with correct versions obtained by
+transferring the files in their entirety.
+Such transfers are called fixups.
 .It Fl l Ar lockfile
 Creates and locks the
 .Ar lockfile

==== //depot/projects/hammer/contrib/csup/fattr.c#2 (text) ====

@@ -23,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/contrib/csup/fattr.c,v 1.1.1.1 2006/03/03 04:11:26 mux Exp $
+ * $FreeBSD: src/contrib/csup/fattr.c,v 1.1.1.2 2006/03/14 03:51:12 mux Exp $
  */
 
 #include <sys/time.h>
@@ -32,14 +32,13 @@
 
 #include <assert.h>
 #include <errno.h>
-#include <grp.h>
-#include <pwd.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
 
 #include "fattr.h"
+#include "idcache.h"
 #include "misc.h"
 
 /*
@@ -126,6 +125,8 @@
 		fa->mask |= FA_MODE;
 		defaults[i] = fa;
 	}
+	/* Initialize the uid/gid lookup cache. */
+	idcache_init();
 }
 
 void
@@ -133,6 +134,7 @@
 {
 	int i;
 
+	idcache_fini();
 	for (i = 0; i < FT_NUMBER; i++)
 		fattr_free(defaults[i]);
 }
@@ -336,29 +338,26 @@
 		int extval;
 		char *ext;
 	} pieces[FA_NUMBER], *piece;
-	struct passwd *pw;
-	struct group *gr;
-	char *cp, *s;
+	char *cp, *s, *username, *groupname;
 	size_t len, vallen;
 	mode_t mode, modemask;
 	int mask, n, i;
 
-	pw = NULL;
-	gr = NULL;
+	username = NULL;
+	groupname = NULL;
 	if (support == NULL)
 		mask = fa->mask;
 	else
 		mask = fa->mask & support[fa->type];
 	mask &= ~ignore;
-	/* XXX - Use getpwuid_r() and getgrgid_r(). */
 	if (fa->mask & FA_OWNER) {
-		pw = getpwuid(fa->uid);
-		if (pw == NULL)
+		username = getuserbyid(fa->uid);
+		if (username == NULL)
 			mask &= ~FA_OWNER;
 	}
 	if (fa->mask & FA_GROUP) {
-		gr = getgrgid(fa->gid);
-		if (gr == NULL)
+		groupname = getgroupbyid(fa->gid);
+		if (groupname == NULL)
 			mask &= ~FA_GROUP;
 	}
 	if (fa->mask & FA_LINKCOUNT && fa->linkcount == 1)
@@ -408,17 +407,17 @@
 		piece++;
 	}
 	if (mask & FA_OWNER) {
-		vallen = strlen(pw->pw_name);
+		vallen = strlen(username);
 		piece->extval = 1;
-		piece->ext = pw->pw_name;
+		piece->ext = username;
 		len += snprintf(piece->len, sizeof(piece->len), "%lld",
 		    (long long)vallen) + vallen + 1;
 		piece++;
 	}
 	if (mask & FA_GROUP) {
-		vallen = strlen(gr->gr_name);
+		vallen = strlen(groupname);
 		piece->extval = 1;
-		piece->ext = gr->gr_name;
+		piece->ext = groupname;
 		len += snprintf(piece->len, sizeof(piece->len), "%lld",
 		    (long long)vallen) + vallen + 1;
 		piece++;
@@ -551,11 +550,10 @@
 static char *
 fattr_scanattr(struct fattr *fa, int type, const char *attr)
 {
-	struct passwd *pw;
-	struct group *gr;
 	char *attrend, *attrstart, *end;
 	size_t len;
 	unsigned long attrlen;
+	int error;
 	mode_t modemask;
 	char tmp;
 
@@ -606,21 +604,13 @@
 			goto bad;
 		break;
 	case FA_OWNER:
-		/*
-		 * XXX - We need to use getpwnam_r() since getpwnam()
-		 * is not thread-safe, and we also need to use a cache.
-		 */
-		pw = getpwnam(attrstart);
-		if (pw != NULL)
-			fa->uid = pw->pw_uid;
-		else
+		error = getuidbyname(attrstart, &fa->uid);
+		if (error)
 			fa->mask &= ~FA_OWNER;
 		break;
 	case FA_GROUP:
-		gr = getgrnam(attrstart);
-		if (gr != NULL)
-			fa->gid = gr->gr_gid;
-		else
+		error = getgidbyname(attrstart, &fa->gid);
+		if (error)
 			fa->mask &= ~FA_GROUP;
 		break;
 	case FA_MODE:
@@ -770,11 +760,13 @@
 		return (-1);
 	}
 
+#ifdef HAVE_FFLAGS
 	/* Clear flags. */
 	if (fa->mask & FA_FLAGS && fa->flags != 0) {
 		fa->flags = 0;
 		(void)chflags(path, fa->flags);
 	}
+#endif
 
 	if (fa->type == FT_DIRECTORY)
 		error = rmdir(path);
@@ -812,35 +804,35 @@
 		inplace = 1;
 	}
 	old = fattr_frompath(topath, FATTR_NOFOLLOW);
-	if (old == NULL)
-		return (-1);
-	if (inplace && fattr_equal(fa, old)) {
-		fattr_free(old);
-		return (0);
-	}
+	if (old != NULL) {
+		if (inplace && fattr_equal(fa, old)) {
+			fattr_free(old);
+			return (0);
+		}
 
 #ifdef HAVE_FFLAGS
-	/*
-	 * Determine whether we need to clear the flags of the target.
-	 * This is bogus in that it assumes a value of 0 is safe and
-	 * that non-zero is unsafe.  I'm not really worried by that
-	 * since as far as I know that's the way things are.
-	 */
-	if ((old->mask & FA_FLAGS) && old->flags > 0) {
-		(void)chflags(topath, 0);
-		old->flags = 0;
-	}
+		/*
+		 * Determine whether we need to clear the flags of the target.
+		 * This is bogus in that it assumes a value of 0 is safe and
+		 * that non-zero is unsafe.  I'm not really worried by that
+		 * since as far as I know that's the way things are.
+		 */
+		if ((old->mask & FA_FLAGS) && old->flags > 0) {
+			(void)chflags(topath, 0);
+			old->flags = 0;
+		}
 #endif
 
-	/* Determine whether we need to remove the target first. */
-	if (!inplace && (fa->type == FT_DIRECTORY) !=
-	    (old->type == FT_DIRECTORY)) {
-		if (old->type == FT_DIRECTORY)
-			error = rmdir(topath);
-		else
-			error = unlink(topath);
-		if (error)
-			goto bad;
+		/* Determine whether we need to remove the target first. */
+		if (!inplace && (fa->type == FT_DIRECTORY) !=
+		    (old->type == FT_DIRECTORY)) {
+			if (old->type == FT_DIRECTORY)
+				error = rmdir(topath);
+			else
+				error = unlink(topath);
+			if (error)
+				goto bad;
+		}
 	}
 
 	/* Change those attributes that we can before moving the file
@@ -866,8 +858,8 @@
 	}
 	if (mask & FA_MODE) {
 		newmode = fa->mode & modemask;
-		/* Merge in set*id bits from the old attribute.  XXX - Why? */
-		if (old->mask & FA_MODE) {
+		/* Merge in set*id bits from the old attribute. */
+		if (old != NULL && old->mask & FA_MODE) {
 			newmode |= (old->mode & ~modemask);
 			newmode &= (FA_SETIDMASK | FA_PERMMASK);
 		}

==== //depot/projects/hammer/contrib/csup/globtree.c#2 (text) ====

@@ -23,16 +23,16 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/contrib/csup/globtree.c,v 1.1.1.1 2006/03/03 04:11:27 mux Exp $
+ * $FreeBSD: src/contrib/csup/globtree.c,v 1.1.1.2 2006/03/14 03:51:12 mux Exp $
  */
 
 #include <sys/types.h>
 
 #include <assert.h>
-#include <fnmatch.h>
 #include <regex.h>
 #include <stdlib.h>
 
+#include "fnmatch.h"
 #include "globtree.h"
 #include "misc.h"
 

==== //depot/projects/hammer/contrib/csup/lister.c#2 (text) ====

@@ -23,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/contrib/csup/lister.c,v 1.1.1.1 2006/03/03 04:11:27 mux Exp $
+ * $FreeBSD: src/contrib/csup/lister.c,v 1.1.1.2 2006/03/14 03:51:12 mux Exp $
  */
 
 #include <assert.h>
@@ -145,6 +145,7 @@
 	struct attrstack *as;
 	struct statusrec *sr;
 	struct fattr *fa;
+	size_t i;
 	int depth, error, ret, prunedepth;
 
 	wr = l->wr;
@@ -203,7 +204,7 @@
 		return (LISTER_ERR_WRITE);
 	return (0);
 bad:
-	while (depth-- > 0) {
+	for (i = 0; i < attrstack_size(as); i++) {
 		fa = attrstack_pop(as);
 		fattr_free(fa);
 	}

==== //depot/projects/hammer/contrib/csup/main.c#2 (text) ====

@@ -23,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/contrib/csup/main.c,v 1.1.1.1 2006/03/03 04:11:28 mux Exp $
+ * $FreeBSD: src/contrib/csup/main.c,v 1.1.1.2 2006/03/14 03:51:11 mux Exp $
  */
 
 #include <sys/file.h>
@@ -66,6 +66,8 @@
 	    "Override supfile's \"base\" directory");
 	lprintf(-1, USAGE_OPTFMT, "-c collDir",
 	    "Subdirectory of \"base\" for collections (default \"sup\")");
+	lprintf(-1, USAGE_OPTFMT, "-d delLimit",
+	    "Allow at most \"delLimit\" file deletions (default unlimited)");
 	lprintf(-1, USAGE_OPTFMT, "-h host",
 	    "Override supfile's \"host\" name");
 	lprintf(-1, USAGE_OPTFMT, "-i pattern",
@@ -73,6 +75,8 @@
 	lprintf(-1, USAGE_OPTFMTSUB,
 	    "May be repeated for an OR operation.  Default is");
 	lprintf(-1, USAGE_OPTFMTSUB, "to include each entire collection.");
+	lprintf(-1, USAGE_OPTFMT, "-k",
+	    "Keep bad temporary files when fixups are required");
 	lprintf(-1, USAGE_OPTFMT, "-l lockfile",
 	    "Lock file during update; fail if already locked");
 	lprintf(-1, USAGE_OPTFMT, "-L n",
@@ -102,13 +106,13 @@
 	socklen_t laddrlen;
 	struct stream *lock;
 	char *argv0, *file, *lockfile;
-	uint16_t port;
 	int family, error, lockfd, lflag, overridemask;
-	int c, i, retries, status;
+	int c, i, deletelim, port, retries, status;
 	time_t nexttry;
 
 	error = 0;
 	family = PF_UNSPEC;
+	deletelim = -1;
 	port = 0;
 	lflag = 0;
 	lockfd = 0;
@@ -121,7 +125,8 @@
 	override = coll_new(NULL);
 	overridemask = 0;
 
-	while ((c = getopt(argc, argv, "146A:b:c:gh:i:l:L:p:P:r:svzZ")) != -1) {
+	while ((c = getopt(argc, argv,
+	    "146A:b:c:d:gh:i:kl:L:p:P:r:svzZ")) != -1) {
 		switch (c) {
 		case '1':
 			retries = 0;
@@ -152,6 +157,14 @@
 		case 'c':
 			override->co_colldir = optarg;
 			break;
+		case 'd':
+			error = asciitoint(optarg, &deletelim, 0);
+			if (error || deletelim < 0) {
+				lprintf(-1, "Invalid deletion limit\n");
+				usage(argv0);
+				return (1);
+			}
+			break;
 		case 'g':
 			/* For compatibility. */
 			break;
@@ -163,6 +176,10 @@
 		case 'i':
 			pattlist_add(override->co_accepts, optarg);
 			break;
+		case 'k':
+			override->co_options |= CO_KEEPBADFILES;
+			overridemask |= CO_KEEPBADFILES;
+			break;
 		case 'l':
 			lockfile = optarg;
 			lflag = 1;
@@ -191,9 +208,8 @@
 			stream_close(lock);
 			break;
 		case 'L':
-			errno = 0;
-			verbose = strtol(optarg, NULL, 0);
-			if (errno == EINVAL) {
+			error = asciitoint(optarg, &verbose, 0);
+			if (error) {
 				lprintf(-1, "Invalid verbosity\n");
 				usage(argv0);
 				return (1);
@@ -201,13 +217,21 @@
 			break;
 		case 'p':
 			/* Use specified server port. */
-			errno = 0;
-			port = strtol(optarg, NULL, 0);
-			if (errno == EINVAL) {
+			error = asciitoint(optarg, &port, 0);
+			if (error) {
 				lprintf(-1, "Invalid server port\n");
 				usage(argv0);
 				return (1);
 			}
+			if (port <= 0 || port >= 65536) {
+				lprintf(-1, "Invalid port %d\n", port);
+				return (1);
+			}
+			if (port < 1024) {
+				lprintf(-1, "Reserved port %d not permitted\n",
+				    port);
+				return (1);
+			}
 			break;
 		case 'P':
 			/* For compatibility. */
@@ -218,9 +242,8 @@
 			}
 			break;
 		case 'r':
-			errno = 0;
-			retries = strtol(optarg, NULL, 0);
-			if (errno == EINVAL || retries < 0) {
+			error = asciitoint(optarg, &retries, 0);
+			if (error || retries < 0) {
 				lprintf(-1, "Invalid retry limit\n");
 				usage(argv0);
 				return (1);
@@ -270,15 +293,16 @@
 	if (config == NULL)
 		return (1);
 
-	if (laddr != NULL) {
-		config->laddr = laddr;
-		config->laddrlen = laddrlen;
-	}
 	if (config_checkcolls(config) == 0) {
 		lprintf(-1, "No collections selected\n");
 		return (1);
 	}
 
+	if (laddr != NULL) {
+		config->laddr = laddr;
+		config->laddrlen = laddrlen;
+	}
+	config->deletelim = deletelim;
 	lprintf(2, "Connecting to %s\n", config->host);
 
 	i = 0;

==== //depot/projects/hammer/contrib/csup/misc.c#2 (text) ====

@@ -23,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/contrib/csup/misc.c,v 1.1.1.2 2006/03/03 18:45:08 mux Exp $
+ * $FreeBSD: src/contrib/csup/misc.c,v 1.1.1.3 2006/03/14 03:51:11 mux Exp $
  */
 
 #include <sys/types.h>
@@ -34,6 +34,7 @@
 #include <err.h>
 #include <errno.h>
 #include <fcntl.h>
+#include <limits.h>
 #include <pthread.h>
 #include <stdarg.h>
 #include <stdio.h>
@@ -64,6 +65,24 @@
 static void	bt_addjitter(struct backoff_timer *);
 
 int
+asciitoint(const char *s, int *val, int base)
+{
+	char *end;
+	long longval;
+
+	errno = 0;
+	longval = strtol(s, &end, base);
+	if (errno || *end != '\0')
+		return (-1);
+	if (longval > INT_MAX || longval < INT_MIN) {
+		errno = ERANGE;
+		return (-1);
+	}
+	*val = longval;
+	return (0);
+}
+
+int
 lprintf(int level, const char *fmt, ...)
 {
 	FILE *to;

==== //depot/projects/hammer/contrib/csup/misc.h#2 (text) ====

@@ -23,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/contrib/csup/misc.h,v 1.1.1.1 2006/03/03 04:11:28 mux Exp $
+ * $FreeBSD: src/contrib/csup/misc.h,v 1.1.1.2 2006/03/14 03:51:11 mux Exp $
  */
 #ifndef _MISC_H_
 #define _MISC_H_
@@ -99,6 +99,7 @@
 struct pattlist;
 struct tm;
 
+int	 asciitoint(const char *, int *, int);
 int	 lprintf(int, const char *, ...) __printflike(2, 3);
 int	 MD5_File(char *, char *);
 void	 MD5_End(char *, MD5_CTX *);
@@ -125,4 +126,5 @@
 time_t			 bt_get(struct backoff_timer *);
 void			 bt_pause(struct backoff_timer *);
 void			 bt_free(struct backoff_timer *);
+
 #endif /* !_MISC_H_ */

==== //depot/projects/hammer/contrib/csup/proto.c#2 (text) ====

@@ -23,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/contrib/csup/proto.c,v 1.1.1.1 2006/03/03 04:11:28 mux Exp $
+ * $FreeBSD: src/contrib/csup/proto.c,v 1.1.1.2 2006/03/14 03:51:11 mux Exp $
  */
 
 #include <sys/param.h>
@@ -35,7 +35,6 @@
 #include <assert.h>
 #include <err.h>
 #include <errno.h>
-#include <limits.h>
 #include <netdb.h>
 #include <pthread.h>
 #include <signal.h>
@@ -228,7 +227,7 @@
 	stream_flush(s);
 	line = stream_getln(s, NULL);
 	cmd = proto_get_ascii(&line);
-	if (line == NULL)
+	if (cmd == NULL || line == NULL)
 		goto bad;
 	if (strcmp(cmd, "!") == 0) {
 		msg = proto_get_rest(&line);
@@ -256,13 +255,20 @@
 proto_login(struct config *config)
 {
 	struct stream *s;
-	char host[MAXHOSTNAMELEN];
-	char *line, *cmd, *realm, *challenge, *msg;
+	char hostbuf[MAXHOSTNAMELEN];
+	char *line, *login, *host, *cmd, *realm, *challenge, *msg;
+	int error;
 
 	s = config->server;
-	gethostname(host, sizeof(host));
-	host[sizeof(host) - 1] = '\0';
-	proto_printf(s, "USER %s %s\n", getlogin(), host);
+	error = gethostname(hostbuf, sizeof(hostbuf));
+	hostbuf[sizeof(hostbuf) - 1] = '\0';
+	if (error)
+		host = NULL;
+	else
+		host = hostbuf;
+	login = getlogin();
+	proto_printf(s, "USER %s %s\n", login != NULL ? login : "?",
+	    host != NULL ? host : "?");
 	stream_flush(s);
 	line = stream_getln(s, NULL);
 	cmd = proto_get_ascii(&line);
@@ -279,6 +285,8 @@
 	stream_flush(s);
 	line = stream_getln(s, NULL);
 	cmd = proto_get_ascii(&line);
+	if (cmd == NULL || line == NULL)
+		goto bad;
 	if (strcmp(cmd, "OK") == 0)
 		return (STATUS_SUCCESS);
 	if (strcmp(cmd, "!") == 0) {
@@ -371,9 +379,11 @@
 	}
 	proto_printf(s, ".\n");
 	stream_flush(s);
+
 	STAILQ_FOREACH(coll, &config->colls, co_next) {
 		if (coll->co_options & CO_SKIP)
 			continue;
+		coll->co_norsync = globtree_false();
 		line = stream_getln(s, NULL);
 		if (line == NULL)
 			goto bad;
@@ -430,7 +440,21 @@
 				    ident);
 				if (error)
 					goto bad;
-			}
+			} else if (strcmp(cmd, "NORS") == 0) {
+				pat = proto_get_ascii(&line);
+				if (pat == NULL || line != NULL)
+					goto bad;
+				coll->co_norsync = globtree_or(coll->co_norsync,
+				    globtree_match(pat, FNM_PATHNAME));
+			} else if (strcmp(cmd, "RNORS") == 0) {
+				pat = proto_get_ascii(&line);
+				if (pat == NULL || line != NULL)
+					goto bad;
+				coll->co_norsync = globtree_or(coll->co_norsync,
+				    globtree_match(pat, FNM_PATHNAME |
+				    FNM_LEADING_DIR));
+			} else
+				goto bad;
 		}
 		if (line == NULL)
 			goto bad;
@@ -904,22 +928,14 @@
 int
 proto_get_int(char **s, int *val, int base)
 {
-	char *cp, *end;
-	long longval;
+	char *cp;
+	int error;
 
 	cp = proto_get_ascii(s);
 	if (cp == NULL)
 		return (-1);
-	errno = 0;
-	longval = strtol(cp, &end, base);
-	if (errno || *end != '\0')
-		return (-1);
-	if (longval > INT_MAX || longval < INT_MIN) {
-		errno = ERANGE;
-		return (-1);
-	}
-	*val = longval;
-	return (0);
+	error = asciitoint(cp, val, base);
+	return (error);
 }
 
 /*


>>> TRUNCATED FOR MAIL (1000 lines) <<<


More information about the p4-projects mailing list