Re: websh - safe interps and other questions



APN wrote:
- websh does not seem to use safe interps. This would seem to be an
ideal place to use that particular Tcl feature to protect against
programmer errors. Any reason why safe interp's would not work? Any
way of configuring the websh interpreter to be safe?

No reason why a safe interp would not work, but since the safe interp you'd invoke will not contain any websh functionality, it is relatively useless, not just safe...

You could tweak the htmlhandler.ws3 wrapper to eval some page or code in a safe interp instead of directly in the master interp. But as I said: none of the functionality websh provides will be available. And currently, you cannot load libwebsh.so in the safe interp, as there is no Websh_SafeInit procedure. (Might be done I guess, but I never really explored the possibilities / limitations ...)

- Does websh fire a new interp for every web request? The docs seem to
indicate this is configurable (number of requests handled before the
interp is deleted). Does that mean any data (globals for instance)
left over from processing a request is available in subsequent
requests?

Yes. Use web::interpclasscfg to set the number of requests to be handled by an interpreter. (Note however, that usually a subsequent request is not handled by the same interp, so be very careful when passing info from request to request...)
Ina typical prefork Apache environment you have plenty of independent processes with plenty of interps each: changes are pretty slim to hit the same interp twice.

- Does websh use the Tcl installation on the system or does it have
its own built-in interpreter? auto_path from within websh shows the
system's Tcl installation directories. Is this because websh was built
on that system ? How does one configure websh to use a separate area
for loading packages etc.

mod_websh doesn't have any special means to configure the environment. Setting the proper environment when you start Apache however will make sure that you have the desired Tcl lib, init.tcl etc...

- Can binary Tcl extensions be loaded into websh ? In particular, I
need a database interface.

Yes: [load] is your friend

hth
Ronnie
--
Ronnie Brunner | ronnie.brunner@xxxxxxxxxxxx
phone +41-44-247 79 79 | fax +41-44-247 70 75
Netcetera AG | 8040 Zürich | Switzerland | http://netcetera.ch
.



Relevant Pages

  • Re: Redirect file output into variables
    ... Hmm, i would use a safe interpreter for that..., as you say limited ... interp alias foo puts buffered_puts ... set script "script you want to execute in a safe environment" ...
    (comp.lang.tcl)
  • Re: safe base and package require
    ... I reported the "package require math in a safe interp" problem on the ... I can successfully require calculus in the master interp. ... packages accessible in the auto_path of the master, ...
    (comp.lang.tcl)
  • Re: safe base and package require
    ... I am having a few troubles with the safe base mechanism. ... % interp eval interp0 "package require math" ... I believe safe slaves do not search down into sub-directories when looking for packages, so you may need to add the exact dir containing math::calculus to the search path. ...
    (comp.lang.tcl)
  • Re: XML Parsing....?
    ... like tcl code and eval it in a safe interp. ... Since your xml is very simple, it's *almost* tcl... ...
    (comp.lang.tcl)