reworked sudo handling for #316