Refactor: remoted: Clean up load_env_vars()
The changes in this commit involve using (gchar *) strings and some
dynamic allocation to make load_env_vars() easier to reason about.
Previously, we tried to be as efficient as possible by reading a line
into a buffer, iterating over it with multiple pointers, dividing
it into name and value by insertion of a null terminator, etc.
This is premature optimization. This function is not called along a path
of execution where performance is so critical as to require this. In my
opinion, clarity is more important.
- Use pcmk__scan_nvpair() to separate the line on the equal sign.
- Simplify name validation since we now have name as a separate string (before the equal sign) and don't need to return first and last pointers.
- Skip the leading quote by converting it to a space and calling g_strchug() to memmove() value up by one position. This ensures that value still points to the beginning of the buffer, which simplifies freeing it later.
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>