mirror of
https://github.com/samba-team/samba.git
synced 2025-01-27 14:04:05 +03:00
r3261: added seek to RAW-SEARCH test
(This used to be commit 05530bfb99011db8a00f5debcf8eec19b5e8a5d6)
This commit is contained in:
parent
e767d8d1b2
commit
f493f7be97
@ -261,27 +261,36 @@ BOOL check_password_quality(const char *s)
|
|||||||
Use the random number generator to generate a random string.
|
Use the random number generator to generate a random string.
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
|
|
||||||
static char c_list[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+_-#.,";
|
char *generate_random_str_list(TALLOC_CTX *mem_ctx, size_t len, const char *list)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
size_t list_len = strlen(list);
|
||||||
|
|
||||||
|
char *retstr = talloc(mem_ctx, len + 1);
|
||||||
|
if (!retstr) return NULL;
|
||||||
|
|
||||||
|
generate_random_buffer(retstr, len);
|
||||||
|
for (i = 0; i < len; i++) {
|
||||||
|
retstr[i] = list[retstr[i] % list_len];
|
||||||
|
}
|
||||||
|
retstr[i] = '\0';
|
||||||
|
|
||||||
|
return retstr;
|
||||||
|
}
|
||||||
|
|
||||||
char *generate_random_str(TALLOC_CTX *mem_ctx, size_t len)
|
char *generate_random_str(TALLOC_CTX *mem_ctx, size_t len)
|
||||||
{
|
{
|
||||||
size_t i;
|
char *retstr;
|
||||||
|
const char *c_list = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+_-#.,";
|
||||||
char *retstr = talloc(mem_ctx, len + 1);
|
|
||||||
|
|
||||||
if (!retstr)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
again:
|
again:
|
||||||
generate_random_buffer(retstr, len);
|
retstr = generate_random_str_list(mem_ctx, len, c_list);
|
||||||
for (i = 0; i < len; i++)
|
if (!retstr) return NULL;
|
||||||
retstr[i] = c_list[retstr[i] % (sizeof(c_list)-1) ];
|
|
||||||
|
|
||||||
retstr[i] = '\0';
|
|
||||||
|
|
||||||
/* we need to make sure the random string passes basic quality tests
|
/* we need to make sure the random string passes basic quality tests
|
||||||
or it might be rejected by windows as a password */
|
or it might be rejected by windows as a password */
|
||||||
if (len >= 7 && !check_password_quality(retstr)) {
|
if (len >= 7 && !check_password_quality(retstr)) {
|
||||||
|
talloc_free(retstr);
|
||||||
goto again;
|
goto again;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -811,15 +811,15 @@ static BOOL test_modify_search(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
|
|||||||
|
|
||||||
io2.generic.level = RAW_SEARCH_BOTH_DIRECTORY_INFO;
|
io2.generic.level = RAW_SEARCH_BOTH_DIRECTORY_INFO;
|
||||||
io2.t2fnext.in.handle = io.t2ffirst.out.handle;
|
io2.t2fnext.in.handle = io.t2ffirst.out.handle;
|
||||||
io2.t2fnext.in.max_count = num_files - 2;
|
io2.t2fnext.in.max_count = num_files - 1;
|
||||||
io2.t2fnext.in.resume_key = 0;
|
io2.t2fnext.in.resume_key = 0;
|
||||||
io2.t2fnext.in.flags = 0;
|
io2.t2fnext.in.flags = 0;
|
||||||
io2.t2fnext.in.last_name = result.list[result.count-1].both_directory_info.name.s;
|
io2.t2fnext.in.last_name = result.list[result.count-2].both_directory_info.name.s;
|
||||||
|
|
||||||
status = smb_raw_search_next(cli->tree, mem_ctx,
|
status = smb_raw_search_next(cli->tree, mem_ctx,
|
||||||
&io2, &result, multiple_search_callback);
|
&io2, &result, multiple_search_callback);
|
||||||
CHECK_STATUS(status, NT_STATUS_OK);
|
CHECK_STATUS(status, NT_STATUS_OK);
|
||||||
CHECK_VALUE(result.count, 20);
|
CHECK_VALUE(result.count, 21);
|
||||||
|
|
||||||
ret &= check_result(&result, "t009-9.txt", True, FILE_ATTRIBUTE_ARCHIVE);
|
ret &= check_result(&result, "t009-9.txt", True, FILE_ATTRIBUTE_ARCHIVE);
|
||||||
ret &= check_result(&result, "t014-14.txt", False, 0);
|
ret &= check_result(&result, "t014-14.txt", False, 0);
|
||||||
@ -840,7 +840,6 @@ static BOOL test_modify_search(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
|
|||||||
result.list[i].both_directory_info.attrib);
|
result.list[i].both_directory_info.attrib);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exit(1);
|
|
||||||
|
|
||||||
done:
|
done:
|
||||||
smb_raw_exit(cli->session);
|
smb_raw_exit(cli->session);
|
||||||
@ -871,7 +870,7 @@ static BOOL test_sorted(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
|
|||||||
printf("Creating %d files\n", num_files);
|
printf("Creating %d files\n", num_files);
|
||||||
|
|
||||||
for (i=0;i<num_files;i++) {
|
for (i=0;i<num_files;i++) {
|
||||||
asprintf(&fname, BASEDIR "\\%s.txt", generate_random_str(mem_ctx, 10));
|
asprintf(&fname, BASEDIR "\\%s.txt", generate_random_str_list(mem_ctx, 10, "abcdefgh"));
|
||||||
fnum = smbcli_open(cli->tree, fname, O_CREAT|O_RDWR, DENY_NONE);
|
fnum = smbcli_open(cli->tree, fname, O_CREAT|O_RDWR, DENY_NONE);
|
||||||
if (fnum == -1) {
|
if (fnum == -1) {
|
||||||
printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
|
printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user