The European powers first gained a foothold in Somalia through the signing of various pacts and agreements with the Somali Sultans that then controlled the region , such as Yusuf Ali Kenadid , Boqor Osman Mahamuud and Mohamoud Ali Shire .