From d1b4a1ef46b317d1cf3a80e0e5c8bcc6860198f1 Mon Sep 17 00:00:00 2001 From: mpl Date: Tue, 25 Jun 2013 00:50:49 +0200 Subject: [PATCH] website: added -also_run to camweb and fixed sharing doc -added -also_run so we could run scripts/run-blobserver to start a blobserver for the sharing demos/doc. -added new share blob to the root and rmed the old one -run-blobserver now uses make.go -fixed doc to account for the share handler Change-Id: I2d5120cfbb92f983872bc65ede4ac5b314ca9606 --- .../example-blobserver-config.json | 29 +++++++---- ...1fda36c1bd9e4595ed16ab5e2a46d44491f708.dat | 7 --- ...2758fb54521cb6540d256098e7c0f1625b33e3.dat | 9 ++++ website/camweb.go | 51 ++++++++++++++----- website/content/docs/sharing | 26 ++++++---- website/run.pl | 1 + website/scripts/run-blobserver | 13 +++-- 7 files changed, 90 insertions(+), 46 deletions(-) delete mode 100644 website/blobserver-example/root/sha1/071/fda/sha1-071fda36c1bd9e4595ed16ab5e2a46d44491f708.dat create mode 100644 website/blobserver-example/root/sha1/102/758/sha1-102758fb54521cb6540d256098e7c0f1625b33e3.dat diff --git a/website/blobserver-example/example-blobserver-config.json b/website/blobserver-example/example-blobserver-config.json index 73ddea03e..76c339b8e 100644 --- a/website/blobserver-example/example-blobserver-config.json +++ b/website/blobserver-example/example-blobserver-config.json @@ -1,14 +1,21 @@ { "_for-emacs": "-*- mode: js2;-*-", - "baseURL": ["_env", "http://camlistore.org:3179"], - "password": ["_env", "${CAMLI_PASSWORD}"], + "handlerConfig": true, + "baseURL": ["_env", "http://camlistore.org:3179"], + "https": false, + "auth": ["_env", "userpass:whatever:${CAMLI_PASSWORD}"], - "prefixes": { - "/": { - "handler": "storage-filesystem", - "handlerArgs": { - "path": ["_env", "${CAMLI_ROOT}"] - } - } - } + "prefixes": { + "/": { + "handler": "storage-filesystem", + "handlerArgs": { + "path": ["_env", "${CAMLI_ROOT}"] + } + }, + "/share/": { + "handler": "share", + "handlerArgs": { + "blobRoot": "/" + } + } + } } - diff --git a/website/blobserver-example/root/sha1/071/fda/sha1-071fda36c1bd9e4595ed16ab5e2a46d44491f708.dat b/website/blobserver-example/root/sha1/071/fda/sha1-071fda36c1bd9e4595ed16ab5e2a46d44491f708.dat deleted file mode 100644 index 9a1ad1cd4..000000000 --- a/website/blobserver-example/root/sha1/071/fda/sha1-071fda36c1bd9e4595ed16ab5e2a46d44491f708.dat +++ /dev/null @@ -1,7 +0,0 @@ -{"camliVersion": 1, - "authType": "haveref", - "camliSigner": "sha1-f019d17dd308eebbd49fd94536eb67214c2f0587", - "camliType": "share", - "target": "sha1-0e5e60f367cc8156ae48198c496b2b2ebdf5313d", - "transitive": true -,"camliSig":"iQEcBAABAgAGBQJNQJGuAAoJEIUeCLJL7Fq1EuAIAL/nGoX8caGaANnam0bcIQT7C61wXMRW4qCCaFW+w67ys5z4ztfnTPKwL9ErzMF8Hd32Xe/bVcF6ZL38x/axqI7ehxN8lneKGQNoEdZDA9i752aAr0fkAba6eDehoOj9F4XxOzk3iVrq445jEXtu/+twamHV3UfRozWK1ZQb57dM+cRff47M/Y6VIBRSgW2BrABjuBs8G6PiKxycgh1mb+RL8f9KG+HB/yFuK37YJqZ0zU2OTRp6ELiOgTxbeg99koV9Duy4f4mQgxQgli46077Sv/ujzIeVbmdFL3OenGEzQnyKG0fhf8fa5WkED0XfH7zibAHLiSq3O7x11Q0406U==ANug"} diff --git a/website/blobserver-example/root/sha1/102/758/sha1-102758fb54521cb6540d256098e7c0f1625b33e3.dat b/website/blobserver-example/root/sha1/102/758/sha1-102758fb54521cb6540d256098e7c0f1625b33e3.dat new file mode 100644 index 000000000..cd0772d0e --- /dev/null +++ b/website/blobserver-example/root/sha1/102/758/sha1-102758fb54521cb6540d256098e7c0f1625b33e3.dat @@ -0,0 +1,9 @@ +{"camliVersion": 1, + "authType": "haveref", + "camliSigner": "sha1-3bee195d0dada92a9d88e67f731124238e65a916", + "camliType": "claim", + "claimDate": "2013-06-24T14:17:02.791613849Z", + "claimType": "share", + "target": "sha1-0e5e60f367cc8156ae48198c496b2b2ebdf5313d", + "transitive": true +,"camliSig":"wsBcBAABCAAQBQJRyFTeCRApy/NNAr6GZgAAKmgIAGbCCn1YPoZuqz+mcMaLN09J3rJYZPnjICp9at9UL7fFJ6izzDFLi6gq9ae/Kou51VRnuLYvRXGvqgZ9HCTTJiGaET8I6c3gBvQWMC/NOS/B9Y+CcZ5qEsz84Dk2D6zMIC9adQjN4yjtcsVtKYDVDQ5SCkCE6sOaUebGBS22TOhZMXPalIyzf2EPSiXdeEKtsMwg+sbd4EmpQHeE3XqzI8gbcsUX6VdCp6zU81Y71pNuYdmEVBPY5gVch2Xe1gJQICOatiAi4W/1nrTLB73sKEeulzRMbIDB4rgWooKKmnBPI1ZOTyg/fkKmfWfuJKSU0ySiPwVHn4aPFwCGrBRladE==KjfB"} diff --git a/website/camweb.go b/website/camweb.go index b6d88780e..f375032e2 100644 --- a/website/camweb.go +++ b/website/camweb.go @@ -42,19 +42,21 @@ const defaultAddr = ":31798" // default webserver address var h1TitlePattern = regexp.MustCompile(`

