Re: POSIX file permissions
Re: POSIX file permissions
- Subject: Re: POSIX file permissions
- From: Axel Luttgens <email@hidden>
- Date: Thu, 10 Feb 2011 15:14:24 +0100
Le 9 févr. 2011 à 17:45, Hudson Barton a écrit :
> I have the following script:
>
> property fin : "/private/tmp/in.txt"
> property fout : "/private/tmp/out.txt"
> property finmac : POSIX file fin
> property foutmac : POSIX file out
>
> dostuff("blah blah blah", fin, fout, finmac, foutmac)
>
> on dostuff(sometext, fin, fout, finmac, foutmac)
> open for access finmac with write permission
> set eof finmac to 0
> write (sometext as string) to finmac
> close access finmac
> end dostuff
>
> The script runs fine on one user, but when I move it to any other user, it produces the error "Network file permission error." number -5000 from file "Macintosh HD:private:tmp:in.txt" at open for access finmac.
Hello Hudson,
Let's say user "jimmy" is the first one to run above script.
This will create file "in.txt" with following permissions:
-rw-r--r--@ 1 jimmy wheel 14 10 fév 14:26 /private/tmp/in.txt
It appears that the owner of the file is "jimmy"; this is quite logical, since Jimmy has created that file.
The group asigned to that file is "wheel"; that's a standard unix default behavior: the group is inherited from the directory where the item is created. And indeed, one has:
drwxrwxrwt 31 root wheel 1054 10 fév 14:26 /private/tmp
As a result, user "jimmy" may read from and write to file "in.txt" ("rw-"), members of group "wheel" may read from that file ("r--"), and all other users may read from that file as well ("r--"). Again, this is quite a usual default behavior in the unix world.
It is to be noted that Jimmy has an additional privilege upon file "in.txt": since directory "/private/tmp" is sticky, as indicated by letter "t" appearing at the end of the permissions, Jimmy is the only one to be able to remove that file from its enclosing directory.
> What's going on?
If you now ask user "joe" to run the script while file "in.txt" created by Jimmy still exists, there will be a problem: Joe belongs to "all other users" and thus doesn't have the required rights.
> I don't understand permissions on POSIX files, or more especially how to fix it.
The fix would depend on the workflow you are considering.
For example, do you need to have Jimmy, Joe and Sue to be able to write to the same file?
Axel
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden