Version 2 of Tk in a set-userid application

Updated 2001-12-03 18:44:30

Purpose: to investigate issues relating to writing set-userid Tk applications.

Here's a simple set-userid application that I'm trying to get to run.

$ cat setuid.tcl

 #!/bin/sh
 # \
 exec tclsh "$0" ${1+"$@"}

 package require Tclx
 set i [info loaded]
 puts $i

 set effective [id effective userid]
 set real [id  userid ]

 puts "Before: realid = $real  effectiveid = $effective"
 id userid $real
 puts "After: realid = $real  effectiveid = $effective"

 package require Tk
 proc quitApp { args } {
        puts [format "%s" $args]
 }

 set res [wm protocol . WM_DELETE_WINDOW quitApp]

 puts $res


 $ su differentuid
 Password: 
 % chmod 4755 setuid.tcl
 $
 $ /home/lvirden/setuid.tcl

invalid command name "erid]"

    while executing

"erid]"

    (file "/dev/fd/4" line 1)

Looking for insights on how to get this script to work successfully.