CVS commit: src/usr.sbin/sup/source

2019-02-14 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Feb 14 20:19:51 UTC 2019

Modified Files:
src/usr.sbin/sup/source: supcmeat.c

Log Message:
add breaks for done() since it might not be __dead.


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/usr.sbin/sup/source/supcmeat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/sup/source/supcmeat.c
diff -u src/usr.sbin/sup/source/supcmeat.c:1.42 src/usr.sbin/sup/source/supcmeat.c:1.43
--- src/usr.sbin/sup/source/supcmeat.c:1.42	Tue Apr  9 12:39:20 2013
+++ src/usr.sbin/sup/source/supcmeat.c	Thu Feb 14 15:19:51 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: supcmeat.c,v 1.42 2013/04/09 16:39:20 christos Exp $	*/
+/*	$NetBSD: supcmeat.c,v 1.43 2019/02/14 20:19:51 christos Exp $	*/
 
 /*
  * Copyright (c) 1992 Carnegie Mellon University
@@ -371,17 +371,21 @@ setup(TREE * t)
 	case FSETUPSAME:
 		notify(1, "Attempt to upgrade from same host to same directory");
 		done(FDONESRVERROR, "Overwrite error");
+		break;
 	case FSETUPHOST:
 		notify(1, "This host has no permission to access %s",
 		collname);
 		done(FDONESRVERROR, "Permission denied");
+		break;
 	case FSETUPOLD:
 		notify(1, "This version of SUP is too old for the fileserver");
 		done(FDONESRVERROR, "Obsolete client");
+		break;
 	case FSETUPRELEASE:
 		notify(1, "Invalid release %s for collection %s",
 		release == NULL ? DEFRELEASE : release, collname);
 		done(FDONESRVERROR, "Invalid release");
+		break;
 	case FSETUPBUSY:
 		vnotify(0, "Fileserver is currently busy");
 		t->Tmode = SCMOK;



CVS commit: src/usr.sbin/sup/source

2019-02-14 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Feb 14 17:08:54 UTC 2019

Modified Files:
src/usr.sbin/sup/source: supextern.h

Log Message:
done is not always done (it returns, it is not dead)


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/usr.sbin/sup/source/supextern.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/sup/source/supextern.h
diff -u src/usr.sbin/sup/source/supextern.h:1.27 src/usr.sbin/sup/source/supextern.h:1.28
--- src/usr.sbin/sup/source/supextern.h:1.27	Wed Feb  6 12:21:51 2019
+++ src/usr.sbin/sup/source/supextern.h	Thu Feb 14 12:08:54 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: supextern.h,v 1.27 2019/02/06 17:21:51 christos Exp $	*/
+/*	$NetBSD: supextern.h,v 1.28 2019/02/14 17:08:54 christos Exp $	*/
 
 struct stat;
 
@@ -133,7 +133,7 @@ int recvreg(TREE *, int, struct stat *);
 int copyfile(char *, char *);
 void finishup(int);
 void done(int, const char *, ...)
-	__attribute__((__format__(__printf__, 2, 3))) __dead;
+	__attribute__((__format__(__printf__, 2, 3)));
 void goaway(const char *, ...)
 	__attribute__((__format__(__printf__, 1, 2)));
 



CVS commit: src/usr.sbin/sup/source

2019-02-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Feb  6 17:21:51 UTC 2019

Modified Files:
src/usr.sbin/sup/source: supextern.h

Log Message:
quit is dead


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/usr.sbin/sup/source/supextern.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/sup/source/supextern.h
diff -u src/usr.sbin/sup/source/supextern.h:1.26 src/usr.sbin/sup/source/supextern.h:1.27
--- src/usr.sbin/sup/source/supextern.h:1.26	Wed Feb  6 10:43:13 2019
+++ src/usr.sbin/sup/source/supextern.h	Wed Feb  6 12:21:51 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: supextern.h,v 1.26 2019/02/06 15:43:13 christos Exp $	*/
+/*	$NetBSD: supextern.h,v 1.27 2019/02/06 17:21:51 christos Exp $	*/
 
 struct stat;
 
@@ -43,7 +43,7 @@ void path(const char *, char *, char *);
 
 /* quit.c */
 void quit(int, const char *, ...)
-	__attribute__((__format__(__printf__, 2, 3)));
+	__attribute__((__format__(__printf__, 2, 3))) __dead;
 
 /* read_line.c */
 char *read_line(FILE *, size_t *, size_t *, const char[3], int);



CVS commit: src/usr.sbin/sup/source

2019-02-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Feb  6 15:43:13 UTC 2019

Modified Files:
src/usr.sbin/sup/source: supextern.h

Log Message:
done returns if !dontjump


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/usr.sbin/sup/source/supextern.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/sup/source/supextern.h
diff -u src/usr.sbin/sup/source/supextern.h:1.25 src/usr.sbin/sup/source/supextern.h:1.26
--- src/usr.sbin/sup/source/supextern.h:1.25	Sun Feb  3 07:13:37 2019
+++ src/usr.sbin/sup/source/supextern.h	Wed Feb  6 10:43:13 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: supextern.h,v 1.25 2019/02/03 12:13:37 mrg Exp $	*/
+/*	$NetBSD: supextern.h,v 1.26 2019/02/06 15:43:13 christos Exp $	*/
 
 struct stat;
 
@@ -43,7 +43,7 @@ void path(const char *, char *, char *);
 
 /* quit.c */
 void quit(int, const char *, ...)
-	__attribute__((__format__(__printf__, 2, 3))) __dead;
+	__attribute__((__format__(__printf__, 2, 3)));
 
 /* read_line.c */
 char *read_line(FILE *, size_t *, size_t *, const char[3], int);



CVS commit: src/usr.sbin/sup/source

2019-02-03 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Mon Feb  4 01:07:34 UTC 2019

Modified Files:
src/usr.sbin/sup/source: scmio.c

Log Message:
Fix handling of pushback operation which isn't using negative lengths
for about 10 years.

Found by gcc7.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/usr.sbin/sup/source/scmio.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/sup/source/scmio.c
diff -u src/usr.sbin/sup/source/scmio.c:1.22 src/usr.sbin/sup/source/scmio.c:1.23
--- src/usr.sbin/sup/source/scmio.c:1.22	Fri Mar  8 20:56:44 2013
+++ src/usr.sbin/sup/source/scmio.c	Mon Feb  4 01:07:34 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: scmio.c,v 1.22 2013/03/08 20:56:44 christos Exp $	*/
+/*	$NetBSD: scmio.c,v 1.23 2019/02/04 01:07:34 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 1992 Carnegie Mellon University
@@ -434,11 +434,11 @@ readdata(size_t count, void *vdata, bool
 	char *data = vdata;
 
 	if (push) {
-		if (bufptr + count < buffer)
+		if (bufptr - count < buffer)
 			return (scmerr(-1, "No space in buffer %zu", count));
 		bufptr -= count;
 		bufcnt += count;
-		memcpy(bufptr, data, -count);
+		memcpy(bufptr, data, count);
 		return (SCMOK);
 	}
 	if (count == 0 && data == NULL) {



CVS commit: src/usr.sbin/sup/source

2019-02-03 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sun Feb  3 12:13:37 UTC 2019

Modified Files:
src/usr.sbin/sup/source: supextern.h

Log Message:
- mark logerr(), quit() and done() as __dead.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/usr.sbin/sup/source/supextern.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/sup/source/supextern.h
diff -u src/usr.sbin/sup/source/supextern.h:1.24 src/usr.sbin/sup/source/supextern.h:1.25
--- src/usr.sbin/sup/source/supextern.h:1.24	Fri Mar  8 20:56:44 2013
+++ src/usr.sbin/sup/source/supextern.h	Sun Feb  3 12:13:37 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: supextern.h,v 1.24 2013/03/08 20:56:44 christos Exp $	*/
+/*	$NetBSD: supextern.h,v 1.25 2019/02/03 12:13:37 mrg Exp $	*/
 
 struct stat;
 
@@ -19,7 +19,7 @@ void logopen(char *);
 void logquit(int, const char *, ...)
 	__attribute__((__format__(__printf__, 2, 3)));
 void logerr(const char *, ...)
-	__attribute__((__format__(__printf__, 1, 2))) ;
+	__attribute__((__format__(__printf__, 1, 2)));
 void loginfo(const char *, ...)
 	__attribute__((__format__(__printf__, 1, 2)));
 #ifdef LIBWRAP
@@ -43,7 +43,7 @@ void path(const char *, char *, char *);
 
 /* quit.c */
 void quit(int, const char *, ...)
-	__attribute__((__format__(__printf__, 2, 3)));
+	__attribute__((__format__(__printf__, 2, 3))) __dead;
 
 /* read_line.c */
 char *read_line(FILE *, size_t *, size_t *, const char[3], int);
@@ -133,7 +133,7 @@ int recvreg(TREE *, int, struct stat *);
 int copyfile(char *, char *);
 void finishup(int);
 void done(int, const char *, ...)
-	__attribute__((__format__(__printf__, 2, 3)));
+	__attribute__((__format__(__printf__, 2, 3))) __dead;
 void goaway(const char *, ...)
 	__attribute__((__format__(__printf__, 1, 2)));
 



CVS commit: src/usr.sbin/sup/source

2016-03-11 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sat Mar 12 02:27:31 UTC 2016

Modified Files:
src/usr.sbin/sup/source: cvt.c

Log Message:
Close file on error path. PR 50925 from David Binderman.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/sup/source/cvt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/sup/source/cvt.c
diff -u src/usr.sbin/sup/source/cvt.c:1.3 src/usr.sbin/sup/source/cvt.c:1.4
--- src/usr.sbin/sup/source/cvt.c:1.3	Wed Jul 10 18:53:57 2002
+++ src/usr.sbin/sup/source/cvt.c	Sat Mar 12 02:27:31 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: cvt.c,v 1.3 2002/07/10 18:53:57 wiz Exp $	*/
+/*	$NetBSD: cvt.c,v 1.4 2016/03/12 02:27:31 dholland Exp $	*/
 
 /*
  * Quick hack to convert old binary sup when.collection files into 
@@ -45,6 +45,7 @@ main(int argc, char **argv)
 
 	if (fprintf(fp, "%ld\n", b) < 0) {
 		perror("fprintf");
+		fclose(fp);
 		return 1;
 	}
 	if (fclose(fp) != 0) {



CVS commit: src/usr.sbin/sup/source

2016-03-11 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sat Mar 12 02:26:40 UTC 2016

Modified Files:
src/usr.sbin/sup/source: scan.c

Log Message:
Don't cast malloc.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/usr.sbin/sup/source/scan.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/sup/source/scan.c
diff -u src/usr.sbin/sup/source/scan.c:1.31 src/usr.sbin/sup/source/scan.c:1.32
--- src/usr.sbin/sup/source/scan.c:1.31	Fri Mar  8 20:56:44 2013
+++ src/usr.sbin/sup/source/scan.c	Sat Mar 12 02:26:40 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: scan.c,v 1.31 2013/03/08 20:56:44 christos Exp $	*/
+/*	$NetBSD: scan.c,v 1.32 2016/03/12 02:26:40 dholland Exp $	*/
 
 /*
  * Copyright (c) 1992 Carnegie Mellon University
@@ -213,7 +213,7 @@ parserelease(TREELIST ** tlp, char *reln
 	int opno;
 	char *nextrel;
 
-	tl = (TREELIST *) malloc(sizeof(TREELIST));
+	tl = malloc(sizeof(TREELIST));
 	if ((*tlp = tl) == NULL)
 		goaway("Couldn't allocate TREELIST");
 	tl->TLnext = NULL;



CVS commit: src/usr.sbin/sup/source

2015-12-13 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Dec 13 18:14:13 UTC 2015

Modified Files:
src/usr.sbin/sup/source: expand.c

Log Message:
PR/50547: David Binderman: fix bad sizeof


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/usr.sbin/sup/source/expand.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/sup/source/expand.c
diff -u src/usr.sbin/sup/source/expand.c:1.18 src/usr.sbin/sup/source/expand.c:1.19
--- src/usr.sbin/sup/source/expand.c:1.18	Sat Oct 17 18:26:13 2009
+++ src/usr.sbin/sup/source/expand.c	Sun Dec 13 13:14:13 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: expand.c,v 1.18 2009/10/17 22:26:13 christos Exp $	*/
+/*	$NetBSD: expand.c,v 1.19 2015/12/13 18:14:13 christos Exp $	*/
 
 /*
  * Copyright (c) 1991 Carnegie Mellon University
@@ -78,6 +78,7 @@
 static jmp_buf sjbuf;
 
 static char pathbuf[MAXPATHLEN];
+static size_t maxpathlen;
 static char *path, *pathp, *lastpathp;
 
 static const char globchars[] = "{[*?";/* meta characters */
