Although not the most glamorous part of canine anatomy, anal sacs serve some important purposes. The potently smelling liquid they contain is used for individual identification between animals of the same species and territory marking, and possibly also for lubrication and facilitation of the passage of stool. Anal sacs -- sometimes referred to as anal glands, even though they aren't actually glands -- are also a common source of infections in many dogs.
Normal Anal Sac Liquid
Anal sac liquid is supposed to be dark brown or a grayish-brown color. Ideally, it's oily and fairly fluid in consistency, though some dogs naturally produce a thicker discharge. When everything's working properly, this fluid drains efficiently through short, narrow ducts and is expelled near the anus. It is perfectly normal for anal sac fluid to smell quite strong and foul.
Some dogs develop anal sac impactions, infections and/or abscesses. This occurs when the liquid doesn't drain efficiently enough for one reason or another. If you notice the liquid has turned yellowish, this is a clinical sign of an anal sac infection. You may also notice some pink or red in the fluid, indicating the presence of blood. See your vet, who will manually drain the anal sacs and any abscess, and he'll show you how to express the anal sacs yourself at home. He may also prescribe antibiotics.