Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
028c3088
L
libvirt
项目概览
openeuler
/
libvirt
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
libvirt
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
028c3088
编写于
5月 06, 2011
作者:
C
Cole Robinson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remote: Convert SSH tunnel to virCommand
上级
b3ecd780
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
18 addition
and
47 deletion
+18
-47
src/remote/remote_driver.c
src/remote/remote_driver.c
+18
-47
未找到文件。
src/remote/remote_driver.c
浏览文件 @
028c3088
...
...
@@ -426,8 +426,8 @@ doRemoteOpen (virConnectPtr conn,
char
*
name
=
NULL
,
*
command
=
NULL
,
*
sockname
=
NULL
,
*
netcat
=
NULL
;
char
*
port
=
NULL
,
*
authtype
=
NULL
,
*
username
=
NULL
;
int
no_verify
=
0
,
no_tty
=
0
;
char
**
cmd_argv
=
NULL
;
char
*
pkipath
=
NULL
;
virCommandPtr
cmd
=
NULL
;
/* Return code from this function, and the private data. */
int
retcode
=
VIR_DRV_OPEN_ERROR
;
...
...
@@ -741,50 +741,26 @@ doRemoteOpen (virConnectPtr conn,
}
case
trans_ssh
:
{
int
j
,
nr_args
=
6
;
if
(
username
)
nr_args
+=
2
;
/* For -l username */
if
(
no_tty
)
nr_args
+=
5
;
/* For -T -o BatchMode=yes -e none */
if
(
port
)
nr_args
+=
2
;
/* For -p port */
command
=
command
?
command
:
strdup
(
"ssh"
);
if
(
command
==
NULL
)
goto
out_of_memory
;
cmd
=
virCommandNew
(
command
?
command
:
"ssh"
);
/* Generate the final command argv[] array.
* ssh [-p $port] [-l $username] $hostname $netcat -U $sockname [NULL] */
if
(
VIR_ALLOC_N
(
cmd_argv
,
nr_args
)
<
0
)
goto
out_of_memory
;
* ssh [-p $port] [-l $username] $hostname $netcat -U $sockname */
j
=
0
;
cmd_argv
[
j
++
]
=
strdup
(
command
);
if
(
port
)
{
cmd_argv
[
j
++
]
=
strdup
(
"-p"
);
cmd_argv
[
j
++
]
=
strdup
(
port
);
virCommandAddArgList
(
cmd
,
"-p"
,
port
,
NULL
);
}
if
(
username
)
{
cmd_argv
[
j
++
]
=
strdup
(
"-l"
);
cmd_argv
[
j
++
]
=
strdup
(
username
);
virCommandAddArgList
(
cmd
,
"-l"
,
username
,
NULL
);
}
if
(
no_tty
)
{
cmd_argv
[
j
++
]
=
strdup
(
"-T"
);
cmd_argv
[
j
++
]
=
strdup
(
"-o"
);
cmd_argv
[
j
++
]
=
strdup
(
"BatchMode=yes"
);
cmd_argv
[
j
++
]
=
strdup
(
"-e"
);
cmd_argv
[
j
++
]
=
strdup
(
"none"
);
virCommandAddArgList
(
cmd
,
"-T"
,
"-o"
,
"BatchMode=yes"
,
"-e"
,
"none"
,
NULL
);
}
cmd_argv
[
j
++
]
=
strdup
(
priv
->
hostname
);
cmd_argv
[
j
++
]
=
strdup
(
netcat
?
netcat
:
"nc"
);
cmd_argv
[
j
++
]
=
strdup
(
"-U"
);
cmd_argv
[
j
++
]
=
strdup
(
sockname
?
sockname
:
(
flags
&
VIR_CONNECT_RO
?
LIBVIRTD_PRIV_UNIX_SOCKET_RO
:
LIBVIRTD_PRIV_UNIX_SOCKET
));
cmd_argv
[
j
++
]
=
0
;
assert
(
j
==
nr_args
);
for
(
j
=
0
;
j
<
(
nr_args
-
1
);
j
++
)
if
(
cmd_argv
[
j
]
==
NULL
)
goto
out_of_memory
;
virCommandAddArgList
(
cmd
,
priv
->
hostname
,
netcat
?
netcat
:
"nc"
,
"-U"
,
(
sockname
?
sockname
:
(
flags
&
VIR_CONNECT_RO
?
LIBVIRTD_PRIV_UNIX_SOCKET_RO
:
LIBVIRTD_PRIV_UNIX_SOCKET
)),
NULL
);
priv
->
is_secure
=
1
;
}
...
...
@@ -811,9 +787,11 @@ doRemoteOpen (virConnectPtr conn,
goto
failed
;
}
if
(
virExec
((
const
char
**
)
cmd_argv
,
NULL
,
NULL
,
&
pid
,
sv
[
1
],
&
(
sv
[
1
]),
&
(
errfd
[
1
]),
VIR_EXEC_CLEAR_CAPS
)
<
0
)
virCommandSetInputFD
(
cmd
,
sv
[
1
]);
virCommandSetOutputFD
(
cmd
,
&
(
sv
[
1
]));
virCommandSetErrorFD
(
cmd
,
&
(
errfd
[
1
]));
virCommandClearCaps
(
cmd
);
if
(
virCommandRunAsync
(
cmd
,
&
pid
)
<
0
)
goto
failed
;
/* Parent continues here. */
...
...
@@ -942,14 +920,7 @@ doRemoteOpen (virConnectPtr conn,
VIR_FREE
(
netcat
);
VIR_FREE
(
username
);
VIR_FREE
(
port
);
if
(
cmd_argv
)
{
char
**
cmd_argv_ptr
=
cmd_argv
;
while
(
*
cmd_argv_ptr
)
{
VIR_FREE
(
*
cmd_argv_ptr
);
cmd_argv_ptr
++
;
}
VIR_FREE
(
cmd_argv
);
}
virCommandFree
(
cmd
);
VIR_FREE
(
pkipath
);
return
retcode
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录