Cgi.cfg reading errors
Andreas Ericsson
ae at op5.se
Wed Mar 31 10:29:21 CEST 2004
Dan Adams wrote:
> ---- LONG POST BELOW ----
> Andreas,
> I tried the commands as you had stated and it didn't make much
> sense. When I tried it with the grep command as part of it, it did not show
> anything but a black line but when I use grep I am used to it just going to
> the next prompt if there is nothing to be found,
> below (at the bottom of the
> e-mail is the output of the commands. Any more ideas?
>
Yes. Commented (far) below in the strace output.
> Dan
>
> -----Original Message-----
> From: nagios-users-admin at lists.sourceforge.net
> [mailto:nagios-users-admin at lists.sourceforge.net] On Behalf Of Andreas
> Ericsson
> Sent: Sunday, March 28, 2004 4:23 AM
> To: nagios-users at lists.sourceforge.net
> Subject: Re: [Nagios-users] Cgi.cfg reading errors
>
>
> Dan Adams wrote:
>
>>Andreas,
>> I tried that, su to root first then su to both of the users, what
>>Nagios is and what the web server is.
>
>
> Only the webserver user needs read-access to the files, and it's path
> will not be relative to DocumentRoot.
>
> You can do the following to see what files it's trying to open and what
> happens when it does. First su to the webserver pseudo-user, then run
> this little sequence;
> export REQUEST_METHOD=GET
> export QUERY_STRING="host=all"
> export REMOTE_USER="some-authorized-user"
>
> strace <cgi-program> 2>&1 | grep open | less
>
> You will obviously have to replace some-authorized-user with an
> authorized user, and the 'host=all' string may not work with all CGI's.
>
> If you still can't work it out, post the output of the strace-command
> here and I'll probably be able to help you.
>
Ok. First of all; The 'strace' command executes programs with
PTRACE_ENABLE, so that it can 'hook' the system calls (read, write,
open, brk etc). This is useful because it shows us which functions are
returning bad values. Anyways. Comments below are marked with '::'
execve("./config.cgi", ["./config.cgi"], [/* 29 vars */]) = 0
--[ dynamic link loading cut ]--
:: First linux sets up the PTE's
brk(0) = 0x8068480
brk(0x8069480) = 0x8069480
brk(0) = 0x8069480
brk(0x806a000) = 0x806a000
:: These are the system calls used when reading a file.
open("/usr/local/nagios/etc/cgi.cfg", O_RDONLY|O_LARGEFILE) = 3
:: open() = 3 above tells us that this call succeeded, so the cgi.cfg is
:: actually there.
fstat64(3, {st_mode=S_IFREG|0666, st_size=21335, ...}) = 0
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
= 0x40016000
:: These are just preparations to move the file into memory.
read(3, "################################"..., 4096) = 4096
read(3, "he interval_length variable.\n# N"..., 4096) = 4096
read(3, " GLOBAL HOST AND SERVICE EVENT H"..., 4096) = 4096
read(3, " is set to 1.\n\nstate_retention_f"..., 4096) = 4096
read(3, "implementing distributed monitor"..., 4096) = 4096
read(3, "ripped from macros before being "..., 4096) = 855
read(3, "", 4096) = 0
:: And here it is actually read.
close(3) = 0
munmap(0x40016000, 4096) = 0
:: When it's done, close the handle and release the memory
:: Below is what happens when something fails.
open("common-header.ssi", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such
file or directory)
:: The open() system call returns -1, and the proper system
:: error message is displayed afterwards.
:: Below is the error message from config.cgi which follows
:: immediately after the above open() call fails.
write(1, "<H1>Whoops!</H1>\n", 17<H1>Whoops!</H1>
) = 17
write(1, "<P><STRONG><FONT COLOR=\'RED\'>Err"..., 132<P><STRONG><FONT
COLOR='RED'>Error: Could not open CGI config file
'/usr/local/nagios/etc/cgi.cfg' for reading!</FONT></STRONG></P>
) = 132
:: This is a bug in the config.cgi. It gives warnings for bad the
:: wrong things.
--[ snip ]---
Conclusion; You need to install the stylesheets in the proper location.
--
Mvh
Andreas Ericsson
OP5 AB
+46 (0)733 709032
andreas.ericsson at op5.se
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue.
::: Messages without supporting info will risk being sent to /dev/null
More information about the Users
mailing list