home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.wizards
- Path: sparky!uunet!cs.utexas.edu!sun-barr!ames!pacbell.com!pbhya!dbsuthe
- From: dbsuthe@pbhya.PacBell.COM (Daniel B. Suthers)
- Subject: Re: Changing "pg" options
- Reply-To: dbsuthe@PacBell.COM (Daniel B. Suthers)
- Organization: Pacific * Bell, San Ramon, CA
- Distribution: usa
- Date: Wed, 26 Aug 1992 17:34:46 GMT
- Message-ID: <1992Aug26.173446.11983@pbhya.PacBell.COM>
- References: <1992Aug25.190239.19142@cbfsb.cb.att.com>
- Lines: 45
-
- In article <1992Aug25.190239.19142@cbfsb.cb.att.com> rajeev@cbnewsf.cb.att.com (rajeev.dolas) writes:
- >
- >
- >Howdy all,
- >
- > I am trying to find out if there is a way of turning the "!"
- > option off from pg. Here is something similar to what I am
- > trying to do:
- >
- > main()
- > {
- > char t[25];
- >
- > strcpy(t, "pg $HOME/.profile\n");
- > system(t);
- > }
- >
- > While running this program I don't want the !<command> option
- > to be available to the user.
- >
- > Is there a simple way of doing this? I don't want to reinvent the
- > wheel and write my own pg (if possible).
-
- In the past, I had good results by simply removing the environment variable
- SHELL. This caused PG to issue an error message when the escape was attempted.
-
- If you really want to be safer (not necessarily safe, but safer) add the
- following:
- Fork a new process. In the new process:
- Set SHELL to NULL and PATH to one you want them to use.
- In the forked process, set the effective uid to the real uid (if
- applicable)
- Exec() the program instead of using system().
- (Use the explicit path name in the exec call)
- In the parent process, wait for the child to die.
-
- This should be fairly safe when even if using setuid. Others may correct me,
- so wait a few days before coding. :)
-
- Daniel B. Suthers, CCP
- Technology Consultant, PCS & IN Development Lab, Pac*Bell
- Voice: (510) 671-1325 UUCP: dbsuthe@Pacbell.COM
- ================================================================================
- = Commit unexpected kindnesses and senseless acts of beauty. =
- ================================================================================
-