CVS update: samba/source/smbd
Volker Lendecke
Volker.Lendecke at SerNet.DE
Sat Mar 29 22:29:06 EST 2003
Hi, Andrew!
> If you specify a service type (ie. you don't send '?????' as the
> service type) then windows will check that this service type matches
> the service you are connecting to and will return
> NT_STATUS_BAD_DEVICE_TYPE if it doesn't match.
Thanks for the clarification!
With the following patch HEAD passes the (new) TCONDEV
test. NT4SP6/W2kSP3 also pass that, I did not check anything older
though.
I'm not sure if share_sanity_checks is the right place to put these
checks, but it looked best to me.
Volker
Index: smbd/service.c
===================================================================
RCS file: /space/vl/cvstree/samba/source/smbd/service.c,v
retrieving revision 1.117
diff -u -r1.117 service.c
--- smbd/service.c 18 Mar 2003 23:51:18 -0000 1.117
+++ smbd/service.c 29 Mar 2003 11:15:28 -0000
@@ -220,29 +220,33 @@
****************************************************************************/
static NTSTATUS share_sanity_checks(int snum, fstring dev)
{
-
if (!lp_snum_ok(snum) ||
!check_access(smbd_server_fd(),
lp_hostsallow(snum), lp_hostsdeny(snum))) {
return NT_STATUS_ACCESS_DENIED;
}
- /* you can only connect to the IPC$ service as an ipc device */
- if (strequal(lp_fstype(snum), "IPC"))
- fstrcpy(dev,"IPC");
-
if (dev[0] == '?' || !dev[0]) {
if (lp_print_ok(snum)) {
fstrcpy(dev,"LPT1:");
+ } else if (strequal(lp_fstype(snum), "IPC")) {
+ fstrcpy(dev, "IPC");
} else {
fstrcpy(dev,"A:");
}
}
- /* if the request is as a printer and you can't print then refuse */
strupper(dev);
- if (!lp_print_ok(snum) && (strncmp(dev,"LPT",3) == 0)) {
- DEBUG(1,("Attempt to connect to non-printer as a printer\n"));
+
+ if (lp_print_ok(snum)) {
+ if (!strcmp(dev, "LPT:")) {
+ return NT_STATUS_BAD_DEVICE_TYPE;
+ }
+ } else if (strequal(lp_fstype(snum), "IPC")) {
+ if (!strequal(dev, "IPC")) {
+ return NT_STATUS_BAD_DEVICE_TYPE;
+ }
+ } else if (!strequal(dev, "A:")) {
return NT_STATUS_BAD_DEVICE_TYPE;
}
Index: torture/torture.c
===================================================================
RCS file: /space/vl/cvstree/samba/source/torture/torture.c,v
retrieving revision 1.87
diff -u -r1.87 torture.c
--- torture/torture.c 11 Mar 2003 06:53:44 -0000 1.87
+++ torture/torture.c 29 Mar 2003 11:19:47 -0000
@@ -975,6 +975,103 @@
return True;
}
+static BOOL tcon_devtest(struct cli_state *cli,
+ const char *myshare, const char *devtype,
+ NTSTATUS expected_error)
+{
+ BOOL status;
+ BOOL ret;
+
+ status = cli_send_tconX(cli, myshare, devtype,
+ password, strlen(password)+1);
+
+ if (NT_STATUS_IS_OK(expected_error)) {
+ if (status) {
+ ret = True;
+ } else {
+ printf("tconX to share %s with type %s "
+ "should have succeeded but failed\n",
+ myshare, devtype);
+ ret = False;
+ }
+ cli_tdis(cli);
+ } else {
+ if (status) {
+ printf("tconx to share %s with type %s "
+ "should have failed but succeeded\n",
+ myshare, devtype);
+ ret = False;
+ } else {
+ if (NT_STATUS_EQUAL(cli_nt_error(cli),
+ expected_error)) {
+ ret = True;
+ } else {
+ printf("Returned unexpected error\n");
+ ret = False;
+ }
+ }
+ }
+ return ret;
+}
+
+/*
+ checks for correct tconX support
+ */
+static BOOL run_tcon_devtype_test(int dummy)
+{
+ static struct cli_state *cli1 = NULL;
+ BOOL retry;
+ int flags = 0;
+ NTSTATUS status;
+ BOOL ret;
+
+ status = cli_full_connection(&cli1, myname,
+ host, NULL, port_to_use,
+ NULL, NULL,
+ username, workgroup,
+ password, flags, &retry);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("could not open connection\n");
+ return False;
+ }
+
+ if (!tcon_devtest(cli1, "IPC$", "A:", NT_STATUS_BAD_DEVICE_TYPE))
+ ret = False;
+
+ if (!tcon_devtest(cli1, "IPC$", "?????", NT_STATUS_OK))
+ ret = False;
+
+ if (!tcon_devtest(cli1, "IPC$", "LPT:", NT_STATUS_BAD_DEVICE_TYPE))
+ ret = False;
+
+ if (!tcon_devtest(cli1, "IPC$", "IPC", NT_STATUS_OK))
+ ret = False;
+
+ if (!tcon_devtest(cli1, "IPC$", "FOOBA", NT_STATUS_BAD_DEVICE_TYPE))
+ ret = False;
+
+ if (!tcon_devtest(cli1, share, "A:", NT_STATUS_OK))
+ ret = False;
+
+ if (!tcon_devtest(cli1, share, "?????", NT_STATUS_OK))
+ ret = False;
+
+ if (!tcon_devtest(cli1, share, "LPT:", NT_STATUS_BAD_DEVICE_TYPE))
+ ret = False;
+
+ if (!tcon_devtest(cli1, share, "IPC", NT_STATUS_BAD_DEVICE_TYPE))
+ ret = False;
+
+ if (!tcon_devtest(cli1, share, "FOOBA", NT_STATUS_BAD_DEVICE_TYPE))
+ ret = False;
+
+ cli_shutdown(cli1);
+
+ printf("Passed tcondevtest\n");
+ return True;
+}
+
/*
This test checks that
@@ -4118,6 +4215,7 @@
{"DENY1", torture_denytest1, 0},
{"DENY2", torture_denytest2, 0},
{"TCON", run_tcon_test, 0},
+ {"TCONDEV", run_tcon_devtype_test, 0},
{"RW1", run_readwritetest, 0},
{"RW2", run_readwritemulti, FLAG_MULTIPROC},
{"RW3", run_readwritelarge, 0},
More information about the samba-cvs
mailing list