MVS Volvo Forums user N_D shows us how he fixed his leaking sunroof with this sunroof seal repair:
After peeling off the gasket I discovered that the metal sunroof frame was severely rusted and had begun to separate from the glass. The glass is bonded to the frame with a very hard rubber like sealant, water seeps under the sunroof gasket and sits in the depressed area of the frame causing it to rust.
To repair this I first scraped/filed off as much loose rust as I could and pried the frame as far away from the glass as I could without breaking anything using wooden wedges and continued to clean as much rust out as possible. I then applied a rust converter to the remaining material.