Variational theory of drift and tearing eigenmodes in slab geometry