Hello community,

here is the log from the commit of package reptyr for openSUSE:Factory checked 
in at 2020-10-12 13:59:15
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/reptyr (Old)
 and      /work/SRC/openSUSE:Factory/.reptyr.new.3486 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "reptyr"

Mon Oct 12 13:59:15 2020 rev:12 rq:841056 version:0.8.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/reptyr/reptyr.changes    2018-12-12 
17:28:03.846908871 +0100
+++ /work/SRC/openSUSE:Factory/.reptyr.new.3486/reptyr.changes  2020-10-12 
14:00:04.134234964 +0200
@@ -1,0 +2,8 @@
+Sun Oct 11 16:20:16 UTC 2020 - Mia Herkt <m...@0x0.st>
+
+- spec-cleaner
+- Update to version 0.8.0
+  * Resolve a number of bugs in FreeBSD support
+  * Implement reptyr -T support for FreeBSD
+
+-------------------------------------------------------------------

Old:
----
  reptyr-0.7.0.tar.gz

New:
----
  reptyr-0.8.0.tar.gz

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

Other differences:
------------------
++++++ reptyr.spec ++++++
--- /var/tmp/diff_new_pack.bDKamC/_old  2020-10-12 14:00:04.722235210 +0200
+++ /var/tmp/diff_new_pack.bDKamC/_new  2020-10-12 14:00:04.722235210 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package reptyr
 #
-# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2020 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -17,12 +17,12 @@
 
 
 Name:           reptyr
-Version:        0.7.0
+Version:        0.8.0
 Release:        0
 Summary:        A tool for "re-ptying" programs
 License:        MIT
 Group:          System/Console
-URL:            http://github.com/nelhage/reptyr
+URL:            https://github.com/nelhage/reptyr
 Source:         
https://github.com/nelhage/reptyr/archive/%{name}-%{version}.tar.gz
 BuildRequires:  bash-completion
 BuildRequires:  gcc
@@ -40,7 +40,7 @@
 %build
 export CFLAGS="%{optflags}"
 export CXXFLAGS="%{optflags}"
-make %{?_smp_mflags}
+%make_build
 
 %install
 %make_install PREFIX="%{_prefix}" 
BASHCOMPDIR="%{_datadir}/bash-completion/completions"

++++++ reptyr-0.7.0.tar.gz -> reptyr-0.8.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/reptyr-reptyr-0.7.0/.circleci/config.yml 
new/reptyr-reptyr-0.8.0/.circleci/config.yml
--- old/reptyr-reptyr-0.7.0/.circleci/config.yml        1970-01-01 
01:00:00.000000000 +0100
+++ new/reptyr-reptyr-0.8.0/.circleci/config.yml        2020-09-29 
23:29:59.000000000 +0200
@@ -0,0 +1,15 @@
+version: 2
+jobs:
+  build:
+    docker:
+      - image: debian:stretch
+
+    steps:
+      - checkout
+
+      - run: apt-get update && apt-get -y install gcc-multilib libcap-dev gcc 
python python-virtualenv python-dev make
+      - run: virtualenv venv
+      - run: venv/bin/pip install -r test/requirements.txt
+      - run: . venv/bin/activate && make test
+      - run: make clean
+      - run: . venv/bin/activate && env CFLAGS=-m32 LDFLAGS=-m32 
NO_TEST_STEAL=1 make test
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/reptyr-reptyr-0.7.0/.cirrus.yml 
new/reptyr-reptyr-0.8.0/.cirrus.yml
--- old/reptyr-reptyr-0.7.0/.cirrus.yml 1970-01-01 01:00:00.000000000 +0100
+++ new/reptyr-reptyr-0.8.0/.cirrus.yml 2020-09-29 23:29:59.000000000 +0200
@@ -0,0 +1,35 @@
+env:
+  CIRRUS_CLONE_DEPTH: 1
+
+freebsd_12_task:
+  freebsd_instance:
+    image: freebsd-12-1-release-amd64
+  install_script:
+    pkg install -y gmake py27-pexpect
+  build_script:
+    gmake
+  test_script:
+    - env NO_TEST_BASIC=yes gmake test PYTHON_CMD=python2.7
+
+linux_gcc_py2_task:
+  container:
+    image: gcc:latest
+  install_script:
+    - apt-get update
+    - apt-get install -y python-prctl python-pexpect
+  build_script:
+    - make
+  test_script:
+    - make test
+
+linux_gcc_py3_task:
+  container:
+    image: gcc:latest
+  install_script:
+    - apt-get update
+    - apt-get install -y python3-prctl python3-pexpect
+  build_script:
+    - make
+  test_script:
+    - make test PYTHON_CMD=python3
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/reptyr-reptyr-0.7.0/.gitignore 
new/reptyr-reptyr-0.8.0/.gitignore
--- old/reptyr-reptyr-0.7.0/.gitignore  2018-12-05 04:48:42.000000000 +0100
+++ new/reptyr-reptyr-0.8.0/.gitignore  2020-09-29 23:29:59.000000000 +0200
@@ -1,4 +1,5 @@
 reptyr
 ptrace
 *.o
