classification
Title: os.chmod failure
Type: Stage:
Components: None Versions:
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: georg.brandl, nnorwitz, rgheck
Priority: normal Keywords:

Created on 2007-08-03 18:02 by rgheck, last changed 2007-09-07 07:40 by georg.brandl. This issue is now closed.

Messages (4)
msg32580 - (view) Author: Richard Heck (rgheck) Date: 2007-08-03 18:02
When running on Linux and accessing a FAT partition, os.chmod fails with otherwise sensible partitions:
>>> os.chmod("/media/IHP-100/Test.lyx", 400)
>>> os.chmod("/media/IHP-100/Test.lyx", 600)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
OSError: [Errno 1] Operation not permitted: '/media/IHP-100/Test.lyx'
The only thing that seems to be allowed is `4'. 
msg32581 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2007-08-03 20:25
Why do you think this is Python's fault? os.chmod() is only a very thin wrapper around the OS' chmod().
msg32582 - (view) Author: Richard Heck (rgheck) Date: 2007-08-03 20:39
Well, the shell's chmod doesn't return an error.

[rgheck@rghstudy scripts]$ chmod 600 /media/IHP-100/Test.lyx
[rgheck@rghstudy scripts]$ echo $?
0
[rgheck@rghstudy scripts]$ chmod 400 /media/IHP-100/Test.lyx
[rgheck@rghstudy scripts]$ echo $?
0
[rgheck@rghstudy scripts]$ chmod 700 /media/IHP-100/Test.lyx
[rgheck@rghstudy scripts]$ echo $?
0
[rgheck@rghstudy scripts]$ python
Python 2.4.4 (#1, Oct 23 2006, 13:58:00)
[GCC 4.1.1 20061011 (Red Hat 4.1.1-30)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.chmod("/media/IHP-100/Test.lyx", 400)
>>> os.chmod("/media/IHP-100/Test.lyx", 600)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
OSError: [Errno 1] Operation not permitted: '/media/IHP-100/Test.lyx'

I don't know what would happen in C, say.
msg32583 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2007-08-07 05:45
Note:  you are *not* using octal in python, but the chmod program is using octal:

Try prefixing 400/600 with a zero, ie:  0400 or 0600.
History
Date User Action Args
2007-09-07 07:40:37georg.brandlsetstatus: pending -> closed
2007-08-23 20:31:32georg.brandlsetstatus: open -> pending
2007-08-03 18:02:26rgheckcreate