[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] Hi, Could you help me to solve a bash problem?
From: |
Greg Wooledge |
Subject: |
Re: [Help-bash] Hi, Could you help me to solve a bash problem? |
Date: |
Wed, 26 Mar 2014 09:12:37 -0400 |
User-agent: |
Mutt/1.4.2.3i |
On Wed, Mar 26, 2014 at 09:27:14AM +0800, MD5Ryan wrote:
> my program need check the command user input, if the command is in the
> white-list, it will run normal, but if it's not i will use my program to
> trace it, like strace. so i wanna know how can i do this? bashrc setting
> works?or i must modify the bash source code? add a function in
> read_command(), then re-compile bash?
You say "my program". And yet you say things that make it sound like the
user is typing these commands into bash, instead of into "your program".
If you just want to prompt the user for a command, read it, filter it,
and then (maybe) run it, then you can do that in a script. Simply write
a loop that prompts, reads, and checks.
However, if your objective is to present a command line interface where
the user is fooled into thinking they are typing in a normal shell,
and yet all their commands are really being filtered by your whitelist,
then I believe you will have to modify bash at the source code level.
The DEBUG trap can't be used for all commands (pipelines in particular
are not caught).