Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
3cdc4cb6
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看板
提交
3cdc4cb6
编写于
3月 14, 2010
作者:
M
Matthias Bolte
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
esx: Move username and password helper functions to authhelper.c
上级
a31bc675
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
155 addition
and
94 deletion
+155
-94
po/POTFILES.in
po/POTFILES.in
+1
-0
src/Makefile.am
src/Makefile.am
+1
-0
src/esx/esx_driver.c
src/esx/esx_driver.c
+5
-4
src/esx/esx_util.c
src/esx/esx_util.c
+0
-83
src/esx/esx_util.h
src/esx/esx_util.h
+0
-7
src/util/authhelper.c
src/util/authhelper.c
+115
-0
src/util/authhelper.h
src/util/authhelper.h
+33
-0
未找到文件。
po/POTFILES.in
浏览文件 @
3cdc4cb6
...
...
@@ -55,6 +55,7 @@ src/storage/storage_driver.c
src/test/test_driver.c
src/uml/uml_conf.c
src/uml/uml_driver.c
src/util/authhelper.c
src/util/bridge.c
src/util/conf.c
src/util/hostusb.c
...
...
src/Makefile.am
浏览文件 @
3cdc4cb6
...
...
@@ -45,6 +45,7 @@ augeastest_DATA =
# These files are not related to driver APIs. Simply generic
# helper APIs for various purposes
UTIL_SOURCES
=
\
util/authhelper.c util/authhelper.h
\
util/bridge.c util/bridge.h
\
util/buf.c util/buf.h
\
util/conf.c util/conf.h
\
...
...
src/esx/esx_driver.c
浏览文件 @
3cdc4cb6
...
...
@@ -29,6 +29,7 @@
#include "internal.h"
#include "virterror_internal.h"
#include "domain_conf.h"
#include "authhelper.h"
#include "util.h"
#include "memory.h"
#include "logging.h"
...
...
@@ -354,7 +355,7 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
goto
failure
;
}
}
else
{
username
=
esxUtil_
RequestUsername
(
auth
,
"root"
,
conn
->
uri
->
server
);
username
=
vir
RequestUsername
(
auth
,
"root"
,
conn
->
uri
->
server
);
if
(
username
==
NULL
)
{
ESX_ERROR
(
VIR_ERR_AUTH_FAILED
,
"Username request failed"
);
...
...
@@ -366,7 +367,7 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
goto
failure
;
}
password
=
esxUtil_
RequestPassword
(
auth
,
username
,
conn
->
uri
->
server
);
password
=
vir
RequestPassword
(
auth
,
username
,
conn
->
uri
->
server
);
if
(
password
==
NULL
)
{
ESX_ERROR
(
VIR_ERR_AUTH_FAILED
,
"Password request failed"
);
...
...
@@ -491,14 +492,14 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
goto
failure
;
}
username
=
esxUtil_
RequestUsername
(
auth
,
"administrator"
,
vCenter
);
username
=
vir
RequestUsername
(
auth
,
"administrator"
,
vCenter
);
if
(
username
==
NULL
)
{
ESX_ERROR
(
VIR_ERR_AUTH_FAILED
,
"Username request failed"
);
goto
failure
;
}
password
=
esxUtil_
RequestPassword
(
auth
,
username
,
vCenter
);
password
=
vir
RequestPassword
(
auth
,
username
,
vCenter
);
if
(
password
==
NULL
)
{
ESX_ERROR
(
VIR_ERR_AUTH_FAILED
,
"Password request failed"
);
...
...
src/esx/esx_util.c
浏览文件 @
3cdc4cb6
...
...
@@ -49,89 +49,6 @@
char
*
esxUtil_RequestUsername
(
virConnectAuthPtr
auth
,
const
char
*
defaultUsername
,
const
char
*
hostname
)
{
unsigned
int
ncred
;
virConnectCredential
cred
;
char
*
prompt
=
NULL
;
memset
(
&
cred
,
0
,
sizeof
(
virConnectCredential
));
if
(
virAsprintf
(
&
prompt
,
"Enter username for %s [%s]"
,
hostname
,
defaultUsername
)
<
0
)
{
return
NULL
;
}
for
(
ncred
=
0
;
ncred
<
auth
->
ncredtype
;
ncred
++
)
{
if
(
auth
->
credtype
[
ncred
]
!=
VIR_CRED_AUTHNAME
)
{
continue
;
}
cred
.
type
=
VIR_CRED_AUTHNAME
;
cred
.
prompt
=
prompt
;
cred
.
challenge
=
hostname
;
cred
.
defresult
=
defaultUsername
;
cred
.
result
=
NULL
;
cred
.
resultlen
=
0
;
if
((
*
(
auth
->
cb
))(
&
cred
,
1
,
auth
->
cbdata
)
<
0
)
{
VIR_FREE
(
cred
.
result
);
}
break
;
}
VIR_FREE
(
prompt
);
return
cred
.
result
;
}
char
*
esxUtil_RequestPassword
(
virConnectAuthPtr
auth
,
const
char
*
username
,
const
char
*
hostname
)
{
unsigned
int
ncred
;
virConnectCredential
cred
;
char
*
prompt
;
memset
(
&
cred
,
0
,
sizeof
(
virConnectCredential
));
if
(
virAsprintf
(
&
prompt
,
"Enter %s password for %s"
,
username
,
hostname
)
<
0
)
{
return
NULL
;
}
for
(
ncred
=
0
;
ncred
<
auth
->
ncredtype
;
ncred
++
)
{
if
(
auth
->
credtype
[
ncred
]
!=
VIR_CRED_PASSPHRASE
&&
auth
->
credtype
[
ncred
]
!=
VIR_CRED_NOECHOPROMPT
)
{
continue
;
}
cred
.
type
=
auth
->
credtype
[
ncred
];
cred
.
prompt
=
prompt
;
cred
.
challenge
=
hostname
;
cred
.
defresult
=
NULL
;
cred
.
result
=
NULL
;
cred
.
resultlen
=
0
;
if
((
*
(
auth
->
cb
))(
&
cred
,
1
,
auth
->
cbdata
)
<
0
)
{
VIR_FREE
(
cred
.
result
);
}
break
;
}
VIR_FREE
(
prompt
);
return
cred
.
result
;
}
int
esxUtil_ParseQuery
(
xmlURIPtr
uri
,
char
**
transport
,
char
**
vCenter
,
int
*
noVerify
,
int
*
autoAnswer
)
...
...
src/esx/esx_util.h
浏览文件 @
3cdc4cb6
...
...
@@ -28,13 +28,6 @@
# include "internal.h"
# include "conf.h"
char
*
esxUtil_RequestUsername
(
virConnectAuthPtr
auth
,
const
char
*
defaultUsername
,
const
char
*
hostname
);
char
*
esxUtil_RequestPassword
(
virConnectAuthPtr
auth
,
const
char
*
username
,
const
char
*
hostname
);
int
esxUtil_ParseQuery
(
xmlURIPtr
uri
,
char
**
transport
,
char
**
vCenter
,
int
*
noVerify
,
int
*
autoAnswer
);
...
...
src/util/authhelper.c
0 → 100644
浏览文件 @
3cdc4cb6
/*
* authhelper.c: authentication related utility functions
*
* Copyright (C) 2010 Matthias Bolte <matthias.bolte@googlemail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <config.h>
#include "authhelper.h"
#include "util.h"
#include "memory.h"
char
*
virRequestUsername
(
virConnectAuthPtr
auth
,
const
char
*
defaultUsername
,
const
char
*
hostname
)
{
unsigned
int
ncred
;
virConnectCredential
cred
;
char
*
prompt
;
memset
(
&
cred
,
0
,
sizeof
(
virConnectCredential
));
if
(
defaultUsername
!=
NULL
)
{
if
(
virAsprintf
(
&
prompt
,
_
(
"Enter username for %s [%s]"
),
hostname
,
defaultUsername
)
<
0
)
{
return
NULL
;
}
}
else
{
if
(
virAsprintf
(
&
prompt
,
_
(
"Enter username for %s"
),
hostname
)
<
0
)
{
return
NULL
;
}
}
for
(
ncred
=
0
;
ncred
<
auth
->
ncredtype
;
ncred
++
)
{
if
(
auth
->
credtype
[
ncred
]
!=
VIR_CRED_AUTHNAME
)
{
continue
;
}
cred
.
type
=
VIR_CRED_AUTHNAME
;
cred
.
prompt
=
prompt
;
cred
.
challenge
=
hostname
;
cred
.
defresult
=
defaultUsername
;
cred
.
result
=
NULL
;
cred
.
resultlen
=
0
;
if
((
*
(
auth
->
cb
))(
&
cred
,
1
,
auth
->
cbdata
)
<
0
)
{
VIR_FREE
(
cred
.
result
);
}
break
;
}
VIR_FREE
(
prompt
);
return
cred
.
result
;
}
char
*
virRequestPassword
(
virConnectAuthPtr
auth
,
const
char
*
username
,
const
char
*
hostname
)
{
unsigned
int
ncred
;
virConnectCredential
cred
;
char
*
prompt
;
memset
(
&
cred
,
0
,
sizeof
(
virConnectCredential
));
if
(
virAsprintf
(
&
prompt
,
_
(
"Enter %s's password for %s"
),
username
,
hostname
)
<
0
)
{
return
NULL
;
}
for
(
ncred
=
0
;
ncred
<
auth
->
ncredtype
;
ncred
++
)
{
if
(
auth
->
credtype
[
ncred
]
!=
VIR_CRED_PASSPHRASE
&&
auth
->
credtype
[
ncred
]
!=
VIR_CRED_NOECHOPROMPT
)
{
continue
;
}
cred
.
type
=
auth
->
credtype
[
ncred
];
cred
.
prompt
=
prompt
;
cred
.
challenge
=
hostname
;
cred
.
defresult
=
NULL
;
cred
.
result
=
NULL
;
cred
.
resultlen
=
0
;
if
((
*
(
auth
->
cb
))(
&
cred
,
1
,
auth
->
cbdata
)
<
0
)
{
VIR_FREE
(
cred
.
result
);
}
break
;
}
VIR_FREE
(
prompt
);
return
cred
.
result
;
}
src/util/authhelper.h
0 → 100644
浏览文件 @
3cdc4cb6
/*
* authhelper.h: authentication related utility functions
*
* Copyright (C) 2010 Matthias Bolte <matthias.bolte@googlemail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef __VIR_AUTHHELPER_H__
# define __VIR_AUTHHELPER_H__
# include "internal.h"
char
*
virRequestUsername
(
virConnectAuthPtr
auth
,
const
char
*
defaultUsername
,
const
char
*
hostname
);
char
*
virRequestPassword
(
virConnectAuthPtr
auth
,
const
char
*
username
,
const
char
*
hostname
);
#endif
/* __VIR_AUTHHELPER_H__ */
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录