Post 9w0aZz1HQk72eIxIEC by julienxx@mastodon.sdf.org
 (DIR) More posts by julienxx@mastodon.sdf.org
 (DIR) Post #9w0HNmk9LiUjyFPed6 by Shufei@mastodon.sdf.org
       2020-06-12T09:41:09Z
       
       0 likes, 0 repeats
       
       @julienxx @solderpunk Yay, congrats!  Looks fab!
       
 (DIR) Post #9w0HNmu4koR0T23a6K by solderpunk@tilde.zone
       2020-06-12T10:09:06Z
       
       0 likes, 0 repeats
       
       @Shufei @julienxx It's alive!!!  I'm really excited about the Go+Plan9 combo.I've pushed a lot of good new stuff to Molly in the past week or so (and there's more to come!), but none of it is documented yet.  Hit me up if you are interested in (S)CGI.
       
 (DIR) Post #9w0HiLx09vMExKEQAy by julienxx@mastodon.sdf.org
       2020-06-12T10:12:45Z
       
       0 likes, 0 repeats
       
       @solderpunk @Shufei will do! I'll need this (S)CGI goodness
       
 (DIR) Post #9w0aZz1HQk72eIxIEC by julienxx@mastodon.sdf.org
       2020-06-12T13:44:07Z
       
       0 likes, 0 repeats
       
       @solderpunk so I know next to nothing about CGI. Should I just put a script that returns text in cgi-bin and molly-brown will execute it and serve the output? Do I need to handle the header in the script? @Shufei
       
 (DIR) Post #9w0nCwWZq9Y3ebwDy4 by solderpunk@tilde.zone
       2020-06-12T16:05:43Z
       
       0 likes, 0 repeats
       
       @julienxx @Shufei More or less, yes.  Define one or more CGIPaths in the config file, put your script in any subdirectory of one of those paths, make it world-executable, and Molly Brown will run it as its own process.  Various details about the request (e.g. the URL the client sent) will be available as environment variables.  Whatever the script writes to stdout will be send back to the client.  This needs to include the response header.
       
 (DIR) Post #9w0nRWdEOI0nh20IqW by solderpunk@tilde.zone
       2020-06-12T16:08:21Z
       
       0 likes, 0 repeats
       
       @julienxx @Shufei Note that, due to limitations of Go, which will hopefully be lifted in a future release, the script is run as the same user as the server itself - which means it can do things like read/write the log file, or read the TLS private key, etc.  So if you write something which accepts user input and maps that to the filesystem, be ultra careful!  SCGI lets you get around this and run your scripts as `nobody`, and possibly chrooted, but it's a bit more faff to set up.
       
 (DIR) Post #9w0nX9E8K2J0qFwggC by julienxx@mastodon.sdf.org
       2020-06-12T16:09:17Z
       
       0 likes, 0 repeats
       
       @solderpunk thanks! Plan 9 has other concepts for env, chroot... I'll have to check how everything fits
       
 (DIR) Post #9w0neUf91VGVLn5BS4 by solderpunk@tilde.zone
       2020-06-12T16:10:41Z
       
       0 likes, 0 repeats
       
       @julienxx Oh!  No environment variables?  I have no idea how well, if at all, CGI will work there, then.Does it have an equivalent of unix domain sockets?  SCGI relies on those.  Well, Molly's current implementation does.  In principle you can do it over the loopback network interface too, but I haven't written anything for that yet.
       
 (DIR) Post #9w0nnDv8dgVm23j5zU by julienxx@mastodon.sdf.org
       2020-06-12T16:12:11Z
       
       0 likes, 0 repeats
       
       @solderpunk env vars are files, as a matter of fact everything is a file in plan 9.Simple CGI (a script that calls uptime) works, now I'll try to get the vars
       
 (DIR) Post #9w0okibADtTOGNkjWC by julienxx@mastodon.sdf.org
       2020-06-12T16:22:55Z
       
       0 likes, 0 repeats
       
       @solderpunk so I created a script in cgi-bin, made it executable. If I understand the code correctly here https://tildegit.org/solderpunk/molly-brown/src/branch/master/dynamic.go#L131I should have all those variables passed to my script by molly-brown?
       
 (DIR) Post #9w0ouOJAW5aWEJwplo by julienxx@mastodon.sdf.org
       2020-06-12T16:24:42Z
       
       0 likes, 0 repeats
       
       @solderpunk so I created a script in cgi-bin, made it executable. If I understand the code correctly here https://tildegit.org/solderpunk/molly-brown/src/branch/master/dynamic.go#L131 I should have all those variables passed to my script by molly-brown?