示例#1
0
/********************************************************
resolve via "wins" method
*********************************************************/
static BOOL
resolve_wins (const char *name, struct in_addr *return_ip, int name_type)
{
    int sock;
    struct in_addr wins_ip;
    BOOL wins_ismyip;

    /*
     * "wins" means do a unicast lookup to the WINS server.
     * Ignore if there is no WINS server specified or if the
     * WINS server is one of our interfaces (if we're being
     * called from within nmbd - we can't do this call as we
     * would then block).
     */

    DEBUG (3, ("resolve_name: Attempting wins lookup for name %s<0x%x>\n", name, name_type));

    if (!*lp_wins_server ())
    {
        DEBUG (3, ("resolve_name: WINS server resolution selected and no WINS server present.\n"));
        return False;
    }

    wins_ip = *interpret_addr2 (lp_wins_server ());
    wins_ismyip = ismyip (wins_ip);

    if ((wins_ismyip && !global_in_nmbd) || !wins_ismyip)
    {
        sock = open_socket_in (SOCK_DGRAM, 0, 3, interpret_addr (lp_socket_address ()), True);

        if (sock != -1)
        {
            struct in_addr *iplist = NULL;
            int count;
            iplist = name_query (sock, name, name_type, False, True, wins_ip, &count, NULL);
            if (iplist != NULL)
            {
                *return_ip = iplist[0];
                free ((char *) iplist);
                close (sock);
                return True;
            }
            close (sock);
        }
    }

    return False;
}
示例#2
0
/**************************************************************************** **
  reload the services file
 **************************************************************************** */
BOOL reload_services_nmbd(BOOL test)
{
  BOOL ret;
  extern fstring remote_machine;

  fstrcpy( remote_machine, "nmb" );

  if ( lp_loaded() )
  {
    pstring fname;
    pstrcpy( fname,lp_configfile());
    if (file_exist(fname,NULL) && !strcsequal(fname,servicesf_nmbd))
    {
      pstrcpy(servicesf_nmbd,fname);
      test = False;
    }
  }

  if ( test && !lp_file_list_changed() )
    return(True);

  ret = lp_load( servicesf_nmbd, True , False, False);

  /* perhaps the config filename is now set */
  if ( !test )
  {
    DEBUG( 3, ( "services not loaded\n" ) );
    reload_services_nmbd( True );
  }

  /* Do a sanity check for a misconfigured nmbd */
  if( lp_wins_support() && *lp_wins_server() )
  {
    DEBUG(0,("ERROR: both 'wins support = true' and 'wins server = <server>' \
cannot be set in the smb.conf file. nmbd aborting.\n"));
    exit(10);
  }