Merge "website: added -also_run to camweb and fixed sharing doc"

This commit is contained in:
mpl 2013-06-25 22:32:22 +00:00 committed by Gerrit Code Review
commit dccd401ff0
7 changed files with 90 additions and 46 deletions

View File

@ -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": "/"
}
}
}
}

View File

@ -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"}

View File

@ -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"}

View File

@ -42,19 +42,21 @@ const defaultAddr = ":31798" // default webserver address
var h1TitlePattern = regexp.MustCompile(`<h1>([^<]+)</h1>`)
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{

View File

@ -1,6 +1,6 @@
<h1>Sharing</h1>
<p><b>TODO:</b> finish documenting this.</p>
<p><b>TODO:</b> finish documenting this. In particular, add example with camget -shared.</p>
<p>The basic summary is that you create
a <a href="/docs/terms#claim">claim</a> that a user has access to
@ -36,22 +36,28 @@ Its metadata (inode, filename, etc) is blob <tt>sha1-0e5e60f367cc8156ae48198c496
<p>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.</p>
<p>Now I want to share Hi.txt with you, so I create a share blob (e.g <tt><a href="/cmd/camput">camput</a> --share <blob></tt>).</p>
<p>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</br>
<b><code>"shareHandler"</code></b>: true,</br>
in your server <a href="/docs/server-config">config</a>.</p>
<p>I've created this, and its name is <tt>sha1-071fda36c1bd9e4595ed16ab5e2a46d44491f708</tt></p>
<p>Now I want to share Hi.txt with you, so I create a share blob (e.g <tt><a href="/cmd/camput">camput</a> share --transitive sha1-0e5e60f367cc8156ae48198c496b2b2ebdf5313d</tt>).</p>
<p>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 (<tt>authType</tt> == "haveref" ... like "Share with others that have the link")</p>
<p>I've created this, and its name is <tt>sha1-102758fb54521cb6540d256098e7c0f1625b33e3</tt></p>
<p>Note that you can fetch it without authentication, because you're using the url prefix <code>/share/</code>, 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 (<tt>authType</tt> == "haveref" ... like "Share with others that have the link")</p>
<p>Here's you getting the blob:</p>
<pre class='sty' style='overflow: auto'>$ curl <a href="http://camlistore.org:3179/camli/sha1-071fda36c1bd9e4595ed16ab5e2a46d44491f708">http://camlistore.org:3179/camli/sha1-071fda36c1bd9e4595ed16ab5e2a46d44491f708</a>
<pre class='sty' style='overflow: auto'>$ curl <a href="http://camlistore.org:3179/share/sha1-102758fb54521cb6540d256098e7c0f1625b33e3">http://camlistore.org:3179/share/sha1-102758fb54521cb6540d256098e7c0f1625b33e3</a>
{"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"}</pre>
,"camliSig":"wsBcBAABCAAQBQJRyFTeCRApy/NNAr6GZgAAKmgIAGbCCn1YPoZuqz+mcMaLN09J3rJYZPnjICp9at9UL7fFJ6izzDFLi6gq9ae/Kou51VRnuLYvRXGvqgZ9HCTTJiGaET8I6c3gBvQWMC/NOS/B9Y+CcZ5qEsz84Dk2D6zMIC9adQjN4yjtcsVtKYDVDQ5SCkCE6sOaUebGBS22TOhZMXPalIyzf2EPSiXdeEKtsMwg+sbd4EmpQHeE3XqzI8gbcsUX6VdCp6zU81Y71pNuYdmEVBPY5gVch2Xe1gJQICOatiAi4W/1nrTLB73sKEeulzRMbIDB4rgWooKKmnBPI1ZOTyg/fkKmfWfuJKSU0ySiPwVHn4aPFwCGrBRladE==KjfB"}</pre>
<p>Note the "target" and "transitive".</p>
@ -59,7 +65,7 @@ Its metadata (inode, filename, etc) is blob <tt>sha1-0e5e60f367cc8156ae48198c496
<p>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.</p>
<pre class='sty' style='overflow: auto'>$ curl <a href="http://camlistore.org:3179/camli/sha1-0e5e60f367cc8156ae48198c496b2b2ebdf5313d?via=sha1-071fda36c1bd9e4595ed16ab5e2a46d44491f708">http://camlistore.org:3179/camli/sha1-0e5e60f367cc8156ae48198c496b2b2ebdf5313d<b>?via=</b>sha1-071fda36c1bd9e4595ed16ab5e2a46d44491f708</a>
<pre class='sty' style='overflow: auto'>$ curl <a href="http://camlistore.org:3179/share/sha1-0e5e60f367cc8156ae48198c496b2b2ebdf5313d?via=sha1-102758fb54521cb6540d256098e7c0f1625b33e3">http://camlistore.org:3179/share/sha1-0e5e60f367cc8156ae48198c496b2b2ebdf5313d<b>?via=</b>sha1-102758fb54521cb6540d256098e7c0f1625b33e3</a>
{"camliVersion": 1,
"camliType": "file",
"contentParts": [
@ -80,7 +86,7 @@ Its metadata (inode, filename, etc) is blob <tt>sha1-0e5e60f367cc8156ae48198c496
<p>Now let's get the final bytes of the file:</p>
<pre class='sty' style='overflow: auto'>$ curl <a href="http://camlistore.org:3179/camli/sha1-3dc1d1cfe92fce5f09d194ba73a0b023102c9b25?via=sha1-071fda36c1bd9e4595ed16ab5e2a46d44491f708,sha1-0e5e60f367cc8156ae48198c496b2b2ebdf5313d">http://camlistore.org:3179/camli/sha1-3dc1d1cfe92fce5f09d194ba73a0b023102c9b25<b>?via=</b>sha1-071fda36c1bd9e4595ed16ab5e2a46d44491f708,sha1-0e5e60f367cc8156ae48198c496b2b2ebdf5313d</a>
<pre class='sty' style='overflow: auto'>$ curl <a href="http://camlistore.org:3179/share/sha1-3dc1d1cfe92fce5f09d194ba73a0b023102c9b25?via=sha1-102758fb54521cb6540d256098e7c0f1625b33e3,sha1-0e5e60f367cc8156ae48198c496b2b2ebdf5313d">http://camlistore.org:3179/share/sha1-3dc1d1cfe92fce5f09d194ba73a0b023102c9b25<b>?via=</b>sha1-102758fb54521cb6540d256098e7c0f1625b33e3,sha1-0e5e60f367cc8156ae48198c496b2b2ebdf5313d</a>
Hello, Camli!</pre>
<p>That's it.</p>

View File

@ -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";

View File

@ -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 "$@"