On Sat, Apr 15, 2017 at 10:27:19PM +0200, Matthieu Herrb wrote:
> On 6.1 and -current. run 'pax' without any argment.
>
> $ pax
> Abort (core dumped)
> Exit 134
>
> $ dmesg | tail -1
> pax(81327): syscall 54 "tty"
>
> $ ktrace pax
> $ kdump | tail -4
> 19681 pax CALL ioctl(0,MTIOCGET,0x7f7ffffbd7f0)
> 19681 pax PLDG ioctl, "tty", errno 1 Operation not permitted
> 19681 pax PSIG SIGABRT SIG_DFL
> 19681 pax NAMI "pax.core"
>
> --
> Matthieu Herrb
>
The issue here is, that pledge("tape") does not allow to perform
MTIOCGET on tty devices. So we should call isatty() beforehand and
shortcut ioctl() in case the file descriptor is a tty.
Index: ar_io.c
===================================================================
RCS file: /cvs/src/bin/pax/ar_io.c,v
retrieving revision 1.62
diff -u -p -r1.62 ar_io.c
--- ar_io.c 11 Mar 2017 12:55:47 -0000 1.62
+++ ar_io.c 16 Apr 2017 07:08:29 -0000
@@ -170,9 +170,12 @@ ar_open(const char *name)
return(-1);
}
- if (S_ISCHR(arsb.st_mode))
- artyp = ioctl(arfd, MTIOCGET, &mb) ? ISCHR : ISTAPE;
- else if (S_ISBLK(arsb.st_mode))
+ if (S_ISCHR(arsb.st_mode)) {
+ if (isatty(arfd) || ioctl(arfd, MTIOCGET, &mb))
+ artyp = ISCHR;
+ else
+ artyp = ISTAPE;
+ } else if (S_ISBLK(arsb.st_mode))
artyp = ISBLK;
else if ((lseek(arfd, 0, SEEK_CUR) == -1) && (errno == ESPIPE))
artyp = ISPIPE;
With this diff applied:
$ pax
[waiting for input]
...
Ok?
natano