[v2,5/5] nodewatcher: Exit nodewatcher if subscript fails

Submitted by Fabian Blaese on April 22, 2020, 2:05 p.m.

Details

Message ID 20200422140527.894934-5-fabian@blaese.de
State Accepted
Headers show

Commit Message

Fabian Blaese April 22, 2020, 2:05 p.m.
If a subscript exits with an exit status != 0, its output should not
be used. Because sending incomplete data sets might result in weird
edge cases, the nodewatcher is terminated and the output of other
subscripts is discarded.

Signed-off-by: Fabian Bläse <fabian@blaese.de>
---
Changes in v2:
- 'exit 1' instead of 'continue'
---
 src/packages/fff/fff-nodewatcher/files/usr/sbin/nodewatcher | 4 ++++
 1 file changed, 4 insertions(+)

Patch hide | download patch | download mbox

diff --git a/src/packages/fff/fff-nodewatcher/files/usr/sbin/nodewatcher b/src/packages/fff/fff-nodewatcher/files/usr/sbin/nodewatcher
index 8b55656..26710b3 100755
--- a/src/packages/fff/fff-nodewatcher/files/usr/sbin/nodewatcher
+++ b/src/packages/fff/fff-nodewatcher/files/usr/sbin/nodewatcher
@@ -29,6 +29,10 @@  crawl() {
 
 	for f in /usr/lib/nodewatcher.d/*.sh; do
 		tmp="$($f)"
+		if [ $? -ne 0 ]; then
+			debug "Error when executing subscript $1, exiting!"
+			exit 1
+		fi
 		DATA="$DATA$tmp"
 	done
 

Comments

Adrian Schmutzler April 22, 2020, 2:43 p.m.
Hi,

Acked-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>

Ein Fehler siehe unten.

> -----Original Message-----
> From: franken-dev [mailto:franken-dev-bounces@freifunk.net] On Behalf
> Of Fabian Bläse
> Sent: Mittwoch, 22. April 2020 16:05
> To: franken-dev@freifunk.net
> Subject: [PATCH v2 5/5] nodewatcher: Exit nodewatcher if subscript fails
> 
> If a subscript exits with an exit status != 0, its output should not be used.
> Because sending incomplete data sets might result in weird edge cases, the
> nodewatcher is terminated and the output of other subscripts is discarded.
> 
> Signed-off-by: Fabian Bläse <fabian@blaese.de>
> ---
> Changes in v2:
> - 'exit 1' instead of 'continue'
> ---
>  src/packages/fff/fff-nodewatcher/files/usr/sbin/nodewatcher | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/src/packages/fff/fff-nodewatcher/files/usr/sbin/nodewatcher
> b/src/packages/fff/fff-nodewatcher/files/usr/sbin/nodewatcher
> index 8b55656..26710b3 100755
> --- a/src/packages/fff/fff-nodewatcher/files/usr/sbin/nodewatcher
> +++ b/src/packages/fff/fff-nodewatcher/files/usr/sbin/nodewatcher
> @@ -29,6 +29,10 @@ crawl() {
> 
>  	for f in /usr/lib/nodewatcher.d/*.sh; do
>  		tmp="$($f)"
> +		if [ $? -ne 0 ]; then
> +			debug "Error when executing subscript $1, exiting!"

$f statt $1?

Grüße

Adrian

> +			exit 1
> +		fi
>  		DATA="$DATA$tmp"
>  	done
> 
> --
> 2.26.2
Fabian Blaese April 22, 2020, 3:12 p.m.
On 22.04.20 16:43, mail@adrianschmutzler.de wrote:
>> diff --git a/src/packages/fff/fff-nodewatcher/files/usr/sbin/nodewatcher
>> b/src/packages/fff/fff-nodewatcher/files/usr/sbin/nodewatcher
>> index 8b55656..26710b3 100755
>> --- a/src/packages/fff/fff-nodewatcher/files/usr/sbin/nodewatcher
>> +++ b/src/packages/fff/fff-nodewatcher/files/usr/sbin/nodewatcher
>> @@ -29,6 +29,10 @@ crawl() {
>>
>>  	for f in /usr/lib/nodewatcher.d/*.sh; do
>>  		tmp="$($f)"
>> +		if [ $? -ne 0 ]; then
>> +			debug "Error when executing subscript $1, exiting!"
> 
> $f statt $1?
ja. :-(

Gruß
Fabian