crypt: Add --crypt-show-mapping to show encrypted file mapping
Fixes #1004
This commit is contained in:
parent
20c033b484
commit
390f3cf35b
2 changed files with 29 additions and 2 deletions
|
@ -12,6 +12,12 @@ import (
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Globals
|
||||||
|
var (
|
||||||
|
// Flags
|
||||||
|
cryptShowMapping = fs.BoolP("crypt-show-mapping", "", false, "For all files listed show how the names encrypt.")
|
||||||
|
)
|
||||||
|
|
||||||
// Register with Fs
|
// Register with Fs
|
||||||
func init() {
|
func init() {
|
||||||
fs.Register(&fs.RegInfo{
|
fs.Register(&fs.RegInfo{
|
||||||
|
@ -485,11 +491,14 @@ func (lo *ListOpts) Level() int {
|
||||||
// Multiple goroutines can safely add objects concurrently.
|
// Multiple goroutines can safely add objects concurrently.
|
||||||
func (lo *ListOpts) Add(obj fs.Object) (abort bool) {
|
func (lo *ListOpts) Add(obj fs.Object) (abort bool) {
|
||||||
remote := obj.Remote()
|
remote := obj.Remote()
|
||||||
_, err := lo.f.cipher.DecryptFileName(remote)
|
decryptedRemote, err := lo.f.cipher.DecryptFileName(remote)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fs.Debug(remote, "Skipping undecryptable file name: %v", err)
|
fs.Debug(remote, "Skipping undecryptable file name: %v", err)
|
||||||
return lo.ListOpts.IsFinished()
|
return lo.ListOpts.IsFinished()
|
||||||
}
|
}
|
||||||
|
if *cryptShowMapping {
|
||||||
|
fs.Log(decryptedRemote, "Encrypts to %q", remote)
|
||||||
|
}
|
||||||
return lo.ListOpts.Add(lo.f.newObject(obj))
|
return lo.ListOpts.Add(lo.f.newObject(obj))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -498,11 +507,14 @@ func (lo *ListOpts) Add(obj fs.Object) (abort bool) {
|
||||||
// Multiple goroutines can safely add objects concurrently.
|
// Multiple goroutines can safely add objects concurrently.
|
||||||
func (lo *ListOpts) AddDir(dir *fs.Dir) (abort bool) {
|
func (lo *ListOpts) AddDir(dir *fs.Dir) (abort bool) {
|
||||||
remote := dir.Name
|
remote := dir.Name
|
||||||
_, err := lo.f.cipher.DecryptDirName(remote)
|
decryptedRemote, err := lo.f.cipher.DecryptDirName(remote)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fs.Debug(remote, "Skipping undecryptable dir name: %v", err)
|
fs.Debug(remote, "Skipping undecryptable dir name: %v", err)
|
||||||
return lo.ListOpts.IsFinished()
|
return lo.ListOpts.IsFinished()
|
||||||
}
|
}
|
||||||
|
if *cryptShowMapping {
|
||||||
|
fs.Log(decryptedRemote, "Encrypts to %q", remote)
|
||||||
|
}
|
||||||
return lo.ListOpts.AddDir(lo.f.newDir(dir))
|
return lo.ListOpts.AddDir(lo.f.newDir(dir))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -236,6 +236,21 @@ depends on that.
|
||||||
Hashes are not stored for crypt. However the data integrity is
|
Hashes are not stored for crypt. However the data integrity is
|
||||||
protected by an extremely strong crypto authenticator.
|
protected by an extremely strong crypto authenticator.
|
||||||
|
|
||||||
|
### Specific options ###
|
||||||
|
|
||||||
|
Here are the command line options specific to this cloud storage
|
||||||
|
system.
|
||||||
|
|
||||||
|
#### --crypt-show-mapping ####
|
||||||
|
|
||||||
|
If this flag is set then for each file that the remote is asked to
|
||||||
|
list, it will log (at level INFO) a line stating the decrypted file
|
||||||
|
name and the encrypted file name.
|
||||||
|
|
||||||
|
This is so you can work out which encrypted names are which decrypted
|
||||||
|
names just in case you need to do something with the encrypted file
|
||||||
|
names, or for debugging purposes.
|
||||||
|
|
||||||
## File formats ##
|
## File formats ##
|
||||||
|
|
||||||
### File encryption ###
|
### File encryption ###
|
||||||
|
|
Loading…
Reference in a new issue