File: samba

package info (click to toggle)
logwatch 7.14-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,572 kB
  • sloc: perl: 8,290; sh: 354; makefile: 38
file content (556 lines) | stat: -rw-r--r-- 25,759 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556

########################################################
# Please file all bug reports, patches, and feature
# requests under:
#      https://sourceforge.net/p/logwatch/_list/tickets
# Help requests and discusion can be filed under:
#      https://sourceforge.net/p/logwatch/discussion/
########################################################

#######################################################
## Copyright (c) 2008 Kirk Bauer
## Covered under the included MIT/X-Consortium License:
##    http://www.opensource.org/licenses/mit-license.php
## All modifications and contributions by other persons to
## this script are assumed to have been donated to the
## Logwatch project and thus assume the above copyright
## and licensing terms.  If you want to make contributions
## under your own copyright or a different license this
## must be explicitly stated in the contribution an the
## Logwatch project reserves the right to not accept such
## contributions.  If you have made significant
## contributions to this script and want to claim
## copyright please contact logwatch-devel@lists.sourceforge.net.
#########################################################
use strict;

my $Debug = $ENV{'LOGWATCH_DEBUG'};
my $Detail = $ENV{'LOGWATCH_DETAIL_LEVEL'} || 0;
#Init Counters
my $SocketReadError = 0;
my $SocketWriteError = 0;
my $DbOpenFail = 0;
my $DbCorrupt = 0;
my $GetDomainMasterStatusFail = 0;
#Init String containers
my (
$Addr,          $Browser,           $Command,
$CurrentHost,   $Directory,         $Error,
$Group,         $Host,              $Ip,
$Location,      $Name,              $NoService,
$Reason,        $SID,               $Server,
$Service,       $Share,             $Signal,
$Subnet,        $Temp,              $User,
$Version,       $Where,             $dir,
$dsid,          $file,              $function,
$ip,            $read,              $user,
$write
);
#Init Hashes
my (
%AccountDisabled,       %BeLocalMaster,     %CantChangeDir,
%CantGetGroup,          %Connect,           %Crash,
%CrFile,                %Denied,            %DiscardWins,
%FailedRegister,        %ForceElection,     %GetBackupList,
%InvalidUser,           %LockDbError,       %NoServ,
%NotFoundUser,          %NotImplemented,    %OpenFile,
%OtherList,             %PermissionDenied,  %PrinterStatus,
%RefConnect,            %RejectRegister,    %RejectedUser,
%ReloadAfter,           %RootLoggedIn,      %SIDnotvalid,
%SubnetFail,            %UnicastRegister,   %WrongPassword,
);

if ( $Debug >= 5 ) {
   print STDERR "\n\nDEBUG: Inside Samba Filter \n\n";
}

