summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Layton <jlayton@samba.org>2012-11-07 10:19:18 -0500
committerJeff Layton <jlayton@samba.org>2012-11-07 10:19:18 -0500
commitcc3417e69ca39a8b7eaf0df5ba848d0d4822924e (patch)
tree14e60a4980d97a0767388bf0fa54c1aff2be79ab
parent034a4baa9f3d496a19dbe3eb46d51cf8ef3adffd (diff)
downloadcifs-utils-cc3417e69ca39a8b7eaf0df5ba848d0d4822924e.tar.gz
cifs-utils-cc3417e69ca39a8b7eaf0df5ba848d0d4822924e.tar.bz2
cifs-utils-cc3417e69ca39a8b7eaf0df5ba848d0d4822924e.zip
getcifsacl: fix endianness before handing off SID to winbind
winbind expects SIDs to be expressed in host-endian. Convert them from little-endian before asking winbind to convert them to names. Also use the WBC_ERROR_IS_OK() macro to check the return code. Signed-off-by: Jeff Layton <jlayton@samba.org>
-rw-r--r--getcifsacl.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/getcifsacl.c b/getcifsacl.c
index 083705c..f7e6d4f 100644
--- a/getcifsacl.c
+++ b/getcifsacl.c
@@ -171,6 +171,19 @@ print_ace_type(uint8_t acetype, int raw)
}
}
+/*
+ * Winbind keeps wbcDomainSid fields in host-endian. So, we must convert from
+ * little endian here so that winbind will understand correctly.
+ */
+static void
+convert_sid_endianness(struct wbcDomainSid *sid)
+{
+ int i;
+
+ for (i = 0; i < sid->num_subauth; i++)
+ sid->sub_auth[i] = le32toh(sid->sub_auths[i]);
+}
+
static void
print_sid(struct wbcDomainSid *sidptr, int raw)
{
@@ -182,11 +195,13 @@ print_sid(struct wbcDomainSid *sidptr, int raw)
char *sidname = NULL;
enum wbcSidType sntype;
+ convert_sid_endianness(sidptr);
+
if (raw)
goto print_sid_raw;
rc = wbcLookupSid(sidptr, &domain_name, &sidname, &sntype);
- if (!rc) {
+ if (WBC_ERROR_IS_OK(rc)) {
printf("%s", domain_name);
if (strlen(domain_name))
printf("%c", '\\');
@@ -202,7 +217,7 @@ print_sid_raw:
if (sidptr->id_auth[i])
printf("-%d", sidptr->id_auth[i]);
for (i = 0; i < num_auths; i++)
- printf("-%u", le32toh(sidptr->sub_auths[i]));
+ printf("-%u", sidptr->sub_auths[i]);
}
static void