Subject: Re: 1.3b2 & file permissions

From: Patrick Goebel <[email-masked]>
Date: Thu, 11 Nov 93 18:05:29 -0800

> From:    Patrick Goebel <[email-masked]>
> To:      [email-masked]
>
> ...However, subfolders do not automatically get GID set so that
> files created under subfolders revert back to the user's primary
> group.

> From: [email-masked]
> To: [email-masked]
>
> One solution is to mount your filesystem with the option "grpid".  This
> will cause all directories to always have the setgid bit set.

In the words of Ren (from the Ren & Stimpy show), "That's brilliant
man!"  Thanks Wes.  Works like a charm.

That solves the GID problem.  Now I've run into a different
permissions hurdle.  Let's say you have two folders, X and Y, on a
mounted afp volume.  Folder X belongs to user A and folder Y belongs
to user B.  A and B belong to the same UNIX group G. On the UNIX side,
both folders have permissions 750 and group ownership G so that A and
B can read (and copy) files from each other's folders, but can only
write to their own folder.  This is to prevent user A from overwriting
files in B's folder and vice versa, while still allowing them to share
copies of files.

If A or B creates a file in his or her own folder, the file gets
permissions 640 which is exactly what you want given the above
scenario.  However, if A copies a file from B's folder Y into her own
folder X, the resulting permissions on the copied file are 666.  This
means that B can then turn around and make changes to A's copy of the
file, thereby violating the desired protection.

Since netatalk's afp is apparently set up to create file permissions
that mimmick those of the parent folder/directory, this behavior seems
somewhat puzzling.  Once again, any suggestions for a fix would be
most appreciated.

Cheers,
--
Patrick Goebel                    E-MAIL: [email-masked]
Network Administrator             VOICE:  (415) 321-2052
CASBS, 202 Junipero Serra Blvd.   FAX:    (415) 321-1192
Stanford, CA 94305                BEEPER: Temporarily Out of Order...

---

From: [email-masked]
Date: Thu, 18 Nov 1993 15:02:35 -0500

> From:    Patrick Goebel <[email-masked]>
> To:      [email-masked]

> However, if A copies a file from B's folder Y into her own

Nice bug report.  Here's a patch which should fix the problem:

--- cut ---
*** netatalk-1.3b2/etc/afpd/file.c-	Sat Aug  7 15:28:16 1993
--- netatalk-1.3b2/etc/afpd/file.c	Thu Nov 18 14:40:35 1993
***************
*** 573,579 ****
  	    return( AFPERR_PARAM );
  	}
      } else {
! 	if (( dfd = open( ad_path( dst, 0 ), O_WRONLY|O_CREAT, 0666 )) < 0 ) {
  	    close( sfd );
  	    switch ( errno ) {
  	    case ENOENT :
--- 561,568 ----
  	    return( AFPERR_PARAM );
  	}
      } else {
! 	if (( dfd = open( ad_path( dst, 0 ), O_WRONLY|O_CREAT,
! 		ad_mode( ad_path( dst, 0 ), 0666 ))) < 0 ) {
  	    close( sfd );
  	    switch ( errno ) {
  	    case ENOENT :
***************
*** 606,612 ****
  	    return( AFPERR_PARAM );
  	}
      }
!     if (( dfd = open( dst, O_WRONLY|O_CREAT, 0666 )) < 0 ) {
  	close( sfd );
  	switch ( errno ) {
  	case ENOENT :
--- 595,601 ----
  	    return( AFPERR_PARAM );
  	}
      }
!     if (( dfd = open( dst, O_WRONLY|O_CREAT, ad_mode( dst, 0666 ))) < 0 ) {
  	close( sfd );
  	switch ( errno ) {
  	case ENOENT :
--- cut ---