This question is inspired by an incident in Tinker, Tailor, Soldier, Spy (the Hollywood film version starring Gary Oldman, not the novel or the BBC miniseries with Alec Guinness).
One of the British spies, Peter Guillam (played by Benedict Cumberbatch), is secretly homosexual. Partway through the film, on the advice of George Smiley, he abruptly terminates his romantic relationship and evicts his male lover. The reason he does this is because Smiley's vital counter-espionage operation cannot risk being discovered, and Guillam leading a double-life inevitably leads to discrepancies that, if anyone were to probe, could conceivably lead to the discovery of Smiley's mole hunt.
My question is: would it have been legally acceptable for Guillam to resolve his dilemma by coming out of the closet? In 1973, did homosexuals in the British government face any kind of legal discrimination? Were they barred from serving in the government, or the intelligence service, or from living in London, or anything else?
Was there any legal reason a gay man could not have had Peter Guillam's job in Her Majesty's Government in 1973?
For a more detailed discussion of the fictional context, see this answer of mine on Movies.SE which prompted me to consult you fine folks.