1.30.2 upgrade breaks API access

Forum for questions and support relating to the 1.30.x releases only.
kenworth
Posts: 43
Joined: Tue Feb 11, 2014 1:04 pm

1.30.2 upgrade breaks API access

Post by kenworth » Fri Mar 31, 2017 1:37 pm

After upgrading from 1.30.0 to 1.30.2, zmNinja would not function. I could also not access the API from a web browser. Investigating produced log file entries indicating write permission errors in two different directories:

[Fri Mar 31 08:23:53.710944 2017] [:error] [pid 14004] [client 96.9.246.195:54731] PHP Warning: /usr/share/zoneminder/www/api/app/tmp/cache/persistent/ is not writable in /usr/share/zoneminder/www/api/lib/Cake/Cache/Engine/FileEngine.php on line 385

[Fri Mar 31 08:29:53.531507 2017] [:error] [pid 12624] [client 192.168.1.143:54777] PHP Warning: /usr/share/zoneminder/www/api/app/tmp/cache/models/ is not writable in /usr/share/zoneminder/www/api/lib/Cake/Cache/Engine/FileEngine.php on line 385

Further investigation identified that the directories /usr/share/zoneminder/www/api/app/tmp/cache/models and /usr/share/zoneminder/www/api/app/tmp/cache/persistent did not exist. Creating them manually and assigning ownership to apache.apache resolved the issue.

kenworth
Posts: 43
Joined: Tue Feb 11, 2014 1:04 pm

Re: 1.30.2 upgrade breaks API access

Post by kenworth » Fri Mar 31, 2017 1:44 pm

Just noticed there is already a pull request for this on Github.

User avatar
knight-of-ni
Posts: 2079
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: 1.30.2 upgrade breaks API access

Post by knight-of-ni » Fri Mar 31, 2017 3:08 pm

This is being handled automatically in the packaging scripts, so you need to state what distro you are using and how you installed zoneminder.
This will tell us where the problem is coming from.
Visit my blog for ZoneMinder related projects using the Raspberry Pi, Orange Pi, Odroid, and the ESP8266
All of these can be found at https://zoneminder.blogspot.com/

kenworth
Posts: 43
Joined: Tue Feb 11, 2014 1:04 pm

Re: 1.30.2 upgrade breaks API access

Post by kenworth » Fri Mar 31, 2017 3:40 pm

I'm on Fedora 24 and updated from zmrepo using dnf. I then followed the upgrade instructions in the readme.Fedora file. That process worked without problems, and the standard web interface worked fine. It was only when I tried to access the API directly that I had a problem.

User avatar
knight-of-ni
Posts: 2079
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: 1.30.2 upgrade breaks API access

Post by knight-of-ni » Fri Mar 31, 2017 5:22 pm

kenworth wrote:I'm on Fedora 24 and updated from zmrepo using dnf. I then followed the upgrade instructions in the readme.Fedora file. That process worked without problems, and the standard web interface worked fine. It was only when I tried to access the API directly that I had a problem.
Please post the output of the following commands:

Code: Select all

ls -lh /usr/lib/tmpfiles.d
And

Code: Select all

cat /usr/lib/tmpfiles.d/zoneminder.conf
Visit my blog for ZoneMinder related projects using the Raspberry Pi, Orange Pi, Odroid, and the ESP8266
All of these can be found at https://zoneminder.blogspot.com/

kenworth
Posts: 43
Joined: Tue Feb 11, 2014 1:04 pm

Re: 1.30.2 upgrade breaks API access

Post by kenworth » Fri Mar 31, 2017 6:24 pm

Here you go....

ls -lh /usr/lib/tmpfiles.d
total 192K
-rw-r--r-- 1 root root 91 Jul 18 2016 abrt.conf
-rw-r--r-- 1 root root 78 Nov 22 03:33 colord.conf
-rw-r--r-- 1 root root 125 Jan 11 11:26 cups.conf
-rw-r--r-- 1 root root 264 Jan 11 11:26 cups-lp.conf
-rw-r--r-- 1 root root 164 Aug 18 2016 dnf.conf
-rw-r--r-- 1 root root 40 Feb 27 05:04 dovecot.conf
-rw-r--r-- 1 root root 515 Feb 7 08:05 etc.conf
-rw-r--r-- 1 root root 362 Feb 7 08:05 home.conf
-rw-r--r-- 1 root root 61 Jan 13 03:00 hplip.conf
-rw-r--r-- 1 root root 77 Dec 22 10:27 httpd.conf
-rw-r--r-- 1 root root 39 Feb 3 2016 initscripts.conf
-rw-r--r-- 1 root root 75 Feb 19 2016 iscsi.conf
-rw-r--r-- 1 root root 1.1K Feb 7 08:05 journal-nocow.conf
-rw-r--r-- 1 root root 68 Nov 8 2012 kdm.conf
-rw-r--r-- 1 root root 841 Feb 7 08:05 legacy.conf
-rw-r--r-- 1 root root 36 Sep 22 2016 libgpod.conf
-rw-r--r-- 1 root root 29 Jan 15 18:29 libreswan.conf
-rw-r--r-- 1 root root 34 Nov 22 16:41 libselinux.conf
-rw-r--r-- 1 root root 39 Jan 4 08:17 lirc.conf
-rw-r--r-- 1 root root 70 Apr 6 2016 lockdev.conf
-r--r--r-- 1 root root 61 Jun 13 2016 lvm2.conf
-rw-r--r-- 1 root root 34 Mar 15 2016 man-db.conf
-rw-r--r-- 1 root root 162 Feb 15 19:08 mariadb.conf
-rw-r--r-- 1 root root 34 Aug 12 2016 mdadm.conf
-rw-r--r-- 1 root root 34 Nov 16 08:14 openssh.conf
-rw-r--r-- 1 root root 39 Dec 7 09:16 openvpn.conf
-rw-r--r-- 1 root root 110 Feb 5 2016 pam.conf
-rw-r--r-- 1 root root 39 Sep 28 2016 pesign.conf
-rw-r--r-- 1 root root 57 Feb 4 2016 ppp.conf
-rw-r--r-- 1 root root 21 Dec 2 11:09 pptp.conf
-rw-r--r-- 1 root root 87 Jan 28 15:58 rpcbind.conf
-rw-r--r-- 1 root root 22 Feb 24 08:45 rpm.conf
-rw-r--r-- 1 root root 60 Mar 1 07:28 samba.conf
-rw-r--r-- 1 root root 72 Mar 1 10:15 screen.conf
-rw-r--r-- 1 root root 33 Mar 11 2016 sddm.conf
-rw-r--r-- 1 root root 137 Jan 9 08:29 selinux-policy.conf
-rw-r--r-- 1 root root 58 Aug 31 2016 setroubleshoot.conf
-rw-r--r-- 1 root root 101 Feb 5 2016 spice-vdagentd.conf
-rw-r--r-- 1 root root 313 Nov 8 08:29 sudo.conf
-rw-r--r-- 1 root root 33 May 26 2016 svnserve.conf
-rw-r--r-- 1 root root 1.7K Feb 7 08:05 systemd.conf
-rw-r--r-- 1 root root 496 Feb 7 08:05 systemd-nologin.conf
-rw-r--r-- 1 root root 981 Feb 7 08:05 systemd-nspawn.conf
-rw-r--r-- 1 root root 638 Feb 7 08:05 tmp.conf
-rw-r--r-- 1 root root 532 Feb 7 08:05 var.conf
-rw-r--r-- 1 root root 623 Feb 7 08:05 x11.conf
-rw-r--r-- 1 root root 35 Jan 15 13:06 xl2tpd.conf
-rw-r--r-- 1 root root 375 Mar 30 19:58 zoneminder.conf


cat /usr/lib/tmpfiles.d/zoneminder.conf
D /var/lib/zoneminder/temp 0755 apache apache
D /var/lib/zoneminder/temp/logs 0755 apache apache
D /var/lib/zoneminder/temp/cache 0755 apache apache
D /var/lib/zoneminder/temp/cache/models 0755 apache apache
D /var/lib/zoneminder/temp/cache/persistent 0755 apache apache
D /var/lib/zoneminder/temp/cache/views 0755 apache apache
D /var/lib/zoneminder/sock 0755 apache apache

User avatar
knight-of-ni
Posts: 2079
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: 1.30.2 upgrade breaks API access

Post by knight-of-ni » Fri Mar 31, 2017 6:29 pm

wow, you got lots of stuff.

Okay, that verifies the tmpfile config got updated.

