[Nut-upsuser] Help with CGI upsstats.cgi giving "file not found"
Jim Klimov
jimklimov+nut at gmail.com
Thu Dec 21 17:24:15 GMT 2023
Well, it seems both apache and bash literally say they did not find an
executable there; it is not about NUT configs. Is the file present? (is
"spivey" same as "pi2" in "screenshots" posted?) Does it have the exec bit
set? Are all directories at least "executable" by apache user?
Jim
On Thu, Dec 21, 2023, 13:11 Tim Reimers KA4LFP via Nut-upsuser <
nut-upsuser at alioth-lists.debian.net> wrote:
>
> Hi everyone --
>
> I'm having a problem with the CGI scripts for NUT.
>
> First, a summary:
> - I have a RasPI (hereafter referred to as Pi1) running Bullseye in
> which this all WORKS FINE -- the upsd/upsc/ monitor services, etc
> - I have a SECOND RasPI (hereafter referred to as Pi2) running Bullseye in
> which ONLY the CGI scripts do not work.
> All other (upsc/upsd/systemctl) show normal status and work to retrieve
> data from the single UPS attached to each Pi.
>
> Discussion below is in regard to "PI2", in which CGI scripts don't work.
> On "Pi1" everything works fine.
>
> I have compared many files/permissions/config files, and cannot find a
> difference between the two Pi.
>
> On both of them, running "upsc <ups>@localhost" works fine, and produces
> output from the UPS.
> So at a basic level, the UPS is connected to the USB port, the driver is
> working, and the upsd monitoring service is OK.
>
>
> The essential problem
> The CGI script returns "file not found"
> If I execute it from a browser via Apache,
> I simply get a 500 Internal Server Error.
>
> On another site, I discovered that it's possible to simply execute a CGI
> script directly, if it's a compiled executable.
>
> Here's what happens at the CLI by executing the file.
> root at Pi2 :~# /var/www/cgi-bin/nut/upsstats.cgi
> -bash: /var/www/cgi-bin/nut/upsstats.cgi: No such file or directory
>
> That's different from the suggested scenarios for running upsstats.cgi
> from the CLI, which were issues
> with host authentication or "spits a bunch of HTML at you", which would be
> fine.
>
> On "Pi1", the fully working one - that's exactly what happens - calling
> "upsstats.cgi" from the CLI
> results in it simply spitting out HTML with the configured UPS detailed
> out.
> Running the CGI from a browser > Apache2 on the Pi works exactly as
> expected
>
> What I lack an understanding of is which files in /etc/nut
> these CGI scripts access, and what permissions are needed.
> Or if there are other files in other directories that the CGI scripts need.
> That error, cryptically gives me the impression that the CGI script cannot
> access some file it needs
> I've looked at
> /etc/nut/hosts.conf
> /etc/nut/upsstats.html
> /etc/nut/upssstats-single.html
> /etc/nut/upsset.conf
>
> All those files -- which I believe to be the required ones for CGI, appear
> to be identical on Pi2 as compared to Pi1
>
> Does anyone have any idea which files/permissions that the CGI may require
> other than the above?
> I'm not sure if something in /usr/lib /var/wherever, etc are also
> required?
>
> Thanks Tim
>
> Some details for those who will want to compare versions, etc.
>
> The apache logfile
> [Tue Dec 19 15:20:42.088991 2023] [cgi:error] [pid 3293] [client
> 72.250.240.54:31043] AH01215: (2)No such file or directory: exec of
> '/var/www/cgi-bin/nut/upsstats.cgi' failed:
> /var/www/cgi-bin/nut/upsstats.cgi
> [Tue Dec 19 15:20:42.092452 2023] [cgi:error] [pid 3293] [client
> 72.250.240.54:31043] End of script output before headers: upsstats.cgi
> [Tue Dec 19 15:20:42.498512 2023] [cgi:error] [pid 3294] [client
> 72.250.240.54:40731] AH01215: (2)No such file or directory: exec of
> '/var/www/cgi-bin/nut/upsstats.cgi' failed:
> /var/www/cgi-bin/nut/upsstats.cgi
> [Tue Dec 19 15:20:42.502123 2023] [cgi:error] [pid 3294] [client
> 72.250.240.54:40731] End of script output before headers: upsstats.cgi
>
> Permissions on /etc/nut
> root at spivey:~# ls -la /etc/nut
> total 64
> drwxr-xr-x 1 root nut 292 Dec 18 20:02 .
> drwxr-xr-x 1 root root 3882 Dec 19 06:14 ..
> -rwxr-x--- 1 nut nut 675 Dec 6 20:40 etcnutfileperms.txt
> -rwxr-x--- 1 root root 1148 Dec 18 20:02 hosts.conf
> -rwxr-x--- 1 nut nut 1543 Dec 6 20:40 nut.conf
> -rwxr-x--- 1 nut root 1137 Dec 15 21:12 old-hosts.conf
> -rwxr-x--- 1 nut nut 6170 Dec 18 20:01 ups.conf
> -rwxr-x--- 1 nut nut 4631 Dec 6 20:40 upsd.conf
> -rwxr-x--- 1 nut nut 2185 Dec 18 19:54 upsd.users
> -rwxr-x--- 1 root root 1263 Dec 18 20:01 upsmon.conf
> -rwxr-x--- 1 nut nut 5634 Dec 6 20:40 upssched.conf
> -rwxr-x--- 1 nut nut 1415 Dec 15 21:36 upsset.conf
> -rwxr-x--- 1 nut root 3603 Dec 6 20:40 upsstats.html
> -rwxr-x--- 1 nut root 6446 Dec 6 20:40 upsstats-single.html
> root at spivey:~# ls -la /etc/ | grep nut
> drwxr-xr-x 1 root nut 292 Dec 18 20:02 nut
>
>
> root at Pi2:~# upsc tripplite at localhost
> Init SSL without certificate database
> battery.charge: 100
> .
> .
>
>
> root at Pi2:~# /usr/sbin/upsd -DD -a tripplite at localhost
> Network UPS Tools upsd 2.7.4
>
>
> root at Pi2:~#
> root at spivey:~# file /var/www/cgi-bin/nut/upsstats.cgi
> /var/www/cgi-bin/nut/upsstats.cgi: ELF 32-bit LSB executable, ARM, EABI5
> version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3,
> BuildID[sha1]=52f4d9e65d096388e4b3cb3df2673bf59bbdfa70, for GNU/Linux
> 3.2.0, stripped
> root at Pi2:~#
> root at Pi1:~#
>
>
>
>
>
> ####
> Tim, KA4LFP####
>
> ####
> Morse code, the original digital mode
> Real radios glow in the dark.
> SWAN rule number 1: Life is too short to have a puny signal. © K0MHP
> SWAN rule number 2: No menu required. © K0MHP
>
> ##
> _______________________________________________
> Nut-upsuser mailing list
> Nut-upsuser at alioth-lists.debian.net
> https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsuser
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/nut-upsuser/attachments/20231221/f96b6507/attachment-0001.htm>
More information about the Nut-upsuser
mailing list