Ignore:
Timestamp:
Nov 24, 2016, 1:14:11 PM (9 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to version 4.4.3

Location:
vendor/current/source3/nmbd
Files:
25 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/source3/nmbd/asyncdns.c

    r740 r988  
    33   a async DNS handler
    44   Copyright (C) Andrew Tridgell 1997-1998
    5    
     5
    66   This program is free software; you can redistribute it and/or modify
    77   it under the terms of the GNU General Public License as published by
    88   the Free Software Foundation; either version 3 of the License, or
    99   (at your option) any later version.
    10    
     10
    1111   This program is distributed in the hope that it will be useful,
    1212   but WITHOUT ANY WARRANTY; without even the implied warranty of
    1313   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1414   GNU General Public License for more details.
    15    
     15
    1616   You should have received a copy of the GNU General Public License
    1717   along with this program.  If not, see <http://www.gnu.org/licenses/>.
     
    2020#include "includes.h"
    2121#include "nmbd/nmbd.h"
     22#include "lib/util/sys_rw_data.h"
    2223
    2324/***************************************************************************
     
    3132
    3233        pull_ascii_nstring(qname, sizeof(qname), question->name);
    33  
     34
    3435        if (!addr.s_addr) {
    3536                /* add the fail to WINS cache of names. give it 1 hour in the cache */
     
    9192                NTSTATUS status;
    9293
    93                 status = read_data(fd_in, (char *)&r, sizeof(r));
     94                status = read_data_ntstatus(fd_in, (char *)&r, sizeof(r));
    9495
    9596                if (!NT_STATUS_IS_OK(status)) {
     
    136137  create a child process to handle DNS lookups
    137138  ****************************************************************************/
    138 void start_async_dns(void)
     139void start_async_dns(struct messaging_context *msg)
    139140{
    140141        int fd1[2], fd2[2];
     
    148149        }
    149150
    150         child_pid = sys_fork();
     151        child_pid = fork();
    151152
    152153        if (child_pid) {
     
    167168        CatchSignal(SIGTERM, sig_term);
    168169
    169         status = reinit_after_fork(nmbd_messaging_context(),
    170                                    nmbd_event_context(),
    171                                    procid_self(), true);
     170        status = reinit_after_fork(msg, nmbd_event_context(), true, NULL);
    172171
    173172        if (!NT_STATUS_IS_OK(status)) {
     
    206205  check the DNS queue
    207206  ****************************************************************************/
    208 void run_dns_queue(void)
     207void run_dns_queue(struct messaging_context *msg)
    209208{
    210209        struct query_record r;
     
    219218                close(fd_in);
    220219                close(fd_out);
    221                 start_async_dns();
    222         }
    223 
    224         status = read_data(fd_in, (char *)&r, sizeof(r));
     220                start_async_dns(msg);
     221        }
     222
     223        status = read_data_ntstatus(fd_in, (char *)&r, sizeof(r));
    225224
    226225        if (!NT_STATUS_IS_OK(status)) {
  • vendor/current/source3/nmbd/nmbd.c

    r746 r988  
    2626#include "serverid.h"
    2727#include "messages.h"
     28#include "../lib/util/pidfile.h"
     29#include "util_cluster.h"
    2830
    2931int ClientNMB       = -1;
     
    4345time_t StartupTime = 0;
    4446
    45 struct event_context *nmbd_event_context(void)
     47struct tevent_context *nmbd_event_context(void)
    4648{
    4749        return server_event_context();
    48 }
    49 
    50 struct messaging_context *nmbd_messaging_context(void)
    51 {
    52         struct messaging_context *msg_ctx = server_messaging_context();
    53         if (likely(msg_ctx != NULL)) {
    54                 return msg_ctx;
    55         }
    56         smb_panic("Could not init nmbd's messaging context.\n");
    57         return NULL;
    5850}
    5951
     
    6254 **************************************************************************** */
    6355
    64 static void terminate(void)
     56static void terminate(struct messaging_context *msg)
    6557{
    6658        DEBUG(0,("Got SIGTERM: going down...\n"));
    67  
     59
    6860        /* Write out wins.dat file if samba is a WINS server */
    6961        wins_write_database(0,False);
    70  
     62
    7163        /* Remove all SELF registered names from WINS */
    7264        release_wins_names();
    73  
     65
    7466        /* Announce all server entries as 0 time-to-live, 0 type. */
    7567        announce_my_servers_removed();
     
    7971
    8072        gencache_stabilize();
    81         serverid_deregister(procid_self());
    82 
    83         pidfile_unlink();
     73        serverid_deregister(messaging_server_id(msg));
     74
     75        pidfile_unlink(lp_pid_directory(), "nmbd");
    8476
    8577        exit(0);
     
    9385                                  void *private_data)
    9486{
    95         terminate();
    96 }
    97 
    98 static bool nmbd_setup_sig_term_handler(void)
     87        struct messaging_context *msg = talloc_get_type_abort(
     88                private_data, struct messaging_context);
     89
     90        terminate(msg);
     91}
     92
     93/*
     94  handle stdin becoming readable when we are in --foreground mode
     95 */
     96static void nmbd_stdin_handler(struct tevent_context *ev,
     97                               struct tevent_fd *fde,
     98                               uint16_t flags,
     99                               void *private_data)
     100{
     101        char c;
     102        if (read(0, &c, 1) != 1) {
     103                struct messaging_context *msg = talloc_get_type_abort(
     104                        private_data, struct messaging_context);
     105               
     106                DEBUG(0,("EOF on stdin\n"));
     107                terminate(msg);
     108        }
     109}
     110
     111static bool nmbd_setup_sig_term_handler(struct messaging_context *msg)
    99112{
    100113        struct tevent_signal *se;
     
    104117                               SIGTERM, 0,
    105118                               nmbd_sig_term_handler,
    106                                NULL);
     119                               msg);
    107120        if (!se) {
    108121                DEBUG(0,("failed to setup SIGTERM handler"));
    109122                return false;
     123        }
     124
     125        return true;
     126}
     127
     128static bool nmbd_setup_stdin_handler(struct messaging_context *msg, bool foreground)
     129{
     130        if (foreground) {
     131                /* if we are running in the foreground then look for
     132                   EOF on stdin, and exit if it happens. This allows
     133                   us to die if the parent process dies
     134                   Only do this on a pipe or socket, no other device.
     135                */
     136                struct stat st;
     137                if (fstat(0, &st) != 0) {
     138                        return false;
     139                }
     140                if (S_ISFIFO(st.st_mode) || S_ISSOCK(st.st_mode)) {
     141                        tevent_add_fd(nmbd_event_context(),
     142                                nmbd_event_context(),
     143                                0,
     144                                TEVENT_FD_READ,
     145                                nmbd_stdin_handler,
     146                                msg);
     147                }
    110148        }
    111149
     
    126164                                 void *private_data)
    127165{
     166        struct messaging_context *msg = talloc_get_type_abort(
     167                private_data, struct messaging_context);
     168
    128169        DEBUG(0,("Got SIGHUP dumping debug info.\n"));
    129         msg_reload_nmbd_services(nmbd_messaging_context(),
    130                                  NULL, MSG_SMB_CONF_UPDATED,
    131                                  procid_self(), NULL);
    132 }
    133 
    134 static bool nmbd_setup_sig_hup_handler(void)
     170        msg_reload_nmbd_services(msg, NULL, MSG_SMB_CONF_UPDATED,
     171                                 messaging_server_id(msg), NULL);
     172}
     173
     174static bool nmbd_setup_sig_hup_handler(struct messaging_context *msg)
    135175{
    136176        struct tevent_signal *se;
     
    140180                               SIGHUP, 0,
    141181                               nmbd_sig_hup_handler,
    142                                NULL);
     182                               msg);
    143183        if (!se) {
    144184                DEBUG(0,("failed to setup SIGHUP handler"));
     
    159199                           DATA_BLOB *data)
    160200{
    161         terminate();
    162 }
    163 
    164 /**************************************************************************** **
    165  Possibly continue after a fault.
    166  **************************************************************************** */
    167 
    168 static void fault_continue(void)
    169 {
    170         dump_core();
     201        terminate(msg);
    171202}
    172203
     
    178209{
    179210        static time_t lastrun = 0;
    180  
     211
    181212        if ( !lastrun )
    182213                lastrun = t;
     
    250281                }
    251282
    252                 ip = ((struct sockaddr_in *)(void *)&iface->ip)->sin_addr;
    253                 nmask = ((struct sockaddr_in *)(void *)
     283                ip = ((const struct sockaddr_in *)(const void *)&iface->ip)->sin_addr;
     284                nmask = ((const struct sockaddr_in *)(const void *)
    254285                         &iface->netmask)->sin_addr;
    255286
     
    260291                 */
    261292
    262                 if (is_loopback_addr((struct sockaddr *)(void *)&iface->ip)) {
     293                if (is_loopback_addr((const struct sockaddr *)(const void *)&iface->ip)) {
    263294                        DEBUG(2,("reload_interfaces: Ignoring loopback "
    264295                                "interface %s\n",
     
    366397
    367398        if ( lp_loaded() ) {
    368                 char *fname = lp_configfile();
     399                char *fname = lp_next_configfile(talloc_tos());
    369400                if (file_exist(fname) && !strcsequal(fname,get_dyn_CONFIGFILE())) {
    370401                        set_dyn_CONFIGFILE(fname);
     
    377408                return(True);
    378409
    379         ret = lp_load(get_dyn_CONFIGFILE(), True , False, False, True);
     410        ret = lp_load_global(get_dyn_CONFIGFILE());
    380411
    381412        /* perhaps the config filename is now set */
     
    384415                reload_nmbd_services( True );
    385416        }
     417
     418        reopen_logs();
    386419
    387420        return(ret);
     
    470503 **************************************************************************** */
    471504
    472 static void process(void)
     505static void process(struct messaging_context *msg)
    473506{
    474507        bool run_election;
     
    491524                 */
    492525
    493                 if(listen_for_packets(run_election)) {
     526                if (listen_for_packets(msg, run_election)) {
    494527                        TALLOC_FREE(frame);
    495528                        return;
     
    675708{
    676709        struct sockaddr_storage ss;
    677         const char *sock_addr = lp_socket_address();
     710        const char *sock_addr = lp_nbt_client_socket_address();
    678711
    679712        /*
     
    741774 int main(int argc, const char *argv[])
    742775{
    743         static bool is_daemon;
    744         static bool opt_interactive;
    745         static bool Fork = true;
    746         static bool no_process_group;
    747         static bool log_stdout;
     776        bool is_daemon = false;
     777        bool opt_interactive = false;
     778        bool Fork = true;
     779        bool no_process_group = false;
     780        bool log_stdout = false;
    748781        poptContext pc;
    749782        char *p_lmhosts = NULL;
    750783        int opt;
     784        struct messaging_context *msg;
    751785        enum {
    752786                OPT_DAEMON = 1000,
     
    770804        TALLOC_CTX *frame;
    771805        NTSTATUS status;
     806        bool ok;
    772807
    773808        /*
     
    777812        frame = talloc_stackframe();
    778813
    779         load_case_tables();
     814        /*
     815         * We want total control over the permissions on created files,
     816         * so set our umask to 0.
     817         */
     818        umask(0);
     819
     820        setup_logging(argv[0], DEBUG_DEFAULT_STDOUT);
     821
     822        smb_init_locale();
    780823
    781824        global_nmb_port = NMB_PORT;
     
    809852
    810853        global_in_nmbd = true;
    811        
     854
    812855        StartupTime = time(NULL);
    813        
    814         sys_srandom(time(NULL) ^ sys_getpid());
    815        
     856
     857        sys_srandom(time(NULL) ^ getpid());
     858
    816859        if (!override_logfile) {
    817860                char *lfile = NULL;
     
    822865                SAFE_FREE(lfile);
    823866        }
    824        
    825         fault_setup((void (*)(void *))fault_continue );
    826         dump_core_setup("nmbd");
    827        
     867
     868        fault_setup();
     869        dump_core_setup("nmbd", lp_logfile(talloc_tos()));
     870
    828871        /* POSIX demands that signals are inherited. If the invoking process has
    829872         * these signals masked, we will have problems, as we won't receive them. */
     
    842885#endif
    843886
     887        /* Ignore children - no zombies. */
     888        CatchChild();
     889
    844890        if ( opt_interactive ) {
    845891                Fork = False;
     
    851897                exit(1);
    852898        }
     899
    853900        if (log_stdout) {
    854                 setup_logging( argv[0], DEBUG_STDOUT);
     901                setup_logging(argv[0], DEBUG_STDOUT);
    855902        } else {
    856903                setup_logging( argv[0], DEBUG_FILE);
     
    863910
    864911        if (!lp_load_initial_only(get_dyn_CONFIGFILE())) {
    865                 DEBUG(0, ("error opening config file\n"));
     912                DEBUG(0, ("error opening config file '%s'\n", get_dyn_CONFIGFILE()));
    866913                exit(1);
    867914        }
    868915
    869         if (nmbd_messaging_context() == NULL) {
     916        reopen_logs();
     917
     918        if (lp_server_role() == ROLE_ACTIVE_DIRECTORY_DC
     919            && !lp_parm_bool(-1, "server role check", "inhibit", false)) {
     920                /* TODO: when we have a merged set of defaults for
     921                 * loadparm, we could possibly check if the internal
     922                 * nbt server is in the list, and allow a startup if disabled */
     923                DEBUG(0, ("server role = 'active directory domain controller' not compatible with running nmbd standalone. \n"));
     924                DEBUGADD(0, ("You should start 'samba' instead, and it will control starting the internal nbt server\n"));
     925                exit(1);
     926        }
     927
     928        if (!cluster_probe_ok()) {
     929                exit(1);
     930        }
     931
     932        msg = messaging_init(NULL, server_event_context());
     933        if (msg == NULL) {
    870934                return 1;
    871935        }
     
    887951
    888952        if (!is_daemon && !is_a_socket(0)) {
    889                 DEBUG(0,("standard input is not a socket, assuming -D option\n"));
     953                DEBUG(3, ("standard input is not a socket, assuming -D option\n"));
    890954                is_daemon = True;
    891955        }
    892  
     956
    893957        if (is_daemon && !opt_interactive) {
    894                 DEBUG( 2, ( "Becoming a daemon.\n" ) );
     958                DEBUG(3, ("Becoming a daemon.\n"));
    895959                become_daemon(Fork, no_process_group, log_stdout);
    896960        }
     
    905969#endif
    906970
    907         if (nmbd_messaging_context() == NULL) {
    908                 return 1;
    909         }
    910 
    911971#ifndef SYNC_DNS
    912972        /* Setup the async dns. We do it here so it doesn't have all the other
    913973                stuff initialised and thus chewing memory and sockets */
    914         if(lp_we_are_a_wins_server() && lp_dns_proxy()) {
    915                 start_async_dns();
     974        if(lp_we_are_a_wins_server() && lp_wins_dns_proxy()) {
     975                start_async_dns(msg);
    916976        }
    917977#endif
    918978
    919         if (!directory_exist(lp_lockdir())) {
    920                 mkdir(lp_lockdir(), 0755);
    921         }
    922 
    923         pidfile_create("nmbd");
    924 
    925         status = reinit_after_fork(nmbd_messaging_context(),
    926                                    nmbd_event_context(),
    927                                    procid_self(), false);
     979        ok = directory_create_or_exist(lp_lock_directory(), 0755);
     980        if (!ok) {
     981                exit_daemon("Failed to create directory for lock files, check 'lock directory'", errno);
     982        }
     983
     984        ok = directory_create_or_exist(lp_pid_directory(), 0755);
     985        if (!ok) {
     986                exit_daemon("Failed to create directory for pid files, check 'pid directory'", errno);
     987        }
     988
     989        pidfile_create(lp_pid_directory(), "nmbd");
     990
     991        status = reinit_after_fork(msg, nmbd_event_context(), false, NULL);
    928992
    929993        if (!NT_STATUS_IS_OK(status)) {
    930                 DEBUG(0,("reinit_after_fork() failed\n"));
     994                exit_daemon("reinit_after_fork() failed", map_errno_from_nt_status(status));
     995        }
     996
     997        /*
     998         * Do not initialize the parent-child-pipe before becoming
     999         * a daemon: this is used to detect a died parent in the child
     1000         * process.
     1001         */
     1002        status = init_before_fork();
     1003        if (!NT_STATUS_IS_OK(status)) {
     1004                exit_daemon(nt_errstr(status), map_errno_from_nt_status(status));
     1005        }
     1006
     1007        if (!nmbd_setup_sig_term_handler(msg))
     1008                exit_daemon("NMBD failed to setup signal handler", EINVAL);
     1009        if (!nmbd_setup_stdin_handler(msg, !Fork))
     1010                exit_daemon("NMBD failed to setup stdin handler", EINVAL);
     1011        if (!nmbd_setup_sig_hup_handler(msg))
     1012                exit_daemon("NMBD failed to setup SIGHUP handler", EINVAL);
     1013
     1014        if (!messaging_parent_dgm_cleanup_init(msg)) {
    9311015                exit(1);
    9321016        }
    9331017
    934         if (!nmbd_setup_sig_term_handler())
    935                 exit(1);
    936         if (!nmbd_setup_sig_hup_handler())
    937                 exit(1);
    938 
    9391018        /* get broadcast messages */
    9401019
    941         if (!serverid_register(procid_self(),
    942                                FLAG_MSG_GENERAL|FLAG_MSG_DBWRAP)) {
    943                 DEBUG(1, ("Could not register myself in serverid.tdb\n"));
    944                 exit(1);
    945         }
    946 
    947         messaging_register(nmbd_messaging_context(), NULL,
    948                            MSG_FORCE_ELECTION, nmbd_message_election);
     1020        if (!serverid_register(messaging_server_id(msg),
     1021                                FLAG_MSG_GENERAL |
     1022                                FLAG_MSG_NMBD |
     1023                                FLAG_MSG_DBWRAP)) {
     1024                exit_daemon("Could not register NMBD process in serverid.tdb", EACCES);
     1025        }
     1026
     1027        messaging_register(msg, NULL, MSG_FORCE_ELECTION,
     1028                           nmbd_message_election);
    9491029#if 0
    9501030        /* Until winsrepl is done. */
    951         messaging_register(nmbd_messaging_context(), NULL,
    952                            MSG_WINS_NEW_ENTRY, nmbd_wins_new_entry);
     1031        messaging_register(msg, NULL, MSG_WINS_NEW_ENTRY,
     1032                           nmbd_wins_new_entry);
    9531033#endif
    954         messaging_register(nmbd_messaging_context(), NULL,
    955                            MSG_SHUTDOWN, nmbd_terminate);
    956         messaging_register(nmbd_messaging_context(), NULL,
    957                            MSG_SMB_CONF_UPDATED, msg_reload_nmbd_services);
    958         messaging_register(nmbd_messaging_context(), NULL,
    959                            MSG_SEND_PACKET, msg_nmbd_send_packet);
     1034        messaging_register(msg, NULL, MSG_SHUTDOWN,
     1035                           nmbd_terminate);
     1036        messaging_register(msg, NULL, MSG_SMB_CONF_UPDATED,
     1037                           msg_reload_nmbd_services);
     1038        messaging_register(msg, NULL, MSG_SEND_PACKET,
     1039                           msg_nmbd_send_packet);
    9601040
    9611041        TimeInit();
     
    9731053        /* Create an nmbd subnet record for each of the above. */
    9741054        if( False == create_subnets() ) {
    975                 DEBUG(0,("ERROR: Failed when creating subnet lists. Exiting.\n"));
    9761055                kill_async_dns_child();
    977                 exit(1);
     1056                exit_daemon("NMBD failed when creating subnet lists", EACCES);
    9781057        }
    9791058
     
    9871066        /* If we are acting as a WINS server, initialise data structures. */
    9881067        if( !initialise_wins() ) {
    989                 DEBUG( 0, ( "nmbd: Failed when initialising WINS server.\n" ) );
    9901068                kill_async_dns_child();
    991                 exit(1);
     1069                exit_daemon( "NMBD failed when initialising WINS server.", EACCES);
    9921070        }
    9931071
     
    10011079
    10021080        if( False == register_my_workgroup_and_names() ) {
    1003                 DEBUG(0,("ERROR: Failed when creating my my workgroup. Exiting.\n"));
    10041081                kill_async_dns_child();
    1005                 exit(1);
     1082                exit_daemon( "NMBD failed when creating my workgroup.", EACCES);
    10061083        }
    10071084
    10081085        if (!initialize_nmbd_proxy_logon()) {
    1009                 DEBUG(0,("ERROR: Failed setup nmbd_proxy_logon.\n"));
    10101086                kill_async_dns_child();
    1011                 exit(1);
     1087                exit_daemon( "NMBD failed to setup nmbd_proxy_logon.", EACCES);
    10121088        }
    10131089
    10141090        if (!nmbd_init_packet_server()) {
    10151091                kill_async_dns_child();
    1016                 exit(1);
    1017         }
     1092                exit_daemon( "NMBD failed to setup packet server.", EACCES);
     1093        }
     1094
     1095        if (is_daemon && !opt_interactive) {
     1096                daemon_ready("nmbd");
     1097        }
    10181098
    10191099        TALLOC_FREE(frame);
    1020         process();
     1100        process(msg);
    10211101
    10221102        kill_async_dns_child();
  • vendor/current/source3/nmbd/nmbd_become_dmb.c

    r740 r988  
    2525#include "nmbd/nmbd.h"
    2626
    27 extern uint16 samba_nb_type; /* Samba's NetBIOS type. */
     27extern uint16_t samba_nb_type; /* Samba's NetBIOS type. */
    2828
    2929static void become_domain_master_browser_bcast(const char *);
     
    5252        work->dom_state = DOMAIN_NONE;
    5353
    54         if((servrec = find_server_in_workgroup( work, global_myname())) == NULL) {
     54        if((servrec = find_server_in_workgroup( work, lp_netbios_name())) == NULL) {
    5555                DEBUG(0,("become_domain_master_fail: Error - cannot find server %s \
    5656in workgroup %s on subnet %s\n",
    57                         global_myname(), work->work_group, subrec->subnet_name));
     57                        lp_netbios_name(), work->work_group, subrec->subnet_name));
    5858                return;
    5959        }
     
    7777                                        struct userdata_struct *userdata,
    7878                                        struct nmb_name *registered_name,
    79                                         uint16 nb_flags,
     79                                        uint16_t nb_flags,
    8080                                        int ttl, struct in_addr registered_ip)
    8181{
     
    9393        }
    9494
    95         if((servrec = find_server_in_workgroup( work, global_myname())) == NULL) {
     95        if((servrec = find_server_in_workgroup( work, lp_netbios_name())) == NULL) {
    9696                DEBUG(0,("become_domain_master_stage2: Error - cannot find server %s \
    9797in workgroup %s on subnet %s\n",
    98                 global_myname(), regname, subrec->subnet_name));
     98                lp_netbios_name(), regname, subrec->subnet_name));
    9999                work->dom_state = DOMAIN_NONE;
    100100                return;
     
    111111
    112112        if( DEBUGLVL( 0 ) ) {
    113                 dbgtext( "*****\n\nSamba server %s ", global_myname() );
     113                dbgtext( "*****\n\nSamba server %s ", lp_netbios_name() );
    114114                dbgtext( "is now a domain master browser for " );
    115115                dbgtext( "workgroup %s ", work->work_group );
     
    127127                   a local master browser. */
    128128
    129                 make_nmb_name(&nmbname, global_myname(), 0x20);
     129                make_nmb_name(&nmbname, lp_netbios_name(), 0x20);
    130130
    131131                work->dmb_name = nmbname;
     
    376376
    377377        /* Do the "internet group" - <1c> names. */
    378         if (lp_domain_logons())
     378        if (IS_DC)
    379379                add_logon_names();
    380380
  • vendor/current/source3/nmbd/nmbd_become_lmb.c

    r740 r988  
    2525#include "../librpc/gen_ndr/svcctl.h"
    2626
    27 extern uint16 samba_nb_type; /* Samba's NetBIOS name type. */
     27extern uint16_t samba_nb_type; /* Samba's NetBIOS name type. */
    2828
    2929/*******************************************************************
     
    3333
    3434void insert_permanent_name_into_unicast( struct subnet_record *subrec,
    35                                                 struct nmb_name *nmbname, uint16 nb_type )
     35                                                struct nmb_name *nmbname, uint16_t nb_type )
    3636{
    3737        unstring name;
     
    8686        }
    8787
    88         if((servrec = find_server_in_workgroup( work, global_myname())) == NULL) {
     88        if((servrec = find_server_in_workgroup( work, lp_netbios_name())) == NULL) {
    8989                DEBUG(0,("reset_workgroup_state: Error - cannot find server %s \
    9090in workgroup %s on subnet %s\n",
    91                         global_myname(), work->work_group, subrec->subnet_name));
     91                        lp_netbios_name(), work->work_group, subrec->subnet_name));
    9292                work->mst_state = lp_local_master() ? MST_POTENTIAL : MST_NONE;
    9393                return;
     
    150150        if( DEBUGLVL( 0 ) ) {
    151151                dbgtext( "*****\n\n" );
    152                 dbgtext( "Samba name server %s ", global_myname() );
     152                dbgtext( "Samba name server %s ", lp_netbios_name() );
    153153                dbgtext( "has stopped being a local master browser " );
    154154                dbgtext( "for workgroup %s ", relname );
     
    186186        if( DEBUGLVL( 0 ) ) {
    187187                dbgtext( "*****\n\n" );
    188                 dbgtext( "Samba name server %s ", global_myname() );
     188                dbgtext( "Samba name server %s ", lp_netbios_name() );
    189189                dbgtext( "has stopped being a local master browser " );
    190190                dbgtext( "for workgroup %s ", failname );
     
    281281on subnet %s\n",work->work_group, subrec->subnet_name));
    282282 
    283         if(find_server_in_workgroup( work, global_myname()) == NULL) {
     283        if(find_server_in_workgroup( work, lp_netbios_name()) == NULL) {
    284284                DEBUG(0,("unbecome_local_master_browser: Error - cannot find server %s \
    285285in workgroup %s on subnet %s\n",
    286                         global_myname(), work->work_group, subrec->subnet_name));
     286                        lp_netbios_name(), work->work_group, subrec->subnet_name));
    287287                        work->mst_state = lp_local_master() ? MST_POTENTIAL : MST_NONE;
    288288                return;
     
    325325                                        struct userdata_struct *userdata,
    326326                                        struct nmb_name *registered_name,
    327                                         uint16 nb_flags,
     327                                        uint16_t nb_flags,
    328328                                        int ttl, struct in_addr registered_ip)
    329329{
     
    343343        }
    344344
    345         if((servrec = find_server_in_workgroup( work, global_myname())) == NULL) {
     345        if((servrec = find_server_in_workgroup( work, lp_netbios_name())) == NULL) {
    346346                DEBUG(0,("become_local_master_stage2: Error - cannot find server %s \
    347347in workgroup %s on subnet %s\n",
    348                         global_myname(), regname, subrec->subnet_name));
     348                        lp_netbios_name(), regname, subrec->subnet_name));
    349349                        work->mst_state = lp_local_master() ? MST_POTENTIAL : MST_NONE;
    350350                return;
     
    364364
    365365        /* Add this name to the workgroup as local master browser. */
    366         set_workgroup_local_master_browser_name( work, global_myname());
     366        set_workgroup_local_master_browser_name( work, lp_netbios_name());
    367367
    368368        /* Count the number of servers we have on our list. If it's
     
    397397        if( DEBUGLVL( 0 ) ) {
    398398                dbgtext( "*****\n\n" );
    399                 dbgtext( "Samba name server %s ", global_myname() );
     399                dbgtext( "Samba name server %s ", lp_netbios_name() );
    400400                dbgtext( "is now a local master browser " );
    401401                dbgtext( "for workgroup %s ", work->work_group );
     
    438438                                        struct userdata_struct *userdata,
    439439                                        struct nmb_name *registered_name,
    440                                         uint16 nb_flags,
     440                                        uint16_t nb_flags,
    441441                                        int ttl, struct in_addr registered_ip)
    442442{
     
    488488        }
    489489
    490         if(find_server_in_workgroup(work, global_myname()) == NULL) {
     490        if(find_server_in_workgroup(work, lp_netbios_name()) == NULL) {
    491491                DEBUG(0,("become_local_master_fail1: Error - cannot find server %s \
    492492in workgroup %s on subnet %s\n",
    493                         global_myname(), work->work_group, subrec->subnet_name));
     493                        lp_netbios_name(), work->work_group, subrec->subnet_name));
    494494                return;
    495495        }
     
    528528        }
    529529
    530         if(find_server_in_workgroup( work, global_myname()) == NULL) {
     530        if(find_server_in_workgroup( work, lp_netbios_name()) == NULL) {
    531531                DEBUG(0,("become_local_master_browser: Error - cannot find server %s \
    532532in workgroup %s on subnet %s\n",
    533                         global_myname(), work->work_group, subrec->subnet_name));
     533                        lp_netbios_name(), work->work_group, subrec->subnet_name));
    534534                return;
    535535        }
     
    555555        userdata->free_fn = NULL;
    556556        userdata->userdata_len = strlen(work->work_group)+1;
    557         overmalloc_safe_strcpy(userdata->data, work->work_group, size - sizeof(*userdata) - 1);
     557        strlcpy(userdata->data, work->work_group, size - sizeof(*userdata));
    558558
    559559        /* Register the special browser group name. */
  • vendor/current/source3/nmbd/nmbd_browserdb.c

    r740 r988  
    110110        unstrcpy( browc->lmb_name, browser_name);
    111111        unstrcpy( browc->work_group, work_name);
    112         strupper_m( browc->lmb_name );
    113         strupper_m( browc->work_group );
     112        if (!strupper_m( browc->lmb_name )) {
     113                SAFE_FREE(browc);
     114                return NULL;
     115        }
     116        if (!strupper_m( browc->work_group )) {
     117                SAFE_FREE(browc);
     118                return NULL;
     119        }
    114120 
    115121        browc->ip = ip;
    116122 
    117         DLIST_ADD_END(lmb_browserlist, browc, struct browse_cache_record *);
     123        DLIST_ADD_END(lmb_browserlist, browc);
    118124
    119         if( DEBUGLVL( 3 ) ) {
    120                 Debug1( "nmbd_browserdb:create_browser_in_lmb_cache()\n" );
    121                 Debug1( "  Added lmb cache entry for workgroup %s ", browc->work_group );
    122                 Debug1( "name %s IP %s ", browc->lmb_name, inet_ntoa(ip) );
    123                 Debug1( "ttl %d\n", (int)browc->death_time );
    124         }
     125        DEBUG(3, ("nmbd_browserdb:create_browser_in_lmb_cache()\n"));
     126        DEBUGADD(3, ("  Added lmb cache entry for workgroup %s name %s IP %s "
     127                     "ttl %d\n", browc->work_group, browc->lmb_name,
     128                     inet_ntoa(ip), (int)browc->death_time));
    125129 
    126130        return( browc );
     
    167171
    168172                if( browc->death_time < t ) {
    169                         if( DEBUGLVL( 3 ) ) {
    170                                 Debug1( "nmbd_browserdb:expire_lmb_browsers()\n" );
    171                                 Debug1( "  Removing timed out lmb entry %s\n", browc->lmb_name );
    172                         }
     173                        DEBUG(3, ("nmbd_browserdb:expire_lmb_browsers()\n"));
     174                        DEBUGADD(3, ("  Removing timed out lmb entry %s\n",
     175                                     browc->lmb_name));
    173176                        remove_lmb_browser_entry( browc );
    174177                }
  • vendor/current/source3/nmbd/nmbd_browsesync.c

    r740 r988  
    120120        p++;
    121121
    122         unstrcpy(myname, global_myname());
    123         strupper_m(myname);
     122        unstrcpy(myname, lp_netbios_name());
     123        if (!strupper_m(myname)) {
     124                DEBUG(2,("strupper_m %s failed\n", myname));
     125                return;
     126        }
    124127        myname[15]='\0';
    125128        /* The call below does CH_UNIX -> CH_DOS conversion. JRA */
     
    138141        pull_ascii_nstring(dmb_name, sizeof(dmb_name), work->dmb_name.name);
    139142        send_mailslot(True, BROWSE_MAILSLOT, outbuf,PTR_DIFF(p,outbuf),
    140                 global_myname(), 0x0, dmb_name, 0x0,
     143                lp_netbios_name(), 0x0, dmb_name, 0x0,
    141144                work->dmb_addr, FIRST_SUBNET->myip, DGRAM_PORT);
    142145}
     
    192195     the first SERVER<0x20> name. */
    193196
    194         if(answers->rdata != NULL) {
     197        if (answers->rdlength > 0) {
    195198                char *p = answers->rdata;
    196199                int numnames = CVAL(p, 0);
     
    200203                while (numnames--) {
    201204                        unstring qname;
    202                         uint16 nb_flags;
     205                        uint16_t nb_flags;
    203206                        int name_type;
    204207
     
    331334        userdata->free_fn = NULL;
    332335        userdata->userdata_len = strlen(work->work_group)+1;
    333         overmalloc_safe_strcpy(userdata->data, work->work_group, size - sizeof(*userdata) - 1);
     336        strlcpy(userdata->data, work->work_group, size - sizeof(*userdata));
    334337
    335338        node_status( subrec, &nmbname, answer_ip,
     
    400403                                              struct in_addr from_ip)
    401404{
    402         struct work_record *work;
    403405        unstring server_name;
    404406
     
    415417         */
    416418
    417         if(answers->rdata != NULL) {
     419        if (answers->rdlength > 0) {
    418420                char *p = answers->rdata;
    419421                int numnames = CVAL(p, 0);
     
    423425                while (numnames--) {
    424426                        unstring qname;
    425                         uint16 nb_flags;
     427                        uint16_t nb_flags;
    426428                        int name_type;
    427429
     
    436438                                        server_name[0] == 0) {
    437439                                /* this is almost certainly the server netbios name */
    438                                 unstrcpy(server_name, qname);
     440                                strlcpy(server_name, qname, sizeof(server_name));
    439441                                continue;
    440442                        }
    441443
    442444                        if(!(nb_flags & NB_GROUP) && (name_type == 0x1b)) {
     445                                struct work_record *work;
     446
    443447                                if( DEBUGLVL( 5 ) ) {
    444448                                        dbgtext( "get_domain_master_name_node_status_success:\n" );
     
    453457                                 */
    454458
    455                                 if((work = find_workgroup_on_subnet( subrec, qname)) == NULL) {
     459                                work = find_workgroup_on_subnet( subrec, qname);
     460                                if (work == NULL) {
    456461                                        struct nmb_name nmbname;
    457462                                        /*
    458463                                         * Add it - with an hour in the cache.
    459464                                         */
    460                                         if(!(work= create_workgroup_on_subnet(subrec, qname, 60*60)))
     465                                        work = create_workgroup_on_subnet(subrec, qname, 60*60);
     466                                        if (work == NULL) {
    461467                                                return;
     468                                        }
    462469
    463470                                        /* remember who the master is */
    464                                         unstrcpy(work->local_master_browser_name, server_name);
     471                                        strlcpy(work->local_master_browser_name,
     472                                                server_name,
     473                                                sizeof(work->local_master_browser_name));
    465474                                        make_nmb_name(&nmbname, server_name, 0x20);
    466475                                        work->dmb_name = nmbname;
     
    470479                        }
    471480                }
    472         } else if( DEBUGLVL( 0 ) ) {
     481        } else if( DEBUGLVL( 1 ) ) {
    473482                dbgtext( "get_domain_master_name_node_status_success:\n" );
    474483                dbgtext( "Failed to find a WORKGROUP<0x1b> name in reply from IP " );
     
    484493                       struct response_record *rrec)
    485494{
    486         if( DEBUGLVL( 0 ) ) {
     495        if( DEBUGLVL( 2 ) ) {
    487496                dbgtext( "get_domain_master_name_node_status_fail:\n" );
    488497                dbgtext( "Doing a node status request to the domain master browser " );
  • vendor/current/source3/nmbd/nmbd_elections.c

    r740 r988  
    2323#include "includes.h"
    2424#include "nmbd/nmbd.h"
    25 #include "smbprofile.h"
    2625
    2726/* Election parameters. */
     
    3332
    3433static void send_election_dgram(struct subnet_record *subrec, const char *workgroup_name,
    35                                 uint32 criterion, int timeup,const char *server_name)
     34                                uint32_t criterion, int timeup,const char *server_name)
    3635{
    3736        char outbuf[1024];
     
    5251        p += 13;
    5352        unstrcpy(srv_name, server_name);
    54         strupper_m(srv_name);
     53        if (!strupper_m(srv_name)) {
     54                DEBUG(2,("strupper_m failed for %s\n", srv_name));
     55                return;
     56        }
    5557        /* The following call does UNIX -> DOS charset conversion. */
    5658        push_ascii(p, srv_name, sizeof(outbuf)-PTR_DIFF(p,outbuf)-1, STR_TERMINATE);
     
    5860
    5961        send_mailslot(False, BROWSE_MAILSLOT, outbuf, PTR_DIFF(p,outbuf),
    60                 global_myname(), 0,
     62                lp_netbios_name(), 0,
    6163                workgroup_name, 0x1e,
    6264                subrec->bcast_ip, subrec->myip, DGRAM_PORT);
     
    165167        struct subnet_record *subrec;
    166168 
    167         START_PROFILE(run_elections);
    168 
    169169        /* Send election packets once every 2 seconds - note */
    170170        if (lastime && (t - lastime < 2)) {
    171                 END_PROFILE(run_elections);
    172171                return;
    173172        }
     
    195194
    196195                                send_election_dgram(subrec, work->work_group, work->ElectionCriterion,
    197                                                 t - StartupTime, global_myname());
     196                                                t - StartupTime, lp_netbios_name());
    198197             
    199198                                if (work->ElectionCount++ >= 4) {
     
    209208                }
    210209        }
    211         END_PROFILE(run_elections);
    212210}
    213211
     
    217215
    218216static bool win_election(struct work_record *work, int version,
    219                          uint32 criterion, int timeup, const char *server_name)
     217                         uint32_t criterion, int timeup, const char *server_name)
    220218
    221219        int mytimeup = time(NULL) - StartupTime;
    222         uint32 mycriterion = work->ElectionCriterion;
     220        uint32_t mycriterion = work->ElectionCriterion;
    223221
    224222        /* If local master is false then never win in election broadcasts. */
     
    232230                        criterion, mycriterion,
    233231                        timeup, mytimeup,
    234                         server_name, global_myname()));
     232                        server_name, lp_netbios_name()));
    235233
    236234        if (version > ELECTION_VERSION)
     
    249247                return(True);
    250248
    251         if (StrCaseCmp(global_myname(), server_name) > 0)
     249        if (strcasecmp_m(lp_netbios_name(), server_name) > 0)
    252250                return(False);
    253251 
     
    263261        struct dgram_packet *dgram = &p->packet.dgram;
    264262        int version = CVAL(buf,0);
    265         uint32 criterion = IVAL(buf,1);
     263        uint32_t criterion = IVAL(buf,1);
    266264        int timeup = IVAL(buf,5)/1000;
    267265        unstring server_name;
    268266        struct work_record *work;
    269267        unstring workgroup_name;
    270 
    271         START_PROFILE(election);
    272268
    273269        pull_ascii_nstring(server_name, sizeof(server_name), buf+13);
     
    317313        }
    318314done:
    319 
    320         END_PROFILE(election);
     315        return;
    321316}
    322317
  • vendor/current/source3/nmbd/nmbd_incomingdgrams.c

    r740 r988  
    2424#include "../librpc/gen_ndr/svcctl.h"
    2525#include "nmbd/nmbd.h"
    26 #include "smbprofile.h"
    2726
    2827extern bool found_lm_clients;
     
    101100        int ttl = IVAL(buf,1)/1000;
    102101        unstring announce_name;
    103         uint32 servertype = IVAL(buf,23);
     102        uint32_t servertype = IVAL(buf,23);
    104103        fstring comment;
    105104        struct work_record *work;
     
    107106        unstring work_name;
    108107        unstring source_name;
    109 
    110         START_PROFILE(host_announce);
     108        ZERO_STRUCT(source_name);
     109        ZERO_STRUCT(announce_name);
    111110
    112111        pull_ascii_fstring(comment, buf+31);
     
    145144         */
    146145
    147         if(strequal(work_name, global_myname()))
     146        if(strequal(work_name, lp_netbios_name()))
    148147                unstrcpy(work_name,lp_workgroup());
    149148
     
    173172                        servrec->serv.type = servertype|SV_TYPE_LOCAL_LIST_ONLY;
    174173                        update_server_ttl( servrec, ttl);
    175                         fstrcpy(servrec->serv.comment,comment);
     174                        strlcpy(servrec->serv.comment,comment,sizeof(servrec->serv.comment));
    176175                }
    177176        } else {
     
    188187        subrec->work_changed = True;
    189188done:
    190 
    191         END_PROFILE(host_announce);
     189        return;
    192190}
    193191
     
    202200        unstring workgroup_announce_name;
    203201        unstring master_name;
    204         uint32 servertype = IVAL(buf,23);
     202        uint32_t servertype = IVAL(buf,23);
    205203        struct work_record *work;
    206204        unstring source_name;
    207205        unstring dest_name;
    208 
    209         START_PROFILE(workgroup_announce);
    210206
    211207        pull_ascii_nstring(workgroup_announce_name,sizeof(workgroup_announce_name),buf+5);
     
    245241
    246242done:
    247 
    248         END_PROFILE(workgroup_announce);
     243        return;
    249244}
    250245
     
    258253        int ttl = IVAL(buf,1)/1000;
    259254        unstring server_name;
    260         uint32 servertype = IVAL(buf,23);
     255        uint32_t servertype = IVAL(buf,23);
    261256        fstring comment;
    262257        unstring work_name;
     
    264259        struct server_record *servrec;
    265260        unstring source_name;
    266 
    267         START_PROFILE(local_master_announce);
    268261
    269262        pull_ascii_nstring(server_name,sizeof(server_name),buf+5);
     
    337330                } else {
    338331                        /* Update the record. */
    339                         servrec->serv.type = servertype|SV_TYPE_LOCAL_LIST_ONLY;
     332                        if (servrec->serv.type !=
     333                                        (servertype|SV_TYPE_LOCAL_LIST_ONLY)) {
     334                                servrec->serv.type =
     335                                        servertype|SV_TYPE_LOCAL_LIST_ONLY;
     336                                subrec->work_changed = true;
     337                        }
     338                        if (!strequal(servrec->serv.comment,comment)) {
     339                                strlcpy(servrec->serv.comment,
     340                                        comment,
     341                                        sizeof(servrec->serv.comment));
     342                                subrec->work_changed = true;
     343                        }
    340344                        update_server_ttl(servrec, ttl);
    341                         fstrcpy(servrec->serv.comment,comment);
    342                 }
    343        
    344                 set_workgroup_local_master_browser_name( work, server_name );
     345                }
     346
     347                if (!strequal(work->local_master_browser_name, server_name)) {
     348                        set_workgroup_local_master_browser_name( work, server_name );
     349                        subrec->work_changed = true;
     350                }
    345351        } else {
    346352                /*
     
    354360        }
    355361
    356         subrec->work_changed = True;
    357362done:
    358 
    359         END_PROFILE(local_master_announce);
     363        return;
    360364}
    361365
     
    373377        struct work_record *work;
    374378        struct browse_cache_record *browrec;
    375 
    376         START_PROFILE(master_browser_announce);
    377379
    378380        pull_ascii_nstring(local_master_name,sizeof(local_master_name),buf);
     
    411413
    412414done:
    413 
    414         END_PROFILE(master_browser_announce);
     415        return;
    415416}
    416417
     
    422423{
    423424        struct dgram_packet *dgram = &p->packet.dgram;
    424         uint32 servertype = IVAL(buf,1);
     425        uint32_t servertype = IVAL(buf,1);
    425426        int osmajor=CVAL(buf,5);           /* major version of node software */
    426427        int osminor=CVAL(buf,6);           /* minor version of node software */
     
    434435        char *s = get_safe_str_ptr(buf,len,discard_const_p(char, buf),9);
    435436
    436         START_PROFILE(lm_host_announce);
    437437        if (!s) {
    438438                goto done;
     
    485485         */
    486486
    487         if(strequal(work_name, global_myname()))
     487        if(strequal(work_name, lp_netbios_name()))
    488488                unstrcpy(work_name,lp_workgroup());
    489489
     
    513513                        servrec->serv.type = servertype|SV_TYPE_LOCAL_LIST_ONLY;
    514514                        update_server_ttl( servrec, ttl);
    515                         fstrcpy(servrec->serv.comment,comment);
     515                        strlcpy(servrec->serv.comment,comment,sizeof(servrec->serv.comment));
    516516                }
    517517        } else {
     
    530530
    531531done:
    532 
    533         END_PROFILE(lm_host_announce);
     532        return;
    534533}
    535534
     
    542541                                      struct nmb_name *send_to_name,
    543542                                      unsigned char max_number_requested,
    544                                       uint32 token, struct in_addr sendto_ip,
     543                                      uint32_t token, struct in_addr sendto_ip,
    545544                                      int port)
    546545{
     
    572571        /* We always return at least one name - our own. */
    573572        count = 1;
    574         unstrcpy(myname, global_myname());
    575         strupper_m(myname);
     573        unstrcpy(myname, lp_netbios_name());
     574        if (!strupper_m(myname)) {
     575                DEBUG(4,("strupper_m %s failed\n", myname));
     576                return;
     577        }
    576578        myname[15]='\0';
    577579        push_ascii(p, myname, sizeof(outbuf)-PTR_DIFF(p,outbuf)-1, STR_TERMINATE);
     
    600602      break;
    601603
    602     if(strnequal(servrec->serv.name, global_myname(),15))
     604    if(strnequal(servrec->serv.name, lp_netbios_name(),15))
    603605      continue;
    604606
     
    626628        send_mailslot(True, BROWSE_MAILSLOT,
    627629                outbuf,PTR_DIFF(p,outbuf),
    628                 global_myname(), 0,
     630                lp_netbios_name(), 0,
    629631                send_to_namestr,0,
    630632                sendto_ip, subrec->myip, port);
     
    647649        struct work_record *work;
    648650        unsigned char max_number_requested = CVAL(buf,0);
    649         uint32 token = IVAL(buf,1); /* Sender's key index for the workgroup. */
     651        uint32_t token = IVAL(buf,1); /* Sender's key index for the workgroup. */
    650652        int name_type = dgram->dest_name.name_type;
    651653        unstring workgroup_name;
    652654        struct subnet_record *search_subrec = subrec;
    653655
    654         START_PROFILE(get_backup_list);
    655656        pull_ascii_nstring(workgroup_name, sizeof(workgroup_name), dgram->dest_name.name);
    656657
     
    710711
    711712done:
    712 
    713         END_PROFILE(get_backup_list);
     713        return;
    714714}
    715715
     
    730730        int state = CVAL(buf,0);
    731731        struct subnet_record *sr;
    732 
    733         START_PROFILE(reset_browser);
    734732
    735733        DEBUG(1,("process_reset_browser: received diagnostic browser reset \
     
    765763        if (state & 0x4)
    766764                DEBUG(1,("process_reset_browser: ignoring request to stop being a browser.\n"));
    767 
    768         END_PROFILE(reset_browser);
    769765}
    770766
     
    783779        unstring workgroup_name;
    784780 
    785         START_PROFILE(announce_request);
    786 
    787781        pull_ascii_nstring(workgroup_name, sizeof(workgroup_name), dgram->dest_name.name);
    788782        DEBUG(3,("process_announce_request: Announce request from %s IP %s to %s.\n",
     
    805799        work->needannounce = True;
    806800done:
    807 
    808         END_PROFILE(announce_request);
     801        return;
    809802}
    810803
     
    823816        unstring workgroup_name;
    824817
    825         START_PROFILE(lm_announce_request);
    826 
    827818        pull_ascii_nstring(workgroup_name, sizeof(workgroup_name), dgram->dest_name.name);
    828819        DEBUG(3,("process_lm_announce_request: Announce request from %s IP %s to %s.\n",
     
    846837
    847838done:
    848 
    849         END_PROFILE(lm_announce_request);
    850 }
     839        return;
     840}
  • vendor/current/source3/nmbd/nmbd_incomingrequests.c

    r740 r988  
    6161        unstring qname;
    6262        bool bcast = nmb->header.nm_flags.bcast;
    63         uint16 nb_flags = get_nb_flags(nmb->additional->rdata);
     63        uint16_t nb_flags = get_nb_flags(nmb->additional->rdata);
    6464        bool group = (nb_flags & NB_GROUP) ? True : False;
    6565        struct name_record *namerec;
     
    193193        struct nmb_name *question = &nmb->question.question_name;
    194194        bool bcast = nmb->header.nm_flags.bcast;
    195         uint16 nb_flags = get_nb_flags(nmb->additional->rdata);
     195        uint16_t nb_flags = get_nb_flags(nmb->additional->rdata);
    196196        bool group = (nb_flags & NB_GROUP) ? True : False;
    197197        struct name_record *namerec = NULL;
     
    291291        for (l2=0;l2<15 && n2[l2] && n2[l2] != ' ';l2++)
    292292                ;
    293         l3 = strlen(global_myname());
    294 
    295         if ((l1==l3) && strncmp(n1,global_myname(),l3) == 0 &&
    296                         (l2!=l3 || strncmp(n2,global_myname(),l3) != 0))
     293        l3 = strlen(lp_netbios_name());
     294
     295        if ((l1==l3) && strncmp(n1,lp_netbios_name(),l3) == 0 &&
     296                        (l2!=l3 || strncmp(n2,lp_netbios_name(),l3) != 0))
    297297                return -1;
    298298
    299         if ((l2==l3) && strncmp(n2,global_myname(),l3) == 0 &&
    300                         (l1!=l3 || strncmp(n1,global_myname(),l3) != 0))
     299        if ((l2==l3) && strncmp(n2,lp_netbios_name(),l3) == 0 &&
     300                        (l1!=l3 || strncmp(n1,lp_netbios_name(),l3) != 0))
    301301                return 1;
    302302
     
    348348
    349349                        pull_ascii_nstring(name, sizeof(name), namerec->name.name);
    350                         strupper_m(name);
     350                        if (!strupper_m(name)) {
     351                                DEBUG(2,("strupper_m %s failed\n", name));
     352                                return;
     353                        }
    351354                        if (!strequal(name,"*") &&
    352355                                        !strequal(name,"__SAMBA__") &&
  • vendor/current/source3/nmbd/nmbd_lmhosts.c

    r740 r988  
    7171                if(name_type == -1) {
    7272                        /* Add the (0) and (0x20) names directly into the namelist for this subnet. */
    73                         (void)add_name_to_subnet(subrec,name,0x00,(uint16)NB_ACTIVE,PERMANENT_TTL,source,1,&ipaddr);
    74                         (void)add_name_to_subnet(subrec,name,0x20,(uint16)NB_ACTIVE,PERMANENT_TTL,source,1,&ipaddr);
     73                        (void)add_name_to_subnet(subrec,name,0x00,(uint16_t)NB_ACTIVE,PERMANENT_TTL,source,1,&ipaddr);
     74                        (void)add_name_to_subnet(subrec,name,0x20,(uint16_t)NB_ACTIVE,PERMANENT_TTL,source,1,&ipaddr);
    7575                } else {
    7676                        /* Add the given name type to the subnet namelist. */
    77                         (void)add_name_to_subnet(subrec,name,name_type,(uint16)NB_ACTIVE,PERMANENT_TTL,source,1,&ipaddr);
     77                        (void)add_name_to_subnet(subrec,name,name_type,(uint16_t)NB_ACTIVE,PERMANENT_TTL,source,1,&ipaddr);
    7878                }
    7979        }
  • vendor/current/source3/nmbd/nmbd_logonnames.c

    r740 r988  
    2525#include "nmbd/nmbd.h"
    2626
    27 extern uint16 samba_nb_type; /* Samba's NetBIOS type. */
     27extern uint16_t samba_nb_type; /* Samba's NetBIOS type. */
    2828
    2929/****************************************************************************
     
    4747        }
    4848
    49         if((servrec = find_server_in_workgroup( work, global_myname())) == NULL) {
     49        if((servrec = find_server_in_workgroup( work, lp_netbios_name())) == NULL) {
    5050                DEBUG(0,("become_logon_server_fail: Error - cannot find server %s \
    5151in workgroup %s on subnet %s\n",
    52                         global_myname(), failname, subrec->subnet_name));
     52                        lp_netbios_name(), failname, subrec->subnet_name));
    5353                work->log_state = LOGON_NONE;
    5454                return;
     
    7373                                        struct userdata_struct *userdata,
    7474                                        struct nmb_name *registered_name,
    75                                         uint16 nb_flags,
     75                                        uint16_t nb_flags,
    7676                                        int ttl, struct in_addr registered_ip)
    7777{
     
    8888        }
    8989
    90         if((servrec = find_server_in_workgroup( work, global_myname())) == NULL) {
     90        if((servrec = find_server_in_workgroup( work, lp_netbios_name())) == NULL) {
    9191                DEBUG(0,("become_logon_server_success: Error - cannot find server %s \
    9292in workgroup %s on subnet %s\n",
    93                         global_myname(), reg_name, subrec->subnet_name));
     93                        lp_netbios_name(), reg_name, subrec->subnet_name));
    9494                work->log_state = LOGON_NONE;
    9595                return;
  • vendor/current/source3/nmbd/nmbd_mynames.c

    r740 r988  
    2424#include "nmbd/nmbd.h"
    2525
    26 extern uint16 samba_nb_type; /* Samba's NetBIOS type. */
     26extern uint16_t samba_nb_type; /* Samba's NetBIOS type. */
    2727
    2828/****************************************************************************
     
    8484
    8585static void insert_refresh_name_into_unicast( struct subnet_record *subrec,
    86                                                 struct nmb_name *nmbname, uint16 nb_type )
     86                                                struct nmb_name *nmbname, uint16_t nb_type )
    8787{
    8888        struct name_record *namerec;
  • vendor/current/source3/nmbd/nmbd_namelistdb.c

    r740 r988  
    2525#include "nmbd/nmbd.h"
    2626
    27 uint16 samba_nb_type = 0; /* samba's NetBIOS name type */
     27uint16_t samba_nb_type = 0; /* samba's NetBIOS name type */
    2828
    2929
     
    3434void set_samba_nb_type(void)
    3535{
    36         if( lp_wins_support() || wins_srv_count() ) {
     36        if( lp_we_are_a_wins_server() || wins_srv_count() ) {
    3737                samba_nb_type = NB_HFLAG;               /* samba is a 'hybrid' node type. */
    3838        } else {
     
    4545***************************************************************************/
    4646
    47 static void upcase_name( struct nmb_name *target, const struct nmb_name *source )
     47static bool upcase_name( struct nmb_name *target, const struct nmb_name *source )
    4848{
    4949        int i;
     
    5656
    5757        pull_ascii_nstring(targ, sizeof(targ), target->name);
    58         strupper_m( targ );
     58        if (!strupper_m( targ )) {
     59                return false;
     60        }
    5961        push_ascii_nstring( target->name, targ);
    6062
    6163        pull_ascii(scope, target->scope, 64, -1, STR_TERMINATE);
    62         strupper_m( scope );
     64        if (!strupper_m( scope )) {
     65                return false;
     66        }
    6367        push_ascii(target->scope, scope, 64, STR_TERMINATE);
    6468
     
    7377                target->scope[i] = '\0';
    7478        }
     79        return true;
    7580}
    7681
     
    105110        struct name_record *name_ret;
    106111
    107         upcase_name( &uc_name, nmbname );
     112        if (!upcase_name( &uc_name, nmbname )) {
     113                return NULL;
     114        }
    108115       
    109116        if (subrec == wins_server_subnet) {
     
    185192                        const char *name,
    186193                        int type,
    187                         uint16 nb_flags,
     194                        uint16_t nb_flags,
    188195                        int ttl,
    189196                        enum name_source source,
     
    217224
    218225        make_nmb_name(&namerec->name, name, type);
    219         upcase_name(&namerec->name, NULL );
     226        if (!upcase_name(&namerec->name, NULL )) {
     227                SAFE_FREE(namerec->data.ip);
     228                SAFE_FREE(namerec);
     229                return False;
     230        }
    220231
    221232        /* Enter the name as active. */
     
    276287void standard_success_register(struct subnet_record *subrec,
    277288                             struct userdata_struct *userdata,
    278                              struct nmb_name *nmbname, uint16 nb_flags, int ttl,
     289                             struct nmb_name *nmbname, uint16_t nb_flags, int ttl,
    279290                             struct in_addr registered_ip)
    280291{
     
    632643void dump_all_namelists(void)
    633644{
    634         XFILE *fp; 
     645        XFILE *fp;
    635646        struct subnet_record *subrec;
    636 
    637         fp = x_fopen(lock_path("namelist.debug"),O_WRONLY|O_CREAT|O_TRUNC, 0644);
    638      
    639         if (!fp) {
     647        char *dump_path;
     648
     649        dump_path = lock_path("namelist.debug");
     650        if (dump_path == NULL) {
     651                DEBUG(0, ("out of memory!\n"));
     652                return;
     653        }
     654
     655        fp = x_fopen(dump_path, (O_WRONLY | O_CREAT | O_TRUNC), 0644);
     656        TALLOC_FREE(dump_path);
     657        if (!fp) {
    640658                DEBUG(0,("dump_all_namelists: Can't open file %s. Error was %s\n",
    641659                        "namelist.debug",strerror(errno)));
    642660                return;
    643661        }
    644      
     662
    645663        for (subrec = FIRST_SUBNET; subrec; subrec = NEXT_SUBNET_INCLUDING_UNICAST(subrec)) {
    646664                dump_subnet_namelist( subrec, fp );
  • vendor/current/source3/nmbd/nmbd_nameregister.c

    r740 r988  
    4848        struct nmb_packet *sent_nmb = &rrec->packet->packet.nmb;
    4949        int ttl = 0;
    50         uint16 nb_flags = 0;
     50        uint16_t nb_flags = 0;
    5151        struct in_addr register_ip;
    5252        fstring reg_name;
     
    211211           copes with all the wins servers being down */
    212212        if (wins_srv_is_dead(rrec->packet->ip, register_ip)) {
    213                 uint16 nb_flags = get_nb_flags(sent_nmb->additional->rdata);
     213                uint16_t nb_flags = get_nb_flags(sent_nmb->additional->rdata);
    214214                int ttl = sent_nmb->additional->ttl;
    215215
     
    262262        bool success = False;
    263263        struct nmb_name *question_name = &sent_nmb->question.question_name;
    264         uint16 nb_flags = 0;
     264        uint16_t nb_flags = 0;
    265265        int ttl = 0;
    266266        struct in_addr registered_ip;
     
    307307
    308308static void multihomed_register_one(struct nmb_name *nmbname,
    309                                     uint16 nb_flags,
     309                                    uint16_t nb_flags,
    310310                                    register_name_success_function success_fn,
    311311                                    register_name_fail_function fail_fn,
     
    357357        struct nmb_packet *sent_nmb = &rrec->packet->packet.nmb;
    358358        struct nmb_name *nmbname = &sent_nmb->question.question_name;
    359         uint16 nb_flags = get_nb_flags(sent_nmb->additional->rdata);
     359        uint16_t nb_flags = get_nb_flags(sent_nmb->additional->rdata);
    360360        struct userdata_struct *userdata = rrec->userdata;
    361361        const char *tag;
     
    401401****************************************************************************/
    402402
    403 static void multihomed_register_name(struct nmb_name *nmbname, uint16 nb_flags,
     403static void multihomed_register_name(struct nmb_name *nmbname, uint16_t nb_flags,
    404404                                     register_name_success_function success_fn,
    405405                                     register_name_fail_function fail_fn)
     
    476476
    477477void register_name(struct subnet_record *subrec,
    478                    const char *name, int type, uint16 nb_flags,
     478                   const char *name, int type, uint16_t nb_flags,
    479479                   register_name_success_function success_fn,
    480480                   register_name_fail_function fail_fn,
     
    483483        struct nmb_name nmbname;
    484484        nstring nname;
     485        size_t converted_size;
    485486
    486487        errno = 0;
    487         push_ascii_nstring(nname, name);
    488         if (errno == E2BIG) {
    489                 unstring tname;
    490                 pull_ascii_nstring(tname, sizeof(tname), nname);
    491                 DEBUG(0,("register_name: NetBIOS name %s is too long. Truncating to %s\n",
    492                         name, tname));
    493                 make_nmb_name(&nmbname, tname, type);
     488        converted_size = push_ascii_nstring(nname, name);
     489        if (converted_size != (size_t)-1) {
     490                /* Success. */
     491                make_nmb_name(&nmbname, name, type);
     492        } else if (errno == E2BIG) {
     493                /*
     494                 * Name converted to CH_DOS is too large.
     495                 * try to truncate.
     496                 */
     497                char *converted_str_dos = NULL;
     498                char *converted_str_unix = NULL;
     499                bool ok;
     500
     501                converted_size = 0;
     502
     503                ok = convert_string_talloc(talloc_tos(),
     504                                CH_UNIX,
     505                                CH_DOS,
     506                                name,
     507                                strlen(name)+1,
     508                                &converted_str_dos,
     509                                &converted_size);
     510                if (!ok) {
     511                        DEBUG(0,("register_name: NetBIOS name %s cannot be "
     512                                "converted. Failing to register name.\n",
     513                                name));
     514                        return;
     515                }
     516
     517                /*
     518                 * As it's now CH_DOS codepage
     519                 * we truncate by writing '\0' at
     520                 * MAX_NETBIOSNAME_LEN-1 and then
     521                 * convert back to CH_UNIX which we
     522                 * need for the make_nmb_name() call.
     523                 */
     524                if (converted_size >= MAX_NETBIOSNAME_LEN) {
     525                        converted_str_dos[MAX_NETBIOSNAME_LEN-1] = '\0';
     526                }
     527
     528                ok = convert_string_talloc(talloc_tos(),
     529                                CH_DOS,
     530                                CH_UNIX,
     531                                converted_str_dos,
     532                                strlen(converted_str_dos)+1,
     533                                &converted_str_unix,
     534                                &converted_size);
     535                if (!ok) {
     536                        DEBUG(0,("register_name: NetBIOS name %s cannot be "
     537                                "converted back to CH_UNIX. "
     538                                "Failing to register name.\n",
     539                                converted_str_dos));
     540                        TALLOC_FREE(converted_str_dos);
     541                        return;
     542                }
     543
     544                make_nmb_name(&nmbname, converted_str_unix, type);
     545
     546                TALLOC_FREE(converted_str_dos);
     547                TALLOC_FREE(converted_str_unix);
    494548        } else {
    495                 make_nmb_name(&nmbname, name, type);
     549                /*
     550                 * Generic conversion error. Fail to register.
     551                 */
     552                DEBUG(0,("register_name: NetBIOS name %s cannot be "
     553                        "converted (%s). Failing to register name.\n",
     554                        name, strerror(errno)));
     555                return;
    496556        }
    497557
  • vendor/current/source3/nmbd/nmbd_packets.c

    r740 r988  
    9595**************************************************************************/
    9696
    97 uint16 get_nb_flags(char *buf)
    98 {
    99         return ((((uint16)*buf)&0xFFFF) & NB_FLGMSK);
    100 }
    101 
    102 void set_nb_flags(char *buf, uint16 nb_flags)
     97uint16_t get_nb_flags(char *buf)
     98{
     99        return ((((uint16_t)*buf)&0xFFFF) & NB_FLGMSK);
     100}
     101
     102void set_nb_flags(char *buf, uint16_t nb_flags)
    103103{
    104104        *buf++ = ((nb_flags & NB_FLGMSK) & 0xFF);
     
    146146**************************************************************************/
    147147
    148 static uint16 name_trn_id=0;
    149 
    150 static uint16 generate_name_trn_id(void)
     148static uint16_t name_trn_id=0;
     149
     150static uint16_t generate_name_trn_id(void)
    151151{
    152152        if (!name_trn_id) {
    153                 name_trn_id = ((unsigned)time(NULL)%(unsigned)0x7FFF) + ((unsigned)sys_getpid()%(unsigned)100);
     153                name_trn_id = ((unsigned)time(NULL)%(unsigned)0x7FFF) + ((unsigned)getpid()%(unsigned)100);
    154154        }
    155155        name_trn_id = (name_trn_id+1) % (unsigned)0x7FFF;
     
    243243
    244244static bool create_and_init_additional_record(struct packet_struct *packet,
    245                                                      uint16 nb_flags,
     245                                                     uint16_t nb_flags,
    246246                                                     const struct in_addr *register_ip)
    247247{
     
    336336
    337337static bool initiate_name_register_packet( struct packet_struct *packet,
    338                                     uint16 nb_flags, const struct in_addr *register_ip)
     338                                    uint16_t nb_flags, const struct in_addr *register_ip)
    339339{
    340340        struct nmb_packet *nmb = &packet->packet.nmb;
     
    360360
    361361static bool initiate_multihomed_name_register_packet(struct packet_struct *packet,
    362                                                      uint16 nb_flags, struct in_addr *register_ip)
     362                                                     uint16_t nb_flags, struct in_addr *register_ip)
    363363{
    364364        struct nmb_packet *nmb = &packet->packet.nmb;
     
    388388
    389389static bool initiate_name_refresh_packet( struct packet_struct *packet,
    390                                    uint16 nb_flags, struct in_addr *refresh_ip)
     390                                   uint16_t nb_flags, struct in_addr *refresh_ip)
    391391{
    392392        struct nmb_packet *nmb = &packet->packet.nmb;
     
    412412
    413413static bool initiate_name_release_packet( struct packet_struct *packet,
    414                                    uint16 nb_flags, struct in_addr *release_ip)
     414                                   uint16_t nb_flags, struct in_addr *release_ip)
    415415{
    416416        struct nmb_packet *nmb = &packet->packet.nmb;
     
    485485                          struct userdata_struct *userdata,
    486486                          struct nmb_name *nmbname,
    487                           uint16 nb_flags)
     487                          uint16_t nb_flags)
    488488{
    489489        struct packet_struct *p;
     
    536536                        response_function resp_fn,
    537537                        timeout_response_function timeout_fn,
    538                         uint16 nb_flags,
     538                        uint16_t nb_flags,
    539539                        struct in_addr refresh_ip,
    540540                        const char *tag)
     
    603603                                                        struct userdata_struct *userdata,
    604604                                                        struct nmb_name *nmbname,
    605                                                         uint16 nb_flags,
     605                                                        uint16_t nb_flags,
    606606                                                        struct in_addr register_ip,
    607607                                                        struct in_addr wins_ip)
     
    661661                                            struct userdata_struct *userdata,
    662662                                            struct nmb_name *nmbname,
    663                                             uint16 nb_flags,
     663                                            uint16_t nb_flags,
    664664                                            struct in_addr release_ip,
    665665                                            struct in_addr dest_ip)
     
    964964        }
    965965
    966         DEBUG(4,("reply_netbios_packet: sending a reply of packet type: %s %s to ip %s \
    967 for id %hu\n", packet_type, nmb_namestr(&orig_nmb->question.question_name),
    968                         inet_ntoa(packet.ip), orig_nmb->header.name_trn_id));
     966        DEBUG(4, ("reply_netbios_packet: sending a reply of packet type: %s "
     967                  "%s to ip %s for id %d\n", packet_type,
     968                  nmb_namestr(&orig_nmb->question.question_name),
     969                  inet_ntoa(packet.ip), orig_nmb->header.name_trn_id));
    969970
    970971        nmb->header.name_trn_id = orig_nmb->header.name_trn_id;
     
    10331034void queue_packet(struct packet_struct *packet)
    10341035{
    1035         DLIST_ADD_END(packet_queue, packet, struct packet_struct *);
     1036        DLIST_ADD_END(packet_queue, packet);
    10361037}
    10371038
     
    10741075        /* Drop the packet if it's a different NetBIOS scope, or the source is from one of our names. */
    10751076        pull_ascii(scope, dgram->dest_name.scope, 64, 64, STR_TERMINATE);
    1076         if (!strequal(scope, global_scope())) {
     1077        if (!strequal(scope, lp_netbios_scope())) {
    10771078                DEBUG(7,("process_browse_packet: Discarding datagram from IP %s. Scope (%s) \
    1078 mismatch with our scope (%s).\n", inet_ntoa(p->ip), scope, global_scope()));
     1079mismatch with our scope (%s).\n", inet_ntoa(p->ip), scope, lp_netbios_scope()));
    10791080                return;
    10801081        }
     
    11621163
    11631164        pull_ascii(scope, dgram->dest_name.scope, 64, 64, STR_TERMINATE);
    1164         if (!strequal(scope, global_scope())) {
     1165        if (!strequal(scope, lp_netbios_scope())) {
    11651166                DEBUG(7,("process_lanman_packet: Discarding datagram from IP %s. Scope (%s) \
    1166 mismatch with our scope (%s).\n", inet_ntoa(p->ip), scope, global_scope()));
     1167mismatch with our scope (%s).\n", inet_ntoa(p->ip), scope, lp_netbios_scope()));
    11671168                return;
    11681169        }
     
    12921293        DEBUG(4,("process_dgram: datagram from %s to %s IP %s for %s of type %d len=%d\n",
    12931294                nmb_namestr(&dgram->source_name),nmb_namestr(&dgram->dest_name),
    1294                 inet_ntoa(p->ip), smb_buf(buf),CVAL(buf2,0),len));
     1295                inet_ntoa(p->ip), smb_buf_const(buf),CVAL(buf2,0),len));
    12951296
    12961297        /* Datagram packet received for the browser mailslot */
    1297         if (strequal(smb_buf(buf),BROWSE_MAILSLOT)) {
     1298        if (strequal(smb_buf_const(buf),BROWSE_MAILSLOT)) {
    12981299                process_browse_packet(p,buf2,len);
    12991300                return;
     
    13011302
    13021303        /* Datagram packet received for the LAN Manager mailslot */
    1303         if (strequal(smb_buf(buf),LANMAN_MAILSLOT)) {
     1304        if (strequal(smb_buf_const(buf),LANMAN_MAILSLOT)) {
    13041305                process_lanman_packet(p,buf2,len);
    13051306                return;
     
    13071308
    13081309        /* Datagram packet received for the domain logon mailslot */
    1309         if (strequal(smb_buf(buf),NET_LOGON_MAILSLOT)) {
     1310        if (strequal(smb_buf_const(buf),NET_LOGON_MAILSLOT)) {
    13101311                process_logon_packet(p,buf2,len,NET_LOGON_MAILSLOT);
    13111312                return;
     
    13131314
    13141315        /* Datagram packet received for the NT domain logon mailslot */
    1315         if (strequal(smb_buf(buf),NT_LOGON_MAILSLOT)) {
     1316        if (strequal(smb_buf_const(buf),NT_LOGON_MAILSLOT)) {
    13161317                process_logon_packet(p,buf2,len,NT_LOGON_MAILSLOT);
    13171318                return;
     
    14361437                rrec = find_response_record( &subrec, nmb->header.name_trn_id);
    14371438                if(rrec == NULL) {
    1438                         DEBUG(3,("find_subnet_for_nmb_packet: response record not found for response id %hu\n",
    1439                                 nmb->header.name_trn_id));
     1439                        DEBUG(3, ("find_subnet_for_nmb_packet: response "
     1440                                  "record not found for response id %d\n",
     1441                                  nmb->header.name_trn_id));
    14401442                        nb_packet_dispatch(packet_server, p);
    14411443                        return NULL;
     
    14431445
    14441446                if(subrec == NULL) {
    1445                         DEBUG(0,("find_subnet_for_nmb_packet: subnet record not found for response id %hu\n",
    1446                                 nmb->header.name_trn_id));
     1447                        DEBUG(0, ("find_subnet_for_nmb_packet: subnet record "
     1448                                  "not found for response id %d\n",
     1449                                  nmb->header.name_trn_id));
    14471450                        return NULL;
    14481451                }
     
    15661569
    15671570        if(rrec == NULL) {
    1568                 DEBUG(0,("process_nmb_response: response packet received but no response record \
    1569 found for id = %hu. Ignoring packet.\n", nmb->header.name_trn_id));
     1571                DEBUG(0, ("process_nmb_response: response packet received but "
     1572                          "no response record found for id = %d. Ignoring "
     1573                          "packet.\n", nmb->header.name_trn_id));
    15701574                return;
    15711575        }
     
    16991703             subrec != NULL;
    17001704             subrec = NEXT_SUBNET_EXCLUDING_UNICAST(subrec)) {
    1701                 count += 2;     /* nmb_sock and dgram_sock */
     1705                if (subrec->nmb_sock != -1) {
     1706                        count += 1;
     1707                }
     1708                if (subrec->dgram_sock != -1) {
     1709                        count += 1;
     1710                }
    17021711                if (subrec->nmb_bcast != -1) {
    17031712                        count += 1;
     
    17081717        }
    17091718
    1710         fds = TALLOC_ZERO_ARRAY(NULL, struct pollfd, count);
     1719        fds = talloc_zero_array(NULL, struct pollfd, count);
    17111720        if (fds == NULL) {
    17121721                DEBUG(1, ("create_listen_pollfds: malloc fail for fds. "
     
    17151724        }
    17161725
    1717         attrs = TALLOC_ARRAY(NULL, struct socket_attributes, count);
     1726        attrs = talloc_array(NULL, struct socket_attributes, count);
    17181727        if (fds == NULL) {
    17191728                DEBUG(1, ("create_listen_pollfds: malloc fail for attrs. "
    17201729                          "size %d\n", count));
    1721                 SAFE_FREE(fds);
     1730                TALLOC_FREE(fds);
    17221731                return true;
    17231732        }
     
    17371746        for (subrec = FIRST_SUBNET; subrec; subrec = NEXT_SUBNET_EXCLUDING_UNICAST(subrec)) {
    17381747
    1739                 fds[num].fd = subrec->nmb_sock;
    1740                 attrs[num].type = NMB_PACKET;
    1741                 attrs[num].broadcast = false;
    1742                 num += 1;
     1748                if (subrec->nmb_sock != -1) {
     1749                        fds[num].fd = subrec->nmb_sock;
     1750                        attrs[num].type = NMB_PACKET;
     1751                        attrs[num].broadcast = false;
     1752                        num += 1;
     1753                }
    17431754
    17441755                if (subrec->nmb_bcast != -1) {
     
    17491760                }
    17501761
    1751                 fds[num].fd = subrec->dgram_sock;
    1752                 attrs[num].type = DGRAM_PACKET;
    1753                 attrs[num].broadcast = false;
    1754                 num += 1;
     1762                if (subrec->dgram_sock != -1) {
     1763                        fds[num].fd = subrec->dgram_sock;
     1764                        attrs[num].type = DGRAM_PACKET;
     1765                        attrs[num].broadcast = false;
     1766                        num += 1;
     1767                }
    17551768
    17561769                if (subrec->dgram_bcast != -1) {
     
    18561869***************************************************************************/
    18571870
    1858 bool listen_for_packets(bool run_election)
     1871bool listen_for_packets(struct messaging_context *msg, bool run_election)
    18591872{
    18601873        static struct pollfd *fds = NULL;
     
    18861899         */
    18871900
    1888         fds = TALLOC_REALLOC_ARRAY(NULL, fds, struct pollfd, listen_number);
     1901        fds = talloc_realloc(NULL, fds, struct pollfd, listen_number);
    18891902        if (fds == NULL) {
    18901903                return true;
     
    18951908        dns_fd = asyncdns_fd();
    18961909        if (dns_fd != -1) {
    1897                 fds = TALLOC_REALLOC_ARRAY(NULL, fds, struct pollfd, num_sockets+1);
     1910                fds = talloc_realloc(NULL, fds, struct pollfd, num_sockets+1);
    18981911                if (fds == NULL) {
    18991912                        return true;
     
    19271940                               &fds, &num_sockets, &timeout);
    19281941
    1929         pollrtn = sys_poll(fds, num_sockets, timeout);
     1942        pollrtn = poll(fds, num_sockets, timeout);
    19301943
    19311944        if (run_events_poll(nmbd_event_context(), pollrtn, fds, num_sockets)) {
     
    19401953        if ((dns_fd != -1) && (dns_pollidx != -1) &&
    19411954            (fds[dns_pollidx].revents & (POLLIN|POLLHUP|POLLERR))) {
    1942                 run_dns_queue();
     1955                run_dns_queue(msg);
    19431956        }
    19441957#endif
     
    19872000                }
    19882001
    1989                 if ((is_loopback_ip_v4(packet->ip) || ismyip_v4(packet->ip)) &&
    1990                     packet->port == client_port)
    1991                 {
    1992                         if (client_port == DGRAM_PORT) {
    1993                                 DEBUG(7,("discarding own dgram packet from %s:%d\n",
    1994                                         inet_ntoa(packet->ip),packet->port));
    1995                                 free_packet(packet);
    1996                                 continue;
    1997                         }
    1998 
    1999                         if (packet->packet.nmb.header.nm_flags.bcast) {
    2000                                 DEBUG(7,("discarding own nmb bcast packet from %s:%d\n",
    2001                                         inet_ntoa(packet->ip),packet->port));
    2002                                 free_packet(packet);
    2003                                 continue;
     2002                if (!IS_DC) {
     2003                        if ((is_loopback_ip_v4(packet->ip) || ismyip_v4(packet->ip)) &&
     2004                        packet->port == client_port)
     2005                        {
     2006                                if (client_port == DGRAM_PORT) {
     2007                                        DEBUG(7,("discarding own dgram packet from %s:%d\n",
     2008                                                inet_ntoa(packet->ip),packet->port));
     2009                                        free_packet(packet);
     2010                                        continue;
     2011                                }
     2012
     2013                                if (packet->packet.nmb.header.nm_flags.bcast) {
     2014                                        DEBUG(7,("discarding own nmb bcast packet from %s:%d\n",
     2015                                                inet_ntoa(packet->ip),packet->port));
     2016                                        free_packet(packet);
     2017                                        continue;
     2018                                }
    20042019                        }
    20052020                }
     
    20892104        SSVAL(ptr,smb_vwv16,2);
    20902105        p2 = smb_buf(ptr);
    2091         safe_strcpy_base(p2, mailslot, dgram->data, sizeof(dgram->data));
     2106        strlcpy_base(p2, mailslot, dgram->data, sizeof(dgram->data));
    20922107        p2 = skip_string(ptr,MAX_DGRAM_SIZE,p2);
    20932108
  • vendor/current/source3/nmbd/nmbd_processlogon.c

    r740 r988  
    3333
    3434struct sam_database_info {
    35         uint32 index;
    36         uint32 serial_lo, serial_hi;
    37         uint32 date_lo, date_hi;
     35        uint32_t index;
     36        uint32_t serial_lo, serial_hi;
     37        uint32_t date_lo, date_hi;
    3838};
    3939
     
    5757}
    5858
    59 static void delayed_init_logon_handler(struct event_context *event_ctx,
    60                                        struct timed_event *te,
     59static void delayed_init_logon_handler(struct tevent_context *event_ctx,
     60                                       struct tevent_timer *te,
    6161                                       struct timeval now,
    6262                                       void *private_data)
     
    121121
    122122        /* we create a connected udp socket */
    123         status = cldap_socket_init(ctx, nmbd_event_context(), NULL,
    124                                    server_addr, &ctx->cldap_sock);
     123        status = cldap_socket_init(ctx, NULL, server_addr, &ctx->cldap_sock);
    125124        TALLOC_FREE(server_addr);
    126125        if (!NT_STATUS_IS_OK(status)) {
     
    158157                             struct in_addr local_ip,
    159158                             struct packet_struct *p,
    160                              uint8_t *buf,
     159                             const uint8_t *buf,
    161160                             uint32_t len)
    162161{
     
    174173        struct dgram_packet *dgram = &p->packet.dgram;
    175174
    176         state = TALLOC_ZERO_P(ctx, struct nmbd_proxy_logon_state);
     175        state = talloc_zero(ctx, struct nmbd_proxy_logon_state);
    177176        if (!state) {
    178177                DEBUG(0,("failed to allocate nmbd_proxy_logon_state\n"));
     
    250249        state->io.in.map_response       = false;
    251250
    252         subreq = cldap_netlogon_send(state,
     251        subreq = cldap_netlogon_send(state, nmbd_event_context(),
    253252                                     ctx->cldap_sock,
    254253                                     &state->io);
     
    292291        send_mailslot(true, state->remote_mailslot,
    293292                      (char *)response.data, response.length,
    294                       global_myname(), 0x0,
     293                      lp_netbios_name(), 0x0,
    295294                      state->remote_name,
    296295                      state->remote_name_type,
     
    329328                return;
    330329        }
    331         ip = ((struct sockaddr_in *)pss)->sin_addr;
    332 
    333         if (!lp_domain_logons()) {
     330        ip = ((const struct sockaddr_in *)pss)->sin_addr;
     331
     332        if (!IS_DC) {
    334333                DEBUG(5,("process_logon_packet: Logon packet received from IP %s and domain \
    335334logons are not enabled.\n", inet_ntoa(p->ip) ));
     
    339338        pull_ascii_nstring(source_name, sizeof(source_name), dgram->source_name.name);
    340339
    341         pdc_name = talloc_asprintf(talloc_tos(), "\\\\%s", global_myname());
     340        pdc_name = talloc_asprintf(talloc_tos(), "\\\\%s", lp_netbios_name());
    342341        if (!pdc_name) {
    343342                return;
     
    392391                                (char *)blob_out.data,
    393392                                blob_out.length,
    394                                 global_myname(), 0x0,
     393                                lp_netbios_name(), 0x0,
    395394                                source_name,
    396395                                dgram->source_name.name_type,
     
    412411                        request.req.pdc.computer_name,
    413412                        inet_ntoa(p->ip),
    414                         global_myname(),
     413                        lp_netbios_name(),
    415414                        lp_workgroup(),
    416415                        NETLOGON_RESPONSE_FROM_PDC,
     
    420419
    421420                get_pdc.command                 = NETLOGON_RESPONSE_FROM_PDC;
    422                 get_pdc.pdc_name                = global_myname();
     421                get_pdc.pdc_name                = lp_netbios_name();
    423422                get_pdc._pad                    = data_blob_null;
    424                 get_pdc.unicode_pdc_name        = global_myname();
     423                get_pdc.unicode_pdc_name        = lp_netbios_name();
    425424                get_pdc.domain_name             = lp_workgroup();
    426425                get_pdc.nt_version              = NETLOGON_NT_VERSION_1;
     
    444443                        (char *)blob_out.data,
    445444                        blob_out.length,
    446                         global_myname(), 0x0,
     445                        lp_netbios_name(), 0x0,
    447446                        source_name,
    448447                        dgram->source_name.name_type,
     
    457456
    458457                struct netlogon_samlogon_response samlogon;
     458                struct NETLOGON_SAM_LOGON_RESPONSE_NT40 nt4;
    459459
    460460                if (global_nmbd_proxy_logon) {
    461461                        nmbd_proxy_logon(global_nmbd_proxy_logon,
    462                                          ip, p, (uint8_t *)buf, len);
     462                                         ip, p, (const uint8_t *)buf, len);
    463463                        return;
    464464                }
     
    484484                }
    485485
    486                 /* we want the simple version unless we are an ADS PDC..which means  */
    487                 /* never, at least for now */
    488 
    489                 if ((request.req.logon.nt_version < (NETLOGON_NT_VERSION_1 | NETLOGON_NT_VERSION_5 | NETLOGON_NT_VERSION_5EX_WITH_IP)) ||
    490                     (SEC_ADS != lp_security()) || (ROLE_DOMAIN_PDC != lp_server_role())) {
    491 
    492                         struct NETLOGON_SAM_LOGON_RESPONSE_NT40 nt4;
    493 
    494                         nt4.command             = user_unknown ? LOGON_SAM_LOGON_USER_UNKNOWN :
    495                                                                  LOGON_SAM_LOGON_RESPONSE;
    496                         nt4.pdc_name            = pdc_name;
    497                         nt4.user_name           = request.req.logon.user_name;
    498                         nt4.domain_name         = lp_workgroup();
    499                         nt4.nt_version          = NETLOGON_NT_VERSION_1;
    500                         nt4.lmnt_token          = 0xffff;
    501                         nt4.lm20_token          = 0xffff;
    502 
    503                         samlogon.ntver = NETLOGON_NT_VERSION_1;
    504                         samlogon.data.nt4 = nt4;
    505 
    506                         if (DEBUGLEVEL >= 10) {
    507                                 NDR_PRINT_DEBUG(NETLOGON_SAM_LOGON_RESPONSE_NT40, &nt4);
    508                         }
    509                 }
    510 #ifdef HAVE_ADS
    511                 else {
    512 
    513                         struct NETLOGON_SAM_LOGON_RESPONSE_EX nt5_ex;
    514                         struct GUID domain_guid;
    515                         struct nbt_sockaddr saddr;
    516                         char *domain;
    517                         const char *hostname;
    518 
    519                         saddr.sockaddr_family   = 2; /* AF_INET */
    520                         saddr.pdc_ip            = inet_ntoa(ip);
    521                         saddr.remaining         = data_blob_talloc_zero(talloc_tos(), 8); /* ??? */
    522 
    523                         domain = get_mydnsdomname(talloc_tos());
    524                         if (!domain) {
    525                                 DEBUG(2,("get_mydnsdomname failed.\n"));
    526                                 return;
    527                         }
    528 
    529                         hostname = get_mydnsfullname();
    530                         if (!hostname) {
    531                                 DEBUG(2,("get_mydnsfullname failed.\n"));
    532                                 return;
    533                         }
    534 
    535                         if (!secrets_fetch_domain_guid(domain, &domain_guid)) {
    536                                 DEBUG(2,("Could not fetch DomainGUID for %s\n", domain));
    537                                 return;
    538                         }
    539 
    540                         nt5_ex.command          = user_unknown ? LOGON_SAM_LOGON_USER_UNKNOWN_EX :
    541                                                                  LOGON_SAM_LOGON_RESPONSE_EX;
    542                         nt5_ex.sbz              = 0;
    543                         nt5_ex.server_type      = NBT_SERVER_PDC |
    544                                                   NBT_SERVER_GC |
    545                                                   NBT_SERVER_LDAP |
    546                                                   NBT_SERVER_DS |
    547                                                   NBT_SERVER_KDC |
    548                                                   NBT_SERVER_TIMESERV |
    549                                                   NBT_SERVER_CLOSEST |
    550                                                   NBT_SERVER_WRITABLE;
    551                         nt5_ex.domain_uuid      = domain_guid;
    552                         nt5_ex.forest           = domain;
    553                         nt5_ex.dns_domain       = domain;
    554                         nt5_ex.pdc_dns_name     = hostname;
    555                         nt5_ex.domain_name      = lp_workgroup();
    556                         nt5_ex.pdc_name         = global_myname();
    557                         nt5_ex.user_name        = request.req.logon.user_name;
    558                         nt5_ex.server_site      = "Default-First-Site-Name";
    559                         nt5_ex.client_site      = "Default-First-Site-Name";
    560                         nt5_ex.sockaddr_size    = 0x10; /* the w32 winsock addr size */
    561                         nt5_ex.sockaddr         = saddr;
    562                         nt5_ex.next_closest_site= NULL;
    563                         nt5_ex.nt_version       = NETLOGON_NT_VERSION_1 |
    564                                                   NETLOGON_NT_VERSION_5EX |
    565                                                   NETLOGON_NT_VERSION_5EX_WITH_IP;
    566                         nt5_ex.lmnt_token       = 0xffff;
    567                         nt5_ex.lm20_token       = 0xffff;
    568 
    569                         samlogon.ntver = NETLOGON_NT_VERSION_1 |
    570                                          NETLOGON_NT_VERSION_5EX |
    571                                          NETLOGON_NT_VERSION_5EX_WITH_IP;
    572                         samlogon.data.nt5_ex = nt5_ex;
    573 
    574                         if (DEBUGLEVEL >= 10) {
    575                                 NDR_PRINT_DEBUG(NETLOGON_SAM_LOGON_RESPONSE_EX, &nt5_ex);
    576                         }
    577                 }
    578 #endif /* HAVE_ADS */
     486                nt4.command             = user_unknown ? LOGON_SAM_LOGON_USER_UNKNOWN :
     487                        LOGON_SAM_LOGON_RESPONSE;
     488                nt4.pdc_name            = pdc_name;
     489                nt4.user_name           = request.req.logon.user_name;
     490                nt4.domain_name         = lp_workgroup();
     491                nt4.nt_version          = NETLOGON_NT_VERSION_1;
     492                nt4.lmnt_token          = 0xffff;
     493                nt4.lm20_token          = 0xffff;
     494               
     495                samlogon.ntver = NETLOGON_NT_VERSION_1;
     496                samlogon.data.nt4 = nt4;
     497               
     498                if (DEBUGLEVEL >= 10) {
     499                        NDR_PRINT_DEBUG(NETLOGON_SAM_LOGON_RESPONSE_NT40, &nt4);
     500                }
    579501
    580502                response.response_type = NETLOGON_SAMLOGON;
     
    584506                if (!NT_STATUS_IS_OK(status)) {
    585507                        DEBUG(0,("process_logon_packet: failed to push packet\n"));
     508                        SAFE_FREE(source_addr);
    586509                        return;
    587510                }
     
    605528                                  lp_init_logon_delay()));
    606529
    607                         when = timeval_current_ofs(0,
    608                                 lp_init_logon_delay() * 1000);
     530                        when = timeval_current_ofs_msec(lp_init_logon_delay());
    609531                        p->locked = true;
    610                         event_add_timed(nmbd_event_context(),
     532                        tevent_add_timer(nmbd_event_context(),
    611533                                        NULL,
    612534                                        when,
     
    623545                                (char *)blob_out.data,
    624546                                blob_out.length,
    625                                 global_myname(), 0x0,
     547                                lp_netbios_name(), 0x0,
    626548                                source_name,
    627549                                dgram->source_name.name_type,
  • vendor/current/source3/nmbd/nmbd_proto.h

    r740 r988  
    2929int asyncdns_fd(void);
    3030void kill_async_dns_child(void);
    31 void start_async_dns(void);
    32 void run_dns_queue(void);
     31void start_async_dns(struct messaging_context *msg);
     32void run_dns_queue(struct messaging_context *msg);
    3333bool queue_dns_query(struct packet_struct *p,struct nmb_name *question);
    3434bool queue_dns_query(struct packet_struct *p,struct nmb_name *question);
     
    3737/* The following definitions come from nmbd/nmbd.c  */
    3838
    39 struct event_context *nmbd_event_context(void);
    40 struct messaging_context *nmbd_messaging_context(void);
     39struct tevent_context *nmbd_event_context(void);
    4140
    4241/* The following definitions come from nmbd/nmbd_become_dmb.c  */
     
    4746
    4847void insert_permanent_name_into_unicast( struct subnet_record *subrec,
    49                                                 struct nmb_name *nmbname, uint16 nb_type );
     48                                                struct nmb_name *nmbname, uint16_t nb_type );
    5049void unbecome_local_master_browser(struct subnet_record *subrec, struct work_record *work,
    5150                                   bool force_new_election);
     
    139138                        const char *name,
    140139                        int type,
    141                         uint16 nb_flags,
     140                        uint16_t nb_flags,
    142141                        int ttl,
    143142                        enum name_source source,
     
    146145void standard_success_register(struct subnet_record *subrec,
    147146                             struct userdata_struct *userdata,
    148                              struct nmb_name *nmbname, uint16 nb_flags, int ttl,
     147                             struct nmb_name *nmbname, uint16_t nb_flags, int ttl,
    149148                             struct in_addr registered_ip);
    150149void standard_fail_register( struct subnet_record   *subrec,
     
    178177
    179178void register_name(struct subnet_record *subrec,
    180                    const char *name, int type, uint16 nb_flags,
     179                   const char *name, int type, uint16_t nb_flags,
    181180                   register_name_success_function success_fn,
    182181                   register_name_fail_function fail_fn,
     
    201200bool nmbd_init_packet_server(void);
    202201
    203 uint16 get_nb_flags(char *buf);
    204 void set_nb_flags(char *buf, uint16 nb_flags);
     202uint16_t get_nb_flags(char *buf);
     203void set_nb_flags(char *buf, uint16_t nb_flags);
    205204struct response_record *queue_register_name( struct subnet_record *subrec,
    206205                          response_function resp_fn,
     
    210209                          struct userdata_struct *userdata,
    211210                          struct nmb_name *nmbname,
    212                           uint16 nb_flags);
     211                          uint16_t nb_flags);
    213212void queue_wins_refresh(struct nmb_name *nmbname,
    214213                        response_function resp_fn,
    215214                        timeout_response_function timeout_fn,
    216                         uint16 nb_flags,
     215                        uint16_t nb_flags,
    217216                        struct in_addr refresh_ip,
    218217                        const char *tag);
     
    224223                                                        struct userdata_struct *userdata,
    225224                                                        struct nmb_name *nmbname,
    226                                                         uint16 nb_flags,
     225                                                        uint16_t nb_flags,
    227226                                                        struct in_addr register_ip,
    228227                                                        struct in_addr wins_ip);
     
    234233                                            struct userdata_struct *userdata,
    235234                                            struct nmb_name *nmbname,
    236                                             uint16 nb_flags,
     235                                            uint16_t nb_flags,
    237236                                            struct in_addr release_ip,
    238237                                            struct in_addr dest_ip);
     
    265264void run_packet_queue(void);
    266265void retransmit_or_expire_response_records(time_t t);
    267 bool listen_for_packets(bool run_election);
     266bool listen_for_packets(struct messaging_context *msg, bool run_election);
    268267bool send_mailslot(bool unique, const char *mailslot,char *buf, size_t len,
    269268                   const char *srcname, int src_type,
     
    291290                                              struct userdata_struct *userdata);
    292291struct response_record *find_response_record(struct subnet_record **ppsubrec,
    293                                 uint16 id);
     292                                uint16_t id);
    294293bool is_refresh_already_queued(struct subnet_record *subrec, struct name_record *namerec);
    295294
     
    316315void update_server_ttl(struct server_record *servrec, int ttl);
    317316void expire_servers(struct work_record *work, time_t t);
    318 void write_browse_list_entry(XFILE *fp, const char *name, uint32 rec_type,
     317void write_browse_list_entry(XFILE *fp, const char *name, uint32_t rec_type,
    319318                const char *local_master_browser_name, const char *description);
    320319void write_browse_list(time_t t, bool force_write);
  • vendor/current/source3/nmbd/nmbd_responserecordsdb.c

    r740 r988  
    3838                rrec->response_id, subrec->subnet_name, num_response_packets));
    3939
    40         DLIST_ADD_END(subrec->responselist, rrec, struct response_record *);
     40        DLIST_ADD_END(subrec->responselist, rrec);
    4141}
    4242
     
    170170
    171171static struct response_record *find_response_record_on_subnet(
    172                                 struct subnet_record *subrec, uint16 id)
     172                                struct subnet_record *subrec, uint16_t id)
    173173
    174174        struct response_record *rrec = NULL;
     
    189189
    190190struct response_record *find_response_record(struct subnet_record **ppsubrec,
    191                                 uint16 id)
     191                                uint16_t id)
    192192
    193193        struct response_record *rrec = NULL;
  • vendor/current/source3/nmbd/nmbd_sendannounce.c

    r740 r988  
    5151
    5252        send_mailslot(True, BROWSE_MAILSLOT, outbuf,PTR_DIFF(p,outbuf),
    53                 global_myname(), 0x0, to_name, to_type, to_ip,
     53                lp_netbios_name(), 0x0, to_name, to_type, to_ip,
    5454                FIRST_SUBNET->myip, DGRAM_PORT);
    5555}
     
    7777        SCVAL(p,0,work->token); /* (local) Unique workgroup token id. */
    7878        p++;
    79         p +=  push_string_check(p+1, global_myname(), 15, STR_ASCII|STR_UPPER|STR_TERMINATE);
     79        p +=  push_string_check(p+1, lp_netbios_name(), 15, STR_ASCII|STR_UPPER|STR_TERMINATE);
    8080 
    8181        send_mailslot(False, BROWSE_MAILSLOT, outbuf,PTR_DIFF(p,outbuf),
    82                 global_myname(), 0x0, work->work_group,0x1e, subrec->bcast_ip,
     82                lp_netbios_name(), 0x0, work->work_group,0x1e, subrec->bcast_ip,
    8383                subrec->myip, DGRAM_PORT);
    8484}
     
    106106        SIVAL(p,1,announce_interval*1000); /* Milliseconds - despite the spec. */
    107107
    108         safe_strcpy(upper_server_name, server_name, sizeof(upper_server_name)-1);
    109         strupper_m(upper_server_name);
     108        strlcpy(upper_server_name, server_name ? server_name : "", sizeof(upper_server_name));
     109        if (!strupper_m(upper_server_name)) {
     110                DEBUG(2,("strupper_m %s failed\n", upper_server_name));
     111                return;
     112        }
    110113        push_string_check(p+5, upper_server_name, 16, STR_ASCII|STR_TERMINATE);
    111114
    112         SCVAL(p,21,lp_major_announce_version()); /* Major version. */
    113         SCVAL(p,22,lp_minor_announce_version()); /* Minor version. */
     115        SCVAL(p,21,SAMBA_MAJOR_NBT_ANNOUNCE_VERSION); /* Major version. */
     116        SCVAL(p,22,SAMBA_MINOR_NBT_ANNOUNCE_VERSION); /* Minor version. */
    114117
    115118        SIVAL(p,23,server_type & ~SV_TYPE_LOCAL_LIST_ONLY);
     
    141144        SSVAL(p,0,announce_type);
    142145        SIVAL(p,2,server_type & ~SV_TYPE_LOCAL_LIST_ONLY);
    143         SCVAL(p,6,lp_major_announce_version()); /* Major version. */
    144         SCVAL(p,7,lp_minor_announce_version()); /* Minor version. */
     146        SCVAL(p,6,SAMBA_MAJOR_NBT_ANNOUNCE_VERSION); /* Major version. */
     147        SCVAL(p,7,SAMBA_MINOR_NBT_ANNOUNCE_VERSION); /* Minor version. */
    145148        SSVAL(p,8,announce_interval);            /* In seconds - according to spec. */
    146149
     
    162165{
    163166        /* Ensure we don't have the prohibited bit set. */
    164         uint32 type = servrec->serv.type & ~SV_TYPE_LOCAL_LIST_ONLY;
     167        uint32_t type = servrec->serv.type & ~SV_TYPE_LOCAL_LIST_ONLY;
    165168
    166169        DEBUG(3,("send_local_master_announcement: type %x for name %s on subnet %s for workgroup %s\n",
    167                 type, global_myname(), subrec->subnet_name, work->work_group));
     170                type, lp_netbios_name(), subrec->subnet_name, work->work_group));
    168171
    169172        send_announcement(subrec, ANN_LocalMasterAnnouncement,
    170                         global_myname(),                 /* From nbt name. */
     173                        lp_netbios_name(),                 /* From nbt name. */
    171174                        work->work_group, 0x1e,          /* To nbt name. */
    172175                        subrec->bcast_ip,                /* To ip. */
    173176                        work->announce_interval,         /* Time until next announce. */
    174                         global_myname(),                 /* Name to announce. */
     177                        lp_netbios_name(),                 /* Name to announce. */
    175178                        type,                            /* Type field. */
    176179                        servrec->serv.comment);
     
    187190
    188191        send_announcement(subrec, ANN_DomainAnnouncement,
    189                         global_myname(),                 /* From nbt name. */
     192                        lp_netbios_name(),                 /* From nbt name. */
    190193                        MSBROWSE, 0x1,                   /* To nbt name. */
    191194                        subrec->bcast_ip,                /* To ip. */
     
    193196                        work->work_group,                /* Name to announce. */
    194197                        SV_TYPE_DOMAIN_ENUM|SV_TYPE_NT,  /* workgroup announce flags. */
    195                         global_myname());                /* From name as comment. */
     198                        lp_netbios_name());                /* From name as comment. */
    196199}
    197200
     
    204207{
    205208        /* Ensure we don't have the prohibited bits set. */
    206         uint32 type = servrec->serv.type & ~SV_TYPE_LOCAL_LIST_ONLY;
     209        uint32_t type = servrec->serv.type & ~SV_TYPE_LOCAL_LIST_ONLY;
    207210
    208211        DEBUG(3,("send_host_announcement: type %x for host %s on subnet %s for workgroup %s\n",
     
    227230{
    228231        /* Ensure we don't have the prohibited bits set. */
    229         uint32 type = servrec->serv.type & ~SV_TYPE_LOCAL_LIST_ONLY;
     232        uint32_t type = servrec->serv.type & ~SV_TYPE_LOCAL_LIST_ONLY;
    230233
    231234        DEBUG(3,("send_lm_host_announcement: type %x for host %s on subnet %s for workgroup %s, ttl: %d\n",
     
    252255                our primary name we're being asked to announce. */
    253256
    254         if (AM_LOCAL_MASTER_BROWSER(work) && strequal(global_myname(),servrec->serv.name)) {
     257        if (AM_LOCAL_MASTER_BROWSER(work) && strequal(lp_netbios_name(),servrec->serv.name)) {
    255258                send_local_master_announcement(subrec, work, servrec);
    256259                send_workgroup_announcement(subrec, work);
     
    471474        last_time = t;
    472475
    473         s = lp_remote_announce();
     476        s = lp_remote_announce(talloc_tos());
    474477        if (!*s)
    475478                return;
    476479
    477         comment = string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH);
     480        comment = string_truncate(lp_server_string(talloc_tos()),
     481                                  MAX_SERVER_STRING_LENGTH);
    478482
    479483        frame = talloc_stackframe();
     
    541545        last_time = t;
    542546
    543         s = lp_remote_browse_sync();
     547        s = lp_remote_browse_sync(talloc_tos());
    544548        if (!*s)
    545549                return;
     
    567571        p++;
    568572
    569         unstrcpy(myname, global_myname());
    570         strupper_m(myname);
     573        unstrcpy(myname, lp_netbios_name());
     574        if (!strupper_m(myname)) {
     575                DEBUG(2,("strupper_m %s failed\n", myname));
     576                return;
     577        }
    571578        myname[15]='\0';
    572579        push_ascii(p, myname, sizeof(outbuf)-PTR_DIFF(p,outbuf)-1, STR_TERMINATE);
     
    580587
    581588                DEBUG(5,("announce_remote: Doing remote browse sync announce for server %s to IP %s.\n",
    582                         global_myname(), inet_ntoa(addr) ));
     589                        lp_netbios_name(), inet_ntoa(addr) ));
    583590
    584591                send_mailslot(True, BROWSE_MAILSLOT, outbuf,PTR_DIFF(p,outbuf),
    585                         global_myname(), 0x0, "*", 0x0, addr, FIRST_SUBNET->myip, DGRAM_PORT);
     592                        lp_netbios_name(), 0x0, "*", 0x0, addr, FIRST_SUBNET->myip, DGRAM_PORT);
    586593        }
    587594        TALLOC_FREE(frame);
  • vendor/current/source3/nmbd/nmbd_serverlistdb.c

    r740 r988  
    5555                             struct server_record *servrec)
    5656{
    57         DLIST_ADD_END(work->serverlist, servrec, struct server_record *);
     57        DLIST_ADD_END(work->serverlist, servrec);
    5858        work->subnet->work_changed = True;
    5959}
     
    120120        fstrcpy(servrec->serv.name,name);
    121121        fstrcpy(servrec->serv.comment,comment);
    122         strupper_m(servrec->serv.name);
     122        if (!strupper_m(servrec->serv.name)) {
     123                DEBUG(2,("strupper_m %s failed\n", servrec->serv.name));
     124                SAFE_FREE(servrec);
     125                return NULL;
     126        }
    123127        servrec->serv.type  = servertype;
    124128
     
    130134workgroup %s.\n", name,servertype,comment, work->work_group));
    131135 
    132         work->subnet->work_changed = True;
    133  
    134136        return(servrec);
    135137}
     
    148150        else
    149151                servrec->death_time = (ttl != PERMANENT_TTL) ? time(NULL)+(ttl*3) : PERMANENT_TTL;
    150 
    151         servrec->subnet->work_changed = True;
    152152}
    153153
     
    169169                        DEBUG(3,("expire_old_servers: Removing timed out server %s\n",servrec->serv.name));
    170170                        remove_server_from_workgroup(work, servrec);
    171                         work->subnet->work_changed = True;
    172171                }
    173172        }
     
    180179******************************************************************/
    181180
    182 static uint32 write_this_server_name( struct subnet_record *subrec,
     181static uint32_t write_this_server_name( struct subnet_record *subrec,
    183182                                      struct work_record *work,
    184183                                      struct server_record *servrec)
     
    218217******************************************************************/
    219218
    220 static uint32 write_this_workgroup_name( struct subnet_record *subrec,
     219static uint32_t write_this_workgroup_name( struct subnet_record *subrec,
    221220                                         struct work_record *work)
    222221{
     
    250249  ******************************************************************/
    251250
    252 void write_browse_list_entry(XFILE *fp, const char *name, uint32 rec_type,
     251void write_browse_list_entry(XFILE *fp, const char *name, uint32_t rec_type,
    253252                const char *local_master_browser_name, const char *description)
    254253{
     
    270269        char *fname;
    271270        char *fnamenew;
    272         uint32 stype;
     271        uint32_t stype;
    273272        int i;
    274273        XFILE *fp;
     
    308307                                fname);
    309308        if (!fnamenew) {
     309                talloc_free(fname);
    310310                return;
    311311        }
     
    316316                DEBUG(0,("write_browse_list: Can't open file %s. Error was %s\n",
    317317                        fnamenew,strerror(errno)));
     318                talloc_free(fnamenew);
     319                talloc_free(fname);
    318320                return;
    319321        }
     
    328330                        lp_workgroup()));
    329331                x_fclose(fp);
     332                talloc_free(fnamenew);
     333                talloc_free(fname);
    330334                return;
    331335        }
     
    356360                /* Output server details, plus what workgroup they're in. */
    357361                write_browse_list_entry(fp, my_netbios_names(i), stype,
    358                         string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH), lp_workgroup());
     362                        string_truncate(lp_server_string(talloc_tos()), MAX_SERVER_STRING_LENGTH), lp_workgroup());
    359363        }
    360364
     
    364368                for (work = subrec->workgrouplist; work ; work = work->next) {
    365369                        /* Write out a workgroup record for a workgroup. */
    366                         uint32 wg_type = write_this_workgroup_name( subrec, work);
     370                        uint32_t wg_type = write_this_workgroup_name( subrec, work);
    367371
    368372                        if(wg_type) {
     
    375379
    376380                        for (servrec = work->serverlist; servrec ; servrec = servrec->next) {
    377                                 uint32 serv_type;
     381                                uint32_t serv_type;
    378382
    379383                                /* We have already written our names here. */
     
    396400        rename(fnamenew,fname);
    397401        DEBUG(3,("write_browse_list: Wrote browse list into file %s\n",fname));
    398 }
     402        talloc_free(fnamenew);
     403        talloc_free(fname);
     404}
  • vendor/current/source3/nmbd/nmbd_subnetdb.c

    r740 r988  
    3838struct subnet_record *wins_server_subnet = NULL;
    3939
    40 extern uint16 samba_nb_type; /* Samba's NetBIOS name type. */
     40extern uint16_t samba_nb_type; /* Samba's NetBIOS name type. */
    4141
    4242/****************************************************************************
     
    248248        /* Only count IPv4, non-loopback interfaces. */
    249249        if (iface_count_v4_nl() == 0) {
    250                 DEBUG(0,("create_subnets: No local IPv4 non-loopback interfaces !\n"));
    251                 DEBUG(0,("create_subnets: Waiting for an interface to appear ...\n"));
     250                daemon_status("nmbd",
     251                              "No local IPv4 non-loopback interfaces "
     252                              "available, waiting for interface ...");
     253                DEBUG(0,("NOTE: NetBIOS name resolution is not supported for "
     254                         "Internet Protocol Version 6 (IPv6).\n"));
    252255        }
    253256
     
    305308                 */
    306309
    307                 if (is_loopback_addr((struct sockaddr *)&iface->ip)) {
     310                if (is_loopback_addr((const struct sockaddr *)&iface->ip)) {
    308311                        DEBUG(2,("create_subnets: Ignoring loopback interface.\n" ));
    309312                        continue;
  • vendor/current/source3/nmbd/nmbd_synclists.c

    r740 r988  
    55   Copyright (C) Luke Kenneth Casson Leighton 1994-1998
    66   Copyright (C) Jeremy Allison 1994-1998
    7    
     7
    88   This program is free software; you can redistribute it and/or modify
    99   it under the terms of the GNU General Public License as published by
    1010   the Free Software Foundation; either version 3 of the License, or
    1111   (at your option) any later version.
    12    
     12
    1313   This program is distributed in the hope that it will be useful,
    1414   but WITHOUT ANY WARRANTY; without even the implied warranty of
    1515   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1616   GNU General Public License for more details.
    17    
     17
    1818   You should have received a copy of the GNU General Public License
    1919   along with this program.  If not, see <http://www.gnu.org/licenses/>.
    20    
    2120*/
    2221
     
    3332#include "libsmb/libsmb.h"
    3433#include "libsmb/clirap.h"
    35 #include "smbprofile.h"
     34#include "../libcli/smb/smbXcli_base.h"
    3635
    3736struct sync_record {
     
    5453  ******************************************************************/
    5554
    56 static void callback(const char *sname, uint32 stype,
     55static void callback(const char *sname, uint32_t stype,
    5756                     const char *comment, void *state)
    5857{
     
    7372        fstring unix_workgroup;
    7473        struct cli_state *cli;
    75         uint32 local_type = local ? SV_TYPE_LOCAL_LIST_ONLY : 0;
    76         struct nmb_name called, calling;
     74        uint32_t local_type = local ? SV_TYPE_LOCAL_LIST_ONLY : 0;
    7775        struct sockaddr_storage ss;
    7876        NTSTATUS status;
     
    8280         */
    8381
    84         cli = cli_initialise();
    85         if (!cli) {
    86                 return;
    87         }
    88 
    89         cli_set_port(cli, 139);
    90 
    9182        in_addr_to_sockaddr_storage(&ss, ip);
    92         status = cli_connect(cli, name, &ss);
     83
     84        status = cli_connect_nb(name, &ss, NBT_SMB_PORT, nm_type,
     85                                get_local_machine_name(), SMB_SIGNING_DEFAULT,
     86                                0, &cli);
    9387        if (!NT_STATUS_IS_OK(status)) {
    94                 cli_shutdown(cli);
    95                 return;
    96         }
    97 
    98         make_nmb_name(&calling, get_local_machine_name(), 0x0);
    99         make_nmb_name(&called , name, nm_type);
    100 
    101         if (!cli_session_request(cli, &calling, &called)) {
    102                 cli_shutdown(cli);
    103                 return;
    104         }
    105 
    106         status = cli_negprot(cli);
     88                return;
     89        }
     90
     91        status = smbXcli_negprot(cli->conn, cli->timeout, PROTOCOL_CORE,
     92                                 PROTOCOL_NT1);
    10793        if (!NT_STATUS_IS_OK(status)) {
    10894                cli_shutdown(cli);
     
    116102        }
    117103
    118         if (!NT_STATUS_IS_OK(cli_tcon_andx(cli, "IPC$", "IPC", "", 1))) {
     104        if (!NT_STATUS_IS_OK(cli_tree_connect(cli, "IPC$", "IPC", "", 1))) {
    119105                cli_shutdown(cli);
    120106                return;
     
    128114                          local_type|SV_TYPE_DOMAIN_ENUM,
    129115                          callback, NULL);
    130        
     116
    131117        /* Now fetch a server list. */
    132118        if (servers) {
     
    136122                                  callback, NULL);
    137123        }
    138        
     124
    139125        cli_shutdown(cli);
    140126}
     
    153139        static int counter;
    154140
    155         START_PROFILE(sync_browse_lists);
    156141        /* Check we're not trying to sync with ourselves. This can
    157142           happen if we are a domain *and* a local master browser. */
    158143        if (ismyip_v4(ip)) {
    159144done:
    160                 END_PROFILE(sync_browse_lists);
    161145                return;
    162146        }
     
    171155        s->ip = ip;
    172156
    173         if (asprintf(&s->fname, "%s/sync.%d", lp_lockdir(), counter++) < 0) {
     157        if (asprintf(&s->fname, "%s/sync.%d", lp_lock_directory(), counter++) < 0) {
    174158                SAFE_FREE(s);
    175159                goto done;
     
    181165
    182166        /* the parent forks and returns, leaving the child to do the
    183            actual sync and call END_PROFILE*/
     167           actual sync */
    184168        CatchChild();
    185         if ((s->pid = sys_fork())) return;
     169        if ((s->pid = fork())) return;
    186170
    187171        BlockSignals( False, SIGTERM );
     
    192176        fp = x_fopen(s->fname,O_WRONLY|O_CREAT|O_TRUNC, 0644);
    193177        if (!fp) {
    194                 END_PROFILE(sync_browse_lists);
    195178                _exit(1);
    196179        }
     
    200183
    201184        x_fclose(fp);
    202         END_PROFILE(sync_browse_lists);
    203185        _exit(0);
    204186}
     
    209191
    210192static void complete_one(struct sync_record *s,
    211                          char *sname, uint32 stype, char *comment)
     193                         char *sname, uint32_t stype, char *comment)
    212194{
    213195        struct work_record *work;
  • vendor/current/source3/nmbd/nmbd_winsproxy.c

    r740 r988  
    3535        struct subnet_record *orig_broadcast_subnet;
    3636        struct name_record *namerec = NULL;
    37         uint16 nb_flags;
     37        uint16_t nb_flags;
    3838        int num_ips;
    3939        int i;
  • vendor/current/source3/nmbd/nmbd_winsserver.c

    r746 r988  
    99   the Free Software Foundation; either version 3 of the License, or
    1010   (at your option) any later version.
    11    
     11
    1212   This program is distributed in the hope that it will be useful,
    1313   but WITHOUT ANY WARRANTY; without even the implied warranty of
    1414   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1515   GNU General Public License for more details.
    16    
     16
    1717   You should have received a copy of the GNU General Public License
    1818   along with this program.  If not, see <http://www.gnu.org/licenses/>.
    19    
     19
    2020   Converted to store WINS data in a tdb. Dec 2005. JRA.
    2121*/
     
    7676
    7777/****************************************************************************
    78  Convert a wins.tdb record to a struct name_record. Add in our global_scope().
     78 Convert a wins.tdb record to a struct name_record. Add in our lp_netbios_scope().
    7979*****************************************************************************/
    8080
     
    8282{
    8383        struct name_record *namerec = NULL;
    84         uint16 nb_flags;
     84        uint16_t nb_flags;
    8585        unsigned char nr_src;
    86         uint32 death_time, refresh_time;
    87         uint32 id_low, id_high;
    88         uint32 saddr;
    89         uint32 wins_flags;
    90         uint32 num_ips;
     86        uint32_t death_time, refresh_time;
     87        uint32_t id_low, id_high;
     88        uint32_t saddr;
     89        uint32_t wins_flags;
     90        uint32_t num_ips;
    9191        size_t len;
    9292        int i;
     
    129129        namerec->name.name_type = key.dptr[sizeof(unstring)];
    130130        /* Add the scope. */
    131         push_ascii(namerec->name.scope, global_scope(), 64, STR_TERMINATE);
     131        push_ascii(namerec->name.scope, lp_netbios_scope(), 64, STR_TERMINATE);
    132132
    133133        /* We're using a byte-by-byte compare, so we must be sure that
    134134         * unused space doesn't have garbage in it.
    135135         */
    136                                                                                                                                
     136
    137137        for( i = strlen( namerec->name.name ); i < sizeof( namerec->name.name ); i++ ) {
    138138                namerec->name.name[i] = '\0';
     
    147147        namerec->data.refresh_time = (time_t)refresh_time;
    148148        namerec->data.id = id_low;
    149 #if defined(HAVE_LONGLONG)
    150149        namerec->data.id |= ((uint64_t)id_high << 32);
    151 #endif
    152150        namerec->data.wins_ip.s_addr = saddr;
    153151        namerec->data.wins_flags = wins_flags,
     
    170168        size_t len = 0;
    171169        int i;
    172         uint32 id_low = (namerec->data.id & 0xFFFFFFFF);
    173 #if defined(HAVE_LONGLONG)
    174         uint32 id_high = (namerec->data.id >> 32) & 0xFFFFFFFF;
    175 #else
    176         uint32 id_high = 0;
    177 #endif
     170        uint32_t id_low = (namerec->data.id & 0xFFFFFFFF);
     171        uint32_t id_high = (namerec->data.id >> 32) & 0xFFFFFFFF;
    178172
    179173        ZERO_STRUCT(data);
     
    182176        len += (namerec->data.num_ips * 4);
    183177
    184         data.dptr = (uint8 *)SMB_MALLOC(len);
     178        data.dptr = (uint8_t *)SMB_MALLOC(len);
    185179        if (!data.dptr) {
    186180                return data;
     
    191185                        namerec->data.nb_flags,
    192186                        (unsigned char)namerec->data.source,
    193                         (uint32)namerec->data.death_time,
    194                         (uint32)namerec->data.refresh_time,
     187                        (uint32_t)namerec->data.death_time,
     188                        (uint32_t)namerec->data.refresh_time,
    195189                        id_low,
    196190                        id_high,
    197                         (uint32)namerec->data.wins_ip.s_addr,
    198                         (uint32)namerec->data.wins_flags,
    199                         (uint32)namerec->data.num_ips );
     191                        (uint32_t)namerec->data.wins_ip.s_addr,
     192                        (uint32_t)namerec->data.wins_flags,
     193                        (uint32_t)namerec->data.num_ips );
    200194
    201195        for (i = 0; i < namerec->data.num_ips; i++) {
     
    218212
    219213        pull_ascii_nstring(keydata, sizeof(unstring), nmbname->name);
    220         strupper_m(keydata);
     214        (void)strupper_m(keydata);
    221215        keydata[sizeof(unstring)] = nmbname->name_type;
    222         key.dptr = (uint8 *)keydata;
     216        key.dptr = (uint8_t *)keydata;
    223217        key.dsize = sizeof(keydata);
    224218
     
    277271                }
    278272        }
    279        
     273
    280274        DLIST_ADD(wins_server_subnet->namelist, namerec);
    281275        return namerec;
     
    446440
    447441        DEBUG(5,("get_global_id_and_update: updating version ID: %d\n", (int)general_id));
    448        
     442
    449443        *current_id = general_id;
    450        
     444
    451445        if (update) {
    452446                general_id++;
     
    462456{
    463457        char *command = NULL;
    464         char *cmd = lp_wins_hook();
     458        char *cmd = lp_wins_hook(talloc_tos());
    465459        char *p, *namestr;
    466460        int i;
     
    479473                }
    480474        }
    481        
     475
    482476        /* Use the name without the nametype (and scope) appended */
    483477
     
    601595        XFILE *fp;
    602596        char line[1024];
     597        char *db_path;
     598        char *list_path;
    603599
    604600        if(!lp_we_are_a_wins_server()) {
     
    606602        }
    607603
     604        db_path = state_path("wins.tdb");
     605        if (db_path == NULL) {
     606                return false;
     607        }
     608
    608609        /* Open the wins.tdb. */
    609         wins_tdb = tdb_open_log(state_path("wins.tdb"), 0, TDB_DEFAULT|TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH,
     610        wins_tdb = tdb_open_log(db_path, 0, TDB_DEFAULT|TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH,
    610611                        O_CREAT|O_RDWR, 0600);
     612        TALLOC_FREE(db_path);
    611613        if (!wins_tdb) {
    612614                DEBUG(0,("initialise_wins: failed to open wins.tdb. Error was %s\n",
     
    619621        add_samba_names_to_subnet(wins_server_subnet);
    620622
    621         if((fp = x_fopen(state_path(WINS_LIST),O_RDONLY,0)) == NULL) {
     623        list_path = state_path(WINS_LIST);
     624        if (list_path == NULL) {
     625                tdb_close(wins_tdb);
     626                return false;
     627        }
     628
     629        fp = x_fopen(list_path, O_RDONLY, 0);
     630        TALLOC_FREE(list_path);
     631        if (fp == NULL) {
    622632                DEBUG(2,("initialise_wins: Can't open wins database file %s. Error was %s\n",
    623633                        WINS_LIST, strerror(errno) ));
     
    853863        struct nmb_name *question = &nmb->question.question_name;
    854864        bool bcast = nmb->header.nm_flags.bcast;
    855         uint16 nb_flags = get_nb_flags(nmb->additional->rdata);
     865        uint16_t nb_flags = get_nb_flags(nmb->additional->rdata);
    856866        bool group = (nb_flags & NB_GROUP) ? True : False;
    857867        struct name_record *namerec = NULL;
     
    11601170        struct nmb_name *question = &nmb->question.question_name;
    11611171        bool bcast = nmb->header.nm_flags.bcast;
    1162         uint16 nb_flags = get_nb_flags(nmb->additional->rdata);
     1172        uint16_t nb_flags = get_nb_flags(nmb->additional->rdata);
    11631173        int ttl = get_ttl_from_packet(nmb);
    11641174        struct name_record *namerec = NULL;
     
    16101620        struct nmb_name *question = &nmb->question.question_name;
    16111621        bool bcast = nmb->header.nm_flags.bcast;
    1612         uint16 nb_flags = get_nb_flags(nmb->additional->rdata);
     1622        uint16_t nb_flags = get_nb_flags(nmb->additional->rdata);
    16131623        int ttl = get_ttl_from_packet(nmb);
    16141624        struct name_record *namerec = NULL;
     
    16751685                namerec = NULL;
    16761686        }
    1677  
     1687
    16781688        /*
    16791689         * Deal with the case where the name found was a dns entry.
     
    17681778                        update_wins_flag(namerec, WINS_ACTIVE);
    17691779                }
    1770    
     1780
    17711781                wins_hook("refresh", namerec, ttl);
    17721782                send_wins_name_registration_response(0, ttl, p);
     
    18781888 Deal with the special name query for *<1b>.
    18791889***********************************************************************/
    1880    
    1881 static void process_wins_dmb_query_request(struct subnet_record *subrec, 
     1890
     1891static void process_wins_dmb_query_request(struct subnet_record *subrec,
    18821892                                           struct packet_struct *p)
    1883 { 
     1893{
    18841894        struct name_record *namerec = NULL;
    18851895        char *prdata;
     
    20932103         */
    20942104
    2095         if(lp_dns_proxy() && ((question->name_type == 0x20) || question->name_type == 0)) {
     2105        if(lp_wins_dns_proxy() && ((question->name_type == 0x20) || question->name_type == 0)) {
    20962106                DEBUG(3,("wins_process_name_query: name query for name %s not found - doing dns lookup.\n",
    20972107                                nmb_namestr(question) ));
     
    21382148        struct nmb_name *question = &nmb->question.question_name;
    21392149        bool bcast = nmb->header.nm_flags.bcast;
    2140         uint16 nb_flags = get_nb_flags(nmb->additional->rdata);
     2150        uint16_t nb_flags = get_nb_flags(nmb->additional->rdata);
    21412151        struct name_record *namerec = NULL;
    21422152        struct in_addr from_ip;
     
    21572167                return;
    21582168        }
    2159  
     2169
    21602170        DEBUG(3,("wins_process_name_release_request: %s name release for name %s \
    21612171IP %s\n", releasing_group_name ? "Group" : "Unique", nmb_namestr(question), inet_ntoa(from_ip) ));
    2162    
     2172
    21632173        /*
    21642174         * Deal with policy regarding 0x1d names.
     
    21752185         * See if the name already exists.
    21762186         */
    2177    
     2187
    21782188        namerec = find_name_on_subnet(subrec, question, FIND_ANY_NAME);
    21792189
     
    24712481        if (background) {
    24722482                CatchChild();
    2473                 if (sys_fork()) {
     2483                if (fork()) {
    24742484                        return;
    24752485                }
     
    24882498        all_string_sub(fname,"//", "/", 0);
    24892499
    2490         if (asprintf(&fnamenew, "%s.%u", fname, (unsigned int)sys_getpid()) < 0) {
     2500        if (asprintf(&fnamenew, "%s.%u", fname, (unsigned int)getpid()) < 0) {
    24912501                goto err_exit;
    24922502        }
     
    25422552                return;
    25432553        }
    2544        
     2554
    25452555        /* Record should use UNIX codepage. Ensure this is so in the wrepld code. JRA. */
    25462556        record=(WINS_RECORD *)buf;
    2547        
     2557
    25482558        make_nmb_name(&question, record->name, record->type);
    25492559
     
    25932603                                        else
    25942604                                                overwrite=True;
    2595                                
     2605
    25962606                                } else {
    25972607                                /* the 2 records have different IP address */
     
    26082618                        }
    26092619                }
    2610                
     2620
    26112621                /* the replica is a standard group */
    26122622                if (record->wins_flags&WINS_NGROUP || record->wins_flags&WINS_SGROUP) {
     
    26162626                                ;
    26172627                        overwrite=True;
    2618                
    2619                 }
    2620        
     2628
     2629                }
     2630
    26212631                /* the replica is a special group */
    26222632                if (record->wins_flags&WINS_SGROUP && namerec->data.wins_flags&WINS_SGROUP) {
     
    26292639                        }
    26302640                }
    2631                
     2641
    26322642                /* the replica is a multihomed host */
    2633                
     2643
    26342644                /* I'm giving up on multi homed. Too much complex to understand */
    2635                
     2645
    26362646                if (record->wins_flags&WINS_MHOMED) {
    26372647                        if (! (namerec->data.wins_flags&WINS_ACTIVE)) {
     
    26422652                                if (ip_equal_v4(record->wins_ip, namerec->data.wins_ip))
    26432653                                        overwrite=True;
    2644                                
     2654
    26452655                                if (ip_equal_v4(namerec->data.wins_ip, our_fake_ip))
    26462656                                        if (namerec->data.wins_flags&WINS_UNIQUE)
    26472657                                                get_global_id_and_update(&namerec->data.id, True);
    2648                                
     2658
    26492659                        }
    2650                        
     2660
    26512661                        if (record->wins_flags&WINS_ACTIVE && namerec->data.wins_flags&WINS_ACTIVE)
    26522662                                if (namerec->data.wins_flags&WINS_UNIQUE ||
     
    26542664                                        if (ip_equal_v4(record->wins_ip, namerec->data.wins_ip))
    26552665                                                overwrite=True;
    2656                                
     2666
    26572667                }
    26582668
  • vendor/current/source3/nmbd/nmbd_workgroupdb.c

    r740 r988  
    2525#include "nmbd/nmbd.h"
    2626
    27 extern uint16 samba_nb_type;
     27extern uint16_t samba_nb_type;
    2828
    2929int workgroup_count = 0; /* unique index key: one for each workgroup */
     
    5353                unstring tname;
    5454                pull_ascii_nstring(tname, sizeof(tname), nname);
    55                 unstrcpy(unname, tname);
     55                strlcpy(unname, tname, sizeof(nname));
    5656                DEBUG(0,("name_to_nstring: workgroup name %s is too long. Truncating to %s\n",
    5757                        name, tname));
     
    251251                int stype = lp_default_server_announce() | (lp_local_master() ?  SV_TYPE_POTENTIAL_BROWSER : 0 );
    252252   
    253                 if(!strequal(global_myname(), name))
     253                if(!strequal(lp_netbios_name(), name))
    254254                        stype &= ~(SV_TYPE_MASTER_BROWSER|SV_TYPE_POTENTIAL_BROWSER|SV_TYPE_DOMAIN_MASTER|SV_TYPE_DOMAIN_MEMBER);
    255255   
    256256                create_server_on_workgroup(work,name,stype|SV_TYPE_LOCAL_LIST_ONLY, PERMANENT_TTL,
    257                                 string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH));
     257                                string_truncate(lp_server_string(talloc_tos()), MAX_SERVER_STRING_LENGTH));
    258258                DEBUG(3,("initiate_myworkgroup_startup: Added server name entry %s \
    259259on subnet %s\n", name, subrec->subnet_name));
Note: See TracChangeset for help on using the changeset viewer.