Hello community,

here is the log from the commit of package forkstat for openSUSE:Leap:15.2 
checked in at 2020-03-10 17:15:17
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Leap:15.2/forkstat (Old)
 and      /work/SRC/openSUSE:Leap:15.2/.forkstat.new.26092 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "forkstat"

Tue Mar 10 17:15:17 2020 rev:20 rq:783400 version:0.02.14

Changes:
--------
--- /work/SRC/openSUSE:Leap:15.2/forkstat/forkstat.changes      2020-01-17 
12:01:24.400503164 +0100
+++ /work/SRC/openSUSE:Leap:15.2/.forkstat.new.26092/forkstat.changes   
2020-03-10 17:15:24.093453520 +0100
@@ -1,0 +2,18 @@
+Sun Mar  8 10:41:16 UTC 2020 - Martin Hauke <mar...@gmx.de>
+
+- Drop SLE12 compat ifdef
+
+-------------------------------------------------------------------
+Sat Feb 29 11:33:06 UTC 2020 - Martin Hauke <mar...@gmx.de>
+
+- Update to version 0.02.14
+  * Add effictive user id (EUID) for -x option
+- Supplement against bash-completion, not bash
+
+-------------------------------------------------------------------
+Wed Feb 26 13:39:08 UTC 2020 - Martin Hauke <mar...@gmx.de>
+
+- Update to version 0.02.13
+  * Add bash completion
+
+-------------------------------------------------------------------

Old:
----
  forkstat-0.02.12.tar.xz

New:
----
  forkstat-0.02.14.tar.xz

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

Other differences:
------------------
++++++ forkstat.spec ++++++
--- /var/tmp/diff_new_pack.BQbGiw/_old  2020-03-10 17:15:25.149453849 +0100
+++ /var/tmp/diff_new_pack.BQbGiw/_new  2020-03-10 17:15:25.177453858 +0100
@@ -1,7 +1,7 @@
 #
 # spec file for package forkstat
 #
-# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2020 SUSE LLC
 # Copyright (c) 2017, Martin Hauke <mar...@gmx.de>
 #
 # All modifications and additions to the file contributed by third parties
@@ -18,7 +18,7 @@
 
 
 Name:           forkstat
-Version:        0.02.12
+Version:        0.02.14
 Release:        0
 Summary:        Process fork/exec/exit monitoring tool
 License:        GPL-2.0-or-later
@@ -31,6 +31,17 @@
 monitoring system behaviour and to track down rogue processes that are spawning
 off processes and potentially abusing the system.
 
+%package bash-completion
+Summary:        Bash Completion for %{name}
+Group:          System/Benchmark
+Requires:       %{name} = %{version}
+Requires:       bash-completion
+Supplements:    packageand(forkstat:bash-completion)
+BuildArch:      noarch
+
+%description bash-completion
+Bash completion script for %{name}.
+
 %prep
 %setup -q
 
@@ -46,4 +57,7 @@
 %{_bindir}/forkstat
 %{_mandir}/man8/forkstat.8%{?ext_man}
 
+%files bash-completion
+%{_datadir}/bash-completion/completions/%{name}
+
 %changelog

++++++ forkstat-0.02.12.tar.xz -> forkstat-0.02.14.tar.xz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/forkstat-0.02.12/Makefile 
new/forkstat-0.02.14/Makefile
--- old/forkstat-0.02.12/Makefile       2019-12-13 21:00:52.000000000 +0100
+++ new/forkstat-0.02.14/Makefile       2020-02-28 16:02:57.000000000 +0100
@@ -1,5 +1,5 @@
 #
-# Copyright (C) 2014-2019 Canonical, Ltd.
+# Copyright (C) 2014-2020 Canonical, Ltd.
 #
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
@@ -16,7 +16,7 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 
USA.
 #
 
-VERSION=0.02.12
+VERSION=0.02.14
 #
 # Version "Perspicacious Process Peeker"
 #
@@ -36,6 +36,7 @@
 
 BINDIR=/usr/bin
 MANDIR=/usr/share/man/man8
