Improve ssh_options_set_ssh_dir().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@354 7dcaeef0-15fb-0310-b436-a5af3365683c
Этот коммит содержится в:
родитель
4373fc64e3
Коммит
9ea6ea581d
@ -318,7 +318,7 @@ void ssh_options_set_identity(SSH_OPTIONS *opt, const char *identity);
|
|||||||
void ssh_options_set_status_callback(SSH_OPTIONS *opt, void (*callback)
|
void ssh_options_set_status_callback(SSH_OPTIONS *opt, void (*callback)
|
||||||
(void *arg, float status), void *arg);
|
(void *arg, float status), void *arg);
|
||||||
void ssh_options_set_timeout(SSH_OPTIONS *opt, long seconds, long usec);
|
void ssh_options_set_timeout(SSH_OPTIONS *opt, long seconds, long usec);
|
||||||
void ssh_options_set_ssh_dir(SSH_OPTIONS *opt, const char *dir);
|
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);
|
void 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_ssh1(SSH_OPTIONS *opt, int allow);
|
||||||
void ssh_options_allow_ssh2(SSH_OPTIONS *opt, int allow);
|
void ssh_options_allow_ssh2(SSH_OPTIONS *opt, int allow);
|
||||||
|
@ -355,18 +355,35 @@ int ssh_options_set_bind(SSH_OPTIONS *opt, const char *bindaddr, int port) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** the ssh directory is used for files like known_hosts and
|
/**
|
||||||
* identity (public and private keys)\n
|
* @brief Set the ssh directory.
|
||||||
* \brief set the ssh directory
|
*
|
||||||
* \param opt options structure
|
* The ssh directory is used for files like known_hosts and identity (public
|
||||||
* \param dir directory. It may include "%s" which will be replaced by
|
* and private keys)
|
||||||
* the user home directory
|
*
|
||||||
* \see ssh_options_set_user_home_dir()
|
* @param opt The options structure to use.
|
||||||
|
*
|
||||||
|
* @param dir The directory to set. It may include "%s" which will be
|
||||||
|
* replaced by the user home directory.
|
||||||
|
*
|
||||||
|
* @return 0 on success, < 0 on error.
|
||||||
|
*
|
||||||
|
* @see ssh_options_set_user_home_dir()
|
||||||
*/
|
*/
|
||||||
void ssh_options_set_ssh_dir(SSH_OPTIONS *opt, const char *dir){
|
int ssh_options_set_ssh_dir(SSH_OPTIONS *opt, const char *dir) {
|
||||||
char buffer[1024];
|
char buffer[1024] = {0};
|
||||||
snprintf(buffer,1024,dir,ssh_get_user_home_dir());
|
|
||||||
opt->ssh_dir=strdup(buffer);
|
if (opt == NULL || dir == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
snprintf(buffer, 1024, dir, ssh_get_user_home_dir());
|
||||||
|
opt->ssh_dir = strdup(buffer);
|
||||||
|
if (opt->ssh_dir == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** the known hosts file is used to certify remote hosts are genuine.
|
/** the known hosts file is used to certify remote hosts are genuine.
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user