Re: [grass-addons] r343 - trunk/grassaddons/gui

5 messages Options
Embed this post
Permalink
Michael Barton

Re: [grass-addons] r343 - trunk/grassaddons/gui

Reply Threaded More More options
Print post
Permalink
I just tried this. Seemed like a good idea but didn't work. I got an error
saying that I didn't have the right permissions to use the mapset.

Maybe Daniel understands how os.chmod works

Michael


On 3/27/07 9:00 AM, "Jachym Cepicky" <[hidden email]> wrote:

> hi,
>
> 2007/3/27, [hidden email] <[hidden email]>:
>
>> Modified:
>>    trunk/grassaddons/gui/gis_set.py
>> Log:
>> Fixed bug with new mapset not copying WIND file from PERMANENT.
>>
>> ****Please check to see if permissions need to be set (I just copied
>> the WIND file permissions). Line 674 has a chmod statement, but I don't
>> know what to set it to (needs set of numbers for u+rw,go+r I think).
>>
>>
>
> 644  should mean: "u+rw, go+r"
>
> hope, it helps
>
> j
>
>

__________________________________________
Michael Barton, Professor of Anthropology
School of Human Evolution & Social Change
Center for Social Dynamics & Complexity
Arizona State University

phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton


_______________________________________________
grassgui mailing list
[hidden email]
http://grass.itc.it/mailman/listinfo/grassgui
Glynn Clements

Re: Re: [grass-addons] r343 - trunk/grassaddons/gui

Reply Threaded More More options
Print post
Permalink

Michael Barton wrote:

> > > Modified:
> > >    trunk/grassaddons/gui/gis_set.py
> > > Log:
> > > Fixed bug with new mapset not copying WIND file from PERMANENT.
> > >
> > > ****Please check to see if permissions need to be set (I just copied
> > > the WIND file permissions). Line 674 has a chmod statement, but I don't
> > > know what to set it to (needs set of numbers for u+rw,go+r I think).
> >
> > 644  should mean: "u+rw, go+r"
> >
> > hope, it helps
>
> I just tried this. Seemed like a good idea but didn't work. I got an error
> saying that I didn't have the right permissions to use the mapset.
>
> Maybe Daniel understands how os.chmod works

The documentation at:

        http://docs.python.org/lib/os-file-dir.html

says:

        chmod(path, mode)
       
            Change the mode of path to the numeric mode. mode may take one of
            the following values (as defined in the stat module) or bitwise
            or-ed combinations of them:
       
                * S_ISUID
                * S_ISGID
                * S_ENFMT
                * S_ISVTX
                * S_IREAD
                * S_IWRITE
                * S_IEXEC
                * S_IRWXU
                * S_IRUSR
                * S_IWUSR
                * S_IXUSR
                * S_IRWXG
                * S_IRGRP
                * S_IWGRP
                * S_IXGRP
                * S_IRWXO
                * S_IROTH
                * S_IWOTH
                * S_IXOTH

The stat.py file gives these constants their usual numeric values. If
you want to use a numeric value in the os.chmod() call, you will need
to specify it in octal (with a leading zero), e.g.:

            os.chmod(os.path.join(database,location,mapset,'WIND'), 0644)

Note: 644 (decimal) = 01204 (octal) = t-w----r-- (u=w,g=,o=r,t), which
isn't much use (the owner can't read it).

--
Glynn Clements <[hidden email]>

_______________________________________________
grassgui mailing list
[hidden email]
http://grass.itc.it/mailman/listinfo/grassgui
Michael Barton

Re: Re: [grass-addons] r343 - trunk/grassaddons/gui

Reply Threaded More More options
Print post
Permalink
Aha! A further clarification. Is octal base 8? (Pardon my novicity, but I
don't use this much).

Michael


On 3/27/07 1:34 PM, "Glynn Clements" <[hidden email]> wrote:

>
> Michael Barton wrote:
>
>>>> Modified:
>>>>    trunk/grassaddons/gui/gis_set.py
>>>> Log:
>>>> Fixed bug with new mapset not copying WIND file from PERMANENT.
>>>>
>>>> ****Please check to see if permissions need to be set (I just copied
>>>> the WIND file permissions). Line 674 has a chmod statement, but I don't
>>>> know what to set it to (needs set of numbers for u+rw,go+r I think).
>>>
>>> 644  should mean: "u+rw, go+r"
>>>
>>> hope, it helps
>>
>> I just tried this. Seemed like a good idea but didn't work. I got an error
>> saying that I didn't have the right permissions to use the mapset.
>>
>> Maybe Daniel understands how os.chmod works
>
> The documentation at:
>
> http://docs.python.org/lib/os-file-dir.html
>
> says:
>
> chmod(path, mode)
>
>    Change the mode of path to the numeric mode. mode may take one of
>    the following values (as defined in the stat module) or bitwise
>    or-ed combinations of them:
>
>        * S_ISUID
>        * S_ISGID
>        * S_ENFMT
>        * S_ISVTX
>        * S_IREAD
>        * S_IWRITE
>        * S_IEXEC
>        * S_IRWXU
>        * S_IRUSR
>        * S_IWUSR
>        * S_IXUSR
>        * S_IRWXG
>        * S_IRGRP
>        * S_IWGRP
>        * S_IXGRP
>        * S_IRWXO
>        * S_IROTH
>        * S_IWOTH
>        * S_IXOTH
>
> The stat.py file gives these constants their usual numeric values. If
> you want to use a numeric value in the os.chmod() call, you will need
> to specify it in octal (with a leading zero), e.g.:
>
>             os.chmod(os.path.join(database,location,mapset,'WIND'), 0644)
>
> Note: 644 (decimal) = 01204 (octal) = t-w----r-- (u=w,g=,o=r,t), which
> isn't much use (the owner can't read it).

