mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2024-12-19 21:57:54 +00:00
Only read directories under /sys/class/net
When reading mac addresses, if there is a non-directory file under /sys/class/net, this will cause the supervisor to show an exception on the logs. This now filters out non-directories on the list to prevent this Change-type: patch
This commit is contained in:
parent
649a20fbe0
commit
19de8e6263
@ -17,12 +17,24 @@ export async function getAll(sysClassNet: string): Promise<string | undefined> {
|
||||
return _(
|
||||
await Promise.all(
|
||||
interfaces.map(async (intf) => {
|
||||
const ifacePath = path.join(sysClassNet, intf);
|
||||
try {
|
||||
// Exclude non-directories
|
||||
const entryStat = await fs.stat(ifacePath);
|
||||
if (!entryStat.isDirectory()) {
|
||||
return '';
|
||||
}
|
||||
} catch {
|
||||
// If stat fails ignore the interface
|
||||
return '';
|
||||
}
|
||||
|
||||
try {
|
||||
const [addressFile, typeFile, masterFile] = [
|
||||
'address',
|
||||
'type',
|
||||
'master',
|
||||
].map((f) => path.join(sysClassNet, intf, f));
|
||||
].map((f) => path.join(ifacePath, f));
|
||||
|
||||
const [intfType, intfHasMaster] = await Promise.all([
|
||||
fs.readFile(typeFile, 'utf8'),
|
||||
|
Loading…
Reference in New Issue
Block a user