]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Fix parsing of uid/gid on Mingw32
authorDaniel P. Berrange <berrange@redhat.com>
Tue, 21 Aug 2012 11:07:04 +0000 (12:07 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Tue, 21 Aug 2012 14:03:54 +0000 (15:03 +0100)
The DAC security driver uses the virStrToLong_ui function to
parse the uid/gid out of the seclabel string. This works on
Linux where 'uid_t' is an unsigned int, but on Mingw32 it is
just an 'int'. This causes compiler warnings about signed/
unsigned int pointer mis-match.

To avoid this, use explicit 'unsigned int ouruid' local
vars to pass into virStrToLong_ui, and then simply assign
to the 'uid_t' type after parsing

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
src/security/security_dac.c

index e37b09e2a7d6bb452011cf6c43d49969ef267b44..925498fe4cb9d21e3c59ddba7095a1f33eb732b8 100644 (file)
@@ -68,25 +68,25 @@ void virSecurityDACSetDynamicOwnership(virSecurityManagerPtr mgr,
 static
 int parseIds(const char *label, uid_t *uidPtr, gid_t *gidPtr)
 {
-    uid_t uid;
-    gid_t gid;
+    unsigned int theuid;
+    unsigned int thegid;
     char *endptr = NULL;
 
     if (label == NULL)
         return -1;
 
-    if (virStrToLong_ui(label, &endptr, 10, &uid) ||
+    if (virStrToLong_ui(label, &endptr, 10, &theuid) ||
         endptr == NULL || *endptr != ':') {
         return -1;
     }
 
-    if (virStrToLong_ui(endptr + 1, NULL, 10, &gid))
+    if (virStrToLong_ui(endptr + 1, NULL, 10, &thegid))
         return -1;
 
     if (uidPtr)
-        *uidPtr = uid;
+        *uidPtr = theuid;
     if (gidPtr)
-        *gidPtr = gid;
+        *gidPtr = thegid;
     return 0;
 }