status.c: Added brief option. Patch from ccctim@mailbox.ucdavis.edu
authorSamba Release Account <samba-bugs@samba.org>
Thu, 8 May 1997 21:17:59 +0000 (21:17 +0000)
committerSamba Release Account <samba-bugs@samba.org>
Thu, 8 May 1997 21:17:59 +0000 (21:17 +0000)
client.c: Added translation of '/' characters to '\' characters. Suggested by friedl@mtndew.com (Stephen J. Friedl)
charcn.c: Fix for iso8859-2 (Eastern European) conversions based on a patch from Miroslaw M. Maczka <elvisbze@polbox.com>
(This used to be commit 27708a73cef690ea8aea0f3d82619eaed1fe476d)

source3/client/client.c
source3/lib/charcnv.c
source3/utils/status.c

index a9e81cfd64e29633ac35e5f024d35f8841920f62..e023530cb5ae813bb4412e8ea25a03a317b25700 100644 (file)
@@ -4291,8 +4291,6 @@ static void usage(char *pname)
   DEBUG(0,("\n"));
 }
 
-
-
 /****************************************************************************
   main program
 ****************************************************************************/
@@ -4349,6 +4347,8 @@ static void usage(char *pname)
     {
 
       strcpy(service,argv[1]);  
+      /* Convert any '/' characters in the service name to '\' characters */
+      string_replace( service, '/','\\');
       argc--;
       argv++;
 
index cf4ae4edb62ad5e0657fb0ce08dbb53444806b76..b6debbec4ad8b937b073f4fa0106c3282d455c20 100644 (file)
@@ -51,7 +51,7 @@ static void update_map(char * str) {
     }
 }
 
-static void initiso() {
+static void init_iso8859_1() {
 
     int i;
     if (!mapsinited) initmaps();
@@ -79,6 +79,25 @@ update_map("\370\233\371\227\372\243\373\226\374\201\375\354\376\347\377\230");
 
 }
 
+/* Init for eastern european languages. May need more work ? */
+
+static void init_iso8859_2() {
+
+    int i;
+    if (!mapsinited) initmaps();
+
+    /* Do not map undefined characters to some accidental code */
+    for (i = 128; i < 256; i++) 
+    {
+       unix2dos[i] = CTRLZ;
+       dos2unix[i] = CTRLZ;
+    }
+
+update_map("\241\244\306\217\312\250\243\235\321\343\323\340\246\227\254\215");
+update_map("\257\275\261\245\346\206\352\251\263\210\361\344\363\242\266\230");
+update_map("\274\253\277\276");
+}
+
 /*
  * Convert unix to dos
  */
@@ -125,8 +144,9 @@ int interpret_character_set(char *str, int def)
 {
 
     if (strequal (str, "iso8859-1")) {
-        initiso();
-        return def;
+        init_iso8859_1();
+    } else if (strequal (str, "iso8859-2")) {
+        init_iso8859_2();
     } else {
         DEBUG(0,("unrecognized character set\n"));
     }
index ba7c5f32105d074d318dc310ae2454e389c5b172..e8e57b3dd7cee73210d382dfffa3e4dec69a945d 100644 (file)
 #include "includes.h"
 
 struct connect_record crec;
+
+struct session_record{
+  int pid;
+  int uid;
+  char machine[31];
+  time_t start;
+  struct session_record *next;
+} *srecs;
+
 extern int DEBUGLEVEL;
 extern FILE *dbf;
 extern pstring myhostname;
@@ -51,7 +60,7 @@ unsigned int   Ucrit_IsActive = 0;                    /* added by OH */
   int uid, c;
   static pstring servicesf = CONFIGFILE;
   extern char *optarg;
-  int verbose = 0;
+  int verbose = 0, brief =0;
   BOOL firstopen=True;
   BOOL processes_only=False;
   int last_pid=0;
@@ -65,6 +74,7 @@ unsigned int   Ucrit_IsActive = 0;                    /* added by OH */
   void *dir;
   char *s;
 #endif
+  struct session_record *ptr;
 
 
   TimeInit();
@@ -80,8 +90,11 @@ unsigned int   Ucrit_IsActive = 0;                    /* added by OH */
     return(1);
   }
 
-  while ((c = getopt(argc, argv, "pds:u:")) != EOF) {
+  while ((c = getopt(argc, argv, "pds:u:b")) != EOF) {
     switch (c) {
+    case 'b':
+      brief = 1;
+      break;
     case 'd':
       verbose = 1;
       break;
@@ -133,8 +146,16 @@ unsigned int   Ucrit_IsActive = 0;                    /* added by OH */
   if (!processes_only) {
     printf("\nSamba version %s\n",VERSION);
 
-    printf("Service      uid      gid      pid     machine\n");
-    printf("----------------------------------------------\n");
+    if (brief)
+    {
+      printf("PID     Username  Machine                       Time logged in\n");
+      printf("-------------------------------------------------------------------\n");
+    }
+    else
+    {
+      printf("Service      uid      gid      pid     machine\n");
+      printf("----------------------------------------------\n");
+    }
   }
 
   while (!feof(f))
@@ -145,23 +166,63 @@ unsigned int   Ucrit_IsActive = 0;                    /* added by OH */
            && Ucrit_checkUsername(uidtoname(crec.uid))                      /* added by OH */
          )
       {
-        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)));
+        if (brief)
+        {
+         ptr=srecs;
+         while (ptr!=NULL)
+         {
+           if ((ptr->pid==crec.pid)&&(strncmp(ptr->machine,crec.machine,30)==0)) 
+           {
+             if (ptr->start > crec.start)
+               ptr->start=crec.start;
+             break;
+           }
+           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);
 
   if (processes_only) exit(0);
+  
+  if (brief)
+  {
+    ptr=srecs;
+    while (ptr!=NULL)
+    {
+      printf("%-8d%-10.10s%-30.30s%s",ptr->pid,uidtoname(ptr->uid),ptr->machine,asctime(LocalTime(&(ptr->start))));
+    ptr=ptr->next;
+    }
+    printf("\n");
+    exit(0);
+  }
 
   printf("\n");