* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
* All rights reserved
- * Created: Sat Mar 18 22:15:47 1995 ylo
* Code to connect to a remote host, and to perform the client side of the
* login (authentication) dialog.
+ *
+ * As far as I am concerned, the code I have written for this software
+ * can be used freely for any purpose. Any derived versions of this
+ * software must be clearly marked as such, and if the derived work is
+ * incompatible with the protocol description in the RFC file, it must be
+ * called by a name other than "ssh" or "Secure Shell".
*/
#include "includes.h"
-RCSID("$OpenBSD: sshconnect.c,v 1.76 2000/06/17 20:30:10 markus Exp $");
+RCSID("$OpenBSD: sshconnect.c,v 1.79 2000/09/17 15:52:51 markus Exp $");
#include <openssl/bn.h>
#include <openssl/dsa.h>
/* Stderr is left as it is so that error messages get
printed on the user's terminal. */
- argv[0] = "/bin/sh";
+ argv[0] = _PATH_BSHELL;
argv[1] = "-c";
argv[2] = command_string;
argv[3] = NULL;
/* Execute the proxy command. Note that we gave up any
extra privileges above. */
- execv("/bin/sh", argv);
- perror("/bin/sh");
+ execv(_PATH_BSHELL, argv);
+ perror(_PATH_BSHELL);
exit(1);
}
/* Parent. */
int gaierr;
struct linger linger;
- debug("ssh_connect: getuid %d geteuid %d anon %d",
- (int) getuid(), (int) geteuid(), anonymous);
+ debug("ssh_connect: getuid %u geteuid %u anon %d",
+ (u_int) getuid(), (u_int) geteuid(), anonymous);
/* Get default port if port has not been set. */
if (port == 0) {
/* Create a socket for connecting. */
sock = ssh_create_socket(original_real_uid,
+#ifdef HAVE_CYGWIN
+ !anonymous && port < IPPORT_RESERVED,
+#else
!anonymous && geteuid() == 0 && port < IPPORT_RESERVED,
+#endif
ai->ai_family);
if (sock < 0)
continue;
retval = defval;
if (strcmp(buf, "yes") == 0)
retval = 1;
- if (strcmp(buf, "no") == 0)
+ else if (strcmp(buf, "no") == 0)
retval = 0;
+ else
+ fprintf(stderr, "Please type 'yes' or 'no'.\n");
if (retval != -1) {
if (f != stdin)
/* Get local user name. Use it as server user if no user name was given. */
pw = getpwuid(original_real_uid);
if (!pw)
- fatal("User id %d not found from user database.", original_real_uid);
+ fatal("User id %u not found from user database.", original_real_uid);
local_user = xstrdup(pw->pw_name);
server_user = options.user ? options.user : local_user;