Subject: ANNOUNCEMENT: alpha AFP/TCP support in netatalk

From: a sun <[email-masked]>
Date: Wed, 18 Jun 1997 19:34:07 -0700 (PDT)

i've placed my latest afp/tcp patches for netatalk-1.4b2 in
<ftp://ftp.u.washington.edu/public/asun>. you can either get
netatalk-2.0a7.tar.gz, or the patches up to it. i've compiled it on
linux/intel w/ glibc-2 and on linux/axp as well. i've also compiled a
previous snapshot under sunos 4.1.4. let me know if it works for you.

NB: the 2.0a7 designation is my own and not the official
maintainers. if and when my changes get incorporated into the official
netatalk, numbers are bound to change.

for those that already have the a6 patches, here's a brief list of
changes:
	fixed asp_attentions and server messages
	afpd can run as a ddp-only or tcp-only server if desired.
	limits volume changed attentions to at most 1/second.

for those that aren't familiar w/ my netatalk patches, here's a
synopsis of what they do:
	afp 2.2 support includes
		afp/tcp w/ streaming reads/writes
		server messages and notifications
		server signatures
		large volume support (currently not used by the
				      macintosh filesystem)
	64-bit clean
	random fixes (socket setup, network-byte order blips, and
		      other things i can't recall)

my main test machine is somewhat flaky right now due to my running the
latest, greatest linux development kernel. as a consequence, i haven't
been able to do a good benchmark yet. w/ not-so-flaky kernels, i got
between a 1.5-2x speedup. 

-a

---

From: 藤原__誠/ Makoto Fujiwara <[email-masked]>
Date: Thu, 19 Jun 1997 14:23:36 +0900

In the old days, I have submitted the bug information as attached.
onto Web Page.
  Did anybody encountered such problem ?
---
Makoto Fujiwara,  in Japanese ->(藤原)

Subject: gid(group id) is not honored when creating file.
From: Makoto Fujiwara/ 藤原 誠 <[email-masked]>
To: [email-masked]
Date: Thu, 12 Dec 1996 19:31:30 +0900

Subject: gid(group id) is not honored when creating file.

Short summary of the problem (please make this
meaningful!) 

Environment: 
-----------
netatalk-1.4b2
SunOS 5.5.1 ( Solaris 2.5.1 )
no change on config file excetp missing 
#define MAXHOSTNAMELEN  32
definition

Description: 
-----------

From: Makoto Fujiwara<[email-masked]>
Newsgroups: comp.protocols.appletalk
Subject: [netatalk/CAP60] group of the file/folders
Date: 10 Dec 1996 23:47:58 +0900
Organization: Packet Radio Users Group
Lines: 50
Message-ID: <[email-masked]>
NNTP-Posting-Host: komekome.bay.prug.or.jp
Mime-Version: 1.0 (generated by tm-edit 7.90)
Content-Type: text/plain; charset=US-ASCII
X-Newsreader: Red Gnus v0.52/Emacs 19.31

I have a question on the spec of AppleTalk File Server on Unix.
When I say AppleTalk File Server, I mean 
netatalk-1.4b2 or CAP 60.

(1) Macintosh file system has no attribute file by file.
    It only has folder(directory) attribute.

(2) The access permission of the file is, therefore, decided by 
    the attribute of the directory where the file is in.

(3) There are following  possibilities.

(3-1) Say, my primary group id (gid) of logon ( = passwd file ) 
      is PRIMARY.

(3-2) I also belongs to the group SECONDARY by the definition of
      group file.

(3-3) When I create the folder A, it belongs to PRIMARY of course.

(3-4) I decided to create foler B in folder A, and change the group 
      of folder B to SECONARY
      ( on Macintosh, FILE -> Sharing Menu )

Now I have following folder hierarchies.

                    owner     group
      -----------   --------  ---------
      Folder A      fujiwara  PRIMARY
         Folder B   fujiwara  SECONDARY

    My intention of changing Folder B to the SECONARY group is
    by giving write permission to the folder B and let 
    SECONDARY group to write any folers/files in Folder B.

(3-5) If I  create some stuff in Folder B, what should group be 
     for that file ? Or anybody who belongs to the SECONDARY 
     can do that  if the group/write is allowed.

                    owner     group
      -----------   --------  ---------
      Folder A      fujiwara  PRIMARY
         Folder B   fujiwara  SECONDARY
             file   fujiwara  group-in-question

>From the users point of view, I believe, group-in-question should
be SECONDARY.

If above assumption is right, is AppleTalk File Server software
implemented as to give the right group of file ?

Repeat-By: 

The sequence of events that causes the problem to occur. 

Fix: 
---

Description of how to fix the problem. If you don't know a
fix for the problem, don't include this section. 

diff -uar ../netatalk-1.4b2-ref/etc/afpd/file.c ./etc/afpd/file.c
--- ../netatalk-1.4b2-ref/etc/afpd/file.c	Sat Oct 19 05:33:04 1996
+++ ./etc/afpd/file.c	Thu Dec 12 17:30:53 1996
@@ -263,7 +263,6 @@
 	    return( AFPERR_PARAM );
 	}
     }
-
     ad_setentrylen( &ad, ADEID_NAME, strlen( path ));
     bcopy( path, ad_entry( &ad, ADEID_NAME ),
 	    ad_getentrylen( &ad, ADEID_NAME ));
