s3:lib: add root_unix_token()
authorRalph Boehme <slow@samba.org>
Fri, 16 Mar 2018 18:01:20 +0000 (19:01 +0100)
committerStefan Metzmacher <metze@samba.org>
Fri, 11 Jan 2019 22:11:11 +0000 (23:11 +0100)
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
source3/include/proto.h
source3/lib/util.c

index c92d992..81065c8 100644 (file)
@@ -415,6 +415,7 @@ bool map_open_params_to_ntcreate(const char *smb_base_fname,
                                 uint32_t *pcreate_options,
                                 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);
 bool dir_check_ftype(uint32_t mode, uint32_t dirtype);
 
 /* The following definitions come from lib/util_builtin.c  */
index a3fe7c8..8ff330b 100644 (file)
@@ -2143,6 +2143,32 @@ struct security_unix_token *copy_unix_token(TALLOC_CTX *ctx, const struct securi
        return cpy;
 }
 
+/****************************************************************************
+ Return a root token
+****************************************************************************/
+
+struct security_unix_token *root_unix_token(TALLOC_CTX *mem_ctx)
+{
+       struct security_unix_token *t = NULL;
+
+       t = talloc_zero(mem_ctx, struct security_unix_token);
+       if (t == NULL) {
+               return NULL;
+       }
+
+       /*
+        * This is not needed, but lets make it explicit, not implicit.
+        */
+       *t = (struct security_unix_token) {
+               .uid = 0,
+               .gid = 0,
+               .ngroups = 0,
+               .groups = NULL
+       };
+
+       return t;
+}
+
 /****************************************************************************
  Check that a file matches a particular file type.
 ****************************************************************************/