Subject: gid(group id) is not honored when creating file.
From: B__$B@? ($BF#86(B__$B@?()
Date: Thu Jun 19 1997 - 01:23:36 EDT
In the old days, I have submitted the bug information as attached.
onto Web Page.
Did anybody encountered such problem ?
--- Makoto Fujiwara, in Japanese ->($BF#86(B)
attached mail follows:
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<makoto@komekome.bay.prug.or.jp> 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: <yfmpw0ie9r5.fsf@komekome.bay.prug.or.jp> 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 * netatalk@itd.umich.edu */ - +#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 $B;T>l3+H/(B/CACTG$BK\It!&@_7W5;=QIt!&EEG>4IM}2](B $BF#86(B $B@?(B 621-8338 fujiwara@papageno.sps.mot.com <URL: http://papageno.sps.mot.com/~fujiwara>
This archive was generated by hypermail 2b28 : Sat Dec 18 1999 - 16:25:01 EST