Menu

#57 File permissions incorrect after install

v2.0
open
install (16)
5
2003-04-28
2003-01-21
No

When installing PyOpenGL 2.0.0.44 from source on my
Debian Linux system, it did not set the file
permissions correctly Directories had the correct
permission, in general, as did compiled files.

The problem probably stems from the fact that my umask
was 077 while building the package (but 022 while
installing.) The installation procedure should never be
umask dependent; directories and shared objects should
be installed 0755 (or 0555) by default, and .py files
(and their compiled and optimize-compiled versions)
should be 0644 (or 0444).

The problem caused built files to be unreadable for
others than root, causing an ImportError when doing
'import OpenGL.GL' (and others) but not 'import
OpenGL'. (and others) because
<prefix>/site-packages/OpenGL/__init__.pyc was
readable, allowing import of that package, but
<prefix>/site-packages/OpenGL/GL/__init___.so (required
by its __init__.pyc) was not readable.

Discussion

  • Mike C. Fletcher

    Logged In: YES
    user_id=34901

    I'm not a unix geek, nor am I a distutils guru, so I'm going
    to have to ask for some help here. Basically, the
    build_py.py module is likely what's creating wrong modes for
    the python files (no idea what's setting the permissions for
    the .pyc, .pyo, and .so files).

    Base distutils calculates the mode with:
    mode = ((os.stat(file)[ST_MODE]) | 0111) & 07777

    mode = (os.stat(outfile)[ST_MODE]) | 0111

    There's no notes from Tarn regarding why he was using this,
    so I can't give any insight on whether it would fail to add
    in the &, though I _think_ the & 07777 will just truncate to
    "a valid mode number" (unless there's another whole
    group-type I'm missing).

    So, anyone know:
    1) Where in distutils to apply pressure to change .so
    permissions
    2) Whether there would be any problems on Unix-oid OSes
    setting mode to 0644 for python files regardless of their
    source-file-permissions? (I'm assuming not for now, given
    Thomas expertise).

     
  • Mike C. Fletcher

    • assigned_to: nobody --> mcfletch
     
  • Mike C. Fletcher

    Logged In: YES
    user_id=34901

    Is this still causing a problem in the 2.0.1 series?

     
  • Thomas Wouters

    Thomas Wouters - 2003-04-28

    Logged In: YES
    user_id=34209

    No, it's still not quite working. The problem is still that
    files retain the permissions they were built with, and that
    would be too restrictive when built with umask of '077' of
    '007', which any security-minded person would have. :-)
    Unfortunately, I can't quite figure out where in the
    distutils configuration the actual copying is done. There is
    some specialcasing of .py files that have '#!' as their
    first two bytes (in build_py.py:copy_file()) but it only
    sets the execute bits, not the read bits, and it only does
    its work for 'scripts', not other .py files (which it
    should) and not for .so files (which it should.) And I'm not
    a distutils guru either :)

    The quick and easy fix is to add 'os.umask(022)' at the top
    of setup.py.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.