r23792: convert Samba4 to GPLv3
[kai/samba-autobuild/.git] / source4 / torture / rpc / session_key.c
index 26626c908ee6847550006e6a5cb4a36be514d031..d5026741fc44d34d48ef869f3d81a2f114a63146 100644 (file)
@@ -7,7 +7,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 "torture/torture.h"
-#include "librpc/gen_ndr/ndr_lsa.h"
+#include "librpc/gen_ndr/ndr_lsa_c.h"
 
-#include "torture/rpc/proto.h"
+#include "libcli/auth/libcli_auth.h"
+#include "torture/rpc/rpc.h"
 
 static void init_lsa_String(struct lsa_String *name, const char *s)
 {
@@ -138,7 +138,7 @@ static BOOL test_CreateSecret_basic(struct dcerpc_pipe *p,
                        
                        blob2 = data_blob_talloc(mem_ctx, NULL, blob1.length);
                        
-                       secret2 = sess_decrypt_string(&blob1, &session_key);
+                       secret2 = sess_decrypt_string(mem_ctx, &blob1, &session_key);
                        
                        if (strcmp(secret1, secret2) != 0) {
                                printf("Returned secret '%s' doesn't match '%s'\n", 
@@ -160,7 +160,7 @@ static BOOL test_CreateSecret_basic(struct dcerpc_pipe *p,
 
 /* TEST session key correctness by pushing and pulling secrets */
 
-BOOL torture_rpc_lsa_secrets(void
+BOOL torture_rpc_lsa_secrets(struct torture_context *torture
 {
         NTSTATUS status;
         struct dcerpc_pipe *p;
@@ -178,12 +178,15 @@ BOOL torture_rpc_lsa_secrets(void)
                return False;
        }
 
-       if (!test_lsa_OpenPolicy2(p, mem_ctx, &handle)) {
-               ret = False;
-       }
-
-       if (!test_CreateSecret_basic(p, mem_ctx, handle)) {
-               ret = False;
+       if (test_lsa_OpenPolicy2(p, mem_ctx, &handle)) {
+               if (!handle) {
+                       printf("OpenPolicy2 failed.  This test cannot run against this server\n");
+                       ret = False;
+               } else if (!test_CreateSecret_basic(p, mem_ctx, handle)) {
+                       ret = False;
+               }
+       } else {
+               return False;
        }
 
        talloc_free(mem_ctx);