From 4f5791ebd03eaec1c7da0865a383175b05102712 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 5 May 2024 19:47:29 +0200 Subject: Adding upstream version 2:4.17.12+dfsg. Signed-off-by: Daniel Baumann --- source4/torture/smb2/deny.c | 526 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 526 insertions(+) create mode 100644 source4/torture/smb2/deny.c (limited to 'source4/torture/smb2/deny.c') diff --git a/source4/torture/smb2/deny.c b/source4/torture/smb2/deny.c new file mode 100644 index 0000000..e42fd56 --- /dev/null +++ b/source4/torture/smb2/deny.c @@ -0,0 +1,526 @@ +/* + Unix SMB/CIFS implementation. + SMB2 torture tester - deny mode scanning functions + Copyright (C) Andrew Tridgell 2001 + Copyright (C) David Mulder 2019 + + 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 3 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, see . +*/ + +#include "includes.h" +#include "libcli/smb2/smb2.h" +#include "libcli/smb2/smb2_calls.h" +#include "torture/util.h" +#include "torture/smb2/proto.h" + +enum deny_result {A_0=0, A_X=1, A_R=2, A_W=3, A_RW=5}; + +static const char *denystr(int denymode) +{ + const struct { + int v; + const char *name; + } deny_modes[] = { + {NTCREATEX_SHARE_ACCESS_NONE, "NTCREATEX_SHARE_ACCESS_NONE"}, + {NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_DELETE, "NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_DELETE"}, + {NTCREATEX_SHARE_ACCESS_WRITE|NTCREATEX_SHARE_ACCESS_DELETE, "NTCREATEX_SHARE_ACCESS_WRITE|NTCREATEX_SHARE_ACCESS_DELETE"}, + {NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE|NTCREATEX_SHARE_ACCESS_DELETE, "NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE|NTCREATEX_SHARE_ACCESS_DELETE"}, + {-1, NULL}}; + int i; + for (i=0;deny_modes[i].name;i++) { + if (deny_modes[i].v == denymode) return deny_modes[i].name; + } + return "DENY_XXX"; +} + +static const char *openstr(int mode) +{ + const struct { + int v; + const char *name; + } open_modes[] = { + {SEC_FILE_READ_DATA|SEC_FILE_WRITE_DATA, "SEC_FILE_READ_DATA|SEC_FILE_WRITE_DATA"}, + {SEC_FILE_READ_DATA, "SEC_FILE_READ_DATA"}, + {SEC_FILE_WRITE_DATA, "SEC_FILE_WRITE_DATA"}, + {-1, NULL}}; + int i; + for (i=0;open_modes[i].name;i++) { + if (open_modes[i].v == mode) return open_modes[i].name; + } + return "O_XXX"; +} + +static const char *resultstr(enum deny_result res) +{ + const struct { + enum deny_result res; + const char *name; + } results[] = { + {A_X, "X"}, + {A_0, "-"}, + {A_R, "R"}, + {A_W, "W"}, + {A_RW,"RW"}}; + int i; + for (i=0;idescription = talloc_strdup(suite, "SMB2 deny tests"); + + return suite; +} -- cgit v1.2.3