]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
libgpo: Reimplmeent registry_create_system_token() using get_system_token()
authorAndrew Bartlett <abartlet@samba.org>
Thu, 14 Sep 2023 22:52:51 +0000 (10:52 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 26 Sep 2023 23:45:36 +0000 (23:45 +0000)
This helps ensure we have a smaller number of places that
a struct security_token starts from.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
libgpo/gpo_reg.c

index f52173ea189dadcf3ed625d9561407306983181d..a1a8d7d1a07dc006af7175f9a54e14e6db3d1ebc 100644 (file)
 
 struct security_token *registry_create_system_token(TALLOC_CTX *mem_ctx)
 {
-       struct security_token *token = NULL;
+       const struct security_token *system_token = get_system_token();
 
-       token = talloc_zero(mem_ctx, struct security_token);
-       if (!token) {
-               DEBUG(1,("talloc failed\n"));
-               return NULL;
-       }
-
-       token->privilege_mask = SE_ALL_PRIVS;
+       struct security_token *dup_token
+               = security_token_duplicate(mem_ctx, system_token);
 
-       if (!NT_STATUS_IS_OK(add_sid_to_array(token, &global_sid_System,
-                        &token->sids, &token->num_sids))) {
-               DEBUG(1,("Error adding nt-authority system sid to token\n"));
+       if (dup_token == NULL) {
+               DBG_WARNING("security_token_duplicate() failed\n");
                return NULL;
        }
 
-       return token;
+       return dup_token;
 }
 
 /****************************************************************