From 4e709dc42fff464191f21dfa150a18a072d48569 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 3 Dec 2011 21:13:08 -0800 Subject: Rename cli_open -> cli_openx. Prelude to replacing generic cli_open() with a call that uses NTCreateX in preference to OpenAndX. --- source3/client/client.c | 2 +- source3/client/smbspool.c | 2 +- source3/libgpo/gpo_filesync.c | 2 +- source3/libsmb/clifile.c | 38 +++---- source3/libsmb/libsmb_file.c | 4 +- source3/libsmb/proto.h | 8 +- source3/torture/denytest.c | 12 +-- source3/torture/locktest.c | 4 +- source3/torture/locktest2.c | 2 +- source3/torture/mangle_test.c | 4 +- source3/torture/masktest.c | 2 +- source3/torture/scanner.c | 8 +- source3/torture/test_case_insensitive.c | 4 +- source3/torture/torture.c | 174 ++++++++++++++++---------------- source3/torture/utable.c | 2 +- source3/utils/net_rpc_printer.c | 4 +- 16 files changed, 136 insertions(+), 136 deletions(-) (limited to 'source3') diff --git a/source3/client/client.c b/source3/client/client.c index b3559170136..074fbc93bc4 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -412,7 +412,7 @@ NTSTATUS smbclient_cli_open(struct cli_state *cli, const char *fname, int flags, try_openx: - return cli_open(cli, fname, flags, share_mode_in, pfnum); + return cli_openx(cli, fname, flags, share_mode_in, pfnum); } /**************************************************************************** diff --git a/source3/client/smbspool.c b/source3/client/smbspool.c index ddae1a67852..71bdab17195 100644 --- a/source3/client/smbspool.c +++ b/source3/client/smbspool.c @@ -576,7 +576,7 @@ smb_print(struct cli_state * cli, /* I - SMB connection */ * Open the printer device... */ - nt_status = cli_open(cli, title, O_RDWR | O_CREAT | O_TRUNC, DENY_NONE, + nt_status = cli_openx(cli, title, O_RDWR | O_CREAT | O_TRUNC, DENY_NONE, &fnum); if (!NT_STATUS_IS_OK(nt_status)) { fprintf(stderr, "ERROR: %s opening remote spool %s\n", diff --git a/source3/libgpo/gpo_filesync.c b/source3/libgpo/gpo_filesync.c index ead9261d16a..7f0e4107d6c 100644 --- a/source3/libgpo/gpo_filesync.c +++ b/source3/libgpo/gpo_filesync.c @@ -50,7 +50,7 @@ NTSTATUS gpo_copy_file(TALLOC_CTX *mem_ctx, int read_size = io_bufsize; off_t nread = 0; - result = cli_open(cli, nt_path, O_RDONLY, DENY_NONE, &fnum); + result = cli_openx(cli, nt_path, O_RDONLY, DENY_NONE, &fnum); if (!NT_STATUS_IS_OK(result)) { goto out; } diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c index ec8395626be..fc8408feebf 100644 --- a/source3/libsmb/clifile.c +++ b/source3/libsmb/clifile.c @@ -2111,7 +2111,7 @@ NTSTATUS cli_nttrans_create(struct cli_state *cli, WARNING: if you open with O_WRONLY then getattrE won't work! ****************************************************************************/ -struct cli_open_state { +struct cli_openx_state { struct tevent_context *ev; struct cli_state *cli; const char *fname; @@ -2123,20 +2123,20 @@ struct cli_open_state { struct iovec bytes; }; -static void cli_open_done(struct tevent_req *subreq); +static void cli_openx_done(struct tevent_req *subreq); static void cli_open_ntcreate_done(struct tevent_req *subreq); -struct tevent_req *cli_open_create(TALLOC_CTX *mem_ctx, +struct tevent_req *cli_openx_create(TALLOC_CTX *mem_ctx, struct event_context *ev, struct cli_state *cli, const char *fname, int flags, int share_mode, struct tevent_req **psmbreq) { struct tevent_req *req, *subreq; - struct cli_open_state *state; + struct cli_openx_state *state; uint8_t *bytes; - req = tevent_req_create(mem_ctx, &state, struct cli_open_state); + req = tevent_req_create(mem_ctx, &state, struct cli_openx_state); if (req == NULL) { return NULL; } @@ -2211,19 +2211,19 @@ struct tevent_req *cli_open_create(TALLOC_CTX *mem_ctx, TALLOC_FREE(req); return NULL; } - tevent_req_set_callback(subreq, cli_open_done, req); + tevent_req_set_callback(subreq, cli_openx_done, req); *psmbreq = subreq; return req; } -struct tevent_req *cli_open_send(TALLOC_CTX *mem_ctx, struct event_context *ev, +struct tevent_req *cli_openx_send(TALLOC_CTX *mem_ctx, struct event_context *ev, struct cli_state *cli, const char *fname, int flags, int share_mode) { struct tevent_req *req, *subreq; NTSTATUS status; - req = cli_open_create(mem_ctx, ev, cli, fname, flags, share_mode, + req = cli_openx_create(mem_ctx, ev, cli, fname, flags, share_mode, &subreq); if (req == NULL) { return NULL; @@ -2236,12 +2236,12 @@ struct tevent_req *cli_open_send(TALLOC_CTX *mem_ctx, struct event_context *ev, return req; } -static void cli_open_done(struct tevent_req *subreq) +static void cli_openx_done(struct tevent_req *subreq) { struct tevent_req *req = tevent_req_callback_data( subreq, struct tevent_req); - struct cli_open_state *state = tevent_req_data( - req, struct cli_open_state); + struct cli_openx_state *state = tevent_req_data( + req, struct cli_openx_state); uint8_t wct; uint16_t *vwv; uint8_t *inbuf; @@ -2290,8 +2290,8 @@ static void cli_open_ntcreate_done(struct tevent_req *subreq) { struct tevent_req *req = tevent_req_callback_data( subreq, struct tevent_req); - struct cli_open_state *state = tevent_req_data( - req, struct cli_open_state); + struct cli_openx_state *state = tevent_req_data( + req, struct cli_openx_state); NTSTATUS status; status = cli_ntcreate_recv(subreq, &state->fnum); @@ -2302,10 +2302,10 @@ static void cli_open_ntcreate_done(struct tevent_req *subreq) tevent_req_done(req); } -NTSTATUS cli_open_recv(struct tevent_req *req, uint16_t *pfnum) +NTSTATUS cli_openx_recv(struct tevent_req *req, uint16_t *pfnum) { - struct cli_open_state *state = tevent_req_data( - req, struct cli_open_state); + struct cli_openx_state *state = tevent_req_data( + req, struct cli_openx_state); NTSTATUS status; if (tevent_req_is_nterror(req, &status)) { @@ -2315,7 +2315,7 @@ NTSTATUS cli_open_recv(struct tevent_req *req, uint16_t *pfnum) return NT_STATUS_OK; } -NTSTATUS cli_open(struct cli_state *cli, const char *fname, int flags, +NTSTATUS cli_openx(struct cli_state *cli, const char *fname, int flags, int share_mode, uint16_t *pfnum) { TALLOC_CTX *frame = talloc_stackframe(); @@ -2337,7 +2337,7 @@ NTSTATUS cli_open(struct cli_state *cli, const char *fname, int flags, goto fail; } - req = cli_open_send(frame, ev, cli, fname, flags, share_mode); + req = cli_openx_send(frame, ev, cli, fname, flags, share_mode); if (req == NULL) { status = NT_STATUS_NO_MEMORY; goto fail; @@ -2348,7 +2348,7 @@ NTSTATUS cli_open(struct cli_state *cli, const char *fname, int flags, goto fail; } - status = cli_open_recv(req, pfnum); + status = cli_openx_recv(req, pfnum); fail: TALLOC_FREE(frame); return status; diff --git a/source3/libsmb/libsmb_file.c b/source3/libsmb/libsmb_file.c index b5932c8164a..a89c95cdab9 100644 --- a/source3/libsmb/libsmb_file.c +++ b/source3/libsmb/libsmb_file.c @@ -123,7 +123,7 @@ SMBC_open_ctx(SMBCCTX *context, } /*d_printf(">>>open: resolved %s as %s\n", path, targetpath);*/ - status = cli_open(targetcli, targetpath, flags, + status = cli_openx(targetcli, targetpath, flags, context->internal->share_mode, &fd); if (!NT_STATUS_IS_OK(status)) { @@ -633,7 +633,7 @@ SMBC_setatr(SMBCCTX * context, SMBCSRV *srv, char *path, srv->no_pathinfo = True; /* Open the file */ - if (!NT_STATUS_IS_OK(cli_open(srv->cli, path, O_RDWR, DENY_NONE, &fd))) { + if (!NT_STATUS_IS_OK(cli_openx(srv->cli, path, O_RDWR, DENY_NONE, &fd))) { errno = SMBC_errno(context, srv->cli); TALLOC_FREE(frame); return -1; diff --git a/source3/libsmb/proto.h b/source3/libsmb/proto.h index 182e8c8e4d2..27826cbfa4f 100644 --- a/source3/libsmb/proto.h +++ b/source3/libsmb/proto.h @@ -387,16 +387,16 @@ uint8_t *trans2_bytes_push_str(uint8_t *buf, bool ucs2, size_t *pconverted_size); uint8_t *trans2_bytes_push_bytes(uint8_t *buf, const uint8_t *bytes, size_t num_bytes); -struct tevent_req *cli_open_create(TALLOC_CTX *mem_ctx, +struct tevent_req *cli_openx_create(TALLOC_CTX *mem_ctx, struct event_context *ev, struct cli_state *cli, const char *fname, int flags, int share_mode, struct tevent_req **psmbreq); -struct tevent_req *cli_open_send(TALLOC_CTX *mem_ctx, struct event_context *ev, +struct tevent_req *cli_openx_send(TALLOC_CTX *mem_ctx, struct event_context *ev, struct cli_state *cli, const char *fname, int flags, int share_mode); -NTSTATUS cli_open_recv(struct tevent_req *req, uint16_t *fnum); -NTSTATUS cli_open(struct cli_state *cli, const char *fname, int flags, int share_mode, uint16_t *pfnum); +NTSTATUS cli_openx_recv(struct tevent_req *req, uint16_t *fnum); +NTSTATUS cli_openx(struct cli_state *cli, const char *fname, int flags, int share_mode, uint16_t *pfnum); struct tevent_req *cli_close_create(TALLOC_CTX *mem_ctx, struct event_context *ev, struct cli_state *cli, uint16_t fnum, diff --git a/source3/torture/denytest.c b/source3/torture/denytest.c index 8462894df5e..5b0eeec2fa7 100644 --- a/source3/torture/denytest.c +++ b/source3/torture/denytest.c @@ -1424,7 +1424,7 @@ bool torture_denytest1(int dummy) for (i=0;i<2;i++) { cli_unlink(cli1, fnames[i], FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); - cli_open(cli1, fnames[i], O_RDWR|O_CREAT, DENY_NONE, &fnum1); + cli_openx(cli1, fnames[i], O_RDWR|O_CREAT, DENY_NONE, &fnum1); cli_writeall(cli1, fnum1, 0, (const uint8_t *)fnames[i], 0, strlen(fnames[i]), NULL); cli_close(cli1, fnum1); @@ -1438,10 +1438,10 @@ bool torture_denytest1(int dummy) progress_bar(i, ARRAY_SIZE(denytable1)); - ret1 = cli_open(cli1, fname, + ret1 = cli_openx(cli1, fname, denytable1[i].mode1, denytable1[i].deny1, &fnum1); - ret2 = cli_open(cli1, fname, + ret2 = cli_openx(cli1, fname, denytable1[i].mode2, denytable1[i].deny2, &fnum2); @@ -1522,7 +1522,7 @@ bool torture_denytest2(int dummy) for (i=0;i<2;i++) { cli_unlink(cli1, fnames[i], FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); - cli_open(cli1, fnames[i], O_RDWR|O_CREAT, DENY_NONE, &fnum1); + cli_openx(cli1, fnames[i], O_RDWR|O_CREAT, DENY_NONE, &fnum1); cli_writeall(cli1, fnum1, 0, (const uint8_t *)fnames[i], 0, strlen(fnames[i]), NULL); cli_close(cli1, fnum1); @@ -1534,10 +1534,10 @@ bool torture_denytest2(int dummy) progress_bar(i, ARRAY_SIZE(denytable2)); - ret1 = cli_open(cli1, fname, + ret1 = cli_openx(cli1, fname, denytable2[i].mode1, denytable2[i].deny1, &fnum1); - ret2 = cli_open(cli2, fname, + ret2 = cli_openx(cli2, fname, denytable2[i].mode2, denytable2[i].deny2, &fnum2); diff --git a/source3/torture/locktest.c b/source3/torture/locktest.c index e5189c44f24..288ce8fe543 100644 --- a/source3/torture/locktest.c +++ b/source3/torture/locktest.c @@ -347,7 +347,7 @@ static bool test_one(struct cli_state *cli[NSERVERS][NCONNECTIONS], } for (server=0;serveruse_oplocks = True; - status = cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, + status = cli_openx(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1); if (!NT_STATUS_IS_OK(status)) { printf("open of %s failed (%s)\n", fname, nt_errstr(status)); @@ -3578,7 +3578,7 @@ static bool run_oplock2(int dummy) cli_sockopt(cli1, sockops); cli_sockopt(cli2, sockops); - status = cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, + status = cli_openx(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1); if (!NT_STATUS_IS_OK(status)) { printf("open of %s failed (%s)\n", fname, nt_errstr(status)); @@ -3591,7 +3591,7 @@ static bool run_oplock2(int dummy) if (fork() == 0) { /* Child code */ - status = cli_open(cli2, fname, O_RDWR, DENY_NONE, &fnum2); + status = cli_openx(cli2, fname, O_RDWR, DENY_NONE, &fnum2); if (!NT_STATUS_IS_OK(status)) { printf("second open of %s failed (%s)\n", fname, nt_errstr(status)); *shared_correct = False; @@ -3721,7 +3721,7 @@ static bool run_oplock4(int dummy) cli_sockopt(cli2, sockops); /* Create the file. */ - status = cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, + status = cli_openx(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1); if (!NT_STATUS_IS_OK(status)) { printf("open of %s failed (%s)\n", fname, nt_errstr(status)); @@ -3742,13 +3742,13 @@ static bool run_oplock4(int dummy) } /* Prove that opening hardlinks cause deny modes to conflict. */ - status = cli_open(cli1, fname, O_RDWR, DENY_ALL, &fnum1); + status = cli_openx(cli1, fname, O_RDWR, DENY_ALL, &fnum1); if (!NT_STATUS_IS_OK(status)) { printf("open of %s failed (%s)\n", fname, nt_errstr(status)); return false; } - status = cli_open(cli1, fname_ln, O_RDWR, DENY_NONE, &fnum2); + status = cli_openx(cli1, fname_ln, O_RDWR, DENY_NONE, &fnum2); if (NT_STATUS_IS_OK(status)) { printf("open of %s succeeded - should fail with sharing violation.\n", fname_ln); @@ -3770,7 +3770,7 @@ static bool run_oplock4(int dummy) cli1->use_oplocks = true; cli2->use_oplocks = true; - status = cli_open(cli1, fname, O_RDWR, DENY_NONE, &fnum1); + status = cli_openx(cli1, fname, O_RDWR, DENY_NONE, &fnum1); if (!NT_STATUS_IS_OK(status)) { printf("open of %s failed (%s)\n", fname, nt_errstr(status)); return false; @@ -3800,10 +3800,10 @@ static bool run_oplock4(int dummy) } tevent_req_set_callback(oplock_req, oplock4_got_break, state); - open_req = cli_open_send( + open_req = cli_openx_send( talloc_tos(), ev, cli2, fname_ln, O_RDWR, DENY_NONE); if (oplock_req == NULL) { - printf("cli_open_send failed\n"); + printf("cli_openx_send failed\n"); return false; } tevent_req_set_callback(open_req, oplock4_got_open, state); @@ -3889,9 +3889,9 @@ static void oplock4_got_open(struct tevent_req *req) req, struct oplock4_state); NTSTATUS status; - status = cli_open_recv(req, state->fnum2); + status = cli_openx_recv(req, state->fnum2); if (!NT_STATUS_IS_OK(status)) { - printf("cli_open_recv returned %s\n", nt_errstr(status)); + printf("cli_openx_recv returned %s\n", nt_errstr(status)); *state->fnum2 = 0xffff; } } @@ -3938,7 +3938,7 @@ static bool run_deletetest(int dummy) goto fail; } - if (NT_STATUS_IS_OK(cli_open(cli1, fname, O_RDWR, DENY_NONE, &fnum1))) { + if (NT_STATUS_IS_OK(cli_openx(cli1, fname, O_RDWR, DENY_NONE, &fnum1))) { printf("[1] open of %s succeeded (should fail)\n", fname); correct = False; goto fail; @@ -3974,7 +3974,7 @@ static bool run_deletetest(int dummy) goto fail; } - if (NT_STATUS_IS_OK(cli_open(cli1, fname, O_RDONLY, DENY_NONE, &fnum1))) { + if (NT_STATUS_IS_OK(cli_openx(cli1, fname, O_RDONLY, DENY_NONE, &fnum1))) { printf("[2] open of %s succeeded should have been deleted on close !\n", fname); status = cli_close(cli1, fnum1); if (!NT_STATUS_IS_OK(status)) { @@ -4044,7 +4044,7 @@ static bool run_deletetest(int dummy) /* This should fail - file should no longer be there. */ - if (NT_STATUS_IS_OK(cli_open(cli1, fname, O_RDONLY, DENY_NONE, &fnum1))) { + if (NT_STATUS_IS_OK(cli_openx(cli1, fname, O_RDONLY, DENY_NONE, &fnum1))) { printf("[3] open of %s succeeded should have been deleted on close !\n", fname); status = cli_close(cli1, fnum1); if (!NT_STATUS_IS_OK(status)) { @@ -4117,7 +4117,7 @@ static bool run_deletetest(int dummy) cli_setatr(cli1, fname, 0, 0); cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); - status = cli_open(cli1, fname, O_RDWR|O_CREAT, DENY_NONE, &fnum1); + status = cli_openx(cli1, fname, O_RDWR|O_CREAT, DENY_NONE, &fnum1); if (!NT_STATUS_IS_OK(status)) { printf("[5] open of %s failed (%s)\n", fname, nt_errstr(status)); correct = False; @@ -4207,7 +4207,7 @@ static bool run_deletetest(int dummy) } /* This next open should succeed - we reset the flag. */ - status = cli_open(cli1, fname, O_RDONLY, DENY_NONE, &fnum1); + status = cli_openx(cli1, fname, O_RDONLY, DENY_NONE, &fnum1); if (!NT_STATUS_IS_OK(status)) { printf("[5] open of %s failed (%s)\n", fname, nt_errstr(status)); correct = False; @@ -4278,7 +4278,7 @@ static bool run_deletetest(int dummy) } /* This should fail.. */ - status = cli_open(cli1, fname, O_RDONLY, DENY_NONE, &fnum1); + status = cli_openx(cli1, fname, O_RDONLY, DENY_NONE, &fnum1); if (NT_STATUS_IS_OK(status)) { printf("[8] open of %s succeeded should have been deleted on close !\n", fname); goto fail; @@ -4316,7 +4316,7 @@ static bool run_deletetest(int dummy) } /* This should fail.. */ - if (NT_STATUS_IS_OK(cli_open(cli1, fname, O_RDONLY, DENY_NONE, &fnum1))) { + if (NT_STATUS_IS_OK(cli_openx(cli1, fname, O_RDONLY, DENY_NONE, &fnum1))) { printf("[10] open of %s succeeded should have been deleted on close !\n", fname); goto fail; correct = False; @@ -4411,7 +4411,7 @@ static bool run_deletetest_ln(int dummy) cli_sockopt(cli, sockops); /* Create the file. */ - status = cli_open(cli, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum); + status = cli_openx(cli, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum); if (!NT_STATUS_IS_OK(status)) { printf("open of %s failed (%s)\n", fname, nt_errstr(status)); return false; @@ -4867,7 +4867,7 @@ static bool run_opentest(int dummy) cli_sockopt(cli1, sockops); - status = cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1); + status = cli_openx(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1); if (!NT_STATUS_IS_OK(status)) { printf("open of %s failed (%s)\n", fname, nt_errstr(status)); return False; @@ -4885,14 +4885,14 @@ static bool run_opentest(int dummy) return False; } - status = cli_open(cli1, fname, O_RDONLY, DENY_WRITE, &fnum1); + status = cli_openx(cli1, fname, O_RDONLY, DENY_WRITE, &fnum1); if (!NT_STATUS_IS_OK(status)) { printf("open of %s failed (%s)\n", fname, nt_errstr(status)); return False; } /* This will fail - but the error should be ERRnoaccess, not ERRbadshare. */ - status = cli_open(cli1, fname, O_RDWR, DENY_ALL, &fnum2); + status = cli_openx(cli1, fname, O_RDWR, DENY_ALL, &fnum2); if (check_error(__LINE__, status, ERRDOS, ERRnoaccess, NT_STATUS_ACCESS_DENIED)) { @@ -4907,14 +4907,14 @@ static bool run_opentest(int dummy) cli_setatr(cli1, fname, 0, 0); - status = cli_open(cli1, fname, O_RDONLY, DENY_WRITE, &fnum1); + status = cli_openx(cli1, fname, O_RDONLY, DENY_WRITE, &fnum1); if (!NT_STATUS_IS_OK(status)) { printf("open of %s failed (%s)\n", fname, nt_errstr(status)); return False; } /* This will fail - but the error should be ERRshare. */ - status = cli_open(cli1, fname, O_RDWR, DENY_ALL, &fnum2); + status = cli_openx(cli1, fname, O_RDWR, DENY_ALL, &fnum2); if (check_error(__LINE__, status, ERRDOS, ERRbadshare, NT_STATUS_SHARING_VIOLATION)) { @@ -4932,7 +4932,7 @@ static bool run_opentest(int dummy) printf("finished open test 2\n"); /* Test truncate open disposition on file opened for read. */ - status = cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1); + status = cli_openx(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1); if (!NT_STATUS_IS_OK(status)) { printf("(3) open (1) of %s failed (%s)\n", fname, nt_errstr(status)); return False; @@ -4967,7 +4967,7 @@ static bool run_opentest(int dummy) } /* Now test if we can truncate a file opened for readonly. */ - status = cli_open(cli1, fname, O_RDONLY|O_TRUNC, DENY_NONE, &fnum1); + status = cli_openx(cli1, fname, O_RDONLY|O_TRUNC, DENY_NONE, &fnum1); if (!NT_STATUS_IS_OK(status)) { printf("(3) open (2) of %s failed (%s)\n", fname, nt_errstr(status)); return False; @@ -5860,7 +5860,7 @@ static bool run_dirtest(int dummy) for (i=0;i