svn commit: samba r4248 - in branches/SAMBA_3_0/source/utils: .
vlendec at samba.org
vlendec at samba.org
Fri Dec 17 08:51:24 GMT 2004
Author: vlendec
Date: 2004-12-17 08:51:23 +0000 (Fri, 17 Dec 2004)
New Revision: 4248
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=4248
Log:
Implement smbstatus -n, don't lookup users and groups. On heavily loaded
winbind systems, looking up hundreds of users can turn out to be a bit too
expensive if you just want to find out which smbd handles a particular IP
address.
Volker
P.S: Who is "OH"? ;-)
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-12-17 06:35:11 UTC (rev 4247)
+++ branches/SAMBA_3_0/source/utils/status.c 2004-12-17 08:51:23 UTC (rev 4248)
@@ -36,7 +36,7 @@
#include "includes.h"
#define SMB_MAXPIDS 2048
-static pstring Ucrit_username = ""; /* added by OH */
+static uid_t Ucrit_uid = 0; /* 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 */
@@ -46,24 +46,23 @@
static int locks_only = 0; /* Added by RJS */
static BOOL processes_only=False;
static int show_brl;
+static BOOL numeric_only = False;
const char *username = NULL;
/* added by OH */
-static void Ucrit_addUsername(const char *user_name)
+static void Ucrit_addUid(uid_t uid)
{
- pstrcpy(Ucrit_username, user_name);
-
- if ( strlen(Ucrit_username) > 0 )
- Ucrit_IsActive = 1;
+ Ucrit_uid = uid;
+ Ucrit_IsActive = 1;
}
-static unsigned int Ucrit_checkUsername(const char *user_name)
+static unsigned int Ucrit_checkUid(uid_t uid)
{
if ( !Ucrit_IsActive )
return 1;
- if ( strcmp(Ucrit_username,user_name) == 0 )
+ if ( uid == Ucrit_uid )
return 1;
return 0;
@@ -91,7 +90,7 @@
if ( Ucrit_MaxPid >= SMB_MAXPIDS ) {
d_printf("ERROR: More than %d pids for user %s!\n",
- SMB_MAXPIDS, Ucrit_username);
+ SMB_MAXPIDS, uidtoname(Ucrit_uid));
return False;
}
@@ -538,7 +537,7 @@
if (crec.cnum == -1)
return 0;
- if (!process_exists(crec.pid) || !Ucrit_checkUsername(uidtoname(crec.uid))) {
+ if (!process_exists(crec.pid) || !Ucrit_checkUid(crec.uid)) {
return 0;
}
@@ -553,21 +552,27 @@
static int traverse_sessionid(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, void *state)
{
struct sessionid sessionid;
+ fstring uid_str, gid_str;
if (dbuf.dsize != sizeof(sessionid))
return 0;
memcpy(&sessionid, dbuf.dptr, sizeof(sessionid));
- if (!process_exists(sessionid.pid) || !Ucrit_checkUsername(uidtoname(sessionid.uid))) {
+ if (!process_exists(sessionid.pid) || !Ucrit_checkUid(sessionid.uid)) {
return 0;
}
Ucrit_addPid( sessionid.pid );
+ fstr_sprintf(uid_str, "%d", sessionid.uid);
+ fstr_sprintf(gid_str, "%d", sessionid.gid);
+
d_printf("%5d %-12s %-12s %-12s (%s)\n",
- (int)sessionid.pid, uidtoname(sessionid.uid), gidtoname(sessionid.gid),
- sessionid.remote_machine, sessionid.hostname);
+ (int)sessionid.pid,
+ numeric_only ? uid_str : uidtoname(sessionid.uid),
+ numeric_only ? gid_str : gidtoname(sessionid.gid),
+ sessionid.remote_machine, sessionid.hostname);
return 0;
}
@@ -594,6 +599,7 @@
{"profile", 'P', POPT_ARG_NONE, &profile_only, 'P', "Do profiling" },
#endif /* WITH_PROFILE */
{"byterange", 'B', POPT_ARG_NONE, &show_brl, 'B', "Include byte range locks"},
+ {"numeric", 'n', POPT_ARG_NONE, &numeric_only, 'n', "Numeric uid/gid"},
POPT_COMMON_SAMBA
POPT_TABLEEND
};
@@ -613,7 +619,7 @@
while ((c = poptGetNextOpt(pc)) != -1) {
switch (c) {
case 'u':
- Ucrit_addUsername(poptGetOptArg(pc));
+ Ucrit_addUid(nametouid(poptGetOptArg(pc)));
break;
}
}
@@ -625,7 +631,7 @@
show_shares = !(processes_only || locks_only || profile_only) || shares_only;
if ( username )
- Ucrit_addUsername( username );
+ Ucrit_addUid( nametouid(username) );
if (verbose) {
d_printf("using configfile = %s\n", dyn_CONFIGFILE);
More information about the samba-cvs
mailing list