[OpenSRF-GIT] OpenSRF branch rel_2_4 updated. osrf_rel_2_4_0-8-ga8ea746

Evergreen Git git at git.evergreen-ils.org
Wed Jun 3 13:21:00 EDT 2015


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "OpenSRF".

The branch, rel_2_4 has been updated
       via  a8ea7468ed180c7c4cc2da3511a61949312ee5bf (commit)
       via  3e01997ca7dbd6ce87ce227fc8c950e1de5141f9 (commit)
      from  822bc96c0b192375d342cb0d10ea63c3c4427602 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit a8ea7468ed180c7c4cc2da3511a61949312ee5bf
Author: Galen Charlton <gmc at esilibrary.com>
Date:   Tue Mar 24 21:00:57 2015 +0000

    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 <gmc at esilibrary.com>
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

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"
-			"!<command> [args]      - Forks and runs the given command in the shell\n"
+			"help                   - Display this message\n",
+			stdout );
+	if (!no_bang) fputs(
+			"!<command> [args]      - Forks and runs the given command in the shell\n",
+			stdout );
+	fputs(
 		/*
 			"time			- Prints the current time\n"
 			"time <timestamp>	- Formats seconds since epoch into readable format\n"

commit 3e01997ca7dbd6ce87ce227fc8c950e1de5141f9
Author: Mike Rylander <mrylander at gmail.com>
Date:   Tue Mar 24 16:22:16 2015 -0400

    LP#1436047: Allow disabling of "bang commands" in srfsh
    
    srfsh has the ability to execute commands via system() calls using
    the common "!command" syntax.  This is very useful, but it would
    be nice to be able to turn that functionality off in some cases.
    
    This branch adds argument parsing to detect a new '--safe' command
    line parameter, which disables the "!command" syntax.
    
    Signed-off-by: Mike Rylander <mrylander at gmail.com>
    Signed-off-by: Galen Charlton <gmc at esilibrary.com>

diff --git a/src/srfsh/srfsh.c b/src/srfsh/srfsh.c
index 956d62a..aed9536 100644
--- a/src/srfsh/srfsh.c
+++ b/src/srfsh/srfsh.c
@@ -95,6 +95,7 @@ static void close_all_sessions( void );
 
 static int recv_timeout = 120;
 static int is_from_script = 0;
+static int no_bang = 0;
 
 static osrfHash* server_hash = NULL;
 
@@ -120,20 +121,31 @@ int main( int argc, char* argv[] ) {
 	}
 
 	if(argc > 1) {
-		/* for now.. the first arg is used as a script file for processing */
 		int f;
-		if( (f = open(argv[1], O_RDONLY)) == -1 ) {
-			osrfLogError( OSRF_LOG_MARK, "Unable to open file %s for reading, exiting...", argv[1]);
-			return -1;
-		}
+		int i;
+		for (i = 1; i < argc; i++) {
 
-		if(dup2(f, STDIN_FILENO) == -1) {
-			osrfLogError( OSRF_LOG_MARK, "Unable to duplicate STDIN, exiting...");
-			return -1;
-		}
+			if( !strcmp( argv[i], "--safe" ) ) {
+				no_bang = 1;
+				continue;
+			}
 
-		close(f);
-		is_from_script = 1;
+			/* for now.. the first unrecognized arg is used as a script file for processing */
+			if (is_from_script) continue;
+
+			if( (f = open(argv[i], O_RDONLY)) == -1 ) {
+				osrfLogError( OSRF_LOG_MARK, "Unable to open file %s for reading, exiting...", argv[i]);
+				return -1;
+			}
+
+			if(dup2(f, STDIN_FILENO) == -1) {
+				osrfLogError( OSRF_LOG_MARK, "Unable to duplicate STDIN, exiting...");
+				return -1;
+			}
+
+			close(f);
+			is_from_script = 1;
+		}
 	}
 		
 	/* --------------------------------------------- */
@@ -364,7 +376,7 @@ static int process_request( const char* request ) {
 		ret_val = handle_close( cmd_array );
 
 	else if ( request[0] == '!') {
-		system( request + 1 );
+		if (!no_bang) system( request + 1 );
 		ret_val = 1;
 	}
 

-----------------------------------------------------------------------

Summary of changes:
 src/srfsh/srfsh.c |   48 +++++++++++++++++++++++++++++++++---------------
 1 files changed, 33 insertions(+), 15 deletions(-)


hooks/post-receive
-- 
OpenSRF


More information about the opensrf-commits mailing list