}
-/**
- * virIdentityIsEqual:
- * @identA: the first identity
- * @identB: the second identity
- *
- * Compares every attribute in @identA and @identB
- * to determine if they refer to the same identity
- *
- * Returns true if they are equal, false if not equal
- */
-bool virIdentityIsEqual(virIdentityPtr identA,
- virIdentityPtr identB)
-{
- bool ret = false;
- size_t i;
- VIR_DEBUG("identA=%p identB=%p", identA, identB);
-
- for (i = 0; i < VIR_IDENTITY_ATTR_LAST; i++) {
- if (STRNEQ_NULLABLE(identA->attrs[i],
- identB->attrs[i]))
- goto cleanup;
- }
-
- ret = true;
- cleanup:
- return ret;
-}
-
-
int virIdentityGetUserName(virIdentityPtr ident,
const char **username)
{
}
-static int testIdentityEqual(const void *data ATTRIBUTE_UNUSED)
-{
- int ret = -1;
- virIdentityPtr identa = NULL;
- virIdentityPtr identb = NULL;
-
- if (!(identa = virIdentityNew()))
- goto cleanup;
- if (!(identb = virIdentityNew()))
- goto cleanup;
-
- if (!virIdentityIsEqual(identa, identb)) {
- VIR_DEBUG("Empty identities were not equal");
- goto cleanup;
- }
-
- if (virIdentitySetUserName(identa, "fred") < 0)
- goto cleanup;
-
- if (virIdentityIsEqual(identa, identb)) {
- VIR_DEBUG("Mis-matched identities should not be equal");
- goto cleanup;
- }
-
- if (virIdentitySetUserName(identb, "fred") < 0)
- goto cleanup;
-
- if (!virIdentityIsEqual(identa, identb)) {
- VIR_DEBUG("Matched identities were not equal");
- goto cleanup;
- }
-
- if (virIdentitySetGroupName(identa, "flintstone") < 0)
- goto cleanup;
- if (virIdentitySetGroupName(identb, "flintstone") < 0)
- goto cleanup;
-
- if (!virIdentityIsEqual(identa, identb)) {
- VIR_DEBUG("Matched identities were not equal");
- goto cleanup;
- }
-
- if (virIdentitySetSASLUserName(identb, "fred@FLINTSTONE.COM") < 0)
- goto cleanup;
-
- if (virIdentityIsEqual(identa, identb)) {
- VIR_DEBUG("Mis-matched identities should not be equal");
- goto cleanup;
- }
-
- ret = 0;
- cleanup:
- virObjectUnref(identa);
- virObjectUnref(identb);
- return ret;
-}
-
static int testIdentityGetSystem(const void *data)
{
const char *context = data;
if (virTestRun("Identity attributes ", testIdentityAttrs, NULL) < 0)
ret = -1;
- if (virTestRun("Identity equality ", testIdentityEqual, NULL) < 0)
- ret = -1;
if (virTestRun("Setting fake SELinux context ", testSetFakeSELinuxContext, context) < 0)
ret = -1;
if (virTestRun("System identity (fake SELinux enabled) ", testIdentityGetSystem, context) < 0)