static void set_max_xmit(uint64_t iomax) { char buf[64]; snprintf(buf, sizeof(buf), "%llu", (unsigned long long)iomax); lp_set_cmdline("max xmit", buf); }
/** Set the debug level */ void smbc_setDebug(SMBCCTX *c, int debug) { char buf[32]; snprintf(buf, sizeof(buf), "%d", debug); c->debug = debug; lp_set_cmdline("log level", buf); }
int main(int argc, char **argv) { struct poptOption long_options[] = { POPT_AUTOHELP /* ... */ POPT_COMMON_SAMBA POPT_COMMON_CONNECTION POPT_COMMON_CREDENTIALS POPT_TABLEEND }; int opt; poptContext pc; struct user_auth_info *auth_info; TALLOC_CTX *frame; struct registry_context *ctx; WERROR rv; frame = talloc_stackframe(); setup_logging("regedit", DEBUG_DEFAULT_STDERR); lp_set_cmdline("log level", "0"); /* process options */ auth_info = user_auth_info_init(frame); if (auth_info == NULL) { exit(1); } popt_common_set_auth_info(auth_info); pc = poptGetContext("regedit", argc, (const char **)argv, long_options, 0); while ((opt = poptGetNextOpt(pc)) != -1) { /* TODO */ } if (!lp_load_global(get_dyn_CONFIGFILE())) { DEBUG(0, ("ERROR loading config file...\n")); exit(1); } /* some simple tests */ rv = reg_open_samba3(frame, &ctx); if (!W_ERROR_IS_OK(rv)) { TALLOC_FREE(frame); return 1; } display_window(frame, ctx); TALLOC_FREE(frame); return 0; }
/* basic testing of session/tree context calls */ BOOL torture_raw_context(struct torture_context *torture) { BOOL ret = True; if (lp_use_spnego()) { ret &= torture_raw_context_int(); lp_set_cmdline("use spnego", "False"); } ret &= torture_raw_context_int(); return ret; }
static bool parse_target(struct loadparm_context *lp_ctx, const char *target) { char *host = NULL, *share = NULL; struct dcerpc_binding *binding_struct; NTSTATUS status; /* see if its a RPC transport specifier */ if (!smbcli_parse_unc(target, NULL, &host, &share)) { status = dcerpc_parse_binding(talloc_autofree_context(), target, &binding_struct); if (NT_STATUS_IS_ERR(status)) { d_printf("Invalid option: %s is not a valid torture target (share or binding string)\n\n", target); return false; } lp_set_cmdline(lp_ctx, "torture:host", binding_struct->host); if (lp_parm_string(lp_ctx, NULL, "torture", "share") == NULL) lp_set_cmdline(lp_ctx, "torture:share", "IPC$"); lp_set_cmdline(lp_ctx, "torture:binding", target); } else { lp_set_cmdline(lp_ctx, "torture:host", host); lp_set_cmdline(lp_ctx, "torture:share", share); lp_set_cmdline(lp_ctx, "torture:binding", host); } return true; }
NET_API_STATUS libnetapi_set_debuglevel(struct libnetapi_ctx *ctx, const char *debuglevel) { TALLOC_CTX *frame = talloc_stackframe(); ctx->debuglevel = talloc_strdup(ctx, debuglevel); if (!lp_set_cmdline("log level", debuglevel)) { TALLOC_FREE(frame); return W_ERROR_V(WERR_GENERAL_FAILURE); } TALLOC_FREE(frame); return NET_API_STATUS_SUCCESS; }
static void popt_common_callback(poptContext con, enum poptCallbackReason reason, const struct poptOption *opt, const char *arg, const void *data) { struct loadparm_context *lp_ctx = cmdline_lp_ctx; switch(opt->val) { case 'O': if (arg) { lp_set_cmdline(lp_ctx, "socket options", arg); } break; case 'W': lp_set_cmdline(lp_ctx, "workgroup", arg); break; case 'r': lp_set_cmdline(lp_ctx, "realm", arg); break; case 'n': lp_set_cmdline(lp_ctx, "netbios name", arg); break; case 'i': lp_set_cmdline(lp_ctx, "netbios scope", arg); break; case 'm': lp_set_cmdline(lp_ctx, "client max protocol", arg); break; case 'R': lp_set_cmdline(lp_ctx, "name resolve order", arg); break; case 'S': lp_set_cmdline(lp_ctx, "client signing", arg); break; } }
static void parse_dns(struct loadparm_context *lp_ctx, const char *dns) { char *userdn, *basedn, *secret; char *p, *d; /* retrievieng the userdn */ p = strchr_m(dns, '#'); if (!p) { lp_set_cmdline(lp_ctx, "torture:ldap_userdn", ""); lp_set_cmdline(lp_ctx, "torture:ldap_basedn", ""); lp_set_cmdline(lp_ctx, "torture:ldap_secret", ""); return; } userdn = strndup(dns, p - dns); lp_set_cmdline(lp_ctx, "torture:ldap_userdn", userdn); /* retrieve the basedn */ d = p + 1; p = strchr_m(d, '#'); if (!p) { lp_set_cmdline(lp_ctx, "torture:ldap_basedn", ""); lp_set_cmdline(lp_ctx, "torture:ldap_secret", ""); return; } basedn = strndup(d, p - d); lp_set_cmdline(lp_ctx, "torture:ldap_basedn", basedn); /* retrieve the secret */ p = p + 1; if (!p) { lp_set_cmdline(lp_ctx, "torture:ldap_secret", ""); return; } secret = strdup(p); lp_set_cmdline(lp_ctx, "torture:ldap_secret", secret); printf ("%s - %s - %s\n", userdn, basedn, secret); }
static void run_shell(struct torture_context *tctx) { char *cline; int argc; const char **argv; int ret; while (1) { cline = smb_readline("torture> ", NULL, NULL); if (cline == NULL) return; ret = poptParseArgvString(cline, &argc, &argv); if (ret != 0) { fprintf(stderr, "Error parsing line\n"); continue; } if (!strcmp(argv[0], "quit")) { return; } else if (!strcmp(argv[0], "set")) { if (argc < 3) { fprintf(stderr, "Usage: set <variable> <value>\n"); } else { char *name = talloc_asprintf(NULL, "torture:%s", argv[1]); lp_set_cmdline(tctx->lp_ctx, name, argv[2]); talloc_free(name); } } else if (!strcmp(argv[0], "help")) { fprintf(stderr, "Available commands:\n" " help - This help command\n" " run - Run test\n" " set - Change variables\n" "\n"); } else if (!strcmp(argv[0], "run")) { if (argc < 2) { fprintf(stderr, "Usage: run TEST-NAME [OPTIONS...]\n"); } else { run_test(tctx, argv[1]); } } free(cline); } }
NET_API_STATUS libnetapi_init(struct libnetapi_ctx **context) { NET_API_STATUS ret; TALLOC_CTX *frame; if (stat_ctx && libnetapi_initialized) { *context = stat_ctx; return NET_API_STATUS_SUCCESS; } #if 0 talloc_enable_leak_report(); #endif frame = talloc_stackframe(); /* Case tables must be loaded before any string comparisons occour */ load_case_tables_library(); /* When libnetapi is invoked from an application, it does not * want to be swamped with level 10 debug messages, even if * this has been set for the server in smb.conf */ lp_set_cmdline("log level", "0"); setup_logging("libnetapi", DEBUG_STDERR); if (!lp_load(get_dyn_CONFIGFILE(), true, false, false, true)) { TALLOC_FREE(frame); fprintf(stderr, "error loading %s\n", get_dyn_CONFIGFILE() ); return W_ERROR_V(WERR_GENERAL_FAILURE); } init_names(); load_interfaces(); reopen_logs(); BlockSignals(True, SIGPIPE); ret = libnetapi_net_init(context); TALLOC_FREE(frame); return ret; }
static void popt_samba_callback(poptContext con, enum poptCallbackReason reason, const struct poptOption *opt, const char *arg, const void *data) { const char *pname; if (reason == POPT_CALLBACK_REASON_POST) { if (lp_configfile(cmdline_lp_ctx) == NULL) { lp_load_default(cmdline_lp_ctx); } /* Hook any 'every Samba program must do this, after * the smb.conf is setup' functions here */ return; } /* Find out basename of current program */ pname = strrchr_m(poptGetInvocationName(con),'/'); if (!pname) pname = poptGetInvocationName(con); else pname++; if (reason == POPT_CALLBACK_REASON_PRE) { cmdline_lp_ctx = loadparm_init(talloc_autofree_context()); /* Hook for 'almost the first thing to do in a samba program' here */ /* setup for panics */ fault_setup(poptGetInvocationName(con)); /* and logging */ setup_logging(pname, DEBUG_STDOUT); return; } switch(opt->val) { case OPT_LEAK_REPORT: talloc_enable_leak_report(); break; case OPT_LEAK_REPORT_FULL: talloc_enable_leak_report_full(); break; case OPT_OPTION: if (!lp_set_option(cmdline_lp_ctx, arg)) { fprintf(stderr, "Error setting option '%s'\n", arg); exit(1); } break; case 'd': lp_set_cmdline(cmdline_lp_ctx, "log level", arg); break; case OPT_DEBUG_STDERR: setup_logging(pname, DEBUG_STDERR); break; case 's': if (arg) { lp_load(cmdline_lp_ctx, arg); } break; case 'l': if (arg) { char *new_logfile = talloc_asprintf(NULL, "%s/log.%s", arg, pname); lp_set_cmdline(cmdline_lp_ctx, "log file", new_logfile); talloc_free(new_logfile); } break; } }
BOOL torture_rpc_scanner(struct torture_context *torture) { NTSTATUS status; struct dcerpc_pipe *p; TALLOC_CTX *mem_ctx, *loop_ctx; BOOL ret = True; const struct dcerpc_interface_list *l; const char *binding = torture_setting_string(torture, "binding", NULL); struct dcerpc_binding *b; mem_ctx = talloc_init("torture_rpc_scanner"); if (!binding) { talloc_free(mem_ctx); printf("You must supply a ncacn binding string\n"); return False; } status = dcerpc_parse_binding(mem_ctx, binding, &b); if (!NT_STATUS_IS_OK(status)) { talloc_free(mem_ctx); printf("Failed to parse binding '%s'\n", binding); return False; } for (l=librpc_dcerpc_pipes();l;l=l->next) { loop_ctx = talloc_named(mem_ctx, 0, "torture_rpc_scanner loop context"); /* some interfaces are not mappable */ if (l->table->num_calls == 0 || strcmp(l->table->name, "mgmt") == 0) { talloc_free(loop_ctx); continue; } printf("\nTesting pipe '%s'\n", l->table->name); if (b->transport == NCACN_IP_TCP) { status = dcerpc_epm_map_binding(mem_ctx, b, l->table, NULL); if (!NT_STATUS_IS_OK(status)) { printf("Failed to map port for uuid %s\n", GUID_string(loop_ctx, &l->table->syntax_id.uuid)); talloc_free(loop_ctx); continue; } } else { b->endpoint = talloc_strdup(b, l->table->name); } lp_set_cmdline("torture:binding", dcerpc_binding_string(mem_ctx, b)); status = torture_rpc_connection(loop_ctx, &p, &dcerpc_table_mgmt); if (!NT_STATUS_IS_OK(status)) { talloc_free(loop_ctx); ret = False; continue; } if (!test_inq_if_ids(p, mem_ctx, l->table)) { ret = False; } } return ret; }
/* test ping speed */ static bool test_ping_speed(struct torture_context *tctx) { struct tevent_context *ev; struct messaging_context *msg_client_ctx; struct messaging_context *msg_server_ctx; int ping_count = 0; int pong_count = 0; struct timeval tv; int timelimit = torture_setting_int(tctx, "timelimit", 10); uint32_t msg_ping, msg_exit; lp_set_cmdline(tctx->lp_ctx, "pid directory", "piddir.tmp"); ev = tctx->ev; msg_server_ctx = messaging_init(tctx, lp_messaging_path(tctx, tctx->lp_ctx), cluster_id(0, 1), lp_iconv_convenience(tctx->lp_ctx), ev); torture_assert(tctx, msg_server_ctx != NULL, "Failed to init ping messaging context"); messaging_register_tmp(msg_server_ctx, NULL, ping_message, &msg_ping); messaging_register_tmp(msg_server_ctx, tctx, exit_message, &msg_exit); msg_client_ctx = messaging_init(tctx, lp_messaging_path(tctx, tctx->lp_ctx), cluster_id(0, 2), lp_iconv_convenience(tctx->lp_ctx), ev); torture_assert(tctx, msg_client_ctx != NULL, "msg_client_ctx messaging_init() failed"); messaging_register_tmp(msg_client_ctx, &pong_count, pong_message, &msg_pong); tv = timeval_current(); torture_comment(tctx, "Sending pings for %d seconds\n", timelimit); while (timeval_elapsed(&tv) < timelimit) { DATA_BLOB data; NTSTATUS status1, status2; data.data = discard_const_p(uint8_t, "testing"); data.length = strlen((const char *)data.data); status1 = messaging_send(msg_client_ctx, cluster_id(0, 1), msg_ping, &data); status2 = messaging_send(msg_client_ctx, cluster_id(0, 1), msg_ping, NULL); torture_assert_ntstatus_ok(tctx, status1, "msg1 failed"); ping_count++; torture_assert_ntstatus_ok(tctx, status2, "msg2 failed"); ping_count++; while (ping_count > pong_count + 20) { event_loop_once(ev); } } torture_comment(tctx, "waiting for %d remaining replies (done %d)\n", ping_count - pong_count, pong_count); while (timeval_elapsed(&tv) < 30 && pong_count < ping_count) { event_loop_once(ev); } torture_comment(tctx, "sending exit\n"); messaging_send(msg_client_ctx, cluster_id(0, 1), msg_exit, NULL); torture_assert_int_equal(tctx, ping_count, pong_count, "ping test failed"); torture_comment(tctx, "ping rate of %.0f messages/sec\n", (ping_count+pong_count)/timeval_elapsed(&tv)); talloc_free(msg_client_ctx); talloc_free(msg_server_ctx); return true; }
int main(int argc, const char *argv[]) { int ret = 0; poptContext pc; /* static int show_all_parameters = 0; static char *new_local_machine = NULL; */ static const char *section_name = NULL; static char *parameter_name = NULL; static const char *cname; static const char *caddr; static int silent_mode = false; static int show_defaults = false; /* This must be an 'int', * as we take it as we pass * it's address as an int * pointer */ struct loadparm_context *lp_ctx; struct poptOption long_options[] = { POPT_AUTOHELP {"suppress-prompt", 0, POPT_ARG_NONE, &silent_mode, true, "Suppress prompt for enter"}, {"verbose", 'v', POPT_ARG_NONE, &show_defaults, true, "Show default options too"}, /* We need support for smb.conf macros before this will work again {"server", 'L',POPT_ARG_STRING, &new_local_machine, 0, "Set %%L macro to servername\n"}, */ /* These are harder to do with the new code structure {"show-all-parameters", '\0', POPT_ARG_NONE, &show_all_parameters, 1, "Show the parameters, type, possible values" }, */ {"section-name", '\0', POPT_ARG_STRING, §ion_name, 0, "Limit testparm to a named section" }, {"parameter-name", '\0', POPT_ARG_STRING, ¶meter_name, 0, "Limit testparm to a named parameter" }, {"client-name", '\0', POPT_ARG_STRING, &cname, 0, "Client DNS name for 'hosts allow' checking (should match reverse lookup)"}, {"client-ip", '\0', POPT_ARG_STRING, &caddr, 0, "Client IP address for 'hosts allow' checking"}, POPT_COMMON_SAMBA POPT_COMMON_VERSION { NULL } }; setup_logging(NULL, DEBUG_STDERR); pc = poptGetContext(NULL, argc, argv, long_options, POPT_CONTEXT_KEEP_FIRST); poptSetOtherOptionHelp(pc, "[OPTION...] [host-name] [host-ip]"); while(poptGetNextOpt(pc) != -1); /* if (show_all_parameters) { show_parameter_list(); exit(0); } */ if ( cname && ! caddr ) { printf ( "ERROR: For 'hosts allow' check you must specify both a DNS name and an IP address.\n" ); return(1); } /* We need support for smb.conf macros before this will work again if (new_local_machine) { set_local_machine_name(new_local_machine, True); } */ lp_ctx = cmdline_lp_ctx; /* We need this to force the output */ lp_set_cmdline(lp_ctx, "log level", "2"); fprintf(stderr, "Loaded smb config files from %s\n", lp_configfile(lp_ctx)); if (!lp_load(lp_ctx, lp_configfile(lp_ctx))) { fprintf(stderr,"Error loading services.\n"); return(1); } fprintf(stderr,"Loaded services file OK.\n"); ret = do_global_checks(lp_ctx); ret |= do_share_checks(lp_ctx, cname, caddr, silent_mode, show_defaults, section_name, parameter_name); return(ret); }
bool torture_samba3_badpath(struct torture_context *torture) { struct smbcli_state *cli_nt; struct smbcli_state *cli_dos; const char *fname = "test.txt"; const char *fname1 = "test1.txt"; const char *dirname = "testdir"; char *fpath; char *fpath1; int fnum; NTSTATUS status; bool ret = true; TALLOC_CTX *mem_ctx; bool nt_status_support; if (!(mem_ctx = talloc_init("torture_samba3_badpath"))) { d_printf("talloc_init failed\n"); return false; } nt_status_support = lp_nt_status_support(torture->lp_ctx); if (!lp_set_cmdline(torture->lp_ctx, "nt status support", "yes")) { printf("Could not set 'nt status support = yes'\n"); goto fail; } if (!torture_open_connection(&cli_nt, torture, 0)) { goto fail; } if (!lp_set_cmdline(torture->lp_ctx, "nt status support", "no")) { printf("Could not set 'nt status support = yes'\n"); goto fail; } if (!torture_open_connection(&cli_dos, torture, 1)) { goto fail; } if (!lp_set_cmdline(torture->lp_ctx, "nt status support", nt_status_support ? "yes":"no")) { printf("Could not reset 'nt status support = yes'"); goto fail; } smbcli_deltree(cli_nt->tree, dirname); status = smbcli_mkdir(cli_nt->tree, dirname); if (!NT_STATUS_IS_OK(status)) { d_printf("smbcli_mkdir failed: %s\n", nt_errstr(status)); ret = false; goto done; } status = smbcli_chkpath(cli_nt->tree, dirname); CHECK_STATUS(status, NT_STATUS_OK); status = smbcli_chkpath(cli_nt->tree, talloc_asprintf(mem_ctx, "%s\\bla", dirname)); CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); status = smbcli_chkpath(cli_dos->tree, talloc_asprintf(mem_ctx, "%s\\bla", dirname)); CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRbadpath)); status = smbcli_chkpath(cli_nt->tree, talloc_asprintf(mem_ctx, "%s\\bla\\blub", dirname)); CHECK_STATUS(status, NT_STATUS_OBJECT_PATH_NOT_FOUND); status = smbcli_chkpath(cli_dos->tree, talloc_asprintf(mem_ctx, "%s\\bla\\blub", dirname)); CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRbadpath)); if (!(fpath = talloc_asprintf(mem_ctx, "%s\\%s", dirname, fname))) { goto fail; } fnum = smbcli_open(cli_nt->tree, fpath, O_RDWR | O_CREAT, DENY_NONE); if (fnum == -1) { d_printf("Could not create file %s: %s\n", fpath, smbcli_errstr(cli_nt->tree)); goto fail; } smbcli_close(cli_nt->tree, fnum); if (!(fpath1 = talloc_asprintf(mem_ctx, "%s\\%s", dirname, fname1))) { goto fail; } fnum = smbcli_open(cli_nt->tree, fpath1, O_RDWR | O_CREAT, DENY_NONE); if (fnum == -1) { d_printf("Could not create file %s: %s\n", fpath1, smbcli_errstr(cli_nt->tree)); goto fail; } smbcli_close(cli_nt->tree, fnum); /* * Do a whole bunch of error code checks on chkpath */ status = smbcli_chkpath(cli_nt->tree, fpath); CHECK_STATUS(status, NT_STATUS_NOT_A_DIRECTORY); status = smbcli_chkpath(cli_dos->tree, fpath); CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRbadpath)); status = smbcli_chkpath(cli_nt->tree, ".."); CHECK_STATUS(status, NT_STATUS_OBJECT_PATH_SYNTAX_BAD); status = smbcli_chkpath(cli_dos->tree, ".."); CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRinvalidpath)); status = smbcli_chkpath(cli_nt->tree, "."); CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_INVALID); status = smbcli_chkpath(cli_dos->tree, "."); CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRbadpath)); status = smbcli_chkpath(cli_nt->tree, "\t"); CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_INVALID); status = smbcli_chkpath(cli_dos->tree, "\t"); CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRbadpath)); status = smbcli_chkpath(cli_nt->tree, "\t\\bla"); CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_INVALID); status = smbcli_chkpath(cli_dos->tree, "\t\\bla"); CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRbadpath)); status = smbcli_chkpath(cli_nt->tree, "<"); CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_INVALID); status = smbcli_chkpath(cli_dos->tree, "<"); CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRbadpath)); status = smbcli_chkpath(cli_nt->tree, "<\\bla"); CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_INVALID); status = smbcli_chkpath(cli_dos->tree, "<\\bla"); CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRbadpath)); /* * .... And the same gang against getatr. Note that the DOS error codes * differ.... */ status = smbcli_getatr(cli_nt->tree, fpath, NULL, NULL, NULL); CHECK_STATUS(status, NT_STATUS_OK); status = smbcli_getatr(cli_dos->tree, fpath, NULL, NULL, NULL); CHECK_STATUS(status, NT_STATUS_OK); status = smbcli_getatr(cli_nt->tree, "..", NULL, NULL, NULL); CHECK_STATUS(status, NT_STATUS_OBJECT_PATH_SYNTAX_BAD); status = smbcli_getatr(cli_dos->tree, "..", NULL, NULL, NULL); CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRinvalidpath)); status = smbcli_getatr(cli_nt->tree, ".", NULL, NULL, NULL); CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_INVALID); status = smbcli_getatr(cli_dos->tree, ".", NULL, NULL, NULL); CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRinvalidname)); status = smbcli_getatr(cli_nt->tree, "\t", NULL, NULL, NULL); CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_INVALID); status = smbcli_getatr(cli_dos->tree, "\t", NULL, NULL, NULL); CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRinvalidname)); status = smbcli_getatr(cli_nt->tree, "\t\\bla", NULL, NULL, NULL); CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_INVALID); status = smbcli_getatr(cli_dos->tree, "\t\\bla", NULL, NULL, NULL); CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRinvalidname)); status = smbcli_getatr(cli_nt->tree, "<", NULL, NULL, NULL); CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_INVALID); status = smbcli_getatr(cli_dos->tree, "<", NULL, NULL, NULL); CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRinvalidname)); status = smbcli_getatr(cli_nt->tree, "<\\bla", NULL, NULL, NULL); CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_INVALID); status = smbcli_getatr(cli_dos->tree, "<\\bla", NULL, NULL, NULL); CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRinvalidname)); /* Try the same set with openX. */ status = raw_smbcli_open(cli_nt->tree, "..", O_RDONLY, DENY_NONE, NULL); CHECK_STATUS(status, NT_STATUS_OBJECT_PATH_SYNTAX_BAD); status = raw_smbcli_open(cli_dos->tree, "..", O_RDONLY, DENY_NONE, NULL); CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRinvalidpath)); status = raw_smbcli_open(cli_nt->tree, ".", O_RDONLY, DENY_NONE, NULL); CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_INVALID); status = raw_smbcli_open(cli_dos->tree, ".", O_RDONLY, DENY_NONE, NULL); CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRinvalidname)); status = raw_smbcli_open(cli_nt->tree, "\t", O_RDONLY, DENY_NONE, NULL); CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_INVALID); status = raw_smbcli_open(cli_dos->tree, "\t", O_RDONLY, DENY_NONE, NULL); CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRinvalidname)); status = raw_smbcli_open(cli_nt->tree, "\t\\bla", O_RDONLY, DENY_NONE, NULL); CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_INVALID); status = raw_smbcli_open(cli_dos->tree, "\t\\bla", O_RDONLY, DENY_NONE, NULL); CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRinvalidname)); status = raw_smbcli_open(cli_nt->tree, "<", O_RDONLY, DENY_NONE, NULL); CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_INVALID); status = raw_smbcli_open(cli_dos->tree, "<", O_RDONLY, DENY_NONE, NULL); CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRinvalidname)); status = raw_smbcli_open(cli_nt->tree, "<\\bla", O_RDONLY, DENY_NONE, NULL); CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_INVALID); status = raw_smbcli_open(cli_dos->tree, "<\\bla", O_RDONLY, DENY_NONE, NULL); CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRinvalidname)); /* Let's test EEXIST error code mapping. */ status = raw_smbcli_open(cli_nt->tree, fpath, O_RDONLY | O_CREAT| O_EXCL, DENY_NONE, NULL); CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_COLLISION); status = raw_smbcli_open(cli_dos->tree, fpath, O_RDONLY | O_CREAT| O_EXCL, DENY_NONE, NULL); CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS,ERRfilexists)); status = raw_smbcli_t2open(cli_nt->tree, fpath, O_RDONLY | O_CREAT| O_EXCL, DENY_NONE, NULL); if (!NT_STATUS_EQUAL(status, NT_STATUS_EAS_NOT_SUPPORTED) || !torture_setting_bool(torture, "samba3", false)) { /* Against samba3, treat EAS_NOT_SUPPORTED as acceptable */ CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_COLLISION); } status = raw_smbcli_t2open(cli_dos->tree, fpath, O_RDONLY | O_CREAT| O_EXCL, DENY_NONE, NULL); if (!NT_STATUS_EQUAL(status, NT_STATUS_DOS(ERRDOS,ERReasnotsupported)) || !torture_setting_bool(torture, "samba3", false)) { /* Against samba3, treat EAS_NOT_SUPPORTED as acceptable */ CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS,ERRfilexists)); } status = raw_smbcli_ntcreate(cli_nt->tree, fpath, NULL); CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_COLLISION); status = raw_smbcli_ntcreate(cli_dos->tree, fpath, NULL); CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS,ERRfilexists)); /* Try the rename test. */ { union smb_rename io; memset(&io, '\0', sizeof(io)); io.rename.in.pattern1 = fpath1; io.rename.in.pattern2 = fpath; /* Try with SMBmv rename. */ status = smb_raw_rename(cli_nt->tree, &io); CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_COLLISION); status = smb_raw_rename(cli_dos->tree, &io); CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS,ERRrename)); /* Try with NT rename. */ io.generic.level = RAW_RENAME_NTRENAME; io.ntrename.in.old_name = fpath1; io.ntrename.in.new_name = fpath; io.ntrename.in.attrib = 0; io.ntrename.in.cluster_size = 0; io.ntrename.in.flags = RENAME_FLAG_RENAME; status = smb_raw_rename(cli_nt->tree, &io); CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_COLLISION); status = smb_raw_rename(cli_dos->tree, &io); CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS,ERRrename)); } goto done; fail: ret = false; done: if (cli_nt != NULL) { smbcli_deltree(cli_nt->tree, dirname); torture_close_connection(cli_nt); } if (cli_dos != NULL) { torture_close_connection(cli_dos); } talloc_free(mem_ctx); return ret; }
int main(int argc, const char *argv[]) { const char *config_file = get_dyn_CONFIGFILE(); int s; static int silent_mode = False; static int show_all_parameters = False; int ret = 0; poptContext pc; static char *parameter_name = NULL; static const char *section_name = NULL; const char *cname; const char *caddr; static int show_defaults; static int skip_logic_checks = 0; struct poptOption long_options[] = { POPT_AUTOHELP {"suppress-prompt", 's', POPT_ARG_VAL, &silent_mode, 1, "Suppress prompt for enter"}, {"verbose", 'v', POPT_ARG_NONE, &show_defaults, 1, "Show default options too"}, {"skip-logic-checks", 'l', POPT_ARG_NONE, &skip_logic_checks, 1, "Skip the global checks"}, {"show-all-parameters", '\0', POPT_ARG_VAL, &show_all_parameters, True, "Show the parameters, type, possible values" }, {"parameter-name", '\0', POPT_ARG_STRING, ¶meter_name, 0, "Limit testparm to a named parameter" }, {"section-name", '\0', POPT_ARG_STRING, §ion_name, 0, "Limit testparm to a named section" }, POPT_COMMON_VERSION POPT_COMMON_DEBUGLEVEL POPT_COMMON_OPTION POPT_TABLEEND }; TALLOC_CTX *frame = talloc_stackframe(); load_case_tables(); /* * Set the default debug level to 2. * Allow it to be overridden by the command line, * not by smb.conf. */ lp_set_cmdline("log level", "2"); pc = poptGetContext(NULL, argc, argv, long_options, POPT_CONTEXT_KEEP_FIRST); poptSetOtherOptionHelp(pc, "[OPTION...] <config-file> [host-name] [host-ip]"); while(poptGetNextOpt(pc) != -1); if (show_all_parameters) { show_parameter_list(); exit(0); } setup_logging(poptGetArg(pc), DEBUG_STDERR); if (poptPeekArg(pc)) config_file = poptGetArg(pc); cname = poptGetArg(pc); caddr = poptGetArg(pc); poptFreeContext(pc); if ( cname && ! caddr ) { printf ( "ERROR: You must specify both a machine name and an IP address.\n" ); ret = 1; goto done; } fprintf(stderr,"Load smb config files from %s\n",config_file); if (!lp_load_with_registry_shares(config_file,False,True,False,True)) { fprintf(stderr,"Error loading services.\n"); ret = 1; goto done; } fprintf(stderr,"Loaded services file OK.\n"); if (skip_logic_checks == 0) { ret = do_global_checks(); } for (s=0;s<1000;s++) { if (VALID_SNUM(s)) if (strlen(lp_servicename(talloc_tos(), s)) > 12) { fprintf(stderr, "WARNING: You have some share names that are longer than 12 characters.\n" ); fprintf(stderr, "These may not be accessible to some older clients.\n" ); fprintf(stderr, "(Eg. Windows9x, WindowsMe, and smbclient prior to Samba 3.0.)\n" ); break; } } for (s=0;s<1000;s++) { if (VALID_SNUM(s) && (skip_logic_checks == 0)) { do_per_share_checks(s); } } if (!section_name && !parameter_name) { fprintf(stderr, "Server role: %s\n\n", server_role_str(lp_server_role())); } if (!cname) { if (!silent_mode) { fprintf(stderr,"Press enter to see a dump of your service definitions\n"); fflush(stdout); getc(stdin); } if (parameter_name || section_name) { bool isGlobal = False; s = GLOBAL_SECTION_SNUM; if (!section_name) { section_name = GLOBAL_NAME; isGlobal = True; } else if ((isGlobal=!strwicmp(section_name, GLOBAL_NAME)) == 0 && (s=lp_servicenumber(section_name)) == -1) { fprintf(stderr,"Unknown section %s\n", section_name); ret = 1; goto done; } if (parameter_name) { if (!dump_a_parameter( s, parameter_name, stdout, isGlobal)) { fprintf(stderr,"Parameter %s unknown for section %s\n", parameter_name, section_name); ret = 1; goto done; } } else { if (isGlobal == True) lp_dump(stdout, show_defaults, 0); else lp_dump_one(stdout, show_defaults, s); } goto done; } lp_dump(stdout, show_defaults, lp_numservices()); } if(cname && caddr){ /* this is totally ugly, a real `quick' hack */ for (s=0;s<1000;s++) { if (VALID_SNUM(s)) { if (allow_access(lp_hosts_deny(-1), lp_hosts_allow(-1), cname, caddr) && allow_access(lp_hosts_deny(s), lp_hosts_allow(s), cname, caddr)) { fprintf(stderr,"Allow connection from %s (%s) to %s\n", cname,caddr,lp_servicename(talloc_tos(), s)); } else { fprintf(stderr,"Deny connection from %s (%s) to %s\n", cname,caddr,lp_servicename(talloc_tos(), s)); } } } } done: gfree_loadparm(); TALLOC_FREE(frame); return ret; }
int main(int argc, const char *argv[]) { int c; int profile_only = 0; bool show_processes, show_locks, show_shares; bool show_notify = false; poptContext pc; struct poptOption long_options[] = { POPT_AUTOHELP {"processes", 'p', POPT_ARG_NONE, NULL, 'p', "Show processes only" }, {"verbose", 'v', POPT_ARG_NONE, NULL, 'v', "Be verbose" }, {"locks", 'L', POPT_ARG_NONE, NULL, 'L', "Show locks only" }, {"shares", 'S', POPT_ARG_NONE, NULL, 'S', "Show shares only" }, {"notify", 'N', POPT_ARG_NONE, NULL, 'N', "Show notifies" }, {"user", 'u', POPT_ARG_STRING, &username, 'u', "Switch to user" }, {"brief", 'b', POPT_ARG_NONE, NULL, 'b', "Be brief" }, {"profile", 'P', POPT_ARG_NONE, NULL, 'P', "Do profiling" }, {"profile-rates", 'R', POPT_ARG_NONE, NULL, 'R', "Show call rates" }, {"byterange", 'B', POPT_ARG_NONE, NULL, 'B', "Include byte range locks"}, {"numeric", 'n', POPT_ARG_NONE, NULL, 'n', "Numeric uid/gid"}, {"fast", 'f', POPT_ARG_NONE, NULL, 'f', "Skip checks if processes still exist"}, POPT_COMMON_SAMBA POPT_TABLEEND }; TALLOC_CTX *frame = talloc_stackframe(); int ret = 0; struct messaging_context *msg_ctx = NULL; char *db_path; bool ok; sec_init(); smb_init_locale(); setup_logging(argv[0], DEBUG_STDERR); lp_set_cmdline("log level", "0"); if (getuid() != geteuid()) { d_printf("smbstatus should not be run setuid\n"); ret = 1; goto done; } if (getuid() != 0) { d_printf("smbstatus only works as root!\n"); ret = 1; goto done; } pc = poptGetContext(NULL, argc, argv, long_options, POPT_CONTEXT_KEEP_FIRST); while ((c = poptGetNextOpt(pc)) != -1) { switch (c) { case 'p': processes_only = true; break; case 'v': verbose = true; break; case 'L': locks_only = true; break; case 'S': shares_only = true; break; case 'N': show_notify = true; break; case 'b': brief = true; break; case 'u': Ucrit_addUid(nametouid(poptGetOptArg(pc))); break; case 'P': case 'R': profile_only = c; break; case 'B': show_brl = true; break; case 'n': numeric_only = true; break; case 'f': do_checks = false; break; } } /* setup the flags based on the possible combincations */ show_processes = !(shares_only || locks_only || profile_only) || processes_only; show_locks = !(shares_only || processes_only || profile_only) || locks_only; show_shares = !(processes_only || locks_only || profile_only) || shares_only; if ( username ) Ucrit_addUid( nametouid(username) ); if (verbose) { d_printf("using configfile = %s\n", get_dyn_CONFIGFILE()); } if (!lp_load_initial_only(get_dyn_CONFIGFILE())) { fprintf(stderr, "Can't load %s - run testparm to debug it\n", get_dyn_CONFIGFILE()); ret = -1; goto done; } /* * This implicitly initializes the global ctdbd connection, * usable by the db_open() calls further down. */ msg_ctx = messaging_init(NULL, samba_tevent_context_init(NULL)); if (msg_ctx == NULL) { fprintf(stderr, "messaging_init failed\n"); ret = -1; goto done; } if (!lp_load_global(get_dyn_CONFIGFILE())) { fprintf(stderr, "Can't load %s - run testparm to debug it\n", get_dyn_CONFIGFILE()); ret = -1; goto done; } switch (profile_only) { case 'P': /* Dump profile data */ ok = status_profile_dump(verbose); return ok ? 0 : 1; case 'R': /* Continuously display rate-converted data */ ok = status_profile_rates(verbose); return ok ? 0 : 1; default: break; } if ( show_processes ) { d_printf("\nSamba version %s\n",samba_version_string()); d_printf("%-7s %-12s %-12s %-41s %-17s %-20s %-21s\n", "PID", "Username", "Group", "Machine", "Protocol Version", "Encryption", "Signing"); d_printf("----------------------------------------------------------------------------------------------------------------------------------------\n"); sessionid_traverse_read(traverse_sessionid, frame); if (processes_only) { goto done; } } if ( show_shares ) { if (brief) { goto done; } d_printf("\n%-12s %-7s %-13s %-32s %-12s %-12s\n", "Service", "pid", "Machine", "Connected at", "Encryption", "Signing"); d_printf("---------------------------------------------------------------------------------------------\n"); connections_forall_read(traverse_connections, frame); d_printf("\n"); if ( shares_only ) { goto done; } } if ( show_locks ) { int result; struct db_context *db; db_path = lock_path("locking.tdb"); if (db_path == NULL) { d_printf("Out of memory - exiting\n"); ret = -1; goto done; } db = db_open(NULL, db_path, 0, TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH, O_RDONLY, 0, DBWRAP_LOCK_ORDER_1, DBWRAP_FLAG_NONE); if (!db) { d_printf("%s not initialised\n", db_path); d_printf("This is normal if an SMB client has never " "connected to your server.\n"); TALLOC_FREE(db_path); exit(0); } else { TALLOC_FREE(db); TALLOC_FREE(db_path); } if (!locking_init_readonly()) { d_printf("Can't initialise locking module - exiting\n"); ret = 1; goto done; } result = share_entry_forall(print_share_mode, NULL); if (result == 0) { d_printf("No locked files\n"); } else if (result < 0) { d_printf("locked file list truncated\n"); } d_printf("\n"); if (show_brl) { brl_forall(print_brl, NULL); } locking_end(); } if (show_notify) { struct notify_context *n; n = notify_init(talloc_tos(), msg_ctx, messaging_tevent_context(msg_ctx)); if (n == NULL) { goto done; } notify_walk(n, print_notify_rec, NULL); TALLOC_FREE(n); } done: TALLOC_FREE(frame); return ret; }
static void popt_common_callback(poptContext con, enum poptCallbackReason reason, const struct poptOption *opt, const char *arg, const void *data) { if (reason == POPT_CALLBACK_REASON_PRE) { set_logfile(con, get_dyn_LOGFILEBASE()); talloc_set_log_fn(popt_s3_talloc_log_fn); talloc_set_abort_fn(smb_panic); return; } if (reason == POPT_CALLBACK_REASON_POST) { if (PrintSambaVersionString) { printf( "Version %s\n", samba_version_string()); exit(0); } if (is_default_dyn_CONFIGFILE()) { if(getenv("SMB_CONF_PATH")) { set_dyn_CONFIGFILE(getenv("SMB_CONF_PATH")); } } /* Further 'every Samba program must do this' hooks here. */ return; } switch(opt->val) { case OPT_OPTION: if (!lp_set_option(arg)) { fprintf(stderr, "Error setting option '%s'\n", arg); exit(1); } break; case 'd': if (arg) { lp_set_cmdline("log level", arg); } break; case 'V': PrintSambaVersionString = True; break; case 'O': if (arg) { lp_do_parameter(-1, "socket options", arg); } break; case 's': if (arg) { set_dyn_CONFIGFILE(arg); } break; case 'n': if (arg) { lp_set_cmdline("netbios name", arg); } break; case 'l': if (arg) { set_logfile(con, arg); override_logfile = True; set_dyn_LOGFILEBASE(arg); } break; case 'i': if (arg) { lp_set_cmdline("netbios scope", arg); } break; case 'W': if (arg) { lp_set_cmdline("workgroup", arg); } break; } }
/**************************************************************************** main program ****************************************************************************/ int main(int argc, const char **argv) { int opt,i; char *p; int rc = 0; int argc_new = 0; const char ** argv_new; poptContext pc; TALLOC_CTX *frame = talloc_stackframe(); struct net_context *c = talloc_zero(frame, struct net_context); struct poptOption long_options[] = { {"help", 'h', POPT_ARG_NONE, 0, 'h'}, {"workgroup", 'w', POPT_ARG_STRING, &c->opt_target_workgroup}, {"user", 'U', POPT_ARG_STRING, &c->opt_user_name, 'U'}, {"ipaddress", 'I', POPT_ARG_STRING, 0,'I'}, {"port", 'p', POPT_ARG_INT, &c->opt_port}, {"myname", 'n', POPT_ARG_STRING, &c->opt_requester_name}, {"server", 'S', POPT_ARG_STRING, &c->opt_host}, {"encrypt", 'e', POPT_ARG_NONE, NULL, 'e', N_("Encrypt SMB transport (UNIX extended servers only)") }, {"container", 'c', POPT_ARG_STRING, &c->opt_container}, {"comment", 'C', POPT_ARG_STRING, &c->opt_comment}, {"maxusers", 'M', POPT_ARG_INT, &c->opt_maxusers}, {"flags", 'F', POPT_ARG_INT, &c->opt_flags}, {"long", 'l', POPT_ARG_NONE, &c->opt_long_list_entries}, {"reboot", 'r', POPT_ARG_NONE, &c->opt_reboot}, {"force", 'f', POPT_ARG_NONE, &c->opt_force}, {"stdin", 'i', POPT_ARG_NONE, &c->opt_stdin}, {"timeout", 't', POPT_ARG_INT, &c->opt_timeout}, {"request-timeout",0,POPT_ARG_INT, &c->opt_request_timeout}, {"machine-pass",'P', POPT_ARG_NONE, &c->opt_machine_pass}, {"kerberos", 'k', POPT_ARG_NONE, &c->opt_kerberos}, {"myworkgroup", 'W', POPT_ARG_STRING, &c->opt_workgroup}, {"use-ccache", 0, POPT_ARG_NONE, &c->opt_ccache}, {"verbose", 'v', POPT_ARG_NONE, &c->opt_verbose}, {"test", 'T', POPT_ARG_NONE, &c->opt_testmode}, /* Options for 'net groupmap set' */ {"local", 'L', POPT_ARG_NONE, &c->opt_localgroup}, {"domain", 'D', POPT_ARG_NONE, &c->opt_domaingroup}, {"ntname", 'N', POPT_ARG_STRING, &c->opt_newntname}, {"rid", 'R', POPT_ARG_INT, &c->opt_rid}, /* Options for 'net rpc share migrate' */ {"acls", 0, POPT_ARG_NONE, &c->opt_acls}, {"attrs", 0, POPT_ARG_NONE, &c->opt_attrs}, {"timestamps", 0, POPT_ARG_NONE, &c->opt_timestamps}, {"exclude", 'X', POPT_ARG_STRING, &c->opt_exclude}, {"destination", 0, POPT_ARG_STRING, &c->opt_destination}, {"tallocreport", 0, POPT_ARG_NONE, &c->do_talloc_report}, /* Options for 'net rpc vampire (keytab)' */ {"force-full-repl", 0, POPT_ARG_NONE, &c->opt_force_full_repl}, {"single-obj-repl", 0, POPT_ARG_NONE, &c->opt_single_obj_repl}, {"clean-old-entries", 0, POPT_ARG_NONE, &c->opt_clean_old_entries}, /* Options for 'net idmap'*/ {"db", 0, POPT_ARG_STRING, &c->opt_db}, {"lock", 0, POPT_ARG_NONE, &c->opt_lock}, {"auto", 'a', POPT_ARG_NONE, &c->opt_auto}, {"repair", 0, POPT_ARG_NONE, &c->opt_repair}, /* Options for 'net registry check'*/ {"reg-version", 0, POPT_ARG_INT, &c->opt_reg_version}, {"output", 'o', POPT_ARG_STRING, &c->opt_output}, {"wipe", 0, POPT_ARG_NONE, &c->opt_wipe}, POPT_COMMON_SAMBA { 0, 0, 0, 0} }; zero_sockaddr(&c->opt_dest_ip); setup_logging(argv[0], DEBUG_STDERR); load_case_tables(); setlocale(LC_ALL, ""); #if defined(HAVE_BINDTEXTDOMAIN) bindtextdomain(MODULE_NAME, get_dyn_LOCALEDIR()); #endif #if defined(HAVE_TEXTDOMAIN) textdomain(MODULE_NAME); #endif /* set default debug level to 0 regardless of what smb.conf sets */ lp_set_cmdline("log level", "0"); c->private_data = net_func; pc = poptGetContext(NULL, argc, (const char **) argv, long_options, POPT_CONTEXT_KEEP_FIRST); while((opt = poptGetNextOpt(pc)) != -1) { switch (opt) { case 'h': c->display_usage = true; break; case 'e': c->smb_encrypt = true; break; case 'I': if (!interpret_string_addr(&c->opt_dest_ip, poptGetOptArg(pc), 0)) { d_fprintf(stderr, _("\nInvalid ip address specified\n")); } else { c->opt_have_ip = true; } break; case 'U': c->opt_user_specified = true; c->opt_user_name = SMB_STRDUP(c->opt_user_name); p = strchr(c->opt_user_name,'%'); if (p) { *p = 0; c->opt_password = p+1; } break; default: d_fprintf(stderr, _("\nInvalid option %s: %s\n"), poptBadOption(pc, 0), poptStrerror(opt)); net_help(c, argc, argv); exit(1); } } lp_load_global(get_dyn_CONFIGFILE()); #if defined(HAVE_BIND_TEXTDOMAIN_CODESET) /* Bind our gettext results to 'unix charset' This ensures that the translations and any embedded strings are in the same charset. It won't be the one from the user's locale (we no longer auto-detect that), but it will be self-consistent. */ bind_textdomain_codeset(MODULE_NAME, lp_unix_charset()); #endif argv_new = (const char **)poptGetArgs(pc); argc_new = argc; for (i=0; i<argc; i++) { if (argv_new[i] == NULL) { argc_new = i; break; } } if (c->do_talloc_report) { talloc_enable_leak_report(); } if (c->opt_requester_name) { lp_set_cmdline("netbios name", c->opt_requester_name); } if (!c->opt_user_name && getenv("LOGNAME")) { c->opt_user_name = getenv("LOGNAME"); } if (!c->opt_workgroup) { c->opt_workgroup = smb_xstrdup(lp_workgroup()); } if (!c->opt_target_workgroup) { c->opt_target_workgroup = smb_xstrdup(lp_workgroup()); } if (!init_names()) exit(1); load_interfaces(); /* this makes sure that when we do things like call scripts, that it won't assert because we are not root */ sec_init(); if (c->opt_machine_pass) { /* it is very useful to be able to make ads queries as the machine account for testing purposes and for domain leave */ net_use_krb_machine_account(c); } if (!c->opt_password) { c->opt_password = getenv("PASSWD"); } /* Failing to init the msg_ctx isn't a fatal error. Only root-level things (joining/leaving domains etc.) will be denied. */ c->msg_ctx = messaging_init(c, procid_self(), event_context_init(c)); rc = net_run_function(c, argc_new-1, argv_new+1, "net", net_func); DEBUG(2,("return code = %d\n", rc)); gencache_stabilize(); libnetapi_free(c->netapi_ctx); poptFreeContext(pc); TALLOC_FREE(frame); return rc; }
int main(int argc, const char **argv) { struct tevent_context *evt_ctx; struct messaging_context *msg_ctx; struct db_context *db; uint16_t count; const char *dbname; const char *opname; dbwrap_op op; const char *keyname = ""; const char *keytype = "int32"; dbwrap_type type; const char *valuestr = "0"; int32_t value = 0; TALLOC_CTX *mem_ctx = talloc_stackframe(); int ret = 1; load_case_tables(); lp_set_cmdline("log level", "0"); setup_logging(argv[0], DEBUG_STDERR); lp_load(get_dyn_CONFIGFILE(), true, false, false, true); if ((argc < 3) || (argc > 6)) { d_fprintf(stderr, "USAGE: %s <database> <op> [<key> [<type> [<value>]]]\n" " ops: fetch, store, delete, erase, listkeys\n" " types: int32, uint32\n", argv[0]); goto done; } dbname = argv[1]; opname = argv[2]; if (strcmp(opname, "store") == 0) { if (argc != 6) { d_fprintf(stderr, "ERROR: operation 'store' requires " "value argument\n"); goto done; } valuestr = argv[5]; keytype = argv[4]; keyname = argv[3]; op = OP_STORE; } else if (strcmp(opname, "fetch") == 0) { if (argc != 5) { d_fprintf(stderr, "ERROR: operation 'fetch' requires " "type but not value argument\n"); goto done; } op = OP_FETCH; keytype = argv[4]; keyname = argv[3]; } else if (strcmp(opname, "delete") == 0) { if (argc != 4) { d_fprintf(stderr, "ERROR: operation 'delete' does " "not allow type nor value argument\n"); goto done; } keyname = argv[3]; op = OP_DELETE; } else if (strcmp(opname, "erase") == 0) { if (argc != 3) { d_fprintf(stderr, "ERROR: operation 'erase' does " "not take a key argument\n"); goto done; } op = OP_ERASE; } else if (strcmp(opname, "listkeys") == 0) { if (argc != 3) { d_fprintf(stderr, "ERROR: operation 'listkeys' does " "not take a key argument\n"); goto done; } op = OP_LISTKEYS; } else { d_fprintf(stderr, "ERROR: invalid op '%s' specified\n" " supported ops: fetch, store, delete\n", opname); goto done; } if (strcmp(keytype, "int32") == 0) { type = TYPE_INT32; value = (int32_t)strtol(valuestr, NULL, 10); } else if (strcmp(keytype, "uint32") == 0) { type = TYPE_UINT32; value = (int32_t)strtoul(valuestr, NULL, 10); } else { d_fprintf(stderr, "ERROR: invalid type '%s' specified.\n" " supported types: int32, uint32\n", keytype); goto done; } evt_ctx = tevent_context_init(mem_ctx); if (evt_ctx == NULL) { d_fprintf(stderr, "ERROR: could not init event context\n"); goto done; } msg_ctx = messaging_init(mem_ctx, procid_self(), evt_ctx); if (msg_ctx == NULL) { d_fprintf(stderr, "ERROR: could not init messaging context\n"); goto done; } db = db_open(mem_ctx, dbname, 0, TDB_DEFAULT, O_RDWR | O_CREAT, 0644); if (db == NULL) { d_fprintf(stderr, "ERROR: could not open dbname\n"); goto done; } for (count = 0; dispatch_table[count].cmd != NULL; count++) { if ((op == dispatch_table[count].op) && (type == dispatch_table[count].type)) { ret = dispatch_table[count].cmd(db, keyname, &value); break; } } done: TALLOC_FREE(mem_ctx); return ret; }
/**************************************************************************** main program ****************************************************************************/ int main(int argc,char *argv[]) { char *share[NSERVERS]; int opt; int seed, server; int username_count=0; struct tevent_context *ev; struct loadparm_context *lp_ctx; poptContext pc; int argc_new, i; char **argv_new; enum {OPT_UNCLIST=1000}; struct poptOption long_options[] = { POPT_AUTOHELP {"seed", 0, POPT_ARG_INT, &seed, 0, "Seed to use for randomizer", NULL}, {"num-ops", 0, POPT_ARG_INT, &numops, 0, "num ops", NULL}, {"lockrange", 0, POPT_ARG_INT, &lock_range,0, "locking range", NULL}, {"lockbase", 0, POPT_ARG_INT, &lock_base, 0, "locking base", NULL}, {"minlength", 0, POPT_ARG_INT, &min_length,0, "min lock length", NULL}, {"hidefails", 0, POPT_ARG_NONE, &hide_unlock_fails,0,"hide unlock fails", NULL}, {"oplocks", 0, POPT_ARG_NONE, &use_oplocks,0, "use oplocks", NULL}, {"showall", 0, POPT_ARG_NONE, &showall, 0, "display all operations", NULL}, {"analyse", 0, POPT_ARG_NONE, &analyze, 0, "do backtrack analysis", NULL}, {"zerozero", 0, POPT_ARG_NONE, &zero_zero, 0, "do zero/zero lock", NULL}, {"exacterrors", 0, POPT_ARG_NONE, &exact_error_codes,0,"use exact error codes", NULL}, {"unclist", 0, POPT_ARG_STRING, NULL, OPT_UNCLIST, "unclist", NULL}, { "user", 'U', POPT_ARG_STRING, NULL, 'U', "Set the network username", "[DOMAIN/]USERNAME[%PASSWORD]" }, POPT_COMMON_SAMBA POPT_COMMON_CONNECTION POPT_COMMON_CREDENTIALS POPT_COMMON_VERSION { NULL } }; setlinebuf(stdout); seed = time(NULL); pc = poptGetContext("locktest", argc, (const char **) argv, long_options, POPT_CONTEXT_KEEP_FIRST); poptSetOtherOptionHelp(pc, "<unc1> <unc2>"); lp_ctx = cmdline_lp_ctx; servers[0] = cli_credentials_init(talloc_autofree_context()); servers[1] = cli_credentials_init(talloc_autofree_context()); cli_credentials_guess(servers[0], lp_ctx); cli_credentials_guess(servers[1], lp_ctx); while((opt = poptGetNextOpt(pc)) != -1) { switch (opt) { case OPT_UNCLIST: lp_set_cmdline(cmdline_lp_ctx, "torture:unclist", poptGetOptArg(pc)); break; case 'U': if (username_count == 2) { usage(pc); exit(1); } cli_credentials_parse_string(servers[username_count], poptGetOptArg(pc), CRED_SPECIFIED); username_count++; break; } } argv_new = discard_const_p(char *, poptGetArgs(pc)); argc_new = argc; for (i=0; i<argc; i++) { if (argv_new[i] == NULL) { argc_new = i; break; } } if (!(argc_new >= 3)) { usage(pc); exit(1); } setup_logging("locktest", DEBUG_STDOUT); for (server=0;server<NSERVERS;server++) { share[server] = argv_new[1+server]; all_string_sub(share[server],"/","\\",0); } lp_ctx = cmdline_lp_ctx; if (username_count == 0) { usage(pc); return -1; } if (username_count == 1) { servers[1] = servers[0]; } ev = s4_event_context_init(talloc_autofree_context()); gensec_init(lp_ctx); DEBUG(0,("seed=%u base=%d range=%d min_length=%d\n", seed, lock_base, lock_range, min_length)); srandom(seed); return test_locks(ev, lp_ctx, NULL, share); }
int main(int argc, const char **argv) { poptContext pc; int opt; struct tevent_context *evt_ctx; struct messaging_context *msg_ctx; static struct poptOption long_options[] = { /* POPT_AUTOHELP */ { NULL, '\0', POPT_ARG_INCLUDE_TABLE, help_options, 0, "Help options:", NULL }, { "timeout", 't', POPT_ARG_INT, &timeout, 't', "Set timeout value in seconds", "TIMEOUT" }, POPT_COMMON_SAMBA POPT_TABLEEND }; TALLOC_CTX *frame = talloc_stackframe(); int ret = 0; smb_init_locale(); setup_logging(argv[0], DEBUG_STDOUT); lp_set_cmdline("log level", "0"); /* Parse command line arguments using popt */ pc = poptGetContext( "smbcontrol", argc, (const char **)argv, long_options, 0); poptSetOtherOptionHelp(pc, "[OPTION...] <destination> <message-type> " "<parameters>"); if (argc == 1) usage(pc); while ((opt = poptGetNextOpt(pc)) != -1) { switch(opt) { case 't': /* --timeout */ break; default: fprintf(stderr, "Invalid option\n"); poptPrintHelp(pc, stderr, 0); break; } } /* We should now have the remaining command line arguments in argv. The argc parameter should have been decremented to the correct value in the above switch statement. */ argv = (const char **)poptGetArgs(pc); argc = 0; if (argv != NULL) { while (argv[argc] != NULL) { argc++; } } if (argc <= 1) usage(pc); lp_load_global(get_dyn_CONFIGFILE()); /* Need to invert sense of return code -- samba * routines mostly return True==1 for success, but * shell needs 0. */ if (!(evt_ctx = samba_tevent_context_init(NULL)) || !(msg_ctx = messaging_init(NULL, evt_ctx))) { fprintf(stderr, "could not init messaging context\n"); TALLOC_FREE(frame); exit(1); } ret = !do_command(evt_ctx, msg_ctx, argc, argv); TALLOC_FREE(msg_ctx); TALLOC_FREE(frame); return ret; }
int main(int argc, const char **argv) { struct tevent_context *evt_ctx; struct messaging_context *msg_ctx; struct db_context *db; uint16_t count; const char *dbname; const char *opname; enum dbwrap_op op; const char *keyname = ""; const char *keytype = "int32"; enum dbwrap_type type; const char *valuestr = "0"; int persistent = 0; int non_persistent = 0; int tdb_flags = TDB_DEFAULT; TALLOC_CTX *mem_ctx = talloc_stackframe(); int ret = 1; struct poptOption popt_options[] = { POPT_AUTOHELP POPT_COMMON_SAMBA { "non-persistent", 0, POPT_ARG_NONE, &non_persistent, 0, "treat the database as non-persistent " "(CAVEAT: This mode might wipe your database!)", NULL }, { "persistent", 0, POPT_ARG_NONE, &persistent, 0, "treat the database as persistent", NULL }, POPT_TABLEEND }; int opt; const char **extra_argv; int extra_argc = 0; poptContext pc; smb_init_locale(); lp_set_cmdline("log level", "0"); setup_logging(argv[0], DEBUG_STDERR); pc = poptGetContext(argv[0], argc, argv, popt_options, POPT_CONTEXT_KEEP_FIRST); while ((opt = poptGetNextOpt(pc)) != -1) { switch (opt) { default: fprintf(stderr, "Invalid option %s: %s\n", poptBadOption(pc, 0), poptStrerror(opt)); goto done; } } /* setup the remaining options for the main program to use */ extra_argv = poptGetArgs(pc); if (extra_argv) { extra_argv++; while (extra_argv[extra_argc]) extra_argc++; } lp_load_global(get_dyn_CONFIGFILE()); if ((extra_argc < 2) || (extra_argc > 5)) { d_fprintf(stderr, "USAGE: %s [options] <database> <op> [<key> [<type> " "[<value>]]]\n" " ops: fetch, store, delete, exists, " "erase, listkeys, listwatchers\n" " types: int32, uint32, string, hex\n", argv[0]); goto done; } if ((persistent == 0 && non_persistent == 0) || (persistent == 1 && non_persistent == 1)) { d_fprintf(stderr, "ERROR: you must specify exactly one " "of --persistent and --non-persistent\n"); goto done; } else if (non_persistent == 1) { tdb_flags |= TDB_CLEAR_IF_FIRST; } dbname = extra_argv[0]; opname = extra_argv[1]; if (strcmp(opname, "store") == 0) { if (extra_argc != 5) { d_fprintf(stderr, "ERROR: operation 'store' requires " "value argument\n"); goto done; } valuestr = extra_argv[4]; keytype = extra_argv[3]; keyname = extra_argv[2]; op = OP_STORE; } else if (strcmp(opname, "fetch") == 0) { if (extra_argc != 4) { d_fprintf(stderr, "ERROR: operation 'fetch' requires " "type but not value argument\n"); goto done; } op = OP_FETCH; keytype = extra_argv[3]; keyname = extra_argv[2]; } else if (strcmp(opname, "delete") == 0) { if (extra_argc != 3) { d_fprintf(stderr, "ERROR: operation 'delete' does " "not allow type nor value argument\n"); goto done; } keyname = extra_argv[2]; op = OP_DELETE; } else if (strcmp(opname, "erase") == 0) { if (extra_argc != 2) { d_fprintf(stderr, "ERROR: operation 'erase' does " "not take a key argument\n"); goto done; } op = OP_ERASE; } else if (strcmp(opname, "listkeys") == 0) { if (extra_argc != 2) { d_fprintf(stderr, "ERROR: operation 'listkeys' does " "not take a key argument\n"); goto done; } op = OP_LISTKEYS; } else if (strcmp(opname, "exists") == 0) { if (extra_argc != 3) { d_fprintf(stderr, "ERROR: operation 'exists' does " "not allow type nor value argument\n"); goto done; } keyname = extra_argv[2]; op = OP_EXISTS; keytype = "string"; } else { d_fprintf(stderr, "ERROR: invalid op '%s' specified\n" " supported ops: fetch, store, delete, exists, " "erase, listkeys, listwatchers\n", opname); goto done; } if (strcmp(keytype, "int32") == 0) { type = TYPE_INT32; } else if (strcmp(keytype, "uint32") == 0) { type = TYPE_UINT32; } else if (strcmp(keytype, "string") == 0) { type = TYPE_STRING; } else if (strcmp(keytype, "hex") == 0) { type = TYPE_HEX; } else if (strcmp(keytype, "none") == 0) { type = TYPE_NONE; } else { d_fprintf(stderr, "ERROR: invalid type '%s' specified.\n" " supported types: int32, uint32, " "string, hex, none\n", keytype); goto done; } evt_ctx = samba_tevent_context_init(mem_ctx); if (evt_ctx == NULL) { d_fprintf(stderr, "ERROR: could not init event context\n"); goto done; } msg_ctx = messaging_init(mem_ctx, evt_ctx); if (msg_ctx == NULL) { d_fprintf(stderr, "ERROR: could not init messaging context\n"); goto done; } switch (op) { case OP_FETCH: case OP_STORE: case OP_DELETE: case OP_ERASE: case OP_LISTKEYS: case OP_EXISTS: db = db_open(mem_ctx, dbname, 0, tdb_flags, O_RDWR | O_CREAT, 0644, DBWRAP_LOCK_ORDER_1, DBWRAP_FLAG_NONE); if (db == NULL) { d_fprintf(stderr, "ERROR: could not open dbname\n"); goto done; } break; default: db = NULL; break; } for (count = 0; dispatch_table[count].cmd != NULL; count++) { if ((op == dispatch_table[count].op) && (type == dispatch_table[count].type)) { ret = dispatch_table[count].cmd(db, keyname, valuestr); break; } } done: TALLOC_FREE(mem_ctx); return ret; }
int main(int argc, const char **argv) { struct tevent_context *evt_ctx; struct messaging_context *msg_ctx; struct db_context *db; uint16_t count; const char *dbname; const char *opname; dbwrap_op op; const char *keyname = ""; const char *keytype = "int32"; dbwrap_type type; const char *valuestr = "0"; TALLOC_CTX *mem_ctx = talloc_stackframe(); int ret = 1; struct poptOption popt_options[] = { POPT_AUTOHELP POPT_COMMON_SAMBA POPT_TABLEEND }; int opt; const char **extra_argv; int extra_argc = 0; poptContext pc; load_case_tables(); lp_set_cmdline("log level", "0"); setup_logging(argv[0], DEBUG_STDERR); pc = poptGetContext(argv[0], argc, argv, popt_options, POPT_CONTEXT_KEEP_FIRST); while ((opt = poptGetNextOpt(pc)) != -1) { switch (opt) { default: fprintf(stderr, "Invalid option %s: %s\n", poptBadOption(pc, 0), poptStrerror(opt)); goto done; } } /* setup the remaining options for the main program to use */ extra_argv = poptGetArgs(pc); if (extra_argv) { extra_argv++; while (extra_argv[extra_argc]) extra_argc++; } lp_load_global(get_dyn_CONFIGFILE()); if ((extra_argc < 2) || (extra_argc > 5)) { d_fprintf(stderr, "USAGE: %s <database> <op> [<key> [<type> [<value>]]]\n" " ops: fetch, store, delete, erase, listkeys\n" " types: int32, uint32, string, hex\n", argv[0]); goto done; } dbname = extra_argv[0]; opname = extra_argv[1]; if (strcmp(opname, "store") == 0) { if (extra_argc != 5) { d_fprintf(stderr, "ERROR: operation 'store' requires " "value argument\n"); goto done; } valuestr = extra_argv[4]; keytype = extra_argv[3]; keyname = extra_argv[2]; op = OP_STORE; } else if (strcmp(opname, "fetch") == 0) { if (extra_argc != 4) { d_fprintf(stderr, "ERROR: operation 'fetch' requires " "type but not value argument\n"); goto done; } op = OP_FETCH; keytype = extra_argv[3]; keyname = extra_argv[2]; } else if (strcmp(opname, "delete") == 0) { if (extra_argc != 3) { d_fprintf(stderr, "ERROR: operation 'delete' does " "not allow type nor value argument\n"); goto done; } keyname = extra_argv[2]; op = OP_DELETE; } else if (strcmp(opname, "erase") == 0) { if (extra_argc != 2) { d_fprintf(stderr, "ERROR: operation 'erase' does " "not take a key argument\n"); goto done; } op = OP_ERASE; } else if (strcmp(opname, "listkeys") == 0) { if (extra_argc != 2) { d_fprintf(stderr, "ERROR: operation 'listkeys' does " "not take a key argument\n"); goto done; } op = OP_LISTKEYS; } else { d_fprintf(stderr, "ERROR: invalid op '%s' specified\n" " supported ops: fetch, store, delete\n", opname); goto done; } if (strcmp(keytype, "int32") == 0) { type = TYPE_INT32; } else if (strcmp(keytype, "uint32") == 0) { type = TYPE_UINT32; } else if (strcmp(keytype, "string") == 0) { type = TYPE_STRING; } else if (strcmp(keytype, "hex") == 0) { type = TYPE_HEX; } else { d_fprintf(stderr, "ERROR: invalid type '%s' specified.\n" " supported types: int32, uint32, " "string, hex\n", keytype); goto done; } evt_ctx = tevent_context_init(mem_ctx); if (evt_ctx == NULL) { d_fprintf(stderr, "ERROR: could not init event context\n"); goto done; } msg_ctx = messaging_init(mem_ctx, evt_ctx); if (msg_ctx == NULL) { d_fprintf(stderr, "ERROR: could not init messaging context\n"); goto done; } db = db_open(mem_ctx, dbname, 0, TDB_DEFAULT, O_RDWR | O_CREAT, 0644); if (db == NULL) { d_fprintf(stderr, "ERROR: could not open dbname\n"); goto done; } for (count = 0; dispatch_table[count].cmd != NULL; count++) { if ((op == dispatch_table[count].op) && (type == dispatch_table[count].type)) { ret = dispatch_table[count].cmd(db, keyname, valuestr); break; } } done: TALLOC_FREE(mem_ctx); return ret; }
/**************************************************************************** main program ****************************************************************************/ int main(int argc,char *argv[]) { int opt, i; bool correct = true; int max_runtime=0; int argc_new; struct torture_context *torture; struct torture_results *results; const struct torture_ui_ops *ui_ops; char **argv_new; poptContext pc; static const char *target = "other"; NTSTATUS status; int shell = false; static const char *ui_ops_name = "subunit"; const char *basedir = NULL; const char *extra_module = NULL; static int list_tests = 0; int num_extra_users = 0; enum {OPT_LOADFILE=1000,OPT_UNCLIST,OPT_TIMELIMIT,OPT_DNS, OPT_LIST, OPT_DANGEROUS,OPT_SMB_PORTS,OPT_ASYNC,OPT_NUMPROGS, OPT_EXTRA_USER,}; struct poptOption long_options[] = { POPT_AUTOHELP {"format", 0, POPT_ARG_STRING, &ui_ops_name, 0, "Output format (one of: simple, subunit)", NULL }, {"smb-ports", 'p', POPT_ARG_STRING, NULL, OPT_SMB_PORTS, "SMB ports", NULL}, {"basedir", 0, POPT_ARG_STRING, &basedir, 0, "base directory", "BASEDIR" }, {"seed", 0, POPT_ARG_INT, &torture_seed, 0, "Seed to use for randomizer", NULL}, {"num-progs", 0, POPT_ARG_INT, NULL, OPT_NUMPROGS, "num progs", NULL}, {"num-ops", 0, POPT_ARG_INT, &torture_numops, 0, "num ops", NULL}, {"entries", 0, POPT_ARG_INT, &torture_entries, 0, "entries", NULL}, {"loadfile", 0, POPT_ARG_STRING, NULL, OPT_LOADFILE, "NBench load file to use", NULL}, {"list", 0, POPT_ARG_NONE, &list_tests, 0, "List available tests and exit", NULL }, {"unclist", 0, POPT_ARG_STRING, NULL, OPT_UNCLIST, "unclist", NULL}, {"timelimit", 't', POPT_ARG_INT, NULL, OPT_TIMELIMIT, "Set time limit (in seconds)", NULL}, {"failures", 'f', POPT_ARG_INT, &torture_failures, 0, "failures", NULL}, {"parse-dns", 'D', POPT_ARG_STRING, NULL, OPT_DNS, "parse-dns", NULL}, {"dangerous", 'X', POPT_ARG_NONE, NULL, OPT_DANGEROUS, "run dangerous tests (eg. wiping out password database)", NULL}, {"load-module", 0, POPT_ARG_STRING, &extra_module, 0, "load tests from DSO file", "SOFILE"}, {"shell", 0, POPT_ARG_NONE, &shell, true, "Run shell", NULL}, {"target", 'T', POPT_ARG_STRING, &target, 0, "samba3|samba4|other", NULL}, {"async", 'a', POPT_ARG_NONE, NULL, OPT_ASYNC, "run async tests", NULL}, {"num-async", 0, POPT_ARG_INT, &torture_numasync, 0, "number of simultaneous async requests", NULL}, {"maximum-runtime", 0, POPT_ARG_INT, &max_runtime, 0, "set maximum time for smbtorture to live", "seconds"}, {"extra-user", 0, POPT_ARG_STRING, NULL, OPT_EXTRA_USER, "extra user credentials", NULL}, POPT_COMMON_SAMBA POPT_COMMON_CONNECTION POPT_COMMON_CREDENTIALS POPT_COMMON_VERSION { NULL } }; setlinebuf(stdout); /* we are never interested in SIGPIPE */ BlockSignals(true, SIGPIPE); pc = poptGetContext("smbtorture", argc, (const char **) argv, long_options, POPT_CONTEXT_KEEP_FIRST); poptSetOtherOptionHelp(pc, "<binding>|<unc> TEST1 TEST2 ..."); while((opt = poptGetNextOpt(pc)) != -1) { switch (opt) { case OPT_LOADFILE: lp_set_cmdline(cmdline_lp_ctx, "torture:loadfile", poptGetOptArg(pc)); break; case OPT_UNCLIST: lp_set_cmdline(cmdline_lp_ctx, "torture:unclist", poptGetOptArg(pc)); break; case OPT_TIMELIMIT: lp_set_cmdline(cmdline_lp_ctx, "torture:timelimit", poptGetOptArg(pc)); break; case OPT_NUMPROGS: lp_set_cmdline(cmdline_lp_ctx, "torture:nprocs", poptGetOptArg(pc)); break; case OPT_DNS: parse_dns(cmdline_lp_ctx, poptGetOptArg(pc)); break; case OPT_DANGEROUS: lp_set_cmdline(cmdline_lp_ctx, "torture:dangerous", "Yes"); break; case OPT_ASYNC: lp_set_cmdline(cmdline_lp_ctx, "torture:async", "Yes"); break; case OPT_SMB_PORTS: lp_set_cmdline(cmdline_lp_ctx, "smb ports", poptGetOptArg(pc)); break; case OPT_EXTRA_USER: { char *option = talloc_asprintf(NULL, "torture:extra_user%u", ++num_extra_users); const char *value = poptGetOptArg(pc); lp_set_cmdline(cmdline_lp_ctx, option, value); talloc_free(option); } break; default: printf("bad command line option\n"); exit(1); } } if (strcmp(target, "samba3") == 0) { lp_set_cmdline(cmdline_lp_ctx, "torture:samba3", "true"); lp_set_cmdline(cmdline_lp_ctx, "torture:resume_key_support", "false"); } else if (strcmp(target, "samba4") == 0) { lp_set_cmdline(cmdline_lp_ctx, "torture:samba4", "true"); } else if (strcmp(target, "winxp") == 0) { lp_set_cmdline(cmdline_lp_ctx, "torture:winxp", "true"); } else if (strcmp(target, "w2k3") == 0) { lp_set_cmdline(cmdline_lp_ctx, "torture:w2k3", "true"); } else if (strcmp(target, "w2k8") == 0) { lp_set_cmdline(cmdline_lp_ctx, "torture:w2k8", "true"); lp_set_cmdline(cmdline_lp_ctx, "torture:invalid_lock_range_support", "false"); } else if (strcmp(target, "win7") == 0) { lp_set_cmdline(cmdline_lp_ctx, "torture:win7", "true"); lp_set_cmdline(cmdline_lp_ctx, "torture:cn_max_buffer_size", "0x00010000"); lp_set_cmdline(cmdline_lp_ctx, "torture:resume_key_support", "false"); lp_set_cmdline(cmdline_lp_ctx, "torture:rewind_support", "false"); /* RAW-SEARCH for fails for inexplicable reasons against win7 */ lp_set_cmdline(cmdline_lp_ctx, "torture:search_ea_support", "false"); lp_set_cmdline(cmdline_lp_ctx, "torture:hide_on_access_denied", "true"); } else if (strcmp(target, "onefs") == 0) { lp_set_cmdline(cmdline_lp_ctx, "torture:onefs", "true"); lp_set_cmdline(cmdline_lp_ctx, "torture:openx_deny_dos_support", "false"); lp_set_cmdline(cmdline_lp_ctx, "torture:sacl_support", "false"); lp_set_cmdline(cmdline_lp_ctx, "torture:ea_support", "false"); lp_set_cmdline(cmdline_lp_ctx, "torture:smblock_pdu_support", "false"); lp_set_cmdline(cmdline_lp_ctx, "torture:2_step_break_to_none", "true"); lp_set_cmdline(cmdline_lp_ctx, "torture:deny_dos_support", "false"); lp_set_cmdline(cmdline_lp_ctx, "torture:deny_fcb_support", "false"); lp_set_cmdline(cmdline_lp_ctx, "torture:read_support", "false"); lp_set_cmdline(cmdline_lp_ctx, "torture:writeclose_support", "false"); lp_set_cmdline(cmdline_lp_ctx, "torture:resume_key_support", "false"); lp_set_cmdline(cmdline_lp_ctx, "torture:rewind_support", "false"); } if (max_runtime) { /* this will only work if nobody else uses alarm(), which means it won't work for some tests, but we can't use the event context method we use for smbd as so many tests create their own event context. This will at least catch most cases. */ signal(SIGALRM, max_runtime_handler); alarm(max_runtime); } if (extra_module != NULL) { init_module_fn fn = load_module(talloc_autofree_context(), poptGetOptArg(pc)); if (fn == NULL) d_printf("Unable to load module from %s\n", poptGetOptArg(pc)); else { status = fn(); if (NT_STATUS_IS_ERR(status)) { d_printf("Error initializing module %s: %s\n", poptGetOptArg(pc), nt_errstr(status)); } } } else { torture_init(); } if (list_tests) { print_test_list(); return 0; } if (torture_seed == 0) { torture_seed = time(NULL); } printf("Using seed %d\n", torture_seed); srandom(torture_seed); argv_new = discard_const_p(char *, poptGetArgs(pc)); argc_new = argc; for (i=0; i<argc; i++) { if (argv_new[i] == NULL) { argc_new = i; break; } } if (!(argc_new >= 3 || (shell && argc_new >= 2))) { usage(pc); exit(1); } if (!parse_target(cmdline_lp_ctx, argv_new[1])) { usage(pc); exit(1); } if (!strcmp(ui_ops_name, "simple")) { ui_ops = &std_ui_ops; } else if (!strcmp(ui_ops_name, "subunit")) { ui_ops = &torture_subunit_ui_ops; } else { printf("Unknown output format '%s'\n", ui_ops_name); exit(1); } results = torture_results_init(talloc_autofree_context(), ui_ops); torture = torture_context_init(s4_event_context_init(NULL), results); if (basedir != NULL) { if (basedir[0] != '/') { fprintf(stderr, "Please specify an absolute path to --basedir\n"); return 1; } torture->outputdir = basedir; } else { char *pwd = talloc_size(torture, PATH_MAX); if (!getcwd(pwd, PATH_MAX)) { fprintf(stderr, "Unable to determine current working directory\n"); return 1; } torture->outputdir = pwd; } torture->lp_ctx = cmdline_lp_ctx; gensec_init(cmdline_lp_ctx); if (argc_new == 0) { printf("You must specify a test to run, or 'ALL'\n"); } else if (shell) { run_shell(torture); } else { for (i=2;i<argc_new;i++) { if (!run_test(torture, argv_new[i])) { correct = false; } } } if (torture->results->returncode && correct) { return(0); } else { return(1); } }
int main(int argc, const char **argv) { static int list_users = False; static int verbose = False; static int spstyle = False; static int machine = False; static int add_user = False; static int delete_user = False; static int modify_user = False; uint32_t setparms, checkparms; int opt; static char *full_name = NULL; static char *acct_desc = NULL; static const char *user_name = NULL; static char *home_dir = NULL; static char *home_drive = NULL; static const char *backend = NULL; static char *backend_in = NULL; static char *backend_out = NULL; static int transfer_groups = False; static int transfer_account_policies = False; static int reset_account_policies = False; static int force_initialised_password = False; static char *logon_script = NULL; static char *profile_path = NULL; static char *user_domain = NULL; static char *account_control = NULL; static char *account_policy = NULL; static char *user_sid = NULL; static char *machine_sid = NULL; static long int account_policy_value = 0; bool account_policy_value_set = False; static int badpw_reset = False; static int hours_reset = False; static char *pwd_time_format = NULL; static int pw_from_stdin = False; struct pdb_methods *bin, *bout; static char *kickoff_time = NULL; TALLOC_CTX *frame = talloc_stackframe(); NTSTATUS status; poptContext pc; struct poptOption long_options[] = { POPT_AUTOHELP {"list", 'L', POPT_ARG_NONE, &list_users, 0, "list all users", NULL}, {"verbose", 'v', POPT_ARG_NONE, &verbose, 0, "be verbose", NULL }, {"smbpasswd-style", 'w',POPT_ARG_NONE, &spstyle, 0, "give output in smbpasswd style", NULL}, {"user", 'u', POPT_ARG_STRING, &user_name, 0, "use username", "USER" }, {"account-desc", 'N', POPT_ARG_STRING, &acct_desc, 0, "set account description", NULL}, {"fullname", 'f', POPT_ARG_STRING, &full_name, 0, "set full name", NULL}, {"homedir", 'h', POPT_ARG_STRING, &home_dir, 0, "set home directory", NULL}, {"drive", 'D', POPT_ARG_STRING, &home_drive, 0, "set home drive", NULL}, {"script", 'S', POPT_ARG_STRING, &logon_script, 0, "set logon script", NULL}, {"profile", 'p', POPT_ARG_STRING, &profile_path, 0, "set profile path", NULL}, {"domain", 'I', POPT_ARG_STRING, &user_domain, 0, "set a users' domain", NULL}, {"user SID", 'U', POPT_ARG_STRING, &user_sid, 0, "set user SID or RID", NULL}, {"machine SID", 'M', POPT_ARG_STRING, &machine_sid, 0, "set machine SID or RID", NULL}, {"create", 'a', POPT_ARG_NONE, &add_user, 0, "create user", NULL}, {"modify", 'r', POPT_ARG_NONE, &modify_user, 0, "modify user", NULL}, {"machine", 'm', POPT_ARG_NONE, &machine, 0, "account is a machine account", NULL}, {"delete", 'x', POPT_ARG_NONE, &delete_user, 0, "delete user", NULL}, {"backend", 'b', POPT_ARG_STRING, &backend, 0, "use different passdb backend as default backend", NULL}, {"import", 'i', POPT_ARG_STRING, &backend_in, 0, "import user accounts from this backend", NULL}, {"export", 'e', POPT_ARG_STRING, &backend_out, 0, "export user accounts to this backend", NULL}, {"group", 'g', POPT_ARG_NONE, &transfer_groups, 0, "use -i and -e for groups", NULL}, {"policies", 'y', POPT_ARG_NONE, &transfer_account_policies, 0, "use -i and -e to move account policies between backends", NULL}, {"policies-reset", 0, POPT_ARG_NONE, &reset_account_policies, 0, "restore default policies", NULL}, {"account-policy", 'P', POPT_ARG_STRING, &account_policy, 0,"value of an account policy (like maximum password age)",NULL}, {"value", 'C', POPT_ARG_LONG, &account_policy_value, 'C',"set the account policy to this value", NULL}, {"account-control", 'c', POPT_ARG_STRING, &account_control, 0, "Values of account control", NULL}, {"force-initialized-passwords", 0, POPT_ARG_NONE, &force_initialised_password, 0, "Force initialization of corrupt password strings in a passdb backend", NULL}, {"bad-password-count-reset", 'z', POPT_ARG_NONE, &badpw_reset, 0, "reset bad password count", NULL}, {"logon-hours-reset", 'Z', POPT_ARG_NONE, &hours_reset, 0, "reset logon hours", NULL}, {"time-format", 0, POPT_ARG_STRING, &pwd_time_format, 0, "The time format for time parameters", NULL }, {"password-from-stdin", 't', POPT_ARG_NONE, &pw_from_stdin, 0, "get password from standard in", NULL}, {"kickoff-time", 'K', POPT_ARG_STRING, &kickoff_time, 0, "set the kickoff time", NULL}, POPT_COMMON_SAMBA POPT_TABLEEND }; bin = bout = NULL; smb_init_locale(); setup_logging("pdbedit", DEBUG_STDOUT); pc = poptGetContext(NULL, argc, argv, long_options, POPT_CONTEXT_KEEP_FIRST); while((opt = poptGetNextOpt(pc)) != -1) { switch (opt) { case 'C': account_policy_value_set = True; break; } } poptGetArg(pc); /* Drop argv[0], the program name */ if (user_name == NULL) user_name = poptGetArg(pc); if (!lp_load_global(get_dyn_CONFIGFILE())) { fprintf(stderr, "Can't load %s - run testparm to debug it\n", get_dyn_CONFIGFILE()); exit(1); } if (!init_names()) exit(1); setparms = (backend ? BIT_BACKEND : 0) + (verbose ? BIT_VERBOSE : 0) + (spstyle ? BIT_SPSTYLE : 0) + (full_name ? BIT_FULLNAME : 0) + (home_dir ? BIT_HOMEDIR : 0) + (home_drive ? BIT_HDIRDRIVE : 0) + (logon_script ? BIT_LOGSCRIPT : 0) + (profile_path ? BIT_PROFILE : 0) + (user_domain ? BIT_USERDOMAIN : 0) + (machine ? BIT_MACHINE : 0) + (user_name ? BIT_USER : 0) + (list_users ? BIT_LIST : 0) + (force_initialised_password ? BIT_FIX_INIT : 0) + (user_sid ? BIT_USERSIDS : 0) + (machine_sid ? BIT_USERSIDS : 0) + (modify_user ? BIT_MODIFY : 0) + (add_user ? BIT_CREATE : 0) + (delete_user ? BIT_DELETE : 0) + (account_control ? BIT_ACCTCTRL : 0) + (account_policy ? BIT_ACCPOLICY : 0) + (account_policy_value_set ? BIT_ACCPOLVAL : 0) + (backend_in ? BIT_IMPORT : 0) + (backend_out ? BIT_EXPORT : 0) + (badpw_reset ? BIT_BADPWRESET : 0) + (hours_reset ? BIT_LOGONHOURS : 0) + (kickoff_time ? BIT_KICKOFFTIME : 0) + (acct_desc ? BIT_DESCRIPTION : 0); if (setparms & BIT_BACKEND) { /* HACK: set the global passdb backend by overwriting globals. * This way we can use regular pdb functions for default * operations that do not involve passdb migrations */ lp_set_cmdline("passdb backend", backend); } else { backend = lp_passdb_backend(); } if (!initialize_password_db(False, NULL)) { fprintf(stderr, "Can't initialize passdb backend.\n"); exit(1); } /* the lowest bit options are always accepted */ checkparms = setparms & ~MASK_ALWAYS_GOOD; if (checkparms & BIT_FIX_INIT) { return fix_users_list(); } /* account policy operations */ if ((checkparms & BIT_ACCPOLICY) && !(checkparms & ~(BIT_ACCPOLICY + BIT_ACCPOLVAL))) { uint32_t value; enum pdb_policy_type field = account_policy_name_to_typenum(account_policy); if (field == 0) { const char **names; int count; int i; account_policy_names_list(talloc_tos(), &names, &count); fprintf(stderr, "No account policy by that name!\n"); if (count !=0) { fprintf(stderr, "Account policy names are:\n"); for (i = 0; i < count ; i++) { d_fprintf(stderr, "%s\n", names[i]); } } TALLOC_FREE(names); exit(1); } if (!pdb_get_account_policy(field, &value)) { fprintf(stderr, "valid account policy, but unable to fetch value!\n"); if (!account_policy_value_set) exit(1); } printf("account policy \"%s\" description: %s\n", account_policy, account_policy_get_desc(field)); if (account_policy_value_set) { printf("account policy \"%s\" value was: %u\n", account_policy, value); if (!pdb_set_account_policy(field, account_policy_value)) { fprintf(stderr, "valid account policy, but unable to set value!\n"); exit(1); } printf("account policy \"%s\" value is now: %lu\n", account_policy, account_policy_value); exit(0); } else { printf("account policy \"%s\" value is: %u\n", account_policy, value); exit(0); } } if (reset_account_policies) { if (reinit_account_policies()) { exit(1); } exit(0); } /* import and export operations */ if (((checkparms & BIT_IMPORT) || (checkparms & BIT_EXPORT)) && !(checkparms & ~(BIT_IMPORT +BIT_EXPORT +BIT_USER))) { if (backend_in) { status = make_pdb_method_name(&bin, backend_in); } else { status = make_pdb_method_name(&bin, backend); } if (!NT_STATUS_IS_OK(status)) { fprintf(stderr, "Unable to initialize %s.\n", backend_in ? backend_in : backend); return 1; } if (backend_out) { status = make_pdb_method_name(&bout, backend_out); } else { status = make_pdb_method_name(&bout, backend); } if (!NT_STATUS_IS_OK(status)) { fprintf(stderr, "Unable to initialize %s.\n", backend_out ? backend_out : backend); return 1; } if (transfer_account_policies) { if (!(checkparms & BIT_USER)) { return export_account_policies(bin, bout); } } else if (transfer_groups) { if (!(checkparms & BIT_USER)) { return export_groups(bin, bout); } } else { return export_database(bin, bout, (checkparms & BIT_USER) ? user_name : NULL); } } /* if BIT_USER is defined but nothing else then threat it as -l -u for compatibility */ /* fake up BIT_LIST if only BIT_USER is defined */ if ((checkparms & BIT_USER) && !(checkparms & ~BIT_USER)) { checkparms += BIT_LIST; } /* modify flag is optional to maintain backwards compatibility */ /* fake up BIT_MODIFY if BIT_USER and at least one of MASK_USER_GOOD is defined */ if (!((checkparms & ~MASK_USER_GOOD) & ~BIT_USER) && (checkparms & MASK_USER_GOOD)) { checkparms += BIT_MODIFY; } /* list users operations */ if (checkparms & BIT_LIST) { if (!(checkparms & ~BIT_LIST)) { return print_users_list(verbose, spstyle); } if (!(checkparms & ~(BIT_USER + BIT_LIST))) { return print_user_info(user_name, verbose, spstyle); } } /* mask out users options */ checkparms &= ~MASK_USER_GOOD; /* if bad password count is reset, we must be modifying */ if (checkparms & BIT_BADPWRESET) { checkparms |= BIT_MODIFY; checkparms &= ~BIT_BADPWRESET; } /* if logon hours is reset, must modify */ if (checkparms & BIT_LOGONHOURS) { checkparms |= BIT_MODIFY; checkparms &= ~BIT_LOGONHOURS; } /* account operation */ if ((checkparms & BIT_CREATE) || (checkparms & BIT_MODIFY) || (checkparms & BIT_DELETE)) { /* check use of -u option */ if (!(checkparms & BIT_USER)) { fprintf (stderr, "Username not specified! (use -u option)\n"); return -1; } /* account creation operations */ if (!(checkparms & ~(BIT_CREATE + BIT_USER + BIT_MACHINE))) { if (checkparms & BIT_MACHINE) { return new_machine(user_name, machine_sid); } else { return new_user(user_name, full_name, home_dir, home_drive, logon_script, profile_path, user_sid, pw_from_stdin); } } /* account deletion operations */ if (!(checkparms & ~(BIT_DELETE + BIT_USER + BIT_MACHINE))) { if (checkparms & BIT_MACHINE) { return delete_machine_entry(user_name); } else { return delete_user_entry(user_name); } } /* account modification operations */ if (!(checkparms & ~(BIT_MODIFY + BIT_USER + BIT_MACHINE))) { if (checkparms & BIT_MACHINE) { return set_machine_info(user_name, account_control, machine_sid); } else { return set_user_info(user_name, full_name, home_dir, acct_desc, home_drive, logon_script, profile_path, account_control, user_sid, user_domain, badpw_reset, hours_reset, kickoff_time); } } } if (setparms >= 0x20) { fprintf (stderr, "Incompatible or insufficient options on command line!\n"); } poptPrintHelp(pc, stderr, 0); TALLOC_FREE(frame); return 1; }
static int process_options(int argc, char **argv, int local_flags) { int ch; const char *configfile = get_dyn_CONFIGFILE(); local_flags |= LOCAL_SET_PASSWORD; ZERO_STRUCT(user_name); user_name[0] = '\0'; while ((ch = getopt(argc, argv, "c:axdehminjr:sw:R:D:U:LW")) != EOF) { switch(ch) { case 'L': if (getuid() != 0) { fprintf(stderr, "smbpasswd -L can only be used by root.\n"); exit(1); } local_flags |= LOCAL_AM_ROOT; break; case 'c': configfile = optarg; set_dyn_CONFIGFILE(optarg); break; case 'a': local_flags |= LOCAL_ADD_USER; break; case 'x': local_flags |= LOCAL_DELETE_USER; local_flags &= ~LOCAL_SET_PASSWORD; break; case 'd': local_flags |= LOCAL_DISABLE_USER; local_flags &= ~LOCAL_SET_PASSWORD; break; case 'e': local_flags |= LOCAL_ENABLE_USER; local_flags &= ~LOCAL_SET_PASSWORD; break; case 'm': local_flags |= LOCAL_TRUST_ACCOUNT; break; case 'i': local_flags |= LOCAL_INTERDOM_ACCOUNT; break; case 'j': d_printf("See 'net join' for this functionality\n"); exit(1); break; case 'n': local_flags |= LOCAL_SET_NO_PASSWORD; local_flags &= ~LOCAL_SET_PASSWORD; SAFE_FREE(new_passwd); new_passwd = smb_xstrdup("NO PASSWORD"); break; case 'r': remote_machine = optarg; break; case 's': set_line_buffering(stdin); set_line_buffering(stdout); set_line_buffering(stderr); stdin_passwd_get = True; break; case 'w': local_flags |= LOCAL_SET_LDAP_ADMIN_PW; fstrcpy(ldap_secret, optarg); break; case 'R': lp_set_cmdline("name resolve order", optarg); break; case 'D': lp_set_cmdline("log level", optarg); break; case 'U': { got_username = True; fstrcpy(user_name, optarg); break; case 'W': local_flags |= LOCAL_SET_LDAP_ADMIN_PW; *ldap_secret = '\0'; break; } case 'h': default: usage(); } } argc -= optind; argv += optind; switch(argc) { case 0: if (!got_username) fstrcpy(user_name, ""); break; case 1: if (!(local_flags & LOCAL_AM_ROOT)) { usage(); } else { if (got_username) { usage(); } else { fstrcpy(user_name, argv[0]); } } break; default: usage(); } if (!lp_load_global(configfile)) { fprintf(stderr, "Can't load %s - run testparm to debug it\n", configfile); exit(1); } return local_flags; }
/* main program */ int main(int argc, const char *argv[]) { TALLOC_CTX *mem_ctx; struct tevent_context *ev_ctx; struct messaging_context *msg_ctx; struct db_context *db; int unsafe_writes = 0; struct poptOption popt_options[] = { POPT_AUTOHELP POPT_COMMON_SAMBA { "timelimit", 't', POPT_ARG_INT, &timelimit, 0, "timelimit", "INTEGER" }, { "delay", 'D', POPT_ARG_INT, &torture_delay, 0, "delay (in seconds) between operations", "INTEGER" }, { "verbose", 'v', POPT_ARG_NONE, &verbose, 0, "switch on verbose mode", NULL }, { "db-name", 'N', POPT_ARG_STRING, &db_name, 0, "name of the test db", "NAME" }, { "no-trans", 'n', POPT_ARG_NONE, &no_trans, 0, "use fetch_lock/record store instead of transactions", NULL }, { "unsafe-writes", 'u', POPT_ARG_NONE, &unsafe_writes, 0, "do not use tdb transactions when writing", NULL }, POPT_TABLEEND }; int opt; const char **extra_argv; int extra_argc = 0; poptContext pc; int tdb_flags; int ret = 1; mem_ctx = talloc_stackframe(); if (verbose) { setbuf(stdout, (char *)NULL); /* don't buffer */ } else { setlinebuf(stdout); } load_case_tables(); setup_logging(argv[0], DEBUG_STDERR); lp_set_cmdline("log level", "0"); pc = poptGetContext(argv[0], argc, argv, popt_options, POPT_CONTEXT_KEEP_FIRST); while ((opt = poptGetNextOpt(pc)) != -1) { switch (opt) { default: fprintf(stderr, "Invalid option %s: %s\n", poptBadOption(pc, 0), poptStrerror(opt)); goto done; } } /* setup the remaining options for the main program to use */ extra_argv = poptGetArgs(pc); if (extra_argv) { extra_argv++; while (extra_argv[extra_argc]) extra_argc++; } lp_load_global(get_dyn_CONFIGFILE()); ev_ctx = samba_tevent_context_init(mem_ctx); if (ev_ctx == NULL) { d_fprintf(stderr, "ERROR: could not init event context\n"); goto done; } msg_ctx = messaging_init(mem_ctx, ev_ctx); if (msg_ctx == NULL) { d_fprintf(stderr, "ERROR: could not init messaging context\n"); goto done; } if (unsafe_writes == 1) { tdb_flags = TDB_NOSYNC; } else { tdb_flags = TDB_DEFAULT; } if (no_trans) { tdb_flags |= TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH; } db = db_open(mem_ctx, db_name, 0, tdb_flags, O_RDWR | O_CREAT, 0644, DBWRAP_LOCK_ORDER_1); if (db == NULL) { d_fprintf(stderr, "failed to open db '%s': %s\n", db_name, strerror(errno)); goto done; } if (get_my_vnn() == NONCLUSTER_VNN) { set_my_vnn(0); } pnn = get_my_vnn(); printf("Starting test on node %u. running for %u seconds. " "sleep delay: %u seconds.\n", pnn, timelimit, torture_delay); if (!verbose && (pnn == 0)) { tevent_add_timer(ev_ctx, db, timeval_current_ofs(1, 0), each_second, db); } test_store_records(db, ev_ctx); if (verbose || (pnn == 0)) { if (success != true) { printf("The test FAILED\n"); ret = 2; } else { printf("SUCCESS!\n"); ret = 0; } } done: talloc_free(mem_ctx); return ret; }
bool torture_rpc_mgmt(struct torture_context *torture) { NTSTATUS status; struct dcerpc_pipe *p; TALLOC_CTX *mem_ctx, *loop_ctx; bool ret = true; const struct ndr_interface_list *l; struct dcerpc_binding *b; mem_ctx = talloc_init("torture_rpc_mgmt"); status = torture_rpc_binding(torture, &b); if (!NT_STATUS_IS_OK(status)) { talloc_free(mem_ctx); return false; } for (l=ndr_table_list();l;l=l->next) { loop_ctx = talloc_named(mem_ctx, 0, "torture_rpc_mgmt loop context"); /* some interfaces are not mappable */ if (l->table->num_calls == 0 || strcmp(l->table->name, "mgmt") == 0) { talloc_free(loop_ctx); continue; } printf("\nTesting pipe '%s'\n", l->table->name); status = dcerpc_epm_map_binding(loop_ctx, b, l->table, NULL, torture->lp_ctx); if (!NT_STATUS_IS_OK(status)) { printf("Failed to map port for uuid %s\n", GUID_string(loop_ctx, &l->table->syntax_id.uuid)); talloc_free(loop_ctx); continue; } lp_set_cmdline(torture->lp_ctx, "torture:binding", dcerpc_binding_string(loop_ctx, b)); status = torture_rpc_connection(torture, &p, &ndr_table_mgmt); if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) { printf("Interface not available - skipping\n"); talloc_free(loop_ctx); continue; } if (!NT_STATUS_IS_OK(status)) { talloc_free(loop_ctx); ret = false; continue; } if (!test_is_server_listening(p, loop_ctx)) { ret = false; } if (!test_stop_server_listening(p, loop_ctx)) { ret = false; } if (!test_inq_stats(p, loop_ctx)) { ret = false; } if (!test_inq_princ_name(p, loop_ctx)) { ret = false; } if (!test_inq_if_ids(torture, p, loop_ctx, NULL, NULL)) { ret = false; } } return ret; }