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.
-
3Why would a non-root user have access to such information? For what purpose? Also, what is the motherboard ID for a virtual machine running inside VMWare or VirtualBox? – Juliano Feb 13 '11 at 16:23
-
1You can get that information on recent kernels from `/sys/class/dmi/id/board_serial`, which, you guessed it... is only readable by `root`, as it should be. – Frédéric Hamidi Feb 13 '11 at 16:28
-
@Juliano That's for licensing purposes to avoid unauthorized usage of the main app. This licensing app should quietly collect motherboard serial and check if it matches the registered one. Of course, the Linux user may not be the root – Alexey Feb 13 '11 at 16:43
-
This form of "licensing" is horribly broken. There are lots of questions all over StackOverflow about this, search for it. For instance, any method you may invent to try to protect unauthorized copies will just end with either: 1. an LD_PRELOAD trick that fouls your application; or 2. your application distributed in a virtual machine with a single, constant environment. – Juliano Feb 13 '11 at 16:50
-
@Juliano I understand that this protection can be broken especially with VMWare, still I need to be able to retrieve motherboard ID without having to be the root - that's part of what I've already committed to. – Alexey Feb 13 '11 at 17:05
-
1@Alexey: you may have "committed to" doing the infeasible. Might be a good idea to reconsider this commitment. You could use other bits of information like the network adapter's MAC address or whatever if you feel you need to pursue hardware signature based licensing. – John Zwinck Feb 13 '11 at 17:11
-
@Alexey: I make @John's words mine. And I must add: If you want to create a software copy protection that would really work, you would need at least the same amount of expertise than the people who crack copy protection schemes, and some of these people have more than 15 years of experience on that. Just for the fact that you are asking this question on StackOverflow, I'm sure you are not even near their level. Just stop wasting your time, you are going into a battle you already lost. – Juliano Feb 13 '11 at 17:20
-
I just checked my serial number. It is "To be filled by O.E.M." and since I am the OEM I guess I can put whatever I want in there. – Karl Bielefeldt Feb 13 '11 at 19:04
5 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).
-
1OK, but I can retrieve information about HDD (ATA) serial, MAC address or even CPU ID without root permissions. Why motherboard serial would be so special that there is no workaround? – Alexey Feb 13 '11 at 17:32
-
MAC address is useful for "normal" programming purposes, such as when you need to know what address another computer should tag a wake-on-lan "magic packet" with, or for other low-level networking functions. As for the ATA HDD serial number, maybe Linux will decide to limit that to privileged users too (I think this could be a good idea, actually). The CPU ID is useful for programs that have optimized code for specific processors. Motherboard serial numbers have no such use in normal code. – John Zwinck Feb 13 '11 at 18:17
-
@Alexey: As John alludes to, CPUID describes capabilities, it is not a unique identifier like the motherboard serial number is. – Ben Voigt Feb 14 '11 at 03:27
$ lshal | grep 'system\.hardware\.serial'
system.hardware.serial = '<serial-number>' (string)
Works as non-root user on FC11.

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

- 21
- 1
-
1I tried it before, but it looks like Motherboard serial is returned only if lshw is started as root – Alexey Feb 14 '11 at 21:29
-
Very nice command, however the returned serial (BSN12345678901234567) looks a bit improbable... (also - only as root, run as user misses serials or says "UNCLAIMED"). – Tomasz Gandor Mar 10 '14 at 21:02
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
-
The information is in /sys, not /proc. Also, /proc/pci is obsolete, and doesn't exist in many current Linux versions anymore. The information about the motherboard serial number is sensitive, and only root has access. Dmidecode also needs root privileges, which he said he doesn't want to depend on. – Juliano Feb 13 '11 at 16:34
-
@Andrew I need to find the way to get it without being the root, that's the main reason I can't utilize dmidecode or its source or access those files directly. – Alexey Feb 13 '11 at 16:39
-
-
@Alexey @Juliano I understand that he was asking for a non-root method, basically I am saying I dont think you can. – Feb 13 '11 at 19:29