config: push path() into moveifchanged()
Every caller path()s its arguments anyways, just simplify these and push
path() into moveifchanged(). This fixes a number of memory leaks in the
process since path() allocates memory, which we will now free().
While we're here, make sure we close from_fd/to_fd appropriately.
CID: 1471040, 1471714, 1472045, 1006907, 1006908
Reviewed by: emaste, imp
Differential Revision: https://reviews.freebsd.org/D38641