A terse, one-line unix token representation for debugging purposes
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
uint32_t *pprivate_flags);
struct security_unix_token *copy_unix_token(TALLOC_CTX *ctx, const struct security_unix_token *tok);
struct security_unix_token *root_unix_token(TALLOC_CTX *mem_ctx);
+char *utok_string(TALLOC_CTX *mem_ctx, const struct security_unix_token *tok);
bool dir_check_ftype(uint32_t mode, uint32_t dirtype);
/* The following definitions come from lib/util_builtin.c */
return t;
}
+char *utok_string(TALLOC_CTX *mem_ctx, const struct security_unix_token *tok)
+{
+ char *str;
+ uint32_t i;
+
+ str = talloc_asprintf(
+ mem_ctx,
+ "uid=%ju, gid=%ju, %"PRIu32" groups:",
+ (uintmax_t)(tok->uid),
+ (uintmax_t)(tok->gid),
+ tok->ngroups);
+ if (str == NULL) {
+ return NULL;
+ }
+
+ for (i=0; i<tok->ngroups; i++) {
+ char *tmp;
+ tmp = talloc_asprintf_append_buffer(
+ str, " %ju", (uintmax_t)tok->groups[i]);
+ if (tmp == NULL) {
+ TALLOC_FREE(str);
+ return NULL;
+ }
+ str = tmp;
+ }
+
+ return str;
+}
+
/****************************************************************************
Check that a file matches a particular file type.
****************************************************************************/