fix(nfs): move fsid=N inside client parentheses in /etc/exports
exportfs parses 'path host(flags) fsid=N' as a separate fsid= token without host or options, causing 'No options for path fsid=N' errors. The correct format puts fsid=N inside the host parentheses: /path host(flags,fsid=N) Changes: - clientFlags(c, fsid) now appends fsid=N at the end - buildExportFlags(e, fsid) same - buildExportLine removed buildExportSuffix call; fsid is now per-client - Removed now-unused buildExportSuffix function Version: 0.5.3
This commit is contained in:
+10
-12
@@ -82,8 +82,8 @@ func (m *Module) Apply(ctx context.Context, database *db.DB) error {
|
||||
return database.ClearDirty(ModuleName)
|
||||
}
|
||||
|
||||
func buildExportFlags(e db.NFSExport) string {
|
||||
parts := make([]string, 0, 8)
|
||||
func buildExportFlags(e db.NFSExport, fsid int64) string {
|
||||
parts := make([]string, 0, 9)
|
||||
if e.ReadOnly {
|
||||
parts = append(parts, "ro")
|
||||
} else {
|
||||
@@ -132,15 +132,12 @@ func buildExportFlags(e db.NFSExport) string {
|
||||
}
|
||||
}
|
||||
}
|
||||
parts = append(parts, fmt.Sprintf("fsid=%d", fsid))
|
||||
return strings.Join(parts, ",")
|
||||
}
|
||||
|
||||
func buildExportSuffix(e db.NFSExport) string {
|
||||
return fmt.Sprintf("fsid=%d", e.FSID)
|
||||
}
|
||||
|
||||
func clientFlags(c db.NFSClient) string {
|
||||
parts := make([]string, 0, 8)
|
||||
func clientFlags(c db.NFSClient, fsid int64) string {
|
||||
parts := make([]string, 0, 9)
|
||||
if c.ReadOnly {
|
||||
parts = append(parts, "ro")
|
||||
} else {
|
||||
@@ -184,12 +181,13 @@ func clientFlags(c db.NFSClient) string {
|
||||
if c.Advanced.Crossmnt {
|
||||
parts = append(parts, "crossmnt")
|
||||
}
|
||||
parts = append(parts, fmt.Sprintf("fsid=%d", fsid))
|
||||
return strings.Join(parts, ",")
|
||||
}
|
||||
|
||||
func buildExportLine(e db.NFSExport) string {
|
||||
if len(e.Clients) == 0 {
|
||||
return fmt.Sprintf("%s *(%s) %s", e.Path, buildExportFlags(e), buildExportSuffix(e))
|
||||
return fmt.Sprintf("%s *(%s)", e.Path, buildExportFlags(e, e.FSID))
|
||||
}
|
||||
specs := make([]string, 0, len(e.Clients))
|
||||
for _, c := range e.Clients {
|
||||
@@ -197,12 +195,12 @@ func buildExportLine(e db.NFSExport) string {
|
||||
if c.Host == "" {
|
||||
continue
|
||||
}
|
||||
specs = append(specs, fmt.Sprintf("%s(%s)", c.Host, clientFlags(c)))
|
||||
specs = append(specs, fmt.Sprintf("%s(%s)", c.Host, clientFlags(c, e.FSID)))
|
||||
}
|
||||
if len(specs) == 0 {
|
||||
return fmt.Sprintf("%s *(%s) %s", e.Path, buildExportFlags(e), buildExportSuffix(e))
|
||||
return fmt.Sprintf("%s *(%s)", e.Path, buildExportFlags(e, e.FSID))
|
||||
}
|
||||
return fmt.Sprintf("%s %s %s", e.Path, strings.Join(specs, " "), buildExportSuffix(e))
|
||||
return fmt.Sprintf("%s %s", e.Path, strings.Join(specs, " "))
|
||||
}
|
||||
|
||||
func (m *Module) renderConfig(exports []db.NFSExport) ([]byte, error) {
|
||||
|
||||
Reference in New Issue
Block a user