/* * Initialize and create a specific agent channel. */ static void controller_agent_channel_init( rwcli_controller_t* inst, rwcli_transport_mode_t type) { rwcli_msg_channel_t* agent_ch = &(inst->agent_channels[type]); msg_channel_init(agent_ch); msg_channel_create(agent_ch); }
static NTSTATUS smbXsrv_session_table_init(struct smbXsrv_connection *conn, uint32_t lowest_id, uint32_t highest_id, uint32_t max_sessions) { struct smbXsrv_session_table *table; NTSTATUS status; struct tevent_req *subreq; int ret; uint64_t max_range; if (lowest_id > highest_id) { return NT_STATUS_INTERNAL_ERROR; } max_range = highest_id; max_range -= lowest_id; max_range += 1; if (max_sessions > max_range) { return NT_STATUS_INTERNAL_ERROR; } table = talloc_zero(conn, struct smbXsrv_session_table); if (table == NULL) { return NT_STATUS_NO_MEMORY; } table->local.db_ctx = db_open_rbt(table); if (table->local.db_ctx == NULL) { TALLOC_FREE(table); return NT_STATUS_NO_MEMORY; } table->local.lowest_id = lowest_id; table->local.highest_id = highest_id; table->local.max_sessions = max_sessions; status = smbXsrv_session_global_init(); if (!NT_STATUS_IS_OK(status)) { TALLOC_FREE(table); return status; } table->global.db_ctx = smbXsrv_session_global_db_ctx; dbwrap_watch_db(table->global.db_ctx, conn->msg_ctx); ret = msg_channel_init(table, conn->msg_ctx, MSG_SMBXSRV_SESSION_CLOSE, &table->close_channel); if (ret != 0) { status = map_nt_error_from_unix_common(errno); TALLOC_FREE(table); return status; } subreq = msg_read_send(table, conn->ev_ctx, table->close_channel); if (subreq == NULL) { TALLOC_FREE(table); return NT_STATUS_NO_MEMORY; } tevent_req_set_callback(subreq, smbXsrv_session_close_loop, conn); conn->session_table = table; return NT_STATUS_OK; }
int boot_(Module m) { char* dummy = NULL; // Initialize the trace module and set appropriate severity rift_init_trace(); recv_buf = (uint8_t*)calloc(sizeof(uint8_t), RW_CLI_MAX_BUF); recv_buf_len = RW_CLI_MAX_BUF; // Decide the RW.CLI communication mode with RW.MgmtAgent if (rift_cmdargs.use_netconf == -1) { const char* agent_mode = rw_getenv("RWMGMT_AGENT_MODE"); if (agent_mode && strcmp(agent_mode, "XML") == 0) { // If the agent mode is XML only RW.MSG mode is possible. Override the // command line option for netconf and opt for RW.MSG mode. rift_cmdargs.use_netconf = 0; } else { // Transport mode not chosen in command line and not XML mode. Choose // Netconf mode by default. rift_cmdargs.use_netconf = 1; } } // Authenticate in case of RW.MSG mode rwcli_transport_mode_t transport_mode = RWCLI_TRANSPORT_MODE_NETCONF; rwcli_user_mode_t user_mode = RWCLI_USER_MODE_NONE; if (!rift_cmdargs.use_netconf) { user_mode = rift_authenticate(&rift_cmdargs); if (user_mode == RWCLI_USER_MODE_INVALID) { printf("\nERROR: Invalid username/password\n"); exit(-1); } transport_mode = RWCLI_TRANSPORT_MODE_RWMSG; } rwcli_zsh_plugin_init(transport_mode, user_mode); rwcli_set_messaging_hook(messaging_hook); rwcli_set_history_hook(history_hook); // To support background processes and job control, there should // be multiple channels available msg_channel_init(&rwcli_agent_ch); msg_channel_create(&rwcli_agent_ch); // Always load the rwmsg_agent module, If netconf is enabled then // this module will only receive logging notifications if (load_module("zsh/rwmsg_agent", NULL, 0) != 0) { printf("\nCRITICAL: Loading the messaging agent module failed\n"); fflush(stdout); return -1; } // Load the agent that is required if (rift_cmdargs.use_netconf) { if (load_module("zsh/rwnetconf_agent", NULL, 0) != 0) { printf("\nCRITICAL: Loading the netconf agent module failed\n"); fflush(stdout); return -1; } } /* Register the completion widget */ w_comp = addzlefunction("rift-complete", rift_complete, 0); Keymap km = openkeymap("main"); t_orig_tab_bind = keybind(km, "\t", &dummy); bindkey(km, "\t", refthingy(w_comp->first), NULL); /* Bind ? to generate help */ w_gen_help = addzlefunction("rift-gen-help", rift_generate_help, 0); bindkey(km, "?", refthingy(w_gen_help->first), NULL); /* Set the lookup hook */ rw_lookup_fn = rift_lookup; /* Set the prompt hook */ addprepromptfn(rift_prompt); return 0; }