Refactor: remoted: Simplify parent process renaming
When pacemaker-remoted is launched, it quickly forks a child process.
This child process does the real work of pacemaker-remoted. The parent
remains as a sort of "init" process to reap any dead child processes.
This is because pacemaker-remoted may be pid 1 on a container: that is,
there may be no true init process.
Previously, there was some complicated logic to rename the parent
process from "/usr/bin/pacemaker-remoted" (or similar) to "pcmk-init".
This appears to be only for clarity in ps output.
This logic relied on the assumption that the buffers pointed to by argv
are contiguous with one another and with the buffers pointed to by envp.
This is true on Linux but perhaps not on other platforms.
It also assigned NULL to argv[1] so that only argv[0] would appear in
the ps output. However, this approach doesn't work, at least on my
Fedora 42 machine. With a simple test program (not pacemaker-remoted),
the remaining arguments appear unchanged in ps output. Instead, we must
zero out the buffers themselves.
The previous logic was also overkill. argv[0] ought to be at least as
long as "pacemaker-remoted" unless it's run as a link with a very short
name, or in some other contrived way. It's not necessary to copy over
multiple arguments and environment variables just to ensure we have
enough room for "pcmk-init".
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>