aboutsummaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
Diffstat (limited to 'internal')
-rw-r--r--internal/configfile/config_file.go10
-rw-r--r--internal/configfile/config_test.go4
-rw-r--r--internal/configfile/kdf.go4
-rw-r--r--internal/contentenc/content.go10
-rw-r--r--internal/contentenc/offsets.go6
-rw-r--r--internal/cryptocore/gcm_go1.4.go6
-rw-r--r--internal/cryptocore/nonce.go4
-rw-r--r--internal/fusefrontend/compat_linux.go4
-rw-r--r--internal/fusefrontend/file.go60
-rw-r--r--internal/fusefrontend/file_holes.go4
-rw-r--r--internal/fusefrontend/fs.go26
-rw-r--r--internal/fusefrontend/fs_dir.go34
-rw-r--r--internal/fusefrontend/names.go8
-rw-r--r--internal/nametransform/longnames.go10
-rw-r--r--internal/nametransform/names_diriv.go12
-rw-r--r--internal/prefer_openssl/prefer.go6
-rw-r--r--internal/readpassword/extpass_test.go4
-rw-r--r--internal/readpassword/read.go22
-rw-r--r--internal/tlog/log.go (renamed from internal/toggledlog/log.go)2
-rw-r--r--internal/tlog/log_go1.4.go (renamed from internal/toggledlog/log_go1.4.go)2
-rw-r--r--internal/tlog/log_go1.5.go (renamed from internal/toggledlog/log_go1.5.go)2
21 files changed, 120 insertions, 120 deletions
diff --git a/internal/configfile/config_file.go b/internal/configfile/config_file.go
index ea023d0..1753cf3 100644
--- a/internal/configfile/config_file.go
+++ b/internal/configfile/config_file.go
@@ -7,7 +7,7 @@ import (
"github.com/rfjakob/gocryptfs/internal/contentenc"
"github.com/rfjakob/gocryptfs/internal/cryptocore"
- "github.com/rfjakob/gocryptfs/internal/toggledlog"
+ "github.com/rfjakob/gocryptfs/internal/tlog"
)
import "os"
@@ -84,7 +84,7 @@ func LoadConfFile(filename string, password string) ([]byte, *ConfFile, error) {
// Unmarshal
err = json.Unmarshal(js, &cf)
if err != nil {
- toggledlog.Warn.Printf("Failed to unmarshal config file")
+ tlog.Warn.Printf("Failed to unmarshal config file")
return nil, nil, err
}
@@ -135,11 +135,11 @@ func LoadConfFile(filename string, password string) ([]byte, *ConfFile, error) {
cc := cryptocore.New(scryptHash, false, false)
ce := contentenc.New(cc, 4096)
- toggledlog.Warn.Enabled = false // Silence DecryptBlock() error messages on incorrect password
+ tlog.Warn.Enabled = false // Silence DecryptBlock() error messages on incorrect password
key, err := ce.DecryptBlock(cf.EncryptedKey, 0, nil)
- toggledlog.Warn.Enabled = true
+ tlog.Warn.Enabled = true
if err != nil {
- toggledlog.Warn.Printf("failed to unlock master key: %s", err.Error())
+ tlog.Warn.Printf("failed to unlock master key: %s", err.Error())
return nil, nil, fmt.Errorf("Password incorrect.")
}
diff --git a/internal/configfile/config_test.go b/internal/configfile/config_test.go
index d0540c3..775a616 100644
--- a/internal/configfile/config_test.go
+++ b/internal/configfile/config_test.go
@@ -5,7 +5,7 @@ import (
"testing"
"time"
- "github.com/rfjakob/gocryptfs/internal/toggledlog"
+ "github.com/rfjakob/gocryptfs/internal/tlog"
)
func TestLoadV1(t *testing.T) {
@@ -35,7 +35,7 @@ func TestLoadV2(t *testing.T) {
func TestLoadV2PwdError(t *testing.T) {
if !testing.Verbose() {
- toggledlog.Warn.Enabled = false
+ tlog.Warn.Enabled = false
}
_, _, err := LoadConfFile("config_test/v2.conf", "wrongpassword")
if err == nil {
diff --git a/internal/configfile/kdf.go b/internal/configfile/kdf.go
index e77a743..ca87975 100644
--- a/internal/configfile/kdf.go
+++ b/internal/configfile/kdf.go
@@ -8,7 +8,7 @@ import (
"golang.org/x/crypto/scrypt"
"github.com/rfjakob/gocryptfs/internal/cryptocore"
- "github.com/rfjakob/gocryptfs/internal/toggledlog"
+ "github.com/rfjakob/gocryptfs/internal/tlog"
)
const (
@@ -32,7 +32,7 @@ func NewScryptKdf(logN int) scryptKdf {
s.N = 1 << ScryptDefaultLogN
} else {
if logN < 10 {
- toggledlog.Fatal.Println("Error: scryptn below 10 is too low to make sense. Aborting.")
+ tlog.Fatal.Println("Error: scryptn below 10 is too low to make sense. Aborting.")
os.Exit(1)
}
s.N = 1 << uint32(logN)
diff --git a/internal/contentenc/content.go b/internal/contentenc/content.go
index dd6aa26..5bac2a2 100644
--- a/internal/contentenc/content.go
+++ b/internal/contentenc/content.go
@@ -8,7 +8,7 @@ import (
"encoding/hex"
"errors"
- "github.com/rfjakob/gocryptfs/internal/toggledlog"
+ "github.com/rfjakob/gocryptfs/internal/tlog"
)
// DecryptBlocks - Decrypt a number of blocks
@@ -42,12 +42,12 @@ func (be *ContentEnc) DecryptBlock(ciphertext []byte, blockNo uint64, fileId []b
// All-zero block?
if bytes.Equal(ciphertext, be.allZeroBlock) {
- toggledlog.Debug.Printf("DecryptBlock: file hole encountered")
+ tlog.Debug.Printf("DecryptBlock: file hole encountered")
return make([]byte, be.plainBS), nil
}
if len(ciphertext) < be.cryptoCore.IVLen {
- toggledlog.Warn.Printf("DecryptBlock: Block is too short: %d bytes", len(ciphertext))
+ tlog.Warn.Printf("DecryptBlock: Block is too short: %d bytes", len(ciphertext))
return nil, errors.New("Block is too short")
}
@@ -64,8 +64,8 @@ func (be *ContentEnc) DecryptBlock(ciphertext []byte, blockNo uint64, fileId []b
plaintext, err := be.cryptoCore.Gcm.Open(plaintext, nonce, ciphertext, aData)
if err != nil {
- toggledlog.Warn.Printf("DecryptBlock: %s, len=%d", err.Error(), len(ciphertextOrig))
- toggledlog.Debug.Println(hex.Dump(ciphertextOrig))
+ tlog.Warn.Printf("DecryptBlock: %s, len=%d", err.Error(), len(ciphertextOrig))
+ tlog.Debug.Println(hex.Dump(ciphertextOrig))
return nil, err
}
diff --git a/internal/contentenc/offsets.go b/internal/contentenc/offsets.go
index cfb1c69..da0551a 100644
--- a/internal/contentenc/offsets.go
+++ b/internal/contentenc/offsets.go
@@ -1,7 +1,7 @@
package contentenc
import (
- "github.com/rfjakob/gocryptfs/internal/toggledlog"
+ "github.com/rfjakob/gocryptfs/internal/tlog"
)
// Contentenc methods that translate offsets between ciphertext and plaintext
@@ -35,12 +35,12 @@ func (be *ContentEnc) CipherSizeToPlainSize(cipherSize uint64) uint64 {
}
if cipherSize == HEADER_LEN {
- toggledlog.Warn.Printf("cipherSize %d == header size: interrupted write?\n", cipherSize)
+ tlog.Warn.Printf("cipherSize %d == header size: interrupted write?\n", cipherSize)
return 0
}
if cipherSize < HEADER_LEN {
- toggledlog.Warn.Printf("cipherSize %d < header size %d: corrupt file\n", cipherSize, HEADER_LEN)
+ tlog.Warn.Printf("cipherSize %d < header size %d: corrupt file\n", cipherSize, HEADER_LEN)
return 0
}
diff --git a/internal/cryptocore/gcm_go1.4.go b/internal/cryptocore/gcm_go1.4.go
index aaae259..f7b77b2 100644
--- a/internal/cryptocore/gcm_go1.4.go
+++ b/internal/cryptocore/gcm_go1.4.go
@@ -7,7 +7,7 @@ import (
"crypto/cipher"
"fmt"
- "github.com/rfjakob/gocryptfs/internal/toggledlog"
+ "github.com/rfjakob/gocryptfs/internal/tlog"
)
// goGCMWrapper - This wrapper makes sure gocryptfs can be compiled on Go
@@ -16,8 +16,8 @@ import (
// compiled on 1.4.
func goGCMWrapper(bc cipher.Block, nonceSize int) (cipher.AEAD, error) {
if nonceSize != 12 {
- toggledlog.Warn.Printf("128 bit GCM IVs are not supported by Go 1.4 and lower.")
- toggledlog.Warn.Printf("Please use openssl crypto or recompile using a newer Go runtime.")
+ tlog.Warn.Printf("128 bit GCM IVs are not supported by Go 1.4 and lower.")
+ tlog.Warn.Printf("Please use openssl crypto or recompile using a newer Go runtime.")
return nil, fmt.Errorf("128 bit GCM IVs are not supported by Go 1.4 and lower")
}
return cipher.NewGCM(bc)
diff --git a/internal/cryptocore/nonce.go b/internal/cryptocore/nonce.go
index 72d8588..6b0c31d 100644
--- a/internal/cryptocore/nonce.go
+++ b/internal/cryptocore/nonce.go
@@ -7,7 +7,7 @@ import (
"encoding/hex"
"fmt"
- "github.com/rfjakob/gocryptfs/internal/toggledlog"
+ "github.com/rfjakob/gocryptfs/internal/tlog"
)
// Get "n" random bytes from /dev/urandom or panic
@@ -34,7 +34,7 @@ type nonceGenerator struct {
// Get a random "nonceLen"-byte nonce
func (n *nonceGenerator) Get() []byte {
nonce := RandBytes(n.nonceLen)
- toggledlog.Debug.Printf("nonceGenerator.Get(): %s\n", hex.EncodeToString(nonce))
+ tlog.Debug.Printf("nonceGenerator.Get(): %s\n", hex.EncodeToString(nonce))
if bytes.Equal(nonce, n.lastNonce) {
m := fmt.Sprintf("Got the same nonce twice: %s. This should never happen!", hex.EncodeToString(nonce))
panic(m)
diff --git a/internal/fusefrontend/compat_linux.go b/internal/fusefrontend/compat_linux.go
index 8a20d5d..9a8684f 100644
--- a/internal/fusefrontend/compat_linux.go
+++ b/internal/fusefrontend/compat_linux.go
@@ -5,7 +5,7 @@ import (
"syscall"
)
-import "github.com/rfjakob/gocryptfs/internal/toggledlog"
+import "github.com/rfjakob/gocryptfs/internal/tlog"
var preallocWarn sync.Once
@@ -24,7 +24,7 @@ func prealloc(fd int, off int64, len int64) (err error) {
// ZFS does not support fallocate which caused gocryptfs to abort
// every write operation: https://github.com/rfjakob/gocryptfs/issues/22
preallocWarn.Do(func() {
- toggledlog.Warn.Printf("Warning: The underlying filesystem " +
+ tlog.Warn.Printf("Warning: The underlying filesystem " +
"does not support fallocate(2). gocryptfs will continue working " +
"but is no longer resistant against out-of-space errors.\n")
})
diff --git a/internal/fusefrontend/file.go b/internal/fusefrontend/file.go
index 96a07fc..7f25172 100644
--- a/internal/fusefrontend/file.go
+++ b/internal/fusefrontend/file.go
@@ -16,7 +16,7 @@ import (
"github.com/hanwen/go-fuse/fuse/nodefs"
"github.com/rfjakob/gocryptfs/internal/contentenc"
- "github.com/rfjakob/gocryptfs/internal/toggledlog"
+ "github.com/rfjakob/gocryptfs/internal/tlog"
)
// File - based on loopbackFile in go-fuse/fuse/nodefs/files.go
@@ -50,7 +50,7 @@ func NewFile(fd *os.File, writeOnly bool, contentEnc *contentenc.ContentEnc) (no
var st syscall.Stat_t
err := syscall.Fstat(int(fd.Fd()), &st)
if err != nil {
- toggledlog.Warn.Printf("NewFile: Fstat on fd %d failed: %v\n", fd.Fd(), err)
+ tlog.Warn.Printf("NewFile: Fstat on fd %d failed: %v\n", fd.Fd(), err)
return nil, fuse.ToStatus(err)
}
wlock.register(st.Ino)
@@ -102,7 +102,7 @@ func (f *file) createHeader() error {
// Prevent partially written (=corrupt) header by preallocating the space beforehand
err := prealloc(int(f.fd.Fd()), 0, contentenc.HEADER_LEN)
if err != nil {
- toggledlog.Warn.Printf("ino%d: createHeader: prealloc failed: %s\n", f.ino, err.Error())
+ tlog.Warn.Printf("ino%d: createHeader: prealloc failed: %s\n", f.ino, err.Error())
return err
}
@@ -145,18 +145,18 @@ func (f *file) doRead(off uint64, length uint64) ([]byte, fuse.Status) {
blocks := f.contentEnc.ExplodePlainRange(off, length)
alignedOffset, alignedLength := blocks[0].JointCiphertextRange(blocks)
skip := blocks[0].Skip
- toggledlog.Debug.Printf("JointCiphertextRange(%d, %d) -> %d, %d, %d", off, length, alignedOffset, alignedLength, skip)
+ tlog.Debug.Printf("JointCiphertextRange(%d, %d) -> %d, %d, %d", off, length, alignedOffset, alignedLength, skip)
ciphertext := make([]byte, int(alignedLength))
n, err := f.fd.ReadAt(ciphertext, int64(alignedOffset))
if err != nil && err != io.EOF {
- toggledlog.Warn.Printf("read: ReadAt: %s", err.Error())
+ tlog.Warn.Printf("read: ReadAt: %s", err.Error())
return nil, fuse.ToStatus(err)
}
// Truncate ciphertext buffer down to actually read bytes
ciphertext = ciphertext[0:n]
firstBlockNo := blocks[0].BlockNo
- toggledlog.Debug.Printf("ReadAt offset=%d bytes (%d blocks), want=%d, got=%d", alignedOffset, firstBlockNo, alignedLength, n)
+ tlog.Debug.Printf("ReadAt offset=%d bytes (%d blocks), want=%d, got=%d", alignedOffset, firstBlockNo, alignedLength, n)
// Decrypt it
plaintext, err := f.contentEnc.DecryptBlocks(ciphertext, firstBlockNo, f.header.Id)
@@ -164,7 +164,7 @@ func (f *file) doRead(off uint64, length uint64) ([]byte, fuse.Status) {
curruptBlockNo := firstBlockNo + f.contentEnc.PlainOffToBlockNo(uint64(len(plaintext)))
cipherOff := f.contentEnc.BlockNoToCipherOff(curruptBlockNo)
plainOff := f.contentEnc.BlockNoToPlainOff(curruptBlockNo)
- toggledlog.Warn.Printf("ino%d: doRead: corrupt block #%d (plainOff=%d, cipherOff=%d)",
+ tlog.Warn.Printf("ino%d: doRead: corrupt block #%d (plainOff=%d, cipherOff=%d)",
f.ino, curruptBlockNo, plainOff, cipherOff)
return nil, fuse.EIO
}
@@ -188,23 +188,23 @@ func (f *file) Read(buf []byte, off int64) (resultData fuse.ReadResult, code fus
f.fdLock.RLock()
defer f.fdLock.RUnlock()
- toggledlog.Debug.Printf("ino%d: FUSE Read: offset=%d length=%d", f.ino, len(buf), off)
+ tlog.Debug.Printf("ino%d: FUSE Read: offset=%d length=%d", f.ino, len(buf), off)
if f.writeOnly {
- toggledlog.Warn.Printf("ino%d: Tried to read from write-only file", f.ino)
+ tlog.Warn.Printf("ino%d: Tried to read from write-only file", f.ino)
return nil, fuse.EBADF
}
out, status := f.doRead(uint64(off), uint64(len(buf)))
if status == fuse.EIO {
- toggledlog.Warn.Printf("ino%d: Read failed with EIO, offset=%d, length=%d", f.ino, len(buf), off)
+ tlog.Warn.Printf("ino%d: Read failed with EIO, offset=%d, length=%d", f.ino, len(buf), off)
}
if status != fuse.OK {
return nil, status
}
- toggledlog.Debug.Printf("ino%d: Read: status %v, returning %d bytes", f.ino, status, len(out))
+ tlog.Debug.Printf("ino%d: Read: status %v, returning %d bytes", f.ino, status, len(out))
return fuse.ReadResultData(out), status
}
@@ -246,24 +246,24 @@ func (f *file) doWrite(data []byte, off int64) (uint32, fuse.Status) {
var oldData []byte
oldData, status = f.doRead(o, f.contentEnc.PlainBS())
if status != fuse.OK {
- toggledlog.Warn.Printf("ino%d fh%d: RMW read failed: %s", f.ino, f.intFd(), status.String())
+ tlog.Warn.Printf("ino%d fh%d: RMW read failed: %s", f.ino, f.intFd(), status.String())
return written, status
}
// Modify
blockData = f.contentEnc.MergeBlocks(oldData, blockData, int(b.Skip))
- toggledlog.Debug.Printf("len(oldData)=%d len(blockData)=%d", len(oldData), len(blockData))
+ tlog.Debug.Printf("len(oldData)=%d len(blockData)=%d", len(oldData), len(blockData))
}
// Encrypt
blockOffset, blockLen := b.CiphertextRange()
blockData = f.contentEnc.EncryptBlock(blockData, b.BlockNo, f.header.Id)
- toggledlog.Debug.Printf("ino%d: Writing %d bytes to block #%d",
+ tlog.Debug.Printf("ino%d: Writing %d bytes to block #%d",
f.ino, uint64(len(blockData))-f.contentEnc.BlockOverhead(), b.BlockNo)
// Prevent partially written (=corrupt) blocks by preallocating the space beforehand
err := prealloc(int(f.fd.Fd()), int64(blockOffset), int64(blockLen))
if err != nil {
- toggledlog.Warn.Printf("ino%d fh%d: doWrite: prealloc failed: %s", f.ino, f.intFd(), err.Error())
+ tlog.Warn.Printf("ino%d fh%d: doWrite: prealloc failed: %s", f.ino, f.intFd(), err.Error())
status = fuse.ToStatus(err)
break
}
@@ -272,7 +272,7 @@ func (f *file) doWrite(data []byte, off int64) (uint32, fuse.Status) {
_, err = f.fd.WriteAt(blockData, int64(blockOffset))
if err != nil {
- toggledlog.Warn.Printf("doWrite: Write failed: %s", err.Error())
+ tlog.Warn.Printf("doWrite: Write failed: %s", err.Error())
status = fuse.ToStatus(err)
break
}
@@ -289,24 +289,24 @@ func (f *file) Write(data []byte, off int64) (uint32, fuse.Status) {
// The file descriptor has been closed concurrently, which also means
// the wlock has been freed. Exit here so we don't crash trying to access
// it.
- toggledlog.Warn.Printf("ino%d fh%d: Write on released file", f.ino, f.intFd())
+ tlog.Warn.Printf("ino%d fh%d: Write on released file", f.ino, f.intFd())
return 0, fuse.EBADF
}
wlock.lock(f.ino)
defer wlock.unlock(f.ino)
- toggledlog.Debug.Printf("ino%d: FUSE Write: offset=%d length=%d", f.ino, off, len(data))
+ tlog.Debug.Printf("ino%d: FUSE Write: offset=%d length=%d", f.ino, off, len(data))
fi, err := f.fd.Stat()
if err != nil {
- toggledlog.Warn.Printf("Write: Fstat failed: %v", err)
+ tlog.Warn.Printf("Write: Fstat failed: %v", err)
return 0, fuse.ToStatus(err)
}
plainSize := f.contentEnc.CipherSizeToPlainSize(uint64(fi.Size()))
if f.createsHole(plainSize, off) {
status := f.zeroPad(plainSize)
if status != fuse.OK {
- toggledlog.Warn.Printf("zeroPad returned error %v", status)
+ tlog.Warn.Printf("zeroPad returned error %v", status)
return 0, status
}
}
@@ -356,7 +356,7 @@ func (f *file) Truncate(newSize uint64) fuse.Status {
defer f.fdLock.RUnlock()
if f.released {
// The file descriptor has been closed concurrently.
- toggledlog.Warn.Printf("ino%d fh%d: Truncate on released file", f.ino, f.intFd())
+ tlog.Warn.Printf("ino%d fh%d: Truncate on released file", f.ino, f.intFd())
return fuse.EBADF
}
wlock.lock(f.ino)
@@ -367,7 +367,7 @@ func (f *file) Truncate(newSize uint64) fuse.Status {
if newSize == 0 {
err = syscall.Ftruncate(int(f.fd.Fd()), 0)
if err != nil {
- toggledlog.Warn.Printf("ino%d fh%d: Ftruncate(fd, 0) returned error: %v", f.ino, f.intFd(), err)
+ tlog.Warn.Printf("ino%d fh%d: Ftruncate(fd, 0) returned error: %v", f.ino, f.intFd(), err)
return fuse.ToStatus(err)
}
// Truncate to zero kills the file header
@@ -379,14 +379,14 @@ func (f *file) Truncate(newSize uint64) fuse.Status {
// the file
fi, err := f.fd.Stat()
if err != nil {
- toggledlog.Warn.Printf("ino%d fh%d: Truncate: Fstat failed: %v", f.ino, f.intFd(), err)
+ tlog.Warn.Printf("ino%d fh%d: Truncate: Fstat failed: %v", f.ino, f.intFd(), err)
return fuse.ToStatus(err)
}
oldSize := f.contentEnc.CipherSizeToPlainSize(uint64(fi.Size()))
{
oldB := float32(oldSize) / float32(f.contentEnc.PlainBS())
newB := float32(newSize) / float32(f.contentEnc.PlainBS())
- toggledlog.Debug.Printf("ino%d: FUSE Truncate from %.2f to %.2f blocks (%d to %d bytes)", f.ino, oldB, newB, oldSize, newSize)
+ tlog.Debug.Printf("ino%d: FUSE Truncate from %.2f to %.2f blocks (%d to %d bytes)", f.ino, oldB, newB, oldSize, newSize)
}
// File size stays the same - nothing to do
@@ -419,7 +419,7 @@ func (f *file) Truncate(newSize uint64) fuse.Status {
off, length := b.CiphertextRange()
err = syscall.Ftruncate(int(f.fd.Fd()), int64(off+length))
if err != nil {
- toggledlog.Warn.Printf("grow Ftruncate returned error: %v", err)
+ tlog.Warn.Printf("grow Ftruncate returned error: %v", err)
return fuse.ToStatus(err)
}
}
@@ -436,14 +436,14 @@ func (f *file) Truncate(newSize uint64) fuse.Status {
var status fuse.Status
data, status = f.doRead(plainOff, lastBlockLen)
if status != fuse.OK {
- toggledlog.Warn.Printf("shrink doRead returned error: %v", err)
+ tlog.Warn.Printf("shrink doRead returned error: %v", err)
return status
}
}
// Truncate down to last complete block
err = syscall.Ftruncate(int(f.fd.Fd()), int64(cipherOff))
if err != nil {
- toggledlog.Warn.Printf("shrink Ftruncate returned error: %v", err)
+ tlog.Warn.Printf("shrink Ftruncate returned error: %v", err)
return fuse.ToStatus(err)
}
// Append partial block
@@ -473,7 +473,7 @@ func (f *file) GetAttr(a *fuse.Attr) fuse.Status {
f.fdLock.RLock()
defer f.fdLock.RUnlock()
- toggledlog.Debug.Printf("file.GetAttr()")
+ tlog.Debug.Printf("file.GetAttr()")
st := syscall.Stat_t{}
err := syscall.Fstat(int(f.fd.Fd()), &st)
if err != nil {
@@ -491,7 +491,7 @@ var allocateWarnOnce sync.Once
// Allocate - FUSE call, fallocate(2)
func (f *file) Allocate(off uint64, sz uint64, mode uint32) fuse.Status {
allocateWarnOnce.Do(func() {
- toggledlog.Warn.Printf("fallocate(2) is not supported, returning ENOSYS - see https://github.com/rfjakob/gocryptfs/issues/1")
+ tlog.Warn.Printf("fallocate(2) is not supported, returning ENOSYS - see https://github.com/rfjakob/gocryptfs/issues/1")
})
return fuse.ENOSYS
}
@@ -519,7 +519,7 @@ func (f *file) Utimens(a *time.Time, m *time.Time) fuse.Status {
fn := fmt.Sprintf("/proc/self/fd/%d", f.fd.Fd())
err := syscall.UtimesNano(fn, ts)
if err != nil {
- toggledlog.Debug.Printf("UtimesNano on %q failed: %v", fn, err)
+ tlog.Debug.Printf("UtimesNano on %q failed: %v", fn, err)
}
if err == syscall.ENOENT {
// If /proc/self/fd/X did not exist, the actual error is that the file
diff --git a/internal/fusefrontend/file_holes.go b/internal/fusefrontend/file_holes.go
index 0259ae9..46a5865 100644
--- a/internal/fusefrontend/file_holes.go
+++ b/internal/fusefrontend/file_holes.go
@@ -5,7 +5,7 @@ package fusefrontend
import (
"github.com/hanwen/go-fuse/fuse"
- "github.com/rfjakob/gocryptfs/internal/toggledlog"
+ "github.com/rfjakob/gocryptfs/internal/tlog"
)
// Will a write to offset "off" create a file hole?
@@ -23,7 +23,7 @@ func (f *file) zeroPad(plainSize uint64) fuse.Status {
lastBlockLen := plainSize % f.contentEnc.PlainBS()
missing := f.contentEnc.PlainBS() - lastBlockLen
pad := make([]byte, missing)
- toggledlog.Debug.Printf("zeroPad: Writing %d bytes\n", missing)
+ tlog.Debug.Printf("zeroPad: Writing %d bytes\n", missing)
_, status := f.doWrite(pad, int64(plainSize))
return status
}
diff --git a/internal/fusefrontend/fs.go b/internal/fusefrontend/fs.go
index c216c86..26c9252 100644
--- a/internal/fusefrontend/fs.go
+++ b/internal/fusefrontend/fs.go
@@ -17,7 +17,7 @@ import (
"github.com/rfjakob/gocryptfs/internal/contentenc"
"github.com/rfjakob/gocryptfs/internal/cryptocore"
"github.com/rfjakob/gocryptfs/internal/nametransform"
- "github.com/rfjakob/gocryptfs/internal/toggledlog"
+ "github.com/rfjakob/gocryptfs/internal/tlog"
)
type FS struct {
@@ -49,7 +49,7 @@ func NewFS(args Args) *FS {
}
func (fs *FS) GetAttr(name string, context *fuse.Context) (*fuse.Attr, fuse.Status) {
- toggledlog.Debug.Printf("FS.GetAttr('%s')", name)
+ tlog.Debug.Printf("FS.GetAttr('%s')", name)
if fs.isFiltered(name) {
return nil, fuse.EPERM
}
@@ -59,7 +59,7 @@ func (fs *FS) GetAttr(name string, context *fuse.Context) (*fuse.Attr, fuse.Stat
}
a, status := fs.FileSystem.GetAttr(cName, context)
if a == nil {
- toggledlog.Debug.Printf("FS.GetAttr failed: %s", status.String())
+ tlog.Debug.Printf("FS.GetAttr failed: %s", status.String())
return a, status
}
if a.IsRegular() {
@@ -91,10 +91,10 @@ func (fs *FS) Open(path string, flags uint32, context *fuse.Context) (fuseFile n
iflags, writeOnly := fs.mangleOpenFlags(flags)
cPath, err := fs.getBackingPath(path)
if err != nil {
- toggledlog.Debug.Printf("Open: getBackingPath: %v", err)
+ tlog.Debug.Printf("Open: getBackingPath: %v", err)
return nil, fuse.ToStatus(err)
}
- toggledlog.Debug.Printf("Open: %s", cPath)
+ tlog.Debug.Printf("Open: %s", cPath)
f, err := os.OpenFile(cPath, iflags, 0666)
if err != nil {
return nil, fuse.ToStatus(err)
@@ -213,7 +213,7 @@ var truncateWarnOnce sync.Once
func (fs *FS) Truncate(path string, offset uint64, context *fuse.Context) (code fuse.Status) {
truncateWarnOnce.Do(func() {
- toggledlog.Warn.Printf("truncate(2) is not supported, returning ENOSYS - use ftruncate(2)")
+ tlog.Warn.Printf("truncate(2) is not supported, returning ENOSYS - use ftruncate(2)")
})
return fuse.ENOSYS
}
@@ -254,7 +254,7 @@ func (fs *FS) Readlink(path string, context *fuse.Context) (out string, status f
var target string
target, err = fs.decryptPath(cTarget)
if err != nil {
- toggledlog.Warn.Printf("Readlink: CBC decryption failed: %v", err)
+ tlog.Warn.Printf("Readlink: CBC decryption failed: %v", err)
return "", fuse.EIO
}
return target, fuse.OK
@@ -262,12 +262,12 @@ func (fs *FS) Readlink(path string, context *fuse.Context) (out string, status f
// Since gocryptfs v0.5 symlinks are encrypted like file contents (GCM)
cBinTarget, err := base64.URLEncoding.DecodeString(cTarget)
if err != nil {
- toggledlog.Warn.Printf("Readlink: %v", err)
+ tlog.Warn.Printf("Readlink: %v", err)
return "", fuse.EIO
}
target, err := fs.contentEnc.DecryptBlock([]byte(cBinTarget), 0, nil)
if err != nil {
- toggledlog.Warn.Printf("Readlink: %v", err)
+ tlog.Warn.Printf("Readlink: %v", err)
return "", fuse.EIO
}
return string(target), fuse.OK
@@ -298,7 +298,7 @@ func (fs *FS) Unlink(path string, context *fuse.Context) (code fuse.Status) {
// Delete ".name"
err = nametransform.DeleteLongName(dirfd, cName)
if err != nil {
- toggledlog.Warn.Printf("Unlink: could not delete .name file: %v", err)
+ tlog.Warn.Printf("Unlink: could not delete .name file: %v", err)
}
return fuse.ToStatus(err)
}
@@ -308,7 +308,7 @@ func (fs *FS) Unlink(path string, context *fuse.Context) (code fuse.Status) {
}
func (fs *FS) Symlink(target string, linkName string, context *fuse.Context) (code fuse.Status) {
- toggledlog.Debug.Printf("Symlink(\"%s\", \"%s\")", target, linkName)
+ tlog.Debug.Printf("Symlink(\"%s\", \"%s\")", target, linkName)
if fs.isFiltered(linkName) {
return fuse.EPERM
}
@@ -322,7 +322,7 @@ func (fs *FS) Symlink(target string, linkName string, context *fuse.Context) (co
var cTarget string
cTarget, err = fs.encryptPath(target)
if err != nil {
- toggledlog.Warn.Printf("Symlink: BUG: we should not get an error here: %v", err)
+ tlog.Warn.Printf("Symlink: BUG: we should not get an error here: %v", err)
return fuse.ToStatus(err)
}
err = os.Symlink(cTarget, cPath)
@@ -417,7 +417,7 @@ func (fs *FS) Rename(oldPath string, newPath string, context *fuse.Context) (cod
// If an empty directory is overwritten we will always get ENOTEMPTY as
// the "empty" directory will still contain gocryptfs.diriv.
// Handle that case by removing the target directory and trying again.
- toggledlog.Debug.Printf("Rename: Handling ENOTEMPTY")
+ tlog.Debug.Printf("Rename: Handling ENOTEMPTY")
if fs.Rmdir(newPath, context) == fuse.OK {
err = syscall.Renameat(finalOldDirFd, finalOldPath, finalNewDirFd, finalNewPath)
}
diff --git a/internal/fusefrontend/fs_dir.go b/internal/fusefrontend/fs_dir.go
index b7d33ff..f77486d 100644
--- a/internal/fusefrontend/fs_dir.go
+++ b/internal/fusefrontend/fs_dir.go
@@ -13,7 +13,7 @@ import (
"github.com/rfjakob/gocryptfs/internal/configfile"
"github.com/rfjakob/gocryptfs/internal/cryptocore"
"github.com/rfjakob/gocryptfs/internal/nametransform"
- "github.com/rfjakob/gocryptfs/internal/toggledlog"
+ "github.com/rfjakob/gocryptfs/internal/tlog"
)
func (fs *FS) mkdirWithIv(cPath string, mode uint32) error {
@@ -32,7 +32,7 @@ func (fs *FS) mkdirWithIv(cPath string, mode uint32) error {
if err != nil {
err2 := syscall.Rmdir(cPath)
if err2 != nil {
- toggledlog.Warn.Printf("mkdirWithIv: rollback failed: %v", err2)
+ tlog.Warn.Printf("mkdirWithIv: rollback failed: %v", err2)
}
}
return err
@@ -86,7 +86,7 @@ func (fs *FS) Mkdir(newPath string, mode uint32, context *fuse.Context) (code fu
if origMode != mode {
err = os.Chmod(cPath, os.FileMode(origMode))
if err != nil {
- toggledlog.Warn.Printf("Mkdir: Chmod failed: %v", err)
+ tlog.Warn.Printf("Mkdir: Chmod failed: %v", err)
}
}
@@ -114,19 +114,19 @@ func (fs *FS) Rmdir(path string, context *fuse.Context) (code fuse.Status) {
syscall.O_RDONLY, 0)
if err == syscall.EACCES {
// We need permission to read and modify the directory
- toggledlog.Debug.Printf("Rmdir: handling EACCESS")
+ tlog.Debug.Printf("Rmdir: handling EACCESS")
// TODO use syscall.Fstatat once it is available in Go
var fi os.FileInfo
fi, err = os.Lstat(cPath)
if err != nil {
- toggledlog.Debug.Printf("Rmdir: Stat: %v", err)
+ tlog.Debug.Printf("Rmdir: Stat: %v", err)
return fuse.ToStatus(err)
}
origMode := fi.Mode()
// TODO use syscall.Chmodat once it is available in Go
err = os.Chmod(cPath, origMode|0700)
if err != nil {
- toggledlog.Debug.Printf("Rmdir: Chmod failed: %v", err)
+ tlog.Debug.Printf("Rmdir: Chmod failed: %v", err)
return fuse.ToStatus(err)
}
// Retry open
@@ -139,13 +139,13 @@ func (fs *FS) Rmdir(path string, context *fuse.Context) (code fuse.Status) {
if code != fuse.OK {
err = os.Chmod(cPath, origMode)
if err != nil {
- toggledlog.Warn.Printf("Rmdir: Chmod rollback failed: %v", err)
+ tlog.Warn.Printf("Rmdir: Chmod rollback failed: %v", err)
}
}
}()
}
if err != nil {
- toggledlog.Debug.Printf("Rmdir: Open: %v", err)
+ tlog.Debug.Printf("Rmdir: Open: %v", err)
return fuse.ToStatus(err)
}
dirfd := os.NewFile(uintptr(dirfdRaw), cName)
@@ -153,7 +153,7 @@ func (fs *FS) Rmdir(path string, context *fuse.Context) (code fuse.Status) {
children, err := dirfd.Readdirnames(10)
if err != nil {
- toggledlog.Warn.Printf("Rmdir: Readdirnames: %v", err)
+ tlog.Warn.Printf("Rmdir: Readdirnames: %v", err)
return fuse.ToStatus(err)
}
// If the directory is not empty besides gocryptfs.diriv, do not even
@@ -164,7 +164,7 @@ func (fs *FS) Rmdir(path string, context *fuse.Context) (code fuse.Status) {
// Move "gocryptfs.diriv" to the parent dir as "gocryptfs.diriv.rmdir.XYZ"
tmpName := fmt.Sprintf("gocryptfs.diriv.rmdir.%d", cryptocore.RandUint64())
- toggledlog.Debug.Printf("Rmdir: Renaming %s to %s", nametransform.DirIVFilename, tmpName)
+ tlog.Debug.Printf("Rmdir: Renaming %s to %s", nametransform.DirIVFilename, tmpName)
// The directory is in an inconsistent state between rename and rmdir.
// Protect against concurrent readers.
fs.dirIVLock.Lock()
@@ -172,7 +172,7 @@ func (fs *FS) Rmdir(path string, context *fuse.Context) (code fuse.Status) {
err = syscall.Renameat(int(dirfd.Fd()), nametransform.DirIVFilename,
int(parentDirFd.Fd()), tmpName)
if err != nil {
- toggledlog.Warn.Printf("Rmdir: Renaming %s to %s failed: %v",
+ tlog.Warn.Printf("Rmdir: Renaming %s to %s failed: %v",
nametransform.DirIVFilename, tmpName, err)
return fuse.ToStatus(err)
}
@@ -186,14 +186,14 @@ func (fs *FS) Rmdir(path string, context *fuse.Context) (code fuse.Status) {
err2 := syscall.Renameat(int(parentDirFd.Fd()), tmpName,
int(dirfd.Fd()), nametransform.DirIVFilename)
if err != nil {
- toggledlog.Warn.Printf("Rmdir: Rename rollback failed: %v", err2)
+ tlog.Warn.Printf("Rmdir: Rename rollback failed: %v", err2)
}
return fuse.ToStatus(err)
}
// Delete "gocryptfs.diriv.rmdir.XYZ"
err = syscall.Unlinkat(int(parentDirFd.Fd()), tmpName)
if err != nil {
- toggledlog.Warn.Printf("Rmdir: Could not clean up %s: %v", tmpName, err)
+ tlog.Warn.Printf("Rmdir: Could not clean up %s: %v", tmpName, err)
}
// Delete .name file
if nametransform.IsLongContent(cName) {
@@ -205,7 +205,7 @@ func (fs *FS) Rmdir(path string, context *fuse.Context) (code fuse.Status) {
}
func (fs *FS) OpenDir(dirName string, context *fuse.Context) ([]fuse.DirEntry, fuse.Status) {
- toggledlog.Debug.Printf("OpenDir(%s)", dirName)
+ tlog.Debug.Printf("OpenDir(%s)", dirName)
cDirName, err := fs.encryptPath(dirName)
if err != nil {
return nil, fuse.ToStatus(err)
@@ -255,7 +255,7 @@ func (fs *FS) OpenDir(dirName string, context *fuse.Context) ([]fuse.DirEntry, f
if isLong == nametransform.LongNameContent {
cNameLong, err := nametransform.ReadLongName(filepath.Join(cDirAbsPath, cName))
if err != nil {
- toggledlog.Warn.Printf("Skipping file %q in dir %q: Could not read .name: %v",
+ tlog.Warn.Printf("Skipping file %q in dir %q: Could not read .name: %v",
cName, cDirName, err)
errorCount++
continue
@@ -268,7 +268,7 @@ func (fs *FS) OpenDir(dirName string, context *fuse.Context) ([]fuse.DirEntry, f
name, err := fs.nameTransform.DecryptName(cName, cachedIV)
if err != nil {
- toggledlog.Warn.Printf("Skipping invalid name %q in dir %q: %s",
+ tlog.Warn.Printf("Skipping invalid name %q in dir %q: %s",
cName, cDirName, err)
errorCount++
continue
@@ -281,7 +281,7 @@ func (fs *FS) OpenDir(dirName string, context *fuse.Context) ([]fuse.DirEntry, f
if errorCount > 0 && len(plain) == 0 {
// Don't let the user stare on an empty directory. Report that things went
// wrong.
- toggledlog.Warn.Printf("All %d entries in directory %q were invalid, returning EIO",
+ tlog.Warn.Printf("All %d entries in directory %q were invalid, returning EIO",
errorCount, cDirName)
status = fuse.EIO
}
diff --git a/internal/fusefrontend/names.go b/internal/fusefrontend/names.go
index e913792..907b6b4 100644
--- a/internal/fusefrontend/names.go
+++ b/internal/fusefrontend/names.go
@@ -6,7 +6,7 @@ import (
"path/filepath"
"github.com/rfjakob/gocryptfs/internal/configfile"
- "github.com/rfjakob/gocryptfs/internal/toggledlog"
+ "github.com/rfjakob/gocryptfs/internal/tlog"
)
// isFiltered - check if plaintext "path" should be forbidden
@@ -18,7 +18,7 @@ func (fs *FS) isFiltered(path string) bool {
}
// gocryptfs.conf in the root directory is forbidden
if path == configfile.ConfDefaultName {
- toggledlog.Info.Printf("The name /%s is reserved when -plaintextnames is used\n",
+ tlog.Info.Printf("The name /%s is reserved when -plaintextnames is used\n",
configfile.ConfDefaultName)
return true
}
@@ -35,7 +35,7 @@ func (fs *FS) getBackingPath(relPath string) (string, error) {
return "", err
}
cAbsPath := filepath.Join(fs.args.Cipherdir, cPath)
- toggledlog.Debug.Printf("getBackingPath: %s + %s -> %s", fs.args.Cipherdir, relPath, cAbsPath)
+ tlog.Debug.Printf("getBackingPath: %s + %s -> %s", fs.args.Cipherdir, relPath, cAbsPath)
return cAbsPath, nil
}
@@ -49,7 +49,7 @@ func (fs *FS) encryptPath(plainPath string) (string, error) {
}
fs.dirIVLock.RLock()
cPath, err := fs.nameTransform.EncryptPathDirIV(plainPath, fs.args.Cipherdir)
- toggledlog.Debug.Printf("encryptPath '%s' -> '%s' (err: %v)", plainPath, cPath, err)
+ tlog.Debug.Printf("encryptPath '%s' -> '%s' (err: %v)", plainPath, cPath, err)
fs.dirIVLock.RUnlock()
return cPath, err
}
diff --git a/internal/nametransform/longnames.go b/internal/nametransform/longnames.go
index 0746cd6..13bedb3 100644
--- a/internal/nametransform/longnames.go
+++ b/internal/nametransform/longnames.go
@@ -9,7 +9,7 @@ import (
"strings"
"syscall"
- "github.com/rfjakob/gocryptfs/internal/toggledlog"
+ "github.com/rfjakob/gocryptfs/internal/tlog"
)
const (
@@ -58,7 +58,7 @@ func IsLongContent(cName string) bool {
func ReadLongName(path string) (string, error) {
content, err := ioutil.ReadFile(path + LongNameSuffix)
if err != nil {
- toggledlog.Warn.Printf("ReadLongName: %v", err)
+ tlog.Warn.Printf("ReadLongName: %v", err)
}
return string(content), err
}
@@ -67,7 +67,7 @@ func ReadLongName(path string) (string, error) {
func DeleteLongName(dirfd *os.File, hashName string) error {
err := syscall.Unlinkat(int(dirfd.Fd()), hashName+LongNameSuffix)
if err != nil {
- toggledlog.Warn.Printf("DeleteLongName: %v", err)
+ tlog.Warn.Printf("DeleteLongName: %v", err)
}
return err
}
@@ -89,14 +89,14 @@ func (n *NameTransform) WriteLongName(dirfd *os.File, hashName string, plainName
fdRaw, err := syscall.Openat(int(dirfd.Fd()), hashName+LongNameSuffix,
syscall.O_WRONLY|syscall.O_CREAT|syscall.O_EXCL, 0600)
if err != nil {
- toggledlog.Warn.Printf("WriteLongName: Openat: %v", err)
+ tlog.Warn.Printf("WriteLongName: Openat: %v", err)
return err
}
fd := os.NewFile(uintptr(fdRaw), hashName+LongNameSuffix)
defer fd.Close()
_, err = fd.Write([]byte(cName))
if err != nil {
- toggledlog.Warn.Printf("WriteLongName: Write: %v", err)
+ tlog.Warn.Printf("WriteLongName: Write: %v", err)
}
return err
}
diff --git a/internal/nametransform/names_diriv.go b/internal/nametransform/names_diriv.go
index f5aa88d..b9473aa 100644
--- a/internal/nametransform/names_diriv.go
+++ b/internal/nametransform/names_diriv.go
@@ -9,7 +9,7 @@ import (
"syscall"
"github.com/rfjakob/gocryptfs/internal/cryptocore"
- "github.com/rfjakob/gocryptfs/internal/toggledlog"
+ "github.com/rfjakob/gocryptfs/internal/tlog"
)
const (
@@ -37,7 +37,7 @@ func ReadDirIV(dir string) (iv []byte, err error) {
func ReadDirIVAt(dirfd *os.File) (iv []byte, err error) {
fdRaw, err := syscall.Openat(int(dirfd.Fd()), DirIVFilename, syscall.O_RDONLY, 0)
if err != nil {
- toggledlog.Warn.Printf("ReadDirIVAt: opening %q in dir %q failed: %v",
+ tlog.Warn.Printf("ReadDirIVAt: opening %q in dir %q failed: %v",
DirIVFilename, dirfd.Name(), err)
return nil, err
}
@@ -47,12 +47,12 @@ func ReadDirIVAt(dirfd *os.File) (iv []byte, err error) {
iv = make([]byte, dirIVLen+1)
n, err := fd.Read(iv)
if err != nil {
- toggledlog.Warn.Printf("ReadDirIVAt: Read failed: %v", err)
+ tlog.Warn.Printf("ReadDirIVAt: Read failed: %v", err)
return nil, err
}
iv = iv[0:n]
if len(iv) != dirIVLen {
- toggledlog.Warn.Printf("ReadDirIVAt: wanted %d bytes, got %d", dirIVLen, len(iv))
+ tlog.Warn.Printf("ReadDirIVAt: wanted %d bytes, got %d", dirIVLen, len(iv))
return nil, errors.New("invalid iv length")
}
return iv, nil
@@ -66,7 +66,7 @@ func WriteDirIV(dir string) error {
file := filepath.Join(dir, DirIVFilename)
err := ioutil.WriteFile(file, iv, 0400)
if err != nil {
- toggledlog.Warn.Printf("WriteDirIV: %v", err)
+ tlog.Warn.Printf("WriteDirIV: %v", err)
}
return err
}
@@ -126,7 +126,7 @@ func (be *NameTransform) DecryptPathDirIV(encryptedPath string, rootDir string)
var wd = rootDir
var plainNames []string
encryptedNames := strings.Split(encryptedPath, "/")
- toggledlog.Debug.Printf("DecryptPathDirIV: decrypting %v\n", encryptedNames)
+ tlog.Debug.Printf("DecryptPathDirIV: decrypting %v\n", encryptedNames)
for _, encryptedName := range encryptedNames {
iv, err := ReadDirIV(wd)
if err != nil {
diff --git a/internal/prefer_openssl/prefer.go b/internal/prefer_openssl/prefer.go
index 0bc24b4..598b26b 100644
--- a/internal/prefer_openssl/prefer.go
+++ b/internal/prefer_openssl/prefer.go
@@ -4,7 +4,7 @@ import (
"io/ioutil"
"regexp"
- "github.com/rfjakob/gocryptfs/internal/toggledlog"
+ "github.com/rfjakob/gocryptfs/internal/tlog"
)
// filePreferOpenSSL tells us if OpenSSL is faster than Go GCM on this machine.
@@ -18,12 +18,12 @@ import (
func filePreferOpenSSL(file string) bool {
ci, err := ioutil.ReadFile(file)
if err != nil {
- toggledlog.Warn.Println(err)
+ tlog.Warn.Println(err)
return true
}
haveAes, err := regexp.Match(`(?m)^flags.*\baes\b`, ci)
if err != nil {
- toggledlog.Warn.Println(err)
+ tlog.Warn.Println(err)
return true
}
return !haveAes
diff --git a/internal/readpassword/extpass_test.go b/internal/readpassword/extpass_test.go
index 6eda142..cdb800c 100644
--- a/internal/readpassword/extpass_test.go
+++ b/internal/readpassword/extpass_test.go
@@ -5,12 +5,12 @@ import (
"os/exec"
"testing"
- "github.com/rfjakob/gocryptfs/internal/toggledlog"
+ "github.com/rfjakob/gocryptfs/internal/tlog"
)
func TestMain(m *testing.M) {
// Shut up info output
- toggledlog.Info.Enabled = false
+ tlog.Info.Enabled = false
m.Run()
}
diff --git a/internal/readpassword/read.go b/internal/readpassword/read.go
index 1f2a9fa..2c0bce3 100644
--- a/internal/readpassword/read.go
+++ b/internal/readpassword/read.go
@@ -9,7 +9,7 @@ import (
"golang.org/x/crypto/ssh/terminal"
- "github.com/rfjakob/gocryptfs/internal/toggledlog"
+ "github.com/rfjakob/gocryptfs/internal/tlog"
)
const (
@@ -40,7 +40,7 @@ func Twice(extpass string) string {
p1 := readPasswordTerminal("Password: ")
p2 := readPasswordTerminal("Repeat: ")
if p1 != p2 {
- toggledlog.Fatal.Println("Passwords do not match")
+ tlog.Fatal.Println("Passwords do not match")
os.Exit(exitCode)
}
return p1
@@ -54,12 +54,12 @@ func readPasswordTerminal(prompt string) string {
// terminal.ReadPassword removes the trailing newline
p, err := terminal.ReadPassword(fd)
if err != nil {
- toggledlog.Fatal.Printf("Could not read password from terminal: %v\n", err)
+ tlog.Fatal.Printf("Could not read password from terminal: %v\n", err)
os.Exit(exitCode)
}
fmt.Fprintf(os.Stderr, "\n")
if len(p) == 0 {
- toggledlog.Fatal.Println("Password is empty")
+ tlog.Fatal.Println("Password is empty")
os.Exit(exitCode)
}
return string(p)
@@ -68,11 +68,11 @@ func readPasswordTerminal(prompt string) string {
// readPasswordStdin reads a line from stdin
// Exits on read error or empty result.
func readPasswordStdin() string {
- toggledlog.Info.Println("Reading password from stdin")
+ tlog.Info.Println("Reading password from stdin")
p := readLineUnbuffered(os.Stdin)
if len(p) == 0 {
fmt.Fprintf(os.Stderr, "FOOOOOO\n")
- toggledlog.Fatal.Println("Got empty password from stdin")
+ tlog.Fatal.Println("Got empty password from stdin")
os.Exit(exitCode)
}
return p
@@ -82,25 +82,25 @@ func readPasswordStdin() string {
// of the output.
// Exits on read error or empty result.
func readPasswordExtpass(extpass string) string {
- toggledlog.Info.Println("Reading password from extpass program")
+ tlog.Info.Println("Reading password from extpass program")
parts := strings.Split(extpass, " ")
cmd := exec.Command(parts[0], parts[1:]...)
cmd.Stderr = os.Stderr
pipe, err := cmd.StdoutPipe()
if err != nil {
- toggledlog.Fatal.Printf("extpass pipe setup failed: %v", err)
+ tlog.Fatal.Printf("extpass pipe setup failed: %v", err)
os.Exit(exitCode)
}
err = cmd.Start()
if err != nil {
- toggledlog.Fatal.Printf("extpass cmd start failed: %v", err)
+ tlog.Fatal.Printf("extpass cmd start failed: %v", err)
os.Exit(exitCode)
}
p := readLineUnbuffered(pipe)
pipe.Close()
cmd.Wait()
if len(p) == 0 {
- toggledlog.Fatal.Println("extpass: password is empty")
+ tlog.Fatal.Println("extpass: password is empty")
os.Exit(exitCode)
}
return p
@@ -116,7 +116,7 @@ func readLineUnbuffered(r io.Reader) (l string) {
return l
}
if err != nil {
- toggledlog.Fatal.Printf("readLineUnbuffered: %v", err)
+ tlog.Fatal.Printf("readLineUnbuffered: %v", err)
os.Exit(exitCode)
}
if n == 0 {
diff --git a/internal/toggledlog/log.go b/internal/tlog/log.go
index 30fab18..254a207 100644
--- a/internal/toggledlog/log.go
+++ b/internal/tlog/log.go
@@ -1,4 +1,4 @@
-package toggledlog
+package tlog
import (
"encoding/json"
diff --git a/internal/toggledlog/log_go1.4.go b/internal/tlog/log_go1.4.go
index 4cdba44..fae0e9b 100644
--- a/internal/toggledlog/log_go1.4.go
+++ b/internal/tlog/log_go1.4.go
@@ -1,7 +1,7 @@
// +build !go1.5
// = go 1.4 or lower
-package toggledlog
+package tlog
import (
"log/syslog"
diff --git a/internal/toggledlog/log_go1.5.go b/internal/tlog/log_go1.5.go
index e8e71f9..755f623 100644
--- a/internal/toggledlog/log_go1.5.go
+++ b/internal/tlog/log_go1.5.go
@@ -1,7 +1,7 @@
// +build go1.5
// = go 1.5 or higher
-package toggledlog
+package tlog
import (
"log/syslog"