كتاب الطهارة وسننها
1  
The Book of Purification and its Sunnah
(18)
Chapter: Permission concerning that in the toilet with walls and its permissiblity, not in deserts
(18)
باب الرُّخْصَةِ فِي ذَلِكَ فِي الْكُنُفِ وَإِبَاحَتِهِ دُونَ الصَّحَارَى
Sunan Ibn Majah 323
It was narrated that Ibn 'Umar said:
"I saw the Messenger of Allah in his (constructed) toilet, facing towards the Qiblah." (Da'if) (One of the narrators) 'Eisa said: "I told that to Sha'bi, and he said: 'Ibn 'Umar spoke the truth. As for the words of Abu Hurairah, he said: "In the desert do not face the Qiblah nor turn one's back towards it." As for the words of Ibn 'Umar, he said: "In the (constructed) toilet there is no Qiblah so turn in whatever direction you want." Another chain with similar wording.
حَدَّثَنَا مُحَمَّدُ بْنُ يَحْيَى، حَدَّثَنَا عُبَيْدُ اللَّهِ بْنُ مُوسَى، عَنْ عِيسَى الْحَنَّاطِ، عَنْ نَافِعٍ، عَنِ ابْنِ عُمَرَ، قَالَ رَأَيْتُ رَسُولَ اللَّهِ ـ صلى الله عليه وسلم ـ فِي كَنِيفِهِ مُسْتَقْبِلَ الْقِبْلَةِ ‏.

‏ قَالَ عِيسَى فَقُلْتُ ذَلِكَ لِلشَّعْبِيِّ فَقَالَ صَدَقَ ابْنُ عُمَرَ وَصَدَقَ أَبُو هُرَيْرَةَ أَمَّا قَوْلُ أَبِي هُرَيْرَةَ فَقَالَ فِي الصَّحْرَاءِ لاَ يَسْتَقْبِلِ الْقِبْلَةَ وَلاَ يَسْتَدْبِرْهَا وَأَمَّا قَوْلُ ابْنِ عُمَرَ فَإِنَّ الْكَنِيفَ لَيْسَ فِيهِ قِبْلَةٌ اسْتَقْبِلْ فِيهِ حَيْثُ شِئْتَ ‏.‏ قَالَ أَبُو الْحَسَنِ بْنُ سَلَمَةَ وَحَدَّثَنَا أَبُو حَاتِمٍ، حَدَّثَنَا عُبَيْدُ اللَّهِ بْنُ مُوسَى، فَذَكَرَ نَحْوَهُ ‏.‏

Reference : Sunan Ibn Majah 323
In-book reference : Book 1, Hadith 57
English translation : Vol. 1, Book 1, Hadith 323