From 13b90749eb1b3547bbfbb47fe142cb96a17234b5 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Mon, 10 Jun 2019 23:36:05 +0200 Subject: [PATCH] nsscash: improve comments --- file.go | 8 +++++++- group.go | 4 ++-- passwd.go | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/file.go b/file.go index 33d71c1..02bc767 100644 --- a/file.go +++ b/file.go @@ -31,6 +31,11 @@ import ( ) func handleFiles(cfg *Config, state *State) error { + // Split into fetch and deploy phase to prevent updates of only some + // files which might lead to inconsistent state; obviously this won't + // work during the deploy phase, but it helps if the web server fails + // to deliver some files + for i, f := range cfg.Files { err := fetchFile(&cfg.Files[i], state) if err != nil { @@ -135,7 +140,8 @@ func deployFile(file *File) error { defer os.Remove(f.Name()) defer f.Close() - // Apply permissions/user/group from the target file + // Apply permissions/user/group from the target file, use Stat instead + // of Lstat as only the target's permissions are relevant stat, err := os.Stat(file.Path) if err != nil { // We do not create the path if it doesn't exist, because we diff --git a/group.go b/group.go index 4513758..0ad8671 100644 --- a/group.go +++ b/group.go @@ -45,7 +45,7 @@ type GroupKey struct { Name string Passwd string Gid uint64 - Members string + Members string // "," separated } func toKey(g Group) GroupKey { @@ -58,7 +58,7 @@ func toKey(g Group) GroupKey { } // ParseGroups parses a file in the format of /etc/group and returns all -// entries as Group structs. +// entries as slice of Group structs. func ParseGroups(r io.Reader) ([]Group, error) { var res []Group diff --git a/passwd.go b/passwd.go index 90fed68..07a62d8 100644 --- a/passwd.go +++ b/passwd.go @@ -44,7 +44,7 @@ type Passwd struct { } // ParsePasswds parses a file in the format of /etc/passwd and returns all -// entries as Passwd structs. +// entries as slice of Passwd structs. func ParsePasswds(r io.Reader) ([]Passwd, error) { var res []Passwd -- 2.45.2