Skip to content
Tcl Source Code History Of Ticket 488530
Login

History Of Ticket 488530

Artifacts Associated With Ticket 488530

  1. Ticket change [f566e674a0] (rid 130099) by kennykb on 2001-12-03 19:35:41:

    1. assignee initialized to: "msofer"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      On Solaris, create a script, "foo.tcl", that looks like the following:
      
      #!/bin/sh
      #\
      exec tclsh8.3 "$0" ${1+"$@"}
      
      puts "----------------------------------------------------------------------"
      puts "----------------------------------------------------------------------"
      puts "----------------------------------------------------------------------"
      puts "----------------------------------------------------------------------"
      puts "----------------------------------------------------------------------"
      
      Now change its permissions to 2755 (rwsr-xr-x).  Attempt to execute ./foo.tcl
      from the command line.  An error results:
      
      invalid command name "---------------------------------------------------------------------""
          while executing
      "---------------------------------------------------------------------""
          (file "/dev/fd/3" line 1)
      
      
      What's happening here is that Solaris, for security reasons, doesn't pass the name of the script file 
      into the shell.  Instead, it opens the script file, leaves it open, and launches the shell with argv[0] 
      equal to /dev/fd/N, where N is the number of the script file's filedescriptor.
      
      When this file is opened, the kernel simply dup's the filedescriptor.  The file is not rewound.  The 
      result is that the Tcl_EvalFileEx that's been called from Tcl_Main starts reading the file in the 
      middle.
      
      One obvious potential fix is to have Tcl_EvalFileEx seek the file to the beginning before reading it.  
      The only problem I can see with this is if someone's [source]ing a device file and depending on its 
      being left in place.  I think I'd be prepared to break this behavior in order to make setuid scripts 
      work.
      
    4. foundin initialized to: "obsolete: 8.3.4"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "kennykb"
    9. subsystem initialized to: "45. Parsing and Eval"
    10. title initialized to: "setuid Tcl scripts don't work on Solaris"
    11. type initialized to: "Bug"
  2. Ticket change [9ac47d77de] (rid 111012) by dkf on 2001-12-04 18:04:34:

    1. icomment:
      Logged In: YES 
      user_id=79902
      
      Possible workaround: Put an extra blank line or *any*
      comment line after the exec line; the problem is really that
      the Solaris /bin/sh reads too far from the FD...
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  3. Ticket change [7b10e97bcc] (rid 90449) by kennykb on 2001-12-04 22:01:14:

    1. icomment:
      Logged In: YES 
      user_id=99768
      
      The user in question already has a workaround of separating the setuid shell script from the Tcl script: 
      http://mini.net/tcl/2654.html 
      
      The proposed workaround depends on the size of the buffer used in /bin/sh.  There really isn't any reason 
      for the shell to reposition its script file before doing an exec, so I'd be really reluctant to call this a shell 
      bug.  Note that one expects the script to restart from the beginning, as it would if the /dev/fd hack weren't 
      there.
      
      I think that the underlying bug is in the kernel, that opening /dev/fd/N doesn't do a rewind.  It should, if the 
      implementors are going to use this hack on setuid shell scripts.
      
      
    2. login: "kennykb"
    3. mimetype: "text/plain"
    4. username: "kennykb"
  4. Ticket change [1a822845d6] (rid 122988) by kennykb on 2001-12-13 03:47:56:

    1. icomment:
      Logged In: YES 
      user_id=99768
      
      The right place to rewind the file is most likely in Tcl_FSEvalFile, after the
      channel is opened but before reading from it.  Once again, failure to seek
      should not be treated as an error, in case anyone decides to 'source' a
      character special device.
      
      
    2. login: "kennykb"
    3. mimetype: "text/plain"
    4. subsystem changed to: "37. File System"
    5. username: "kennykb"
  5. Ticket change [f97102db00] (rid 91711) by kennykb on 2001-12-13 03:49:57:

    1. assignee changed to: "vincentdarley"
  6. Ticket change [9fadb0dcfd] (rid 96679) by vincentdarley on 2001-12-14 02:18:41:

    1. assignee changed to: "andreas_kupries"
    2. icomment:
      Logged In: YES 
      user_id=32170
      
      I don't think I'm particularly qualified to judge what 
      should be done here.  It seems the proposed change is 
      inoccuous enough,...  Given that, I'll argue this is more 
      of a channel issue than a filesystem issue, so I'm 
      assigning to Andreas ;-)
      
      
      
    3. login: "vincentdarley"
    4. mimetype: "text/plain"
    5. username: "vincentdarley"
  7. Ticket change [5fe9f84a67] (rid 115902) by andreas_kupries on 2006-03-15 07:28:13:

    1. icomment:
      Logged In: YES 
      user_id=75003
      
      Kevin, should we do anything anymore with this entry ?
      
      
    2. login: "andreas_kupries"
    3. mimetype: "text/plain"
    4. username: "andreas_kupries"