s3:utils/smbget fix recursive download with empty source directories
[garming/samba-autobuild/.git] / source3 / utils / status.c
1 /* 
2    Unix SMB/CIFS implementation.
3    status reporting
4    Copyright (C) Andrew Tridgell 1994-1998
5
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 3 of the License, or
9    (at your option) any later version.
10
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
19    Revision History:
20
21    12 aug 96: Erik.Devriendt@te6.siemens.be
22    added support for shared memory implementation of share mode locking
23
24    21-Jul-1998: rsharpe@ns.aus.com (Richard Sharpe)
25    Added -L (locks only) -S (shares only) flags and code
26
27 */
28
29 /*
30  * This program reports current SMB connections
31  */
32
33 #include "includes.h"
34 #include "lib/util/server_id.h"
35 #include "smbd/globals.h"
36 #include "system/filesys.h"
37 #include "popt_common.h"
38 #include "dbwrap/dbwrap.h"
39 #include "dbwrap/dbwrap_open.h"
40 #include "../libcli/security/security.h"
41 #include "session.h"
42 #include "locking/proto.h"
43 #include "messages.h"
44 #include "librpc/gen_ndr/open_files.h"
45 #include "smbd/smbd.h"
46 #include "librpc/gen_ndr/notify.h"
47 #include "lib/conn_tdb.h"
48 #include "serverid.h"
49 #include "status_profile.h"
50 #include "smbd/notifyd/notifyd.h"
51 #include "cmdline_contexts.h"
52
53 #define SMB_MAXPIDS             2048
54 static uid_t            Ucrit_uid = 0;               /* added by OH */
55 static struct server_id Ucrit_pid[SMB_MAXPIDS];  /* Ugly !!! */   /* added by OH */
56 static int              Ucrit_MaxPid=0;                    /* added by OH */
57 static unsigned int     Ucrit_IsActive = 0;                /* added by OH */
58
59 static bool verbose, brief;
60 static bool shares_only;            /* Added by RJS */
61 static bool locks_only;            /* Added by RJS */
62 static bool processes_only;
63 static bool show_brl;
64 static bool numeric_only;
65 static bool do_checks = true;
66
67 const char *username = NULL;
68
69 /* added by OH */
70 static void Ucrit_addUid(uid_t uid)
71 {
72         Ucrit_uid = uid;
73         Ucrit_IsActive = 1;
74 }
75
76 static unsigned int Ucrit_checkUid(uid_t uid)
77 {
78         if ( !Ucrit_IsActive ) 
79                 return 1;
80
81         if ( uid == Ucrit_uid ) 
82                 return 1;
83
84         return 0;
85 }
86
87 static unsigned int Ucrit_checkPid(struct server_id pid)
88 {
89         int i;
90
91         if ( !Ucrit_IsActive ) 
92                 return 1;
93
94         for (i=0;i<Ucrit_MaxPid;i++) {
95                 if (serverid_equal(&pid, &Ucrit_pid[i])) {
96                         return 1;
97                 }
98         }
99
100         return 0;
101 }
102
103 static bool Ucrit_addPid( struct server_id pid )
104 {
105         if ( !Ucrit_IsActive )
106                 return True;
107
108         if ( Ucrit_MaxPid >= SMB_MAXPIDS ) {
109                 d_printf("ERROR: More than %d pids for user %s!\n",
110                          SMB_MAXPIDS, uidtoname(Ucrit_uid));
111
112                 return False;
113         }
114
115         Ucrit_pid[Ucrit_MaxPid++] = pid;
116
117         return True;
118 }
119
120 static int print_share_mode(struct file_id fid,
121                             const struct share_mode_data *d,
122                             const struct share_mode_entry *e,
123                             void *private_data)
124 {
125         static int count;
126
127         if (do_checks && !is_valid_share_mode_entry(e)) {
128                 return 0;
129         }
130
131         if (count==0) {
132                 d_printf("Locked files:\n");
133                 d_printf("Pid          Uid        DenyMode   Access      R/W        Oplock           SharePath   Name   Time\n");
134                 d_printf("--------------------------------------------------------------------------------------------------\n");
135         }
136         count++;
137
138         if (do_checks && !serverid_exists(&e->pid)) {
139                 /* the process for this entry does not exist any more */
140                 return 0;
141         }
142
143         if (Ucrit_checkPid(e->pid)) {
144                 struct server_id_buf tmp;
145                 d_printf("%-11s  ", server_id_str_buf(e->pid, &tmp));
146                 d_printf("%-9u  ", (unsigned int)e->uid);
147                 switch (map_share_mode_to_deny_mode(e->share_access,
148                                                     e->private_options)) {
149                         case DENY_NONE: d_printf("DENY_NONE  "); break;
150                         case DENY_ALL:  d_printf("DENY_ALL   "); break;
151                         case DENY_DOS:  d_printf("DENY_DOS   "); break;
152                         case DENY_READ: d_printf("DENY_READ  "); break;
153                         case DENY_WRITE:printf("DENY_WRITE "); break;
154                         case DENY_FCB:  d_printf("DENY_FCB "); break;
155                         default: {
156                                 d_printf("unknown-please report ! "
157                                          "e->share_access = 0x%x, "
158                                          "e->private_options = 0x%x\n",
159                                          (unsigned int)e->share_access,
160                                          (unsigned int)e->private_options );
161                                 break;
162                         }
163                 }
164                 d_printf("0x%-8x  ",(unsigned int)e->access_mask);
165                 if ((e->access_mask & (FILE_READ_DATA|FILE_WRITE_DATA))==
166                                 (FILE_READ_DATA|FILE_WRITE_DATA)) {
167                         d_printf("RDWR       ");
168                 } else if (e->access_mask & FILE_WRITE_DATA) {
169                         d_printf("WRONLY     ");
170                 } else {
171                         d_printf("RDONLY     ");
172                 }
173
174                 if((e->op_type & (EXCLUSIVE_OPLOCK|BATCH_OPLOCK)) == 
175                                         (EXCLUSIVE_OPLOCK|BATCH_OPLOCK)) {
176                         d_printf("EXCLUSIVE+BATCH ");
177                 } else if (e->op_type & EXCLUSIVE_OPLOCK) {
178                         d_printf("EXCLUSIVE       ");
179                 } else if (e->op_type & BATCH_OPLOCK) {
180                         d_printf("BATCH           ");
181                 } else if (e->op_type & LEVEL_II_OPLOCK) {
182                         d_printf("LEVEL_II        ");
183                 } else if (e->op_type == LEASE_OPLOCK) {
184                         struct share_mode_lease *l = &d->leases[e->lease_idx];
185                         uint32_t lstate = l->current_state;
186                         d_printf("LEASE(%s%s%s)%s%s%s      ",
187                                  (lstate & SMB2_LEASE_READ)?"R":"",
188                                  (lstate & SMB2_LEASE_WRITE)?"W":"",
189                                  (lstate & SMB2_LEASE_HANDLE)?"H":"",
190                                  (lstate & SMB2_LEASE_READ)?"":" ",
191                                  (lstate & SMB2_LEASE_WRITE)?"":" ",
192                                  (lstate & SMB2_LEASE_HANDLE)?"":" ");
193                 } else {
194                         d_printf("NONE            ");
195                 }
196
197                 d_printf(" %s   %s%s   %s",
198                          d->servicepath, d->base_name,
199                          (d->stream_name != NULL) ? d->stream_name : "",
200                          time_to_asc((time_t)e->time.tv_sec));
201         }
202
203         return 0;
204 }
205
206 static void print_brl(struct file_id id,
207                         struct server_id pid, 
208                         enum brl_type lock_type,
209                         enum brl_flavour lock_flav,
210                         br_off start,
211                         br_off size,
212                         void *private_data)
213 {
214         static int count;
215         unsigned int i;
216         static const struct {
217                 enum brl_type lock_type;
218                 const char *desc;
219         } lock_types[] = {
220                 { READ_LOCK, "R" },
221                 { WRITE_LOCK, "W" },
222                 { PENDING_READ_LOCK, "PR" },
223                 { PENDING_WRITE_LOCK, "PW" },
224                 { UNLOCK_LOCK, "U" }
225         };
226         const char *desc="X";
227         const char *sharepath = "";
228         char *fname = NULL;
229         struct share_mode_lock *share_mode;
230         struct server_id_buf tmp;
231
232         if (count==0) {
233                 d_printf("Byte range locks:\n");
234                 d_printf("Pid        dev:inode       R/W  start     size      SharePath               Name\n");
235                 d_printf("--------------------------------------------------------------------------------\n");
236         }
237         count++;
238
239         share_mode = fetch_share_mode_unlocked(NULL, id);
240         if (share_mode) {
241                 bool has_stream = share_mode->data->stream_name != NULL;
242
243                 fname = talloc_asprintf(NULL, "%s%s%s",
244                                         share_mode->data->base_name,
245                                         has_stream ? ":" : "",
246                                         has_stream ?
247                                         share_mode->data->stream_name :
248                                         "");
249         } else {
250                 fname = talloc_strdup(NULL, "");
251                 if (fname == NULL) {
252                         return;
253                 }
254         }
255
256         for (i=0;i<ARRAY_SIZE(lock_types);i++) {
257                 if (lock_type == lock_types[i].lock_type) {
258                         desc = lock_types[i].desc;
259                 }
260         }
261
262         d_printf("%-10s %-15s %-4s %-9jd %-9jd %-24s %-24s\n",
263                  server_id_str_buf(pid, &tmp), file_id_string_tos(&id),
264                  desc,
265                  (intmax_t)start, (intmax_t)size,
266                  sharepath, fname);
267
268         TALLOC_FREE(fname);
269         TALLOC_FREE(share_mode);
270 }
271
272 static const char *session_dialect_str(uint16_t dialect)
273 {
274         static fstring unkown_dialect;
275
276         switch(dialect){
277         case SMB2_DIALECT_REVISION_000:
278                 return "NT1";
279         case SMB2_DIALECT_REVISION_202:
280                 return "SMB2_02";
281         case SMB2_DIALECT_REVISION_210:
282                 return "SMB2_10";
283         case SMB2_DIALECT_REVISION_222:
284                 return "SMB2_22";
285         case SMB2_DIALECT_REVISION_224:
286                 return "SMB2_24";
287         case SMB3_DIALECT_REVISION_300:
288                 return "SMB3_00";
289         case SMB3_DIALECT_REVISION_302:
290                 return "SMB3_02";
291         case SMB3_DIALECT_REVISION_310:
292                 return "SMB3_10";
293         case SMB3_DIALECT_REVISION_311:
294                 return "SMB3_11";
295         }
296
297         fstr_sprintf(unkown_dialect, "Unknown (0x%04x)", dialect);
298         return unkown_dialect;
299 }
300
301 static int traverse_connections(const struct connections_key *key,
302                                 const struct connections_data *crec,
303                                 void *private_data)
304 {
305         TALLOC_CTX *mem_ctx = (TALLOC_CTX *)private_data;
306         struct server_id_buf tmp;
307         char *timestr = NULL;
308         int result = 0;
309         const char *encryption = "-";
310         const char *signing = "-";
311
312         if (crec->cnum == TID_FIELD_INVALID)
313                 return 0;
314
315         if (do_checks &&
316             (!process_exists(crec->pid) || !Ucrit_checkUid(crec->uid))) {
317                 return 0;
318         }
319
320         timestr = timestring(mem_ctx, crec->start);
321         if (timestr == NULL) {
322                 return -1;
323         }
324
325         if (smbXsrv_is_encrypted(crec->encryption_flags)) {
326                 switch (crec->cipher) {
327                 case SMB_ENCRYPTION_GSSAPI:
328                         encryption = "GSSAPI";
329                         break;
330                 case SMB2_ENCRYPTION_AES128_CCM:
331                         encryption = "AES-128-CCM";
332                         break;
333                 case SMB2_ENCRYPTION_AES128_GCM:
334                         encryption = "AES-128-GCM";
335                         break;
336                 default:
337                         encryption = "???";
338                         result = -1;
339                         break;
340                 }
341         }
342
343         if (smbXsrv_is_signed(crec->signing_flags)) {
344                 if (crec->dialect >= SMB3_DIALECT_REVISION_302) {
345                         signing = "AES-128-CMAC";
346                 } else if (crec->dialect >= SMB2_DIALECT_REVISION_202) {
347                         signing = "HMAC-SHA256";
348                 } else {
349                         signing = "HMAC-MD5";
350                 }
351         }
352
353         d_printf("%-12s %-7s %-13s %-32s %-12s %-12s\n",
354                  crec->servicename, server_id_str_buf(crec->pid, &tmp),
355                  crec->machine,
356                  timestr,
357                  encryption,
358                  signing);
359
360         TALLOC_FREE(timestr);
361
362         return result;
363 }
364
365 static int traverse_sessionid(const char *key, struct sessionid *session,
366                               void *private_data)
367 {
368         TALLOC_CTX *mem_ctx = (TALLOC_CTX *)private_data;
369         fstring uid_gid_str;
370         struct server_id_buf tmp;
371         char *machine_hostname = NULL;
372         int result = 0;
373         const char *encryption = "-";
374         const char *signing = "-";
375
376         if (do_checks &&
377             (!process_exists(session->pid) ||
378              !Ucrit_checkUid(session->uid))) {
379                 return 0;
380         }
381
382         Ucrit_addPid(session->pid);
383
384         if (numeric_only) {
385                 fstr_sprintf(uid_gid_str, "%-12u %-12u",
386                              (unsigned int)session->uid,
387                              (unsigned int)session->gid);
388         } else {
389                 if (session->uid == -1 && session->gid == -1) {
390                         /*
391                          * The session is not fully authenticated yet.
392                          */
393                         fstrcpy(uid_gid_str, "(auth in progress)");
394                 } else {
395                         /*
396                          * In theory it should not happen that one of
397                          * session->uid and session->gid is valid (ie != -1)
398                          * while the other is not (ie = -1), so we a check for
399                          * that case that bails out would be reasonable.
400                          */
401                         const char *uid_name = "-1";
402                         const char *gid_name = "-1";
403
404                         if (session->uid != -1) {
405                                 uid_name = uidtoname(session->uid);
406                                 if (uid_name == NULL) {
407                                         return -1;
408                                 }
409                         }
410                         if (session->gid != -1) {
411                                 gid_name = gidtoname(session->gid);
412                                 if (gid_name == NULL) {
413                                         return -1;
414                                 }
415                         }
416                         fstr_sprintf(uid_gid_str, "%-12s %-12s",
417                                      uid_name, gid_name);
418                 }
419         }
420
421         machine_hostname = talloc_asprintf(mem_ctx, "%s (%s)",
422                                            session->remote_machine,
423                                            session->hostname);
424         if (machine_hostname == NULL) {
425                 return -1;
426         }
427
428         if (smbXsrv_is_encrypted(session->encryption_flags)) {
429                 switch (session->cipher) {
430                 case SMB2_ENCRYPTION_AES128_CCM:
431                         encryption = "AES-128-CCM";
432                         break;
433                 case SMB2_ENCRYPTION_AES128_GCM:
434                         encryption = "AES-128-GCM";
435                         break;
436                 default:
437                         encryption = "???";
438                         result = -1;
439                         break;
440                 }
441         } else if (smbXsrv_is_partially_encrypted(session->encryption_flags)) {
442                 switch (session->cipher) {
443                 case SMB_ENCRYPTION_GSSAPI:
444                         encryption = "partial(GSSAPI)";
445                         break;
446                 case SMB2_ENCRYPTION_AES128_CCM:
447                         encryption = "partial(AES-128-CCM)";
448                         break;
449                 case SMB2_ENCRYPTION_AES128_GCM:
450                         encryption = "partial(AES-128-GCM)";
451                         break;
452                 default:
453                         encryption = "???";
454                         result = -1;
455                         break;
456                 }
457         }
458
459         if (smbXsrv_is_signed(session->signing_flags)) {
460                 if (session->connection_dialect >= SMB3_DIALECT_REVISION_302) {
461                         signing = "AES-128-CMAC";
462                 } else if (session->connection_dialect >= SMB2_DIALECT_REVISION_202) {
463                         signing = "HMAC-SHA256";
464                 } else {
465                         signing = "HMAC-MD5";
466                 }
467         } else if (smbXsrv_is_partially_signed(session->signing_flags)) {
468                 if (session->connection_dialect >= SMB3_DIALECT_REVISION_302) {
469                         signing = "partial(AES-128-CMAC)";
470                 } else if (session->connection_dialect >= SMB2_DIALECT_REVISION_202) {
471                         signing = "partial(HMAC-SHA256)";
472                 } else {
473                         signing = "partial(HMAC-MD5)";
474                 }
475         }
476
477
478         d_printf("%-7s %-25s %-41s %-17s %-20s %-21s\n",
479                  server_id_str_buf(session->pid, &tmp),
480                  uid_gid_str,
481                  machine_hostname,
482                  session_dialect_str(session->connection_dialect),
483                  encryption,
484                  signing);
485
486         TALLOC_FREE(machine_hostname);
487
488         return result;
489 }
490
491
492 static bool print_notify_rec(const char *path, struct server_id server,
493                              const struct notify_instance *instance,
494                              void *private_data)
495 {
496         struct server_id_buf idbuf;
497
498         d_printf("%s\\%s\\%x\\%x\n", path, server_id_str_buf(server, &idbuf),
499                  (unsigned)instance->filter,
500                  (unsigned)instance->subdir_filter);
501
502         return true;
503 }
504
505 int main(int argc, const char *argv[])
506 {
507         int c;
508         int profile_only = 0;
509         bool show_processes, show_locks, show_shares;
510         bool show_notify = false;
511         poptContext pc;
512         struct poptOption long_options[] = {
513                 POPT_AUTOHELP
514                 {"processes",   'p', POPT_ARG_NONE,     NULL, 'p', "Show processes only" },
515                 {"verbose",     'v', POPT_ARG_NONE,     NULL, 'v', "Be verbose" },
516                 {"locks",       'L', POPT_ARG_NONE,     NULL, 'L', "Show locks only" },
517                 {"shares",      'S', POPT_ARG_NONE,     NULL, 'S', "Show shares only" },
518                 {"notify",      'N', POPT_ARG_NONE,     NULL, 'N', "Show notifies" },
519                 {"user",        'u', POPT_ARG_STRING,   &username, 'u', "Switch to user" },
520                 {"brief",       'b', POPT_ARG_NONE,     NULL, 'b', "Be brief" },
521                 {"profile",     'P', POPT_ARG_NONE, NULL, 'P', "Do profiling" },
522                 {"profile-rates", 'R', POPT_ARG_NONE, NULL, 'R', "Show call rates" },
523                 {"byterange",   'B', POPT_ARG_NONE,     NULL, 'B', "Include byte range locks"},
524                 {"numeric",     'n', POPT_ARG_NONE,     NULL, 'n', "Numeric uid/gid"},
525                 {"fast",        'f', POPT_ARG_NONE,     NULL, 'f', "Skip checks if processes still exist"},
526                 POPT_COMMON_SAMBA
527                 POPT_TABLEEND
528         };
529         TALLOC_CTX *frame = talloc_stackframe();
530         int ret = 0;
531         struct messaging_context *msg_ctx = NULL;
532         char *db_path;
533         bool ok;
534
535         sec_init();
536         smb_init_locale();
537
538         setup_logging(argv[0], DEBUG_STDERR);
539         lp_set_cmdline("log level", "0");
540
541         if (getuid() != geteuid()) {
542                 d_printf("smbstatus should not be run setuid\n");
543                 ret = 1;
544                 goto done;
545         }
546
547         if (getuid() != 0) {
548                 d_printf("smbstatus only works as root!\n");
549                 ret = 1;
550                 goto done;
551         }
552
553
554         pc = poptGetContext(NULL, argc, argv, long_options,
555                             POPT_CONTEXT_KEEP_FIRST);
556
557         while ((c = poptGetNextOpt(pc)) != -1) {
558                 switch (c) {
559                 case 'p':
560                         processes_only = true;
561                         break;
562                 case 'v':
563                         verbose = true;
564                         break;
565                 case 'L':
566                         locks_only = true;
567                         break;
568                 case 'S':
569                         shares_only = true;
570                         break;
571                 case 'N':
572                         show_notify = true;
573                         break;
574                 case 'b':
575                         brief = true;
576                         break;
577                 case 'u':
578                         Ucrit_addUid(nametouid(poptGetOptArg(pc)));
579                         break;
580                 case 'P':
581                 case 'R':
582                         profile_only = c;
583                         break;
584                 case 'B':
585                         show_brl = true;
586                         break;
587                 case 'n':
588                         numeric_only = true;
589                         break;
590                 case 'f':
591                         do_checks = false;
592                         break;
593                 }
594         }
595
596         /* setup the flags based on the possible combincations */
597
598         show_processes = !(shares_only || locks_only || profile_only) || processes_only;
599         show_locks     = !(shares_only || processes_only || profile_only) || locks_only;
600         show_shares    = !(processes_only || locks_only || profile_only) || shares_only;
601
602         if ( username )
603                 Ucrit_addUid( nametouid(username) );
604
605         if (verbose) {
606                 d_printf("using configfile = %s\n", get_dyn_CONFIGFILE());
607         }
608
609         msg_ctx = cmdline_messaging_context(get_dyn_CONFIGFILE());
610         if (msg_ctx == NULL) {
611                 fprintf(stderr, "Could not initialize messaging, not root?\n");
612                 ret = -1;
613                 goto done;
614         }
615
616         if (!lp_load_global(get_dyn_CONFIGFILE())) {
617                 fprintf(stderr, "Can't load %s - run testparm to debug it\n",
618                         get_dyn_CONFIGFILE());
619                 ret = -1;
620                 goto done;
621         }
622
623         switch (profile_only) {
624                 case 'P':
625                         /* Dump profile data */
626                         ok = status_profile_dump(verbose);
627                         return ok ? 0 : 1;
628                 case 'R':
629                         /* Continuously display rate-converted data */
630                         ok = status_profile_rates(verbose);
631                         return ok ? 0 : 1;
632                 default:
633                         break;
634         }
635
636         if ( show_processes ) {
637                 d_printf("\nSamba version %s\n",samba_version_string());
638                 d_printf("%-7s %-12s %-12s %-41s %-17s %-20s %-21s\n", "PID", "Username", "Group", "Machine", "Protocol Version", "Encryption", "Signing");
639                 d_printf("----------------------------------------------------------------------------------------------------------------------------------------\n");
640
641                 sessionid_traverse_read(traverse_sessionid, frame);
642
643                 if (processes_only) {
644                         goto done;
645                 }
646         }
647
648         if ( show_shares ) {
649                 if (brief) {
650                         goto done;
651                 }
652
653                 d_printf("\n%-12s %-7s %-13s %-32s %-12s %-12s\n", "Service", "pid", "Machine", "Connected at", "Encryption", "Signing");
654                 d_printf("---------------------------------------------------------------------------------------------\n");
655
656                 connections_forall_read(traverse_connections, frame);
657
658                 d_printf("\n");
659
660                 if ( shares_only ) {
661                         goto done;
662                 }
663         }
664
665         if ( show_locks ) {
666                 int result;
667                 struct db_context *db;
668
669                 db_path = lock_path(talloc_tos(), "locking.tdb");
670                 if (db_path == NULL) {
671                         d_printf("Out of memory - exiting\n");
672                         ret = -1;
673                         goto done;
674                 }
675
676                 db = db_open(NULL, db_path, 0,
677                              TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH, O_RDONLY, 0,
678                              DBWRAP_LOCK_ORDER_1, DBWRAP_FLAG_NONE);
679
680                 if (!db) {
681                         d_printf("%s not initialised\n", db_path);
682                         d_printf("This is normal if an SMB client has never "
683                                  "connected to your server.\n");
684                         TALLOC_FREE(db_path);
685                         exit(0);
686                 } else {
687                         TALLOC_FREE(db);
688                         TALLOC_FREE(db_path);
689                 }
690
691                 if (!locking_init_readonly()) {
692                         d_printf("Can't initialise locking module - exiting\n");
693                         ret = 1;
694                         goto done;
695                 }
696
697                 result = share_entry_forall(print_share_mode, NULL);
698
699                 if (result == 0) {
700                         d_printf("No locked files\n");
701                 } else if (result < 0) {
702                         d_printf("locked file list truncated\n");
703                 }
704
705                 d_printf("\n");
706
707                 if (show_brl) {
708                         brl_forall(print_brl, NULL);
709                 }
710
711                 locking_end();
712         }
713
714         if (show_notify) {
715                 struct notify_context *n;
716
717                 n = notify_init(talloc_tos(), msg_ctx,
718                                 NULL, NULL);
719                 if (n == NULL) {
720                         goto done;
721                 }
722                 notify_walk(n, print_notify_rec, NULL);
723                 TALLOC_FREE(n);
724         }
725
726 done:
727         TALLOC_FREE(frame);
728         return ret;
729 }