Lagom
You might want to enclose the #include <unistd.h> with: ifdef HAVE_UNISTD_H endi...
Also need to fix the cleanup code at the bottom of the function: if(1 != fd) close(fd);...
getpass_r() in tool_getpass.c is reading password from stdout instead of stdin