Subject: netatalk bugfix: this can't be right
To: NetBSD Help <netbsd-help@netbsd.org>
From: B. James Phillippe <bryanxms@ecst.csuchico.edu>
List: netbsd-help
Date: 01/12/2002 20:04:02
Hello,

I am a relatively new NetBSD user, running 1.5.2 on an Alpha.  I'm using
the system as a fileserver, and would like to be able to share volumes to
an Apple iMac using Appletalk.  I installed netatalk in October of last
year, and had problems getting it to work.  I posted to netbsd-help and was
not able to find anyone else with my problem, nor was I able to find a
solution.  The problem was that any time I tried to create a directory on
the server from the client (or copy a directory), I would get an error on
the Mac console about insufficient permission, and the following entry in
my server syslog:

Jan 12 18:28:05 jupiter afpd[10741]: setdirmode: chmod .AppleDouble: Operation not permitted

Even though this error was reported on both the client and server, an empty
directory would be created anyway.  If I was copying a folder, the folder
would be created but without any files.  I could then copy files into the
folder without a problem.

I gave up for a few months, and came back to this problem today.
Determined to find the cause (and solution), I downloaded the source code
and quickly identified the trouble spot.  This diff illustrates where the
problem happens and what works around it:

--- etc/afpd/unix.c.orig	Sat Jan 12 19:43:00 2002
+++ etc/afpd/unix.c	Sat Jan 12 19:43:21 2002
@@ -588,17 +588,21 @@
     /* XXX: use special bits to tag directory permissions */

     /* XXX: need to preserve special modes */
+#if 0
     if ( chmod( ".AppleDouble",  DIRBITS | mode ) < 0 ) {
 	syslog( LOG_ERR, "setdirmode: chmod .AppleDouble: %m" );
 	return( -1 );
     }
+#endif

 setdirmode_noadouble:
     /* XXX: need to preserve special modes */
+#if 0
     if ( chmod( ".",  DIRBITS | mode ) < 0 ) {
 	syslog( LOG_ERR, "setdirmode: chmod .: %m" );
 	return( -1 );
     }
+#endif
     return( 0 );
 }


The chmod() call in both those places is failing with "Operation not
permitted", and I can't figure out why (the permissions are fine).  #if'ing
out these routines solves the problem and seems to have no ill side-effects
(I copied Gigs of data with this change w/out trouble).  My question now
is, "why was this only happening to me", and "what is the proper solution"?

This is netatalk-asun-2.1.3nb4, and I am in securelevel 1 multiuser.  The
Mac client is connecting as guest.

thanks,
-bp
--
# bryanxms at ecst dot csuchico dot edu
# Software Engineer