Skip to content

Commit

Permalink
Relax startup to avoid race conditions under certain scenario. (#909)
Browse files Browse the repository at this point in the history
  • Loading branch information
joel-rieke committed Jan 25, 2024
1 parent d1b1c5c commit 05a6670
Showing 1 changed file with 9 additions and 11 deletions.
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

0 comments on commit 05a6670

Please sign in to comment.