summaryrefslogtreecommitdiff
path: root/source3/utils
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2003-11-12 22:37:09 +0000
committerGerald Carter <jerry@samba.org>2003-11-12 22:37:09 +0000
commitbd4e882b0b5e6ae9d64c784b16a3b7fffb6c5e50 (patch)
treeadce21bb5505927039ed2ae83c8cb507db01b64b /source3/utils
parenta40625bc9dc82794c9c8ca40a6095046b95a245e (diff)
downloadsamba-bd4e882b0b5e6ae9d64c784b16a3b7fffb6c5e50.tar.gz
samba-bd4e882b0b5e6ae9d64c784b16a3b7fffb6c5e50.tar.bz2
samba-bd4e882b0b5e6ae9d64c784b16a3b7fffb6c5e50.zip
show locked files for -u <user>; bug 590
(This used to be commit 3290582cb0542d1e2a7e1e5213614fca8788b070)
Diffstat (limited to 'source3/utils')
-rw-r--r--source3/utils/status.c51
1 files changed, 41 insertions, 10 deletions
diff --git a/source3/utils/status.c b/source3/utils/status.c
index c17e080b6b..54dce1ecf0 100644
--- a/source3/utils/status.c
+++ b/source3/utils/status.c
@@ -35,10 +35,12 @@
#include "includes.h"
-static pstring Ucrit_username = ""; /* added by OH */
-static pid_t Ucrit_pid[100]; /* Ugly !!! */ /* added by OH */
-static int Ucrit_MaxPid=0; /* added by OH */
-static unsigned int Ucrit_IsActive = 0; /* added by OH */
+#define SMB_MAXPIDS 2048
+static pstring Ucrit_username = ""; /* added by OH */
+static pid_t Ucrit_pid[SMB_MAXPIDS]; /* Ugly !!! */ /* added by OH */
+static int Ucrit_MaxPid=0; /* added by OH */
+static unsigned int Ucrit_IsActive = 0; /* added by OH */
+
static int verbose, brief;
static int shares_only = 0; /* Added by RJS */
static int locks_only = 0; /* Added by RJS */
@@ -49,26 +51,53 @@ static int show_brl;
static void Ucrit_addUsername(const char *username)
{
pstrcpy(Ucrit_username, username);
- if(strlen(Ucrit_username) > 0)
+
+ if ( strlen(Ucrit_username) > 0 )
Ucrit_IsActive = 1;
}
static unsigned int Ucrit_checkUsername(const char *username)
{
- if ( !Ucrit_IsActive) return 1;
- if (strcmp(Ucrit_username,username) ==0) return 1;
+ if ( !Ucrit_IsActive )
+ return 1;
+
+ if ( strcmp(Ucrit_username,username) == 0 )
+ return 1;
+
return 0;
}
static unsigned int Ucrit_checkPid(pid_t pid)
{
int i;
- if ( !Ucrit_IsActive) return 1;
- for (i=0;i<Ucrit_MaxPid;i++)
- if( pid == Ucrit_pid[i] ) return 1;
+
+ if ( !Ucrit_IsActive )
+ return 1;
+
+ for (i=0;i<Ucrit_MaxPid;i++) {
+ if( pid == Ucrit_pid[i] )
+ return 1;
+ }
+
return 0;
}
+static BOOL Ucrit_addPid( pid_t pid )
+{
+ if ( !Ucrit_IsActive )
+ return True;
+
+ if ( Ucrit_MaxPid >= SMB_MAXPIDS ) {
+ d_printf("ERROR: More than %d pids for user %s!\n",
+ SMB_MAXPIDS, Ucrit_username);
+
+ return False;
+ }
+
+ Ucrit_pid[Ucrit_MaxPid++] = pid;
+
+ return True;
+}
static void print_share_mode(share_mode_entry *e, char *fname)
{
@@ -526,6 +555,8 @@ static int traverse_sessionid(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, vo
return 0;
}
+ Ucrit_addPid( sessionid.pid );
+
d_printf("%5d %-12s %-12s %-12s (%s)\n",
(int)sessionid.pid, uidtoname(sessionid.uid), gidtoname(sessionid.gid),
sessionid.remote_machine, sessionid.hostname);