Fix include paths to new location of libutil.
[kai/samba-autobuild/.git] / source4 / libnet / libnet_passwd.c
index db54935a78f2d8f7e5d5656757c4372f558603fe..de2ed01abd8690218f32052e4eb6c26b92fb5968 100644 (file)
@@ -6,7 +6,7 @@
    
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "includes.h"
 #include "libnet/libnet.h"
-#include "librpc/gen_ndr/ndr_samr.h"
-#include "lib/crypto/crypto.h"
+#include "../lib/crypto/crypto.h"
+#include "libcli/auth/libcli_auth.h"
+#include "librpc/gen_ndr/ndr_samr_c.h"
 
 /*
  * do a password change using DCERPC/SAMR calls
@@ -53,14 +53,14 @@ static NTSTATUS libnet_ChangePassword_samr(struct libnet_context *ctx, TALLOC_CT
 
        /* prepare connect to the SAMR pipe of the users domain PDC */
        c.level                    = LIBNET_RPC_CONNECT_PDC;
-       c.in.domain_name           = r->samr.in.domain_name;
-       c.in.dcerpc_iface          = &dcerpc_table_samr;
+       c.in.name                  = r->samr.in.domain_name;
+       c.in.dcerpc_iface          = &ndr_table_samr;
 
        /* 1. connect to the SAMR pipe of users domain PDC (maybe a standalone server or workstation) */
        status = libnet_RpcConnect(ctx, mem_ctx, &c);
        if (!NT_STATUS_IS_OK(status)) {
                r->samr.out.error_string = talloc_asprintf(mem_ctx,
-                                               "Connection to SAMR pipe of PDC of domain '%s' failed: %s\n",
+                                               "Connection to SAMR pipe of PDC of domain '%s' failed: %s",
                                                r->samr.in.domain_name, nt_errstr(status));
                return status;
        }
