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 | 54 ++++++++++++++++++++++++++++++++++++++++
src/util/viridentity.h | 8 ++++++
3 files changed, 64 insertions(+)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index d42a939f5d..a33b84efe0 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2143,6 +2143,7 @@ virIdentityGetOSProcessID;
virIdentityGetOSProcessTime;
virIdentityGetOSUserID;
virIdentityGetOSUserName;
+virIdentityGetParameters;
virIdentityGetSASLUserName;
virIdentityGetSELinuxContext;
virIdentityGetSystem;
@@ -2155,6 +2156,7 @@ virIdentitySetOSProcessID;
virIdentitySetOSProcessTime;
virIdentitySetOSUserID;
virIdentitySetOSUserName;
+virIdentitySetParameters;
virIdentitySetSASLUserName;
virIdentitySetSELinuxContext;
virIdentitySetX509DName;
diff --git a/src/util/viridentity.c b/src/util/viridentity.c
index 5324400650..461e41ec3d 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
@@ -532,3 +533,56 @@ 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_OS_USER_NAME,
+ VIR_TYPED_PARAM_STRING,
+ VIR_CONNECT_IDENTITY_OS_USER_ID,
+ VIR_TYPED_PARAM_ULLONG,
+ VIR_CONNECT_IDENTITY_OS_GROUP_NAME,
+ VIR_TYPED_PARAM_STRING,
+ VIR_CONNECT_IDENTITY_OS_GROUP_ID,
+ VIR_TYPED_PARAM_ULLONG,
+ VIR_CONNECT_IDENTITY_OS_PROCESS_ID,
+ VIR_TYPED_PARAM_LLONG,
+ VIR_CONNECT_IDENTITY_OS_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;
+ if (virTypedParamsCopy(&ident->params, params, nparams) < 0)
+ return -1;
+ ident->nparams = 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 6dc0393810..edb838cf17 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