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
commit4fae92dc32fb5e04fdb0533140997797614a9ed5 (patch)
treed0ab08551726b4950c43dc858a03c7a9bd514f2e
parent067a0c8c63c8e5e4e7e70a95009d25a9d089b5dd (diff)
downloadcifs-utils-4fae92dc32fb5e04fdb0533140997797614a9ed5.tar.gz
cifs-utils-4fae92dc32fb5e04fdb0533140997797614a9ed5.tar.bz2
cifs-utils-4fae92dc32fb5e04fdb0533140997797614a9ed5.zip
getcifsacl: fix raw SID printing routine
The current routine prints multiple authority values as different numbers instead of combining them, which is wrong. Print the SID according to the rules in MS-DTYP. Signed-off-by: Jeff Layton <jlayton@samba.org>
-rw-r--r--getcifsacl.c29
1 files changed, 20 insertions, 9 deletions
diff --git a/getcifsacl.c b/getcifsacl.c
index 1bcbd58..b832c50 100644
--- a/getcifsacl.c
+++ b/getcifsacl.c
@@ -188,12 +188,11 @@ static void
print_sid(struct cifs_sid *sidptr, int raw)
{
int i;
- int num_auths;
- int num_auth = MAX_NUM_AUTHS;
wbcErr rc;
char *domain_name = NULL;
char *sidname = NULL;
enum wbcSidType sntype;
+ unsigned long long id_auth_val;
convert_sid_endianness(sidptr);
@@ -211,13 +210,25 @@ print_sid(struct cifs_sid *sidptr, int raw)
}
print_sid_raw:
- num_auths = sidptr->num_subauth;
- printf("S");
- printf("-%d", sidptr->revision);
- for (i = 0; i < num_auth; ++i)
- if (sidptr->authority[i])
- printf("-%d", sidptr->authority[i]);
- for (i = 0; i < num_auths; i++)
+ printf("S-%hhu", sidptr->revision);
+
+ id_auth_val = (unsigned long long)sidptr->authority[5];
+ id_auth_val += (unsigned long long)sidptr->authority[4] << 8;
+ id_auth_val += (unsigned long long)sidptr->authority[3] << 16;
+ id_auth_val += (unsigned long long)sidptr->authority[2] << 24;
+ id_auth_val += (unsigned long long)sidptr->authority[1] << 32;
+ id_auth_val += (unsigned long long)sidptr->authority[0] << 48;
+
+ /*
+ * MS-DTYP states that if the authority is >= 2^32, then it should be
+ * expressed as a hex value.
+ */
+ if (id_auth_val <= UINT_MAX)
+ printf("-%llu", id_auth_val);
+ else
+ printf("-0x%llx", id_auth_val);
+
+ for (i = 0; i < sidptr->num_subauth; i++)
printf("-%u", sidptr->sub_auth[i]);
}