[PATCH 2/9] util: change identity class attribute names

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Remove the "UNIX" tag from the names for user name, group name,
process ID and process time, since these attributes are all usable
for non-UNIX platforms like Windows.

User ID and group ID are left with a "UNIX" tag, since there's no
equivalent on Windows. The closest equivalent concept on Windows,
SID, is a struct containing a number of integer fields, which is
commonly represented in string format instead. This would require
a separate attribute, and is left for a future exercise, since
the daemons are not currently built on Windows anyway.

Signed-off-by: Daniel P. Berrangé <berrange@xxxxxxxxxx>
---
 src/access/viraccessdriverpolkit.c |  8 ++---
 src/admin/admin_server.c           |  6 ++--
 src/libvirt_private.syms           | 16 ++++-----
 src/rpc/virnetserverclient.c       |  8 ++---
 src/util/viridentity.c             | 56 +++++++++++++++---------------
 src/util/viridentity.h             | 40 ++++++++++-----------
 tests/viridentitytest.c            | 18 +++++-----
 tests/virnetserverclienttest.c     |  4 +--
 8 files changed, 78 insertions(+), 78 deletions(-)

diff --git a/src/access/viraccessdriverpolkit.c b/src/access/viraccessdriverpolkit.c
index b1473cd0a4..75dbf8a0fa 100644
--- a/src/access/viraccessdriverpolkit.c
+++ b/src/access/viraccessdriverpolkit.c
@@ -88,14 +88,14 @@ virAccessDriverPolkitGetCaller(const char *actionid,
         return -1;
     }
 
-    if (virIdentityGetUNIXProcessID(identity, pid) < 0) {
+    if (virIdentityGetProcessID(identity, pid) < 0) {
         virAccessError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("No UNIX process ID available"));
+                       _("No process ID available"));
         goto cleanup;
     }
-    if (virIdentityGetUNIXProcessTime(identity, startTime) < 0) {
+    if (virIdentityGetProcessTime(identity, startTime) < 0) {
         virAccessError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("No UNIX process start time available"));
+                       _("No process start time available"));
         goto cleanup;
     }
     if (virIdentityGetUNIXUserID(identity, uid) < 0) {
diff --git a/src/admin/admin_server.c b/src/admin/admin_server.c
index f2a38f6dfa..80e5a36679 100644
--- a/src/admin/admin_server.c
+++ b/src/admin/admin_server.c
@@ -262,7 +262,7 @@ adminClientGetInfo(virNetServerClientPtr client,
                                  VIR_CLIENT_INFO_UNIX_USER_ID, uid) < 0)
             goto cleanup;
 
-        if (virIdentityGetUNIXUserName(identity, &attr) < 0 ||
+        if (virIdentityGetUserName(identity, &attr) < 0 ||
             virTypedParamsAddString(&tmpparams, nparams, &maxparams,
                                     VIR_CLIENT_INFO_UNIX_USER_NAME,
                                     attr) < 0)
@@ -273,13 +273,13 @@ adminClientGetInfo(virNetServerClientPtr client,
                                  VIR_CLIENT_INFO_UNIX_GROUP_ID, gid) < 0)
             goto cleanup;
 
