Tcl Source Code

View Ticket
Login
Ticket UUID: 219334
Title: tclsh needs a -setuid and -setgid command line argument
Type: RFE Created on: 2000-10-26 05:10:54
Submitter: nobody Assigned to: hobbs
Subsystem: 50. Embedding Support Severity:
Priority: 2 Last modified: 2026-11-13 11:18:44
Status: Closed Closed by: serhiy.storchaka
Resolution: Rejected Closed on: 2026-11-13 11:18:43
Version: obsolete: 8.4a3
Description:
OriginalBugID: 5082 RFE
Version: 8.3.1
SubmitDate: '2000-04-14'
LastModified: '2000-04-14'
Severity: MED
Status: UnAssn
Submitter: welch
ChangedBy: welch
OS: All Unix
FixedDate: '2000-10-25'
ClosedDate: '2000-10-25'


The tcl shells should process a -setuid and -setgid command line
argument before the Tcl interpreter is initialized.  The problem is
that if the setuid is done after the Notifier thread (or any other thread)
then on many systems only the main thread changes user ID.  After that,
the signals used between threads by the pthread implementation fail,
therefore condition variables don't work, therefore Tcl locks up.

It gets worse.  If the Tcl shell wants to open a privileged socket port,
it can only do this as root.  I'm not sure, but it may be possible
to temporarily restore the main thread to root, open the socket,
and then switch back.  I think setuid lets you do this sort of thing.
User Comments:
dkf added on 2001-06-26 05:47:43:
Logged In: YES 
user_id=79902

I've not seen any Tcl shells that are setuid/setgid by default (there are a lot of security concerns, as you 
might well imagine, and this has been a source of much trouble to the Perl people) and neither tclsh nor 
wish provide special support for such command lines. That means that they must be provided by an 
extension of some kind, and at a guess it might do some processing before calling Tcl_Main() or 
Tk_Main() (maybe it'll never call those functions at all; I don't care for the purposes of this point) and 
that is when all this sort of thing should be handled. Thus, in my opinion this is not a fault with Tcl (or Tk) 
at all, and the request should be passed on to whoever *is* responsible for this (I don't recognise this.)

hobbs added on 2002-03-23 07:53:00:
Logged In: YES 
user_id=72656

see TIP #88

serhiy.storchaka added on 2026-11-13 11:18:44:

Closing per dkf's comment: changing the user or group id before the interpreter and the notifier thread start is the job of the embedding application (or a wrapper) before it calls Tcl_Main, not of tclsh.