Re: [Pharo-dev] [PROVENANCE INTERNET] Re: FileSystem Permissions
Le 02/07/2013 15:49, Goubier Thierry a écrit :
Done:
SLICE-Issue-11102-FileSystemError-Path--root-ThierryGoubier.1
In http://ss3.gemstone.com/ss/PharoInbox
(It's for 2.0 at the moment. I'll try on 3.0 to port the same code).
Oh, it has a problem with utf8 :( Thierry
Thierry
Le 02/07/2013 15:24, Camillo Bruni a écrit :
On 2013-07-02, at 15:27, Goubier Thierry <thierry.goubier@cea.fr> wrote:
I think I have what is needed.
ACCESS(2) Linux Programmer's Manual ACCESS(2)
NAME access - check real user's permissions for a file
SYNOPSIS #include <unistd.h>
int access(const char *pathname, int mode);
that looks doable in NativeBoost :)
-- Thierry Goubier CEA list Laboratoire des Fondations des Systèmes Temps Réel Embarqués 91191 Gif sur Yvette Cedex France Phone/Fax: +33 (0) 1 69 08 32 92 / 83 95
On 2013-07-02, at 16:05, Goubier Thierry <thierry.goubier@cea.fr> wrote:
Le 02/07/2013 15:49, Goubier Thierry a écrit :
Done:
SLICE-Issue-11102-FileSystemError-Path--root-ThierryGoubier.1
In http://ss3.gemstone.com/ss/PharoInbox
(It's for 2.0 at the moment. I'll try on 3.0 to port the same code).
Oh, it has a problem with utf8 :(
and most probably it won't work under OSX. I think you have to implement these primitives on the different platform specific stores, that implies a separate version for win/mac/linux
On Tue, Jul 02, 2013 at 04:05:18PM +0200, Camillo Bruni wrote:
On 2013-07-02, at 16:05, Goubier Thierry <thierry.goubier@cea.fr> wrote:
Le 02/07/2013 15:49, Goubier Thierry a ?crit :
Done:
SLICE-Issue-11102-FileSystemError-Path--root-ThierryGoubier.1
In http://ss3.gemstone.com/ss/PharoInbox
(It's for 2.0 at the moment. I'll try on 3.0 to port the same code).
Oh, it has a problem with utf8 :(
and most probably it won't work under OSX.
I think you have to implement these primitives on the different platform specific stores, that implies a separate version for win/mac/linux
Both the concept and the implementation will be different on Windows, but for Unix and OS X you can use this for reference: UnixOSProcessPlugin>>primitiveFileStat "Call stat(2) to obtain the file protection mask for a file. Answer errno on failure, or on success answer an array with: UID with: GID with: protectionMask. The protectionMask is an Array of four integers representing the protection mask, or answer errno on failure. The protection mask is four Integers, each of which may be considered an octal digit (0-7), with bit values 4, 2, and 1. The first digit selects the set user ID (4) and set group ID (2) and save text image (1) attributes. The second digit selects permissions for the user who owns the file: read (4), write (2), and execute (1); the third selects permissions for other users in the file's group, with the same values; and the fourth for other users not in the file's group, with the same values." For example: OSProcess accessor fileStat: '/etc/hosts' Dave
Hi Lewis, we have already this in a way; Pharo provides the permissions as per stat in fact, but probably not the uid/guid of the file which would allow for a real check of the permissions. (that is, the current (wrong) situation is that isReadable returns ownerCanRead, which has a strong chance of being wrong for a directory owned by root, as you can guess) As you can see, I was wrong in asking for stat/fstat... But thanks for the info. Thierry Le 02/07/2013 16:32, David T. Lewis a écrit :
On Tue, Jul 02, 2013 at 04:05:18PM +0200, Camillo Bruni wrote:
On 2013-07-02, at 16:05, Goubier Thierry <thierry.goubier@cea.fr> wrote:
Le 02/07/2013 15:49, Goubier Thierry a ?crit :
Done:
SLICE-Issue-11102-FileSystemError-Path--root-ThierryGoubier.1
In http://ss3.gemstone.com/ss/PharoInbox
(It's for 2.0 at the moment. I'll try on 3.0 to port the same code).
Oh, it has a problem with utf8 :(
and most probably it won't work under OSX.
I think you have to implement these primitives on the different platform specific stores, that implies a separate version for win/mac/linux
Both the concept and the implementation will be different on Windows, but for Unix and OS X you can use this for reference:
UnixOSProcessPlugin>>primitiveFileStat "Call stat(2) to obtain the file protection mask for a file. Answer errno on failure, or on success answer an array with: UID with: GID with: protectionMask. The protectionMask is an Array of four integers representing the protection mask, or answer errno on failure. The protection mask is four Integers, each of which may be considered an octal digit (0-7), with bit values 4, 2, and 1. The first digit selects the set user ID (4) and set group ID (2) and save text image (1) attributes. The second digit selects permissions for the user who owns the file: read (4), write (2), and execute (1); the third selects permissions for other users in the file's group, with the same values; and the fourth for other users not in the file's group, with the same values."
For example:
OSProcess accessor fileStat: '/etc/hosts'
Dave
-- Thierry Goubier CEA list Laboratoire des Fondations des Systèmes Temps Réel Embarqués 91191 Gif sur Yvette Cedex France Phone/Fax: +33 (0) 1 69 08 32 92 / 83 95
Hi Thierry, You were right in asking for stat/fstat. The unix stat() call provides the uid and gid of the file, so those values are provided by primitiveFileStat. In order to determine if the file is e.g. readable, you need that information along with the file protection mask (also provided by primitiveFileStat), and of course you need to know the uid and gid of your VM process, see primitiveGetUid, primitiveGetGid, primitiveGetEUid and primitiveGetEGid in UnixOSProcessPlugin. There are also some unit tests that show how this works, for example: UnixProcessAccessorTestCase>>testIsReadableForUserInGroup I'm not sure if this helps with your original question, but maybe it will help as a reference. Dave On Tue, Jul 02, 2013 at 04:46:25PM +0200, Goubier Thierry wrote:
Hi Lewis,
we have already this in a way; Pharo provides the permissions as per stat in fact, but probably not the uid/guid of the file which would allow for a real check of the permissions.
(that is, the current (wrong) situation is that isReadable returns ownerCanRead, which has a strong chance of being wrong for a directory owned by root, as you can guess)
As you can see, I was wrong in asking for stat/fstat... But thanks for the info.
Thierry
Le 02/07/2013 16:32, David T. Lewis a ?crit :
On Tue, Jul 02, 2013 at 04:05:18PM +0200, Camillo Bruni wrote:
On 2013-07-02, at 16:05, Goubier Thierry <thierry.goubier@cea.fr> wrote:
Le 02/07/2013 15:49, Goubier Thierry a ?crit :
Done:
SLICE-Issue-11102-FileSystemError-Path--root-ThierryGoubier.1
In http://ss3.gemstone.com/ss/PharoInbox
(It's for 2.0 at the moment. I'll try on 3.0 to port the same code).
Oh, it has a problem with utf8 :(
and most probably it won't work under OSX.
I think you have to implement these primitives on the different platform specific stores, that implies a separate version for win/mac/linux
Both the concept and the implementation will be different on Windows, but for Unix and OS X you can use this for reference:
UnixOSProcessPlugin>>primitiveFileStat "Call stat(2) to obtain the file protection mask for a file. Answer errno on failure, or on success answer an array with: UID with: GID with: protectionMask. The protectionMask is an Array of four integers representing the protection mask, or answer errno on failure. The protection mask is four Integers, each of which may be considered an octal digit (0-7), with bit values 4, 2, and 1. The first digit selects the set user ID (4) and set group ID (2) and save text image (1) attributes. The second digit selects permissions for the user who owns the file: read (4), write (2), and execute (1); the third selects permissions for other users in the file's group, with the same values; and the fourth for other users not in the file's group, with the same values."
For example:
OSProcess accessor fileStat: '/etc/hosts'
Dave
-- Thierry Goubier CEA list Laboratoire des Fondations des Syst?mes Temps R?el Embarqu?s 91191 Gif sur Yvette Cedex France Phone/Fax: +33 (0) 1 69 08 32 92 / 83 95
Thanks Lewis, my bad. Everything needed is in there, even examples :) Cool. Now, there is still a problem with utf8 in path names, but I suspect it's inside FileReference. Thierry ________________________________________ De : Pharo-dev [pharo-dev-bounces@lists.pharo.org] de la part de David T. Lewis [lewis@mail.msen.com] Date d'envoi : mardi 2 juillet 2013 17:59 Ã : Pharo Development List Objet : Re: [Pharo-dev] [PROVENANCE INTERNET] Re: FileSystem Permissions Hi Thierry, You were right in asking for stat/fstat. The unix stat() call provides the uid and gid of the file, so those values are provided by primitiveFileStat. In order to determine if the file is e.g. readable, you need that information along with the file protection mask (also provided by primitiveFileStat), and of course you need to know the uid and gid of your VM process, see primitiveGetUid, primitiveGetGid, primitiveGetEUid and primitiveGetEGid in UnixOSProcessPlugin. There are also some unit tests that show how this works, for example: UnixProcessAccessorTestCase>>testIsReadableForUserInGroup I'm not sure if this helps with your original question, but maybe it will help as a reference. Dave On Tue, Jul 02, 2013 at 04:46:25PM +0200, Goubier Thierry wrote:
Hi Lewis,
we have already this in a way; Pharo provides the permissions as per stat in fact, but probably not the uid/guid of the file which would allow for a real check of the permissions.
(that is, the current (wrong) situation is that isReadable returns ownerCanRead, which has a strong chance of being wrong for a directory owned by root, as you can guess)
As you can see, I was wrong in asking for stat/fstat... But thanks for the info.
Thierry
Le 02/07/2013 16:32, David T. Lewis a ?crit :
On Tue, Jul 02, 2013 at 04:05:18PM +0200, Camillo Bruni wrote:
On 2013-07-02, at 16:05, Goubier Thierry <thierry.goubier@cea.fr> wrote:
Le 02/07/2013 15:49, Goubier Thierry a ?crit :
Done:
SLICE-Issue-11102-FileSystemError-Path--root-ThierryGoubier.1
In http://ss3.gemstone.com/ss/PharoInbox
(It's for 2.0 at the moment. I'll try on 3.0 to port the same code).
Oh, it has a problem with utf8 :(
and most probably it won't work under OSX.
I think you have to implement these primitives on the different platform specific stores, that implies a separate version for win/mac/linux
Both the concept and the implementation will be different on Windows, but for Unix and OS X you can use this for reference:
UnixOSProcessPlugin>>primitiveFileStat "Call stat(2) to obtain the file protection mask for a file. Answer errno on failure, or on success answer an array with: UID with: GID with: protectionMask. The protectionMask is an Array of four integers representing the protection mask, or answer errno on failure. The protection mask is four Integers, each of which may be considered an octal digit (0-7), with bit values 4, 2, and 1. The first digit selects the set user ID (4) and set group ID (2) and save text image (1) attributes. The second digit selects permissions for the user who owns the file: read (4), write (2), and execute (1); the third selects permissions for other users in the file's group, with the same values; and the fourth for other users not in the file's group, with the same values."
For example:
OSProcess accessor fileStat: '/etc/hosts'
Dave
-- Thierry Goubier CEA list Laboratoire des Fondations des Syst?mes Temps R?el Embarqu?s 91191 Gif sur Yvette Cedex France Phone/Fax: +33 (0) 1 69 08 32 92 / 83 95
On 02/07/13 17:41, GOUBIER Thierry wrote:
Thanks Lewis,
my bad. Everything needed is in there, even examples :) Cool. Now, there is still a problem with utf8 in path names, but I suspect it's inside FileReference.
File names as kind of tricky under linux because it is not defined in which encoding the filenames are. The name is just a sequence of bytes. The safe way is check for "system" encoding using nl_langinfo(CODESET) and encode/decode strings passed to and from OS to whatever internal representation is used to store strings. So far this works good on our systems. On Windows its lot easier as pathnames are always encoded in Unicode :-) Cheers, Jan
Thierry ________________________________________ De : Pharo-dev [pharo-dev-bounces@lists.pharo.org] de la part de David T. Lewis [lewis@mail.msen.com] Date d'envoi : mardi 2 juillet 2013 17:59 Ã : Pharo Development List Objet : Re: [Pharo-dev] [PROVENANCE INTERNET] Re: FileSystem Permissions
Hi Thierry,
You were right in asking for stat/fstat. The unix stat() call provides the uid and gid of the file, so those values are provided by primitiveFileStat. In order to determine if the file is e.g. readable, you need that information along with the file protection mask (also provided by primitiveFileStat), and of course you need to know the uid and gid of your VM process, see primitiveGetUid, primitiveGetGid, primitiveGetEUid and primitiveGetEGid in UnixOSProcessPlugin.
There are also some unit tests that show how this works, for example:
UnixProcessAccessorTestCase>>testIsReadableForUserInGroup
I'm not sure if this helps with your original question, but maybe it will help as a reference.
Dave
On Tue, Jul 02, 2013 at 04:46:25PM +0200, Goubier Thierry wrote:
Hi Lewis,
we have already this in a way; Pharo provides the permissions as per stat in fact, but probably not the uid/guid of the file which would allow for a real check of the permissions.
(that is, the current (wrong) situation is that isReadable returns ownerCanRead, which has a strong chance of being wrong for a directory owned by root, as you can guess)
As you can see, I was wrong in asking for stat/fstat... But thanks for the info.
Thierry
Le 02/07/2013 16:32, David T. Lewis a ?crit :
On Tue, Jul 02, 2013 at 04:05:18PM +0200, Camillo Bruni wrote:
On 2013-07-02, at 16:05, Goubier Thierry <thierry.goubier@cea.fr> wrote:
Le 02/07/2013 15:49, Goubier Thierry a ?crit :
Done:
SLICE-Issue-11102-FileSystemError-Path--root-ThierryGoubier.1
In http://ss3.gemstone.com/ss/PharoInbox
(It's for 2.0 at the moment. I'll try on 3.0 to port the same code).
Oh, it has a problem with utf8 :(
and most probably it won't work under OSX.
I think you have to implement these primitives on the different platform specific stores, that implies a separate version for win/mac/linux
Both the concept and the implementation will be different on Windows, but for Unix and OS X you can use this for reference:
UnixOSProcessPlugin>>primitiveFileStat "Call stat(2) to obtain the file protection mask for a file. Answer errno on failure, or on success answer an array with: UID with: GID with: protectionMask. The protectionMask is an Array of four integers representing the protection mask, or answer errno on failure. The protection mask is four Integers, each of which may be considered an octal digit (0-7), with bit values 4, 2, and 1. The first digit selects the set user ID (4) and set group ID (2) and save text image (1) attributes. The second digit selects permissions for the user who owns the file: read (4), write (2), and execute (1); the third selects permissions for other users in the file's group, with the same values; and the fourth for other users not in the file's group, with the same values."
For example:
OSProcess accessor fileStat: '/etc/hosts'
Dave
-- Thierry Goubier CEA list Laboratoire des Fondations des Syst?mes Temps R?el Embarqu?s 91191 Gif sur Yvette Cedex France Phone/Fax: +33 (0) 1 69 08 32 92 / 83 95
On 2013-07-02, at 18:41, GOUBIER Thierry <thierry.goubier@cea.fr> wrote:
Thanks Lewis,
my bad. Everything needed is in there, even examples :) Cool. Now, there is still a problem with utf8 in path names, but I suspect it's inside FileReference.
Thierry
participants (5)
-
Camillo Bruni -
David T. Lewis -
GOUBIER Thierry -
Goubier Thierry -
Jan Vrany