#include "system/filesys.h"
#include "system/dir.h"
#include "libcli/libcli.h"
-#include "libcli/raw/libcliraw.h"
#include "system/time.h"
-#include "pstring.h"
#include "auth/credentials/credentials.h"
#include "auth/gensec/gensec.h"
#include "param/param.h"
-#include "dynconfig/dynconfig.h"
#include "libcli/resolve/resolve.h"
#include "lib/events/events.h"
if (ISDOTDOT(file)) file = ".";
- return ms_fnmatch(pattern, file, cli->transport->negotiate.protocol)==0;
+ return ms_fnmatch_protocol(
+ pattern, file, cli->transport->negotiate.protocol, false)==0;
}
-static char *reg_test(struct smbcli_state *cli, char *pattern, char *long_name, char *short_name)
+static char *reg_test(struct smbcli_state *cli, TALLOC_CTX *mem_ctx, const char *pattern, const char *long_name, const char *short_name)
{
- static fstring ret;
- fstrcpy(ret, "---");
+ char *ret;
+ ret = talloc_strdup(mem_ctx, "---");
pattern = 1+strrchr_m(pattern,'\\');
return a connection to a server
*******************************************************/
static struct smbcli_state *connect_one(struct resolve_context *resolve_ctx,
- struct event_context *ev,
+ struct tevent_context *ev,
+ TALLOC_CTX *mem_ctx,
char *share, const char **ports,
+ const char *socket_options,
struct smbcli_options *options,
- struct smbcli_session_options *session_options)
+ struct smbcli_session_options *session_options,
+ struct gensec_settings *gensec_settings)
{
struct smbcli_state *c;
- fstring server;
+ char *server;
NTSTATUS status;
- fstrcpy(server,share+2);
+ server = talloc_strdup(mem_ctx, share+2);
share = strchr_m(server,'\\');
if (!share) return NULL;
*share = 0;
share++;
- cli_credentials_set_workstation(cmdline_credentials, "masktest", CRED_SPECIFIED);
+ cli_credentials_set_workstation(popt_get_cmdline_credentials(),
+ "masktest", CRED_SPECIFIED);
status = smbcli_full_connection(NULL, &c,
server,
ports,
share, NULL,
- cmdline_credentials, resolve_ctx, ev,
- options, session_options);
+ socket_options,
+ popt_get_cmdline_credentials(),
+ resolve_ctx, ev,
+ options, session_options,
+ gensec_settings);
if (!NT_STATUS_IS_OK(status)) {
return NULL;
}
static void get_real_name(TALLOC_CTX *mem_ctx, struct smbcli_state *cli,
- char **long_name, fstring short_name)
+ char **long_name, char **short_name)
{
const char *mask;
struct masktest_state state;
listfn, &state);
if (f_info_hit) {
- fstrcpy(short_name, last_hit.short_name);
- strlower(short_name);
- *long_name = talloc_strdup(mem_ctx, last_hit.long_name);
- strlower(*long_name);
+ *short_name = strlower_talloc(mem_ctx, last_hit.short_name);
+ *long_name = strlower_talloc(mem_ctx, last_hit.long_name);
}
- if (*short_name == '\0') {
- fstrcpy(short_name, *long_name);
+ if (*short_name[0] == '\0') {
+ *short_name = talloc_strdup(mem_ctx, *long_name);
}
}
char *file)
{
int fnum;
- fstring res1;
+ char res1[256];
char *res2;
static int count;
- fstring short_name;
+ char *short_name = NULL;
char *long_name = NULL;
struct masktest_state state;
count++;
- fstrcpy(res1, "---");
+ strlcpy(res1, "---", sizeof(res1));
state.mem_ctx = mem_ctx;
smbcli_close(cli->tree, fnum);
resultp = res1;
- fstrcpy(short_name, "");
- get_real_name(mem_ctx, cli, &long_name, short_name);
- fstrcpy(res1, "---");
+ short_name = talloc_strdup(mem_ctx, "");
+ get_real_name(mem_ctx, cli, &long_name, &short_name);
+ strlcpy(res1, "---", sizeof(res1));
smbcli_list_new(cli->tree, mask,
FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_DIRECTORY,
RAW_SEARCH_DATA_BOTH_DIRECTORY_INFO,
listfn, &state);
- res2 = reg_test(cli, mask, long_name, short_name);
+ res2 = reg_test(cli, mem_ctx, mask, long_name, short_name);
if (showall || strcmp(res1, res2)) {
d_printf("%s %s %d mask=[%s] file=[%s] rfile=[%s/%s]\n",
}
static void test_mask(int argc, char *argv[],
+ TALLOC_CTX *mem_ctx,
struct smbcli_state *cli)
{
- TALLOC_CTX *mem_ctx;
char *mask, *file;
int l1, l2, i, l;
int mc_len = strlen(maskchars);
int fc_len = strlen(filechars);
- mem_ctx = talloc_init("test_mask");
-
smbcli_mkdir(cli->tree, "\\masktest");
smbcli_unlink(cli->tree, "\\masktest\\*");
finished:
smbcli_rmdir(cli->tree, "\\masktest");
- talloc_free(mem_ctx);
}
/****************************************************************************
main program
****************************************************************************/
- int main(int argc,char *argv[])
+int main(int argc, const char *argv[])
{
char *share;
struct smbcli_state *cli;
int opt;
int seed;
- struct event_context *ev;
+ struct tevent_context *ev;
struct loadparm_context *lp_ctx;
struct smbcli_options options;
struct smbcli_session_options session_options;
poptContext pc;
int argc_new, i;
char **argv_new;
+ TALLOC_CTX *mem_ctx = NULL;
enum {OPT_UNCLIST=1000};
struct poptOption long_options[] = {
POPT_AUTOHELP
POPT_COMMON_CONNECTION
POPT_COMMON_CREDENTIALS
POPT_COMMON_VERSION
- { NULL }
+ {0}
};
setlinebuf(stdout);
seed = time(NULL);
- pc = poptGetContext("locktest", argc, (const char **) argv, long_options,
+ mem_ctx = talloc_named_const(NULL, 0, "masktest_ctx");
+ if (mem_ctx == NULL) {
+ exit(1);
+ }
+
+ pc = poptGetContext("locktest", argc, argv, long_options,
POPT_CONTEXT_KEEP_FIRST);
poptSetOtherOptionHelp(pc, "<unc>");
while((opt = poptGetNextOpt(pc)) != -1) {
switch (opt) {
case OPT_UNCLIST:
- lp_set_cmdline(cmdline_lp_ctx, "torture:unclist", poptGetOptArg(pc));
+ lpcfg_set_cmdline(cmdline_lp_ctx, "torture:unclist", poptGetOptArg(pc));
break;
}
}
if (!(argc_new >= 2)) {
usage(pc);
+ talloc_free(mem_ctx);
exit(1);
}
lp_ctx = cmdline_lp_ctx;
- ev = s4_event_context_init(talloc_autofree_context());
+ ev = s4_event_context_init(mem_ctx);
- gensec_init(lp_ctx);
+ gensec_init();
- lp_smbcli_options(lp_ctx, &options);
- lp_smbcli_session_options(lp_ctx, &session_options);
+ lpcfg_smbcli_options(lp_ctx, &options);
+ lpcfg_smbcli_session_options(lp_ctx, &session_options);
- cli = connect_one(lp_resolve_context(lp_ctx), ev, share,
- lp_smb_ports(lp_ctx), &options, &session_options);
+ cli = connect_one(lpcfg_resolve_context(lp_ctx), ev, mem_ctx, share,
+ lpcfg_smb_ports(lp_ctx), lpcfg_socket_options(lp_ctx),
+ &options, &session_options,
+ lpcfg_gensec_settings(mem_ctx, lp_ctx));
if (!cli) {
DEBUG(0,("Failed to connect to %s\n", share));
+ talloc_free(mem_ctx);
exit(1);
}
DEBUG(0,("seed=%d format --- --- (server, correct)\n", seed));
srandom(seed);
- test_mask(argc_new-1, argv_new+1, cli);
+ test_mask(argc_new-1, argv_new+1, mem_ctx, cli);
+ poptFreeContext(pc);
+ talloc_free(mem_ctx);
return(0);
}