]> andersk Git - openssh.git/blobdiff - readpass.c
- (dtucker) [sftp-common.c] Wrap include of util.h in an ifdef.
[openssh.git] / readpass.c
index a193d0368637e8ec3de34285f8ea91ef8ad3d59a..bd144c2e39177a15f8fd21535782b9e141de6d8e 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenBSD: readpass.c,v 1.47 2006/08/03 03:34:42 deraadt Exp $ */
 /*
  * Copyright (c) 2001 Markus Friedl.  All rights reserved.
  *
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: readpass.c,v 1.32 2005/04/23 23:43:47 dtucker Exp $");
+
+#include <sys/types.h>
+#include <sys/wait.h>
+
+#include <errno.h>
+#include <fcntl.h>
+#ifdef HAVE_PATHS_H
+# include <paths.h>
+#endif
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
 
 #include "xmalloc.h"
 #include "misc.h"
 #include "pathnames.h"
 #include "log.h"
 #include "ssh.h"
+#include "uidswap.h"
 
 static char *
 ssh_askpass(char *askpass, const char *msg)
@@ -53,8 +68,7 @@ ssh_askpass(char *askpass, const char *msg)
                return NULL;
        }
        if (pid == 0) {
-               seteuid(getuid());
-               setuid(getuid());
+               permanently_drop_suid(getuid());
                close(p[0]);
                if (dup2(p[1], STDOUT_FILENO) < 0)
                        fatal("ssh_askpass: dup2: %s", strerror(errno));
@@ -106,9 +120,10 @@ read_passphrase(const char *prompt, int flags)
        if (flags & RP_USE_ASKPASS)
                use_askpass = 1;
        else if (flags & RP_ALLOW_STDIN) {
-               if (!isatty(STDIN_FILENO))
+               if (!isatty(STDIN_FILENO)) {
                        debug("read_passphrase: stdin is not a tty");
                        use_askpass = 1;
+               }
        } else {
                rppflags |= RPP_REQUIRE_TTY;
                ttyfd = open(_PATH_TTY, O_RDWR);
This page took 0.034261 seconds and 4 git commands to generate.