+*.d
 /.vagrant/
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/reptyr-reptyr-0.7.0/.travis.yml 
new/reptyr-reptyr-0.8.0/.travis.yml
--- old/reptyr-reptyr-0.7.0/.travis.yml 2018-12-05 04:48:42.000000000 +0100
+++ new/reptyr-reptyr-0.8.0/.travis.yml 2020-09-29 23:29:59.000000000 +0200
@@ -1,15 +1,14 @@
 script: make test
-sudo: required
 language: python
 python:
-  - "2.7"
+  - "3.7"
 install:
-  - env -u CFLAGS -u LDFLAGS pip install -r test/requirements.txt
+  - pip install -r test/requirements.txt
+arch:
+  - arm64
 addons:
   apt:
     packages:
-      - gcc-multilib
       - libcap-dev
 env:
-  - CFLAGS=-m32 LDFLAGS=-m32 DISABLE_TESTS=1
-  - CFLAGS=-m64 LDFLAGS=-m64
+  - PYTHON_CMD=python3
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/reptyr-reptyr-0.7.0/ChangeLog 
new/reptyr-reptyr-0.8.0/ChangeLog
--- old/reptyr-reptyr-0.7.0/ChangeLog   2018-12-05 04:48:42.000000000 +0100
+++ new/reptyr-reptyr-0.8.0/ChangeLog   2020-09-29 23:29:59.000000000 +0200
@@ -1,3 +1,7 @@
+* 0.8.0 (Sep 29, 2020)
+ - Resolve a number of bugs in FreeBSD support
+ - Implement reptyr -T support for FreeBSD
+
 * 0.7.0 (Dec 05, 2018)
  - Add bash completion support
  - Fix compilation with musl libc, CentOS, or GCC 7+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/reptyr-reptyr-0.7.0/Makefile 
new/reptyr-reptyr-0.8.0/Makefile
--- old/reptyr-reptyr-0.7.0/Makefile    2018-12-05 04:48:42.000000000 +0100
+++ new/reptyr-reptyr-0.8.0/Makefile    2020-09-29 23:29:59.000000000 +0200
@@ -1,5 +1,6 @@
-override CFLAGS := -Wall -Werror -D_GNU_SOURCE -g $(CFLAGS)
+override CFLAGS := -MD -Wall -Werror -D_GNU_SOURCE -g $(CFLAGS)
 OBJS=reptyr.o reallocarray.o attach.o
