Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
2ed0b3f9
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,发现更多精彩内容 >>
提交
2ed0b3f9
编写于
3月 14, 2010
作者:
M
Matthias Bolte
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
xenapi: Request a username if there is non in the URI
Use virRequestUsername and virRequestPassword.
上级
45b6e68e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
85 addition
and
35 deletion
+85
-35
src/xenapi/xenapi_driver.c
src/xenapi/xenapi_driver.c
+85
-35
未找到文件。
src/xenapi/xenapi_driver.c
浏览文件 @
2ed0b3f9
...
...
@@ -31,6 +31,7 @@
#include "domain_conf.h"
#include "virterror_internal.h"
#include "datatypes.h"
#include "authhelper.h"
#include "util.h"
#include "uuid.h"
#include "memory.h"
...
...
@@ -83,62 +84,101 @@ getCapsObject (void)
static
virDrvOpenStatus
xenapiOpen
(
virConnectPtr
conn
,
virConnectAuthPtr
auth
,
int
flags
ATTRIBUTE_UNUSED
)
{
char
*
passwd
=
NULL
;
xen_session
*
session
;
struct
_xenapiPrivate
*
privP
;
char
*
username
=
NULL
;
char
*
password
=
NULL
;
struct
_xenapiPrivate
*
privP
=
NULL
;
if
(
STRCASENEQ
(
conn
->
uri
->
scheme
,
"XenAPI"
))
{
return
VIR_DRV_OPEN_DECLINED
;
}
if
(
conn
->
uri
->
server
==
NULL
)
{
xenapiSessionErrorHandler
(
conn
,
VIR_ERR_AUTH_FAILED
,
"Server name not in URI"
);
return
VIR_DRV_OPEN_ERROR
;
xenapiSessionErrorHandler
(
conn
,
VIR_ERR_AUTH_FAILED
,
"Server name not in URI"
);
goto
error
;
}
if
(
auth
==
NULL
)
{
xenapiSessionErrorHandler
(
conn
,
VIR_ERR_AUTH_FAILED
,
"Authentication Credentials not found"
);
goto
error
;
}
if
(
auth
)
{
passwd
=
xenapiUtil_RequestPassword
(
auth
,
conn
->
uri
->
user
,
conn
->
uri
->
server
);
if
(
conn
->
uri
->
user
!=
NULL
)
{
username
=
strdup
(
conn
->
uri
->
user
);
if
(
username
==
NULL
)
{
virReportOOMError
();
goto
error
;
}
}
else
{
xenapiSessionErrorHandler
(
conn
,
VIR_ERR_AUTH_FAILED
,
"Authentication Credentials not found"
);
return
VIR_DRV_OPEN_ERROR
;
username
=
virRequestUsername
(
auth
,
NULL
,
conn
->
uri
->
server
);
if
(
username
==
NULL
)
{
xenapiSessionErrorHandler
(
conn
,
VIR_ERR_AUTH_FAILED
,
"Username request failed"
);
goto
error
;
}
}
if
(
!
passwd
||
!
conn
->
uri
->
user
)
{
xenapiSessionErrorHandler
(
conn
,
VIR_ERR_AUTH_FAILED
,
"Username/Password not valid"
);
VIR_FREE
(
passwd
);
return
VIR_DRV_OPEN_ERROR
;
password
=
virRequestPassword
(
auth
,
username
,
conn
->
uri
->
server
);
if
(
password
==
NULL
)
{
xenapiSessionErrorHandler
(
conn
,
VIR_ERR_AUTH_FAILED
,
"Password request failed"
);
goto
error
;
}
if
(
VIR_ALLOC
(
privP
)
<
0
)
{
virReportOOMError
();
return
VIR_DRV_OPEN_ERROR
;
goto
error
;
}
if
(
virAsprintf
(
&
privP
->
url
,
"https://%s"
,
conn
->
uri
->
server
)
<
0
)
{
virReportOOMError
();
VIR_FREE
(
passwd
);
return
VIR_DRV_OPEN_ERROR
;
goto
error
;
}
xenapiUtil_ParseQuery
(
conn
,
conn
->
uri
,
&
privP
->
noVerify
);
if
(
xenapiUtil_ParseQuery
(
conn
,
conn
->
uri
,
&
privP
->
noVerify
)
<
0
)
goto
error
;
if
(
!
(
privP
->
caps
=
getCapsObject
()))
{
xenapiSessionErrorHandler
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
"Capabilities not found"
);
goto
error
;
}
xmlInitParser
();
xmlKeepBlanksDefault
(
0
);
xen_init
();
curl_global_init
(
CURL_GLOBAL_ALL
);
session
=
xen_session_login_with_password
(
call_func
,
privP
,
conn
->
uri
->
user
,
passwd
,
xen_api_latest_version
);
privP
->
session
=
xen_session_login_with_password
(
call_func
,
privP
,
username
,
password
,
xen_api_latest_version
);
if
(
session
&&
session
->
ok
)
{
privP
->
session
=
session
;
if
(
!
(
privP
->
caps
=
getCapsObject
()))
{
xenapiSessionErrorHandler
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
"Capabilities not found"
);
VIR_FREE
(
passwd
);
return
VIR_DRV_OPEN_ERROR
;
}
if
(
privP
->
session
!=
NULL
&&
privP
->
session
->
ok
)
{
conn
->
privateData
=
privP
;
VIR_FREE
(
passwd
);
VIR_FREE
(
username
);
VIR_FREE
(
password
);
return
VIR_DRV_OPEN_SUCCESS
;
}
else
{
xenapiSessionErrorHandler
(
conn
,
VIR_ERR_AUTH_FAILED
,
""
);
if
(
session
)
xenSessionFree
(
session
);
}
xenapiSessionErrorHandler
(
conn
,
VIR_ERR_AUTH_FAILED
,
""
);
error:
VIR_FREE
(
username
);
VIR_FREE
(
password
);
if
(
privP
!=
NULL
)
{
if
(
privP
->
session
!=
NULL
)
xenSessionFree
(
privP
->
session
);
VIR_FREE
(
privP
);
VIR_FREE
(
passwd
);
return
VIR_DRV_OPEN_ERROR
;
}
return
VIR_DRV_OPEN_ERROR
;
}
/*
...
...
@@ -150,10 +190,20 @@ xenapiOpen (virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUS
static
int
xenapiClose
(
virConnectPtr
conn
)
{
xen_session_logout
(((
struct
_xenapiPrivate
*
)(
conn
->
privateData
))
->
session
);
virCapabilitiesFree
(((
struct
_xenapiPrivate
*
)(
conn
->
privateData
))
->
caps
);
VIR_FREE
(((
struct
_xenapiPrivate
*
)(
conn
->
privateData
))
->
url
);
VIR_FREE
(
conn
->
privateData
);
struct
_xenapiPrivate
*
priv
=
conn
->
privateData
;
virCapabilitiesFree
(
priv
->
caps
);
if
(
priv
->
session
!=
NULL
)
{
xen_session_logout
(
priv
->
session
);
xenSessionFree
(
priv
->
session
);
}
VIR_FREE
(
priv
->
url
);
VIR_FREE
(
priv
);
conn
->
privateData
=
NULL
;
return
0
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录