road modelling

I am working on a road modelling software in OpenGL, wherein the user can click two points on a terrain and a road appears between the points, depending on the topography and all.
I was wondering if I could get help with the basic question: how do I ensure that the road that is created after the clicks ‘sticks’ to the terrain properly and doesn’t leave the ground?