[Dovecot] "doveadm auth user" requiring a tty
Hello, "doveadm auth user password" may be scripted without a glitch. But this comes with the usual problem of a "ps" command showing the password, which may be especially annoying in case of a single-letter typo: the almost correct password is then visible for about two seconds... Clearing the password argument (zeroing it) in doveadm-auth.c, in the hope to reduce the window during which the password may be catched, didn't prove successful. "doveadm auth user" could be an alternative, but it imperatively requires a tty, which may not always easily nor efficiently be available in a scripting environment. I thus ended with this very quick and dirty hack (I guess this should be named that way): --- askpass.original.c 2010-05-31 18:36:52.000000000 +0200 +++ askpass.c 2010-11-27 19:12:03.000000000 +0100 @@ -16,8 +16,24 @@ char ch; int fd; + // A very crude attempt... this supposes that STDIN not being a tty + // may never happen outside of "doveadm auth", and that STDIN will + // always be clean. + //if (!isatty(STDIN_FILENO)) + // i_fatal("stdin isn't a TTY"); if (!isatty(STDIN_FILENO)) - i_fatal("stdin isn't a TTY"); + { + pos = 0; + while (read(STDIN_FILENO, &ch, 1) > 0) { + if (pos >= buf_size-1) + break; + if (ch == '\n' || ch == '\r') + break; + buf[pos++] = ch; + } + buf[pos] = '\0'; + return; + } fputs(prompt, stderr); fflush(stderr); but this for sure must overlook a lot of things. What would be the best way to achieve a scriptable "doveadm auth", say through php's proc_open(), without possibly compromise passwords? TIA, Axel
On 27.11.2010, at 23.17, Axel Luttgens wrote:
"doveadm auth user" could be an alternative, but it imperatively requires a tty, which may not always easily nor efficiently be available in a scripting environment.
- // A very crude attempt... this supposes that STDIN not being a tty
- // may never happen outside of "doveadm auth", and that STDIN will
- // always be clean.
I'm also not sure if there's any better way to do this.. There is anyway only two users of askpass() and in both situations it should be pretty safe to just use stdin. Committed:
http://hg.dovecot.org/dovecot-2.0/rev/6ea1671108f1 http://hg.dovecot.org/dovecot-2.0/rev/719ce27f9955
Le 30 nov. 2010 à 01:19, Timo Sirainen a écrit :
[...]
I'm also not sure if there's any better way to do this.. There is anyway only two users of askpass() and in both situations it should be pretty safe to just use stdin. Committed:
http://hg.dovecot.org/dovecot-2.0/rev/6ea1671108f1 http://hg.dovecot.org/dovecot-2.0/rev/719ce27f9955
Once again, many thanks, Timo! Axel
participants (2)
-
Axel Luttgens
-
Timo Sirainen