net_server: Fixed overwriting wrong interface config

* When the "interfaces" file contains a configuration for a missing
  device, the first interface found would be overwritten, irregardless
  of its status.
* Now, _ConfigureDevices() properly honours the
  "devicesAlreadyConfigured" list.
* This fixes bug #14908.
This commit is contained in:
Axel Dörfler
2019-11-21 08:06:33 +01:00
parent f1271b6454
commit b240f0ad50
+4 -3
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2006-2018, Haiku, Inc. All Rights Reserved. * Copyright 2006-2019, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -731,7 +731,8 @@ NetServer::_ConfigureDevices(const char* startPath,
BPath path; BPath path;
if (entry.GetName(name) != B_OK if (entry.GetName(name) != B_OK
|| entry.GetPath(&path) != B_OK || entry.GetPath(&path) != B_OK
|| entry.GetStat(&stat) != B_OK) || entry.GetStat(&stat) != B_OK
|| devicesAlreadyConfigured.HasString(path.Path()))
continue; continue;
if (S_ISBLK(stat.st_mode) || S_ISCHR(stat.st_mode)) { if (S_ISBLK(stat.st_mode) || S_ISCHR(stat.st_mode)) {
@@ -739,7 +740,7 @@ NetServer::_ConfigureDevices(const char* startPath,
&& suggestedInterface->SetString("device", path.Path()) == B_OK && suggestedInterface->SetString("device", path.Path()) == B_OK
&& _ConfigureInterface(*suggestedInterface) == B_OK) && _ConfigureInterface(*suggestedInterface) == B_OK)
suggestedInterface = NULL; suggestedInterface = NULL;
else if (!devicesAlreadyConfigured.HasString(path.Path())) else
_ConfigureDevice(path.Path()); _ConfigureDevice(path.Path());
} else if (entry.IsDirectory()) { } else if (entry.IsDirectory()) {
_ConfigureDevices(path.Path(), devicesAlreadyConfigured, _ConfigureDevices(path.Path(), devicesAlreadyConfigured,