+BASHDIR=/usr/share/bash-completion/completions
 
 forkstat: forkstat.o
        $(CC) $(CPPFLAGS) $(CFLAGS) $< -o $@ $(LDFLAGS)
@@ -48,7 +49,7 @@
        rm -rf forkstat-$(VERSION)
        mkdir forkstat-$(VERSION)
        cp -rp Makefile forkstat.c forkstat.8 mascot COPYING \
-               snap .travis.yml forkstat-$(VERSION)
+               snap .travis.yml bash-completion forkstat-$(VERSION)
        tar -Jcf forkstat-$(VERSION).tar.xz forkstat-$(VERSION)
        rm -rf forkstat-$(VERSION)
 
@@ -68,3 +69,5 @@
        cp forkstat ${DESTDIR}${BINDIR}
        mkdir -p ${DESTDIR}${MANDIR}
        cp forkstat.8.gz ${DESTDIR}${MANDIR}
+       mkdir -p ${DESTDIR}${BASHDIR}
+       cp bash-completion/forkstat  ${DESTDIR}${BASHDIR}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/forkstat-0.02.12/bash-completion/forkstat 
new/forkstat-0.02.14/bash-completion/forkstat
--- old/forkstat-0.02.12/bash-completion/forkstat       1970-01-01 
01:00:00.000000000 +0100
+++ new/forkstat-0.02.14/bash-completion/forkstat       2020-02-28 
16:02:57.000000000 +0100
@@ -0,0 +1,35 @@
+# forkstat tab completion for bash.
+#
+# Copyright (C) 2020 Canonical
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 
USA.
+
+_forkstat()
+{
+       local cur prev words cword
+       _init_completion || return
+
+       case "$cur" in
+                -*)
+                        OPTS="-c -d -D -e -E -g -h -l -r -s -S -q -x -X"
+                        COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+                        return 0
+                        ;;
+        esac
+       return 0
+}
+
+# load the completion
+complete -F _forkstat forkstat
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/forkstat-0.02.12/forkstat.c 
new/forkstat-0.02.14/forkstat.c
--- old/forkstat-0.02.12/forkstat.c     2019-12-13 21:00:52.000000000 +0100
+++ new/forkstat-0.02.14/forkstat.c     2020-02-28 16:02:57.000000000 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014-2019 Canonical Ltd.
+ * Copyright (C) 2014-2020 Canonical Ltd.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -103,6 +103,7 @@
        pid_t   pid;            /* Process ID */
        uid_t   uid;            /* User ID */
        gid_t   gid;            /* GUID */
+       uid_t   euid;           /* EUID */
        struct timeval start;   /* time when process started */
        bool    kernel_thread;  /* true if a kernel thread */
 } proc_info_t;
@@ -319,21 +320,25 @@
        static char buf[12];
        const size_t hash = uid % MAX_UIDS;
        uid_name_info_t *uni = uid_name_info[hash];
-       char *name;
+       char *name = NULL;
 