Few more easy things to check:
1) make sure all those folders under /var/lib/zoneminder/temp/ exist and are owned by apache
2) make sure the following symlink exists and it looks like this:

Code: Select all

$ ls -lh /usr/share/zoneminder/www/api/app/tmp
lrwxrwxrwx 1 root root 41 Mar 30 18:48 /usr/share/zoneminder/www/api/app/tmp -> ../../../../../../var/lib/zoneminder/temp
if 1=no and 2=yes, then reboot and check again.

If a reboot causes the folders to appear, then I know how to fix this so a reboot is not required.
Visit my blog for ZoneMinder related projects using the Raspberry Pi, Orange Pi, Odroid, and the ESP8266
All of these can be found at https://zoneminder.blogspot.com/

kenworth
Posts: 43
Joined: Tue Feb 11, 2014 1:04 pm

Re: 1.30.2 upgrade breaks API access

Post by kenworth » Fri Mar 31, 2017 7:40 pm

I should clarify that everything is working now that I manually created the cache directories. When I first encountered the issue, the symlink was in place, but the directory /var/lib/zoneminder/temp/cache did not exist (just the "cache" part...rest of it was there). Once I manually created it, then created the persistent and models directories then the API functioned normally.

I do notice that there is a 3rd directory from the conf file called views. That does not currently exist, but I assume it is probably needed for something? I can go ahead and manually create that as well just in case.

User avatar
knight-of-ni
Posts: 2079
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: 1.30.2 upgrade breaks API access

Post by knight-of-ni » Fri Mar 31, 2017 7:58 pm

But it should happen automatically.

Stop zoneminder, delete all the folders under /var/lib/zoneminder/temp then reboot.
All the folders, including views, should be automatically recreated after a reboot. This is critical information I need to know so I can prevent this from happening to others. I appreciate your help in this matter.
Visit my blog for ZoneMinder related projects using the Raspberry Pi, Orange Pi, Odroid, and the ESP8266
All of these can be found at https://zoneminder.blogspot.com/

User avatar
knight-of-ni
Posts: 2079
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: 1.30.2 upgrade breaks API access

Post by knight-of-ni » Fri Mar 31, 2017 9:45 pm

On my machine, if I delete the subfolders under /var/lib/zoneminder/temp, after a reboot they are all put back correctly.

Alternatively, the command to re-establish the folders, without rebooting, is:

Code: Select all

sudo systemd-tmpfiles --create zoneminder.conf
It's always nice to get feedback this works on someone else's machine, other than my own.

The next time I build a new set of packages for zmrepo, I'll configure the package to create these folders immediately upon installation, so no manual steps or a reboot will be required.
Visit my blog for ZoneMinder related projects using the Raspberry Pi, Orange Pi, Odroid, and the ESP8266
All of these can be found at https://zoneminder.blogspot.com/

kenworth
Posts: 43
Joined: Tue Feb 11, 2014 1:04 pm

Re: 1.30.2 upgrade breaks API access

Post by kenworth » Sat Apr 01, 2017 12:00 pm

I can confirm both the systemd-tmpfiles command and a reboot create the necessary directory structure.

User avatar
knight-of-ni
Posts: 2079
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: 1.30.2 upgrade breaks API access

Post by knight-of-ni » Sat Apr 01, 2017 12:38 pm

Excellent, thank you for your help.
Visit my blog for ZoneMinder related projects using the Raspberry Pi, Orange Pi, Odroid, and the ESP8266
All of these can be found at https://zoneminder.blogspot.com/

McFuzz
Posts: 175
Joined: Tue Aug 28, 2012 7:03 am

Re: 1.30.2 upgrade breaks API access

Post by McFuzz » Sat Apr 08, 2017 10:19 am

Hello!

I just upgraded to 1.30.2 on my Ubuntu 14.04.5 LTS box and am also experiencing a malfunctioning API

Code: Select all

