void start_fssd(struct tevent_context *ev_ctx, struct messaging_context *msg_ctx) { struct rpc_srv_callbacks fss_cb; NTSTATUS status; pid_t pid; bool ok; int rc; fss_cb.init = fss_init_cb; fss_cb.shutdown = fss_shutdown_cb; fss_cb.private_data = msg_ctx; DEBUG(1, ("Forking File Server Shadow-copy Daemon\n")); pid = fork(); if (pid == -1) { DEBUG(0, ("failed to fork file server shadow-copy daemon [%s], " "aborting ...\n", strerror(errno))); exit(1); } if (pid) { /* parent */ return; } /* child */ status = smbd_reinit_after_fork(msg_ctx, ev_ctx, true); if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("reinit_after_fork() failed\n")); smb_panic("reinit_after_fork() failed"); } fssd_reopen_logs(); fssd_setup_sig_term_handler(ev_ctx); fssd_setup_sig_hup_handler(ev_ctx, msg_ctx); ok = serverid_register(procid_self(), FLAG_MSG_GENERAL | FLAG_MSG_PRINT_GENERAL); if (!ok) { DEBUG(0, ("Failed to register serverid in fssd!\n")); exit(1); } messaging_register(msg_ctx, ev_ctx, MSG_SMB_CONF_UPDATED, fssd_smb_conf_updated); status = rpc_FileServerVssAgent_init(&fss_cb); if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("Failed to register fssd rpc inteface! (%s)\n", nt_errstr(status))); exit(1); } /* case is normalized by smbd on connection */ ok = setup_named_pipe_socket("fssagentrpc", ev_ctx, msg_ctx); if (!ok) { DEBUG(0, ("Failed to open fssd named pipe!\n")); exit(1); } DEBUG(1, ("File Server Shadow-copy Daemon Started (%d)\n", (int)getpid())); /* loop forever */ rc = tevent_loop_wait(ev_ctx); /* should not be reached */ DEBUG(0,("tevent_loop_wait() exited with %d - %s\n", rc, (rc == 0) ? "out of events" : strerror(errno))); exit(1); }
void start_epmd(struct tevent_context *ev_ctx, struct messaging_context *msg_ctx) { struct rpc_srv_callbacks epmapper_cb; NTSTATUS status; pid_t pid; bool ok; int rc; epmapper_cb.init = NULL; epmapper_cb.shutdown = epmapper_shutdown_cb; epmapper_cb.private_data = NULL; DEBUG(1, ("Forking Endpoint Mapper Daemon\n")); pid = fork(); if (pid == -1) { DEBUG(0, ("Failed to fork Endpoint Mapper [%s], aborting ...\n", strerror(errno))); exit(1); } if (pid) { /* parent */ return; } status = reinit_after_fork(msg_ctx, ev_ctx, true); if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("reinit_after_fork() failed\n")); smb_panic("reinit_after_fork() failed"); } epmd_reopen_logs(); epmd_setup_sig_term_handler(ev_ctx); epmd_setup_sig_hup_handler(ev_ctx, msg_ctx); ok = serverid_register(procid_self(), FLAG_MSG_GENERAL | FLAG_MSG_PRINT_GENERAL); if (!ok) { DEBUG(0, ("Failed to register serverid in epmd!\n")); exit(1); } messaging_register(msg_ctx, ev_ctx, MSG_SMB_CONF_UPDATED, epmd_smb_conf_updated); status = rpc_epmapper_init(&epmapper_cb); if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("Failed to register epmd rpc inteface! (%s)\n", nt_errstr(status))); exit(1); } status = rpc_setup_tcpip_sockets(ev_ctx, msg_ctx, &ndr_table_epmapper, NULL, 135); if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("Failed to open epmd tcpip sockets!\n")); exit(1); } ok = setup_dcerpc_ncalrpc_socket(ev_ctx, msg_ctx, "EPMAPPER", srv_epmapper_delete_endpoints); if (!ok) { DEBUG(0, ("Failed to open epmd ncalrpc pipe!\n")); exit(1); } ok = setup_named_pipe_socket("epmapper", ev_ctx, msg_ctx); if (!ok) { DEBUG(0, ("Failed to open epmd named pipe!\n")); exit(1); } DEBUG(1, ("Endpoint Mapper Daemon Started (%d)\n", getpid())); /* loop forever */ rc = tevent_loop_wait(ev_ctx); /* should not be reached */ DEBUG(0,("background_queue: tevent_loop_wait() exited with %d - %s\n", rc, (rc == 0) ? "out of events" : strerror(errno))); exit(1); }
void start_spoolssd(struct tevent_context *ev_ctx, struct messaging_context *msg_ctx) { struct rpc_srv_callbacks spoolss_cb; pid_t pid; NTSTATUS status; int ret; DEBUG(1, ("Forking SPOOLSS Daemon\n")); pid = sys_fork(); if (pid == -1) { DEBUG(0, ("Failed to fork SPOOLSS [%s], aborting ...\n", strerror(errno))); exit(1); } if (pid) { /* parent */ return; } /* child */ close_low_fds(false); status = reinit_after_fork(msg_ctx, ev_ctx, procid_self(), true); if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("reinit_after_fork() failed\n")); smb_panic("reinit_after_fork() failed"); } spoolss_reopen_logs(); spoolss_setup_sig_term_handler(ev_ctx); spoolss_setup_sig_hup_handler(ev_ctx, msg_ctx); if (!serverid_register(procid_self(), FLAG_MSG_GENERAL|FLAG_MSG_SMBD |FLAG_MSG_PRINT_GENERAL)) { exit(1); } if (!locking_init()) { exit(1); } messaging_register(msg_ctx, NULL, MSG_PRINTER_UPDATE, print_queue_receive); messaging_register(msg_ctx, ev_ctx, MSG_SMB_CONF_UPDATED, smb_conf_updated); /* * Initialize spoolss with an init function to convert printers first. * static_init_rpc will try to initialize the spoolss server too but you * can't register it twice. */ spoolss_cb.init = spoolss_init_cb; spoolss_cb.shutdown = spoolss_shutdown_cb; spoolss_cb.private_data = msg_ctx; status = rpc_winreg_init(NULL); if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("Failed to register winreg rpc inteface! (%s)\n", nt_errstr(status))); exit(1); } status = rpc_spoolss_init(&spoolss_cb); if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("Failed to register spoolss rpc inteface! (%s)\n", nt_errstr(status))); exit(1); } if (!setup_named_pipe_socket(SPOOLSS_PIPE_NAME, ev_ctx)) { exit(1); } status = rpc_ep_setup_register(ev_ctx, msg_ctx, &ndr_table_spoolss, NULL, 0); if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("Failed to register spoolss endpoint! (%s)\n", nt_errstr(status))); exit(1); } DEBUG(1, ("SPOOLSS Daemon Started (%d)\n", getpid())); /* loop forever */ ret = tevent_loop_wait(ev_ctx); /* should not be reached */ DEBUG(0,("background_queue: tevent_loop_wait() exited with %d - %s\n", ret, (ret == 0) ? "out of events" : strerror(errno))); exit(1); }