lfreist / hwinfo

cross platform C++ library for hardware information (CPU, RAM, GPU, ...)
MIT License
433 stars 74 forks source link

[Linux] PCIMapper pci.ids file location bug #60

Closed ZanderFoster closed 4 weeks ago

ZanderFoster commented 10 months ago

I found a bug using the GPU module.

When compiled as user PCIMapper looks for the id files at /home/${user}/.hwinfo/pci.ids
However if the program is ran as sudo or root the getenv("HOME"); function will return /root/.hwinfo/pci.ids

I propose this line be changed to store the pci.ids file to the same location as the applications binary. https://github.com/lfreist/hwinfo/blob/b4adfd795aa2aa25b8dff6dd8116725f72b187dd/CMakeLists.txt#L39C67-L39C67

I'm trying to get into some open-source coding so if you would let me know your opinions I would be happy to implement them.

lfreist commented 10 months ago

Hi, Thanks for reporting this Bug! The pci.ids file brings some more issues: HWinfo is a library that can be build shared and static. For a shared library, it is relatively easy to place the pci.ids file along the binaries. For static builds it becomes more difficult. I am currently working on a PCIMapper that does not parse the pci.ids file but builds a dictionary like structure in compile time from the file. This way, static and shared builds become much easier.