From 483df6fd821145de6a5e64ed2bff3e9647e87e7e Mon Sep 17 00:00:00 2001 From: galal-hussein Date: Wed, 8 May 2019 23:34:12 +0200 Subject: [PATCH] Check if server time before 1/1/1980 Check --- pkg/cli/server/server.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pkg/cli/server/server.go b/pkg/cli/server/server.go index 0b7b26a423..5011132fe1 100644 --- a/pkg/cli/server/server.go +++ b/pkg/cli/server/server.go @@ -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 +}