When using system() you can run just about anything as if it were a headless call to bash (non-interactive), you can save the output to a file and read from that (so you could at least get the output from ifconfig and figure out the device name from that)
system(ifconfig > devices.txt);
ifstream file("devices.txt");
file ...read from file... etc.
If you're going to change the mac of one device you might as well change the others at the same time as a precaution. If a device is disabled it will not show up in ifconfig's default output.
You also have to keep in mind that the first half of the mac address (I'll say nic for short) indicates what company produced the device, so it's important that the first half of your "random" mac address corresponds to an existing company...
http://aruljohn.com/mac/vendor/dell <- look up existing vendors like edimax, dell, apple, etc. This link is preset to look up dell
What I did was select a dozen or so of the existing company nic's and saved them in a switch-case form of library so that I could ask for a random number to align to a known company ... You should probably do this separately for ethernet, wifi, and bluetooth.
system(echo ~ > homePath.txt); <- gives you both the username and home directory in one go.
system(pwd >> homePath.txt); <- gives you the current working directory.
As far as security, I would not distribute this kind of code because of all the calls to system(). I couldn't guarantee that the bash interactions would be the same for all systems, and there's no guarantee that someone hasn't replaced one of the programs you are calling with something malicious.
cstdio has the function remove which can then delete the created files for cleanliness... personally, I made a bash script that handled all system calls and my only c++ portion was to simply spit out a valid mac based on the inputs received from argv.
I don't know of a way to output directly to a string from a system call, I checked out your github and agree that python is probably the way to go.
As far as legality, the best I've read is that it is perfectly legal to spoof your mac as long as you don't end up using a nic that is government owned.