@@ -104,7 +105,8 @@ expand(char *spec, char **buffer, int bu
 {
 	pathp = path = pathbuf;
 	*pathp = 0;
-	lastpathp = [MAXPATHLEN - 2];
+	maxpathlen = sizeof(pathbuf) - 1;
+	lastpathp = [maxpathlen];
 	BUFFER = buffer;
 	BUFSIZE = bufsize;
 	bufcnt = 0;
@@ -131,12 +133,11 @@ glob(char *as)
 		if (!*cs || *cs == '/') {
 			if (pathp != path + 1) {
 *pathp = 0;
-if (gethdir(path + 1, sizeof path - 1))
+if (gethdir(path + 1, maxpathlen))
 	goto endit;
-strncpy(path, path + 1, sizeof path - 1);
+strlcpy(path, path + 1, maxpathlen);
 			} else
-strncpy(path, (char *) getenv("HOME"), sizeof path - 1);
-			path[sizeof path - 1] = '\0';
+strlcpy(path, getenv("HOME"), maxpathlen);
 			pathp = path + strlen(path);
 		}
 	}
@@ -398,7 +399,6 @@ gethdir(char *home, size_t homelen)
 
 	if (pp == 0)
 		return (1);
-	strncpy(home, pp->pw_dir, homelen - 1);
-	home[homelen - 1] = '\0';
+	strlcpy(home, pp->pw_dir, homelen);
 	return (0);
 }



CVS commit: src/usr.sbin/sup/source

2013-05-28 Thread S.P.Zeidler
Module Name:src
Committed By:   spz
Date:   Tue May 28 20:13:17 UTC 2013

Modified Files:
src/usr.sbin/sup/source: supservers.8

Log Message:
document the anon account for anonymous access
fixing PR misc/5545
(the last bits thereof)


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.sbin/sup/source/supservers.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/sup/source/supservers.8
diff -u src/usr.sbin/sup/source/supservers.8:1.10 src/usr.sbin/sup/source/supservers.8:1.11
--- src/usr.sbin/sup/source/supservers.8:1.10	Mon Nov  2 00:33:34 2009
+++ src/usr.sbin/sup/source/supservers.8	Tue May 28 20:13:16 2013
@@ -1,4 +1,4 @@
-.\	$NetBSD: supservers.8,v 1.10 2009/11/02 00:33:34 joerg Exp $
+.\	$NetBSD: supservers.8,v 1.11 2013/05/28 20:13:16 spz Exp $
 .\
 .\ Copyright (c) 1992 Carnegie Mellon University
 .\ All Rights Reserved.
@@ -116,6 +116,13 @@ the server will listen for a network con
 This is useful for debugging the servers in live mode rather than as
 daemons.
 
+If anonymous serving of files is desired, an account
+.I anon
+needs to exist.
+This account should have /sbin/nologin as shell, no password, needs to be
+able to read the files to be served (but not to write or to own them), and
+should have as home the directory containing the files to be served.
+
 For debugging purposes, the -P debugging ports flag can be used.
 It will cause the selection of an alternate, non-privileged set of
 TCP ports instead of the usual ports, which are reserved for the



CVS commit: src/usr.sbin/sup/source

2013-04-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Apr  9 16:38:21 UTC 2013

Modified Files:
src/usr.sbin/sup/source: supfilesrv.c

Log Message:
return busy for checkchild instead of killing the connection


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/usr.sbin/sup/source/supfilesrv.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/sup/source/supfilesrv.c
diff -u src/usr.sbin/sup/source/supfilesrv.c:1.49 src/usr.sbin/sup/source/supfilesrv.c:1.50
--- src/usr.sbin/sup/source/supfilesrv.c:1.49	Fri Mar  8 15:58:35 2013
+++ src/usr.sbin/sup/source/supfilesrv.c	Tue Apr  9 12:38:18 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: supfilesrv.c,v 1.49 2013/03/08 20:58:35 christos Exp $	*/
+/*	$NetBSD: supfilesrv.c,v 1.50 2013/04/09 16:38:18 christos Exp $	*/
 
 /*
  * Copyright (c) 1992 Carnegie Mellon University
@@ -496,7 +496,7 @@ main(int argc, char **argv)
 		 * If we are being bombarded, don't even spend time forking
 		 * or conversing
 		 */
