Alexey
Alexey

Reputation: 355

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.

Upvotes: 4

Views: 12413

Answers (5)

Pipo
Pipo

Reputation: 5093

sudo dmidecode --type baseboard

Upvotes: 2

Peter
Peter

Reputation: 297

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

Works as non-root user on FC11.

Upvotes: 3

Allen
Allen

Reputation: 21

lshw should get the serial for you. It will tell you it should be run as superuser but will run anyway. (tested on ubuntu)

Upvotes: 2

Ben Voigt
Ben Voigt

Reputation: 283921

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).

Upvotes: 3

user427165
user427165

Reputation:

I think you need to be root

opening up /proc/pci will give you alot of information chipset etc, not sure if /proc/ has a specific directory for motherboard or BIOS info, have a look ls /proc ?

Other than that you could look at calling the dmidecode commandline tool from your application and capturing its output. If thats not good enough, perhaps even look at the source code of dmidecode to see how it works?

Andrew

Upvotes: 0

Related Questions