summaryrefslogtreecommitdiff
path: root/source/utils/status.c
diff options
context:
space:
mode:
Diffstat (limited to 'source/utils/status.c')
-rw-r--r--source/utils/status.c123
1 files changed, 54 insertions, 69 deletions
diff --git a/source/utils/status.c b/source/utils/status.c
index d6e408e52ea..df742f73e79 100644
--- a/source/utils/status.c
+++ b/source/utils/status.c
@@ -35,7 +35,7 @@
#define SMB_MAXPIDS 2048
static uid_t Ucrit_uid = 0; /* added by OH */
-static struct server_id Ucrit_pid[SMB_MAXPIDS]; /* Ugly !!! */ /* 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 */
@@ -69,7 +69,7 @@ static unsigned int Ucrit_checkUid(uid_t uid)
return 0;
}
-static unsigned int Ucrit_checkPid(struct server_id pid)
+static unsigned int Ucrit_checkPid(pid_t pid)
{
int i;
@@ -77,14 +77,14 @@ static unsigned int Ucrit_checkPid(struct server_id pid)
return 1;
for (i=0;i<Ucrit_MaxPid;i++) {
- if (cluster_id_equal(&pid, &Ucrit_pid[i]))
+ if( pid == Ucrit_pid[i] )
return 1;
}
return 0;
}
-static BOOL Ucrit_addPid( struct server_id pid )
+static BOOL Ucrit_addPid( pid_t pid )
{
if ( !Ucrit_IsActive )
return True;
@@ -119,7 +119,7 @@ static void print_share_mode(const struct share_mode_entry *e,
}
count++;
- if (Ucrit_checkPid(e->pid)) {
+ if (Ucrit_checkPid(procid_to_pid(&e->pid))) {
d_printf("%-11s ",procid_str_static(&e->pid));
d_printf("%-9u ", (unsigned int)e->uid);
switch (map_share_mode_to_deny_mode(e->share_access,
@@ -166,27 +166,15 @@ static void print_share_mode(const struct share_mode_entry *e,
}
}
-static void print_brl(struct file_id id,
- struct server_id pid,
+static void print_brl(SMB_DEV_T dev,
+ SMB_INO_T ino,
+ struct process_id pid,
enum brl_type lock_type,
enum brl_flavour lock_flav,
br_off start,
- br_off size,
- void *private_data)
+ br_off size)
{
static int count;
- int i;
- static const struct {
- enum brl_type lock_type;
- const char *desc;
- } lock_types[] = {
- { READ_LOCK, "R" },
- { WRITE_LOCK, "W" },
- { PENDING_READ_LOCK, "PR" },
- { PENDING_WRITE_LOCK, "PW" },
- { UNLOCK_LOCK, "U" }
- };
- const char *desc="X";
if (count==0) {
d_printf("Byte range locks:\n");
d_printf(" Pid dev:inode R/W start size\n");
@@ -194,49 +182,47 @@ static void print_brl(struct file_id id,
}
count++;
- for (i=0;i<ARRAY_SIZE(lock_types);i++) {
- if (lock_type == lock_types[i].lock_type) {
- desc = lock_types[i].desc;
- }
- }
-
- d_printf("%8s %s %2s %9.0f %9.0f\n",
- procid_str_static(&pid), file_id_static_string(&id),
- desc,
- (double)start, (double)size);
+ d_printf("%8s %05x:%05x %s %9.0f %9.0f\n",
+ procid_str_static(&pid), (int)dev, (int)ino,
+ lock_type==READ_LOCK?"R":"W",
+ (double)start, (double)size);
}
-static int traverse_fn1(struct db_record *rec,
- const struct connections_key *key,
- const struct connections_data *crec,
- void *state)
+static int traverse_fn1(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, void *state)
{
- if (crec->cnum == -1)
+ struct connections_data crec;
+
+ if (dbuf.dsize != sizeof(crec))
+ return 0;
+
+ memcpy(&crec, dbuf.dptr, sizeof(crec));
+
+ if (crec.cnum == -1)
return 0;
- if (!process_exists(crec->pid) || !Ucrit_checkUid(crec->uid)) {
+ if (!process_exists(crec.pid) || !Ucrit_checkUid(crec.uid)) {
return 0;
}
d_printf("%-10s %s %-12s %s",
- crec->servicename,procid_str_static(&crec->pid),
- crec->machine,
- time_to_asc(crec->start));
+ crec.servicename,procid_str_static(&crec.pid),
+ crec.machine,
+ time_to_asc(crec.start));
return 0;
}
-static int traverse_sessionid(struct db_record *db, void *state)
+static int traverse_sessionid(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, void *state)
{
struct sessionid sessionid;
fstring uid_str, gid_str;
- if (db->value.dsize != sizeof(sessionid))
+ if (dbuf.dsize != sizeof(sessionid))
return 0;
- memcpy(&sessionid, db->value.dptr, sizeof(sessionid));
+ memcpy(&sessionid, dbuf.dptr, sizeof(sessionid));
- if (!process_exists(sessionid.pid) || !Ucrit_checkUid(sessionid.uid)) {
+ if (!process_exists_by_pid(sessionid.pid) || !Ucrit_checkUid(sessionid.uid)) {
return 0;
}
@@ -245,8 +231,8 @@ static int traverse_sessionid(struct db_record *db, void *state)
fstr_sprintf(uid_str, "%d", sessionid.uid);
fstr_sprintf(gid_str, "%d", sessionid.gid);
- d_printf("%-7s %-12s %-12s %-12s (%s)\n",
- procid_str_static(&sessionid.pid),
+ d_printf("%5d %-12s %-12s %-12s (%s)\n",
+ (int)sessionid.pid,
numeric_only ? uid_str : uidtoname(sessionid.uid),
numeric_only ? gid_str : gidtoname(sessionid.gid),
sessionid.remote_machine, sessionid.hostname);
@@ -261,6 +247,7 @@ static int traverse_sessionid(struct db_record *db, void *state)
{
int c;
int profile_only = 0;
+ TDB_CONTEXT *tdb;
BOOL show_processes, show_locks, show_shares;
poptContext pc;
struct poptOption long_options[] = {
@@ -323,13 +310,6 @@ static int traverse_sessionid(struct db_record *db, void *state)
return (-1);
}
- /*
- * This implicitly initializes the global ctdbd connection, usable by
- * the db_open() calls further down.
- */
-
- messaging_init(NULL, procid_self(), event_context_init(NULL));
-
switch (profile_only) {
case 'P':
/* Dump profile data */
@@ -342,18 +322,16 @@ static int traverse_sessionid(struct db_record *db, void *state)
}
if ( show_processes ) {
- struct db_context *db;
- db = db_open(NULL, lock_path("sessionid.tdb"), 0,
- TDB_DEFAULT, O_RDWR, 0644);
- if (!db) {
+ 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");
- db->traverse_read(db, traverse_sessionid, NULL);
- talloc_free(db);
+ tdb_traverse(tdb, traverse_sessionid, NULL);
+ tdb_close(tdb);
}
if (processes_only)
@@ -361,19 +339,26 @@ static int traverse_sessionid(struct db_record *db, void *state)
}
if ( show_shares ) {
- if (verbose) {
- d_printf("Opened %s\n", lock_path("connections.tdb"));
- }
+ 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);
+ if (brief)
+ exit(0);
- d_printf("\nService pid machine Connected at\n");
- d_printf("-------------------------------------------------------\n");
+ d_printf("\nService pid machine Connected at\n");
+ d_printf("-------------------------------------------------------\n");
- connections_forall(traverse_fn1, NULL);
+ tdb_traverse(tdb, traverse_fn1, NULL);
+ tdb_close(tdb);
- d_printf("\n");
+ d_printf("\n");
+ }
if ( shares_only )
exit(0);
@@ -398,7 +383,7 @@ static int traverse_sessionid(struct db_record *db, void *state)
d_printf("\n");
if (show_brl) {
- brl_forall(print_brl, NULL);
+ brl_forall(print_brl);
}
locking_end();