+DEPS=$(wildcard *.d platform/*/*.d)
 UNAME_S := $(shell uname -s)
 ifeq ($(UNAME_S),Linux)
        OBJS += platform/linux/linux_ptrace.o platform/linux/linux.o
@@ -17,6 +18,7 @@
 MANDIR=$(PREFIX)/share/man
 
 PKG_CONFIG ?= pkg-config
+PYTHON_CMD ?= python2
 
 all: reptyr
 
@@ -24,8 +26,8 @@
 
 ifeq ($(DISABLE_TESTS),)
 test: reptyr test/victim PHONY
-       python2 test/basic.py
-       python2 test/tty-steal.py
+       $(PYTHON_CMD) test/basic.py
+       $(PYTHON_CMD) test/tty-steal.py
 else
 test: all
 endif
@@ -36,12 +38,8 @@
 test/victim: override CFLAGS := $(VICTIM_CFLAGS)
 test/victim: override LDFLAGS := $(VICTIM_LDFLAGS)
 
-attach.o: reptyr.h ptrace.h
-reptyr.o: reptyr.h reallocarray.h
-ptrace.o: ptrace.h platform/platform.h $(wildcard platform/*/arch/*.h)
-
 clean:
-       rm -f reptyr $(OBJS) test/victim.o test/victim
+       rm -f reptyr $(OBJS) test/victim.o test/victim $(DEPS)
 
 BASHCOMPDIR ?= $(shell $(PKG_CONFIG) --variable=completionsdir bash-completion 
2>/dev/null)
 
@@ -58,3 +56,6 @@
        install -m 644 reptyr.bash $(DESTDIR)$$bashcompdir/reptyr
 
 .PHONY: PHONY
+
+# Pull-in dependencies generated by -MD
+-include $(OBJS:.o=.d)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/reptyr-reptyr-0.7.0/attach.c 
new/reptyr-reptyr-0.8.0/attach.c
--- old/reptyr-reptyr-0.7.0/attach.c    2018-12-05 04:48:42.000000000 +0100
+++ new/reptyr-reptyr-0.8.0/attach.c    2020-09-29 23:29:59.000000000 +0200
@@ -117,8 +117,8 @@
 
 out_kill:
     kill(dummy.pid, SIGKILL);
-    ptrace_wait(&dummy);
     ptrace_detach_child(&dummy);
+    ptrace_wait(&dummy);
     do_syscall(child, wait4, dummy.pid, 0, WNOHANG, 0, 0, 0);
     return err;
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/reptyr-reptyr-0.7.0/platform/freebsd/freebsd.c 
new/reptyr-reptyr-0.8.0/platform/freebsd/freebsd.c
--- old/reptyr-reptyr-0.7.0/platform/freebsd/freebsd.c  2018-12-05 
04:48:42.000000000 +0100
+++ new/reptyr-reptyr-0.8.0/platform/freebsd/freebsd.c  2020-09-29 
23:29:59.000000000 +0200
@@ -39,6 +39,7 @@
     pg = getpgid(target);
 
     procstat = procstat_open_sysctl();
+    cnt = 0;
     kp = procstat_getprocs(procstat, KERN_PROC_PGRP, pg, &cnt);
     procstat_freeprocs(procstat, kp);
     procstat_close(procstat);
@@ -54,10 +55,11 @@
 int check_proc_stopped(pid_t pid, int fd) {
     struct procstat *procstat;
     struct kinfo_proc *kp;
-    int state;
+    int state = 0;
     unsigned int cnt;
 
     procstat = procstat_open_sysctl();
+    cnt = 0;
     kp = procstat_getprocs(procstat, KERN_PROC_PID, pid, &cnt);
 
     if (cnt > 0)
@@ -79,6 +81,7 @@
 struct filestat_list* get_procfiles(pid_t pid, struct kinfo_proc **kp, struct 
procstat **procstat, unsigned int *cnt) {
     int mflg = 0; // include mmapped files
     (*procstat) = procstat_open_sysctl();
+    *cnt = 0;
     (*kp) = procstat_getprocs(*procstat, KERN_PROC_PID, pid, cnt);
     if ((*kp) == NULL || *cnt < 1)
         return NULL;
@@ -107,7 +110,7 @@
                 goto out;
             }
 
-            if (vn.vn_dev == kp->ki_tdev) {
+            if (vn.vn_dev == kp->ki_tdev && fst->fs_fd >= 0) {
                 if (fd_array_push(&fds, fst->fs_fd) != 0) {
                     error("Unable to allocate memory for fd array.");
                     goto out;
@@ -137,6 +140,7 @@
     unsigned int cnt;
 
     procstat = procstat_open_sysctl();
+    cnt = 0;
     kp = procstat_getprocs(procstat, KERN_PROC_PID, steal->target_stat.sid, 
&cnt);
 
     if (kp && cnt > 0)
@@ -145,6 +149,39 @@
     procstat_freeprocs(procstat, kp);
     procstat_close(procstat);
 
+    return (cnt != 0 ? 0 : 1);
+}
+
+int fill_proc_stat(struct steal_pty_state *steal, struct kinfo_proc *kp) {
+    struct proc_stat *ps = &steal->target_stat;
+
+    if (strlcpy(ps->comm, kp->ki_comm, sizeof(ps->comm)) >= sizeof(ps->comm))
+      return ENOMEM;
+    ps->pid = kp->ki_pid;
+    ps->ppid = kp->ki_ppid;
+    ps->sid = kp->ki_sid;
+    ps->pgid = kp->ki_pgid;
+    ps->ctty = kp->ki_tdev;
+
+    return 0;
+}
+
+int grab_uid(pid_t pid, uid_t *out) {
+    struct procstat *procstat;
+    struct kinfo_proc *kp;
+    unsigned int cnt;
+
+    procstat = procstat_open_sysctl();
+    cnt = 0;
+    kp = procstat_getprocs(procstat, KERN_PROC_PID, pid, &cnt);
+
+    if (kp && cnt > 0)
+        *out = kp->ki_uid;
+    else
+        return ESRCH;
+    procstat_freeprocs(procstat, kp);
+    procstat_close(procstat);
+
     return 0;
 }
 
@@ -155,6 +192,7 @@
     int err = 0;
 
     procstat = procstat_open_sysctl();
+    cnt = 0;
     kp = procstat_getprocs(procstat, KERN_PROC_PID, target, &cnt);
     if (kp == NULL || cnt < 1)
         goto done;
@@ -165,9 +203,14 @@
         goto done;
     }
 
+    if ((err = fill_proc_stat(steal, kp)))
+        return err;
+
     if ((err = find_terminal_emulator(steal)))
         return err;
 
+    if ((err = grab_uid(steal->emulator_pid, &steal->emulator_uid)))
+        return err;
 done:
     procstat_freeprocs(procstat, kp);
     procstat_close(procstat);
@@ -175,8 +218,43 @@
 }
 
 int find_master_fd(struct steal_pty_state *steal) {
-    error("How do I find master in FreeBSD? FIXME.");
-    return EINVAL;
+    char errbuf[_POSIX2_LINE_MAX];
+    struct filestat *fst;
+    struct filestat_list *head;
+    struct procstat *procstat;
+    struct kinfo_proc *kp;
+    struct ptsstat pts;
+    unsigned int cnt;
+    int err;
+
+    head = get_procfiles(steal->child.pid, &kp, &procstat, &cnt);
+
+    STAILQ_FOREACH(fst, head, next) {
+        if (fst->fs_type != PS_FST_TYPE_PTS)
+            continue;
+
+        err = procstat_get_pts_info(procstat, fst, &pts, errbuf);
+        if (err != 0) {
+            error("error discovering fd=%d", fst->fs_fd);
+            continue;
+        }
+
+        if (pts.dev != steal->target_stat.ctty)
+            continue;
+
+        if (fd_array_push(&steal->master_fds, fst->fs_fd) != 0) {
+            error("unable to allocate memory for fd array");
+            return ENOMEM;
+        }
+    }
+
+    procstat_freefiles(procstat, head);
+    procstat_freeprocs(procstat, kp);
+    procstat_close(procstat);
+    debug("Found %d master tty fds in child %d.", steal->master_fds.n, 
steal->child.pid);
+    if (steal->master_fds.n == 0)
+        return ESRCH;
+    return 0;
 }
 
 int get_pt() {
@@ -228,6 +306,7 @@
     int err;
 
     procstat = procstat_open_sysctl();
+    cnt = 0;
     kp = procstat_getprocs(procstat, KERN_PROC_PGRP, from, &cnt);
 
     for (i = 0; i < cnt; i++) {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/reptyr-reptyr-0.7.0/platform/freebsd/freebsd_ptrace.c 
new/reptyr-reptyr-0.8.0/platform/freebsd/freebsd_ptrace.c
--- old/reptyr-reptyr-0.7.0/platform/freebsd/freebsd_ptrace.c   2018-12-05 
04:48:42.000000000 +0100
+++ new/reptyr-reptyr-0.8.0/platform/freebsd/freebsd_ptrace.c   2020-09-29 
23:29:59.000000000 +0200
@@ -220,6 +220,9 @@
                                     unsigned long p0, unsigned long p1,
                                     unsigned long p2, unsigned long p3,
                                     unsigned long p4, unsigned long p5) {
+#ifdef PT_GET_SC_RET
+    struct ptrace_sc_ret psr;
+#endif
     unsigned long rv;
     if (ptrace_advance_to_state(child, ptrace_at_syscall) < 0)
         return -1;
@@ -240,10 +243,28 @@
     if (ptrace_advance_to_state(child, ptrace_after_syscall) < 0)
         return -1;
 
+#ifndef PT_GET_SC_RET
+    /*
+     * In case of an error, this is technically incorrect.  FreeBSD, on most
+     * architectures, stores the return value in this register as expected and
+     * sets a separate bit to indicate if this an error or not -- contrary to
+     * the Linux convention of negative values indicating an error, positive
+     * values otherwise.  This should switch to PT_GET_SC_RET unconditionally
+     * as it makes its way into all supported releases.
+     */
     rv = arch_get_register(child, personality(child)->syscall_rv);
+
     if (child->error)
         return -1;
+#else
+    if (ptrace_command(child, PT_GET_SC_RET, &psr, sizeof(psr)) < 0)
+        return -1;
 
+    if (psr.sr_error != 0)
+        rv = -psr.sr_error;
+    else
+        rv = psr.sr_retval[0];
+#endif
     setreg(reg_ip, *(unsigned long*)((void*)&child->regs +
                                      personality(child)->reg_ip));
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/reptyr-reptyr-0.7.0/platform/linux/arch/aarch64.h 
new/reptyr-reptyr-0.8.0/platform/linux/arch/aarch64.h
--- old/reptyr-reptyr-0.7.0/platform/linux/arch/aarch64.h       2018-12-05 
04:48:42.000000000 +0100
+++ new/reptyr-reptyr-0.8.0/platform/linux/arch/aarch64.h       2020-09-29 
23:29:59.000000000 +0200
@@ -19,6 +19,11 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+
+#ifndef NT_ARM_SYSTEM_CALL
+#define NT_ARM_SYSTEM_CALL     0x404   /* ARM system call number */
+#endif
+
 static struct ptrace_personality arch_personality[1] = {
     {
         offsetof(struct user_regs_struct, regs[0]),
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/reptyr-reptyr-0.7.0/ptrace.h 
new/reptyr-reptyr-0.8.0/ptrace.h
--- old/reptyr-reptyr-0.7.0/ptrace.h    2018-12-05 04:48:42.000000000 +0100
+++ new/reptyr-reptyr-0.8.0/ptrace.h    2020-09-29 23:29:59.000000000 +0200
@@ -22,6 +22,9 @@
 #ifndef PTRACE_H
 #define PTRACE_H
 
+#ifdef __powerpc__
+#include <asm/ptrace.h>
+#endif
 #include <sys/ptrace.h>
 #include <sys/types.h>
 #include <sys/user.h>
@@ -44,6 +47,12 @@
 #ifndef PTRACE_GETEVENTMSG
 #define PTRACE_GETEVENTMSG  0x4201
 #endif
+#ifndef PTRACE_GETREGSET
+#define PTRACE_GETREGSET  0x4204
+#endif
+#ifndef PTRACE_SETREGSET
+#define PTRACE_SETREGSET  0x4205
+#endif
 
 enum child_state {
     ptrace_detached = 0,
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/reptyr-reptyr-0.7.0/reptyr.h 
new/reptyr-reptyr-0.8.0/reptyr.h
--- old/reptyr-reptyr-0.7.0/reptyr.h    2018-12-05 04:48:42.000000000 +0100
+++ new/reptyr-reptyr-0.8.0/reptyr.h    2020-09-29 23:29:59.000000000 +0200
@@ -20,7 +20,7 @@
  * THE SOFTWARE.
  */
 
-#define REPTYR_VERSION "0.7.0"
+#define REPTYR_VERSION "0.8.0"
 
 #define assert_nonzero(expr) ({                         \
             typeof(expr) __val = expr;                  \
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/reptyr-reptyr-0.7.0/test/.gitignore 
new/reptyr-reptyr-0.8.0/test/.gitignore
--- old/reptyr-reptyr-0.7.0/test/.gitignore     2018-12-05 04:48:42.000000000 
+0100
+++ new/reptyr-reptyr-0.8.0/test/.gitignore     2020-09-29 23:29:59.000000000 
+0200
@@ -1,2 +1,3 @@
 victim.o
 victim
+*.pyc
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/reptyr-reptyr-0.7.0/test/basic.py 
new/reptyr-reptyr-0.8.0/test/basic.py
--- old/reptyr-reptyr-0.7.0/test/basic.py       2018-12-05 04:48:42.000000000 
+0100
+++ new/reptyr-reptyr-0.8.0/test/basic.py       2020-09-29 23:29:59.000000000 
+0200
@@ -1,19 +1,30 @@
+import os
 import pexpect
 import sys
 
+from util import expect_eof
+
+if os.getenv("NO_TEST_BASIC") is not None:
+    print("Skipping basic tests because $NO_TEST_BASIC is set.")
+    sys.exit(0)
+
+logfile = sys.stdout
+if sys.version_info[0] >= 3:
+    logfile = logfile.buffer
+
 child = pexpect.spawn("test/victim")
-child.logfile = sys.stdout
+child.logfile = logfile
 child.setecho(False)
 child.sendline("hello")
 child.expect("ECHO: hello")
 
 reptyr = pexpect.spawn("./reptyr -V %d" % (child.pid,))
-reptyr.logfile = sys.stdout
+reptyr.logfile = logfile
 reptyr.sendline("world")
 reptyr.expect("ECHO: world")
 
 child.sendline("final")
-child.expect(pexpect.EOF)
+expect_eof(child.child_fd)
 
 reptyr.sendeof()
 reptyr.expect(pexpect.EOF)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/reptyr-reptyr-0.7.0/test/tty-steal.py 
new/reptyr-reptyr-0.8.0/test/tty-steal.py
--- old/reptyr-reptyr-0.7.0/test/tty-steal.py   2018-12-05 04:48:42.000000000 
+0100
+++ new/reptyr-reptyr-0.8.0/test/tty-steal.py   2020-09-29 23:29:59.000000000 
+0200
@@ -2,10 +2,16 @@
 import os
 import sys
 
+from util import expect_eof
+
 if os.getenv("NO_TEST_STEAL") is not None:
     print("Skipping tty-stealing tests because $NO_TEST_STEAL is set.")
     sys.exit(0)
 
+logfile = sys.stdout
+if sys.version_info[0] >= 3:
+    logfile = logfile.buffer
+
 did_prctl = False
 try:
     import prctl
@@ -26,13 +32,13 @@
 
 reptyr = pexpect.spawn("./reptyr -V -T %d" % (child.pid,))
 print("spawned children: me={} victim={} reptyr={}".format(os.getpid(), 
child.pid, reptyr.pid))
-reptyr.logfile = sys.stdout
+reptyr.logfile = logfile
 
 reptyr.sendline("world")
 reptyr.expect("ECHO: world")
 
 child.sendline("final")
-child.expect(pexpect.EOF)
+expect_eof(child.child_fd)
 assert os.stat("/dev/null").st_rdev == os.fstat(child.fileno()).st_rdev
 
 reptyr.sendeof()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/reptyr-reptyr-0.7.0/test/util.py 
new/reptyr-reptyr-0.8.0/test/util.py
--- old/reptyr-reptyr-0.7.0/test/util.py        1970-01-01 01:00:00.000000000 
+0100
+++ new/reptyr-reptyr-0.8.0/test/util.py        2020-09-29 23:29:59.000000000 
+0200
@@ -0,0 +1,17 @@
+import os
+import errno
+import select
+
+def expect_eof(fd):
+  r, _, _ = select.select([fd], [], [])
+  if fd not in r:
+    raise AssertionError("Expected EOF, fd not readable")
+  try:
+    data = os.read(fd, 1024)
+    if len(data) == 0:
+      return
+    raise AssertionError("Expected EOF, got read: `{}'".format(data))
+  except OSError as e:
+    if e.errno == errno.EIO:
+      return
+    raise AssertionError("Expected EOF, other expection: {}".format(e))
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/reptyr-reptyr-0.7.0/test/victim.c 
new/reptyr-reptyr-0.8.0/test/victim.c
--- old/reptyr-reptyr-0.7.0/test/victim.c       2018-12-05 04:48:42.000000000 
+0100
+++ new/reptyr-reptyr-0.8.0/test/victim.c       2020-09-29 23:29:59.000000000 
+0200
@@ -1,4 +1,6 @@
 #include <stdio.h>
+
+#ifdef __linux__
 #include <sys/prctl.h>
 
 #ifndef PR_SET_PTRACER
@@ -8,15 +10,18 @@
 #ifndef PR_SET_PTRACER_ANY
 # define PR_SET_PTRACER_ANY ((unsigned long)-1)
 #endif
+#endif
 
 int main(int argc, char **argv) {
     char *line = NULL;
     size_t cap = 0;
 
+#ifdef __linux__
     int err = prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY);
     if (err != 0) {
         fprintf(stderr, "Unable to PR_SET_PTRACER: %m\n");
     }
+#endif
 
     while(getline(&line, &cap, stdin) != -1) {
         printf("ECHO: %s", line);


Reply via email to