while (defined(my $ThisLine = <STDIN>)) {
   chomp($ThisLine);
   if (
      ($ThisLine =~ /smbd\/server\.c:open_sockets_smbd\(\d+\)  Reloading services after SIGHUP/) or
      ($ThisLine =~ /lib\/util_sock\.c:get_peer_addr\(\d+\)  getpeername failed\. Error was (Transport endpoint|Socket) is not connected/) or
      ($ThisLine =~ /add_domain_logon_names/) or
      ($ThisLine =~ /become_domain_master/) or
      ($ThisLine =~ /become_local_master/) or
      ($ThisLine =~ /become_logon_server/) or
      ($ThisLine =~ /cli_connect\(783\)  Error connecting to [^ ]+ \(Operation already in progress\)$/) or
      ($ThisLine =~ /closed connection to/) or
      ($ThisLine =~ /Connection reset by peer/) or
      ($ThisLine =~ /Connection timed out/) or
      ($ThisLine =~ /current master browser/) or
      ($ThisLine =~ /Currently not implemented/) or
      ($ThisLine =~ /debug_message/) or
      ($ThisLine =~ /get_socket_addr\(\d+\)  getpeername failed. Error was Transport endpoint is not connected$/) or
      ($ThisLine =~ /Got SIGHUP dumping debug info.$/) or
      ($ThisLine =~ /Got SIGTERM: going down/) or
      ($ThisLine =~ /matchname/i) or
      ($ThisLine =~ /Multiple .+ responses received for a query/) or
      ($ThisLine =~ /nmbd\/nmbd_incomingdgrams\.c:process_local_master_announce\(\d+\)$/) or
      ($ThisLine =~ /nmbd_incomingrequests\.c:process_name_refresh_request\([0-9]+\)$/) or
      ($ThisLine =~ /nmbd_namelistdb\.c:standard_success_release\(\d+\)  standard_success_release: Name release for name/) or
      ($ThisLine =~ /No route to host/) or
      ($ThisLine =~ /Operation not permitted/) or
      ($ThisLine =~ /oplock[_ ]break/) or
      ($ThisLine =~ /process_local_message: unknown UDP message command code \(.+\) - ignoring./) or
      ($ThisLine =~ /process_name_refresh_request\(184\)  Error - should be sent to WINS server$/) or
      ($ThisLine =~ /Record does not exist/) or
      ($ThisLine =~ /response packet id \d+ received with no matching record/) or
      ($ThisLine =~ /Failed to resend packet id \d+ to IP/) or
      ($ThisLine =~ /smbd\/process\.c:process_smb\(\d+\)$/) or
      ($ThisLine =~ /smbmount/) or
      ($ThisLine =~ /start_async_dns/) or
      ($ThisLine =~ /timeout connecting to/) or
      ($ThisLine =~ /version .+ started/) or
      ($ThisLine =~ /lib\/account_pol\.c:account_policy_get\(204\)  account_policy_get: tdb_fetch_uint32 failed for field \d+ \(.*\), returning 0/ ) or
      ($ThisLine =~ /lib\/access\.c:check_access\(\d+\)$/) or
      ($ThisLine =~ /lib\/access\.c:check_access\(\d+\)  Allowed connection from/) or
      ($ThisLine =~ /smbd\/close\.c:close_normal_file\(\d+\)  .+ closed file/) or
      ($ThisLine =~ /smbd\/open\.c:open_file\(\d+\)  .+ opened file/) or
      ($ThisLine =~ /smbd\/process.c:timeout_processing\(\d+\)  Closing idle connection/) or
      ($ThisLine =~ /nmbd\/nmbd_browsesync\.c:sync_with_dmb\(\d+\)  sync_with_dmb:  Initiating sync with domain master browser/) or
      ($ThisLine =~ /param\/loadparm\.c:do_section\(\d+\)  Processing section/) or
      ($ThisLine =~ /lib\/interface\.c:add_interface\(\d+\)  added interface/) or
      ($ThisLine =~ /smbd\/reply\.c:reply_tcon_and_X\(\d+\)  Serving .+ as a Dfs root/) or
      ($ThisLine =~ /smbd\/reply\.c:reply_special\(\d+\)  netbios connect: name1=.+ /) or
      ($ThisLine =~ /nmbd\/nmbd_browsesync\.c:announce_local_master_browser_to_domain_master_browser\(\d+\)  announce_local_master_browser_to_domain_master_browser:  We are both a domain and a local master browser for workgroup .+ /) or
      ($ThisLine =~ /auth\/auth\.c:check_ntlm_password\(\d+\)  check_ntlm_password:  authentication for user \[.+\] -> \[.+\] -> \[.+\] succeeded/) or
      ($ThisLine =~ /rpc_server\/srv_samr_nt\.c:_samr_lookup_domain\(\d+\)  Returning domain sid for domain ([^ ]) -> ([^ ])/) or
		($ThisLine =~ /===============================================================/)
   ) {
      #Don't care about these...
   } elsif ( ($Host, undef, $Service, undef, $User) = ( $ThisLine =~ /([^ ]+ \([^ ]+\)) (signed |)connect to service ([^ ]+) (initially |)as user ([^ ]+)/) ) {
		$CurrentHost=$Host;
		$Connect{$Service}{$User}{$Host}++;
	} elsif ( ($Host,$NoService) = ( $ThisLine =~ /([^ ]+ \([^ ]+\)) couldn't find service (\S+)/ ) ) {
		$NoServ{$Host}{$NoService}++;
	} elsif ($ThisLine =~ s/Denied connection from\s+\((\S+)\)([ *]+|)$/$1/) {
		$Denied{$ThisLine}++;
   } elsif ($ThisLine =~ s/ Connection denied from\s+(\S+)$/$1/) {
      $Denied{$ThisLine}++;
   } elsif ( ($Where,$Ip,$Browser) = ($ThisLine =~ /(.*)  Denied connection from  \(([^ ]+)\)  Doing a node status request to the domain master browser at IP ([^ ]+) failed.  Cannot get workgroup name./ ) ) {
      $Temp = "$Where  ($Ip)";
      $Denied{$Temp}++;
      $CantGetGroup{$Browser}++;
   } elsif (
      ($Where,$Ip,$Name,$Group,$Subnet) = ($ThisLine =~ /(.*)  Denied connection from  \(([^ ]+)\) [ *]+Samba name server ([^ ]+) is now a local master browser for workgroup ([^ ]+) on subnet ([^ ]+)/ ) or
      ($Where,$Ip,$Name,$Group,$Subnet) = ($ThisLine =~ /(.*)  Denied connection from  \(([^ ]+)\) [ *]+Samba name server ([^ ]+) has stopped being a local master browser for workgroup  ([^ ]+) on subnet ([^ ]+)/ )
   ) {
      $Temp = "$Where  ($Ip)";
      $Denied{$Temp}++;
      $BeLocalMaster{$Subnet}{$Group}{$Name}++;
	} elsif (($User) = $ThisLine =~ /rejected invalid user ([^ ]+)/ ) {
		$InvalidUser{$User}++;
   } elsif (($User) = $ThisLine =~ /Authentication for user ([^ ]+) -> ([^ ]+) FAILED with error NT_STATUS_WRONG_PASSWORD/ ) {
      $WrongPassword{$User}++;
	} elsif (($User) = $ThisLine =~ /Couldn't find user '([^ ]+)'/) {
		$NotFoundUser{$User}++;
   } elsif (($User) = $ThisLine =~ /pdb_smbpasswd\.c:build_sam_account\(\d+\)  build_sam_account: smbpasswd database is corrupt!  username ([^ ]+) not in unix passwd database!/ ) {
      $NotFoundUser{$User}++;
      $DbOpenFail++;
      $DbCorrupt++;
	} elsif (($User) = $ThisLine =~ /Rejecting user '([^ ]+)'/) {
		$RejectedUser{$User}++;
	} elsif ( ( $ThisLine =~ /lib\/util_sock.c:read_data\(436\)/ ) ) {
		# This is due to a nasty bug in samba which causes it to drop connections :-(
		$SocketReadError++;
   } elsif (
      ( $ThisLine =~ /lib\/util_sock.c:write_socket\(\d+\)  write_socket: Error writing \d bytes to socket/ ) or
      ( $ThisLine =~ /lib\/util_sock.c:write_socket_data\(\d+\)  write_socket_data: write failure./ ) or
      ( $ThisLine =~ /lib\/util_sock.c:send_smb\(\d+\)  Error writing \d+ bytes to client. / )
   ) {
      # Something more generic should be here
      $SocketWriteError++;
	} elsif (
      ( $ThisLine =~ /unable to open passdb database.$/ ) or
      ( $ThisLine =~ / get_sampwd_entries: Unable to open passdb.$/ )
   ) {
		$DbOpenFail++;
   } elsif ( ($Name,$Group,$Subnet) = ( $ThisLine =~ /pdb_smbpasswd.c:pdb_getsampwnam\(\d+\)  unable to open passdb database\.  [ *]+Samba name server ([^ ]+) is now a local master browser for workgroup ([^ ]+) on subnet ([^ ]+)   / )) {
      $Temp = "$Where  ($Ip)";
      $DbOpenFail++;
      $BeLocalMaster{$Subnet}{$Group}{$Name}++;
	} elsif ( ($Server,$Ip,$Group) = ($ThisLine =~ /Server ([^ ]+) at IP ([^ ]+) is announcing itself as a local master browser for workgroup ([^ ]+) and we think we are master. Forcing election.$/ ) ) {
		$Temp = $Server . "(" . $Ip . ")";
		$ForceElection{$Group}{$Temp}++;
   } elsif ( (undef,$Command,$Server,$Ip,undef) = ($ThisLine =~ /([^ ]+): unicast name ([^ ]+) request received for name ([^ ]+) from IP ([^ ]+) on subnet (.*)\./ ) ) {     $Temp = "$Command on subnet $Subnet : $Server ($Ip)";
      $Temp = "$Command on subnet $Subnet : $Server ($Ip)";
      $UnicastRegister{$Temp}++;
	} elsif ( ($Group,$Subnet) = ($ThisLine =~ /standard_fail_register: Failed to register\/refresh name ([^ ]+) on subnet ([^ ]+)$/ ) ) {
		$FailedRegister{$Subnet}{$Group}++;
	} elsif ( ($Ip,$Group,undef) = ($ThisLine =~ /register_name_response: server at IP ([^ ]+) rejected our name registration of ([^ ]+) with error code ([^ ]+)\.$/ ) ) {
		$RejectRegister{$Group}{$Ip}++;
	} elsif ( ($Ip) = ($ThisLine =~ /get_domain_master_name_node_status_fail:  Doing a node status request to the domain master browser at IP ([^ ]+) failed\.  Cannot get workgroup name\.$/ ) ) {
		$CantGetGroup{$Ip}++;
	} elsif ( ($Signal,undef,$Version) = ($ThisLine =~ /INTERNAL ERROR: Signal ([^ ]+) in pid ([^ ]+) \(([^ ]+)\)  Please read the file BUGS.txt in the distribution$/ ) ) {
		$Temp = "Version $Version with signal $Signal";
		$Crash{$Temp}++;
   } elsif ( ($Error) = ($ThisLine =~ /util.c:smb_panic\(\d+\)  (PANIC: internal error)$/ ) ) {
      $Crash{$Error}++;
	} elsif ( ( $ThisLine =~ /get_domain_master_name_node_status_fail\(([^ ]+)\)/ ) ) {
		$GetDomainMasterStatusFail++;
   } elsif ( ($User) = ($ThisLine =~ /pass_check_smb\(552\)  Account for user '([^ ]+)' was disabled.$/) ) {
      $AccountDisabled{$User}++;
   } elsif ( ($Version) = ($ThisLine =~ /Discarding invalid wins\.dat file \[(.*)\]$/) ) {
      $DiscardWins{$Version}++;
	} elsif ( ($user,$ip,$dir) = ($ThisLine =~ /smbd\/service.c:make_connection\([0-9]+\)  ([a-zA-Z]+) \(([\d.]+)\) Can't change directory to ([a-zA-Z_\/]+) \(Permission denied\)$/)) {
		$PermissionDenied{$user}{$ip}{$dir}++;
	} elsif ( ($user) = ($ThisLine =~ /smbd\/service.c:make_connection\([0-9]+\)  make_connection: ([a-zA-Z_-]+) logged in as admin user \(root privileges\)$/)) {
		$RootLoggedIn{$user}++;
	} elsif ( ($file,$function) = ($ThisLine =~ /([a-zA-Z_\/():\.0-9-]+)  ([a-zA-Z0-9_-]+): Not yet implemented.$/)) {
		$NotImplemented{$file}{$function}++;
   } elsif ( ($User,$Ip,$Directory,$Reason) = ($ThisLine =~ /service.c:make_connection\([0-9]+\)  ([^ ]+) \(([^ ]+)\) Can't change directory to ([^ ]+) \((.*)\)/)) {
      $Temp = "Netbios name $User on $Ip";
      $CantChangeDir{$Directory}{$Reason}{$Temp}++;
   } elsif ( ($Signal) = ($ThisLine =~ /open_sockets\([0-9]+\)  Reloading services after ([^ ]+)/)) {
      $ReloadAfter{$Signal}++;
   } elsif ( ($Signal) = ($ThisLine =~ /open_sockets\([0-9]+\)  Got ([^ ]+)/)) {
      $ReloadAfter{$Signal}++;
   } elsif ( ($Share,$Reason) = ($ThisLine =~ /cups_printername_ok\([0-9]+\)  (Unable to get printer status for [^ ]+) - ([^ ]+)/)) {
      $PrinterStatus{$Share}{$Reason}++;
   } elsif ( ($Share,$Reason) = ($ThisLine =~ /cups_queue_get\([0-9]+\)  (Unable to get jobs for [^ ]+) - ([^ ]+)/)) {
      $PrinterStatus{$Share}{$Reason}++;
   } elsif ( $ThisLine =~ m/main\([0-9]+\)  ERROR: Failed when creating subnet lists. Exiting./) {
      $SubnetFail{"Failed when creating subnet lists"}++;
   } elsif ( $ThisLine =~ m/create_subnets\([0-9]+\)  create_subnets: No local interfaces !/) {
      $SubnetFail{"No local interfaces"}++;
   } elsif ( $ThisLine =~ m/reload_interfaces: No subnets to listen to. Shutting down.../) {
      $SubnetFail{"No subnets to listen to. Shutting down."}++;
   } elsif ( $ThisLine =~ s/process_get_backup_list_request\([0-9]+\)  process_get_backup_list_request: (.*)/$1/) {
      $GetBackupList{$ThisLine}++;
   } elsif ( ($Error) = ($ThisLine =~ /brl_init\([0-9]+\)  (Failed to open byte range locking database)$/)) {
      $LockDbError{$Error}++;
   } elsif ( ($Error) = ($ThisLine =~ /locking_init\([0-9]+\)  ERROR: (Failed to initialise locking database)$/)) {
      $LockDbError{$Error}++;
   } elsif ( ($SID,$dsid) = ($ThisLine =~ /User administrator has Primary Group SID ([^ ]+),   which conflicts with the domain sid ([^ ]+).  Failing operation.$/)) {
      $SIDnotvalid{"$SID,$dsid"}++;
   } elsif ( ($Addr) = ($ThisLine =~ /libsmb\/cliconnect.c:cli_connect\([0-9]+\)  Error connecting to ([0-9.]*) \(Connection refused\)/)) {
      $RefConnect{$Addr}++;
   } elsif ( ($Name) = ($ThisLine =~ /passdb\/pdb_smbpasswd.c:startsmbfilepwent\([0-9]+\)  startsmbfilepwent_internal: file ([^ ]*) did not exist. File successfully created./)) {
      $CrFile{$Name}++;
   } elsif ( ($user,$file,$read,$write) = ($ThisLine =~ /(\S+) opened file (\S+) read=(\w+) write=(\w+)/)) {
      $OpenFile{$CurrentHost}{$user}{$file}{($read=~/Y/?"R":"").($write=~/Y/?"W":"")}++;
   } elsif ( ($Location,$Reason) = ($ThisLine =~ /tdb_log\([0-9]+\)  tdb\(([^ ]+)\): tdb_reopen: (open failed \([^ ]+\))/)) {
      $LockDbError{"$Location - $Reason"}++;
	} else {
		# Report any unmatched entries...
		$OtherList{$ThisLine}++;

      #TODO:
      #smbd/oplock.c:process_local_message(418)  process_local_message: unknown UDP message command code (424d) - ignoring.
      #smbd/process.c:switch_message(662)  Non-SMB packet of length 156. Terminating server
      #smbd/process.c:switch_message(662)  Non-SMB packet of length 133. Terminating server
      #libsmb/nmblib.c:send_udp(756)  Packet send failed to 153.19.207.127(138) ERRNO=Invalid argument
      #lib/util_sock.c:read_data(436)  read_data: read failure for 4. Error = Brak drogi do systemu
      #lib/util_sock.c:get_peer_addr(1229)  getpeername failed. Error was Drugi koniec nie jest po³±czony
      #lib/util_sock.c:open_socket_out(911)  error connecting to 192.168.0.101:445 (Po³±czenie odrzucone)
      #lib/util_sock.c:read_data(534)  read_data: read failure for 4 bytes to client 192.168.0.51. Error = Przekroczony czas oczekiwania na po³±czenie
      #lib/util_sock.c:write_data(562)  write_data: write failure in writing to client 0.0.0.0. Error Po³±czenie zerwane przez drug± stronê
      #libsmb/cliconnect.c:cli_start_connection(1445)  session request to P1 failed (Called name not present)
      #printing/printing.c:start_background_queue(1419)
      #printing/printing.c:start_background_queue(1419)  Reloading services after SIGHUP
      #rpc_server/srv_spoolss_nt.c:spoolss_connect_to_client(2551)  spoolss_connect_to_client: connection to [P1] failed!
      #smbd/sesssetup.c:setup_new_vc_session(799)  setup_new_vc_session: New VC == 0, if NT4.x compatible we would close all old resources
      #smbd/utmp.c:sys_utmp_update(419)  utmp_update: uname:/var/run/utmp wname:/var/log/wtmp
	}
}

#########################################
#

if (keys %Crash) {
	print "\nWARNING!!!!!!\n";
	print "Server crashed:\n";
	foreach my $Dead (sort {$a cmp $b} keys %Crash) {
		print "   $Dead : $Crash{$Dead} Time(s)\n";
	}
}

if (keys %SubnetFail) {
   print "\nWARNING!!!!!!\n";
   print "Errors when creating subnets:\n";
   foreach my $Error (sort {$a cmp $b} keys %SubnetFail) {
      print "   $Error : $SubnetFail{$Error} Time(s)\n";
   }
}

if (keys %ReloadAfter) {
   print "\nReloaded services after signal:\n";
   foreach $Signal (sort {$a cmp $b} keys %ReloadAfter) {
      print "   $Signal : $ReloadAfter{$Signal} Time(s)\n";
   }
}

if (keys %DiscardWins) {
   print "\nDiscarded invalid wins.dat file with version:\n";
   foreach my $Version (sort {$a cmp $b} keys %DiscardWins) {
      print "   $Version : $DiscardWins{$Version} Time(s)\n";
   }
}

if (($Detail >= 5) and (keys %Connect)) {
   print "\nOpened Sessions:\n";
   foreach my $Serv (sort {$a cmp $b} keys %Connect) {
      print "   Service $Serv as user:\n";
      foreach my $Us (sort {$a cmp $b} keys %{$Connect{$Serv}}) {
         print "      $Us " . (" " x (10 - length ($Us))) . "from host";
         my $size = keys %{$Connect{$Serv}{$Us}};
         if ($size >= 2) {
            print ":\n";
            foreach my $Ho (sort {$a cmp $b} keys %{$Connect{$Serv}{$Us}}) {
               print "         $Ho : $Connect{$Serv}{$Us}{$Ho} Time(s)\n";
            }
         } else {
            foreach my $Ho (keys %{$Connect{$Serv}{$Us}}) {
               print " $Ho " . (" " x (25 - length($Ho))) . ":
               $Connect{$Serv}{$Us}{$Ho} Time(s)\n";
            }
         }
      }
   }
}

if (($Detail >= 5) and (keys %OpenFile)) {
   print "\nOpened Files:\n";
   foreach my $Host (sort {$a cmp $b} keys %OpenFile) {
      print "   Host $Host:\n";
      foreach my $User (sort {$a cmp $b} keys %{$OpenFile{$Host}}) {
         foreach my $File (sort {$a cmp $b} keys %{$OpenFile{$Host}{$User}}) {
            print "     File \"$File\"";
            foreach my $Mode (sort {$a cmp $b} keys %{$OpenFile{$Host}{$User}{$File}}) {
               print " $Mode: $OpenFile{$Host}{$User}{$File}{$Mode} Time(s)";
            }
            print "\n";
         }
      }
   }
}

if (keys %Denied) {
   print "\nConnections Denied:\n";
   foreach my $Line (sort {$a cmp $b} keys %Denied) {
      print "   $Line : $Denied{$Line} Time(s)\n";
   }
}

if (keys %RefConnect) {
   print "\nConnections Refused\n";
   foreach my $Line (keys %RefConnect) {
      print "   Connection refused by $Line : $RefConnect{$Line} Time(s)\n";
   }
}

if (keys %CrFile) {
  print "\nCreated files\n";
  foreach my $Line (keys %CrFile) {
     print "   file $Line did not exist. File successfully created: $CrFile{$Line} Time(s)\n";
  }
}

if (($Detail >= 5) and (keys %PermissionDenied)) {
   print "\nPermission denied:\n";
   foreach my $user (sort {$a cmp $b} keys %PermissionDenied) {
      foreach my $ip (sort {$a cmp $b} keys %{$PermissionDenied{$user}}) {
         foreach my $dir (sort {$a cmp $b} keys %{$PermissionDenied{$user}{$ip}}) {
	    print "   Permission denied (user $user from $ip) directory $dir: $PermissionDenied{$user}{$ip}{$dir} Time(s)\n";
         }
      }
   }
}

if (keys %PrinterStatus) {
   print "\nPrinter Errors:\n";
   foreach my $Share (sort {$a cmp $b} keys %PrinterStatus) {
      print "   $Share:\n";
      foreach my $Reason (sort {$a cmp $b} keys %{$PrinterStatus{$Share}}) {
         print "      $Reason : $PrinterStatus{$Share}{$Reason} Time(s)\n";
      }
   }
}

if (($Detail >= 5) and (keys %RootLoggedIn)) {
   print "\nAdmin logins (root privileges):\n";
   foreach my $user (sort {$a cmp $b} keys %RootLoggedIn) {
      print "   User $user: $RootLoggedIn{$user} Time(s)\n";
   }
}

if (($Detail >= 9) and (keys %NotImplemented)) {
   print "\nNot implemented functions:\n";
   foreach my $file (sort {$a cmp $b} keys %NotImplemented) {
      foreach my $func (sort {$a cmp $b} keys %{$NotImplemented{$file}}) {
          print "   Function $func in $file: $NotImplemented{$file}{$func} Time(s)\n";
      }
   }
}


if (keys %ForceElection) {
	print "\nForced Election:\n";
	foreach my $Group (sort {$a cmp $b} keys %ForceElection) {
		print "   In workgroup $Group when announced server was:\n";
		foreach my $Host (sort {$a cmp $b} keys %{$ForceElection{$Group}}) {
			print "      $Host : $ForceElection{$Group}{$Host} Time(s)\n";
		}
	}
}

if (keys %BeLocalMaster) {
	print "\nChanged Local Master Browser:\n";
	foreach my $Subnet (sort {$a cmp $b} keys %BeLocalMaster) {
		print "   On subnet $Subnet:\n";
		foreach my $Group (sort {$a cmp $b} keys %{$BeLocalMaster{$Subnet}}) {
			print "      For workgroup $Group:\n";
			foreach my $Name (sort {$a cmp $b} keys %{$BeLocalMaster{$Subnet}{$Group}}) {
				print "         $Name : $BeLocalMaster{$Subnet}{$Group}{$Name} Time(s)\n";
			}
		}
	}
}

if (keys %CantGetGroup) {
	print "\nCannot get workgroup name from domain name browser:\n";
	foreach my $Ip (sort {$a cmp $b} keys %CantGetGroup) {
		print "   $Ip : $CantGetGroup{$Ip} Time(s)\n";
	}
}

if ($GetDomainMasterStatusFail > 0) {
	print "\nFailed to get Domain Master node name: $GetDomainMasterStatusFail Time(s)\n";
}

if (keys %GetBackupList) {
   print "\nBackup list requests:\n";
   foreach my $Request (sort {$a cmp $b} keys %GetBackupList) {
      print "   $Request : $GetBackupList{$Request} Time(s)\n";
   }
}

if (($Detail >= 5) and (keys %NoServ)) {
   print "\nCouldn't find services:\n";
   foreach my $Host (sort {$a cmp $b} keys %NoServ) {
      print "   Host: $Host\n";
      foreach my $ThisOne (sort {$a cmp $b} keys %{$NoServ{$Host}}) {
         print "      $ThisOne : $NoServ{$Host}{$ThisOne} Time(s)\n";
      }
   }
}

if (($Detail >= 5) and (keys %UnicastRegister)) {
	print "\nUnicast name requests:\n";
	foreach my $ThisOne (sort {$a cmp $b} keys %UnicastRegister) {
		print "   $ThisOne : $UnicastRegister{$ThisOne} Time(s)\n";
	}
}

if (keys %FailedRegister) {
	print "\nFailed to register/refresh:\n";
	foreach my $Subnet (sort {$a cmp $b} keys %FailedRegister) {
		print "   On subnet $Subnet:\n";
		foreach my $Group (sort {$a cmp $b} keys %{$FailedRegister{$Subnet}}) {
			print "      $Group : $FailedRegister{$Subnet}{$Group} Time(s)\n";
		}
	}
}

if (keys %RejectRegister) {
	print "\nRejected our name registration:\n";
	foreach my $Group (sort {$a cmp $b} keys %RejectRegister) {
		print "   Name $Group at IP:\n";
		foreach my $Ip (sort {$a cmp $b} keys %{$RejectRegister{$Group}}) {
			print "      $Ip : $RejectRegister{$Group}{$Ip} Time(s)\n";
		}
	}
}

if ($DbOpenFail > 0) {
	print "\nFailed to open passwd database: $DbOpenFail Time(s)\n";
}

if ($DbCorrupt > 0) {
	print "smbpasswd database corrupt: $DbOpenFail Time(s)\n";
}

if (keys %InvalidUser) {
   print "\nInvalid Users:\n";
   foreach my $Line (sort {$a cmp $b} keys %InvalidUser) {
      print "   $Line : $InvalidUser{$Line} Time(s)\n";
   }
}

if (keys %WrongPassword) {
   print "\nWrong Passwords:\n";
   foreach my $Line (sort {$a cmp $b} keys %WrongPassword) {
      print "   $Line : $WrongPassword{$Line} Time(s)\n";
   }
}


if (keys %NotFoundUser) {
   print "\nUsers not found in UNIX Database:\n";
   foreach my $Line (sort {$a cmp $b} keys %NotFoundUser) {
      print "   $Line : $NotFoundUser{$Line} Time(s)\n";
   }
}

if (keys %RejectedUser) {
   print "\nRejected Users:\n";
   foreach my $Line (sort {$a cmp $b} keys %RejectedUser) {
      print "   $Line : $RejectedUser{$Line} Time(s)\n";
   }
}

if (keys %AccountDisabled) {
    print "\nAccounts disabled:\n";
    foreach my $User (sort {$a cmp $b} keys %AccountDisabled) {
        print "   $User : $AccountDisabled{$User} Time(s)\n";
    }
}

if (keys %CantChangeDir) {
   print "\nCan't change directory while browsing:\n";
   foreach my $Directory (sort {$a cmp $b} keys %CantChangeDir) {
      print "   $Directory:\n";
      foreach my $Reason (sort {$a cmp $b} keys %{$CantChangeDir{$Directory}}) {
         print "      $Reason:\n";
         foreach my $Entry (sort {$a cmp $b} keys %{$CantChangeDir{$Directory}{$Reason}}) {
            print "         $Entry : $CantChangeDir{$Directory}{$Reason}{$Entry} Time(s)\n";
         }
      }
   }
}

if ($SocketReadError > 0) {
	print "\nSocket Read Error (Samba bug): $SocketReadError Time(s)\n";
}

if (keys %LockDbError) {
   print "\nLocking Database error:\n";
   foreach my $Error (sort {$a cmp $b} keys %LockDbError) {
      print "   $Error : $LockDbError{$Error} Time(s)\n";
   }
}

if (keys %SIDnotvalid) {
  print ("\nSID is not valid for the domain\n");
  foreach my $SIDLog (keys %SIDnotvalid) {
    my ($SID,$dsid) = split(",",$SIDLog);
    print "   User administrator Primary Group SID ($SID) conflicts with the domain sid ($dsid): $SIDnotvalid{$SIDLog} Time(s) \n";
  }
}


if (($Detail >= 10) and keys %OtherList) {
	print "\n**Unmatched Entries**\n";
	foreach my $Line (sort {$a cmp $b} keys %OtherList) {
		print "$Line : $OtherList{$Line} Time(s)\n";
	}
}

exit(0);

# vi: shiftwidth=3 tabstop=3 syntax=perl et
# Local Variables:
# mode: perl
# perl-indent-level: 3
# indent-tabs-mode: nil
# End: