Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: f28f5cf99dd200e58aa7c40c9829d01b75c04f2e
Ticket: 1157137fffffffffffffffffffffffffffffffff
Cannot open file if parent directory unreadable on Solaris
User & Date: nobody on 2005-04-13 07:22:27
Changes

  1. icomment:
    Logged In: NO 
    
    Hi Vince,
    
    Sorry for the slow response - I have been away for a few 
    weeks.
    
    I have done quite a bit of debugging, and the problem occurs 
    because TCL appears to be making the assumption that 
    getcwd() will ALWAYS succeed if the current directory 
    exists. This seems to be true on Linux, but it is NOT true on 
    other Unices. Strictly, on Unix you can CD to a directory as 
    long as you have EXECUTE access to it - you do NOT need 
    read access. However to read the directory (eg: do an "ls", or 
    call readdir()), you need READ access to it.
    
    Under some Unices, getcwd() works by recursively reading 
    the directory tree from the current directory back up to root, 
    finding the name of the directory at each level. In order to do 
    this, you need READ access to every directory in the chain.
    
    When TCL opens a file in Tcl_FSOpenFileChannel(), it first 
    calls Tcl_FSGetNormalizedPath() (in generic/tclIOUtil.c). If 
    the file name provided is TCL_PATH_RELATIVE this calls 
    Tcl_FSGetCwd() (a few lines below the comment "We have to 
    be a little bit careful here to avoid infinite loops"). On Unices 
    where getcwd() fails because it cannot read one of the parent 
    directories, Tcl_FSGetCwd() returns NULL, causing 
    Tcl_FSGetNormalizedPath() to also return NULL, in turn 
    causing Tcl_FSOpenFileChannel() to return NULL.
    
    Thus the file open fails even though the file is actually 
    readable, simply becuase TCL seems to always want the 
    filename as a full pathname. This appears to be a design flaw 
    in TCL. It *should* be able to open a readable file even if 
    getcwd() fails - just like any other programming language.
    
    Best regards,
    Mike Selig ([email protected])
    
    
  2. login: "nobody"
  3. mimetype: "text/plain"
  4. username: "nobody"