Skip to content

Commit

Permalink
mfw-5748(#423)
Browse files Browse the repository at this point in the history
version: bug
  • Loading branch information
abriles1216 authored Oct 22, 2024
1 parent c375617 commit 5b554f9
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -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}]
[{"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}]
21 changes: 19 additions & 2 deletions services/settings/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down
13 changes: 9 additions & 4 deletions services/settings/filesystem_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
{
Expand All @@ -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 {
Expand Down

0 comments on commit 5b554f9

Please sign in to comment.