Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: f566e674a003fe3ee9d4d0918853b46e51006251
Ticket: 488530ffffffffffffffffffffffffffffffffff
setuid Tcl scripts don't work on Solaris
User & Date: kennykb on 2001-12-03 19:35:41
Changes

  1. assignee changed to: "msofer"
  2. cmimetype changed to: "text/plain"
  3. comment changed 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 changed to: "obsolete: 8.3.4"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "kennykb"
  9. subsystem changed to: "45. Parsing and Eval"
  10. title changed to: "setuid Tcl scripts don't work on Solaris"
  11. type changed to: "Bug"