I am writing a small Python utility that stores a Kerberos v5 keytab in a StringIO object. I want to avoid storing said keytab anywhere on the machine's disk.
Therefore, I would very much want to invoke kinit
like this (split()
and subprocess()
to follow):
command = "/usr/bin/kinit -V -c {0} -t {1} {2}@{3}".format(cache, ticket, loginUser, kerberosDomain)
where the ticket is:
ticket = StringIO.StringIO(data)
But kinit doesn't really like it. Its source file says:
925 /* Ensure we can be driven from a pipe */
Does anyone have experience with driving kinit
from a pipe, and specifically how to inject the ticket into (presumably) its stdin?
Alternatively, can a StringIO
be wrapped into something like mmap
to behave like a "real" file to kinit
?
Thanks!
PS: A very interesting discussion I read as I was posting this question: Python - How do I pass a string into subprocess.Popen (using the stdin argument)?