From a384ff188dd104d2e2f73560e0b87070e93a8034 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Mon, 20 Jan 2014 13:47:08 -0800 Subject: [PATCH] Get rid of CAMLI_DEV_KEYBLOBS / keyblobs / etc. Fixes camlistore.org/issue/277 Change-Id: I7f380f9d18785f600fa0c442d5a19cd118782788 --- cmd/camput/init.go | 16 ---------------- config/dev-client-dir/keyblobs/.gitignore | 1 - config/dev-client-dir/keyblobs/README | 3 --- dev/devcam/env.go | 1 - dev/devcam/test.go | 23 ----------------------- doc/environment-vars.txt | 4 ---- pkg/blob/fetcher.go | 5 ----- pkg/client/config.go | 23 +---------------------- pkg/osutil/paths.go | 10 ---------- pkg/test/world.go | 1 - 10 files changed, 1 insertion(+), 86 deletions(-) delete mode 100644 config/dev-client-dir/keyblobs/.gitignore delete mode 100644 config/dev-client-dir/keyblobs/README diff --git a/cmd/camput/init.go b/cmd/camput/init.go index fbf23b93e..45a2e5019 100644 --- a/cmd/camput/init.go +++ b/cmd/camput/init.go @@ -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 { diff --git a/config/dev-client-dir/keyblobs/.gitignore b/config/dev-client-dir/keyblobs/.gitignore deleted file mode 100644 index 5bf2f7d0b..000000000 --- a/config/dev-client-dir/keyblobs/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.camli diff --git a/config/dev-client-dir/keyblobs/README b/config/dev-client-dir/keyblobs/README deleted file mode 100644 index 4c51f8c1b..000000000 --- a/config/dev-client-dir/keyblobs/README +++ /dev/null @@ -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) diff --git a/dev/devcam/env.go b/dev/devcam/env.go index 2a8d2de19..0880933a1 100644 --- a/dev/devcam/env.go +++ b/dev/devcam/env.go @@ -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 diff --git a/dev/devcam/test.go b/dev/devcam/test.go index 4dc19b745..dc32e9047 100644 --- a/dev/devcam/test.go +++ b/dev/devcam/test.go @@ -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") { diff --git a/doc/environment-vars.txt b/doc/environment-vars.txt index 579869a3c..b89791e30 100644 --- a/doc/environment-vars.txt +++ b/doc/environment-vars.txt @@ -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. diff --git a/pkg/blob/fetcher.go b/pkg/blob/fetcher.go index fb01c355d..c1f383891 100644 --- a/pkg/blob/fetcher.go +++ b/pkg/blob/fetcher.go @@ -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 } diff --git a/pkg/client/config.go b/pkg/client/config.go index 49d526615..b2a13ce3a 100644 --- a/pkg/client/config.go +++ b/pkg/client/config.go @@ -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 } diff --git a/pkg/osutil/paths.go b/pkg/osutil/paths.go index 6f1c101c5..016235702 100644 --- a/pkg/osutil/paths.go +++ b/pkg/osutil/paths.go @@ -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. diff --git a/pkg/test/world.go b/pkg/test/world.go index ef63beca7..41f12e824 100644 --- a/pkg/test/world.go +++ b/pkg/test/world.go @@ -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: