Re: OpenSSH uploaded replacing ssh, please test
On Wed, Nov 03, 1999 at 03:19:00AM +0000, Philip Hands wrote:
> It doesn't know about ssh-askpass, so if you normally use that,
> you'll have to use ssh-add in an xterm instead.
Here's a patch to make it use ssh-askpass, now someone
needs to provide a free ssh-askpass too..
--
Havoc Consulting | unix, linux, perl, mail, www, internet, security consulting
+358 50 5486010 | software development, unix administration, training
diff -r openssh-1.2pre7.orig/ssh-add.c openssh-1.2pre7.tv/ssh-add.c
54a55
> #define BUFSIZE 1024
61a63,67
> int pipes[2];
> char buf[BUFSIZE];
> int tmp;
> pid_t child;
> FILE *pipef;
83,84c89,154
< xfree(saved_comment);
< return;
---
> if (pipe(pipes) ==-1)
> {
> fprintf(stderr, "Creating pipes failed: %s\n", strerror(errno));
> exit(1);
> }
> if (fflush(NULL)==EOF)
> {
> fprintf(stderr, "Cannot flush buffers: %s\n", strerror(errno));
> exit(1);
> }
> switch (child=fork())
> {
> case -1:
> fprintf(stderr, "Cannot fork: %s\n", strerror(errno));
> exit(1);
> case 0:
> close(pipes[0]);
> if (dup2(pipes[1], 1) ==-1)
> {
> fprintf(stderr, "dup2 failed: %s\n", strerror(errno));
> exit(1);
> }
> tmp=snprintf(buf, BUFSIZE, "Need passphrase for %s (%s)",
> filename, saved_comment);
> /* skip the prompt if it won't fit */
> if (tmp < 0 || tmp >= BUFSIZE)
> tmp=execlp("ssh-askpass", "ssh-askpass", 0);
> else
> tmp=execlp("ssh-askpass", "ssh-askpass", buf, 0);
> if (tmp==-1)
> {
> fprintf(stderr, "Executing ssh-askpass failed: %s\n",
> strerror(errno));
> exit(1);
> }
> break;
> default:
> close(pipes[1]);
> if ( (pipef=fdopen(pipes[0], "r")) ==NULL)
> {
> fprintf(stderr, "fdopen failed: %s\n", strerror(errno));
> exit(1);
> }
> if(fgets(buf, sizeof(buf), pipef)==NULL)
> {
> xfree(saved_comment);
> return;
> }
> fclose(pipef);
> if (strchr(buf, '\n'))
> *strchr(buf, '\n') = 0;
> pass = xstrdup(buf);
> memset(buf, 0, sizeof(buf));
> if (waitpid(child, NULL, 0) ==-1)
> {
> fprintf(stderr, "Waiting for child failed: %s\n",
> strerror(errno));
> exit(1);
> }
> if (strcmp(pass, "") == 0)
> {
> xfree(saved_comment);
> xfree(pass);
> return;
> }
> }
Reply to: