summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2004-11-11 23:30:32 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:53:14 -0500
commit5cb9d9286134ff5c75fc7b71cb9cf5216f309320 (patch)
tree66d0498fd2d533f435e386552bc6e0d2a87f347c /source3
parent80a5b023267e45b58e7a3fe3b495d6317943080b (diff)
downloadsamba-5cb9d9286134ff5c75fc7b71cb9cf5216f309320.tar.gz
samba-5cb9d9286134ff5c75fc7b71cb9cf5216f309320.tar.bz2
samba-5cb9d9286134ff5c75fc7b71cb9cf5216f309320.zip
r3688: fix output of smbstatus to make the man page; fix -L, -p, & -S and the -u <username> functionality
(This used to be commit 7dd12ed8a5ebbfa791f014b35debcf55d80e6d87)
Diffstat (limited to 'source3')
-rw-r--r--source3/utils/status.c81
1 files changed, 50 insertions, 31 deletions
diff --git a/source3/utils/status.c b/source3/utils/status.c
index 4585b101b2..122c6193f9 100644
--- a/source3/utils/status.c
+++ b/source3/utils/status.c
@@ -47,6 +47,8 @@ static int locks_only = 0; /* Added by RJS */
static BOOL processes_only=False;
static int show_brl;
+const char *username = NULL;
+
/* added by OH */
static void Ucrit_addUsername(const char *username)
{
@@ -578,6 +580,7 @@ static int traverse_sessionid(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, vo
int c;
static int profile_only = 0;
TDB_CONTEXT *tdb;
+ BOOL show_processes, show_locks, show_shares;
poptContext pc;
struct poptOption long_options[] = {
POPT_AUTOHELP
@@ -585,7 +588,7 @@ static int traverse_sessionid(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, vo
{"verbose", 'v', POPT_ARG_NONE, &verbose, 'v', "Be verbose" },
{"locks", 'L', POPT_ARG_NONE, &locks_only, 'L', "Show locks only" },
{"shares", 'S', POPT_ARG_NONE, &shares_only, 'S', "Show shares only" },
- {"user", 'u', POPT_ARG_STRING, 0, 'u', "Switch to user" },
+ {"user", 'u', POPT_ARG_STRING, &username, 'u', "Switch to user" },
{"brief", 'b', POPT_ARG_NONE, &brief, 'b', "Be brief" },
#ifdef WITH_PROFILE
{"profile", 'P', POPT_ARG_NONE, &profile_only, 'P', "Do profiling" },
@@ -615,6 +618,15 @@ static int traverse_sessionid(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, vo
}
}
+ /* setup the flags based on the possible combincations */
+
+ show_processes = !(shares_only || locks_only || profile_only) || processes_only;
+ show_locks = !(shares_only || processes_only || profile_only) || locks_only;
+ show_shares = !(processes_only || locks_only || profile_only) || shares_only;
+
+ if ( username )
+ Ucrit_addUsername( username );
+
if (verbose) {
d_printf("using configfile = %s\n", dyn_CONFIGFILE);
}
@@ -628,43 +640,50 @@ static int traverse_sessionid(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, vo
return profile_dump();
}
- tdb = tdb_open_log(lock_path("sessionid.tdb"), 0, TDB_DEFAULT, O_RDONLY, 0);
- if (!tdb) {
- d_printf("sessionid.tdb not initialised\n");
- } else {
- if (locks_only) goto locks;
-
- d_printf("\nSamba version %s\n",SAMBA_VERSION_STRING);
- d_printf("PID Username Group Machine \n");
- d_printf("-------------------------------------------------------------------\n");
-
- tdb_traverse(tdb, traverse_sessionid, NULL);
- tdb_close(tdb);
+ if ( show_processes ) {
+ tdb = tdb_open_log(lock_path("sessionid.tdb"), 0, TDB_DEFAULT, O_RDONLY, 0);
+ if (!tdb) {
+ d_printf("sessionid.tdb not initialised\n");
+ } else {
+ d_printf("\nSamba version %s\n",SAMBA_VERSION_STRING);
+ d_printf("PID Username Group Machine \n");
+ d_printf("-------------------------------------------------------------------\n");
+
+ tdb_traverse(tdb, traverse_sessionid, NULL);
+ tdb_close(tdb);
+ }
+
+ if (processes_only)
+ exit(0);
}
- tdb = tdb_open_log(lock_path("connections.tdb"), 0, TDB_DEFAULT, O_RDONLY, 0);
- if (!tdb) {
- d_printf("%s not initialised\n", lock_path("connections.tdb"));
- d_printf("This is normal if an SMB client has never connected to your server.\n");
- } else {
- if (verbose) {
- d_printf("Opened %s\n", lock_path("connections.tdb"));
+ if ( show_shares ) {
+ tdb = tdb_open_log(lock_path("connections.tdb"), 0, TDB_DEFAULT, O_RDONLY, 0);
+ if (!tdb) {
+ d_printf("%s not initialised\n", lock_path("connections.tdb"));
+ d_printf("This is normal if an SMB client has never connected to your server.\n");
+ } else {
+ if (verbose) {
+ d_printf("Opened %s\n", lock_path("connections.tdb"));
+ }
+
+ if (brief)
+ exit(0);
+
+ d_printf("\nService pid machine Connected at\n");
+ d_printf("-------------------------------------------------------\n");
+
+ tdb_traverse(tdb, traverse_fn1, NULL);
+ tdb_close(tdb);
+
+ d_printf("\n");
}
- if (brief)
+ if ( shares_only )
exit(0);
-
- d_printf("\nService pid machine Connected at\n");
- d_printf("-------------------------------------------------------\n");
-
- tdb_traverse(tdb, traverse_fn1, NULL);
- tdb_close(tdb);
}
- locks:
- if (processes_only) exit(0);
-
- if (!shares_only) {
+ if ( show_locks ) {
int ret;
if (!locking_init(1)) {