diff options
author | Michael Adam <obnox@samba.org> | 2007-08-31 09:54:30 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:30:25 -0500 |
commit | 018f72aa9c55b5776d3e6b22591af6d7ee52eec9 (patch) | |
tree | c85460f09bcb9b6b045378e265683b466ac63e72 /source3 | |
parent | 8843550c28832e1de92cb72584d7b2448aefe273 (diff) | |
download | samba-018f72aa9c55b5776d3e6b22591af6d7ee52eec9.tar.gz samba-018f72aa9c55b5776d3e6b22591af6d7ee52eec9.tar.bz2 samba-018f72aa9c55b5776d3e6b22591af6d7ee52eec9.zip |
r24827: Give smbstatus an initial talloc stackframe.
Rewrite main() so as to exit only at a single point
where the stack frame is freed, too.
Michael
(This used to be commit dbe38995ec6d2251562a3b10e750bbd681008e16)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/utils/status.c | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/source3/utils/status.c b/source3/utils/status.c index d8723788c9..ccf98a5b29 100644 --- a/source3/utils/status.c +++ b/source3/utils/status.c @@ -294,6 +294,8 @@ static int traverse_sessionid(struct db_record *db, void *state) POPT_COMMON_SAMBA POPT_TABLEEND }; + TALLOC_CTX *frame = talloc_stackframe(); + int ret = 0; sec_init(); load_case_tables(); @@ -304,7 +306,8 @@ static int traverse_sessionid(struct db_record *db, void *state) if (getuid() != geteuid()) { d_printf("smbstatus should not be run setuid\n"); - return(1); + ret = 1; + goto done; } pc = poptGetContext(NULL, argc, (const char **) argv, long_options, @@ -336,7 +339,8 @@ static int traverse_sessionid(struct db_record *db, void *state) if (!lp_load(dyn_CONFIGFILE,False,False,False,True)) { fprintf(stderr, "Can't load %s - run testparm to debug it\n", dyn_CONFIGFILE); - return (-1); + ret = -1; + goto done; } /* @@ -372,8 +376,9 @@ static int traverse_sessionid(struct db_record *db, void *state) TALLOC_FREE(db); } - if (processes_only) - exit(0); + if (processes_only) { + goto done; + } } if ( show_shares ) { @@ -381,8 +386,9 @@ static int traverse_sessionid(struct db_record *db, void *state) d_printf("Opened %s\n", lock_path("connections.tdb")); } - if (brief) - exit(0); + if (brief) { + goto done; + } d_printf("\nService pid machine Connected at\n"); d_printf("-------------------------------------------------------\n"); @@ -391,23 +397,25 @@ static int traverse_sessionid(struct db_record *db, void *state) d_printf("\n"); - if ( shares_only ) - exit(0); + if ( shares_only ) { + goto done; + } } if ( show_locks ) { - int ret; + int result; if (!locking_init(1)) { d_printf("Can't initialise locking module - exiting\n"); - exit(1); + ret = 1; + goto done; } - ret = share_mode_forall(print_share_mode, NULL); + result = share_mode_forall(print_share_mode, NULL); - if (ret == 0) { + if (result == 0) { d_printf("No locked files\n"); - } else if (ret == -1) { + } else if (result == -1) { d_printf("locked file list truncated\n"); } @@ -420,5 +428,7 @@ static int traverse_sessionid(struct db_record *db, void *state) locking_end(); } - return (0); +done: + TALLOC_FREE(frame); + return ret; } |