Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2026-11-13
11:18 • Closed ticket [219334ffff]: tclsh needs a -setuid and -setgid command line argum... artifact: 3b30d31edb user: serhiy.storchaka
2002-03-23
07:53 • Ticket [219334ffff]: 5 changes artifact: b8b316bd8c user: hobbs
2001-06-26
05:47 • Ticket [219334ffff]: 5 changes artifact: c6e11b6482 user: dkf
2001-04-04
04:53 • Ticket [219334ffff]: 1 change artifact: 60b71c11f3 user: dgp
2000-11-16
15:59 • Ticket [219334ffff]: 1 change artifact: c0dbb330ca user: andreas_kupries
2000-10-26
05:10 • New ticket [219334ffff]. artifact: 6e44aeabf7 user: nobody

tclsh needs a -setuid and -setgid command line argument

Closed / Rejected219334ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 19 days ago
Descriptionplain2000-10-26 05:10:54
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.
andreas_kupries Ticket [219334ffff]: 1 change [History diff]2000-11-16 15:59:46
dgp Ticket [219334ffff]: 1 change [History diff]2001-04-04 04:53:08
dkfplain2001-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.)
hobbsplain2002-03-23 07:53:00
Logged In: YES 
user_id=72656

see TIP #88
serhiy.storchakawiki2026-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.

Log in (anonymous is fine) to add a comment.