- snprintf(buf, sizeof buf, "%s/%s", pw->pw_dir, SSH_CLIENT_IDENTITY);
- if (deleting)
- delete_file(ac, buf);
- else
- add_file(ac, buf);
- }
- ssh_close_authentication_connection(ac);
- exit(0);
-}
-
-#ifdef USE_EXTERNAL_ASKPASS
-int askpass(const char *filename, RSA *key, const char *saved_comment, char **comment)
-{
- int pipes[2];
- char buf[1024];
- int tmp;
- pid_t child;
- FILE *pipef;
-
- /* Check that we are X11-capable */
- if (getenv("DISPLAY") == NULL)
- exit(1);
-
- 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);
- }
-
- child = fork();
- if (child == -1) {
- fprintf(stderr, "Cannot fork: %s\n", strerror(errno));
- exit(1);
- }
-
- if (child == 0) {
- /* In child */
-
- close(pipes[0]);
- if (dup2(pipes[1], 1) ==-1) {
- fprintf(stderr, "dup2 failed: %s\n", strerror(errno));
- exit(1);
- }
-
- tmp = snprintf(buf, sizeof(buf), "Need passphrase for %s", saved_comment);
- /* skip the prompt if it won't fit */
- if ((tmp < 0) || (tmp >= sizeof(buf)))
- tmp = execlp(ASKPASS_PROGRAM, "ssh-askpass", 0);
- else
- tmp = execlp(ASKPASS_PROGRAM, "ssh-askpass", buf, 0);
-
- /* Shouldn't get this far */
- fprintf(stderr, "Executing ssh-askpass failed: %s\n", strerror(errno));
- exit(1);
- }
-
- /* In parent */
- close(pipes[1]);
-
- if ((pipef = fdopen(pipes[0], "r")) == NULL) {
- fprintf(stderr, "fdopen failed: %s\n", strerror(errno));
- exit(1);
- }
-
- /* Read passphrase back from child, abort if none presented */
- if(fgets(buf, sizeof(buf), pipef) == NULL)
- exit(1);
-
- fclose(pipef);
-
- if (strchr(buf, '\n'))
- *strchr(buf, '\n') = 0;
-
- if (waitpid(child, NULL, 0) == -1) {
- fprintf(stderr, "Waiting for child failed: %s\n",
- strerror(errno));
- exit(1);
- }
-
- /* Try password as it was presented */
- tmp = load_private_key(filename, buf, key, comment);
-
- memset(buf, 0, sizeof(buf));