[mdlug] Programatically Answering a Password Prompt

Wojtak, Greg GregWojtak at quickenloans.com
Thu Aug 7 13:38:24 EDT 2014


I’m writing  a python script and part of it is calling kinit to get a kerberos ticket before doing some ldap operations.  I’m trying to find a method to pass the password into my script, and I haven’t been able to reliably do this.  Depending on the distribution of Linux and the version of that distribution, I’ve found that different versions of kinit will read the password:


  *   From STDIN
  *   From a file descriptor dup()’ed from STDIN
  *   By opening /dev/tty and polling directly for key presses/input

I have been able to get the first two cases covered, but I am at a loss as to how to get the third case going.  I’ve even tried firing off the kinit and then writing directly to /dev/tty, but as expected, that does not work.  If it helps, I am using the python subprocess module with Popen to run kinit, but as far as I know, there is no method to redirect anything other than file descriptors 0, 1, and 2 with Popen.

Does anyone have any insight into this?  Even if you’re not a python programmer, if you know how this is working, any insight you could give would be much appreciated.

TIA,

Greg


More information about the mdlug mailing list