Hello community,

here is the log from the commit of package forkstat for openSUSE:Factory 
checked in at 2020-11-12 22:47:57
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/forkstat (Old)
 and      /work/SRC/openSUSE:Factory/.forkstat.new.24930 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "forkstat"

Thu Nov 12 22:47:57 2020 rev:15 rq:847945 version:0.02.16

Changes:
--------
--- /work/SRC/openSUSE:Factory/forkstat/forkstat.changes        2020-08-24 
15:13:47.426706536 +0200
+++ /work/SRC/openSUSE:Factory/.forkstat.new.24930/forkstat.changes     
2020-11-12 22:49:52.226798103 +0100
@@ -1,0 +2,7 @@
+Sat Nov  7 18:17:09 UTC 2020 - Martin Hauke <[email protected]>
+
+- Update to version 0.02.16
+  * forkstat: handle weird comm field in /proc/$PID/stat
+  * conditionally build in helper functions
+
+-------------------------------------------------------------------

Old:
----
  forkstat-0.02.15.tar.xz

New:
----
  forkstat-0.02.16.tar.xz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ forkstat.spec ++++++
--- /var/tmp/diff_new_pack.Zh6ksD/_old  2020-11-12 22:49:52.786798688 +0100
+++ /var/tmp/diff_new_pack.Zh6ksD/_new  2020-11-12 22:49:52.794798697 +0100
@@ -2,7 +2,7 @@
 # spec file for package forkstat
 #
 # Copyright (c) 2020 SUSE LLC
-# Copyright (c) 2017, Martin Hauke <[email protected]>
+# Copyright (c) 2017-2020, Martin Hauke <[email protected]>
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -18,7 +18,7 @@
 
 
 Name:           forkstat
-Version:        0.02.15
+Version:        0.02.16
 Release:        0
 Summary:        Process fork/exec/exit monitoring tool
 License:        GPL-2.0-or-later

++++++ forkstat-0.02.15.tar.xz -> forkstat-0.02.16.tar.xz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/forkstat-0.02.15/Makefile 
new/forkstat-0.02.16/Makefile
--- old/forkstat-0.02.15/Makefile       2020-07-04 12:17:09.000000000 +0200
+++ new/forkstat-0.02.16/Makefile       2020-11-07 17:10:07.000000000 +0100
@@ -16,7 +16,7 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 
USA.
 #
 
-VERSION=0.02.15
+VERSION=0.02.16
 #
 # Version "Perspicacious Process Peeker"
 #
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/forkstat-0.02.15/forkstat.c 
new/forkstat-0.02.16/forkstat.c
--- old/forkstat-0.02.15/forkstat.c     2020-07-04 12:17:09.000000000 +0200
+++ new/forkstat-0.02.16/forkstat.c     2020-11-07 17:10:07.000000000 +0100
@@ -289,6 +289,51 @@
 }
 
 /*
+ *  get_proc_self_stat_field()
+ *     find nth field of /proc/$PID/stat data. This works around
+ *     the problem that the comm field can contain spaces and
+ *     multiple ) so sscanf on this field won't work.  The returned
+ *     pointer is the start of the Nth field and it is up to the
+ *     caller to determine the end of the field
+ */
+static const char *get_proc_self_stat_field(const char *buf, const int num)
+{
+       const char *ptr = buf, *comm_end;
+       int n;
+
+       if (num < 1 || !buf || !*buf)
+               return NULL;
+       if (num == 1)
+               return buf;
+       if (num == 2)
+               return strstr(buf, "(");
+
+       comm_end = NULL;
+       for (ptr = buf; *ptr; ptr++) {
+               if (*ptr == ')')
+                       comm_end = ptr;
+       }
+       if (!comm_end)
+               return NULL;
+       comm_end++;
+       n = num - 2;
+
+       ptr = comm_end;
+       while (*ptr) {
+               while (*ptr && *ptr == ' ')
+                       ptr++;
+               n--;
+               if (n <= 0)
+                       break;
+               while (*ptr && *ptr != ' ')
+                       ptr++;
+       }
+
+       return ptr;
+}
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,14)
+/*
  *  secs_to_str()
  *     report seconds in different units.
  */
@@ -309,6 +354,7 @@
                (unsigned int)s, (unsigned int)fract, second_scales[i].ch);
        return buf;
 }
