util: make generic identity accessors private

Only expose the type safe getters/setters to other code in preparation
for changing the internal storage of data.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrangé
2019-07-26 12:21:29 +01:00
parent 3caf033916
commit 1bbc53c264
5 changed files with 46 additions and 89 deletions

View File

@@ -53,9 +53,9 @@ static int testIdentity(const void *opaque ATTRIBUTE_UNUSED)
virNetServerClientPtr client = NULL;
virIdentityPtr ident = NULL;
const char *gotUsername = NULL;
const char *gotUserID = NULL;
uid_t gotUserID;
const char *gotGroupname = NULL;
const char *gotGroupID = NULL;
gid_t gotGroupID;
const char *gotSELinuxContext = NULL;
if (socketpair(PF_UNIX, SOCK_STREAM, 0, sv) < 0) {
@@ -85,9 +85,7 @@ static int testIdentity(const void *opaque ATTRIBUTE_UNUSED)
goto cleanup;
}
if (virIdentityGetAttr(ident,
VIR_IDENTITY_ATTR_USER_NAME,
&gotUsername) < 0) {
if (virIdentityGetUserName(ident, &gotUsername) < 0) {
fprintf(stderr, "Missing username in identity\n");
goto cleanup;
}
@@ -97,21 +95,17 @@ static int testIdentity(const void *opaque ATTRIBUTE_UNUSED)
goto cleanup;
}
if (virIdentityGetAttr(ident,
VIR_IDENTITY_ATTR_UNIX_USER_ID,
&gotUserID) < 0) {
if (virIdentityGetUNIXUserID(ident, &gotUserID) < 0) {
fprintf(stderr, "Missing user ID in identity\n");
goto cleanup;
}
if (STRNEQ_NULLABLE("666", gotUserID)) {
fprintf(stderr, "Want username '666' got '%s'\n",
NULLSTR(gotUserID));
if (666 != gotUserID) {
fprintf(stderr, "Want username '666' got '%llu'\n",
(unsigned long long)gotUserID);
goto cleanup;
}
if (virIdentityGetAttr(ident,
VIR_IDENTITY_ATTR_GROUP_NAME,
&gotGroupname) < 0) {
if (virIdentityGetGroupName(ident, &gotGroupname) < 0) {
fprintf(stderr, "Missing groupname in identity\n");
goto cleanup;
}
@@ -121,21 +115,17 @@ static int testIdentity(const void *opaque ATTRIBUTE_UNUSED)
goto cleanup;
}
if (virIdentityGetAttr(ident,
VIR_IDENTITY_ATTR_UNIX_GROUP_ID,
&gotGroupID) < 0) {
if (virIdentityGetUNIXGroupID(ident, &gotGroupID) < 0) {
fprintf(stderr, "Missing group ID in identity\n");
goto cleanup;
}
if (STRNEQ_NULLABLE("7337", gotGroupID)) {
fprintf(stderr, "Want groupname '7337' got '%s'\n",
NULLSTR(gotGroupID));
if (7337 != gotGroupID) {
fprintf(stderr, "Want groupname '7337' got '%llu'\n",
(unsigned long long)gotGroupID);
goto cleanup;
}
if (virIdentityGetAttr(ident,
VIR_IDENTITY_ATTR_SELINUX_CONTEXT,
&gotSELinuxContext) < 0) {
if (virIdentityGetSELinuxContext(ident, &gotSELinuxContext) < 0) {
fprintf(stderr, "Missing SELinux context in identity\n");
goto cleanup;
}