static double create_procs(bool (*fn)(int), bool *result);
-
-/* return a pointer to a anonymous shared memory segment of size "size"
- which will persist across fork() but will disappear when all processes
- exit
-
- The memory is not zeroed
-
- This function uses system5 shared memory. It takes advantage of a property
- that the memory is not destroyed if it is attached when the id is removed
- */
-void *shm_setup(int size)
-{
- int shmid;
- void *ret;
-
-#ifdef __QNXNTO__
- shmid = shm_open("private", O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
- if (shmid == -1) {
- printf("can't get shared memory\n");
- exit(1);
- }
- shm_unlink("private");
- if (ftruncate(shmid, size) == -1) {
- printf("can't set shared memory size\n");
- exit(1);
- }
- ret = mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, shmid, 0);
- if (ret == MAP_FAILED) {
- printf("can't map shared memory\n");
- exit(1);
- }
-#else
- shmid = shmget(IPC_PRIVATE, size, S_IRUSR | S_IWUSR);
- if (shmid == -1) {
- printf("can't get shared memory\n");
- exit(1);
- }
- ret = (void *)shmat(shmid, 0, 0);
- if (!ret || ret == (void *)-1) {
- printf("can't attach to shared memory\n");
- return NULL;
- }
- /* the following releases the ipc, but note that this process
- and all its children will still have access to the memory, its
- just that the shmid is no longer valid for other shm calls. This
- means we don't leave behind lots of shm segments after we exit
-
- See Stevens "advanced programming in unix env" for details
- */
- shmctl(shmid, IPC_RMID, 0);
-#endif
-
- return ret;
-}
-
/********************************************************************
Ensure a connection is encrypted.
********************************************************************/
static void alarm_handler_parent(int dummy)
{
- cli_state_disconnect(alarm_cli);
+ smbXcli_conn_disconnect(alarm_cli->conn, NT_STATUS_OK);
}
static void do_local_lock(int read_fd, int write_fd)
for (i=0;i<50000;i++) {
struct tevent_req *req;
- req = cli_negprot_send(ev, ev, cli, PROTOCOL_NT1);
+ req = smbXcli_negprot_send(ev, ev, cli->conn, cli->timeout,
+ PROTOCOL_CORE, PROTOCOL_NT1);
if (req == NULL) {
TALLOC_FREE(ev);
return false;
size_t nread;
NTSTATUS status;
- shared_correct = (volatile bool *)shm_setup(sizeof(bool));
+ shared_correct = (volatile bool *)anonymous_shared_allocate(sizeof(bool));
*shared_correct = True;
use_level_II_oplocks = True;
/* This should fail with a sharing violation - open for delete is only compatible
with SHARE_DELETE. */
- if (NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, GENERIC_READ_ACCESS, FILE_ATTRIBUTE_NORMAL,
- FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0, 0, &fnum2))) {
+ status = cli_ntcreate(cli1, fname, 0, GENERIC_READ_ACCESS,
+ FILE_ATTRIBUTE_NORMAL,
+ FILE_SHARE_READ|FILE_SHARE_WRITE,
+ FILE_OPEN, 0, 0, &fnum2);
+ if (NT_STATUS_IS_OK(status)) {
printf("[3] open - 2 of %s succeeded - should have failed.\n", fname);
correct = False;
goto fail;
/* This should fail - file should no longer be there. */
- if (NT_STATUS_IS_OK(cli_openx(cli1, fname, O_RDONLY, DENY_NONE, &fnum1))) {
+ status = cli_openx(cli1, fname, O_RDONLY, DENY_NONE, &fnum1);
+ if (NT_STATUS_IS_OK(status)) {
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)) {
goto out;
}
+ /* Ensure st_mode == 0600 */
+ if ((sbuf.st_ex_mode & 07777) != 0600) {
+ printf("posix_open - bad permissions 0%o != 0600\n",
+ (unsigned int)(sbuf.st_ex_mode & 07777));
+ goto out;
+ }
+
/* Test ftruncate - set file size back to zero. */
status = cli_ftruncate(cli1, fnum1, 0);
if (!NT_STATUS_IS_OK(status)) {
goto out;
}
+ /* Check directory opens with a specific permission. */
+ status = cli_posix_mkdir(cli1, dname, 0700);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("POSIX mkdir of %s failed (%s)\n", dname, nt_errstr(status));
+ goto out;
+ }
+
+ /* Ensure st_mode == 0700 */
+ status = cli_posix_stat(cli1, dname, &sbuf);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("stat failed (%s)\n", nt_errstr(status));
+ goto out;
+ }
+
+ if ((sbuf.st_ex_mode & 07777) != 0700) {
+ printf("posix_mkdir - bad permissions 0%o != 0700\n",
+ (unsigned int)(sbuf.st_ex_mode & 07777));
+ goto out;
+ }
+
printf("Simple POSIX open test passed\n");
correct = true;
ret = check_error(__LINE__, status, ERRDOS, ERRbadfile,
NT_STATUS_OBJECT_NAME_NOT_FOUND);
} else {
- printf("* chkpath on a non existant file should fail\n");
+ printf("* chkpath on a non existent file should fail\n");
ret = False;
}
correct = False;
}
- /* Try and delete a non existant EA. */
+ /* Try and delete a non existent EA. */
status = cli_set_ea_path(cli, fname, "foo", "", 0);
if (!NT_STATUS_IS_OK(status)) {
- printf("deleting non-existant EA 'foo' should succeed. %s\n",
+ printf("deleting non-existent EA 'foo' should succeed. %s\n",
nt_errstr(status));
correct = False;
}
}
disable_spnego = false;
- status = cli_negprot(c_nt, PROTOCOL_NT1);
+ status = smbXcli_negprot(c_nt->conn, c_nt->timeout, PROTOCOL_CORE,
+ PROTOCOL_NT1);
if (!NT_STATUS_IS_OK(status)) {
printf("%s rejected the NT-error negprot (%s)\n", host,
disable_spnego = false;
force_dos_errors = false;
- status = cli_negprot(c_dos, PROTOCOL_NT1);
+ status = smbXcli_negprot(c_dos->conn, c_dos->timeout, PROTOCOL_CORE,
+ PROTOCOL_NT1);
if (!NT_STATUS_IS_OK(status)) {
printf("%s rejected the DOS-error negprot (%s)\n", host,
nt_errstr(status));
if (reqs[2] == NULL) return false;
tevent_req_set_callback(reqs[2], chain1_close_completion, &done);
- status = cli_smb_chain_send(smbreqs, ARRAY_SIZE(smbreqs));
+ status = smb1cli_req_chain_submit(smbreqs, ARRAY_SIZE(smbreqs));
if (!NT_STATUS_IS_OK(status)) {
return false;
}
if (reqs[1] == NULL) return false;
tevent_req_set_callback(reqs[1], chain2_tcon_completion, &done);
- status = cli_smb_chain_send(smbreqs, ARRAY_SIZE(smbreqs));
+ status = smb1cli_req_chain_submit(smbreqs, ARRAY_SIZE(smbreqs));
if (!NT_STATUS_IS_OK(status)) {
return false;
}
break;
}
- status = dbwrap_fetch_uint32(db, "transtest", &val);
+ status = dbwrap_fetch_uint32_bystring(db, "transtest", &val);
if (!NT_STATUS_IS_OK(status)) {
printf(__location__ "dbwrap_fetch_uint32 failed: %s\n",
nt_errstr(status));
}
}
- status = dbwrap_fetch_uint32(db, "transtest", &val2);
+ status = dbwrap_fetch_uint32_bystring(db, "transtest", &val2);
if (!NT_STATUS_IS_OK(status)) {
printf(__location__ "dbwrap_fetch_uint32 failed: %s\n",
nt_errstr(status));
synccount = 0;
- child_status = (volatile pid_t *)shm_setup(sizeof(pid_t)*torture_nprocs);
+ child_status = (volatile pid_t *)anonymous_shared_allocate(sizeof(pid_t)*torture_nprocs);
if (!child_status) {
printf("Failed to setup shared memory\n");
return -1;
}
- child_status_out = (volatile bool *)shm_setup(sizeof(bool)*torture_nprocs);
+ child_status_out = (volatile bool *)anonymous_shared_allocate(sizeof(bool)*torture_nprocs);
if (!child_status_out) {
printf("Failed to setup result status shared memory\n");
return -1;