[6/7] pakfire.cgi: Discard tac stderr output

Message ID 20220508120952.52-6-hofmann@leo-andres.de
State Accepted
Commit 3706e0a5b34f65baa7b6bfaad38ac6bd0496d50c
Headers
Series [1/7] pakfire.cgi: Separate command processing and HTML generation |

Commit Message

Leo-Andres Hofmann May 8, 2022, 12:09 p.m. UTC
  Prevents meaningless "broken pipe" messages in the httpd error log.

Signed-off-by: Leo-Andres Hofmann <hofmann@leo-andres.de>
---
 html/cgi-bin/pakfire.cgi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Peter Müller May 8, 2022, 1:12 p.m. UTC | #1
Acked-by: Peter Müller <peter.muelle@ipfire.org>

> Prevents meaningless "broken pipe" messages in the httpd error log.
> 
> Signed-off-by: Leo-Andres Hofmann <hofmann@leo-andres.de>
> ---
>  html/cgi-bin/pakfire.cgi | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/html/cgi-bin/pakfire.cgi b/html/cgi-bin/pakfire.cgi
> index 6fade81bd..489b07a6d 100644
> --- a/html/cgi-bin/pakfire.cgi
> +++ b/html/cgi-bin/pakfire.cgi
> @@ -75,7 +75,7 @@ if($cgiparams{'ACTION'} eq 'json-getstatus') {
>  
>  	# Read /var/log/messages backwards until a "Pakfire started" header is found,
>  	# to capture all messages of the last (i.e. current) Pakfire run
> -	my @messages = `tac /var/log/messages | sed -n '/pakfire:/{p;/Pakfire.*started/q}'`;
> +	my @messages = `tac /var/log/messages 2>/dev/null | sed -n '/pakfire:/{p;/Pakfire.*started/q}'`;
>  
>  	# Test if the log contains an error message (fastest implementation, stops at first match)
>  	my $failure = any{ index($_, 'ERROR') != -1 } @messages;
  

Patch

diff --git a/html/cgi-bin/pakfire.cgi b/html/cgi-bin/pakfire.cgi
index 6fade81bd..489b07a6d 100644
--- a/html/cgi-bin/pakfire.cgi
+++ b/html/cgi-bin/pakfire.cgi
@@ -75,7 +75,7 @@  if($cgiparams{'ACTION'} eq 'json-getstatus') {
 
 	# Read /var/log/messages backwards until a "Pakfire started" header is found,
 	# to capture all messages of the last (i.e. current) Pakfire run
-	my @messages = `tac /var/log/messages | sed -n '/pakfire:/{p;/Pakfire.*started/q}'`;
+	my @messages = `tac /var/log/messages 2>/dev/null | sed -n '/pakfire:/{p;/Pakfire.*started/q}'`;
 
 	# Test if the log contains an error message (fastest implementation, stops at first match)
 	my $failure = any{ index($_, 'ERROR') != -1 } @messages;