[mdlug] Programatically Answering a Password Prompt

Aaron Kulkis akulkis00 at gmail.com
Fri Aug 8 01:52:14 EDT 2014


Wojtak, Greg wrote:
> 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.
>

Any GOOD password prompter reads directly from the keyboard, not from stdin.


I had to get around a similar issue years ago on a Sequent system.  Unfortunately, I forget what I did in that script 
exactly, but it did involve the use of a very short-lived named pipe, using the PID as part of the filesystem name
for the pipe.

The whole purpose was so that I could load up several 6-tape autoloaders on Friday afternoon, and do
completely automatic backups of a database on Sunday with no need for human activity.

Unfortunately, I do not have a copy of the script.

[That was before I smartened up and started emailing myself at my gmail account any script I wrote]



More information about the mdlug mailing list