H*tp header with safe body

It struck me that it should be possible to have ye olde websites on unSAFE internet, make use of SAFE for their files.

That websites bodies then become mostly stored on SAFE, need not be apparent to the end user, yet that use case is multiply useful for the host - cheaper; and more robust; and more expandable; etc etc.

I haven’t had time or cracked it yet but wonder that some simple apache+php server, necessarily could be the header for any site, that then has either exec or passthru executing the usual safe CLI.

So, something like this should work…

<?php
    passthru("safe file cat safe://hello/index.html");
?>

but the context of what php in a website is allowed to execute, I haven’t looked into … expecting it needs to be within the /var/www/ context and unclear atm if CLI can handle being outside of a user’s /home/ directory.

:thinking:

1 Like

Trivially I moved /home/$USER/bin/safe to /usr/bin and successfully started the authenticator, created a new account on the shared-section.

Next step is to build a small sample site in /var/www and try to PUT it to the shared section from there.

Unsure just what this is proving or disproving but might as well have a go.
Perhaps I should create a brand new user for this in case I am missing something and settings from /home/$USER/.safe are still being read.

1 Like

Even more trivially, I was tempted to log a bug perhaps for future, to prompt an option that CLI gets installed with option for all users as

  • /usr/local/bin/
  • generic config to /etc/
  • user config to ~/.config/

Not an expert and might need checking but noting that /usr/bin is strictly for packages managed by the distribution package manager, which comes then with a fear of loss where that tidies up on occasion.

and another while I’m noting off topic that option to create man pages is set out as abcs at https://www.cyberciti.biz/faq/linux-unix-creating-a-manpage/ and then looks simple - again for future perhaps.

#on-topic thanks for taking a look… I wonder it’s a powerful option to leverage what exists, if it can be made to work. :+1:

1 Like

Yeah I realised that after posting that maybe was not the brightest choice to put it
/usr/local/bin would perhaps be more appropriate

Yeah I’ll try to get around to that once I have done a lot more of the navi cheatsheets https://github.com/willief/cheats/blob/master/network/safe.cheat

Im noting with horror its over a week since I have added to that – PRs VERY welcome indeed

Ideally we could have SAFE .deb packages managed by the package manager in the future.

2 Likes

So, currently wondering that perl is better than php for waiting some reply from an executable.

Stuck atm with uncertainty about what ./safe executable is looking for beyond just itself.

So, this works for the version detail but not for a basic request:

#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "<html><p>Hello, World.<p>";
system("./safe -V");
system("./safe dog safe://hello");

output just gets the basic

Hello, World.

safe-cli 0.12.0

:thinking:

edit: and to note the safe executable put to /usr/lib/cgi-bin to see that working.

edit2: and adding system("./safe --help"); makes even more of a mess :smiley:

1 Like