Accepting request 487331 from Archiving

1

OBS-URL: https://build.opensuse.org/request/show/487331
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/cpio?expand=0&rev=54
This commit is contained in:
Dominique Leuenberger 2017-05-10 18:31:36 +00:00 committed by Git OBS Bridge
commit 9db1c8a492
5 changed files with 132 additions and 733 deletions

View File

@ -11,12 +11,22 @@ Index: cpio-2.12/src/copyin.c
===================================================================
--- cpio-2.12.orig/src/copyin.c
+++ cpio-2.12/src/copyin.c
@@ -1434,6 +1434,8 @@ process_copy_in ()
@@ -1433,6 +1433,18 @@ process_copy_in ()
break;
}
+ if (file_hdr.c_namesize <= 1)
+ file_hdr.c_name = xrealloc(file_hdr.c_name, 2);
+ /* Fix for CVE-2016-2037 (bsc#963448) and resultant regression (bsc#1028410).
+ For tar and ustar archive formats, file_hdr.c_namesize is not defined and
+ file_hdr.c_name uses static memory. Therefore we can't rely on
+ file_hdr.c_namesize and we can't realloc memory for these archive types.
+ However the patch is still correct for CVE-2016-2037 (we have to be sure
+ that the allocated NAME buffer has a capacity at least 2 bytes to allow
+ us to store the "." string inside) as static char array for tar and ustar
+ has size 2 at least (see tar.c:stash_tar_filename()).
+ */
+ if (archive_format != arf_tar && archive_format != arf_ustar
+ && file_hdr.c_namesize <= 1)
+ file_hdr.c_name = xrealloc(file_hdr.c_name, 2);
cpio_safer_name_suffix (file_hdr.c_name, false, !no_abs_paths_flag,
false);
@ -36,3 +46,4 @@ Index: cpio-2.12/src/util.c
void
cpio_safer_name_suffix (char *name, bool link_target, bool absolute_names,
bool strip_leading_dots)

View File

@ -1,695 +0,0 @@
Index: doc/mt.1
===================================================================
--- doc/mt.1.orig
+++ doc/mt.1
@@ -100,10 +100,6 @@ Absolute space to file number
Equivalent to rewind followed by fsf
.IR count .
.TP
-.B seek
-Seek to block number
-.IR count .
-.TP
.B eom
Space to the end of the recorded media on the tape
(for appending files onto tapes).
@@ -123,6 +119,82 @@ then rewind it again.
.TP
.B erase
Erase the tape.
+.TP
+.B fss
+(SCSI tapes) Forward space
+.I count
+setmarks.
+.TP
+.B bss
+(SCSI tapes) Backward space
+.I count
+setmarks.
+.TP
+.B "wset"
+(SCSI tapes) Write
+.I count
+setmarks at current position (only SCSI tape).
+.TP
+.B "eod, seod"
+Space to end of valid data. Used on streamer tape
+drives to append data to the logical and of tape.
+.TP
+.B setblk
+(SCSI tapes) Set the block size of the drive to
+.I count
+bytes per record.
+.TP
+.B setdensity
+(SCSI tapes) Set the tape density code to
+.I count.
+The proper codes to use with each drive should be looked up from the
+drive documentation.
+.TP
+.B drvbuffer
+(SCSI tapes) Set the tape drive buffer code to
+.I number.
+The proper value for unbuffered operation is zero and "normal" buffered
+operation one. The meanings of other values can be found in the drive
+documentation or, in case of a SCSI-2 drive, from the SCSI-2 standard.
+.TP
+.B stoptions
+(SCSI tapes) Set the driver options bits to
+.I count
+for the device.
+The bits can be set by oring the following values: 1 to enable write
+buffering, 2 to enable asynchronous writes, 4 to enable read ahead,
+8 to enable debugging output (if it has been compiled to the driver).
+.TP
+.B stwrthreshold
+(SCSI tapes) The write threshold for the tape device is set to
+.I count
+kilobytes. The value must be smaller than or equal to the driver
+buffer size.
+.TP
+.B seek
+(SCSI tapes) Seek to the
+.I count
+block on the tape. This operation is available on some
+Tandberg and Wangtek streamers and some SCSI-2 tape drives.
+.TP
+.B tell
+(SCSI tapes) Tell the current block on tape. This operation is available on some
+Tandberg and Wangtek streamers and some SCSI-2 tape drives.
+.TP
+.B densities
+(SCSI tapes) Write explanation of some common density codes to
+standard output.
+.TP
+.B datcompression
+(some SCSI-2 DAT tapes) Inquire or set the compression status
+(on/off). If the
+.I count
+is one the compression status is printed. If the
+.I count
+is zero, compression is disabled. Otherwise, compression is
+enabled. The command uses the SCSI ioctl to read and write the Data
+Compression Characteristics mode page (15). ONLY ROOT CAN USE THIS
+COMMAND.
.PP
.B mt
exits with a status of 0 if the operation succeeded, 1 if the
Index: lib/system.h
===================================================================
--- lib/system.h.orig
+++ lib/system.h
@@ -438,10 +438,11 @@ char *getenv ();
#if HAVE_LOCALE_H
# include <locale.h>
-#endif
+#else
#if !HAVE_SETLOCALE
# define setlocale(category, locale) /* empty */
#endif
+#endif
#include <time.h>
#ifdef TIME_WITH_SYS_TIME
Index: src/copyin.c
===================================================================
--- src/copyin.c.orig
+++ src/copyin.c
@@ -698,7 +698,7 @@ copyin_link (struct cpio_file_stat *file
static void
copyin_file (struct cpio_file_stat *file_hdr, int in_file_des)
{
- int existing_dir;
+ int existing_dir=0;
if (!to_stdout_option
&& try_existing_file (file_hdr, in_file_des, &existing_dir) < 0)
@@ -1287,6 +1287,7 @@ process_copy_in ()
int in_file_des; /* Input file descriptor. */
char skip_file; /* Flag for use with patterns. */
int i; /* Loop index variable. */
+ int lastpattern = 0;
newdir_umask = umask (0); /* Reset umask to preserve modes of
created files */
@@ -1397,8 +1398,10 @@ process_copy_in ()
for (i = 0; i < num_patterns
&& skip_file == copy_matching_files; i++)
{
- if (fnmatch (save_patterns[i], file_hdr.c_name, 0) == 0)
+ if (fnmatch (save_patterns[lastpattern], file_hdr.c_name, 0) == 0)
skip_file = !copy_matching_files;
+ else if (++lastpattern >= num_patterns)
+ lastpattern = 0;
}
}
Index: src/mt.c
===================================================================
--- src/mt.c.orig
+++ src/mt.c
@@ -18,6 +18,10 @@
02110-1301 USA
*/
+/* Modified for the Linux SCSI tape driver by Brian Mays from code
+ written by Kai Makisara.
+ Last Modified: Tue Apr 23 15:37:54 EDT 1996
+*/
/* If -f is not given, the environment variable TAPE is used;
if that is not set, a default device defined in sys/mtio.h is used.
@@ -52,9 +56,51 @@
retension Rewind the tape, then wind it to the end of the reel,
then rewind it again.
erase Erase the tape.
+ fss (SCSI tapes) Forward space COUNT setmarks.
+ bss (SCSI tapes) Backward space COUNT setmarks.
+ wset (SCSI tapes) Write COUNT setmarks at current position
+ (only SCSI tape).
+ eod, seod Space to end of valid data. Used on streamer tape
+ drives to append data to the logical and of tape.
+ setblk (SCSI tapes) Set the block size of the drive to COUNT
+ bytes per record.
+ setdensity (SCSI tapes) Set the tape density code to COUNT. The
+ proper codes to use with each drive should be looked
+ up from the drive documentation.
+ drvbuffer (SCSI tapes) Set the tape drive buffer code to
+ NUMBER. The proper value for unbuffered operation is
+ zero and "normal" buffered operation one. The meanings
+ of other values can be found in the drive
+ documentation or, in case of a SCSI-2 drive, from the
+ SCSI-2 standard.
+ stoptions (SCSI tapes) Set the driver options bits to COUNT for
+ the device. The bits can be set by oring the
+ following values: 1 to enable write buffering, 2 to
+ enable asynchronous writes, 4 to enable read ahead, 8
+ to enable debugging output (if it has been compiled to
+ the driver).
+ stwrthreshold
+ (SCSI tapes) The write threshold for the tape device
+ is set to COUNT kilobytes. The value must be smaller
+ than or equal to the driver buffer size.
+ seek (SCSI tapes) Seek to the COUNT block on the tape.
+ This operation is available on some Tandberg and
+ Wangtek streamers and some SCSI-2 tape drives.
+ tell (SCSI tapes) Tell the current block on tape. This
+ operation is available on some Tandberg and Wangtek
+ streamers and some SCSI-2 tape drives.
+ densities (SCSI tapes) Write explanation of some common density
+ codes to standard output.
+ datcompression
+ (some SCSI-2 DAT tapes) Inquire or set the compression
+ status (on/off). If the COUNT is one the compression
+ status is printed. If the COUNT is zero, compression
+ is disabled. Otherwise, compression is enabled.
David MacKenzie <djm@gnu.ai.mit.edu> */
+#include <configmake.h>
+
#include <system.h>
#include <stdio.h>
@@ -90,6 +136,110 @@
#define MT_EXIT_INVOP 1
#define MT_EXIT_FAILURE 2
+#if defined(linux) || defined(__linux)
+#define MTDATCOMP 1000 /* Random unused number. */
+#define MTDENS 1001 /* Random unused number. */
+
+struct densities {
+ int code;
+ char *name;
+} density_tbl[] = {
+ {0x00, "default"},
+ {0x01, "NRZI (800 bpi)"},
+ {0x02, "PE (1600 bpi)"},
+ {0x03, "GCR (6250 bpi)"},
+ {0x04, "QIC-11"},
+ {0x05, "QIC-45/60 (GCR, 8000 bpi)"},
+ {0x06, "PE (3200 bpi)"},
+ {0x07, "IMFM (6400 bpi)"},
+ {0x08, "GCR (8000 bpi)"},
+ {0x09, "GCR /37871 bpi)"},
+ {0x0a, "MFM (6667 bpi)"},
+ {0x0b, "PE (1600 bpi)"},
+ {0x0c, "GCR (12960 bpi)"},
+ {0x0d, "GCR (25380 bpi)"},
+ {0x0f, "QIC-120 (GCR 10000 bpi)"},
+ {0x10, "QIC-150/250 (GCR 10000 bpi)"},
+ {0x11, "QIC-320/525 (GCR 16000 bpi)"},
+ {0x12, "QIC-1350 (RLL 51667 bpi)"},
+ {0x13, "DDS (61000 bpi)"},
+ {0x14, "EXB-8200 (RLL 43245 bpi)"},
+ {0x15, "EXB-8500 (RLL 45434 bpi)"},
+ {0x16, "MFM 10000 bpi"},
+ {0x17, "MFM 42500 bpi"},
+ {0x18, "TZ86"},
+ {0x19, "DLT 10GB"},
+ {0x1a, "DLT 20GB"},
+ {0x1b, "DLT 35GB"},
+ {0x1c, "QIC-385M"},
+ {0x1d, "QIC-410M"},
+ {0x1e, "QIC-1000C"},
+ {0x1f, "QIC-2100C"},
+ {0x20, "QIC-6GB"},
+ {0x21, "QIC-20GB"},
+ {0x22, "QIC-2GB"},
+ {0x23, "QIC-875"},
+ {0x24, "DDS-2"},
+ {0x25, "DDS-3"},
+ {0x26, "DDS-4 or QIC-4GB"},
+ {0x27, "Exabyte Mammoth"},
+ {0x28, "Exabyte Mammoth-2"},
+ {0x29, "QIC-3080MC"},
+ {0x30, "AIT-1 or MLR3"},
+ {0x31, "AIT-2"},
+ {0x32, "AIT-3"},
+ {0x33, "SLR6"},
+ {0x34, "SLR100"},
+ {0x40, "DLT1 40 GB, or Ultrium"},
+ {0x41, "DLT 40GB, or Ultrium2"},
+ {0x42, "LTO-2"},
+ {0x45, "QIC-3095-MC (TR-4)"},
+ {0x47, "TR-5"},
+ {0x48, "DAT160"},
+ {0x80, "DLT 15GB uncomp. or Ecrix"},
+ {0x81, "DLT 15GB compressed"},
+ {0x82, "DLT 20GB uncompressed"},
+ {0x83, "DLT 20GB compressed"},
+ {0x84, "DLT 35GB uncompressed"},
+ {0x85, "DLT 35GB compressed"},
+ {0x86, "DLT1 40 GB uncompressed"},
+ {0x87, "DLT1 40 GB compressed"},
+ {0x88, "DLT 40GB uncompressed"},
+ {0x89, "DLT 40GB compressed"},
+ {0x8c, "EXB-8505 compressed"},
+ {0x90, "SDLT110 uncompr/EXB-8205 compr"},
+ {0x91, "SDLT110 compressed"},
+ {0x92, "SDLT160 uncompressed"},
+ {0x93, "SDLT160 comprssed"},
+ {-1, NULL}};
+#endif
+
+char *cbnames[] =
+{
+#ifdef MT_ST_BOOLEANS
+ "stoptions",
+#endif
+#ifdef MT_ST_WRITE_THRESHOLD
+ "stwrthreshold",
+#endif
+ NULL
+};
+
+int count_bits[] =
+{
+#ifdef MT_ST_BOOLEANS
+ MT_ST_BOOLEANS,
+#endif
+#ifdef MT_ST_WRITE_THRESHOLD
+ MT_ST_WRITE_THRESHOLD,
+#endif
+ 0
+};
+
+#ifdef MT_TAPE_INFO
+ struct mt_tape_info tapes[] = MT_TAPE_INFO;
+#endif
+
char const * const opnames[] =
{
"eof",
@@ -108,6 +258,8 @@ char const * const opnames[] =
#endif
#ifdef MTEOM
"eom",
+ "eod",
+ "seod",
#endif
#ifdef MTRETEN
"retension",
@@ -122,6 +274,39 @@ char const * const opnames[] =
#ifdef MTSEEK
"seek",
#endif
+#ifdef MTTELL
+ "tell",
+#endif
+#ifdef MTFSS
+ "fss",
+#endif
+#ifdef MTBSS
+ "bss",
+#endif
+#ifdef MTWSM
+ "wset",
+#endif
+#ifdef MTSETBLK
+ "setblk",
+#endif
+#ifdef MTSETDENSITY
+ "setdensity",
+#endif
+#ifdef MTSETDRVBUFFER
+ "drvbuffer",
+#ifdef MT_ST_BOOLEANS
+ "stoptions",
+#endif
+#ifdef MT_ST_WRITE_THRESHOLD
+ "stwrthreshold",
+#endif
+#endif
+#ifdef MTDATCOMP
+ "datcompression",
+#endif
+#ifdef MTDENS
+ "densities",
+#endif
NULL
};
@@ -144,6 +329,8 @@ short operations[] =
#endif
#ifdef MTEOM
MTEOM,
+ MTEOM,
+ MTEOM,
#endif
#ifdef MTRETEN
MTRETEN,
@@ -158,6 +345,39 @@ short operations[] =
#ifdef MTSEEK
MTSEEK,
#endif
+#ifdef MTTELL
+ MTTELL,
+#endif
+#ifdef MTFSS
+ MTFSS,
+#endif
+#ifdef MTBSS
+ MTBSS,
+#endif
+#ifdef MTWSM
+ MTWSM,
+#endif
+#ifdef MTSETBLK
+ MTSETBLK,
+#endif
+#ifdef MTSETDENSITY
+ MTSETDENSITY,
+#endif
+#ifdef MTSETDRVBUFFER
+ MTSETDRVBUFFER,
+#ifdef MT_ST_BOOLEANS
+ MTSETDRVBUFFER,
+#endif
+#ifdef MT_ST_WRITE_THRESHOLD
+ MTSETDRVBUFFER,
+#endif
+#endif
+#ifdef MTDATCOMP
+ MTDATCOMP,
+#endif
+#ifdef MTDENS
+ MTDENS,
+#endif
};
ARGMATCH_VERIFY (opnames, operations);
@@ -286,10 +506,23 @@ void
print_status (char *dev, int desc)
{
struct mtget status;
+ #ifdef MT_TAPE_INFO
+ struct mt_tape_info *mt;
+ #endif
if (rmtioctl (desc, MTIOCGET, (char*)&status) == -1)
error (MT_EXIT_FAILURE, errno, _("%s: rmtioctl failed"), dev);
+ #ifdef MT_TAPE_INFO
+ for (mt = tapes; mt->t_type; mt++)
+ if (mt->t_type == status.mt_type) break;
+ if (mt->t_type != 0)
+ {
+ printf ("drive type = %s\n", mt->t_name);
+ }
+ else
+ #endif
+
printf ("drive type = %d\n", (int) status.mt_type);
#if defined(hpux) || defined(__hpux)
printf ("drive status (high) = %d\n", (int) status.mt_dsreg1);
@@ -303,7 +536,177 @@ print_status (char *dev, int desc)
printf ("file number = %d\n", (int) status.mt_fileno);
printf ("block number = %d\n", (int) status.mt_blkno);
#endif
+#if defined(linux) || defined(__linux)
+ if (status.mt_type == MT_ISSCSI1 ||
+ status.mt_type == MT_ISSCSI2)
+ {
+ int dens, i;
+ char *density;
+ dens = (status.mt_dsreg & MT_ST_DENSITY_MASK) >> MT_ST_DENSITY_SHIFT;
+ density = "unknown";
+ for (i=0; density_tbl[i].code >= 0; i++)
+ if (density_tbl[i].code == dens)
+ {
+ density = density_tbl[i].name;
+ break;
+ }
+ printf("Tape block size %ld bytes. Density code 0x%x (%s).\n",
+ ((status.mt_dsreg & MT_ST_BLKSIZE_MASK) >> MT_ST_BLKSIZE_SHIFT),
+ dens, density);
+
+ printf("Soft error count since last status=%ld\n",
+ (status.mt_erreg & MT_ST_SOFTERR_MASK) >> MT_ST_SOFTERR_SHIFT);
+ printf("General status bits on (%lx):\n", status.mt_gstat);
+ if (GMT_EOF(status.mt_gstat))
+ printf(" EOF");
+ if (GMT_BOT(status.mt_gstat))
+ printf(" BOT");
+ if (GMT_EOT(status.mt_gstat))
+ printf(" EOT");
+ if (GMT_SM(status.mt_gstat))
+ printf(" SM");
+ if (GMT_EOD(status.mt_gstat))
+ printf(" EOD");
+ if (GMT_WR_PROT(status.mt_gstat))
+ printf(" WR_PROT");
+ if (GMT_ONLINE(status.mt_gstat))
+ printf(" ONLINE");
+ if (GMT_D_6250(status.mt_gstat))
+ printf(" D_6250");
+ if (GMT_D_1600(status.mt_gstat))
+ printf(" D_1600");
+ if (GMT_D_800(status.mt_gstat))
+ printf(" D_800");
+ if (GMT_DR_OPEN(status.mt_gstat))
+ printf(" DR_OPEN");
+ if (GMT_IM_REP_EN(status.mt_gstat))
+ printf(" IM_REP_EN");
+ if (status.mt_gstat != 0)
+ putchar ('\n');
+ }
+ else
+ {
+ printf("gstat = %0lx\n", status.mt_gstat);
+ }
+#endif
+}
+
+
+#if defined(linux) || defined(__linux)
+/*** Get and set the DAT compression (Mode Page 15) ***/
+
+#define MODE_SENSE 0x1a
+#define MODE_SELECT 0x15
+
+int
+read_mode_page(int fn, int page, int length, unsigned char *buffer,
+ int do_mask)
+{
+ int result, *ip;
+ unsigned char tmpbuffer[30], *cmd;
+
+ memset(tmpbuffer, 0, 14);
+ ip = (int *)&(tmpbuffer[0]);
+ *ip = 0;
+ *(ip+1) = length + 4;
+
+ cmd = &(tmpbuffer[8]);
+ cmd[0] = MODE_SENSE;
+ cmd[1] = 8;
+ cmd[2] = page;
+ if (do_mask)
+ cmd[2] |= 0x40; /* Get changeable parameter mask */
+ cmd[4] = length + 4;
+
+ result = ioctl(fn, 1, tmpbuffer);
+ if (result) {
+ fprintf(stderr, "Can't read mode page. Are you sure you are root?\n");
+ return 0;
+ }
+ memcpy(buffer, tmpbuffer + 8, length + 4);
+ return 1;
+}
+
+
+int
+write_mode_page(int fn, int page, int length, unsigned char *buffer)
+{
+ int result, *ip;
+ unsigned char tmpbuffer[40], *cmd;
+
+ memset(tmpbuffer, 0, 14);
+ ip = (int *)&(tmpbuffer[0]);
+ *ip = length + 4;
+ *(ip+1) = 0;
+
+ cmd = &(tmpbuffer[8]);
+ cmd[0] = MODE_SELECT;
+ cmd[1] = 0x10;
+ cmd[4] = length + 4;
+
+ memcpy(tmpbuffer + 14, buffer, length + 4);
+ tmpbuffer[14] = 0; /* reserved data length */
+ tmpbuffer[18] &= 0x3f; /* reserved bits in page code byte */
+
+ result = ioctl(fn, 1, tmpbuffer);
+ if (result) {
+ fprintf(stderr, "Can't write mode page.\n");
+ return 0;
+ }
+ return 1;
+}
+
+
+int
+do_dat_compression(char *dev, int fn, int count)
+{
+ int i;
+ unsigned char buffer[30], mask[30];
+
+ if (!read_mode_page(fn, 0x0f, 16, buffer, 0)) {
+ error (2, errno, "%s", dev);
+ }
+
+ if (count != -1) {
+ if (count == 0)
+ buffer[4+2] &= 0x7f;
+ else
+ buffer[4+2] |= 0x80;
+/* if (read_mode_page(fn, 0x0f, 16, mask, 1))
+ for (i=3; i < 16; i++)
+ buffer[4+i] |= mask[4+i]; bug #223494 */
+ if (!write_mode_page(fn, 0x0f, 16, buffer)) {
+ error (2, errno, "%s", dev);
+ }
+ if (!read_mode_page(fn, 0x0f, 16, buffer, 0)) { /* Re-read to check */
+ error (2, errno, "%s", dev);
+ }
+ }
+
+ if (buffer[4+2] & 0x80)
+ printf("Compression on.\n");
+ else
+ printf("Compression off.\n");
+
+ return 1;
+}
+#endif
+
+#ifdef MTTELL
+void
+print_position (dev, desc)
+ char *dev;
+ int desc;
+{
+ struct mtpos position;
+
+ if (rmtioctl (desc, MTIOCPOS, &position) == -1)
+ error (2, errno, "%s", dev);
+ printf("At block %ld.\n", position.mt_blkno);
+
}
+#endif
+
void
fatal_exit ()
@@ -314,7 +717,7 @@ fatal_exit ()
int
main (int argc, char **argv)
{
- int tapedesc;
+ int tapedesc,i;
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);
@@ -327,13 +730,32 @@ main (int argc, char **argv)
if (argp_parse (&argp, argc, argv, ARGP_IN_ORDER, NULL, NULL))
exit (MT_EXIT_INVOP);
+#ifdef MTDENS
+ if (operation == MTDENS)
+ {
+ printf("Some SCSI tape density codes:\ncode explanation\n");
+ for (i=0; density_tbl[i].code >= 0; i++)
+ printf("0x%02x %s\n", density_tbl[i].code, density_tbl[i].name);
+ exit (0);
+ }
+#endif
+
switch (operation)
{
case MTWEOF:
#ifdef MTERASE
case MTERASE:
#endif
- tapedesc = rmtopen (tapedev, O_WRONLY, 0, rsh_command_option);
+#ifdef MTWSM
+ case MTWSM:
+#endif
+#ifdef MTSETDRVBUFFER
+ case MTSETDRVBUFFER:
+#endif
+#ifdef MTDATCOMP
+ case MTDATCOMP:
+#endif
+ tapedesc = rmtopen (tapedev, O_WRONLY, 0, rsh_command_option);
break;
default:
@@ -344,6 +766,17 @@ main (int argc, char **argv)
error (MT_EXIT_INVOP, errno, _("%s: rmtopen failed"), tapedev);
check_type (tapedev, tapedesc);
+#ifdef MTDATCOMP
+ if (operation == MTDATCOMP)
+ do_dat_compression(tapedev, tapedesc, count);
+ else
+#endif
+#ifdef MTTELL
+ if (operation == MTTELL)
+ print_position (tapedev, tapedesc);
+ else
+#endif
+ {
if (operation == MTASF)
{
perform_operation (tapedev, tapedesc, MTREW, 1);
@@ -352,6 +785,7 @@ main (int argc, char **argv)
perform_operation (tapedev, tapedesc, operation, count);
if (operation == MTNOP)
print_status (tapedev, tapedesc);
+ }
if (rmtclose (tapedesc) == -1)
error (MT_EXIT_FAILURE, errno, _("%s: rmtclose failed"), tapedev);

View File

@ -1,13 +1,41 @@
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
@@ -723,11 +723,11 @@ main (int argc, char **argv)
#ifdef MTDATCOMP
case MTDATCOMP:
@@ -333,11 +333,11 @@
#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);
- tapedesc = rmtopen (tapedev, O_WRONLY, 0, rsh_command_option);
+ tapedesc = rmtopen (tapedev, O_WRONLY | O_NONBLOCK, 0, rsh_command_option);
break;
default:
@ -20,7 +48,7 @@ Index: src/util.c
===================================================================
--- src/util.c.orig
+++ src/util.c
@@ -767,14 +767,14 @@ open_archive (char *file)
@@ -814,14 +814,14 @@
copy_in = process_copy_in;
if (copy_function == copy_in)

View File

@ -1,3 +1,33 @@
-------------------------------------------------------------------
Tue Apr 11 10:06:17 UTC 2017 - kstreitova@suse.com
- modify cpio-2.12-out_of_bounds_write.patch to fix a regression
causing cpio to crash for tar and ustar archive types
[bsc#1028410]
-------------------------------------------------------------------
Mon Mar 27 11:13:08 UTC 2017 - mpluskal@suse.com
- Use macro for configure and make install
- Use update-alternatives according to current documentation
- Enable testsuite
-------------------------------------------------------------------
Fri Mar 24 13:28:00 UTC 2017 - svalx@svalx.net
- Enable mt building
- Separated cpio-mt subpackge
- Change recommend to own mt subpackge
- Remove cpio-mt.patch - those features available in original mt-st package
- Switch to use alternatives system for mt
- Disable rmt building: this binary fully identical to rmt from tar
- Change default rmt dir to /usr/bin
-------------------------------------------------------------------
Thu Mar 23 15:14:25 UTC 2017 - kstreitova@suse.com
- cleanup with spec-cleaner
-------------------------------------------------------------------
Sat Mar 5 12:31:47 UTC 2016 - mpluskal@suse.com

View File

@ -1,7 +1,7 @@
#
# spec file for package cpio
#
# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@ -27,10 +27,9 @@ Source0: http://ftp.gnu.org/gnu/%{name}/%{name}-%{version}.tar.bz2
Source1: http://ftp.gnu.org/gnu/%{name}/%{name}-%{version}.tar.bz2.sig
Source2: %{name}.keyring
Patch2: cpio-use_new_ascii_format.patch
#oouch what a ...?! pieces of code grabed from mt_st package to add missing functionality (e.g. density info)
#TODO: review is patches needed while mt is no longer building
Patch3: cpio-mt.patch
Patch4: cpio-use_sbin_rmt.patch
#PATCH-FIX-UPSTREAM cpio-2.12 cpio-open_nonblock.patch bnc#94449,
#https://savannah.gnu.org/patch/?9263 -- open device with O_NONBLOCK option
Patch5: cpio-open_nonblock.patch
Patch15: cpio-eof_tape_handling.patch
# make posibble to have device nodes with major number > 127
@ -47,10 +46,11 @@ Patch26: cpio-2.12-util.c_no_return_in_nonvoid_fnc.patch
Patch27: cpio-2.12-out_of_bounds_write.patch
BuildRequires: autoconf
BuildRequires: automake
Recommends: mt_st
Requires(post): %{install_info_prereq}
Requires(preun): %{install_info_prereq}
Recommends: %{name}-lang = %{version}
Recommends: %{name}-mt = %{version}
Recommends: rmt
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%description
@ -60,16 +60,22 @@ other files plus information about them, such as their pathname, owner,
time stamps, and access permissions. The archive can be another file on
the disk, a magnetic tape, or a pipe.
This package also includes the program 'rmt', which provides remote tape
drive control. The 'mt', a local tape drive control program can be found
in mt_st package.
%package mt
Summary: Tape drive control utility
Group: Productivity/Archiving/Backup
Requires: %{name} = %{version}
Requires(post): update-alternatives
Requires(postun): update-alternatives
Provides: mt
%description mt
This package includes the 'mt', a local tape drive control program.
%lang_package
%prep
%setup -q
%patch2
%patch3
%patch4
%patch5
%patch15
@ -82,37 +88,49 @@ in mt_st package.
%patch25 -p1
%patch26 -p1
%patch27 -p1
#chmod 755 .
#chmod u+w *
#chmod a+r *
%build
gettextize -f
autoreconf --force --install
CFLAGS="%{optflags} -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fPIE" \
LDFLAGS="-pie" \
./configure \
--prefix=%{_prefix} \
--mandir=%{_mandir} \
--infodir=%{_infodir} \
--libdir=%{_libdir} \
--disable-silent-rules
autoreconf -fiv
export CFLAGS="%{optflags} -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fPIE"
export LDFLAGS="-pie"
%configure \
--with-rmt="%{_bindir}/rmt" \
--enable-mt \
--disable-silent-rules \
--program-transform-name='s/^mt$/gnumt/'
make %{?_smp_mflags}
%install
mkdir -p %{buildroot}/{usr/bin,bin}
make prefix=%{buildroot}%{_prefix} infodir=%{buildroot}%{_infodir} mandir=%{buildroot}%{_mandir} \
DEFAULT_RMT_DIR=%{buildroot}%{_sbindir} install
%make_install
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
ln -sf %{_sysconfdir}/alternatives/mt %{buildroot}%{_bindir}/mt
ln -sf %{_sysconfdir}/alternatives/mt.1%{ext_man} %{buildroot}%{_mandir}/man1/mt.1%{ext_man}
#UsrMerge
ln -sf %{_bindir}/cpio %{buildroot}/bin
#EndUsrMerge
%find_lang %{name}
%check
make %{?_smp_mflags} check
%post mt
%{_sbindir}/update-alternatives --force \
--install %{_bindir}/mt mt %{_bindir}/gnumt 10 \
--slave %{_mandir}/man1/mt.1%{ext_man} mt.1%{ext_man} %{_mandir}/man1/gnumt.1%{ext_man}
%post
%install_info --info-dir=%{_infodir} %{_infodir}/%{name}.info.gz
%install_info --info-dir=%{_infodir} %{_infodir}/%{name}.info%{ext_info}
%preun
%install_info_delete --info-dir=%{_infodir} %{_infodir}/%{name}.info.gz
%install_info_delete --info-dir=%{_infodir} %{_infodir}/%{name}.info%{ext_info}
%postun mt
if [ ! -f %{_bindir}/gnumt ] ; then
"%{_sbindir}/update-alternatives" --remove mt %{_bindir}/gnumt
fi
%files
%defattr(-,root,root)
@ -120,10 +138,17 @@ ln -sf %{_bindir}/cpio %{buildroot}/bin
/bin/cpio
#EndUsrMerge
%{_bindir}/cpio
%{_sbindir}/rmt
%{_infodir}/cpio.info.gz
%{_mandir}/man1/cpio.1.gz
%{_mandir}/man8/rmt.8.gz
%{_infodir}/cpio.info%{ext_info}
%{_mandir}/man1/cpio.1%{ext_man}
%files mt
%defattr(-,root,root)
%ghost %{_bindir}/mt
%{_bindir}/gnumt
%ghost %{_mandir}/man1/mt.1%{ext_man}
%{_mandir}/man1/gnumt.1%{ext_man}
%ghost %{_sysconfdir}/alternatives/mt
%ghost %{_sysconfdir}/alternatives/mt.1%{ext_man}
%files lang -f %{name}.lang
%defattr(-,root,root)