diff --git a/_service b/_service new file mode 100644 index 0000000..9a19051 --- /dev/null +++ b/_service @@ -0,0 +1,16 @@ + + + git + https://github.com/fujita/tgt.git + + tgt + v1.0.74 + 1.0.74 + enable + + + *tgt*.tar + gz + + + diff --git a/_servicedata b/_servicedata new file mode 100644 index 0000000..d425a52 --- /dev/null +++ b/_servicedata @@ -0,0 +1,4 @@ + + + https://github.com/fujita/tgt.git + f33f6b73d3bfac8b3e44f068d02f90627b407f4e \ No newline at end of file diff --git a/tgt-Fix-gcc7-string-truncation-warnings.patch b/tgt-Fix-gcc7-string-truncation-warnings.patch new file mode 100644 index 0000000..5756f9d --- /dev/null +++ b/tgt-Fix-gcc7-string-truncation-warnings.patch @@ -0,0 +1,102 @@ +From 2de8bebe132e3b998bf4848d0bd22b50367ad4b8 Mon Sep 17 00:00:00 2001 +From: Lee Duncan +Date: Sat, 16 Feb 2019 10:29:19 -0800 +Subject: [PATCH] Fix gcc7 string truncation warnings. + +Mostly, this is fixed by checking the legnth +of strings to be copied, making sure they will +fit where they are being copied to, and +erroring out if the copy will not fit. Then +we can just use strcpy(). We also use +scsi_sprintf() for copying to SCSI structures, +with their special requirements. +--- + usr/mgmt.c | 9 +++++++-- + usr/smc.c | 9 +++++++-- + usr/spc.c | 9 ++++++--- + usr/tgtadm.c | 6 +++++- + 4 files changed, 25 insertions(+), 8 deletions(-) + +diff --git a/usr/mgmt.c b/usr/mgmt.c +index de23f1469494..00a4e08c01dc 100644 +--- a/usr/mgmt.c ++++ b/usr/mgmt.c +@@ -797,11 +797,16 @@ int ipc_init(void) + goto close_lock_fd; + } + +- snprintf(mgmt_path, sizeof(mgmt_path), "%s.%d", path, control_port); ++ snprintf(mgmt_path, sizeof(mgmt_path) - 1, "%s.%d", path, control_port); ++ if (strlen(mgmt_path) > (sizeof(addr.sun_path) - 1)) { ++ eprintf("managment path too long: %s\n", mgmt_path); ++ goto close_ipc_fd; ++ } + unlink(mgmt_path); + memset(&addr, 0, sizeof(addr)); + addr.sun_family = AF_LOCAL; +- strncpy(addr.sun_path, mgmt_path, sizeof(addr.sun_path)); ++ /* no need for strncpy because we already checked length */ ++ strcpy(addr.sun_path, mgmt_path); + + err = bind(fd, (struct sockaddr *) &addr, sizeof(addr)); + if (err) { +diff --git a/usr/smc.c b/usr/smc.c +index b80aba272909..bbc7b7fc7b88 100644 +--- a/usr/smc.c ++++ b/usr/smc.c +@@ -732,8 +732,13 @@ static tgtadm_err config_slot(struct scsi_lu *lu, struct tmp_param *tmp) + adm_err = TGTADM_SUCCESS; + break; + } +- strncpy(s->barcode, tmp->barcode, sizeof(s->barcode)); +- strncpy(s->volume_tag, tmp->volume_tag, sizeof(s->volume_tag)); ++ if (strlen(tmp->barcode) > sizeof(s->barcode) || ++ strlen(tmp->volume_tag) > sizeof(s->volume_tag)) { ++ eprintf("barcode or volume tag too large?"); ++ break; ++ } ++ strcpy(s->barcode, tmp->barcode); ++ strcpy(s->volume_tag, tmp->volume_tag); + set_slot_full(s, 0, NULL); + adm_err = TGTADM_SUCCESS; + break; +diff --git a/usr/spc.c b/usr/spc.c +index 82a6ec9ee863..902d5bf4a60b 100644 +--- a/usr/spc.c ++++ b/usr/spc.c +@@ -289,9 +289,12 @@ int spc_inquiry(int host_no, struct scsi_cmd *cmd) + data[7] = 0x02; + + memset(data + 8, 0x20, 28); +- strncpy((char *)data + 8, attrs->vendor_id, VENDOR_ID_LEN); +- strncpy((char *)data + 16, attrs->product_id, PRODUCT_ID_LEN); +- strncpy((char *)data + 32, attrs->product_rev, PRODUCT_REV_LEN); ++ scsi_sprintf((char *)data + 8, VENDOR_ID_LEN, "%-*s", ++ VENDOR_ID_LEN, attrs->vendor_id); ++ scsi_sprintf((char *)data + 16, PRODUCT_ID_LEN, "%-*s", ++ PRODUCT_ID_LEN, attrs->product_id); ++ scsi_sprintf((char *)data + 32, PRODUCT_REV_LEN, "%-*s", ++ PRODUCT_REV_LEN, attrs->product_rev); + + desc = (uint16_t *)(data + 58); + for (i = 0; i < ARRAY_SIZE(attrs->version_desc); i++) +diff --git a/usr/tgtadm.c b/usr/tgtadm.c +index 5572c3888a80..cb3eb1cd126f 100644 +--- a/usr/tgtadm.c ++++ b/usr/tgtadm.c +@@ -224,7 +224,11 @@ static int ipc_mgmt_connect(int *fd) + snprintf(mgmt_path, sizeof(mgmt_path), "%s.%d", + path, control_port); + +- strncpy(addr.sun_path, mgmt_path, sizeof(addr.sun_path)); ++ if (strlen(mgmt_path) > (sizeof(addr.sun_path) - 1)) { ++ eprintf("management path too long: %s\n", mgmt_path); ++ return EINVAL; ++ } ++ strcpy(addr.sun_path, mgmt_path); + + err = connect(*fd, (struct sockaddr *) &addr, sizeof(addr)); + if (err < 0) +-- +2.16.4 + diff --git a/tgt-compare-pointer-to-null.patch b/tgt-compare-pointer-to-null.patch deleted file mode 100644 index bcd5d79..0000000 --- a/tgt-compare-pointer-to-null.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff -aurp tgt-1.0.60.orig/usr/tgtd.c tgt-1.0.60/usr/tgtd.c ---- tgt-1.0.60.orig/usr/tgtd.c 2015-07-01 17:10:39.000000000 -0700 -+++ tgt-1.0.60/usr/tgtd.c 2018-08-11 18:08:50.707873331 -0700 -@@ -310,7 +310,7 @@ int call_program(const char *cmd, void ( - pos = arg; - str_spacecpy(&pos, cmd); - if (strchr(cmd, ' ')) { -- while (pos != '\0') -+ while (pos != NULL) - argv[i++] = strsep(&pos, " "); - } else - argv[i++] = arg; diff --git a/tgt-fix-build b/tgt-fix-build index 5a572a3..675d5a2 100644 --- a/tgt-fix-build +++ b/tgt-fix-build @@ -16,22 +16,13 @@ diff --git a/usr/Makefile b/usr/Makefile index e29826c..31067e8 100644 --- a/usr/Makefile +++ b/usr/Makefile -@@ -32,12 +32,15 @@ INCLUDES += -I. +@@ -40,6 +40,9 @@ INCLUDES += -I. CFLAGS += -D_GNU_SOURCE CFLAGS += $(INCLUDES) -+ifneq ($(OPTFLAGS),) ++ifneq ($(OPTFAGS),) +CFLAGS += $(OPTFLAGS) ++endif ifneq ($(DEBUG),) CFLAGS += -g -O0 -ggdb -rdynamic else - CFLAGS += -g -O2 -fno-strict-aliasing - endif - CFLAGS += -Wall -Wstrict-prototypes -fPIC -+endif - CFLAGS += -DTGT_VERSION=\"$(VERSION)$(EXTRAVERSION)\" - CFLAGS += -DBSDIR=\"$(DESTDIR)$(libdir)/backing-store\" - --- -1.8.1.4 - diff --git a/tgt-handle-access-of-a-target-that-has-been-removed b/tgt-handle-access-of-a-target-that-has-been-removed deleted file mode 100644 index 032c9f5..0000000 --- a/tgt-handle-access-of-a-target-that-has-been-removed +++ /dev/null @@ -1,55 +0,0 @@ -From: Lee Duncan -Date: Wed, 28 Oct 2015 14:16:13 +0900 -Subject: Handle access of a target that has been removed -Git-commit: 2791ed243ab2a2fcfe48aea4a0cc23f4ad8467dc -Patch-mainline: v1.0.61 - -I recently got a report of a tgtd core dump from our opencloud -group. The stack trace showed that a strcmp against a NULL was causing -the failure: - ----------------------------------------------------------------- -Program terminated with signal 11, Segmentation fault. -(gdb) bt - name=0x6ac16f "iqn.2010-10.org.openstack:volume-e812c705-80bc-4064-a84c-5559cda8b1ca") at iscsi/target.c:216 - at iscsi/iscsid.c:654 - events=1, data=0x63a480 ) at iscsi/iscsi_tcp.c:158 ----------------------------------------------------------------- - -It looks like target_find_by_name() uses tgt_targetname(), but doesn't -account for the fact that it can return a NULL when the target being -looked up does not (now) exist: - ----------------------------------------------------------------- -char *tgt_targetname(int tid) -{ - struct target *target; - - target = target_lookup(tid); - if (!target) - return NULL; - - return target->name; -} - -Signed-off-by: FUJITA Tomonori -Acked-by: Lee Duncan ---- - usr/iscsi/target.c | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - ---- a/usr/iscsi/target.c -+++ b/usr/iscsi/target.c -@@ -369,9 +369,11 @@ void target_list_build(struct iscsi_conn - struct iscsi_target *target_find_by_name(const char *name) - { - struct iscsi_target *target; -+ char *tname; - - list_for_each_entry(target, &iscsi_targets_list, tlist) { -- if (!strcmp(tgt_targetname(target->tid), name)) -+ tname = tgt_targetname(target->tid); -+ if (tname && !strcmp(tname, name)) - return target; - } - diff --git a/tgt-include-sys-macros-for-major.patch b/tgt-include-sys-macros-for-major.patch index cb14477..c1d44da 100644 --- a/tgt-include-sys-macros-for-major.patch +++ b/tgt-include-sys-macros-for-major.patch @@ -1,9 +1,9 @@ diff -aurp tgt-1.0.60.orig/usr/bs_sg.c tgt-1.0.60/usr/bs_sg.c --- tgt-1.0.60.orig/usr/bs_sg.c 2015-07-01 17:10:39.000000000 -0700 +++ tgt-1.0.60/usr/bs_sg.c 2018-08-11 18:03:25.489712435 -0700 -@@ -36,6 +36,7 @@ - #include +@@ -38,6 +38,7 @@ #include + #include #include +#include diff --git a/tgt-missing-module-directory-not-an-error b/tgt-missing-module-directory-not-an-error deleted file mode 100644 index 32630aa..0000000 --- a/tgt-missing-module-directory-not-an-error +++ /dev/null @@ -1,26 +0,0 @@ -From: Lee Duncan -Date: Mon Nov 16 08:49:57 PST 2015 -Subject: backing-store modules directory not present is not an error - -The backing-store modules directory, normally -/usr/lib/tgt/backing-store, is not created, needed, or used when there -are no backing store modules. So change the error message printed when -the directory is not present to a debug message. - -Signed-off-by: Lee Duncan ---- - usr/bs.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - ---- a/usr/bs.c -+++ b/usr/bs.c -@@ -263,7 +263,8 @@ static int bs_init_signalfd(void) - - dir = opendir(BSDIR); - if (dir == NULL) { -- eprintf("could not open backing-store module directory %s\n", -+ /* not considered an error if there are no modules */ -+ dprintf("could not open backing-store module directory %s\n", - BSDIR); - } else { - struct dirent *dirent; diff --git a/tgt.changes b/tgt.changes index 8738464..c12beae 100644 --- a/tgt.changes +++ b/tgt.changes @@ -1,3 +1,39 @@ +------------------------------------------------------------------- +Fri Feb 15 23:19:22 UTC 2019 - lduncan@suse.com + +- Update to version v1.0.74 from version v1.0.60: + * tgt 1.0.74 + * AIO backing store now reports a list of supported opcodes + * tgt 1.0.73 + * Update tgt-admin + * fix build w/newer glibc + * Display nop_count and and nop_interval + * Quote $backing_store variable in system(), execute() and + backtick-calls + * Buffer size is stored in struct concat_buf.size field, so + use that instead of BUFSIZE since buffer size can be more + than BUFSIZE. Also, remove BUFSIZE since its not used anymore. + * tgt 1.0.72 + * smc: fix snprintf warnings with gcc7 + + This removed the tarball v1.0.60.tar.gz, and replaced it + with v1.0.74.tar.gz, which can now be gotten using the new + _service file. This also updated the SPEC file with the new + version number and the different patch set. Remaining + patches were renumbered. + + This following patches were UPDATED (refreshed): + * tgt-fix-build + * tgt-include-sys-macros-for-major.patch + + The following patches were REMOVED (no longer needed): + * tgt-handle-access-of-a-target-that-has-been-removed + * tgt-missing-module-directory-not-an-error + * tgt-compare-pointer-to-null.patch + + And the following patch was added (and submitted upstream): + * tgt-Fix-gcc7-string-truncation-warnings.patch + ------------------------------------------------------------------- Sun Aug 12 01:11:13 UTC 2018 - lduncan@suse.com diff --git a/tgt.spec b/tgt.spec index 4a6a980..cd6eea8 100644 --- a/tgt.spec +++ b/tgt.spec @@ -1,7 +1,7 @@ # # spec file for package tgt # -# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2019 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 @@ -22,22 +22,20 @@ %endif Name: tgt -Version: 1.0.60 +Version: 1.0.74 Release: 0 Summary: Generic Linux target framework (tgt) License: GPL-2.0-only Group: System/Daemons Url: http://stgt.sourceforge.net/ -Source: https://github.com/fujita/tgt/archive/v%{version}.tar.gz +Source: https://github.com/fujita/%{name}/archive/v%{version}.tar.gz Source1: %{name}d.service Source3: %{name}.services Source4: sysconfig.%{name} -Patch2: %{name}-fix-build -Patch3: setup-tgt-conf-d.patch -Patch4: %{name}-handle-access-of-a-target-that-has-been-removed -Patch5: %{name}-missing-module-directory-not-an-error -Patch6: %{name}-include-sys-macros-for-major.patch -Patch7: %{name}-compare-pointer-to-null.patch +Patch1: %{name}-fix-build +Patch2: setup-tgt-conf-d.patch +Patch3: %{name}-include-sys-macros-for-major.patch +Patch4: %{name}-Fix-gcc7-string-truncation-warnings.patch BuildRequires: docbook-xsl-stylesheets BuildRequires: libaio-devel BuildRequires: libxslt @@ -58,12 +56,10 @@ user-space daemon and tools (i.e. they completely runs in user space). %prep %setup -q +%patch1 -p1 %patch2 -p1 %patch3 -p1 %patch4 -p1 -%patch5 -p1 -%patch6 -p1 -%patch7 -p1 %build %ifarch ppc ppc64 ppc64le @@ -107,6 +103,7 @@ ln -sf service %{buildroot}/%{_sbindir}/rc%{name}d %doc doc/README.rbd doc/tmf.txt %doc %_defaultdocdir/%name/examples %doc %_defaultdocdir/%name/html +%{_mandir}/man5/* %{_mandir}/man8/* %changelog diff --git a/v1.0.60.tar.gz b/v1.0.60.tar.gz deleted file mode 100644 index 39e5ba8..0000000 --- a/v1.0.60.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:c126c3dc8fe51d188b979f859e6fc5bc37d76b16f7a753f2966f90382ce15641 -size 295175 diff --git a/v1.0.74.tar.gz b/v1.0.74.tar.gz new file mode 100644 index 0000000..5d36724 --- /dev/null +++ b/v1.0.74.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bfc202790d5326d7a18bd3928b4bb204ffb0acf443a5ec5c16a1a0fbc53be99f +size 296992