There are no substitutes for good quality sealants to fill gaps around window and door frames. Putty and cement mortar, which were once used by many builders, should be raked out when they show signs of deteriorating; the cavities should be brushed clean, then filled with an exterior grade sealant.
Where gaps are deep, use tubed sealant in a cartridge gun and force sealant deep into the holes. Bring the sealant a little higher than the surface, then smooth with a wet finger.
Where gaps are shallow, use a mastic supplied in strip form. Merely peel off the protective strip and press the sealant in place, smoothing it with your finger.
When you cut off the nozzle from a tube, keep it as a cap for the nozzle; merely reverse the cut-off piece and push it in the end of the nozzle.
With awkward-to-reach holes, such as where waste pipes come from an external wall, use a modern expanding foam filler, supplied in pressurised cans. Direct the nozzle deep into the cavity and allow foam to fill the void. It will expand to many times its original volume, then set. It may then be trimmed with a knife. A serrated kitchen knife is ideal.
If you find fine hairline gaps between putty and window or glazed door frames, but the putty is sound, clean out any dirt with the point of a knife; make sure the surface is dry, then seal the cracks with clear silicone rubber sealant of the type used for sealing around baths and basins. This is highly adhesive and will stick to the glass. And it will remain flexible even when set.
Sealant will not normally stick to damp surfaces. If you encounter damp, dry the surface with a hot-air paint-stripper, using it rather like a powerful hair dryer. Keep it well back from the surface so you don't damage paintwork or crack glass.