-       /*
-        *  Try and find it in cache first
-        */
-       while (uni) {
-               if (uni->uid == uid)
-                       return uni->name;
-               uni = uni->next;
+       if (uid != NULL_UID) {
+               /*
+                *  Try and find it in cache first
+                */
+               while (uni) {
+                       if (uni->uid == uid)
+                               return uni->name;
+                       uni = uni->next;
+               }
+
+               pwd = getpwuid(uid);
+               if (pwd)
+                       name = pwd->pw_name;
        }
 
-       pwd = getpwuid(uid);
-       if (pwd) {
-               name = pwd->pw_name;
-       } else {
+       /* Unknow UID, use numeric instead */
+       if (!name) {
                (void)snprintf(buf, sizeof(buf), "%d", uid);
                name = buf;
        }
@@ -522,43 +527,70 @@
 
 /*
  *  get_extra()
- *     quick and dirty way to get UID and GID from a PID,
- *     note that this does not cater of changes
- *     because of use of an effective ID.
+ *     quick and dirty way to get UID, EUID and GID from a PID
  */
 static void get_extra(const pid_t pid, proc_info_t * const info)
 {
-       ssize_t ret;
        long dev;
-       int fd;
+       FILE *fp;
        char path[PATH_MAX];
-       char buffer[4096];
+       char buffer[1024];
        struct stat buf;
 
        info->uid = NULL_UID;
        info->gid = NULL_GID;
+       info->euid = NULL_UID;
        info->tty = NULL_TTY;
 
        if (!(opt_flags & OPT_EXTRA))
                return;
 
-       (void)snprintf(path, sizeof(path), "/proc/%u/stat", pid);
-       fd = open(path, O_RDONLY);
-       if (fd < 0)
+       (void)snprintf(path, sizeof(path), "/proc/%u/status", pid);
+       fp = fopen(path, "r");
+       if (!fp)
                return;
 
-       if (fstat(fd, &buf) == 0) {
-               info->uid = buf.st_uid;
-               info->gid = buf.st_gid;
+       (void)memset(buffer, 0, sizeof(buffer));
+       while (fgets(buffer, sizeof(buffer) - 1, fp)) {
+               int gid, uid, euid;
+
+               if (!strncmp(buffer, "Uid:", 4)) {
+                       if (sscanf(buffer + 4, "%d %d", &uid, &euid) == 2) {
+                               info->uid = uid;
+                               info->euid = euid;
+                       }
+               }
+               if (!strncmp(buffer, "Gid:", 4)) {
+                       if (sscanf(buffer + 4, "%d", &gid) == 1) {
+                               info->gid = gid;
+                       }
+               }
+               if ((info->uid != NULL_UID) &&
+                   (info->euid != NULL_UID) &&
+                   (info->gid != NULL_GID))
+                       break;
        }
+       (void)fclose(fp);
 
-       ret = read(fd, buffer, sizeof(buffer));
-       (void)close(fd);
-       if (ret < 0)
+       (void)snprintf(path, sizeof(path), "/proc/%u/stat", pid);
+       fp = fopen(path, "r");
+       if (!fp)
                return;
 
-       if (sscanf(buffer, "%*d %*s %*s %*d %*d %*d %ld", &dev) == 1)
+       /*
+        *  Failed to parse /proc/$PID/status? then at least get
+        *  some info by stat'ing /proc/$PID/stat
+        */
+       if ((info->uid == NULL_UID) || (info->gid == NULL_GID)) {
+               if (fstat(fileno(fp), &buf) == 0) {
+                       info->uid = buf.st_uid;
+                       info->gid = buf.st_gid;
+               }
+       }
+
+       if (fscanf(fp, "%*d %*s %*s %*d %*d %*d %ld", &dev) == 1)
                info->tty = (dev_t)dev;
+       (void)fclose(fp);
 }
 
 /*
@@ -786,7 +818,7 @@
 
        (void)printf("Time     Event %*.*s %s%sInfo   Duration Process\n",
                pid_size, pid_size, "PID",
-               (opt_flags & OPT_EXTRA) ? "   UID TTY    " : "",
+               (opt_flags & OPT_EXTRA) ? "    UID    EUID TTY    " : "",
                (opt_flags & OPT_GLYPH) ? " " : "");
 }
 
@@ -1138,6 +1170,7 @@
                        info->pid = NULL_PID;
                        info->uid = NULL_UID;
                        info->gid = NULL_GID;
+                       info->euid = NULL_UID;
                        free_proc_comm(info->cmdline);
                        info->cmdline = NULL;
                        return;
@@ -1304,15 +1337,16 @@
  */
 static char *extra_info(const uid_t uid)
 {
-       static char buf[20];
+       static char buf[28];
 
        *buf = '\0';
        if (opt_flags & OPT_EXTRA) {
                const proc_info_t *info = proc_info_get(uid);
 
                if (info && info->uid != NULL_UID)
-                       (void)snprintf(buf, sizeof(buf), "%6s %-6.6s ",
+                       (void)snprintf(buf, sizeof(buf), "%7.7s %7.7s %6.6s ",
                                get_username(info->uid),
+                               get_username(info->euid),
                                get_tty(info->tty));
                else
                        (void)snprintf(buf, sizeof(buf), "%14s", "");


Reply via email to