This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: directory permission error with make install in 3.0
Type: resource usage Stage:
Components: Distutils Versions: Python 3.0, Python 3.1
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: amaury.forgeotdarc, legerf, tarek, vstinner
Priority: normal Keywords: patch

Created on 2008-12-08 21:27 by legerf, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
altinstall.log legerf, 2008-12-08 21:27
setup_chmod.patch vstinner, 2008-12-08 23:34
Messages (11)
msg77344 - (view) Author: Leger (legerf) Date: 2008-12-08 21:27
Under Debian/Lenny, with Python3.0.final install from the tarball, any
user can't import lib-dynload, launch IDLE ... but local root can do them.

When I login in root and run "chmod -R o+rx /usr/lib/python3.0/*", users
can use normaly python3.0.

Install detail : "configure --with-pydebug --with-doc-strings
--enable-shared --enable-profiling --enable-ipv6 --with-threads
--with-tsc --prefix=/usr ; make ; make test" and after "make altinstall
> altinstall.log 2>&1". I join altinstall.log.
msg77351 - (view) Author: Leger (legerf) Date: 2008-12-08 21:59
My root umask = 0027 (hardened system), so the altinstall/install script
don't manage umask parameter.
msg77352 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2008-12-08 22:10
I'm able to reproduce the bug with umask set to 0027:
drwxr-x--- 2 root root 3072 déc  8 22:59 
(...)/lib/python3.1/lib-dynload

With umask 0077, it's:
drwx------ 2 root root 3072 déc  8 22:59 
(...)/lib/python3.1/lib-dynload

The problem is specific to this directory.
msg77354 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2008-12-08 22:27
install() method of the install_lib command 
(Lib/distutils/command/install_lib.py) calls self.copy_tree() which 
calls copy_tree() from Lib/distutils/dir_util.py. By default, this 
function preserve the modes (perserve_mode=1 by default). Or the build 
created a directory with permissions "drwx------".

I wrote that only lib-dynload directory has a problem. But other files 
are install with permissions -rw-------:
 - .../lib/python?.?/*.{pyc,pyo}
 - .../lib/python?.?/lib2to3/PatternGrammar*.pickle
 - .../lib/python?.?/lib2to3/Grammar*.pickle
 - .../lib/python?.?/lib-dynload/Python*.egg-info
msg77356 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2008-12-08 22:38
With Python trunk, the directory has the right permission (drwxr-xr-x) 
whereas build/lib.linux(...) has permission 
drwx------.

But the problem is still open for listed files 
(.pyc, .pyo, .picle, .egg-info).
msg77364 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2008-12-08 23:34
Gotcha! os.path.walk() was replaced by os.walk() but walk() argument is 
no more a callback because walk() is a generator! Here is a fix.
msg77404 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2008-12-09 11:57
The patch is fine.

If it were me, I'd change os.walk to accept keyword-only arguments:
def walk(top, *, topdown=True, onerror=None, followlinks=False):
   ...
msg77406 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2008-12-09 12:19
Hum, there is not fixer for 2to3. But I might be hard to write such 
fixer because walk() generates (dirpath, dirnames, filenames) instead 
of (dirpath, filenames).

Python2 prototype:
  os.path.walk(path, visit, arg) -> None
  with visit: callback(arg, dirpath, filenames)

Python3 prototype:
  os.walk(top[, topdown=True[, onerror=None[, followlinks=False]]]) -> 
generator
  with onerror: callback()
  the generator produces (dirpath, dirnames, filenames)

Example:
   os.path.walk('Lib/xml/', callback, 42)
can be replaced by
   for dirpath, dirnames, filenames in os.walk('Lib/xml/'):
      callback(42, dirpath, dirnames + filenames)

About the keyword only: +1 (or +2 :-)).

Index: Lib/os.py
===================================================================
--- Lib/os.py   (révision 67652)
+++ Lib/os.py   (copie de travail)
@@ -192,7 +192,7 @@

 __all__.extend(["makedirs", "removedirs", "renames"])

-def walk(top, topdown=True, onerror=None, followlinks=False):
+def walk(top, *, topdown=True, onerror=None, followlinks=False):
     """Directory tree generator.

     For each directory in the directory tree rooted at top (including 
top
msg84129 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2009-03-24 23:51
amaury> The patch is fine.

Cool :-) Anyone to commit the fix? Maybe, tarek?

amaury> If it were me, I'd change os.walk to accept 
amaury> keyword-only arguments:
amaury> def walk(top, *, topdown=True, onerror=None,
amaury>          followlinks=False):
amaury>          ...

I like the idea but it should be proposed in a new issue :-) I 
proposed an API change for open() (issue #4121) but it was rejected by 
Guido:

"(...) Beyond 3.0, I'm still rather reluctant -- I expect most users 
will be wise and use keyword args anyway; I'm not sure what we buy by 
forcing this. (...)"

But walk() is a different case than open().
msg90025 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2009-07-02 16:47
ping
msg90037 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2009-07-02 23:57
Ok, fixed in r73788 and r73789.
History
Date User Action Args
2022-04-11 14:56:42adminsetgithub: 48851
2009-07-02 23:57:32amaury.forgeotdarcsetstatus: open -> closed
resolution: accepted -> fixed
messages: + msg90037
2009-07-02 16:47:00vstinnersetmessages: + msg90025
2009-03-24 23:51:43vstinnersetnosy: + tarek
messages: + msg84129
2008-12-09 12:19:38vstinnersetmessages: + msg77406
2008-12-09 11:57:11amaury.forgeotdarcsetresolution: accepted
messages: + msg77404
nosy: + amaury.forgeotdarc
2008-12-08 23:34:09vstinnersetfiles: + setup_chmod.patch
keywords: + patch
title: permissions errors with altinstall in 3.0 -> directory permission error with make install in 3.0
messages: + msg77364
versions: - Python 2.6, Python 2.7
2008-12-08 22:38:49vstinnersetmessages: + msg77356
2008-12-08 22:27:56vstinnersetmessages: + msg77354
components: + Distutils, - Library (Lib)
versions: + Python 2.6, Python 3.1, Python 2.7
2008-12-08 22:10:08vstinnersetnosy: + vstinner
messages: + msg77352
2008-12-08 21:59:55legerfsetmessages: + msg77351
2008-12-08 21:27:52legerfcreate