Skip to content
Tcl Source Code History Of Ticket 1157137fff
Login

History Of Ticket 1157137fff

Artifacts Associated With Ticket 1157137fff

  1. Ticket change [ba75558713] (rid 129330) by nobody on 2005-03-05 05:47:53:

    1. assignee initialized to: "vincentdarley"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      Tcl version: 8.4.6 & 8.4.9
      OS: Solaris 2.6 & 8 (possibly other Unixes, but *not* 
      Linux)
      
      To replicate the problem, do the following under a shell:
      
      mkdir -p /tmp/dir1/dir2
      chmod 111 /tmp/dir1
      cd /tmp/dir1/dir2
      echo JUNK > file
      tclsh
      % open file
      error getting working directory name: permission denied
      
      Yet this file is very readable! It's just that a parent 
      directory is not readable (dir1). For some reason Tcl 8.4 
      appears to want to do a getcwd() before opening the file, 
      which fails on Solaris (and possibly other Unices).
      
      This is causing us great grief, and I cannot even find a 
      workaround other than to change the directory 
      permissions, which we do not want to do for security 
      reasons.
      
      Is this problem known or patched somewhere? We need 
      a fix real soon!
      
      Thank you,
      Mike Selig
      
    4. foundin initialized to: "obsolete: 8.4.9"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "nobody"
    9. subsystem initialized to: "37. File System"
    10. title initialized to:
      Cannot open file if parent directory unreadable on Solaris
      
    11. type initialized to: "Bug"
  2. Ticket change [41eddcbede] (rid 116280) by vincentdarley on 2005-03-15 01:31:32:

    1. icomment:
      Logged In: YES 
      user_id=32170
      
      You'll want to try debugging TclpObjNormalizePath in
      tcl/unix/tclUnixFCmd.c, to see what goes wrong, I would say.
      
      It does seem odd that 'cd' works, put 'getcwd' fails?  Can
      you confirm that [pwd] in dir2 also throws an error?
      
      
    2. login: "vincentdarley"
    3. mimetype: "text/plain"
    4. username: "vincentdarley"
  3. Ticket change [f28f5cf99d] (rid 109568) by nobody on 2005-04-13 07:22:27:

    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"
  4. Ticket change [0c84d45929] (rid 114191) by vincentdarley on 2005-04-13 18:54:35:

    1. icomment:
      Logged In: YES 
      user_id=32170
      
      I'm not really sure how to resolve this.  The first point to
      make is that Tcl must check cwd() because if the getcwd()
      has changed (possible in C programs using the Tcl API) then
      the file reference is different. Also this is required to
      deal with the whole virtual-filesystem stuff. Now there are
      some changes that could perhaps be made to help with this,
      so all is hopefully not lost.
      
      However, Tcl's test suite actually tests for the case where:
      
      cd foo
      exec chmod foo .... (remove permissions)
      pwd
      ->throws error that there are no permissions.
      
      So, Tcl wants to throw an error in this case. 
      
      The only solution I can think of is that, if Tcl_FSGetCwd()
      returns NULL _and_ the error is a lack of permissions _and_
      we're just accessing Tcl_FSGetCwd() in order to normalize a
      path _then_ we use the cached value that was passed to 'cd'
      instead.
      
      This might allow this situation to work ok on Solaris but
      not break anything else.
      
      any thoughts?
      
      
      
    2. login: "vincentdarley"
    3. mimetype: "text/plain"
    4. username: "vincentdarley"
  5. Ticket change [54d29f42f2] (rid 94017) by hobbs on 2005-10-05 12:28:27:

    1. icomment:
      Logged In: YES 
      user_id=72656
      
      Is there a patch to try for this?
      
      
    2. login: "hobbs"
    3. mimetype: "text/plain"
    4. priority changed to: "6"
    5. username: "hobbs"