Updated to 1.24.4; control of Axis cameras stopped working

Forum for questions and support relating to the 1.24.x releases only.
Post Reply
MichaelTiemann
Posts: 18
Joined: Wed Apr 20, 2011 1:04 am

Updated to 1.24.4; control of Axis cameras stopped working

Post by MichaelTiemann » Thu Jun 23, 2011 9:58 am

I tried my first live update from 1.24.3 to 1.24.4 and had two problems. The first was that I had to re-apply the following patch discovered some months ago in zmtrigger:

Code: Select all

diff zmtrigger.pl~ zmtrigger.pl
53,54c53,54
< use ZoneMinder::Trigger::Channel::Unix;
< use ZoneMinder::Trigger::Channel::Serial;
---
> #CUA use ZoneMinder::Trigger::Channel::Unix;
> #CUA use ZoneMinder::Trigger::Channel::Serial;
59c59
< push( @connections, ZoneMinder::Trigger::Connection->new( name=>"Chan2", channel=>ZoneMinder::Trigger::Channel::Unix->new( path=>ZM_PATH_SOCKS.'/zmtrigger.sock' ), mode=>"rw" ) );
---
> #CUA push( @connections, ZoneMinder::Trigger::Connection->new( name=>"Chan2", channel=>ZoneMinder::Trigger::Channel::Unix->new( path=>ZM_PATH_SOCKS.'/zmtrigger.sock' ), mode=>"rw" ) );
61c61
< push( @connections, ZoneMinder::Trigger::Connection->new( name=>"Chan4", channel=>ZoneMinder::Trigger::Channel::Serial->new( path=>'/dev/ttyS0' ), mode=>"rw" ) );
---
> #CUA push( @connections, ZoneMinder::Trigger::Connection->new( name=>"Chan4", channel=>ZoneMinder::Trigger::Channel::Serial->new( path=>'/dev/ttyS0' ), mode=>"rw" ) );
337a338,345
> 	#  CUA  - Axis camera send the message quoted with"
> 	#  CUA  - Also Axis camera cannot save the plus sign which
> 	#  CUA  - possibly exists in the 1|on+20|score|cause|text|showtext formatted msg
> 	$message=~ s/^\"//g;
> 	$message=~ s/\"$//g;
> 	$message=~ s/on /on\+/;
> 	#  CUA - end of modifications
> 
The second is that I used to be able to control my Axis cameras using the V2 api monitor setting, but now I seem to have no control. Moreover, I don't see any info in the logs (not even with Debug = 9) to show what command is being sent to the cameras (if any).

I am running with selinux enabled, with a policy that was working for me under version 1.24.3. Anybody else make the switch and had success? Failure?

User avatar
zoneminder
Site Admin
Posts: 5220
Joined: Wed Jul 09, 2003 2:07 pm
Location: Bristol, UK
Contact:

Re: Updated to 1.24.4; control of Axis cameras stopped worki

Post by zoneminder » Thu Jun 23, 2011 10:25 am

Can you tell me your o/s and version of php?
Phil

MichaelTiemann
Posts: 18
Joined: Wed Apr 20, 2011 1:04 am

Re: Updated to 1.24.4; control of Axis cameras stopped worki

Post by MichaelTiemann » Fri Jun 24, 2011 12:40 am

$ uname -a
Linux bbsvr 2.6.32-131.4.1.el6.x86_64 #1 SMP Fri Jun 10 10:54:26 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux
$ yum info php
Loaded plugins: refresh-packagekit, rhnplugin
*Note* Red Hat Network repositories are not listed below. You must run this command as root to access RHN repositories.
Installed Packages
Name : php
Arch : x86_64
Version : 5.3.3
Release : 3.el6
Size : 3.5 M
Repo : installed
From repo : rhel-x86_64-server-6
[...]

timcraig
Posts: 195
Joined: Mon Dec 10, 2007 5:53 pm
Location: San Jose, CA
Contact:

Re: Updated to 1.24.4; control of Axis cameras stopped worki

Post by timcraig » Fri Jun 24, 2011 6:26 am

The controls to my AirLink 747W died in Zoneminder after a recent update to 1.24.4 as well.

I manually entered debugging statements in the perl scripts and I found that zmcontrol.pl silently dies (couldn't find any error messages anywhere) when the script reaches General.pm at the line "my $result = eval $out;". It looks like the change from using PHP:Serialization to using Json encoding/decode broke the zmcontrol.pl script on my system.


I see there was is Zoneminder 1.25 update tonight and upgraded to that (on a side note: Make was failing complaining that zm_jpeg.o was missing target zm_jpeg.c. I then did "cp zm_jpeg.cpp zm_jpeg.c" and make then complied). The controls don't work in Zoneminder 1.25 either.


I'm using Zoneminder on 64-bit Arch Linux (with latest updates).
The command "perl -v" on my system prints

Code: Select all

This is perl 5, version 12, subversion 3 (v5.12.3) built for x86_64-linux-thread-multi
From "php -v":

Code: Select all

PHP 5.3.6 with Suhosin-Patch (cli) (built: Jun  1 2011 11:57:13) 
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies

User avatar
zoneminder
Site Admin
Posts: 5220
Joined: Wed Jul 09, 2003 2:07 pm
Location: Bristol, UK
Contact:

Re: Updated to 1.24.4; control of Axis cameras stopped worki

Post by zoneminder » Fri Jun 24, 2011 8:44 am

Ok, I think I have made progress on this issue. It's a long story but not all versions of PHP come with json handling functions and perl might have several or none depending on what modules are installed. I think in the cases where it fails it is because perl can't find any module JSON functions are so are using the ZM custom ones as a backup. It seemed there was a problem with the taintedness of the decode string which was not reported because the standard output and error were closed.

There are two solutions to this. If possible please try the first so I can confirm it works for others, you can then do the second which might make things more robust in the future.
1) Apply this patch

