by Imam Malik, translation by A'isha `Abdarahman at-Tarjumana and Ya`qub Johnson , Volume: The Qibla
Chapter: The Prohibition against Relieving Oneself Facing the Qibla
Yahya related to me from Malik from Ishaq ibn Abdullah ibn Abi Talha that Rafiibn Ishaq, a mawla of the family of ash-Shifa who was known as the mawla of Abu Talha, heard Abu Ayyub al-Ansari, one of the companions of the Messenger of Allah, may Allah bless him and grant him peace, say, while he was in Egypt, "By Allah! I don't know how to deal with these lavatories." The Messenger of Allah, may Allah bless him and grant him peace, said, "When you go to defecate or urinate, do not expose your genitals towards the qibla, and do not put your back to it."
Yahya related to me from Malik from one of the Ansar that the Messenger of Allah, may Allah bless him and grant him peace, forbade defecating or urinating while facing the qibla.
14.2 Permission to Face the Qibla when Urinating or Defecating