mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-11 18:50:28 +09:00
Improve ssh_options_default_ssh_dir().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@361 7dcaeef0-15fb-0310-b436-a5af3365683c
This commit is contained in:
@@ -548,10 +548,6 @@ static char *get_username_from_uid(SSH_OPTIONS *opt, uid_t uid){
|
|||||||
int ssh_options_default_username(SSH_OPTIONS *opt) {
|
int ssh_options_default_username(SSH_OPTIONS *opt) {
|
||||||
char *user = NULL;
|
char *user = NULL;
|
||||||
|
|
||||||
if (opt == NULL) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (opt->username) {
|
if (opt->username) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -579,12 +575,19 @@ int ssh_options_default_username(SSH_OPTIONS *opt) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ssh_options_default_ssh_dir(SSH_OPTIONS *opt){
|
int ssh_options_default_ssh_dir(SSH_OPTIONS *opt) {
|
||||||
char buffer[256];
|
char buffer[256] = {0};
|
||||||
if(opt->ssh_dir)
|
|
||||||
|
if (opt->ssh_dir) {
|
||||||
return 0;
|
return 0;
|
||||||
snprintf(buffer,256,"%s/.ssh/",ssh_get_user_home_dir());
|
}
|
||||||
opt->ssh_dir=strdup(buffer);
|
|
||||||
|
snprintf(buffer, 256, "%s/.ssh/", ssh_get_user_home_dir());
|
||||||
|
opt->ssh_dir = strdup(buffer);
|
||||||
|
if (opt->ssh_dir == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user