Skip to content

Commit

Permalink
Merge pull request #22 from trimble-oss/address_global_init_problem
Browse files Browse the repository at this point in the history
Simplify pensedir
  • Loading branch information
joel-rieke authored Sep 27, 2024
2 parents b0ae82a + 0c5028a commit 35e0d5f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 16 deletions.
4 changes: 3 additions & 1 deletion brim/brim.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ func init() {
rand.Seed(time.Now().UnixNano())
}

const penseDir = "/tmp/trccarrier/"

var letterRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")

func randomString(n int) string {
Expand Down Expand Up @@ -66,7 +68,7 @@ func penseQuery(pense string) {
}
}

eyeMap, err := tap.TapWriter(penseSum)
eyeMap, err := tap.TapWriter(penseDir, penseSum)
if err != nil {
log.Fatalf("Failure to communicate: %v", err)
}
Expand Down
18 changes: 5 additions & 13 deletions cap/tap/tap_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,11 @@ import (

const penseSocket = "./snap.sock"

var (
penseDir string = "/tmp/trccarrier/"
)

func TapInit(pd string) {
penseDir = pd
}

//const penseDir = "/tmp/trccarrier/"
func Tap(penseDir string, tapMap map[string]string, group string, skipPathControls bool) error {
// Tap always starts with a clean slate.

var penseDirSocket = filepath.Clean(penseDir + penseSocket)
var penseDirSocket = filepath.Clean(penseDir + penseSocket)

func Tap(tapMap map[string]string, group string, skipPathControls bool) error {
// Tap always starts with a clean slate.
err := os.MkdirAll(penseDir, 0770)
if err != nil {
return errors.Join(errors.New("Dir create error"), err)
Expand Down Expand Up @@ -152,7 +143,8 @@ func Tap(tapMap map[string]string, group string, skipPathControls bool) error {
}
}

func TapWriter(pense string) (map[string]string, error) {
func TapWriter(penseDir string, pense string) (map[string]string, error) {
var penseDirSocket = filepath.Clean(penseDir + penseSocket)
penseConn, penseErr := net.Dial("unix", penseDirSocket)
if penseErr != nil {
return nil, penseErr
Expand Down
4 changes: 3 additions & 1 deletion captap/captap.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"github.com/trimble-oss/tierceron-hat/cap/tap"
)

const penseDir = "/tmp/trccarrier/"

// Not really part of example set... extracted from cap to simplify that library.
func main() {
ex, err := os.Executable()
Expand All @@ -18,6 +20,6 @@ func main() {
exePath := filepath.Dir(ex)
brimPath := strings.Replace(exePath, "/Cap", "/brim", 1)
tapMap := map[string]string{brimPath: "2c1d03a2869e2040bbd125661f49d4bca2b9b0751ec92d0119a744edc31932ff"}
go tap.Tap(tapMap, "", true)
go tap.Tap(penseDir, tapMap, "", true)
cap.TapServer("127.0.0.1:1534")
}
4 changes: 3 additions & 1 deletion crown/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"github.com/trimble-oss/tierceron-hat/cap/tap"
)

const penseDir = "/tmp/trccarrier/"

// The original crown
func main() {
exePath, exePathErr := os.Readlink("/proc/self/exe")
Expand All @@ -16,7 +18,7 @@ func main() {
}
brimPath := strings.Replace(exePath, "/crown", "/brim", 1)
tapMap := map[string]string{brimPath: "2c1d03a2869e2040bbd125661f49d4bca2b9b0751ec92d0119a744edc31932ff"}
go tap.Tap(tapMap, "", false)
go tap.Tap(penseDir, tapMap, "", false)

tap.TapEyeRemember("eye", "rememeber")
cap.TapMemorize("I think", "therefore I am.")
Expand Down

0 comments on commit 35e0d5f

Please sign in to comment.