diff --git a/services/licensemanager/testdata/appstates/appstate_service_state.json b/services/licensemanager/testdata/appstates/appstate_service_state.json index fb5b410f..1460f8c4 100644 --- a/services/licensemanager/testdata/appstates/appstate_service_state.json +++ b/services/licensemanager/testdata/appstates/appstate_service_state.json @@ -1 +1 @@ -[{"name":"untangle-node-geoip","allowedState":0},{"name":"untangle-node-discovery","allowedState":0},{"name":"untangle-node-classd","allowedState":1},{"name":"untangle-node-dynamic-lists","allowedState":0},{"name":"untangle-node-captiveportal","allowedState":0},{"name":"untangle-node-threat-prevention","allowedState":1},{"name":"untangle-node-sitefilter","allowedState":0}] \ No newline at end of file +[{"name":"untangle-node-captiveportal","allowedState":0},{"name":"untangle-node-threat-prevention","allowedState":1},{"name":"untangle-node-sitefilter","allowedState":0},{"name":"untangle-node-geoip","allowedState":0},{"name":"untangle-node-discovery","allowedState":0},{"name":"untangle-node-classd","allowedState":1},{"name":"untangle-node-dynamic-lists","allowedState":0}] \ No newline at end of file diff --git a/services/settings/filesystem.go b/services/settings/filesystem.go index b49c19ef..bbc87b68 100644 --- a/services/settings/filesystem.go +++ b/services/settings/filesystem.go @@ -23,8 +23,14 @@ const ( // prefix specifically for config files in hybrid mode hybridModeSettingsPrefix = "/mnt/flash/mfw-settings" + + nativeEOSIndicatorFile = "/etc/EfwNativeEos" ) +var openWRTFileToNativeEOS = map[string]string{ + "/etc/config/categories.json": "/usr/share/bctid/categories.json", +} + // NoFileAtPath is an error for if a file doesn't exist. In this case // platform detection may have gone okay but we didn't see the file. type NoFileAtPath struct { @@ -56,9 +62,20 @@ func FileExists(fname string) bool { func (f *FilenameLocator) getPlatformFileName(filename string) (string, error) { // Determine platform var newFileName string - if f.fileExists(kernelModeSettingsPrefix) { // Kernel/OpenWRT mode + if f.fileExists(kernelModeSettingsPrefix) { + // Kernel/OpenWRT mode newFileName = kernelModeSettingsPrefix + "/" + filename[strings.LastIndex(filename, "/")+1:] - } else { // Hybrid mode + } else { + // Hybrid mode + if f.fileExists(nativeEOSIndicatorFile) { + // Packetd running natively EOS mode + if nativePath, exists := openWRTFileToNativeEOS[filename]; exists { + return nativePath, nil + } + + // Fall through to Hybrid mode handling + } + if !strings.HasPrefix(filename, kernelModeSettingsPrefix) { // Not a config file, use generic prefix newFileName = filepath.Join(hybridModeGenericPrefix, filename) diff --git a/services/settings/filesystem_test.go b/services/settings/filesystem_test.go index 740c7c03..275788d0 100644 --- a/services/settings/filesystem_test.go +++ b/services/settings/filesystem_test.go @@ -31,17 +31,17 @@ func TestFilenameLocator(t *testing.T) { }{ { filename: "/etc/config/settings.json", - existResults: []bool{false, false, true}, + existResults: []bool{false, false, false, true}, returnValue: "/mnt/flash/mfw-settings/settings.json", }, { filename: "/usr/share/geoip", - existResults: []bool{false, false, true}, + existResults: []bool{false, false, false, true}, returnValue: "/mfw/usr/share/geoip", }, { filename: "/etc/config/appstate.json", - existResults: []bool{false, false, true}, + existResults: []bool{false, false, false, true}, returnValue: "/mnt/flash/mfw-settings/appstate.json", }, { @@ -56,10 +56,15 @@ func TestFilenameLocator(t *testing.T) { }, { filename: "/etc/config/appstate.json", - existResults: []bool{false, false, false}, + existResults: []bool{false, false, false, false}, returnValue: "/mnt/flash/mfw-settings/appstate.json", returnErr: fmt.Errorf("no file at path: /mnt/flash/mfw-settings/appstate.json"), }, + { + filename: "/etc/config/categories.json", + existResults: []bool{false, false, true}, + returnValue: "/usr/share/bctid/categories.json", + }, } for _, test := range tests {