1) updated ipc.c NetUserGetInfo - load \\%L\%U instead of \\%L\HOMES
[samba.git] / source3 / nameelect.c
1 /* 
2    Unix SMB/Netbios implementation.
3    Version 1.9.
4    NBT netbios routines and daemon - version 2
5    Copyright (C) Andrew Tridgell 1994-1996
6    
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2 of the License, or
10    (at your option) any later version.
11    
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16    
17    You should have received a copy of the GNU General Public License
18    along with this program; if not, write to the Free Software
19    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20    
21    Module name: nameelect.c
22
23    Revision History:
24
25    14 jan 96: lkcl@pires.co.uk
26    added multiple workgroup domain master support
27
28    04 jul 96: lkcl@pires.co.uk
29    added system to become a master browser by stages.
30
31
32 */
33
34 #include "includes.h"
35
36 extern int ClientNMB;
37 extern int ClientDGRAM;
38
39 extern int DEBUGLEVEL;
40 extern pstring scope;
41
42 extern pstring myname;
43 extern struct in_addr ipzero;
44 extern struct in_addr ipgrp;
45
46 /* here are my election parameters */
47
48 extern time_t StartupTime;
49
50 extern struct subnet_record *subnetlist;
51
52 extern uint16 nb_type; /* samba's NetBIOS name type */
53
54
55 /*******************************************************************
56   occasionally check to see if the master browser is around
57   ******************************************************************/
58 void check_master_browser(time_t t)
59 {
60         static time_t lastrun=0;
61         struct subnet_record *d;
62
63         if (!lastrun) lastrun = t;
64         if (t < lastrun + CHECK_TIME_MST_BROWSE * 60)
65         return;
66         lastrun = t;
67
68         dump_workgroups();
69
70         for (d = subnetlist; d; d = d->next)
71         {
72                 struct work_record *work;
73
74                 for (work = d->workgrouplist; work; work = work->next)
75                 {
76                         if (!AM_MASTER(work))
77                         {
78                                 if (lp_preferred_master())
79                                 {
80                                         /* preferred master - not a master browser.  force
81                                            becoming a master browser, hence the log message.
82                                          */
83
84                                         DEBUG(0,("%s preferred master for %s %s - force election\n",
85                                                   timestring(), work->work_group,
86                                                   inet_ntoa(d->bcast_ip)));
87
88                                         browser_gone(work->work_group, d->bcast_ip);
89                                 }
90                                 else
91                                 {
92                                         /* if we are not the browse master of a workgroup,
93                                            and we can't find a browser on the subnet, do
94                                            something about it.
95                                          */
96
97                                         queue_netbios_packet(d,ClientNMB,NMB_QUERY,NAME_QUERY_MST_CHK,
98                                                      work->work_group,0x1d,0,0,0,NULL,NULL,
99                                                      True,False,d->bcast_ip,d->bcast_ip);
100                                 }
101                         }
102                 }
103         }
104 }
105
106
107 /*******************************************************************
108   what to do if a master browser DOESN't exist
109   ******************************************************************/
110 void browser_gone(char *work_name, struct in_addr ip)
111 {
112   struct subnet_record *d = find_subnet(ip);
113   struct work_record *work = find_workgroupstruct(d, work_name, False);
114
115   /* i don't know about this workgroup, therefore i don't care */
116   if (!work || !d) return;
117
118   /* don't do election stuff on the WINS subnet */
119   if (ip_equal(d->bcast_ip,ipgrp)) 
120     return;
121
122   if (strequal(work->work_group, lp_workgroup()))
123   {
124
125       DEBUG(2,("Forcing election on %s %s\n",
126                work->work_group,inet_ntoa(d->bcast_ip)));
127
128       /* we can attempt to become master browser */
129       work->needelection = True;
130   }
131   else
132   {
133      /* local interfaces: force an election */
134     send_election(d, work->work_group, 0, 0, myname);
135
136      /* only removes workgroup completely on a local interface 
137         persistent lmhosts entries on a local interface _will_ be removed).
138       */
139      remove_workgroup(d, work,True);
140   }
141 }
142
143
144 /****************************************************************************
145   send an election packet
146   **************************************************************************/
147 void send_election(struct subnet_record *d, char *group,uint32 criterion,
148                    int timeup,char *name)
149 {
150   pstring outbuf;
151   char *p;
152
153   if (!d) return;
154   
155   DEBUG(2,("Sending election to %s for workgroup %s\n",
156            inet_ntoa(d->bcast_ip),group));         
157
158   bzero(outbuf,sizeof(outbuf));
159   p = outbuf;
160   CVAL(p,0) = ANN_Election; /* election */
161   p++;
162
163   CVAL(p,0) = (criterion == 0 && timeup == 0) ? 0 : ELECTION_VERSION;
164   SIVAL(p,1,criterion);
165   SIVAL(p,5,timeup*1000); /* ms - despite the spec */
166   p += 13;
167   strcpy(p,name);
168   strupper(p);
169   p = skip_string(p,1);
170   
171   send_mailslot_reply(False,BROWSE_MAILSLOT,ClientDGRAM,
172               outbuf,PTR_DIFF(p,outbuf),
173                       name,group,0,0x1e,d->bcast_ip,*iface_ip(d->bcast_ip));
174 }
175
176
177 /****************************************************************************
178   un-register a SELF name that got rejected.
179
180   if this name happens to be rejected when samba is in the process
181   of becoming a master browser (registering __MSBROWSE__, WORKGROUP(1d)
182   or WORKGROUP(1b)) then we must stop being a master browser. sad.
183
184   **************************************************************************/
185 void name_unregister_work(struct subnet_record *d, char *name, int name_type)
186 {
187     struct work_record *work;
188     int remove_type_local  = 0;
189     int remove_type_domain = 0;
190     int remove_type_logon  = 0;
191
192     remove_netbios_name(d,name,name_type,SELF,ipzero);
193
194     if (!(work = find_workgroupstruct(d, name, False))) return;
195
196     /* work out what to unbecome, from the name type being removed */
197
198     if (ms_browser_name(name, name_type))
199     {
200       remove_type_local |= SV_TYPE_MASTER_BROWSER;
201     }
202     if (AM_MASTER(work) && strequal(name, lp_workgroup()) == 0 &&
203          name_type == 0x1d)
204     {
205       remove_type_local |= SV_TYPE_MASTER_BROWSER;
206     }
207     if (AM_DOMMST(work) && strequal(name, lp_workgroup()) == 0 &&
208          name_type == 0x1b)
209     {
210       remove_type_domain |= SV_TYPE_DOMAIN_MASTER;
211     }
212     if (AM_DOMMEM(work) && strequal(name, lp_workgroup()) == 0 &&
213          name_type == 0x1c)
214     {
215       remove_type_logon|= SV_TYPE_DOMAIN_MEMBER;
216     }
217
218     if (remove_type_local ) unbecome_local_master (d, work, remove_type_local );
219     if (remove_type_domain) unbecome_domain_master(d, work, remove_type_domain);
220     if (remove_type_logon ) unbecome_logon_server (d, work, remove_type_logon );
221 }
222
223
224 /****************************************************************************
225   registers a name.
226
227   if the name being added is a SELF name, we must additionally check
228   whether to proceed to the next stage in samba becoming a master browser.
229
230   **************************************************************************/
231 void name_register_work(struct subnet_record *d, char *name, int name_type,
232                                 int nb_flags, time_t ttl, struct in_addr ip, BOOL bcast)
233 {
234   enum name_source source = (ismyip(ip) || ip_equal(ip, ipzero)) ?
235                                                                 SELF : REGISTER;
236
237   if (source == SELF)
238   {
239     struct work_record *work = find_workgroupstruct(d, lp_workgroup(), False);
240
241     add_netbios_entry(d,name,name_type,nb_flags,ttl,source,ip,True,!bcast);
242
243     if (work)
244     {
245       if (work->mst_state != MST_POTENTIAL)
246       {
247         /* samba is working towards local master browser-ness.
248            initiate the next stage.
249          */
250         become_local_master(d, work);
251         return;
252       }
253       if (work->dom_state != DOMAIN_NONE)
254       {
255         /* samba is working towards domain master browser-ness.
256            initiate the next stage.
257          */
258         become_domain_master(d, work);
259         return;
260       }
261       if (work->log_state != LOGON_NONE)
262       {
263         /* samba is working towards domain master browser-ness.
264            initiate the next stage.
265          */
266         become_logon_server(d, work);
267         return;
268       }
269     }
270   }
271 }
272
273
274 /*******************************************************************
275   become the local master browser.
276
277   this is done in stages. note that this could take a while, 
278   particularly on a broadcast subnet, as we have to wait for
279   the implicit registration of each name to be accepted.
280
281   as each name is successfully registered, become_local_master() is
282   called again, in order to initiate the next stage. see
283   dead_netbios_entry() - deals with implicit name registration
284   and response_name_reg() - deals with explicit registration
285   with a WINS server.
286
287   stage 1: was MST_POTENTIAL - go to MST_POTENTIAL and register ^1^2__MSBROWSE__^2^1.
288   stage 2: was MST_BACK  - go to MST_MSB  and register WORKGROUP(0x1d)
289   stage 3: was MST_MSB  - go to MST_BROWSER and stay there 
290
291   XXXX note: this code still does not cope with the distinction
292   between different types of nodes, particularly between M and P
293   nodes. that comes later.
294
295   ******************************************************************/
296 void become_local_master(struct subnet_record *d, struct work_record *work)
297 {
298   /* domain type must be limited to domain enum + server type. it must
299      not have SV_TYPE_SERVER or anything else with SERVER in it, else
300      clients get confused and start thinking this entry is a server
301      not a workgroup
302    */
303   uint32 domain_type = SV_TYPE_DOMAIN_ENUM|SV_TYPE_NT;
304
305   if (!work || !d) return;
306   
307   DEBUG(2,("Becoming master for %s %s (currently at stage %d)\n",
308                                         work->work_group,inet_ntoa(d->bcast_ip),work->mst_state));
309   
310   switch (work->mst_state)
311   {
312     case MST_POTENTIAL: /* while we were nothing but a server... */
313     {
314       DEBUG(3,("go to first stage: register ^1^2__MSBROWSE__^2^1\n"));
315       work->mst_state = MST_BACK; /* ... an election win was successful */
316
317       work->ElectionCriterion |= 0x5;
318
319       /* update our server status */
320       work->ServerType &= ~SV_TYPE_POTENTIAL_BROWSER;
321       add_server_entry(d,work,myname,work->ServerType,0,lp_serverstring(),True);
322
323       /* add special browser name */
324       add_my_name_entry(d,MSBROWSE        ,0x01,nb_type|NB_ACTIVE|NB_GROUP);
325
326       /* DON'T do anything else after calling add_my_name_entry() */
327       break;
328     }
329
330     case MST_BACK: /* while nothing had happened except we won an election... */
331     {
332       DEBUG(3,("go to second stage: register as master browser\n"));
333       work->mst_state = MST_MSB; /* ... registering MSBROWSE was successful */
334
335       /* add server entry on successful registration of MSBROWSE */
336       add_server_entry(d,work,work->work_group,domain_type,0,myname,True);
337
338       /* add master name */
339       add_my_name_entry(d,work->work_group,0x1d,nb_type|NB_ACTIVE);
340   
341       /* DON'T do anything else after calling add_my_name_entry() */
342       break;
343     }
344
345     case MST_MSB: /* while we were still only registered MSBROWSE state... */
346     {
347       DEBUG(3,("2nd stage complete: registered as master browser\n"));
348       work->mst_state = MST_BROWSER; /* ... registering WORKGROUP(1d) succeeded */
349
350       /* update our server status */
351       work->ServerType |= SV_TYPE_MASTER_BROWSER;
352       add_server_entry(d,work,myname,work->ServerType,0,lp_serverstring(),True);
353
354       if (work->serverlist == NULL) /* no servers! */
355       {
356         /* ask all servers on our local net to announce to us */
357         /* XXXX OOPS! add_server_entry will always add one entry - our own. */
358         announce_request(work, d->bcast_ip);
359       }
360       break;
361     }
362
363     case MST_BROWSER:
364     {
365       /* don't have to do anything: just report success */
366       DEBUG(3,("3rd stage: become master browser!\n"));
367
368       break;
369     }
370   }
371 }
372
373
374 /*******************************************************************
375   become the domain master browser.
376
377   this is done in stages. note that this could take a while, 
378   particularly on a broadcast subnet, as we have to wait for
379   the implicit registration of each name to be accepted.
380
381   as each name is successfully registered, become_domain_master() is
382   called again, in order to initiate the next stage. see
383   dead_netbios_entry() - deals with implicit name registration
384   and response_name_reg() - deals with explicit registration
385   with a WINS server.
386
387   stage 1: was DOMAIN_NONE - go to DOMAIN_MST 
388
389   XXXX note: this code still does not cope with the distinction
390   between different types of nodes, particularly between M and P
391   nodes. that comes later.
392
393   ******************************************************************/
394 void become_domain_master(struct subnet_record *d, struct work_record *work)
395 {
396   /* domain type must be limited to domain enum + server type. it must
397      not have SV_TYPE_SERVER or anything else with SERVER in it, else
398      clients get confused and start thinking this entry is a server
399      not a workgroup
400    */
401
402   if (!work || !d) return;
403   
404   DEBUG(2,("Becoming domain master for %s %s (currently at stage %d)\n",
405                                         work->work_group,inet_ntoa(d->bcast_ip),work->dom_state));
406   
407   switch (work->dom_state)
408   {
409     case DOMAIN_NONE: /* while we were nothing but a server... */
410     {
411       if (lp_domain_master())
412       {
413                   DEBUG(3,("go to first stage: register <1b> name\n"));
414                   work->dom_state = DOMAIN_WAIT;
415
416                   /* XXXX the 0x1b is domain master browser name */
417                   add_my_name_entry(d, lp_workgroup(),0x1b,nb_type|NB_ACTIVE|NB_GROUP);
418
419                   /* DON'T do anything else after calling add_my_name_entry() */
420                   break;
421       }
422       else
423       {
424         DEBUG(4,("samba not configured as a domain master.\n"));
425       }
426   
427       break;
428     }
429
430    case DOMAIN_WAIT:
431    {
432       if (lp_domain_master())
433       {
434         work->dom_state = DOMAIN_MST; /* ... become domain master */
435         DEBUG(3,("domain first stage: register as domain member\n"));
436  
437         /* update our server status */
438         work->ServerType |= SV_TYPE_NT|SV_TYPE_DOMAIN_MASTER;
439         add_server_entry(d,work,myname,work->ServerType,0,
440                          lp_serverstring(),True);
441
442         DEBUG(4,("samba is now a domain master\n"));
443
444         break;
445       }
446       else
447       {
448         DEBUG(4,("samba not configured as a domain master.\n"));
449       }
450   
451       break;
452    }
453
454     case DOMAIN_MST:
455     {
456       /* don't have to do anything: just report success */
457       DEBUG(3,("domain second stage: there isn't one!\n"));
458       break;
459     }
460   }
461 }
462
463
464 /*******************************************************************
465   become a logon server.
466   ******************************************************************/
467 void become_logon_server(struct subnet_record *d, struct work_record *work)
468 {
469   if (!work || !d) return;
470   
471   DEBUG(2,("Becoming logon server for %s %s (currently at stage %d)\n",
472                                         work->work_group,inet_ntoa(d->bcast_ip),work->log_state));
473   
474   switch (work->log_state)
475   {
476     case LOGON_NONE: /* while we were nothing but a server... */
477     {
478       if (lp_domain_logons())
479       {
480                   DEBUG(3,("go to first stage: register <1c> name\n"));
481                   work->log_state = LOGON_WAIT;
482
483           /* XXXX the 0x1c is apparently something to do with domain logons */
484           add_my_name_entry(d, lp_workgroup(),0x1c,nb_type|NB_ACTIVE|NB_GROUP);
485
486                   /* DON'T do anything else after calling add_my_name_entry() */
487                   break;
488       }
489       {
490         DEBUG(4,("samba not configured as a logon master.\n"));
491       }
492   
493       break;
494     }
495
496    case LOGON_WAIT:
497    {
498       if (lp_domain_logons())
499       {
500         work->log_state = LOGON_SRV; /* ... become logon server */
501         DEBUG(3,("logon second stage: register \n"));
502  
503         /* update our server status */
504         work->ServerType |= SV_TYPE_NT|SV_TYPE_DOMAIN_MEMBER;
505         add_server_entry(d,work,myname,work->ServerType,0,
506                          lp_serverstring(),True);
507
508         /* DON'T do anything else after calling add_my_name_entry() */
509         break;
510       }
511       else
512       {
513         DEBUG(4,("samba not configured as a logon server.\n"));
514       }
515   
516       break;
517    }
518
519    case LOGON_SRV:
520    {
521       DEBUG(3,("logon third stage: there isn't one!\n"));
522       break;
523    }
524
525   }
526 }
527
528
529 /*******************************************************************
530   unbecome the local master browser. initates removal of necessary netbios 
531   names, and tells the world that we are no longer a master browser.
532
533   XXXX this _should_ be used to demote to a backup master browser, without
534   going straight to non-master browser.  another time.
535
536   ******************************************************************/
537 void unbecome_local_master(struct subnet_record *d, struct work_record *work,
538                                 int remove_type)
539 {
540   int new_server_type = work->ServerType;
541
542   /* can only remove master types with this function */
543   remove_type &= SV_TYPE_MASTER_BROWSER;
544
545   new_server_type &= ~remove_type;
546
547   if (remove_type)
548   {
549     DEBUG(2,("Becoming local non-master for %s\n",work->work_group));
550   
551     /* no longer a master browser of any sort */
552
553     work->ServerType |= SV_TYPE_POTENTIAL_BROWSER;
554     work->ElectionCriterion &= ~0x4;
555     work->mst_state = MST_POTENTIAL;
556
557         /* announce ourselves as no longer active as a master browser. */
558     announce_server(d, work, work->work_group, myname, 0, 0);
559     remove_name_entry(d,MSBROWSE        ,0x01);
560     remove_name_entry(d,work->work_group,0x1d);
561   }
562 }
563
564
565 /*******************************************************************
566   unbecome the domain master browser. initates removal of necessary netbios 
567   names, and tells the world that we are no longer a domain browser.
568   ******************************************************************/
569 void unbecome_domain_master(struct subnet_record *d, struct work_record *work,
570                                 int remove_type)
571 {
572   int new_server_type = work->ServerType;
573
574   DEBUG(2,("Becoming domain non-master for %s\n",work->work_group));
575   
576   /* can only remove master or domain types with this function */
577   remove_type &= SV_TYPE_DOMAIN_MASTER;
578
579   new_server_type &= ~remove_type;
580
581   if (remove_type)
582   {
583     /* no longer a domain master browser of any sort */
584
585     work->dom_state = DOMAIN_NONE;
586
587         /* announce ourselves as no longer active as a master browser. */
588     announce_server(d, work, work->work_group, myname, 0, 0);
589     remove_name_entry(d,work->work_group,0x1b);    
590   }
591 }
592
593
594 /*******************************************************************
595   unbecome the logon server. initates removal of necessary netbios 
596   names, and tells the world that we are no longer a logon server.
597   ******************************************************************/
598 void unbecome_logon_server(struct subnet_record *d, struct work_record *work,
599                                 int remove_type)
600 {
601   int new_server_type = work->ServerType;
602
603   DEBUG(2,("Becoming logon non-server for %s\n",work->work_group));
604   
605   /* can only remove master or domain types with this function */
606   remove_type &= SV_TYPE_DOMAIN_MEMBER;
607
608   new_server_type &= ~remove_type;
609
610   if (remove_type)
611   {
612     /* no longer a master browser of any sort */
613
614     work->log_state = LOGON_NONE;
615
616         /* announce ourselves as no longer active as a master browser. */
617     announce_server(d, work, work->work_group, myname, 0, 0);
618     remove_name_entry(d,work->work_group,0x1c);    
619   }
620 }
621
622
623 /*******************************************************************
624   run the election
625   ******************************************************************/
626 void run_elections(time_t t)
627 {
628   static time_t lastime = 0;
629   
630   struct subnet_record *d;
631   
632   /* send election packets once a second */
633   if (lastime && t-lastime <= 0) return;
634   
635   lastime = t;
636   
637   for (d = subnetlist; d; d = d->next)
638   {
639     struct work_record *work;
640     for (work = d->workgrouplist; work; work = work->next)
641         {
642           if (work->RunningElection)
643           {
644             send_election(d,work->work_group, work->ElectionCriterion,
645                             t-StartupTime,myname);
646               
647             if (work->ElectionCount++ >= 4)
648                 {
649                   /* I won! now what :-) */
650                   DEBUG(2,(">>> Won election on %s %s <<<\n",
651                            work->work_group,inet_ntoa(d->bcast_ip)));
652                   
653                   work->RunningElection = False;
654                   work->mst_state = MST_POTENTIAL;
655
656                   become_local_master(d, work);
657                 }
658           }
659         }
660   }
661 }
662
663
664 /*******************************************************************
665   work out if I win an election
666   ******************************************************************/
667 static BOOL win_election(struct work_record *work,int version,uint32 criterion,
668                          int timeup,char *name)
669 {  
670   int mytimeup = time(NULL) - StartupTime;
671   uint32 mycriterion = work->ElectionCriterion;
672
673   DEBUG(4,("election comparison: %x:%x %x:%x %d:%d %s:%s\n",
674            version,ELECTION_VERSION,
675            criterion,mycriterion,
676            timeup,mytimeup,
677            name,myname));
678
679   if (version > ELECTION_VERSION) return(False);
680   if (version < ELECTION_VERSION) return(True);
681   
682   if (criterion > mycriterion) return(False);
683   if (criterion < mycriterion) return(True);
684
685   if (timeup > mytimeup) return(False);
686   if (timeup < mytimeup) return(True);
687
688   if (strcasecmp(myname,name) > 0) return(False);
689   
690   return(True);
691 }
692
693
694 /*******************************************************************
695   process a election packet
696
697   An election dynamically decides who will be the master. 
698   ******************************************************************/
699 void process_election(struct packet_struct *p,char *buf)
700 {
701   struct dgram_packet *dgram = &p->packet.dgram;
702   struct in_addr ip = dgram->header.source_ip;
703   struct subnet_record *d = find_subnet(ip);
704   int version = CVAL(buf,0);
705   uint32 criterion = IVAL(buf,1);
706   int timeup = IVAL(buf,5)/1000;
707   char *name = buf+13;
708   struct work_record *work;
709
710   if (!d) return;
711
712   if (ip_equal(d->bcast_ip,ipgrp)) {
713     DEBUG(3,("Unexpected election request from %s %s on WINS net\n",
714              name, inet_ntoa(p->ip)));
715     return;
716   }
717   
718   name[15] = 0;  
719
720   DEBUG(3,("Election request from %s %s vers=%d criterion=%08x timeup=%d\n",
721            name,inet_ntoa(p->ip),version,criterion,timeup));
722   
723   if (same_context(dgram)) return;
724   
725   for (work = d->workgrouplist; work; work = work->next)
726     {
727       if (!strequal(work->work_group, lp_workgroup()))
728         continue;
729
730       if (win_election(work, version,criterion,timeup,name)) {
731         if (!work->RunningElection) {
732           work->needelection = True;
733           work->ElectionCount=0;
734           work->mst_state = MST_POTENTIAL;
735         }
736       } else {
737         work->needelection = False;
738           
739         if (work->RunningElection || AM_MASTER(work)) {
740           work->RunningElection = False;
741           DEBUG(3,(">>> Lost election on %s %s <<<\n",
742                    work->work_group,inet_ntoa(d->bcast_ip)));
743           if (AM_MASTER(work))
744             unbecome_local_master(d, work, SV_TYPE_MASTER_BROWSER);
745         }
746       }
747     }
748 }
749
750
751 /****************************************************************************
752   checks whether a browser election is to be run on any workgroup
753
754   this function really ought to return the time between election
755   packets (which depends on whether samba intends to be a domain
756   master or a master browser) in milliseconds.
757
758   ***************************************************************************/
759 BOOL check_elections(void)
760 {
761   struct subnet_record *d;
762   BOOL run_any_election = False;
763
764   for (d = subnetlist; d; d = d->next)
765     {
766       struct work_record *work;
767       for (work = d->workgrouplist; work; work = work->next)
768         {
769           run_any_election |= work->RunningElection;
770           
771           if (work->needelection && !work->RunningElection)
772             {
773               DEBUG(3,(">>> Starting election on %s %s <<<\n",
774                        work->work_group,inet_ntoa(d->bcast_ip)));
775               work->ElectionCount = 0;
776               work->RunningElection = True;
777               work->needelection = False;
778             }
779         }
780     }
781   return run_any_election;
782 }
783