diff -Nru extrace-0.6/debian/changelog extrace-0.7/debian/changelog --- extrace-0.6/debian/changelog 2018-08-19 11:27:54.000000000 +0000 +++ extrace-0.7/debian/changelog 2019-02-09 14:39:02.000000000 +0000 @@ -1,3 +1,13 @@ +extrace (0.7-1) unstable; urgency=medium + + * New upstream version (2010-02-08) + * debian/control + + Update the maintainer's email address + + Declare compliance with policy v4.3.0. + No change required + + -- Nicolas Braud-Santoni Sat, 09 Feb 2019 15:39:02 +0100 + extrace (0.6-1) unstable; urgency=medium * New upstream version (2018-07-19) diff -Nru extrace-0.6/debian/control extrace-0.7/debian/control --- extrace-0.6/debian/control 2018-08-19 11:27:54.000000000 +0000 +++ extrace-0.7/debian/control 2019-02-09 14:39:02.000000000 +0000 @@ -1,10 +1,10 @@ Source: extrace -Maintainer: Nicolas Braud-Santoni +Maintainer: Nicolas Braud-Santoni Section: utils Priority: optional Build-Depends: debhelper (>= 11) Rules-Requires-Root: no -Standards-Version: 4.1.5 +Standards-Version: 4.3.0 Homepage: https://github.com/chneukirchen/extrace Vcs-Browser: https://salsa.debian.org/debian/extrace Vcs-Git: https://salsa.debian.org/debian/extrace.git diff -Nru extrace-0.6/extrace.c extrace-0.7/extrace.c --- extrace-0.6/extrace.c 2018-07-19 17:25:39.000000000 +0000 +++ extrace-0.7/extrace.c 2019-02-08 17:39:30.000000000 +0000 @@ -15,7 +15,7 @@ * -q don't print exec() arguments * -u print user of process * - * Copyright (C) 2014-2018 Leah Neukirchen + * Copyright (C) 2014-2019 Leah Neukirchen * * hacked from sources of: */ @@ -366,8 +366,8 @@ fprintf(output, "%d", pid); if (show_exit) { putc('+', output); - strncpy(pid_db[i].cmdline, cmdline, CMDLINE_DB_MAX-1); - pid_db[i].cmdline[CMDLINE_DB_MAX-1] = 0; + snprintf(pid_db[i].cmdline, CMDLINE_DB_MAX, + "%s", cmdline); } if (show_user) { struct stat st; @@ -443,6 +443,29 @@ } } +static pid_t +parse_pid(char *s) +{ + pid_t pid; + char *end; + + errno = 0; + pid = strtol(s, &end, 10); + if (pid <= 0 || *end || errno != 0) { + fprintf(stderr, "extrace: %s: invalid process id\n", s); + exit(1); + } + + errno = 0; + kill(pid, 0); + if (errno == ESRCH) { + fprintf(stderr, "extrace: %s: no such process\n", s); + exit(1); + } + + return pid; +} + int main(int argc, char *argv[]) { @@ -465,7 +488,7 @@ case 'e': show_env = 1; break; case 'f': flat = 1; break; case 'l': full_path = 1; break; - case 'p': parent = atoi(optarg); break; + case 'p': parent = parse_pid(optarg); break; case 'q': show_args = 0; break; case 't': show_exit = 1; break; case 'o': @@ -564,6 +587,9 @@ (struct sockaddr *)&from_nla, &from_nla_len); if (from_nla.nl_pid != 0 || recv_len < 1) continue; + + if (cproc->what == PROC_EVENT_NONE) + continue; if (last_seq[cproc->cpu] && cmsg->seq != last_seq[cproc->cpu] + 1) diff -Nru extrace-0.6/LICENSE extrace-0.7/LICENSE --- extrace-0.6/LICENSE 2018-07-19 17:25:39.000000000 +0000 +++ extrace-0.7/LICENSE 2019-02-08 17:39:30.000000000 +0000 @@ -1,7 +1,7 @@ /* pwait - wait for processes to terminate * extrace - trace exec() calls system-wide * - * Copyright (C) 2014-2018 Leah Neukirchen + * Copyright (C) 2014-2019 Leah Neukirchen * * hacked from sources of: */ diff -Nru extrace-0.6/Makefile extrace-0.7/Makefile --- extrace-0.6/Makefile 2018-07-19 17:25:39.000000000 +0000 +++ extrace-0.7/Makefile 2019-02-08 17:39:30.000000000 +0000 @@ -1,16 +1,16 @@ ALL=extrace pwait -CFLAGS=-g -O2 -Wall -Wno-switch -Wextra -Wwrite-strings -pedantic -ansi +CFLAGS?=-g -O2 -Wall -Wno-switch -Wextra -Wwrite-strings -pedantic -ansi DESTDIR= -PREFIX=/usr/local +PREFIX?=/usr/local BINDIR=$(PREFIX)/bin MANDIR=$(PREFIX)/share/man all: $(ALL) -README: extrace.1 - mandoc -Tutf8 $< | col -bx >$@ +README: extrace.1 pwait.1 + mandoc -Tutf8 $^ | col -bx >$@ cap: $(ALL) sudo setcap cap_net_admin+ep extrace cap_net_admin+ep pwait diff -Nru extrace-0.6/NEWS.md extrace-0.7/NEWS.md --- extrace-0.6/NEWS.md 2018-07-19 17:25:39.000000000 +0000 +++ extrace-0.7/NEWS.md 2019-02-08 17:39:30.000000000 +0000 @@ -1,4 +1,8 @@ -## HEAD +## 0.7 (2019-02-08) + +* pwait: detect and warn for non-existing PID. +* extract: detect and error for non-existing PID in `-p`. +* Bug fixes. ## 0.6 (2018-06-19) diff -Nru extrace-0.6/pwait.1 extrace-0.7/pwait.1 --- extrace-0.6/pwait.1 2018-07-19 17:25:39.000000000 +0000 +++ extrace-0.7/pwait.1 2019-02-08 17:39:30.000000000 +0000 @@ -1,4 +1,4 @@ -.Dd June 13, 2016 +.Dd September 17, 2018 .Dt PWAIT 1 .Os .Sh NAME @@ -22,6 +22,8 @@ .El .Sh EXIT STATUS .Ex -std +.Pp +Invalid pids elicit a warning message but are otherwise ignored. .Sh ERRORS Check these prerequisites if you see this error: .Bd -literal -offset Ds diff -Nru extrace-0.6/pwait.c extrace-0.7/pwait.c --- extrace-0.6/pwait.c 2018-07-19 17:25:39.000000000 +0000 +++ extrace-0.7/pwait.c 2019-02-08 17:39:30.000000000 +0000 @@ -7,7 +7,7 @@ * -v Print the exit status when each process terminates. * -c Check for PIDs to exit successfully, else return 111. * - * Copyright (C) 2014-2017 Leah Neukirchen + * Copyright (C) 2014-2019 Leah Neukirchen * * hacked from sources of: */ @@ -146,7 +146,7 @@ enum proc_cn_mcast_op *mcop_msg; size_t recv_len = 0; int opt; - int n; + int n, m; pid_t *pids; pid_t pid; char *end; @@ -173,23 +173,27 @@ pids = calloc(argc, sizeof (pid_t)); if (!pids) { - perror("calloc"); + perror("pwait: calloc"); exit(1); } - for (n = 0; n < argc; n++) { + for (n = m = 0; n < argc; n++) { errno = 0; pid = strtol(argv[n], &end, 10); - if (pid < 0 || *end != '\0' || errno != 0) { - fprintf(stderr, "%s: bad process id\n", argv[n]); + if (pid <= 0 || *end || errno != 0) { + fprintf(stderr, "pwait: %s: invalid process id\n", + argv[n]); continue; } - pids[n] = pid; + pids[m++] = pid; } + if (m == 0) + exit(1); + sk_nl = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_CONNECTOR); if (sk_nl == -1) { - perror("socket sk_nl error"); + perror("pwait: socket sk_nl error"); exit(1); } @@ -202,7 +206,7 @@ kern_nla.nl_pid = 1; if (bind(sk_nl, (struct sockaddr *)&my_nla, sizeof my_nla) == -1) { - perror("binding sk_nl error"); + perror("pwait: binding sk_nl error"); goto close_and_exit; } nl_hdr = (struct nlmsghdr *)buff; @@ -225,13 +229,29 @@ cn_hdr->len = sizeof (enum proc_cn_mcast_op); if (send(sk_nl, nl_hdr, nl_hdr->nlmsg_len, 0) != nl_hdr->nlmsg_len) { - fprintf(stderr, "failed to send proc connector mcast ctl op!\n"); + fprintf(stderr, + "pwait: failed to send proc connector mcast ctl op!\n"); goto close_and_exit; } if (*mcop_msg == PROC_CN_MCAST_IGNORE) goto close_and_exit; + quit = 1; + for (n = 0; n < m; n++) { + errno = 0; + kill(pids[n], 0); + if (errno == ESRCH) { + fprintf(stderr, "pwait: %d: no such process\n", + pids[n]); + pids[n] = 0; + continue; + } + quit = 0; + } + if (quit) + exit(1); + signal(SIGINT, sigint); rc = 0; @@ -261,7 +281,7 @@ pid_t pid = ev->event_data.exit.process_pid; seen = 0; - for (n = 0; n < argc; n++) + for (n = 0; n < m; n++) if (pids[n] == pid) { if (verbose && !seen) display(pid, status); @@ -280,12 +300,13 @@ } quit = 1; - for (n = 0; n < argc; n++) + for (n = 0; n < m; n++) if (pids[n] != 0) quit = 0; } close_and_exit: close(sk_nl); + free(pids); return rc; } diff -Nru extrace-0.6/README extrace-0.7/README --- extrace-0.6/README 2018-07-19 17:25:39.000000000 +0000 +++ extrace-0.7/README 2019-02-08 17:39:30.000000000 +0000 @@ -71,3 +71,53 @@ extrace is licensed under the terms of the GPLv2. Void Linux June 19, 2018 Void Linux + +------------------------------------------------------------------------------ + +PWAIT(1) General Commands Manual PWAIT(1) + +NAME + pwait – wait for processes to terminate + +SYNOPSIS + pwait [-v] [-c] pid ... + +DESCRIPTION + pwait waits until each of the given processes has terminated. + + The options are as follows: + + -v Print the exit status when each process terminates. + + -c Return 111 if any process exited non-successfully. + +EXIT STATUS + The pwait utility exits 0 on success, and >0 if an error occurs. + + Invalid pids elicit a warning message but are otherwise ignored. + +ERRORS + Check these prerequisites if you see this error: + + binding sk_nl error: Operation not permitted + + pwait requires special permissions to run, either root or the Linux + CAP_NET_ADMIN capability. + + pwait only works on Linux kernels with the kernel options + + CONFIG_CONNECTOR=y + CONFIG_PROC_EVENTS=y + +SEE ALSO + extrace(1), kill(1), pkill(1), ps(1), wait(1) + +AUTHORS + Leah Neukirchen + + Built upon code from FreeBSD pwait written by Jilles Tjoelker. + +LICENSE + pwait is licensed under the terms of the GPLv2. + +Void Linux September 17, 2018 Void Linux