zms cgi unstable

Support and queries relating to all previous versions of ZoneMinder
Locked
User avatar
Leandro
Posts: 4
Joined: Sun Feb 05, 2006 3:02 pm
Location: Bauru, SP, Brazil
Contact:

zms cgi unstable

Post by Leandro »

Slackware 10.2
gcc: 3.3.4
php 5.1.2
mysql 4.1.14
perl 5.8.4
apache 2.0.55
libavcodec: 51.1.0

scanpci

Pci bus 0x0003 cardnum 0x00 function 0x00: vendor 0x109e device 0x036e
Brooktree Corporation Bt878 Video Capture
STATUS 0x0290 COMMAND 0x0106
CLASS 0x04 0x00 0x00 REVISION 0x11
BIST 0x00 HEADER 0x80 LATENCY 0x20 CACHE 0x00
BASE0 0xf6afe008 addr 0xf6afe000 MEM PREFETCHABLE
MAX_LAT 0x28 MIN_GNT 0x10 INT_PIN 0x01 INT_LINE 0x0b

zmu


Video Capabilities
Name: BT878 video (GrandTec Multi Cap
Type: 171
Can capture
Can tune
Overlay onto frame buffer
Can clip
Scalable
Video Channels: 4
Audio Channels: 0
Maximum Width: 768
Maximum Height: 480
Minimum Width: 48
Minimum Height: 32
Window Attributes
X Offset: 0
Y Offset: 0
Width: 320
Height: 240
Picture Attributes
Palette: 4 - 24bit RGB
Colour Depth: 24
Brightness: 32768
Hue: 32768
Colour :32768
Contrast: 32768
Whiteness: 0
Channel 0 Attributes
Name: Composite0
Channel: 0
Flags: 2
Channel has audio
Type: 2 - Camera
Format: 1 - NTSC
Channel 1 Attributes
Name: Composite1
Channel: 1
Flags: 2
Channel has audio
Type: 2 - Camera
Format: 1 - NTSC
Channel 2 Attributes
Name: Composite2
Channel: 2
Flags: 2
Channel has audio
Type: 2 - Camera
Format: 1 - NTSC
Channel 3 Attributes
Name: Composite3
Channel: 3
Flags: 2
Channel has audio
Type: 2 - Camera
Format: 1 - NTSC

/etc/sysctl.conf:
kernel.shmall = 536870912
kernel.shmmax = 536870912
kernel.shmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 65536
kernel.panic=10

apache httpd.conf :
user apache
group apache
documentroot /home/www/zm/html-root
scriptalias /cgi-bin /home/www/zm/cgi-bin

all directorys is ok and accessible on browser:
http://localhost/images
http://localhost/events
http://localhost/sounds
http://localhost/temp

zoneminder configure:

./configure --with-ffmpeg=/usr/local --with-webdir=/home/www/zm/html-root
--with-mysql
--with-cgidir=/home/www/zm/cgi-bin
--with-webgroup=apache
--with-webuser=apache
ZM_DB_USER=zmuser
ZM_DB_PASS=zmpass

________________________

Video Card OK
Configure OK.
Make OK.

Database OK

configuration:
ZM_DIR_EVENTS = events
ZM_DIR_IMAGES = images
ZM_DIR_SOUNDS = sounds
ZM_PATH_ZMS = /cgi-bin/nph-zms
ZM_PATH_SOCKS = /tmp
ZM_PATH_LOGS = /var/logs/zm
ZM_PATH_MPEG_ENCODE=/usr/local/bin/mpeg_encode
ZM_PATH_FFMPEG=/usr/local/bin/ffmpeg
ZM_PATH_NETPBM=/usr/local/netpbm
ZM_STREAM_METHOD=jpeg

chmods:
chmod -R 4777 /home/www
chown -R apache:apache /home/www
chmod +s /usr/local/bin/ffmpeg
chmod +s /usr/local/bin/mpeg_encode
chmod +s /usr/local/lib/libavcodec*

Delete monitor patch applied!

(all recomendations in VSS_Installation-Details.pdf for slackware are done too)

:x ________________________________ :x
_____________PROBLEMS______________

1. su command dont work on zmpkg.pl.. but ok.. started on console (as root) <----- mistake

2. no image on monitor Screen
http://localhost/cgi-bin/nph-zms?mode=j ... 1139150447
dont show image

3. no image on zone
apache log:
[Sun Feb 05 12:44:05 2006] [error] [client 127.0.0.1] File does not exist: /home/www/zm/html-root/images/New-Zones.jpg, referer: http://localhost/index.php?view=zone&mid=5&zid=6

4. When deleting all monitors.. monitor ID dont reset the counter.

5. When deleting all events.. event ID dont reset the counter.

6. ZM Debug is always simple...dont show errors!

-
No errors on /var/log/messages
-
/var/log/syslog:

Feb 5 14:53:00 slack zmu[24168]: ERR [Can't shmget, probably not enough shared memory space free: Permission denied]
-
But all events work OK!!
Events Thumbs OK!
Events jpeg stream OK.!
Events mpeg, move, asf streams OK on linux firefox and windows iexplorer!

(p.s.: zm-1.21.4 works ok too.)

What can I do.. where is the problem? where i can look next?
please.. my brains will explode!
thanks
Last edited by Leandro on Sat Feb 11, 2006 12:22 pm, edited 2 times in total.
User avatar
cordel
Posts: 5210
Joined: Fri Mar 05, 2004 4:47 pm
Location: /USA/Washington/Seattle

Post by cordel »

I say from the two log entries and the description you post it sounds like a permissions problem.

Corey
User avatar
Leandro
Posts: 4
Joined: Sun Feb 05, 2006 3:02 pm
Location: Bauru, SP, Brazil
Contact:

Post by Leandro »

humm.. ok... but. where??
shmget problem solved. (/etc/sysctl.conf was not been executed)
I just checked all permissions that I know... and nothing! :cry:

logged as root I run..
export QUERY_STRING="mode=jpeg&monitor=7&scale=100&maxfps=5"
./nph-zms > test.log

-
test.log:
HTTP/1.0 200 OK
Server: ZoneMinder Video Server/1.22.0
Expires: Mon, 26 Jul 1997 05:00:00 GMT
Last-Modified: Mon, 06 Feb 2006 10:27:04 GMT
Cache-Control: no-store, no-cache, must-revalidate
Cache-Control: post-check=0, pre-check=0
Pragma: no-cache
-

Why I cant get the content-information like content-type... etc..?

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

Post by zoneminder »

In your original example you had monitor=1 and in the last one it was 7. Do you have a monitor with the id of 7 or was that a typo?
Phil
User avatar
Leandro
Posts: 4
Joined: Sun Feb 05, 2006 3:02 pm
Location: Bauru, SP, Brazil
Contact:

Post by Leandro »

yeah man.... monitor=7.. this ID was generated after some monitor adds and removes.. and ID count never back to 1... I tried 1,2,3,4,5.... same result! No image! :?
but thanks for for the tip
User avatar
zoneminder
Site Admin
Posts: 5215
Joined: Wed Jul 09, 2003 2:07 pm
Location: Bristol, UK
Contact:

Post by zoneminder »

Do you know if the capture parts of the system are working? If you use zmu you can check the last image capture time etc. Also do you get images using single image mode?
Phil
candlerb
Posts: 29
Joined: Tue Jan 10, 2006 4:02 pm

Post by candlerb »

su command dont work on zmpkg.pl.. but ok.. started on console
What exactly do you mean by "started on console"?

I have found that if I run zmc directly as root, I get a permissions problem like this. You need to start zmc as the webserver user, typically 'apache', otherwise /cgi-bin/zms can't access the images in shared memory.

Arguably these scripts shouldn't be using su, which isn't particularly portable. It could be done directly in Perl instead, something along the lines of:

Code: Select all

my $uid = getpwnam("apache");
die "getpwnam: $!" unless defined($uid);
my $gid = getgrnam("apache");
die "getgrnam: $!" unless defined($gid);

my $pid = fork();
die "fork: $!" unless defined($pid);

if ($pid == 0) { # CHILD
  # change gid first, then uid
  $( = $gid;
  $) = $gid;
  $< = $uid;
  $> = $uid;
  # example
  exec("/usr/bin/id");
}

# PARENT
waitpid($pid, 0);
Regards, Brian.
User avatar
zoneminder
Site Admin
Posts: 5215
Joined: Wed Jul 09, 2003 2:07 pm
Location: Bristol, UK
Contact:

Post by zoneminder »

You are correct about this. The use of 'su' is mostly just a hangover from the original implementation and takes it's place on the long roster of 'things to revisit and do better' :)
Phil
User avatar
cordel
Posts: 5210
Joined: Fri Mar 05, 2004 4:47 pm
Location: /USA/Washington/Seattle

Post by cordel »

Something to keep in mind as well is Apache now supports the directives User, Group, and SuexecUserGroup as of version 2.0. I think that SuexecUserGroup is supposed to replace the User and Group directive though. I will also hopefully get back to working on an SELinux policy where ZM will run as user zm instead of sharing the apache user.

Corey
candlerb
Posts: 29
Joined: Tue Jan 10, 2006 4:02 pm

Post by candlerb »

cordel wrote:I will also hopefully get back to working on an SELinux policy where ZM will run as user zm instead of sharing the apache user.
With or without SELinux, I think it makes sense for all the zm daemons to run as user zm. /cgi-bin/zms can be made setuid zm. As long as the PHP scripts can read zm.conf, I don't think there's any other interaction with the webserver uid.

Also, I would like to see zm split into two packages: the backend daemons (e.g. zmc, zma and startup scripts, which depend on perl), and the front-end viewer and admin tools (which depend on apache and php). The backend could be bundled with a simple standalone HTTP server for /cgi-bin/zms, even one written in Perl. Of course you could still run it as a CGI under a 'proper' webserver if one were available.

The benefit is that you could install just the backend part for a remote dumb zm installation, storing and analysing images, which is viewed and managed from another server.

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

Post by zoneminder »

Brian, you make some very good points here. I will have a think and see how easy it might be to start moving in that direction in the next few releases.
Phil
User avatar
Leandro
Posts: 4
Joined: Sun Feb 05, 2006 3:02 pm
Location: Bauru, SP, Brazil
Contact:

Post by Leandro »

:D
Brian... gooood shot! you solved!!
simple... executing:

sudo -u apache /etc/rc.d/rc.zoneminder start

now.. zmc and zma is running on user apache
Great work!
Thanks Phil and Corey
Locked