159. Who is entitled to apply for writ.

The person illegally imprisoned or detained in confinement without legal justification is, both at common law and by statute1, entitled to apply for a writ of habeas corpus, but it is not essential that the application should proceed directly from him.

Any person may, on behalf of the person illegally imprisoned or detained, institute proceedings to obtain a writ of habeas corpus for the purpose of liberating another from an illegal imprisonment, and any person who is legally entitled to the custody of another may apply for the writ in order to regain that custody