Check if server time before 1/1/1980

Check
pull/459/head
galal-hussein 2019-05-08 23:34:12 +02:00
parent 1d42fc9755
commit 483df6fd82
1 changed files with 14 additions and 0 deletions

View File

@ -8,6 +8,7 @@ import (
"os"
"path/filepath"
"strings"
"time"
systemd "github.com/coreos/go-systemd/daemon"
"github.com/docker/docker/pkg/reexec"
@ -67,6 +68,10 @@ func run(app *cli.Context, cfg *cmds.Server) error {
return runWithLogging(app, cfg)
}
if err := checkUnixTimestamp(); err != nil {
return err
}
setupLogging(app)
if !cfg.DisableAgent && os.Getuid() != 0 && !cfg.Rootless {
@ -180,3 +185,12 @@ func knownIPs(ips []string) []string {
}
return ips
}
func checkUnixTimestamp() error {
timeNow := time.Now()
// check if time before 01/01/1980
if timeNow.Before(time.Unix(315532800, 0)) {
return fmt.Errorf("server time isn't set properly: %v", timeNow)
}
return nil
}