([^<]+)

`) var ( - httpAddr = flag.String("http", defaultAddr, "HTTP service address (e.g., '"+defaultAddr+"')") - httpsAddr = flag.String("https", "", "HTTPS service address") - root = flag.String("root", "", "Website root (parent of 'static', 'content', and 'tmpl") - gitwebScript = flag.String("gitwebscript", "/usr/lib/cgi-bin/gitweb.cgi", "Path to gitweb.cgi, or blank to disable.") - gitwebFiles = flag.String("gitwebfiles", "/usr/share/gitweb/static", "Path to gitweb's static files.") - logDir = flag.String("logdir", "", "Directory to write log files to (one per hour), or empty to not log.") - logStdout = flag.Bool("logstdout", true, "Write to stdout?") - tlsCertFile = flag.String("tlscert", "", "TLS cert file") - tlsKeyFile = flag.String("tlskey", "", "TLS private key file") - gerritUser = flag.String("gerrituser", "ubuntu", "Gerrit host's username") - gerritHost = flag.String("gerrithost", "", "Gerrit host, or empty.") - buildbotBackend = flag.String("buildbot_backend", "", "Build bot status backend URL") - buildbotHost = flag.String("buildbot_host", "", "Hostname to map to the buildbot_backend. If an HTTP request with this hostname is received, it proxies to buildbot_backend.") + httpAddr = flag.String("http", defaultAddr, "HTTP service address (e.g., '"+defaultAddr+"')") + httpsAddr = flag.String("https", "", "HTTPS service address") + root = flag.String("root", "", "Website root (parent of 'static', 'content', and 'tmpl") + gitwebScript = flag.String("gitwebscript", "/usr/lib/cgi-bin/gitweb.cgi", "Path to gitweb.cgi, or blank to disable.") + gitwebFiles = flag.String("gitwebfiles", "/usr/share/gitweb/static", "Path to gitweb's static files.") + logDir = flag.String("logdir", "", "Directory to write log files to (one per hour), or empty to not log.") + logStdout = flag.Bool("logstdout", true, "Write to stdout?") + tlsCertFile = flag.String("tlscert", "", "TLS cert file") + tlsKeyFile = flag.String("tlskey", "", "TLS private key file") + gerritUser = flag.String("gerrituser", "ubuntu", "Gerrit host's username") + gerritHost = flag.String("gerrithost", "", "Gerrit host, or empty.") + buildbotBackend = flag.String("buildbot_backend", "", "Build bot status backend URL") + buildbotHost = flag.String("buildbot_host", "", "Hostname to map to the buildbot_backend. If an HTTP request with this hostname is received, it proxies to buildbot_backend.") + alsoRun = flag.String("also_run", "", "Optional path to run as a child process. (Used to run camlistore.org's ./scripts/run-blob-server)") + pageHtml, errorHtml *template.Template packageHTML *txttemplate.Template ) @@ -272,6 +274,25 @@ func fixupGitwebFiles() { } } +// runAsChild runs res as a child process and +// does not wait for it to finish. +func runAsChild(res string) { + cmdName, err := exec.LookPath(res) + if err != nil { + log.Fatalf("Could not find %v in $PATH: %v", res, err) + } + cmd := exec.Command(cmdName) + log.Printf("Running %v", res) + if err := cmd.Start(); err != nil { + log.Fatal("Program %v failed to start: %v", res, err) + } + go func() { + if err := cmd.Wait(); err != nil { + log.Fatalf("Program %s did not end successfully: %v", res, err) + } + }() +} + func main() { flag.Parse() @@ -352,6 +373,10 @@ func main() { handler = NewLoggingHandler(handler, *logDir, *logStdout) } + if *alsoRun != "" { + runAsChild(*alsoRun) + } + errch := make(chan error) httpServer := &http.Server{ diff --git a/website/content/docs/sharing b/website/content/docs/sharing index dcdffc109..f28a2cb7d 100644 --- a/website/content/docs/sharing +++ b/website/content/docs/sharing @@ -1,6 +1,6 @@

Sharing

-

TODO: finish documenting this.

+

TODO: finish documenting this. In particular, add example with camget -shared.

The basic summary is that you create a claim that a user has access to @@ -36,22 +36,28 @@ Its metadata (inode, filename, etc) is blob sha1-0e5e60f367cc8156ae48198c496

Note also that any errors you get from my private blob server always delay for at least 200 ms to mask timing attacks that could otherwise reveal the existence or non-existence of a blob on my private server.

-

Now I want to share Hi.txt with you, so I create a share blob (e.g camput --share ).

+

Note that in order to have all of the following working, your server needs to have a share handler, so you need to have the line
+"shareHandler": true,
+in your server config.

-

I've created this, and its name is sha1-071fda36c1bd9e4595ed16ab5e2a46d44491f708

+

Now I want to share Hi.txt with you, so I create a share blob (e.g camput share --transitive sha1-0e5e60f367cc8156ae48198c496b2b2ebdf5313d).

-

Note that you can fetch it without authentication, because my blobserver knows I have it and that it's a share blob that doesn't require auth (authType == "haveref" ... like "Share with others that have the link")

+

I've created this, and its name is sha1-102758fb54521cb6540d256098e7c0f1625b33e3

+ +

Note that you can fetch it without authentication, because you're using the url prefix /share/, which delegates the task to the share handler, and because the share handler checks that it's a share blob that doesn't require auth (authType == "haveref" ... like "Share with others that have the link")

Here's you getting the blob:

-
$ curl http://camlistore.org:3179/camli/sha1-071fda36c1bd9e4595ed16ab5e2a46d44491f708
+
$ curl http://camlistore.org:3179/share/sha1-102758fb54521cb6540d256098e7c0f1625b33e3
 {"camliVersion": 1,
   "authType": "haveref",
-  "camliSigner": "sha1-f019d17dd308eebbd49fd94536eb67214c2f0587",
-  "camliType": "share",
+  "camliSigner": "sha1-3bee195d0dada92a9d88e67f731124238e65a916",
+  "camliType": "claim",
+  "claimDate": "2013-06-24T14:17:02.791613849Z",
+  "claimType": "share",
   "target": "sha1-0e5e60f367cc8156ae48198c496b2b2ebdf5313d",
   "transitive": true
-,"camliSig":"iQEcBAABAgAGBQJNQJGuAAoJEIUeCLJL7Fq1EuAIAL/nGoX8caGaANnam0bcIQT7C61wXMRW4qCCaFW+w67ys5z4ztfnTPKwL9ErzMF8Hd32Xe/bVcF6ZL38x/axqI7ehxN8lneKGQNoEdZDA9i752aAr0fkAba6eDehoOj9F4XxOzk3iVrq445jEXtu/+twamHV3UfRozWK1ZQb57dM+cRff47M/Y6VIBRSgW2BrABjuBs8G6PiKxycgh1mb+RL8f9KG+HB/yFuK37YJqZ0zU2OTRp6ELiOgTxbeg99koV9Duy4f4mQgxQgli46077Sv/ujzIeVbmdFL3OenGEzQnyKG0fhf8fa5WkED0XfH7zibAHLiSq3O7x11Q0406U==ANug"}
+,"camliSig":"wsBcBAABCAAQBQJRyFTeCRApy/NNAr6GZgAAKmgIAGbCCn1YPoZuqz+mcMaLN09J3rJYZPnjICp9at9UL7fFJ6izzDFLi6gq9ae/Kou51VRnuLYvRXGvqgZ9HCTTJiGaET8I6c3gBvQWMC/NOS/B9Y+CcZ5qEsz84Dk2D6zMIC9adQjN4yjtcsVtKYDVDQ5SCkCE6sOaUebGBS22TOhZMXPalIyzf2EPSiXdeEKtsMwg+sbd4EmpQHeE3XqzI8gbcsUX6VdCp6zU81Y71pNuYdmEVBPY5gVch2Xe1gJQICOatiAi4W/1nrTLB73sKEeulzRMbIDB4rgWooKKmnBPI1ZOTyg/fkKmfWfuJKSU0ySiPwVHn4aPFwCGrBRladE==KjfB"}

Note the "target" and "transitive".

@@ -59,7 +65,7 @@ Its metadata (inode, filename, etc) is blob sha1-0e5e60f367cc8156ae48198c496

Here's the first hop to the metadata, in which we discover the blobRef of the bytes of the file (in this case, just one part is the whole file bytes...) I already told you this earlier in the email, but assume you're just discovering this now.

-
$ curl http://camlistore.org:3179/camli/sha1-0e5e60f367cc8156ae48198c496b2b2ebdf5313d?via=sha1-071fda36c1bd9e4595ed16ab5e2a46d44491f708
+
$ curl http://camlistore.org:3179/share/sha1-0e5e60f367cc8156ae48198c496b2b2ebdf5313d?via=sha1-102758fb54521cb6540d256098e7c0f1625b33e3
 {"camliVersion": 1,
   "camliType": "file",
   "contentParts": [
@@ -80,7 +86,7 @@ Its metadata (inode, filename, etc) is blob sha1-0e5e60f367cc8156ae48198c496
 
 

Now let's get the final bytes of the file:

-
$ curl http://camlistore.org:3179/camli/sha1-3dc1d1cfe92fce5f09d194ba73a0b023102c9b25?via=sha1-071fda36c1bd9e4595ed16ab5e2a46d44491f708,sha1-0e5e60f367cc8156ae48198c496b2b2ebdf5313d
+
$ curl http://camlistore.org:3179/share/sha1-3dc1d1cfe92fce5f09d194ba73a0b023102c9b25?via=sha1-102758fb54521cb6540d256098e7c0f1625b33e3,sha1-0e5e60f367cc8156ae48198c496b2b2ebdf5313d
 Hello, Camli!

That's it.

diff --git a/website/run.pl b/website/run.pl index d07951100..e64d9bc7b 100755 --- a/website/run.pl +++ b/website/run.pl @@ -22,6 +22,7 @@ push @args, "--root=$Bin"; push @args, "--logdir=$logdir"; push @args, "--buildbot_host=build.camlistore.org"; push @args, "--buildbot_backend=http://c1.danga.com:8080"; +push @args, "--also_run=$Bin/scripts/run-blobserver"; if ($in_prod) { push @args, "--http=:8080"; push @args, "--https=:4430"; diff --git a/website/scripts/run-blobserver b/website/scripts/run-blobserver index 2b9443954..c606cf1e9 100755 --- a/website/scripts/run-blobserver +++ b/website/scripts/run-blobserver @@ -3,11 +3,14 @@ set -e Bin=$(dirname $( readlink -f $0)) -export CAMLI_PASSWORD=`cat $HOME/.camli/camorg-blobserver.pass` +export CAMLI_PASSWORD=`cat $HOME/.config/camlistore/camorg-blobserver.pass` export CAMLI_ROOT=$Bin/../blobserver-example/root -$Bin/../../build.pl server/go/camlistored && \ - $Bin/../../server/go/camlistored/camlistored \ - -configfile=$Bin/../blobserver-example/example-blobserver-config.json \ - -listen=:3179 "$@" +cd $Bin/../.. +go run make.go \ + -embed_static=false \ + -targets=camlistore.org/server/camlistored && \ +./bin/camlistored \ + -configfile=$Bin/../blobserver-example/example-blobserver-config.json \ + -listen=:3179 "$@"