__________________________________________
Michael Barton, Professor of Anthropology
School of Human Evolution & Social Change
Center for Social Dynamics and Complexity
Arizona State University

phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton 

_______________________________________________
grassgui mailing list
[hidden email]
http://grass.itc.it/mailman/listinfo/grassgui
Daniel Calvelo

Re: Re: [grass-addons] r343 - trunk/grassaddons/gui

Reply Threaded More More options
Print post
Permalink
On 3/27/07, Michael Barton <[hidden email]> wrote:
> Aha! A further clarification. Is octal base 8? (Pardon my novicity, but I
> don't use this much).

Yes, it's actually quite intuitive once you get the gist (and see bits
where appropriate):

0644 is:

0 : this is octal, i.e. base 8
6 : this is the octal value for user (owner) permissions as bits rwx,
6 = 4+2 so we have rw-
  1 for r
  1 for w
  0 for x
4 : octal value for group permissions : r--
  1 for r
  0 for w
  0 for x
4 : octal value for other (i.e. public) permissions, r-- as before

The unixy representation of this is rw-r--r-- ; the chmod "more human"
command would be chmod u+rw-x g+r-wx o+r-wx

Daniel.


>
> Michael
>
>
> On 3/27/07 1:34 PM, "Glynn Clements" <[hidden email]> wrote:
>
> >
> > Michael Barton wrote:
> >
> >>>> Modified:
> >>>>    trunk/grassaddons/gui/gis_set.py
> >>>> Log:
> >>>> Fixed bug with new mapset not copying WIND file from PERMANENT.
> >>>>
> >>>> ****Please check to see if permissions need to be set (I just copied
> >>>> the WIND file permissions). Line 674 has a chmod statement, but I don't
> >>>> know what to set it to (needs set of numbers for u+rw,go+r I think).
> >>>
> >>> 644  should mean: "u+rw, go+r"
> >>>
> >>> hope, it helps
> >>
> >> I just tried this. Seemed like a good idea but didn't work. I got an error
> >> saying that I didn't have the right permissions to use the mapset.
> >>
> >> Maybe Daniel understands how os.chmod works
> >
> > The documentation at:
> >
> > http://docs.python.org/lib/os-file-dir.html
> >
> > says:
> >
> > chmod(path, mode)
> >
> >    Change the mode of path to the numeric mode. mode may take one of
> >    the following values (as defined in the stat module) or bitwise
> >    or-ed combinations of them:
> >
> >        * S_ISUID
> >        * S_ISGID
> >        * S_ENFMT
> >        * S_ISVTX
> >        * S_IREAD
> >        * S_IWRITE
> >        * S_IEXEC
> >        * S_IRWXU
> >        * S_IRUSR
> >        * S_IWUSR
> >        * S_IXUSR
> >        * S_IRWXG
> >        * S_IRGRP
> >        * S_IWGRP
> >        * S_IXGRP
> >        * S_IRWXO
> >        * S_IROTH
> >        * S_IWOTH
> >        * S_IXOTH
> >
> > The stat.py file gives these constants their usual numeric values. If
> > you want to use a numeric value in the os.chmod() call, you will need
> > to specify it in octal (with a leading zero), e.g.:
> >
> >             os.chmod(os.path.join(database,location,mapset,'WIND'), 0644)
> >
> > Note: 644 (decimal) = 01204 (octal) = t-w----r-- (u=w,g=,o=r,t), which
> > isn't much use (the owner can't read it).
>
> __________________________________________
> Michael Barton, Professor of Anthropology
> School of Human Evolution & Social Change
> Center for Social Dynamics and Complexity
> Arizona State University
>
> phone: 480-965-6213
> fax: 480-965-7671
> www: http://www.public.asu.edu/~cmbarton
>
> _______________________________________________
> grassgui mailing list
> [hidden email]
> http://grass.itc.it/mailman/listinfo/grassgui
>


--
-- Daniel Calvelo Aros

_______________________________________________
grassgui mailing list
[hidden email]
http://grass.itc.it/mailman/listinfo/grassgui
Glynn Clements

Re: Re: [grass-addons] r343 - trunk/grassaddons/gui

Reply Threaded More More options
Print post
Permalink
In reply to this post by Michael Barton

Michael Barton wrote:

> Aha! A further clarification. Is octal base 8? (Pardon my novicity, but I
> don't use this much).

Yes. Octal is base 8, so one octal digit equals 3 bits. In the case of
file permissions, those 3 bits map directly to the "rwx" bits, so each
of u(ser), g(roup) and o(ther) get one octal digit each. This is why
octal has remained in common use (e.g. the "chmod" command
automatically reads numeric permissions as octal) for permissions
while hexadecimal has replaced it almost everywhere else.

        digit permissions

        0 ---
        1 --x [*]
        2 -w- [*]
        3 -wx [*]
        4 r--
        5 r-x
        6 rw-
        7 rwx

[*] 1 (--x) is often used for directories, so that normal users can
access files and subdirectories if they know the name but can't list
the directory. It may also be used for setuid/setgid executables, to
prevent users from analysing the binary in search of potential
security holes.

[*] 2 (-w-, i.e. write-only) is uncommon, although may be used (via
"mesg y") for tty devices to allow other users to send messages using
the "write" command.

[*] 3 (-wx, write and execute but not read) is essentially unheard of.

Uses for the other possibilites should be relatively obvious.

--
Glynn Clements <[hidden email]>

_______________________________________________
grassgui mailing list
[hidden email]
http://grass.itc.it/mailman/listinfo/grassgui