From andy@sarc.city.ac.uk  Fri Aug  9 06:24:34 1996
Received: from cripplecock.sarc.city.ac.uk ([138.40.91.253])
          by freefall.freebsd.org (8.7.5/8.7.3) with SMTP id GAA08171
          for <FreeBSD-gnats-submit@freebsd.org>; Fri, 9 Aug 1996 06:23:39 -0700 (PDT)
Received: (from andy@localhost) by cripplecock.sarc.city.ac.uk (8.6.12/8.6.12) id OAA17333; Fri, 9 Aug 1996 14:23:27 +0100
Message-Id: <199608091323.OAA17333@cripplecock.sarc.city.ac.uk>
Date: Fri, 9 Aug 1996 14:23:27 +0100
From: Andy Whitcroft <andy@sarc.city.ac.uk>
Reply-To: andy@sarc.city.ac.uk
To: FreeBSD-gnats-submit@freebsd.org
Subject: rdist(1) bug and fix
X-Send-Pr-Version: 3.2

>Number:         1483
>Category:       bin
>Synopsis:       rdist(1) server silently exits verifying symlinks
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Aug  9 06:30:01 PDT 1996
>Closed-Date:    Sat Aug 10 01:06:49 PDT 1996
>Last-Modified:  Sat Aug 10 01:08:00 PDT 1996
>Originator:     Andy Whitcroft
>Release:        FreeBSD 2.1-STABLE i386 and later
>Organization:
Andy.
--
Andy Whitcroft                       EMail: andy@cs.city.ac.uk (MIME) (PGP)
Systems Support, Informatics,        Tel: +44 71 477 8550, Fax: 8587
City University, London, UK.         URL: http://web.cs.city.ac.uk/finger/andy
>Environment:
>Description:

rdist(1) server will silently disconnect from the originator when asked to
verify a symlink which is either incorrect or not a symlink.  rdist is able
to install the link correctly if not verifying.

>How-To-Repeat:

Attempt to rdist a symlink over an existing directory of the same name.  All
futher communication with the server is impossible.

>Fix:

The problem is caused by the badnew2 bail out code which closes fd 'f'.
In the case of a symlink installation f is not initialised at all and tends
to be 0 so closing the client/server channel.

--- server.c.orig	Fri Jul 12 09:03:00 1996
+++ server.c	Fri Aug  9 14:08:47 1996
@@ -697,7 +697,7 @@
 	int type;
 {
 	register char *cp;
-	int f, mode, opts, wrerr, olderrno;
+	int f = -1, mode, opts, wrerr, olderrno;
 	off_t i, size;
 	time_t mtime;
 	struct stat stb;
@@ -922,7 +922,7 @@
 		note("%s: utimes failed %s: %s\n", host, new, strerror(errno));
 
 	if (fchog(f, new, owner, group, mode) < 0) {
-badnew2:	(void) close(f);
+badnew2:	(void) if (f != -1) close(f);
 		(void) unlink(new);
 		return;
 	}
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: peter 
State-Changed-When: Sat Aug 10 01:06:49 PDT 1996 
State-Changed-Why:  
Fix applied in most recent commit.  I had already noticed the uninitialised 
variable with -Wall but had not fixed it yet. 
>Unformatted:
