util_smb: For some (unknown) reason the previous patch changed the permissions -...
[ira/wip.git] / source4 / torture / util_smb.c
index 32e4453acad9ce81f3c9688587df8dad92299efd..99b00d232939febb7f42dcb967a3e5c16b0727a9 100644 (file)
@@ -29,7 +29,7 @@
 #include "system/wait.h"
 #include "system/time.h"
 #include "torture/torture.h"
-#include "util/dlinklist.h"
+#include "../lib/util/dlinklist.h"
 #include "auth/credentials/credentials.h"
 #include "libcli/resolve/resolve.h"
 #include "param/param.h"
@@ -257,6 +257,23 @@ void *shm_setup(int size)
        int shmid;
        void *ret;
 
+#ifdef __QNXNTO__
+       shmid = shm_open("private", O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
+       if (shmid == -1) {
+               printf("can't get shared memory\n");
+               exit(1);
+       }
+       shm_unlink("private");
+       if (ftruncate(shmid, size) == -1) {
+               printf("can't set shared memory size\n");
+               exit(1);
+       }
+       ret = mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, shmid, 0);
+       if (ret == MAP_FAILED) {
+               printf("can't map shared memory\n");
+               exit(1);
+       }
+#else
        shmid = shmget(IPC_PRIVATE, size, SHM_R | SHM_W);
        if (shmid == -1) {
                printf("can't get shared memory\n");
@@ -275,6 +292,7 @@ void *shm_setup(int size)
           See Stevens "advanced programming in unix env" for details
           */
        shmctl(shmid, IPC_RMID, 0);
+#endif
        
        return ret;
 }
@@ -470,7 +488,7 @@ _PUBLIC_ bool torture_open_connection_share(TALLOC_CTX *mem_ctx,
                                   struct torture_context *tctx,
                                   const char *hostname, 
                                   const char *sharename,
-                                  struct event_context *ev)
+                                  struct tevent_context *ev)
 {
        NTSTATUS status;
 
@@ -486,9 +504,12 @@ _PUBLIC_ bool torture_open_connection_share(TALLOC_CTX *mem_ctx,
        status = smbcli_full_connection(mem_ctx, c, hostname, 
                                        lp_smb_ports(tctx->lp_ctx),
                                        sharename, NULL,
+                                       lp_socket_options(tctx->lp_ctx),
                                        cmdline_credentials, 
                                        lp_resolve_context(tctx->lp_ctx),
-                                       ev, &options, &session_options);
+                                       ev, &options, &session_options,
+                                       lp_iconv_convenience(tctx->lp_ctx),
+                                       lp_gensec_settings(tctx, tctx->lp_ctx));
        if (!NT_STATUS_IS_OK(status)) {
                printf("Failed to open connection - %s\n", nt_errstr(status));
                return false;
@@ -514,7 +535,7 @@ _PUBLIC_ bool torture_get_conn_index(int conn_index,
                return true;
        }
 
-       unc_list = file_lines_load(p, &num_unc_names, NULL);
+       unc_list = file_lines_load(p, &num_unc_names, 0, NULL);
        if (!unc_list || num_unc_names <= 0) {
                DEBUG(0,("Failed to load unc names list from '%s'\n", p));
                return false;
@@ -536,7 +557,7 @@ _PUBLIC_ bool torture_get_conn_index(int conn_index,
 _PUBLIC_ bool torture_open_connection_ev(struct smbcli_state **c,
                                         int conn_index,
                                         struct torture_context *tctx,
-                                        struct event_context *ev)
+                                        struct tevent_context *ev)
 {
        char *host, *share;
        bool ret;
@@ -580,10 +601,10 @@ _PUBLIC_ bool check_error(const char *location, struct smbcli_state *c,
        
        status = smbcli_nt_error(c->tree);
        if (NT_STATUS_IS_DOS(status)) {
-               int class, num;
-               class = NT_STATUS_DOS_CLASS(status);
+               int classnum, num;
+               classnum = NT_STATUS_DOS_CLASS(status);
                num = NT_STATUS_DOS_CODE(status);
-                if (eclass != class || ecode != num) {
+                if (eclass != classnum || ecode != num) {
                         printf("unexpected error code %s\n", nt_errstr(status));
                         printf(" expected %s or %s (at %s)\n", 
                               nt_errstr(NT_STATUS_DOS(eclass, ecode)), 
@@ -653,7 +674,10 @@ double torture_create_procs(struct torture_context *tctx,
                        pid_t mypid = getpid();
                        srandom(((int)mypid) ^ ((int)time(NULL)));
 
-                       asprintf(&myname, "CLIENT%d", i);
+                       if (asprintf(&myname, "CLIENT%d", i) == -1) {
+                               printf("asprintf failed\n");
+                               return -1;
+                       }
                        lp_set_cmdline(tctx->lp_ctx, "netbios name", myname);
                        free(myname);