Code: Select all

--- ZoneMinder/lib/ZoneMinder/General.pm        (revision 3460)
+++ ZoneMinder/lib/ZoneMinder/General.pm        (working copy)
@@ -301,7 +301,6 @@
     };
     $testedJSON = 1;
     $hasJSONAny = 1 if ( $result );
-
 }

 sub _getJSONType( $ )
@@ -329,7 +328,6 @@
         return( $string );
     }

-
     my $type = _getJSONType($value);
     if ( $type eq 'integer' || $type eq 'double' )
     {
@@ -426,6 +424,7 @@
     $out =~ s/=>true/=>1/g;
     $out =~ s/=>false/=>0/g;
     $out =~ s/=>null/=>undef/g;
+    ( $out ) = $out =~ m/^({.+})$/; # Detaint and check it's a valid object syntax
     my $result = eval $out;
     Fatal( $@ ) if ( $@ );
     return( $result );
and then restart your system. This should fix the problem directly.
2) Install the perl JSON::Any module. This will provide a common interface to other perl JSON modules. You may find that installing it also installs at least one other actual JSON processor but if not then also install the baseJSON module or the JSON::XS one which will be a bit quicker.

Please let me know how you get on with these and if successful I will update the packages.

On the point about the missing zm_jpeg.c file, this is a side effect of how the automake calculates file dependencies which doesn't seem to handle files changing from .c to .cpp (or vice versa). I would not recommend renaming files yourself and the simplest way I have found to address it is to delete the .deps directory under src and then rerun configure and make etc. As a general rule, I would also suggest building new versions in their own directory and not necessarily on top of previous ones, though normally this shouldn't cause too many issues.
Phil

timcraig
Posts: 195
Joined: Mon Dec 10, 2007 5:53 pm
Location: San Jose, CA
Contact:

Re: Updated to 1.24.4; control of Axis cameras stopped worki

Post by timcraig » Fri Jun 24, 2011 10:59 am

Hi Phil,

I installed JSON::ANY through the cpan before I saw your post. The ptz controls are working now.

I didn't get a chance to try your patch on a system without JSON::ANY installed. :(



Thanks for the .dep advice, that fixed the issue. I keep a working copy of the Zoneminder SVN repo that has a few patches I made. When ever there's an update to the SVN, I do a "make clean", "svn revert <to files I didn't change but show up as modified>". Then "svn update" then rebuild and install Zoneminder. I'll clear out any unrevisioned files that I didn't create next time.

Thanks!
Last edited by timcraig on Fri Jun 24, 2011 5:40 pm, edited 1 time in total.

MichaelTiemann
Posts: 18
Joined: Wed Apr 20, 2011 1:04 am

Re: Updated to 1.24.4; control of Axis cameras stopped worki

Post by MichaelTiemann » Fri Jun 24, 2011 12:55 pm

zoneminder wrote:Ok, I think I have made progress on this issue. It's a long story but not all versions of PHP come with json handling functions and perl might have several or none depending on what modules are installed. I think in the cases where it fails it is because perl can't find any module JSON functions are so are using the ZM custom ones as a backup. It seemed there was a problem with the taintedness of the decode string which was not reported because the standard output and error were closed.

There are two solutions to this. If possible please try the first so I can confirm it works for others, you can then do the second which might make things more robust in the future.
1) Apply this patch

Code: Select all

--- ZoneMinder/lib/ZoneMinder/General.pm        (revision 3460)
+++ ZoneMinder/lib/ZoneMinder/General.pm        (working copy)
@@ -301,7 +301,6 @@
     };
     $testedJSON = 1;
     $hasJSONAny = 1 if ( $result );
-
 }

 sub _getJSONType( $ )
@@ -329,7 +328,6 @@
         return( $string );
     }

-
     my $type = _getJSONType($value);
     if ( $type eq 'integer' || $type eq 'double' )
     {
@@ -426,6 +424,7 @@
     $out =~ s/=>true/=>1/g;
     $out =~ s/=>false/=>0/g;
     $out =~ s/=>null/=>undef/g;
+    ( $out ) = $out =~ m/^({.+})$/; # Detaint and check it's a valid object syntax
     my $result = eval $out;
     Fatal( $@ ) if ( $@ );
     return( $result );
and then restart your system. This should fix the problem directly.
2) Install the perl JSON::Any module. This will provide a common interface to other perl JSON modules. You may find that installing it also installs at least one other actual JSON processor but if not then also install the baseJSON module or the JSON::XS one which will be a bit quicker.

Please let me know how you get on with these and if successful I will update the packages.
I tried method #1 (the patch) and it worked. Thanks so much!

windracer
Posts: 61
Joined: Sat Jul 23, 2011 1:15 am

Re: Updated to 1.24.4; control of Axis cameras stopped worki

Post by windracer » Sat Jul 23, 2011 1:59 am

Why didn't I search these forums first? That'll teach me! :D

I'm pretty new to ZM but had everything working with my TrendNET and Foscam cams. I decided to try and get PTZ working on the TV-IP422W using Setarcos' AirLink driver but wasn't having any luck.

After much of my own manual debugging, I had it narrowed down to the jsonDecode line but wasn't able to get any further. Then I found this thread, applied the patch and installed libjson-any-perl on my Ubuntu 11.04 box and wallah, PTZ started working!

Thanks!!

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests