1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:27:35 +00:00

NetworkServer: Kill DHCPServer as the first thing done

The DHCPServer running while we setup interfaces might manage to setup
its own config before we kill it.
This commit is contained in:
Maciej 2022-07-10 17:54:38 +02:00 committed by Andreas Kling
parent 101c5566cb
commit 211ced3b65

View file

@ -34,6 +34,10 @@ ErrorOr<int> serenity_main(Main::Arguments)
JsonParser parser(data);
JsonValue proc_net_adapters_json = TRY(parser.parse());
// Kill all previously running DHCPServers that may manage to re-assign the IP
// address before we clear it manually.
MUST(Core::command("killall", { "DHCPClient" }, {}));
auto groups = config_file->groups();
dbgln("Interfaces to configure: {}", groups);
@ -89,7 +93,7 @@ ErrorOr<int> serenity_main(Main::Arguments)
for (auto& iface : interfaces_with_dhcp_enabled)
args.append(const_cast<char*>(iface.characters()));
args.append(nullptr);
MUST(Core::command("killall", { "DHCPClient" }, {}));
auto dhcp_client_pid = TRY(Core::System::posix_spawnp("DHCPClient"sv, nullptr, nullptr, args.data(), environ));
TRY(Core::System::disown(dhcp_client_pid));
}