Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get motherboard ID on Linux from a C++ program

I want to retrieve motherboard ID from a C++ program on Linux (Ubuntu) without root privileges. I know that dmidecode can do this, but it requires root privileges, so it is not suitable for my needs. Does anyone know of non-root alternatives? Source code will be much appreciated.

like image 557
Alexey Avatar asked Dec 28 '22 01:12

Alexey


2 Answers

You don't have to be root to get the information, but you do need to have root first give you permission. Obviously root is allowed to secure access to their machine, and this includes access to hardware identity information.

root controls what the software on their machine can do, your software does not restrict what root can do. (Linux Corollary to The #1 Law of Software Licensing)

If root chooses to install your hardware id collector, it's relatively straightforward to make that data available to non-root users (but it's also relatively easy for root to modify your id collector to lie).

like image 93
Ben Voigt Avatar answered Jan 10 '23 17:01

Ben Voigt


$ lshal | grep 'system\.hardware\.serial'
  system.hardware.serial = '<serial-number>'  (string)

Works as non-root user on FC11.

like image 24
Peter Avatar answered Jan 10 '23 18:01

Peter