MatthewKing / DeviceId

A simple library providing functionality to generate a 'device ID' that can be used to uniquely identify a computer.
MIT License
729 stars 118 forks source link

Add support for Linux #12

Closed shshzi closed 4 years ago

shshzi commented 4 years ago

This PR adds support for cross-platform, especially Linux. I don't have a MacOS to test this on, so I'm leaving that task to someone else :-)

The extension methods have been extended to provide different implement for each type of ID, per OS platform. The following ComponentIDs have been implemented for Linux:

In addition, I've added another type of component named OSInstallationID which are identities that are set when the OS is installed. There quite a few of these in Windows (MachineGuid, ActivationID, Machine account SID...) but I've chosen the MachineGuid because it's the easiest to implement. It is stored in the registry under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography\MachineGuid. For that a RegistryValueDeviceIdComponent has been implemented to be able to read values from the Registry. Under Linux, we read the /etc/machine-id or /var/lib/dbus/machine-id. These are set when DBUS package is installed and should be supported in all modern Linux distributions.

Please let me know what you think

MatthewKing commented 4 years ago

This looks like a great PR. Thanks!

It will probably take me a bit longer than usual to review, test, merge, and release this one, as I've got a lot going on due to the current COVID situation. I'll try and get to it as soon as I can, though.

Cheers

MatthewKing commented 4 years ago

Hey @shshzi

Thanks again for this excellent PR. I've merged it, and also made a few tweaks to both your code and my existing code. Can you please have a look at the updated codebase and give it a test on your linux machine, and let me know if it's working like you'd expect it to?

Once that's done, I'll feel comfortable deploying the changes.

Cheers

shshzi commented 4 years ago

Hi @MatthewKing , I can confirm it is working on Ubuntu 16.04.

MatthewKing commented 4 years ago

Thanks. I'm just updating some documentation and seeing if there are any other features I want to put into the next release. I should be publishing the new release (including your changes) in the next couple of days.