Issues with server recognizing cgi-bin #24

Closed
opened 2021-04-11 17:45:45 +00:00 by ElDifinitivo · 6 comments

The answer to this may be incredibly simple, but any sort of web hosting is a glaring weakness of mine.

I'm trying out gemini and I'm having issues in getting molly-brown to recognize that cgi-bin is the directory for executables. At the bottom is the server hierarchy and I have CGIPaths=["cgi-bin"] set in molly.conf.

The script is marked as executable, it runs perfectly fine in terminal, but navigating to the link just displays the contents of the file. I made the script a simple hello world to try it out which contains nothing but these lines:

#!/usr/bin/env python3

print("20 text/gemini\n")
print("Hello, world!")

There has to be something I'm missing and I wasn't sure where else to ask.

|-- data                                                                                                                                                                           
|   |-- cert.pem                                                                                                                                                                   
|   `-- key.pem                                                                                                                                                                    
|-- molly.conf                                                                                                                                                                     
|-- root                                                                                                                                                                           
|   |-- article.gmi                                                                                                                                           
|   |-- cgi-bin                                                                                                                                                                    
|   |   `-- echo.py                                                                                                                                                                
|   `-- index.gmi                                                                                                                                                                                                                                                                                                        
`-- var                                                                                                                                                                            
    |-- access.log                                                                                                                                                                 
    |-- error.log  
The answer to this may be incredibly simple, but any sort of web hosting is a glaring weakness of mine. I'm trying out gemini and I'm having issues in getting molly-brown to recognize that cgi-bin is the directory for executables. At the bottom is the server hierarchy and I have `CGIPaths=["cgi-bin"]` set in `molly.conf`. The script is marked as executable, it runs perfectly fine in terminal, but navigating to the link just displays the contents of the file. I made the script a simple hello world to try it out which contains nothing but these lines: ``` #!/usr/bin/env python3 print("20 text/gemini\n") print("Hello, world!") ``` There has to be something I'm missing and I wasn't sure where else to ask. ``` |-- data | |-- cert.pem | `-- key.pem |-- molly.conf |-- root | |-- article.gmi | |-- cgi-bin | | `-- echo.py | `-- index.gmi `-- var |-- access.log |-- error.log ```
Contributor

At the bottom is the server hierarchy and I have CGIPaths=["cgi-bin"] set in molly.conf.

I believe the items in the CGIPaths array are supposed to be absolute paths. This is what I have in my setup, which works, and it seems to be what the README indicates.

> At the bottom is the server hierarchy and I have `CGIPaths=["cgi-bin"]` set in `molly.conf`. I believe the items in the `CGIPaths` array are supposed to be absolute paths. This is what I have in my setup, which works, and it seems to be what the README [indicates](https://tildegit.org/solderpunk/molly-brown#dynamic-content).
Author

I've tried with the absolute path as well, but without success; it still just prints the contents.

I've tried with the absolute path as well, but without success; it still just prints the contents.
Contributor

I'm not sure then. It works fine for me. Make sure:

  • You're using an absolute path (best to stick with that)
  • You're running from the latest master
  • Your CGI files are actually executable, and can run in the terminal with ./name
  • They are world-readable and world-executable. That usually looks like -rwxr-xr-x in ls -l output. You can set this with chmod 755.

Perhaps the last one is tripping you up.

I'm not sure then. It works fine for me. Make sure: - You're using an absolute path (best to stick with that) - You're running from the latest master - Your CGI files are actually executable, and can run in the terminal with `./name` - They are world-readable and world-executable. That usually looks like `-rwxr-xr-x` in `ls -l` output. You can set this with `chmod 755`. Perhaps the last one is tripping you up.
Author

Made sure I followed all of that, but still no luck. I tried it out with another server (jetforce) and I got it working no problem.

If it helps, here's some system info

Linux <hostname> 4.19.0-14-amd64 #1 SMP Debian 4.19.171-2 (2021-01-30) x86_64 GNU/Linux
go version go1.16.3 linux/amd64

I did a test run on my local machine and navigating to the script (used lagrange as my browser) diplays this:

Unsupported Content Type
The received content cannot be viewed with this application.

application/octet-stream

You can save it as a file to your Downloads folder, though. Press Ctrl+S or select "Save to Downloads" from the menu.
Made sure I followed all of that, but still no luck. I tried it out with another server (jetforce) and I got it working no problem. If it helps, here's some system info `Linux <hostname> 4.19.0-14-amd64 #1 SMP Debian 4.19.171-2 (2021-01-30) x86_64 GNU/Linux` `go version go1.16.3 linux/amd64` I did a test run on my local machine and navigating to the script (used lagrange as my browser) diplays this: ``` Unsupported Content Type The received content cannot be viewed with this application. application/octet-stream You can save it as a file to your Downloads folder, though. Press Ctrl+S or select "Save to Downloads" from the menu. ```
Contributor

I don't think this is related, because I still can't replicate your bug. But the line print("20 text/gemini\n") is wrong. It should be print("20 text/gemini\r"). The Gemini spec requires the header line end with \r\n, and print will add \n to the end automatically.

Other than that I don't know, because it works for me. Or in the case of your original script, it still runs the executable, but my client just says there's a header error.

I don't think this is related, because I still can't replicate your bug. But the line `print("20 text/gemini\n")` is wrong. It should be `print("20 text/gemini\r")`. The Gemini spec requires the header line end with `\r\n`, and `print` will add `\n` to the end automatically. Other than that I don't know, because it works for me. Or in the case of your original script, it still runs the executable, but my client just says there's a header error.
Owner

Sorry that my answer to this issue is coming many years too late. There's nothing in what you've posted above that jumps out to me as an obvious cause for your problems (assuming makeworld's point about line termination wasn't the answer). I guess by now this is probably no longer of much interest to you, but let me know if you want help trying to chase this down further.

I will close this issue shortly, but I'm going to leave it open for now as a reminder to look into changing the behaviour of the CGI path config variables such that if they are given relative paths, they get resolved relative to the DocBase.

Sorry that my answer to this issue is coming many years too late. There's nothing in what you've posted above that jumps out to me as an obvious cause for your problems (assuming makeworld's point about line termination wasn't the answer). I guess by now this is probably no longer of much interest to you, but let me know if you want help trying to chase this down further. I will close this issue shortly, but I'm going to leave it open for now as a reminder to look into changing the behaviour of the CGI path config variables such that if they are given relative paths, they get resolved relative to the `DocBase`.
Sign in to join this conversation.
No Label
No Milestone
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: solderpunk/molly-brown#24
No description provided.