Changeset 745 for trunk/server/source3/torture
- Timestamp:
- Nov 27, 2012, 4:43:17 PM (13 years ago)
- Location:
- trunk/server
- Files:
-
- 1 deleted
- 17 edited
- 9 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
- Property svn:mergeinfo changed
/vendor/current merged: 581,587,591,594,597,600,615,618,740
- Property svn:mergeinfo changed
-
trunk/server/source3/torture/cmd_vfs.c
r414 r745 21 21 22 22 #include "includes.h" 23 #include "smbd/smbd.h" 24 #include "system/passwd.h" 25 #include "system/filesys.h" 23 26 #include "vfstest.h" 27 #include "../lib/util/util_pw.h" 24 28 25 29 static const char *null_string = ""; … … 1129 1133 static NTSTATUS cmd_realpath(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, const char **argv) 1130 1134 { 1131 char respath[PATH_MAX];1132 1133 1135 if (argc != 2) { 1134 1136 printf("Usage: realpath <path>\n"); … … 1136 1138 } 1137 1139 1138 if (SMB_VFS_REALPATH(vfs->conn, argv[1] , respath) == NULL) {1140 if (SMB_VFS_REALPATH(vfs->conn, argv[1]) == NULL) { 1139 1141 printf("realpath: error=%d (%s)\n", errno, strerror(errno)); 1140 1142 return NT_STATUS_UNSUCCESSFUL; -
trunk/server/source3/torture/denytest.c
r414 r745 19 19 20 20 #include "includes.h" 21 #include "system/filesys.h" 22 #include "torture/proto.h" 23 #include "libsmb/libsmb.h" 21 24 22 25 extern bool torture_showall; … … 1420 1423 1421 1424 for (i=0;i<2;i++) { 1422 cli_unlink(cli1, fnames[i], aSYSTEM | aHIDDEN);1425 cli_unlink(cli1, fnames[i], FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 1423 1426 cli_open(cli1, fnames[i], O_RDWR|O_CREAT, DENY_NONE, &fnum1); 1424 cli_write(cli1, fnum1, 0, fnames[i], 0, strlen(fnames[i])); 1427 cli_writeall(cli1, fnum1, 0, (uint8_t *)fnames[i], 0, 1428 strlen(fnames[i]), NULL); 1425 1429 cli_close(cli1, fnum1); 1426 1430 } … … 1451 1455 res += A_R; 1452 1456 } 1453 if (cli_write(cli1, fnum2, 0, (char *)&x, 0, 1) == 1) { 1457 if (NT_STATUS_IS_OK(cli_writeall(cli1, fnum2, 0, 1458 (uint8_t *)&x, 0, 1, 1459 NULL))) { 1454 1460 res += A_W; 1455 1461 } … … 1480 1486 1481 1487 for (i=0;i<2;i++) { 1482 cli_unlink(cli1, fnames[i], aSYSTEM | aHIDDEN);1488 cli_unlink(cli1, fnames[i], FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 1483 1489 } 1484 1490 … … 1511 1517 1512 1518 for (i=0;i<2;i++) { 1513 cli_unlink(cli1, fnames[i], aSYSTEM | aHIDDEN);1519 cli_unlink(cli1, fnames[i], FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 1514 1520 cli_open(cli1, fnames[i], O_RDWR|O_CREAT, DENY_NONE, &fnum1); 1515 cli_write(cli1, fnum1, 0, fnames[i], 0, strlen(fnames[i])); 1521 cli_writeall(cli1, fnum1, 0, (uint8_t *)fnames[i], 0, 1522 strlen(fnames[i]), NULL); 1516 1523 cli_close(cli1, fnum1); 1517 1524 } … … 1540 1547 res += A_R; 1541 1548 } 1542 if (cli_write(cli2, fnum2, 0, (char *)&x, 0, 1) == 1) { 1549 if (NT_STATUS_IS_OK(cli_writeall(cli2, fnum2, 0, 1550 (uint8_t *)&x, 0, 1, 1551 NULL))) { 1543 1552 res += A_W; 1544 1553 } … … 1569 1578 1570 1579 for (i=0;i<2;i++) { 1571 cli_unlink(cli1, fnames[i], aSYSTEM | aHIDDEN);1580 cli_unlink(cli1, fnames[i], FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 1572 1581 } 1573 1582 -
trunk/server/source3/torture/locktest.c
r414 r745 19 19 20 20 #include "includes.h" 21 #include "libsmb/libsmb.h" 22 #include "system/filesys.h" 23 #include "locking/proto.h" 24 #include "libsmb/nmblib.h" 21 25 22 26 static fstring password[2]; … … 234 238 } 235 239 236 if (!NT_STATUS_IS_OK(cli_session_setup(c, username[snum], 237 password[snum], 238 strlen(password[snum]), 239 password[snum], 240 strlen(password[snum]), 241 lp_workgroup()))) { 242 DEBUG(0,("session setup failed: %s\n", cli_errstr(c))); 240 status = cli_session_setup(c, username[snum], 241 password[snum], strlen(password[snum]), 242 password[snum], strlen(password[snum]), 243 lp_workgroup()); 244 if (!NT_STATUS_IS_OK(status)) { 245 DEBUG(0,("session setup failed: %s\n", nt_errstr(status))); 243 246 return NULL; 244 247 } … … 399 402 } 400 403 for (server=0;server<NSERVERS;server++) { 401 cli_unlink(cli[server][0], FILENAME, aSYSTEM | aHIDDEN);404 cli_unlink(cli[server][0], FILENAME, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 402 405 } 403 406 } … … 605 608 load_case_tables(); 606 609 607 dbf = x_stderr;608 609 610 if (argc < 3 || argv[1][0] == '-') { 610 611 usage(); … … 612 613 } 613 614 614 setup_logging(argv[0], True);615 setup_logging(argv[0], DEBUG_STDOUT); 615 616 616 617 for (server=0;server<NSERVERS;server++) { -
trunk/server/source3/torture/locktest2.c
r414 r745 19 19 20 20 #include "includes.h" 21 #include "libsmb/libsmb.h" 22 #include "system/filesys.h" 23 #include "locking/proto.h" 21 24 22 25 static fstring password; … … 191 194 nt_status = cli_full_connection(&c, myname, server_n, NULL, 0, share, "?????", 192 195 username, lp_workgroup(), password, 0, 193 Undefined , NULL);196 Undefined); 194 197 195 198 if (!NT_STATUS_IS_OK(nt_status)) { … … 324 327 } 325 328 for (server=0;server<NSERVERS;server++) { 326 cli_unlink(cli[server][0], FILENAME, aSYSTEM | aHIDDEN);329 cli_unlink(cli[server][0], FILENAME, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 327 330 } 328 331 } … … 492 495 setlinebuf(stdout); 493 496 494 dbf = x_stderr;495 496 497 if (argc < 5 || argv[1][0] == '-') { 497 498 usage(); 498 499 exit(1); 499 500 } 501 502 setup_logging(argv[0], DEBUG_STDOUT); 500 503 501 504 share1 = argv[1]; … … 506 509 all_string_sub(share1,"/","\\",0); 507 510 all_string_sub(share2,"/","\\",0); 508 509 setup_logging(argv[0],True);510 511 511 512 argc -= 4; -
trunk/server/source3/torture/mangle_test.c
r414 r745 19 19 20 20 #include "includes.h" 21 #include "system/filesys.h" 22 #include "torture/proto.h" 23 #include "libsmb/libsmb.h" 24 #include "libsmb/clirap.h" 25 #include "util_tdb.h" 21 26 22 27 extern int torture_numops; … … 56 61 57 62 fstr_sprintf(name2, "\\mangle_test\\%s", shortname); 58 if (!NT_STATUS_IS_OK(cli_unlink(cli, name2, aSYSTEM | aHIDDEN))) {63 if (!NT_STATUS_IS_OK(cli_unlink(cli, name2, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN))) { 59 64 printf("unlink of %s (%s) failed (%s)\n", 60 65 name2, name, cli_errstr(cli)); … … 73 78 74 79 /* and unlink by long name */ 75 if (!NT_STATUS_IS_OK(cli_unlink(cli, name, aSYSTEM | aHIDDEN))) {80 if (!NT_STATUS_IS_OK(cli_unlink(cli, name, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN))) { 76 81 printf("unlink2 of %s (%s) failed (%s)\n", 77 82 name, name2, cli_errstr(cli)); 78 83 failures++; 79 cli_unlink(cli, name2, aSYSTEM | aHIDDEN);84 cli_unlink(cli, name2, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 80 85 return True; 81 86 } … … 176 181 } 177 182 178 cli_unlink(cli, "\\mangle_test\\*", aSYSTEM | aHIDDEN);183 cli_unlink(cli, "\\mangle_test\\*", FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 179 184 cli_rmdir(cli, "\\mangle_test"); 180 185 … … 200 205 } 201 206 202 cli_unlink(cli, "\\mangle_test\\*", aSYSTEM | aHIDDEN);207 cli_unlink(cli, "\\mangle_test\\*", FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 203 208 if (!NT_STATUS_IS_OK(cli_rmdir(cli, "\\mangle_test"))) { 204 209 printf("ERROR: Failed to remove directory\n"); -
trunk/server/source3/torture/masktest.c
r414 r745 19 19 20 20 #include "includes.h" 21 #include "system/filesys.h" 22 #include "trans2.h" 23 #include "libsmb/libsmb.h" 24 #include "libsmb/nmblib.h" 21 25 22 26 static fstring password; … … 35 39 extern char *optarg; 36 40 extern int optind; 37 extern bool AllowDebugChange;38 41 39 42 /* a test fn for LANMAN mask support */ … … 228 231 } 229 232 230 if (!NT_STATUS_IS_OK(cli_session_setup(c, username, 231 password, strlen(password), 232 password, strlen(password), 233 lp_workgroup()))) { 234 DEBUG(0,("session setup failed: %s\n", cli_errstr(c))); 233 status = cli_session_setup(c, username, 234 password, strlen(password), 235 password, strlen(password), 236 lp_workgroup()); 237 if (!NT_STATUS_IS_OK(status)) { 238 DEBUG(0, ("session setup failed: %s\n", nt_errstr(status))); 235 239 return NULL; 236 240 } … … 264 268 265 269 static char *resultp; 266 static file_info *f_info; 267 268 static void listfn(const char *mnt, file_info *f, const char *s, void *state) 269 { 270 271 struct rn_state { 272 char **pp_long_name; 273 char *short_name; 274 }; 275 276 static NTSTATUS listfn(const char *mnt, struct file_info *f, const char *s, 277 void *private_data) 278 { 279 struct rn_state *state = (struct rn_state *)private_data; 270 280 if (strcmp(f->name,".") == 0) { 271 281 resultp[0] = '+'; … … 275 285 resultp[2] = '+'; 276 286 } 277 f_info = f; 287 288 if (state == NULL) { 289 return NT_STATUS_INTERNAL_ERROR; 290 } 291 292 if (ISDOT(f->name) || ISDOTDOT(f->name)) { 293 return NT_STATUS_OK; 294 } 295 296 fstrcpy(state->short_name, f->short_name); 297 strlower_m(state->short_name); 298 *state->pp_long_name = SMB_STRDUP(f->name); 299 if (!*state->pp_long_name) { 300 return NT_STATUS_NO_MEMORY; 301 } 302 strlower_m(*state->pp_long_name); 303 return NT_STATUS_OK; 278 304 } 279 305 … … 281 307 char **pp_long_name, fstring short_name) 282 308 { 309 struct rn_state state; 310 311 state.pp_long_name = pp_long_name; 312 state.short_name = short_name; 313 283 314 *pp_long_name = NULL; 284 315 /* nasty hack to force level 260 listings - tridge */ 285 cli->capabilities |= CAP_NT_SMBS;286 316 if (max_protocol <= PROTOCOL_LANMAN1) { 287 cli_list_new(cli, "\\masktest\\*.*", aHIDDEN | aDIR, listfn, NULL); 317 cli_list_trans(cli, "\\masktest\\*.*", FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_DIRECTORY, 318 SMB_FIND_FILE_BOTH_DIRECTORY_INFO, listfn, 319 &state); 288 320 } else { 289 cli_list_new(cli, "\\masktest\\*", aHIDDEN | aDIR, listfn, NULL); 290 } 291 if (f_info) { 292 fstrcpy(short_name, f_info->short_name); 293 strlower_m(short_name); 294 *pp_long_name = SMB_STRDUP(f_info->name); 295 if (!*pp_long_name) { 296 return; 297 } 298 strlower_m(*pp_long_name); 321 cli_list_trans(cli, "\\masktest\\*", FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_DIRECTORY, 322 SMB_FIND_FILE_BOTH_DIRECTORY_INFO, 323 listfn, &state); 299 324 } 300 325 … … 331 356 resultp = res1; 332 357 fstrcpy(short_name, ""); 333 f_info = NULL;334 358 get_real_name(cli, &long_name, short_name); 335 359 if (!long_name) { 336 360 return; 337 361 } 338 f_info = NULL;339 362 fstrcpy(res1, "---"); 340 cli_list(cli, mask, aHIDDEN | aDIR, listfn, NULL);363 cli_list(cli, mask, FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_DIRECTORY, listfn, NULL); 341 364 342 365 res2 = reg_test(cli, mask, long_name, short_name); … … 350 373 } 351 374 352 cli_unlink(cli, file, aSYSTEM | aHIDDEN);375 cli_unlink(cli, file, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 353 376 354 377 if (count % 100 == 0) DEBUG(0,("%d\n", count)); … … 367 390 cli_mkdir(cli, "\\masktest"); 368 391 369 cli_unlink(cli, "\\masktest\\*", aSYSTEM | aHIDDEN);392 cli_unlink(cli, "\\masktest\\*", FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 370 393 371 394 if (argc >= 2) { … … 466 489 setlinebuf(stdout); 467 490 468 dbf = x_stderr; 469 470 DEBUGLEVEL = 0; 471 AllowDebugChange = False; 491 lp_set_cmdline("log level", "0"); 472 492 473 493 if (argc < 2 || argv[1][0] == '-') { … … 480 500 all_string_sub(share,"/","\\",0); 481 501 482 setup_logging(argv[0], True);502 setup_logging(argv[0], DEBUG_STDERR); 483 503 484 504 argc -= 1; 485 505 argv += 1; 486 506 507 load_case_tables(); 487 508 lp_load(get_dyn_CONFIGFILE(),True,False,False,True); 488 509 load_interfaces(); … … 500 521 break; 501 522 case 'd': 502 DEBUGLEVEL = atoi(optarg);523 lp_set_cmdline("log level", optarg); 503 524 break; 504 525 case 'E': -
trunk/server/source3/torture/msgtest.c
r414 r745 2 2 Unix SMB/CIFS implementation. 3 3 Copyright (C) Andrew Tridgell 2000 4 4 5 5 This program is free software; you can redistribute it and/or modify 6 6 it under the terms of the GNU General Public License as published by 7 7 the Free Software Foundation; either version 3 of the License, or 8 8 (at your option) any later version. 9 9 10 10 This program is distributed in the hope that it will be useful, 11 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 13 GNU General Public License for more details. 14 14 15 15 You should have received a copy of the GNU General Public License 16 16 along with this program. If not, see <http://www.gnu.org/licenses/>. … … 22 22 23 23 #include "includes.h" 24 #include "messages.h" 24 25 25 26 static int pong_count; … … 49 50 load_case_tables(); 50 51 51 setup_logging(argv[0], True);52 52 setup_logging(argv[0], DEBUG_STDOUT); 53 53 54 lp_load(get_dyn_CONFIGFILE(),False,False,False,True); 54 55 55 56 if (!(evt_ctx = tevent_context_init(NULL)) || 56 !(msg_ctx = messaging_init(NULL, server_id_self(), evt_ctx))) {57 !(msg_ctx = messaging_init(NULL, procid_self(), evt_ctx))) { 57 58 fprintf(stderr, "could not init messaging context\n"); 58 59 exit(1); 59 60 } 60 61 61 62 if (argc != 3) { 62 63 fprintf(stderr, "%s: Usage - %s pid count\n", argv[0], … … 88 89 89 90 for (i=0;i<n;i++) { 90 messaging_send(msg_ctx, pid_to_procid(getpid()), MSG_PING,91 messaging_send(msg_ctx, messaging_server_id(msg_ctx), MSG_PING, 91 92 &data_blob_null); 92 messaging_send_buf(msg_ctx, pid_to_procid(getpid()), MSG_PING,93 (uint8 *)buf, 11);93 messaging_send_buf(msg_ctx, messaging_server_id(msg_ctx), 94 MSG_PING,(uint8 *)buf, 11); 94 95 } 95 96 … … 133 134 } 134 135 } 135 136 136 137 printf("waiting for %d remaining replies (done %d)\n", 137 138 (int)(ping_count - pong_count), pong_count); … … 142 143 } 143 144 } 144 145 145 146 if (ping_count != pong_count) { 146 147 fprintf(stderr, "ping test failed! received %d, sent " 147 148 "%d\n", pong_count, (int)ping_count); 148 149 } 149 150 150 151 printf("ping rate of %.0f messages/sec\n", 151 152 (ping_count+pong_count)/timeval_elapsed(&tv)); -
trunk/server/source3/torture/nbio.c
r414 r745 21 21 22 22 #include "includes.h" 23 #include "torture/proto.h" 24 #include "../libcli/security/security.h" 25 #include "libsmb/libsmb.h" 26 #include "libsmb/clirap.h" 23 27 24 28 #define MAX_FILES 1000 … … 28 32 extern int nbio_id; 29 33 static int nprocs; 34 static struct timeval nb_start; 30 35 31 36 static struct { … … 61 66 } 62 67 63 printf("%4d %8d %.2f MB/sec\r", num_clients, lines/nprocs, 1.0e-6 * nbio_total() / end_timer()); 68 printf("%4d %8d %.2f MB/sec\r", 69 num_clients, lines/nprocs, 70 1.0e-6 * nbio_total() / timeval_elapsed(&nb_start)); 64 71 65 72 signal(SIGALRM, nb_alarm); … … 122 129 signal(SIGSEGV, sigsegv); 123 130 c = cli; 124 start_timer();131 nb_start = timeval_current(); 125 132 children[nbio_id].done = 0; 126 133 } … … 129 136 void nb_unlink(const char *fname) 130 137 { 131 if (!NT_STATUS_IS_OK(cli_unlink(c, fname, aSYSTEM | aHIDDEN))) {138 if (!NT_STATUS_IS_OK(cli_unlink(c, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN))) { 132 139 #if NBDEBUG 133 140 printf("(%d) unlink %s failed (%s)\n", … … 184 191 { 185 192 int i; 193 NTSTATUS status; 186 194 187 195 if (buf[0] == 0) memset(buf, 1, sizeof(buf)); 188 196 189 197 i = find_handle(handle); 190 if (cli_write(c, ftable[i].fd, 0, buf, offset, size) != ret_size) { 191 printf("(%d) ERROR: write failed on handle %d, fd %d \ 192 errno %d (%s)\n", line_count, handle, ftable[i].fd, errno, strerror(errno)); 198 status = cli_writeall(c, ftable[i].fd, 0, (uint8_t *)buf, offset, size, 199 NULL); 200 if (!NT_STATUS_IS_OK(status)) { 201 printf("(%d) ERROR: write failed on handle %d, fd %d " 202 "error %s\n", line_count, handle, ftable[i].fd, 203 nt_errstr(status)); 193 204 exit(1); 194 205 } … … 242 253 void nb_qpathinfo(const char *fname) 243 254 { 244 cli_qpathinfo (c, fname, NULL, NULL, NULL, NULL, NULL);255 cli_qpathinfo1(c, fname, NULL, NULL, NULL, NULL, NULL); 245 256 } 246 257 … … 249 260 int i; 250 261 i = find_handle(fnum); 251 cli_qfileinfo(c, ftable[i].fd, NULL, NULL, NULL, NULL, NULL, NULL, NULL); 262 cli_qfileinfo_basic(c, ftable[i].fd, NULL, NULL, NULL, NULL, NULL, 263 NULL, NULL); 252 264 } 253 265 … … 259 271 } 260 272 261 static void find_fn(const char *mnt, file_info *finfo, const char *name, void *state) 273 static NTSTATUS find_fn(const char *mnt, struct file_info *finfo, const char *name, 274 void *state) 262 275 { 263 276 /* noop */ 277 return NT_STATUS_OK; 264 278 } 265 279 … … 278 292 static int total_deleted; 279 293 280 static void delete_fn(const char *mnt, file_info *finfo, const char *name, void *state) 281 { 294 static NTSTATUS delete_fn(const char *mnt, struct file_info *finfo, 295 const char *name, void *state) 296 { 297 NTSTATUS status; 282 298 char *s, *n; 283 if (finfo->name[0] == '.') return; 299 if (finfo->name[0] == '.') { 300 return NT_STATUS_OK; 301 } 284 302 285 303 n = SMB_STRDUP(name); … … 287 305 if (asprintf(&s, "%s%s", n, finfo->name) == -1) { 288 306 printf("asprintf failed\n"); 289 return ;290 } 291 if (finfo->mode & aDIR) {307 return NT_STATUS_NO_MEMORY; 308 } 309 if (finfo->mode & FILE_ATTRIBUTE_DIRECTORY) { 292 310 char *s2; 293 311 if (asprintf(&s2, "%s\\*", s) == -1) { 294 312 printf("asprintf failed\n"); 295 return ;313 return NT_STATUS_NO_MEMORY; 296 314 } 297 cli_list(c, s2, aDIR, delete_fn, NULL); 315 status = cli_list(c, s2, FILE_ATTRIBUTE_DIRECTORY, delete_fn, NULL); 316 if (!NT_STATUS_IS_OK(status)) { 317 free(n); 318 free(s2); 319 return status; 320 } 298 321 nb_rmdir(s); 299 322 } else { … … 303 326 free(s); 304 327 free(n); 328 return NT_STATUS_OK; 305 329 } 306 330 … … 314 338 315 339 total_deleted = 0; 316 cli_list(c, mask, aDIR, delete_fn, NULL);340 cli_list(c, mask, FILE_ATTRIBUTE_DIRECTORY, delete_fn, NULL); 317 341 free(mask); 318 342 cli_rmdir(c, dname); -
trunk/server/source3/torture/pdbtest.c
r596 r745 22 22 23 23 #include "includes.h" 24 #include "popt_common.h" 25 #include "passdb.h" 24 26 25 27 static bool samu_correct(struct samu *s1, struct samu *s2) … … 248 250 load_case_tables(); 249 251 250 pc = poptGetContext(" vfstest", argc, (const char **) argv,252 pc = poptGetContext("pdbtest", argc, (const char **) argv, 251 253 long_options, 0); 252 254 … … 259 261 /* Load configuration */ 260 262 lp_load(get_dyn_CONFIGFILE(), False, False, True, True); 261 setup_logging("pdbtest", True);263 setup_logging("pdbtest", DEBUG_STDOUT); 262 264 263 265 if (backend == NULL) { -
trunk/server/source3/torture/rpc_open_tcp.c
r414 r745 20 20 21 21 #include "includes.h" 22 22 #include "rpc_client/cli_pipe.h" 23 23 #include "librpc/gen_ndr/ndr_dfs.h" 24 24 #include "librpc/gen_ndr/ndr_drsuapi.h" -
trunk/server/source3/torture/scanner.c
r414 r745 3 3 SMB torture tester - scanning functions 4 4 Copyright (C) Andrew Tridgell 2001 5 5 6 6 This program is free software; you can redistribute it and/or modify 7 7 it under the terms of the GNU General Public License as published by 8 8 the Free Software Foundation; either version 3 of the License, or 9 9 (at your option) any later version. 10 10 11 11 This program is distributed in the hope that it will be useful, 12 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 GNU General Public License for more details. 15 15 16 16 You should have received a copy of the GNU General Public License 17 17 along with this program. If not, see <http://www.gnu.org/licenses/>. … … 19 19 20 20 #include "includes.h" 21 #include "system/filesys.h" 22 #include "torture/proto.h" 23 #include "libsmb/libsmb.h" 21 24 22 25 #define VERBOSE 0 … … 50 53 static NTSTATUS try_trans2(struct cli_state *cli, 51 54 int op, 52 char *param, char*data,53 int param_len, int data_len,54 u nsigned int *rparam_len, unsigned int *rdata_len)55 { 56 uint16 setup = op;57 char*rparam=NULL, *rdata=NULL;58 59 if (!cli_send_trans(cli, SMBtrans2, 60 NULL, /* name */ 61 -1, 0, /* fid, flags */ 62 &setup, 1, 0, /* setup, length, max */ 63 param, param_len, 2, /* param, length, max*/64 data, data_len, cli->max_xmit /* data, length, max */ 65 )) { 66 return cli_nt_error(cli);67 }68 69 cli_receive_trans(cli, SMBtrans2,70 &rparam, rparam_len,71 &rdata, rdata_len);72 73 SAFE_FREE(rdata);74 SAFE_FREE(rparam);75 76 return cli_nt_error(cli);55 uint8_t *param, uint8_t *data, 56 uint32_t param_len, uint32_t data_len, 57 uint32_t *rparam_len, uint32_t *rdata_len) 58 { 59 uint16_t setup[1]; 60 uint8_t *rparam=NULL, *rdata=NULL; 61 NTSTATUS status; 62 63 SSVAL(setup+0, 0, op); 64 65 status = cli_trans(talloc_tos(), cli, SMBtrans2, 66 NULL, -1, /* name, fid */ 67 op, 0, 68 NULL, 0, 0, /* setup */ 69 param, param_len, 2, 70 data, data_len, cli->max_xmit, 71 NULL, /* recv_flags2 */ 72 NULL, 0, NULL, /* rsetup */ 73 &rparam, 0, rparam_len, 74 &rdata, 0, rdata_len); 75 76 TALLOC_FREE(rdata); 77 TALLOC_FREE(rparam); 78 79 return status; 77 80 } 78 81 … … 81 84 const char *format, 82 85 int op, int level, 83 char *param, char*data,84 int param_len, int *data_len,85 u nsigned int *rparam_len, unsigned int *rdata_len)86 uint8_t *param, uint8_t *data, 87 uint32_t param_len, uint32_t *data_len, 88 uint32_t *rparam_len, uint32_t *rdata_len) 86 89 { 87 90 NTSTATUS ret=NT_STATUS_OK; … … 116 119 int fnum, int dnum, const char *fname) 117 120 { 118 int data_len = 0;119 int param_len = 0;120 u nsigned int rparam_len, rdata_len;121 charparam[PARAM_SIZE], data[DATA_SIZE];121 uint32_t data_len = 0; 122 uint32_t param_len = 0; 123 uint32_t rparam_len, rdata_len; 124 uint8_t param[PARAM_SIZE], data[DATA_SIZE]; 122 125 NTSTATUS status; 123 126 … … 171 174 status = try_trans2_len(cli, "newfile", op, level, param, data, param_len, &data_len, 172 175 &rparam_len, &rdata_len); 173 cli_unlink(cli, "\\newfile.dat", aSYSTEM | aHIDDEN);176 cli_unlink(cli, "\\newfile.dat", FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 174 177 cli_rmdir(cli, "\\newfile.dat"); 175 178 if (NT_STATUS_IS_OK(status)) return True; … … 259 262 ****************************************************************************/ 260 263 static NTSTATUS try_nttrans(struct cli_state *cli, 261 int op, 262 char *param, char *data, 263 int param_len, int data_len, 264 unsigned int *rparam_len, unsigned int *rdata_len) 265 { 266 char *rparam=NULL, *rdata=NULL; 267 268 if (!cli_send_nt_trans(cli, op, 269 0, 270 NULL, 0, 0, 271 param, param_len, 2, /* param, length, max */ 272 data, data_len, cli->max_xmit /* data, length, max */ 273 )) { 274 return cli_nt_error(cli); 275 } 276 277 cli_receive_nt_trans(cli, 278 &rparam, rparam_len, 279 &rdata, rdata_len); 280 264 int op, 265 uint8_t *param, uint8_t *data, 266 int32_t param_len, uint32_t data_len, 267 uint32_t *rparam_len, 268 uint32_t *rdata_len) 269 { 270 uint8_t *rparam=NULL, *rdata=NULL; 271 NTSTATUS status; 272 273 status = cli_trans(talloc_tos(), cli, SMBnttrans, 274 NULL, -1, /* name, fid */ 275 op, 0, 276 NULL, 0, 0, /* setup */ 277 param, param_len, 2, 278 data, data_len, cli->max_xmit, 279 NULL, /* recv_flags2 */ 280 NULL, 0, NULL, /* rsetup */ 281 &rparam, 0, rparam_len, 282 &rdata, 0, rdata_len); 281 283 SAFE_FREE(rdata); 282 284 SAFE_FREE(rparam); 283 285 284 return cli_nt_error(cli);286 return status; 285 287 } 286 288 … … 289 291 const char *format, 290 292 int op, int level, 291 char *param, char*data,292 int param_len, int *data_len,293 u nsigned int *rparam_len, unsigned int *rdata_len)293 uint8_t *param, uint8_t *data, 294 int param_len, uint32_t *data_len, 295 uint32_t *rparam_len, uint32_t *rdata_len) 294 296 { 295 297 NTSTATUS ret=NT_STATUS_OK; … … 324 326 int fnum, int dnum, const char *fname) 325 327 { 326 int data_len = 0;327 int param_len = 0;328 u nsigned int rparam_len, rdata_len;329 charparam[PARAM_SIZE], data[DATA_SIZE];328 uint32_t data_len = 0; 329 uint32_t param_len = 0; 330 uint32_t rparam_len, rdata_len; 331 uint8_t param[PARAM_SIZE], data[DATA_SIZE]; 330 332 NTSTATUS status; 331 333 … … 379 381 status = try_nttrans_len(cli, "newfile", op, level, param, data, param_len, &data_len, 380 382 &rparam_len, &rdata_len); 381 cli_unlink(cli, "\\newfile.dat", aSYSTEM | aHIDDEN);383 cli_unlink(cli, "\\newfile.dat", FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 382 384 cli_rmdir(cli, "\\newfile.dat"); 383 385 if (NT_STATUS_IS_OK(status)) return True; -
trunk/server/source3/torture/smbiconv.c
r414 r745 22 22 23 23 #include "includes.h" 24 #include "system/filesys.h" 25 #include "popt_common.h" 24 26 #undef realloc 25 27 … … 201 203 /* the following functions are part of the Samba debugging 202 204 facilities. See lib/debug.c */ 203 setup_logging("smbiconv", True);205 setup_logging("smbiconv", DEBUG_STDOUT); 204 206 205 207 if (preload_modules[0]) smb_load_modules(preload_modules); -
trunk/server/source3/torture/t_stringoverflow.c
r414 r745 3 3 int main(void) 4 4 { 5 fstring dest;5 char dest[100]; 6 6 char *ptr = dest; 7 7 … … 18 18 #endif /* 0 */ 19 19 20 pstrcpy(ptr, "hello!");20 fstrcpy(ptr, "hello!"); 21 21 22 22 return 0; -
trunk/server/source3/torture/torture.c
r454 r745 20 20 21 21 #include "includes.h" 22 #include "nsswitch/libwbclient/wbc_async.h" 22 #include "system/shmem.h" 23 #include "wbc_async.h" 24 #include "torture/proto.h" 25 #include "libcli/security/security.h" 26 #include "tldap.h" 27 #include "tldap_util.h" 28 #include "../librpc/gen_ndr/svcctl.h" 29 #include "memcache.h" 30 #include "nsswitch/winbind_client.h" 31 #include "dbwrap.h" 32 #include "talloc_dict.h" 33 #include "async_smb.h" 34 #include "libsmb/libsmb.h" 35 #include "libsmb/clirap.h" 36 #include "trans2.h" 37 #include "libsmb/nmblib.h" 38 #include "../lib/util/tevent_ntstatus.h" 39 #include "util_tdb.h" 23 40 24 41 extern char *optarg; … … 43 60 static bool do_encrypt; 44 61 static const char *local_path = NULL; 62 static int signing_state = Undefined; 45 63 46 64 bool torture_showall = False; 47 65 48 66 static double create_procs(bool (*fn)(int), bool *result); 49 50 51 static struct timeval tp1,tp2;52 53 54 void start_timer(void)55 {56 GetTimeOfDay(&tp1);57 }58 59 double end_timer(void)60 {61 GetTimeOfDay(&tp2);62 return((tp2.tv_sec - tp1.tv_sec) +63 (tp2.tv_usec - tp1.tv_usec)*1.0e-6);64 }65 67 66 68 … … 185 187 zero_sockaddr(&ss); 186 188 187 if (!(c = cli_initialise ())) {189 if (!(c = cli_initialise_ex(signing_state))) { 188 190 printf("Failed initialize cli_struct to connect with %s\n", host); 189 191 return NULL; … … 228 230 } 229 231 232 /**************************************************************************** 233 Send a corrupt session request. See rfc1002.txt 4.3 and 4.3.2. 234 ****************************************************************************/ 235 236 static bool cli_bad_session_request(struct cli_state *cli, 237 struct nmb_name *calling, struct nmb_name *called) 238 { 239 char *p; 240 int len = 4; 241 int namelen = 0; 242 char *tmp; 243 244 memcpy(&(cli->calling), calling, sizeof(*calling)); 245 memcpy(&(cli->called ), called , sizeof(*called )); 246 247 /* put in the destination name */ 248 249 tmp = name_mangle(talloc_tos(), cli->called.name, 250 cli->called.name_type); 251 if (tmp == NULL) { 252 return false; 253 } 254 255 p = cli->outbuf+len; 256 namelen = name_len((unsigned char *)tmp, talloc_get_size(tmp)); 257 if (namelen > 0) { 258 memcpy(p, tmp, namelen); 259 len += namelen; 260 } 261 TALLOC_FREE(tmp); 262 263 /* Deliberately corrupt the name len (first byte) */ 264 *p = 100; 265 266 /* and my name */ 267 268 tmp = name_mangle(talloc_tos(), cli->calling.name, 269 cli->calling.name_type); 270 if (tmp == NULL) { 271 return false; 272 } 273 274 p = cli->outbuf+len; 275 namelen = name_len((unsigned char *)tmp, talloc_get_size(tmp)); 276 if (namelen > 0) { 277 memcpy(p, tmp, namelen); 278 len += namelen; 279 } 280 TALLOC_FREE(tmp); 281 /* Deliberately corrupt the name len (first byte) */ 282 *p = 100; 283 284 /* send a session request (RFC 1002) */ 285 /* setup the packet length 286 * Remove four bytes from the length count, since the length 287 * field in the NBT Session Service header counts the number 288 * of bytes which follow. The cli_send_smb() function knows 289 * about this and accounts for those four bytes. 290 * CRH. 291 */ 292 len -= 4; 293 _smb_setlen(cli->outbuf,len); 294 SCVAL(cli->outbuf,0,0x81); 295 296 cli_send_smb(cli); 297 DEBUG(5,("Sent session request\n")); 298 299 if (!cli_receive_smb(cli)) 300 return False; 301 302 if (CVAL(cli->inbuf,0) != 0x82) { 303 /* This is the wrong place to put the error... JRA. */ 304 cli->rap_error = CVAL(cli->inbuf,4); 305 return False; 306 } 307 return(True); 308 } 309 310 static struct cli_state *open_bad_nbt_connection(void) 311 { 312 struct nmb_name called, calling; 313 struct sockaddr_storage ss; 314 struct cli_state *c; 315 NTSTATUS status; 316 317 make_nmb_name(&calling, myname, 0x0); 318 make_nmb_name(&called , host, 0x20); 319 320 zero_sockaddr(&ss); 321 322 if (!(c = cli_initialise_ex(signing_state))) { 323 printf("Failed initialize cli_struct to connect with %s\n", host); 324 return NULL; 325 } 326 327 c->port = 139; 328 329 status = cli_connect(c, host, &ss); 330 if (!NT_STATUS_IS_OK(status)) { 331 printf("Failed to connect with %s. Error %s\n", host, nt_errstr(status) ); 332 return NULL; 333 } 334 335 c->timeout = 4000; /* set a short timeout (4 seconds) */ 336 337 if (!cli_bad_session_request(c, &calling, &called)) { 338 printf("Failed to connect with %s. Error %s\n", host, nt_errstr(status) ); 339 return NULL; 340 } 341 342 return c; 343 } 344 345 230 346 /* Insert a NULL at the first separator of the given path and return a pointer 231 347 * to the remainder of the string. … … 290 406 const char *sharename) 291 407 { 292 bool retry;293 408 int flags = 0; 294 409 NTSTATUS status; … … 305 420 sharename, "?????", 306 421 username, workgroup, 307 password, flags, Undefined, &retry);422 password, flags, signing_state); 308 423 if (!NT_STATUS_IS_OK(status)) { 309 424 printf("failed to open share connection: //%s/%s port:%d - %s\n", … … 380 495 { 381 496 bool ret = True; 382 if (!cli_tdis(c)) { 383 printf("tdis failed (%s)\n", cli_errstr(c)); 497 NTSTATUS status; 498 499 status = cli_tdis(c); 500 if (!NT_STATUS_IS_OK(status)) { 501 printf("tdis failed (%s)\n", nt_errstr(status)); 384 502 ret = False; 385 503 } … … 464 582 for (i=0;i<torture_numops;i++) { 465 583 unsigned n = (unsigned)sys_random()%10; 584 466 585 if (i % 10 == 0) { 467 586 printf("%d\r", i); fflush(stdout); … … 479 598 } 480 599 481 if (cli_write(c, fnum, 0, (char *)&pid, 0, sizeof(pid)) != sizeof(pid)) { 482 printf("write failed (%s)\n", cli_errstr(c)); 600 status = cli_writeall(c, fnum, 0, (uint8_t *)&pid, 0, 601 sizeof(pid), NULL); 602 if (!NT_STATUS_IS_OK(status)) { 603 printf("write failed (%s)\n", nt_errstr(status)); 483 604 correct = False; 484 605 } 485 606 486 607 for (j=0;j<50;j++) { 487 if (cli_write(c, fnum, 0, (char *)buf, 488 sizeof(pid)+(j*sizeof(buf)), 489 sizeof(buf)) != sizeof(buf)) { 490 printf("write failed (%s)\n", cli_errstr(c)); 608 status = cli_writeall(c, fnum, 0, (uint8_t *)buf, 609 sizeof(pid)+(j*sizeof(buf)), 610 sizeof(buf), NULL); 611 if (!NT_STATUS_IS_OK(status)) { 612 printf("write failed (%s)\n", 613 nt_errstr(status)); 491 614 correct = False; 492 615 } … … 510 633 } 511 634 512 if (!NT_STATUS_IS_OK(cli_unlink(c, fname, aSYSTEM | aHIDDEN))) {635 if (!NT_STATUS_IS_OK(cli_unlink(c, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN))) { 513 636 printf("unlink failed (%s)\n", cli_errstr(c)); 514 637 correct = False; … … 522 645 523 646 cli_close(c, fnum2); 524 cli_unlink(c, lockfname, aSYSTEM | aHIDDEN);647 cli_unlink(c, lockfname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 525 648 526 649 printf("%d\n", i); … … 557 680 ssize_t sent = 0; 558 681 bool correct = True; 559 NTSTATUS status ;682 NTSTATUS status = NT_STATUS_OK; 560 683 561 684 srandom(1); … … 567 690 if (procnum == 0) 568 691 { 692 if (!NT_STATUS_IS_OK(cli_unlink(c, lockfname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN))) { 693 printf("unlink failed (%s) (normal, this file should not exist)\n", cli_errstr(c)); 694 } 695 569 696 if (!NT_STATUS_IS_OK(cli_open(c, lockfname, O_RDWR | O_CREAT | O_EXCL, 570 697 DENY_NONE, &fnum))) { … … 610 737 } 611 738 612 if (cli_write(c, fnum, 0, buf+count, count, (size_t)sent) != sent) { 613 printf("write failed (%s)\n", cli_errstr(c)); 739 status = cli_writeall(c, fnum, 0, (uint8_t *)buf+count, 740 count, (size_t)sent, NULL); 741 if (!NT_STATUS_IS_OK(status)) { 742 printf("write failed (%s)\n", 743 nt_errstr(status)); 614 744 correct = False; 615 745 } … … 660 790 ssize_t bytes_read; 661 791 662 if (!NT_STATUS_IS_OK(cli_unlink(c1, lockfname, aSYSTEM | aHIDDEN))) {792 if (!NT_STATUS_IS_OK(cli_unlink(c1, lockfname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN))) { 663 793 printf("unlink failed (%s) (normal, this file should not exist)\n", cli_errstr(c1)); 664 794 } … … 680 810 for (i=0;i<torture_numops;i++) 681 811 { 812 NTSTATUS status; 682 813 size_t buf_size = ((unsigned)sys_random()%(sizeof(buf)-1))+ 1; 683 814 if (i % 10 == 0) { … … 687 818 generate_random_buffer((unsigned char *)buf, buf_size); 688 819 689 if (cli_write(c1, fnum1, 0, buf, 0, buf_size) != buf_size) { 690 printf("write failed (%s)\n", cli_errstr(c1)); 820 status = cli_writeall(c1, fnum1, 0, (uint8_t *)buf, 0, 821 buf_size, NULL); 822 if (!NT_STATUS_IS_OK(status)) { 823 printf("write failed (%s)\n", nt_errstr(status)); 691 824 correct = False; 692 825 break; … … 718 851 } 719 852 720 if (!NT_STATUS_IS_OK(cli_unlink(c1, lockfname, aSYSTEM | aHIDDEN))) {853 if (!NT_STATUS_IS_OK(cli_unlink(c1, lockfname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN))) { 721 854 printf("unlink failed (%s)\n", cli_errstr(c1)); 722 855 correct = False; … … 777 910 } 778 911 779 static bool run_readwritelarge (int dummy)912 static bool run_readwritelarge_internal(int max_xmit_k) 780 913 { 781 914 static struct cli_state *cli1; … … 792 925 memset(buf,'\0',sizeof(buf)); 793 926 794 cli1->max_xmit = 128*1024; 795 796 printf("starting readwritelarge\n"); 797 798 cli_unlink(cli1, lockfname, aSYSTEM | aHIDDEN); 927 cli1->max_xmit = max_xmit_k*1024; 928 929 if (signing_state == Required) { 930 /* Horrible cheat to force 931 multiple signed outstanding 932 packets against a Samba server. 933 */ 934 cli1->is_samba = false; 935 } 936 937 printf("starting readwritelarge_internal\n"); 938 939 cli_unlink(cli1, lockfname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 799 940 800 941 if (!NT_STATUS_IS_OK(cli_open(cli1, lockfname, O_RDWR | O_CREAT | O_EXCL, DENY_NONE, &fnum1))) { … … 803 944 } 804 945 805 cli_write(cli1, fnum1, 0, buf, 0, sizeof(buf)); 806 807 if (!cli_qfileinfo(cli1, fnum1, NULL, &fsize, NULL, NULL, NULL, NULL, NULL)) { 946 cli_writeall(cli1, fnum1, 0, (uint8_t *)buf, 0, sizeof(buf), NULL); 947 948 if (!NT_STATUS_IS_OK(cli_qfileinfo_basic( 949 cli1, fnum1, NULL, &fsize, NULL, NULL, 950 NULL, NULL, NULL))) { 808 951 printf("qfileinfo failed (%s)\n", cli_errstr(cli1)); 809 952 correct = False; … … 811 954 812 955 if (fsize == sizeof(buf)) 813 printf("readwritelarge test 1 succeeded (size = %lx)\n",956 printf("readwritelarge_internal test 1 succeeded (size = %lx)\n", 814 957 (unsigned long)fsize); 815 958 else { 816 printf("readwritelarge test 1 failed (size = %lx)\n",959 printf("readwritelarge_internal test 1 failed (size = %lx)\n", 817 960 (unsigned long)fsize); 818 961 correct = False; … … 824 967 } 825 968 826 if (!NT_STATUS_IS_OK(cli_unlink(cli1, lockfname, aSYSTEM | aHIDDEN))) {969 if (!NT_STATUS_IS_OK(cli_unlink(cli1, lockfname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN))) { 827 970 printf("unlink failed (%s)\n", cli_errstr(cli1)); 828 971 correct = False; … … 836 979 cli1->max_xmit = 4*1024; 837 980 838 cli_smbwrite(cli1, fnum1, buf, 0, sizeof(buf)); 839 840 if (!cli_qfileinfo(cli1, fnum1, NULL, &fsize, NULL, NULL, NULL, NULL, NULL)) { 981 cli_smbwrite(cli1, fnum1, buf, 0, sizeof(buf), NULL); 982 983 if (!NT_STATUS_IS_OK(cli_qfileinfo_basic( 984 cli1, fnum1, NULL, &fsize, NULL, NULL, 985 NULL, NULL, NULL))) { 841 986 printf("qfileinfo failed (%s)\n", cli_errstr(cli1)); 842 987 correct = False; … … 844 989 845 990 if (fsize == sizeof(buf)) 846 printf("readwritelarge test 2 succeeded (size = %lx)\n",991 printf("readwritelarge_internal test 2 succeeded (size = %lx)\n", 847 992 (unsigned long)fsize); 848 993 else { 849 printf("readwritelarge test 2 failed (size = %lx)\n",994 printf("readwritelarge_internal test 2 failed (size = %lx)\n", 850 995 (unsigned long)fsize); 851 996 correct = False; … … 858 1003 return False; 859 1004 } 860 if (!cli_qfileinfo(cli1, fnum1, NULL, &fsize, NULL, NULL, NULL, NULL, NULL)) { 1005 if (!cli_qfileinfo_basic(cli1, fnum1, NULL, &fsize, NULL, NULL, NULL, 1006 NULL, NULL)) { 861 1007 printf("qfileinfo failed (%s)\n", cli_errstr(cli1)); 862 1008 correct = False; … … 875 1021 } 876 1022 return correct; 1023 } 1024 1025 static bool run_readwritelarge(int dummy) 1026 { 1027 return run_readwritelarge_internal(128); 1028 } 1029 1030 static bool run_readwritelarge_signtest(int dummy) 1031 { 1032 bool ret; 1033 signing_state = Required; 1034 ret = run_readwritelarge_internal(2); 1035 signing_state = Undefined; 1036 return ret; 877 1037 } 878 1038 … … 1024 1184 printf("starting locktest1\n"); 1025 1185 1026 cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);1186 cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 1027 1187 1028 1188 if (!NT_STATUS_IS_OK(cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1))) { … … 1096 1256 } 1097 1257 1098 if (!NT_STATUS_IS_OK(cli_unlink(cli1, fname, aSYSTEM | aHIDDEN))) {1258 if (!NT_STATUS_IS_OK(cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN))) { 1099 1259 printf("unlink failed (%s)\n", cli_errstr(cli1)); 1100 1260 return False; … … 1138 1298 printf("starting tcontest\n"); 1139 1299 1140 cli_unlink(cli, fname, aSYSTEM | aHIDDEN);1300 cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 1141 1301 1142 1302 if (!NT_STATUS_IS_OK(cli_open(cli, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1))) { … … 1148 1308 vuid1 = cli->vuid; 1149 1309 1150 if (cli_write(cli, fnum1, 0, buf, 130, 4) != 4) { 1151 printf("initial write failed (%s)", cli_errstr(cli)); 1310 status = cli_writeall(cli, fnum1, 0, (uint8_t *)buf, 130, 4, NULL); 1311 if (!NT_STATUS_IS_OK(status)) { 1312 printf("initial write failed (%s)", nt_errstr(status)); 1152 1313 return False; 1153 1314 } … … 1169 1330 cli->cnum = cnum2; 1170 1331 1171 if (cli_write(cli, fnum1, 0, buf, 130, 4) == 4) { 1332 status = cli_writeall(cli, fnum1, 0, (uint8_t *)buf, 130, 4, NULL); 1333 if (NT_STATUS_IS_OK(status)) { 1172 1334 printf("* server allows write with wrong TID\n"); 1173 1335 ret = False; 1174 1336 } else { 1175 printf("server fails write with wrong TID : %s\n", cli_errstr(cli)); 1337 printf("server fails write with wrong TID : %s\n", 1338 nt_errstr(status)); 1176 1339 } 1177 1340 … … 1180 1343 cli->cnum = cnum3; 1181 1344 1182 if (cli_write(cli, fnum1, 0, buf, 130, 4) == 4) { 1345 status = cli_writeall(cli, fnum1, 0, (uint8_t *)buf, 130, 4, NULL); 1346 if (NT_STATUS_IS_OK(status)) { 1183 1347 printf("* server allows write with invalid TID\n"); 1184 1348 ret = False; 1185 1349 } else { 1186 printf("server fails write with invalid TID : %s\n", cli_errstr(cli)); 1350 printf("server fails write with invalid TID : %s\n", 1351 nt_errstr(status)); 1187 1352 } 1188 1353 … … 1191 1356 cli->cnum = cnum1; 1192 1357 1193 if (cli_write(cli, fnum1, 0, buf, 130, 4) == 4) { 1358 status = cli_writeall(cli, fnum1, 0, (uint8_t *)buf, 130, 4, NULL); 1359 if (NT_STATUS_IS_OK(status)) { 1194 1360 printf("* server allows write with invalid VUID\n"); 1195 1361 ret = False; 1196 1362 } else { 1197 printf("server fails write with invalid VUID : %s\n", cli_errstr(cli)); 1363 printf("server fails write with invalid VUID : %s\n", 1364 nt_errstr(status)); 1198 1365 } 1199 1366 … … 1208 1375 cli->cnum = cnum2; 1209 1376 1210 if (!cli_tdis(cli)) { 1211 printf("secondary tdis failed (%s)\n", cli_errstr(cli)); 1377 status = cli_tdis(cli); 1378 if (!NT_STATUS_IS_OK(status)) { 1379 printf("secondary tdis failed (%s)\n", nt_errstr(status)); 1212 1380 return False; 1213 1381 } … … 1246 1414 status = cli_raw_tcon(cli, service, password, "?????", &max_xmit, &cnum); 1247 1415 1416 SAFE_FREE(service); 1417 1248 1418 if (!NT_STATUS_IS_OK(status)) { 1249 printf("tcon2 failed : %s\n", cli_errstr(cli));1419 printf("tcon2 failed : %s\n", nt_errstr(status)); 1250 1420 } else { 1251 printf("tcon OK : max_xmit=%d cnum=%d tid=%d\n",1252 (int)max_xmit, (int)cnum , SVAL(cli->inbuf, smb_tid));1421 printf("tcon OK : max_xmit=%d cnum=%d\n", 1422 (int)max_xmit, (int)cnum); 1253 1423 } 1254 1424 … … 1315 1485 { 1316 1486 static struct cli_state *cli1 = NULL; 1317 bool retry;1318 1487 int flags = 0; 1319 1488 NTSTATUS status; … … 1324 1493 NULL, NULL, 1325 1494 username, workgroup, 1326 password, flags, Undefined, &retry);1495 password, flags, signing_state); 1327 1496 1328 1497 if (!NT_STATUS_IS_OK(status)) { … … 1396 1565 printf("starting locktest2\n"); 1397 1566 1398 cli_unlink(cli, fname, aSYSTEM | aHIDDEN);1567 cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 1399 1568 1400 1569 cli_setpid(cli, 1); … … 1533 1702 printf("starting locktest3\n"); 1534 1703 1535 cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);1704 cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 1536 1705 1537 1706 if (!NT_STATUS_IS_OK(cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1))) { … … 1613 1782 } 1614 1783 1615 if (!NT_STATUS_IS_OK(cli_unlink(cli1, fname, aSYSTEM | aHIDDEN))) {1784 if (!NT_STATUS_IS_OK(cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN))) { 1616 1785 printf("unlink failed (%s)\n", cli_errstr(cli1)); 1617 1786 return False; … … 1646 1815 char buf[1000]; 1647 1816 bool correct = True; 1817 NTSTATUS status; 1648 1818 1649 1819 if (!torture_open_connection(&cli1, 0) || !torture_open_connection(&cli2, 1)) { … … 1656 1826 printf("starting locktest4\n"); 1657 1827 1658 cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);1828 cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 1659 1829 1660 1830 cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1); … … 1663 1833 memset(buf, 0, sizeof(buf)); 1664 1834 1665 if (cli_write(cli1, fnum1, 0, buf, 0, sizeof(buf)) != sizeof(buf)) { 1666 printf("Failed to create file\n"); 1835 status = cli_writeall(cli1, fnum1, 0, (uint8_t *)buf, 0, sizeof(buf), 1836 NULL); 1837 if (!NT_STATUS_IS_OK(status)) { 1838 printf("Failed to create file: %s\n", nt_errstr(status)); 1667 1839 correct = False; 1668 1840 goto fail; … … 1736 1908 printf("this server %s strict write locking\n", ret?"doesn't do":"does"); 1737 1909 1738 ret = cli_lock(cli1, fnum1, 130, 4, 0, READ_LOCK) && 1739 (cli_write(cli2, fnum2, 0, buf, 130, 4) == 4); 1910 ret = cli_lock(cli1, fnum1, 130, 4, 0, READ_LOCK); 1911 if (ret) { 1912 status = cli_writeall(cli2, fnum2, 0, (uint8_t *)buf, 130, 4, 1913 NULL); 1914 ret = NT_STATUS_IS_OK(status); 1915 } 1740 1916 EXPECTED(ret, False); 1741 1917 printf("this server %s strict read locking\n", ret?"doesn't do":"does"); … … 1754 1930 NT_STATUS_IS_OK(cli_unlock(cli1, fnum1, 150, 4)) && 1755 1931 (cli_read(cli2, fnum2, buf, 150, 4) == 4) && 1756 !(cli_write(cli2, fnum2, 0, buf, 150, 4) == 4) && 1932 !(NT_STATUS_IS_OK(cli_writeall(cli2, fnum2, 0, (uint8_t *)buf, 1933 150, 4, NULL))) && 1757 1934 NT_STATUS_IS_OK(cli_unlock(cli1, fnum1, 150, 4)); 1758 1935 EXPECTED(ret, True); … … 1761 1938 ret = cli_lock(cli1, fnum1, 160, 4, 0, READ_LOCK) && 1762 1939 NT_STATUS_IS_OK(cli_unlock(cli1, fnum1, 160, 4)) && 1763 (cli_write(cli2, fnum2, 0, buf, 160, 4) == 4) && 1940 NT_STATUS_IS_OK(cli_writeall(cli2, fnum2, 0, (uint8_t *)buf, 1941 160, 4, NULL)) && 1764 1942 (cli_read(cli2, fnum2, buf, 160, 4) == 4); 1765 1943 EXPECTED(ret, True); … … 1768 1946 ret = cli_lock(cli1, fnum1, 170, 4, 0, WRITE_LOCK) && 1769 1947 NT_STATUS_IS_OK(cli_unlock(cli1, fnum1, 170, 4)) && 1770 (cli_write(cli2, fnum2, 0, buf, 170, 4) == 4) && 1948 NT_STATUS_IS_OK(cli_writeall(cli2, fnum2, 0, (uint8_t *)buf, 1949 170, 4, NULL)) && 1771 1950 (cli_read(cli2, fnum2, buf, 170, 4) == 4); 1772 1951 EXPECTED(ret, True); … … 1776 1955 cli_lock(cli1, fnum1, 190, 4, 0, READ_LOCK) && 1777 1956 NT_STATUS_IS_OK(cli_unlock(cli1, fnum1, 190, 4)) && 1778 !(cli_write(cli2, fnum2, 0, buf, 190, 4) == 4) && 1957 !NT_STATUS_IS_OK(cli_writeall(cli2, fnum2, 0, (uint8_t *)buf, 1958 190, 4, NULL)) && 1779 1959 (cli_read(cli2, fnum2, buf, 190, 4) == 4); 1780 1960 EXPECTED(ret, True); … … 1798 1978 cli_close(cli1, fnum1); 1799 1979 cli_close(cli2, fnum2); 1800 cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);1980 cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 1801 1981 torture_close_connection(cli1); 1802 1982 torture_close_connection(cli2); … … 1817 1997 char buf[1000]; 1818 1998 bool correct = True; 1999 NTSTATUS status; 1819 2000 1820 2001 if (!torture_open_connection(&cli1, 0) || !torture_open_connection(&cli2, 1)) { … … 1827 2008 printf("starting locktest5\n"); 1828 2009 1829 cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);2010 cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 1830 2011 1831 2012 cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1); … … 1835 2016 memset(buf, 0, sizeof(buf)); 1836 2017 1837 if (cli_write(cli1, fnum1, 0, buf, 0, sizeof(buf)) != sizeof(buf)) { 1838 printf("Failed to create file\n"); 2018 status = cli_writeall(cli1, fnum1, 0, (uint8_t *)buf, 0, sizeof(buf), 2019 NULL); 2020 if (!NT_STATUS_IS_OK(status)) { 2021 printf("Failed to create file: %s\n", nt_errstr(status)); 1839 2022 correct = False; 1840 2023 goto fail; … … 1917 2100 cli_close(cli1, fnum1); 1918 2101 cli_close(cli2, fnum2); 1919 cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);2102 cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 1920 2103 if (!torture_close_connection(cli1)) { 1921 2104 correct = False; … … 1952 2135 printf("Testing %s\n", fname[i]); 1953 2136 1954 cli_unlink(cli, fname[i], aSYSTEM | aHIDDEN);2137 cli_unlink(cli, fname[i], FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 1955 2138 1956 2139 cli_open(cli, fname[i], O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum); … … 1964 2147 printf("CANCEL_LOCK gave %s\n", nt_errstr(status)); 1965 2148 1966 cli_unlink(cli, fname[i], aSYSTEM | aHIDDEN);2149 cli_unlink(cli, fname[i], FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 1967 2150 } 1968 2151 … … 1980 2163 char buf[200]; 1981 2164 bool correct = False; 2165 NTSTATUS status; 1982 2166 1983 2167 if (!torture_open_connection(&cli1, 0)) { … … 1989 2173 printf("starting locktest7\n"); 1990 2174 1991 cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);2175 cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 1992 2176 1993 2177 cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1); … … 1995 2179 memset(buf, 0, sizeof(buf)); 1996 2180 1997 if (cli_write(cli1, fnum1, 0, buf, 0, sizeof(buf)) != sizeof(buf)) { 1998 printf("Failed to create file\n"); 2181 status = cli_writeall(cli1, fnum1, 0, (uint8_t *)buf, 0, sizeof(buf), 2182 NULL); 2183 if (!NT_STATUS_IS_OK(status)) { 2184 printf("Failed to create file: %s\n", nt_errstr(status)); 1999 2185 goto fail; 2000 2186 } … … 2016 2202 } 2017 2203 2018 if (cli_write(cli1, fnum1, 0, buf, 130, 4) != 4) { 2019 printf("pid1 unable to write to the range 130:4, error was %s\n", cli_errstr(cli1)); 2020 if (NT_STATUS_V(cli_nt_error(cli1)) != NT_STATUS_V(NT_STATUS_FILE_LOCK_CONFLICT)) { 2204 status = cli_writeall(cli1, fnum1, 0, (uint8_t *)buf, 130, 4, NULL); 2205 if (!NT_STATUS_IS_OK(status)) { 2206 printf("pid1 unable to write to the range 130:4, error was " 2207 "%s\n", nt_errstr(status)); 2208 if (!NT_STATUS_EQUAL(status, NT_STATUS_FILE_LOCK_CONFLICT)) { 2021 2209 printf("Incorrect error (should be NT_STATUS_FILE_LOCK_CONFLICT)\n"); 2022 2210 goto fail; … … 2035 2223 } 2036 2224 2037 if (cli_write(cli1, fnum1, 0, buf, 130, 4) != 4) { 2038 printf("pid2 unable to write to the range 130:4, error was %s\n", cli_errstr(cli1)); 2039 if (NT_STATUS_V(cli_nt_error(cli1)) != NT_STATUS_V(NT_STATUS_FILE_LOCK_CONFLICT)) { 2225 status = cli_writeall(cli1, fnum1, 0, (uint8_t *)buf, 130, 4, NULL); 2226 if (!NT_STATUS_IS_OK(status)) { 2227 printf("pid2 unable to write to the range 130:4, error was " 2228 "%s\n", nt_errstr(status)); 2229 if (!NT_STATUS_EQUAL(status, NT_STATUS_FILE_LOCK_CONFLICT)) { 2040 2230 printf("Incorrect error (should be NT_STATUS_FILE_LOCK_CONFLICT)\n"); 2041 2231 goto fail; … … 2063 2253 } 2064 2254 2065 if (cli_write(cli1, fnum1, 0, buf, 130, 4) != 4) { 2066 printf("pid1 unable to write to the range 130:4, error was %s\n", cli_errstr(cli1)); 2255 status = cli_writeall(cli1, fnum1, 0, (uint8_t *)buf, 130, 4, NULL); 2256 if (!NT_STATUS_IS_OK(status)) { 2257 printf("pid1 unable to write to the range 130:4, error was " 2258 "%s\n", nt_errstr(status)); 2067 2259 goto fail; 2068 2260 } else { … … 2083 2275 } 2084 2276 2085 if (cli_write(cli1, fnum1, 0, buf, 130, 4) != 4) { 2086 printf("pid2 unable to write to the range 130:4, error was %s\n", cli_errstr(cli1)); 2087 if (NT_STATUS_V(cli_nt_error(cli1)) != NT_STATUS_V(NT_STATUS_FILE_LOCK_CONFLICT)) { 2277 status = cli_writeall(cli1, fnum1, 0, (uint8_t *)buf, 130, 4, NULL); 2278 if (!NT_STATUS_IS_OK(status)) { 2279 printf("pid2 unable to write to the range 130:4, error was " 2280 "%s\n", nt_errstr(status)); 2281 if (!NT_STATUS_EQUAL(status, NT_STATUS_FILE_LOCK_CONFLICT)) { 2088 2282 printf("Incorrect error (should be NT_STATUS_FILE_LOCK_CONFLICT)\n"); 2089 2283 goto fail; … … 2099 2293 fail: 2100 2294 cli_close(cli1, fnum1); 2101 cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);2295 cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 2102 2296 torture_close_connection(cli1); 2103 2297 … … 2131 2325 printf("starting locktest8\n"); 2132 2326 2133 cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);2327 cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 2134 2328 2135 2329 status = cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_WRITE, … … 2173 2367 cli_close(cli1, fnum1); 2174 2368 cli_close(cli1, fnum2); 2175 cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);2369 cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 2176 2370 torture_close_connection(cli1); 2177 2371 … … 2278 2472 char c = '\0'; 2279 2473 int ret; 2474 struct timeval start; 2280 2475 double seconds; 2281 2476 NTSTATUS status; … … 2350 2545 alarm(20); 2351 2546 2352 start _timer();2547 start = timeval_current(); 2353 2548 2354 2549 if (!cli_lock(cli1, fnum, 0, 4, -1, WRITE_LOCK)) { … … 2359 2554 alarm(0); 2360 2555 2361 seconds = end_timer();2556 seconds = timeval_elapsed(&start); 2362 2557 2363 2558 printf("Parent got the lock after %.2f seconds.\n", … … 2392 2587 uint16_t fnum1; 2393 2588 char buf[1024]; 2589 NTSTATUS status; 2394 2590 2395 2591 if (!torture_open_connection(&cli1, 0) || !torture_open_connection(&cli2, 1)) { … … 2401 2597 printf("starting fdpasstest\n"); 2402 2598 2403 cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);2599 cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 2404 2600 2405 2601 if (!NT_STATUS_IS_OK(cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1))) { … … 2408 2604 } 2409 2605 2410 if (cli_write(cli1, fnum1, 0, "hello world\n", 0, 13) != 13) { 2411 printf("write failed (%s)\n", cli_errstr(cli1)); 2606 status = cli_writeall(cli1, fnum1, 0, (uint8_t *)"hello world\n", 0, 2607 13, NULL); 2608 if (!NT_STATUS_IS_OK(status)) { 2609 printf("write failed (%s)\n", nt_errstr(status)); 2412 2610 return False; 2413 2611 } … … 2424 2622 2425 2623 cli_close(cli1, fnum1); 2426 cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);2624 cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 2427 2625 2428 2626 torture_close_connection(cli1); … … 2446 2644 char buf[1024]; 2447 2645 bool ret = True; 2646 NTSTATUS status; 2448 2647 2449 2648 if (!torture_open_connection(&cli, 0)) … … 2462 2661 printf("starting fdsesstest\n"); 2463 2662 2464 cli_unlink(cli, fname, aSYSTEM | aHIDDEN);2465 cli_unlink(cli, fname1, aSYSTEM | aHIDDEN);2663 cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 2664 cli_unlink(cli, fname1, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 2466 2665 2467 2666 if (!NT_STATUS_IS_OK(cli_open(cli, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1))) { … … 2470 2669 } 2471 2670 2472 if (cli_write(cli, fnum1, 0, "hello world\n", 0, 13) != 13) { 2473 printf("write failed (%s)\n", cli_errstr(cli)); 2671 status = cli_writeall(cli, fnum1, 0, (uint8_t *)"hello world\n", 0, 13, 2672 NULL); 2673 if (!NT_STATUS_IS_OK(status)) { 2674 printf("write failed (%s)\n", nt_errstr(status)); 2474 2675 return False; 2475 2676 } … … 2487 2688 printf("create with different vuid, same cnum succeeded.\n"); 2488 2689 cli_close(cli, fnum2); 2489 cli_unlink(cli, fname1, aSYSTEM | aHIDDEN);2690 cli_unlink(cli, fname1, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 2490 2691 } else { 2491 2692 printf("create with different vuid, same cnum failed.\n"); … … 2507 2708 cli->cnum = saved_cnum; 2508 2709 cli_close(cli, fnum1); 2509 cli_unlink(cli, fname, aSYSTEM | aHIDDEN);2710 cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 2510 2711 2511 2712 torture_close_connection(cli); … … 2535 2736 printf("starting unlink test\n"); 2536 2737 2537 cli_unlink(cli, fname, aSYSTEM | aHIDDEN);2738 cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 2538 2739 2539 2740 cli_setpid(cli, 1); … … 2544 2745 } 2545 2746 2546 if (NT_STATUS_IS_OK(cli_unlink(cli, fname, aSYSTEM | aHIDDEN))) {2747 if (NT_STATUS_IS_OK(cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN))) { 2547 2748 printf("error: server allowed unlink on an open file\n"); 2548 2749 correct = False; … … 2553 2754 2554 2755 cli_close(cli, fnum); 2555 cli_unlink(cli, fname, aSYSTEM | aHIDDEN);2756 cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 2556 2757 2557 2758 if (!torture_close_connection(cli)) { … … 2605 2806 slprintf(fname,sizeof(fname)-1,ftemplate, i,(int)getpid()); 2606 2807 cli_close(cli, fnums[i]); 2607 if (!NT_STATUS_IS_OK(cli_unlink(cli, fname, aSYSTEM | aHIDDEN))) {2808 if (!NT_STATUS_IS_OK(cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN))) { 2608 2809 printf("unlink of %s failed (%s)\n", 2609 2810 fname, cli_errstr(cli)); … … 2633 2834 static bool run_negprot_nowait(int dummy) 2634 2835 { 2836 struct tevent_context *ev; 2635 2837 int i; 2838 struct cli_state *cli; 2839 bool correct = True; 2840 2841 printf("starting negprot nowait test\n"); 2842 2843 ev = tevent_context_init(talloc_tos()); 2844 if (ev == NULL) { 2845 return false; 2846 } 2847 2848 if (!(cli = open_nbt_connection())) { 2849 TALLOC_FREE(ev); 2850 return False; 2851 } 2852 2853 for (i=0;i<50000;i++) { 2854 struct tevent_req *req; 2855 2856 req = cli_negprot_send(ev, ev, cli); 2857 if (req == NULL) { 2858 TALLOC_FREE(ev); 2859 return false; 2860 } 2861 if (!tevent_req_poll(req, ev)) { 2862 d_fprintf(stderr, "tevent_req_poll failed: %s\n", 2863 strerror(errno)); 2864 TALLOC_FREE(ev); 2865 return false; 2866 } 2867 TALLOC_FREE(req); 2868 } 2869 2870 if (torture_close_connection(cli)) { 2871 correct = False; 2872 } 2873 2874 printf("finished negprot nowait test\n"); 2875 2876 return correct; 2877 } 2878 2879 /* send smb negprot commands, not reading the response */ 2880 static bool run_bad_nbt_session(int dummy) 2881 { 2636 2882 static struct cli_state *cli; 2637 bool correct = True; 2638 2639 printf("starting negprot nowait test\n"); 2640 2641 if (!(cli = open_nbt_connection())) { 2642 return False; 2643 } 2644 2645 for (i=0;i<50000;i++) { 2646 cli_negprot_sendsync(cli); 2647 } 2648 2649 if (!torture_close_connection(cli)) { 2650 correct = False; 2651 } 2652 2653 printf("finished negprot nowait test\n"); 2654 2655 return correct; 2656 } 2657 2883 2884 printf("starting bad nbt session test\n"); 2885 2886 if (!(cli = open_bad_nbt_connection())) { 2887 return False; 2888 } 2889 2890 cli_shutdown(cli); 2891 printf("finished bad nbt session test\n"); 2892 return true; 2893 } 2658 2894 2659 2895 /* send random IPC commands */ … … 2766 3002 } 2767 3003 2768 cli_unlink(cli, fname, aSYSTEM | aHIDDEN);3004 cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 2769 3005 cli_open(cli, fname, 2770 3006 O_RDWR | O_CREAT | O_TRUNC, DENY_NONE, &fnum); … … 2801 3037 } 2802 3038 2803 cli_unlink(cli, fname, aSYSTEM | aHIDDEN);3039 cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 2804 3040 2805 3041 if (!torture_close_connection(cli)) { … … 2828 3064 char pname[1024]; 2829 3065 bool correct = True; 3066 NTSTATUS status; 3067 uint32_t fs_attr; 2830 3068 2831 3069 printf("starting trans2 test\n"); … … 2835 3073 } 2836 3074 2837 cli_unlink(cli, fname, aSYSTEM | aHIDDEN); 3075 status = cli_get_fs_attr_info(cli, &fs_attr); 3076 if (!NT_STATUS_IS_OK(status)) { 3077 printf("ERROR: cli_get_fs_attr_info returned %s\n", 3078 nt_errstr(status)); 3079 correct = false; 3080 } 3081 3082 cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 2838 3083 cli_open(cli, fname, 2839 3084 O_RDWR | O_CREAT | O_TRUNC, DENY_NONE, &fnum); 2840 if (!cli_qfileinfo(cli, fnum, NULL, &size, &c_time_ts, &a_time_ts, &w_time_ts, 2841 &m_time_ts, NULL)) { 3085 if (!NT_STATUS_IS_OK(cli_qfileinfo_basic( 3086 cli, fnum, NULL, &size, &c_time_ts, 3087 &a_time_ts, &w_time_ts, 3088 &m_time_ts, NULL))) { 2842 3089 printf("ERROR: qfileinfo failed (%s)\n", cli_errstr(cli)); 2843 3090 correct = False; 2844 3091 } 2845 3092 2846 if (! cli_qfilename(cli, fnum, pname, sizeof(pname))) {3093 if (!NT_STATUS_IS_OK(cli_qfilename(cli, fnum, pname, sizeof(pname)))) { 2847 3094 printf("ERROR: qfilename failed (%s)\n", cli_errstr(cli)); 2848 3095 correct = False; … … 2859 3106 sleep(2); 2860 3107 2861 cli_unlink(cli, fname, aSYSTEM | aHIDDEN);3108 cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 2862 3109 if (!NT_STATUS_IS_OK(cli_open(cli, fname, 2863 3110 O_RDWR | O_CREAT | O_TRUNC, DENY_NONE, &fnum))) { … … 2867 3114 cli_close(cli, fnum); 2868 3115 2869 if (!cli_qpathinfo(cli, fname, &c_time, &a_time, &m_time, &size, NULL)) { 2870 printf("ERROR: qpathinfo failed (%s)\n", cli_errstr(cli)); 3116 status = cli_qpathinfo1(cli, fname, &c_time, &a_time, &m_time, &size, 3117 NULL); 3118 if (!NT_STATUS_IS_OK(status)) { 3119 printf("ERROR: qpathinfo failed (%s)\n", nt_errstr(status)); 2871 3120 correct = False; 2872 3121 } else { … … 2889 3138 2890 3139 2891 cli_unlink(cli, fname, aSYSTEM | aHIDDEN);3140 cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 2892 3141 cli_open(cli, fname, 2893 3142 O_RDWR | O_CREAT | O_TRUNC, DENY_NONE, &fnum); 2894 3143 cli_close(cli, fnum); 2895 if (!cli_qpathinfo2(cli, fname, &c_time_ts, &a_time_ts, &w_time_ts, 2896 &m_time_ts, &size, NULL, NULL)) { 2897 printf("ERROR: qpathinfo2 failed (%s)\n", cli_errstr(cli)); 3144 status = cli_qpathinfo2(cli, fname, &c_time_ts, &a_time_ts, &w_time_ts, 3145 &m_time_ts, &size, NULL, NULL); 3146 if (!NT_STATUS_IS_OK(status)) { 3147 printf("ERROR: qpathinfo2 failed (%s)\n", nt_errstr(status)); 2898 3148 correct = False; 2899 3149 } else { … … 2905 3155 } 2906 3156 2907 cli_unlink(cli, fname, aSYSTEM | aHIDDEN);3157 cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 2908 3158 2909 3159 … … 2915 3165 } 2916 3166 sleep(3); 2917 if (!cli_qpathinfo2(cli, "\\trans2\\", &c_time_ts, &a_time_ts, &w_time_ts, 2918 &m_time_ts, &size, NULL, NULL)) { 2919 printf("ERROR: qpathinfo2 failed (%s)\n", cli_errstr(cli)); 3167 status = cli_qpathinfo2(cli, "\\trans2\\", &c_time_ts, &a_time_ts, 3168 &w_time_ts, &m_time_ts, &size, NULL, NULL); 3169 if (!NT_STATUS_IS_OK(status)) { 3170 printf("ERROR: qpathinfo2 failed (%s)\n", nt_errstr(status)); 2920 3171 correct = False; 2921 3172 } … … 2923 3174 cli_open(cli, fname2, 2924 3175 O_RDWR | O_CREAT | O_TRUNC, DENY_NONE, &fnum); 2925 cli_write (cli, fnum, 0, (char *)&fnum, 0, sizeof(fnum));3176 cli_writeall(cli, fnum, 0, (uint8_t *)&fnum, 0, sizeof(fnum), NULL); 2926 3177 cli_close(cli, fnum); 2927 if (!cli_qpathinfo2(cli, "\\trans2\\", &c_time_ts, &a_time_ts, &w_time_ts, 2928 &m_time2_ts, &size, NULL, NULL)) { 2929 printf("ERROR: qpathinfo2 failed (%s)\n", cli_errstr(cli)); 3178 status = cli_qpathinfo2(cli, "\\trans2\\", &c_time_ts, &a_time_ts, 3179 &w_time_ts, &m_time2_ts, &size, NULL, NULL); 3180 if (!NT_STATUS_IS_OK(status)) { 3181 printf("ERROR: qpathinfo2 failed (%s)\n", nt_errstr(status)); 2930 3182 correct = False; 2931 3183 } else { … … 2936 3188 } 2937 3189 } 2938 cli_unlink(cli, fname2, aSYSTEM | aHIDDEN);3190 cli_unlink(cli, fname2, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 2939 3191 cli_rmdir(cli, dname); 2940 3192 … … 2952 3204 */ 2953 3205 2954 static boolnew_trans(struct cli_state *pcli, int fnum, int level)2955 { 2956 char*buf = NULL;3206 static NTSTATUS new_trans(struct cli_state *pcli, int fnum, int level) 3207 { 3208 uint8_t *buf = NULL; 2957 3209 uint32 len; 2958 bool correct = True; 2959 2960 if (!cli_qfileinfo_test(pcli, fnum, level, &buf, &len)) { 2961 printf("ERROR: qfileinfo (%d) failed (%s)\n", level, cli_errstr(pcli)); 2962 correct = False; 3210 NTSTATUS status; 3211 3212 status = cli_qfileinfo(talloc_tos(), pcli, fnum, level, 0, 3213 pcli->max_xmit, &buf, &len); 3214 if (!NT_STATUS_IS_OK(status)) { 3215 printf("ERROR: qfileinfo (%d) failed (%s)\n", level, 3216 nt_errstr(status)); 2963 3217 } else { 2964 3218 printf("qfileinfo: level %d, len = %u\n", level, len); … … 2966 3220 printf("\n"); 2967 3221 } 2968 SAFE_FREE(buf);2969 return correct;3222 TALLOC_FREE(buf); 3223 return status; 2970 3224 } 2971 3225 … … 3019 3273 } 3020 3274 3021 cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);3275 cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 3022 3276 3023 3277 cli_sockopt(cli1, sockops); … … 3032 3286 cli1->use_oplocks = False; 3033 3287 3034 cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);3035 cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);3288 cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 3289 cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 3036 3290 3037 3291 if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) { … … 3040 3294 } 3041 3295 3042 if (!NT_STATUS_IS_OK(cli_unlink(cli1, fname, aSYSTEM | aHIDDEN))) {3296 if (!NT_STATUS_IS_OK(cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN))) { 3043 3297 printf("unlink failed (%s)\n", cli_errstr(cli1)); 3044 3298 return False; … … 3090 3344 cli2->use_level_II_oplocks = True; 3091 3345 3092 cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);3346 cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 3093 3347 3094 3348 cli_sockopt(cli1, sockops); … … 3155 3409 cli_read(cli1, fnum1, buf, 0, 4); 3156 3410 3157 #if 03158 if (cli_write(cli1, fnum1, 0, buf, 0, 4) != 4) {3159 printf("write on fnum1 failed (%s)\n", cli_errstr(cli1));3160 correct = False;3161 }3162 #endif3163 3164 3411 if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) { 3165 3412 printf("close1 failed (%s)\n", cli_errstr(cli1)); … … 3169 3416 sleep(4); 3170 3417 3171 if (!NT_STATUS_IS_OK(cli_unlink(cli1, fname, aSYSTEM | aHIDDEN))) {3418 if (!NT_STATUS_IS_OK(cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN))) { 3172 3419 printf("unlink failed (%s)\n", cli_errstr(cli1)); 3173 3420 correct = False; … … 3220 3467 /* try to trigger a oplock break in parent */ 3221 3468 cli_open(cli, fname, O_RDWR, DENY_NONE, &fnum); 3222 cli_write (cli, fnum, 0, buf, 0, 4);3469 cli_writeall(cli, fnum, 0, (uint8_t *)buf, 0, 4, NULL); 3223 3470 exit(0); 3224 3471 } … … 3232 3479 cli_oplock_handler(cli, oplock3_handler); 3233 3480 cli_open(cli, fname, O_RDWR|O_CREAT, DENY_NONE, &fnum); 3234 cli_write (cli, fnum, 0, buf, 0, 4);3481 cli_writeall(cli, fnum, 0, (uint8_t *)buf, 0, 4, NULL); 3235 3482 cli_close(cli, fnum); 3236 3483 cli_open(cli, fname, O_RDWR, DENY_NONE, &fnum); … … 3244 3491 } 3245 3492 3493 /* handler for oplock 4 tests */ 3494 bool *oplock4_shared_correct; 3495 3496 static NTSTATUS oplock4_handler(struct cli_state *cli, uint16_t fnum, unsigned char level) 3497 { 3498 printf("got oplock break fnum=%d level=%d\n", 3499 fnum, level); 3500 *oplock4_shared_correct = true; 3501 cli_oplock_ack(cli, fnum, level); 3502 return NT_STATUS_UNSUCCESSFUL; /* Cause cli_receive_smb to return. */ 3503 } 3504 3505 static bool run_oplock4(int dummy) 3506 { 3507 struct cli_state *cli1, *cli2; 3508 const char *fname = "\\lockt4.lck"; 3509 const char *fname_ln = "\\lockt4_ln.lck"; 3510 uint16_t fnum1, fnum2; 3511 int saved_use_oplocks = use_oplocks; 3512 NTSTATUS status; 3513 bool correct = true; 3514 3515 oplock4_shared_correct = (bool *)shm_setup(sizeof(bool)); 3516 *oplock4_shared_correct = false; 3517 3518 printf("starting oplock test 4\n"); 3519 3520 if (!torture_open_connection(&cli1, 0)) { 3521 use_level_II_oplocks = false; 3522 use_oplocks = saved_use_oplocks; 3523 return false; 3524 } 3525 3526 if (!torture_open_connection(&cli2, 1)) { 3527 use_level_II_oplocks = false; 3528 use_oplocks = saved_use_oplocks; 3529 return false; 3530 } 3531 3532 cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 3533 cli_unlink(cli1, fname_ln, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 3534 3535 cli_sockopt(cli1, sockops); 3536 cli_sockopt(cli2, sockops); 3537 3538 /* Create the file. */ 3539 if (!NT_STATUS_IS_OK(cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1))) { 3540 printf("open of %s failed (%s)\n", fname, cli_errstr(cli1)); 3541 return false; 3542 } 3543 3544 if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) { 3545 printf("close1 failed (%s)\n", cli_errstr(cli1)); 3546 return false; 3547 } 3548 3549 /* Now create a hardlink. */ 3550 if (!NT_STATUS_IS_OK(cli_nt_hardlink(cli1, fname, fname_ln))) { 3551 printf("nt hardlink failed (%s)\n", cli_errstr(cli1)); 3552 return false; 3553 } 3554 3555 /* Prove that opening hardlinks cause deny modes to conflict. */ 3556 if (!NT_STATUS_IS_OK(cli_open(cli1, fname, O_RDWR, DENY_ALL, &fnum1))) { 3557 printf("open of %s failed (%s)\n", fname, cli_errstr(cli1)); 3558 return false; 3559 } 3560 3561 status = cli_open(cli1, fname_ln, O_RDWR, DENY_NONE, &fnum2); 3562 if (NT_STATUS_IS_OK(status)) { 3563 printf("open of %s succeeded - should fail with sharing violation.\n", 3564 fname_ln); 3565 return false; 3566 } 3567 3568 if (!NT_STATUS_EQUAL(status, NT_STATUS_SHARING_VIOLATION)) { 3569 printf("open of %s should fail with sharing violation. Got %s\n", 3570 fname_ln, nt_errstr(status)); 3571 return false; 3572 } 3573 3574 if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) { 3575 printf("close1 failed (%s)\n", cli_errstr(cli1)); 3576 return false; 3577 } 3578 3579 cli1->use_oplocks = true; 3580 cli1->use_level_II_oplocks = true; 3581 3582 cli2->use_oplocks = true; 3583 cli2->use_level_II_oplocks = true; 3584 3585 cli_oplock_handler(cli1, oplock4_handler); 3586 if (!NT_STATUS_IS_OK(cli_open(cli1, fname, O_RDWR, DENY_NONE, &fnum1))) { 3587 printf("open of %s failed (%s)\n", fname, cli_errstr(cli1)); 3588 return false; 3589 } 3590 3591 if (fork() == 0) { 3592 /* Child code */ 3593 if (!NT_STATUS_IS_OK(cli_open(cli2, fname_ln, O_RDWR, DENY_NONE, &fnum2))) { 3594 printf("open of %s failed (%s)\n", fname_ln, cli_errstr(cli1)); 3595 *oplock4_shared_correct = false; 3596 exit(0); 3597 } 3598 3599 if (!NT_STATUS_IS_OK(cli_close(cli2, fnum2))) { 3600 printf("close2 failed (%s)\n", cli_errstr(cli1)); 3601 *oplock4_shared_correct = false; 3602 } 3603 3604 exit(0); 3605 } 3606 3607 sleep(2); 3608 3609 /* Process the oplock break. */ 3610 cli_receive_smb(cli1); 3611 3612 if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) { 3613 printf("close1 failed (%s)\n", cli_errstr(cli1)); 3614 correct = false; 3615 } 3616 3617 if (!NT_STATUS_IS_OK(cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN))) { 3618 printf("unlink failed (%s)\n", cli_errstr(cli1)); 3619 correct = false; 3620 } 3621 if (!NT_STATUS_IS_OK(cli_unlink(cli1, fname_ln, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN))) { 3622 printf("unlink failed (%s)\n", cli_errstr(cli1)); 3623 correct = false; 3624 } 3625 3626 if (!torture_close_connection(cli1)) { 3627 correct = false; 3628 } 3629 3630 if (!*oplock4_shared_correct) { 3631 correct = false; 3632 } 3633 3634 printf("finished oplock test 4\n"); 3635 3636 return correct; 3637 } 3246 3638 3247 3639 … … 3269 3661 3270 3662 cli_setatr(cli1, fname, 0, 0); 3271 cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);3663 cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 3272 3664 3273 3665 if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, GENERIC_ALL_ACCESS|DELETE_ACCESS, FILE_ATTRIBUTE_NORMAL, … … 3279 3671 } 3280 3672 3281 #if 0 /* JRATEST */3282 {3283 uint32 *accinfo = NULL;3284 uint32 len;3285 cli_qfileinfo_test(cli1, fnum1, SMB_FILE_ACCESS_INFORMATION, (char **)&accinfo, &len);3286 if (accinfo)3287 printf("access mode = 0x%lx\n", *accinfo);3288 SAFE_FREE(accinfo);3289 }3290 #endif3291 3292 3673 if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) { 3293 3674 printf("[1] close failed (%s)\n", cli_errstr(cli1)); … … 3307 3688 3308 3689 cli_setatr(cli1, fname, 0, 0); 3309 cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);3690 cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 3310 3691 3311 3692 if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, GENERIC_ALL_ACCESS, … … 3336 3717 goto fail; 3337 3718 } 3338 cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);3719 cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 3339 3720 } else 3340 3721 printf("second delete on close test succeeded.\n"); … … 3342 3723 /* Test 3 - ... */ 3343 3724 cli_setatr(cli1, fname, 0, 0); 3344 cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);3725 cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 3345 3726 3346 3727 if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, GENERIC_ALL_ACCESS, FILE_ATTRIBUTE_NORMAL, … … 3395 3776 printf("[3] close failed (%s)\n", cli_errstr(cli1)); 3396 3777 } 3397 cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);3778 cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 3398 3779 correct = False; 3399 3780 goto fail; … … 3403 3784 /* Test 4 ... */ 3404 3785 cli_setatr(cli1, fname, 0, 0); 3405 cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);3786 cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 3406 3787 3407 3788 if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, FILE_READ_DATA|FILE_WRITE_DATA|DELETE_ACCESS, … … 3450 3831 /* Test 5 ... */ 3451 3832 cli_setatr(cli1, fname, 0, 0); 3452 cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);3833 cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 3453 3834 3454 3835 if (!NT_STATUS_IS_OK(cli_open(cli1, fname, O_RDWR|O_CREAT, DENY_NONE, &fnum1))) { … … 3476 3857 /* Test 6 ... */ 3477 3858 cli_setatr(cli1, fname, 0, 0); 3478 cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);3859 cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 3479 3860 3480 3861 if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, FILE_READ_DATA|FILE_WRITE_DATA, … … 3504 3885 /* Test 7 ... */ 3505 3886 cli_setatr(cli1, fname, 0, 0); 3506 cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);3887 cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 3507 3888 3508 3889 if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, FILE_READ_DATA|FILE_WRITE_DATA|DELETE_ACCESS, … … 3549 3930 /* Test 7 ... */ 3550 3931 cli_setatr(cli1, fname, 0, 0); 3551 cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);3932 cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 3552 3933 3553 3934 if (!torture_open_connection(&cli2, 1)) { … … 3634 4015 3635 4016 cli_setatr(cli1, fname, 0, 0); 3636 cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);4017 cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 3637 4018 3638 4019 /* What error do we get when attempting to open a read-only file with … … 3682 4063 if (fnum2 != (uint16_t)-1) cli_close(cli1, fnum2); 3683 4064 cli_setatr(cli1, fname, 0, 0); 3684 cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);4065 cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 3685 4066 3686 4067 if (cli1 && !torture_close_connection(cli1)) { … … 3693 4074 } 3694 4075 4076 static bool run_deletetest_ln(int dummy) 4077 { 4078 struct cli_state *cli; 4079 const char *fname = "\\delete1"; 4080 const char *fname_ln = "\\delete1_ln"; 4081 uint16_t fnum; 4082 uint16_t fnum1; 4083 NTSTATUS status; 4084 bool correct = true; 4085 time_t t; 4086 4087 printf("starting deletetest-ln\n"); 4088 4089 if (!torture_open_connection(&cli, 0)) { 4090 return false; 4091 } 4092 4093 cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 4094 cli_unlink(cli, fname_ln, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 4095 4096 cli_sockopt(cli, sockops); 4097 4098 /* Create the file. */ 4099 if (!NT_STATUS_IS_OK(cli_open(cli, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum))) { 4100 printf("open of %s failed (%s)\n", fname, cli_errstr(cli)); 4101 return false; 4102 } 4103 4104 if (!NT_STATUS_IS_OK(cli_close(cli, fnum))) { 4105 printf("close1 failed (%s)\n", cli_errstr(cli)); 4106 return false; 4107 } 4108 4109 /* Now create a hardlink. */ 4110 if (!NT_STATUS_IS_OK(cli_nt_hardlink(cli, fname, fname_ln))) { 4111 printf("nt hardlink failed (%s)\n", cli_errstr(cli)); 4112 return false; 4113 } 4114 4115 /* Open the original file. */ 4116 status = cli_ntcreate(cli, fname, 0, FILE_READ_DATA, 4117 FILE_ATTRIBUTE_NORMAL, 4118 FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, 4119 FILE_OPEN_IF, 0, 0, &fnum); 4120 if (!NT_STATUS_IS_OK(status)) { 4121 printf("ntcreate of %s failed (%s)\n", fname, nt_errstr(status)); 4122 return false; 4123 } 4124 4125 /* Unlink the hard link path. */ 4126 status = cli_ntcreate(cli, fname_ln, 0, DELETE_ACCESS, 4127 FILE_ATTRIBUTE_NORMAL, 4128 FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, 4129 FILE_OPEN_IF, 0, 0, &fnum1); 4130 if (!NT_STATUS_IS_OK(status)) { 4131 printf("ntcreate of %s failed (%s)\n", fname_ln, nt_errstr(status)); 4132 return false; 4133 } 4134 status = cli_nt_delete_on_close(cli, fnum1, true); 4135 if (!NT_STATUS_IS_OK(status)) { 4136 d_printf("(%s) failed to set delete_on_close %s: %s\n", 4137 __location__, fname_ln, nt_errstr(status)); 4138 return false; 4139 } 4140 4141 status = cli_close(cli, fnum1); 4142 if (!NT_STATUS_IS_OK(status)) { 4143 printf("close %s failed (%s)\n", 4144 fname_ln, nt_errstr(status)); 4145 return false; 4146 } 4147 4148 status = cli_close(cli, fnum); 4149 if (!NT_STATUS_IS_OK(status)) { 4150 printf("close %s failed (%s)\n", 4151 fname, nt_errstr(status)); 4152 return false; 4153 } 4154 4155 /* Ensure the original file is still there. */ 4156 status = cli_getatr(cli, fname, NULL, NULL, &t); 4157 if (!NT_STATUS_IS_OK(status)) { 4158 printf("%s getatr on file %s failed (%s)\n", 4159 __location__, 4160 fname, 4161 nt_errstr(status)); 4162 correct = False; 4163 } 4164 4165 /* Ensure the link path is gone. */ 4166 status = cli_getatr(cli, fname_ln, NULL, NULL, &t); 4167 if (!NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) { 4168 printf("%s, getatr for file %s returned wrong error code %s " 4169 "- should have been deleted\n", 4170 __location__, 4171 fname_ln, nt_errstr(status)); 4172 correct = False; 4173 } 4174 4175 cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 4176 cli_unlink(cli, fname_ln, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 4177 4178 if (!torture_close_connection(cli)) { 4179 correct = false; 4180 } 4181 4182 printf("finished deletetest-ln\n"); 4183 4184 return correct; 4185 } 3695 4186 3696 4187 /* … … 3791 4282 bool correct = True; 3792 4283 uint16_t fnum1; 4284 uint16_t attr; 3793 4285 NTSTATUS status; 3794 4286 … … 3799 4291 } 3800 4292 3801 cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);3802 cli_unlink(cli1, fname1, aSYSTEM | aHIDDEN);4293 cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 4294 cli_unlink(cli1, fname1, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 3803 4295 if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, GENERIC_READ_ACCESS, FILE_ATTRIBUTE_NORMAL, 3804 4296 FILE_SHARE_READ, FILE_OVERWRITE_IF, 0, 0, &fnum1))) { … … 3819 4311 } 3820 4312 3821 cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);3822 cli_unlink(cli1, fname1, aSYSTEM | aHIDDEN);4313 cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 4314 cli_unlink(cli1, fname1, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 3823 4315 status = cli_ntcreate(cli1, fname, 0, GENERIC_READ_ACCESS, FILE_ATTRIBUTE_NORMAL, 3824 4316 #if 0 … … 3845 4337 } 3846 4338 3847 cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);3848 cli_unlink(cli1, fname1, aSYSTEM | aHIDDEN);4339 cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 4340 cli_unlink(cli1, fname1, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 3849 4341 3850 4342 if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, READ_CONTROL_ACCESS, FILE_ATTRIBUTE_NORMAL, … … 3888 4380 } 3889 4381 3890 cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);3891 cli_unlink(cli1, fname1, aSYSTEM | aHIDDEN);4382 cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 4383 cli_unlink(cli1, fname1, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 3892 4384 3893 4385 /*----*/ … … 3911 4403 } 3912 4404 3913 cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);3914 cli_unlink(cli1, fname1, aSYSTEM | aHIDDEN);4405 cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 4406 cli_unlink(cli1, fname1, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 3915 4407 3916 4408 /*--*/ … … 3945 4437 3946 4438 /*--*/ 3947 3948 3949 4439 if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) { 3950 4440 printf("close - 5 failed (%s)\n", cli_errstr(cli1)); … … 3952 4442 } 3953 4443 3954 cli_unlink(cli1, fname, aSYSTEM | aHIDDEN); 3955 cli_unlink(cli1, fname1, aSYSTEM | aHIDDEN); 4444 /* Check that the renamed file has FILE_ATTRIBUTE_ARCHIVE. */ 4445 if (!NT_STATUS_IS_OK(cli_getatr(cli1, fname1, &attr, NULL, NULL))) { 4446 printf("getatr on file %s failed - %s ! \n", 4447 fname1, 4448 cli_errstr(cli1)); 4449 correct = False; 4450 } else { 4451 if (attr != FILE_ATTRIBUTE_ARCHIVE) { 4452 printf("Renamed file %s has wrong attr 0x%x " 4453 "(should be 0x%x)\n", 4454 fname1, 4455 attr, 4456 (unsigned int)FILE_ATTRIBUTE_ARCHIVE); 4457 correct = False; 4458 } else { 4459 printf("Renamed file %s has archive bit set\n", fname1); 4460 } 4461 } 4462 4463 cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 4464 cli_unlink(cli1, fname1, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 3956 4465 3957 4466 if (!torture_close_connection(cli1)) { … … 4003 4512 bool correct = True; 4004 4513 char *tmp_path; 4514 NTSTATUS status; 4005 4515 4006 4516 printf("starting open test\n"); … … 4011 4521 4012 4522 cli_setatr(cli1, fname, 0, 0); 4013 cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);4523 cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 4014 4524 4015 4525 cli_sockopt(cli1, sockops); … … 4025 4535 } 4026 4536 4027 if (!NT_STATUS_IS_OK(cli_setatr(cli1, fname, aRONLY, 0))) {4537 if (!NT_STATUS_IS_OK(cli_setatr(cli1, fname, FILE_ATTRIBUTE_READONLY, 0))) { 4028 4538 printf("cli_setatr failed (%s)\n", cli_errstr(cli1)); 4029 4539 return False; … … 4069 4579 } 4070 4580 4071 cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);4581 cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 4072 4582 4073 4583 printf("finished open test 2\n"); … … 4084 4594 memset(buf, '\0', 20); 4085 4595 4086 if (cli_write(cli1, fnum1, 0, buf, 0, 20) != 20) { 4087 printf("write failed (%s)\n", cli_errstr(cli1)); 4596 status = cli_writeall(cli1, fnum1, 0, (uint8_t *)buf, 0, 20, NULL); 4597 if (!NT_STATUS_IS_OK(status)) { 4598 printf("write failed (%s)\n", nt_errstr(status)); 4088 4599 correct = False; 4089 4600 } … … 4129 4640 printf("finished open test 3\n"); 4130 4641 4131 cli_unlink(cli1, fname, aSYSTEM | aHIDDEN); 4132 4133 4134 printf("testing ctemp\n"); 4642 cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 4643 4644 printf("Do ctemp tests\n"); 4135 4645 if (!NT_STATUS_IS_OK(cli_ctemp(cli1, talloc_tos(), "\\", &fnum1, &tmp_path))) { 4136 4646 printf("ctemp failed (%s)\n", cli_errstr(cli1)); … … 4141 4651 printf("close of temp failed (%s)\n", cli_errstr(cli1)); 4142 4652 } 4143 if (!NT_STATUS_IS_OK(cli_unlink(cli1, tmp_path, aSYSTEM | aHIDDEN))) {4653 if (!NT_STATUS_IS_OK(cli_unlink(cli1, tmp_path, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN))) { 4144 4654 printf("unlink of temp failed (%s)\n", cli_errstr(cli1)); 4145 4655 } … … 4152 4662 4153 4663 cli_setatr(cli2, fname, 0, 0); 4154 cli_unlink(cli2, fname, aSYSTEM | aHIDDEN);4664 cli_unlink(cli2, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 4155 4665 4156 4666 cli_sockopt(cli2, sockops); … … 4160 4670 if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL, 4161 4671 FILE_SHARE_NONE, FILE_OVERWRITE_IF, 0, 0, &fnum1))) { 4162 printf(" test1 open 1 of %s failed (%s)\n", fname, cli_errstr(cli1));4672 printf("TEST #1 open 1 of %s failed (%s)\n", fname, cli_errstr(cli1)); 4163 4673 return False; 4164 4674 } … … 4166 4676 if (!NT_STATUS_IS_OK(cli_ntcreate(cli2, fname, 0, FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL, 4167 4677 FILE_SHARE_NONE, FILE_OPEN_IF, 0, 0, &fnum2))) { 4168 printf(" test1 open 2 of %s failed (%s)\n", fname, cli_errstr(cli2));4678 printf("TEST #1 open 2 of %s failed (%s)\n", fname, cli_errstr(cli2)); 4169 4679 return False; 4170 4680 } 4171 4681 4172 4682 if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) { 4173 printf(" test1 close 1 of %s failed (%s)\n", fname, cli_errstr(cli1));4683 printf("TEST #1 close 1 of %s failed (%s)\n", fname, cli_errstr(cli1)); 4174 4684 return False; 4175 4685 } 4176 4686 if (!NT_STATUS_IS_OK(cli_close(cli2, fnum2))) { 4177 printf(" test1 close 2 of %s failed (%s)\n", fname, cli_errstr(cli2));4687 printf("TEST #1 close 2 of %s failed (%s)\n", fname, cli_errstr(cli2)); 4178 4688 return False; 4179 4689 } … … 4181 4691 printf("non-io open test #1 passed.\n"); 4182 4692 4183 cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);4693 cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 4184 4694 4185 4695 printf("TEST #2 testing 2 non-io opens (first with delete)\n"); … … 4187 4697 if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, DELETE_ACCESS|FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL, 4188 4698 FILE_SHARE_NONE, FILE_OVERWRITE_IF, 0, 0, &fnum1))) { 4189 printf(" test2 open 1 of %s failed (%s)\n", fname, cli_errstr(cli1));4699 printf("TEST #2 open 1 of %s failed (%s)\n", fname, cli_errstr(cli1)); 4190 4700 return False; 4191 4701 } … … 4193 4703 if (!NT_STATUS_IS_OK(cli_ntcreate(cli2, fname, 0, FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL, 4194 4704 FILE_SHARE_NONE, FILE_OPEN_IF, 0, 0, &fnum2))) { 4195 printf(" test2 open 2 of %s failed (%s)\n", fname, cli_errstr(cli2));4705 printf("TEST #2 open 2 of %s failed (%s)\n", fname, cli_errstr(cli2)); 4196 4706 return False; 4197 4707 } 4198 4708 4199 4709 if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) { 4200 printf(" test 1close 1 of %s failed (%s)\n", fname, cli_errstr(cli1));4710 printf("TEST #2 close 1 of %s failed (%s)\n", fname, cli_errstr(cli1)); 4201 4711 return False; 4202 4712 } 4203 4713 if (!NT_STATUS_IS_OK(cli_close(cli2, fnum2))) { 4204 printf(" test 1close 2 of %s failed (%s)\n", fname, cli_errstr(cli1));4714 printf("TEST #2 close 2 of %s failed (%s)\n", fname, cli_errstr(cli1)); 4205 4715 return False; 4206 4716 } … … 4208 4718 printf("non-io open test #2 passed.\n"); 4209 4719 4210 cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);4720 cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 4211 4721 4212 4722 printf("TEST #3 testing 2 non-io opens (second with delete)\n"); … … 4214 4724 if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL, 4215 4725 FILE_SHARE_NONE, FILE_OVERWRITE_IF, 0, 0, &fnum1))) { 4216 printf(" test3 open 1 of %s failed (%s)\n", fname, cli_errstr(cli1));4726 printf("TEST #3 open 1 of %s failed (%s)\n", fname, cli_errstr(cli1)); 4217 4727 return False; 4218 4728 } … … 4220 4730 if (!NT_STATUS_IS_OK(cli_ntcreate(cli2, fname, 0, DELETE_ACCESS|FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL, 4221 4731 FILE_SHARE_NONE, FILE_OPEN_IF, 0, 0, &fnum2))) { 4222 printf(" test3 open 2 of %s failed (%s)\n", fname, cli_errstr(cli2));4732 printf("TEST #3 open 2 of %s failed (%s)\n", fname, cli_errstr(cli2)); 4223 4733 return False; 4224 4734 } 4225 4735 4226 4736 if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) { 4227 printf(" test3 close 1 of %s failed (%s)\n", fname, cli_errstr(cli1));4737 printf("TEST #3 close 1 of %s failed (%s)\n", fname, cli_errstr(cli1)); 4228 4738 return False; 4229 4739 } 4230 4740 if (!NT_STATUS_IS_OK(cli_close(cli2, fnum2))) { 4231 printf(" test3 close 2 of %s failed (%s)\n", fname, cli_errstr(cli2));4741 printf("TEST #3 close 2 of %s failed (%s)\n", fname, cli_errstr(cli2)); 4232 4742 return False; 4233 4743 } … … 4235 4745 printf("non-io open test #3 passed.\n"); 4236 4746 4237 cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);4747 cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 4238 4748 4239 4749 printf("TEST #4 testing 2 non-io opens (both with delete)\n"); … … 4241 4751 if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, DELETE_ACCESS|FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL, 4242 4752 FILE_SHARE_NONE, FILE_OVERWRITE_IF, 0, 0, &fnum1))) { 4243 printf(" test4 open 1 of %s failed (%s)\n", fname, cli_errstr(cli1));4753 printf("TEST #4 open 1 of %s failed (%s)\n", fname, cli_errstr(cli1)); 4244 4754 return False; 4245 4755 } … … 4247 4757 if (NT_STATUS_IS_OK(cli_ntcreate(cli2, fname, 0, DELETE_ACCESS|FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL, 4248 4758 FILE_SHARE_NONE, FILE_OPEN_IF, 0, 0, &fnum2))) { 4249 printf(" test4 open 2 of %s SUCCEEDED - should have failed (%s)\n", fname, cli_errstr(cli2));4250 return False; 4251 } 4252 4253 printf(" test 3open 2 of %s gave %s (correct error should be %s)\n", fname, cli_errstr(cli2), "sharing violation");4759 printf("TEST #4 open 2 of %s SUCCEEDED - should have failed (%s)\n", fname, cli_errstr(cli2)); 4760 return False; 4761 } 4762 4763 printf("TEST #4 open 2 of %s gave %s (correct error should be %s)\n", fname, cli_errstr(cli2), "sharing violation"); 4254 4764 4255 4765 if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) { 4256 printf(" test4 close 1 of %s failed (%s)\n", fname, cli_errstr(cli1));4766 printf("TEST #4 close 1 of %s failed (%s)\n", fname, cli_errstr(cli1)); 4257 4767 return False; 4258 4768 } … … 4260 4770 printf("non-io open test #4 passed.\n"); 4261 4771 4262 cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);4772 cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 4263 4773 4264 4774 printf("TEST #5 testing 2 non-io opens (both with delete - both with file share delete)\n"); … … 4266 4776 if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, DELETE_ACCESS|FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL, 4267 4777 FILE_SHARE_DELETE, FILE_OVERWRITE_IF, 0, 0, &fnum1))) { 4268 printf(" test5 open 1 of %s failed (%s)\n", fname, cli_errstr(cli1));4778 printf("TEST #5 open 1 of %s failed (%s)\n", fname, cli_errstr(cli1)); 4269 4779 return False; 4270 4780 } … … 4272 4782 if (!NT_STATUS_IS_OK(cli_ntcreate(cli2, fname, 0, DELETE_ACCESS|FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL, 4273 4783 FILE_SHARE_DELETE, FILE_OPEN_IF, 0, 0, &fnum2))) { 4274 printf(" test5 open 2 of %s failed (%s)\n", fname, cli_errstr(cli2));4784 printf("TEST #5 open 2 of %s failed (%s)\n", fname, cli_errstr(cli2)); 4275 4785 return False; 4276 4786 } 4277 4787 4278 4788 if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) { 4279 printf(" test5 close 1 of %s failed (%s)\n", fname, cli_errstr(cli1));4789 printf("TEST #5 close 1 of %s failed (%s)\n", fname, cli_errstr(cli1)); 4280 4790 return False; 4281 4791 } 4282 4792 4283 4793 if (!NT_STATUS_IS_OK(cli_close(cli2, fnum2))) { 4284 printf(" test5 close 2 of %s failed (%s)\n", fname, cli_errstr(cli2));4794 printf("TEST #5 close 2 of %s failed (%s)\n", fname, cli_errstr(cli2)); 4285 4795 return False; 4286 4796 } … … 4290 4800 printf("TEST #6 testing 1 non-io open, one io open\n"); 4291 4801 4292 cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);4802 cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 4293 4803 4294 4804 if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, FILE_READ_DATA, FILE_ATTRIBUTE_NORMAL, 4295 4805 FILE_SHARE_NONE, FILE_OVERWRITE_IF, 0, 0, &fnum1))) { 4296 printf(" test6 open 1 of %s failed (%s)\n", fname, cli_errstr(cli1));4806 printf("TEST #6 open 1 of %s failed (%s)\n", fname, cli_errstr(cli1)); 4297 4807 return False; 4298 4808 } … … 4300 4810 if (!NT_STATUS_IS_OK(cli_ntcreate(cli2, fname, 0, FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL, 4301 4811 FILE_SHARE_READ, FILE_OPEN_IF, 0, 0, &fnum2))) { 4302 printf(" test6 open 2 of %s failed (%s)\n", fname, cli_errstr(cli2));4812 printf("TEST #6 open 2 of %s failed (%s)\n", fname, cli_errstr(cli2)); 4303 4813 return False; 4304 4814 } 4305 4815 4306 4816 if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) { 4307 printf(" test6 close 1 of %s failed (%s)\n", fname, cli_errstr(cli1));4817 printf("TEST #6 close 1 of %s failed (%s)\n", fname, cli_errstr(cli1)); 4308 4818 return False; 4309 4819 } 4310 4820 4311 4821 if (!NT_STATUS_IS_OK(cli_close(cli2, fnum2))) { 4312 printf(" test6 close 2 of %s failed (%s)\n", fname, cli_errstr(cli2));4822 printf("TEST #6 close 2 of %s failed (%s)\n", fname, cli_errstr(cli2)); 4313 4823 return False; 4314 4824 } … … 4318 4828 printf("TEST #7 testing 1 non-io open, one io open with delete\n"); 4319 4829 4320 cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);4830 cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 4321 4831 4322 4832 if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, FILE_READ_DATA, FILE_ATTRIBUTE_NORMAL, 4323 4833 FILE_SHARE_NONE, FILE_OVERWRITE_IF, 0, 0, &fnum1))) { 4324 printf(" test7 open 1 of %s failed (%s)\n", fname, cli_errstr(cli1));4834 printf("TEST #7 open 1 of %s failed (%s)\n", fname, cli_errstr(cli1)); 4325 4835 return False; 4326 4836 } … … 4328 4838 if (NT_STATUS_IS_OK(cli_ntcreate(cli2, fname, 0, DELETE_ACCESS|FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL, 4329 4839 FILE_SHARE_READ|FILE_SHARE_DELETE, FILE_OPEN_IF, 0, 0, &fnum2))) { 4330 printf(" test7 open 2 of %s SUCCEEDED - should have failed (%s)\n", fname, cli_errstr(cli2));4331 return False; 4332 } 4333 4334 printf(" test7 open 2 of %s gave %s (correct error should be %s)\n", fname, cli_errstr(cli2), "sharing violation");4840 printf("TEST #7 open 2 of %s SUCCEEDED - should have failed (%s)\n", fname, cli_errstr(cli2)); 4841 return False; 4842 } 4843 4844 printf("TEST #7 open 2 of %s gave %s (correct error should be %s)\n", fname, cli_errstr(cli2), "sharing violation"); 4335 4845 4336 4846 if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) { 4337 printf(" test7 close 1 of %s failed (%s)\n", fname, cli_errstr(cli1));4847 printf("TEST #7 close 1 of %s failed (%s)\n", fname, cli_errstr(cli1)); 4338 4848 return False; 4339 4849 } … … 4341 4851 printf("non-io open test #7 passed.\n"); 4342 4852 4343 cli_unlink(cli1, fname, aSYSTEM | aHIDDEN); 4853 cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 4854 4855 printf("TEST #8 testing open without WRITE_ATTRIBUTES, updating close write time.\n"); 4856 status = cli_ntcreate(cli1, fname, 0, FILE_WRITE_DATA, FILE_ATTRIBUTE_NORMAL, 4857 FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, 4858 FILE_OVERWRITE_IF, 0, 0, &fnum1); 4859 if (!NT_STATUS_IS_OK(status)) { 4860 printf("TEST #8 open of %s failed (%s)\n", fname, nt_errstr(status)); 4861 correct = false; 4862 goto out; 4863 } 4864 4865 /* Write to ensure we have to update the file time. */ 4866 status = cli_writeall(cli1, fnum1, 0, (uint8_t *)"TEST DATA\n", 0, 10, 4867 NULL); 4868 if (!NT_STATUS_IS_OK(status)) { 4869 printf("TEST #8 cli_write failed: %s\n", nt_errstr(status)); 4870 correct = false; 4871 goto out; 4872 } 4873 4874 status = cli_close(cli1, fnum1); 4875 if (!NT_STATUS_IS_OK(status)) { 4876 printf("TEST #8 close of %s failed (%s)\n", fname, nt_errstr(status)); 4877 correct = false; 4878 } 4879 4880 out: 4344 4881 4345 4882 if (!torture_close_connection(cli1)) { … … 4351 4888 4352 4889 return correct; 4890 } 4891 4892 NTSTATUS torture_setup_unix_extensions(struct cli_state *cli) 4893 { 4894 uint16 major, minor; 4895 uint32 caplow, caphigh; 4896 NTSTATUS status; 4897 4898 if (!SERVER_HAS_UNIX_CIFS(cli)) { 4899 printf("Server doesn't support UNIX CIFS extensions.\n"); 4900 return NT_STATUS_NOT_SUPPORTED; 4901 } 4902 4903 status = cli_unix_extensions_version(cli, &major, &minor, &caplow, 4904 &caphigh); 4905 if (!NT_STATUS_IS_OK(status)) { 4906 printf("Server didn't return UNIX CIFS extensions: %s\n", 4907 nt_errstr(status)); 4908 return status; 4909 } 4910 4911 status = cli_set_unix_extensions_capabilities(cli, major, minor, 4912 caplow, caphigh); 4913 if (!NT_STATUS_IS_OK(status)) { 4914 printf("Server doesn't support setting UNIX CIFS extensions: " 4915 "%s.\n", nt_errstr(status)); 4916 return status; 4917 } 4918 4919 return NT_STATUS_OK; 4353 4920 } 4354 4921 … … 4365 4932 char buf[10]; 4366 4933 char namebuf[11]; 4367 uint16 major, minor;4368 uint32 caplow, caphigh;4369 4934 uint16_t fnum1 = (uint16_t)-1; 4370 4935 SMB_STRUCT_STAT sbuf; … … 4380 4945 cli_sockopt(cli1, sockops); 4381 4946 4382 if (!SERVER_HAS_UNIX_CIFS(cli1)) {4383 printf("Server doesn't support UNIX CIFS extensions.\n");4947 status = torture_setup_unix_extensions(cli1); 4948 if (!NT_STATUS_IS_OK(status)) { 4384 4949 return false; 4385 4950 } 4386 4387 status = cli_unix_extensions_version(cli1, &major, &minor, &caplow,4388 &caphigh);4389 if (!NT_STATUS_IS_OK(status)) {4390 printf("Server didn't return UNIX CIFS extensions: %s\n",4391 nt_errstr(status));4392 return false;4393 }4394 4395 if (!cli_set_unix_extensions_capabilities(cli1,4396 major, minor, caplow, caphigh)) {4397 printf("Server doesn't support setting UNIX CIFS extensions.\n");4398 return false;4399 }4400 4951 4401 4952 cli_setatr(cli1, fname, 0, 0); … … 4470 5021 } 4471 5022 4472 /* What happens when we try and POSIX open a directory ? */ 4473 if (NT_STATUS_IS_OK(cli_posix_open(cli1, dname, O_RDONLY, 0, &fnum1))) { 5023 /* Create again to test open with O_TRUNC. */ 5024 if (!NT_STATUS_IS_OK(cli_posix_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, 0600, &fnum1))) { 5025 printf("POSIX create of %s failed (%s)\n", fname, cli_errstr(cli1)); 5026 goto out; 5027 } 5028 5029 /* Test ftruncate - set file size. */ 5030 if (!NT_STATUS_IS_OK(cli_ftruncate(cli1, fnum1, 1000))) { 5031 printf("ftruncate failed (%s)\n", cli_errstr(cli1)); 5032 goto out; 5033 } 5034 5035 /* Ensure st_size == 1000 */ 5036 if (!NT_STATUS_IS_OK(cli_posix_stat(cli1, fname, &sbuf))) { 5037 printf("stat failed (%s)\n", cli_errstr(cli1)); 5038 goto out; 5039 } 5040 5041 if (sbuf.st_ex_size != 1000) { 5042 printf("ftruncate - stat size (%u) != 1000\n", (unsigned int)sbuf.st_ex_size); 5043 goto out; 5044 } 5045 5046 if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) { 5047 printf("close(2) failed (%s)\n", cli_errstr(cli1)); 5048 goto out; 5049 } 5050 5051 /* Re-open with O_TRUNC. */ 5052 if (!NT_STATUS_IS_OK(cli_posix_open(cli1, fname, O_WRONLY|O_TRUNC, 0600, &fnum1))) { 5053 printf("POSIX create of %s failed (%s)\n", fname, cli_errstr(cli1)); 5054 goto out; 5055 } 5056 5057 /* Ensure st_size == 0 */ 5058 if (!NT_STATUS_IS_OK(cli_posix_stat(cli1, fname, &sbuf))) { 5059 printf("stat failed (%s)\n", cli_errstr(cli1)); 5060 goto out; 5061 } 5062 5063 if (sbuf.st_ex_size != 0) { 5064 printf("O_TRUNC - stat size (%u) != 0\n", (unsigned int)sbuf.st_ex_size); 5065 goto out; 5066 } 5067 5068 if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) { 5069 printf("close failed (%s)\n", cli_errstr(cli1)); 5070 goto out; 5071 } 5072 5073 if (!NT_STATUS_IS_OK(cli_posix_unlink(cli1, fname))) { 5074 printf("POSIX unlink of %s failed (%s)\n", fname, cli_errstr(cli1)); 5075 goto out; 5076 } 5077 5078 if (!NT_STATUS_IS_OK(cli_posix_open(cli1, dname, O_RDONLY, 0, &fnum1))) { 5079 printf("POSIX open directory O_RDONLY of %s failed (%s)\n", 5080 dname, cli_errstr(cli1)); 5081 goto out; 5082 } 5083 5084 cli_close(cli1, fnum1); 5085 5086 /* What happens when we try and POSIX open a directory for write ? */ 5087 if (NT_STATUS_IS_OK(cli_posix_open(cli1, dname, O_RDWR, 0, &fnum1))) { 4474 5088 printf("POSIX open of directory %s succeeded, should have failed.\n", fname); 4475 5089 goto out; … … 4488 5102 4489 5103 /* Write some data into it. */ 4490 if (cli_write(cli1, fnum1, 0, "TEST DATA\n", 0, 10) != 10) { 4491 printf("cli_write failed: %s\n", cli_errstr(cli1)); 5104 status = cli_writeall(cli1, fnum1, 0, (uint8_t *)"TEST DATA\n", 0, 10, 5105 NULL); 5106 if (!NT_STATUS_IS_OK(status)) { 5107 printf("cli_write failed: %s\n", nt_errstr(status)); 4492 5108 goto out; 4493 5109 } … … 4671 5287 for (k = 0, i = 0; i < sizeof(open_attrs_table)/sizeof(uint32); i++) { 4672 5288 cli_setatr(cli1, fname, 0, 0); 4673 cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);5289 cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 4674 5290 if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, FILE_WRITE_DATA, open_attrs_table[i], 4675 5291 FILE_SHARE_NONE, FILE_OVERWRITE_IF, 0, 0, &fnum1))) { … … 4743 5359 4744 5360 cli_setatr(cli1, fname, 0, 0); 4745 cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);5361 cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 4746 5362 4747 5363 printf("open attr test %s.\n", correct ? "passed" : "failed"); … … 4753 5369 } 4754 5370 4755 static void list_fn(const char *mnt, file_info *finfo, const char *name, void *state) 4756 { 4757 5371 static NTSTATUS list_fn(const char *mnt, struct file_info *finfo, 5372 const char *name, void *state) 5373 { 5374 int *matched = (int *)state; 5375 if (matched != NULL) { 5376 *matched += 1; 5377 } 5378 return NT_STATUS_OK; 4758 5379 } 4759 5380 … … 4766 5387 static struct cli_state *cli; 4767 5388 uint16_t fnum; 4768 double t1;5389 struct timeval core_start; 4769 5390 bool correct = True; 5391 int matched; 4770 5392 4771 5393 printf("starting directory test\n"); … … 4788 5410 } 4789 5411 4790 t1 = end_timer(); 4791 4792 printf("Matched %d\n", cli_list(cli, "a*.*", 0, list_fn, NULL)); 4793 printf("Matched %d\n", cli_list(cli, "b*.*", 0, list_fn, NULL)); 4794 printf("Matched %d\n", cli_list(cli, "xyzabc", 0, list_fn, NULL)); 4795 4796 printf("dirtest core %g seconds\n", end_timer() - t1); 5412 core_start = timeval_current(); 5413 5414 matched = 0; 5415 cli_list(cli, "a*.*", 0, list_fn, &matched); 5416 printf("Matched %d\n", matched); 5417 5418 matched = 0; 5419 cli_list(cli, "b*.*", 0, list_fn, &matched); 5420 printf("Matched %d\n", matched); 5421 5422 matched = 0; 5423 cli_list(cli, "xyzabc", 0, list_fn, &matched); 5424 printf("Matched %d\n", matched); 5425 5426 printf("dirtest core %g seconds\n", timeval_elapsed(&core_start)); 4797 5427 4798 5428 srandom(0); … … 4800 5430 fstring fname; 4801 5431 slprintf(fname, sizeof(fname), "\\%x", (int)random()); 4802 cli_unlink(cli, fname, aSYSTEM | aHIDDEN);5432 cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 4803 5433 } 4804 5434 … … 4812 5442 } 4813 5443 4814 static void del_fn(const char *mnt, file_info *finfo, const char *mask, void *state) 5444 static NTSTATUS del_fn(const char *mnt, struct file_info *finfo, const char *mask, 5445 void *state) 4815 5446 { 4816 5447 struct cli_state *pcli = (struct cli_state *)state; … … 4819 5450 4820 5451 if (strcmp(finfo->name, ".") == 0 || strcmp(finfo->name, "..") == 0) 4821 return ;4822 4823 if (finfo->mode & aDIR) {5452 return NT_STATUS_OK; 5453 5454 if (finfo->mode & FILE_ATTRIBUTE_DIRECTORY) { 4824 5455 if (!NT_STATUS_IS_OK(cli_rmdir(pcli, fname))) 4825 5456 printf("del_fn: failed to rmdir %s\n,", fname ); 4826 5457 } else { 4827 if (!NT_STATUS_IS_OK(cli_unlink(pcli, fname, aSYSTEM | aHIDDEN)))5458 if (!NT_STATUS_IS_OK(cli_unlink(pcli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN))) 4828 5459 printf("del_fn: failed to unlink %s\n,", fname ); 4829 5460 } 5461 return NT_STATUS_OK; 4830 5462 } 4831 5463 … … 4849 5481 printf("starting ioctl test\n"); 4850 5482 4851 cli_unlink(cli, fname, aSYSTEM | aHIDDEN);5483 cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 4852 5484 4853 5485 if (!NT_STATUS_IS_OK(cli_open(cli, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum))) { … … 4857 5489 4858 5490 status = cli_raw_ioctl(cli, fnum, 0x2d0000 | (0x0420<<2), &blob); 4859 printf("ioctl device info: %s\n", cli_errstr(cli));5491 printf("ioctl device info: %s\n", nt_errstr(status)); 4860 5492 4861 5493 status = cli_raw_ioctl(cli, fnum, IOCTL_QUERY_JOB_INFO, &blob); 4862 printf("ioctl job info: %s\n", cli_errstr(cli));5494 printf("ioctl job info: %s\n", nt_errstr(status)); 4863 5495 4864 5496 for (device=0;device<0x100;device++) { 4865 printf(" testing device=0x%x\n", device);5497 printf("ioctl test with device = 0x%x\n", device); 4866 5498 for (function=0;function<0x100;function++) { 4867 5499 uint32 code = (device<<16) | function; … … 4902 5534 /* cleanup from an old run */ 4903 5535 cli_rmdir(cli, "\\chkpath.dir\\dir2"); 4904 cli_unlink(cli, "\\chkpath.dir\\*", aSYSTEM | aHIDDEN);5536 cli_unlink(cli, "\\chkpath.dir\\*", FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 4905 5537 cli_rmdir(cli, "\\chkpath.dir"); 4906 5538 … … 4956 5588 4957 5589 cli_rmdir(cli, "\\chkpath.dir\\dir2"); 4958 cli_unlink(cli, "\\chkpath.dir\\*", aSYSTEM | aHIDDEN);5590 cli_unlink(cli, "\\chkpath.dir\\*", FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 4959 5591 cli_rmdir(cli, "\\chkpath.dir"); 4960 5592 … … 4976 5608 struct ea_struct *ea_list = NULL; 4977 5609 TALLOC_CTX *mem_ctx = talloc_init("eatest"); 5610 NTSTATUS status; 4978 5611 4979 5612 printf("starting eatest\n"); … … 4984 5617 } 4985 5618 4986 cli_unlink(cli, fname, aSYSTEM | aHIDDEN);5619 cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 4987 5620 if (!NT_STATUS_IS_OK(cli_ntcreate(cli, fname, 0, 4988 5621 FIRST_DESIRED_ACCESS, FILE_ATTRIBUTE_ARCHIVE, … … 4999 5632 slprintf(ea_name, sizeof(ea_name), "EA_%d", i); 5000 5633 memset(ea_val, (char)i+1, i+1); 5001 if (!cli_set_ea_fnum(cli, fnum, ea_name, ea_val, i+1)) { 5002 printf("ea_set of name %s failed - %s\n", ea_name, cli_errstr(cli)); 5634 status = cli_set_ea_fnum(cli, fnum, ea_name, ea_val, i+1); 5635 if (!NT_STATUS_IS_OK(status)) { 5636 printf("ea_set of name %s failed - %s\n", ea_name, 5637 nt_errstr(status)); 5003 5638 talloc_destroy(mem_ctx); 5004 5639 return False; … … 5012 5647 slprintf(ea_name, sizeof(ea_name), "EA_%d", i+10); 5013 5648 memset(ea_val, (char)i+1, i+1); 5014 if (!cli_set_ea_path(cli, fname, ea_name, ea_val, i+1)) { 5015 printf("ea_set of name %s failed - %s\n", ea_name, cli_errstr(cli)); 5649 status = cli_set_ea_path(cli, fname, ea_name, ea_val, i+1); 5650 if (!NT_STATUS_IS_OK(status)) { 5651 printf("ea_set of name %s failed - %s\n", ea_name, 5652 nt_errstr(status)); 5016 5653 talloc_destroy(mem_ctx); 5017 5654 return False; … … 5019 5656 } 5020 5657 5021 if (!cli_get_ea_list_path(cli, fname, mem_ctx, &num_eas, &ea_list)) { 5022 printf("ea_get list failed - %s\n", cli_errstr(cli)); 5658 status = cli_get_ea_list_path(cli, fname, mem_ctx, &num_eas, &ea_list); 5659 if (!NT_STATUS_IS_OK(status)) { 5660 printf("ea_get list failed - %s\n", nt_errstr(status)); 5023 5661 correct = False; 5024 5662 } … … 5050 5688 fstring ea_name; 5051 5689 slprintf(ea_name, sizeof(ea_name), "ea_%d", i); 5052 if (!cli_set_ea_path(cli, fname, ea_name, "", 0)) { 5053 printf("ea_set of name %s failed - %s\n", ea_name, cli_errstr(cli)); 5690 status = cli_set_ea_path(cli, fname, ea_name, "", 0); 5691 if (!NT_STATUS_IS_OK(status)) { 5692 printf("ea_set of name %s failed - %s\n", ea_name, 5693 nt_errstr(status)); 5054 5694 talloc_destroy(mem_ctx); 5055 5695 return False; … … 5058 5698 #endif 5059 5699 5060 if (!cli_get_ea_list_path(cli, fname, mem_ctx, &num_eas, &ea_list)) { 5061 printf("ea_get list failed - %s\n", cli_errstr(cli)); 5700 status = cli_get_ea_list_path(cli, fname, mem_ctx, &num_eas, &ea_list); 5701 if (!NT_STATUS_IS_OK(status)) { 5702 printf("ea_get list failed - %s\n", nt_errstr(status)); 5062 5703 correct = False; 5063 5704 } … … 5076 5717 5077 5718 /* Try and delete a non existant EA. */ 5078 if (!cli_set_ea_path(cli, fname, "foo", "", 0)) { 5079 printf("deleting non-existant EA 'foo' should succeed. %s\n", cli_errstr(cli)); 5719 status = cli_set_ea_path(cli, fname, "foo", "", 0); 5720 if (!NT_STATUS_IS_OK(status)) { 5721 printf("deleting non-existant EA 'foo' should succeed. %s\n", 5722 nt_errstr(status)); 5080 5723 correct = False; 5081 5724 } … … 5106 5749 5107 5750 cli_list(cli, "\\LISTDIR\\*", 0, del_fn, cli); 5108 cli_list(cli, "\\LISTDIR\\*", aDIR, del_fn, cli);5751 cli_list(cli, "\\LISTDIR\\*", FILE_ATTRIBUTE_DIRECTORY, del_fn, cli); 5109 5752 cli_rmdir(cli, "\\LISTDIR"); 5110 5753 cli_mkdir(cli, "\\LISTDIR"); … … 5131 5774 5132 5775 /* Now ensure that doing an old list sees both files and directories. */ 5133 num_seen = cli_list_old(cli, "\\LISTDIR\\*", aDIR, list_fn, NULL); 5776 num_seen = 0; 5777 cli_list_old(cli, "\\LISTDIR\\*", FILE_ATTRIBUTE_DIRECTORY, list_fn, &num_seen); 5134 5778 printf("num_seen = %d\n", num_seen ); 5135 5779 /* We should see 100 files + 1000 directories + . and .. */ … … 5140 5784 * relevent entries. 5141 5785 */ 5142 num_seen = cli_list_old(cli, "\\LISTDIR\\*", (aDIR<<8)|aDIR, list_fn, NULL); 5786 num_seen = 0; 5787 cli_list_old(cli, "\\LISTDIR\\*", (FILE_ATTRIBUTE_DIRECTORY<<8)|FILE_ATTRIBUTE_DIRECTORY, list_fn, &num_seen); 5143 5788 printf("num_seen = %d\n", num_seen ); 5144 5789 if (num_seen != 1002) 5145 5790 correct = False; 5146 5791 5147 num_seen = cli_list_old(cli, "\\LISTDIR\\*", (aARCH<<8)|aDIR, list_fn, NULL); 5792 num_seen = 0; 5793 cli_list_old(cli, "\\LISTDIR\\*", (FILE_ATTRIBUTE_ARCHIVE<<8)|FILE_ATTRIBUTE_DIRECTORY, list_fn, &num_seen); 5148 5794 printf("num_seen = %d\n", num_seen ); 5149 5795 if (num_seen != 1000) … … 5152 5798 /* Delete everything. */ 5153 5799 cli_list(cli, "\\LISTDIR\\*", 0, del_fn, cli); 5154 cli_list(cli, "\\LISTDIR\\*", aDIR, del_fn, cli);5800 cli_list(cli, "\\LISTDIR\\*", FILE_ATTRIBUTE_DIRECTORY, del_fn, cli); 5155 5801 cli_rmdir(cli, "\\LISTDIR"); 5156 5802 … … 5317 5963 d_printf("\r%d ", (int)c->vuid); 5318 5964 5319 if (!cli_ulogoff(c)) { 5965 status = cli_ulogoff(c); 5966 if (!NT_STATUS_IS_OK(status)) { 5320 5967 d_printf("(%s) cli_ulogoff failed: %s\n", 5321 __location__, cli_errstr(c));5968 __location__, nt_errstr(status)); 5322 5969 return false; 5323 5970 } … … 5455 6102 printf("starting chain2 test\n"); 5456 6103 status = cli_start_connection(&cli1, global_myname(), host, NULL, 5457 port_to_use, Undefined, 0 , NULL);6104 port_to_use, Undefined, 0); 5458 6105 if (!NT_STATUS_IS_OK(status)) { 5459 6106 return False; … … 5792 6439 NTSTATUS status; 5793 6440 uint16_t dnum; 5794 struct tevent_req *req1, *req2; 6441 struct tevent_req *req1; 6442 struct tevent_req *req2 = NULL; 5795 6443 int i, num_unc_names; 5796 6444 int num_finished = 0; … … 5928 6576 cli_close(cli, fnum); 5929 6577 5930 if (!cli_qpathinfo(cli, alt_name, &change_time, &access_time, 5931 &write_time, &size, &mode)) { 5932 d_printf("cli_qpathinfo(%s) failed: %s\n", alt_name, 5933 cli_errstr(cli)); 6578 status = cli_qpathinfo1(cli, alt_name, &change_time, &access_time, 6579 &write_time, &size, &mode); 6580 if (!NT_STATUS_IS_OK(status)) { 6581 d_printf("cli_qpathinfo1(%s) failed: %s\n", alt_name, 6582 nt_errstr(status)); 5934 6583 return false; 5935 6584 } … … 5960 6609 bool ret = false; 5961 6610 const char *fname = "\\writetest.txt"; 6611 struct timeval start_time; 5962 6612 double seconds; 5963 6613 double kbytes; … … 5975 6625 cli_sockopt(cli1, sockops); 5976 6626 5977 start_time r();6627 start_time = timeval_current(); 5978 6628 5979 6629 for (i=0; i<torture_numops; i++) { 5980 charc = 0;6630 uint8_t c = 0; 5981 6631 off_t start = i * torture_blocksize; 5982 6632 NTSTATUS status; 5983 6633 size_t to_pull = torture_blocksize - 1; 5984 6634 5985 if (cli_write(cli1, fnum, 0, &c, 5986 start + torture_blocksize - 1, 1) != 1) { 5987 printf("cli_write failed: %s\n", cli_errstr(cli1)); 6635 status = cli_writeall(cli1, fnum, 0, &c, 6636 start + torture_blocksize - 1, 1, NULL); 6637 if (!NT_STATUS_IS_OK(status)) { 6638 printf("cli_write failed: %s\n", nt_errstr(status)); 5988 6639 goto fail; 5989 6640 } … … 5997 6648 } 5998 6649 5999 seconds = end_timer();6650 seconds = timeval_elapsed(&start_time); 6000 6651 kbytes = (double)torture_blocksize * torture_numops; 6001 6652 kbytes /= 1024; … … 6007 6658 fail: 6008 6659 cli_close(cli1, fnum); 6009 cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);6660 cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 6010 6661 torture_close_connection(cli1); 6011 6662 return ret; … … 6037 6688 int16_t old_cnum; 6038 6689 bool correct = True; 6690 NTSTATUS status; 6039 6691 6040 6692 printf("starting uid regression test\n"); … … 6049 6701 old_vuid = cli->vuid; 6050 6702 6051 if (!cli_ulogoff(cli)) { 6703 status = cli_ulogoff(cli); 6704 if (!NT_STATUS_IS_OK(status)) { 6052 6705 d_printf("(%s) cli_ulogoff failed: %s\n", 6053 __location__, cli_errstr(cli));6706 __location__, nt_errstr(status)); 6054 6707 correct = false; 6055 6708 goto out; … … 6059 6712 6060 6713 /* Try an operation. */ 6061 if (!NT_STATUS_IS_OK(cli_mkdir(cli, "\\uid_reg_test"))) { 6062 /* We expect bad uid. */ 6714 status = cli_mkdir(cli, "\\uid_reg_test"); 6715 if (NT_STATUS_IS_OK(status)) { 6716 d_printf("(%s) cli_mkdir succeeded\n", 6717 __location__); 6718 correct = false; 6719 goto out; 6720 } else { 6721 /* Should be bad uid. */ 6063 6722 if (!check_error(__LINE__, cli, ERRSRV, ERRbaduid, 6064 NT_STATUS_NO_SUCH_USER)) { 6065 return False; 6723 NT_STATUS_USER_SESSION_DELETED)) { 6724 correct = false; 6725 goto out; 6066 6726 } 6067 6727 } … … 6073 6733 6074 6734 /* This should succeed. */ 6075 if (cli_tdis(cli)) { 6076 printf("First tdis with invalid vuid should succeed.\n"); 6735 status = cli_tdis(cli); 6736 6737 if (NT_STATUS_IS_OK(status)) { 6738 d_printf("First tdis with invalid vuid should succeed.\n"); 6077 6739 } else { 6078 printf("First tdis failed (%s)\n", cli_errstr(cli)); 6740 d_printf("First tdis failed (%s)\n", nt_errstr(status)); 6741 correct = false; 6742 goto out; 6079 6743 } 6080 6744 … … 6083 6747 6084 6748 /* This should fail. */ 6085 if (cli_tdis(cli)) { 6086 printf("Second tdis with invalid vuid should fail - succeeded instead !.\n"); 6749 status = cli_tdis(cli); 6750 if (NT_STATUS_IS_OK(status)) { 6751 d_printf("Second tdis with invalid vuid should fail - succeeded instead !.\n"); 6752 correct = false; 6753 goto out; 6087 6754 } else { 6088 6755 /* Should be bad tid. */ 6089 6756 if (!check_error(__LINE__, cli, ERRSRV, ERRinvnid, 6090 6757 NT_STATUS_NETWORK_NAME_DELETED)) { 6091 return False; 6758 correct = false; 6759 goto out; 6092 6760 } 6093 6761 } … … 6105 6773 static char force_shortname_chars[] = " +,.[];=\177"; 6106 6774 6107 static void shortname_del_fn(const char *mnt, file_info *finfo, const char *mask, void *state) 6775 static NTSTATUS shortname_del_fn(const char *mnt, struct file_info *finfo, 6776 const char *mask, void *state) 6108 6777 { 6109 6778 struct cli_state *pcli = (struct cli_state *)state; 6110 6779 fstring fname; 6780 NTSTATUS status = NT_STATUS_OK; 6781 6111 6782 slprintf(fname, sizeof(fname), "\\shortname\\%s", finfo->name); 6112 6783 6113 6784 if (strcmp(finfo->name, ".") == 0 || strcmp(finfo->name, "..") == 0) 6114 return; 6115 6116 if (finfo->mode & aDIR) { 6117 if (!NT_STATUS_IS_OK(cli_rmdir(pcli, fname))) 6785 return NT_STATUS_OK; 6786 6787 if (finfo->mode & FILE_ATTRIBUTE_DIRECTORY) { 6788 status = cli_rmdir(pcli, fname); 6789 if (!NT_STATUS_IS_OK(status)) { 6118 6790 printf("del_fn: failed to rmdir %s\n,", fname ); 6791 } 6119 6792 } else { 6120 if (!NT_STATUS_IS_OK(cli_unlink(pcli, fname, aSYSTEM | aHIDDEN))) 6793 status = cli_unlink(pcli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 6794 if (!NT_STATUS_IS_OK(status)) { 6121 6795 printf("del_fn: failed to unlink %s\n,", fname ); 6122 } 6796 } 6797 } 6798 return status; 6123 6799 } 6124 6800 6125 6801 struct sn_state { 6802 int matched; 6126 6803 int i; 6127 6804 bool val; 6128 6805 }; 6129 6806 6130 static void shortname_list_fn(const char *mnt, file_info *finfo, const char *name, void *state) 6807 static NTSTATUS shortname_list_fn(const char *mnt, struct file_info *finfo, 6808 const char *name, void *state) 6131 6809 { 6132 6810 struct sn_state *s = (struct sn_state *)state; … … 6151 6829 s->val = true; 6152 6830 } 6831 s->matched += 1; 6832 return NT_STATUS_OK; 6153 6833 } 6154 6834 … … 6170 6850 6171 6851 cli_list(cli, "\\shortname\\*", 0, shortname_del_fn, cli); 6172 cli_list(cli, "\\shortname\\*", aDIR, shortname_del_fn, cli);6852 cli_list(cli, "\\shortname\\*", FILE_ATTRIBUTE_DIRECTORY, shortname_del_fn, cli); 6173 6853 cli_rmdir(cli, "\\shortname"); 6174 6854 … … 6205 6885 } 6206 6886 cli_close(cli, fnum); 6207 if (cli_list(cli, "\\shortname\\test*.*", 0, shortname_list_fn, &s) != 1) { 6887 6888 s.matched = 0; 6889 cli_list(cli, "\\shortname\\test*.*", 0, shortname_list_fn, 6890 &s); 6891 if (s.matched != 1) { 6208 6892 d_printf("(%s) failed to list %s: %s\n", 6209 6893 __location__, fname, cli_errstr(cli)); … … 6211 6895 goto out; 6212 6896 } 6213 if (!NT_STATUS_IS_OK(cli_unlink(cli, fname, aSYSTEM | aHIDDEN))) {6897 if (!NT_STATUS_IS_OK(cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN))) { 6214 6898 d_printf("(%s) failed to delete %s: %s\n", 6215 6899 __location__, fname, cli_errstr(cli)); … … 6227 6911 6228 6912 cli_list(cli, "\\shortname\\*", 0, shortname_del_fn, cli); 6229 cli_list(cli, "\\shortname\\*", aDIR, shortname_del_fn, cli);6913 cli_list(cli, "\\shortname\\*", FILE_ATTRIBUTE_DIRECTORY, shortname_del_fn, cli); 6230 6914 cli_rmdir(cli, "\\shortname"); 6231 6915 torture_close_connection(cli); … … 6266 6950 struct tevent_req *req; 6267 6951 char *basedn; 6952 const char *filter; 6268 6953 6269 6954 if (!resolve_name(host, &addr, 0, false)) { … … 6319 7004 TALLOC_FREE(req); 6320 7005 7006 /* test search filters against rootDSE */ 7007 filter = "(&(|(name=samba)(nextRid<=10000000)(usnChanged>=10)(samba~=ambas)(!(name=s*m*a)))" 7008 "(|(name:=samba)(name:dn:2.5.13.5:=samba)(:dn:2.5.13.5:=samba)(!(name=*samba))))"; 7009 7010 rc = tldap_search(ld, "", TLDAP_SCOPE_BASE, filter, 7011 NULL, 0, 0, NULL, 0, NULL, 0, 0, 0, 0, 7012 talloc_tos(), NULL, NULL); 7013 if (rc != TLDAP_SUCCESS) { 7014 d_printf("tldap_search with complex filter failed: %s\n", 7015 tldap_errstr(talloc_tos(), ld, rc)); 7016 return false; 7017 } 7018 6321 7019 TALLOC_FREE(ld); 6322 7020 return true; 6323 7021 } 7022 7023 /* Torture test to ensure no regression of : 7024 https://bugzilla.samba.org/show_bug.cgi?id=7084 7025 */ 7026 7027 static bool run_dir_createtime(int dummy) 7028 { 7029 struct cli_state *cli; 7030 const char *dname = "\\testdir"; 7031 const char *fname = "\\testdir\\testfile"; 7032 NTSTATUS status; 7033 struct timespec create_time; 7034 struct timespec create_time1; 7035 uint16_t fnum; 7036 bool ret = false; 7037 7038 if (!torture_open_connection(&cli, 0)) { 7039 return false; 7040 } 7041 7042 cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 7043 cli_rmdir(cli, dname); 7044 7045 status = cli_mkdir(cli, dname); 7046 if (!NT_STATUS_IS_OK(status)) { 7047 printf("mkdir failed: %s\n", nt_errstr(status)); 7048 goto out; 7049 } 7050 7051 status = cli_qpathinfo2(cli, dname, &create_time, NULL, NULL, NULL, 7052 NULL, NULL, NULL); 7053 if (!NT_STATUS_IS_OK(status)) { 7054 printf("cli_qpathinfo2 returned %s\n", 7055 nt_errstr(status)); 7056 goto out; 7057 } 7058 7059 /* Sleep 3 seconds, then create a file. */ 7060 sleep(3); 7061 7062 status = cli_open(cli, fname, O_RDWR | O_CREAT | O_EXCL, 7063 DENY_NONE, &fnum); 7064 if (!NT_STATUS_IS_OK(status)) { 7065 printf("cli_open failed: %s\n", nt_errstr(status)); 7066 goto out; 7067 } 7068 7069 status = cli_qpathinfo2(cli, dname, &create_time1, NULL, NULL, NULL, 7070 NULL, NULL, NULL); 7071 if (!NT_STATUS_IS_OK(status)) { 7072 printf("cli_qpathinfo2 (2) returned %s\n", 7073 nt_errstr(status)); 7074 goto out; 7075 } 7076 7077 if (timespec_compare(&create_time1, &create_time)) { 7078 printf("run_dir_createtime: create time was updated (error)\n"); 7079 } else { 7080 printf("run_dir_createtime: create time was not updated (correct)\n"); 7081 ret = true; 7082 } 7083 7084 out: 7085 7086 cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 7087 cli_rmdir(cli, dname); 7088 if (!torture_close_connection(cli)) { 7089 ret = false; 7090 } 7091 return ret; 7092 } 7093 6324 7094 6325 7095 static bool run_streamerror(int dummy) … … 6339 7109 } 6340 7110 7111 cli_unlink(cli, "\\testdir\\*", FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 6341 7112 cli_rmdir(cli, dname); 6342 7113 … … 6347 7118 } 6348 7119 6349 cli_qpathinfo (cli, streamname, &change_time, &access_time, &write_time,7120 cli_qpathinfo1(cli, streamname, &change_time, &access_time, &write_time, 6350 7121 &size, &mode); 6351 7122 status = cli_nt_error(cli); … … 6651 7422 TALLOC_FREE(dict); 6652 7423 7424 return true; 7425 } 7426 7427 static bool run_local_string_to_sid(int dummy) { 7428 struct dom_sid sid; 7429 7430 if (string_to_sid(&sid, "S--1-5-32-545")) { 7431 printf("allowing S--1-5-32-545\n"); 7432 return false; 7433 } 7434 if (string_to_sid(&sid, "S-1-5-32-+545")) { 7435 printf("allowing S-1-5-32-+545\n"); 7436 return false; 7437 } 7438 if (string_to_sid(&sid, "S-1-2-3-4-5-6-7-8-9-0-1-2-3-4-5-6-7-8-9-0")) { 7439 printf("allowing S-1-2-3-4-5-6-7-8-9-0-1-2-3-4-5-6-7-8-9-0\n"); 7440 return false; 7441 } 7442 if (string_to_sid(&sid, "S-1-5-32-545-abc")) { 7443 printf("allowing S-1-5-32-545-abc\n"); 7444 return false; 7445 } 7446 if (!string_to_sid(&sid, "S-1-5-32-545")) { 7447 printf("could not parse S-1-5-32-545\n"); 7448 return false; 7449 } 7450 if (!dom_sid_equal(&sid, &global_sid_Builtin_Users)) { 7451 printf("mis-parsed S-1-5-32-545 as %s\n", 7452 sid_string_tos(&sid)); 7453 return false; 7454 } 7455 return true; 7456 } 7457 7458 static bool run_local_binary_to_sid(int dummy) { 7459 struct dom_sid *sid = talloc(NULL, struct dom_sid); 7460 static const char good_binary_sid[] = { 7461 0x1, /* revision number */ 7462 15, /* num auths */ 7463 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, /* id_auth */ 7464 0x1, 0x1, 0x1, 0x1, /* auth[0] */ 7465 0x1, 0x1, 0x1, 0x1, /* auth[1] */ 7466 0x1, 0x1, 0x1, 0x1, /* auth[2] */ 7467 0x1, 0x1, 0x1, 0x1, /* auth[3] */ 7468 0x1, 0x1, 0x1, 0x1, /* auth[4] */ 7469 0x1, 0x1, 0x1, 0x1, /* auth[5] */ 7470 0x1, 0x1, 0x1, 0x1, /* auth[6] */ 7471 0x1, 0x1, 0x1, 0x1, /* auth[7] */ 7472 0x1, 0x1, 0x1, 0x1, /* auth[8] */ 7473 0x1, 0x1, 0x1, 0x1, /* auth[9] */ 7474 0x1, 0x1, 0x1, 0x1, /* auth[10] */ 7475 0x1, 0x1, 0x1, 0x1, /* auth[11] */ 7476 0x1, 0x1, 0x1, 0x1, /* auth[12] */ 7477 0x1, 0x1, 0x1, 0x1, /* auth[13] */ 7478 0x1, 0x1, 0x1, 0x1, /* auth[14] */ 7479 }; 7480 7481 static const char long_binary_sid[] = { 7482 0x1, /* revision number */ 7483 15, /* num auths */ 7484 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, /* id_auth */ 7485 0x1, 0x1, 0x1, 0x1, /* auth[0] */ 7486 0x1, 0x1, 0x1, 0x1, /* auth[1] */ 7487 0x1, 0x1, 0x1, 0x1, /* auth[2] */ 7488 0x1, 0x1, 0x1, 0x1, /* auth[3] */ 7489 0x1, 0x1, 0x1, 0x1, /* auth[4] */ 7490 0x1, 0x1, 0x1, 0x1, /* auth[5] */ 7491 0x1, 0x1, 0x1, 0x1, /* auth[6] */ 7492 0x1, 0x1, 0x1, 0x1, /* auth[7] */ 7493 0x1, 0x1, 0x1, 0x1, /* auth[8] */ 7494 0x1, 0x1, 0x1, 0x1, /* auth[9] */ 7495 0x1, 0x1, 0x1, 0x1, /* auth[10] */ 7496 0x1, 0x1, 0x1, 0x1, /* auth[11] */ 7497 0x1, 0x1, 0x1, 0x1, /* auth[12] */ 7498 0x1, 0x1, 0x1, 0x1, /* auth[13] */ 7499 0x1, 0x1, 0x1, 0x1, /* auth[14] */ 7500 0x1, 0x1, 0x1, 0x1, /* auth[15] */ 7501 0x1, 0x1, 0x1, 0x1, /* auth[16] */ 7502 0x1, 0x1, 0x1, 0x1, /* auth[17] */ 7503 }; 7504 7505 static const char long_binary_sid2[] = { 7506 0x1, /* revision number */ 7507 32, /* num auths */ 7508 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, /* id_auth */ 7509 0x1, 0x1, 0x1, 0x1, /* auth[0] */ 7510 0x1, 0x1, 0x1, 0x1, /* auth[1] */ 7511 0x1, 0x1, 0x1, 0x1, /* auth[2] */ 7512 0x1, 0x1, 0x1, 0x1, /* auth[3] */ 7513 0x1, 0x1, 0x1, 0x1, /* auth[4] */ 7514 0x1, 0x1, 0x1, 0x1, /* auth[5] */ 7515 0x1, 0x1, 0x1, 0x1, /* auth[6] */ 7516 0x1, 0x1, 0x1, 0x1, /* auth[7] */ 7517 0x1, 0x1, 0x1, 0x1, /* auth[8] */ 7518 0x1, 0x1, 0x1, 0x1, /* auth[9] */ 7519 0x1, 0x1, 0x1, 0x1, /* auth[10] */ 7520 0x1, 0x1, 0x1, 0x1, /* auth[11] */ 7521 0x1, 0x1, 0x1, 0x1, /* auth[12] */ 7522 0x1, 0x1, 0x1, 0x1, /* auth[13] */ 7523 0x1, 0x1, 0x1, 0x1, /* auth[14] */ 7524 0x1, 0x1, 0x1, 0x1, /* auth[15] */ 7525 0x1, 0x1, 0x1, 0x1, /* auth[16] */ 7526 0x1, 0x1, 0x1, 0x1, /* auth[17] */ 7527 0x1, 0x1, 0x1, 0x1, /* auth[18] */ 7528 0x1, 0x1, 0x1, 0x1, /* auth[19] */ 7529 0x1, 0x1, 0x1, 0x1, /* auth[20] */ 7530 0x1, 0x1, 0x1, 0x1, /* auth[21] */ 7531 0x1, 0x1, 0x1, 0x1, /* auth[22] */ 7532 0x1, 0x1, 0x1, 0x1, /* auth[23] */ 7533 0x1, 0x1, 0x1, 0x1, /* auth[24] */ 7534 0x1, 0x1, 0x1, 0x1, /* auth[25] */ 7535 0x1, 0x1, 0x1, 0x1, /* auth[26] */ 7536 0x1, 0x1, 0x1, 0x1, /* auth[27] */ 7537 0x1, 0x1, 0x1, 0x1, /* auth[28] */ 7538 0x1, 0x1, 0x1, 0x1, /* auth[29] */ 7539 0x1, 0x1, 0x1, 0x1, /* auth[30] */ 7540 0x1, 0x1, 0x1, 0x1, /* auth[31] */ 7541 }; 7542 7543 if (!sid_parse(good_binary_sid, sizeof(good_binary_sid), sid)) { 7544 return false; 7545 } 7546 if (sid_parse(long_binary_sid2, sizeof(long_binary_sid2), sid)) { 7547 return false; 7548 } 7549 if (sid_parse(long_binary_sid, sizeof(long_binary_sid), sid)) { 7550 return false; 7551 } 6653 7552 return true; 6654 7553 } … … 6776 7675 6777 7676 error: 6778 d_fprintf(stderr, " test_stream(%s, %s, %s, %s)\n",7677 d_fprintf(stderr, "Do test_stream(%s, %s, %s, %s)\n", 6779 7678 fname, expected_base ? expected_base : "<NULL>", 6780 7679 expected_stream ? expected_stream : "<NULL>", … … 7166 8065 } 7167 8066 8067 /* 8068 * Just a dummy test to be run under a debugger. There's no real way 8069 * to inspect the tevent_select specific function from outside of 8070 * tevent_select.c. 8071 */ 8072 8073 static bool run_local_tevent_select(int dummy) 8074 { 8075 struct tevent_context *ev; 8076 struct tevent_fd *fd1, *fd2; 8077 bool result = false; 8078 8079 ev = tevent_context_init_byname(NULL, "select"); 8080 if (ev == NULL) { 8081 d_fprintf(stderr, "tevent_context_init_byname failed\n"); 8082 goto fail; 8083 } 8084 8085 fd1 = tevent_add_fd(ev, ev, 2, 0, NULL, NULL); 8086 if (fd1 == NULL) { 8087 d_fprintf(stderr, "tevent_add_fd failed\n"); 8088 goto fail; 8089 } 8090 fd2 = tevent_add_fd(ev, ev, 3, 0, NULL, NULL); 8091 if (fd2 == NULL) { 8092 d_fprintf(stderr, "tevent_add_fd failed\n"); 8093 goto fail; 8094 } 8095 TALLOC_FREE(fd2); 8096 8097 fd2 = tevent_add_fd(ev, ev, 1, 0, NULL, NULL); 8098 if (fd2 == NULL) { 8099 d_fprintf(stderr, "tevent_add_fd failed\n"); 8100 goto fail; 8101 } 8102 8103 result = true; 8104 fail: 8105 TALLOC_FREE(ev); 8106 return result; 8107 } 8108 7168 8109 static double create_procs(bool (*fn)(int), bool *result) 7169 8110 { … … 7173 8114 int synccount; 7174 8115 int tries = 8; 8116 struct timeval start; 7175 8117 7176 8118 synccount = 0; … … 7193 8135 } 7194 8136 7195 start _timer();8137 start = timeval_current(); 7196 8138 7197 8139 for (i=0;i<nprocs;i++) { … … 7214 8156 child_status[i] = getpid(); 7215 8157 7216 while (child_status[i] && end_timer() < 5) smb_msleep(2);8158 while (child_status[i] && timeval_elapsed(&start) < 5) smb_msleep(2); 7217 8159 7218 8160 child_status_out[i] = fn(i); … … 7228 8170 if (synccount == nprocs) break; 7229 8171 smb_msleep(10); 7230 } while ( end_timer() < 30);8172 } while (timeval_elapsed(&start) < 30); 7231 8173 7232 8174 if (synccount != nprocs) { 7233 8175 printf("FAILED TO START %d CLIENTS (started %d)\n", nprocs, synccount); 7234 8176 *result = False; 7235 return end_timer();8177 return timeval_elapsed(&start); 7236 8178 } 7237 8179 7238 8180 /* start the client load */ 7239 start _timer();8181 start = timeval_current(); 7240 8182 7241 8183 for (i=0;i<nprocs;i++) { … … 7256 8198 } 7257 8199 } 7258 return end_timer();8200 return timeval_elapsed(&start); 7259 8201 } 7260 8202 … … 7285 8227 {"NEGNOWAIT", run_negprot_nowait, 0}, 7286 8228 {"NBENCH", run_nbench, 0}, 8229 {"NBENCH2", run_nbench2, 0}, 7287 8230 {"OPLOCK1", run_oplock1, 0}, 7288 8231 {"OPLOCK2", run_oplock2, 0}, 7289 8232 {"OPLOCK3", run_oplock3, 0}, 8233 {"OPLOCK4", run_oplock4, 0}, 7290 8234 {"DIR", run_dirtest, 0}, 7291 8235 {"DIR1", run_dirtest1, 0}, 8236 {"DIR-CREATETIME", run_dir_createtime, 0}, 7292 8237 {"DENY1", torture_denytest1, 0}, 7293 8238 {"DENY2", torture_denytest2, 0}, … … 7297 8242 {"RW2", run_readwritemulti, FLAG_MULTIPROC}, 7298 8243 {"RW3", run_readwritelarge, 0}, 8244 {"RW-SIGNING", run_readwritelarge_signtest, 0}, 7299 8245 {"OPEN", run_opentest, 0}, 7300 8246 {"POSIX", run_simple_posix_open_test, 0}, 8247 {"POSIX-APPEND", run_posix_append, 0}, 8248 {"ASYNC-ECHO", run_async_echo, 0}, 7301 8249 { "UID-REGRESSION-TEST", run_uid_regression_test, 0}, 7302 8250 { "SHORTNAME-TEST", run_shortname_test, 0}, 8251 { "ADDRCHANGE", run_addrchange, 0}, 7303 8252 #if 1 7304 8253 {"OPENATTR", run_openattrtest, 0}, … … 7307 8256 {"RENAME", run_rename, 0}, 7308 8257 {"DELETE", run_deletetest, 0}, 8258 {"DELETE-LN", run_deletetest_ln, 0}, 7309 8259 {"PROPERTIES", run_properties, 0}, 7310 8260 {"MANGLE", torture_mangle, 0}, … … 7331 8281 { "STREAMERROR", run_streamerror }, 7332 8282 { "NOTIFY-BENCH", run_notify_bench }, 8283 { "BAD-NBT-SESSION", run_bad_nbt_session }, 8284 { "SMB-ANY-CONNECT", run_smb_any_connect }, 7333 8285 { "LOCAL-SUBSTITUTE", run_local_substitute, 0}, 7334 8286 { "LOCAL-GENCACHE", run_local_gencache, 0}, … … 7339 8291 { "LOCAL-STREAM-NAME", run_local_stream_name, 0}, 7340 8292 { "LOCAL-WBCLIENT", run_local_wbclient, 0}, 8293 { "LOCAL-string_to_sid", run_local_string_to_sid, 0}, 8294 { "LOCAL-binary_to_sid", run_local_binary_to_sid, 0}, 7341 8295 { "LOCAL-DBTRANS", run_local_dbtrans, 0}, 8296 { "LOCAL-TEVENT-SELECT", run_local_tevent_select, 0}, 7342 8297 {NULL, NULL, 0}}; 7343 8298 … … 7375 8330 } 7376 8331 } else { 7377 start_timer(); 8332 struct timeval start; 8333 start = timeval_current(); 7378 8334 if (!torture_ops[i].fn(0)) { 7379 8335 ret = False; 7380 8336 printf("TEST %s FAILED!\n", name); 7381 8337 } 7382 t = end_timer();8338 t = timeval_elapsed(&start); 7383 8339 } 7384 8340 printf("%s took %g secs\n\n", name, t); … … 7445 8401 int seed = time(NULL); 7446 8402 7447 dbf = x_stdout;7448 7449 8403 #ifdef HAVE_SETBUFFER 7450 8404 setbuffer(stdout, NULL, 0); 7451 8405 #endif 7452 8406 8407 setup_logging("smbtorture", DEBUG_STDOUT); 8408 7453 8409 load_case_tables(); 7454 7455 setup_logging("smbtorture", true);7456 8410 7457 8411 if (is_default_dyn_CONFIGFILE()) { … … 7519 8473 break; 7520 8474 case 'd': 7521 DEBUGLEVEL = atoi(optarg);8475 lp_set_cmdline("log level", optarg); 7522 8476 break; 7523 8477 case 'O': -
trunk/server/source3/torture/utable.c
r414 r745 19 19 20 20 #include "includes.h" 21 #include "system/filesys.h" 22 #include "torture/proto.h" 23 #include "../libcli/security/security.h" 24 #include "libsmb/libsmb.h" 25 #include "libsmb/clirap.h" 21 26 22 27 bool torture_utable(int dummy) … … 39 44 40 45 cli_mkdir(cli, "\\utable"); 41 cli_unlink(cli, "\\utable\\*", aSYSTEM | aHIDDEN);46 cli_unlink(cli, "\\utable\\*", FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 42 47 43 48 for (c=1; c < 0x10000; c++) { … … 69 74 70 75 cli_close(cli, fnum); 71 cli_unlink(cli, fname, aSYSTEM | aHIDDEN);76 cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 72 77 73 78 if (c % 100 == 0) { … … 132 137 memset(equiv, 0, sizeof(equiv)); 133 138 134 cli_unlink(cli, "\\utable\\*", aSYSTEM | aHIDDEN);139 cli_unlink(cli, "\\utable\\*", FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 135 140 cli_rmdir(cli, "\\utable"); 136 141 if (!NT_STATUS_IS_OK(cli_mkdir(cli, "\\utable"))) { … … 158 163 size = 0; 159 164 160 if (!cli_qfileinfo(cli, fnum, NULL, &size, 161 NULL, NULL, NULL, NULL, NULL)) continue; 165 if (!NT_STATUS_IS_OK(cli_qfileinfo_basic( 166 cli, fnum, NULL, &size, 167 NULL, NULL, NULL, NULL, NULL))) { 168 continue; 169 } 162 170 163 171 if (size > 0) { … … 183 191 } 184 192 185 cli_write(cli, fnum, 0, (char *)&c, size, sizeof(c)); 193 cli_writeall(cli, fnum, 0, (uint8_t *)&c, size, sizeof(c), 194 NULL); 186 195 cli_close(cli, fnum); 187 196 } 188 197 189 cli_unlink(cli, "\\utable\\*", aSYSTEM | aHIDDEN);198 cli_unlink(cli, "\\utable\\*", FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); 190 199 cli_rmdir(cli, "\\utable"); 191 200 -
trunk/server/source3/torture/vfstest.c
r414 r745 25 25 26 26 #include "includes.h" 27 #include "smbd/smbd.h" 28 #include "popt_common.h" 27 29 #include "vfstest.h" 30 #include "../libcli/smbreadline/smbreadline.h" 28 31 29 32 /* List to hold groups of commands */ … … 32 35 struct cmd_set *cmd_set; 33 36 } *cmd_list; 34 35 int get_client_fd(void)36 {37 return -1;38 }39 37 40 38 /**************************************************************************** … … 192 190 193 191 if (argc == 2) { 194 DEBUGLEVEL = atoi(argv[1]);192 lp_set_cmdline("log level", argv[1]); 195 193 } 196 194 … … 415 413 } 416 414 417 static int server_fd = -1;418 415 int last_message = -1; 419 420 int smbd_server_fd(void)421 {422 return server_fd;423 }424 425 void reload_printers(void)426 {427 return;428 }429 430 /****************************************************************************431 Reload the services file.432 **************************************************************************/433 434 bool reload_services(bool test)435 {436 bool ret;437 438 if (lp_loaded()) {439 const char *fname = lp_configfile();440 if (file_exist(fname) &&441 !strcsequal(fname, get_dyn_CONFIGFILE())) {442 set_dyn_CONFIGFILE(fname);443 test = False;444 }445 }446 447 reopen_logs();448 449 if (test && !lp_file_list_changed())450 return(True);451 452 lp_killunused(conn_snum_used);453 454 ret = lp_load(get_dyn_CONFIGFILE(), False, False, True, True);455 456 /* perhaps the config filename is now set */457 if (!test)458 reload_services(True);459 460 reopen_logs();461 462 load_interfaces();463 464 {465 if (smbd_server_fd() != -1) {466 set_socket_options(smbd_server_fd(),"SO_KEEPALIVE");467 set_socket_options(smbd_server_fd(),468 lp_socket_options());469 }470 }471 472 mangle_reset_cache();473 reset_stat_cache();474 475 /* this forces service parameters to be flushed */476 set_current_service(NULL,0,True);477 478 return (ret);479 }480 416 481 417 struct event_context *smbd_event_context(void) … … 487 423 } 488 424 return ctx; 489 }490 491 struct messaging_context *smbd_messaging_context(void)492 {493 static struct messaging_context *ctx;494 495 if (!ctx && !(ctx = messaging_init(NULL, server_id_self(),496 smbd_event_context()))) {497 smb_panic("Could not init smbd messaging context\n");498 }499 return ctx;500 }501 502 struct memcache *smbd_memcache(void)503 {504 static struct memcache *cache;505 506 if (!cache507 && !(cache = memcache_init(NULL,508 lp_max_stat_cache_size()*1024))) {509 510 smb_panic("Could not init smbd memcache");511 }512 return cache;513 425 } 514 426 … … 547 459 poptFreeContext(pc); 548 460 461 lp_load_initial_only(get_dyn_CONFIGFILE()); 462 549 463 /* TODO: check output */ 550 reload_services( False);464 reload_services(smbd_messaging_context(), -1, False); 551 465 552 466 /* the following functions are part of the Samba debugging 553 467 facilities. See lib/debug.c */ 554 setup_logging("vfstest", True);468 setup_logging("vfstest", DEBUG_STDOUT); 555 469 556 470 /* Load command lists */
Note:
See TracChangeset
for help on using the changeset viewer.