| 1 |
/* |
| 2 |
Unix SMB/CIFS implementation. |
| 3 |
|
| 4 |
test alternate data streams |
| 5 |
|
| 6 |
Copyright (C) Andrew Tridgell 2004 |
| 7 |
|
| 8 |
This program is free software; you can redistribute it and/or modify |
| 9 |
it under the terms of the GNU General Public License as published by |
| 10 |
the Free Software Foundation; either version 3 of the License, or |
| 11 |
(at your option) any later version. |
| 12 |
|
| 13 |
This program is distributed in the hope that it will be useful, |
| 14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
GNU General Public License for more details. |
| 17 |
|
| 18 |
You should have received a copy of the GNU General Public License |
| 19 |
along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 |
*/ |
| 21 |
|
| 22 |
#include "includes.h" |
| 23 |
#include "system/locale.h" |
| 24 |
#include "torture/torture.h" |
| 25 |
#include "libcli/raw/libcliraw.h" |
| 26 |
#include "libcli/security/dom_sid.h" |
| 27 |
#include "libcli/security/security_descriptor.h" |
| 28 |
#include "system/filesys.h" |
| 29 |
#include "libcli/libcli.h" |
| 30 |
#include "torture/util.h" |
| 31 |
#include "lib/util/tsort.h" |
| 32 |
#include "torture/raw/proto.h" |
| 33 |
|
| 34 |
#define BASEDIR "\\teststreams" |
| 35 |
|
| 36 |
#define CHECK_STATUS(status, correct) \ |
| 37 |
torture_assert_ntstatus_equal_goto(tctx,status,correct,ret,done,"CHECK_STATUS") |
| 38 |
|
| 39 |
#define CHECK_VALUE(v, correct) \ |
| 40 |
torture_assert_int_equal(tctx,v,correct,"CHECK_VALUE") |
| 41 |
|
| 42 |
#define CHECK_NTTIME(v, correct) \ |
| 43 |
torture_assert_u64_equal(tctx,v,correct,"CHECK_NTTIME") |
| 44 |
|
| 45 |
#define CHECK_STR(v, correct) \ |
| 46 |
torture_assert_str_equal(tctx,v,correct,"CHECK_STR") |
| 47 |
|
| 48 |
/* |
| 49 |
check that a stream has the right contents |
| 50 |
*/ |
| 51 |
static bool check_stream(struct smbcli_state *cli, const char *location, |
| 52 |
TALLOC_CTX *mem_ctx, |
| 53 |
const char *fname, const char *sname, |
| 54 |
const char *value) |
| 55 |
{ |
| 56 |
int fnum; |
| 57 |
const char *full_name; |
| 58 |
uint8_t *buf; |
| 59 |
ssize_t ret; |
| 60 |
|
| 61 |
full_name = talloc_asprintf(mem_ctx, "%s:%s", fname, sname); |
| 62 |
|
| 63 |
fnum = smbcli_open(cli->tree, full_name, O_RDONLY, DENY_NONE); |
| 64 |
|
| 65 |
if (value == NULL) { |
| 66 |
if (fnum != -1) { |
| 67 |
printf("(%s) should have failed stream open of %s\n", |
| 68 |
location, full_name); |
| 69 |
return false; |
| 70 |
} |
| 71 |
return true; |
| 72 |
} |
| 73 |
|
| 74 |
if (fnum == -1) { |
| 75 |
printf("(%s) Failed to open stream '%s' - %s\n", |
| 76 |
location, full_name, smbcli_errstr(cli->tree)); |
| 77 |
return false; |
| 78 |
} |
| 79 |
|
| 80 |
buf = talloc_array(mem_ctx, uint8_t, strlen(value)+11); |
| 81 |
|
| 82 |
ret = smbcli_read(cli->tree, fnum, buf, 0, strlen(value)+11); |
| 83 |
if (ret != strlen(value)) { |
| 84 |
printf("(%s) Failed to read %lu bytes from stream '%s' - got %d\n", |
| 85 |
location, (long)strlen(value), full_name, (int)ret); |
| 86 |
return false; |
| 87 |
} |
| 88 |
|
| 89 |
if (memcmp(buf, value, strlen(value)) != 0) { |
| 90 |
printf("(%s) Bad data in stream\n", location); |
| 91 |
return false; |
| 92 |
} |
| 93 |
|
| 94 |
smbcli_close(cli->tree, fnum); |
| 95 |
return true; |
| 96 |
} |
| 97 |
|
| 98 |
static int qsort_string(char * const *s1, char * const *s2) |
| 99 |
{ |
| 100 |
return strcmp(*s1, *s2); |
| 101 |
} |
| 102 |
|
| 103 |
static int qsort_stream(const struct stream_struct *s1, const struct stream_struct *s2) |
| 104 |
{ |
| 105 |
return strcmp(s1->stream_name.s, s2->stream_name.s); |
| 106 |
} |
| 107 |
|
| 108 |
static bool check_stream_list(struct torture_context *tctx, |
| 109 |
struct smbcli_state *cli, const char *fname, |
| 110 |
int num_exp, const char **exp) |
| 111 |
{ |
| 112 |
union smb_fileinfo finfo; |
| 113 |
NTSTATUS status; |
| 114 |
int i; |
| 115 |
TALLOC_CTX *tmp_ctx = talloc_new(cli); |
| 116 |
char **exp_sort; |
| 117 |
struct stream_struct *stream_sort; |
| 118 |
bool ret = false; |
| 119 |
int fail = -1; |
| 120 |
|
| 121 |
finfo.generic.level = RAW_FILEINFO_STREAM_INFO; |
| 122 |
finfo.generic.in.file.path = fname; |
| 123 |
|
| 124 |
status = smb_raw_pathinfo(cli->tree, tmp_ctx, &finfo); |
| 125 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 126 |
|
| 127 |
CHECK_VALUE(finfo.stream_info.out.num_streams, num_exp); |
| 128 |
|
| 129 |
if (num_exp == 0) { |
| 130 |
ret = true; |
| 131 |
goto done; |
| 132 |
} |
| 133 |
|
| 134 |
exp_sort = (char **)talloc_memdup(tmp_ctx, exp, num_exp * sizeof(*exp)); |
| 135 |
|
| 136 |
if (exp_sort == NULL) { |
| 137 |
goto done; |
| 138 |
} |
| 139 |
|
| 140 |
TYPESAFE_QSORT(exp_sort, num_exp, qsort_string); |
| 141 |
|
| 142 |
stream_sort = (struct stream_struct *)talloc_memdup(tmp_ctx, |
| 143 |
finfo.stream_info.out.streams, |
| 144 |
finfo.stream_info.out.num_streams * |
| 145 |
sizeof(*stream_sort)); |
| 146 |
|
| 147 |
if (stream_sort == NULL) { |
| 148 |
goto done; |
| 149 |
} |
| 150 |
|
| 151 |
TYPESAFE_QSORT(stream_sort, finfo.stream_info.out.num_streams, qsort_stream); |
| 152 |
|
| 153 |
for (i=0; i<num_exp; i++) { |
| 154 |
if (strcmp(exp_sort[i], stream_sort[i].stream_name.s) != 0) { |
| 155 |
fail = i; |
| 156 |
goto show_streams; |
| 157 |
} |
| 158 |
} |
| 159 |
|
| 160 |
ret = true; |
| 161 |
done: |
| 162 |
talloc_free(tmp_ctx); |
| 163 |
return ret; |
| 164 |
|
| 165 |
show_streams: |
| 166 |
for (i=0; i<num_exp; i++) { |
| 167 |
torture_comment(tctx, "stream names '%s' '%s'\n", |
| 168 |
exp_sort[i], stream_sort[i].stream_name.s); |
| 169 |
} |
| 170 |
CHECK_STR(stream_sort[fail].stream_name.s, exp_sort[fail]); |
| 171 |
talloc_free(tmp_ctx); |
| 172 |
return ret; |
| 173 |
} |
| 174 |
|
| 175 |
/* |
| 176 |
test behavior of streams on directories |
| 177 |
*/ |
| 178 |
static bool test_stream_dir(struct torture_context *tctx, |
| 179 |
struct smbcli_state *cli) |
| 180 |
{ |
| 181 |
NTSTATUS status; |
| 182 |
union smb_open io; |
| 183 |
const char *fname = BASEDIR "\\stream.txt"; |
| 184 |
const char *sname1; |
| 185 |
bool ret = true; |
| 186 |
const char *basedir_data; |
| 187 |
|
| 188 |
torture_assert(tctx, torture_setup_dir(cli, BASEDIR), "Failed to setup up test directory: " BASEDIR); |
| 189 |
|
| 190 |
basedir_data = talloc_asprintf(tctx, "%s::$DATA", BASEDIR); |
| 191 |
sname1 = talloc_asprintf(tctx, "%s:%s", fname, "Stream One"); |
| 192 |
|
| 193 |
printf("(%s) opening non-existent directory stream\n", __location__); |
| 194 |
io.generic.level = RAW_OPEN_NTCREATEX; |
| 195 |
io.ntcreatex.in.root_fid.fnum = 0; |
| 196 |
io.ntcreatex.in.flags = 0; |
| 197 |
io.ntcreatex.in.access_mask = SEC_FILE_WRITE_DATA; |
| 198 |
io.ntcreatex.in.create_options = NTCREATEX_OPTIONS_DIRECTORY; |
| 199 |
io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; |
| 200 |
io.ntcreatex.in.share_access = 0; |
| 201 |
io.ntcreatex.in.alloc_size = 0; |
| 202 |
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE; |
| 203 |
io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; |
| 204 |
io.ntcreatex.in.security_flags = 0; |
| 205 |
io.ntcreatex.in.fname = sname1; |
| 206 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 207 |
CHECK_STATUS(status, NT_STATUS_NOT_A_DIRECTORY); |
| 208 |
|
| 209 |
printf("(%s) opening basedir stream\n", __location__); |
| 210 |
io.generic.level = RAW_OPEN_NTCREATEX; |
| 211 |
io.ntcreatex.in.root_fid.fnum = 0; |
| 212 |
io.ntcreatex.in.flags = 0; |
| 213 |
io.ntcreatex.in.access_mask = SEC_FILE_WRITE_DATA; |
| 214 |
io.ntcreatex.in.create_options = NTCREATEX_OPTIONS_DIRECTORY; |
| 215 |
io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_DIRECTORY; |
| 216 |
io.ntcreatex.in.share_access = 0; |
| 217 |
io.ntcreatex.in.alloc_size = 0; |
| 218 |
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN; |
| 219 |
io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; |
| 220 |
io.ntcreatex.in.security_flags = 0; |
| 221 |
io.ntcreatex.in.fname = basedir_data; |
| 222 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 223 |
CHECK_STATUS(status, NT_STATUS_NOT_A_DIRECTORY); |
| 224 |
|
| 225 |
printf("(%s) opening basedir ::$DATA stream\n", __location__); |
| 226 |
io.generic.level = RAW_OPEN_NTCREATEX; |
| 227 |
io.ntcreatex.in.root_fid.fnum = 0; |
| 228 |
io.ntcreatex.in.flags = 0x10; |
| 229 |
io.ntcreatex.in.access_mask = SEC_FILE_WRITE_DATA; |
| 230 |
io.ntcreatex.in.create_options = 0; |
| 231 |
io.ntcreatex.in.file_attr = 0; |
| 232 |
io.ntcreatex.in.share_access = 0; |
| 233 |
io.ntcreatex.in.alloc_size = 0; |
| 234 |
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN; |
| 235 |
io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; |
| 236 |
io.ntcreatex.in.security_flags = 0; |
| 237 |
io.ntcreatex.in.fname = basedir_data; |
| 238 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 239 |
CHECK_STATUS(status, NT_STATUS_FILE_IS_A_DIRECTORY); |
| 240 |
|
| 241 |
printf("(%s) list the streams on the basedir\n", __location__); |
| 242 |
ret &= check_stream_list(tctx, cli, BASEDIR, 0, NULL); |
| 243 |
done: |
| 244 |
smbcli_deltree(cli->tree, BASEDIR); |
| 245 |
return ret; |
| 246 |
} |
| 247 |
|
| 248 |
/* |
| 249 |
test basic behavior of streams on directories |
| 250 |
*/ |
| 251 |
static bool test_stream_io(struct torture_context *tctx, |
| 252 |
struct smbcli_state *cli) |
| 253 |
{ |
| 254 |
NTSTATUS status; |
| 255 |
union smb_open io; |
| 256 |
const char *fname = BASEDIR "\\stream.txt"; |
| 257 |
const char *sname1, *sname2; |
| 258 |
bool ret = true; |
| 259 |
int fnum = -1; |
| 260 |
ssize_t retsize; |
| 261 |
|
| 262 |
const char *one[] = { "::$DATA" }; |
| 263 |
const char *two[] = { "::$DATA", ":Second Stream:$DATA" }; |
| 264 |
const char *three[] = { "::$DATA", ":Stream One:$DATA", |
| 265 |
":Second Stream:$DATA" }; |
| 266 |
|
| 267 |
torture_assert(tctx, torture_setup_dir(cli, BASEDIR), "Failed to setup up test directory: " BASEDIR); |
| 268 |
|
| 269 |
sname1 = talloc_asprintf(tctx, "%s:%s", fname, "Stream One"); |
| 270 |
sname2 = talloc_asprintf(tctx, "%s:%s:$DaTa", fname, "Second Stream"); |
| 271 |
|
| 272 |
printf("(%s) creating a stream on a non-existent file\n", __location__); |
| 273 |
io.generic.level = RAW_OPEN_NTCREATEX; |
| 274 |
io.ntcreatex.in.root_fid.fnum = 0; |
| 275 |
io.ntcreatex.in.flags = 0; |
| 276 |
io.ntcreatex.in.access_mask = SEC_FILE_WRITE_DATA; |
| 277 |
io.ntcreatex.in.create_options = 0; |
| 278 |
io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; |
| 279 |
io.ntcreatex.in.share_access = 0; |
| 280 |
io.ntcreatex.in.alloc_size = 0; |
| 281 |
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE; |
| 282 |
io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; |
| 283 |
io.ntcreatex.in.security_flags = 0; |
| 284 |
io.ntcreatex.in.fname = sname1; |
| 285 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 286 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 287 |
fnum = io.ntcreatex.out.file.fnum; |
| 288 |
|
| 289 |
ret &= check_stream(cli, __location__, tctx, fname, "Stream One", NULL); |
| 290 |
|
| 291 |
printf("(%s) check that open of base file is allowed\n", __location__); |
| 292 |
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN; |
| 293 |
io.ntcreatex.in.fname = fname; |
| 294 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 295 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 296 |
smbcli_close(cli->tree, io.ntcreatex.out.file.fnum); |
| 297 |
|
| 298 |
printf("(%s) writing to stream\n", __location__); |
| 299 |
retsize = smbcli_write(cli->tree, fnum, 0, "test data", 0, 9); |
| 300 |
CHECK_VALUE(retsize, 9); |
| 301 |
|
| 302 |
smbcli_close(cli->tree, fnum); |
| 303 |
|
| 304 |
ret &= check_stream(cli, __location__, tctx, fname, "Stream One", "test data"); |
| 305 |
|
| 306 |
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN; |
| 307 |
io.ntcreatex.in.fname = sname1; |
| 308 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 309 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 310 |
fnum = io.ntcreatex.out.file.fnum; |
| 311 |
|
| 312 |
printf("(%s) modifying stream\n", __location__); |
| 313 |
retsize = smbcli_write(cli->tree, fnum, 0, "MORE DATA ", 5, 10); |
| 314 |
CHECK_VALUE(retsize, 10); |
| 315 |
|
| 316 |
smbcli_close(cli->tree, fnum); |
| 317 |
|
| 318 |
ret &= check_stream(cli, __location__, tctx, fname, "Stream One:$FOO", NULL); |
| 319 |
|
| 320 |
printf("(%s) creating a stream2 on a existing file\n", __location__); |
| 321 |
io.ntcreatex.in.fname = sname2; |
| 322 |
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF; |
| 323 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 324 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 325 |
fnum = io.ntcreatex.out.file.fnum; |
| 326 |
|
| 327 |
printf("(%s) modifying stream\n", __location__); |
| 328 |
retsize = smbcli_write(cli->tree, fnum, 0, "SECOND STREAM", 0, 13); |
| 329 |
CHECK_VALUE(retsize, 13); |
| 330 |
|
| 331 |
smbcli_close(cli->tree, fnum); |
| 332 |
|
| 333 |
ret &= check_stream(cli, __location__, tctx, fname, "Stream One", "test MORE DATA "); |
| 334 |
ret &= check_stream(cli, __location__, tctx, fname, "Stream One:$DATA", "test MORE DATA "); |
| 335 |
ret &= check_stream(cli, __location__, tctx, fname, "Stream One:", NULL); |
| 336 |
ret &= check_stream(cli, __location__, tctx, fname, "Second Stream", "SECOND STREAM"); |
| 337 |
ret &= check_stream(cli, __location__, tctx, fname, |
| 338 |
"SECOND STREAM:$DATA", "SECOND STREAM"); |
| 339 |
ret &= check_stream(cli, __location__, tctx, fname, "Second Stream:$DATA", "SECOND STREAM"); |
| 340 |
ret &= check_stream(cli, __location__, tctx, fname, "Second Stream:", NULL); |
| 341 |
ret &= check_stream(cli, __location__, tctx, fname, "Second Stream:$FOO", NULL); |
| 342 |
|
| 343 |
check_stream_list(tctx, cli, fname, 3, three); |
| 344 |
|
| 345 |
printf("(%s) deleting stream\n", __location__); |
| 346 |
status = smbcli_unlink(cli->tree, sname1); |
| 347 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 348 |
|
| 349 |
check_stream_list(tctx, cli, fname, 2, two); |
| 350 |
|
| 351 |
printf("(%s) delete a stream via delete-on-close\n", __location__); |
| 352 |
io.ntcreatex.in.fname = sname2; |
| 353 |
io.ntcreatex.in.create_options = NTCREATEX_OPTIONS_DELETE_ON_CLOSE; |
| 354 |
io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_DELETE; |
| 355 |
io.ntcreatex.in.access_mask = SEC_STD_DELETE; |
| 356 |
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN; |
| 357 |
|
| 358 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 359 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 360 |
fnum = io.ntcreatex.out.file.fnum; |
| 361 |
|
| 362 |
smbcli_close(cli->tree, fnum); |
| 363 |
status = smbcli_unlink(cli->tree, sname2); |
| 364 |
CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); |
| 365 |
|
| 366 |
check_stream_list(tctx, cli, fname, 1, one); |
| 367 |
|
| 368 |
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE; |
| 369 |
io.ntcreatex.in.fname = sname1; |
| 370 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 371 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 372 |
smbcli_close(cli->tree, io.ntcreatex.out.file.fnum); |
| 373 |
io.ntcreatex.in.fname = sname2; |
| 374 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 375 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 376 |
smbcli_close(cli->tree, io.ntcreatex.out.file.fnum); |
| 377 |
|
| 378 |
printf("(%s) deleting file\n", __location__); |
| 379 |
status = smbcli_unlink(cli->tree, fname); |
| 380 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 381 |
|
| 382 |
done: |
| 383 |
smbcli_close(cli->tree, fnum); |
| 384 |
smbcli_deltree(cli->tree, BASEDIR); |
| 385 |
return ret; |
| 386 |
} |
| 387 |
|
| 388 |
/* |
| 389 |
test stream sharemodes |
| 390 |
*/ |
| 391 |
static bool test_stream_sharemodes(struct torture_context *tctx, |
| 392 |
struct smbcli_state *cli) |
| 393 |
{ |
| 394 |
NTSTATUS status; |
| 395 |
union smb_open io; |
| 396 |
const char *fname = BASEDIR "\\stream.txt"; |
| 397 |
const char *sname1, *sname2; |
| 398 |
bool ret = true; |
| 399 |
int fnum1 = -1; |
| 400 |
int fnum2 = -1; |
| 401 |
|
| 402 |
torture_assert(tctx, torture_setup_dir(cli, BASEDIR), "Failed to setup up test directory: " BASEDIR); |
| 403 |
|
| 404 |
sname1 = talloc_asprintf(tctx, "%s:%s", fname, "Stream One"); |
| 405 |
sname2 = talloc_asprintf(tctx, "%s:%s:$DaTa", fname, "Second Stream"); |
| 406 |
|
| 407 |
printf("(%s) testing stream share mode conflicts\n", __location__); |
| 408 |
io.generic.level = RAW_OPEN_NTCREATEX; |
| 409 |
io.ntcreatex.in.root_fid.fnum = 0; |
| 410 |
io.ntcreatex.in.flags = 0; |
| 411 |
io.ntcreatex.in.access_mask = SEC_FILE_WRITE_DATA; |
| 412 |
io.ntcreatex.in.create_options = 0; |
| 413 |
io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; |
| 414 |
io.ntcreatex.in.share_access = 0; |
| 415 |
io.ntcreatex.in.alloc_size = 0; |
| 416 |
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE; |
| 417 |
io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; |
| 418 |
io.ntcreatex.in.security_flags = 0; |
| 419 |
io.ntcreatex.in.fname = sname1; |
| 420 |
|
| 421 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 422 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 423 |
fnum1 = io.ntcreatex.out.file.fnum; |
| 424 |
|
| 425 |
/* |
| 426 |
* A different stream does not give a sharing violation |
| 427 |
*/ |
| 428 |
|
| 429 |
io.ntcreatex.in.fname = sname2; |
| 430 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 431 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 432 |
fnum2 = io.ntcreatex.out.file.fnum; |
| 433 |
|
| 434 |
/* |
| 435 |
* ... whereas the same stream does with unchanged access/share_access |
| 436 |
* flags |
| 437 |
*/ |
| 438 |
|
| 439 |
io.ntcreatex.in.fname = sname1; |
| 440 |
io.ntcreatex.in.open_disposition = 0; |
| 441 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 442 |
CHECK_STATUS(status, NT_STATUS_SHARING_VIOLATION); |
| 443 |
|
| 444 |
io.ntcreatex.in.fname = sname2; |
| 445 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 446 |
CHECK_STATUS(status, NT_STATUS_SHARING_VIOLATION); |
| 447 |
|
| 448 |
done: |
| 449 |
if (fnum1 != -1) smbcli_close(cli->tree, fnum1); |
| 450 |
if (fnum2 != -1) smbcli_close(cli->tree, fnum2); |
| 451 |
status = smbcli_unlink(cli->tree, fname); |
| 452 |
smbcli_deltree(cli->tree, BASEDIR); |
| 453 |
return ret; |
| 454 |
} |
| 455 |
|
| 456 |
/* |
| 457 |
* Test FILE_SHARE_DELETE on streams |
| 458 |
* |
| 459 |
* A stream opened with !FILE_SHARE_DELETE prevents the main file to be opened |
| 460 |
* with SEC_STD_DELETE. |
| 461 |
* |
| 462 |
* The main file opened with !FILE_SHARE_DELETE does *not* prevent a stream to |
| 463 |
* be opened with SEC_STD_DELETE. |
| 464 |
* |
| 465 |
* A stream held open with FILE_SHARE_DELETE allows the file to be |
| 466 |
* deleted. After the main file is deleted, access to the open file descriptor |
| 467 |
* still works, but all name-based access to both the main file as well as the |
| 468 |
* stream is denied with DELETE pending. |
| 469 |
* |
| 470 |
* This means, an open of the main file with SEC_STD_DELETE should walk all |
| 471 |
* streams and also open them with SEC_STD_DELETE. If any of these opens gives |
| 472 |
* SHARING_VIOLATION, the main open fails. |
| 473 |
* |
| 474 |
* Closing the main file after delete_on_close has been set does not really |
| 475 |
* unlink it but leaves the corresponding share mode entry with |
| 476 |
* delete_on_close being set around until all streams are closed. |
| 477 |
* |
| 478 |
* Opening a stream must also look at the main file's share mode entry, look |
| 479 |
* at the delete_on_close bit and potentially return DELETE_PENDING. |
| 480 |
*/ |
| 481 |
|
| 482 |
static bool test_stream_delete(struct torture_context *tctx, |
| 483 |
struct smbcli_state *cli) |
| 484 |
{ |
| 485 |
NTSTATUS status; |
| 486 |
union smb_open io; |
| 487 |
const char *fname = BASEDIR "\\stream.txt"; |
| 488 |
const char *sname1; |
| 489 |
bool ret = true; |
| 490 |
int fnum = -1; |
| 491 |
uint8_t buf[9]; |
| 492 |
ssize_t retsize; |
| 493 |
union smb_fileinfo finfo; |
| 494 |
|
| 495 |
torture_assert(tctx, torture_setup_dir(cli, BASEDIR), "Failed to setup up test directory: " BASEDIR); |
| 496 |
|
| 497 |
sname1 = talloc_asprintf(tctx, "%s:%s", fname, "Stream One"); |
| 498 |
|
| 499 |
printf("(%s) opening non-existent file stream\n", __location__); |
| 500 |
io.generic.level = RAW_OPEN_NTCREATEX; |
| 501 |
io.ntcreatex.in.root_fid.fnum = 0; |
| 502 |
io.ntcreatex.in.flags = 0; |
| 503 |
io.ntcreatex.in.access_mask = SEC_FILE_READ_DATA|SEC_FILE_WRITE_DATA; |
| 504 |
io.ntcreatex.in.create_options = 0; |
| 505 |
io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; |
| 506 |
io.ntcreatex.in.share_access = 0; |
| 507 |
io.ntcreatex.in.alloc_size = 0; |
| 508 |
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE; |
| 509 |
io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; |
| 510 |
io.ntcreatex.in.security_flags = 0; |
| 511 |
io.ntcreatex.in.fname = sname1; |
| 512 |
|
| 513 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 514 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 515 |
fnum = io.ntcreatex.out.file.fnum; |
| 516 |
|
| 517 |
retsize = smbcli_write(cli->tree, fnum, 0, "test data", 0, 9); |
| 518 |
CHECK_VALUE(retsize, 9); |
| 519 |
|
| 520 |
/* |
| 521 |
* One stream opened without FILE_SHARE_DELETE prevents the main file |
| 522 |
* to be deleted or even opened with DELETE access |
| 523 |
*/ |
| 524 |
|
| 525 |
status = smbcli_unlink(cli->tree, fname); |
| 526 |
CHECK_STATUS(status, NT_STATUS_SHARING_VIOLATION); |
| 527 |
|
| 528 |
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN; |
| 529 |
io.ntcreatex.in.fname = fname; |
| 530 |
io.ntcreatex.in.access_mask = SEC_STD_DELETE; |
| 531 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 532 |
CHECK_STATUS(status, NT_STATUS_SHARING_VIOLATION); |
| 533 |
|
| 534 |
smbcli_close(cli->tree, fnum); |
| 535 |
|
| 536 |
/* |
| 537 |
* ... but unlink works if a stream is opened with FILE_SHARE_DELETE |
| 538 |
*/ |
| 539 |
|
| 540 |
io.ntcreatex.in.fname = sname1; |
| 541 |
io.ntcreatex.in.access_mask = SEC_FILE_READ_DATA|SEC_FILE_WRITE_DATA; |
| 542 |
io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_DELETE; |
| 543 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 544 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 545 |
fnum = io.ntcreatex.out.file.fnum; |
| 546 |
|
| 547 |
status = smbcli_unlink(cli->tree, fname); |
| 548 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 549 |
|
| 550 |
/* |
| 551 |
* file access still works on the stream while the main file is closed |
| 552 |
*/ |
| 553 |
|
| 554 |
retsize = smbcli_read(cli->tree, fnum, buf, 0, 9); |
| 555 |
CHECK_VALUE(retsize, 9); |
| 556 |
|
| 557 |
finfo.generic.level = RAW_FILEINFO_STANDARD; |
| 558 |
finfo.generic.in.file.path = fname; |
| 559 |
|
| 560 |
/* |
| 561 |
* name-based access to both the main file and the stream does not |
| 562 |
* work anymore but gives DELETE_PENDING |
| 563 |
*/ |
| 564 |
|
| 565 |
status = smb_raw_pathinfo(cli->tree, tctx, &finfo); |
| 566 |
CHECK_STATUS(status, NT_STATUS_DELETE_PENDING); |
| 567 |
|
| 568 |
/* |
| 569 |
* older S3 doesn't do this |
| 570 |
*/ |
| 571 |
finfo.generic.in.file.path = sname1; |
| 572 |
status = smb_raw_pathinfo(cli->tree, tctx, &finfo); |
| 573 |
CHECK_STATUS(status, NT_STATUS_DELETE_PENDING); |
| 574 |
|
| 575 |
/* |
| 576 |
* fd-based qfileinfo on the stream still works, the stream does not |
| 577 |
* have the delete-on-close bit set. This could mean that open on the |
| 578 |
* stream first opens the main file |
| 579 |
*/ |
| 580 |
|
| 581 |
finfo.all_info.level = RAW_FILEINFO_ALL_INFO; |
| 582 |
finfo.all_info.in.file.fnum = fnum; |
| 583 |
|
| 584 |
status = smb_raw_fileinfo(cli->tree, tctx, &finfo); |
| 585 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 586 |
|
| 587 |
/* w2k and w2k3 return 0 and w2k8 returns 1 */ |
| 588 |
if (TARGET_IS_WINXP(tctx) || TARGET_IS_W2K3(tctx) || |
| 589 |
TARGET_IS_SAMBA3(tctx) || TARGET_IS_SAMBA4(tctx)) { |
| 590 |
CHECK_VALUE(finfo.all_info.out.delete_pending, 0); |
| 591 |
} else { |
| 592 |
CHECK_VALUE(finfo.all_info.out.delete_pending, 1); |
| 593 |
} |
| 594 |
|
| 595 |
smbcli_close(cli->tree, fnum); |
| 596 |
|
| 597 |
/* |
| 598 |
* After closing the stream the file is really gone. |
| 599 |
*/ |
| 600 |
|
| 601 |
finfo.generic.in.file.path = fname; |
| 602 |
status = smb_raw_pathinfo(cli->tree, tctx, &finfo); |
| 603 |
CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); |
| 604 |
|
| 605 |
io.ntcreatex.in.access_mask = SEC_FILE_READ_DATA|SEC_FILE_WRITE_DATA |
| 606 |
|SEC_STD_DELETE; |
| 607 |
io.ntcreatex.in.create_options = NTCREATEX_OPTIONS_DELETE_ON_CLOSE; |
| 608 |
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE; |
| 609 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 610 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 611 |
fnum = io.ntcreatex.out.file.fnum; |
| 612 |
|
| 613 |
finfo.generic.in.file.path = fname; |
| 614 |
status = smb_raw_pathinfo(cli->tree, tctx, &finfo); |
| 615 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 616 |
|
| 617 |
smbcli_close(cli->tree, fnum); |
| 618 |
|
| 619 |
status = smb_raw_pathinfo(cli->tree, tctx, &finfo); |
| 620 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 621 |
done: |
| 622 |
smbcli_close(cli->tree, fnum); |
| 623 |
smbcli_unlink(cli->tree, fname); |
| 624 |
smbcli_deltree(cli->tree, BASEDIR); |
| 625 |
return ret; |
| 626 |
} |
| 627 |
|
| 628 |
/* |
| 629 |
test stream names |
| 630 |
*/ |
| 631 |
static bool test_stream_names(struct torture_context *tctx, |
| 632 |
struct smbcli_state *cli) |
| 633 |
{ |
| 634 |
NTSTATUS status; |
| 635 |
union smb_open io; |
| 636 |
union smb_fileinfo info; |
| 637 |
union smb_fileinfo finfo; |
| 638 |
union smb_fileinfo stinfo; |
| 639 |
union smb_setfileinfo sinfo; |
| 640 |
const char *fname = BASEDIR "\\stream_names.txt"; |
| 641 |
const char *sname1, *sname1b, *sname1c, *sname1d; |
| 642 |
const char *sname2, *snamew, *snamew2; |
| 643 |
const char *snamer1; |
| 644 |
bool ret = true; |
| 645 |
int fnum1 = -1; |
| 646 |
int fnum2 = -1; |
| 647 |
int fnum3 = -1; |
| 648 |
int i; |
| 649 |
const char *four[4] = { |
| 650 |
"::$DATA", |
| 651 |
":\x05Stream\n One:$DATA", |
| 652 |
":MStream Two:$DATA", |
| 653 |
":?Stream*:$DATA" |
| 654 |
}; |
| 655 |
const char *five1[5] = { |
| 656 |
"::$DATA", |
| 657 |
":\x05Stream\n One:$DATA", |
| 658 |
":BeforeRename:$DATA", |
| 659 |
":MStream Two:$DATA", |
| 660 |
":?Stream*:$DATA" |
| 661 |
}; |
| 662 |
const char *five2[5] = { |
| 663 |
"::$DATA", |
| 664 |
":\x05Stream\n One:$DATA", |
| 665 |
":AfterRename:$DATA", |
| 666 |
":MStream Two:$DATA", |
| 667 |
":?Stream*:$DATA" |
| 668 |
}; |
| 669 |
|
| 670 |
torture_assert(tctx, torture_setup_dir(cli, BASEDIR), "Failed to setup up test directory: " BASEDIR); |
| 671 |
|
| 672 |
sname1 = talloc_asprintf(tctx, "%s:%s", fname, "\x05Stream\n One"); |
| 673 |
sname1b = talloc_asprintf(tctx, "%s:", sname1); |
| 674 |
sname1c = talloc_asprintf(tctx, "%s:$FOO", sname1); |
| 675 |
sname1d = talloc_asprintf(tctx, "%s:?D*a", sname1); |
| 676 |
sname2 = talloc_asprintf(tctx, "%s:%s:$DaTa", fname, "MStream Two"); |
| 677 |
snamew = talloc_asprintf(tctx, "%s:%s:$DATA", fname, "?Stream*"); |
| 678 |
snamew2 = talloc_asprintf(tctx, "%s\\stream*:%s:$DATA", BASEDIR, "?Stream*"); |
| 679 |
snamer1 = talloc_asprintf(tctx, "%s:%s:$DATA", fname, "BeforeRename"); |
| 680 |
|
| 681 |
printf("(%s) testing stream names\n", __location__); |
| 682 |
io.generic.level = RAW_OPEN_NTCREATEX; |
| 683 |
io.ntcreatex.in.root_fid.fnum = 0; |
| 684 |
io.ntcreatex.in.flags = 0; |
| 685 |
io.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; |
| 686 |
io.ntcreatex.in.create_options = 0; |
| 687 |
io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; |
| 688 |
io.ntcreatex.in.share_access = |
| 689 |
NTCREATEX_SHARE_ACCESS_READ | |
| 690 |
NTCREATEX_SHARE_ACCESS_WRITE; |
| 691 |
io.ntcreatex.in.alloc_size = 0; |
| 692 |
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE; |
| 693 |
io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; |
| 694 |
io.ntcreatex.in.security_flags = 0; |
| 695 |
io.ntcreatex.in.fname = fname; |
| 696 |
|
| 697 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 698 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 699 |
fnum1 = io.ntcreatex.out.file.fnum; |
| 700 |
|
| 701 |
torture_comment(tctx, "Adding two EAs to base file\n"); |
| 702 |
ZERO_STRUCT(sinfo); |
| 703 |
sinfo.generic.level = RAW_SFILEINFO_EA_SET; |
| 704 |
sinfo.generic.in.file.fnum = fnum1; |
| 705 |
sinfo.ea_set.in.num_eas = 2; |
| 706 |
sinfo.ea_set.in.eas = talloc_array(tctx, struct ea_struct, 2); |
| 707 |
sinfo.ea_set.in.eas[0].flags = 0; |
| 708 |
sinfo.ea_set.in.eas[0].name.s = "EAONE"; |
| 709 |
sinfo.ea_set.in.eas[0].value = data_blob_string_const("VALUE1"); |
| 710 |
sinfo.ea_set.in.eas[1].flags = 0; |
| 711 |
sinfo.ea_set.in.eas[1].name.s = "SECONDEA"; |
| 712 |
sinfo.ea_set.in.eas[1].value = data_blob_string_const("ValueTwo"); |
| 713 |
|
| 714 |
status = smb_raw_setfileinfo(cli->tree, &sinfo); |
| 715 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 716 |
|
| 717 |
/* |
| 718 |
* Make sure the create time of the streams are different from the |
| 719 |
* base file. |
| 720 |
*/ |
| 721 |
sleep(2); |
| 722 |
smbcli_close(cli->tree, fnum1); |
| 723 |
|
| 724 |
io.generic.level = RAW_OPEN_NTCREATEX; |
| 725 |
io.ntcreatex.in.root_fid.fnum = 0; |
| 726 |
io.ntcreatex.in.flags = 0; |
| 727 |
io.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; |
| 728 |
io.ntcreatex.in.create_options = 0; |
| 729 |
io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; |
| 730 |
io.ntcreatex.in.share_access = |
| 731 |
NTCREATEX_SHARE_ACCESS_READ | |
| 732 |
NTCREATEX_SHARE_ACCESS_WRITE; |
| 733 |
io.ntcreatex.in.alloc_size = 0; |
| 734 |
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE; |
| 735 |
io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; |
| 736 |
io.ntcreatex.in.security_flags = 0; |
| 737 |
io.ntcreatex.in.fname = sname1; |
| 738 |
|
| 739 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 740 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 741 |
fnum1 = io.ntcreatex.out.file.fnum; |
| 742 |
|
| 743 |
torture_comment(tctx, "Adding one EAs to first stream file\n"); |
| 744 |
ZERO_STRUCT(sinfo); |
| 745 |
sinfo.generic.level = RAW_SFILEINFO_EA_SET; |
| 746 |
sinfo.generic.in.file.fnum = fnum1; |
| 747 |
sinfo.ea_set.in.num_eas = 1; |
| 748 |
sinfo.ea_set.in.eas = talloc_array(tctx, struct ea_struct, 1); |
| 749 |
sinfo.ea_set.in.eas[0].flags = 0; |
| 750 |
sinfo.ea_set.in.eas[0].name.s = "STREAMEA"; |
| 751 |
sinfo.ea_set.in.eas[0].value = data_blob_string_const("EA_VALUE1"); |
| 752 |
|
| 753 |
status = smb_raw_setfileinfo(cli->tree, &sinfo); |
| 754 |
CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER); |
| 755 |
|
| 756 |
status = torture_check_ea(cli, sname1, "STREAMEA", "EA_VALUE1"); |
| 757 |
CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER); |
| 758 |
|
| 759 |
ZERO_STRUCT(info); |
| 760 |
info.generic.level = RAW_FILEINFO_ALL_EAS; |
| 761 |
info.all_eas.in.file.path = sname1; |
| 762 |
|
| 763 |
status = smb_raw_pathinfo(cli->tree, tctx, &info); |
| 764 |
CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER); |
| 765 |
|
| 766 |
/* |
| 767 |
* A different stream does not give a sharing violation |
| 768 |
*/ |
| 769 |
|
| 770 |
io.ntcreatex.in.fname = sname2; |
| 771 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 772 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 773 |
fnum2 = io.ntcreatex.out.file.fnum; |
| 774 |
|
| 775 |
/* |
| 776 |
* ... whereas the same stream does with unchanged access/share_access |
| 777 |
* flags |
| 778 |
*/ |
| 779 |
|
| 780 |
io.ntcreatex.in.fname = sname1; |
| 781 |
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_SUPERSEDE; |
| 782 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 783 |
CHECK_STATUS(status, NT_STATUS_SHARING_VIOLATION); |
| 784 |
|
| 785 |
io.ntcreatex.in.fname = sname1b; |
| 786 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 787 |
CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_INVALID); |
| 788 |
|
| 789 |
io.ntcreatex.in.fname = sname1c; |
| 790 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 791 |
if (NT_STATUS_EQUAL(status, NT_STATUS_INVALID_PARAMETER)) { |
| 792 |
/* w2k returns INVALID_PARAMETER */ |
| 793 |
CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER); |
| 794 |
} else { |
| 795 |
CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_INVALID); |
| 796 |
} |
| 797 |
|
| 798 |
io.ntcreatex.in.fname = sname1d; |
| 799 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 800 |
if (NT_STATUS_EQUAL(status, NT_STATUS_INVALID_PARAMETER)) { |
| 801 |
/* w2k returns INVALID_PARAMETER */ |
| 802 |
CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER); |
| 803 |
} else { |
| 804 |
CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_INVALID); |
| 805 |
} |
| 806 |
|
| 807 |
io.ntcreatex.in.fname = sname2; |
| 808 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 809 |
CHECK_STATUS(status, NT_STATUS_SHARING_VIOLATION); |
| 810 |
|
| 811 |
io.ntcreatex.in.fname = snamew; |
| 812 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 813 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 814 |
fnum3 = io.ntcreatex.out.file.fnum; |
| 815 |
|
| 816 |
io.ntcreatex.in.fname = snamew2; |
| 817 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 818 |
CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_INVALID); |
| 819 |
|
| 820 |
ret &= check_stream_list(tctx, cli, fname, 4, four); |
| 821 |
|
| 822 |
smbcli_close(cli->tree, fnum1); |
| 823 |
smbcli_close(cli->tree, fnum2); |
| 824 |
smbcli_close(cli->tree, fnum3); |
| 825 |
|
| 826 |
finfo.generic.level = RAW_FILEINFO_ALL_INFO; |
| 827 |
finfo.generic.in.file.path = fname; |
| 828 |
status = smb_raw_pathinfo(cli->tree, tctx, &finfo); |
| 829 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 830 |
|
| 831 |
ret &= check_stream_list(tctx, cli, fname, 4, four); |
| 832 |
|
| 833 |
for (i=0; i < 4; i++) { |
| 834 |
NTTIME write_time; |
| 835 |
uint64_t stream_size; |
| 836 |
char *path = talloc_asprintf(tctx, "%s%s", |
| 837 |
fname, four[i]); |
| 838 |
|
| 839 |
char *rpath = talloc_strdup(path, path); |
| 840 |
char *p = strrchr(rpath, ':'); |
| 841 |
/* eat :$DATA */ |
| 842 |
*p = 0; |
| 843 |
p--; |
| 844 |
if (*p == ':') { |
| 845 |
/* eat ::$DATA */ |
| 846 |
*p = 0; |
| 847 |
} |
| 848 |
printf("(%s): i[%u][%s]\n", __location__, i, path); |
| 849 |
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN; |
| 850 |
io.ntcreatex.in.access_mask = SEC_FILE_READ_ATTRIBUTE | |
| 851 |
SEC_FILE_WRITE_ATTRIBUTE | |
| 852 |
SEC_RIGHTS_FILE_ALL; |
| 853 |
io.ntcreatex.in.fname = path; |
| 854 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 855 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 856 |
fnum1 = io.ntcreatex.out.file.fnum; |
| 857 |
|
| 858 |
finfo.generic.level = RAW_FILEINFO_ALL_INFO; |
| 859 |
finfo.generic.in.file.path = fname; |
| 860 |
status = smb_raw_pathinfo(cli->tree, tctx, &finfo); |
| 861 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 862 |
|
| 863 |
stinfo.generic.level = RAW_FILEINFO_ALL_INFO; |
| 864 |
stinfo.generic.in.file.fnum = fnum1; |
| 865 |
status = smb_raw_fileinfo(cli->tree, tctx, &stinfo); |
| 866 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 867 |
if (!(torture_setting_bool(tctx, "samba3", false) || |
| 868 |
torture_setting_bool(tctx, "samba4", false))) |
| 869 |
{ |
| 870 |
CHECK_NTTIME(stinfo.all_info.out.create_time, |
| 871 |
finfo.all_info.out.create_time); |
| 872 |
CHECK_NTTIME(stinfo.all_info.out.access_time, |
| 873 |
finfo.all_info.out.access_time); |
| 874 |
CHECK_NTTIME(stinfo.all_info.out.write_time, |
| 875 |
finfo.all_info.out.write_time); |
| 876 |
CHECK_NTTIME(stinfo.all_info.out.change_time, |
| 877 |
finfo.all_info.out.change_time); |
| 878 |
} |
| 879 |
CHECK_VALUE(stinfo.all_info.out.attrib, |
| 880 |
finfo.all_info.out.attrib); |
| 881 |
CHECK_VALUE(stinfo.all_info.out.size, |
| 882 |
finfo.all_info.out.size); |
| 883 |
CHECK_VALUE(stinfo.all_info.out.delete_pending, |
| 884 |
finfo.all_info.out.delete_pending); |
| 885 |
CHECK_VALUE(stinfo.all_info.out.directory, |
| 886 |
finfo.all_info.out.directory); |
| 887 |
CHECK_VALUE(stinfo.all_info.out.ea_size, |
| 888 |
finfo.all_info.out.ea_size); |
| 889 |
|
| 890 |
stinfo.generic.level = RAW_FILEINFO_NAME_INFO; |
| 891 |
stinfo.generic.in.file.fnum = fnum1; |
| 892 |
status = smb_raw_fileinfo(cli->tree, tctx, &stinfo); |
| 893 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 894 |
if (!(torture_setting_bool(tctx, "samba3", false) || |
| 895 |
torture_setting_bool(tctx, "samba4", false))) { |
| 896 |
CHECK_STR(stinfo.name_info.out.fname.s, rpath); |
| 897 |
} |
| 898 |
|
| 899 |
write_time = finfo.all_info.out.write_time; |
| 900 |
write_time += i*1000000; |
| 901 |
write_time /= 1000000; |
| 902 |
write_time *= 1000000; |
| 903 |
|
| 904 |
ZERO_STRUCT(sinfo); |
| 905 |
sinfo.basic_info.level = RAW_SFILEINFO_BASIC_INFO; |
| 906 |
sinfo.basic_info.in.file.fnum = fnum1; |
| 907 |
sinfo.basic_info.in.write_time = write_time; |
| 908 |
sinfo.basic_info.in.attrib = stinfo.all_info.out.attrib; |
| 909 |
status = smb_raw_setfileinfo(cli->tree, &sinfo); |
| 910 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 911 |
|
| 912 |
stream_size = i*8192; |
| 913 |
|
| 914 |
ZERO_STRUCT(sinfo); |
| 915 |
sinfo.end_of_file_info.level = RAW_SFILEINFO_END_OF_FILE_INFO; |
| 916 |
sinfo.end_of_file_info.in.file.fnum = fnum1; |
| 917 |
sinfo.end_of_file_info.in.size = stream_size; |
| 918 |
status = smb_raw_setfileinfo(cli->tree, &sinfo); |
| 919 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 920 |
|
| 921 |
stinfo.generic.level = RAW_FILEINFO_ALL_INFO; |
| 922 |
stinfo.generic.in.file.fnum = fnum1; |
| 923 |
status = smb_raw_fileinfo(cli->tree, tctx, &stinfo); |
| 924 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 925 |
if (!(torture_setting_bool(tctx, "samba3", false) || |
| 926 |
torture_setting_bool(tctx, "samba4", false))) { |
| 927 |
CHECK_NTTIME(stinfo.all_info.out.write_time, |
| 928 |
write_time); |
| 929 |
CHECK_VALUE(stinfo.all_info.out.attrib, |
| 930 |
finfo.all_info.out.attrib); |
| 931 |
} |
| 932 |
CHECK_VALUE(stinfo.all_info.out.size, |
| 933 |
stream_size); |
| 934 |
CHECK_VALUE(stinfo.all_info.out.delete_pending, |
| 935 |
finfo.all_info.out.delete_pending); |
| 936 |
CHECK_VALUE(stinfo.all_info.out.directory, |
| 937 |
finfo.all_info.out.directory); |
| 938 |
CHECK_VALUE(stinfo.all_info.out.ea_size, |
| 939 |
finfo.all_info.out.ea_size); |
| 940 |
|
| 941 |
ret &= check_stream_list(tctx, cli, fname, 4, four); |
| 942 |
|
| 943 |
smbcli_close(cli->tree, fnum1); |
| 944 |
talloc_free(path); |
| 945 |
} |
| 946 |
|
| 947 |
printf("(%s): testing stream renames\n", __location__); |
| 948 |
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE; |
| 949 |
io.ntcreatex.in.access_mask = SEC_FILE_READ_ATTRIBUTE | |
| 950 |
SEC_FILE_WRITE_ATTRIBUTE | |
| 951 |
SEC_RIGHTS_FILE_ALL; |
| 952 |
io.ntcreatex.in.fname = snamer1; |
| 953 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 954 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 955 |
fnum1 = io.ntcreatex.out.file.fnum; |
| 956 |
|
| 957 |
ret &= check_stream_list(tctx, cli, fname, 5, five1); |
| 958 |
|
| 959 |
ZERO_STRUCT(sinfo); |
| 960 |
sinfo.rename_information.level = RAW_SFILEINFO_RENAME_INFORMATION; |
| 961 |
sinfo.rename_information.in.file.fnum = fnum1; |
| 962 |
sinfo.rename_information.in.overwrite = true; |
| 963 |
sinfo.rename_information.in.root_fid = 0; |
| 964 |
sinfo.rename_information.in.new_name = ":AfterRename:$DATA"; |
| 965 |
status = smb_raw_setfileinfo(cli->tree, &sinfo); |
| 966 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 967 |
|
| 968 |
ret &= check_stream_list(tctx, cli, fname, 5, five2); |
| 969 |
|
| 970 |
ZERO_STRUCT(sinfo); |
| 971 |
sinfo.rename_information.level = RAW_SFILEINFO_RENAME_INFORMATION; |
| 972 |
sinfo.rename_information.in.file.fnum = fnum1; |
| 973 |
sinfo.rename_information.in.overwrite = false; |
| 974 |
sinfo.rename_information.in.root_fid = 0; |
| 975 |
sinfo.rename_information.in.new_name = ":MStream Two:$DATA"; |
| 976 |
status = smb_raw_setfileinfo(cli->tree, &sinfo); |
| 977 |
CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_COLLISION); |
| 978 |
|
| 979 |
ret &= check_stream_list(tctx, cli, fname, 5, five2); |
| 980 |
|
| 981 |
ZERO_STRUCT(sinfo); |
| 982 |
sinfo.rename_information.level = RAW_SFILEINFO_RENAME_INFORMATION; |
| 983 |
sinfo.rename_information.in.file.fnum = fnum1; |
| 984 |
sinfo.rename_information.in.overwrite = true; |
| 985 |
sinfo.rename_information.in.root_fid = 0; |
| 986 |
sinfo.rename_information.in.new_name = ":MStream Two:$DATA"; |
| 987 |
status = smb_raw_setfileinfo(cli->tree, &sinfo); |
| 988 |
if (torture_setting_bool(tctx, "samba4", false) || |
| 989 |
torture_setting_bool(tctx, "samba3", false)) { |
| 990 |
/* why should this rename be considered invalid?? */ |
| 991 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 992 |
ret &= check_stream_list(tctx, cli, fname, 4, four); |
| 993 |
} else { |
| 994 |
CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER); |
| 995 |
ret &= check_stream_list(tctx, cli, fname, 5, five2); |
| 996 |
} |
| 997 |
|
| 998 |
|
| 999 |
/* TODO: we need to test more rename combinations */ |
| 1000 |
|
| 1001 |
done: |
| 1002 |
if (fnum1 != -1) smbcli_close(cli->tree, fnum1); |
| 1003 |
if (fnum2 != -1) smbcli_close(cli->tree, fnum2); |
| 1004 |
if (fnum3 != -1) smbcli_close(cli->tree, fnum3); |
| 1005 |
status = smbcli_unlink(cli->tree, fname); |
| 1006 |
smbcli_deltree(cli->tree, BASEDIR); |
| 1007 |
return ret; |
| 1008 |
} |
| 1009 |
|
| 1010 |
/* |
| 1011 |
test stream names |
| 1012 |
*/ |
| 1013 |
static bool test_stream_names2(struct torture_context *tctx, |
| 1014 |
struct smbcli_state *cli) |
| 1015 |
{ |
| 1016 |
NTSTATUS status; |
| 1017 |
union smb_open io; |
| 1018 |
const char *fname = BASEDIR "\\stream_names2.txt"; |
| 1019 |
bool ret = true; |
| 1020 |
int fnum1 = -1; |
| 1021 |
uint8_t i; |
| 1022 |
|
| 1023 |
torture_assert(tctx, torture_setup_dir(cli, BASEDIR), "Failed to setup up test directory: " BASEDIR); |
| 1024 |
|
| 1025 |
printf("(%s) testing stream names\n", __location__); |
| 1026 |
io.generic.level = RAW_OPEN_NTCREATEX; |
| 1027 |
io.ntcreatex.in.root_fid.fnum = 0; |
| 1028 |
io.ntcreatex.in.flags = 0; |
| 1029 |
io.ntcreatex.in.access_mask = SEC_FILE_WRITE_DATA; |
| 1030 |
io.ntcreatex.in.create_options = 0; |
| 1031 |
io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; |
| 1032 |
io.ntcreatex.in.share_access = 0; |
| 1033 |
io.ntcreatex.in.alloc_size = 0; |
| 1034 |
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE; |
| 1035 |
io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; |
| 1036 |
io.ntcreatex.in.security_flags = 0; |
| 1037 |
io.ntcreatex.in.fname = fname; |
| 1038 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 1039 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 1040 |
fnum1 = io.ntcreatex.out.file.fnum; |
| 1041 |
|
| 1042 |
for (i=0x01; i < 0x7F; i++) { |
| 1043 |
char *path = talloc_asprintf(tctx, "%s:Stream%c0x%02X:$DATA", |
| 1044 |
fname, i, i); |
| 1045 |
NTSTATUS expected; |
| 1046 |
|
| 1047 |
switch (i) { |
| 1048 |
case '/':/*0x2F*/ |
| 1049 |
case ':':/*0x3A*/ |
| 1050 |
case '\\':/*0x5C*/ |
| 1051 |
expected = NT_STATUS_OBJECT_NAME_INVALID; |
| 1052 |
break; |
| 1053 |
default: |
| 1054 |
expected = NT_STATUS_OBJECT_NAME_NOT_FOUND; |
| 1055 |
break; |
| 1056 |
} |
| 1057 |
|
| 1058 |
|
| 1059 |
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN; |
| 1060 |
io.ntcreatex.in.fname = path; |
| 1061 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 1062 |
if (!NT_STATUS_EQUAL(status, expected)) { |
| 1063 |
printf("(%s) %s:Stream%c0x%02X:$DATA%s => expected[%s]\n", |
| 1064 |
__location__, fname, isprint(i)?(char)i:' ', i, |
| 1065 |
isprint(i)?"":" (not printable)", |
| 1066 |
nt_errstr(expected)); |
| 1067 |
} |
| 1068 |
CHECK_STATUS(status, expected); |
| 1069 |
|
| 1070 |
talloc_free(path); |
| 1071 |
} |
| 1072 |
|
| 1073 |
done: |
| 1074 |
if (fnum1 != -1) smbcli_close(cli->tree, fnum1); |
| 1075 |
status = smbcli_unlink(cli->tree, fname); |
| 1076 |
smbcli_deltree(cli->tree, BASEDIR); |
| 1077 |
return ret; |
| 1078 |
} |
| 1079 |
|
| 1080 |
#define CHECK_CALL_FNUM(call, rightstatus) do { \ |
| 1081 |
sfinfo.generic.level = RAW_SFILEINFO_ ## call; \ |
| 1082 |
sfinfo.generic.in.file.fnum = fnum; \ |
| 1083 |
status = smb_raw_setfileinfo(cli->tree, &sfinfo); \ |
| 1084 |
torture_assert_ntstatus_equal_goto(tctx, status, rightstatus, ret, done, #call); \ |
| 1085 |
finfo1.generic.level = RAW_FILEINFO_ALL_INFO; \ |
| 1086 |
finfo1.generic.in.file.fnum = fnum; \ |
| 1087 |
status2 = smb_raw_fileinfo(cli->tree, tctx, &finfo1); \ |
| 1088 |
torture_assert_ntstatus_ok_goto(tctx, status2, ret, done, "ALL_INFO"); \ |
| 1089 |
} while (0) |
| 1090 |
|
| 1091 |
/* |
| 1092 |
test stream renames |
| 1093 |
*/ |
| 1094 |
static bool test_stream_rename(struct torture_context *tctx, |
| 1095 |
struct smbcli_state *cli) |
| 1096 |
{ |
| 1097 |
NTSTATUS status, status2; |
| 1098 |
union smb_open io; |
| 1099 |
const char *fname = BASEDIR "\\stream_rename.txt"; |
| 1100 |
const char *sname1, *sname2; |
| 1101 |
union smb_fileinfo finfo1; |
| 1102 |
union smb_setfileinfo sfinfo; |
| 1103 |
bool ret = true; |
| 1104 |
int fnum = -1; |
| 1105 |
|
| 1106 |
torture_assert(tctx, torture_setup_dir(cli, BASEDIR), "Failed to setup up test directory: " BASEDIR); |
| 1107 |
|
| 1108 |
sname1 = talloc_asprintf(tctx, "%s:%s", fname, "Stream One"); |
| 1109 |
sname2 = talloc_asprintf(tctx, "%s:%s:$DaTa", fname, "Second Stream"); |
| 1110 |
|
| 1111 |
printf("(%s) testing stream renames\n", __location__); |
| 1112 |
io.generic.level = RAW_OPEN_NTCREATEX; |
| 1113 |
io.ntcreatex.in.root_fid.fnum = 0; |
| 1114 |
io.ntcreatex.in.flags = 0; |
| 1115 |
io.ntcreatex.in.access_mask = SEC_FILE_READ_ATTRIBUTE | |
| 1116 |
SEC_FILE_WRITE_ATTRIBUTE | |
| 1117 |
SEC_RIGHTS_FILE_ALL; |
| 1118 |
io.ntcreatex.in.create_options = 0; |
| 1119 |
io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; |
| 1120 |
io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE | NTCREATEX_SHARE_ACCESS_DELETE; |
| 1121 |
io.ntcreatex.in.alloc_size = 0; |
| 1122 |
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE; |
| 1123 |
io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; |
| 1124 |
io.ntcreatex.in.security_flags = 0; |
| 1125 |
io.ntcreatex.in.fname = sname1; |
| 1126 |
|
| 1127 |
/* Create two streams. */ |
| 1128 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 1129 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 1130 |
fnum = io.ntcreatex.out.file.fnum; |
| 1131 |
if (fnum != -1) smbcli_close(cli->tree, fnum); |
| 1132 |
|
| 1133 |
io.ntcreatex.in.fname = sname2; |
| 1134 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 1135 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 1136 |
fnum = io.ntcreatex.out.file.fnum; |
| 1137 |
|
| 1138 |
if (fnum != -1) smbcli_close(cli->tree, fnum); |
| 1139 |
|
| 1140 |
/* |
| 1141 |
* Open the second stream. |
| 1142 |
*/ |
| 1143 |
|
| 1144 |
io.ntcreatex.in.access_mask = SEC_STD_DELETE; |
| 1145 |
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF; |
| 1146 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 1147 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 1148 |
fnum = io.ntcreatex.out.file.fnum; |
| 1149 |
|
| 1150 |
/* |
| 1151 |
* Now rename the second stream onto the first. |
| 1152 |
*/ |
| 1153 |
|
| 1154 |
ZERO_STRUCT(sfinfo); |
| 1155 |
|
| 1156 |
sfinfo.rename_information.in.overwrite = 1; |
| 1157 |
sfinfo.rename_information.in.root_fid = 0; |
| 1158 |
sfinfo.rename_information.in.new_name = ":Stream One"; |
| 1159 |
CHECK_CALL_FNUM(RENAME_INFORMATION, NT_STATUS_OK); |
| 1160 |
|
| 1161 |
done: |
| 1162 |
if (fnum != -1) smbcli_close(cli->tree, fnum); |
| 1163 |
status = smbcli_unlink(cli->tree, fname); |
| 1164 |
smbcli_deltree(cli->tree, BASEDIR); |
| 1165 |
return ret; |
| 1166 |
} |
| 1167 |
|
| 1168 |
static bool test_stream_rename2(struct torture_context *tctx, |
| 1169 |
struct smbcli_state *cli) |
| 1170 |
{ |
| 1171 |
NTSTATUS status; |
| 1172 |
union smb_open io; |
| 1173 |
const char *fname1 = BASEDIR "\\stream.txt"; |
| 1174 |
const char *fname2 = BASEDIR "\\stream2.txt"; |
| 1175 |
const char *stream_name1 = ":Stream One:$DATA"; |
| 1176 |
const char *stream_name2 = ":Stream Two:$DATA"; |
| 1177 |
const char *stream_name_default = "::$DATA"; |
| 1178 |
const char *sname1; |
| 1179 |
const char *sname2; |
| 1180 |
bool ret = true; |
| 1181 |
int fnum = -1; |
| 1182 |
union smb_setfileinfo sinfo; |
| 1183 |
union smb_rename rio; |
| 1184 |
|
| 1185 |
torture_assert(tctx, torture_setup_dir(cli, BASEDIR), "Failed to setup up test directory: " BASEDIR); |
| 1186 |
|
| 1187 |
sname1 = talloc_asprintf(tctx, "%s:%s", fname1, "Stream One"); |
| 1188 |
sname2 = talloc_asprintf(tctx, "%s:%s", fname1, "Stream Two"); |
| 1189 |
|
| 1190 |
io.generic.level = RAW_OPEN_NTCREATEX; |
| 1191 |
io.ntcreatex.in.root_fid.fnum = 0; |
| 1192 |
io.ntcreatex.in.flags = 0; |
| 1193 |
io.ntcreatex.in.access_mask = (SEC_FILE_READ_DATA|SEC_FILE_WRITE_DATA| |
| 1194 |
SEC_STD_DELETE|SEC_FILE_APPEND_DATA|SEC_STD_READ_CONTROL); |
| 1195 |
io.ntcreatex.in.create_options = 0; |
| 1196 |
io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; |
| 1197 |
io.ntcreatex.in.share_access = (NTCREATEX_SHARE_ACCESS_READ | |
| 1198 |
NTCREATEX_SHARE_ACCESS_WRITE | |
| 1199 |
NTCREATEX_SHARE_ACCESS_DELETE); |
| 1200 |
io.ntcreatex.in.alloc_size = 0; |
| 1201 |
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE; |
| 1202 |
io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; |
| 1203 |
io.ntcreatex.in.security_flags = 0; |
| 1204 |
io.ntcreatex.in.fname = sname1; |
| 1205 |
|
| 1206 |
/* Open/create new stream. */ |
| 1207 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 1208 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 1209 |
|
| 1210 |
smbcli_close(cli->tree, io.ntcreatex.out.file.fnum); |
| 1211 |
|
| 1212 |
/* |
| 1213 |
* Check raw rename with <base>:<stream>. |
| 1214 |
*/ |
| 1215 |
printf("(%s) Checking NTRENAME of a stream using <base>:<stream>\n", |
| 1216 |
__location__); |
| 1217 |
rio.generic.level = RAW_RENAME_NTRENAME; |
| 1218 |
rio.ntrename.in.old_name = sname1; |
| 1219 |
rio.ntrename.in.new_name = sname2; |
| 1220 |
rio.ntrename.in.attrib = 0; |
| 1221 |
rio.ntrename.in.cluster_size = 0; |
| 1222 |
rio.ntrename.in.flags = RENAME_FLAG_RENAME; |
| 1223 |
status = smb_raw_rename(cli->tree, &rio); |
| 1224 |
CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER); |
| 1225 |
|
| 1226 |
/* |
| 1227 |
* Check raw rename to the default stream using :<stream>. |
| 1228 |
*/ |
| 1229 |
printf("(%s) Checking NTRENAME to default stream using :<stream>\n", |
| 1230 |
__location__); |
| 1231 |
rio.ntrename.in.new_name = stream_name_default; |
| 1232 |
status = smb_raw_rename(cli->tree, &rio); |
| 1233 |
CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_COLLISION); |
| 1234 |
|
| 1235 |
/* |
| 1236 |
* Check raw rename using :<stream>. |
| 1237 |
*/ |
| 1238 |
printf("(%s) Checking NTRENAME of a stream using :<stream>\n", |
| 1239 |
__location__); |
| 1240 |
rio.ntrename.in.new_name = stream_name2; |
| 1241 |
status = smb_raw_rename(cli->tree, &rio); |
| 1242 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 1243 |
|
| 1244 |
/* |
| 1245 |
* Check raw rename of a stream to a file. |
| 1246 |
*/ |
| 1247 |
printf("(%s) Checking NTRENAME of a stream to a file\n", |
| 1248 |
__location__); |
| 1249 |
rio.ntrename.in.old_name = sname2; |
| 1250 |
rio.ntrename.in.new_name = fname2; |
| 1251 |
status = smb_raw_rename(cli->tree, &rio); |
| 1252 |
CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER); |
| 1253 |
|
| 1254 |
/* |
| 1255 |
* Check raw rename of a file to a stream. |
| 1256 |
*/ |
| 1257 |
printf("(%s) Checking NTRENAME of a file to a stream\n", |
| 1258 |
__location__); |
| 1259 |
|
| 1260 |
/* Create the file. */ |
| 1261 |
io.ntcreatex.in.fname = fname2; |
| 1262 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 1263 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 1264 |
smbcli_close(cli->tree, io.ntcreatex.out.file.fnum); |
| 1265 |
|
| 1266 |
/* Try the rename. */ |
| 1267 |
rio.ntrename.in.old_name = fname2; |
| 1268 |
rio.ntrename.in.new_name = sname1; |
| 1269 |
status = smb_raw_rename(cli->tree, &rio); |
| 1270 |
CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_INVALID); |
| 1271 |
|
| 1272 |
/* |
| 1273 |
* Reopen the stream for trans2 renames. |
| 1274 |
*/ |
| 1275 |
io.ntcreatex.in.fname = sname2; |
| 1276 |
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN; |
| 1277 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 1278 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 1279 |
fnum = io.ntcreatex.out.file.fnum; |
| 1280 |
|
| 1281 |
/* |
| 1282 |
* Check trans2 rename of a stream using :<stream>. |
| 1283 |
*/ |
| 1284 |
printf("(%s) Checking trans2 rename of a stream using :<stream>\n", |
| 1285 |
__location__); |
| 1286 |
ZERO_STRUCT(sinfo); |
| 1287 |
sinfo.rename_information.level = RAW_SFILEINFO_RENAME_INFORMATION; |
| 1288 |
sinfo.rename_information.in.file.fnum = fnum; |
| 1289 |
sinfo.rename_information.in.overwrite = 1; |
| 1290 |
sinfo.rename_information.in.root_fid = 0; |
| 1291 |
sinfo.rename_information.in.new_name = stream_name1; |
| 1292 |
status = smb_raw_setfileinfo(cli->tree, &sinfo); |
| 1293 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 1294 |
|
| 1295 |
/* |
| 1296 |
* Check trans2 rename of an overwriting stream using :<stream>. |
| 1297 |
*/ |
| 1298 |
printf("(%s) Checking trans2 rename of an overwriting stream using " |
| 1299 |
":<stream>\n", __location__); |
| 1300 |
|
| 1301 |
/* Create second stream. */ |
| 1302 |
io.ntcreatex.in.fname = sname2; |
| 1303 |
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE; |
| 1304 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 1305 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 1306 |
smbcli_close(cli->tree, io.ntcreatex.out.file.fnum); |
| 1307 |
|
| 1308 |
/* Rename the first stream onto the second. */ |
| 1309 |
sinfo.rename_information.in.file.fnum = fnum; |
| 1310 |
sinfo.rename_information.in.new_name = stream_name2; |
| 1311 |
status = smb_raw_setfileinfo(cli->tree, &sinfo); |
| 1312 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 1313 |
|
| 1314 |
smbcli_close(cli->tree, fnum); |
| 1315 |
|
| 1316 |
/* |
| 1317 |
* Reopen the stream with the new name. |
| 1318 |
*/ |
| 1319 |
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN; |
| 1320 |
io.ntcreatex.in.fname = sname2; |
| 1321 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 1322 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 1323 |
fnum = io.ntcreatex.out.file.fnum; |
| 1324 |
|
| 1325 |
/* |
| 1326 |
* Check trans2 rename of a stream using <base>:<stream>. |
| 1327 |
*/ |
| 1328 |
printf("(%s) Checking trans2 rename of a stream using " |
| 1329 |
"<base>:<stream>\n", __location__); |
| 1330 |
sinfo.rename_information.in.file.fnum = fnum; |
| 1331 |
sinfo.rename_information.in.new_name = sname1; |
| 1332 |
status = smb_raw_setfileinfo(cli->tree, &sinfo); |
| 1333 |
CHECK_STATUS(status, NT_STATUS_NOT_SUPPORTED); |
| 1334 |
|
| 1335 |
/* |
| 1336 |
* Samba3 doesn't currently support renaming a stream to the default |
| 1337 |
* stream. This test does pass on windows. |
| 1338 |
*/ |
| 1339 |
if (torture_setting_bool(tctx, "samba3", false) || |
| 1340 |
torture_setting_bool(tctx, "samba4", false)) { |
| 1341 |
goto done; |
| 1342 |
} |
| 1343 |
|
| 1344 |
/* |
| 1345 |
* Check trans2 rename to the default stream using :<stream>. |
| 1346 |
*/ |
| 1347 |
printf("(%s) Checking trans2 rename to defaualt stream using " |
| 1348 |
":<stream>\n", __location__); |
| 1349 |
sinfo.rename_information.in.file.fnum = fnum; |
| 1350 |
sinfo.rename_information.in.new_name = stream_name_default; |
| 1351 |
status = smb_raw_setfileinfo(cli->tree, &sinfo); |
| 1352 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 1353 |
|
| 1354 |
smbcli_close(cli->tree, fnum); |
| 1355 |
|
| 1356 |
done: |
| 1357 |
smbcli_close(cli->tree, fnum); |
| 1358 |
status = smbcli_unlink(cli->tree, fname1); |
| 1359 |
status = smbcli_unlink(cli->tree, fname2); |
| 1360 |
smbcli_deltree(cli->tree, BASEDIR); |
| 1361 |
return ret; |
| 1362 |
} |
| 1363 |
|
| 1364 |
/* |
| 1365 |
test stream renames |
| 1366 |
*/ |
| 1367 |
static bool test_stream_rename3(struct torture_context *tctx, |
| 1368 |
struct smbcli_state *cli) |
| 1369 |
{ |
| 1370 |
NTSTATUS status, status2; |
| 1371 |
union smb_open io; |
| 1372 |
const char *fname = BASEDIR "\\stream_rename.txt"; |
| 1373 |
const char *sname1, *sname2; |
| 1374 |
union smb_fileinfo finfo1; |
| 1375 |
union smb_setfileinfo sfinfo; |
| 1376 |
bool ret = true; |
| 1377 |
int fnum = -1; |
| 1378 |
int fnum2 = -1; |
| 1379 |
|
| 1380 |
torture_assert(tctx, torture_setup_dir(cli, BASEDIR), "Failed to setup up test directory: " BASEDIR); |
| 1381 |
|
| 1382 |
sname1 = talloc_asprintf(tctx, "%s:%s", fname, "MStream Two:$DATA"); |
| 1383 |
sname2 = talloc_asprintf(tctx, "%s:%s:$DaTa", fname, "Second Stream"); |
| 1384 |
|
| 1385 |
printf("(%s) testing stream renames\n", __location__); |
| 1386 |
io.generic.level = RAW_OPEN_NTCREATEX; |
| 1387 |
io.ntcreatex.in.root_fid.fnum = 0; |
| 1388 |
io.ntcreatex.in.flags = 0; |
| 1389 |
io.ntcreatex.in.access_mask = SEC_FILE_READ_ATTRIBUTE | |
| 1390 |
SEC_FILE_WRITE_ATTRIBUTE | |
| 1391 |
SEC_RIGHTS_FILE_ALL; |
| 1392 |
io.ntcreatex.in.create_options = 0; |
| 1393 |
io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; |
| 1394 |
io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ | |
| 1395 |
NTCREATEX_SHARE_ACCESS_WRITE | NTCREATEX_SHARE_ACCESS_DELETE; |
| 1396 |
io.ntcreatex.in.alloc_size = 0; |
| 1397 |
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE; |
| 1398 |
io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; |
| 1399 |
io.ntcreatex.in.security_flags = 0; |
| 1400 |
io.ntcreatex.in.fname = sname1; |
| 1401 |
|
| 1402 |
/* Create two streams. */ |
| 1403 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 1404 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 1405 |
fnum = io.ntcreatex.out.file.fnum; |
| 1406 |
if (fnum != -1) smbcli_close(cli->tree, fnum); |
| 1407 |
|
| 1408 |
io.ntcreatex.in.fname = sname2; |
| 1409 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 1410 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 1411 |
fnum = io.ntcreatex.out.file.fnum; |
| 1412 |
|
| 1413 |
if (fnum != -1) smbcli_close(cli->tree, fnum); |
| 1414 |
|
| 1415 |
/* open the second stream. */ |
| 1416 |
io.ntcreatex.in.access_mask = SEC_STD_DELETE; |
| 1417 |
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF; |
| 1418 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 1419 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 1420 |
fnum = io.ntcreatex.out.file.fnum; |
| 1421 |
|
| 1422 |
/* Keep a handle to the first stream open. */ |
| 1423 |
io.ntcreatex.in.fname = sname1; |
| 1424 |
io.ntcreatex.in.access_mask = SEC_STD_DELETE; |
| 1425 |
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF; |
| 1426 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 1427 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 1428 |
fnum2 = io.ntcreatex.out.file.fnum; |
| 1429 |
|
| 1430 |
ZERO_STRUCT(sfinfo); |
| 1431 |
sfinfo.rename_information.in.overwrite = 1; |
| 1432 |
sfinfo.rename_information.in.root_fid = 0; |
| 1433 |
sfinfo.rename_information.in.new_name = ":MStream Two:$DATA"; |
| 1434 |
if (torture_setting_bool(tctx, "samba4", false) || |
| 1435 |
torture_setting_bool(tctx, "samba3", false)) { |
| 1436 |
CHECK_CALL_FNUM(RENAME_INFORMATION, NT_STATUS_OK); |
| 1437 |
} else { |
| 1438 |
CHECK_CALL_FNUM(RENAME_INFORMATION, |
| 1439 |
NT_STATUS_INVALID_PARAMETER); |
| 1440 |
} |
| 1441 |
|
| 1442 |
|
| 1443 |
done: |
| 1444 |
if (fnum != -1) smbcli_close(cli->tree, fnum); |
| 1445 |
if (fnum2 != -1) smbcli_close(cli->tree, fnum2); |
| 1446 |
status = smbcli_unlink(cli->tree, fname); |
| 1447 |
smbcli_deltree(cli->tree, BASEDIR); |
| 1448 |
return ret; |
| 1449 |
} |
| 1450 |
|
| 1451 |
static bool create_file_with_stream(struct torture_context *tctx, |
| 1452 |
struct smbcli_state *cli, |
| 1453 |
const char *stream) |
| 1454 |
{ |
| 1455 |
NTSTATUS status; |
| 1456 |
bool ret = true; |
| 1457 |
union smb_open io; |
| 1458 |
|
| 1459 |
ZERO_STRUCT(io); |
| 1460 |
|
| 1461 |
/* Create a file with a stream */ |
| 1462 |
io.generic.level = RAW_OPEN_NTCREATEX; |
| 1463 |
io.ntcreatex.in.root_fid.fnum = 0; |
| 1464 |
io.ntcreatex.in.flags = 0; |
| 1465 |
io.ntcreatex.in.access_mask = (SEC_FILE_READ_DATA|SEC_FILE_WRITE_DATA| |
| 1466 |
SEC_FILE_APPEND_DATA|SEC_STD_READ_CONTROL); |
| 1467 |
io.ntcreatex.in.create_options = 0; |
| 1468 |
io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; |
| 1469 |
io.ntcreatex.in.share_access = 0; |
| 1470 |
io.ntcreatex.in.alloc_size = 0; |
| 1471 |
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE; |
| 1472 |
io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; |
| 1473 |
io.ntcreatex.in.security_flags = 0; |
| 1474 |
io.ntcreatex.in.fname = stream; |
| 1475 |
|
| 1476 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 1477 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 1478 |
|
| 1479 |
done: |
| 1480 |
smbcli_close(cli->tree, io.ntcreatex.out.file.fnum); |
| 1481 |
return ret; |
| 1482 |
} |
| 1483 |
|
| 1484 |
/* Test how streams interact with create dispositions */ |
| 1485 |
static bool test_stream_create_disposition(struct torture_context *tctx, |
| 1486 |
struct smbcli_state *cli) |
| 1487 |
{ |
| 1488 |
NTSTATUS status; |
| 1489 |
union smb_open io; |
| 1490 |
const char *fname = BASEDIR "\\stream.txt"; |
| 1491 |
const char *stream = "Stream One:$DATA"; |
| 1492 |
const char *fname_stream; |
| 1493 |
const char *default_stream_name = "::$DATA"; |
| 1494 |
const char *stream_list[2]; |
| 1495 |
bool ret = false; |
| 1496 |
int fnum = -1; |
| 1497 |
|
| 1498 |
torture_assert(tctx, torture_setup_dir(cli, BASEDIR), "Failed to setup up test directory: " BASEDIR); |
| 1499 |
|
| 1500 |
fname_stream = talloc_asprintf(tctx, "%s:%s", fname, stream); |
| 1501 |
|
| 1502 |
stream_list[0] = talloc_asprintf(tctx, ":%s", stream); |
| 1503 |
stream_list[1] = default_stream_name; |
| 1504 |
|
| 1505 |
if (!create_file_with_stream(tctx, cli, fname_stream)) { |
| 1506 |
goto done; |
| 1507 |
} |
| 1508 |
|
| 1509 |
/* Open the base file with OPEN */ |
| 1510 |
io.generic.level = RAW_OPEN_NTCREATEX; |
| 1511 |
io.ntcreatex.in.root_fid.fnum = 0; |
| 1512 |
io.ntcreatex.in.flags = 0; |
| 1513 |
io.ntcreatex.in.access_mask = (SEC_FILE_READ_DATA|SEC_FILE_WRITE_DATA| |
| 1514 |
SEC_FILE_APPEND_DATA|SEC_STD_READ_CONTROL); |
| 1515 |
io.ntcreatex.in.create_options = 0; |
| 1516 |
io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; |
| 1517 |
io.ntcreatex.in.share_access = 0; |
| 1518 |
io.ntcreatex.in.alloc_size = 0; |
| 1519 |
io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; |
| 1520 |
io.ntcreatex.in.security_flags = 0; |
| 1521 |
io.ntcreatex.in.fname = fname; |
| 1522 |
|
| 1523 |
/* |
| 1524 |
* check ntcreatex open: sanity check |
| 1525 |
*/ |
| 1526 |
printf("(%s) Checking ntcreatex disp: open\n", __location__); |
| 1527 |
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN; |
| 1528 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 1529 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 1530 |
smbcli_close(cli->tree, io.ntcreatex.out.file.fnum); |
| 1531 |
if (!check_stream_list(tctx, cli, fname, 2, stream_list)) { |
| 1532 |
goto done; |
| 1533 |
} |
| 1534 |
|
| 1535 |
/* |
| 1536 |
* check ntcreatex overwrite |
| 1537 |
*/ |
| 1538 |
printf("(%s) Checking ntcreatex disp: overwrite\n", __location__); |
| 1539 |
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OVERWRITE; |
| 1540 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 1541 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 1542 |
smbcli_close(cli->tree, io.ntcreatex.out.file.fnum); |
| 1543 |
if (!check_stream_list(tctx, cli, fname, 1, &default_stream_name)) { |
| 1544 |
goto done; |
| 1545 |
} |
| 1546 |
|
| 1547 |
/* |
| 1548 |
* check ntcreatex overwrite_if |
| 1549 |
*/ |
| 1550 |
printf("(%s) Checking ntcreatex disp: overwrite_if\n", __location__); |
| 1551 |
smbcli_unlink(cli->tree, fname); |
| 1552 |
if (!create_file_with_stream(tctx, cli, fname_stream)) { |
| 1553 |
goto done; |
| 1554 |
} |
| 1555 |
|
| 1556 |
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OVERWRITE_IF; |
| 1557 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 1558 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 1559 |
smbcli_close(cli->tree, io.ntcreatex.out.file.fnum); |
| 1560 |
if (!check_stream_list(tctx, cli, fname, 1, &default_stream_name)) { |
| 1561 |
goto done; |
| 1562 |
} |
| 1563 |
|
| 1564 |
/* |
| 1565 |
* check ntcreatex supersede |
| 1566 |
*/ |
| 1567 |
printf("(%s) Checking ntcreatex disp: supersede\n", __location__); |
| 1568 |
smbcli_unlink(cli->tree, fname); |
| 1569 |
if (!create_file_with_stream(tctx, cli, fname_stream)) { |
| 1570 |
goto done; |
| 1571 |
} |
| 1572 |
|
| 1573 |
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_SUPERSEDE; |
| 1574 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 1575 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 1576 |
smbcli_close(cli->tree, io.ntcreatex.out.file.fnum); |
| 1577 |
if (!check_stream_list(tctx, cli, fname, 1, &default_stream_name)) { |
| 1578 |
goto done; |
| 1579 |
} |
| 1580 |
|
| 1581 |
/* |
| 1582 |
* check ntcreatex overwrite_if on a stream. |
| 1583 |
*/ |
| 1584 |
printf("(%s) Checking ntcreatex disp: overwrite_if on stream\n", |
| 1585 |
__location__); |
| 1586 |
smbcli_unlink(cli->tree, fname); |
| 1587 |
if (!create_file_with_stream(tctx, cli, fname_stream)) { |
| 1588 |
goto done; |
| 1589 |
} |
| 1590 |
|
| 1591 |
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OVERWRITE_IF; |
| 1592 |
io.ntcreatex.in.fname = fname_stream; |
| 1593 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 1594 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 1595 |
smbcli_close(cli->tree, io.ntcreatex.out.file.fnum); |
| 1596 |
if (!check_stream_list(tctx, cli, fname, 2, stream_list)) { |
| 1597 |
goto done; |
| 1598 |
} |
| 1599 |
|
| 1600 |
/* |
| 1601 |
* check openx overwrite_if |
| 1602 |
*/ |
| 1603 |
printf("(%s) Checking openx disp: overwrite_if\n", __location__); |
| 1604 |
smbcli_unlink(cli->tree, fname); |
| 1605 |
if (!create_file_with_stream(tctx, cli, fname_stream)) { |
| 1606 |
goto done; |
| 1607 |
} |
| 1608 |
|
| 1609 |
io.openx.level = RAW_OPEN_OPENX; |
| 1610 |
io.openx.in.flags = OPENX_FLAGS_ADDITIONAL_INFO; |
| 1611 |
io.openx.in.open_mode = OPENX_MODE_ACCESS_RDWR | OPEN_FLAGS_DENY_NONE; |
| 1612 |
io.openx.in.search_attrs = 0; |
| 1613 |
io.openx.in.file_attrs = 0; |
| 1614 |
io.openx.in.write_time = 0; |
| 1615 |
io.openx.in.size = 1024*1024; |
| 1616 |
io.openx.in.timeout = 0; |
| 1617 |
io.openx.in.fname = fname; |
| 1618 |
|
| 1619 |
io.openx.in.open_func = OPENX_OPEN_FUNC_TRUNC | OPENX_OPEN_FUNC_CREATE; |
| 1620 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 1621 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 1622 |
smbcli_close(cli->tree, io.openx.out.file.fnum); |
| 1623 |
if (!check_stream_list(tctx, cli, fname, 1, &default_stream_name)) { |
| 1624 |
goto done; |
| 1625 |
} |
| 1626 |
|
| 1627 |
ret = true; |
| 1628 |
|
| 1629 |
done: |
| 1630 |
smbcli_close(cli->tree, fnum); |
| 1631 |
smbcli_unlink(cli->tree, fname); |
| 1632 |
smbcli_deltree(cli->tree, BASEDIR); |
| 1633 |
return ret; |
| 1634 |
} |
| 1635 |
|
| 1636 |
#if 0 |
| 1637 |
/* Test streaminfo with enough streams on a file to fill up the buffer. */ |
| 1638 |
static bool test_stream_large_streaminfo(struct torture_context *tctx, |
| 1639 |
struct smbcli_state *cli) |
| 1640 |
{ |
| 1641 |
#define LONG_STREAM_SIZE 2 |
| 1642 |
char *lstream_name; |
| 1643 |
const char *fname = BASEDIR "\\stream.txt"; |
| 1644 |
const char *fname_stream; |
| 1645 |
NTSTATUS status; |
| 1646 |
bool ret = true; |
| 1647 |
int i; |
| 1648 |
union smb_fileinfo finfo; |
| 1649 |
|
| 1650 |
torture_assert(tctx, torture_setup_dir(cli, BASEDIR), "Failed to setup up test directory: " BASEDIR); |
| 1651 |
|
| 1652 |
lstream_name = talloc_array(tctx, char, LONG_STREAM_SIZE); |
| 1653 |
|
| 1654 |
for (i = 0; i < LONG_STREAM_SIZE - 1; i++) { |
| 1655 |
lstream_name[i] = (char)('a' + i%26); |
| 1656 |
} |
| 1657 |
lstream_name[LONG_STREAM_SIZE - 1] = '\0'; |
| 1658 |
|
| 1659 |
torture_comment(tctx, "(%s) Creating a file with a lot of streams\n", __location__); |
| 1660 |
for (i = 0; i < 10000; i++) { |
| 1661 |
fname_stream = talloc_asprintf(tctx, "%s:%s%d", fname, |
| 1662 |
lstream_name, i); |
| 1663 |
ret = create_file_with_stream(tctx, cli, fname_stream); |
| 1664 |
if (!ret) { |
| 1665 |
goto done; |
| 1666 |
} |
| 1667 |
} |
| 1668 |
|
| 1669 |
finfo.generic.level = RAW_FILEINFO_STREAM_INFO; |
| 1670 |
finfo.generic.in.file.path = fname; |
| 1671 |
|
| 1672 |
status = smb_raw_pathinfo(cli->tree, tctx, &finfo); |
| 1673 |
CHECK_STATUS(status, STATUS_BUFFER_OVERFLOW); |
| 1674 |
|
| 1675 |
done: |
| 1676 |
smbcli_unlink(cli->tree, fname); |
| 1677 |
smbcli_deltree(cli->tree, BASEDIR); |
| 1678 |
return ret; |
| 1679 |
} |
| 1680 |
#endif |
| 1681 |
|
| 1682 |
/* Test the effect of setting attributes on a stream. */ |
| 1683 |
static bool test_stream_attributes(struct torture_context *tctx, |
| 1684 |
struct smbcli_state *cli) |
| 1685 |
{ |
| 1686 |
bool ret = true; |
| 1687 |
NTSTATUS status; |
| 1688 |
union smb_open io; |
| 1689 |
const char *fname = BASEDIR "\\stream_attr.txt"; |
| 1690 |
const char *stream = "Stream One:$DATA"; |
| 1691 |
const char *fname_stream; |
| 1692 |
int fnum = -1; |
| 1693 |
union smb_fileinfo finfo; |
| 1694 |
union smb_setfileinfo sfinfo; |
| 1695 |
time_t basetime = (time(NULL) - 86400) & ~1; |
| 1696 |
|
| 1697 |
torture_assert(tctx, torture_setup_dir(cli, BASEDIR), "Failed to setup up test directory: " BASEDIR); |
| 1698 |
|
| 1699 |
torture_comment(tctx, "(%s) testing attribute setting on stream\n", __location__); |
| 1700 |
|
| 1701 |
fname_stream = talloc_asprintf(tctx, "%s:%s", fname, stream); |
| 1702 |
|
| 1703 |
/* Create a file with a stream with attribute FILE_ATTRIBUTE_ARCHIVE. */ |
| 1704 |
ret = create_file_with_stream(tctx, cli, fname_stream); |
| 1705 |
if (!ret) { |
| 1706 |
goto done; |
| 1707 |
} |
| 1708 |
|
| 1709 |
ZERO_STRUCT(finfo); |
| 1710 |
finfo.generic.level = RAW_FILEINFO_BASIC_INFO; |
| 1711 |
finfo.generic.in.file.path = fname; |
| 1712 |
status = smb_raw_pathinfo(cli->tree, tctx, &finfo); |
| 1713 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 1714 |
|
| 1715 |
torture_assert_int_equal_goto(tctx, finfo.all_info.out.attrib & ~FILE_ATTRIBUTE_NONINDEXED, FILE_ATTRIBUTE_ARCHIVE, ret, done, "attrib incorrect"); |
| 1716 |
|
| 1717 |
/* Now open the stream name. */ |
| 1718 |
|
| 1719 |
io.generic.level = RAW_OPEN_NTCREATEX; |
| 1720 |
io.ntcreatex.in.root_fid.fnum = 0; |
| 1721 |
io.ntcreatex.in.flags = 0; |
| 1722 |
io.ntcreatex.in.access_mask = (SEC_FILE_READ_DATA|SEC_FILE_WRITE_DATA| |
| 1723 |
SEC_FILE_APPEND_DATA|SEC_STD_READ_CONTROL|SEC_FILE_WRITE_ATTRIBUTE); |
| 1724 |
io.ntcreatex.in.create_options = 0; |
| 1725 |
io.ntcreatex.in.file_attr = 0; |
| 1726 |
io.ntcreatex.in.share_access = 0; |
| 1727 |
io.ntcreatex.in.alloc_size = 0; |
| 1728 |
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF; |
| 1729 |
io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; |
| 1730 |
io.ntcreatex.in.security_flags = 0; |
| 1731 |
io.ntcreatex.in.fname = fname_stream; |
| 1732 |
|
| 1733 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 1734 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 1735 |
|
| 1736 |
fnum = io.ntcreatex.out.file.fnum; |
| 1737 |
|
| 1738 |
/* Change the attributes + time on the stream fnum. */ |
| 1739 |
ZERO_STRUCT(sfinfo); |
| 1740 |
sfinfo.basic_info.in.attrib = FILE_ATTRIBUTE_READONLY; |
| 1741 |
unix_to_nt_time(&sfinfo.basic_info.in.write_time, basetime); |
| 1742 |
|
| 1743 |
sfinfo.generic.level = RAW_SFILEINFO_BASIC_INFORMATION; |
| 1744 |
sfinfo.generic.in.file.fnum = fnum; |
| 1745 |
status = smb_raw_setfileinfo(cli->tree, &sfinfo); |
| 1746 |
torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, done, "smb_raw_setfileinfo failed"); |
| 1747 |
|
| 1748 |
smbcli_close(cli->tree, fnum); |
| 1749 |
fnum = -1; |
| 1750 |
|
| 1751 |
ZERO_STRUCT(finfo); |
| 1752 |
finfo.generic.level = RAW_FILEINFO_ALL_INFO; |
| 1753 |
finfo.generic.in.file.path = fname; |
| 1754 |
status = smb_raw_pathinfo(cli->tree, tctx, &finfo); |
| 1755 |
torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, done, "smb_raw_pathinfo failed"); |
| 1756 |
|
| 1757 |
torture_assert_int_equal_goto(tctx, finfo.all_info.out.attrib & ~FILE_ATTRIBUTE_NONINDEXED, FILE_ATTRIBUTE_READONLY, ret, done, "attrib incorrect"); |
| 1758 |
|
| 1759 |
torture_assert_int_equal_goto(tctx, nt_time_to_unix(finfo.all_info.out.write_time), basetime, ret, done, "time incorrect"); |
| 1760 |
|
| 1761 |
done: |
| 1762 |
|
| 1763 |
if (fnum != -1) { |
| 1764 |
smbcli_close(cli->tree, fnum); |
| 1765 |
} |
| 1766 |
smbcli_unlink(cli->tree, fname); |
| 1767 |
smbcli_deltree(cli->tree, BASEDIR); |
| 1768 |
return ret; |
| 1769 |
} |
| 1770 |
|
| 1771 |
/** |
| 1772 |
* A rough approximation of how a windows client creates the streams for use |
| 1773 |
* in the summary tab. |
| 1774 |
*/ |
| 1775 |
static bool test_stream_summary_tab(struct torture_context *tctx, |
| 1776 |
struct smbcli_state *cli) |
| 1777 |
{ |
| 1778 |
bool ret = true; |
| 1779 |
NTSTATUS status; |
| 1780 |
union smb_open io; |
| 1781 |
const char *fname = BASEDIR "\\stream_summary.txt"; |
| 1782 |
const char *stream = ":\005SummaryInformation:$DATA"; |
| 1783 |
const char *fname_stream = NULL; |
| 1784 |
const char *tmp_stream = ":Updt_\005SummaryInformation:$DATA"; |
| 1785 |
const char *fname_tmp_stream = NULL; |
| 1786 |
int fnum = -1; |
| 1787 |
union smb_fileinfo finfo; |
| 1788 |
union smb_rename rio; |
| 1789 |
ssize_t retsize; |
| 1790 |
|
| 1791 |
torture_assert(tctx, torture_setup_dir(cli, BASEDIR), "Failed to setup up test directory: " BASEDIR); |
| 1792 |
|
| 1793 |
fname_stream = talloc_asprintf(tctx, "%s%s", fname, stream); |
| 1794 |
fname_tmp_stream = talloc_asprintf(tctx, "%s%s", fname, |
| 1795 |
tmp_stream); |
| 1796 |
|
| 1797 |
/* Create summary info stream */ |
| 1798 |
ret = create_file_with_stream(tctx, cli, fname_stream); |
| 1799 |
if (!ret) { |
| 1800 |
goto done; |
| 1801 |
} |
| 1802 |
|
| 1803 |
/* Create summary info tmp update stream */ |
| 1804 |
ret = create_file_with_stream(tctx, cli, fname_tmp_stream); |
| 1805 |
if (!ret) { |
| 1806 |
goto done; |
| 1807 |
} |
| 1808 |
|
| 1809 |
/* Open tmp stream and write to it */ |
| 1810 |
io.generic.level = RAW_OPEN_NTCREATEX; |
| 1811 |
io.ntcreatex.in.root_fid.fnum = 0; |
| 1812 |
io.ntcreatex.in.flags = 0; |
| 1813 |
io.ntcreatex.in.access_mask = SEC_FILE_READ_DATA|SEC_FILE_WRITE_DATA; |
| 1814 |
io.ntcreatex.in.create_options = 0; |
| 1815 |
io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; |
| 1816 |
io.ntcreatex.in.share_access = 0; |
| 1817 |
io.ntcreatex.in.alloc_size = 0; |
| 1818 |
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN; |
| 1819 |
io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; |
| 1820 |
io.ntcreatex.in.security_flags = 0; |
| 1821 |
io.ntcreatex.in.fname = fname_tmp_stream; |
| 1822 |
|
| 1823 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 1824 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 1825 |
fnum = io.ntcreatex.out.file.fnum; |
| 1826 |
|
| 1827 |
retsize = smbcli_write(cli->tree, fnum, 0, "test data", 0, 9); |
| 1828 |
CHECK_VALUE(retsize, 9); |
| 1829 |
|
| 1830 |
/* close the tmp stream. */ |
| 1831 |
smbcli_close(cli->tree, fnum); |
| 1832 |
fnum = -1; |
| 1833 |
|
| 1834 |
/* Delete the current stream */ |
| 1835 |
smbcli_unlink(cli->tree, fname_stream); |
| 1836 |
|
| 1837 |
/* Do the rename. */ |
| 1838 |
rio.generic.level = RAW_RENAME_RENAME; |
| 1839 |
rio.rename.in.pattern1 = fname_tmp_stream; |
| 1840 |
rio.rename.in.pattern2 = stream; |
| 1841 |
rio.rename.in.attrib = FILE_ATTRIBUTE_SYSTEM | |
| 1842 |
FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_DIRECTORY; |
| 1843 |
status = smb_raw_rename(cli->tree, &rio); |
| 1844 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 1845 |
|
| 1846 |
/* Try to open the tmp stream that we just renamed away. */ |
| 1847 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 1848 |
CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); |
| 1849 |
|
| 1850 |
/* Query the base file to make sure it's still there. */ |
| 1851 |
finfo.generic.level = RAW_FILEINFO_BASIC_INFO; |
| 1852 |
finfo.generic.in.file.path = fname; |
| 1853 |
|
| 1854 |
status = smb_raw_pathinfo(cli->tree, tctx, &finfo); |
| 1855 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 1856 |
|
| 1857 |
done: |
| 1858 |
|
| 1859 |
if (fnum != -1) { |
| 1860 |
smbcli_close(cli->tree, fnum); |
| 1861 |
} |
| 1862 |
smbcli_unlink(cli->tree, fname); |
| 1863 |
|
| 1864 |
smbcli_deltree(cli->tree, BASEDIR); |
| 1865 |
return ret; |
| 1866 |
} |
| 1867 |
|
| 1868 |
/* Test how streams interact with base file permissions */ |
| 1869 |
/* Regression test for bug: |
| 1870 |
https://bugzilla.samba.org/show_bug.cgi?id=10229 |
| 1871 |
bug #10229 - No access check verification on stream files. |
| 1872 |
*/ |
| 1873 |
static bool test_stream_permissions(struct torture_context *tctx, |
| 1874 |
struct smbcli_state *cli) |
| 1875 |
{ |
| 1876 |
NTSTATUS status; |
| 1877 |
bool ret = true; |
| 1878 |
union smb_open io; |
| 1879 |
const char *fname = BASEDIR "\\stream_permissions.txt"; |
| 1880 |
const char *stream = "Stream One:$DATA"; |
| 1881 |
const char *fname_stream; |
| 1882 |
union smb_fileinfo finfo; |
| 1883 |
union smb_setfileinfo sfinfo; |
| 1884 |
int fnum = -1; |
| 1885 |
union smb_fileinfo q; |
| 1886 |
union smb_setfileinfo set; |
| 1887 |
struct security_ace ace = {}; |
| 1888 |
struct security_descriptor *sd; |
| 1889 |
|
| 1890 |
torture_assert(tctx, torture_setup_dir(cli, BASEDIR), |
| 1891 |
"Failed to setup up test directory: " BASEDIR); |
| 1892 |
|
| 1893 |
torture_comment(tctx, "(%s) testing permissions on streams\n", __location__); |
| 1894 |
|
| 1895 |
fname_stream = talloc_asprintf(tctx, "%s:%s", fname, stream); |
| 1896 |
|
| 1897 |
/* Create a file with a stream with attribute FILE_ATTRIBUTE_ARCHIVE. */ |
| 1898 |
ret = create_file_with_stream(tctx, cli, fname_stream); |
| 1899 |
if (!ret) { |
| 1900 |
goto done; |
| 1901 |
} |
| 1902 |
|
| 1903 |
ZERO_STRUCT(finfo); |
| 1904 |
finfo.generic.level = RAW_FILEINFO_BASIC_INFO; |
| 1905 |
finfo.generic.in.file.path = fname; |
| 1906 |
status = smb_raw_pathinfo(cli->tree, tctx, &finfo); |
| 1907 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 1908 |
|
| 1909 |
torture_assert_int_equal_goto(tctx, |
| 1910 |
finfo.all_info.out.attrib & ~FILE_ATTRIBUTE_NONINDEXED, |
| 1911 |
FILE_ATTRIBUTE_ARCHIVE, ret, done, "attrib incorrect"); |
| 1912 |
|
| 1913 |
/* Change the attributes on the base file name. */ |
| 1914 |
ZERO_STRUCT(sfinfo); |
| 1915 |
sfinfo.generic.level = RAW_SFILEINFO_SETATTR; |
| 1916 |
sfinfo.generic.in.file.path = fname; |
| 1917 |
sfinfo.setattr.in.attrib = FILE_ATTRIBUTE_READONLY; |
| 1918 |
|
| 1919 |
status = smb_raw_setpathinfo(cli->tree, &sfinfo); |
| 1920 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 1921 |
|
| 1922 |
/* Try and open the stream name for WRITE_DATA. Should |
| 1923 |
fail with ACCESS_DENIED. */ |
| 1924 |
|
| 1925 |
ZERO_STRUCT(io); |
| 1926 |
io.generic.level = RAW_OPEN_NTCREATEX; |
| 1927 |
io.ntcreatex.in.root_fid.fnum = 0; |
| 1928 |
io.ntcreatex.in.flags = 0; |
| 1929 |
io.ntcreatex.in.access_mask = SEC_FILE_WRITE_DATA; |
| 1930 |
io.ntcreatex.in.create_options = 0; |
| 1931 |
io.ntcreatex.in.file_attr = 0; |
| 1932 |
io.ntcreatex.in.share_access = 0; |
| 1933 |
io.ntcreatex.in.alloc_size = 0; |
| 1934 |
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN; |
| 1935 |
io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; |
| 1936 |
io.ntcreatex.in.security_flags = 0; |
| 1937 |
io.ntcreatex.in.fname = fname_stream; |
| 1938 |
|
| 1939 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 1940 |
CHECK_STATUS(status, NT_STATUS_ACCESS_DENIED); |
| 1941 |
|
| 1942 |
/* Change the attributes on the base file back. */ |
| 1943 |
ZERO_STRUCT(sfinfo); |
| 1944 |
sfinfo.generic.level = RAW_SFILEINFO_SETATTR; |
| 1945 |
sfinfo.generic.in.file.path = fname; |
| 1946 |
sfinfo.setattr.in.attrib = 0; |
| 1947 |
|
| 1948 |
status = smb_raw_setpathinfo(cli->tree, &sfinfo); |
| 1949 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 1950 |
|
| 1951 |
/* Re-open the file name. */ |
| 1952 |
|
| 1953 |
ZERO_STRUCT(io); |
| 1954 |
io.generic.level = RAW_OPEN_NTCREATEX; |
| 1955 |
io.ntcreatex.in.root_fid.fnum = 0; |
| 1956 |
io.ntcreatex.in.flags = 0; |
| 1957 |
io.ntcreatex.in.access_mask = (SEC_FILE_READ_DATA|SEC_FILE_WRITE_DATA| |
| 1958 |
SEC_STD_READ_CONTROL|SEC_STD_WRITE_DAC| |
| 1959 |
SEC_FILE_WRITE_ATTRIBUTE); |
| 1960 |
io.ntcreatex.in.create_options = 0; |
| 1961 |
io.ntcreatex.in.file_attr = 0; |
| 1962 |
io.ntcreatex.in.share_access = 0; |
| 1963 |
io.ntcreatex.in.alloc_size = 0; |
| 1964 |
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN; |
| 1965 |
io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; |
| 1966 |
io.ntcreatex.in.security_flags = 0; |
| 1967 |
io.ntcreatex.in.fname = fname; |
| 1968 |
|
| 1969 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 1970 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 1971 |
|
| 1972 |
fnum = io.ntcreatex.out.file.fnum; |
| 1973 |
|
| 1974 |
/* Get the existing security descriptor. */ |
| 1975 |
ZERO_STRUCT(q); |
| 1976 |
q.query_secdesc.level = RAW_FILEINFO_SEC_DESC; |
| 1977 |
q.query_secdesc.in.file.fnum = fnum; |
| 1978 |
q.query_secdesc.in.secinfo_flags = |
| 1979 |
SECINFO_OWNER | |
| 1980 |
SECINFO_GROUP | |
| 1981 |
SECINFO_DACL; |
| 1982 |
status = smb_raw_fileinfo(cli->tree, tctx, &q); |
| 1983 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 1984 |
sd = q.query_secdesc.out.sd; |
| 1985 |
|
| 1986 |
/* Now add a DENY WRITE security descriptor for Everyone. */ |
| 1987 |
torture_comment(tctx, "add a new ACE to the DACL\n"); |
| 1988 |
|
| 1989 |
ace.type = SEC_ACE_TYPE_ACCESS_DENIED; |
| 1990 |
ace.flags = 0; |
| 1991 |
ace.access_mask = SEC_FILE_WRITE_DATA; |
| 1992 |
ace.trustee = global_sid_World; |
| 1993 |
|
| 1994 |
status = security_descriptor_dacl_add(sd, &ace); |
| 1995 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 1996 |
|
| 1997 |
/* security_descriptor_dacl_add adds to the *end* of |
| 1998 |
the ace array, we need it at the start. Swap.. */ |
| 1999 |
ace = sd->dacl->aces[0]; |
| 2000 |
sd->dacl->aces[0] = sd->dacl->aces[sd->dacl->num_aces-1]; |
| 2001 |
sd->dacl->aces[sd->dacl->num_aces-1] = ace; |
| 2002 |
|
| 2003 |
ZERO_STRUCT(set); |
| 2004 |
set.set_secdesc.level = RAW_SFILEINFO_SEC_DESC; |
| 2005 |
set.set_secdesc.in.file.fnum = fnum; |
| 2006 |
set.set_secdesc.in.secinfo_flags = SECINFO_DACL; |
| 2007 |
set.set_secdesc.in.sd = sd; |
| 2008 |
|
| 2009 |
status = smb_raw_setfileinfo(cli->tree, &set); |
| 2010 |
CHECK_STATUS(status, NT_STATUS_OK); |
| 2011 |
|
| 2012 |
smbcli_close(cli->tree, fnum); |
| 2013 |
fnum = -1; |
| 2014 |
|
| 2015 |
/* Try and open the stream name for WRITE_DATA. Should |
| 2016 |
fail with ACCESS_DENIED. */ |
| 2017 |
|
| 2018 |
ZERO_STRUCT(io); |
| 2019 |
io.generic.level = RAW_OPEN_NTCREATEX; |
| 2020 |
io.ntcreatex.in.root_fid.fnum = 0; |
| 2021 |
io.ntcreatex.in.flags = 0; |
| 2022 |
io.ntcreatex.in.access_mask = SEC_FILE_WRITE_DATA; |
| 2023 |
io.ntcreatex.in.create_options = 0; |
| 2024 |
io.ntcreatex.in.file_attr = 0; |
| 2025 |
io.ntcreatex.in.share_access = 0; |
| 2026 |
io.ntcreatex.in.alloc_size = 0; |
| 2027 |
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN; |
| 2028 |
io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; |
| 2029 |
io.ntcreatex.in.security_flags = 0; |
| 2030 |
io.ntcreatex.in.fname = fname_stream; |
| 2031 |
|
| 2032 |
status = smb_raw_open(cli->tree, tctx, &io); |
| 2033 |
CHECK_STATUS(status, NT_STATUS_ACCESS_DENIED); |
| 2034 |
|
| 2035 |
done: |
| 2036 |
|
| 2037 |
if (fnum != -1) { |
| 2038 |
smbcli_close(cli->tree, fnum); |
| 2039 |
} |
| 2040 |
smbcli_unlink(cli->tree, fname); |
| 2041 |
|
| 2042 |
smbcli_deltree(cli->tree, BASEDIR); |
| 2043 |
return ret; |
| 2044 |
} |
| 2045 |
|
| 2046 |
/* |
| 2047 |
basic testing of streams calls |
| 2048 |
*/ |
| 2049 |
struct torture_suite *torture_raw_streams(TALLOC_CTX *tctx) |
| 2050 |
{ |
| 2051 |
struct torture_suite *suite = torture_suite_create(tctx, "streams"); |
| 2052 |
|
| 2053 |
torture_suite_add_1smb_test(suite, "dir", test_stream_dir); |
| 2054 |
torture_suite_add_1smb_test(suite, "io", test_stream_io); |
| 2055 |
torture_suite_add_1smb_test(suite, "sharemodes", test_stream_sharemodes); |
| 2056 |
torture_suite_add_1smb_test(suite, "delete", test_stream_delete); |
| 2057 |
torture_suite_add_1smb_test(suite, "names", test_stream_names); |
| 2058 |
torture_suite_add_1smb_test(suite, "names2", test_stream_names2); |
| 2059 |
torture_suite_add_1smb_test(suite, "rename", test_stream_rename); |
| 2060 |
torture_suite_add_1smb_test(suite, "rename2", test_stream_rename2); |
| 2061 |
torture_suite_add_1smb_test(suite, "rename3", test_stream_rename3); |
| 2062 |
torture_suite_add_1smb_test(suite, "createdisp", |
| 2063 |
test_stream_create_disposition); |
| 2064 |
torture_suite_add_1smb_test(suite, "attr", test_stream_attributes); |
| 2065 |
torture_suite_add_1smb_test(suite, "sumtab", test_stream_summary_tab); |
| 2066 |
torture_suite_add_1smb_test(suite, "perms", test_stream_permissions); |
| 2067 |
|
| 2068 |
#if 0 |
| 2069 |
torture_suite_add_1smb_test(suite, "LARGESTREAMINFO", |
| 2070 |
test_stream_large_streaminfo); |
| 2071 |
#endif |
| 2072 |
|
| 2073 |
return suite; |
| 2074 |
} |