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
f26d92a4
Commit
f26d92a4
authored
Jul 27, 2023
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ssh: exec with paths for OpenSSH
Handle custom paths for OpenSSH.
parent
3eb7ff2b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
22 deletions
+55
-22
src/libgit2/transports/ssh.c
+27
-20
src/libgit2/transports/ssh_exec.c
+28
-2
No files found.
src/libgit2/transports/ssh.c
View file @
f26d92a4
...
...
@@ -24,7 +24,31 @@ int git_smart_subtransport_ssh(
GIT_UNUSED
(
owner
);
GIT_UNUSED
(
param
);
git_error_set
(
GIT_ERROR_INVALID
,
"cannot create SSH transport. Library was built without SSH support"
);
git_error_set
(
GIT_ERROR_INVALID
,
"cannot create SSH transport; library was built without SSH support"
);
return
-
1
;
#endif
}
static
int
transport_set_paths
(
git_transport
*
t
,
git_strarray
*
paths
)
{
transport_smart
*
smart
=
(
transport_smart
*
)
t
;
#ifdef GIT_SSH_LIBSSH2
return
git_smart_subtransport_ssh_libssh2_set_paths
(
(
git_smart_subtransport
*
)
smart
->
wrapped
,
paths
->
strings
[
0
],
paths
->
strings
[
1
]);
#elif GIT_SSH_EXEC
return
git_smart_subtransport_ssh_exec_set_paths
(
(
git_smart_subtransport
*
)
smart
->
wrapped
,
paths
->
strings
[
0
],
paths
->
strings
[
1
]);
#else
GIT_UNUSED
(
t
);
GIT_UNUSED
(
smart
);
GIT_UNUSED
(
paths
);
GIT_ASSERT
(
!
"cannot create SSH library; library was built without SSH support"
);
return
-
1
;
#endif
}
...
...
@@ -34,16 +58,14 @@ int git_transport_ssh_with_paths(
git_remote
*
owner
,
void
*
payload
)
{
#ifdef GIT_SSH_LIBSSH2
git_strarray
*
paths
=
(
git_strarray
*
)
payload
;
git_transport
*
transport
;
transport_smart
*
smart
;
int
error
;
git_smart_subtransport_definition
ssh_definition
=
{
git_smart_subtransport_ssh
,
0
,
/* no RPC */
NULL
,
NULL
};
if
(
paths
->
count
!=
2
)
{
...
...
@@ -54,25 +76,10 @@ int git_transport_ssh_with_paths(
if
((
error
=
git_transport_smart
(
&
transport
,
owner
,
&
ssh_definition
))
<
0
)
return
error
;
smart
=
(
transport_smart
*
)
transport
;
if
((
error
=
git_smart_subtransport_ssh_libssh2_set_paths
(
(
git_smart_subtransport
*
)
smart
->
wrapped
,
paths
->
strings
[
0
],
paths
->
strings
[
1
]))
<
0
)
if
((
error
=
transport_set_paths
(
transport
,
paths
))
<
0
)
return
error
;
*
out
=
transport
;
return
0
;
#elif GIT_SSH_EXEC
abort
();
#else
GIT_UNUSED
(
out
);
GIT_UNUSED
(
owner
);
GIT_UNUSED
(
payload
);
git_error_set
(
GIT_ERROR_INVALID
,
"cannot create SSH transport. Library was built without SSH support"
);
return
-
1
;
#endif
}
src/libgit2/transports/ssh_exec.c
View file @
f26d92a4
...
...
@@ -28,6 +28,9 @@ typedef struct {
ssh_exec_subtransport_stream
*
current_stream
;
char
*
cmd_uploadpack
;
char
*
cmd_receivepack
;
git_smart_service_t
action
;
git_process
*
process
;
}
ssh_exec_subtransport
;
...
...
@@ -173,10 +176,12 @@ static int start_ssh(
switch
(
action
)
{
case
GIT_SERVICE_UPLOADPACK_LS
:
command
=
"git-upload-pack"
;
command
=
transport
->
cmd_uploadpack
?
transport
->
cmd_uploadpack
:
"git-upload-pack"
;
break
;
case
GIT_SERVICE_RECEIVEPACK_LS
:
command
=
"git-receive-pack"
;
command
=
transport
->
cmd_receivepack
?
transport
->
cmd_receivepack
:
"git-receive-pack"
;
break
;
default
:
git_error_set
(
GIT_ERROR_NET
,
"invalid action"
);
...
...
@@ -277,6 +282,8 @@ static void ssh_exec_subtransport_free(git_smart_subtransport *t)
{
ssh_exec_subtransport
*
transport
=
(
ssh_exec_subtransport
*
)
t
;
git__free
(
transport
->
cmd_uploadpack
);
git__free
(
transport
->
cmd_receivepack
);
git__free
(
transport
);
}
...
...
@@ -301,4 +308,23 @@ int git_smart_subtransport_ssh_exec(
return
0
;
}
int
git_smart_subtransport_ssh_exec_set_paths
(
git_smart_subtransport
*
subtransport
,
const
char
*
cmd_uploadpack
,
const
char
*
cmd_receivepack
)
{
ssh_exec_subtransport
*
t
=
(
ssh_exec_subtransport
*
)
subtransport
;
git__free
(
t
->
cmd_uploadpack
);
git__free
(
t
->
cmd_receivepack
);
t
->
cmd_uploadpack
=
git__strdup
(
cmd_uploadpack
);
GIT_ERROR_CHECK_ALLOC
(
t
->
cmd_uploadpack
);
t
->
cmd_receivepack
=
git__strdup
(
cmd_receivepack
);
GIT_ERROR_CHECK_ALLOC
(
t
->
cmd_receivepack
);
return
0
;
}
#endif
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