-		if (nchildren = maxchildren || !checkchild()) {
+		if (nchildren  maxchildren) {
 			(void) servicekill();
 			continue;
 		}
@@ -1011,7 +1011,7 @@ srvsetup(void)
 	if (x  0)
 		goaway(Can't stat base/prefix directory (%s),
 		strerror(errno));
-	if (nchildren = maxchildren) {
+	if (nchildren = maxchildren || !checkchild()) {
 		setupack = FSETUPBUSY;
 		(void) msgsetupack();
 		if (protver = 6)



CVS commit: src/usr.sbin/sup/source

2013-04-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Apr  9 16:39:20 UTC 2013

Modified Files:
src/usr.sbin/sup/source: sup.1 sup.h supcdefs.h supcmain.c supcmeat.c
supcparse.c

Log Message:
- add new ignore chown/chgrp flag
- bump strings space to 8K someone has 4K paths now.
- use snprintf where possible and detect long lines.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/usr.sbin/sup/source/sup.1
cvs rdiff -u -r1.11 -r1.12 src/usr.sbin/sup/source/sup.h
cvs rdiff -u -r1.14 -r1.15 src/usr.sbin/sup/source/supcdefs.h
cvs rdiff -u -r1.32 -r1.33 src/usr.sbin/sup/source/supcmain.c
cvs rdiff -u -r1.41 -r1.42 src/usr.sbin/sup/source/supcmeat.c
cvs rdiff -u -r1.15 -r1.16 src/usr.sbin/sup/source/supcparse.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/sup/source/sup.1
diff -u src/usr.sbin/sup/source/sup.1:1.21 src/usr.sbin/sup/source/sup.1:1.22
--- src/usr.sbin/sup/source/sup.1:1.21	Thu Sep 22 03:30:04 2011
+++ src/usr.sbin/sup/source/sup.1	Tue Apr  9 12:39:19 2013
@@ -1,4 +1,4 @@
-.\	$NetBSD: sup.1,v 1.21 2011/09/22 07:30:04 mrg Exp $
+.\	$NetBSD: sup.1,v 1.22 2013/04/09 16:39:19 christos Exp $
 .\
 .\ Copyright (c) 1992 Carnegie Mellon University
 .\ All Rights Reserved.
@@ -45,7 +45,7 @@
 .\ 04-Apr-85  Steven Shafer (sas) at Carnegie-Mellon University
 .\ 	Created.
 .\
-.TH SUP 1 10/01/08
+.TH SUP 1 2013/03/13
 .CM 4
 .SH NAME
 sup \- software upgrade protocol
@@ -266,6 +266,12 @@ upgrade will be performed.
 Messages will be printed that indicate what would happen if
 an actual upgrade were done.
 .TP
+.B i
+Ignore errors from
+.IR chown(2)
+or
+.IR chgrp(2) .
+.TP
 .B -k
 .I Sup
 will check the modification times of

Index: src/usr.sbin/sup/source/sup.h
diff -u src/usr.sbin/sup/source/sup.h:1.11 src/usr.sbin/sup/source/sup.h:1.12
--- src/usr.sbin/sup/source/sup.h:1.11	Thu Dec 20 15:14:24 2007
+++ src/usr.sbin/sup/source/sup.h	Tue Apr  9 12:39:20 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: sup.h,v 1.11 2007/12/20 20:14:24 christos Exp $	*/
+/*	$NetBSD: sup.h,v 1.12 2013/04/09 16:39:20 christos Exp $	*/
 
 /*
  * Copyright (c) 1992 Carnegie Mellon University
@@ -169,7 +169,7 @@ extern char scmversion[];		/* string ver
 #endif
 
 /* String length */
-#define STRINGLENGTH	2000
+#define STRINGLENGTH	8192
 
 /* Password transmission encryption key */
 #define PSWDCRYPT	SuperMan

Index: src/usr.sbin/sup/source/supcdefs.h
diff -u src/usr.sbin/sup/source/supcdefs.h:1.14 src/usr.sbin/sup/source/supcdefs.h:1.15
--- src/usr.sbin/sup/source/supcdefs.h:1.14	Wed Sep 21 15:34:54 2011
+++ src/usr.sbin/sup/source/supcdefs.h	Tue Apr  9 12:39:20 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: supcdefs.h,v 1.14 2011/09/21 19:34:54 christos Exp $	*/
+/*	$NetBSD: supcdefs.h,v 1.15 2013/04/09 16:39:20 christos Exp $	*/
 
 /*
  * Copyright (c) 1992 Carnegie Mellon University
@@ -117,6 +117,7 @@ typedef struct collstruct COLLECTION;
 #define CFCOMPRESS	04000
 #define CFSILENT	1
 #define CFCANONICALIZE	2
+#define CFIGNCHERR	4
 
 /*
  ***	M A C R O S***

Index: src/usr.sbin/sup/source/supcmain.c
diff -u src/usr.sbin/sup/source/supcmain.c:1.32 src/usr.sbin/sup/source/supcmain.c:1.33
--- src/usr.sbin/sup/source/supcmain.c:1.32	Wed Sep 21 15:34:54 2011
+++ src/usr.sbin/sup/source/supcmain.c	Tue Apr  9 12:39:20 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: supcmain.c,v 1.32 2011/09/21 19:34:54 christos Exp $	*/
+/*	$NetBSD: supcmain.c,v 1.33 2013/04/09 16:39:20 christos Exp $	*/
 
 /*
  * Copyright (c) 1992 Carnegie Mellon University
@@ -470,7 +470,7 @@ doswitch(int *argc, char ***argv, TREE *
 	int oflags, aflags;
 	int c;
 
-#define SUPOPTIONS abBCdDeEfkKlmM:NoOPRsStuvXzZ=:
+#define SUPOPTIONS abBCdDeEifkKlmM:NoOPRsStuvXzZ=:
 
 	oflags = aflags = 0;
 	while ((c = getopt(*argc, *argv, SUPOPTIONS)) != -1)
@@ -524,6 +524,10 @@ doswitch(int *argc, char ***argv, TREE *
 		case 'f':
 			oflags |= CFLIST;
 			break;
+		case 'i':
+			oflags |= CFIGNCHERR;
+			aflags = ~CFIGNCHERR;
+			break;
 		case 'k':
 			oflags |= CFKEEP;
 			aflags = ~CFKEEP;

Index: src/usr.sbin/sup/source/supcmeat.c
diff -u src/usr.sbin/sup/source/supcmeat.c:1.41 src/usr.sbin/sup/source/supcmeat.c:1.42
--- src/usr.sbin/sup/source/supcmeat.c:1.41	Fri Mar  8 15:56:44 2013
+++ src/usr.sbin/sup/source/supcmeat.c	Tue Apr  9 12:39:20 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: supcmeat.c,v 1.41 2013/03/08 20:56:44 christos Exp $	*/
+/*	$NetBSD: supcmeat.c,v 1.42 2013/04/09 16:39:20 christos Exp $	*/
 
 /*
  * Copyright (c) 1992 Carnegie Mellon University
@@ -334,7 +334,8 @@ setup(TREE * t)
 	/* read time of last upgrade from when file */
 
 	if ((thisC-Cflags  CFURELSUF)  thisC-Crelease)
-		(void) sprintf(relsufix, .%s, thisC-Crelease);
+		(void) snprintf(relsufix, sizeof(relsufix), .%s,
+		thisC-Crelease);
 	else
 		relsufix[0] = '\0';
 	lasttime = getwhen(collname, relsufix);
@@ -404,7 +405,7 @@ suplogin(void)
 	int f, x;
 

CVS commit: src/usr.sbin/sup/source

2013-03-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Mar  8 20:56:44 UTC 2013

Modified Files:
src/usr.sbin/sup/source: log.c scan.c scm.c scmio.c setproctitle.c
supcmeat.c supcmisc.c supextern.h supfilesrv.c supscan.c

Log Message:
- don't allow multiple active connections from the same host
- prefix all messages with the local hostname
- more error checking


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.sbin/sup/source/log.c
cvs rdiff -u -r1.30 -r1.31 src/usr.sbin/sup/source/scan.c
cvs rdiff -u -r1.29 -r1.30 src/usr.sbin/sup/source/scm.c
cvs rdiff -u -r1.21 -r1.22 src/usr.sbin/sup/source/scmio.c
cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/sup/source/setproctitle.c
cvs rdiff -u -r1.40 -r1.41 src/usr.sbin/sup/source/supcmeat.c
cvs rdiff -u -r1.22 -r1.23 src/usr.sbin/sup/source/supcmisc.c \
src/usr.sbin/sup/source/supscan.c
cvs rdiff -u -r1.23 -r1.24 src/usr.sbin/sup/source/supextern.h
cvs rdiff -u -r1.47 -r1.48 src/usr.sbin/sup/source/supfilesrv.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/sup/source/log.c
diff -u src/usr.sbin/sup/source/log.c:1.10 src/usr.sbin/sup/source/log.c:1.11
--- src/usr.sbin/sup/source/log.c:1.10	Fri Oct 16 08:41:37 2009
+++ src/usr.sbin/sup/source/log.c	Fri Mar  8 15:56:44 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: log.c,v 1.10 2009/10/16 12:41:37 christos Exp $	*/
+/*	$NetBSD: log.c,v 1.11 2013/03/08 20:56:44 christos Exp $	*/
 
 /*
  * Copyright (c) 1992 Carnegie Mellon University
@@ -63,6 +63,19 @@ logopen(char *program)
 	opened++;
 }
 
+static void
+vfmtbuf(int f, char *buf, size_t bufsiz, const char *fmt, va_list ap)
+{
+	char hostname[MAXHOSTNAMELEN];
+	char xbuf[STRINGLENGTH], ybuf[STRINGLENGTH];
+	gethostname(hostname, sizeof(hostname));
+	snprintf(ybuf, sizeof(ybuf), SUP@%s%s , hostname, f ? : : );
+	vsnprintf(xbuf, sizeof(xbuf), fmt, ap);
+	snprintf(buf, bufsiz, %s%s, ybuf, xbuf);
+	return buf;
+}
+
+
 void
 logquit(int retval, const char *fmt, ...)
 {
@@ -70,7 +83,7 @@ logquit(int retval, const char *fmt, ...
 	va_list ap;
 
 	va_start(ap, fmt);
-	vsnprintf(buf, sizeof(buf), fmt, ap);
+	vfmtbuf(1, buf, sizeof(buf), fmt, ap);
 	va_end(ap);
 	if (opened) {
 		syslog(LOG_ERR, %s, buf);
@@ -87,7 +100,7 @@ logerr(const char *fmt, ...)
 	va_list ap;
 
 	va_start(ap, fmt);
-	vsnprintf(buf, sizeof(buf), fmt, ap);
+	vfmtbuf(1, buf, sizeof(buf), fmt, ap);
 	va_end(ap);
 	if (opened) {
 		syslog(LOG_ERR, %s, buf);
@@ -104,7 +117,7 @@ loginfo(const char *fmt, ...)
 	va_list ap;
 
 	va_start(ap, fmt);
-	vsnprintf(buf, sizeof(buf), fmt, ap);
+	vfmtbuf(0, buf, sizeof(buf), fmt, ap);
 	va_end(ap);
 	if (opened) {
 		syslog(LOG_INFO, %s, buf);
@@ -137,7 +150,7 @@ logdeny(const char *fmt, ...)
 	va_list ap;
 
 	va_start(ap, fmt);
-	vsnprintf(buf, sizeof(buf), fmt, ap);
+	vfmtbuf(1, buf, sizeof(buf), fmt, ap);
 	va_end(ap);
 	if (opened) {
 		syslog(deny_severity, %s, buf);
@@ -154,7 +167,7 @@ logallow(const char *fmt, ...)
 	va_list ap;
 
 	va_start(ap, fmt);
-	vsnprintf(buf, sizeof(buf), fmt, ap);
+	vfmtbuf(1, buf, sizeof(buf), fmt, ap);
 	va_end(ap);
 	if (opened) {
 		syslog(allow_severity, %s, buf);

Index: src/usr.sbin/sup/source/scan.c
diff -u src/usr.sbin/sup/source/scan.c:1.30 src/usr.sbin/sup/source/scan.c:1.31
--- src/usr.sbin/sup/source/scan.c:1.30	Wed Aug 31 12:25:00 2011
+++ src/usr.sbin/sup/source/scan.c	Fri Mar  8 15:56:44 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: scan.c,v 1.30 2011/08/31 16:25:00 plunky Exp $	*/
+/*	$NetBSD: scan.c,v 1.31 2013/03/08 20:56:44 christos Exp $	*/
 
 /*
  * Copyright (c) 1992 Carnegie Mellon University
@@ -310,7 +310,9 @@ getrelease(char *release)
 	free(frelease);
 return (FALSE);
 			} else
-(void) chdir(basedir);
+if (chdir(basedir)  0)
+	goaway(Can't chdir to %s (%s),
+	basedir, strerror(errno));
 			tl-TLnext = listTL;
 			listTL = tl;
 			if (release == NULL)
@@ -363,8 +365,11 @@ makescanlists(void)
 prefix = saveprefix;
 			if (prefix != NULL) {
 if (chdir(prefix)  0)
-	goaway(Can't chdir to %s, prefix);
-(void) chdir(basedir);
+	goaway(Can't chdir to %s (%s),
+	prefix, strerror(errno));
+if (chdir(basedir)  0)
+	goaway(Can't chdir to %s (%s),
+	basedir, strerror(errno));
 			}
 			makescan(tl-TLlist, tl-TLscan);
 			free(tl);
@@ -628,13 +633,21 @@ listentry(char *name, char *fullname, ch
 		}
 		listdir(fullname, always);
 		if (updir == 0 || linkcount) {
-			(void) chdir(basedir);
+			if (chdir(basedir)  0)
+goaway(Can't chdir to %s (%s),
+basedir, strerror(errno));
 			if (prefix)
-(void) chdir(prefix);
+if (chdir(prefix)  0)
+	goaway(Can't chdir to %s (%s),
+	prefix, strerror(errno));
 			if (updir  *updir)
-(void) chdir(updir);
+if (chdir(updir)  0)
+	goaway(Can't chdir to %s (%s),
+	updir, strerror(errno));
 		} else
-			(void) chdir(..);
+			if (chdir(..)  0)
+

CVS commit: src/usr.sbin/sup/source

2013-03-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Mar  8 20:58:35 UTC 2013

Modified Files:
src/usr.sbin/sup/source: log.c supfilesrv.c

Log Message:
fix compilation issues.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/usr.sbin/sup/source/log.c
cvs rdiff -u -r1.48 -r1.49 src/usr.sbin/sup/source/supfilesrv.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/sup/source/log.c
diff -u src/usr.sbin/sup/source/log.c:1.11 src/usr.sbin/sup/source/log.c:1.12
--- src/usr.sbin/sup/source/log.c:1.11	Fri Mar  8 15:56:44 2013
+++ src/usr.sbin/sup/source/log.c	Fri Mar  8 15:58:35 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: log.c,v 1.11 2013/03/08 20:56:44 christos Exp $	*/
+/*	$NetBSD: log.c,v 1.12 2013/03/08 20:58:35 christos Exp $	*/
 
 /*
  * Copyright (c) 1992 Carnegie Mellon University
@@ -72,7 +72,7 @@ vfmtbuf(int f, char *buf, size_t bufsiz,
 	snprintf(ybuf, sizeof(ybuf), SUP@%s%s , hostname, f ? : : );
 	vsnprintf(xbuf, sizeof(xbuf), fmt, ap);
 	snprintf(buf, bufsiz, %s%s, ybuf, xbuf);
-	return buf;
+	return;
 }
 
 

Index: src/usr.sbin/sup/source/supfilesrv.c
diff -u src/usr.sbin/sup/source/supfilesrv.c:1.48 src/usr.sbin/sup/source/supfilesrv.c:1.49
--- src/usr.sbin/sup/source/supfilesrv.c:1.48	Fri Mar  8 15:56:44 2013
+++ src/usr.sbin/sup/source/supfilesrv.c	Fri Mar  8 15:58:35 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: supfilesrv.c,v 1.48 2013/03/08 20:56:44 christos Exp $	*/
+/*	$NetBSD: supfilesrv.c,v 1.49 2013/03/08 20:58:35 christos Exp $	*/
 
 /*
  * Copyright (c) 1992 Carnegie Mellon University
@@ -375,7 +375,7 @@ struct hostpid {
 	pid_t pid;
 } *hp;
 
-static int
+static void
 addchild(pid_t pid)
 {
 	size_t i;



CVS commit: src/usr.sbin/sup/source

2012-04-25 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Apr 25 17:33:49 UTC 2012

Modified Files:
src/usr.sbin/sup/source: supscan.c

Log Message:
- don't declare victory when there are errors.
- better error messages.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/usr.sbin/sup/source/supscan.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/sup/source/supscan.c
diff -u src/usr.sbin/sup/source/supscan.c:1.19 src/usr.sbin/sup/source/supscan.c:1.20
--- src/usr.sbin/sup/source/supscan.c:1.19	Wed Aug 31 12:25:00 2011
+++ src/usr.sbin/sup/source/supscan.c	Wed Apr 25 13:33:49 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: supscan.c,v 1.19 2011/08/31 16:25:00 plunky Exp $	*/
+/*	$NetBSD: supscan.c,v 1.20 2012/04/25 17:33:49 christos Exp $	*/
 
 /*
  * Copyright (c) 1992 Carnegie Mellon University
@@ -158,7 +158,7 @@ TREE *refuseT = NULL;		/* list of all fi
 
 
 void usage(void);
-void init(int, char **);
+int init(int, char **);
 static SCAN_COLLECTION *getscancoll(char *, char *, char *);
 int localhost(char *);
 int main(int, char **);
@@ -171,6 +171,7 @@ int
 main(int argc, char **argv)
 {
 	SCAN_COLLECTION * volatile c;	/* Avoid longjmp clobbering */
+	int errs;
 #ifdef RLIMIT_DATA
 	struct rlimit dlim;
 
@@ -185,7 +186,11 @@ main(int argc, char **argv)
 	}
 #endif
 
-	init(argc, argv);	/* process arguments */
+	errs = init(argc, argv);	/* process arguments */
+	if (errs) {
+		fprintf(stderr, supscan: %d collections had errors, errs);
+		return 1;
+	}
 	for (c = firstC; c; c = c-Cnext) {
 		collname = c-Cname;
 		basedir = c-Cbase;
@@ -202,10 +207,12 @@ main(int argc, char **argv)
 			if (!quiet)
 printf(SUP Scan for %s completed at %s,
 collname, ctime(scantime));
-		} else
+		} else {
 			fprintf(stderr,
 			SUP: Scan for %s aborted at %s, collname,
 			ctime(scantime));
+			errs++;
+		}
 		if (!quiet)
 			(void) fflush(stdout);
 	}
@@ -217,7 +224,7 @@ main(int argc, char **argv)
 			free(c-Cprefix);
 		free(c);
 	}
-	exit(0);
+	return errs ? 1 : 0;
 }
 /*
  ***I N I T I A L I Z A T I O N***
@@ -232,7 +239,7 @@ usage(void)
 	exit(1);
 }
 
-void
+int
 init(int argc, char **argv)
 {
 	char buf[STRINGLENGTH], fbuf[STRINGLENGTH], *p, *q;
@@ -240,6 +247,7 @@ init(int argc, char **argv)
 	SCAN_COLLECTION **c;
 	int fflag, sflag;
 	char *filename = NULL;
+	int errs = 0;
 
 	quiet = FALSE;
 	trace = FALSE;
@@ -297,9 +305,11 @@ init(int argc, char **argv)
 			*c = getscancoll(filename, estrdup(collname), NULL);
 			if (*c)
 c = ((*c)-Cnext);
+			else
+errs++;
 		}
 		(void) fclose(f);
-		return;
+		return errs;
 	}
 	if (argc  2  fflag) {
 		firstC = NULL;
@@ -317,14 +327,19 @@ init(int argc, char **argv)
 			*c = getscancoll(filename, estrdup(q), estrdup(p));
 			if (*c)
 c = ((*c)-Cnext);
+			else
+errs++;
 		}
 		(void) fclose(f);
-		return;
+		return errs;
 	}
 	if (argc  2 || argc  3)
 		usage();
 	firstC = getscancoll(filename, estrdup(argv[1]),
 	argc  2 ? estrdup(argv[2]) : NULL);
+	if (firstC == NULL)
+		errs++;
+	return errs;
 }
 
 static SCAN_COLLECTION *
@@ -357,8 +372,8 @@ getscancoll(char *filename, char *collna
 		}
 	}
 	if (chdir(basedir)  0) {
-		fprintf(stderr, supscan:  Can't chdir to base directory %s for %s\n,
-		basedir, collname);
+		fprintf(stderr, supscan: Can't chdir to base directory %s 
+		for %s (%s)\n, basedir, collname, strerror(errno));
 		return (NULL);
 	}
 	prefix = NULL;
@@ -372,8 +387,9 @@ getscancoll(char *filename, char *collna
 continue;
 			prefix = estrdup(p);
 			if (chdir(prefix)  0) {
-fprintf(stderr, supscan: can't chdir to %s from base directory %s for %s\n,
-prefix, basedir, collname);
+fprintf(stderr, supscan: can't chdir to %s 
+ from base directory %s for %s\n,
+prefix, basedir, collname, strerror(errno));
 fclose(f);
 free(prefix);
 return (NULL);
@@ -382,7 +398,7 @@ getscancoll(char *filename, char *collna
 		}
 		(void) fclose(f);
 	}
-	if ((c = (SCAN_COLLECTION *) malloc(sizeof(SCAN_COLLECTION))) == NULL)
+	if ((c = malloc(sizeof(*c))) == NULL)
 		quit(1, supscan: can't malloc collection structure\n);
 	c-Cname = collname;
 	c-Cbase = basedir;



CVS commit: src/usr.sbin/sup/source

2012-04-25 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Apr 25 18:07:45 UTC 2012

Modified Files:
src/usr.sbin/sup/source: supscan.c

Log Message:
forgot the %s for the error


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/usr.sbin/sup/source/supscan.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/sup/source/supscan.c
diff -u src/usr.sbin/sup/source/supscan.c:1.20 src/usr.sbin/sup/source/supscan.c:1.21
--- src/usr.sbin/sup/source/supscan.c:1.20	Wed Apr 25 13:33:49 2012
+++ src/usr.sbin/sup/source/supscan.c	Wed Apr 25 14:07:45 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: supscan.c,v 1.20 2012/04/25 17:33:49 christos Exp $	*/
+/*	$NetBSD: supscan.c,v 1.21 2012/04/25 18:07:45 christos Exp $	*/
 
 /*
  * Copyright (c) 1992 Carnegie Mellon University
@@ -388,7 +388,7 @@ getscancoll(char *filename, char *collna
 			prefix = estrdup(p);
 			if (chdir(prefix)  0) {
 fprintf(stderr, supscan: can't chdir to %s 
- from base directory %s for %s\n,
+ from base directory %s for %s (%s)\n,
 prefix, basedir, collname, strerror(errno));
 fclose(f);
 free(prefix);



CVS commit: src/usr.sbin/sup/source

2012-04-25 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Apr 25 22:35:00 UTC 2012

Modified Files:
src/usr.sbin/sup/source: supscan.c

Log Message:
errs might be clobbered by longjmp, so declare it volatile.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/usr.sbin/sup/source/supscan.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/sup/source/supscan.c
diff -u src/usr.sbin/sup/source/supscan.c:1.21 src/usr.sbin/sup/source/supscan.c:1.22
--- src/usr.sbin/sup/source/supscan.c:1.21	Wed Apr 25 18:07:45 2012
+++ src/usr.sbin/sup/source/supscan.c	Wed Apr 25 22:35:00 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: supscan.c,v 1.21 2012/04/25 18:07:45 christos Exp $	*/
+/*	$NetBSD: supscan.c,v 1.22 2012/04/25 22:35:00 martin Exp $	*/
 
 /*
  * Copyright (c) 1992 Carnegie Mellon University
@@ -171,7 +171,7 @@ int
 main(int argc, char **argv)
 {
 	SCAN_COLLECTION * volatile c;	/* Avoid longjmp clobbering */
-	int errs;
+	volatile int errs;
 #ifdef RLIMIT_DATA
 	struct rlimit dlim;
 



CVS commit: src/usr.sbin/sup/source

2011-12-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Dec  7 22:52:54 UTC 2011

Modified Files:
src/usr.sbin/sup/source: setproctitle.c

Log Message:
be more portable, explain what we are doing, simplify.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/sup/source/setproctitle.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/sup/source/setproctitle.c
diff -u src/usr.sbin/sup/source/setproctitle.c:1.3 src/usr.sbin/sup/source/setproctitle.c:1.4
--- src/usr.sbin/sup/source/setproctitle.c:1.3	Mon Apr 28 16:24:17 2008
+++ src/usr.sbin/sup/source/setproctitle.c	Wed Dec  7 17:52:54 2011
@@ -27,10 +27,13 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include sys/param.h
 #include stdio.h
 #include stdlib.h
 #include string.h
 #include stdarg.h
+#include limits.h
+#include unistd.h
 
 #ifdef NEED_SETPROCTITLE
 
@@ -42,18 +45,42 @@ setproctitle(const char *fmt, ...)
 	va_list ap;
 	char buf[1024];
 	int len;
-	char *pname, *p;
-	char **args = __environ - 2;
+	char *pname, *p, *s;
+	/*
+	 * Assumes that stack grows down, and than environ has not bee
+	 * reallocated because of setenv() required growth. Stack layout:
+	 * 
+	 * argc
+	 * argv[0]
+	 * ...
+	 * argv[n]
+	 * NULL
+	 * environ[0]
+	 * ...
+	 * environ[n]
+	 * NULL
+	 */
 
+	/* 1 for the first entry, 1 for the NULL */
+	char **args = __environ - 2, *s;
+#ifdef _SC_ARG_MAX
+	s = (char *)sysconf(_SC_ARG_MAX);
+#elifdef ARG_MAX
+	s = (char *)ARG_MAX;
+#elifdef NCARGS
+	s = (char *)NCARGS;
+#else
+	s = (char *)(256 * 1024);
+#endif
 	/*
 	 * Keep going while it looks like a pointer. We'll stop at argc,
-	 * Assume that we have  10K args.
+	 * Which is a lot smaller than a pointer, limited by ARG_MAX
 	 */
-	while (*args  (char *)10240)
+	while (*args  s)
 		args--;
 
-	pname = *++args;
-	*(int *)((int *)pname - 1) = 1; /* *argc = 1; */
+	*(int *)args = 1; /* *argc = 1; */
+	pname = *++args;  /* pname = argv[0] */
  
 	/* Just the last component of the name */
 	if ((p = strrchr(pname, '/')) != NULL)



CVS commit: src/usr.sbin/sup/source

2011-09-22 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Sep 22 07:30:04 UTC 2011

Modified Files:
src/usr.sbin/sup/source: sup.1

Log Message:
remove an extra .TP that broke my build.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/usr.sbin/sup/source/sup.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/sup/source/sup.1
diff -u src/usr.sbin/sup/source/sup.1:1.20 src/usr.sbin/sup/source/sup.1:1.21
--- src/usr.sbin/sup/source/sup.1:1.20	Wed Sep 21 20:12:11 2011
+++ src/usr.sbin/sup/source/sup.1	Thu Sep 22 07:30:04 2011
@@ -1,4 +1,4 @@
-.\	$NetBSD: sup.1,v 1.20 2011/09/21 20:12:11 wiz Exp $
+.\	$NetBSD: sup.1,v 1.21 2011/09/22 07:30:04 mrg Exp $
 .\
 .\ Copyright (c) 1992 Carnegie Mellon University
 .\ All Rights Reserved.
@@ -222,7 +222,6 @@
 behind sup's back, and attempt to repair them.
 This option is expensive.
 .TP
-.TP
 .B -d
 Files that are no longer in the collection on the
 repository will be deleted if present on the local



CVS commit: src/usr.sbin/sup/source

2011-09-21 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Sep 21 19:32:59 UTC 2011

Modified Files:
src/usr.sbin/sup/source: path.c supextern.h

Log Message:
constify


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/sup/source/path.c
cvs rdiff -u -r1.22 -r1.23 src/usr.sbin/sup/source/supextern.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/sup/source/path.c
diff -u src/usr.sbin/sup/source/path.c:1.4 src/usr.sbin/sup/source/path.c:1.5
--- src/usr.sbin/sup/source/path.c:1.4	Wed Jul 10 16:19:41 2002
+++ src/usr.sbin/sup/source/path.c	Wed Sep 21 15:32:59 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: path.c,v 1.4 2002/07/10 20:19:41 wiz Exp $	*/
+/*	$NetBSD: path.c,v 1.5 2011/09/21 19:32:59 christos Exp $	*/
 
 /*
  * Copyright (c) 1991 Carnegie Mellon University
@@ -62,11 +62,11 @@
 #include supextern.h
 
 void
-path(char *original, char *direc, char *file)
+path(const char *original, char *direc, char *file)
 {
 	char *y;
 	/* x is direc */
-	char *p;
+	const char *p;
 
 	/* copy and note the end */
 	p = original;

Index: src/usr.sbin/sup/source/supextern.h
diff -u src/usr.sbin/sup/source/supextern.h:1.22 src/usr.sbin/sup/source/supextern.h:1.23
--- src/usr.sbin/sup/source/supextern.h:1.22	Sat Oct 17 18:26:13 2009
+++ src/usr.sbin/sup/source/supextern.h	Wed Sep 21 15:32:59 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: supextern.h,v 1.22 2009/10/17 22:26:13 christos Exp $	*/
+/*	$NetBSD: supextern.h,v 1.23 2011/09/21 19:32:59 christos Exp $	*/
 
 struct stat;
 
@@ -39,7 +39,7 @@
 char *nxtarg(char **, const char *);
 
 /* path.c */
-void path(char *, char *, char *);
+void path(const char *, char *, char *);
 
 /* quit.c */
 void quit(int, const char *, ...)



CVS commit: src/usr.sbin/sup/source

2011-09-21 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Sep 21 19:34:54 UTC 2011

Modified Files:
src/usr.sbin/sup/source: sup.1 supcdefs.h supcmain.c supcmeat.c
supcparse.c

Log Message:
Add a canonicalize option to avoid disaster when one converts directories
to symlinks in the tree and back. This option is expensive, it could be
made better by cacheing, but not now.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/usr.sbin/sup/source/sup.1
cvs rdiff -u -r1.13 -r1.14 src/usr.sbin/sup/source/supcdefs.h
cvs rdiff -u -r1.31 -r1.32 src/usr.sbin/sup/source/supcmain.c
cvs rdiff -u -r1.39 -r1.40 src/usr.sbin/sup/source/supcmeat.c
cvs rdiff -u -r1.14 -r1.15 src/usr.sbin/sup/source/supcparse.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/sup/source/sup.1
diff -u src/usr.sbin/sup/source/sup.1:1.18 src/usr.sbin/sup/source/sup.1:1.19
--- src/usr.sbin/sup/source/sup.1:1.18	Sun Nov  1 19:29:04 2009
+++ src/usr.sbin/sup/source/sup.1	Wed Sep 21 15:34:54 2011
@@ -1,4 +1,4 @@
-.\	$NetBSD: sup.1,v 1.18 2009/11/02 00:29:04 joerg Exp $
+.\	$NetBSD: sup.1,v 1.19 2011/09/21 19:34:54 christos Exp $
 .\
 .\ Copyright (c) 1992 Carnegie Mellon University
 .\ All Rights Reserved.
@@ -197,6 +197,16 @@
 .B backup
 supfile option.
 .TP
+.B -C
+The
+.B -C
+flag or the
+.B canonicalize
+supfile option, canonicalize all pathnames upon reception to make sure
+local changes from directories to symlinks and vice versa have not happened
+behind sup's back, and attempt to repair them. This option is expensive.
+.TP
+.TP
 .B -d
 Files that are no longer in the collection on the
 repository will be deleted if present on the local
@@ -861,6 +871,8 @@
 that contains the same names.
 Then sup will cross the symlink and start deleting files and directories
 from the destination.
-This is not easily fixed.
+This is avoided by using the
+.B canonicalize
+option, but it is expensive.
 Don't use sup with symlink/rsymlink and the delete
 option at the same time or *be careful*!

Index: src/usr.sbin/sup/source/supcdefs.h
diff -u src/usr.sbin/sup/source/supcdefs.h:1.13 src/usr.sbin/sup/source/supcdefs.h:1.14
--- src/usr.sbin/sup/source/supcdefs.h:1.13	Fri Nov 29 22:10:58 2002
+++ src/usr.sbin/sup/source/supcdefs.h	Wed Sep 21 15:34:54 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: supcdefs.h,v 1.13 2002/11/30 03:10:58 lukem Exp $	*/
+/*	$NetBSD: supcdefs.h,v 1.14 2011/09/21 19:34:54 christos Exp $	*/
 
 /*
  * Copyright (c) 1992 Carnegie Mellon University
@@ -116,6 +116,7 @@
 #define CFURELSUF	02000
 #define CFCOMPRESS	04000
 #define CFSILENT	1
+#define CFCANONICALIZE	2
 
 /*
  ***	M A C R O S***

Index: src/usr.sbin/sup/source/supcmain.c
diff -u src/usr.sbin/sup/source/supcmain.c:1.31 src/usr.sbin/sup/source/supcmain.c:1.32
--- src/usr.sbin/sup/source/supcmain.c:1.31	Wed Aug 31 12:25:00 2011
+++ src/usr.sbin/sup/source/supcmain.c	Wed Sep 21 15:34:54 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: supcmain.c,v 1.31 2011/08/31 16:25:00 plunky Exp $	*/
+/*	$NetBSD: supcmain.c,v 1.32 2011/09/21 19:34:54 christos Exp $	*/
 
 /*
  * Copyright (c) 1992 Carnegie Mellon University
@@ -470,7 +470,7 @@
 	int oflags, aflags;
 	int c;
 
-#define SUPOPTIONS abBdDeEfkKlmM:NoOPRsStuvXzZ=:
+#define SUPOPTIONS abBCdDeEfkKlmM:NoOPRsStuvXzZ=:
 
 	oflags = aflags = 0;
 	while ((c = getopt(*argc, *argv, SUPOPTIONS)) != -1)
@@ -502,6 +502,9 @@
 			oflags = ~CFBACKUP;
 			aflags |= CFBACKUP;
 			break;
+		case 'C':
+			oflags |= CFCANONICALIZE;
+			break;
 		case 'd':
 			oflags |= CFDELETE;
 			aflags = ~CFDELETE;

Index: src/usr.sbin/sup/source/supcmeat.c
diff -u src/usr.sbin/sup/source/supcmeat.c:1.39 src/usr.sbin/sup/source/supcmeat.c:1.40
--- src/usr.sbin/sup/source/supcmeat.c:1.39	Wed Aug 31 12:25:00 2011
+++ src/usr.sbin/sup/source/supcmeat.c	Wed Sep 21 15:34:54 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: supcmeat.c,v 1.39 2011/08/31 16:25:00 plunky Exp $	*/
+/*	$NetBSD: supcmeat.c,v 1.40 2011/09/21 19:34:54 christos Exp $	*/
 
 /*
  * Copyright (c) 1992 Carnegie Mellon University
@@ -140,6 +140,7 @@
 static int linkone(TREE *, void *);
 static int execone(TREE *, void *);
 static int finishone(TREE *, void *);
+static int canonicalize(const char *);
 
 
 /* The next two routines define the fsm to support multiple fileservers
@@ -493,6 +494,8 @@
 *q = '\0';
 			if (strchr(#;:, *p))
 continue;
+			if (canonicalize(p) != 0)
+continue;
 			(void) Tinsert(lastT, p, FALSE);
 		}
 		(void) fclose(f);
@@ -720,6 +723,8 @@
 			goaway(Error sending compression check to server);
 		if (docompress)
 			vnotify(SUP Using compressed file transfer\n);
+		if (thisC-Cflags  CFCANONICALIZE)
+			vnotify(SUP Filename canonicalization is on\n);
 	}
 	recvmore = TRUE;
 	upgradeT = NULL;
@@ -942,10 +947,22 @@
 	char dirpart[STRINGLENGTH], filepart[STRINGLENGTH];
 	char filename[STRINGLENGTH], buf[STRINGLENGTH];
 	struct timeval 

CVS commit: src/usr.sbin/sup/source

2011-09-21 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Wed Sep 21 20:12:12 UTC 2011

Modified Files:
src/usr.sbin/sup/source: sup.1

Log Message:
New sentence, new line. Remove empty EXAMPLE section.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/usr.sbin/sup/source/sup.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/sup/source/sup.1
diff -u src/usr.sbin/sup/source/sup.1:1.19 src/usr.sbin/sup/source/sup.1:1.20
--- src/usr.sbin/sup/source/sup.1:1.19	Wed Sep 21 19:34:54 2011
+++ src/usr.sbin/sup/source/sup.1	Wed Sep 21 20:12:11 2011
@@ -1,4 +1,4 @@
-.\	$NetBSD: sup.1,v 1.19 2011/09/21 19:34:54 christos Exp $
+.\	$NetBSD: sup.1,v 1.20 2011/09/21 20:12:11 wiz Exp $
 .\
 .\ Copyright (c) 1992 Carnegie Mellon University
 .\ All Rights Reserved.
@@ -54,7 +54,8 @@
 .SH DESCRIPTION
 .I Sup
 is a program used for upgrading collections of files from other machines
-to your machine.  You execute
+to your machine.
+You execute
 .IR sup ,
 the
 .I client
@@ -66,22 +67,28 @@
 to determine which files of the collection need to be upgraded on
 your machine.
 
-Sup collections can have multiple releases. One use for such releases is
-to provide different versions of the same files. At CMU, for example,
+Sup collections can have multiple releases.
+One use for such releases is
+to provide different versions of the same files.
+At CMU, for example,
 system binaries have alpha, beta and default release corresponding to
-different staging levels of the software. We also use release names
+different staging levels of the software.
+We also use release names
 default and minimal to provide complete releases or subset releases.
 In both of these cases, it only makes sense to sup one release of the
-collections. Releases have also been used in private or external sups to
+collections.
+Releases have also been used in private or external sups to
 provide subsets of collections where it makes sense to pick up several
-of the releases. For example the Mach 3.0 kernel sources has a default
+of the releases.
+For example the Mach 3.0 kernel sources has a default
 release of machine independent sources and separate releases of
 machine dependent sources for each supported platform.
 
 In performing an upgrade, the file server constructs a list of
-files included in the specified release of the collection.  The list is sent to your machine,
-which determines which files are needed.  Those files are then sent
-from the file server.
+files included in the specified release of the collection.
+The list is sent to your machine,
+which determines which files are needed.
+Those files are then sent from the file server.
 It will be most useful to run
 .I sup
 as a daemon each night so you will continually have the latest version of the
@@ -89,15 +96,17 @@
 
 The only required argument to
 .I sup
-is the name of a supfile.  It must either be given explicitly on the command
-line, or the
+is the name of a supfile.
+It must either be given explicitly on the command line, or the
 .B -s
-flag must be specified.  If the
+flag must be specified.
+If the
 .B -s
 flag is given, the system supfile will be used and a supfile command argument
-should not be specified.  The list of collections is optional and if specified
-will be the only collections upgraded.  The following flags affect all
-collections specified:
+should not be specified.
+The list of collections is optional and if specified
+will be the only collections upgraded.
+The following flags affect all collections specified:
 .TP
 .B -s
 As described above.
@@ -131,15 +140,18 @@
 .PP
 
 The remaining flags affect all collections unless an explicit list
-of collections are given with the flags.  Multiple flags may be
-specified together that affect the same collections.  For the sake
+of collections are given with the flags.
+Multiple flags may be
+specified together that affect the same collections.
+For the sake
 of convenience, any flags that always affect all collections can be
-specified with flags that affect only some collections.  For
-example,
+specified with flags that affect only some collections.
+For example,
 .B sup -sde=coll1,coll2
 would perform a system upgrade,
 and the first two collections would allow both file deletions and
-command executions.  Note that this is not the same command as
+command executions.
+Note that this is not the same command as
 .B sup -sde=coll1 coll2,
 which would perform a system upgrade of
 just the coll2 collection and would ignore the flags given for the
@@ -148,10 +160,12 @@
 .B -a
 All files in the collection will be copied from
 the repository, regardless of their status on the
-current machine.  Because of this, it is a very
+current machine.
+Because of this, it is a very
 expensive operation and should only be done for
 small collections if data corruption is suspected
-and been confirmed.  In most cases, the

CVS commit: src/usr.sbin/sup/source

2011-03-17 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Mar 17 19:43:35 UTC 2011

Modified Files:
src/usr.sbin/sup/source: supfilesrv.c

Log Message:
don't decrement if children are 0


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/usr.sbin/sup/source/supfilesrv.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/sup/source/supfilesrv.c
diff -u src/usr.sbin/sup/source/supfilesrv.c:1.45 src/usr.sbin/sup/source/supfilesrv.c:1.46
--- src/usr.sbin/sup/source/supfilesrv.c:1.45	Wed Mar 16 16:17:00 2011
+++ src/usr.sbin/sup/source/supfilesrv.c	Thu Mar 17 15:43:34 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: supfilesrv.c,v 1.45 2011/03/16 20:17:00 christos Exp $	*/
+/*	$NetBSD: supfilesrv.c,v 1.46 2011/03/17 19:43:34 christos Exp $	*/
 
 /*
  * Copyright (c) 1992 Carnegie Mellon University
@@ -495,9 +495,11 @@
 		if (kill(pid, 0) == -1)
 			switch (errno) {
 			case ESRCH:
-if (nchildren == 0)
+if (nchildren == 0) {
 	logerr(no children but pid %jd\n,
 	(intmax_t)pid);
+	break;
+}
 nchildren--;
 break;
 			default:



CVS commit: src/usr.sbin/sup/source

2011-01-04 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Tue Jan  4 10:14:25 UTC 2011

Modified Files:
src/usr.sbin/sup/source: scan.c

Log Message:
Fix fd leaks in error cases. Found by cppcheck.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/usr.sbin/sup/source/scan.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/sup/source/scan.c
diff -u src/usr.sbin/sup/source/scan.c:1.27 src/usr.sbin/sup/source/scan.c:1.28
--- src/usr.sbin/sup/source/scan.c:1.27	Sat Oct 17 20:46:03 2009
+++ src/usr.sbin/sup/source/scan.c	Tue Jan  4 10:14:25 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: scan.c,v 1.27 2009/10/17 20:46:03 christos Exp $	*/
+/*	$NetBSD: scan.c,v 1.28 2011/01/04 10:14:25 wiz Exp $	*/
 
 /*
  * Copyright (c) 1992 Carnegie Mellon University
@@ -968,9 +968,9 @@
 	if (scanF == NULL)
 		goto out;
 	if (fprintf(scanF, V%d\n, SCANVERSION)  0)
-		goto out;
+		goto closeout;
 	if (Tprocess(listT, recordone, scanF) != SCMOK)
-		goto out;
+		goto closeout;
 	if (fclose(scanF) != 0)
 		goto out;
 	if (rename(tname, fname)  0) {
@@ -983,6 +983,8 @@
 	tbuf[1].tv_usec = 0;
 	(void) utimes(fname, tbuf);
 	return;
+closeout:
+	(void) fclose(scanF);
 out:
 	goaway(Can't write scan file temp %s for %s, tname, collname);
 }



CVS commit: src/usr.sbin/sup/source

2011-01-04 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Tue Jan  4 10:23:40 UTC 2011

Modified Files:
src/usr.sbin/sup/source: scan.c

Log Message:
unifdef -U RCSSTAT
This code was added in 1.2 by brezak with changes for the commit message:
Change sys/dir.h to dirent.h
and looks like it never worked.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/usr.sbin/sup/source/scan.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/sup/source/scan.c
diff -u src/usr.sbin/sup/source/scan.c:1.28 src/usr.sbin/sup/source/scan.c:1.29
--- src/usr.sbin/sup/source/scan.c:1.28	Tue Jan  4 10:14:25 2011
+++ src/usr.sbin/sup/source/scan.c	Tue Jan  4 10:23:40 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: scan.c,v 1.28 2011/01/04 10:14:25 wiz Exp $	*/
+/*	$NetBSD: scan.c,v 1.29 2011/01/04 10:23:40 wiz Exp $	*/
 
 /*
  * Copyright (c) 1992 Carnegie Mellon University
@@ -166,11 +166,6 @@
 extern int trace;		/* trace directories */
 extern int newonly;		/* new files only */
 
-#ifdef RCSSTAT
-extern char *rcs_branch;
-extern int candorcs;
-#endif
-
 /*
  ***   STATIC   R O U T I N E S***
  */
@@ -644,27 +639,6 @@
 	}
 	if (access(name, R_OK)  0)
 		return;
-#ifdef RCSSTAT
-	if (candorcs) {
-		char rcs_release[STRINGLENGTH];
-		int status;
-		if (rcs_branch != NULL)
-#ifdef CVS
-			sprintf(rcs_release, -r %s, rcs_branch);
-#else
-			sprintf(rcs_release, -r%s, rcs_branch);
-#endif
-		else
-			rcs_release[0] = '\0';
-#ifdef CVS
-		sprintf(sys_com, cvs -d %s -r -l -Q co -p %s %s  %s\n, cvs_root, rcs_release, name, rcs_file);
-#else
-		status = runp(rcsstat, rcsstat, -q, rcs_release, name, 0);
-#endif
-		if (status != 0)
-			return;
-	}
-#endif
 	listname(fullname, statbuf);
 }
 



CVS commit: src/usr.sbin/sup/source

2010-10-20 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Oct 20 17:05:54 UTC 2010

Modified Files:
src/usr.sbin/sup/source: scmio.c supcmeat.c supcmisc.c supfilesrv.c

Log Message:
improve error handling and logging.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/usr.sbin/sup/source/scmio.c
cvs rdiff -u -r1.37 -r1.38 src/usr.sbin/sup/source/supcmeat.c
cvs rdiff -u -r1.20 -r1.21 src/usr.sbin/sup/source/supcmisc.c
cvs rdiff -u -r1.43 -r1.44 src/usr.sbin/sup/source/supfilesrv.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/sup/source/scmio.c
diff -u src/usr.sbin/sup/source/scmio.c:1.19 src/usr.sbin/sup/source/scmio.c:1.20
--- src/usr.sbin/sup/source/scmio.c:1.19	Sun Oct 18 11:23:54 2009
+++ src/usr.sbin/sup/source/scmio.c	Wed Oct 20 13:05:54 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: scmio.c,v 1.19 2009/10/18 15:23:54 christos Exp $	*/
+/*	$NetBSD: scmio.c,v 1.20 2010/10/20 17:05:54 christos Exp $	*/
 
 /*
  * Copyright (c) 1992 Carnegie Mellon University
@@ -542,7 +542,7 @@
 	(void) readmend();
 	if (goawayreason == NULL)
 		return (SCMEOF);
-	logerr(SCM GOAWAY %s, goawayreason);
+	logerr(SCM GOAWAY for %s %s, remotehost(), goawayreason);
 	return (SCMEOF);
 }
 

Index: src/usr.sbin/sup/source/supcmeat.c
diff -u src/usr.sbin/sup/source/supcmeat.c:1.37 src/usr.sbin/sup/source/supcmeat.c:1.38
--- src/usr.sbin/sup/source/supcmeat.c:1.37	Sat Oct 17 16:46:03 2009
+++ src/usr.sbin/sup/source/supcmeat.c	Wed Oct 20 13:05:54 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: supcmeat.c,v 1.37 2009/10/17 20:46:03 christos Exp $	*/
+/*	$NetBSD: supcmeat.c,v 1.38 2010/10/20 17:05:54 christos Exp $	*/
 
 /*
  * Copyright (c) 1992 Carnegie Mellon University
@@ -1407,20 +1407,24 @@
 	}
 	(void) sprintf(fname, FILEWHEN, collname, relsufix);
 	if (establishdir(fname)) {
+		int oerrno = errno;
 		Tfree(lastT);
 		if (protver  6)
 			return;
-		done(FDONEUSRERROR, Couldn't timestamp);
+		done(FDONEUSRERROR, Couldn't create directory `%s' (%s),
+			fname, strerror(oerrno));
 		(void) requestend();
 		return;
 	}
 	if (!putwhen(fname, scantime)) {
+		int oerrno = errno;
 		notify(SUP: Can't record current time in %s (%s)\n,
-		fname, strerror(errno));
+		fname, strerror(oerrno));
 		Tfree(lastT);
 		if (protver  6)
 			return;
-		done(FDONEUSRERROR, Couldn't timestamp);
+		done(FDONEUSRERROR, Couldn't timestamp `%s' (%s),
+			fname, strerror(oerrno));
 		(void) requestend();
 		return;
 	}

Index: src/usr.sbin/sup/source/supcmisc.c
diff -u src/usr.sbin/sup/source/supcmisc.c:1.20 src/usr.sbin/sup/source/supcmisc.c:1.21
--- src/usr.sbin/sup/source/supcmisc.c:1.20	Fri Oct 16 08:41:37 2009
+++ src/usr.sbin/sup/source/supcmisc.c	Wed Oct 20 13:05:54 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: supcmisc.c,v 1.20 2009/10/16 12:41:37 christos Exp $	*/
+/*	$NetBSD: supcmisc.c,v 1.21 2010/10/20 17:05:54 christos Exp $	*/
 
 /*
  * Copyright (c) 1992 Carnegie Mellon University
@@ -144,14 +144,17 @@
 	if (strcmp(fpart, .) == 0) {	/* dname is / or . */
 		notify(SUP: Can't create directory %s for %s (Invalid name)\n,
 		dname, fname);
+		errno = EINVAL;
 		return (TRUE);
 	}
 	x = estabd(fname, dpart);
 	if (x)
 		return (TRUE);
 	if (makedir(dname, 0755, sbuf)  0) {
+		int oerrno = errno;
 		notify(SUP: Can't create directory %s for %s (%s)\n, dname,
 		fname, strerror(errno));
+		errno = oerrno;
 		return TRUE;
 	}
 	vnotify(SUP Created directory %s for %s\n, dname, fname);

Index: src/usr.sbin/sup/source/supfilesrv.c
diff -u src/usr.sbin/sup/source/supfilesrv.c:1.43 src/usr.sbin/sup/source/supfilesrv.c:1.44
--- src/usr.sbin/sup/source/supfilesrv.c:1.43	Sat Oct 17 16:46:03 2009
+++ src/usr.sbin/sup/source/supfilesrv.c	Wed Oct 20 13:05:54 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: supfilesrv.c,v 1.43 2009/10/17 20:46:03 christos Exp $	*/
+/*	$NetBSD: supfilesrv.c,v 1.44 2010/10/20 17:05:54 christos Exp $	*/
 
 /*
  * Copyright (c) 1992 Carnegie Mellon University
@@ -783,7 +783,7 @@
 {
 	int x;
 	char *p, *q;
-	char buf[STRINGLENGTH];
+	char buf[STRINGLENGTH], filename[MAXPATHLEN];
 	FILE *f;
 	struct stat sbuf;
 	TREELIST *tl;
@@ -882,8 +882,8 @@
 		release = estrdup(DEFRELEASE);
 	if (basedir == NULL || *basedir == '\0') {
 		basedir = NULL;
-		(void) sprintf(buf, FILEDIRS, DEFDIR);
-		f = fopen(buf, r);
+		(void) sprintf(filename, FILEDIRS, DEFDIR);
+		f = fopen(filename, r);
 		if (f) {
 			while ((p = fgets(buf, STRINGLENGTH, f)) != NULL) {
 q = strchr(p, '\n');
@@ -906,9 +906,10 @@
 		}
 	}
 	if (chdir(basedir)  0)
-		goaway(Can't chdir to base directory %s, basedir);
-	(void) sprintf(buf, FILEPREFIX, collname);
-	f = fopen(buf, r);
+		goaway(Can't chdir to base directory %s (%s), basedir,
+		strerror(errno));
+	(void) sprintf(filename, FILEPREFIX, collname);
+	f = fopen(filename, r);
 	if (f) {
 		while ((p = fgets(buf, STRINGLENGTH, f)) != NULL) {
 			q = strchr(p, '\n');
@@ -918,8 +919,9 @@
 continue;
 			prefix 

CVS commit: src/usr.sbin/sup/source

2009-11-01 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Sun Nov  1 20:25:57 UTC 2009

Modified Files:
src/usr.sbin/sup/source: sup.1

Log Message:
Fix markup.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/usr.sbin/sup/source/sup.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/sup/source/sup.1
diff -u src/usr.sbin/sup/source/sup.1:1.16 src/usr.sbin/sup/source/sup.1:1.17
--- src/usr.sbin/sup/source/sup.1:1.16	Wed Dec 17 17:53:19 2008
+++ src/usr.sbin/sup/source/sup.1	Sun Nov  1 20:25:57 2009
@@ -1,4 +1,4 @@
-.\	$NetBSD: sup.1,v 1.16 2008/12/17 17:53:19 christos Exp $
+.\	$NetBSD: sup.1,v 1.17 2009/11/01 20:25:57 joerg Exp $
 .\
 .\ Copyright (c) 1992 Carnegie Mellon University
 .\ All Rights Reserved.
@@ -860,7 +860,7 @@
 .SH BUGS
 The encryption mechanism should be strengthened, although it's
 not trivial.
-.Pp
+.PP
 .I sup 
 can delete files it should not with the delete option.
 This is because in the delete pass, it tries to delete all files



CVS commit: src/usr.sbin/sup/source

2009-11-01 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Mon Nov  2 00:29:04 UTC 2009

Modified Files:
src/usr.sbin/sup/source: sup.1

Log Message:
Drop .i0, it is an undefined macro.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/usr.sbin/sup/source/sup.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/sup/source/sup.1
diff -u src/usr.sbin/sup/source/sup.1:1.17 src/usr.sbin/sup/source/sup.1:1.18
--- src/usr.sbin/sup/source/sup.1:1.17	Sun Nov  1 20:25:57 2009
+++ src/usr.sbin/sup/source/sup.1	Mon Nov  2 00:29:04 2009
@@ -1,4 +1,4 @@
-.\	$NetBSD: sup.1,v 1.17 2009/11/01 20:25:57 joerg Exp $
+.\	$NetBSD: sup.1,v 1.18 2009/11/02 00:29:04 joerg Exp $
 .\
 .\ Copyright (c) 1992 Carnegie Mellon University
 .\ All Rights Reserved.
@@ -127,7 +127,6 @@
 .B -P
 Sup will use a set of non-privileged network
 ports reserved for debugging purposes.
-.i0
 .DT
 .PP
 
@@ -350,7 +349,6 @@
 messages during normal progress showing what
 .I sup
 is doing.
-.i0
 .DT
 .PP
 .SH SETTING UP UPGRADES
@@ -408,7 +406,6 @@
 .B -d
 flag is used to locate files previously upgraded that are no longer
 in the collection that should be deleted.
-.i0
 .DT
 .PP
 
@@ -552,7 +549,6 @@
 .I when
 files. This is necessary whenever you are supping more than one
 release in the same collection.
-.i0
 .DT
 .PP
 .SH PREPARING A FILE COLLECTION REPOSITORY
@@ -667,7 +663,6 @@
 will append the last time an upgrade was successfully completed,
 the time the last upgrade started and finished, and the name of
 the host requesting the upgrade.
-.i0
 .DT
 .PP
 It should be noted that
@@ -778,7 +773,6 @@
 when one collection subsumes other collections; the larger collection
 can simply specify the listfiles for the smaller collections contained
 within it.
-.i0
 .DT
 .PP
 The order in which the command lines appear in the list file does not
@@ -810,7 +804,6 @@
 .TP
 \fB/usr/sup/\fR\*[Lt]\fIcollection\fR\*[Gt]
 default base directory for file collection
-.i0
 .DT
 .PP
 
@@ -847,7 +840,6 @@
 .TP
 \fB/usr/\fR\*[Lt]\fIcollection\fR\*[Gt]
 default base directory for a file collection
-.i0
 .DT
 .PP
 .SH SEE ALSO



CVS commit: src/usr.sbin/sup/source

2009-11-01 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Mon Nov  2 00:33:34 UTC 2009

Modified Files:
src/usr.sbin/sup/source: supservers.8

Log Message:
Drop undefined macros.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/usr.sbin/sup/source/supservers.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/sup/source/supservers.8
diff -u src/usr.sbin/sup/source/supservers.8:1.9 src/usr.sbin/sup/source/supservers.8:1.10
--- src/usr.sbin/sup/source/supservers.8:1.9	Fri Feb  8 01:38:56 2002
+++ src/usr.sbin/sup/source/supservers.8	Mon Nov  2 00:33:34 2009
@@ -1,4 +1,4 @@
-.\	$NetBSD: supservers.8,v 1.9 2002/02/08 01:38:56 ross Exp $
+.\	$NetBSD: supservers.8,v 1.10 2009/11/02 00:33:34 joerg Exp $
 .\
 .\ Copyright (c) 1992 Carnegie Mellon University
 .\ All Rights Reserved.
@@ -29,7 +29,6 @@
 .\ 	[92/08/11mrt]
 .\
 .TH SUPSERVERS 8 1/16/86
-.CM 1
 .SH NAME
 supfilesrv, supscan \- sup server processes
 .SH SYNOPSIS
@@ -220,7 +219,6 @@
 .I
 supscan
 from list file
-.i0
 .DT
 .PP
 .SH SEE ALSO



CVS commit: src/usr.sbin/sup/source

2009-10-18 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Oct 18 15:23:54 UTC 2009

Modified Files:
src/usr.sbin/sup/source: ffilecopy.c scmio.c

Log Message:
fix size_t issues on _LP64


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.sbin/sup/source/ffilecopy.c
cvs rdiff -u -r1.18 -r1.19 src/usr.sbin/sup/source/scmio.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/sup/source/ffilecopy.c
diff -u src/usr.sbin/sup/source/ffilecopy.c:1.10 src/usr.sbin/sup/source/ffilecopy.c:1.11
--- src/usr.sbin/sup/source/ffilecopy.c:1.10	Sat Oct 17 18:26:13 2009
+++ src/usr.sbin/sup/source/ffilecopy.c	Sun Oct 18 11:23:54 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffilecopy.c,v 1.10 2009/10/17 22:26:13 christos Exp $	*/
+/*	$NetBSD: ffilecopy.c,v 1.11 2009/10/18 15:23:54 christos Exp $	*/
 
 /*
  * Copyright (c) 1991 Carnegie Mellon University
@@ -96,7 +96,7 @@
  *
  */
 
