Music fans who bought CDs with Sony BMG Music Entertainment's controversial XCP copy control software are going to get refunds.

A US federal judge yesterday gave final approval to a class-action lawsuit that was brought against the entertainment company after Sony included a pair of invasive and potentially dangerous copy protection programs on an estimated 15 million music CDs.

The agreement ends one chapter in a public-relations disaster for the entertainment company, which must still contend with a lawsuit brought against it by the state of Texas for violation of state antispyware laws.

Sony was sued in three separate class-action lawsuits, which were consolidated into yesterday's settlement. The suits were launched in November 2005, soon after computer science researchers disclosed that Sony's XCP software used dangerous 'rootkit' techniques to cloak itself after installation. Sony licensed the XCP software from First 4 Internet, based in Banbury.

Rootkit software is normally used by hackers to hide their malware from system tools and antivirus products, and Sony was widely criticised for using this potentially dangerous software.

With its approval of the deal on Monday, the court finalised a tentative agreement reached between Sony and the plaintiffs in December.

Under terms of the settlement, people who purchased XCP-protected CDs can apply for either a cash payment of $7.50 (about £4) plus a free album download, or three album downloads, whichever they prefer.

"This settlement gets music fans what they thought they were buying in the first place: music that will play on all their electronic devices without installing sneaky software," said Cindy Cohn, legal director of the EFF (Electronic Frontier Foundation), in a statement yesterday. The EFF represented plaintiffs in the case.

Sony issued a statement yesterday saying it was pleased with the settlement.

Computer science researchers also found problems with another type of software Sony put on some CDs, called MediaMax. That software, written by SunnComm, installs software without the user's permission, is difficult to uninstall, and surreptitiously transmits information about users' activities to SunnComm's servers.

Customers who bought MediaMax CDs can now get free downloads.

More information on the class-action lawsuit, including lists of CDs that included the software in question, can be found here.

The EFF has information on the case as well, which can be found here.