From 1d3fd053d4f76633567e321528b894ed1f727b73 Mon Sep 17 00:00:00 2001 From: Michael Larson Date: Tue, 9 Nov 2010 17:28:47 -0800 Subject: make commit aware of error location key and allow for passthrough. --- lib/Vyatta/Config.pm | 8 +++---- src/commit2.c | 63 ++++++++++++++++++++++++++++------------------------ 2 files changed, 38 insertions(+), 33 deletions(-) diff --git a/lib/Vyatta/Config.pm b/lib/Vyatta/Config.pm index e8fda29..5283b06 100755 --- a/lib/Vyatta/Config.pm +++ b/lib/Vyatta/Config.pm @@ -676,13 +676,13 @@ sub compareValueLists { return %comp_hash; } + sub outputError { my ($location, $msg) = @_; - print STDERR $msg . "\n"; if (defined($ENV{VYATTA_OUTPUT_ERROR_LOCATION})) { - foreach my $elem (@$location) { - print STDERR "errloc:[" . $elem . "]\n"; - } + foreach my $elem (@$location) { + print STDERR "_errloc_:[" . $elem . "]\n" . $msg . "\n"; + } } } diff --git a/src/commit2.c b/src/commit2.c index 2f9be94..92f37ed 100644 --- a/src/commit2.c +++ b/src/commit2.c @@ -564,36 +564,41 @@ process_func(GNode *node, gpointer data) status = execute_list(c->_def.actions[result->_action].vtw_list_head,&c->_def,NULL); } if (!status && g_print_error_location_all == TRUE) { //EXECUTE_LIST RETURNS FALSE ON FAILURE.... - //just need to convert slashes into spaces here - char path_buf[1024]; - char tmp[1024]; - char *ptr; - path_buf[0] = '\0'; - - strcpy(tmp,d->_path); - ptr = (char*)tmp; - char *slash = strchr(tmp,'/'); - if (slash == NULL) { - strcat(path_buf,d->_path); + if (strstr(outbuf,"_errloc_:[") != NULL) { + fprintf(out_stream,"%s\n",outbuf); } else { - do { //convert '/' to ' ' - strncat(path_buf,ptr,slash - ptr); - strcat(path_buf," "); - ++slash; - ptr = slash; - } while ((slash = strchr(slash,'/')) != NULL); - } - if (strncmp(ptr,"value:",6) == 0) { - if (strlen(ptr)-6 > 0) { - strncat(path_buf,ptr+6,strlen(ptr)-6); + //just need to convert slashes into spaces here + char path_buf[1024]; + char tmp[1024]; + char *ptr; + path_buf[0] = '\0'; + + strcpy(tmp,d->_path); + ptr = (char*)tmp; + char *slash = strchr(tmp,'/'); + if (slash == NULL) { + strcat(path_buf,d->_path); + } + else { + do { //convert '/' to ' ' + strncat(path_buf,ptr,slash - ptr); + strcat(path_buf," "); + ++slash; + ptr = slash; + } while ((slash = strchr(slash,'/')) != NULL); + } + if (strncmp(ptr,"value:",6) == 0) { + if (strlen(ptr)-6 > 0) { + strncat(path_buf,ptr+6,strlen(ptr)-6); + } + } + char *p = clind_unescape(path_buf); + + if (strlen(outbuf) > 0) { + //currently set to format option for GUI client. + fprintf(out_stream,"_errloc_:[%s]\n%s\n",p,outbuf); } - } - char *p = clind_unescape(path_buf); - - if (strlen(outbuf) > 0) { - //currently set to format option for GUI client. - fprintf(out_stream,"_errloc_:[%s]\n%s\n",p,outbuf); } } } @@ -624,7 +629,7 @@ process_func(GNode *node, gpointer data) if (!status) { //EXECUTE_LIST RETURNS FALSE ON FAILURE.... syslog(LOG_ERR,"commit error for %s:[%s]\n",ActionNames[result->_action],d->_path); if (g_display_error_node) { - fprintf(out_stream,"%s@errloc:[%s]\n",ActionNames[result->_action],d->_path); + fprintf(out_stream,"%s@_errloc_:[%s]\n",ActionNames[result->_action],d->_path); } result->_err_code = 1; if (g_debug) { @@ -1473,7 +1478,7 @@ validate_func(GNode *node, gpointer data) } syslog(LOG_ERR,"commit error for %s:[%s]\n",ActionNames[result->_action],d->_path); if (g_display_error_node) { - fprintf(out_stream,"%s@errloc:[%s]\n",ActionNames[result->_action],d->_path); + fprintf(out_stream,"%s@_errloc_:[%s]\n",ActionNames[result->_action],d->_path); } result->_err_code = 1; if (g_debug) { -- cgit v1.2.3 From cd5ff95c1a39e73a740c3f8cba2fe8d3215bd24b Mon Sep 17 00:00:00 2001 From: Michael Larson Date: Tue, 9 Nov 2010 17:29:59 -0800 Subject: 0.18.8 --- debian/changelog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/debian/changelog b/debian/changelog index 30f814f..568bd85 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +vyatta-cfg (0.18.8) unstable; urgency=low + + * make commit aware of error location key and allow for passthrough. + + -- Michael Larson Tue, 09 Nov 2010 17:29:59 -0800 + vyatta-cfg (0.18.7) unstable; urgency=low [ Michael Larson ] -- cgit v1.2.3 From e146bb9a234e45125e8237ca4c099cb18bd2459e Mon Sep 17 00:00:00 2001 From: Michael Larson Date: Tue, 9 Nov 2010 18:00:52 -0800 Subject: additional change in support of error location. --- lib/Vyatta/Config.pm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/Vyatta/Config.pm b/lib/Vyatta/Config.pm index 5283b06..28326dd 100755 --- a/lib/Vyatta/Config.pm +++ b/lib/Vyatta/Config.pm @@ -684,6 +684,9 @@ sub outputError { print STDERR "_errloc_:[" . $elem . "]\n" . $msg . "\n"; } } + else { + print STDERR $msg . "\n"; + } } ############################################################ -- cgit v1.2.3 From b63ee9b6c597397f5c80a0b161a8638977f469cc Mon Sep 17 00:00:00 2001 From: Michael Larson Date: Tue, 9 Nov 2010 18:01:32 -0800 Subject: 0.18.9 --- debian/changelog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/debian/changelog b/debian/changelog index 568bd85..7efa6d9 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +vyatta-cfg (0.18.9) unstable; urgency=low + + * additional change in support of error location. + + -- Michael Larson Tue, 09 Nov 2010 18:01:31 -0800 + vyatta-cfg (0.18.8) unstable; urgency=low * make commit aware of error location key and allow for passthrough. -- cgit v1.2.3