<div dir="auto">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?<div dir="auto"><br></div><div dir="auto">Jim</div><div dir="auto"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Dec 21, 2023, 13:11 Tim Reimers KA4LFP via Nut-upsuser <<a href="mailto:nut-upsuser@alioth-lists.debian.net">nut-upsuser@alioth-lists.debian.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><br></div><div><div>Hi everyone --</div><div><br></div><div>I'm having a problem with the CGI scripts for NUT.</div><div><br></div><div>First, a summary:</div><div>- I have a RasPI (hereafter referred to as Pi1) running Bullseye in which this all WORKS FINE -- the upsd/upsc/ monitor services, etc</div><div>- I have a SECOND RasPI (hereafter referred to as Pi2) running Bullseye in which ONLY the CGI scripts do not work. </div><div>All other (upsc/upsd/systemctl) show normal status and work to retrieve data from the single UPS attached to each Pi.</div><div><br></div><div>Discussion below is in regard to "PI2", in which CGI scripts don't work. </div><div>On "Pi1" everything works fine.</div><div><br></div><div>I have compared many files/permissions/config files, and cannot find a difference between the two Pi.</div><div><br></div><div>On both of them, running "upsc <ups>@localhost" works fine, and produces output from the UPS. </div><div>So at a basic level, the UPS is connected to the USB port, the driver is working, and the upsd monitoring service is OK.</div><div><br></div><div><br></div><div>The essential problem</div><div>The CGI script returns "file not found"</div><div>If I execute it from a browser via Apache, </div><div>I simply get a 500 Internal Server Error. </div><div><br></div><div><div>On another site, I discovered that it's possible to simply execute a CGI script directly, if it's a compiled executable. </div><div><br></div></div><div>Here's what happens at the CLI by executing the file.</div><div>root@Pi2 :~# /var/www/cgi-bin/nut/upsstats.cgi<br>-bash: /var/www/cgi-bin/nut/upsstats.cgi: No such file or directory<br></div><div><br></div><div>That's different from the suggested scenarios for running upsstats.cgi from the CLI, which were issues</div><div>with host authentication or "spits a bunch of HTML at you", which would be fine. </div><div><br></div><div>On "Pi1", the fully working one - that's exactly what happens - calling "upsstats.cgi" from the CLI </div><div>results in it simply spitting out HTML with the configured UPS detailed out.</div><div>Running the CGI from a browser > Apache2 on the Pi works exactly as expected </div><div><br></div><div>What I lack an understanding of is which files in /etc/nut </div><div>these CGI scripts access, and what permissions are needed.</div><div>Or if there are other files in other directories that the CGI scripts need.</div><div>That error, cryptically gives me the impression that the CGI script cannot access some file it needs</div><div>I've looked at </div><div>/etc/nut/hosts.conf</div><div>/etc/nut/upsstats.html</div><div>/etc/nut/upssstats-single.html</div><div>/etc/nut/upsset.conf</div><div><br></div><div>All those files -- which I believe to be the required ones for CGI, appear to be identical on Pi2 as compared to Pi1 </div><div><br></div><div>Does anyone have any idea which files/permissions that the CGI may require other than the above?</div><div>I'm not sure if something in /usr/lib /var/wherever, etc are also required? </div><div><br></div><div>Thanks Tim</div><div><br></div><div>Some details for those who will want to compare versions, etc.<br></div><div><br></div><div>The apache logfile</div><div>[Tue Dec 19 15:20:42.088991 2023] [cgi:error] [pid 3293] [client <a href="http://72.250.240.54:31043/" target="_blank" rel="noreferrer">72.250.240.54:31043</a>] AH01215: (2)No such file or directory: exec of '/var/www/cgi-bin/nut/upsstats.cgi' failed: /var/www/cgi-bin/nut/upsstats.cgi<br>[Tue Dec 19 15:20:42.092452 2023] [cgi:error] [pid 3293] [client <a href="http://72.250.240.54:31043/" target="_blank" rel="noreferrer">72.250.240.54:31043</a>] End of script output before headers: upsstats.cgi<br>[Tue Dec 19 15:20:42.498512 2023] [cgi:error] [pid 3294] [client <a href="http://72.250.240.54:40731/" target="_blank" rel="noreferrer">72.250.240.54:40731</a>] AH01215: (2)No such file or directory: exec of '/var/www/cgi-bin/nut/upsstats.cgi' failed: /var/www/cgi-bin/nut/upsstats.cgi<br>[Tue Dec 19 15:20:42.502123 2023] [cgi:error] [pid 3294] [client <a href="http://72.250.240.54:40731/" target="_blank" rel="noreferrer">72.250.240.54:40731</a>] End of script output before headers: upsstats.cgi<br></div><div><br></div><div>Permissions on /etc/nut</div><div>root@spivey:~# ls -la /etc/nut<br>total 64<br>drwxr-xr-x 1 root nut 292 Dec 18 20:02 .<br>drwxr-xr-x 1 root root 3882 Dec 19 06:14 ..<br>-rwxr-x--- 1 nut nut 675 Dec 6 20:40 etcnutfileperms.txt<br>-rwxr-x--- 1 root root 1148 Dec 18 20:02 hosts.conf<br>-rwxr-x--- 1 nut nut 1543 Dec 6 20:40 nut.conf<br>-rwxr-x--- 1 nut root 1137 Dec 15 21:12 old-hosts.conf<br>-rwxr-x--- 1 nut nut 6170 Dec 18 20:01 ups.conf<br>-rwxr-x--- 1 nut nut 4631 Dec 6 20:40 upsd.conf<br>-rwxr-x--- 1 nut nut 2185 Dec 18 19:54 upsd.users<br>-rwxr-x--- 1 root root 1263 Dec 18 20:01 upsmon.conf<br>-rwxr-x--- 1 nut nut 5634 Dec 6 20:40 upssched.conf<br>-rwxr-x--- 1 nut nut 1415 Dec 15 21:36 upsset.conf<br>-rwxr-x--- 1 nut root 3603 Dec 6 20:40 upsstats.html<br>-rwxr-x--- 1 nut root 6446 Dec 6 20:40 upsstats-single.html<br>root@spivey:~# ls -la /etc/ | grep nut<br>drwxr-xr-x 1 root nut 292 Dec 18 20:02 nut<br></div><div><br></div><div><br>root@Pi2:~# upsc tripplite@localhost<br>Init SSL without certificate database<br>battery.charge: 100<br></div><div>.</div><div>.</div><div><br></div><div><br></div>root@Pi2:~# /usr/sbin/upsd -DD -a tripplite@localhost<br>Network UPS Tools upsd 2.7.4<div><br></div><div><br></div><div>root@Pi2:~#<br>root@spivey:~# file /var/www/cgi-bin/nut/upsstats.cgi<br>/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<br>root@Pi2:~#<br>root@Pi1:~#<br></div><div><br></div><div><br></div><div><br></div></div><div><br></div><br clear="all"><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">####</div><div dir="ltr"><h1 style="margin:0px 0px 15px;color:rgb(24,24,24);font-weight:normal;padding:0px;font-size:14px;font-family:Merriweather,Georgia,serif;line-height:21px"><span style="font-family:Arial,Helvetica,sans-serif;font-size:small;color:rgb(32,33,36)">Tim, KA4LFP</span></h1><h1 style="margin:0px 0px 15px;color:rgb(24,24,24);font-weight:normal;padding:0px;font-size:14px;font-family:Merriweather,Georgia,serif;line-height:21px">####</h1><div><br></div><div><span style="color:rgb(5,5,5);font-family:"Segoe UI Historic","Segoe UI",Helvetica,Arial,sans-serif;font-size:15px;white-space:pre-wrap">####</span></div></div><div dir="ltr">Morse code, the original digital mode</div><div dir="ltr"><div>Real radios glow in the dark.</div><div>SWAN rule number 1: Life is too short to have a puny signal. © K0MHP</div><div>SWAN rule number 2: No menu required. © K0MHP</div><div><br></div><div>##</div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>
_______________________________________________<br>
Nut-upsuser mailing list<br>
<a href="mailto:Nut-upsuser@alioth-lists.debian.net" target="_blank" rel="noreferrer">Nut-upsuser@alioth-lists.debian.net</a><br>
<a href="https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsuser" rel="noreferrer noreferrer" target="_blank">https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsuser</a><br>
</blockquote></div>