提交 44710038 编写于 作者: D Daniel P. Berrangé

util: allow identity to be imported/exported as typed parameters

Add ability to import/export all the parameters associated with an
identity, so that they can be exposed via the public API.
Reviewed-by: NMichal Privoznik <mprivozn@redhat.com>
Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
上级 b1aa3121
......@@ -2144,6 +2144,7 @@ virHostGetBootTime;
# util/viridentity.h
virIdentityGetCurrent;
virIdentityGetGroupName;
virIdentityGetParameters;
virIdentityGetProcessID;
virIdentityGetProcessTime;
virIdentityGetSASLUserName;
......@@ -2156,6 +2157,7 @@ virIdentityGetX509DName;
virIdentityNew;
virIdentitySetCurrent;
virIdentitySetGroupName;
virIdentitySetParameters;
virIdentitySetProcessID;
virIdentitySetProcessTime;
virIdentitySetSASLUserName;
......
......@@ -36,6 +36,7 @@
#include "virutil.h"
#include "virstring.h"
#include "virprocess.h"
#include "virtypedparam.h"
#define VIR_FROM_THIS VIR_FROM_IDENTITY
......@@ -545,3 +546,58 @@ int virIdentitySetSELinuxContext(virIdentityPtr ident,
VIR_CONNECT_IDENTITY_SELINUX_CONTEXT,
context);
}
int virIdentitySetParameters(virIdentityPtr ident,
virTypedParameterPtr params,
int nparams)
{
if (virTypedParamsValidate(params, nparams,
VIR_CONNECT_IDENTITY_USER_NAME,
VIR_TYPED_PARAM_STRING,
VIR_CONNECT_IDENTITY_UNIX_USER_ID,
VIR_TYPED_PARAM_ULLONG,
VIR_CONNECT_IDENTITY_GROUP_NAME,
VIR_TYPED_PARAM_STRING,
VIR_CONNECT_IDENTITY_UNIX_GROUP_ID,
VIR_TYPED_PARAM_ULLONG,
VIR_CONNECT_IDENTITY_PROCESS_ID,
VIR_TYPED_PARAM_LLONG,
VIR_CONNECT_IDENTITY_PROCESS_TIME,
VIR_TYPED_PARAM_ULLONG,
VIR_CONNECT_IDENTITY_SASL_USER_NAME,
VIR_TYPED_PARAM_STRING,
VIR_CONNECT_IDENTITY_X509_DISTINGUISHED_NAME,
VIR_TYPED_PARAM_STRING,
VIR_CONNECT_IDENTITY_SELINUX_CONTEXT,
VIR_TYPED_PARAM_STRING,
NULL) < 0)
return -1;
virTypedParamsFree(ident->params, ident->nparams);
ident->params = NULL;
ident->nparams = 0;
ident->maxparams = 0;
if (virTypedParamsCopy(&ident->params, params, nparams) < 0)
return -1;
ident->nparams = nparams;
ident->maxparams = nparams;
return 0;
}
int virIdentityGetParameters(virIdentityPtr ident,
virTypedParameterPtr *params,
int *nparams)
{
*params = NULL;
*nparams = 0;
if (virTypedParamsCopy(params, ident->params, ident->nparams) < 0)
return -1;
*nparams = ident->nparams;
return 0;
}
......@@ -71,3 +71,11 @@ int virIdentitySetX509DName(virIdentityPtr ident,
const char *dname);
int virIdentitySetSELinuxContext(virIdentityPtr ident,
const char *context);
int virIdentitySetParameters(virIdentityPtr ident,
virTypedParameterPtr params,
int nparams);
int virIdentityGetParameters(virIdentityPtr ident,
virTypedParameterPtr *params,
int *nparams);
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册