svn commit: samba r3688 - in branches/SAMBA_3_0/source/utils: .

jerry at samba.org jerry at samba.org
Thu Nov 11 23:30:33 GMT 2004


Author: jerry
Date: 2004-11-11 23:30:32 +0000 (Thu, 11 Nov 2004)
New Revision: 3688

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=3688

Log:
fix output of smbstatus to make the man page; fix -L, -p, & -S and the -u <username> functionality
Modified:
   branches/SAMBA_3_0/source/utils/status.c


Changeset:
Modified: branches/SAMBA_3_0/source/utils/status.c
===================================================================
--- branches/SAMBA_3_0/source/utils/status.c	2004-11-11 23:25:33 UTC (rev 3687)
+++ branches/SAMBA_3_0/source/utils/status.c	2004-11-11 23:30:32 UTC (rev 3688)
@@ -47,6 +47,8 @@
 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 @@
 	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 @@
 		{"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 @@
 		}
 	}
 
+	/* 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 @@
 		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;
+	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");
 
-		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);
+		}
 
-		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)) {



More information about the samba-cvs mailing list