If these sacs become infected or impacted, problems result. This can be a very painful situation when they become infected. If a dog is scared or overly excited, these glands can secrete the smelly, oily substance on the surrounding fur, causing bad odor.
If you choose to do so, your veterinarian can show you how to check and even empty the anal sacs at home to prevent problems with odor. Always consult with your veterinarian if your notice an odd odor or anything "not quite right" with your pet. An ounce of prevention is definitely better than a pound of cure.