diff options
author | Luke Leighton <lkcl@samba.org> | 1999-08-18 00:12:19 +0000 |
---|---|---|
committer | Luke Leighton <lkcl@samba.org> | 1999-08-18 00:12:19 +0000 |
commit | 06b4627df0b75d91f3f7198f1cad1098e3431820 (patch) | |
tree | ad29374ad274564c9a1ba6cda53febdef59d95c1 | |
parent | 7a0595b23461c259f2ce6662f0d2a5a047c1c0fb (diff) | |
download | samba-06b4627df0b75d91f3f7198f1cad1098e3431820.tar.gz samba-06b4627df0b75d91f3f7198f1cad1098e3431820.tar.bz2 samba-06b4627df0b75d91f3f7198f1cad1098e3431820.zip |
patch from Michael Glauche to call get_status_connections() instead of
reading STATUS..LCK direct.
(This used to be commit d794e2eb51b94a334ddb1d1b0775ebf4cef048db)
-rw-r--r-- | source3/include/proto.h | 5 | ||||
-rw-r--r-- | source3/utils/status.c | 104 |
2 files changed, 57 insertions, 52 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h index e64865b85c..5b52e5aa61 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -558,6 +558,11 @@ void reset_globals_after_fork(void); char *client_name(int fd); char *client_addr(int fd); +/*The following definitions come from lib/util_status.c */ + +BOOL get_connection_status(struct connect_record **crec, + uint32 *connection_count); + /*The following definitions come from lib/util_str.c */ void set_first_token(char *ptr); diff --git a/source3/utils/status.c b/source3/utils/status.c index e20af8444c..320a54cc7d 100644 --- a/source3/utils/status.c +++ b/source3/utils/status.c @@ -36,8 +36,6 @@ #include "includes.h" -struct connect_record crec; - struct session_record{ int pid; int uid; @@ -172,6 +170,9 @@ static int profile_dump(void) int last_pid=0; struct session_record *ptr; int profile_only = 0; + struct connect_record *crec = NULL; + uint32 connection_count; + uint32 conn; TimeInit(); setup_logging(argv[0],True); @@ -266,60 +267,59 @@ static int profile_dump(void) printf("----------------------------------------------\n"); } } - - while (!feof(f)) - { - if (fread(&crec,sizeof(crec),1,f) != 1) - break; - if (crec.cnum == -1) continue; - if ( crec.magic == 0x280267 && process_exists(crec.pid) - && Ucrit_checkUsername(uidtoname(crec.uid)) /* added by OH */ - ) + + if (get_connection_status(&crec, &connection_count)) + { + for (conn=0;conn<connection_count;conn++) { - if (brief) - { - ptr=srecs; - while (ptr!=NULL) - { - if ((ptr->pid==crec.pid)&&(strncmp(ptr->machine,crec.machine,30)==0)) + if (Ucrit_checkUsername(uidtoname(crec[conn].uid))) + { + if (brief) { - if (ptr->start > crec.start) - ptr->start=crec.start; - break; + ptr=srecs; + while (ptr!=NULL) + { + if ((ptr->pid==crec[conn].pid)&&(strncmp(ptr->machine,crec[conn].machine,30)==0)) + { + if (ptr->start > crec[conn].start) + ptr->start=crec[conn].start; + break; + } + ptr=ptr->next; + } + if (ptr==NULL) + { + ptr=(struct session_record *) malloc(sizeof(struct session_record)); + ptr->uid=crec[conn].uid; + ptr->pid=crec[conn].pid; + ptr->start=crec[conn].start; + strncpy(ptr->machine,crec[conn].machine,30); + ptr->machine[30]='\0'; + ptr->next=srecs; + srecs=ptr; + } } - ptr=ptr->next; - } - if (ptr==NULL) - { - ptr=(struct session_record *) malloc(sizeof(struct session_record)); - ptr->uid=crec.uid; - ptr->pid=crec.pid; - ptr->start=crec.start; - strncpy(ptr->machine,crec.machine,30); - ptr->machine[30]='\0'; - ptr->next=srecs; - srecs=ptr; - } - } - else - { - Ucrit_addPid(crec.pid); /* added by OH */ - if (processes_only) { - if (last_pid != crec.pid) - printf("%d\n",crec.pid); - last_pid = crec.pid; /* XXXX we can still get repeats, have to - add a sort at some time */ - } - else - printf("%-10.10s %-8s %-8s %5d %-8s (%s) %s", - crec.name,uidtoname(crec.uid),gidtoname(crec.gid),crec.pid, - crec.machine,crec.addr, - asctime(LocalTime(&crec.start))); - } - } - } - fclose(f); + else + { + Ucrit_addPid(crec[conn].pid); /* added by OH */ + if (processes_only) { + if (last_pid != crec[conn].pid) + printf("%d\n",crec[conn].pid); + last_pid = crec[conn].pid; /* XXXX we can still get repeats, have to + add a sort at some time */ + } + else + printf("%-10.10s %-8s %-8s %5d %-8s (%s) %s", + crec[conn].name,uidtoname(crec[conn].uid),gidtoname(crec[conn].gid),crec[conn].pid, + crec[conn].machine,crec[conn].addr, + asctime(LocalTime(&crec[conn].start))); + } + } + } + free(crec); + } } + if (processes_only) exit(0); if (brief) |