1
1

Improve ssh_options_set_known_hosts_file().

git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@355 7dcaeef0-15fb-0310-b436-a5af3365683c
Этот коммит содержится в:
Andreas Schneider 2009-04-02 12:04:56 +00:00
родитель 9ea6ea581d
Коммит 5ba2acde0a
2 изменённых файлов: 29 добавлений и 11 удалений

Просмотреть файл

@ -319,7 +319,7 @@ void ssh_options_set_status_callback(SSH_OPTIONS *opt, void (*callback)
(void *arg, float status), void *arg);
void ssh_options_set_timeout(SSH_OPTIONS *opt, long seconds, long usec);
int ssh_options_set_ssh_dir(SSH_OPTIONS *opt, const char *dir);
void ssh_options_set_known_hosts_file(SSH_OPTIONS *opt, const char *dir);
int ssh_options_set_known_hosts_file(SSH_OPTIONS *opt, const char *dir);
void ssh_options_allow_ssh1(SSH_OPTIONS *opt, int allow);
void ssh_options_allow_ssh2(SSH_OPTIONS *opt, int allow);
void ssh_options_set_dsa_server_key(SSH_OPTIONS *opt, const char *dsakey);

Просмотреть файл

@ -386,17 +386,35 @@ int ssh_options_set_ssh_dir(SSH_OPTIONS *opt, const char *dir) {
return 0;
}
/** the known hosts file is used to certify remote hosts are genuine.
* \brief set the known hosts file name
* \param opt options structure
* \param dir path to the file including its name. "%s" will be substitued
* with the user home directory
* \see ssh_options_set_user_home_dir()
/**
* @brief Set the known hosts file name.
*
* The known hosts file is used to certify remote hosts are genuine.
*
* @param opt The options structure to use.
*
* @param dir The path to the file including its name. "%s" will be
* substitued with the user home directory.
*
* @return 0 on success, < 0 on error.
*
* @see ssh_options_set_user_home_dir()
*/
void ssh_options_set_known_hosts_file(SSH_OPTIONS *opt, const char *dir){
char buffer[1024];
snprintf(buffer,1024,dir,ssh_get_user_home_dir());
opt->known_hosts_file=strdup(buffer);
int ssh_options_set_known_hosts_file(SSH_OPTIONS *opt, const char *dir){
char buffer[1024] = {0};
if (opt == NULL || dir == NULL) {
return -1;
}
snprintf(buffer, 1024, dir, ssh_get_user_home_dir());
SAFE_FREE(opt->known_hosts_file);
opt->known_hosts_file = strdup(buffer);
if (opt->known_hosts_file == NULL) {
return -1;
}
return 0;
}
/** the identity file is used authenticate with public key.