If agent_write_shadow_key does now also check for an existing private key file, then I'd replace following code in cmd_readkey:
if (agent_key_available (grip))
{
/* Shadow-key is not available in our key storage. */
rc = agent_write_shadow_key (0, grip, serialno, keyid, pkbuf, 0,
dispserialno);
}
else
{
/* Shadow-key is available in our key storage but ne check
* whether we need to update it with a new display-s/n or
* whatever. */
rc = agent_write_shadow_key (1, grip, serialno, keyid, pkbuf, 0,
dispserialno);
}with a simple call of agent_write_shadow_key (removing the maybe_update flag) and let agent_write_shadow_key do all checking for an already existing private key file and whether it's a stub file that needs updating.
