2003-12-19 Ken Raeburn <raeburn@mit.edu>
+ * prompter.c (catch_signals, restore_signals): Take pointer to old
+ signal handler info as new argument.
+ (osiginfo): New typedef.
+ (setup_tty, restore_tty): Take pointer to old signal handler info
+ and old termios settings as new arguments.
+ (krb5_prompter_posix): Pass the extra arguments, addresses of new
+ automatic variables.
+ (osigint, saveparm): Variables deleted.
+
* Makefile.in (STLIBOBJS, OBJS, SRCS): Don't build promptusr.c.
* sendto_kdc.c (default_debug_handler, put, putstr): Define only
#include <termios.h>
-static void catch_signals(void);
-static void restore_signals(void);
-static krb5_sigtype intrfunc(int sig);
-
-static krb5_error_code setup_tty(FILE*, int);
-static krb5_error_code restore_tty(FILE*);
-
#ifdef POSIX_SIGNALS
-static struct sigaction osigint;
+typedef struct sigaction osiginfo;
#else
-static krb5_sigtype (*osigint)();
+typedef struct krb5_sigtype (*osiginfo)();
#endif
-static volatile int got_int;
+static void catch_signals(osiginfo *);
+static void restore_signals(osiginfo *);
+static krb5_sigtype intrfunc(int sig);
+
+static krb5_error_code setup_tty(FILE*, int, struct termios *, osiginfo *);
+static krb5_error_code restore_tty(FILE*, struct termios *, osiginfo *);
+
+static volatile int got_int; /* should be sig_atomic_t */
krb5_error_code KRB5_CALLCONV
krb5_prompter_posix(
FILE *fp;
char *retp;
krb5_error_code errcode;
+ struct termios saveparm;
+ osiginfo osigint;
errcode = KRB5_LIBOS_CANTREADPWD;
if (prompts[i].reply->length > INT_MAX)
goto cleanup;
- errcode = setup_tty(fp, prompts[i].hidden);
+ errcode = setup_tty(fp, prompts[i].hidden, &saveparm, &osigint);
if (errcode)
break;
errcode = KRB5_LIBOS_PWDINTR;
else
errcode = KRB5_LIBOS_CANTREADPWD;
- restore_tty(fp);
+ restore_tty(fp, &saveparm, &osigint);
break;
}
} while (scratchchar != EOF && scratchchar != '\n');
}
- errcode = restore_tty(fp);
+ errcode = restore_tty(fp, &saveparm, &osigint);
if (errcode)
break;
prompts[i].reply->length = strlen(prompts[i].reply->data);
}
static void
-catch_signals(void)
+catch_signals(osiginfo *osigint)
{
#ifdef POSIX_SIGNALS
struct sigaction sa;
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
sa.sa_handler = intrfunc;
- sigaction(SIGINT, &sa, &osigint);
+ sigaction(SIGINT, &sa, osigint);
#else
- osigint = signal(SIGINT, intrfunc);
+ *osigint = signal(SIGINT, intrfunc);
#endif
}
static void
-restore_signals(void)
+restore_signals(osiginfo *osigint)
{
#ifdef POSIX_SIGNALS
- sigaction(SIGINT, &osigint, NULL);
+ sigaction(SIGINT, osigint, NULL);
#else
- signal(SIGINT, osigint);
+ signal(SIGINT, *osigint);
#endif
}
-static struct termios saveparm;
-
static krb5_error_code
-setup_tty(FILE *fp, int hidden)
+setup_tty(FILE *fp, int hidden, struct termios *saveparm, osiginfo *osigint)
{
krb5_error_code ret;
int fd;
struct termios tparm;
ret = KRB5_LIBOS_CANTREADPWD;
- catch_signals();
+ catch_signals(osigint);
fd = fileno(fp);
do {
if (!isatty(fd)) {
}
if (tcgetattr(fd, &tparm) < 0)
break;
- saveparm = tparm;
+ *saveparm = tparm;
#ifndef ECHO_PASSWORD
if (hidden)
tparm.c_lflag &= ~(ECHO|ECHONL);
} while (0);
/* If we're losing, restore signal handlers. */
if (ret)
- restore_signals();
+ restore_signals(osigint);
return ret;
}
static krb5_error_code
-restore_tty(FILE* fp)
+restore_tty(FILE* fp, struct termios *saveparm, osiginfo *osigint)
{
int ret, fd;
ret = 0;
fd = fileno(fp);
if (isatty(fd)) {
- ret = tcsetattr(fd, TCSANOW, &saveparm);
+ ret = tcsetattr(fd, TCSANOW, saveparm);
if (ret < 0)
ret = KRB5_LIBOS_CANTREADPWD;
else
ret = 0;
}
- restore_signals();
+ restore_signals(osigint);
return ret;
}