int is_console_enabled(osm_subn_opt_t * p_opt) { /* checks for a variety of types of consoles - default is off or 0 */ if (p_opt) return is_local(p_opt->console) || is_loopback(p_opt->console) || is_remote(p_opt->console); return 0; }
/********************************************************************** * Do authentication & authorization check **********************************************************************/ int is_authorized(osm_console_t * p_oct) { /* allowed to use the console? */ p_oct->authorized = !is_remote(p_oct->client_type) || hosts_ctl(OSM_DAEMON_NAME, p_oct->client_hn, p_oct->client_ip, "STRING_UNKNOWN"); return p_oct->authorized; }
void verify_dest(const std::string& cmd_dest, container& backup_dir) { if (not is_remote(cmd_dest)) { fs::path dest_dir(fs::initial_path()); dest_dir = fs::system_complete(fs::path(cmd_dest, fs::native)); backup_dir.destination(dest_dir.native_file_string()); if (not fs::exists(dest_dir)) throw Backup::Error::Directory_Error("Destination directory does not exist!"); if (not fs::is_directory(dest_dir)) throw Backup::Error::Directory_Error("Destination specified is not a directory!"); } else { backup_dir.destination(cmd_dest); } }
void abstract_actor::cleanup(uint32_t reason) { CAF_LOG_TRACE(CAF_ARG(reason)); CAF_ASSERT(reason != exit_reason::not_exited); // move everyhting out of the critical section before processing it attachable_ptr head; { // lifetime scope of guard guard_type guard{mtx_}; if (exit_reason_ != exit_reason::not_exited) { // already exited return; } exit_reason_ = reason; attachables_head_.swap(head); } CAF_LOG_INFO_IF(! is_remote(), "cleanup actor with ID " << id_ << "; exit reason = " << reason); // send exit messages for (attachable* i = head.get(); i != nullptr; i = i->next.get()) { i->actor_exited(this, reason); } }
void abstract_actor::cleanup(uint32_t reason) { // log as 'actor' CAF_LOGM_TRACE("caf::actor", CAF_ARG(m_id) << ", " << CAF_ARG(reason) << ", " << CAF_ARG(m_is_proxy)); CAF_REQUIRE(reason != exit_reason::not_exited); // move everyhting out of the critical section before processing it decltype(m_links) mlinks; decltype(m_attachables) mattachables; { // lifetime scope of guard guard_type guard{m_mtx}; if (m_exit_reason != exit_reason::not_exited) { // already exited return; } m_exit_reason = reason; mlinks = std::move(m_links); mattachables = std::move(m_attachables); // make sure lists are empty m_links.clear(); m_attachables.clear(); } CAF_LOG_INFO_IF(!is_remote(), "actor with ID " << m_id << " had " << mlinks.size() << " links and " << mattachables.size() << " attached functors; exit reason = " << reason << ", class = " << detail::demangle(typeid(*this))); // send exit messages auto msg = make_message(exit_msg{address(), reason}); CAF_LOGM_DEBUG("caf::actor", "send EXIT to " << mlinks.size() << " links"); for (auto& aptr : mlinks) { aptr->enqueue(address(), message_id {}.with_high_priority(), msg, m_host); } CAF_LOGM_DEBUG("caf::actor", "run " << mattachables.size() << " attachables"); for (attachable_ptr& ptr : mattachables) { ptr->actor_exited(reason); } }
void file::ensure_local() { if (is_remote()) throw exception_io_object_is_remote(); }
/* * Sort a list of server endpoints so that address for local interfaces * occur before remote interfaces. If an error occurs (e.g., no memory), * we just clean up and return; we end up not sorting the endpoints, but * this is just for optimization anyway. * * There is a lot of work in this routine, so it should not be called * frequently. */ static void nis_sort_server_endpoints_inet(nis_server *svr) { int i; int j; int neps = svr->ep.ep_len; endpoint *eps = svr->ep.ep_val; struct netconfig *ncp, *ncp_inet = 0, *ncp_inet6 = 0; void *local_interfaces; void *nch; nch = setnetconfig(); if (nch == 0) return; /* find any inet entry so we can do uaddr2taddr */ while ((ncp = getnetconfig(nch)) != 0 && ncp_inet == 0 && ncp_inet6 == 0) { if (strcmp(ncp->nc_protofmly, NC_INET) == 0) ncp_inet = ncp; else if (strcmp(ncp->nc_protofmly, NC_INET6)) ncp_inet6 = ncp; } if (ncp_inet == 0 && ncp_inet6 == 0) { (void) endnetconfig(nch); return; } local_interfaces = __inet_get_local_interfaces(); if (local_interfaces == 0) { (void) endnetconfig(nch); return; } /* * Sort endpoints so local inet addresses are first. The * variable 'i' points to the beginning of the array, * and 'j' points to the end. We advance 'i' as long * as it indexes a non-inet endpoint or a local endpoint. * We retract 'j' as long as it indexes a non-inet endpoint * or a remote endpoint. If either of these cases fail, * then 'i' is pointing at a remote endpoint and 'j' is * pointing at a local endpoint. We swap them, adjust * the indexes, and continue. When the indexes cross * we are done. */ i = 0; j = neps - 1; while (i < j) { if ((strcmp(eps[i].family, NC_INET) != 0 && strcmp(eps[i].family, NC_INET6) != 0) || is_local(local_interfaces, ncp, eps[i].uaddr)) { i++; continue; } if ((strcmp(eps[j].family, NC_INET) != 0 && strcmp(eps[j].family, NC_INET6) != 0) || is_remote(local_interfaces, ncp, eps[j].uaddr)) { --j; continue; } __nis_swap_endpoints(&eps[i], &eps[j]); i++; --j; } /* clean up */ __inet_free_local_interfaces(local_interfaces); (void) endnetconfig(nch); }