core-util: add api for setting env vars and record them so that we can undo them...