-        if (virIdentityGetUNIXGroupName(identity, &attr) < 0 ||
+        if (virIdentityGetGroupName(identity, &attr) < 0 ||
             virTypedParamsAddString(&tmpparams, nparams, &maxparams,
                                     VIR_CLIENT_INFO_UNIX_GROUP_NAME,
                                     attr) < 0)
             goto cleanup;
 
-        if (virIdentityGetUNIXProcessID(identity, &pid) < 0 ||
+        if (virIdentityGetProcessID(identity, &pid) < 0 ||
             virTypedParamsAddInt(&tmpparams, nparams, &maxparams,
                                  VIR_CLIENT_INFO_UNIX_PROCESS_ID, pid) < 0)
             goto cleanup;
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index a34d92f5ef..a46d9a9165 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2144,28 +2144,28 @@ virHostGetBootTime;
 # util/viridentity.h
 virIdentityGetAttr;
 virIdentityGetCurrent;
+virIdentityGetGroupName;
+virIdentityGetProcessID;
+virIdentityGetProcessTime;
 virIdentityGetSASLUserName;
 virIdentityGetSELinuxContext;
 virIdentityGetSystem;
 virIdentityGetUNIXGroupID;
-virIdentityGetUNIXGroupName;
-virIdentityGetUNIXProcessID;
-virIdentityGetUNIXProcessTime;
 virIdentityGetUNIXUserID;
-virIdentityGetUNIXUserName;
+virIdentityGetUserName;
 virIdentityGetX509DName;
 virIdentityIsEqual;
 virIdentityNew;
 virIdentitySetAttr;
 virIdentitySetCurrent;
+virIdentitySetGroupName;
+virIdentitySetProcessID;
+virIdentitySetProcessTime;
 virIdentitySetSASLUserName;
 virIdentitySetSELinuxContext;
 virIdentitySetUNIXGroupID;
-virIdentitySetUNIXGroupName;
-virIdentitySetUNIXProcessID;
-virIdentitySetUNIXProcessTime;
 virIdentitySetUNIXUserID;
-virIdentitySetUNIXUserName;
+virIdentitySetUserName;
 virIdentitySetX509DName;
 
 
diff --git a/src/rpc/virnetserverclient.c b/src/rpc/virnetserverclient.c
index 410de253d2..1b96d0339b 100644
--- a/src/rpc/virnetserverclient.c
+++ b/src/rpc/virnetserverclient.c
@@ -779,21 +779,21 @@ virNetServerClientCreateIdentity(virNetServerClientPtr client)
 
         if (!(username = virGetUserName(uid)))
             goto error;
-        if (virIdentitySetUNIXUserName(ret, username) < 0)
+        if (virIdentitySetUserName(ret, username) < 0)
             goto error;
         if (virIdentitySetUNIXUserID(ret, uid) < 0)
             goto error;
 
         if (!(groupname = virGetGroupName(gid)))
             goto error;
-        if (virIdentitySetUNIXGroupName(ret, groupname) < 0)
+        if (virIdentitySetGroupName(ret, groupname) < 0)
             goto error;
         if (virIdentitySetUNIXGroupID(ret, gid) < 0)
             goto error;
 
-        if (virIdentitySetUNIXProcessID(ret, pid) < 0)
+        if (virIdentitySetProcessID(ret, pid) < 0)
             goto error;
-        if (virIdentitySetUNIXProcessTime(ret, timestamp) < 0)
+        if (virIdentitySetProcessTime(ret, timestamp) < 0)
             goto error;
     }
 
diff --git a/src/util/viridentity.c b/src/util/viridentity.c
index 4ceff3cb74..d920152c08 100644
--- a/src/util/viridentity.c
+++ b/src/util/viridentity.c
@@ -144,25 +144,25 @@ virIdentityPtr virIdentityGetSystem(void)
     if (!(ret = virIdentityNew()))
         goto error;
 
-    if (virIdentitySetUNIXProcessID(ret, getpid()) < 0)
+    if (virIdentitySetProcessID(ret, getpid()) < 0)
         goto error;
 
     if (virProcessGetStartTime(getpid(), &startTime) < 0)
         goto error;
     if (startTime != 0 &&
-        virIdentitySetUNIXProcessTime(ret, startTime) < 0)
+        virIdentitySetProcessTime(ret, startTime) < 0)
         goto error;
 
     if (!(username = virGetUserName(geteuid())))
         return ret;
-    if (virIdentitySetUNIXUserName(ret, username) < 0)
+    if (virIdentitySetUserName(ret, username) < 0)
         goto error;
     if (virIdentitySetUNIXUserID(ret, getuid()) < 0)
         goto error;
 
     if (!(groupname = virGetGroupName(getegid())))
         return ret;
-    if (virIdentitySetUNIXGroupName(ret, groupname) < 0)
+    if (virIdentitySetGroupName(ret, groupname) < 0)
         goto error;
     if (virIdentitySetUNIXGroupID(ret, getgid()) < 0)
         goto error;
@@ -310,11 +310,11 @@ bool virIdentityIsEqual(virIdentityPtr identA,
 }
 
 
-int virIdentityGetUNIXUserName(virIdentityPtr ident,
-                               const char **username)
+int virIdentityGetUserName(virIdentityPtr ident,
+                           const char **username)
 {
     return virIdentityGetAttr(ident,
-                              VIR_IDENTITY_ATTR_UNIX_USER_NAME,
+                              VIR_IDENTITY_ATTR_USER_NAME,
                               username);
 }
 
