home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / unix / wizards / 3696 < prev    next >
Encoding:
Text File  |  1992-08-26  |  2.1 KB  |  58 lines

  1. Newsgroups: comp.unix.wizards
  2. Path: sparky!uunet!cs.utexas.edu!sun-barr!ames!pacbell.com!pbhya!dbsuthe
  3. From: dbsuthe@pbhya.PacBell.COM (Daniel B. Suthers)
  4. Subject: Re: Changing "pg" options
  5. Reply-To: dbsuthe@PacBell.COM (Daniel B. Suthers)
  6. Organization: Pacific * Bell, San Ramon, CA
  7. Distribution: usa
  8. Date: Wed, 26 Aug 1992 17:34:46 GMT
  9. Message-ID: <1992Aug26.173446.11983@pbhya.PacBell.COM>
  10. References: <1992Aug25.190239.19142@cbfsb.cb.att.com>
  11. Lines: 45
  12.  
  13. In article <1992Aug25.190239.19142@cbfsb.cb.att.com> rajeev@cbnewsf.cb.att.com (rajeev.dolas) writes:
  14. >
  15. >
  16. >Howdy all,
  17. >
  18. >    I am trying to find out if there is a way of turning the "!"
  19. >    option off from pg.  Here is something similar to what I am 
  20. >    trying to do:
  21. >
  22. >    main()
  23. >    {
  24. >        char t[25];
  25. >
  26. >        strcpy(t, "pg $HOME/.profile\n");
  27. >        system(t);
  28. >    }
  29. >
  30. >    While running this program I don't want the !<command> option
  31. >    to be available to the user.
  32. >
  33. >    Is there a simple way of doing this?  I don't want to reinvent the
  34. >    wheel and write my own pg (if possible).
  35.  
  36. In the past, I had good results by simply removing the environment variable
  37. SHELL.  This caused PG to issue an error message when the escape was attempted.
  38.  
  39. If you really want to be safer (not necessarily safe, but safer) add the 
  40. following:
  41.     Fork a new process.  In the new process:
  42.         Set SHELL to NULL and PATH to one you want them to use.
  43.         In the forked process, set the effective uid to the real uid (if
  44.         applicable)
  45.         Exec() the program instead of using system().
  46.         (Use the explicit path name in the exec call)
  47.     In the parent process, wait for the child to die.
  48.  
  49. This should be fairly safe when even if using setuid.  Others may correct me,
  50. so wait a few days before coding. :)
  51.  
  52. Daniel B. Suthers,  CCP
  53. Technology Consultant, PCS & IN Development Lab,        Pac*Bell
  54. Voice: (510) 671-1325               UUCP:  dbsuthe@Pacbell.COM
  55. ================================================================================
  56. =  Commit unexpected kindnesses and senseless acts of beauty.                  =
  57. ================================================================================
  58.