()
| 246 | } |
| 247 | |
| 248 | func (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. |
| 270 | func (n *NFSServerSetup) exportNFSConfig() error { |
no test coverage detected