-int 
+ssize_t 
 ffilecopy(FILE * here, FILE * there)
 {
 	int i, herefile, therefile;

Index: src/usr.sbin/sup/source/scmio.c
diff -u src/usr.sbin/sup/source/scmio.c:1.18 src/usr.sbin/sup/source/scmio.c:1.19
--- src/usr.sbin/sup/source/scmio.c:1.18	Sat Oct 17 18:26:13 2009
+++ src/usr.sbin/sup/source/scmio.c	Sun Oct 18 11:23:54 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: scmio.c,v 1.18 2009/10/17 22:26:13 christos Exp $	*/
+/*	$NetBSD: scmio.c,v 1.19 2009/10/18 15:23:54 christos Exp $	*/
 
 /*
  * Copyright (c) 1992 Carnegie Mellon University
@@ -256,7 +256,8 @@
 		return (scmerr(-1, Write retries failed));
 	}
 	if (x != count)
-		return (scmerr(-1, Write error on network returned %d on write of %d, x, count));
+		return (scmerr(-1, Write error on network returned %d 
+		on write of %zu, x, count));
 	return (SCMOK);
 }
 
@@ -434,7 +435,7 @@
 
 	if (push) {
 		if (bufptr + count  buffer)
-			return (scmerr(-1, No space in buffer %d, count));
+			return (scmerr(-1, No space in buffer %zu, count));
 		bufptr -= count;
 		bufcnt += count;
 		memcpy(bufptr, data, -count);



CVS commit: src/usr.sbin/sup/source

2009-10-17 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Oct 17 20:46:03 UTC 2009

Modified Files:
src/usr.sbin/sup/source: scan.c stree.c supcmain.c supcmeat.c
supcname.c supfilesrv.c supscan.c

Log Message:
change to strchr and strrchr


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/usr.sbin/sup/source/scan.c
cvs rdiff -u -r1.13 -r1.14 src/usr.sbin/sup/source/stree.c
cvs rdiff -u -r1.29 -r1.30 src/usr.sbin/sup/source/supcmain.c
cvs rdiff -u -r1.36 -r1.37 src/usr.sbin/sup/source/supcmeat.c
cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/sup/source/supcname.c
cvs rdiff -u -r1.42 -r1.43 src/usr.sbin/sup/source/supfilesrv.c
cvs rdiff -u -r1.17 -r1.18 src/usr.sbin/sup/source/supscan.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/sup/source/scan.c
diff -u src/usr.sbin/sup/source/scan.c:1.26 src/usr.sbin/sup/source/scan.c:1.27
--- src/usr.sbin/sup/source/scan.c:1.26	Thu Dec 20 15:15:59 2007
+++ src/usr.sbin/sup/source/scan.c	Sat Oct 17 16:46:03 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: scan.c,v 1.26 2007/12/20 20:15:59 christos Exp $	*/
+/*	$NetBSD: scan.c,v 1.27 2009/10/17 20:46:03 christos Exp $	*/
 
 /*
  * Copyright (c) 1992 Carnegie Mellon University
@@ -297,10 +297,10 @@
 rewound = TRUE;
 continue;
 			}
-			q = index(p, '\n');
+			q = strchr(p, '\n');
 			if (q)
 *q = 0;
-			if (index(#;:, *p))
+			if (strchr(#;:, *p))
 continue;
 			q = nxtarg(p,  \t);
 			if (strcmp(q, release) != 0)
@@ -357,10 +357,10 @@
 	f = fopen(buf, r);
 	if (f != NULL) {
 		while ((p = fgets(buf, sizeof(buf), f)) != NULL) {
-			q = index(p, '\n');
+			q = strchr(p, '\n');
 			if (q)
 *q = 0;
-			if (index(#;:, *p))
+			if (strchr(#;:, *p))
 continue;
 			q = nxtarg(p,  \t);
 			(void) parserelease(tl, q, p);
@@ -481,9 +481,9 @@
 		goaway(Can't read list file %s, fname);
 	cdprefix(prefix);
 	while ((p = fgets(buf, sizeof(buf), f)) != NULL) {
-		if ((q = index(p, '\n')) != NULL)
+		if ((q = strchr(p, '\n')) != NULL)
 			*q = '\0';
-		if (index(#;:, *p))
+		if (strchr(#;:, *p))
 			continue;
 		q = nxtarg(p,  \t);
 		if (*q == '\0')
@@ -851,7 +851,7 @@
 		(void) fclose(f);
 		return (FALSE);
 	}
-	if ((q = index(p, '\n')) != NULL)
+	if ((q = strchr(p, '\n')) != NULL)
 		*q = '\0';
 	if (*p++ != 'V') {
 		(void) fclose(f);
@@ -869,7 +869,7 @@
 	}
 	notwanted = FALSE;
 	while ((p = fgets(buf, sizeof(buf), f)) != NULL) {
-		q = index(p, '\n');
+		q = strchr(p, '\n');
 		if (q)
 			*q = 0;
 		ts.Tflags = 0;
@@ -890,17 +890,17 @@
 			p++;
 			ts.Tflags |= FNOACCT;
 		}
-		if ((q = index(p, ' ')) == NULL)
+		if ((q = strchr(p, ' ')) == NULL)
 			goaway(scanfile format inconsistent);
 		*q++ = '\0';
 		ts.Tmode = atoo(p);
 		p = q;
-		if ((q = index(p, ' ')) == NULL)
+		if ((q = strchr(p, ' ')) == NULL)
 			goaway(scanfile format inconsistent);
 		*q++ = '\0';
 		ts.Tctime = atoi(p);
 		p = q;
-		if ((q = index(p, ' ')) == NULL)
+		if ((q = strchr(p, ' ')) == NULL)
 			goaway(scanfile format inconsistent);
 		*q++ = 0;
 		ts.Tmtime = atoi(p);

Index: src/usr.sbin/sup/source/stree.c
diff -u src/usr.sbin/sup/source/stree.c:1.13 src/usr.sbin/sup/source/stree.c:1.14
--- src/usr.sbin/sup/source/stree.c:1.13	Fri Oct 16 08:41:37 2009
+++ src/usr.sbin/sup/source/stree.c	Sat Oct 17 16:46:03 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: stree.c,v 1.13 2009/10/16 12:41:37 christos Exp $	*/
+/*	$NetBSD: stree.c,v 1.14 2009/10/17 20:46:03 christos Exp $	*/
 
 /*
  * Copyright (c) 1992 Carnegie Mellon University
@@ -280,7 +280,7 @@
 		return (x);
 	(void) strncpy(buf, p, sizeof(buf) - 1);
 	buf[MAXPATHLEN] = '\0';
-	while ((q = rindex(buf, '/')) != NULL) {
+	while ((q = strrchr(buf, '/')) != NULL) {
 		while (q = buf  *(q - 1) == '/')
 			q--;
 		if (q == buf)

Index: src/usr.sbin/sup/source/supcmain.c
diff -u src/usr.sbin/sup/source/supcmain.c:1.29 src/usr.sbin/sup/source/supcmain.c:1.30
--- src/usr.sbin/sup/source/supcmain.c:1.29	Fri Oct 16 18:45:18 2009
+++ src/usr.sbin/sup/source/supcmain.c	Sat Oct 17 16:46:03 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: supcmain.c,v 1.29 2009/10/16 22:45:18 christos Exp $	*/
+/*	$NetBSD: supcmain.c,v 1.30 2009/10/17 20:46:03 christos Exp $	*/
 
 /*
  * Copyright (c) 1992 Carnegie Mellon University
@@ -671,7 +671,7 @@
 	lastC = NULL;
 	bogus = FALSE;
 	while ((p = read_line(f, NULL, NULL, NULL, 0)) != NULL) {
-		if (index(#;:, *p))
+		if (strchr(#;:, *p))
 			continue;
 		arg = nxtarg(p,  \t);
 		if (*arg == '\0') {

Index: src/usr.sbin/sup/source/supcmeat.c
diff -u src/usr.sbin/sup/source/supcmeat.c:1.36 src/usr.sbin/sup/source/supcmeat.c:1.37
--- src/usr.sbin/sup/source/supcmeat.c:1.36	Fri Oct 16 18:45:18 2009
+++ src/usr.sbin/sup/source/supcmeat.c	Sat Oct 17 16:46:03 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: supcmeat.c,v 1.36 2009/10/16 22:45:18 christos Exp $	*/
+/*	$NetBSD: supcmeat.c,v 1.37 2009/10/17 20:46:03 christos Exp $	*/
 
 /*
  * Copyright (c) 1992 Carnegie Mellon 

CVS commit: src/usr.sbin/sup/source

2009-10-17 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Oct 17 22:26:13 UTC 2009

Modified Files:
src/usr.sbin/sup/source: expand.c ffilecopy.c filecopy.c netcryptvoid.c
scm.c scmio.c stree.c supextern.h supmsg.c

Log Message:
pass lint


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/usr.sbin/sup/source/expand.c \
src/usr.sbin/sup/source/scmio.c
cvs rdiff -u -r1.9 -r1.10 src/usr.sbin/sup/source/ffilecopy.c \
src/usr.sbin/sup/source/netcryptvoid.c
cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/sup/source/filecopy.c
cvs rdiff -u -r1.27 -r1.28 src/usr.sbin/sup/source/scm.c
cvs rdiff -u -r1.14 -r1.15 src/usr.sbin/sup/source/stree.c
cvs rdiff -u -r1.21 -r1.22 src/usr.sbin/sup/source/supextern.h
cvs rdiff -u -r1.16 -r1.17 src/usr.sbin/sup/source/supmsg.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/sup/source/expand.c
diff -u src/usr.sbin/sup/source/expand.c:1.17 src/usr.sbin/sup/source/expand.c:1.18
--- src/usr.sbin/sup/source/expand.c:1.17	Tue Oct 13 08:11:19 2009
+++ src/usr.sbin/sup/source/expand.c	Sat Oct 17 18:26:13 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: expand.c,v 1.17 2009/10/13 12:11:19 christos Exp $	*/
+/*	$NetBSD: expand.c,v 1.18 2009/10/17 22:26:13 christos Exp $	*/
 
 /*
  * Copyright (c) 1991 Carnegie Mellon University
@@ -97,7 +97,7 @@
 static int amatch(char *, char *);
 static void addone(char *, const char *);
 static int addpath(char);
-static int gethdir(char *, int);
+static int gethdir(char *, size_t);
 
 int 
 expand(char *spec, char **buffer, int bufsize)
@@ -392,7 +392,7 @@
 }
 
 static int 
-gethdir(char *home, int homelen)
+gethdir(char *home, size_t homelen)
 {
 	struct passwd *pp = getpwnam(home);
 
Index: src/usr.sbin/sup/source/scmio.c
diff -u src/usr.sbin/sup/source/scmio.c:1.17 src/usr.sbin/sup/source/scmio.c:1.18
--- src/usr.sbin/sup/source/scmio.c:1.17	Fri Oct 16 08:41:37 2009
+++ src/usr.sbin/sup/source/scmio.c	Sat Oct 17 18:26:13 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: scmio.c,v 1.17 2009/10/16 12:41:37 christos Exp $	*/
+/*	$NetBSD: scmio.c,v 1.18 2009/10/17 22:26:13 christos Exp $	*/
 
 /*
  * Copyright (c) 1992 Carnegie Mellon University
@@ -157,6 +157,7 @@
 
 #include libc.h
 #include errno.h
+#include stdbool.h
 #include sys/types.h
 #include sys/stat.h
 #include sys/file.h
@@ -201,9 +202,9 @@
 }   buffers[2];
 struct buf *gblbufptr;		/* buffer pointer */
 
-static int writedata(int, char *);
-static int writeblock(int, char *);
-static int readdata(int, char *);
+static int writedata(size_t, void *);
+static int writeblock(size_t, void *);
+static int readdata(size_t, void *, bool);
 static int readcount(int *);
 
 
@@ -212,7 +213,7 @@
  ***/
 
 static int
-writedata(int count, char *data)
+writedata(size_t count, void *data)
 {/* write raw data to network */
 	int x, tries;
 	struct buf *bp;
@@ -260,12 +261,12 @@
 }
 
 static int
-writeblock(int count, char *data)
+writeblock(size_t count, void *data)
 {/* write data block */
 	int x;
-	int y = byteswap(count);
+	int y = byteswap((int)count);
 
-	x = writedata(sizeof(int), (char *) y);
+	x = writedata(sizeof(int), y);
 	if (x == SCMOK)
 		x = writedata(count, data);
 	return (x);
@@ -284,18 +285,18 @@
 	gblbufptr-b_ptr = gblbufptr-b_data;
 	gblbufptr-b_cnt = 0;
 	x = byteswap(msg);
-	return (writedata(sizeof(int), (char *) x));
+	return (writedata(sizeof(int), x));
 }
 
 int
 writemend(void)
 {/* write end of message */
-	int count;
+	size_t count;
 	char *data;
 	int x;
 
 	x = byteswap(ENDCOUNT);
-	x = writedata(sizeof(int), (char *) x);
+	x = writedata(sizeof(int), x);
 	if (x != SCMOK)
 		return (x);
 	if (gblbufptr == NULL)
@@ -317,18 +318,19 @@
 	if (scmdebug  2)
 		loginfo(SCM Writing integer %d, i);
 	x = byteswap(i);
-	return (writeblock(sizeof(int), (char *) x));
+	return (writeblock(sizeof(int), x));
 }
 
 int
 writestring(char *p)
 {/* write string as data block */
-	int len, x;
+	int len;
+	int x;
 	if (p == NULL) {
 		int y = byteswap(NULLCOUNT);
 		if (scmdebug  2)
 			loginfo(SCM Writing string NULL);
-		return (writedata(sizeof(int), (char *) y));
+		return (writedata(sizeof(int), y));
 	}
 	if (scmdebug  2)
 		loginfo(SCM Writing string %s, p);
@@ -340,7 +342,7 @@
 		encode(p, cryptbuf, len);
 		p = cryptbuf;
 	}
-	return (writeblock(len, p));
+	return (writeblock((size_t)len, p));
 }
 
 int
