[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.65 and 1.66

version 1.65, 2020/10/18 11:32:01 version 1.66, 2020/11/08 22:37:24
Line 219 
Line 219 
         return (allowed);          return (allowed);
 }  }
   
   static void
   writemsg(const char *msg)
   {
           (void)write(STDERR_FILENO, "\r", 1);
           (void)write(STDERR_FILENO, msg, strlen(msg));
           (void)write(STDERR_FILENO, "\r\n", 2);
   }
   
 struct notifier_ctx {  struct notifier_ctx {
         pid_t pid;          pid_t pid;
         void (*osigchld)(int);          void (*osigchld)(int);
Line 229 
Line 237 
 {  {
         va_list args;          va_list args;
         char *prompt = NULL;          char *prompt = NULL;
         pid_t pid;          pid_t pid = -1;
         void (*osigchld)(int);          void (*osigchld)(int) = NULL;
         const char *askpass, *s;          const char *askpass, *s;
         struct notifier_ctx *ret = NULL;          struct notifier_ctx *ret = NULL;
   
Line 241 
Line 249 
         if (fflush(NULL) != 0)          if (fflush(NULL) != 0)
                 error_f("fflush: %s", strerror(errno));                  error_f("fflush: %s", strerror(errno));
         if (!force_askpass && isatty(STDERR_FILENO)) {          if (!force_askpass && isatty(STDERR_FILENO)) {
                 (void)write(STDERR_FILENO, "\r", 1);                  writemsg(prompt);
                 (void)write(STDERR_FILENO, prompt, strlen(prompt));                  goto out_ctx;
                 (void)write(STDERR_FILENO, "\r\n", 2);  
                 goto out;  
         }          }
         if ((askpass = getenv("SSH_ASKPASS")) == NULL)          if ((askpass = getenv("SSH_ASKPASS")) == NULL)
                 askpass = _PATH_SSH_ASKPASS_DEFAULT;                  askpass = _PATH_SSH_ASKPASS_DEFAULT;
Line 275 
Line 281 
                 _exit(1);                  _exit(1);
                 /* NOTREACHED */                  /* NOTREACHED */
         }          }
    out_ctx:
         if ((ret = calloc(1, sizeof(*ret))) == NULL) {          if ((ret = calloc(1, sizeof(*ret))) == NULL) {
                 kill(pid, SIGTERM);                  kill(pid, SIGTERM);
                 fatal_f("calloc failed");                  fatal_f("calloc failed");
Line 287 
Line 294 
 }  }
   
 void  void
 notify_complete(struct notifier_ctx *ctx)  notify_complete(struct notifier_ctx *ctx, const char *fmt, ...)
 {  {
         int ret;          int ret;
           char *msg = NULL;
           va_list args;
   
           if (fmt != NULL && ctx->pid == -1) {
                   /*
                    * notify_start wrote to stderr, so send conclusion message
                    * there too
                   */
                   va_start(args, fmt);
                   xvasprintf(&msg, fmt, args);
                   va_end(args);
                   writemsg(msg);
           }
   
         if (ctx == NULL || ctx->pid <= 0) {          if (ctx == NULL || ctx->pid <= 0) {
                 free(ctx);                  free(ctx);

Legend:
Removed from v.1.65  
changed lines
  Added in v.1.66