Subject: NFS fix for realpath in VR11

From: Gregory A Lundberg <[email-masked]>
Date: Tue, 1 Dec 1998 13:07:50 -0500 (EST)

I have updated this patch for VR11 and commited it to my CVS tree. It came
in too late to make it into VR11, so it will appear in VR12 (due out
January 1, 1999).

This patch is available at:

  ftp://ftp.vr.net/pub/wu-ftpd/unsupported/vr11.1.patch

You only need it if you NFS mount parts of your FTP area.

---- Original Message ----

>From [email-masked] Tue Dec  1 11:54:05 1998
Date: Sun, 29 Nov 1998 15:23:52 +0100 (MET)
From: Denis N. Antonioli <[email-masked]>
To: WU-FTPD Discussion List <[email-masked]>
Subject: Re: realpath in 2.4.2-beta-18-vr10

On Fri, 27 Nov 1998, Gregory A Lundberg wrote:

> On Fri, 27 Nov 1998, Denis N. Antonioli wrote:
>
> > Maybe ftpd could seteuid(0) only if a normal access failed?
>
> Sounds fine.  The seteuid(0) stuff is there mainly to support people
> who've revoked read access on the common directory containing the users'
> home directories as in:
>
> d--x--x--x root root /home
> drwx------ greg greg /home/greg
>
> Where 'greg' is a guest user chroot'd to /home/./greg and we want him to
> be able to cd, pwd, etc., but not see the other users in /home

Ok. Here then is a patch for realpath.c.

Happy programming,
        Denis N. Antonioli

---- Updated patch ----

Index: realpath.c
===================================================================
RCS file: /cvsroot/wu-ftpd/src/realpath.c,v
retrieving revision 1.1.1.1.2.6.2.6
retrieving revision 1.1.1.1.2.6.2.7
diff -c -w -r1.1.1.1.2.6.2.6 -r1.1.1.1.2.6.2.7
*** realpath.c	1998/11/23 17:42:37	1.1.1.1.2.6.2.6
--- realpath.c	1998/12/01 17:30:50	1.1.1.1.2.6.2.7
***************
*** 108,114 ****
  	int fd, n, rootd, serrno;
  	char *p, *q, wbuf[MAXPATHLEN];
        int symlinks = 0;
- 	uid_t userid;
  	int resultcode;
  #ifdef HAS_NO_FCHDIR
  /* AIX Has no fchdir() so we hope the getcwd() call doesn't overrun the buffer! */
--- 108,113 ----
***************
*** 117,123 ****
  #endif
  
  	/* Save the starting point. */
! 	userid = geteuid();
  	delay_signaling(); /* we can't allow any signals while euid==0: kinch */
  	seteuid(0);
  #ifdef HAS_NO_FCHDIR
--- 116,128 ----
  #endif
  
  	/* Save the starting point. */
! #ifdef HAS_NO_FCHDIR
! 	pcwd = getcwd(cwd, sizeof (cwd));
! #else
! 	fd = open(".", O_RDONLY);
! #endif
! 	if (EACCES == errno) {
! 		uid_t userid = geteuid();
  		delay_signaling(); /* we can't allow any signals while euid==0: kinch */
  		seteuid(0);
  #ifdef HAS_NO_FCHDIR
***************
*** 131,141 ****
  #endif
  	seteuid(userid);
  	enable_signaling(); /* we can allow signals once again: kinch */
  #ifdef HAS_NO_FCHDIR
! 	if (pcwd == NULL) {
  #else
! 	if (fd < 0) {
  #endif
  		(void)strcpy(resolved, ".");
  		return (NULL);
  	}
--- 136,148 ----
  #endif
  		seteuid(userid);
  		enable_signaling(); /* we can allow signals once again: kinch */
+ 	}
  #ifdef HAS_NO_FCHDIR
! 	if (pcwd == NULL)
  #else
! 	if (fd < 0)
  #endif
+ 	{
  		(void)strcpy(resolved, ".");
  		return (NULL);
  	}
***************
*** 163,174 ****
  			q[1] = '\0';
  			q = resolved;
  		}
! 		userid = geteuid();
  		delay_signaling(); /* we can't allow any signals while euid==0: kinch */
  		seteuid(0);
  		resultcode = chdir(q);
  		seteuid(userid);
  		enable_signaling(); /* we can allow signals once again: kinch */
  		if (resultcode < 0)
  			goto err1;
  	} else
--- 170,184 ----
  			q[1] = '\0';
  			q = resolved;
  		}
