diff --git a/readconf.c b/readconf.c index 6d05210..f74bf70 100644 --- a/readconf.c +++ b/readconf.c @@ -294,6 +294,11 @@ static struct { { NULL, oBadOption } }; +#ifdef WIN32_FIXME +char user_hostfile_name[MAX_PATH] ; // full path of "known_hosts" +char user_hostfile_name2[MAX_PATH] ; // full path of "known_hosts2" +#endif + /* * Adds a local TCP/IP port forward to options. Never returns if there is an * error. @@ -379,7 +384,7 @@ clear_forwardings(Options *options) void add_identity_file(Options *options, const char *dir, const char *filename, - int userprovided) + int userprovided, struct passwd *pw) { char *path; int i; @@ -391,7 +396,12 @@ add_identity_file(Options *options, const char *dir, const char *filename, if (dir == NULL) /* no dir, filename is absolute */ path = xstrdup(filename); else + #ifndef WIN32_FIXME (void)xasprintf(&path, "%.100s%.100s", dir, filename); + #else + if ( strcmp(dir, "~/") == 0) + (void)xasprintf(&path, "%.100s\\%.100s", pw->pw_dir, filename); + #endif /* Avoid registering duplicates */ for (i = 0; i < options->num_identity_files; i++) { @@ -995,7 +1005,7 @@ parse_time: fatal("%.200s line %d: Too many identity files specified (max %d).", filename, linenum, SSH_MAX_IDENTITY_FILES); add_identity_file(options, NULL, - arg, flags & SSHCONF_USERCONF); + arg, flags & SSHCONF_USERCONF, pw); } break; @@ -1748,9 +1758,18 @@ fill_default_options_for_canonicalization(Options *options) * Called after processing other sources of option data, this fills those * options for which no value has been specified with their default values. */ +#ifndef WIN32_FIXME void fill_default_options(Options * options) +#else +void fill_default_options(Options * options, struct passwd *pw) +#endif { + #ifdef WIN32_FIXME + sprintf(user_hostfile_name,"%s\\%s\\known_hosts", pw->pw_dir, _PATH_SSH_USER_DIR );// SSH_USER_HOSTFILE2; + sprintf(user_hostfile_name2,"%s\\%s\\known_hosts2", pw->pw_dir, _PATH_SSH_USER_DIR );// SSH_USER_HOSTFILE2; + #endif + if (options->forward_agent == -1) options->forward_agent = 0; if (options->forward_x11 == -1) @@ -1818,19 +1837,19 @@ fill_default_options(Options * options) if (options->num_identity_files == 0) { if (options->protocol & SSH_PROTO_1) { add_identity_file(options, "~/", - _PATH_SSH_CLIENT_IDENTITY, 0); + _PATH_SSH_CLIENT_IDENTITY, 0, pw); } if (options->protocol & SSH_PROTO_2) { add_identity_file(options, "~/", - _PATH_SSH_CLIENT_ID_RSA, 0); + _PATH_SSH_CLIENT_ID_RSA, 0, pw); add_identity_file(options, "~/", - _PATH_SSH_CLIENT_ID_DSA, 0); + _PATH_SSH_CLIENT_ID_DSA, 0, pw); #ifdef OPENSSL_HAS_ECC add_identity_file(options, "~/", - _PATH_SSH_CLIENT_ID_ECDSA, 0); + _PATH_SSH_CLIENT_ID_ECDSA, 0, pw); #endif add_identity_file(options, "~/", - _PATH_SSH_CLIENT_ID_ED25519, 0); + _PATH_SSH_CLIENT_ID_ED25519, 0, pw); } } if (options->escape_char == -1) @@ -1843,9 +1862,17 @@ fill_default_options(Options * options) } if (options->num_user_hostfiles == 0) { options->user_hostfiles[options->num_user_hostfiles++] = + #ifdef WIN32_FIXME + user_hostfile_name ; + #else xstrdup(_PATH_SSH_USER_HOSTFILE); + #endif options->user_hostfiles[options->num_user_hostfiles++] = + #ifdef WIN32_FIXME + user_hostfile_name2 ; + #else xstrdup(_PATH_SSH_USER_HOSTFILE2); + #endif } if (options->log_level == SYSLOG_LEVEL_NOT_SET) options->log_level = SYSLOG_LEVEL_INFO; diff --git a/readconf.h b/readconf.h index 9946168..6ae35c8 100644 --- a/readconf.h +++ b/readconf.h @@ -189,7 +189,11 @@ typedef struct { #define SSH_UPDATE_HOSTKEYS_ASK 2 void initialize_options(Options *); +#ifdef WIN32_FIXME +void fill_default_options(Options *, struct passwd *pw); +#else void fill_default_options(Options *); +#endif void fill_default_options_for_canonicalization(Options *); int process_config_line(Options *, struct passwd *, const char *, const char *, char *, const char *, int, int *, int); @@ -202,6 +206,6 @@ void dump_client_config(Options *o, const char *host); void add_local_forward(Options *, const struct Forward *); void add_remote_forward(Options *, const struct Forward *); -void add_identity_file(Options *, const char *, const char *, int); +void add_identity_file(Options *, const char *, const char *, int, struct passwd *); #endif /* READCONF_H */ diff --git a/runconfigure b/runconfigure index 8387298..9cd8982 100644 --- a/runconfigure +++ b/runconfigure @@ -1 +1,2 @@ -./configure --build=i686-pc-mingw32 --host=i686-pc-mingw32 --with-ssl-dir=../openssl-1.0.2d --with-zlib=../zlib-1.2.8 --with-kerberos5 \ No newline at end of file +@REM ./configure --build=i686-pc-mingw32 --host=i686-pc-mingw32 --with-ssl-dir=../openssl-1.0.2d --with-zlib=../zlib-1.2.8 --with-kerberos5 +./configure --build=i686-pc-mingw32 --host=i686-pc-mingw32 --with-ssl-dir=../openssl-1.0.2d --with-kerberos5 \ No newline at end of file diff --git a/ssh-keysign.c b/ssh-keysign.c index 1dca3e2..7b8bba8 100644 --- a/ssh-keysign.c +++ b/ssh-keysign.c @@ -209,7 +209,13 @@ main(int argc, char **argv) /* verify that ssh-keysign is enabled by the admin */ initialize_options(&options); (void)read_config_file(_PATH_HOST_CONFIG_FILE, pw, "", "", &options, 0); + + #ifndef WIN32_FIXME fill_default_options(&options); + #else + fill_default_options(&options, pw); + #endif + if (options.enable_ssh_keysign != 1) fatal("ssh-keysign not enabled in %s", _PATH_HOST_CONFIG_FILE); diff --git a/ssh.c b/ssh.c index 86350c0..24c013b 100644 --- a/ssh.c +++ b/ssh.c @@ -126,6 +126,8 @@ extern int PassInputFd; extern int PassOutputFd; + char dotsshdir[MAX_PATH]; + #endif /* WIN32_FIXME */ extern char *__progname; @@ -587,6 +589,7 @@ main(int ac, char **av) char cname[NI_MAXHOST]; struct stat st; struct passwd *pw; + int timeout_ms; extern int optind, optreset; extern char *optarg; @@ -811,7 +814,7 @@ main(int ac, char **av) strerror(errno)); break; } - add_identity_file(&options, NULL, optarg, 1); + add_identity_file(&options, NULL, optarg, 1, pw); break; case 'I': #ifdef ENABLE_PKCS11 @@ -1055,6 +1058,10 @@ main(int ac, char **av) PassOutputFd = _open_osfhandle(options.passOutputHandle_, O_WRONLY); } + // create various Windows user home directory based file names + sprintf(dotsshdir,"%s\\%s", pw->pw_dir, _PATH_SSH_USER_DIR ); + _mkdir(dotsshdir); //this base directory for the user is needed + #endif /* Check that we got a host name. */ @@ -1189,7 +1196,11 @@ main(int ac, char **av) } /* Fill configuration defaults. */ + #ifndef WIN32_FIXME fill_default_options(&options); + #else + fill_default_options(&options, pw); + #endif if (options.port == 0) options.port = default_ssh_port();