Add ability to import/export all the parameters associated with an
identity, so that they can be exposed via the public API.
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
src/libvirt_private.syms | 2 ++
src/util/viridentity.c | 56 ++++++++++++++++++++++++++++++++++++++++
src/util/viridentity.h | 8 ++++++
3 files changed, 66 insertions(+)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index fec1787497..a406aef0ae 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -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;
diff --git a/src/util/viridentity.c b/src/util/viridentity.c
index 30621ca2a4..22e2644c19 100644
--- a/src/util/viridentity.c
+++ b/src/util/viridentity.c
@@ -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;
+}
diff --git a/src/util/viridentity.h b/src/util/viridentity.h
index 805ad3ea4d..861ecca736 100644
--- a/src/util/viridentity.h
+++ b/src/util/viridentity.h
@@ -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);
--
2.21.0