/*
- Unix SMB/Netbios implementation.
- Version 1.9.
+ Unix SMB/CIFS implementation.
status reporting
Copyright (C) Andrew Tridgell 1994-1998
#include "includes.h"
-struct session_record{
- pid_t pid;
- uid_t uid;
- char machine[31];
- time_t start;
- struct session_record *next;
-} *srecs;
-
-extern int DEBUGLEVEL;
-
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 BOOL processes_only=False;
static int show_brl;
-/* we need these because we link to locking*.o */
- void become_root(void) {}
- void unbecome_root(void) {}
-
-
/* added by OH */
-static void Ucrit_addUsername(char *username)
+static void Ucrit_addUsername(const char *username)
{
pstrcpy(Ucrit_username, username);
if(strlen(Ucrit_username) > 0)
Ucrit_IsActive = 1;
}
-static unsigned int Ucrit_checkUsername(char *username)
+static unsigned int Ucrit_checkUsername(const char *username)
{
if ( !Ucrit_IsActive) return 1;
if (strcmp(Ucrit_username,username) ==0) return 1;
static int count;
if (count==0) {
d_printf("Locked files:\n");
- d_printf("Pid DenyMode R/W Oplock Name\n");
- d_printf("--------------------------------------------------\n");
+ d_printf("Pid DenyMode Access R/W Oplock Name\n");
+ d_printf("--------------------------------------------------------------\n");
}
count++;
case DENY_WRITE:printf("DENY_WRITE "); break;
case DENY_FCB: d_printf("DENY_FCB "); break;
}
+ d_printf("0x%-8x ",(unsigned int)e->desired_access);
switch (e->share_mode&0xF) {
case 0: d_printf("RDONLY "); break;
case 1: d_printf("WRONLY "); break;
******************************************************************/
static int profile_dump(void)
{
+#ifdef WITH_PROFILE
if (!profile_setup(True)) {
fprintf(stderr,"Failed to initialise profile memory\n");
return -1;
d_printf("write_count: %u\n", profile_p->syscall_write_count);
d_printf("write_time: %u\n", profile_p->syscall_write_time);
d_printf("write_bytes: %u\n", profile_p->syscall_write_bytes);
+#ifdef WITH_SENDFILE
+ d_printf("sendfile_count: %u\n", profile_p->syscall_sendfile_count);
+ d_printf("sendfile_time: %u\n", profile_p->syscall_sendfile_time);
+ d_printf("sendfile_bytes: %u\n", profile_p->syscall_sendfile_bytes);
+#endif
d_printf("lseek_count: %u\n", profile_p->syscall_lseek_count);
d_printf("lseek_time: %u\n", profile_p->syscall_lseek_time);
d_printf("rename_count: %u\n", profile_p->syscall_rename_count);
d_printf("run_elections_time: %u\n", profile_p->run_elections_time);
d_printf("election_count: %u\n", profile_p->election_count);
d_printf("election_time: %u\n", profile_p->election_time);
+#else /* WITH_PROFILE */
+ fprintf(stderr, "Profile data unavailable\n");
+#endif /* WITH_PROFILE */
return 0;
}
int main(int argc, char *argv[])
{
- pstring fname;
int c;
- static pstring servicesf = CONFIGFILE;
- extern char *optarg;
- int profile_only = 0, new_debuglevel = -1;
+ static int profile_only = 0;
TDB_CONTEXT *tdb;
+ poptContext pc;
+ struct poptOption long_options[] = {
+ POPT_AUTOHELP
+ {"processes", 'p', POPT_ARG_NONE, &processes_only, 'p', "Show processes only" },
+ {"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" },
+ {"brief", 'b', POPT_ARG_NONE, &brief, 'b', "Be brief" },
+#ifdef WITH_PROFILE
+ {"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"},
+ POPT_COMMON_SAMBA
+ POPT_TABLEEND
+ };
- TimeInit();
setup_logging(argv[0],True);
- DEBUGLEVEL = 0;
dbf = x_stderr;
if (getuid() != geteuid()) {
d_printf("smbstatus should not be run setuid\n");
return(1);
}
+
+ pc = poptGetContext(NULL, argc, (const char **) argv, long_options,
+ POPT_CONTEXT_KEEP_FIRST);
- while ((c = getopt(argc, argv, "pvLSs:u:bPBd:")) != EOF) {
+ while ((c = poptGetNextOpt(pc)) != -1) {
switch (c) {
- case 'b':
- brief = 1;
- break;
- case 'B':
- show_brl = 1;
- break;
- case 'd':
- new_debuglevel = atoi(optarg);
- break;
-
- case 'v':
- verbose = 1;
- break;
- case 'L':
- locks_only = 1;
- break;
- case 'p':
- processes_only = 1;
- break;
- case 'P':
- profile_only = 1;
- break;
- case 'S':
- shares_only = 1;
- break;
- case 's':
- pstrcpy(servicesf, optarg);
- break;
case 'u':
- Ucrit_addUsername(optarg);
+ Ucrit_addUsername(poptGetOptArg(pc));
break;
- default:
- fprintf(stderr, "Usage: %s [-P] [-v] [-L] [-p] [-S] [-s configfile] [-u username] [-d debuglevel]\n", *argv);
- return (-1);
}
}
-
- if (!lp_load(servicesf,False,False,False)) {
- fprintf(stderr, "Can't load %s - run testparm to debug it\n", servicesf);
- return (-1);
- }
-
- if (new_debuglevel != -1) {
- DEBUGLEVEL = new_debuglevel;
- }
if (verbose) {
- d_printf("using configfile = %s\n", servicesf);
+ d_printf("using configfile = %s\n", dyn_CONFIGFILE);
+ }
+
+ if (!lp_load(dyn_CONFIGFILE,False,False,False)) {
+ fprintf(stderr, "Can't load %s - run testparm to debug it\n", dyn_CONFIGFILE);
+ return (-1);
}
if (profile_only) {
tdb = tdb_open_log(lock_path("connections.tdb"), 0, TDB_DEFAULT, O_RDONLY, 0);
if (!tdb) {
- d_printf("connections.tdb not initialised\n");
- } else
+ 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 status file %s\n", fname);
+ d_printf("Opened %s\n", lock_path("connections.tdb"));
}
if (brief)
return (0);
}
-