Logo Search packages:      
Sourcecode: condor version File versions  Download package

char * DaemonCore::InfoCommandSinfulStringMyself ( bool  usePrivateAddress  ) 

Returns the Sinful String <host:port> of the DaemonCore command socket of this process

  • If false, return whatever getpeername provides, which may be a white lie if GCB is involved.
  • If true, return the "real" local address, no GCB deception allowed. Note that the true (no GCB deception) result should not be passed to another machine; doing so defeats the entire point of GCB. This functionality is provided only for passing to other processes on the same machine as an optimization.
A pointer into a static buffer, or NULL on error

Definition at line 941 of file daemon_core.cpp.

References MyString::sprintf(), and MyString::Value().

Referenced by Create_Process(), InfoCommandSinfulString(), privateNetworkIpAddr(), and publicNetworkIpAddr().

      static char * sinful_public = NULL;
      static char * sinful_private = NULL;
      static bool initialized_sinful_private = false;

      if ( initial_command_sock == -1 ) {
            // there is no command sock!
            return NULL;

            // If we haven't initialized our address(es), do so now.
      if (sinful_public == NULL) {
            char* tmp = param("TCP_FORWARDING_HOST");
                  // If TCP_FORWARDING_HOST is defined, we will advertize
                  // our local IP address for daemons that have the same
                  // PRIVATE_NETWORK_NAME as us.  For everyone else, we
                  // advertize the address of the TCP forwarder.
            if (tmp != NULL) {
                  MyString tcp_forwarding_host = tmp;
                  struct sockaddr_in sin;
                  if (!is_ipaddr(tcp_forwarding_host.Value(), &sin.sin_addr)) {
                        struct hostent *he = condor_gethostbyname(tcp_forwarding_host.Value());
                        if (he == NULL) {
                              EXCEPT("failed to resolve address of SSH_BROKER");
                        sin.sin_addr = *(in_addr*)(he->h_addr_list[0]);;
                  sin.sin_port = htons(((Sock*)(*sockTable)[initial_command_sock].iosock)->get_port());
                  sinful_public = strdup(sin_to_string(&sin));
            else {
                  sinful_public = strdup(
                      sock_to_string( (*sockTable)[initial_command_sock].iosock->get_file_desc() ) );

      if (!initialized_sinful_private) {
            MyString private_sinful_string;
            char* tmp;
            if ((tmp = param("PRIVATE_NETWORK_INTERFACE"))) {
                  int port = ((Sock*)(*sockTable)[initial_command_sock].iosock)->get_port();
                  private_sinful_string.sprintf("<%s:%d>", tmp, port);
                  sinful_private = strdup(private_sinful_string.Value());
            if (sinful_private == NULL
                  && (param_boolean("NET_REMAP_ENABLE", false, false))) {
                        // If the knob wasn't defined, and GCB is enabled, ask GCB.
                  struct sockaddr_in addr;
                  SOCKET_LENGTH_TYPE addr_len = sizeof(addr);
                  SOCKET sockd = ((Sock*)(*sockTable)[initial_command_sock].iosock)->get_file_desc();
                  if (GCB_real_getsockname(sockd, (struct sockaddr *)&addr, &addr_len) >= 0) {
                        sinful_private = strdup(sin_to_string(&addr));
#endif /* HAVE_EXT_GCB */
            initialized_sinful_private = true;

      if (usePrivateAddress && sinful_private) {
            return sinful_private;
      return sinful_public;

Generated by  Doxygen 1.6.0   Back to index