@@ -353,9 +355,9 @@
 
 	if (fstat(f, statbuf)  0)
 		return (scmerr(errno, Can't access open file for message));
-	filesize = statbuf.st_size;
+	filesize = (int)statbuf.st_size;
 	y = byteswap(filesize);
-	x = writedata(sizeof(int), (char *) y);
+	x = writedata(sizeof(int), y);
 
 	if (cryptflag)
 		x = getcryptbuf(FILEXFER);
@@ -367,9 +369,9 @@
 			if (number  0) {
 if (cryptflag) {
 	encode(buf, cryptbuf, number);
-	x = writedata(number, cryptbuf);
+	x = writedata((size_t)number, cryptbuf);
 

CVS commit: src/usr.sbin/sup/source

2009-10-16 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Oct 16 12:41:37 UTC 2009

Modified Files:
src/usr.sbin/sup/source: log.c nxtarg.c quit.c scm.c scmio.c skipto.c
stree.c supcmain.c supcmeat.c supcmisc.c supextern.h supfilesrv.c
supmsg.c supmsg.h

Log Message:
constification from Paul Ripke to make it compile on OS/X


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/usr.sbin/sup/source/log.c
cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/sup/source/nxtarg.c \
src/usr.sbin/sup/source/quit.c src/usr.sbin/sup/source/skipto.c
cvs rdiff -u -r1.26 -r1.27 src/usr.sbin/sup/source/scm.c
cvs rdiff -u -r1.16 -r1.17 src/usr.sbin/sup/source/scmio.c
cvs rdiff -u -r1.12 -r1.13 src/usr.sbin/sup/source/stree.c
cvs rdiff -u -r1.27 -r1.28 src/usr.sbin/sup/source/supcmain.c
cvs rdiff -u -r1.34 -r1.35 src/usr.sbin/sup/source/supcmeat.c
cvs rdiff -u -r1.19 -r1.20 src/usr.sbin/sup/source/supcmisc.c
cvs rdiff -u -r1.20 -r1.21 src/usr.sbin/sup/source/supextern.h
cvs rdiff -u -r1.41 -r1.42 src/usr.sbin/sup/source/supfilesrv.c
cvs rdiff -u -r1.15 -r1.16 src/usr.sbin/sup/source/supmsg.c
cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/sup/source/supmsg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/sup/source/log.c
diff -u src/usr.sbin/sup/source/log.c:1.9 src/usr.sbin/sup/source/log.c:1.10
--- src/usr.sbin/sup/source/log.c:1.9	Thu Dec 20 15:17:52 2007
+++ src/usr.sbin/sup/source/log.c	Fri Oct 16 08:41:37 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: log.c,v 1.9 2007/12/20 20:17:52 christos Exp $	*/
+/*	$NetBSD: log.c,v 1.10 2009/10/16 12:41:37 christos Exp $	*/
 
 /*
  * Copyright (c) 1992 Carnegie Mellon University
@@ -64,7 +64,7 @@
 }
 
 void
-logquit(int retval, char *fmt, ...)
+logquit(int retval, const char *fmt, ...)
 {
 	char buf[STRINGLENGTH];
 	va_list ap;
@@ -81,7 +81,7 @@
 }
 
 void
-logerr(char *fmt, ...)
+logerr(const char *fmt, ...)
 {
 	char buf[STRINGLENGTH];
 	va_list ap;
@@ -98,7 +98,7 @@
 }
 
 void
-loginfo(char *fmt, ...)
+loginfo(const char *fmt, ...)
 {
 	char buf[STRINGLENGTH];
 	va_list ap;
@@ -131,7 +131,7 @@
 int deny_severity = LIBWRAP_DENY_FACILITY | LIBWRAP_DENY_SEVERITY;
 
 void
-logdeny(char *fmt, ...)
+logdeny(const char *fmt, ...)
 {
 	char buf[STRINGLENGTH];
 	va_list ap;
@@ -148,7 +148,7 @@
 }
 
 void
-logallow(char *fmt, ...)
+logallow(const char *fmt, ...)
 {
 	char buf[STRINGLENGTH];
 	va_list ap;

Index: src/usr.sbin/sup/source/nxtarg.c
diff -u src/usr.sbin/sup/source/nxtarg.c:1.5 src/usr.sbin/sup/source/nxtarg.c:1.6
--- src/usr.sbin/sup/source/nxtarg.c:1.5	Wed Jul 10 16:19:41 2002
+++ src/usr.sbin/sup/source/nxtarg.c	Fri Oct 16 08:41:37 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: nxtarg.c,v 1.5 2002/07/10 20:19:41 wiz Exp $	*/
+/*	$NetBSD: nxtarg.c,v 1.6 2009/10/16 12:41:37 christos Exp $	*/
 
 /*
  * Copyright (c) 1991 Carnegie Mellon University
@@ -27,8 +27,8 @@
 /*
  *  nxtarg -- strip off arguments from a string
  *
- *  Usage:  p = nxtarg (q,brk);
- *	char *p,*q,*brk;
+ *  Usage:  p = nxtarg (q,sep);
+ *	char *p,*q,*sep;
  *	extern char _argbreak;
  *
  *	q is pointer to next argument in string
@@ -36,12 +36,12 @@
  *	q points to remainder of string
  *
  *  Leading blanks and tabs are skipped; the argument ends at the
- *  first occurence of one of the characters in the string brk.
+ *  first occurence of one of the characters in the string sep.
  *  When such a character is found, it is put into the external
  *  variable _argbreak, and replaced by a null character; if the
  *  arg string ends before that, then the null character is
  *  placed into _argbreak;
- *  If brk is 0, then   is substituted.
+ *  If sep is 0, then   is substituted.
  *
  *  HISTORY
  * 01-Jul-83  Steven Shafer (sas) at Carnegie-Mellon University
@@ -60,7 +60,7 @@
 char _argbreak;
 
 char *
-nxtarg(char **q, char *brk)
+nxtarg(char **q, const char *sep)
 {
 	char *front, *back;
 	front = *q;		/* start of string */
@@ -68,9 +68,9 @@
 	while (*front  (*front == ' ' || *front == '\t'))
 		front++;
 	/* find break character at end */
-	if (brk == 0)
-		brk =  ;
-	back = skipto(front, brk);
+	if (sep == 0)
+		sep =  ;
+	back = skipto(front, sep);
 	_argbreak = *back;
 	*q = (*back ? back + 1 : back);	/* next arg start loc */
 	/* elim trailing blanks and tabs */
Index: src/usr.sbin/sup/source/quit.c
diff -u src/usr.sbin/sup/source/quit.c:1.5 src/usr.sbin/sup/source/quit.c:1.6
--- src/usr.sbin/sup/source/quit.c:1.5	Wed Jul 10 16:19:41 2002
+++ src/usr.sbin/sup/source/quit.c	Fri Oct 16 08:41:37 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: quit.c,v 1.5 2002/07/10 20:19:41 wiz Exp $	*/
+/*	$NetBSD: quit.c,v 1.6 2009/10/16 12:41:37 christos Exp $	*/
 
 /*
  * Copyright (c) 1991 Carnegie Mellon University
@@ -49,7 +49,7 @@
 #include supextern.h
 
 void
-quit(int status, char *fmt, ...)
+quit(int status, const char *fmt, ...)
 {
 	va_list args;
 
Index: src/usr.sbin/sup/source/skipto.c
diff -u 

CVS commit: src/usr.sbin/sup/source

2009-10-16 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Oct 16 22:45:19 UTC 2009

Modified Files:
src/usr.sbin/sup/source: supcmain.c supcmeat.c supscan.c

Log Message:
Make this compile again. I should have tried to compile the patches myself,
but ran out of time this morning.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/usr.sbin/sup/source/supcmain.c
cvs rdiff -u -r1.35 -r1.36 src/usr.sbin/sup/source/supcmeat.c
cvs rdiff -u -r1.16 -r1.17 src/usr.sbin/sup/source/supscan.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/sup/source/supcmain.c
diff -u src/usr.sbin/sup/source/supcmain.c:1.28 src/usr.sbin/sup/source/supcmain.c:1.29
--- src/usr.sbin/sup/source/supcmain.c:1.28	Fri Oct 16 08:41:37 2009
+++ src/usr.sbin/sup/source/supcmain.c	Fri Oct 16 18:45:18 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: supcmain.c,v 1.28 2009/10/16 12:41:37 christos Exp $	*/
+/*	$NetBSD: supcmain.c,v 1.29 2009/10/16 22:45:18 christos Exp $	*/
 
 /*
  * Copyright (c) 1992 Carnegie Mellon University
@@ -599,7 +599,7 @@
 	char buf[STRINGLENGTH], *p;
 	const char *u;
 	char username[STRINGLENGTH];
-	char *supfname, **arg;
+	char *supfname, *arg;
 	COLLECTION *c, *lastC;
 	FILE *f;
 	int bogus;

Index: src/usr.sbin/sup/source/supcmeat.c
diff -u src/usr.sbin/sup/source/supcmeat.c:1.35 src/usr.sbin/sup/source/supcmeat.c:1.36
--- src/usr.sbin/sup/source/supcmeat.c:1.35	Fri Oct 16 08:41:37 2009
+++ src/usr.sbin/sup/source/supcmeat.c	Fri Oct 16 18:45:18 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: supcmeat.c,v 1.35 2009/10/16 12:41:37 christos Exp $	*/
+/*	$NetBSD: supcmeat.c,v 1.36 2009/10/16 22:45:18 christos Exp $	*/
 
 /*
  * Copyright (c) 1992 Carnegie Mellon University
@@ -1483,7 +1483,7 @@
 }
 
 void
-goaway(char *fmt, ...)
+goaway(const char *fmt, ...)
 {
 	char buf[STRINGLENGTH];
 	va_list ap;

Index: src/usr.sbin/sup/source/supscan.c
diff -u src/usr.sbin/sup/source/supscan.c:1.16 src/usr.sbin/sup/source/supscan.c:1.17
--- src/usr.sbin/sup/source/supscan.c:1.16	Thu Dec 20 15:17:52 2007
+++ src/usr.sbin/sup/source/supscan.c	Fri Oct 16 18:45:18 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: supscan.c,v 1.16 2007/12/20 20:17:52 christos Exp $	*/
+/*	$NetBSD: supscan.c,v 1.17 2009/10/16 22:45:18 christos Exp $	*/
 
 /*
  * Copyright (c) 1992 Carnegie Mellon University
@@ -393,7 +393,7 @@
 }
 
 void
-goaway(char *fmt, ...)
+goaway(const char *fmt, ...)
 {
 	va_list ap;
 



CVS commit: src/usr.sbin/sup/source

2009-10-13 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Oct 13 12:11:20 UTC 2009

Modified Files:
src/usr.sbin/sup/source: expand.c

Log Message:
- use const where appropriate
- don't cast return value from malloc


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/usr.sbin/sup/source/expand.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/sup/source/expand.c
diff -u src/usr.sbin/sup/source/expand.c:1.16 src/usr.sbin/sup/source/expand.c:1.17
--- src/usr.sbin/sup/source/expand.c:1.16	Fri Jul 20 12:39:05 2007
+++ src/usr.sbin/sup/source/expand.c	Tue Oct 13 08:11:19 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: expand.c,v 1.16 2007/07/20 16:39:05 christos Exp $	*/
+/*	$NetBSD: expand.c,v 1.17 2009/10/13 12:11:19 christos Exp $	*/
 
 /*
  * Copyright (c) 1991 Carnegie Mellon University
@@ -80,7 +80,7 @@
 static char pathbuf[MAXPATHLEN];
 static char *path, *pathp, *lastpathp;
 
-static char *globchars = {[*?;/* meta characters */
+static const char globchars[] = {[*?;/* meta characters */
 static char *entp;		/* current dir entry pointer */
 
 static char **BUFFER;		/* pointer to the buffer */
@@ -95,7 +95,7 @@
 static int execbrc(char *, char *);
 static int match(char *, char *);
 static int amatch(char *, char *);
-static void addone(char *, char *);
+static void addone(char *, const char *);
 static int addpath(char);
 static int gethdir(char *, int);
 
@@ -361,7 +361,7 @@
 }
 
 static void 
-addone(char *s1, char *s2)
+addone(char *s1, const char *s2)
 {
 	char *ep;
 
@@ -369,7 +369,7 @@
 		bufcnt = BUFSIZE + 1;
 		longjmp(sjbuf, 1);
 	}
-	ep = (char *) malloc(strlen(s1) + strlen(s2) + 1);
+	ep = malloc(strlen(s1) + strlen(s2) + 1);
 	if (ep == 0) {
 		bufcnt = -1;
 		longjmp(sjbuf, 1);



CVS commit: src/usr.sbin/sup/source

2009-07-17 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Fri Jul 17 20:31:21 UTC 2009

Modified Files:
src/usr.sbin/sup/source: supcmain.c

Log Message:
doswitch() has changed the value of argc by the time it's checked here,
adjust accordingly.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/usr.sbin/sup/source/supcmain.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/sup/source/supcmain.c
diff -u src/usr.sbin/sup/source/supcmain.c:1.26 src/usr.sbin/sup/source/supcmain.c:1.27
--- src/usr.sbin/sup/source/supcmain.c:1.26	Sun Jan  4 17:10:47 2009
+++ src/usr.sbin/sup/source/supcmain.c	Fri Jul 17 20:31:20 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: supcmain.c,v 1.26 2009/01/04 17:10:47 christos Exp $	*/
+/*	$NetBSD: supcmain.c,v 1.27 2009/07/17 20:31:20 jakllsch Exp $	*/
 
 /*
  * Copyright (c) 1992 Carnegie Mellon University
@@ -627,7 +627,7 @@
 	doswitch(argc, argv, collT, oflags, aflags, username,
 	sizeof(username));
 
-	if (argc == 1  !sysflag)
+	if (argc == 0  !sysflag)
 		logquit(1, Need either -s or supfile);
 #if	MACH
 	oldsigsys = signal(SIGSYS, SIG_IGN);