From: Galen Charlton Date: Tue, 24 Mar 2015 21:00:57 +0000 (+0000) Subject: LP#1436047: make srfsh --safe act as if "! command" doesn't exist X-Git-Tag: osrf_rel_2_4_1~9^2~1 X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=42f14c919d82abbf5927775b933ff8c5d4070d2e;p=OpenSRF.git LP#1436047: make srfsh --safe act as if "! command" doesn't exist This patch make srfsh treat attempting to run an external command via "! command" as a parsing error if --safe is supplied. It also suppress mention of "! commands" from the internal help. Signed-off-by: Galen Charlton Signed-off-by: Mike Rylander --- diff --git a/src/srfsh/srfsh.c b/src/srfsh/srfsh.c index aed9536..753180b 100644 --- a/src/srfsh/srfsh.c +++ b/src/srfsh/srfsh.c @@ -376,8 +376,10 @@ static int process_request( const char* request ) { ret_val = handle_close( cmd_array ); else if ( request[0] == '!') { - if (!no_bang) system( request + 1 ); - ret_val = 1; + if (!no_bang) { + system( request + 1 ); + ret_val = 1; + } } osrfStringArrayFree( cmd_array ); @@ -985,8 +987,12 @@ static int print_help( void ) { "---------------------------------------------------------------------------------\n" "General commands:\n" "---------------------------------------------------------------------------------\n" - "help - Display this message\n" - "! [args] - Forks and runs the given command in the shell\n" + "help - Display this message\n", + stdout ); + if (!no_bang) fputs( + "! [args] - Forks and runs the given command in the shell\n", + stdout ); + fputs( /* "time - Prints the current time\n" "time - Formats seconds since epoch into readable format\n"