mirror of https://github.com/perkeep/perkeep.git
jsonsign: use wkfs.Open instead of os.Open directly, so it can open GCS files
Change-Id: Ie447207b33790dd458c1e27d5517e0c88dbaf27c
This commit is contained in:
parent
966d25cb62
commit
7d7eb4d28e
|
@ -27,7 +27,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"camlistore.org/pkg/osutil"
|
"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"
|
||||||
"camlistore.org/third_party/code.google.com/p/go.crypto/openpgp/armor"
|
"camlistore.org/third_party/code.google.com/p/go.crypto/openpgp/armor"
|
||||||
"camlistore.org/third_party/code.google.com/p/go.crypto/openpgp/packet"
|
"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) {
|
func VerifyPublicKeyFile(file, keyid string) (bool, error) {
|
||||||
f, err := os.Open(file)
|
f, err := wkfs.Open(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ func EntityFromSecring(keyId, keyFile string) (*openpgp.Entity, error) {
|
||||||
if keyFile == "" {
|
if keyFile == "" {
|
||||||
keyFile = osutil.SecretRingFile()
|
keyFile = osutil.SecretRingFile()
|
||||||
}
|
}
|
||||||
secring, err := os.Open(keyFile)
|
secring, err := wkfs.Open(keyFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("jsonsign: failed to open keyring: %v", err)
|
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
|
// ring file secRing. It expects only one keyId in this secret ring
|
||||||
// and returns an error otherwise.
|
// and returns an error otherwise.
|
||||||
func KeyIdFromRing(secRing string) (keyId string, err error) {
|
func KeyIdFromRing(secRing string) (keyId string, err error) {
|
||||||
f, err := os.Open(secRing)
|
f, err := wkfs.Open(secRing)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("Could not open secret ring file %v: %v", secRing, err)
|
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 {
|
if err := os.MkdirAll(filepath.Dir(secRing), 0700); err != nil {
|
||||||
return "", err
|
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 {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,6 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
@ -29,6 +28,7 @@ import (
|
||||||
|
|
||||||
"camlistore.org/pkg/blob"
|
"camlistore.org/pkg/blob"
|
||||||
"camlistore.org/pkg/osutil"
|
"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"
|
||||||
"camlistore.org/third_party/code.google.com/p/go.crypto/openpgp/packet"
|
"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) {
|
func (fe *FileEntityFetcher) FetchEntity(keyId string) (*openpgp.Entity, error) {
|
||||||
f, err := os.Open(fe.File)
|
f, err := wkfs.Open(fe.File)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("jsonsign: FetchEntity: %v", err)
|
return nil, fmt.Errorf("jsonsign: FetchEntity: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -182,7 +182,7 @@ func (sr *SignRequest) Sign() (signedJSON string, err error) {
|
||||||
if file == "" {
|
if file == "" {
|
||||||
return "", errors.New("jsonsign: no EntityFetcher, and no secret ring file defined.")
|
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 {
|
if err != nil {
|
||||||
return "", fmt.Errorf("jsonsign: failed to open secret ring file %q: %v", sr.secretRingPath(), err)
|
return "", fmt.Errorf("jsonsign: failed to open secret ring file %q: %v", sr.secretRingPath(), err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue