session: avoid using strncpy()
session: avoid using strncpy()

GCC throws warnings if you use strncpy() for its intended purpose and
it's difficult and ugly to #pragma them away (while getting the version
right).  Let's write some complicated and less clear code to accomplish
the relatively simple thing that we wanted to do in the first place.

Closes #13912
martinpitt/cockpit,moraleslazaro/cockpit,garrett/cockpit,moraleslazaro/cockpit,moraleslazaro/cockpit,mvollmer/cockpit,cockpituous/cockpit,cockpit-project/cockpit,cockpituous/cockpit,deryni/cockpit,deryni/cockpit,garrett/cockpit,garrett/cockpit,mvollmer/cockpit,cockpit-project/cockpit,deryni/cockpit,garrett/cockpit,deryni/cockpit,cockpit-project/cockpit,cockpituous/cockpit,martinpitt/cockpit,moraleslazaro/cockpit,deryni/cockpit,cockpit-project/cockpit,moraleslazaro/cockpit,moraleslazaro/cockpit,moraleslazaro/cockpit,martinpitt/cockpit,mvollmer/cockpit,martinpitt/cockpit,garrett/cockpit,mvollmer/cockpit,deryni/cockpit,cockpituous/cockpit,martinpitt/cockpit,cockpit-project/cockpit,cockpituous/cockpit,cockpituous/cockpit,mvollmer/cockpit,deryni/cockpit