Get rid of CAMLI_DEV_KEYBLOBS / keyblobs / etc.

Fixes camlistore.org/issue/277

Change-Id: I7f380f9d18785f600fa0c442d5a19cd118782788
This commit is contained in:
Brad Fitzpatrick 2014-01-20 13:47:08 -08:00
parent d5ec2925dd
commit a384ff188d
10 changed files with 1 additions and 86 deletions

View File

@ -21,11 +21,9 @@ import (
"errors"
"flag"
"fmt"
"io/ioutil"
"log"
"os"
"os/exec"
"path"
"camlistore.org/pkg/blob"
"camlistore.org/pkg/cmdmain"
@ -128,11 +126,6 @@ func (c *initCmd) RunCommand(args []string) error {
log.Fatal("--newkey and --gpgkey are mutually exclusive")
}
blobDir := osutil.KeyBlobsDir()
if err := os.MkdirAll(blobDir, 0700); err != nil {
return err
}
var keyId string
var err error
secRing := osutil.IdentitySecretRing()
@ -155,15 +148,6 @@ func (c *initCmd) RunCommand(args []string) error {
bref := blob.SHA1FromString(string(pubArmor))
keyBlobPath := path.Join(blobDir, bref.String()+".camli")
if err = ioutil.WriteFile(keyBlobPath, pubArmor, 0644); err != nil {
log.Fatalf("Error writing public key blob to %q: %v", keyBlobPath, err)
}
if ok, err := jsonsign.VerifyPublicKeyFile(keyBlobPath, keyId); !ok {
log.Fatalf("Error verifying public key at %q: %v", keyBlobPath, err)
}
log.Printf("Your Camlistore identity (your GPG public key's blobref) is: %s", bref.String())
if c.noconfig {

View File

@ -1 +0,0 @@
*.camli

View File

@ -1,3 +0,0 @@
This directory is empty in git (except for this file and .gitignore).
It should be populated by the camli client tools (e.g. devcam put)

View File

@ -89,7 +89,6 @@ func NewCopyEnv() *Env {
func (e *Env) SetCamdevVars(altkey bool) {
e.Set("CAMLI_CONFIG_DIR", filepath.Join("config", "dev-client-dir"))
e.Set("CAMLI_AUTH", "userpass:camlistore:pass3179")
e.Set("CAMLI_DEV_KEYBLOBS", filepath.FromSlash("config/dev-client-dir/keyblobs"))
secring := defaultSecring
identity := defaultIdentity

View File

@ -68,9 +68,6 @@ func (c *testCmd) RunCommand(args []string) error {
if err := c.buildSelf(); err != nil {
return err
}
if err := c.genKeyBlob(); err != nil {
return err
}
if err := c.runTests(); err != nil {
return err
}
@ -121,26 +118,6 @@ func (c *testCmd) buildSelf() error {
return nil
}
func (c *testCmd) genKeyBlob() error {
cmdBin := filepath.FromSlash("./bin/devcam")
args := []string{
"put",
"init",
"--gpgkey=" + defaultIdentity,
"--noconfig",
}
cmd := exec.Command(cmdBin, args...)
env := c.env()
env.Set("CAMLI_SECRET_RING", filepath.FromSlash(defaultSecring))
cmd.Env = env.Flat()
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if err := cmd.Run(); err != nil {
return fmt.Errorf("Error generating keyblobs: %v", err)
}
return nil
}
func (c *testCmd) runTests() error {
args := []string{"test"}
if !strings.HasSuffix(c.buildGoPath, "-nosqlite") {

View File

@ -60,10 +60,6 @@ CAMLI_DEV_CLOSURE_DIR (string):
Path override for pkg/server. If specified, this path will be used to serve
the closure handler.
CAMLI_DEV_KEYBLOBS (string):
Path to keyblobs directory.
Used by pkg/client to override 'selfPubKeyDir' value in configuration files.
CAMLI_HTTP_DEBUG (bool):
Enable per-request logging in pkg/webserver.

View File

@ -28,7 +28,6 @@ import (
"sync"
"camlistore.org/pkg/constants"
"camlistore.org/pkg/osutil"
"camlistore.org/pkg/types"
)
@ -110,10 +109,6 @@ func NewSimpleDirectoryFetcher(dir string) *DirFetcher {
return &DirFetcher{dir, "camli"}
}
func NewConfigDirFetcher() *DirFetcher {
return NewSimpleDirectoryFetcher(osutil.KeyBlobsDir())
}
type serialFetcher struct {
fetchers []SeekFetcher
}

View File

@ -20,7 +20,6 @@ import (
"errors"
"flag"
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
@ -377,27 +376,7 @@ func (c *Client) initSignerPublicKeyBlobref() {
log.Fatalf("Error serializing public key: %v", err)
}
// TODO(mpl): completely get rid of it if possible
// http://camlistore.org/issue/377
selfPubKeyDir := osutil.KeyBlobsDir()
fi, err := os.Stat(selfPubKeyDir)
if err != nil || !fi.IsDir() {
log.Fatalf("selfPubKeyDir as %q doesn't exist or not a directory", selfPubKeyDir)
}
br := blob.SHA1FromString(armored)
pubFile := filepath.Join(selfPubKeyDir, br.String()+".camli")
fi, err = os.Stat(pubFile)
if err != nil {
if !os.IsNotExist(err) {
log.Fatalf("Could not stat %q: %v", pubFile, err)
}
err = ioutil.WriteFile(pubFile, []byte(armored), 0644)
if err != nil {
log.Fatalf("Error writing public key to %q: %v", pubFile, err)
}
}
c.signerPublicKeyRef = br
c.signerPublicKeyRef = blob.SHA1FromString(armored)
c.publicKeyArmored = armored
}

View File

@ -128,16 +128,6 @@ func IdentitySecretRing() string {
return filepath.Join(CamliConfigDir(), "identity-secring.gpg")
}
// KeyBlobsDir returns the path to the directory containing
// the blob(s) for the public gpg key(s). It is overriden by
// the CAMLI_DEV_KEYBLOBS environment variable.
func KeyBlobsDir() string {
if e := os.Getenv("CAMLI_DEV_KEYBLOBS"); e != "" {
return e
}
return filepath.Join(CamliConfigDir(), "keyblobs")
}
// DefaultTLSCert returns the path to the default TLS certificate
// file that is used (creating if necessary) when TLS is specified
// without the cert file.

View File

@ -178,7 +178,6 @@ func (w *World) CmdWithEnv(binary string, env []string, args ...string) *exec.Cm
"CAMLI_SERVER=" + w.ServerBaseURL(),
"CAMLI_SECRET_RING=" + filepath.Join(w.camRoot, "pkg", "jsonsign", "testdata", "test-secring.gpg"),
"CAMLI_KEYID=26F5ABDA",
"CAMLI_DEV_KEYBLOBS=" + filepath.Join(clientConfigDir, "keyblobs"),
"CAMLI_AUTH=userpass:testuser:passTestWorld",
}, env...)
default: