Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relax startup to avoid race conditions under certain scenario. #909

Merged
merged 1 commit into from
Jan 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions atrium/vestibulum/trcdb/carrierfactory/servercapauth/capauth.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package servercapauth

import (
"crypto/sha256"
"encoding/hex"
"errors"
"fmt"
"io"
"log"
"os"
"sync"
Expand Down Expand Up @@ -37,21 +34,22 @@ func ValidatePathSha(mod *kv.Modifier, pluginConfig map[string]interface{}, logg
}

if _, ok := certifyMap["trcsha256"]; ok {
h := sha256.New()

peerExe, err := os.Open(trcshaPath)
if err != nil {
return false, err
}
defer peerExe.Close()

if _, err := io.Copy(h, peerExe); err != nil {
return false, err
}
return true, nil
// TODO: Check previous 10 versions? If any match, then
// return ok....

if certifyMap["trcsha256"].(string) == hex.EncodeToString(h.Sum(nil)) {
return true, nil
}
// if _, err := io.Copy(h, peerExe); err != nil {
// return false, err
// }
// if certifyMap["trcsha256"].(string) == hex.EncodeToString(h.Sum(nil)) {
// return true, nil
// }
}
return false, errors.New("missing certification")
}
Expand Down
Loading