]> ruderich.org/simon Gitweb - safcm/safcm.git/commitdiff
Use 4 spaces per tab for Go files master
authorSimon Ruderich <simon@ruderich.org>
Sat, 18 Oct 2025 06:52:51 +0000 (08:52 +0200)
committerSimon Ruderich <simon@ruderich.org>
Sat, 18 Oct 2025 06:52:51 +0000 (08:52 +0200)
65 files changed:
cmd/safcm-remote/main.go
cmd/safcm/config/commands.go
cmd/safcm/config/config.go
cmd/safcm/config/files.go
cmd/safcm/config/files_test.go
cmd/safcm/config/groups.go
cmd/safcm/config/groups_test.go
cmd/safcm/config/hosts.go
cmd/safcm/config/hosts_test.go
cmd/safcm/config/packages.go
cmd/safcm/config/permissions.go
cmd/safcm/config/permissions_test.go
cmd/safcm/config/services.go
cmd/safcm/config/templates.go
cmd/safcm/config/templates_test.go
cmd/safcm/config/triggers.go
cmd/safcm/config/triggers_test.go
cmd/safcm/fixperms.go
cmd/safcm/main.go
cmd/safcm/main_sync_test.go
cmd/safcm/remote.go
cmd/safcm/sync.go
cmd/safcm/sync_info.go
cmd/safcm/sync_info_test.go
cmd/safcm/sync_sync.go
cmd/safcm/sync_sync_test.go
cmd/safcm/sync_test.go
cmd/safcm/version.go
frontend/changes.go
frontend/changes_test.go
frontend/conn.go
frontend/log.go
frontend/log_test.go
frontend/loop.go
frontend/term.go
frontend/term_test.go
gob.go
log.go
remote/ainsl/ainsl.go
remote/ainsl/ainsl_test.go
remote/info/info.go
remote/log/logger.go
remote/main.go
remote/run/cmd.go
remote/run/runner.go
remote/sync/commands.go
remote/sync/commands_test.go
remote/sync/files.go
remote/sync/files_compat_windows.go
remote/sync/files_test.go
remote/sync/filetest/filetest.go
remote/sync/packages.go
remote/sync/packages_debian.go
remote/sync/packages_debian_test.go
remote/sync/services.go
remote/sync/services_systemd.go
remote/sync/services_systemd_test.go
remote/sync/sync.go
remote/sync/sync_test.go
remote/sync/triggers.go
remote/sync/triggers_test.go
rpc/conn.go
rpc/dial.go
testutil/testutil.go
types.go

index 09ef8180f884c2bb17e106fbb3899e5878fa13bb..6880ce06ec56dda92eee1a93f6498514aa39048b 100644 (file)
@@ -12,3 +12,5 @@ import (
 func main() {
        remote.Main()
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index b479fcebbe8105a9f4d733d7946c7c7106995576..673c539e1806575d6b8f7b65544c4dadd3b09ca3 100644 (file)
@@ -40,3 +40,5 @@ func LoadCommands(group string) ([]*safcm.Command, error) {
        }
        return res, nil
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index 7ec8d4f8fbc287c80e6faa582ffc7de4c9d4b651..43214eaa28c45d1e9235beaf602ede92bcb35d58 100644 (file)
@@ -44,3 +44,5 @@ func LoadConfig() (*Config, error) {
        }
        return &cfg, nil
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index a488974faeaec83ab3595935b5f6ba78576ccd07..66b9c60b3117f8dc5a0102378dd00896d23f8a38 100644 (file)
@@ -47,18 +47,16 @@ via "safcm fixperms".
                perm := FileModeToFullPerm(info.Mode())
 
                var data []byte
-               // See errMsg above. If a user stores a file with stricter
-               // permissions they could assume that these permissions are
-               // respected. This is not the case.
+               // See errMsg above. If a user stores a file with stricter permissions
+               // they could assume that these permissions are respected. This is not
+               // the case.
                if typ == 0 /* regular file */ {
                        if windows {
                                perm = 0644
-                               // 0755 must be set via permissions.yaml if
-                               // windows is used
+                               // 0755 must be set via permissions.yaml if windows is used
                        }
                        if perm != 0644 && perm != 0755 {
-                               return fmt.Errorf(
-                                       "%q: invalid permissions %#o%s",
+                               return fmt.Errorf("%q: invalid permissions %#o%s",
                                        path, perm, errMsg)
                        }
                        data, err = os.ReadFile(path)
@@ -70,8 +68,7 @@ via "safcm fixperms".
                                perm = 0755
                        }
                        if perm != 0755 {
-                               return fmt.Errorf(
-                                       "%q: invalid permissions %#o%s",
+                               return fmt.Errorf("%q: invalid permissions %#o%s",
                                        path, perm, errMsg)
                        }
                } else if typ == fs.ModeSymlink {
@@ -85,8 +82,8 @@ via "safcm fixperms".
                        return fmt.Errorf("%q: file type not supported", path)
                }
 
-               // Convert to absolute and slash-separated path as used on the
-               // target host
+               // Convert to absolute and slash-separated path as used on the target
+               // host
                x, err := filepath.Rel(basePath, path)
                if err != nil {
                        return err
@@ -110,3 +107,5 @@ via "safcm fixperms".
        }
        return files, nil
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index de9a2ad0a65ac5d119b466166d412fa49de1bf5a..194238030434ad7089fbb557f5151d464c3419ab 100644 (file)
@@ -204,3 +204,5 @@ host3.example.net
                })
        }
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index d77dbbef579396d2406a52364dd90ebcd80c220a..626c053b7669a328303cde8300251dfdb317ef3d 100644 (file)
@@ -49,24 +49,20 @@ func LoadGroups(cfg *Config, hosts *Hosts) (map[string][]string, error) {
                                errPrefix, name)
                }
                if hosts.Map[name] != nil ||
-                       hosts.Map[strings.TrimSuffix(name,
-                               GroupRemoveSuffix)] != nil {
-                       return nil, fmt.Errorf(
-                               "%s conflict with existing host",
+                       hosts.Map[strings.TrimSuffix(name, GroupRemoveSuffix)] != nil {
+                       return nil, fmt.Errorf("%s conflict with existing host",
                                errPrefix)
                }
 
                if strings.HasPrefix(name, GroupDetectedPrefix) {
-                       return nil, fmt.Errorf(
-                               "%s name must not start with %q "+
-                                       "(reserved for detected groups)",
+                       return nil, fmt.Errorf("%s name must not start with %q "+
+                               "(reserved for detected groups)",
                                errPrefix, GroupDetectedPrefix)
                }
                if !groupNameRegexp.MatchString(
                        strings.TrimSuffix(name, GroupRemoveSuffix)) {
-                       return nil, fmt.Errorf(
-                               "%s name contains invalid characters "+
-                                       "(must match %s)",
+                       return nil, fmt.Errorf("%s name contains invalid characters "+
+                               "(must match %s)",
                                errPrefix, groupNameRegexp)
                }
 
@@ -74,11 +70,10 @@ func LoadGroups(cfg *Config, hosts *Hosts) (map[string][]string, error) {
                        if x == GroupAll {
                                continue
                        }
-                       // Don't validate against groupNameRegexp because
-                       // hosts have less strict restrictions.
+                       // Don't validate against groupNameRegexp because hosts have less
+                       // strict restrictions.
                        if strings.Contains(x, GroupSpecialSeparator) {
-                               return nil, fmt.Errorf(
-                                       "%s member %q must not contain %q",
+                               return nil, fmt.Errorf("%s member %q must not contain %q",
                                        errPrefix, x, GroupSpecialSeparator)
                        }
                        if strings.HasPrefix(x, GroupDetectedPrefix) {
@@ -87,8 +82,7 @@ func LoadGroups(cfg *Config, hosts *Hosts) (map[string][]string, error) {
                        if hosts.Map[x] != nil || groups[x] != nil {
                                continue
                        }
-                       return nil, fmt.Errorf("%s member %q not found",
-                               errPrefix, x)
+                       return nil, fmt.Errorf("%s member %q not found", errPrefix, x)
                }
        }
 
@@ -100,8 +94,7 @@ func LoadGroups(cfg *Config, hosts *Hosts) (map[string][]string, error) {
                        continue
                }
                if strings.Contains(x, GroupSpecialSeparator) {
-                       return nil, fmt.Errorf("%s invalid group name %q",
-                               errPrefix, x)
+                       return nil, fmt.Errorf("%s invalid group name %q", errPrefix, x)
                }
                if strings.HasPrefix(x, GroupDetectedPrefix) {
                        continue
@@ -109,8 +102,7 @@ func LoadGroups(cfg *Config, hosts *Hosts) (map[string][]string, error) {
                if groups[x] != nil {
                        continue
                }
-               return nil, fmt.Errorf("%s group %q does not exist",
-                       errPrefix, x)
+               return nil, fmt.Errorf("%s group %q does not exist", errPrefix, x)
        }
 
        return groups, nil
@@ -139,8 +131,7 @@ func ResolveHostGroups(host string, groups map[string][]string,
                        if x == host || detectedGroupsMap[x] || x == GroupAll {
                                return true
                        }
-                       if lookup(x, depth+1) &&
-                               !lookup(x+GroupRemoveSuffix, depth+1) {
+                       if lookup(x, depth+1) && !lookup(x+GroupRemoveSuffix, depth+1) {
                                return true
                        }
                }
@@ -165,8 +156,7 @@ func ResolveHostGroups(host string, groups map[string][]string,
                }
        }
        if cycle != nil {
-               return nil, fmt.Errorf(
-                       "groups.yaml: cycle while expanding group %q",
+               return nil, fmt.Errorf("groups.yaml: cycle while expanding group %q",
                        *cycle)
        }
 
@@ -194,12 +184,10 @@ func TransitivelyDetectedGroups(groups map[string][]string) map[string]bool {
                change := false
                for group, members := range work {
                        for _, x := range members {
-                               if !detected[x] && !strings.HasPrefix(x,
-                                       GroupDetectedPrefix) {
+                               if !detected[x] && !strings.HasPrefix(x, GroupDetectedPrefix) {
                                        continue
                                }
-                               detected[strings.TrimSuffix(group,
-                                       GroupRemoveSuffix)] = true
+                               detected[strings.TrimSuffix(group, GroupRemoveSuffix)] = true
                                delete(work, group)
                                change = true
                        }
@@ -210,3 +198,5 @@ func TransitivelyDetectedGroups(groups map[string][]string) map[string]bool {
        }
        return detected
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index 6f08d1ceb5abbca8d7973598c739b1b3baa06ae1..bba47d94b6be815103a89dca8d4142f5653c71df 100644 (file)
@@ -285,8 +285,7 @@ func TestResolveHostGroups(t *testing.T) {
 
        for _, tc := range tests {
                t.Run(tc.name, func(t *testing.T) {
-                       res, err := ResolveHostGroups(tc.host, allGroups,
-                               tc.detected)
+                       res, err := ResolveHostGroups(tc.host, allGroups, tc.detected)
                        testutil.AssertEqual(t, "res", res, tc.exp)
                        testutil.AssertErrorEqual(t, "err", err, tc.expErr)
                })
@@ -435,3 +434,5 @@ func TestTransitivelyDetectedGroups(t *testing.T) {
                })
        }
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index 457f1e323af0127b23db7cf33dd9449032af7900..4c36718f166334bb5f73081a8ee81ae8e91b65aa 100644 (file)
@@ -41,25 +41,21 @@ func LoadHosts() (*Hosts, error) {
        for _, x := range hostList {
                errPrefix := fmt.Sprintf("%s: host %q:", path, x.Name)
                if x.Name == GroupAll {
-                       return nil, fmt.Errorf(
-                               "%s conflict with pre-defined group %q",
+                       return nil, fmt.Errorf("%s conflict with pre-defined group %q",
                                errPrefix, x.Name)
                }
                if strings.HasPrefix(x.Name, GroupDetectedPrefix) {
-                       return nil, fmt.Errorf(
-                               "%s name must not start with %q "+
-                                       "(reserved for detected groups)",
+                       return nil, fmt.Errorf("%s name must not start with %q "+
+                               "(reserved for detected groups)",
                                errPrefix, GroupDetectedPrefix)
                }
                if strings.Contains(x.Name, GroupSpecialSeparator) {
-                       return nil, fmt.Errorf(
-                               "%s name must not contain %q",
+                       return nil, fmt.Errorf("%s name must not contain %q",
                                errPrefix, GroupSpecialSeparator)
                }
 
                if hostMap[x.Name] != nil {
-                       return nil, fmt.Errorf("%s host name already exists",
-                               errPrefix)
+                       return nil, fmt.Errorf("%s host name already exists", errPrefix)
                }
                hostMap[x.Name] = x
        }
@@ -69,3 +65,5 @@ func LoadHosts() (*Hosts, error) {
                Map:  hostMap,
        }, nil
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index 0eebc56d5b7244f7fbdd9aee9095ca0091aa5673..c55b766be4a8f9f663111ca0cc8287533226df49 100644 (file)
@@ -75,3 +75,5 @@ func TestLoadHosts(t *testing.T) {
                })
        }
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index 6f87c5a1b94f921a55fe9fbdc8d1b80da2d37bd7..c93608169f231f20d6f05479a874ade66668b8ac 100644 (file)
@@ -41,3 +41,5 @@ func LoadPackages(group string) ([]string, error) {
 
        return res, nil
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index 8a8ae64749284527e82b69491bc10efaca024bcd..3a92acab211dae6d13e2e8afd3d1af5a92d91665 100644 (file)
@@ -37,8 +37,7 @@ func LoadPermissions(group string, files map[string]*safcm.File) error {
        for p, x := range cfg {
                _, ok := files[p]
                if !ok {
-                       return fmt.Errorf("%s: %q does not exist in files/",
-                               path, p)
+                       return fmt.Errorf("%s: %q does not exist in files/", path, p)
                }
 
                xs := strings.Fields(x)
@@ -62,9 +61,8 @@ func LoadPermissions(group string, files map[string]*safcm.File) error {
                file := files[p]
                // Sanity check
                if file.Mode.Perm()&0111 != 0 && perm&0111 == 0 {
-                       return fmt.Errorf(
-                               "%s: %q: trying to remove +x from file, "+
-                                       "manually chmod -x in files/",
+                       return fmt.Errorf("%s: %q: trying to remove +x from file, "+
+                               "manually chmod -x in files/",
                                path, p)
                }
                file.Mode = file.Mode.Type() | FullPermToFileMode(int(perm))
@@ -104,3 +102,5 @@ func FullPermToFileMode(perm int) fs.FileMode {
        }
        return mode
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index 3c043f094ca950fecb1e5280b237a348d0ae449f..4a15a15130599889a93ae482aefbf4cbeada2918 100644 (file)
@@ -241,8 +241,8 @@ host3.example.net
 
        for _, tc := range tests {
                t.Run(tc.group, func(t *testing.T) {
-                       // Use LoadFiles() so we work on real data and don't
-                       // make any mistakes generating it
+                       // Use LoadFiles() so we work on real data and don't make any
+                       // mistakes generating it
                        files, err := LoadFiles(tc.group)
                        if err != nil {
                                t.Fatalf("err = %#v, want nil", err)
@@ -254,3 +254,5 @@ host3.example.net
                })
        }
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index 84a85d3f509c3526acffa0ef9c447da11a61837a..6f921fd4bd1718493b9278da62c3d3bcb3bbca52 100644 (file)
@@ -41,3 +41,5 @@ func LoadServices(group string) ([]string, error) {
 
        return res, nil
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index b03b28ec3dbfebd56a1f41373af5e7e80167a013..fd46182a0b75136506e4ec555244318b960c0c0c 100644 (file)
@@ -53,12 +53,10 @@ func LoadTemplates(group string, files map[string]*safcm.File,
        for _, x := range templates {
                f, ok := files[x]
                if !ok {
-                       return fmt.Errorf("%s: %q does not exist in files/",
-                               path, x)
+                       return fmt.Errorf("%s: %q does not exist in files/", path, x)
                }
                if f.Mode.Type() != 0 /* regular file */ {
-                       return fmt.Errorf("%s: %q is not a regular file",
-                               path, x)
+                       return fmt.Errorf("%s: %q is not a regular file", path, x)
                }
 
                tmplPath := filepath.Join(group, "files", x)
@@ -102,8 +100,8 @@ func (t *templateArgs) IsHost(host string) bool {
        return t.host == host
 }
 func (t *templateArgs) InGroup(group string) bool {
-       // Don't permit invalid groups to detect typos; detected groups cannot
-       // be checked
+       // Don't permit invalid groups to detect typos; detected groups cannot be
+       // checked
        if group != GroupAll &&
                !t.allGroups[group] &&
                !t.allHosts[group] &&
@@ -112,3 +110,5 @@ func (t *templateArgs) InGroup(group string) bool {
        }
        return t.groups[group]
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index ff62cdcc1601fe2dec2345ac5f01c03399fc2312..a30578269a3ef91e52751fba43936ea7d85c7184 100644 (file)
@@ -228,8 +228,8 @@ host1.example.org
 
        for _, tc := range tests {
                t.Run(tc.group, func(t *testing.T) {
-                       // Use LoadFiles() so we work on real data and don't
-                       // make any mistakes generating it
+                       // Use LoadFiles() so we work on real data and don't make any
+                       // mistakes generating it
                        files, err := LoadFiles(tc.group)
                        if err != nil {
                                t.Fatalf("err = %#v, want nil", err)
@@ -242,3 +242,5 @@ host1.example.org
                })
        }
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index da9155850d4bbb8b7b4e07ee21f951a23a87260c..de1ed61720ff76f99b92aa55e65fd23ccd515469 100644 (file)
@@ -34,11 +34,12 @@ func LoadTriggers(group string, files map[string]*safcm.File) error {
        for p, x := range triggers {
                f, ok := files[p]
                if !ok {
-                       return fmt.Errorf("%s: %q does not exist in files/",
-                               path, p)
+                       return fmt.Errorf("%s: %q does not exist in files/", path, p)
                }
                f.TriggerCommands = x
        }
 
        return nil
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index c395249fdb412fdc6b0f748cad1fed4ee1e98045..f15bc6610e79a855e5606a40362670d768950961 100644 (file)
@@ -123,8 +123,8 @@ host3.example.net
 
        for _, tc := range tests {
                t.Run(tc.group, func(t *testing.T) {
-                       // Use LoadFiles() so we work on real data and don't
-                       // make any mistakes generating it
+                       // Use LoadFiles() so we work on real data and don't make any
+                       // mistakes generating it
                        files, err := LoadFiles(tc.group)
                        if err != nil {
                                t.Fatalf("err = %#v, want nil", err)
@@ -136,3 +136,5 @@ host3.example.net
                })
        }
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index 738261e2ee102c243e48bb945cb52a680821badf..cebe6f6e55fcd091a813c72e22c1c0ad29d70b87 100644 (file)
@@ -64,9 +64,8 @@ func fixpermsWalkDirFunc(path string, d fs.DirEntry, err error) error {
                                perm = 0644
                        }
                        log.Printf("chmodding %q to %#o", path, perm)
-                       // This is safe because perm does not include
-                       // setuid/setgid/sticky which use different values in
-                       // FileMode.
+                       // This is safe because perm does not include setuid/setgid/sticky
+                       // which use different values in FileMode.
                        err := chmodNoFollow(path, fs.FileMode(perm))
                        if err != nil {
                                return err
@@ -102,3 +101,5 @@ func chmodNoFollow(path string, mode fs.FileMode) error {
 
        return nil
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index 2a9b11ec7ff6b5c3e73b9ab28818c51de49a8a92..f1d5f9e9f9368c6fa6f6d08ba2914113f9143120 100644 (file)
@@ -64,3 +64,5 @@ func LoadBaseFiles() (*config.Config, *config.Hosts, map[string][]string,
        }
        return cfg, hosts, groups, nil
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index b31b2ef90a4f11a4905c2261685b052aa8c3fd74..ac1ace020d5c11521b7d9e0320ec856e56336163 100644 (file)
@@ -140,8 +140,8 @@ func TestSyncSshEndToEnd(t *testing.T) {
                        nil,
                },
 
-               // NOTE: We use -n on regular runs to prevent changing
-               // anything important on the host when running as root!
+               // NOTE: We use -n on regular runs to prevent changing anything
+               // important on the host when running as root!
 
                {
                        "no changes (dry-run)",
@@ -336,8 +336,8 @@ executed 2 command(s):
                // Fake $PATH so safcm cannot find the `ssh` binary.
                t.Setenv("PATH", "")
 
-               cmd := exec.Command("../../../../../safcm",
-                       "sync", "-n", "no-settings.example.org")
+               cmd := exec.Command("../../../../../safcm", "sync", "-n",
+                       "no-settings.example.org")
                _, err = cmd.CombinedOutput()
                if err == nil {
                        t.Errorf("err = nil")
@@ -358,8 +358,8 @@ executed 2 command(s):
 
                        var tmp []string
                        for _, x := range strings.Split(string(out), "\n") {
-                               // Strip parts which change on each run (LOG)
-                               // or depending on the system (DET)
+                               // Strip parts which change on each run (LOG) or depending on
+                               // the system (DET)
                                x = logRegexp.ReplaceAllString(x, "<LOG>")
                                x = detectedRegexp.ReplaceAllString(x, "<DET>")
                                tmp = append(tmp, x)
@@ -373,3 +373,5 @@ executed 2 command(s):
 
        _ = os.Remove(remotePath)
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index 6f87d20611802458c24e92139ed6ee286993fb93..fc294941a1275a2815d6d66647930e8c45583a6a 100644 (file)
@@ -14,3 +14,5 @@ import (
 //
 //go:embed remote/*
 var RemoteHelpers embed.FS
+
+// vi: set noet ts=4 sw=4 sts=4:
index 232ff6d8d74476524fb20ac0a5cdbcb8205a495d..13a9c9aef807a30ba505fe3071db7835e59b3d3f 100644 (file)
@@ -38,8 +38,7 @@ type Sync struct {
 
 func MainSync(args []string) error {
        flag.Usage = func() {
-               fmt.Fprintf(os.Stderr,
-                       "usage: %s sync [<options>] <host|group...>\n",
+               fmt.Fprintf(os.Stderr, "usage: %s sync [<options>] <host|group...>\n",
                        args[0])
                flag.PrintDefaults()
        }
@@ -110,8 +109,7 @@ func MainSync(args []string) error {
                        isTTY:     isTTY,
                        loop:      loop,
                }
-               s.logFunc = func(level safcm.LogLevel, escaped bool,
-                       msg string) {
+               s.logFunc = func(level safcm.LogLevel, escaped bool, msg string) {
                        s.loop.Log(s, level, escaped, msg)
                }
                hosts = append(hosts, s)
@@ -120,8 +118,8 @@ func MainSync(args []string) error {
        succ := loop.Run(hosts)
 
        if !succ {
-               // Exit instead of returning an error to prevent an extra log
-               // message from main()
+               // Exit instead of returning an error to prevent an extra log message
+               // from main()
                os.Exit(1)
        }
        return nil
@@ -189,8 +187,7 @@ are only available after the hosts were contacted.
                var unmatched []string
                for x := range nameMap {
                        if !nameMatched[x] {
-                               unmatched = append(unmatched,
-                                       fmt.Sprintf("%q", x))
+                               unmatched = append(unmatched, fmt.Sprintf("%q", x))
                        }
                }
                sort.Strings(unmatched)
@@ -249,3 +246,5 @@ func (s *Sync) logDebugf(format string, a ...interface{}) {
 func (s *Sync) logVerbosef(format string, a ...interface{}) {
        s.log(safcm.LogVerbose, false, fmt.Sprintf(format, a...))
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index a298ff3c11b4e567d77ddee58618890fd08a6403..ed443b1d647164cddff2053fd9571ae372bd2b33 100644 (file)
@@ -50,3 +50,5 @@ func hostInfoDetectedGroupName(x string) string {
        x = config.GroupDetectedPrefix + "_" + x
        return x
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index 355db6d0ab5a1eee8ee5bb39d9c048dd7082db4f..e36c0c32ebb9e2ac8a409c6707967fc1f67dba5d 100644 (file)
@@ -73,3 +73,5 @@ func TestHostInfoRespToGroups(t *testing.T) {
                })
        }
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index c76ec4ac9fa753a18636e1c7e15a8a71a6553c8f..dfb3386ffc80cb516b0d8aa2d2976e112e6816ed 100644 (file)
@@ -55,16 +55,15 @@ func (s *Sync) hostSyncReq(detectedGroups []string) (
                return empty, err
        }
        {
-               // Don't leak internal group priority which is confusing
-               // without knowing the implementation details.
+               // Don't leak internal group priority which is confusing without
+               // knowing the implementation details.
                groupsSorted := make([]string, len(groups))
                copy(groupsSorted, groups)
                sort.Strings(groupsSorted)
-               s.logVerbosef("host groups: %s",
-                       strings.Join(groupsSorted, " "))
+               s.logVerbosef("host groups: %s", strings.Join(groupsSorted, " "))
 
-               // Don't leak internal priority values. Instead, order groups
-               // by priority.
+               // Don't leak internal priority values. Instead, order groups by
+               // priority.
                var priorities []string
                for x := range groupPriority {
                        priorities = append(priorities, x)
@@ -98,8 +97,8 @@ func (s *Sync) hostSyncReq(detectedGroups []string) (
                if err != nil {
                        return empty, err
                }
-               err = config.LoadTemplates(group, files,
-                       s.host.Name, groups, s.allHosts, s.allGroups)
+               err = config.LoadTemplates(group, files, s.host.Name, groups,
+                       s.allHosts, s.allGroups)
                if err != nil {
                        return empty, err
                }
@@ -108,8 +107,7 @@ func (s *Sync) hostSyncReq(detectedGroups []string) (
                        return empty, err
                }
                for k, v := range files {
-                       err := s.checkFileConflict(group, k, v,
-                               allFiles, groupPriority)
+                       err := s.checkFileConflict(group, k, v, allFiles, groupPriority)
                        if err != nil {
                                return empty, err
                        }
@@ -169,8 +167,8 @@ func (s *Sync) hostSyncReq(detectedGroups []string) (
 func (s *Sync) resolveHostGroups(detectedGroups []string) (
        []string, map[string]int, error) {
 
-       groups, err := config.ResolveHostGroups(s.host.Name,
-               s.allGroups, detectedGroups)
+       groups, err := config.ResolveHostGroups(s.host.Name, s.allGroups,
+               detectedGroups)
        if err != nil {
                return nil, nil, err
        }
@@ -222,8 +220,8 @@ func (s *Sync) checkFileConflict(group string, path string, file *safcm.File,
                panic("invalid group priorities")
        }
 
-       // Directories with default permissions and no triggers do not count
-       // as conflict
+       // Directories with default permissions and no triggers do not count as
+       // conflict
        if file.Mode.IsDir() && file.Mode == old.Mode &&
                config.FileModeToFullPerm(file.Mode) == 0755 &&
                file.TriggerCommands == nil && old.TriggerCommands == nil {
@@ -247,9 +245,9 @@ func resolveFileDirConflicts(files map[string]*safcm.File) {
        // Slash separated paths are used for the configuration
        const sep = "/"
 
-       // Remove invalid paths which can result from group_priority
-       // overriding paths from another group (e.g. "/foo" as file from one
-       // group and "/foo/bar" from another).
+       // Remove invalid paths which can result from group_priority overriding
+       // paths from another group (e.g. "/foo" as file from one group and
+       // "/foo/bar" from another).
        var last *safcm.File
        for _, x := range paths {
                file := files[x]
@@ -262,3 +260,5 @@ func resolveFileDirConflicts(files map[string]*safcm.File) {
                last = file
        }
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index 6493fe3cec7282c32e4559cefbdb476afeede938..8f377acecfe125f2b946d30400354a201a6efbcd 100644 (file)
@@ -27,8 +27,8 @@ func TestHostSyncReq(t *testing.T) {
                expErr    error
        }{
 
-               // NOTE: Also update MsgSyncReq in safcm-remote test cases
-               // changing the MsgSyncReq struct!
+               // NOTE: Also update MsgSyncReq in safcm-remote test cases changing
+               // the MsgSyncReq struct!
 
                {
                        "project: host1",
@@ -367,8 +367,9 @@ func TestHostSyncReq(t *testing.T) {
                        res, err := s.hostSyncReq(tc.detected)
                        testutil.AssertEqual(t, "res", res, tc.exp)
                        testutil.AssertErrorEqual(t, "err", err, tc.expErr)
-                       testutil.AssertEqual(t, "events",
-                               events, tc.expEvents)
+                       testutil.AssertEqual(t, "events", events, tc.expEvents)
                })
        }
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index 86774121a9530e1b9f7ac1359bbcd5c151fe84fe..cd1579d91ee5284ea3f1e730f03f1a9d27b512f2 100644 (file)
@@ -168,3 +168,5 @@ are only available after the hosts were contacted.
                })
        }
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index 8ff729810316e451395d418c41a034fa6e6c33b9..06c529103648bc141e603f06385b3c0745bc99f9 100644 (file)
@@ -16,8 +16,8 @@ var (
 )
 
 func MainVersion() error {
-       fmt.Printf("safcm %s, compiled with %s\n",
-               versionGit,
-               versionGo)
+       fmt.Printf("safcm %s, compiled with %s\n", versionGit, versionGo)
        return nil
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index 6dd01ced4d8b36e5cbf6ef8418b4fd086aaea45f..3388b3295115c23c978a549b18fd0b57f3319c45 100644 (file)
@@ -27,20 +27,16 @@ type Changes struct {
 func (c *Changes) FormatChanges(resp safcm.MsgSyncResp) string {
        var changes []string
        if len(resp.FileChanges) > 0 {
-               changes = append(changes,
-                       c.FormatFileChanges(resp.FileChanges))
+               changes = append(changes, c.FormatFileChanges(resp.FileChanges))
        }
        if len(resp.PackageChanges) > 0 {
-               changes = append(changes,
-                       c.FormatPackageChanges(resp.PackageChanges))
+               changes = append(changes, c.FormatPackageChanges(resp.PackageChanges))
        }
        if len(resp.ServiceChanges) > 0 {
-               changes = append(changes,
-                       c.FormatServiceChanges(resp.ServiceChanges))
+               changes = append(changes, c.FormatServiceChanges(resp.ServiceChanges))
        }
        if len(resp.CommandChanges) > 0 {
-               changes = append(changes,
-                       c.FormatCommandChanges(resp.CommandChanges))
+               changes = append(changes, c.FormatCommandChanges(resp.CommandChanges))
        }
        if len(changes) == 0 {
                // Notify user that the host was synced successfully
@@ -48,10 +44,10 @@ func (c *Changes) FormatChanges(resp safcm.MsgSyncResp) string {
        }
 
        x := strings.Join(changes, "\n")
-       // If quiet is used and only commands without output were executed
-       // then don't prepend a newline so that the whole change output of a
-       // host fits in a single line. This makes the output much more
-       // readable with multiple hosts.
+       // If quiet is used and only commands without output were executed then
+       // don't prepend a newline so that the whole change output of a host fits
+       // in a single line. This makes the output much more readable with
+       // multiple hosts.
        if strings.Count(x, "\n") == 1 {
                return x
        }
@@ -61,8 +57,7 @@ func (c *Changes) FormatChanges(resp safcm.MsgSyncResp) string {
 func (c *Changes) FormatFileChanges(changes []safcm.FileChange) string {
        var buf strings.Builder
        if c.DryRun {
-               fmt.Fprintf(&buf, "will change %d file(s): (dry-run)\n",
-                       len(changes))
+               fmt.Fprintf(&buf, "will change %d file(s): (dry-run)\n", len(changes))
        } else {
                fmt.Fprintf(&buf, "changed %d file(s):\n", len(changes))
        }
@@ -167,8 +162,7 @@ func (c *Changes) FormatServiceChanges(changes []safcm.ServiceChange) string {
                        info = append(info, "enabled")
                }
                fmt.Fprintf(&buf, "%s: %s\n",
-                       c.FormatTarget(x.Name),
-                       strings.Join(info, ", "))
+                       c.FormatTarget(x.Name), strings.Join(info, ", "))
        }
        return buf.String()
 }
@@ -180,14 +174,12 @@ func (c *Changes) FormatCommandChanges(changes []safcm.CommandChange) string {
        // output. This is useful as many commands will be used to enforce a
        // certain state (e.g. file not-present, `ainsl`, etc.) and are run on
        // each sync. Displaying them provides not much useful information.
-       // Instead, quiet shows them only when they produce output (e.g.
-       // `ainsl`, `rm -v`) and thus modify the host's state.
+       // Instead, quiet shows them only when they produce output (e.g. `ainsl`,
+       // `rm -v`) and thus modify the host's state.
        var noOutput int
        if c.Quiet {
                for _, x := range changes {
-                       if x.Trigger == "" &&
-                               x.Error == "" &&
-                               x.Output == "" {
+                       if x.Trigger == "" && x.Error == "" && x.Output == "" {
                                noOutput++
                        }
                }
@@ -225,8 +217,7 @@ func (c *Changes) FormatCommandChanges(changes []safcm.CommandChange) string {
                if x.Output != "" {
                        // TODO: truncate very large outputs?
                        x := indentBlock(x.Output, indent)
-                       fmt.Fprintf(&buf, ":\n%s",
-                               EscapeControlCharacters(c.IsTTY, x))
+                       fmt.Fprintf(&buf, ":\n%s", EscapeControlCharacters(c.IsTTY, x))
                }
                fmt.Fprintf(&buf, "\n")
        }
@@ -270,3 +261,5 @@ func indentBlock(x string, sep string) string {
 
        return sep + strings.Join(lines, "\n"+sep)
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index e0f7e56cfc372d3ca9c2b313cbec410b233ba8fa..a03831864198db09083b885e402fbec66fa3a977 100644 (file)
@@ -21,8 +21,8 @@ func TestFormatChanges(t *testing.T) {
                exp    string
        }{
 
-               // Just a few basic tests and border cases; see the other
-               // tests for more detailed tests of each format function
+               // Just a few basic tests and border cases; see the other tests for
+               // more detailed tests of each format function
 
                {
                        "no changes",
@@ -1220,3 +1220,5 @@ func TestFormatCommandChanges(t *testing.T) {
                })
        }
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index 8546169967047978fec76df72812e882e5b471ff..c2b7cfd779a6cb76945e8358226aada132f97627 100644 (file)
@@ -69,3 +69,5 @@ func (l *Loop) HostSyncMsg(host Host, conn *rpc.Conn, req safcm.MsgSyncReq) (
        }
        return resp, nil
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index 4224996bb4a5994270cf178f08424038555058fd..41c10b6885e02a726d55362b47cc83180ba51c99 100644 (file)
@@ -98,10 +98,12 @@ func LogEvent(x Event, level safcm.LogLevel, isTTY bool,
        if color != 0 {
                host = ColorString(isTTY, color, host)
        }
-       // Make sure to escape control characters to prevent terminal
-       // injection attacks
+       // Make sure to escape control characters to prevent terminal injection
+       // attacks
        if !x.Escaped {
                data = EscapeControlCharacters(isTTY, data)
        }
        log.Printf("%-9s [%s] %s", prefix, host, data)
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index 12fa5be801075b54f1f2205a495f3f9e85edd7e9..d67a89978fe5c8db38321e965f7e7d87a2eff333 100644 (file)
@@ -156,8 +156,7 @@ func TestLogEvent(t *testing.T) {
                        },
                        safcm.LogDebug3,
                        false,
-                       fmt.Sprintf("[INVALID=%d] [fake-host] debug3 log\n",
-                               safcm.LogDebug3),
+                       fmt.Sprintf("[INVALID=%d] [fake-host] debug3 log\n", safcm.LogDebug3),
                        false,
                },
                {
@@ -170,8 +169,7 @@ func TestLogEvent(t *testing.T) {
                        },
                        safcm.LogDebug3,
                        true,
-                       fmt.Sprintf("[INVALID=%d] [\x1b[31mfake-host\x1b[0m] debug3 log\n",
-                               safcm.LogDebug3),
+                       fmt.Sprintf("[INVALID=%d] [\x1b[31mfake-host\x1b[0m] debug3 log\n", safcm.LogDebug3),
                        false,
                },
                {
@@ -369,10 +367,10 @@ func TestLogEvent(t *testing.T) {
                        var failed bool
                        LogEvent(tc.event, tc.level, tc.isTTY, &failed)
 
-                       testutil.AssertEqual(t, "log",
-                               buf.String(), tc.exp)
-                       testutil.AssertEqual(t, "failed",
-                               failed, tc.expFailed)
+                       testutil.AssertEqual(t, "log", buf.String(), tc.exp)
+                       testutil.AssertEqual(t, "failed", failed, tc.expFailed)
                })
        }
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index 4e70ed3c3b5ec781cbd5a4a0b0aa8ea6baa65b4f..ff6d829db4cd1dd886a9f61a392d7d588e42ac94 100644 (file)
@@ -58,8 +58,8 @@ func (l *Loop) Run(hosts []Host) bool {
        sigint := make(chan os.Signal, 1)   // buffered for Notify()
        signal.Notify(sigint, os.Interrupt) // = SIGINT = Ctrl-C
        go func() {
-               // Running `ssh` processes get killed by SIGINT which is sent
-               // to all processes
+               // Running `ssh` processes get killed by SIGINT which is sent to all
+               // processes
 
                <-sigint
                log.Print("Received SIGINT, aborting ...")
@@ -67,9 +67,9 @@ func (l *Loop) Run(hosts []Host) bool {
                // Print all queued events
                events <- Event{} // poison pill
                <-done
-               // "races" with <-done in the main function and will hang here
-               // if the other is faster. This is fine because then all hosts
-               // were synced successfully.
+               // "races" with <-done in the main function and will hang here if the
+               // other is faster. This is fine because then all hosts were synced
+               // successfully.
 
                hostsLeftMutex.Lock()
                var hosts []string
@@ -156,3 +156,5 @@ func (l *Loop) syncHost(wg *sync.WaitGroup, host Host) error {
 
        return nil
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index 559445d26846a40c216b701d6f381884c82118ce..19e16bd289ec54a11d82599286bbbaeff3c5f44e 100644 (file)
@@ -63,3 +63,5 @@ func EscapeControlCharacters(isTTY bool, x string) string {
                return ColorString(isTTY, ColorMagenta, x)
        })
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index f96786cc7faca3422dc84421173458a40aaad87f..e6c9549b8cfc610b14953b14bdf9d2fa30a919ac 100644 (file)
@@ -76,3 +76,5 @@ func TestEscapeControlCharacters(t *testing.T) {
                })
        }
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
diff --git a/gob.go b/gob.go
index e5b8e9c0f0e5d7f91826b662ffe3450ff2c3249c..dea8bf80ae3e0fa2603df13608d772be2d377fa5 100644 (file)
--- a/gob.go
+++ b/gob.go
@@ -23,8 +23,8 @@ func NewGobConn(r io.Reader, w io.Writer) *GobConn {
 }
 
 func (c *GobConn) Send(x Msg) error {
-       // & lets Encode send the interface itself and not a concrete type
-       // which is necessary to Decode as an interface
+       // & lets Encode send the interface itself and not a concrete type which
+       // is necessary to Decode as an interface
        return c.enc.Encode(&x)
 }
 
@@ -36,3 +36,5 @@ func (c *GobConn) Recv() (Msg, error) {
        }
        return x, nil
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
diff --git a/log.go b/log.go
index 51e8a311fbe2e54db5caa6bd84f49ea69ef428db..9aeb643fe6bbad358f49d70c57baf1c8a3b0e4a7 100644 (file)
--- a/log.go
+++ b/log.go
@@ -50,3 +50,5 @@ func ParseLogLevel(s string) (LogLevel, error) {
        }
        return x, nil
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index 01c660e972bfb45870939ce8740c8ecfa71df5df..2d5c0b867aa08a6127ec74eee1787467c4f1162a 100644 (file)
@@ -26,8 +26,7 @@ import (
 
 func Main(args []string) error {
        flag.Usage = func() {
-               fmt.Fprintf(os.Stderr,
-                       "usage: %s ainsl [<options>] <path> <line>\n",
+               fmt.Fprintf(os.Stderr, "usage: %s ainsl [<options>] <path> <line>\n",
                        args[0])
                flag.PrintDefaults()
        }
@@ -59,8 +58,7 @@ func handle(path string, line string, create bool) ([]string, error) {
                return nil, fmt.Errorf("empty line")
        }
        if strings.Contains(line, "\n") {
-               return nil, fmt.Errorf("line must not contain newlines: %q",
-                       line)
+               return nil, fmt.Errorf("line must not contain newlines: %q", line)
        }
 
        parentFd, baseName, err := sync.OpenParentDirectoryNoSymlinks(path)
@@ -79,23 +77,21 @@ func handle(path string, line string, create bool) ([]string, error) {
                        return nil, fmt.Errorf("%q: %v", path, err)
                }
                if !create {
-                       return nil, fmt.Errorf(
-                               "%q: file does not exist, use -create",
+                       return nil, fmt.Errorf("%q: file does not exist, use -create",
                                path)
                }
 
                uid, gid = os.Getuid(), os.Getgid()
-               // Read current umask. Don't do this in programs where
-               // multiple goroutines create files because this is inherently
-               // racy! No goroutines here, so it's fine.
+               // Read current umask. Don't do this in programs where multiple
+               // goroutines create files because this is inherently racy! No
+               // goroutines here, so it's fine.
                umask := syscall.Umask(0)
                syscall.Umask(umask)
                // Apply umask to created file
                mode = 0666 & ^fs.FileMode(umask)
 
                changes = append(changes,
-                       fmt.Sprintf("%q: created file (%d/%d %s)",
-                               path, uid, gid, mode))
+                       fmt.Sprintf("%q: created file (%d/%d %s)", path, uid, gid, mode))
 
        } else {
                // Preserve user/group and mode of existing file
@@ -117,16 +113,14 @@ func handle(path string, line string, create bool) ([]string, error) {
                        break
                }
        }
-       // Make sure the file has a trailing newline. This enforces symmetry
-       // with our changes. Whenever we add a line we also append a trailing
-       // newline. When we conclude that no changes are necessary the file
-       // should be in the same state as we would leave it if there were
-       // changes.
+       // Make sure the file has a trailing newline. This enforces symmetry with
+       // our changes. Whenever we add a line we also append a trailing newline.
+       // When we conclude that no changes are necessary the file should be in
+       // the same state as we would leave it if there were changes.
        if len(data) != 0 && data[len(data)-1] != '\n' {
                data = append(data, '\n')
                changes = append(changes,
-                       fmt.Sprintf("%q: added missing trailing newline",
-                               path))
+                       fmt.Sprintf("%q: added missing trailing newline", path))
        }
 
        // Line present, nothing to do
@@ -183,3 +177,5 @@ func readFileAtNoFollow(dirfd int, base string) ([]byte, fs.FileInfo, error) {
 
        return x, stat, nil
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index d84659447f6e0ad5983ab1be7cc1e858b6a10865..0454ae45df281f632e93e9ee1fac3958c65e3f90 100644 (file)
@@ -284,8 +284,7 @@ func TestHandle(t *testing.T) {
                        }
 
                        changes, err := handle(tc.path, tc.line, tc.create)
-                       testutil.AssertEqual(t, "changes",
-                               changes, tc.expChanges)
+                       testutil.AssertEqual(t, "changes", changes, tc.expChanges)
                        testutil.AssertErrorEqual(t, "err", err, tc.expErr)
 
                        files, err := ft.WalkDir(path)
@@ -296,3 +295,5 @@ func TestHandle(t *testing.T) {
                })
        }
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index 5ae48be083f344ce082a4167d91ac651fdfc04e9..6f37b66d24e626e3ba57bdd276736d14eaaea800 100644 (file)
@@ -22,8 +22,8 @@ type Info struct {
        logger *log.Logger
 }
 
-func Handle(req safcm.MsgInfoReq,
-       runner run.Runner, fun log.LogFunc) safcm.MsgInfoResp {
+func Handle(req safcm.MsgInfoReq, runner run.Runner,
+       fun log.LogFunc) safcm.MsgInfoResp {
 
        i := Info{
                req:    req,
@@ -43,8 +43,7 @@ func (i *Info) handle() error {
        i.resp.Goarch = runtime.GOARCH
 
        for _, x := range i.req.DetectGroups {
-               stdout, _, err := i.cmd.Run("detect group",
-                       "/bin/sh", "-c", x)
+               stdout, _, err := i.cmd.Run("detect group", "/bin/sh", "-c", x)
                if err != nil {
                        return err
                }
@@ -53,3 +52,5 @@ func (i *Info) handle() error {
 
        return nil
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index 6a150a47f788377d18487dc48dd4c771d1ba09f5..4a3e6640e6fbd4b21d6a3944663122612ab10b4d 100644 (file)
@@ -38,3 +38,5 @@ func (l *Logger) log(level safcm.LogLevel,
        format string, a ...interface{}) {
        l.fun(level, fmt.Sprintf(format, a...))
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index 4f29a1ff115290dc44ababa5dd54f6dd1d12408c..da17e7b93c5fdc0a8158b1f6973ea4343417f98b 100644 (file)
@@ -63,9 +63,9 @@ func mainLoop() error {
        var logLevel safcm.LogLevel
        logFunc := func(level safcm.LogLevel, msg string) {
                if logLevel >= level {
-                       // Handling errors here is complex and quite verbose.
-                       // If it happens the connection is gone anyway so skip
-                       // the error handling.
+                       // Handling errors here is complex and quite verbose. If it
+                       // happens the connection is gone anyway so skip the error
+                       // handling.
                        conn.Send(safcm.MsgLog{ //nolint:errcheck
                                Level: level,
                                Text:  msg,
@@ -103,3 +103,5 @@ func mainLoop() error {
        }
        return nil
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index fbd9b8833ff0a0bcc8640d5a0532bbe82239cf63..b622e8e36f998feb0dc2aea8d3305de8fb5c1a8b 100644 (file)
@@ -41,16 +41,13 @@ func (c *Cmd) Run(module string, args ...string) ([]byte, []byte, error) {
        c.logger.Debugf("%s: running %s", module, quoted)
        err := c.Runner.Run(cmd)
        if stdout.Len() > 0 {
-               c.logger.Debug2f("%s: command stdout:\n%s",
-                       module, stdout.Bytes())
+               c.logger.Debug2f("%s: command stdout:\n%s", module, stdout.Bytes())
        }
        if stderr.Len() > 0 {
-               c.logger.Debug2f("%s: command stderr:\n%s",
-                       module, stderr.Bytes())
+               c.logger.Debug2f("%s: command stderr:\n%s", module, stderr.Bytes())
        }
        if err != nil {
-               return nil, nil, fmt.Errorf(
-                       "%s failed: %v; stdout: %q, stderr: %q",
+               return nil, nil, fmt.Errorf("%s failed: %v; stdout: %q, stderr: %q",
                        quoted, err, stdout.String(), stderr.String())
        }
        return stdout.Bytes(), stderr.Bytes(), nil
@@ -66,8 +63,7 @@ func (c *Cmd) CombinedOutputCmd(module string, cmd *exec.Cmd) ([]byte, error) {
                c.logger.Debug2f("%s: command output:\n%s", module, out)
        }
        if err != nil {
-               return nil, fmt.Errorf("%s failed: %v; output: %q",
-                       quoted, err, out)
+               return nil, fmt.Errorf("%s failed: %v; output: %q", quoted, err, out)
        }
        return out, nil
 }
@@ -80,3 +76,5 @@ func QuoteForDebug(cmd *exec.Cmd) string {
        }
        return strings.Join(quoted, " ")
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index 6fd35e5cfa316198ca29df036201988e7fd399c8..ac5de6168ff0ebafb4f63d70c5ce91944f90982b 100644 (file)
@@ -26,3 +26,5 @@ func (r ExecRunner) Run(cmd *exec.Cmd) error {
 func (r ExecRunner) CombinedOutput(cmd *exec.Cmd) ([]byte, error) {
        return cmd.CombinedOutput()
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index 7837c12057540270985697e2b89faf39b23e224b..0b0b7f59a3729b10bb7e32f0392a6c1d926a2bdc 100644 (file)
@@ -25,8 +25,7 @@ func (s *Sync) syncCommands() error {
                        }
                }
        }
-       // Regular commands afterwards so they can react on triggers if
-       // necessary
+       // Regular commands afterwards so they can react on triggers if necessary
        for _, x := range s.req.Commands {
                err := s.syncCommand(x.Cmd, x.OrigGroup, "")
                if err != nil {
@@ -56,11 +55,10 @@ func (s *Sync) syncCommand(command, group, trigger string) error {
 
        cmd := exec.Command("/bin/sh", "-c", command)
        cmd.Env = safcmEnviroment(s.req.Groups)
-       // Cannot use cmd.CombinedOutputCmd() because we need another log
-       // level (here the command is the actual change and not a side effect)
-       // and different error handling.
-       s.log.Verbosef("commands: running %s (%s)",
-               run.QuoteForDebug(cmd), info)
+       // Cannot use cmd.CombinedOutputCmd() because we need another log level
+       // (here the command is the actual change and not a side effect) and
+       // different error handling.
+       s.log.Verbosef("commands: running %s (%s)", run.QuoteForDebug(cmd), info)
        out, err := s.cmd.Runner.CombinedOutput(cmd)
        if len(out) > 0 {
                s.log.Debug2f("commands: command output:\n%s", out)
@@ -90,3 +88,5 @@ func safcmEnviroment(groups []string) []string {
        }
        return env
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index eba5199f08224d2e2b0e9d86d6708440da81a8db..44583a0c2a8250253e1f49ea1a6cb9b88bfec7d6 100644 (file)
@@ -41,8 +41,8 @@ func TestSyncCommands(t *testing.T) {
                expErr   error
        }{
 
-               // NOTE: Also update MsgSyncResp in safcm test cases when
-               // changing the MsgSyncResp struct!
+               // NOTE: Also update MsgSyncResp in safcm test cases when changing the
+               // MsgSyncResp struct!
 
                {
                        "successful command",
@@ -529,3 +529,5 @@ func TestSyncCommands(t *testing.T) {
                })
        }
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index 620890f20631fd76aa0d210b75a7f0da8456a261..33631964cebbf6af43354bd879d79fd26c4e047f 100644 (file)
@@ -41,8 +41,8 @@ import (
 const openReadonlyFlags = unix.O_RDONLY | unix.O_NOFOLLOW | unix.O_NONBLOCK
 
 func (s *Sync) syncFiles() error {
-       // Sort for deterministic order and so parent directories are present
-       // when files in them are created
+       // Sort for deterministic order and so parent directories are present when
+       // files in them are created
        var files []*safcm.File
        for _, x := range s.req.Files {
                files = append(files, x)
@@ -66,28 +66,28 @@ func (s *Sync) syncFiles() error {
 }
 
 func (s *Sync) syncFile(file *safcm.File, changed *bool) error {
-       // The general strategy is "update by rename": If any property of a
-       // file changes the new version will be written to a temporary file
-       // and then renamed "over" the original file. This is simple and
-       // prevents race conditions where the file is partially readable while
-       // changes to permissions or owner/group are applied. However, this
-       // strategy does not work for directories which must be removed first
-       // (was directory), must remove the existing file (will be directory)
-       // or must be directly modified (changed permissions or owner). In the
-       // first two cases the old path is removed. In the last the directory
-       // is modified (carefully) in place.
+       // The general strategy is "update by rename": If any property of a file
+       // changes the new version will be written to a temporary file and then
+       // renamed "over" the original file. This is simple and prevents race
+       // conditions where the file is partially readable while changes to
+       // permissions or owner/group are applied. However, this strategy does not
+       // work for directories which must be removed first (was directory), must
+       // remove the existing file (will be directory) or must be directly
+       // modified (changed permissions or owner). In the first two cases the old
+       // path is removed. In the last the directory is modified (carefully) in
+       // place.
        //
        // The implementation is careful not to follow any symlinks to prevent
        // possible race conditions which can be exploited and are especially
-       // dangerous when running with elevated privileges (which will most
-       // likely be the case). This includes not using absolute paths in
-       // syscalls to prevent symlink attacks when a directory is writable by
-       // other users (e.g. when syncing a file to /home/user/dir/file the
-       // user could create dir as symlink to another directory and file
-       // would be written there). To prevent this *at syscalls are used and
-       // all symlinks in the path are rejected. This still permits the user
-       // to move dir during the sync but only to places which are writable
-       // by the user which cannot be prevented.
+       // dangerous when running with elevated privileges (which will most likely
+       // be the case). This includes not using absolute paths in syscalls to
+       // prevent symlink attacks when a directory is writable by other users
+       // (e.g. when syncing a file to /home/user/dir/file the user could create
+       // dir as symlink to another directory and file would be written there).
+       // To prevent this *at syscalls are used and all symlinks in the path are
+       // rejected. This still permits the user to move dir during the sync but
+       // only to places which are writable by the user which cannot be
+       // prevented.
 
        err := s.fileResolveIds(file)
        if err != nil {
@@ -161,10 +161,9 @@ reopen:
        var oldData []byte
        var changeType, changePerm, changeUserOrGroup, changeData bool
        if !change.Created {
-               // Manually convert to FileMode; from src/os/stat_linux.go in
-               // Go's sources (stat_*.go for other UNIX systems are
-               // identical, except for stat_darwin.go which has an extra
-               // S_IFWHT)
+               // Manually convert to FileMode; from src/os/stat_linux.go in Go's
+               // sources (stat_*.go for other UNIX systems are identical, except for
+               // stat_darwin.go which has an extra S_IFWHT)
                mode := fs.FileMode(oldStat.Mode & 0777)
                switch oldStat.Mode & unix.S_IFMT {
                case unix.S_IFBLK:
@@ -181,8 +180,7 @@ reopen:
                        // nothing to do
                case unix.S_IFSOCK:
                        mode |= fs.ModeSocket
-               // Guard against unknown file types (e.g. on darwin); not in
-               // stat_*.go
+               // Guard against unknown file types (e.g. on darwin); not in stat_*.go
                default:
                        return fmt.Errorf("unexpected file mode %v",
                                oldStat.Mode&unix.S_IFMT)
@@ -200,11 +198,10 @@ reopen:
                // Compare permissions
                change.Old.Mode = mode
                if change.Old.Mode.Type() == fs.ModeSymlink {
-                       // Some BSD systems permit changing permissions of
-                       // symlinks but ignore them on traversal. To keep it
-                       // simple we don't support that and always use 0777
-                       // for symlink permissions (the value on GNU/Linux)
-                       // when comparing. The actual permissions on the file
+                       // Some BSD systems permit changing permissions of symlinks but
+                       // ignore them on traversal. To keep it simple we don't support
+                       // that and always use 0777 for symlink permissions (the value on
+                       // GNU/Linux) when comparing. The actual permissions on the file
                        // system might be different on BSD systems.
                        //
                        // TODO: Add proper support for symlinks on BSD
@@ -217,8 +214,8 @@ reopen:
                                        change.Old.Mode.Type(),
                                        file.Mode.Type())
                        } else {
-                               // Be careful with .Perm() which does not
-                               // contain the setuid/setgid/sticky bits!
+                               // Be careful with .Perm() which does not contain the
+                               // setuid/setgid/sticky bits!
                                changePerm = true
                                debugf("permission differs %s -> %s",
                                        change.Old.Mode, file.Mode)
@@ -235,9 +232,8 @@ reopen:
                                file.Uid, file.Gid)
                }
                u, g, err := resolveIdsToNames(change.Old.Uid, change.Old.Gid)
-               // Errors are not relevant as this is only used to report the
-               // change. If the user/group no longer exits only the ids will
-               // be reported.
+               // Errors are not relevant as this is only used to report the change.
+               // If the user/group no longer exits only the ids will be reported.
                if err == nil {
                        change.Old.User = u
                        change.Old.Group = g
@@ -248,16 +244,14 @@ reopen:
                case 0: // regular file
                        x, err := io.ReadAll(oldFh)
                        if err != nil {
-                               return fmt.Errorf("reading old content: %v",
-                                       err)
+                               return fmt.Errorf("reading old content: %v", err)
                        }
                        oldData = x
                case fs.ModeSymlink:
                        buf := make([]byte, unix.PathMax)
                        n, err := unix.Readlinkat(parentFd, baseName, buf)
                        if err != nil {
-                               return fmt.Errorf("reading old content: %v",
-                                       err)
+                               return fmt.Errorf("reading old content: %v", err)
                        }
                        oldData = buf[:n]
                }
@@ -278,10 +272,10 @@ reopen:
        }
        *changed = true
 
-       // Don't show a diff with the full content for newly created files or
-       // on type changes. This is just noise for the user as the new file
-       // content is obvious. But we always want to see a diff when files are
-       // replaced because this destroys data.
+       // Don't show a diff with the full content for newly created files or on
+       // type changes. This is just noise for the user as the new file content
+       // is obvious. But we always want to see a diff when files are replaced
+       // because this destroys data.
        if !change.Created &&
                (change.Old.Mode.Type() == 0 ||
                        change.Old.Mode.Type() == fs.ModeSymlink) {
@@ -291,8 +285,8 @@ reopen:
                }
        }
 
-       // Add change here so it is stored even when applying it fails. This
-       // way the user knows exactly what was attempted.
+       // Add change here so it is stored even when applying it fails. This way
+       // the user knows exactly what was attempted.
        s.resp.FileChanges = append(s.resp.FileChanges, change)
 
        if change.Created {
@@ -310,16 +304,15 @@ reopen:
        if changeType && (change.Old.Mode.IsDir() || file.Mode.IsDir()) {
                debugf("removing (due to type change)")
                // In the past os.RemoveAll() was used here. However, this is
-               // difficult to implement manually with *at syscalls. To keep
-               // it simple only permit removing files and empty directories
-               // here. This also has the bonus of preventing data loss when
-               // (accidentally) replacing a directory tree with a file.
+               // difficult to implement manually with *at syscalls. To keep it
+               // simple only permit removing files and empty directories here. This
+               // also has the bonus of preventing data loss when (accidentally)
+               // replacing a directory tree with a file.
                const msg = "will not replace non-empty directory, " +
                        "please remove manually"
                err := unix.Unlinkat(parentFd, baseName, 0 /* flags */)
                if err != nil && !os.IsNotExist(err) {
-                       err2 := unix.Unlinkat(parentFd, baseName,
-                               unix.AT_REMOVEDIR)
+                       err2 := unix.Unlinkat(parentFd, baseName, unix.AT_REMOVEDIR)
                        if err2 != nil && !os.IsNotExist(err2) {
                                // See src/os/file_unix.go in Go's sources
                                if err2 == unix.ENOTDIR {
@@ -340,10 +333,10 @@ reopen:
                if err != nil {
                        return err
                }
-               // We must be careful not to chmod arbitrary files. If the
-               // target directory is writable then it might have changed to
-               // a symlink at this point. There's no lchmod and fchmodat is
-               // incomplete so open the directory.
+               // We must be careful not to chmod arbitrary files. If the target
+               // directory is writable then it might have changed to a symlink at
+               // this point. There's no lchmod and fchmodat is incomplete so open
+               // the directory.
                debugf("chmodding %s", file.Mode)
                dh, err := OpenAtNoFollow(parentFd, baseName)
                if err != nil {
@@ -355,8 +348,8 @@ reopen:
                if err != nil {
                        return err
                }
-               // Less restrictive access is not relevant here because there
-               // are no files present yet.
+               // Less restrictive access is not relevant here because there are no
+               // files present yet.
                debugf("chowning %d/%d", file.Uid, file.Gid)
                err = dh.Chown(file.Uid, file.Gid)
                if err != nil {
@@ -366,20 +359,19 @@ reopen:
        }
        // Directory: changed permission or user/group
        if file.Mode.IsDir() {
-               // We don't know if the new permission or if the new
-               // user/group is more restrictive (e.g. root:root 0750 ->
-               // user:group 0700; applying group first gives group
-               // unexpected access). To prevent a short window where the
-               // access might be too lax we temporarily deny all access.
+               // We don't know if the new permission or if the new user/group is
+               // more restrictive (e.g. root:root 0750 -> user:group 0700; applying
+               // group first gives group unexpected access). To prevent a short
+               // window where the access might be too lax we temporarily deny all
+               // access.
                if changePerm && changeUserOrGroup {
-                       // Only drop group and other permission because user
-                       // has access anyway (either before or after the
-                       // change). This also prevents temporary errors during
-                       // the error when the user tries to access this
-                       // directory (access for the group will fail though).
+                       // Only drop group and other permission because user has access
+                       // anyway (either before or after the change). This also prevents
+                       // temporary errors during the error when the user tries to access
+                       // this directory (access for the group will fail though).
                        mode := change.Old.Mode & fs.ModePerm & 0700
-                       // Retain setgid/sticky so that the behavior does not
-                       // change when creating and removing files.
+                       // Retain setgid/sticky so that the behavior does not change when
+                       // creating and removing files.
                        mode |= change.Old.Mode & fs.ModeSetgid
                        mode |= change.Old.Mode & fs.ModeSticky
                        debugf("chmodding %#o (temporary)", mode)
@@ -406,14 +398,13 @@ reopen:
        }
 
        dir := slashpath.Dir(file.Path) // only used in debug messages
-       // Create hidden file which should be ignored by most other tools and
-       // thus not affect anything during creation
+       // Create hidden file which should be ignored by most other tools and thus
+       // not affect anything during creation
        tmpBase := "." + baseName
 
        switch file.Mode.Type() {
        case 0: // regular file
-               debugf("creating temporary file %q",
-                       slashpath.Join(dir, tmpBase+"*"))
+               debugf("creating temporary file %q", slashpath.Join(dir, tmpBase+"*"))
                x, err := WriteTempAt(parentFd, tmpBase, file.Data,
                        file.Uid, file.Gid, file.Mode)
                if err != nil {
@@ -425,8 +416,7 @@ reopen:
                i := 0
        retry:
                x := tmpBase + strconv.Itoa(rand.Int())
-               debugf("creating temporary symlink %q",
-                       slashpath.Join(dir, x))
+               debugf("creating temporary symlink %q", slashpath.Join(dir, x))
                err := unix.Symlinkat(string(file.Data), parentFd, x)
                if err != nil {
                        if os.IsExist(err) && i < 10000 {
@@ -458,11 +448,11 @@ reopen:
        // To guarantee durability fsync must be called on a parent directory
        // after adding, renaming or removing files therein.
        //
-       // Calling sync on the files itself is not enough according to POSIX;
-       // man 2 fsync: "Calling fsync() does not necessarily ensure that the
-       // entry in the directory containing the file has also reached disk.
-       // For that an explicit fsync() on a file descriptor for the directory
-       // is also needed."
+       // Calling sync on the files itself is not enough according to POSIX; man
+       // 2 fsync: "Calling fsync() does not necessarily ensure that the entry in
+       // the directory containing the file has also reached disk. For that an
+       // explicit fsync() on a file descriptor for the directory is also
+       // needed."
        err = unix.Fsync(parentFd)
        if err != nil {
                return err
@@ -529,8 +519,8 @@ func OpenParentDirectoryNoSymlinks(path string) (int, string, error) {
 
        var dir string
        if path == "/" {
-               // Root: use root itself as base name because root is the
-               // parent of itself
+               // Root: use root itself as base name because root is the parent of
+               // itself
                dir = "/"
                parts = []string{"/"}
        } else if parts[0] == "" {
@@ -538,12 +528,12 @@ func OpenParentDirectoryNoSymlinks(path string) (int, string, error) {
                dir = "/"
                parts = parts[1:]
        } else if path == "." {
-               // Current directory: open parent directory and use current
-               // directory name as base name
+               // Current directory: open parent directory and use current directory
+               // name as base name
                wd, err := os.Getwd()
                if err != nil {
-                       return -1, "", fmt.Errorf(
-                               "failed to get working directory: %w", err)
+                       return -1, "", fmt.Errorf("failed to get working directory: %w",
+                               err)
                }
                dir = ".."
                parts = []string{filepath.Base(wd)}
@@ -555,24 +545,22 @@ func OpenParentDirectoryNoSymlinks(path string) (int, string, error) {
                }
        }
 
-       dirFd, err := unix.Openat(unix.AT_FDCWD, dir,
-               openReadonlyFlags, 0 /* mode */)
+       dirFd, err := unix.Openat(unix.AT_FDCWD, dir, openReadonlyFlags,
+               0 /* mode */)
        if err != nil {
                return -1, "", err
        }
-       // Walk path one directory at a time to ensure there are no symlinks
-       // in the path. This prevents users with write access to change the
-       // path to point to arbitrary locations. O_NOFOLLOW when opening the
-       // path is not enough as only the last path component is checked.
+       // Walk path one directory at a time to ensure there are no symlinks in
+       // the path. This prevents users with write access to change the path to
+       // point to arbitrary locations. O_NOFOLLOW when opening the path is not
+       // enough as only the last path component is checked.
        for i, name := range parts[:len(parts)-1] {
                fd, err := unix.Openat(dirFd, name, openReadonlyFlags, 0)
                if err != nil {
                        unix.Close(dirFd) //nolint:errcheck
                        if err == unix.ELOOP || err == unix.EMLINK {
-                               x := filepath.Join(append([]string{dir},
-                                       parts[:i+1]...)...)
-                               return -1, "", fmt.Errorf(
-                                       "symlink not permitted in path: %q",
+                               x := filepath.Join(append([]string{dir}, parts[:i+1]...)...)
+                               return -1, "", fmt.Errorf("symlink not permitted in path: %q",
                                        x)
                        }
                        return -1, "", err
@@ -709,3 +697,5 @@ retry:
 
        return os.NewFile(uintptr(fd), ""), tmpBase, nil
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index f6e7b76ac73d7d9aa78303443cec3d59b27b87ff..bfe896a30dc1bae5627f9d1573c322e1220027c1 100644 (file)
@@ -20,3 +20,5 @@ func (s *Sync) syncFiles() error {
 func OpenFileNoSymlinks(path string) (*os.File, error) {
        return nil, fmt.Errorf("not implemented on Windows")
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index b1c91ef26ee460d466e0f1e044712610282e3bb9..9376413afbc58efb818d56a025039057a3a556c2 100644 (file)
@@ -41,11 +41,11 @@ func TestSyncFiles(t *testing.T) {
                expErr      error
        }{
 
-               // NOTE: Also update MsgSyncResp in safcm test cases when
-               // changing the MsgSyncResp struct!
+               // NOTE: Also update MsgSyncResp in safcm test cases when changing the
+               // MsgSyncResp struct!
 
-               // See TestSyncFile() for most file related tests. This
-               // function only tests the overall results and triggers.
+               // See TestSyncFile() for most file related tests. This function only
+               // tests the overall results and triggers.
 
                {
                        "basic: create",
@@ -236,13 +236,12 @@ func TestSyncFiles(t *testing.T) {
                },
 
                {
-                       // We use relative paths for most tests because we
-                       // don't want to modify the running system. Use this
-                       // test (and the one below for triggers) as a basic
-                       // check that absolute paths work.
+                       // We use relative paths for most tests because we don't want to
+                       // modify the running system. Use this test (and the one below for
+                       // triggers) as a basic check that absolute paths work.
                        //
-                       // Use numeric IDs as not all systems use root/root;
-                       // for example BSDs use root/wheel.
+                       // Use numeric IDs as not all systems use root/root; for example
+                       // BSDs use root/wheel.
                        "absolute paths: no change",
                        skipUnlessCiRun,
                        safcm.MsgSyncReq{
@@ -837,8 +836,7 @@ func TestSyncFiles(t *testing.T) {
                        testutil.AssertEqual(t, "files", files, tc.expFiles)
 
                        testutil.AssertEqual(t, "resp", s.resp, tc.expResp)
-                       testutil.AssertEqual(t, "triggers",
-                               s.triggers, tc.expTriggers)
+                       testutil.AssertEqual(t, "triggers", s.triggers, tc.expTriggers)
                })
        }
 
@@ -864,8 +862,8 @@ func TestSyncFile(t *testing.T) {
                expErr     error
        }{
 
-               // NOTE: Also update MsgSyncResp in safcm test cases when
-               // changing the MsgSyncResp struct!
+               // NOTE: Also update MsgSyncResp in safcm test cases when changing the
+               // MsgSyncResp struct!
 
                // TODO: Add tests for chown and run them only as root
 
@@ -2582,3 +2580,5 @@ file
                })
        }
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index 07e803aae768e4cc36d285c2eab8321bbae4c7b8..5d22ded5fa677faac09253cbf506e5833e9aa7aa 100644 (file)
@@ -134,3 +134,5 @@ func CreateFifo(path string, mode fs.FileMode) {
                panic(err)
        }
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index 9afff835fde3b211cb44397f14e4a8c2a5e03790..c31cd443a036b40e620b57344f679f270aebec71 100644 (file)
@@ -22,3 +22,5 @@ func (s *Sync) syncPackages() error {
        // TODO: support more distributions
        return fmt.Errorf("not yet supported on this distribution")
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index 56fcc2dcfd6cfd707e1b6c0715cbc904278737ae..bd9e22f000b65e824574b50dd56203a10c232fd2 100644 (file)
@@ -84,15 +84,16 @@ func (s *Sync) debianInstalledPackages() (map[string]bool, error) {
        for _, line := range lines {
                xs := strings.Split(line, "\t")
                if len(xs) != 2 {
-                       return nil, fmt.Errorf("invalid dpkg-query line %q",
-                               line)
+                       return nil, fmt.Errorf("invalid dpkg-query line %q", line)
                }
-               // We only care if the package is currently successfully
-               // installed (last two fields). If a package is on hold (first
-               // field) this is fine as well.
+               // We only care if the package is currently successfully installed
+               // (last two fields). If a package is on hold (first field) this is
+               // fine as well.
                if strings.HasSuffix(xs[0], " ok installed") {
                        res[xs[1]] = true
                }
        }
        return res, nil
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index 30b3b54004730e18beba2e3b8a449ccd5271f852..356d33528ac41ae9e60f7ceaaca125cc6b8b95bd 100644 (file)
@@ -27,8 +27,8 @@ func TestSyncPackagesDebian(t *testing.T) {
                expErr  error
        }{
 
-               // NOTE: Also update MsgSyncResp in safcm test cases when
-               // changing the MsgSyncResp struct!
+               // NOTE: Also update MsgSyncResp in safcm test cases when changing the
+               // MsgSyncResp struct!
 
                {
                        "packages already installed",
@@ -302,3 +302,5 @@ install ok installed        golang-1.16-src
                })
        }
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index ee3885de3db386c1ce9abbfe21a47617179c15b1..a89c0bd4a5fdd43776305632711645439480b7ce 100644 (file)
@@ -25,3 +25,5 @@ func (s *Sync) syncServices() error {
        // TODO: support more distributions
        return fmt.Errorf("not yet supported on this distribution")
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index fe8e2a45a3d154180230aad2977ce063400c9a86..ca432ebae6efc6f4bfe008f8dcb686ab86849689 100644 (file)
@@ -36,8 +36,7 @@ func (s *Sync) syncServicesSystemd() error {
 
                if change.Started || change.Enabled {
                        change.Name = name
-                       s.resp.ServiceChanges = append(s.resp.ServiceChanges,
-                               change)
+                       s.resp.ServiceChanges = append(s.resp.ServiceChanges, change)
                }
        }
        if len(start) == 0 && len(enable) == 0 {
@@ -48,15 +47,14 @@ func (s *Sync) syncServicesSystemd() error {
                return nil
        }
 
-       // Reload service files which were possibly changed during file sync
-       // or package installation
+       // Reload service files which were possibly changed during file sync or
+       // package installation
        _, _, err = s.cmd.Run("services", "/bin/systemctl", "daemon-reload")
        if err != nil {
                return err
        }
        if len(start) != 0 {
-               s.log.Verbosef("services: starting %s",
-                       strings.Join(start, " "))
+               s.log.Verbosef("services: starting %s", strings.Join(start, " "))
                _, _, err := s.cmd.Run("services", append([]string{
                        "/bin/systemctl", "start", "--",
                }, start...)...)
@@ -65,8 +63,7 @@ func (s *Sync) syncServicesSystemd() error {
                }
        }
        if len(enable) != 0 {
-               s.log.Verbosef("services: enabling %s",
-                       strings.Join(enable, " "))
+               s.log.Verbosef("services: enabling %s", strings.Join(enable, " "))
                _, _, err := s.cmd.Run("services", append([]string{
                        "/bin/systemctl", "enable", "--",
                }, enable...)...)
@@ -102,8 +99,7 @@ func (s *Sync) systemdServiceState(services []string) (
        for _, block := range strings.Split(string(out), "\n\n") {
                lines := strings.Split(strings.TrimSpace(block), "\n")
                if len(lines) != 3 {
-                       return nil, fmt.Errorf("invalid systemctl output: %q",
-                               block)
+                       return nil, fmt.Errorf("invalid systemctl output: %q", block)
                }
 
                var service SystemdService
@@ -115,23 +111,19 @@ func (s *Sync) systemdServiceState(services []string) (
                        )
 
                        if strings.HasPrefix(x, activePrefix) {
-                               service.ActiveState = strings.TrimPrefix(x,
-                                       activePrefix)
+                               service.ActiveState = strings.TrimPrefix(x, activePrefix)
                        } else if strings.HasPrefix(x, unitPrefix) {
-                               service.UnitFileState = strings.TrimPrefix(x,
-                                       unitPrefix)
+                               service.UnitFileState = strings.TrimPrefix(x, unitPrefix)
                        } else if strings.HasPrefix(x, errorPrefix) {
                                x := strings.TrimPrefix(x, errorPrefix)
-                               // Older systemd versions (e.g. 237) add empty
-                               // quotes even if there is no error
+                               // Older systemd versions (e.g. 237) add empty quotes even if
+                               // there is no error
                                if x != "" && x != ` ""` {
-                                       return nil, fmt.Errorf(
-                                               "systemd unit %q not found",
+                                       return nil, fmt.Errorf("systemd unit %q not found",
                                                services[i])
                                }
                        } else {
-                               return nil, fmt.Errorf(
-                                       "invalid systemctl show line %q", x)
+                               return nil, fmt.Errorf("invalid systemctl show line %q", x)
                        }
                }
                res[services[i]] = service
@@ -141,3 +133,5 @@ func (s *Sync) systemdServiceState(services []string) (
 
        return res, nil
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index 935828a3658d843caddc60d9d13088f5e5a8a5c6..e4640603755ef8856abaf0c9b5cfb794bc95c80f 100644 (file)
@@ -26,8 +26,8 @@ func TestSyncServicesSystemd(t *testing.T) {
                expErr  error
        }{
 
-               // NOTE: Also update MsgSyncResp in safcm test cases when
-               // changing the MsgSyncResp struct!
+               // NOTE: Also update MsgSyncResp in safcm test cases when changing the
+               // MsgSyncResp struct!
 
                {
                        "no service change necessary",
@@ -505,3 +505,5 @@ LoadError=
                })
        }
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index ce87a8358752987271a0610286f102c85f0e6a19..e17217b1fea21c0dabeeb5b086bcca0e3c3aa084 100644 (file)
@@ -82,3 +82,5 @@ func (s *Sync) setDefaults() error {
 
        return nil
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index dfe498b6b2c450d13f876e7d715358c9ecd84c80..c601c44fa60fd808301d4bb9ff11af28b6875d16 100644 (file)
@@ -143,3 +143,5 @@ func (s *syncTestResult) Wait() []string {
 
        return s.dbg
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index d786724b183682755f1e12edd8615b700f2f68e0..9a5be18fa25b6403dc20f54a7489873af9852f1a 100644 (file)
@@ -20,14 +20,12 @@ func (s *Sync) queueTriggers(file *safcm.File) {
                }
                // Queue each trigger only once
                if s.triggersActive[path] {
-                       s.log.Debugf(
-                               "files: %q: skipping trigger on %q, already active",
+                       s.log.Debugf("files: %q: skipping trigger on %q, already active",
                                file.Path, path)
                        continue
                }
 
-               s.log.Verbosef("files: %q: queuing trigger on %q",
-                       file.Path, path)
+               s.log.Verbosef("files: %q: queuing trigger on %q", file.Path, path)
                s.triggers = append(s.triggers, path)
                s.triggersActive[path] = true
        }
@@ -58,3 +56,5 @@ func triggerPaths(path string) []string {
        }
        return res
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index 07652caba3880f270f4c0704bac7e929ed27e054..c1e97fb4fccb4e52b0a971a2856f3a7e794a0d2c 100644 (file)
@@ -48,3 +48,5 @@ func TestTriggerPaths(t *testing.T) {
                })
        }
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index 41e5be1c13b494e0b25891a974b00fc467ccc236..80a51cc5492e16dcd0d631255e2d3da773ad658e 100644 (file)
@@ -108,8 +108,8 @@ func (c *Conn) wait() error {
        close(c.events)
        // We cannot reuse this channel.
        c.events = nil
-       // Don't set c.Events to nil because this creates a data race when
-       // another thread is still waiting.
+       // Don't set c.Events to nil because this creates a data race when another
+       // thread is still waiting.
 
        return err
 }
@@ -159,3 +159,5 @@ func (c *Conn) handleStderrAsEvents(cmd *exec.Cmd) error {
 
        return nil
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index 0838c9729b6ce730c90cf8bdadadd892abc05e15..3b6a956a2ca7746105fddbab52ad8781c5855383 100644 (file)
@@ -135,23 +135,23 @@ compat_sha512sum() {
                return fmt.Errorf("internal error: no support for %q", goos)
        }
 
-       // Use a function so the shell cannot execute the input line-wise.
-       // This is important because we're also using stdin to send data to
-       // the script. If the shell executes the input line-wise then our
-       // script is interpreted as input for `read`.
+       // Use a function so the shell cannot execute the input line-wise. This is
+       // important because we're also using stdin to send data to the script. If
+       // the shell executes the input line-wise then our script is interpreted
+       // as input for `read`.
        //
-       // The target directory must no permit other users to delete our files
-       // or symlink attacks and arbitrary code execution is possible. For
-       // /tmp this is guaranteed by the sticky bit. The code verifies the
-       // directory has the proper permissions.
+       // The target directory must no permit other users to delete our files or
+       // symlink attacks and arbitrary code execution is possible. For /tmp this
+       // is guaranteed by the sticky bit. The code verifies the directory has
+       // the proper permissions.
        //
        // We cannot use `test -f && test -O` because this is open to TOCTOU
-       // attacks. `stat` gives use the full file state. If the file is owned
-       // by us and not a symlink then it's safe to use (assuming sticky
-       // directory or directory not writable by others).
+       // attacks. `stat` gives use the full file state. If the file is owned by
+       // us and not a symlink then it's safe to use (assuming sticky directory
+       // or directory not writable by others).
        //
-       // `test -e` is only used to prevent error messages if the file
-       // doesn't exist. It does not guard against any races.
+       // `test -e` is only used to prevent error messages if the file doesn't
+       // exist. It does not guard against any races.
        _, err = fmt.Fprintf(stdin, `
 %s
 f() {
@@ -219,8 +219,7 @@ f
        } else {
                x := strings.Fields(remoteSum)
                if len(x) < 1 {
-                       return fmt.Errorf("got unexpected checksum line %q",
-                               remoteSum)
+                       return fmt.Errorf("got unexpected checksum line %q", remoteSum)
                }
                sha := sha512.Sum512(helper)
                hex := hex.EncodeToString(sha[:])
@@ -245,11 +244,10 @@ f
                }
                // Get path to temporary file for upload.
                //
-               // Write to the temporary file instead of the final path so
-               // that a concurrent run of this function won't use a
-               // partially written file. The rm in the script could still
-               // cause a missing file but at least no file with unknown
-               // content is executed.
+               // Write to the temporary file instead of the final path so that a
+               // concurrent run of this function won't use a partially written file.
+               // The rm in the script could still cause a missing file but at least
+               // no file with unknown content is executed.
                path, err := stdout.ReadString('\n')
                if err != nil {
                        return err
@@ -350,3 +348,5 @@ func connGetUID(stdin io.Writer, stdout *bufio.Reader) (int, error) {
        }
        return uid, nil
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index eb1857c8f194a10230d38a83823859001257f08e..e3de9556cba876588b8bdf21de2bd0eb10e70da7 100644 (file)
@@ -28,7 +28,8 @@ func AssertErrorEqual(t *testing.T, name string, act, exp error) {
        actStr := fmt.Sprintf("%v", act)
        expStr := fmt.Sprintf("%v", exp)
        if actStr != expStr {
-               t.Errorf("err = %s (%#v), want %s (%#v)",
-                       actStr, act, expStr, exp)
+               t.Errorf("err = %s (%#v), want %s (%#v)", actStr, act, expStr, exp)
        }
 }
+
+// vi: set noet ts=4 sw=4 sts=4:
index 7333fa7278b4de2264e1ad21ed98d42056345387..9f5010080827bfe81a8ee226f632e14ad129e5e8 100644 (file)
--- a/types.go
+++ b/types.go
@@ -130,3 +130,5 @@ type CommandChange struct {
        Output  string // stdout and stderr combined
        Error   string
 }
+
+// vi: set noet ts=4 sw=4 sts=4: