accessing file permissions within the image

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

accessing file permissions within the image

Chris Muller-4
Is it possible to determine the Linux file permissions of a file or
directory from within the image running on Linux?

Reply | Threaded
Open this post in threaded view
|

Re: accessing file permissions within the image

Levente Uzonyi-2
IIRC the Pharo guys have added that feature to their version of
FilePlugin.

Levente

On Wed, 8 Jul 2015, Chris Muller wrote:

> Is it possible to determine the Linux file permissions of a file or
> directory from within the image running on Linux?
>
>

Reply | Threaded
Open this post in threaded view
|

Re: accessing file permissions within the image

David T. Lewis
On Wed, Jul 08, 2015 at 11:43:50PM +0200, Levente Uzonyi wrote:

>
> On Wed, 8 Jul 2015, Chris Muller wrote:
> >
> >Is it possible to determine the Linux file permissions of a file or
> >directory from within the image running on Linux?
> >
>
> IIRC the Pharo guys have added that feature to their version of
> FilePlugin.
>

OSProcess accessor fileStat: '/etc/hosts' ==> #(0 0 #(0 6 4 4))

The primitive is in UnixOSProcessPlugin, and is accessed like this:

UnixOSProcessAccessor>>primFileStat: aPathString
        "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."

        <primitive: 'primitiveFileStat' module: 'UnixOSProcessPlugin'>
        ^ nil

Dave


Reply | Threaded
Open this post in threaded view
|

Re: accessing file permissions within the image

Chris Muller-3
Dave, I would like to say, OSProcess is one fine package!  I keep
getting surprised at the cool things (like RemoteTask) in there.  It
seems to have become a permanent part of my images.

On Wed, Jul 8, 2015 at 9:37 PM, David T. Lewis <[hidden email]> wrote:

> On Wed, Jul 08, 2015 at 11:43:50PM +0200, Levente Uzonyi wrote:
>>
>> On Wed, 8 Jul 2015, Chris Muller wrote:
>> >
>> >Is it possible to determine the Linux file permissions of a file or
>> >directory from within the image running on Linux?
>> >
>>
>> IIRC the Pharo guys have added that feature to their version of
>> FilePlugin.
>>
>
> OSProcess accessor fileStat: '/etc/hosts' ==> #(0 0 #(0 6 4 4))
>
> The primitive is in UnixOSProcessPlugin, and is accessed like this:
>
> UnixOSProcessAccessor>>primFileStat: aPathString
>         "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."
>
>         <primitive: 'primitiveFileStat' module: 'UnixOSProcessPlugin'>
>         ^ nil
>
> Dave
>
>