Using `mkstemp()` is nice, but if you don't need the FD, then don't forget to close it!
TBD: - improve error handling, logging, tracing! - move all REST services out of kdc/