/* return a count of the number of IPs for a particular tag, including dead ones */ unsigned wins_srv_count_tag(const char *tag) { const char **list; int i, count=0; /* if we are a wins server then we always just talk to ourselves */ if (lp_wins_support()) { return 1; } list = lp_wins_server_list(); if (!list || !list[0]) { return 0; } /* find the first live one for this tag */ for (i=0; list[i]; i++) { struct tagged_ip t_ip; parse_ip(&t_ip, list[i]); if (strcmp(tag, t_ip.tag) == 0) { count++; } } return count; }
/* return the IP of the currently active wins server for the given tag, or the zero IP otherwise */ struct in_addr wins_srv_ip_tag(const char *tag, struct in_addr src_ip) { const char **list; int i; struct tagged_ip t_ip; /* if we are a wins server then we always just talk to ourselves */ if (lp_wins_support()) { struct in_addr loopback_ip; loopback_ip.s_addr = htonl(INADDR_LOOPBACK); return loopback_ip; } list = lp_wins_server_list(); if (!list || !list[0]) { struct in_addr ip; zero_ip_v4(&ip); return ip; } /* find the first live one for this tag */ for (i=0; list[i]; i++) { parse_ip(&t_ip, list[i]); if (strcmp(tag, t_ip.tag) != 0) { /* not for the right tag. Move along */ continue; } if (!wins_srv_is_dead(t_ip.ip, src_ip)) { fstring src_name; fstrcpy(src_name, inet_ntoa(src_ip)); DEBUG(6,("Current wins server for tag '%s' with source %s is %s\n", tag, src_name, inet_ntoa(t_ip.ip))); return t_ip.ip; } } /* they're all dead - try the first one until they revive */ for (i=0; list[i]; i++) { parse_ip(&t_ip, list[i]); if (strcmp(tag, t_ip.tag) != 0) { continue; } return t_ip.ip; } /* this can't happen?? */ zero_ip_v4(&t_ip.ip); return t_ip.ip; }
static int do_global_checks(void) { int ret = 0; SMB_STRUCT_STAT st; if (lp_security() >= SEC_DOMAIN && !lp_encrypted_passwords()) { fprintf(stderr, "ERROR: in 'security=domain' mode the 'encrypt passwords' parameter must always be set to 'true'.\n"); ret = 1; } if (lp_wins_support() && lp_wins_server_list()) { fprintf(stderr, "ERROR: both 'wins support = true' and 'wins server = <server list>' \ cannot be set in the smb.conf file. nmbd will abort with this setting.\n"); ret = 1; }
static WERROR wins_status( const char *service, struct SERVICE_STATUS *service_status ) { ZERO_STRUCTP( service_status ); service_status->type = SERVICE_TYPE_WIN32_OWN_PROCESS; service_status->controls_accepted = SVCCTL_ACCEPT_NONE; if ( lp_wins_support() ) service_status->state = SVCCTL_RUNNING; else { service_status->state = SVCCTL_STOPPED; service_status->win32_exit_code = WERR_SERVICE_NEVER_STARTED; } return WERR_OK; }
/* return the total number of wins servers, dead or not */ unsigned wins_srv_count(void) { const char **list; int count = 0; if (lp_wins_support()) { /* simple - just talk to ourselves */ return 1; } list = lp_wins_server_list(); for (count=0; list && list[count]; count++) /* nop */ ; return count; }
/* startup the WINS server, if configured */ NTSTATUS nbtd_winsserver_init(struct nbtd_server *nbtsrv) { uint32_t tmp; const char *owner; if (!lp_wins_support(nbtsrv->task->lp_ctx)) { nbtsrv->winssrv = NULL; return NT_STATUS_OK; } nbtsrv->winssrv = talloc_zero(nbtsrv, struct wins_server); NT_STATUS_HAVE_NO_MEMORY(nbtsrv->winssrv); nbtsrv->winssrv->config.max_renew_interval = lp_max_wins_ttl(nbtsrv->task->lp_ctx); nbtsrv->winssrv->config.min_renew_interval = lp_min_wins_ttl(nbtsrv->task->lp_ctx); tmp = lp_parm_int(nbtsrv->task->lp_ctx, NULL, "wreplsrv", "tombstone_interval", 6*24*60*60); nbtsrv->winssrv->config.tombstone_interval = tmp; tmp = lp_parm_int(nbtsrv->task->lp_ctx, NULL, "wreplsrv"," tombstone_timeout", 1*24*60*60); nbtsrv->winssrv->config.tombstone_timeout = tmp; owner = lp_parm_string(nbtsrv->task->lp_ctx, NULL, "winsdb", "local_owner"); if (owner == NULL) { struct interface *ifaces; load_interfaces(nbtsrv->task, lp_interfaces(nbtsrv->task->lp_ctx), &ifaces); owner = iface_n_ip(ifaces, 0); } nbtsrv->winssrv->wins_db = winsdb_connect(nbtsrv->winssrv, nbtsrv->task->event_ctx, nbtsrv->task->lp_ctx, owner, WINSDB_HANDLE_CALLER_NBTD); if (!nbtsrv->winssrv->wins_db) { return NT_STATUS_INTERNAL_DB_ERROR; } irpc_add_name(nbtsrv->task->msg_ctx, "wins_server"); return NT_STATUS_OK; }
static struct in_addr *lookup_byname_backend(const char *name, int *count) { int fd; struct in_addr *ret = NULL; struct in_addr p; int j, flags; *count = 0; fd = wins_lookup_open_socket_in(); if (fd == -1) return NULL; p = wins_srv_ip(); if( !is_zero_ip(p) ) { ret = name_query(fd,name,0x20,False,True, p, count, &flags); goto out; } if (lp_wins_support()) { /* we are our own WINS server */ ret = name_query(fd,name,0x20,False,True, *interpret_addr2("127.0.0.1"), count, &flags); goto out; } /* uggh, we have to broadcast to each interface in turn */ for (j=iface_count() - 1; j >= 0; j--) { struct in_addr *bcast = iface_n_bcast(j); ret = name_query(fd,name,0x20,True,True,*bcast,count, &flags); if (ret) break; } out: close(fd); return ret; }
/**************************************************************************** ** 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); }