@@ -97,7 +97,7 @@ static NTSTATUS libnet_ChangePassword_samr(struct libnet_context *ctx, TALLOC_CT
        status = dcerpc_samr_ChangePasswordUser3(c.out.dcerpc_pipe, mem_ctx, &pw3);
        if (!NT_STATUS_IS_OK(status)) {
                r->samr.out.error_string = talloc_asprintf(mem_ctx,
-                                               "samr_ChangePasswordUser3 failed: %s\n",
+                                               "samr_ChangePasswordUser3 failed: %s",
                                                nt_errstr(status));
                goto ChangePasswordUser2;
        }
@@ -105,7 +105,7 @@ static NTSTATUS libnet_ChangePassword_samr(struct libnet_context *ctx, TALLOC_CT
        /* check result of samr_ChangePasswordUser3 */
        if (!NT_STATUS_IS_OK(pw3.out.result)) {
                r->samr.out.error_string = talloc_asprintf(mem_ctx,
-                                               "samr_ChangePasswordUser3 for '%s\\%s' failed: %s\n",
+                                               "samr_ChangePasswordUser3 for '%s\\%s' failed: %s",
                                                r->samr.in.domain_name, r->samr.in.account_name, 
                                                nt_errstr(pw3.out.result));
                                                /* TODO: give the reason of the reject */
@@ -140,7 +140,7 @@ ChangePasswordUser2:
        status = dcerpc_samr_ChangePasswordUser2(c.out.dcerpc_pipe, mem_ctx, &pw2);
        if (!NT_STATUS_IS_OK(status)) {
                r->samr.out.error_string = talloc_asprintf(mem_ctx,
-                                               "samr_ChangePasswordUser2 failed: %s\n",
+                                               "samr_ChangePasswordUser2 failed: %s",
                                                nt_errstr(status));
                goto OemChangePasswordUser2;
        }
@@ -148,7 +148,7 @@ ChangePasswordUser2:
        /* check result of samr_ChangePasswordUser2 */
        if (!NT_STATUS_IS_OK(pw2.out.result)) {
                r->samr.out.error_string = talloc_asprintf(mem_ctx,
-                                               "samr_ChangePasswordUser2 for '%s\\%s' failed: %s\n",
+                                               "samr_ChangePasswordUser2 for '%s\\%s' failed: %s",
                                                r->samr.in.domain_name, r->samr.in.account_name, 
                                                nt_errstr(pw2.out.result));
                if (NT_STATUS_EQUAL(pw2.out.result, NT_STATUS_PASSWORD_RESTRICTION)) {
@@ -178,7 +178,7 @@ OemChangePasswordUser2:
        status = dcerpc_samr_OemChangePasswordUser2(c.out.dcerpc_pipe, mem_ctx, &oe2);
        if (!NT_STATUS_IS_OK(status)) {
                r->samr.out.error_string = talloc_asprintf(mem_ctx,
-                                               "samr_OemChangePasswordUser2 failed: %s\n",
+                                               "samr_OemChangePasswordUser2 failed: %s",
                                                nt_errstr(status));
                goto ChangePasswordUser;
        }
@@ -186,7 +186,7 @@ OemChangePasswordUser2:
        /* check result of samr_OemChangePasswordUser2 */
        if (!NT_STATUS_IS_OK(oe2.out.result)) {
                r->samr.out.error_string = talloc_asprintf(mem_ctx,
-                                               "samr_OemChangePasswordUser2 for '%s\\%s' failed: %s\n",
+                                               "samr_OemChangePasswordUser2 for '%s\\%s' failed: %s",
                                                r->samr.in.domain_name, r->samr.in.account_name, 
                                                nt_errstr(oe2.out.result));
                if (NT_STATUS_EQUAL(oe2.out.result, NT_STATUS_PASSWORD_RESTRICTION)) {
@@ -225,7 +225,7 @@ ChangePasswordUser:
        status = dcerpc_samr_ChangePasswordUser(c.pdc.out.dcerpc_pipe, mem_ctx, &pw);
        if (!NT_STATUS_IS_OK(status)) {
                r->samr.out.error_string = talloc_asprintf(mem_ctx,
-                                               "samr_ChangePasswordUser failed: %s\n",
+                                               "samr_ChangePasswordUser failed: %s",
                                                nt_errstr(status));
                goto disconnect;
        }
@@ -233,7 +233,7 @@ ChangePasswordUser:
        /* check result of samr_ChangePasswordUser */
        if (!NT_STATUS_IS_OK(pw.out.result)) {
                r->samr.out.error_string = talloc_asprintf(mem_ctx,
-                                               "samr_ChangePasswordUser for '%s\\%s' failed: %s\n",
+                                               "samr_ChangePasswordUser for '%s\\%s' failed: %s",
                                                r->samr.in.domain_name, r->samr.in.account_name, 
                                                nt_errstr(pw.out.result));
                if (NT_STATUS_EQUAL(pw.out.result, NT_STATUS_PASSWORD_RESTRICTION)) {
@@ -289,14 +289,18 @@ NTSTATUS libnet_ChangePassword(struct libnet_context *ctx, TALLOC_CTX *mem_ctx,
 static NTSTATUS libnet_SetPassword_samr_handle_26(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, union libnet_SetPassword *r)
 {
        NTSTATUS status;
-       struct samr_SetUserInfo sui;
+       struct samr_SetUserInfo2 sui;
        union samr_UserInfo u_info;
        DATA_BLOB session_key;
        DATA_BLOB confounded_session_key = data_blob_talloc(mem_ctx, NULL, 16);
        uint8_t confounder[16]; 
        struct MD5Context md5;
 
-       /* prepare samr_SetUserInfo level 26 */
+       if (r->samr_handle.in.info21) {
+               return NT_STATUS_INVALID_PARAMETER_MIX;
+       }
+
+       /* prepare samr_SetUserInfo2 level 26 */
        ZERO_STRUCT(u_info);
        encode_pw_buffer(u_info.info26.password.data, r->samr_handle.in.newpassword, STR_UNICODE);
        u_info.info26.pw_len = strlen(r->samr_handle.in.newpassword);
@@ -304,7 +308,7 @@ static NTSTATUS libnet_SetPassword_samr_handle_26(struct libnet_context *ctx, TA
        status = dcerpc_fetch_session_key(r->samr_handle.in.dcerpc_pipe, &session_key);
        if (!NT_STATUS_IS_OK(status)) {
                r->samr_handle.out.error_string = talloc_asprintf(mem_ctx,
-                                                                 "dcerpc_fetch_session_key failed: %s\n",
+                                                                 "dcerpc_fetch_session_key failed: %s",
                                                                  nt_errstr(status));
                return status;
        }
@@ -323,13 +327,13 @@ static NTSTATUS libnet_SetPassword_samr_handle_26(struct libnet_context *ctx, TA
        sui.in.info = &u_info;
        sui.in.level = 26;
        
-       /* 7. try samr_SetUserInfo level 26 to set the password */
-       status = dcerpc_samr_SetUserInfo(r->samr_handle.in.dcerpc_pipe, mem_ctx, &sui);
-       /* check result of samr_SetUserInfo level 26 */
+       /* 7. try samr_SetUserInfo2 level 26 to set the password */
+       status = dcerpc_samr_SetUserInfo2(r->samr_handle.in.dcerpc_pipe, mem_ctx, &sui);
+       /* check result of samr_SetUserInfo2 level 26 */
        if (!NT_STATUS_IS_OK(status)) {
                r->samr_handle.out.error_string
                        = talloc_asprintf(mem_ctx,
-                                         "SetUserInfo level 26 for [%s] failed: %s\n",
+                                         "SetUserInfo2 level 26 for [%s] failed: %s",
                                          r->samr_handle.in.account_name, nt_errstr(status));
        }
        return status;
@@ -338,22 +342,27 @@ static NTSTATUS libnet_SetPassword_samr_handle_26(struct libnet_context *ctx, TA
 static NTSTATUS libnet_SetPassword_samr_handle_25(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, union libnet_SetPassword *r)
 {
        NTSTATUS status;
-       struct samr_SetUserInfo sui;
+       struct samr_SetUserInfo2 sui;
        union samr_UserInfo u_info;
        DATA_BLOB session_key;
        DATA_BLOB confounded_session_key = data_blob_talloc(mem_ctx, NULL, 16);
        uint8_t confounder[16]; 
        struct MD5Context md5;
 
-       /* prepare samr_SetUserInfo level 25 */
+       if (!r->samr_handle.in.info21) {
+               return NT_STATUS_INVALID_PARAMETER_MIX;
+       }
+
+       /* prepare samr_SetUserInfo2 level 25 */
        ZERO_STRUCT(u_info);
-       u_info.info25.info.fields_present = SAMR_FIELD_PASSWORD;
+       u_info.info25.info = *r->samr_handle.in.info21;
+       u_info.info25.info.fields_present |= SAMR_FIELD_PASSWORD;
        encode_pw_buffer(u_info.info25.password.data, r->samr_handle.in.newpassword, STR_UNICODE);
 
        status = dcerpc_fetch_session_key(r->samr_handle.in.dcerpc_pipe, &session_key);
        if (!NT_STATUS_IS_OK(status)) {
                r->samr_handle.out.error_string = talloc_asprintf(mem_ctx,
-                                               "dcerpc_fetch_session_key failed: %s\n",
+                                               "dcerpc_fetch_session_key failed: %s",
                                                nt_errstr(status));
                return status;
        }
@@ -372,12 +381,12 @@ static NTSTATUS libnet_SetPassword_samr_handle_25(struct libnet_context *ctx, TA
        sui.in.info = &u_info;
        sui.in.level = 25;
 
-       /* 8. try samr_SetUserInfo level 25 to set the password */
-       status = dcerpc_samr_SetUserInfo(r->samr_handle.in.dcerpc_pipe, mem_ctx, &sui);
+       /* 8. try samr_SetUserInfo2 level 25 to set the password */
+       status = dcerpc_samr_SetUserInfo2(r->samr_handle.in.dcerpc_pipe, mem_ctx, &sui);
        if (!NT_STATUS_IS_OK(status)) {
                r->samr_handle.out.error_string
                        = talloc_asprintf(mem_ctx,
-                                         "SetUserInfo level 25 for [%s] failed: %s\n",
+                                         "SetUserInfo2 level 25 for [%s] failed: %s",
                                          r->samr_handle.in.account_name, nt_errstr(status));
        }
        return status;
@@ -386,11 +395,15 @@ static NTSTATUS libnet_SetPassword_samr_handle_25(struct libnet_context *ctx, TA
 static NTSTATUS libnet_SetPassword_samr_handle_24(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, union libnet_SetPassword *r)
 {
        NTSTATUS status;
-       struct samr_SetUserInfo sui;
+       struct samr_SetUserInfo2 sui;
        union samr_UserInfo u_info;
        DATA_BLOB session_key;
 
-       /* prepare samr_SetUserInfo level 24 */
+       if (r->samr_handle.in.info21) {
+               return NT_STATUS_INVALID_PARAMETER_MIX;
+       }
+
+       /* prepare samr_SetUserInfo2 level 24 */
        ZERO_STRUCT(u_info);
        encode_pw_buffer(u_info.info24.password.data, r->samr_handle.in.newpassword, STR_UNICODE);
        /* w2k3 ignores this length */
@@ -399,7 +412,7 @@ static NTSTATUS libnet_SetPassword_samr_handle_24(struct libnet_context *ctx, TA
        status = dcerpc_fetch_session_key(r->samr_handle.in.dcerpc_pipe, &session_key);
        if (!NT_STATUS_IS_OK(status)) {
                r->samr_handle.out.error_string = talloc_asprintf(mem_ctx,
-                                               "dcerpc_fetch_session_key failed: %s\n",
+                                               "dcerpc_fetch_session_key failed: %s",
                                                nt_errstr(status));
                return status;
        }
@@ -410,12 +423,12 @@ static NTSTATUS libnet_SetPassword_samr_handle_24(struct libnet_context *ctx, TA
        sui.in.info = &u_info;
        sui.in.level = 24;
 
-       /* 9. try samr_SetUserInfo level 24 to set the password */
-       status = dcerpc_samr_SetUserInfo(r->samr_handle.in.dcerpc_pipe, mem_ctx, &sui);
+       /* 9. try samr_SetUserInfo2 level 24 to set the password */
+       status = dcerpc_samr_SetUserInfo2(r->samr_handle.in.dcerpc_pipe, mem_ctx, &sui);
        if (!NT_STATUS_IS_OK(status)) {
                r->samr_handle.out.error_string
                        = talloc_asprintf(mem_ctx,
-                                         "SetUserInfo level 24 for [%s] failed: %s\n",
+                                         "SetUserInfo2 level 24 for [%s] failed: %s",
                                          r->samr_handle.in.account_name, nt_errstr(status));
        }
        return status;
@@ -424,20 +437,25 @@ static NTSTATUS libnet_SetPassword_samr_handle_24(struct libnet_context *ctx, TA
 static NTSTATUS libnet_SetPassword_samr_handle_23(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, union libnet_SetPassword *r)
 {
        NTSTATUS status;
-       struct samr_SetUserInfo sui;
+       struct samr_SetUserInfo2 sui;
        union samr_UserInfo u_info;
        DATA_BLOB session_key;
 
-       /* prepare samr_SetUserInfo level 23 */
+       if (!r->samr_handle.in.info21) {
+               return NT_STATUS_INVALID_PARAMETER_MIX;
+       }
+
+       /* prepare samr_SetUserInfo2 level 23 */
        ZERO_STRUCT(u_info);
-       u_info.info23.info.fields_present = SAMR_FIELD_PASSWORD;
+       u_info.info23.info = *r->samr_handle.in.info21;
+       u_info.info23.info.fields_present |= SAMR_FIELD_PASSWORD;
        encode_pw_buffer(u_info.info23.password.data, r->samr_handle.in.newpassword, STR_UNICODE);
 
        status = dcerpc_fetch_session_key(r->samr_handle.in.dcerpc_pipe, &session_key);
        if (!NT_STATUS_IS_OK(status)) {
                r->samr_handle.out.error_string
                        = talloc_asprintf(mem_ctx,
-                                         "dcerpc_fetch_session_key failed: %s\n",
+                                         "dcerpc_fetch_session_key failed: %s",
                                          nt_errstr(status));
                return status;
        }
@@ -448,25 +466,26 @@ static NTSTATUS libnet_SetPassword_samr_handle_23(struct libnet_context *ctx, TA
        sui.in.info = &u_info;
        sui.in.level = 23;
 
-       /* 10. try samr_SetUserInfo level 23 to set the password */
-       status = dcerpc_samr_SetUserInfo(r->samr_handle.in.dcerpc_pipe, mem_ctx, &sui);
+       /* 10. try samr_SetUserInfo2 level 23 to set the password */
+       status = dcerpc_samr_SetUserInfo2(r->samr_handle.in.dcerpc_pipe, mem_ctx, &sui);
        if (!NT_STATUS_IS_OK(status)) {
                r->samr_handle.out.error_string
                        = talloc_asprintf(mem_ctx,
-                                         "SetUserInfo level 23 for [%s] failed: %s\n",
+                                         "SetUserInfo2 level 23 for [%s] failed: %s",
                                          r->samr_handle.in.account_name, nt_errstr(status));
        }
        return status;
 }
 
 /*
- * 1. try samr_SetUserInfo level 26 to set the password
- * 2. try samr_SetUserInfo level 25 to set the password
- * 3. try samr_SetUserInfo level 24 to set the password
- * 4. try samr_SetUserInfo level 23 to set the password
+ * 1. try samr_SetUserInfo2 level 26 to set the password
+ * 2. try samr_SetUserInfo2 level 25 to set the password
+ * 3. try samr_SetUserInfo2 level 24 to set the password
+ * 4. try samr_SetUserInfo2 level 23 to set the password
 */
 static NTSTATUS libnet_SetPassword_samr_handle(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, union libnet_SetPassword *r)
 {
+
        NTSTATUS status;
        enum libnet_SetPassword_level levels[] = {
                LIBNET_SET_PASSWORD_SAMR_HANDLE_26,
@@ -475,13 +494,17 @@ static NTSTATUS libnet_SetPassword_samr_handle(struct libnet_context *ctx, TALLO
                LIBNET_SET_PASSWORD_SAMR_HANDLE_23,
        };
        int i;
-       
+
        for (i=0; i < ARRAY_SIZE(levels); i++) {
                r->generic.level = levels[i];
                status = libnet_SetPassword(ctx, mem_ctx, r);
-               if (!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_INFO_CLASS) && !NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
-                       break;
+               if (NT_STATUS_EQUAL(status, NT_STATUS_INVALID_INFO_CLASS)
+                   || NT_STATUS_EQUAL(status, NT_STATUS_INVALID_PARAMETER_MIX)
+                   || NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
+                       /* Try another password set mechanism */
+                       continue;
                }
+               break;
        }
        
        return status;
@@ -513,15 +536,15 @@ static NTSTATUS libnet_SetPassword_samr(struct libnet_context *ctx, TALLOC_CTX *
        union libnet_SetPassword r2;
 
        /* prepare connect to the SAMR pipe of users domain PDC */
-       c.level                     = LIBNET_RPC_CONNECT_PDC;
-       c.in.domain_name            = r->samr.in.domain_name;
-       c.in.dcerpc_iface               = &dcerpc_table_samr;
+       c.level               = LIBNET_RPC_CONNECT_PDC;
+       c.in.name             = r->samr.in.domain_name;
+       c.in.dcerpc_iface     = &ndr_table_samr;
 
        /* 1. connect to the SAMR pipe of users domain PDC (maybe a standalone server or workstation) */
        status = libnet_RpcConnect(ctx, mem_ctx, &c);
        if (!NT_STATUS_IS_OK(status)) {
                r->samr.out.error_string = talloc_asprintf(mem_ctx,
-                                                          "Connection to SAMR pipe of PDC of domain '%s' failed: %s\n",
+                                                          "Connection to SAMR pipe of PDC of domain '%s' failed: %s",
                                                           r->samr.in.domain_name, nt_errstr(status));
                return status;
        }
@@ -536,7 +559,7 @@ static NTSTATUS libnet_SetPassword_samr(struct libnet_context *ctx, TALLOC_CTX *
        status = dcerpc_samr_Connect(c.out.dcerpc_pipe, mem_ctx, &sc);
        if (!NT_STATUS_IS_OK(status)) {
                r->samr.out.error_string = talloc_asprintf(mem_ctx,
-                                               "samr_Connect failed: %s\n",
+                                               "samr_Connect failed: %s",
                                                nt_errstr(status));
                goto disconnect;
        }
@@ -550,7 +573,7 @@ static NTSTATUS libnet_SetPassword_samr(struct libnet_context *ctx, TALLOC_CTX *
        status = dcerpc_samr_LookupDomain(c.out.dcerpc_pipe, mem_ctx, &ld);
        if (!NT_STATUS_IS_OK(status)) {
                r->samr.out.error_string = talloc_asprintf(mem_ctx,
-                                               "samr_LookupDomain for [%s] failed: %s\n",
+                                               "samr_LookupDomain for [%s] failed: %s",
                                                r->samr.in.domain_name, nt_errstr(status));
                goto disconnect;
        }
@@ -566,7 +589,7 @@ static NTSTATUS libnet_SetPassword_samr(struct libnet_context *ctx, TALLOC_CTX *
        status = dcerpc_samr_OpenDomain(c.out.dcerpc_pipe, mem_ctx, &od);
        if (!NT_STATUS_IS_OK(status)) {
                r->samr.out.error_string = talloc_asprintf(mem_ctx,
-                                               "samr_OpenDomain for [%s] failed: %s\n",
+                                               "samr_OpenDomain for [%s] failed: %s",
                                                r->samr.in.domain_name, nt_errstr(status));
                goto disconnect;
        }
@@ -585,7 +608,7 @@ static NTSTATUS libnet_SetPassword_samr(struct libnet_context *ctx, TALLOC_CTX *
        status = dcerpc_samr_LookupNames(c.out.dcerpc_pipe, mem_ctx, &ln);
        if (!NT_STATUS_IS_OK(status)) {
                r->samr.out.error_string = talloc_asprintf(mem_ctx,
-                                               "samr_LookupNames for [%s] failed: %s\n",
+                                               "samr_LookupNames for [%s] failed: %s",
                                                r->samr.in.account_name, nt_errstr(status));
                goto disconnect;
        }
@@ -593,7 +616,7 @@ static NTSTATUS libnet_SetPassword_samr(struct libnet_context *ctx, TALLOC_CTX *
        /* check if we got one RID for the user */
        if (ln.out.rids.count != 1) {
                r->samr.out.error_string = talloc_asprintf(mem_ctx,
-                                               "samr_LookupNames for [%s] returns %d RIDs\n",
+                                               "samr_LookupNames for [%s] returns %d RIDs",
                                                r->samr.in.account_name, ln.out.rids.count);
                status = NT_STATUS_INVALID_PARAMETER;
                goto disconnect;        
@@ -610,7 +633,7 @@ static NTSTATUS libnet_SetPassword_samr(struct libnet_context *ctx, TALLOC_CTX *
        status = dcerpc_samr_OpenUser(c.out.dcerpc_pipe, mem_ctx, &ou);
        if (!NT_STATUS_IS_OK(status)) {
                r->samr.out.error_string = talloc_asprintf(mem_ctx,
-                                               "samr_OpenUser for [%s] failed: %s\n",
+                                               "samr_OpenUser for [%s] failed: %s",
                                                r->samr.in.account_name, nt_errstr(status));
                goto disconnect;
        }
@@ -620,6 +643,7 @@ static NTSTATUS libnet_SetPassword_samr(struct libnet_context *ctx, TALLOC_CTX *
        r2.samr_handle.in.newpassword   = r->samr.in.newpassword;
        r2.samr_handle.in.user_handle   = &u_handle;
        r2.samr_handle.in.dcerpc_pipe   = c.out.dcerpc_pipe;
+       r2.samr_handle.in.info21        = NULL;
 
        status = libnet_SetPassword(ctx, mem_ctx, &r2);