mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 14:15:28 +00:00
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: Michal Privoznik <mprivozn@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
b1aa312185
commit
4471003836
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user