NET_API_STATUS libnetapi_set_debuglevel(struct libnetapi_ctx *ctx, const char *debuglevel) { AllowDebugChange = true; ctx->debuglevel = talloc_strdup(ctx, debuglevel); if (!debug_parse_levels(debuglevel)) { return W_ERROR_V(WERR_GENERAL_FAILURE); } return NET_API_STATUS_SUCCESS; }
/**************************************************************************** receive a "set debug level" message ****************************************************************************/ static void debug_message(int msg_type, pid_t src, void *buf, size_t len) { const char *params_str = buf; /* Check, it's a proper string! */ if (params_str[len-1] != '\0') { DEBUG(1, ("Invalid debug message from pid %u to pid %u\n", (unsigned int)src, (unsigned int)getpid())); return; } DEBUG(3, ("INFO: Remote set of debug to `%s' (pid %u from pid %u)\n", params_str, (unsigned int)getpid(), (unsigned int)src)); debug_parse_levels(params_str); }
int main(int argc, char **argv) { TALLOC_CTX *mem_ctx = talloc_init("samba-dig"); struct tevent_context *ev; struct dns_name_packet *dns_packet, *in_packet; struct dns_name_question *question; enum dns_qtype type; enum ndr_err_code ndr_err; struct tevent_req *req; WERROR w_err; DATA_BLOB out, in; int ret = 0; if (argc < 4) { usage(); exit(1); } ev = tevent_context_init(mem_ctx); setup_logging("samba-dig", DEBUG_STDERR); debug_parse_levels("1"); DEBUG(1,("Querying %s for %s %s\n", argv[1], argv[2], argv[3])); dns_packet = make_name_packet(mem_ctx, DNS_OPCODE_QUERY); type = parse_qtype(argv[3]); if (type == -1) { DEBUG(0, ("Invalid DNS_QTYPE %s\n", argv[3])); ret = 1; goto error; } question = make_question(dns_packet, argv[2], type); dns_packet->qdcount = 1; dns_packet->questions = question; NDR_PRINT_DEBUG(dns_name_packet, dns_packet); ndr_err = ndr_push_struct_blob(&out, mem_ctx, dns_packet, (ndr_push_flags_fn_t)ndr_push_dns_name_packet); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { DEBUG(0, ("Failed to marshall dns_name_packet: %d\n", ndr_err)); ret = 1; goto error; } req = dns_udp_request_send(mem_ctx, ev, argv[1], out.data, out.length); if (req == NULL) { DEBUG(0, ("Failed to allocate memory for tevent_req\n")); ret = 1; goto error; } if (!tevent_req_poll(req, ev)) { DEBUG(0, ("Error sending dns request\n")); ret = 1; goto error; } w_err = dns_udp_request_recv(req, mem_ctx, &in.data, &in.length); if (!W_ERROR_IS_OK(w_err)) { DEBUG(0, ("Error receiving dns request: %s\n", win_errstr(w_err))); ret = 1; goto error; } in_packet = talloc(mem_ctx, struct dns_name_packet); ndr_err = ndr_pull_struct_blob(&in, in_packet, in_packet, (ndr_pull_flags_fn_t)ndr_pull_dns_name_packet); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { DEBUG(0, ("Failed to unmarshall dns_name_packet: %d\n", ndr_err)); ret = 1; goto error; } NDR_PRINT_DEBUG(dns_name_packet, in_packet); error: talloc_free(mem_ctx); 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, dyn_LOGFILEBASE); return; } switch(opt->val) { case 'd': if (arg) { debug_parse_levels(arg); AllowDebugChange = False; } break; case 'V': printf( "Version %s\n", SAMBA_VERSION_STRING); exit(0); break; case 'O': if (arg) { pstrcpy(user_socket_options,arg); } break; case 's': if (arg) { pstrcpy(dyn_CONFIGFILE, arg); } break; case 'n': if (arg) { set_global_myname(arg); } break; case 'l': if (arg) { set_logfile(con, arg); override_logfile = True; pstr_sprintf(dyn_LOGFILEBASE, "%s", arg); } break; case 'i': if (arg) { set_global_scope(arg); } break; case 'W': if (arg) { set_global_myworkgroup(arg); } break; } }
static void popt_common_callback(poptContext con, enum poptCallbackReason reason, const struct poptOption *opt, const char *arg, const void *data) { pstring logfile; const char *pname; /* Find out basename of current program */ pname = strrchr_m(poptGetInvocationName(con),'/'); if (!pname) pname = poptGetInvocationName(con); else pname++; if (reason == POPT_CALLBACK_REASON_PRE) { pstr_sprintf(logfile, "%s/log.%s", dyn_LOGFILEBASE, pname); lp_set_logfile(logfile); return; } switch(opt->val) { case 'd': if (arg) { debug_parse_levels(arg); AllowDebugChange = False; } break; case 'V': printf( "Version %s\n", SAMBA_VERSION_STRING); exit(0); break; case 'O': if (arg) { pstrcpy(user_socket_options,arg); } break; case 's': if (arg) { pstrcpy(dyn_CONFIGFILE, arg); } break; case 'n': if (arg) { set_global_myname(arg); } break; case 'l': if (arg) { pstr_sprintf(logfile, "%s/log.%s", arg, pname); lp_set_logfile(logfile); } break; case 'i': if (arg) { set_global_scope(arg); } break; case 'W': if (arg) { set_global_myworkgroup(arg); } break; } }
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()); 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 'd': if (arg) { debug_parse_levels(arg); AllowDebugChange = False; } 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) { set_global_myname(arg); } break; case 'l': if (arg) { set_logfile(con, arg); override_logfile = True; set_dyn_LOGFILEBASE(arg); } break; case 'i': if (arg) { set_global_scope(arg); } break; case 'W': if (arg) { set_global_myworkgroup(arg); } break; } }