+#endif
 
 /*
  *  get_username()
@@ -588,8 +634,13 @@
                }
        }
 
-       if (fscanf(fp, "%*d %*s %*s %*d %*d %*d %ld", &dev) == 1)
-               info->tty = (dev_t)dev;
+       info->tty = (dev_t)0;
+       if (fgets(buffer, sizeof(buffer) - 1, fp) != NULL) {
+               const char *ptr = get_proc_self_stat_field(buffer, 7);
+
+               if (ptr && sscanf(ptr , "%ld", &dev) == 1)
+                       info->tty = (dev_t)dev;
+       }
        (void)fclose(fp);
 }
 
@@ -629,6 +680,7 @@
 
 }
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,14)
 /*
  *  get_parent_pid()
  *     get parent pid and set is_thread to true if process
@@ -679,6 +731,7 @@
 
        return ppid;
 }
+#endif
 
 /*
  *  sane_proc_pid_info()
@@ -823,6 +876,7 @@
                (opt_flags & OPT_GLYPH) ? " " : "");
 }
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,14)
 /*
  *  row_increment()
  *     bump row increment and re-print heading if required
@@ -837,6 +891,7 @@
                row = 2;
        }
 }
+#endif
 
 /*
  *  timeval_to_double()
@@ -858,6 +913,7 @@
        unsigned long jiffies;
        char path[PATH_MAX];
        char buffer[4096];
+       const char *ptr;
        double uptime_secs, secs;
        struct timeval now;
        ssize_t n;
@@ -867,11 +923,12 @@
        fd = open("/proc/uptime", O_RDONLY);
        if (fd < 0)
                return;
-       n = read(fd, buffer, sizeof(buffer));
+       n = read(fd, buffer, sizeof(buffer) - 1);
        if (n <= 0) {
                (void)close(fd);
                return;
        }
+       buffer[n] = '\0';
        (void)close(fd);
        n = sscanf(buffer, "%lg", &uptime_secs);
        if (n != 1)
@@ -882,14 +939,18 @@
        fd = open(path, O_RDONLY);
        if (fd < 0)
                return;
-       n = read(fd, buffer, sizeof(buffer));
+       n = read(fd, buffer, sizeof(buffer) - 1);
        if (n <= 0) {
                (void)close(fd);
                return;
        }
+       buffer[n] = '\0';
        (void)close(fd);
-       n = sscanf(buffer, "%*d %*s %*c %*d %*d %*d %*d %*d %*u %*u %*u %*u "
-               "%*u %*u %*u %*u %*u %*d %*d %*d %*d %llu", &starttime);
+
+       ptr = get_proc_self_stat_field(buffer, 22);
+       if (!ptr)
+               return;
+       n = sscanf(ptr, "%llu", &starttime);
        if (n != 1)
                return;
 
@@ -936,6 +997,7 @@
        return hash % MAX_PIDS;
 }
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,14)
 /*
  *  proc_stats_account()
  *     perform per process accounting
@@ -980,6 +1042,7 @@
        stats->next = proc_stats[h];
        proc_stats[h] = stats;
 }
+#endif
 
 /*
  *  stats_cmp()
@@ -1157,6 +1220,7 @@
        return info;
 }
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,14)
 /*
  *  proc_info_free()
  *     free cached process info and remove from hash table
@@ -1179,6 +1243,7 @@
                info = info->next;
        }
 }
+#endif
 
 /*
  *   proc_info_unload()
@@ -1200,6 +1265,7 @@
        }
 }
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,14)
 /*
  *  proc_info_update()
  *     update process name, for example, if exec has occurred
@@ -1225,6 +1291,7 @@
 
        return info;
 }
+#endif
 
 /*
  *   proc_info_add()
@@ -1332,6 +1399,7 @@
        return 0;
 }
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,14)
 /*
  *  extra_info()
  *     format up extra process information if selected
@@ -1355,6 +1423,7 @@
 
        return buf;
 }
+#endif
 
 /*
  *  handle_sig()
@@ -1488,8 +1557,10 @@
                        struct tm tm;
                        char when[10];
                        time_t now;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,14)
                        pid_t pid, ppid;
                        bool is_thread;
+#endif
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,14)
                        struct timeval tv;
Binary files old/forkstat-0.02.15/mascot/forkstat-icon.png and 
new/forkstat-0.02.16/mascot/forkstat-icon.png differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/forkstat-0.02.15/snap/snapcraft.yaml 
new/forkstat-0.02.16/snap/snapcraft.yaml
--- old/forkstat-0.02.15/snap/snapcraft.yaml    2020-07-04 12:17:09.000000000 
+0200
+++ new/forkstat-0.02.16/snap/snapcraft.yaml    2020-11-07 17:10:07.000000000 
+0100
@@ -1,17 +1,32 @@
 name: forkstat
-version: git
-version-script: |
-    echo $(git describe --tags)
 summary: process fork/exec/exit monitoring tool
 description: Forkstat monitors process fork(), exec() and exit() activity.  It 
is useful for monitoring system behaviour and to track down rogue processes 
that are spawning off processes and potentially abusing the system.
 confinement: strict
 type: app
 grade: stable
+assumes: [snapd2.45]
+base: core18
+adopt-info: forkstat
+
 
 parts:
     forkstat:
         plugin: make
         source: git://kernel.ubuntu.com/cking/forkstat
+        override-pull: |
+            snapcraftctl pull
+            description="$(git describe HEAD --tags)"
+            sha=$(echo $description | tr '-' ' ' | awk '{print $NF}')
+            version=${description%$sha}
+            commits=$(git log --oneline | wc -l)
+            date=$(date +'%Y%m%d')
+            if test "$description" = "$sha"
+            then
+                version="$description"
+            else
+                version=$(echo $version$date-$commits-$sha | cut -c1-32)
+            fi
+            snapcraftctl set-version "$version"
         build-packages:
             - gcc
             - make
_______________________________________________
openSUSE Commits mailing list -- [email protected]
To unsubscribe, email [email protected]
List Netiquette: https://en.opensuse.org/openSUSE:Mailing_list_netiquette
List Archives: 
https://lists.opensuse.org/archives/list/[email protected]

Reply via email to