1
1

Improve ssh_options_set_identity().

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

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

@ -314,12 +314,12 @@ int ssh_options_getopt(SSH_OPTIONS *options, int *argcptr, char **argv);
int ssh_options_set_host(SSH_OPTIONS *opt, const char *host);
int ssh_options_set_fd(SSH_OPTIONS *opt, socket_t fd);
int ssh_options_set_bind(SSH_OPTIONS *opt, const char *bindaddr, int port);
void ssh_options_set_identity(SSH_OPTIONS *opt, const char *identity);
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);
int ssh_options_set_known_hosts_file(SSH_OPTIONS *opt, const char *dir);
int ssh_options_set_identity(SSH_OPTIONS *opt, const char *identity);
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);

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

@ -412,17 +412,35 @@ int ssh_options_set_known_hosts_file(SSH_OPTIONS *opt, const char *dir){
return 0;
}
/** the identity file is used authenticate with public key.
* \brief set the identity file name
* \param opt options structure
* \param identity 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 identity file name.
*
* The identity file is used authenticate with public key.
*
* @param opt The options structure to use.
*
* @param identity 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_identity(SSH_OPTIONS *opt, const char *identity){
char buffer[1024];
snprintf(buffer,1024,identity,ssh_get_user_home_dir());
opt->identity=strdup(buffer);
int ssh_options_set_identity(SSH_OPTIONS *opt, const char *identity){
char buffer[1024] = {0};
if (opt == NULL || identity == NULL) {
return -1;
}
snprintf(buffer, 1024, identity, ssh_get_user_home_dir());
SAFE_FREE(opt->identity);
opt->identity = strdup(buffer);
if (opt->identity == NULL) {
return -1;
}
return 0;
}
/** \warning I don't remember what these functions are supposed