home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / tcl / 2457 < prev    next >
Encoding:
Text File  |  1993-01-23  |  1.1 KB  |  37 lines

  1. Newsgroups: comp.lang.tcl
  2. Path: sparky!uunet!think.com!paperboy.osf.org!rsalz
  3. From: rsalz@osf.org (Rich Salz)
  4. Subject: Re: How difficult is a restricted tcl shell ?
  5. Message-ID: <1993Jan22.205327.3323@osf.org>
  6. Keywords: shell user supervisor interpreter
  7. Sender: news@osf.org (USENET News System)
  8. Organization: Open Software Foundation
  9. References: <brucet.727682251@extro.ucc.su.OZ.AU>
  10. Date: Fri, 22 Jan 1993 20:53:27 GMT
  11. Lines: 24
  12.  
  13. I have another idea.  Allow a programmer to attach an 'authorization'
  14. function to an interpreter.  Something like this:
  15.     /* A TCL "authorization" function.  Return 1 if command can be
  16.      * executed. */
  17.     typedef int (*Tcl_Authorize)(
  18.         ClientData *clientdata,
  19.         Tcl_Interp *interp,
  20.         int argc,
  21.         char *argv[]
  22.     );
  23.  
  24. And these commands:
  25.     Tcl_Authorize Tcl_GetAuthorize(Tcl_Interp *interp);
  26.     void Tcl_SetAuthorize(Tcl_Interp *interp, Tcl_Authorize authfunc);
  27. Then you could do things like
  28.     authfunc(ClientData *clientdata, Tcl_Interp *interp, int argc, char *argv)
  29.     {
  30.     if (strcmp(argv[0], "open") == 0)
  31.         /* validate pathnames */
  32.         return validpath(argv[1]) ? 1 : 0;
  33.     if (strcmp(argv[0], "exec") == 0)
  34.         ...
  35.     return 1;
  36.     }
  37.