Genetically engineered resistance to bacterial and fungal pathogens