[Sat Apr 08 03:11:07.021860 2017] [:error] [pid 1719] [client 10.32.1.131:64516] PHP Warning:  _cake_core_ cache was unable to write 'cake_dev_en-us' to File cache in /usr/share/zoneminder/www/api/lib/Cake/Cache/Cache.php on line 328
[Sat Apr 08 03:11:07.021916 2017] [:error] [pid 1719] [client 10.32.1.131:64516] PHP Warning:  /usr/share/zoneminder/www/api/app/tmp/cache/persistent/ is not writable in /usr/share/zoneminder/www/api/lib/Cake/Cache/Engine/FileEngine.php on line 385
[Sat Apr 08 03:11:07.022068 2017] [:error] [pid 1719] [client 10.32.1.131:64516] PHP Fatal error:  Uncaught exception 'CacheException' with message 'Cache engine "_cake_core_" is not properly configured. Ensure required extensions are installed, and credentials/permissions are correct' in /usr/share/zoneminder/www/api/lib/Cake/Cache/Cache.php:186\nStack trace:\n#0 /usr/share/zoneminder/www/api/lib/Cake/Cache/Cache.php(151): Cache::_buildEngine('_cake_core_')\n#1 /usr/share/zoneminder/www/api/app/Config/core.php(376): Cache::config('_cake_core_', Array)\n#2 /usr/share/zoneminder/www/api/lib/Cake/Core/Configure.php(72): include('/usr/share/zone...')\n#3 /usr/share/zoneminder/www/api/lib/Cake/bootstrap.php(431): Configure::bootstrap(true)\n#4 /usr/share/zoneminder/www/api/app/webroot/index.php(90): include('/usr/share/zone...')\n#5 {main}\n  thrown in /usr/share/zoneminder/www/api/lib/Cake/Cache/Cache.php on line 186
Output as requested in earlier posts:

Code: Select all

ls -lh /usr/lib/tmpfiles.d
total 16K
-rw-r--r-- 1 root root 30 Mar 28 08:40 samba.conf
-rw-r--r-- 1 root root 31 May  2  2014 sshd.conf
-rw-r--r-- 1 root root 30 Apr 18  2013 xconsole.conf
-rw-r--r-- 1 root root 74 Mar 31 07:41 zoneminder.conf

Code: Select all

cat /usr/lib/tmpfiles.d/zoneminder.conf
d /var/run/zm 0755 www-data www-data
d /tmp/zm     0755 www-data www-data

Note that /var/run/zm and /tmp/zm both exist... howevever /usr/share/zoneminder/www/api/app/tmp/cache/persistent/ and ../tmp/cache/models did not.

So I manually created those - and provided proper permissions, however it appears the folders do not survive a reboot AND even if they are connected, I get the red bar of death when hitting server/zm/api :( I do not use systemd on my end.


Any ideas?

Thanks!
Last edited by McFuzz on Sat Apr 08, 2017 10:25 am, edited 2 times in total.

adot
Posts: 1
Joined: Sat Apr 08, 2017 10:06 am

Re: 1.30.2 upgrade breaks API access

Post by adot » Sat Apr 08, 2017 10:20 am

Hi all,

I do have the same problem, but on Ubuntu 14.04.5 server. Unfortunately this approach does not work for me :(

This my output:

~/devel$ ls -lh /usr/lib/tmpfiles.d
insgesamt 20K
-rw-r--r-- 1 root root 595 Aug 26 2015 gvfsd-fuse-tmpfiles.conf
-rw-r--r-- 1 root root 30 Mär 28 17:40 samba.conf
-rw-r--r-- 1 root root 31 Mai 2 2014 sshd.conf
-rw-r--r-- 1 root root 30 Apr 18 2013 xconsole.conf
-rw-r--r-- 1 root root 74 Mär 31 16:41 zoneminder.conf

~/devel$ cat /usr/lib/tmpfiles.d/zoneminder.conf
d /var/run/zm 0755 www-data www-data
d /tmp/zm 0755 www-data www-data

~/devel$ ls -lh /usr/share/zoneminder/www/api/app/tmp
lrwxrwxrwx 1 root root 7 Okt 14 2015 /usr/share/zoneminder/www/api/app/tmp -> /tmp/zm

adding folders manually in /usr/share/zoneminder/temp did not work and also I am not using systemd. A reboot does not work either.

Any hints?
Prior to the update everything worked fine...

Thanks.
Much appreciated.
A.

McFuzz
Posts: 175
Joined: Tue Aug 28, 2012 7:03 am

Re: 1.30.2 upgrade breaks API access

Post by McFuzz » Sat Apr 08, 2017 10:24 am

Wow - we both posted the same issue at the same time!

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests