Bug? in os.chown()

Martin von Loewis loewis at informatik.hu-berlin.de
Mon Jan 1 09:09:07 EST 2001


David Lambert <dave_lambert at ev1.net> writes:

> I am running Python 2.0 on Mandrake Linux 7.2 and have come across an
> apparent anomaly with os.chown(). Running a process as root, I can
> change any file's ownerships apart from symbolic links. No error is
> given, but the ownership refuses to be changed. Is this a feature or a
> bug? How do I change a symbolic link's owner and group?

Python delegates  the call  to Linux,  so if anything,  it's a  bug or
feature  of Linux. In  this case,  it's a  feature of  Linux: chown(2)
modifies  the file  behind the  symbolic link,  not the  symbolic link
itself  (I  believe  in  conformance  with POSIX,  which  makes  it  a
feature).    To    change    the    symbolic    link    itself,    use
lchown(2).  Unfortunately,   lchown  is  not  exposed   in  the  Posix
module. If you have a need for it, I recommend to make a bug report at
sourceforge.net/projects/python.  Better  yet, submit  a patch  to the 
posix module.

Regards,
Martin



More information about the Python-list mailing list