MCPcopy Index your code
hub / github.com/celer-pkg/celer / changeModeForDirsFiles

Method changeModeForDirsFiles

pkgcache/cache_setup.go:248–267  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

246}
247
248func (n *NFSServerSetup) changeModeForDirsFiles() error {
249 dirPerm := fmt.Sprintf("%o", fileio.CacheDirPerm)
250 filePerm := fmt.Sprintf("%o", fileio.CacheFilePerm)
251
252 // - chmod 02775 on directories (group writable + setgid)
253 // - the first "2" is to setgid, it ensures new files/dirs inherit the user group automatically.
254 args := []string{n.nfsDir, "-type", "d", "-exec", "chmod", dirPerm, "{}", ";"}
255 if _, err := cmd.NewExecutor("", "find", args...).ExecuteOutput(); err != nil {
256 return fmt.Errorf("failed to chmod directories %q -> %w", n.nfsDir, err)
257 }
258 color.PrintHint("✔ set permissions of %q to %s", n.nfsDir, dirPerm)
259
260 // chmod 0664 on files (group can overwrite in-place)
261 args = []string{n.nfsDir, "-type", "f", "-exec", "chmod", filePerm, "{}", ";"}
262 if _, err := cmd.NewExecutor("", "find", args...).ExecuteOutput(); err != nil {
263 return fmt.Errorf("failed to chmod files %q -> %w", n.nfsDir, err)
264 }
265 color.PrintHint("✔ set file permissions (chmod %s): %q", filePerm, n.nfsDir)
266 return nil
267}
268
269// exportNFSConfig ensures the NFS export entry exists in /etc/exports, then reloads.
270func (n *NFSServerSetup) exportNFSConfig() error {

Callers 1

SetupMethod · 0.95

Calls 4

NewExecutorFunction · 0.92
PrintHintFunction · 0.92
SprintfMethod · 0.80
ExecuteOutputMethod · 0.80

Tested by

no test coverage detected