! 		resultcode = chdir(q);
! 		if (EACCES == errno) {
! 			uid_t userid = geteuid();
  			delay_signaling(); /* we can't allow any signals while euid==0: kinch */
  			seteuid(0);
  			resultcode = chdir(q);
  			seteuid(userid);
  			enable_signaling(); /* we can allow signals once again: kinch */
+ 		}
  		if (resultcode < 0)
  			goto err1;
  	} else
***************
*** 176,211 ****
  
  	/* Deal with the last component. */
  	if (*p != '\0') {
! 	    userid = geteuid();
  	    delay_signaling(); /* we can't allow any signals while euid==0: kinch */
  	    seteuid(0);
  	    resultcode = lstat(p, &sb);
  	    seteuid(userid);
  	    enable_signaling(); /* we can allow signals once again: kinch */
  	    if (resultcode == 0) {
  		if (S_ISLNK(sb.st_mode)) {
                        if (++symlinks > MAXSYMLINKS) {
                                errno = ELOOP;
                                goto err1;
                        }
! 			userid = geteuid();
  			delay_signaling(); /* we can't allow any signals while euid==0: kinch */
  			seteuid(0);
  			n = readlink(p, resolved, MAXPATHLEN);
  			seteuid(userid);
  			enable_signaling(); /* we can allow signals once again: kinch */
  			if (n < 0)
  				goto err1;
  			resolved[n] = '\0';
  			goto loop;
  		}
  		if (S_ISDIR(sb.st_mode)) {
! 			userid = geteuid();
  			delay_signaling(); /* we can't allow any signals while euid==0: kinch */
  			seteuid(0);
  			resultcode = chdir(p);
  			seteuid(userid);
  			enable_signaling(); /* we can allow signals once again: kinch */
  			if (resultcode < 0)
  				goto err1;
  			p = "";
--- 186,230 ----
  
  	/* Deal with the last component. */
  	if (*p != '\0') {
! 		resultcode = lstat(p, &sb);
! 		if (EACCES == errno) {
! 			uid_t userid = geteuid();
  			delay_signaling(); /* we can't allow any signals while euid==0: kinch */
  			seteuid(0);
  			resultcode = lstat(p, &sb);
  			seteuid(userid);
  			enable_signaling(); /* we can allow signals once again: kinch */
+ 		}
  		if (resultcode == 0) {
  			if (S_ISLNK(sb.st_mode)) {
  				if (++symlinks > MAXSYMLINKS) {
  					errno = ELOOP;
  					goto err1;
  				}
! 				n = readlink(p, resolved, MAXPATHLEN);
! 				if (EACCES == errno) {
! 					uid_t userid = geteuid();
  					delay_signaling(); /* we can't allow any signals while euid==0: kinch */
  					seteuid(0);
  					n = readlink(p, resolved, MAXPATHLEN);
  					seteuid(userid);
  					enable_signaling(); /* we can allow signals once again: kinch */
+ 				}
  				if (n < 0)
  					goto err1;
  				resolved[n] = '\0';
  				goto loop;
  			}
  			if (S_ISDIR(sb.st_mode)) {
! 				resultcode = chdir(p);
! 				if (EACCES == errno) {
! 					uid_t userid = geteuid();
  					delay_signaling(); /* we can't allow any signals while euid==0: kinch */
  					seteuid(0);
  					resultcode = chdir(p);
  					seteuid(userid);
  					enable_signaling(); /* we can allow signals once again: kinch */
+ 				}
  				if (resultcode < 0)
  					goto err1;
  				p = "";
***************
*** 218,224 ****
  	 * the current directory.
  	 */
  	(void)strcpy(wbuf, p);
! 	userid = geteuid();
  	delay_signaling(); /* we can't allow any signals while euid==0: kinch */
  	seteuid(0);
  #ifdef HAVE_GETCWD
--- 237,253 ----
  	 * the current directory.
  	 */
  	(void)strcpy(wbuf, p);
! #ifdef HAVE_GETCWD
! 	resultcode = getcwd(resolved, MAXPATHLEN) == NULL ? 0 : 1;
! #else
! 	resultcode = getwd(resolved) == NULL ? 0 : 1;
! 	if (resolved[MAXPATHLEN -1 ] != '\0') {
! 		resultcode = 0;
! 		errno = ERANGE;
! 	}
! #endif
! 	if (EACCES == errno) {
! 		udt_t userid = geteuid();
  		delay_signaling(); /* we can't allow any signals while euid==0: kinch */
  		seteuid(0);
  #ifdef HAVE_GETCWD
***************
*** 232,237 ****
--- 261,267 ----
  #endif
  		seteuid(userid);
  		enable_signaling(); /* we can allow signals once again: kinch */
+ 	}
  	if (resultcode == 0)
  		goto err1;
  
***************
*** 255,261 ****
  	}
  
  	/* Go back to where we came from. */
! 	userid = geteuid();
  	delay_signaling(); /* we can't allow any signals while euid==0: kinch */
  	seteuid(0);
  #ifdef HAS_NO_FCHDIR
--- 285,297 ----
  	}
  
  	/* Go back to where we came from. */
! #ifdef HAS_NO_FCHDIR
! 	resultcode = chdir(cwd);
! #else
! 	resultcode = fchdir(fd);
! #endif
! 	if (EACCES == errno) {
! 		uid_t userid = geteuid();
  		delay_signaling(); /* we can't allow any signals while euid==0: kinch */
  		seteuid(0);
  #ifdef HAS_NO_FCHDIR
***************
*** 265,270 ****
--- 301,307 ----
  #endif
  		seteuid(userid);
  		enable_signaling(); /* we can allow signals once again: kinch */
+ 	}
  	if (resultcode < 0) {
  		serrno = errno;
  		goto err2;
***************
*** 277,283 ****
  	return (resolved);
  
  err1:	serrno = errno;
! 	userid = geteuid();
  	delay_signaling(); /* we can't allow any signals while euid==0: kinch */
  	seteuid(0);
  #ifdef HAS_NO_FCHDIR
--- 314,326 ----
  	return (resolved);
  
  err1:	serrno = errno;
! #ifdef HAS_NO_FCHDIR
! 	(void)chdir(cwd);
! #else
! 	(void)fchdir(fd);
! #endif
! 	if (EACCES == errno) {
! 		uid_t userid = geteuid();
  		delay_signaling(); /* we can't allow any signals while euid==0: kinch */
  		seteuid(0);
  #ifdef HAS_NO_FCHDIR
***************
*** 287,292 ****
--- 330,336 ----
  #endif
  		seteuid(userid);
  		enable_signaling(); /* we can allow signals once again: kinch */
+ 	}
  #ifdef HAS_NO_FCHDIR
  err2:	errno = serrno;
  #else

-- 

Gregory A Lundberg		Senior Partner, VRnet Company
1441 Elmdale Drive              [email-masked]
Kettering, OH 45409-1615 USA    1-800-809-2195

---

From: "James B. Byrne" <[email-masked]>
Date: Thu, 10 Dec 1998 11:00:03 -0500

Is there a method of including SSL support in wu-ftp or has 
someone already done this?  

This is an emerging requirement for me and I am vague on the 
details of SSL.  We currently run wu-ftp 2.4b18 with Kent 
Landfield's NEWVIRT_050 patches.  Is it possible (practical? 
easy?) to add SSL support to wu-ftp?  I presume that such 
support would also require a modified client?  Does NS-4.x or 
MS-IE 4.x have an SSL ftp client?

What I really need is someone to take a few minutes and tell 
me what I am headed for and whether this is at all possible or 
useful.

Regards,
Jim
---
James B. Byrne                Harte & Lyne Limited
vox: +1 905 561 1241          9 Brockley Drive
fax: +1 905 561 0757          Hamilton, Ontario
mailto:[email-masked]  Canada L8E 3C3

---

From: Gregory A Lundberg <[email-masked]>
Date: Thu, 10 Dec 1998 12:31:29 -0500 (EST)

On Thu, 10 Dec 1998, James B. Byrne wrote:

> Is there a method of including SSL support in wu-ftp or has someone
> already done this?
> 
> This is an emerging requirement for me and I am vague on the details
> of SSL.  We currently run wu-ftp 2.4b18 with Kent Landfield's
> NEWVIRT_050 patches.  Is it possible (practical?  easy?) to add SSL
> support to wu-ftp?  I presume that such support would also require a
> modified client?  Does NS-4.x or MS-IE 4.x have an SSL ftp client?
> 
> What I really need is someone to take a few minutes and tell me what I
> am headed for and whether this is at all possible or useful.

I believe someone has done this to an FTP server (either WU-FTPD or the
old BSD FTPD) and the BSD-ish client. I do not recall where I ran across
it, probably in the mailing list archives, maybe on a web search.

The details of SSL are available at the Netscape site.  They're not for
the faint of heart.

Yes, it's possible to do.  I doubt it will be easy.

Yes, it will require a modified client.  No, that won't be easy either.

I do not know about the web browsers' support for FTP with SSL.  I'd be a
little surprised if any support it.

You will want to be very careful with how you deploy SSL, especially with
respect to Canadian international boarders and foreign laws.

--

---

From: Rainer Schoepf <[email-masked]>
Date: Fri, 11 Dec 1998 09:47:47 +0100 (MET)

> someone already done this?  

You can go through edssl, a non-SSL<->SSL translator daemon. We are using
this for our (non-SSL) POP and IMAP servers. It can be configured for
both server and client side translation.

ftp://ftp.fh-rosenheim.de/pub/mirror/ftp.replay.com/crypto/SSLapps/SSLlynx/edssl83.tgz

Rainer Schöpf

-- 
   Rainer Schöpf
   Zentrum für Datenverarbeitung           A point of view can be a dangerous
    der Universität Mainz                  luxury when substituted for insight
   Anselm-Franz-von-Bentzel-Weg 12         and understanding.
   D-55099 Mainz
   Germany                                  Herbert Marshall McLuhan:
   <[email-masked]>                          The Gutenberg Galaxy

---

From: "James B. Byrne" <[email-masked]>
Date: Fri, 11 Dec 1998 09:32:55 -0500

On 11 Dec 98, at 9:47, Rainer Schoepf wrote:

> this for our (non-SSL) POP and IMAP servers. It can be configured for both
> server and client side translation.
> 

Thanks.

Regards,
Jim
---

---

From: Dan Stromberg <[email-masked]>
Date: Fri, 11 Dec 1998 09:24:09 -0800

> ftp://ftp.fh-rosenheim.de/pub/mirror/ftp.replay.com/crypto/SSLapps/SSLlynx/edssl83.tgz

I'm not sure, but if I had to guess, I'd say edssl (and similar programs) would work fine
for things like imap and pop, but probably wouldn't work for something with a two-socket
design like ftp.

---

From: Gregory A Lundberg <[email-masked]>
Date: Fri, 11 Dec 1998 12:53:14 -0500 (EST)

> ftp://ftp.fh-rosenheim.de/pub/mirror/ftp.replay.com/crypto/SSLapps/SSLlynx/edssl83.tgz

Found it.

  ftp://ftp.psy.uq.oz.au/pub/Crypto/SSLapps/wu-2.4.2-beta11+SSL.diff.gz
  ftp://ftp.psy.uq.oz.au/pub/Crypto/SSLapps/SSLftp-0.13.tar.gz

--

---

From: Gregory A Lundberg <[email-masked]>
Date: Fri, 11 Dec 1998 13:25:40 -0500 (EST)

>   ftp://ftp.psy.uq.oz.au/pub/Crypto/SSLapps/SSLftp-0.13.tar.gz

If someone wants to work on updating this, I have a CVS tree where you
could apply the patches against (beta-11) and merge the diffs up through
(beta-18) and VR11+.  Contact me privately.

-- 

Gregory A Lundberg		Senior Partner, VRnet Company
1441 Elmdale Drive              [email-masked]
Kettering, OH 45409-1615 USA    1-800-809-2195

---

From: Dan Stromberg <[email-masked]>
Date: Fri, 11 Dec 1998 10:30:03 -0800

>   ftp://ftp.psy.uq.oz.au/pub/Crypto/SSLapps/SSLftp-0.13.tar.gz

Gee, it sure would be nifty if these patches made it into the mainline as ifdef's.

...or one of the derived servers...

---

From: Gregory A Lundberg <[email-masked]>
Date: Fri, 11 Dec 1998 13:51:42 -0500 (EST)

> ...or one of the derived servers...

The work, including any support and/or download sites for it, would have
to be done outside the US/Canada.  If I did it, I would have to restrict
access to US/Canadian citizens accessing from sites verifiably within
those countries.  Other countries may have even bigger problems (for
instance, I understand it would be completely illegal in France no matter
how it was obtained).

Perhaps Bernard could do it.  But if he did it as #ifdef's in his main
tree, those of us offering downloads of his version inside the US/Canada
would have to either restrict downloads or stop offering it.

It will have to be a completely separate source tree from the main server
and variants if full, free access to all is to be maintained.  Those of us
doing work on the server can feed our (non-cryptographic) work to the
effort, and we can accept non-cryptographic patches and features from it,
but we cannot merge any direct support of strong crytographic methods
(such as SSL requires) into the general code base.

--