fix: do not proceed with DHCP if no network device with an active link is present

This commit is contained in:
daniel committed 2026-10-02 08:31:57 +02:00
1 parent 24f88ec4c6
commit 41de95b277
2 files changed
+18 -1

No files matched your search

+17
View File
@@ -250,6 +250,23 @@ extern "C" void _start() {
montauk::service_log("MontaukOS DHCP Client");
// 0. Check if any device with an up link even exists.
montauk::abi::NetIfInfo ifs[4];
int n = montauk::net_interfaces(ifs, 4);
bool link = false;
for (int i = 0; i < n; i++) {
if (ifs[i].linkUp == true) {
link = true;
}
}
if (link == false) {
montauk::service_log("Unable to locate a network device with an active link.\n");
montauk::exit(montauk::StatusCodes::NoDevice);
}
// 1. Get MAC address
montauk::abi::NetCfg origCfg;
montauk::get_netcfg(&origCfg);