From def822cd45377715589c2abdd0624049cfd51d35 Mon Sep 17 00:00:00 2001 From: nemunaire Date: Fri, 10 Nov 2017 20:53:49 +0100 Subject: [PATCH] frontend: avoid RW access to TEAMS dir by placing startedFile into submissions --- backend/generation.go | 3 ++- frontend/main.go | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/backend/generation.go b/backend/generation.go index ccc59699..74a51b40 100644 --- a/backend/generation.go +++ b/backend/generation.go @@ -14,7 +14,7 @@ import ( // Check if the challenge is started or not func isStarted() bool { - if _, err := os.Stat(path.Join(TeamsDir, "started")); os.IsNotExist(err) { + if _, err := os.Stat(path.Join(SubmissionDir, "started")); os.IsNotExist(err) { return false } return true @@ -38,6 +38,7 @@ func genTeamMyFile(team fic.Team) error { return err } + // Speed up generation when challenge is started if !isStarted() { if my, err := fic.MyJSONTeam(&team, false); err != nil { return err diff --git a/frontend/main.go b/frontend/main.go index 3c939ef4..0bcac03b 100644 --- a/frontend/main.go +++ b/frontend/main.go @@ -22,7 +22,7 @@ var TmpSubmissionDir string var touchTimer *time.Timer = nil func touchStartedFile() { - if fd, err := os.Create(path.Join(TeamsDir, startedFile)); err == nil { + if fd, err := os.Create(path.Join(SubmissionDir, startedFile)); err == nil { log.Println("Started! Go, Go, Go!!") fd.Close() } else { @@ -39,8 +39,8 @@ func reloadSettings(config settings.FICSettings) { if startSub > 0 { log.Println("Challenge will starts at", config.Start, "in", startSub) - if _, err := os.Stat(path.Join(TeamsDir, startedFile)); !os.IsNotExist(err) { - os.Remove(path.Join(TeamsDir, startedFile)) + if _, err := os.Stat(path.Join(SubmissionDir, startedFile)); !os.IsNotExist(err) { + os.Remove(path.Join(SubmissionDir, startedFile)) } touchTimer = time.AfterFunc(config.Start.Sub(time.Now().Add(time.Duration(1 * time.Second))), touchStartedFile)