void print_info(bool rv, const char * addr, Sock* s, MyString name, int cmd, ClassAd *authz_ad, CondorError *errstack, int output_mode) { MyString cmd_map_ent; cmd_map_ent.formatstr ("{%s,<%i>}", addr, cmd); MyString session_id; KeyCacheEntry *k = NULL; ClassAd *policy = NULL; int ret = 0; if(rv) { // IMPORTANT: this hashtable returns 0 on success! ret = (SecMan::command_map).lookup(cmd_map_ent, session_id); if (ret) { printf("no cmd map!\n"); return; } // IMPORTANT: this hashtable returns 1 on success! ret = (SecMan::session_cache).lookup(session_id.Value(), k); if (!ret) { printf("no session!\n"); return; } policy = k->policy(); } if (output_mode == 0) { // print nothing!! } else if (output_mode == 1) { print_useful_info_1(rv, name, s, policy, authz_ad, errstack); } else if (output_mode == 2) { print_useful_info_2(rv, cmd, name, s, policy, authz_ad, errstack); } else if (output_mode == 10) { print_useful_info_10(rv, name, s, policy, authz_ad, errstack); } }
boost::shared_ptr<ClassAdWrapper> ping(object locate_obj, object command_obj=object("DC_NOP")) { int num = getCommand(command_obj); extract<ClassAdWrapper&> ad_extract(locate_obj); std::string addr; if (ad_extract.check()) { ClassAdWrapper& ad = ad_extract(); if (!ad.EvaluateAttrString(ATTR_MY_ADDRESS, addr)) { THROW_EX(ValueError, "Daemon address not specified."); } } else { addr = extract<std::string>(locate_obj); } Daemon daemon(DT_ANY, addr.c_str(), NULL); if (!daemon.locate()) { THROW_EX(RuntimeError, "Unable to find daemon."); } CondorError errstack; boost::shared_ptr<ClassAdWrapper> authz_ad(new ClassAdWrapper()); ReliSock *sock = NULL; if (!(sock = (ReliSock*) daemon.makeConnectedSocket( Stream::reli_sock, 0, 0, &errstack ))) { THROW_EX(RuntimeError, "Unable to connect to daemon."); } if (!(daemon.startSubCommand(DC_SEC_QUERY, num, sock, 0, &errstack))) { THROW_EX(RuntimeError, "Unable to send security query to daemon."); } sock->decode(); if (!getClassAd(sock, *authz_ad.get()) || !sock->end_of_message()) { THROW_EX(RuntimeError, "Failed to get security session information from remote daemon."); } MyString cmd_map_ent; cmd_map_ent.formatstr ("{%s,<%i>}", addr.c_str(), num); MyString session_id; KeyCacheEntry *k = NULL; ClassAd *policy = NULL; // IMPORTANT: this hashtable returns 0 on success! if ((SecMan::command_map).lookup(cmd_map_ent, session_id)) { THROW_EX(RuntimeError, "No valid entry in command map hash table!"); } // IMPORTANT: this hashtable returns 1 on success! if (!(SecMan::session_cache).lookup(session_id.Value(), k)) { THROW_EX(RuntimeError, "No valid entry in session map hash table!"); } policy = k->policy(); authz_ad->Update(*policy); return authz_ad; }