jsonsign: use wkfs.Open instead of os.Open directly, so it can open GCS files

Change-Id: Ie447207b33790dd458c1e27d5517e0c88dbaf27c
This commit is contained in:
Brad Fitzpatrick 2014-08-05 19:27:01 -07:00
parent 966d25cb62
commit 7d7eb4d28e
2 changed files with 8 additions and 8 deletions

View File

@ -27,7 +27,7 @@ import (
"strings"
"camlistore.org/pkg/osutil"
"camlistore.org/pkg/wkfs"
"camlistore.org/third_party/code.google.com/p/go.crypto/openpgp"
"camlistore.org/third_party/code.google.com/p/go.crypto/openpgp/armor"
"camlistore.org/third_party/code.google.com/p/go.crypto/openpgp/packet"
@ -49,7 +49,7 @@ func ParseArmoredPublicKey(r io.Reader) (shortKeyId, armoredKey string, err erro
}
func VerifyPublicKeyFile(file, keyid string) (bool, error) {
f, err := os.Open(file)
f, err := wkfs.Open(file)
if err != nil {
return false, err
}
@ -105,7 +105,7 @@ func EntityFromSecring(keyId, keyFile string) (*openpgp.Entity, error) {
if keyFile == "" {
keyFile = osutil.SecretRingFile()
}
secring, err := os.Open(keyFile)
secring, err := wkfs.Open(keyFile)
if err != nil {
return nil, fmt.Errorf("jsonsign: failed to open keyring: %v", err)
}
@ -177,7 +177,7 @@ func WriteKeyRing(w io.Writer, el openpgp.EntityList) error {
// ring file secRing. It expects only one keyId in this secret ring
// and returns an error otherwise.
func KeyIdFromRing(secRing string) (keyId string, err error) {
f, err := os.Open(secRing)
f, err := wkfs.Open(secRing)
if err != nil {
return "", fmt.Errorf("Could not open secret ring file %v: %v", secRing, err)
}
@ -204,7 +204,7 @@ func GenerateNewSecRing(secRing string) (keyId string, err error) {
if err := os.MkdirAll(filepath.Dir(secRing), 0700); err != nil {
return "", err
}
f, err := os.OpenFile(secRing, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0600)
f, err := wkfs.OpenFile(secRing, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0600)
if err != nil {
return "", err
}

View File

@ -21,7 +21,6 @@ import (
"encoding/json"
"errors"
"fmt"
"os"
"strings"
"sync"
"time"
@ -29,6 +28,7 @@ import (
"camlistore.org/pkg/blob"
"camlistore.org/pkg/osutil"
"camlistore.org/pkg/wkfs"
"camlistore.org/third_party/code.google.com/p/go.crypto/openpgp"
"camlistore.org/third_party/code.google.com/p/go.crypto/openpgp/packet"
)
@ -77,7 +77,7 @@ func (ce *CachingEntityFetcher) FetchEntity(keyId string) (*openpgp.Entity, erro
}
func (fe *FileEntityFetcher) FetchEntity(keyId string) (*openpgp.Entity, error) {
f, err := os.Open(fe.File)
f, err := wkfs.Open(fe.File)
if err != nil {
return nil, fmt.Errorf("jsonsign: FetchEntity: %v", err)
}
@ -182,7 +182,7 @@ func (sr *SignRequest) Sign() (signedJSON string, err error) {
if file == "" {
return "", errors.New("jsonsign: no EntityFetcher, and no secret ring file defined.")
}
secring, err := os.Open(sr.secretRingPath())
secring, err := wkfs.Open(sr.secretRingPath())
if err != nil {
return "", fmt.Errorf("jsonsign: failed to open secret ring file %q: %v", sr.secretRingPath(), err)
}