I seen a lot of apps in the market that give superuser functionality to applications. However there is a pre-requisite of rooting your phone. I am curios how a rooted phone has those permissions already?

I've downloaded the source code and have managed to locate the su.c file that might invoke an application to change. But im still not sure. Possible if any of the ROM creators can give an insight on this? 

Which actual files delegate permissions? Are all system apps given root permissions at startup? 

Thanx
Asym