The Obama administration is against intelligence officials leaking classified information—but some conditions may apply.

If you're a CIA analyst who talks to reporters, you might end up serving 30 months in federal prison or facing more. Even a reporter could end up being named a co-conspirator by prosecutors. But if you're a decorated general, a former CIA director, and a former member of the Cabinet, you might get off with a $40,000 fine and two years of probation.

Just ask David Petraeus, the man who went from war hero to chief spy to disgraced adulterer in a few short years. While the juicy story was that the CIA director was having an affair with an Army Reserve officer writing his biography, his resignation and apology didn't end the legal issues. The retired four-star general still stood accused of providing classified information to Paula Broadwell, the writer, including binders featuring his daily schedule and notes from meetings with President Obama.

On Tuesday, the Justice Department announced that it had reached a plea deal with Petraeus. He pled guilty to a single count of unauthorized removal and retention of classified material, and while he could have gone to jail for a year on that charge, prosecutors agreed to seek the fine and probation instead.

That's considerably less than what he might have faced. FBI and Justice officials reportedly recommended bringing felony charges against Petraeus. But there were plenty of reasons that the parties involved might have preferred a quiet, non-trial resolution—and if it came on a big news day, when Benjamin Netanyahu was speaking to Congress, surely no one was upset. You can read the full deal, which runs to five pages, here.

First, Petraeus wasn't eager to have a public trial in which his infidelities were discussed, probed, investigated, and questioned, with witnesses under oath. He remains married to his wife Holly, who was the daughter of the West Point superintendent when he attended and is now an official in the Consumer Finance and Protection Bureau. And he was eager to close out the proceeding so he could clear the air and expand his work for the private-equity firm KKR, for whom he's been working since after resigning, but with a role proscribed by the investigation.

Second, the government had incentives to avoid a messy trial, too. For one, it could lose. For another, the CIA isn't fond of public trials involving confidential material. And for a third, there was the potential embarrassment of prosecuting a former member of the Cabinet who had helped design many of the administration's policies in Iraq, Afghanistan, and elsewhere.

Petraeus also had powerful friends. As Attorney General Eric Holder considered whether to charge him, Senator John McCain wrote to Holder asking for leniency and a quick disposition. “Congress and the American people cannot afford to have his voice silenced or curtailed by the shadow of a long-running, unresolved investigation marked by leaks from anonymous sources,” he wrote.

The plea deal may even pave the way for Petraeus to return to government and public service. While the calls for him to run for president may no longer sound so loudly, he is reportedly interested in returning to public-sector work.

That all adds up to a lot of momentum on the side of a lenient deal for Petraeus. There are differences between his case and that of CIA officer Jeffrey Sterling, who awaits sentencing after being convicted of telling a reporter about a sabotage program against Iran's nuclear program, or John Kiriakou, the analyst who was recently released from prison after being convicted of giving a reporter information that connected a covert operative to a secret program. In both cases, the government said those leaks had harmed national security (although it's worth noting that the public simply has to trust authorities, since they can't or won't explain why).

In Petraeus's case, there was no proven harm to national security, but prosecutors said the type of breach he committed, especially from the head of the CIA, was serious enough to merit prosecution. His plea deal makes it easy for naysayers to think there's a double standard on who gets a slap on the wrist and who gets sent to a cell.