summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorJakob Unterwurzacher2020-05-09 17:36:41 +0200
committerJakob Unterwurzacher2020-05-09 17:36:41 +0200
commit16221facb9066ccf03015ccfe9e7ca784b0d2099 (patch)
tree46abce23a8592542563deb463a98d4318deb24af /internal
parent3ef563493a9d0774513ec0d6aab4cfbc0f6334e5 (diff)
ctlsock: create exported ctlsock client library
The former interal ctlsock server package is renamed to ctlsocksrv.
Diffstat (limited to 'internal')
-rw-r--r--internal/ctlsocksrv/ctlsock_serve.go (renamed from internal/ctlsock/ctlsock_serve.go)32
-rw-r--r--internal/ctlsocksrv/sanitize.go (renamed from internal/ctlsock/sanitize.go)2
-rw-r--r--internal/ctlsocksrv/sanitize_test.go (renamed from internal/ctlsock/sanitize_test.go)2
-rw-r--r--internal/fusefrontend/ctlsock_interface.go4
-rw-r--r--internal/fusefrontend_reverse/ctlsock_interface.go4
5 files changed, 12 insertions, 32 deletions
diff --git a/internal/ctlsock/ctlsock_serve.go b/internal/ctlsocksrv/ctlsock_serve.go
index 8b19e8a..b63759e 100644
--- a/internal/ctlsock/ctlsock_serve.go
+++ b/internal/ctlsocksrv/ctlsock_serve.go
@@ -1,6 +1,6 @@
-// Package ctlsock implements the control socket interface that can be
+// Package ctlsocksrv implements the control socket interface that can be
// activated by passing "-ctlsock" on the command line.
-package ctlsock
+package ctlsocksrv
import (
"encoding/json"
@@ -11,6 +11,7 @@ import (
"os"
"syscall"
+ "github.com/rfjakob/gocryptfs/ctlsock"
"github.com/rfjakob/gocryptfs/internal/tlog"
)
@@ -20,27 +21,6 @@ type Interface interface {
DecryptPath(string) (string, error)
}
-// RequestStruct is sent by a client
-type RequestStruct struct {
- EncryptPath string
- DecryptPath string
-}
-
-// ResponseStruct is sent by us as response to a request
-type ResponseStruct struct {
- // Result is the resulting decrypted or encrypted path. Empty on error.
- Result string
- // ErrNo is the error number as defined in errno.h.
- // 0 means success and -1 means that the error number is not known
- // (look at ErrText in this case).
- ErrNo int32
- // ErrText is a detailed error message.
- ErrText string
- // WarnText contains warnings that may have been encountered while
- // processing the message.
- WarnText string
-}
-
type ctlSockHandler struct {
fs Interface
socket *net.UnixListener
@@ -97,7 +77,7 @@ func (ch *ctlSockHandler) handleConnection(conn *net.UnixConn) {
return
}
data := buf[:n]
- var in RequestStruct
+ var in ctlsock.RequestStruct
err = json.Unmarshal(data, &in)
if err != nil {
tlog.Warn.Printf("ctlsock: JSON Unmarshal error: %#v", err)
@@ -110,7 +90,7 @@ func (ch *ctlSockHandler) handleConnection(conn *net.UnixConn) {
}
// handleRequest handles an already-unmarshaled JSON request
-func (ch *ctlSockHandler) handleRequest(in *RequestStruct, conn *net.UnixConn) {
+func (ch *ctlSockHandler) handleRequest(in *ctlsock.RequestStruct, conn *net.UnixConn) {
var err error
var inPath, outPath, clean, warnText string
// You cannot perform both decryption and encryption in one request
@@ -153,7 +133,7 @@ func (ch *ctlSockHandler) handleRequest(in *RequestStruct, conn *net.UnixConn) {
// sendResponse sends a JSON response message
func sendResponse(conn *net.UnixConn, err error, result string, warnText string) {
- msg := ResponseStruct{
+ msg := ctlsock.ResponseStruct{
Result: result,
WarnText: warnText,
}
diff --git a/internal/ctlsock/sanitize.go b/internal/ctlsocksrv/sanitize.go
index 7cf77a5..4333872 100644
--- a/internal/ctlsock/sanitize.go
+++ b/internal/ctlsocksrv/sanitize.go
@@ -1,4 +1,4 @@
-package ctlsock
+package ctlsocksrv
import (
"path/filepath"
diff --git a/internal/ctlsock/sanitize_test.go b/internal/ctlsocksrv/sanitize_test.go
index d79fa7c..2462d5d 100644
--- a/internal/ctlsock/sanitize_test.go
+++ b/internal/ctlsocksrv/sanitize_test.go
@@ -1,4 +1,4 @@
-package ctlsock
+package ctlsocksrv
import (
"testing"
diff --git a/internal/fusefrontend/ctlsock_interface.go b/internal/fusefrontend/ctlsock_interface.go
index e96d08d..2131463 100644
--- a/internal/fusefrontend/ctlsock_interface.go
+++ b/internal/fusefrontend/ctlsock_interface.go
@@ -7,13 +7,13 @@ import (
"strings"
"syscall"
- "github.com/rfjakob/gocryptfs/internal/ctlsock"
+ "github.com/rfjakob/gocryptfs/internal/ctlsocksrv"
"github.com/rfjakob/gocryptfs/internal/nametransform"
"github.com/rfjakob/gocryptfs/internal/syscallcompat"
"github.com/rfjakob/gocryptfs/internal/tlog"
)
-var _ ctlsock.Interface = &FS{} // Verify that interface is implemented.
+var _ ctlsocksrv.Interface = &FS{} // Verify that interface is implemented.
// EncryptPath implements ctlsock.Backend
//
diff --git a/internal/fusefrontend_reverse/ctlsock_interface.go b/internal/fusefrontend_reverse/ctlsock_interface.go
index a1e782d..f7b8afd 100644
--- a/internal/fusefrontend_reverse/ctlsock_interface.go
+++ b/internal/fusefrontend_reverse/ctlsock_interface.go
@@ -6,11 +6,11 @@ import (
"golang.org/x/sys/unix"
- "github.com/rfjakob/gocryptfs/internal/ctlsock"
+ "github.com/rfjakob/gocryptfs/internal/ctlsocksrv"
"github.com/rfjakob/gocryptfs/internal/pathiv"
)
-var _ ctlsock.Interface = &ReverseFS{} // Verify that interface is implemented.
+var _ ctlsocksrv.Interface = &ReverseFS{} // Verify that interface is implemented.
// EncryptPath implements ctlsock.Backend.
// This is used for the control socket and for the "-exclude" logic.