Subject: Re: Problem compiling

From: [email-masked]
Date: Fri, 23 Aug 1996 22:37:22 EST

** Reply to note from [email-masked] Fri, 23 Aug 1996 13:09:53 -0500 (CDT) 
>    
> Michael-John Turner wrote: 
>    
> (hmm...someone else wrote:) 
> > > I recently started to use wu-ftpd 2.4 fixed version.... I really need it 
> > > to support shadow passwords for our newest server etc... 
> > > When compiling I get the following error: 
> > > glob.c: in function 'matchdir': 
> > > glob.c: 240: dereferencing pointer to incomplete type 
> > > make: *** [glob.c] error 1 
>    
> > I've noticed this problem on 3 machines using gcc 2.7.2 under Linux. 
> > wu ftpd compiles fine under gcc 2.7.0, so perhaps you should try that. 
>    
> The announcement for gcc-2.7.2.1 said it fixed problems under Linux. Try 
> that, too. 
>    
> --  
> Chadwick A. Dubuque              [email-masked] 
> http://www.acm.ndsu.NoDak.edu/~cdubuque/     finger for PGP pub. key 
> "If a tree falls in the forest . . . and we've already sold the 
> tree . . . does it have quality?" -The Pointy Haired Boss, "Dilbert" 
>    
>    
>    
> Michael-John Turner wrote: 
>    
> (hmm...someone else wrote:) 
> > > I recently started to use wu-ftpd 2.4 fixed version.... I really need it 
> > > to support shadow passwords for our newest server etc... 
> > > When compiling I get the following error: 
> > > glob.c: in function 'matchdir': 
> > > glob.c: 240: dereferencing pointer to incomplete type 
> > > make: *** [glob.c] error 1 
>    
 
In your CFLAGS, add "-DDIRENT_ILLEGAL_ACCESS". 
 
This is a result of a change in the "dirent.h" include file under 
the newer linux Kernels. I've been compiling wu-ftpd fine ever since I've 
discovered this. 

========================================================================= 
= Clifton Wood       | "Tis better to worry for nothing than to not worry   
- Software Engineer  |  and meet Mr. Murphy when you are the least  
- TeleWorks, Inc.    |  unprepared for him." - Overheard at a bar.

---

From: Marek Michalkiewicz <[email-masked]>
Date: Tue, 27 Aug 1996 16:28:00 +0200 (MET DST)

> > > > to support shadow passwords for our newest server etc... 

Try a newer beta release - it has lots of bug fixes compared to old 2.4.
ftp://ftp.academ.com/pub/wu-ftpd/private/wu-ftpd-2.4.2-beta-11.tar.Z

> In your CFLAGS, add "-DDIRENT_ILLEGAL_ACCESS". 

Better yet, apply the patch below (it's for 2.4.2beta11 - cc'ing to the
maintainer, please consider including this patch in the next release).
The use of DIRENT_ILLEGAL_ACCESS is discouraged - the comment in dirent.h
above the definition of struct DIR says:
/* Use it at your own risk. */

Perhaps the code could be changed to avoid this magic completely -
this glob.c is from 1980 (!), a newer one (from bsd-ftpd-6.00) doesn't
use this.  Can't we just stat() the directory name in question instead
of the current opendir+fstat hack?  Besides, opendir should fail on
non-directories anyway; perhaps it didn't in 1980 :-).

> the newer linux Kernels. I've been compiling wu-ftpd fine ever since I've 

Actually, I think it's a change in newer versions of (ELF) libc.

The patch also enables support for shadow passwords on ELF systems
(getspnam() is standard in libc 5.x, both shadow and non-shadow
passwords will work).  Better to do it here than to tell maintainers
of every Linux distribution to do it...

Regards,

Marek

diff -urN wu-ftpd-2.4.2-beta-11.orig/src/config/config.lnx wu-ftpd-2.4.2-beta-11/src/config/config.lnx
--- wu-ftpd-2.4.2-beta-11.orig/src/config/config.lnx	Mon Apr 15 07:51:40 1996
+++ wu-ftpd-2.4.2-beta-11/src/config/config.lnx	Sun Aug 25 17:40:44 1996
@@ -30,6 +30,11 @@
 #define USE_VAR
 #define VIRTUAL
 
+#ifdef __ELF__
+#define SHADOW_PASSWORD
+#define HAVE_DIRFD
+#endif
+
 #include <bsd/bsd.h>
 #include <stdlib.h>		/* here instead of in all the srcs.  _H*/
 #include <unistd.h>
diff -urN wu-ftpd-2.4.2-beta-11.orig/src/ftpd.c wu-ftpd-2.4.2-beta-11/src/ftpd.c
--- wu-ftpd-2.4.2-beta-11.orig/src/ftpd.c	Mon Apr 15 07:51:11 1996
+++ wu-ftpd-2.4.2-beta-11/src/ftpd.c	Tue Aug 27 16:04:28 1996
@@ -3275,15 +3275,14 @@
 #ifndef HAVE_DIRENT    /* does not have d_namlen */
             if (dir->d_name[0] == '.' && dir->d_namlen == 1)
 #else
-            if (dir->d_name[0] == '.' && (strlen(dir->d_name) == 1))
+            if (strcmp(dir->d_name, ".") == 0)
 #endif
                 continue;
 #ifndef HAVE_DIRENT    /* does not have d_namlen */
             if (dir->d_namlen == 2 && dir->d_name[0] == '.' &&
                 dir->d_name[1] == '.')
 #else
-            if ((strlen(dir->d_name) == 2) && dir->d_name[0] == '.' &&
-                dir->d_name[1] == '.')
+            if (strcmp(dir->d_name, "..") == 0)
 #endif
                 continue;
 
diff -urN wu-ftpd-2.4.2-beta-11.orig/src/glob.c wu-ftpd-2.4.2-beta-11/src/glob.c
--- wu-ftpd-2.4.2-beta-11.orig/src/glob.c	Mon Apr 15 07:51:11 1996
+++ wu-ftpd-2.4.2-beta-11/src/glob.c	Sun Aug 25 17:44:04 1996
@@ -257,6 +257,12 @@
 	*gpathp = 0;
 }
 
+/* Linux libc 5.x: internals of "struct DIR" are hidden unless
+   DIRENT_ILLEGAL_ACCESS is defined.  Use dirfd() instead.  */
+#ifndef HAVE_DIRFD
+#define dirfd(dirp) (dirp)->dd_fd
+#endif
+
 static void
 #ifdef __STDC__
 matchdir(char *pattern)
@@ -281,7 +287,7 @@
 			return;
 		goto patherr2;
 	}
-	if (fstat(dirp->dd_fd, &stb) < 0)
+	if (fstat(dirfd(dirp), &stb) < 0)
 		goto patherr1;
 	if (!isdir(stb)) {
 		errno = ENOTDIR;