s4:samba3sam LDB module - make the "pw_uid"/"pw_gid" conversion a bit clearer
authorMatthias Dieter Wallnöfer <mdw@samba.org>
Sat, 27 Nov 2010 13:07:31 +0000 (14:07 +0100)
committerMatthias Dieter Wallnöfer <mdw@samba.org>
Sat, 27 Nov 2010 14:17:18 +0000 (15:17 +0100)
And remove the "long" specifier since at least on the major platforms
(Linux, BSD and Solaris) these types are defined as "uint32_t".

source4/dsdb/samdb/ldb_modules/samba3sam.c

index 318d605ecd1c316cd0b320d160f52a6bfd240074..3a8521dbdee4759f55b170cfd70243718026f5c1 100644 (file)
@@ -151,7 +151,9 @@ static struct ldb_val lookup_gid(struct ldb_module *module, TALLOC_CTX *ctx, con
                return *talloc_zero(ctx, struct ldb_val);
        }
 
-       retval.data = (uint8_t *)talloc_asprintf(ctx, "%ld", (unsigned long)pwd->pw_gid);
+       /* "pw_gid" is per POSIX definition "unsigned".
+        * But write it out as "signed" for LDAP compliance. */
+       retval.data = (uint8_t *)talloc_asprintf(ctx, "%d", (int) pwd->pw_gid);
        retval.length = strlen((char *)retval.data);
 
        return retval;
@@ -168,7 +170,9 @@ static struct ldb_val lookup_uid(struct ldb_module *module, TALLOC_CTX *ctx, con
                return *talloc_zero(ctx, struct ldb_val);
        }
 
-       retval.data = (uint8_t *)talloc_asprintf(ctx, "%ld", (unsigned long)pwd->pw_uid);
+       /* "pw_uid" is per POSIX definition "unsigned".
+        * But write it out as "signed" for LDAP compliance. */
+       retval.data = (uint8_t *)talloc_asprintf(ctx, "%d", (int) pwd->pw_uid);
        retval.length = strlen((char *)retval.data);
 
        return retval;