cpio/cpio-open_nonblock.patch
Martin Pluskal 22ed1491e1 Accepting request 826878 from home:dirkmueller:branches:Archiving
- update to 2.13:
  * CVE-2015-1197, CVE-2016-2037, CVE-2019-14866 
- remove patches (upstream):
  cpio-2.12-out_of_bounds_write.patch, cpio-2.12-CVE-2019-14866.patch,
  cpio-2.12-util.c_no_return_in_nonvoid_fnc.patch,
  cpio-check_for_symlinks.patch

OBS-URL: https://build.opensuse.org/request/show/826878
OBS-URL: https://build.opensuse.org/package/show/Archiving/cpio?expand=0&rev=81
2020-08-19 10:06:19 +00:00

69 lines
2.6 KiB
Diff

From: Alexey Svistunov <svalx@svalx.net>
Date: 2017-02-17 16:07:00 +0300
Subject: open device with O_NONBLOCK option
References: https://savannah.gnu.org/patch/?9263, bnc#94449
Upstream: submitted
When running the 2.6 kernel, "mt -f /dev/nst0 status" blocks if there is
no media in the drive. The same occurs for other commands.
When running the 2.4.24 kernel, "mt -f /dev/nst0 status" does not block
when there is no tape in the drive.
This behavior change is documented for the 2.6 kernel (see
kernel-source-2.6.3/Documentation/scsi/st.txt for the full doc):
If the open option O_NONBLOCK is used, open succeeds even if the
drive is not ready. If O_NONBLOCK is not used, the driver waits for
the drive to become ready. If this does not happen in ST_BLOCK_SECONDS
seconds, open fails with the errno value EIO. With O_NONBLOCK the
device can be opened for writing even if there is a write protected
tape in the drive (commands trying to write something return error if
attempted).
It appears that the use of O_NONBLOCK is safe with pre-2.6 kernels.
Suggest adding the use of O_NONBLOCK when opening the device. As it is,
for long-running commands such as "fsf", one cannot tell if the command is
progressing or if it's blocking waiting for media.
Index: src/mt.c
===================================================================
--- src/mt.c.orig
+++ src/mt.c
@@ -333,11 +333,11 @@ main (int argc, char **argv)
#ifdef MTERASE
case MTERASE:
#endif
- tapedesc = rmtopen (tapedev, O_WRONLY, 0, rsh_command_option);
+ tapedesc = rmtopen (tapedev, O_WRONLY | O_NONBLOCK, 0, rsh_command_option);
break;
default:
- tapedesc = rmtopen (tapedev, O_RDONLY, 0, rsh_command_option);
+ tapedesc = rmtopen (tapedev, O_RDONLY | O_NONBLOCK, 0, rsh_command_option);
}
if (tapedesc == -1)
Index: src/util.c
===================================================================
--- src/util.c.orig
+++ src/util.c
@@ -801,14 +801,14 @@ open_archive (char *file)
copy_in = process_copy_in;
if (copy_function == copy_in)
- fd = rmtopen (file, O_RDONLY | O_BINARY, MODE_RW, rsh_command_option);
+ fd = rmtopen (file, O_RDONLY | O_BINARY | O_NONBLOCK, MODE_RW, rsh_command_option);
else
{
if (!append_flag)
- fd = rmtopen (file, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, MODE_RW,
+ fd = rmtopen (file, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY | O_NONBLOCK, MODE_RW,
rsh_command_option);
else
- fd = rmtopen (file, O_RDWR | O_BINARY, MODE_RW, rsh_command_option);
+ fd = rmtopen (file, O_RDWR | O_BINARY | O_NONBLOCK, MODE_RW, rsh_command_option);
}
return fd;