Version 0 of Tk in a set-userid application

Updated 2001-12-03 18:17:51

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 wish "$0" ${1+"$@"}

 package require Tclx

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

 set effective [id effective userid]
 puts $effective
 set real [id  userid ]
 puts $real

 id userid $real
 puts "realid = $real  effectiveid = $effective"
 set res [wm protocol . WM_DELETE_WINDOW quitApp]

 puts $res


 $ su differentuid
 Password: 
 % chmod 4755 setuid.tcl
 $
 $ /home/lvirden/setuid.tcl
 Xlib: connection to ":0.0" refused by server
 Xlib: Client is not authorized to connect to Server
 Application initialization failed: this isn't a Tk applicationcouldn't connect to display ":0.0"
 Error in startup script: invalid command name "id"
     while executing
 "id effective userid"
    invoked from within
 "effective [id effective userid]"
    (file "/dev/fd/4" line 1)


Looking for insights on what might be going on. Without the setuid permissions, the application works okay.