Add mass entry verification function (should be used after EntryRefresh); disable CGO across the board

This commit is contained in:
2026-01-24 15:34:34 -05:00
parent b963ccf33e
commit cb3a554676
2 changed files with 28 additions and 4 deletions
+25 -1
View File
@@ -74,7 +74,7 @@ func EntryRefresh(oldRCWPassword, newRCWPassword []byte, removeOldDir bool) erro
// decrypt, optimize, and re-encrypt each entry // decrypt, optimize, and re-encrypt each entry
for _, vanityPath := range entries { for _, vanityPath := range entries {
fmt.Println(vanityPath) // useful for CLI clients to track what entry caused a panic if one is corrupt fmt.Println(vanityPath) // TODO handle error in rcw (slice length?) so it can be captured and returned for use by non-CLI clients to track corrupt entries
realPath := global.GetRealPath(vanityPath) realPath := global.GetRealPath(vanityPath)
encBytes, err := os.ReadFile(realPath) encBytes, err := os.ReadFile(realPath)
if err != nil { if err != nil {
@@ -113,6 +113,30 @@ func EntryRefresh(oldRCWPassword, newRCWPassword []byte, removeOldDir bool) erro
return nil return nil
} }
// VerifyEntries decrypts all entries to memory and returns an error if
// any failures are encountered. Failures likely indicate corrupt entries.
func VerifyEntries(rcwPassword []byte) error {
entries, _, err := synccommon.WalkEntryDir()
if err != nil {
return errors.New("unable to walk entry directory: " + err.Error())
}
for _, vanityPath := range entries {
realPath := global.GetRealPath(vanityPath)
encBytes, err := os.ReadFile(realPath)
if err != nil {
return errors.New("unable to open \"" + realPath + "\" for decryption: " + err.Error())
}
decBytes, err := wrappers.Decrypt(encBytes, rcwPassword)
if err != nil {
return errors.New("unable verify \"" + vanityPath + "\" (decryption failure): " + err.Error())
}
if len(decBytes) < 1 {
return errors.New("unable verify \"" + vanityPath + "\" (contains 0/nil bytes)")
}
}
return nil
}
// clampTrailingWhitespace ensures the provided decSlice contains no trailing blank lines. // clampTrailingWhitespace ensures the provided decSlice contains no trailing blank lines.
// If decSlice contains a note, it strips trailing newlines, carriage returns, and tabs from // If decSlice contains a note, it strips trailing newlines, carriage returns, and tabs from
// each line in the note. Additionally, it removes single trailing spaces and truncates // each line in the note. Additionally, it removes single trailing spaces and truncates
+3 -3
View File
@@ -9,7 +9,7 @@
mkdir -p ./1output mkdir -p ./1output
cd .. cd ..
GOOS=linux CGO_ENABLED=0 GOAMD64=v2 go build -o ./packaging/1output/libmuttonserver-linux-x86_64_v2 -ldflags="-s -w" -trimpath ./libmuttonserver.go GOOS=linux CGO_ENABLED=0 GOAMD64=v2 go build -o ./packaging/1output/libmuttonserver-linux-x86_64_v2 -ldflags="-s -w" -trimpath ./libmuttonserver.go
GOOS=linux GOARCH=arm64 GOARM64=v8.0 CGO_ENABLED=0 go build -o ./packaging/1output/libmuttonserver-linux-arm64v8.0 -ldflags="-s -w" -trimpath ./libmuttonserver.go GOOS=linux CGO_ENABLED=0 GOARCH=arm64 GOARM64=v8.0 CGO_ENABLED=0 go build -o ./packaging/1output/libmuttonserver-linux-arm64v8.0 -ldflags="-s -w" -trimpath ./libmuttonserver.go
GOOS=linux GOARCH=arm64 GOARM64=v8.7 CGO_ENABLED=0 go build -o ./packaging/1output/libmuttonserver-linux-arm64v8.7 -ldflags="-s -w" -trimpath ./libmuttonserver.go GOOS=linux CGO_ENABLED=0 GOARCH=arm64 GOARM64=v8.7 CGO_ENABLED=0 go build -o ./packaging/1output/libmuttonserver-linux-arm64v8.7 -ldflags="-s -w" -trimpath ./libmuttonserver.go
GOOS=windows CGO_ENABLED=0 GOAMD64=v2 go build -o ./packaging/1output/libmuttonserver-windows-x86_64_v2.exe -ldflags="-s -w" -trimpath ./libmuttonserver.go GOOS=windows CGO_ENABLED=0 GOAMD64=v2 go build -o ./packaging/1output/libmuttonserver-windows-x86_64_v2.exe -ldflags="-s -w" -trimpath ./libmuttonserver.go
GOOS=windows GOARCH=arm64 GOARM64=v8.7 CGO_ENABLED=0 go build -o ./packaging/1output/libmuttonserver-windows-arm64v8.7.exe -ldflags="-s -w" -trimpath ./libmuttonserver.go GOOS=windows CGO_ENABLED=0 GOARCH=arm64 GOARM64=v8.7 CGO_ENABLED=0 go build -o ./packaging/1output/libmuttonserver-windows-arm64v8.7.exe -ldflags="-s -w" -trimpath ./libmuttonserver.go