but then , just as david resigned himself to being caught , or at least detained for some hours ; a senior ranking officer observing the action from within his office rapped on the window and rushed out towards them , he had recognized zaqaria as a local and greeted him with a friendly handshake .