4

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.

8
  • 3
    Why 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? Commented Feb 13, 2011 at 16:23
  • 1
    You 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. Commented Feb 13, 2011 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 Commented Feb 13, 2011 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. Commented Feb 13, 2011 at 16:50
  • 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. Commented Feb 13, 2011 at 17:11

5 Answers 5

3

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

Sign up to request clarification or add additional context in comments.

3 Comments

OK, 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?
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.
@Alexey: As John alludes to, CPUID describes capabilities, it is not a unique identifier like the motherboard serial number is.
3
$ lshal | grep 'system\.hardware\.serial'
  system.hardware.serial = '<serial-number>'  (string)

Works as non-root user on FC11.

1 Comment

What is FC11 and what to do when lshal is not available?
2

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

2 Comments

I tried it before, but it looks like Motherboard serial is returned only if lshw is started as root
Very nice command, however the returned serial (BSN12345678901234567) looks a bit improbable... (also - only as root, run as user misses serials or says "UNCLAIMED").
2
sudo dmidecode --type baseboard

Comments

0

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

4 Comments

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.
@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.
@Juliano its been a while since i last used linux Lol
@Alexey @Juliano I understand that he was asking for a non-root method, basically I am saying I dont think you can.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.