@@ -342,11 +342,11 @@ int virIdentityGetUNIXUserID(virIdentityPtr ident,
     return 0;
 }
 
-int virIdentityGetUNIXGroupName(virIdentityPtr ident,
-                                const char **groupname)
+int virIdentityGetGroupName(virIdentityPtr ident,
+                            const char **groupname)
 {
     return virIdentityGetAttr(ident,
-                              VIR_IDENTITY_ATTR_UNIX_GROUP_NAME,
+                              VIR_IDENTITY_ATTR_GROUP_NAME,
                               groupname);
 }
 
@@ -375,15 +375,15 @@ int virIdentityGetUNIXGroupID(virIdentityPtr ident,
 }
 
 
-int virIdentityGetUNIXProcessID(virIdentityPtr ident,
-                                pid_t *pid)
+int virIdentityGetProcessID(virIdentityPtr ident,
+                            pid_t *pid)
 {
     unsigned long long val;
     const char *processid;
 
     *pid = 0;
     if (virIdentityGetAttr(ident,
-                           VIR_IDENTITY_ATTR_UNIX_PROCESS_ID,
+                           VIR_IDENTITY_ATTR_PROCESS_ID,
                            &processid) < 0)
         return -1;
 
@@ -399,12 +399,12 @@ int virIdentityGetUNIXProcessID(virIdentityPtr ident,
 }
 
 
-int virIdentityGetUNIXProcessTime(virIdentityPtr ident,
-                                  unsigned long long *timestamp)
+int virIdentityGetProcessTime(virIdentityPtr ident,
+                              unsigned long long *timestamp)
 {
     const char *processtime;
     if (virIdentityGetAttr(ident,
-                           VIR_IDENTITY_ATTR_UNIX_PROCESS_TIME,
+                           VIR_IDENTITY_ATTR_PROCESS_TIME,
                            &processtime) < 0)
         return -1;
 
@@ -445,11 +445,11 @@ int virIdentityGetSELinuxContext(virIdentityPtr ident,
 }
 
 
-int virIdentitySetUNIXUserName(virIdentityPtr ident,
-                               const char *username)
+int virIdentitySetUserName(virIdentityPtr ident,
+                           const char *username)
 {
     return virIdentitySetAttr(ident,
-                              VIR_IDENTITY_ATTR_UNIX_USER_NAME,
+                              VIR_IDENTITY_ATTR_USER_NAME,
                               username);
 }
 
@@ -468,11 +468,11 @@ int virIdentitySetUNIXUserID(virIdentityPtr ident,
 }
 
 
-int virIdentitySetUNIXGroupName(virIdentityPtr ident,
-                                const char *groupname)
+int virIdentitySetGroupName(virIdentityPtr ident,
+                            const char *groupname)
 {
     return virIdentitySetAttr(ident,
-                              VIR_IDENTITY_ATTR_UNIX_GROUP_NAME,
+                              VIR_IDENTITY_ATTR_GROUP_NAME,
                               groupname);
 }
 
@@ -491,8 +491,8 @@ int virIdentitySetUNIXGroupID(virIdentityPtr ident,
 }
 
 
-int virIdentitySetUNIXProcessID(virIdentityPtr ident,
-                                pid_t pid)
+int virIdentitySetProcessID(virIdentityPtr ident,
+                            pid_t pid)
 {
     VIR_AUTOFREE(char *) val = NULL;
 
@@ -500,13 +500,13 @@ int virIdentitySetUNIXProcessID(virIdentityPtr ident,
         return -1;
 
     return virIdentitySetAttr(ident,
-                              VIR_IDENTITY_ATTR_UNIX_PROCESS_ID,
+                              VIR_IDENTITY_ATTR_PROCESS_ID,
                               val);
 }
 
 
-int virIdentitySetUNIXProcessTime(virIdentityPtr ident,
-                                  unsigned long long timestamp)
+int virIdentitySetProcessTime(virIdentityPtr ident,
+                              unsigned long long timestamp)
 {
     VIR_AUTOFREE(char *) val = NULL;
 
@@ -514,7 +514,7 @@ int virIdentitySetUNIXProcessTime(virIdentityPtr ident,
         return -1;
 
     return virIdentitySetAttr(ident,
-                              VIR_IDENTITY_ATTR_UNIX_PROCESS_TIME,
+                              VIR_IDENTITY_ATTR_PROCESS_TIME,
                               val);
 }
 
diff --git a/src/util/viridentity.h b/src/util/viridentity.h
index 0fde3207ca..e66e60dbf3 100644
--- a/src/util/viridentity.h
+++ b/src/util/viridentity.h
@@ -27,12 +27,12 @@ typedef struct _virIdentity virIdentity;
 typedef virIdentity *virIdentityPtr;
 
 typedef enum {
-      VIR_IDENTITY_ATTR_UNIX_USER_NAME,
+      VIR_IDENTITY_ATTR_USER_NAME,
       VIR_IDENTITY_ATTR_UNIX_USER_ID,
-      VIR_IDENTITY_ATTR_UNIX_GROUP_NAME,
+      VIR_IDENTITY_ATTR_GROUP_NAME,
       VIR_IDENTITY_ATTR_UNIX_GROUP_ID,
-      VIR_IDENTITY_ATTR_UNIX_PROCESS_ID,
-      VIR_IDENTITY_ATTR_UNIX_PROCESS_TIME,
+      VIR_IDENTITY_ATTR_PROCESS_ID,
+      VIR_IDENTITY_ATTR_PROCESS_TIME,
       VIR_IDENTITY_ATTR_SASL_USER_NAME,
       VIR_IDENTITY_ATTR_X509_DISTINGUISHED_NAME,
       VIR_IDENTITY_ATTR_SELINUX_CONTEXT,
@@ -64,18 +64,18 @@ bool virIdentityIsEqual(virIdentityPtr identA,
     ATTRIBUTE_NONNULL(1)
     ATTRIBUTE_NONNULL(2);
 
-int virIdentityGetUNIXUserName(virIdentityPtr ident,
-                               const char **username);
+int virIdentityGetUserName(virIdentityPtr ident,
+                           const char **username);
 int virIdentityGetUNIXUserID(virIdentityPtr ident,
                              uid_t *uid);
-int virIdentityGetUNIXGroupName(virIdentityPtr ident,
-                                const char **groupname);
+int virIdentityGetGroupName(virIdentityPtr ident,
+                            const char **groupname);
 int virIdentityGetUNIXGroupID(virIdentityPtr ident,
                               gid_t *gid);
-int virIdentityGetUNIXProcessID(virIdentityPtr ident,
-                                pid_t *pid);
-int virIdentityGetUNIXProcessTime(virIdentityPtr ident,
-                                  unsigned long long *timestamp);
+int virIdentityGetProcessID(virIdentityPtr ident,
+                            pid_t *pid);
+int virIdentityGetProcessTime(virIdentityPtr ident,
+                              unsigned long long *timestamp);
 int virIdentityGetSASLUserName(virIdentityPtr ident,
                                const char **username);
 int virIdentityGetX509DName(virIdentityPtr ident,
@@ -84,18 +84,18 @@ int virIdentityGetSELinuxContext(virIdentityPtr ident,
                                  const char **context);
 
 
-int virIdentitySetUNIXUserName(virIdentityPtr ident,
-                               const char *username);
+int virIdentitySetUserName(virIdentityPtr ident,
+                           const char *username);
 int virIdentitySetUNIXUserID(virIdentityPtr ident,
                              uid_t uid);
-int virIdentitySetUNIXGroupName(virIdentityPtr ident,
-                                const char *groupname);
+int virIdentitySetGroupName(virIdentityPtr ident,
+                            const char *groupname);
 int virIdentitySetUNIXGroupID(virIdentityPtr ident,
                               gid_t gid);
-int virIdentitySetUNIXProcessID(virIdentityPtr ident,
-                                pid_t pid);
-int virIdentitySetUNIXProcessTime(virIdentityPtr ident,
-                                  unsigned long long timestamp);
+int virIdentitySetProcessID(virIdentityPtr ident,
+                            pid_t pid);
+int virIdentitySetProcessTime(virIdentityPtr ident,
+                              unsigned long long timestamp);
 int virIdentitySetSASLUserName(virIdentityPtr ident,
                                const char *username);
 int virIdentitySetX509DName(virIdentityPtr ident,
diff --git a/tests/viridentitytest.c b/tests/viridentitytest.c
index b60d944d8e..17d6e5f3b3 100644
--- a/tests/viridentitytest.c
+++ b/tests/viridentitytest.c
@@ -46,12 +46,12 @@ static int testIdentityAttrs(const void *data ATTRIBUTE_UNUSED)
         goto cleanup;
 
     if (virIdentitySetAttr(ident,
-                           VIR_IDENTITY_ATTR_UNIX_USER_NAME,
+                           VIR_IDENTITY_ATTR_USER_NAME,
                            "fred") < 0)
         goto cleanup;
 
     if (virIdentityGetAttr(ident,
-                           VIR_IDENTITY_ATTR_UNIX_USER_NAME,
+                           VIR_IDENTITY_ATTR_USER_NAME,
                            &val) < 0)
         goto cleanup;
 
@@ -61,7 +61,7 @@ static int testIdentityAttrs(const void *data ATTRIBUTE_UNUSED)
     }
 
     if (virIdentityGetAttr(ident,
-                           VIR_IDENTITY_ATTR_UNIX_GROUP_NAME,
+                           VIR_IDENTITY_ATTR_GROUP_NAME,
                            &val) < 0)
         goto cleanup;
 
@@ -71,14 +71,14 @@ static int testIdentityAttrs(const void *data ATTRIBUTE_UNUSED)
     }
 
     if (virIdentitySetAttr(ident,
-                           VIR_IDENTITY_ATTR_UNIX_USER_NAME,
+                           VIR_IDENTITY_ATTR_USER_NAME,
                            "joe") != -1) {
         VIR_DEBUG("Unexpectedly overwrote attribute");
         goto cleanup;
     }
 
     if (virIdentityGetAttr(ident,
-                           VIR_IDENTITY_ATTR_UNIX_USER_NAME,
+                           VIR_IDENTITY_ATTR_USER_NAME,
                            &val) < 0)
         goto cleanup;
 
@@ -111,7 +111,7 @@ static int testIdentityEqual(const void *data ATTRIBUTE_UNUSED)
     }
 
     if (virIdentitySetAttr(identa,
-                           VIR_IDENTITY_ATTR_UNIX_USER_NAME,
+                           VIR_IDENTITY_ATTR_USER_NAME,
                            "fred") < 0)
         goto cleanup;
 
@@ -121,7 +121,7 @@ static int testIdentityEqual(const void *data ATTRIBUTE_UNUSED)
     }
 
     if (virIdentitySetAttr(identb,
-                           VIR_IDENTITY_ATTR_UNIX_USER_NAME,
+                           VIR_IDENTITY_ATTR_USER_NAME,
                            "fred") < 0)
         goto cleanup;
 
@@ -131,11 +131,11 @@ static int testIdentityEqual(const void *data ATTRIBUTE_UNUSED)
     }
 
     if (virIdentitySetAttr(identa,
-                           VIR_IDENTITY_ATTR_UNIX_GROUP_NAME,
+                           VIR_IDENTITY_ATTR_GROUP_NAME,
                            "flintstone") < 0)
         goto cleanup;
     if (virIdentitySetAttr(identb,
-                           VIR_IDENTITY_ATTR_UNIX_GROUP_NAME,
+                           VIR_IDENTITY_ATTR_GROUP_NAME,
                            "flintstone") < 0)
         goto cleanup;
 
diff --git a/tests/virnetserverclienttest.c b/tests/virnetserverclienttest.c
index 4d7c6555b9..5015273e55 100644
--- a/tests/virnetserverclienttest.c
+++ b/tests/virnetserverclienttest.c
@@ -86,7 +86,7 @@ static int testIdentity(const void *opaque ATTRIBUTE_UNUSED)
     }
 
     if (virIdentityGetAttr(ident,
-                           VIR_IDENTITY_ATTR_UNIX_USER_NAME,
+                           VIR_IDENTITY_ATTR_USER_NAME,
                            &gotUsername) < 0) {
         fprintf(stderr, "Missing username in identity\n");
         goto cleanup;
@@ -110,7 +110,7 @@ static int testIdentity(const void *opaque ATTRIBUTE_UNUSED)
     }
 
     if (virIdentityGetAttr(ident,
-                           VIR_IDENTITY_ATTR_UNIX_GROUP_NAME,
+                           VIR_IDENTITY_ATTR_GROUP_NAME,
                            &gotGroupname) < 0) {
         fprintf(stderr, "Missing groupname in identity\n");
         goto cleanup;
-- 
2.21.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux