Change registry_create_admin_token() to return NTSTATUS.
authorMichael Adam <obnox@samba.org>
Wed, 9 Jan 2008 00:17:13 +0000 (01:17 +0100)
committerMichael Adam <obnox@samba.org>
Wed, 9 Jan 2008 00:47:10 +0000 (01:47 +0100)
Michael
(This used to be commit 9cd30fb25c42e79946b5140994d0bf2ef4c62f90)

source3/lib/util_reg_smbconf.c
source3/libnet/libnet_conf.c
source3/param/loadparm.c

index 5fb862ac354da3f0adc1866f8aa61cf5a6c0d5cf..6452b0b15bcad8d6a68ceb62804e8c9b4e707696 100644 (file)
@@ -31,14 +31,20 @@ extern REGISTRY_OPS smbconf_reg_ops;
  * - builtin administrators sid
  * - disk operators privilege
  */
-NT_USER_TOKEN *registry_create_admin_token(TALLOC_CTX *mem_ctx)
+NTSTATUS registry_create_admin_token(TALLOC_CTX *mem_ctx,
+                                    NT_USER_TOKEN **ptoken)
 {
        NTSTATUS status;
        NT_USER_TOKEN *token = NULL;
 
+       if (ptoken == NULL) {
+               return NT_STATUS_INVALID_PARAMETER;
+       }
+
        token = TALLOC_ZERO_P(mem_ctx, NT_USER_TOKEN);
        if (token == NULL) {
                DEBUG(1, ("talloc failed\n"));
+               status = NT_STATUS_NO_MEMORY;
                goto done;
        }
        token->privileges = se_disk_operators;
@@ -49,8 +55,11 @@ NT_USER_TOKEN *registry_create_admin_token(TALLOC_CTX *mem_ctx)
                          "to fake token.\n"));
                goto done;
        }
+
+       *ptoken = token;
+
 done:
-       return token;
+       return status;
 }
 
 /*
index c8e55a70b277fdd32c45c4e472dd7f6bae470917..d0ef6eb0e6b239e06eefd374f39cf8d435cfa7a0 100644 (file)
@@ -87,7 +87,7 @@ static WERROR libnet_conf_reg_open_path(TALLOC_CTX *mem_ctx,
                                        struct registry_key **key)
 {
        WERROR werr = WERR_OK;
-       NT_USER_TOKEN *token;
+       NT_USER_TOKEN *token = NULL;
        TALLOC_CTX *tmp_ctx = NULL;
 
        if (path == NULL) {
@@ -109,11 +109,9 @@ static WERROR libnet_conf_reg_open_path(TALLOC_CTX *mem_ctx,
                goto done;
        }
 
-       token = registry_create_admin_token(tmp_ctx);
-       if (token == NULL) {
+       werr = ntstatus_to_werror(registry_create_admin_token(tmp_ctx, &token));
+       if (W_ERROR_IS_OK(werr)) {
                DEBUG(1, ("Error creating admin token\n"));
-               /* what is the appropriate error code here? */
-               werr = WERR_CAN_NOT_COMPLETE;
                goto done;
        }
 
index 358fabfb2a416e21e8571445ea9eefc0958d0c4a..9700cd1320cff77f803c7445c97579fa51fb605c 100644 (file)
@@ -3529,7 +3529,7 @@ static bool process_registry_globals(bool (*pfunc)(const char *, const char *))
        char *valname = NULL;
        char *valstr = NULL;
        uint32 idx = 0;
-       NT_USER_TOKEN *token;
+       NT_USER_TOKEN *token = NULL;
 
        ctx = talloc_init("process_registry_globals");
        if (!ctx) {
@@ -3543,8 +3543,9 @@ static bool process_registry_globals(bool (*pfunc)(const char *, const char *))
                goto done;
        }
 
-       if (!(token = registry_create_admin_token(ctx))) {
-               DEBUG(1, ("Error creating admin token\n"));
+       werr = ntstatus_to_werror(registry_create_admin_token(ctx, &token));
+       if (!W_ERROR_IS_OK(werr)) {
+               DEBUG(1, ("Error creating admin token: %s\n",dos_errstr(werr)));
                goto done;
        }