]> granicus.if.org Git - psmisc/commitdiff
added stefans patches
authorCraig Small <csmall@users.sourceforge.net>
Thu, 3 Apr 2003 04:54:56 +0000 (04:54 +0000)
committerCraig Small <csmall@users.sourceforge.net>
Thu, 3 Apr 2003 04:54:56 +0000 (04:54 +0000)
ChangeLog
src/fuser.c
src/killall.c
src/pstree.c
src/signals.c

index 443088f226687acf4e5ae66a8630249d88eb3233..a453b667ebf4e9bf21198c10f0f66d78f361f1c2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 Changes in 21.3
 ===============
+2003-04-03 Craig Small <csmall@small.dropbear.id.au>
+       * More fixes for types, also some GCC 3.2 fixes, thanks to
+         Stefan at SuSE
+
 2002-09-27 Craig Small <csmall@small.dropbear.id.au>
        * Changed a long to a long long in pstree.
 
index a3cca5369c20c1484c957126b9316ab26adaa143..7fd47bcc24cfa51a1cd4bf075029ca3a56022a2f 100644 (file)
@@ -180,13 +180,12 @@ parse_net_file (SPACE_DSC * dsc,char *filename, NET_CACHE **lastptr,int version
          perror ("malloc");
          exit (1);
        }
-      if (sscanf (line, "%*d: %*x:%x %64[0-9A-Fa-f]:%x %*x %*x:%*x %*x:%*x %*x %*d %*d "
 #ifdef INO_T_IS_LONG_LONG
-                 "%Ld", &new->lcl_port, rmt_addr, &new->rmt_port,
+      if (sscanf (line, "%*d: %*x:%x %64[0-9A-Fa-f]:%x %*x %*x:%*x %*x:%*x %*x %*d %*d %Ld", &new->lcl_port, rmt_addr, &new->rmt_port,
 #elif defined(INO_T_IS_INT)
-                 "%d", &new->lcl_port, rmt_addr, &new->rmt_port,
+      if (sscanf (line, "%*d: %*x:%x %64[0-9A-Fa-f]:%x %*x %*x:%*x %*x:%*x %*x %*d %*d %d", &new->lcl_port, rmt_addr, &new->rmt_port,
 #else
-                 "%d", &new->lcl_port, rmt_addr, &new->rmt_port,
+      if (sscanf (line, "%*d: %*x:%x %64[0-9A-Fa-f]:%x %*x %*x:%*x %*x:%*x %*x %*d %*d %d", &new->lcl_port, rmt_addr, &new->rmt_port,
 #endif
                  &new->ino) != 4)
        {
@@ -474,7 +473,7 @@ scan_fd (void)
     }
   empty = 1;
   while ((de = readdir (dir)) != NULL)
-    if ((pid = atoi (de->d_name)) != 0)
+    if ((pid = (pid_t)atoi (de->d_name)) != 0)
       {
        empty = 0;
        if (asprintf (&path, "%s/%d", PROC_BASE, pid) < 0)
@@ -650,7 +649,7 @@ show_files_or_kill (void)
   const struct passwd *pw;
   const char *user, *scan;
   char tmp[10], *path, comm[COMM_LEN + 1];
-  int length, header, first, dummy;
+  int length, header, first, dummy, last_namelen = 0;
   header = 1;
   for (file = files; file; file = file->next)
     if (file->name && (file->items || all))
@@ -661,7 +660,7 @@ show_files_or_kill (void)
            header = 0;
          }
        length = 0;
-       for (scan = file->name; *scan; scan++)
+       for (scan = file->name; scan && *scan; scan++)
          if (*scan == '\\')
            length += printf ("\\\\");
          else if (*scan > ' ' && *scan <= '~')
@@ -673,6 +672,12 @@ show_files_or_kill (void)
            length += printf ("\\%03o", *scan);
        if (file->name_space)
          length += printf ("/%s", file->name_space->name);
+
+       if (length > 0)
+         last_namelen=length;
+       else
+         printf("\n%*.*s",last_namelen,last_namelen," ");
+
        if (!(file->flags & FLAG_VERB))
          {
            putchar (':');
index a39ec8e9fd34b5e50b259b2a8be3914fc5fcc906..83ce26e62a70a3367b271833345392af5a7a998a 100644 (file)
@@ -11,6 +11,7 @@
 #endif
 
 #include <stdlib.h>
+#include <unistd.h>
 #include <stdio.h>
 #include <string.h>
 #include <unistd.h>
@@ -131,7 +132,7 @@ kill_all (int signal, int names, char **namelist)
   pids = 0;
   while ( (de = readdir (dir)) != NULL)
     {
-      if (!(pid = atoi (de->d_name)) || pid == self)
+      if (!(pid = (pid_t) atoi (de->d_name)) || pid == self)
        continue;
       if (pids == max_pids)
        {
index b252846fbf6825719fbd2749e74755f34767f11d..60051aa94c87c5ef2ed633f7b96194dc644120c7 100644 (file)
@@ -181,12 +181,12 @@ out_scontext ( security_id_t sid )
 
   rv = security_sid_to_context((int)sid, buf, &len);
   if ( rv ) {
-    out_string("`??'"); /* punt */
+    out_string("`??\'"); /* punt */
   }
   else {
     out_string("`");
     out_string(buf);
-    out_string("'");
+    out_string("\'");
   }
 }
 #endif /*FLASK_LINUX*/
@@ -454,7 +454,7 @@ dump_tree (PROC * current, int level, int rep, int leaf, int last,
          len = 0;
          for (here = current->argv[i]; *here; here++)
            len += *here > ' ' && *here <= '~' ? 1 : 4;
-         if (cur_x + len <= output_width - (i == current->argc - 1 ? 0 : 4))
+         if (cur_x + len <= output_width - (i == current->argc - 1 ? 0 : 4) || !trunc)
            for (here = current->argv[i]; *here; here++)
              if (*here > ' ' && *here <= '~')
                out_char (*here);
@@ -591,7 +591,7 @@ read_proc (void)
     }
   empty = 1;
   while ((de = readdir (dir)) != NULL)
-    if ((pid = atoi (de->d_name)) != 0)
+    if ((pid = (pid_t) atoi (de->d_name)) != 0)
       {
        if (!(path = malloc (strlen (PROC_BASE) + strlen (de->d_name) + 10)))
          exit (2);
@@ -627,7 +627,7 @@ read_proc (void)
            if (fscanf
                (file, "%d (%s) %c %d", &dummy, comm, (char *) &dummy,
                 &ppid) == 4)
            */
+ */
                if (!print_args)
 #ifdef FLASK_LINUX
                  add_proc(comm, pid, ppid, st.st_uid, NULL, 0, sid);
@@ -840,7 +840,7 @@ main (int argc, char **argv)
   if (optind == argc - 1) {
     if (isdigit (*argv[optind]))
       {
-       if (!(pid = atoi (argv[optind++])))
+       if (!(pid = (pid_t) atoi (argv[optind++])))
          usage ();
       }
     else if (!(pw = getpwnam (argv[optind++])))
index 46e9ccf1e8bf44d83b15103347fa0f8e6962dd95..a8295d38a7deddd4fc9d2cc03fe4f14fefa39db1 100644 (file)
@@ -7,6 +7,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <ctype.h>
+#include <signal.h>
 #include "signals.h"
 
 
@@ -52,6 +53,8 @@ get_signal (char *name, const char *cmd)
 
   if (isdigit (*name))
     return atoi (name);
+  if (!strncmp("SIG", name, 3))
+    name += 3;
   for (walk = signals; walk->name; walk++)
     if (!strcmp (walk->name, name))
       break;