+2003-02-06 Tom Yu <tlyu@mit.edu>
+
+ * prompter.c (krb5_prompter_posix, setup_tty, restore_tty): Fix to
+ use the actual file descriptor we dup()'ed to in case tcsetattr()
+ doesn't actually change the underlying device modes and instead
+ only affects the specific file descriptor.
+
2003-02-06 Ken Raeburn <raeburn@mit.edu>
* locate_kdc.c (translate_ai_error): Handle EAI_ADDRFAMILY like
static void restore_signals(void);
static krb5_sigtype intrfunc(int sig);
-static krb5_error_code setup_tty(int);
-static krb5_error_code restore_tty(void);
+static krb5_error_code setup_tty(FILE*, int);
+static krb5_error_code restore_tty(FILE*);
#ifdef POSIX_SIGNALS
static struct sigaction osigint;
(void)fflush(stdout);
(void)memset(prompts[i].reply->data, 0, prompts[i].reply->length);
- errcode = setup_tty(prompts[i].hidden);
+ errcode = setup_tty(fp, prompts[i].hidden);
if (errcode) {
if (prompts[i].hidden)
putchar('\n');
errcode = KRB5_LIBOS_PWDINTR;
else
errcode = KRB5_LIBOS_CANTREADPWD;
- restore_tty();
+ restore_tty(fp);
break;
}
} while (scratchchar != EOF && scratchchar != '\n');
}
- errcode = restore_tty();
+ errcode = restore_tty(fp);
if (errcode)
break;
prompts[i].reply->length = strlen(prompts[i].reply->data);
static struct termios saveparm;
static krb5_error_code
-setup_tty(int hidden)
+setup_tty(FILE *fp, int hidden)
{
krb5_error_code ret;
+ int fd;
struct termios tparm;
ret = KRB5_LIBOS_CANTREADPWD;
catch_signals();
+ fd = fileno(fp);
do {
- if (!isatty(STDIN_FILENO)) {
+ if (!isatty(fd)) {
ret = 0;
break;
}
- if (tcgetattr(STDIN_FILENO, &tparm) < 0)
+ if (tcgetattr(fd, &tparm) < 0)
break;
saveparm = tparm;
#ifndef ECHO_PASSWORD
}
static krb5_error_code
-restore_tty(void)
+restore_tty(FILE* fp)
{
- int ret;
+ int ret, fd;
ret = 0;
- if (isatty(STDIN_FILENO)) {
- ret = tcsetattr(STDIN_FILENO, TCSANOW, &saveparm);
+ fd = fileno(fp);
+ if (isatty(fd)) {
+ ret = tcsetattr(fd, TCSANOW, &saveparm);
if (ret < 0)
ret = KRB5_LIBOS_CANTREADPWD;
else