*/
#include "includes.h"
+#include "wbc_async.h"
extern char *optarg;
extern int optind;
uint16 old_vuid = cli->vuid;
fstring old_user_name;
size_t passlen = strlen(password);
+ NTSTATUS status;
bool ret;
fstrcpy(old_user_name, cli->user_name);
workgroup));
*new_vuid = cli->vuid;
cli->vuid = old_vuid;
- fstrcpy(cli->user_name, old_user_name);
+ status = cli_set_username(cli, old_user_name);
+ if (!NT_STATUS_IS_OK(status)) {
+ return false;
+ }
return ret;
}
uint16 vuid1, vuid2;
char buf[4];
bool ret = True;
+ NTSTATUS status;
memset(buf, '\0', sizeof(buf));
return False;
}
- if (!cli_send_tconX(cli, share, "?????",
- password, strlen(password)+1)) {
+ status = cli_tcon_andx(cli, share, "?????",
+ password, strlen(password)+1);
+ if (!NT_STATUS_IS_OK(status)) {
printf("%s refused 2nd tree connect (%s)\n", host,
- cli_errstr(cli));
+ nt_errstr(status));
cli_shutdown(cli);
return False;
}
printf("starting tcon2 test\n");
- asprintf(&service, "\\\\%s\\%s", host, share);
+ if (asprintf(&service, "\\\\%s\\%s", host, share) == -1) {
+ return false;
+ }
status = cli_raw_tcon(cli, service, password, "?????", &max_xmit, &cnum);
const char *return_devtype,
NTSTATUS expected_error)
{
- bool status;
+ NTSTATUS status;
bool ret;
- status = cli_send_tconX(cli, myshare, devtype,
- password, strlen(password)+1);
+ status = cli_tcon_andx(cli, myshare, devtype,
+ password, strlen(password)+1);
if (NT_STATUS_IS_OK(expected_error)) {
- if (status) {
+ if (NT_STATUS_IS_OK(status)) {
if (strcmp(cli->dev, return_devtype) == 0) {
ret = True;
} else {
}
cli_tdis(cli);
} else {
- if (status) {
+ if (NT_STATUS_IS_OK(status)) {
printf("tconx to share %s with type %s "
"should have failed but succeeded\n",
myshare, devtype);
return False;
saved_cnum = cli->cnum;
- if (!cli_send_tconX(cli, share, "?????", "", 1))
+ if (!NT_STATUS_IS_OK(cli_tcon_andx(cli, share, "?????", "", 1)))
return False;
new_cnum = cli->cnum;
cli->cnum = saved_cnum;
return correct;
}
+/*
+ Test POSIX open /mkdir calls.
+ */
+static bool run_simple_posix_open_test(int dummy)
+{
+ static struct cli_state *cli1;
+ const char *fname = "\\posix.file";
+ const char *dname = "\\posix.dir";
+ uint16 major, minor;
+ uint32 caplow, caphigh;
+ int fnum1 = -1;
+ bool correct = false;
+
+ printf("Starting simple POSIX open test\n");
+
+ if (!torture_open_connection(&cli1, 0)) {
+ return false;
+ }
+
+ cli_sockopt(cli1, sockops);
+
+ if (!SERVER_HAS_UNIX_CIFS(cli1)) {
+ printf("Server doesn't support UNIX CIFS extensions.\n");
+ return false;
+ }
+
+ if (!cli_unix_extensions_version(cli1, &major,
+ &minor, &caplow, &caphigh)) {
+ printf("Server didn't return UNIX CIFS extensions.\n");
+ return false;
+ }
+
+ if (!cli_set_unix_extensions_capabilities(cli1,
+ major, minor, caplow, caphigh)) {
+ printf("Server doesn't support setting UNIX CIFS extensions.\n");
+ return false;
+ }
+
+ cli_setatr(cli1, fname, 0, 0);
+ cli_posix_unlink(cli1, fname);
+ cli_setatr(cli1, dname, 0, 0);
+ cli_posix_rmdir(cli1, dname);
+
+ /* Create a directory. */
+ if (cli_posix_mkdir(cli1, dname, 0777) == -1) {
+ printf("Server doesn't support setting UNIX CIFS extensions.\n");
+ goto out;
+ }
+
+ fnum1 = cli_posix_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, 0600);
+ if (fnum1 == -1) {
+ printf("POSIX create of %s failed (%s)\n", fname, cli_errstr(cli1));
+ goto out;
+ }
+
+ if (!cli_close(cli1, fnum1)) {
+ printf("close failed (%s)\n", cli_errstr(cli1));
+ goto out;
+ }
+
+ /* Now open the file again for read only. */
+ fnum1 = cli_posix_open(cli1, fname, O_RDONLY, 0);
+ if (fnum1 == -1) {
+ printf("POSIX open of %s failed (%s)\n", fname, cli_errstr(cli1));
+ goto out;
+ }
+
+ /* Now unlink while open. */
+ if (!cli_posix_unlink(cli1, fname)) {
+ printf("POSIX unlink of %s failed (%s)\n", fname, cli_errstr(cli1));
+ goto out;
+ }
+
+ if (!cli_close(cli1, fnum1)) {
+ printf("close(2) failed (%s)\n", cli_errstr(cli1));
+ goto out;
+ }
+
+ /* Ensure the file has gone. */
+ fnum1 = cli_posix_open(cli1, fname, O_RDONLY, 0);
+ if (fnum1 != -1) {
+ printf("POSIX open of %s succeeded, should have been deleted.\n", fname);
+ goto out;
+ }
+
+ if (!cli_posix_rmdir(cli1, dname)) {
+ printf("POSIX rmdir failed (%s)\n", cli_errstr(cli1));
+ goto out;
+ }
+
+ printf("Simple POSIX open test passed\n");
+ correct = true;
+
+ out:
+
+ if (fnum1 != -1) {
+ cli_close(cli1, fnum1);
+ fnum1 = -1;
+ }
+
+ cli_setatr(cli1, fname, 0, 0);
+ cli_posix_unlink(cli1, fname);
+ cli_setatr(cli1, dname, 0, 0);
+ cli_posix_rmdir(cli1, dname);
+
+ if (!torture_close_connection(cli1)) {
+ correct = false;
+ }
+
+ return correct;
+}
+
+
static uint32 open_attrs_table[] = {
FILE_ATTRIBUTE_NORMAL,
FILE_ATTRIBUTE_ARCHIVE,
static bool run_sesssetup_bench(int dummy)
{
static struct cli_state *c;
+ const char *fname = "\\file.dat";
+ int fnum;
NTSTATUS status;
int i;
- if (!(c = open_nbt_connection())) {
+ if (!torture_open_connection(&c, 0)) {
return false;
}
- status = cli_negprot(c);
- if (!NT_STATUS_IS_OK(status)) {
- printf("%s rejected the NT-error negprot (%s)\n", host,
- nt_errstr(status));
- cli_shutdown(c);
+ fnum = cli_nt_create_full(
+ c, fname, 0, GENERIC_ALL_ACCESS|DELETE_ACCESS,
+ FILE_ATTRIBUTE_NORMAL, 0, FILE_OVERWRITE_IF,
+ FILE_DELETE_ON_CLOSE, 0);
+ if (fnum == -1) {
+ d_printf("open %s failed: %s\n", fname, cli_errstr(c));
return false;
}
return false;
}
+ d_printf("\r%d ", (int)c->vuid);
+
if (!cli_ulogoff(c)) {
d_printf("(%s) cli_ulogoff failed: %s\n",
__location__, cli_errstr(c));
for (i=0; i<1000; i++) {
char *key, *value;
- asprintf(&key, "key%ld", random());
- asprintf(&value, "value%ld", random());
+ if (asprintf(&key, "key%ld", random()) == -1) {
+ goto done;
+ }
+ if (asprintf(&value, "value%ld", random()) == -1) {
+ SAFE_FREE(key);
+ goto done;
+ }
if (!rbt_testval(db, key, value)) {
SAFE_FREE(key);
}
SAFE_FREE(value);
- asprintf(&value, "value%ld", random());
+ if (asprintf(&value, "value%ld", random()) == -1) {
+ SAFE_FREE(key);
+ goto done;
+ }
if (!rbt_testval(db, key, value)) {
SAFE_FREE(key);
return ret;
}
+static void wbclient_done(struct async_req *req)
+{
+ wbcErr wbc_err;
+ struct winbindd_response *wb_resp;
+ int *i = (int *)req->async.priv;
+
+ wbc_err = wb_trans_recv(req, req, &wb_resp);
+ TALLOC_FREE(req);
+ *i += 1;
+ d_printf("wb_trans_recv %d returned %s\n", *i, wbcErrorString(wbc_err));
+}
+
+static bool run_local_wbclient(int dummy)
+{
+ struct event_context *ev;
+ struct wb_context **wb_ctx;
+ struct winbindd_request wb_req;
+ bool result = false;
+ int i, j;
+
+ BlockSignals(True, SIGPIPE);
+
+ ev = event_context_init(talloc_tos());
+ if (ev == NULL) {
+ goto fail;
+ }
+
+ wb_ctx = TALLOC_ARRAY(ev, struct wb_context *, torture_numops);
+ if (wb_ctx == NULL) {
+ goto fail;
+ }
+
+ ZERO_STRUCT(wb_req);
+ wb_req.cmd = WINBINDD_PING;
+
+ for (i=0; i<torture_numops; i++) {
+ wb_ctx[i] = wb_context_init(ev);
+ if (wb_ctx[i] == NULL) {
+ goto fail;
+ }
+ for (j=0; j<5; j++) {
+ struct async_req *req;
+ req = wb_trans_send(ev, ev, wb_ctx[i],
+ (j % 2) == 0, &wb_req);
+ if (req == NULL) {
+ goto fail;
+ }
+ req->async.fn = wbclient_done;
+ req->async.priv = &i;
+ }
+ }
+
+ i = 0;
+
+ while (i < 5 * torture_numops) {
+ event_loop_once(ev);
+ }
+
+ result = true;
+ fail:
+ TALLOC_FREE(ev);
+ return result;
+}
+
static double create_procs(bool (*fn)(int), bool *result)
{
int i, status;
{"RW2", run_readwritemulti, FLAG_MULTIPROC},
{"RW3", run_readwritelarge, 0},
{"OPEN", run_opentest, 0},
+ {"POSIX", run_simple_posix_open_test, 0},
#if 1
{"OPENATTR", run_openattrtest, 0},
#endif
{ "LOCAL-RBTREE", run_local_rbtree, 0},
{ "LOCAL-MEMCACHE", run_local_memcache, 0},
{ "LOCAL-STREAM-NAME", run_local_stream_name, 0},
+ { "LOCAL-WBCLIENT", run_local_wbclient, 0},
{NULL, NULL, 0}};
load_case_tables();
+ if (is_default_dyn_CONFIGFILE()) {
+ if(getenv("SMB_CONF_PATH")) {
+ set_dyn_CONFIGFILE(getenv("SMB_CONF_PATH"));
+ }
+ }
lp_load(get_dyn_CONFIGFILE(),True,False,False,True);
load_interfaces();
*p = 0;
fstrcpy(share, p+1);
- fstrcpy(myname, talloc_get_myname(talloc_tos()));
+ fstrcpy(myname, get_myname(talloc_tos()));
if (!*myname) {
fprintf(stderr, "Failed to get my hostname.\n");
return 1;