54 lines
2.2 KiB
Plaintext
54 lines
2.2 KiB
Plaintext
$NetBSD: patch-scripts_ZoneMinder_lib_ZoneMinder_General_pm,v 1.2 2015/04/05 08:51:08 dsainty Exp $
|
|
|
|
Perl doesn't really support "> /dev/null", so just capture into $output.
|
|
|
|
% ktruss -i perl -e 'qx(does-not-exist >/dev/null 2>&1);'|egrep 'dup2.*2'
|
|
does-not-exist: not found
|
|
% ktruss -i perl -e 'qx(does-not-exist 2>&1);'|egrep 'dup2.*2'
|
|
16954 1 perl dup2(0x1, 0x2) = 2
|
|
|
|
The problem is that, whilst Perl supports 2>&1 internally (and does not use
|
|
the shell at all) if there is no other redirection, it does not support file
|
|
redirection - it defers that (and therefore necessarily must also defer the
|
|
stderr redirection) to the shell. If the system's shell happens to report
|
|
"Not found" errors before redirection is processed (E.g. NetBSD shell) then
|
|
the stderr redirection is happening too late to be captured.
|
|
|
|
That leads to unintended errors reported on stderr - primarily if sudo is not
|
|
installed on the system, or not in the $PATH.
|
|
|
|
Use the -m parameter to su, as ZM_WEB_USER shouldn't require a login shell.
|
|
|
|
--- scripts/ZoneMinder/lib/ZoneMinder/General.pm.orig 2015-04-01 19:40:39.708621257 +1300
|
|
+++ scripts/ZoneMinder/lib/ZoneMinder/General.pm 2015-04-01 19:50:47.372646449 +1300
|
|
@@ -107,7 +107,7 @@
|
|
my $suffix = "";
|
|
my $command = $prefix.$null_command.$suffix;
|
|
Debug( "Testing \"$command\"\n" );
|
|
- $command .= " > /dev/null 2>&1";
|
|
+ $command .= " 2>&1";
|
|
my $output = qx($command);
|
|
my $status = $? >> 8;
|
|
if ( !$status )
|
|
@@ -124,6 +124,7 @@
|
|
$suffix = "'";
|
|
$command = $prefix.$null_command.$suffix;
|
|
Debug( "Testing \"$command\"\n" );
|
|
+ $command .= " 2>&1";
|
|
my $output = qx($command);
|
|
my $status = $? >> 8;
|
|
if ( !$status )
|
|
@@ -136,10 +137,11 @@
|
|
chomp( $output );
|
|
Debug( "Test failed, '$output'\n" );
|
|
|
|
- $prefix = "su ".$Config{ZM_WEB_USER}." -c '";
|
|
+ $prefix = "su -m ".$Config{ZM_WEB_USER}." -c '";
|
|
$suffix = "'";
|
|
$command = $prefix.$null_command.$suffix;
|
|
Debug( "Testing \"$command\"\n" );
|
|
+ $command .= " 2>&1";
|
|
$output = qx($command);
|
|
$status = $? >> 8;
|
|
if ( !$status )
|