Modding TUGm to use custom MAC on a VPS

Modding TUGm to use custom MAC on a VPS

Tugs Uptime Project is a great service for monitoring and recording the uptime of your various hosts.

They have various clients for (almost) all operating systems, including Windows and Linux. Unfortunately all of their clients base the machine id by MD5-ing the machine MAC address. This works perfectly in almost all circumstances, unless you are using a VPS… which will have no MAC address for its network interfaces. (Note, the interfaces will in fact have a 00-00-00-00-…. MAC, which will render the same MD5 hash every time).

So in an attempt to make their latest Linux client – TUPm – usable on my VPSs, I made some changes to the client and conf file to add support for defining my own custom MAC (when a MAC is not found). May not be the brightest, safest or cleanest approach, but it does the job.

After grabbing the client source, we need to edit the src/TUPm.c file and make some changes.
Search for

unsigned char mac_addr[150];             // Mac address without ":"

and right above or below it add

unsigned char MAC[150];                  // custom MAC supplied via conf | mac mod

Search for

if( ini_gets("TUPAccount", "TUPMachine", "" , arrTemporaryBuffer, sizeof arrTemporaryBuffer, sConfPath) > 0 ) {

and right above it add

if( ini_gets("TUPAccount", "MAC", "" , arrTemporaryBuffer, sizeof arrTemporaryBuffer, sConfPath) > 0 ) {
         sprintf(MAC,"%s",arrTemporaryBuffer);
}

Search for

// ** If mac address is empty, error.

and comment out the IF block below
Search for

} // fin tupGet_mac

and right above it, add

// MAC address mod
if (MAC != "") {
     sprintf(mac_addr,"%1",MAC);
}
// end mod

Then compile the client via the usual ./configure && make && make install.
The last thing needed is to edit the /root/TUPm/etc/TUPm.conf file (the installed conf) and beside filing in the required information, add
MAC=001122334455as a setting. Remember to try to make this unique among your machines (and hopefully other machines)

Leave a Reply