summaryrefslogtreecommitdiff
path: root/source4/torture
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2006-01-28 12:58:38 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:51:34 -0500
commitad6303f82fa862111c239b32b39f299e563a0802 (patch)
tree8534fe0fab5b44b8f50f70c46141225704e3de42 /source4/torture
parent654a21178fa7e908e3a2be42d5522ea1b1b23250 (diff)
downloadsamba-ad6303f82fa862111c239b32b39f299e563a0802.tar.gz
samba-ad6303f82fa862111c239b32b39f299e563a0802.tar.bz2
samba-ad6303f82fa862111c239b32b39f299e563a0802.zip
r13208: Clearly separate named pipes from the IPC$ NTVFS type.
This allows the easy addition of additional named pipes and removes the circular dependencies between the CIFS, RPC and RAP servers. Simple tests for a custom named pipe included. (This used to be commit 898d15acbd18e3b302a856c847e08c22c5024792)
Diffstat (limited to 'source4/torture')
-rw-r--r--source4/torture/config.mk11
-rw-r--r--source4/torture/ipc/np_echo.c119
-rw-r--r--source4/torture/ipc/rap.c (renamed from source4/torture/rap/rap.c)2
-rw-r--r--source4/torture/torture.c1
4 files changed, 127 insertions, 6 deletions
diff --git a/source4/torture/config.mk b/source4/torture/config.mk
index c7e8e2cc48..8d022cdce2 100644
--- a/source4/torture/config.mk
+++ b/source4/torture/config.mk
@@ -121,13 +121,14 @@ REQUIRED_SUBSYSTEMS = \
#################################
#################################
-# Start SUBSYSTEM TORTURE_RAP
-[SUBSYSTEM::TORTURE_RAP]
+# Start SUBSYSTEM TORTURE_IPC
+[SUBSYSTEM::TORTURE_IPC]
OBJ_FILES = \
- rap/rap.o
+ ipc/rap.o \
+ ipc/np_echo.o
REQUIRED_SUBSYSTEMS = \
LIBSMB
-# End SUBSYSTEM TORTURE_RAP
+# End SUBSYSTEM TORTURE_IPC
#################################
#################################
@@ -210,7 +211,7 @@ REQUIRED_SUBSYSTEMS = \
TORTURE_RAW \
TORTURE_SMB2 \
TORTURE_RPC \
- TORTURE_RAP \
+ TORTURE_IPC \
TORTURE_AUTH \
TORTURE_LOCAL \
TORTURE_NBENCH \
diff --git a/source4/torture/ipc/np_echo.c b/source4/torture/ipc/np_echo.c
new file mode 100644
index 0000000000..7d81d4fd37
--- /dev/null
+++ b/source4/torture/ipc/np_echo.c
@@ -0,0 +1,119 @@
+/*
+ Unix SMB/CIFS implementation.
+ Named Pipe Echo test
+ Copyright (C) Jelmer Vernooij 2005
+
+ 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
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ 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.
+*/
+
+#include "includes.h"
+#include "librpc/gen_ndr/security.h"
+#include "smb.h"
+#include "torture/torture.h"
+#include "libcli/raw/libcliraw.h"
+#include "libcli/libcli.h"
+
+#define ECHODATA "Good Times, Bad Times"
+
+int torture_np_echo(void)
+{
+ NTSTATUS status;
+ TALLOC_CTX *mem_ctx = NULL;
+ struct smbcli_state *cli;
+ const char *pipe_name = "\\NPECHO";
+ union smb_open open;
+ union smb_read read;
+ union smb_write write;
+ union smb_close close;
+ int fnum;
+ BOOL ret;
+
+ ret = torture_open_connection_share(mem_ctx, &cli,
+ lp_parm_string(-1, "torture", "host"),
+ "IPC$",
+ NULL);
+ if (!ret)
+ return False;
+
+ open.ntcreatex.level = RAW_OPEN_NTCREATEX;
+ open.ntcreatex.in.flags = 0;
+ open.ntcreatex.in.root_fid = 0;
+ open.ntcreatex.in.access_mask =
+ SEC_STD_READ_CONTROL |
+ SEC_FILE_WRITE_ATTRIBUTE |
+ SEC_FILE_WRITE_EA |
+ SEC_FILE_READ_DATA |
+ SEC_FILE_WRITE_DATA;
+ open.ntcreatex.in.file_attr = 0;
+ open.ntcreatex.in.alloc_size = 0;
+ open.ntcreatex.in.share_access =
+ NTCREATEX_SHARE_ACCESS_READ |
+ NTCREATEX_SHARE_ACCESS_WRITE;
+ open.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN;
+ open.ntcreatex.in.create_options = 0;
+ open.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_IMPERSONATION;
+ open.ntcreatex.in.security_flags = 0;
+ open.ntcreatex.in.fname = pipe_name;
+
+ status = smb_raw_open(cli->tree, cli->tree, &open);
+ if (NT_STATUS_IS_ERR(status))
+ return False;
+
+ fnum = open.ntcreatex.out.fnum;
+
+ write.write.level = RAW_WRITE_WRITE;
+ write.write.in.fnum = fnum;
+ write.write.in.count = strlen(ECHODATA);
+ write.write.in.offset = 0;
+ write.write.in.remaining = 0;
+ write.write.in.data = (const uint8_t *)ECHODATA;
+
+ status = smb_raw_write(cli->tree, &write);
+ if (NT_STATUS_IS_ERR(status))
+ return False;
+
+ if (write.write.out.nwritten != strlen(ECHODATA))
+ return False;
+
+ read.read.level = RAW_READ_READ;
+ read.read.in.fnum = fnum;
+ read.read.in.count = strlen(ECHODATA);
+ read.read.in.offset = 0;
+ read.read.in.remaining = 0;
+ read.read.out.data = talloc_array(mem_ctx, uint8_t, strlen(ECHODATA));
+
+ status = smb_raw_read(cli->tree, &read);
+
+ if (NT_STATUS_IS_ERR(status))
+ return False;
+
+ if (read.read.out.nread != strlen(ECHODATA))
+ return False;
+
+ if (memcmp(read.read.out.data, ECHODATA, strlen(ECHODATA)) != 0) {
+ printf ("np_echo: Returned data did not match!\n");
+ return False;
+ }
+
+ close.close.level = RAW_CLOSE_CLOSE;
+ close.close.in.fnum = fnum;
+ close.close.in.write_time = 0;
+
+ status = smb_raw_close(cli->tree, &close);
+ if (NT_STATUS_IS_ERR(status))
+ return False;
+
+ return True;
+}
diff --git a/source4/torture/rap/rap.c b/source4/torture/ipc/rap.c
index e9cb45e3b0..24cf1bb642 100644
--- a/source4/torture/rap/rap.c
+++ b/source4/torture/ipc/rap.c
@@ -20,10 +20,10 @@
*/
#include "includes.h"
-#include "torture/torture.h"
#include "rap.h"
#include "libcli/raw/libcliraw.h"
#include "libcli/libcli.h"
+#include "torture/torture.h"
struct rap_call {
uint16_t callno;
diff --git a/source4/torture/torture.c b/source4/torture/torture.c
index a37fde6938..465c703dc8 100644
--- a/source4/torture/torture.c
+++ b/source4/torture/torture.c
@@ -2246,6 +2246,7 @@ static struct {
{"RAW-ACLS", torture_raw_acls, 0},
{"RAW-RAP", torture_raw_rap, 0},
{"RAW-COMPOSITE", torture_raw_composite, 0},
+ {"RAW-PIPE-ECHO", torture_np_echo, 0 },
/* SMB2 tests */
{"SMB2-CONNECT", torture_smb2_connect, 0},