As a general rule, you are given the opportunity to conduct a home inspection before you buy. You can ask for the repair of defective conditions prior to the closing of title. However, once the closing occurs, absent fraud, you cannot go after the prior homeowner for defects.
Further, as a general rule, you cannot sue a municipal official because they issued a certificate of occupancy.
If this answer was helpful, please mark it as helpful or as a best answer. This answer is for general education purposes only. It neither creates an attorney-client relationship nor provides legal guidance or advice. The answer is based on the limited information provided and the answer might be different had additional information been provided. You should consult an attorney.
Hire a licensed plumber and fix this problem. Then chalk it up to experience. Even if there were recourse against the seller, you'd spend more on lawyer fees than the cost of fixing the problem.
Check the documents you received relating to the transaction. There is probably a disclosure form executed by the seller. If that form indicates that the plumbing works properly, you MAY have some recourse based on that disclosure - assuming the smell you noticed is something the seller would have known about. But like the other answer, the problem can probably be fixed for less than the cost of litigating it.