@@ -280,6 +279,8 @@
 
     ad_flush( &ad, ADFLAGS_DF|ADFLAGS_HF );
     ad_close( &ad, ADFLAGS_DF|ADFLAGS_HF );
+    ad_chown( mtoupath( path ), 0777 );
+    ad_chown( ad_path( mtoupath( path ), ADFLAGS_HF ), 0777 );
     setvoltime( vol );
     return( AFP_OK );
 }
@@ -346,6 +347,7 @@
 	return( AFPERR_ACCESS );
     }
 
+    ad_chown( mtoupath( path), 0777);
     if ( ad_getoflags( &ad, ADFLAGS_HF ) & O_CREAT ) {
 	ad_setentrylen( &ad, ADEID_NAME, strlen( path ));
 	bcopy( path, ad_entry( &ad, ADEID_NAME ),
@@ -495,6 +497,10 @@
     ad_flush( &ad, ADFLAGS_HF );
     ad_close( &ad, ADFLAGS_HF );
 
+    /*    ad_chown( mtoupath( newname, 0777 )) ; /* */
+    ad_chown ( dst, 0777 );
+    ad_chown( ad_path (mtoupath(newname, 0777), ADFLAGS_HF), 0777 ) ;
+
     return( AFP_OK );
 }
 
@@ -653,6 +659,8 @@
 	}
     }
     len = strlen( newname );
+    ad_chown( mtoupath( dst, 0777 )) ;
+    ad_chown( ad_path (mtoupath(dst, 0777), ADFLAGS_HF), 0777 ) ;
     ad_setentrylen( &ad, ADEID_NAME, len );
     bcopy( newname, ad_entry( &ad, ADEID_NAME ), len );
     ad_flush( &ad, ADFLAGS_HF );
diff -uar ../netatalk-1.4b2-ref/etc/afpd/filedir.c ./etc/afpd/filedir.c
--- ../netatalk-1.4b2-ref/etc/afpd/filedir.c	Mon Sep 23 03:06:34 1996
+++ ./etc/afpd/filedir.c	Thu Dec 12 15:32:13 1996
@@ -245,6 +245,7 @@
 	if ( ad_open( newpath, ADFLAGS_HF, O_RDWR|O_CREAT, 0666, &ad ) < 0 ) {
 	    return( AFPERR_PARAM );
 	}
+	/* ad_chown ( newpath, 0777 ); */
     } else {
 	if ( ad_open( newpath, ADFLAGS_HF|ADFLAGS_DIR, O_RDWR|O_CREAT,
 		0666, &ad ) < 0 ) {
diff -uar ../netatalk-1.4b2-ref/include/netatalk/at.h ./include/netatalk/at.h
--- ../netatalk-1.4b2-ref/include/netatalk/at.h	Mon Sep 23 06:16:26 1996
+++ ./include/netatalk/at.h	Thu Dec 12 14:44:39 1996
@@ -20,7 +20,7 @@
  *	+1-313-763-0525
  *	[email-masked]
  */
-
+#define MAXHOSTNAMELEN 32
 #ifndef __AT_HEADER__
 #define __AT_HEADER__
 /*
diff -uar ../netatalk-1.4b2-ref/libatalk/adouble/ad_open.c ./libatalk/adouble/ad_open.c
--- ../netatalk-1.4b2-ref/libatalk/adouble/ad_open.c	Wed Sep 25 00:26:52 1996
+++ ./libatalk/adouble/ad_open.c	Thu Dec 12 17:47:39 1996
@@ -116,6 +116,45 @@
 
     return( mode & stbuf.st_mode );
 }
+int
+ad_chown( path, mode )
+    char		*path;
+    int			mode;
+{
+    static char		modebuf[ MAXPATHLEN ];
+    struct stat		stbuf;
+    char 		*slash;
+
+    if ( mode == 0 ) {
+	return( mode );		/* save on syscalls */
+    }
+
+    if ( strlen( path ) >= MAXPATHLEN ) {
+	return( mode & DEFMASK );  /* can't do it */
+    }
+
+    /*
+     * For a path with directories in it, remove the final component
+     * (path or subdirectory name) to get the name we want to stat.
+     * For a path which is just a filename, use "." instead.
+     */
+    strcpy( modebuf, path );
+    if (( slash = rindex( modebuf, '/' )) != NULL ) {
+	*slash = '\0';		/* remove pathname component */
+    } else {
+	modebuf[0] = '.';	/* use current directory */
+	modebuf[1] = '\0';
+    }
+
+    if ( stat( modebuf, &stbuf ) != 0 ) {
+	return (0);
+    }
+    if ( chown( path, -1 , stbuf.st_gid ) ) { 
+       printf("problem on chown path(%s), gid(%d)\n", path, stbuf.st_gid);
+    }
+    return 1 ;
+    /*     return( mode & stbuf.st_mode ); */
+}
 
 /*
  * Use mkdir() with mode bits taken from ad_mode().

Makoto Fujiwara
---
  Thu Dec 12 19:25:43 1996
  市場開発/CACTG本部・設計技術部・電脳管理課
  藤原  誠              621-8338
  [email-masked]
  <URL: http://papageno.sps.mot.com/~fujiwara>