Section 123(2) in The Code of Criminal Procedure, 1973
(2)Whenever any person has been imprisoned for failing to give security under this Chapter, the High Court or Court of Session, or, where the order was made by any other Court, [the District Magistrate, in the case of an order passed by an Executive Magistrate under section 117, or the Chief Judicial Magistrate in any other case] [Substituted by Act 45 of 1978, Section 12, for "the Chief Judicial Magistrate", w.e.f. 18.12.1978.], may make an order reducing the amount of the security or the number of sureties or the time for which security has been required.