[BACK]Return to readpass.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / ssh

Diff for /src/usr.bin/ssh/readpass.c between version 1.1 and 1.2

version 1.1, 1999/09/26 20:53:37 version 1.2, 1999/09/30 05:03:05
Line 20 
Line 20 
 #include "ssh.h"  #include "ssh.h"
   
 /* Saved old terminal mode for read_passphrase. */  /* Saved old terminal mode for read_passphrase. */
 #ifdef USING_TERMIOS  
 static struct termios saved_tio;  static struct termios saved_tio;
 #endif  
 #ifdef USING_SGTTY  
 static struct sgttyb saved_tio;  
 #endif  
   
 /* Old interrupt signal handler for read_passphrase. */  /* Old interrupt signal handler for read_passphrase. */
 static RETSIGTYPE (*old_handler)(int sig) = NULL;  static RETSIGTYPE (*old_handler)(int sig) = NULL;
Line 35 
Line 30 
 RETSIGTYPE intr_handler(int sig)  RETSIGTYPE intr_handler(int sig)
 {  {
   /* Restore terminal modes. */    /* Restore terminal modes. */
 #ifdef USING_TERMIOS  
   tcsetattr(fileno(stdin), TCSANOW, &saved_tio);    tcsetattr(fileno(stdin), TCSANOW, &saved_tio);
 #endif  
 #ifdef USING_SGTTY  
   ioctl(fileno(stdin), TIOCSETP, &saved_tio);  
 #endif  
   /* Restore the old signal handler. */    /* Restore the old signal handler. */
   signal(sig, old_handler);    signal(sig, old_handler);
   /* Resend the signal, with the old handler. */    /* Resend the signal, with the old handler. */
Line 55 
Line 45 
 char *read_passphrase(const char *prompt, int from_stdin)  char *read_passphrase(const char *prompt, int from_stdin)
 {  {
   char buf[1024], *cp;    char buf[1024], *cp;
 #ifdef USING_TERMIOS  
   struct termios tio;    struct termios tio;
 #endif  
 #ifdef USING_SGTTY  
   struct sgttyb tio;  
 #endif  
   FILE *f;    FILE *f;
   
   if (from_stdin)    if (from_stdin)
Line 105 
Line 90 
   fflush(stderr);    fflush(stderr);
   
   /* Get terminal modes. */    /* Get terminal modes. */
 #ifdef USING_TERMIOS  
   tcgetattr(fileno(f), &tio);    tcgetattr(fileno(f), &tio);
 #endif  
 #ifdef USING_SGTTY  
   ioctl(fileno(f), TIOCGETP, &tio);  
 #endif  
   saved_tio = tio;    saved_tio = tio;
   /* Save signal handler and set the new handler. */    /* Save signal handler and set the new handler. */
   old_handler = signal(SIGINT, intr_handler);    old_handler = signal(SIGINT, intr_handler);
   
   /* Set new terminal modes disabling all echo. */    /* Set new terminal modes disabling all echo. */
 #ifdef USING_TERMIOS  
   tio.c_lflag &= ~(ECHO | ECHOE | ECHOK | ECHONL);    tio.c_lflag &= ~(ECHO | ECHOE | ECHOK | ECHONL);
   tcsetattr(fileno(f), TCSANOW, &tio);    tcsetattr(fileno(f), TCSANOW, &tio);
 #endif  
 #ifdef USING_SGTTY  
   tio.sg_flags &= ~(ECHO);  
   ioctl(fileno(f), TIOCSETP, &tio);  
 #endif  
   
   /* Read the passphrase from the terminal. */    /* Read the passphrase from the terminal. */
   if (fgets(buf, sizeof(buf), f) == NULL)    if (fgets(buf, sizeof(buf), f) == NULL)
     {      {
       /* Got EOF.  Just exit. */        /* Got EOF.  Just exit. */
       /* Restore terminal modes. */        /* Restore terminal modes. */
 #ifdef USING_TERMIOS  
       tcsetattr(fileno(f), TCSANOW, &saved_tio);        tcsetattr(fileno(f), TCSANOW, &saved_tio);
 #endif  
 #ifdef USING_SGTTY  
       ioctl(fileno(f), TIOCSETP, &saved_tio);  
 #endif  
       /* Restore the signal handler. */        /* Restore the signal handler. */
       signal(SIGINT, old_handler);        signal(SIGINT, old_handler);
       /* Print a newline (the prompt probably didn\'t have one). */        /* Print a newline (the prompt probably didn\'t have one). */
Line 146 
Line 115 
       exit(1);        exit(1);
     }      }
   /* Restore terminal modes. */    /* Restore terminal modes. */
 #ifdef USING_TERMIOS  
   tcsetattr(fileno(f), TCSANOW, &saved_tio);    tcsetattr(fileno(f), TCSANOW, &saved_tio);
 #endif  
 #ifdef USING_SGTTY  
   ioctl(fileno(f), TIOCSETP, &saved_tio);  
 #endif  
   /* Restore the signal handler. */    /* Restore the signal handler. */
   (void)signal(SIGINT, old_handler);    (void)signal(SIGINT, old_handler);
   /* Remove newline from the passphrase. */    /* Remove newline from the passphrase. */

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2