Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
3eed595e
Commit
3eed595e
authored
May 05, 2013
by
Brad Morgan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactoring
parent
d9766959
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
25 deletions
+64
-25
src/transports/ssh.c
+64
-25
No files found.
src/transports/ssh.c
View file @
3eed595e
...
...
@@ -254,13 +254,50 @@ static int _git_ssh_authenticate_session(
break
;
}
default:
rc
=
-
1
;
rc
=
LIBSSH2_ERROR_AUTHENTICATION_FAILED
;
}
}
while
(
LIBSSH2_ERROR_EAGAIN
==
rc
||
LIBSSH2_ERROR_TIMEOUT
==
rc
);
return
rc
;
}
static
int
_git_ssh_session_create
(
LIBSSH2_SESSION
**
session
,
gitno_socket
socket
)
{
if
(
!
session
)
{
return
-
1
;
}
LIBSSH2_SESSION
*
s
=
libssh2_session_init
();
if
(
!
s
)
return
-
1
;
int
rc
=
0
;
do
{
rc
=
libssh2_session_startup
(
s
,
socket
.
socket
);
}
while
(
LIBSSH2_ERROR_EAGAIN
==
rc
||
LIBSSH2_ERROR_TIMEOUT
==
rc
);
if
(
0
!=
rc
)
{
goto
on_error
;
}
libssh2_session_set_blocking
(
s
,
1
);
*
session
=
s
;
return
0
;
on_error:
if
(
s
)
{
libssh2_session_free
(
s
),
s
=
NULL
;
}
return
-
1
;
}
static
int
_git_ssh_setup_conn
(
ssh_subtransport
*
t
,
const
char
*
url
,
...
...
@@ -268,9 +305,11 @@ static int _git_ssh_setup_conn(
git_smart_subtransport_stream
**
stream
)
{
char
*
host
,
*
port
,
*
user
=
NULL
,
*
pass
=
NULL
;
const
char
*
default_port
=
"22"
;
char
*
host
,
*
port
=
NULL
,
*
user
=
NULL
,
*
pass
=
NULL
;
const
char
*
default_port
=
"22"
;
ssh_stream
*
s
;
LIBSSH2_SESSION
*
session
=
NULL
;
LIBSSH2_CHANNEL
*
channel
=
NULL
;
*
stream
=
NULL
;
if
(
ssh_stream_alloc
(
t
,
url
,
cmd
,
stream
)
<
0
)
...
...
@@ -307,34 +346,15 @@ static int _git_ssh_setup_conn(
user
=
git__strdup
(
default_user
);
}
LIBSSH2_SESSION
*
session
=
libssh2_session_init
();
if
(
!
session
)
goto
on_error
;
int
rc
=
0
;
do
{
rc
=
libssh2_session_startup
(
session
,
s
->
socket
.
socket
);
}
while
(
LIBSSH2_ERROR_EAGAIN
==
rc
||
LIBSSH2_ERROR_TIMEOUT
==
rc
);
if
(
0
!=
rc
)
{
if
(
_git_ssh_session_create
(
&
session
,
s
->
socket
)
<
0
)
goto
on_error
;
}
libssh2_trace
(
session
,
0x1FF
);
libssh2_session_set_blocking
(
session
,
1
);
if
(
_git_ssh_authenticate_session
(
session
,
user
,
t
->
cred
)
<
0
)
{
if
(
_git_ssh_authenticate_session
(
session
,
user
,
t
->
cred
)
<
0
)
goto
on_error
;
}
LIBSSH2_CHANNEL
*
channel
=
NULL
;
do
{
channel
=
libssh2_channel_open_session
(
session
);
}
while
(
LIBSSH2_ERROR_EAGAIN
==
rc
||
LIBSSH2_ERROR_TIMEOUT
==
rc
);
if
(
!
channel
)
{
if
(
!
channel
)
goto
on_error
;
}
libssh2_channel_set_blocking
(
channel
,
1
);
...
...
@@ -343,6 +363,14 @@ static int _git_ssh_setup_conn(
t
->
current_stream
=
s
;
git__free
(
host
);
git__free
(
port
);
if
(
user
)
{
git__free
(
user
);
}
if
(
pass
)
{
git__free
(
pass
);
}
return
0
;
on_error:
...
...
@@ -350,6 +378,17 @@ on_error:
ssh_stream_free
(
*
stream
);
git__free
(
host
);
git__free
(
port
);
if
(
user
)
{
git__free
(
user
);
}
if
(
pass
)
{
git__free
(
pass
);
}
if
(
session
)
{
libssh2_session_free
(
session
),
session
=
NULL
;
}
return
-
1
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment