Garrett Cooper <[email protected]> added the comment:
That definitely fixes detection for FreeBSD CURRENT with 2.7 and py3k for me.
I'm looking into providing some unit-tests, but the problem is that whether or
not chflags functions on the underlying filesystem is problematic. For
instance, it won't function on msdosfs (Linux calls it vfat), it won't function
on ext[23] (AFAIK), and it didn't function on ZFS (until recently? I'm not sure
whether or not the latest patches for ZFS enhance the filesystem to support
this functionality). So unfortunately adding tests for this feature (while
nice) would potentially be error prone.
Something I tried was:
>>> UF_IMMUTABLE = 2
>>> import tempfile
>>> f = tempfile.mkstemp()[1]
>>> os.getuid()
1000
>>> os.chflags('/tmp', UF_IMMUTABLE)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [Errno 1] Operation not permitted: '/tmp'
>>> os.chflags(f, UF_IMMUTABLE)
>>> fd = open(f, 'w')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IOError: [Errno 1] Operation not permitted: '/tmp/tmpi_hwY7'
>>> fd = open(f, 'r')
>>> fd = open(f, 'r')
>>> fd.read()
''
>>> os.chflags(f, 0)
>>> fd = open(f, 'w')
>>> fd.write('foo')
>>> fd.close()
>>> fd = open(f, 'r')
>>> fd.read()
'foo'
>>> fd.close()
Also, the flags are missing that are described in the manpage. I'll provide a
patch for those.
Otherwise, it looks like everything's functioning as expected for basic
end-to-end tests with chflags(2).
Thanks!
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue8746>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com