summaryrefslogtreecommitdiff
path: root/libopeniscsiusr
Commit message (Collapse)AuthorAgeFilesLines
* libopeniscsiusr: cleanup recent reallocarray->realloc change (#369)Lee Duncan2022-09-221-4/+8
| | | | Just adding more comment, and removing the check to see if a pointer to a structure is zero.
* libopeniscsiusr: use realloc instead of reallocarray (#368)TIAN Yuanhao2022-09-221-1/+5
| | | | | | | | | | | | | | | realloc is similar to reallocarray, except it doesn't check for integer overflow when computing num * size. On 32-bit systems, integer overflow may not happen because the old array is likely to be smaller than 4G and the new array is smaller than the old array. On 64-bit systems, integer overflow can never happen because num is less than 4G and size is always 8. This fixes build errors when using uClibc. Signed-off-by: TIAN Yuanhao <tianyuanhao3@163.com> Signed-off-by: TIAN Yuanhao <tianyuanhao3@163.com>
* Use meson as the main build system (#365)Lee Duncan2022-09-214-0/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Build: Add an iscsiuio 'build_date.sh' script This is currently unused, but will be used by meson to build the "build_date.[ch]" files used by iscsiuio. * Build: have git ignore file '.setup' I commonly use this file for shell aliases/functions. * Add framework to support building using meson. This adds the ability to use meson/ninja to build open-iscsi and iscsiuio, rather than the current system that uses 'autoconf' for iscsiuio and uses 'make' for everything else. The old make/autoconf system is left in place, for now, but deprecated, including a warning about that when running 'make all' or 'make user' from the top-level. * utils/build: enhance iscsi-iname to generate prefix Added new "-g/--generate-iname-prefix" argument to generate the InitiatorName= prefix. Also, updated iscsi-iname to use getopts. Also, use the new option from meson. * git/meson: remove 'builddir' from ignored files The build directory can be called anything. Suggested by: Eli Schwartz * iscsiuio build: fix new build_date.sh script Fixed several issues: - fix option handling for "-S" - fix epoch date handling from env (noticed by Eli Schwartz) - remove debug statements * iscsiuio meson: warn when not creating a symlink for iscsiuio * meson: install man pages more efficiently We don't need to specify path or subdirectory * iscsiuio meson: remove unused source date epoch option This option was never used, since we pass this info from the environment. * meson: no need to set libdir: default is fine * iscsiuio meson: no need to add c_args: already there * Don't generate initiatorname when cross-building (#367) Let it be generated by the iscsi-init service. Signed-off-by: TIAN Yuanhao <tianyuanhao3@163.com> * Set ISCSI_CONFIG_ROOT by meson Signed-off-by: TIAN Yuanhao <tianyuanhao3@163.com> * Set LOCK_DIR from home_dir to lock_dir Signed-off-by: TIAN Yuanhao <tianyuanhao3@163.com> * Install iface.example to db_root/ifaces Signed-off-by: TIAN Yuanhao <tianyuanhao3@163.com> Signed-off-by: TIAN Yuanhao <tianyuanhao3@163.com> Co-authored-by: TIAN Yuanhao <78596099+tianyuanhao@users.noreply.github.com> Co-authored-by: TIAN Yuanhao <tianyuanhao3@163.com>
* Small bug fixes (#364)Lee Duncan2022-09-0610-135/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * build: move utils/sysdeps to top-level The routines here are used by iscsiuio, so move them to the top level. * libopeniscsiusr: fix kernel-doc bugs There were errors in four places, effecting the generated manual pages. * libopeniscsiusr: clean up kernel-doc usage Simplify generation of library interface documentation using the kernel-doc script: * make the kernel-doc perl script executble (the only visible change) * remove mention of sed (not used) * stop compressing man pages -- let distros do that * improve kernel-doc so that doc-preclean.pl and split-man.pl are no longer needed * add list-man-pages.sh to simplify things (copied from libnvme) * build: keep current version number in one place Move the current version number (now 2.1.7) into the top-level Makefile, and out of usr/version.h and libopeniscsiusr/version.h, completely eliminating the need for the latter. Note that this ties the libopeniscsiusr library idea of "version" to the usr/ (iscsid, etc) idea of version, even though they used to be defined separately. But they always had the same value, so nothing lost. * build: insteall man pages uncompressed We were delivering some man pages compressed and other not, and it turns out distros know how to install man pages using the compression they prefer, so stop doing it for them.
* make: avoid hard-coding path to sed (#357)Chris Hofstaedtler2022-07-301-1/+1
| | | | | | Just use PATH to find sed. Not all distributions have moved to a /usr-merged layout yet. Signed-off-by: Chris Hofstaedtler <zeha@debian.org>
* Add a 'distclean' Makefile top-level targetLee Duncan2022-05-091-0/+5
| | | | | | | | | | This cleans up a little more than "make clean", in particular removing files generated from templates, and automake-generated files in iscsiuio. Also, a ".PHONY:" target was added where needed so that each Makefile has a complete list of phony targets.
* Preparing for version 2.1.7.Lee Duncan2022-05-061-1/+1
|
* Merge pull request #333 from thesamesam/masterLee Duncan2022-04-101-4/+4
|\ | | | | Build system tweaks from downstream
| * libopeniscsiusr: fix version in installed pkgconfig (.pc) fileSam James2022-04-061-1/+1
| | | | | | | | | | | | | | Looks like a typo from libnvme. Previously, the installed .pc file had a blank Version field. Signed-off-by: Sam James <sam@gentoo.org>
| * Makefiles: don't hardcode sed, pkg-configSam James2022-04-061-2/+2
| | | | | | | | | | | | | | | | | | - On my system, sed appears to be at /bin/sed. So, let's allow overriding the location. - Allow different pkg-config paths too (useful for cross). Signed-off-by: Sam James <sam@gentoo.org>
| * Makefiles: respect $(CC) fully (don't hardcode GCC); use $(RM)Sam James2022-04-061-1/+1
| | | | | | | | | | | | | | - Don't hardcode GCC, instead respect the detected CC (or from the environment) - Use $(RM) as the location may vary and we've already done the work to detect it Signed-off-by: Sam James <sam@gentoo.org>
* | Build: cleanup libopeniscsiusr/MakefileLee Duncan2022-04-041-6/+6
| | | | | | | | | | Do not need redundant slashes in pathnames. Also, install header files with the proper mode.
* | Remove debug messages from libopeniscsiusr/MakefileLee Duncan2022-04-041-1/+0
| | | | | | | | | | Commit 623a81123c494 ("Use pkg-config in Makefiles for newer libraries.") added a debugging echo statement. Remove it.
* | Build: libopeniscsiusr install should install docsLee Duncan2022-04-041-1/+10
|/ | | | | | | | | We go to all the trouble to generate man pages for all the libopeniscsiusr routines, but we do not install them, so add installing them as part of the "install" target, ut break up that target into 3 sub-targets (install_libs, install_docs, and install_pkg_config) so that callers can choose subsets if they wish.
* Make DB and ISCSIHOME directories configurable.Lee Duncan2022-03-253-5/+12
| | | | | | | | | | | | | | | | | | | | This commit adds two new top-level build options: one for the "home" directory for open-iscsi called "HOMEDIR", and one for the "database" directory, called "DBROOT". One can now override the defaults of "/etc/iscsi" for either or both of these directories on the make command line. The README and man pages are updated with details about these new options. Some Makefile cleanup/repair was done as well. Installation of the initiatorname.iscsi file, was moved out of the top-level Makefile into the etc subdirectory, and installation of man ages moved from the top-level Makefile to the doc subdirectory. Also, this fixes some issues from commit fd14dd8316b1 ("Clean p Makefile build system."), which incorrectly changed the DESTDIR ariable in the Makefiles. This current commit also fixes the top-level variable names for moving DBROOT and HOMEDIR.
* General Makefile/README cleanupLee Duncan2022-03-171-1/+1
| | | | | | | Cleaning up the Makefiles, in preperation for adding the ability to move files out of /etc/iscsi more easily. Also, clean up the README file by updating it with help updated help messages, alignment, and those pesky spaces at the ends of lines.
* Preparing for version 2.1.6Lee Duncan2022-02-141-1/+1
|
* libopeniscsiusr: extend sysfs ignore_error to include EINVALChris Leech2021-12-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | The kernel change "e746f3451ec7 scsi: iscsi: Fix iface sysfs attr detection" fixed an apparently very-long-standing issue blocking iface attribute visibility in sysfs. With that fixed, and networking configuration for the iface now being readable from sysfs, iscsiadm is showing errors when be2iscsi (and probably qla4xxx from looking at the code) expose VLAN attributes but don't have a VLAN configured. Both drivers then return EINVAL on a read to vlan_id or vlan_priority. iSCSI ERROR: Error when reading '/sys/class/iscsi_iface/ipv4-iface-17-0/vlan_id': 22 # sysfs.c:iscsi_sysfs_prop_get_ll():282 iSCSI ERROR: Error when reading '/sys/class/iscsi_iface/ipv4-iface-17-0/vlan_priority': 22 # sysfs.c:iscsi_sysfs_prop_get_ll():282 This change makes the libopeniscsiusr code ignore a read return of EINVAL when ignore_error is set, treating it the same as a non-existent sysfs file for optional attributes. Signed-off-by: Chris Leech <cleech@redhat.com>
* Cosmetic cleanup on recent additionLee Duncan2021-11-111-2/+2
| | | | | cleaned up the new define using SBINDIR to match the rest of the code.
* Fixing last parts of sbindir configurationLee Duncan2021-11-112-2/+2
| | | | | Two small bits in libopeniscsi usr were missed when making sbindir configurable. One was just cosmetic.
* Finish ability to have binary location configurable.Lee Duncan2021-10-282-1/+8
| | | | | | | | | | A Recent commit, fff82c57f5df ("Use "sbindir" for path in systemd service files") added the ability to have our binaries in another location rather than /sbin (e.g. /usr/sbin), but it was incomplete. This commit finishes the job. Fixes: fff82c57f5dfe6d3db795f1195b4d2ebc497d33c
* Fix compiler error introduced with recent IPv6 commit.Lee Duncan2021-09-181-1/+1
| | | | | | | | | | | | | Commit 76350316de38 ("Handle IPv6 interfaces correctly.") added a string copy that creates this gcc-11 error message: > gcc-11 -O2 -g -Wall -Werror -Wextra -fvisibility=hidden -fPIC -I/usr/include/kmod -c -o idbm.o idbm.c > idbm.c: In function ‘_idbm_node_rec_link’: > idbm.c:999:17: error: ‘strncpy’ specified bound 65 equals destination size [-Werror=stringop-truncation] > 999 | strncpy((*node).iface.name, iface_name, ISCSI_MAX_IFACE_LEN); > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ So copy one less character, maximum.
* Preparing for version 2.1.5Lee Duncan2021-09-051-1/+1
|
* Handle IPv6 interfaces correctly.Lee Duncan2021-09-012-8/+39
| | | | | | | | | | | | | | | | | For IPv6 interface files (in iscsi/ifaces), assume the interface uses IPv4 unless it has "ipv6" in the name. Also, when creating interface files, name them ending with "ipv6.N" or "ipv4.N", where "N" is the interface number (normally zero). This was being done in one place, and this commit makes sure all places that create interface files use this convention. Note that iscsiadm cannot determine if the interface file is IPv6 vs IPv4 from the contents because of the way it processes those files: it creates a template of "legal" values, then processes the file. But it needs to know IPv4 vs IPv6 when creating the template.
* Preparing for version 2.1.42.1.4Lee Duncan2021-03-111-1/+1
|
* libopeniscsiusr: dont error loudly if a session isn't found when working ↵Chris Leech2021-02-171-5/+16
| | | | | | | | | | | through iscsi_sessions_get() Suppress the error message from iscsi_session_get when it's being called through iscsi_sessions_get now that it's not being treated as an error. There's no reason to be so alarmed the session being read in isn't specified exactly. Signed-off-by: Chris Leech <cleech@redhat.com>
* libopeniscsiusr: skip over removed sessionsChris Leech2021-02-171-2/+16
| | | | | | | | | | | | | | When looping over all sessions with iscsi_sessions_get, it's possible to race against sessions being destroyed and have the sysfs attribute files be removed before they're read. Let's not treat this as an error, and simply drop the session that failed to read from the list. I think it makes sense to treat session that disapear while they're being read as if they were already gone when the sessions directory was first scanned. Apparently having iscsiadm exit with an error when trying to get a list of sessions is a problem for OpenStack deployments. Signed-off-by: Chris Leech <cleech@redhat.com>
* libopeniscsiusr: fix error messagesChris Leech2021-02-173-8/+8
| | | | | | | | | | | | | The error message in iscsi_session_get [libopeniscsiusr/session.c:140] when a session or connection path isn't found in sysfs was failing to print the session ID, instead it printed the address of the static string for the remainder of the message ("does not exists") due to an extra comma. Additionally change all occurances of "does not exists" to "does not exist" Signed-off-by: Chris Leech <cleech@redhat.com>
* Merge pull request #244 from patsoffice/patsoffice/dir-perm-fix-RH-versionLee Duncan2021-01-182-2/+2
|\ | | | | Change mkdir permissions to 0770, adjust umask
| * Change mkdir permissions to 0770, adjust usmaskPatrick Lawrence2021-01-122-2/+2
| | | | | | | | | | | | | | - Change mkdir() permissions from 0660 to 0770 so that there are not SELinux dac_override violations. - Adjust the umask to preserve execute bit permission on directories created in iscsid and iscsiadm.
* | iscsiadm: Fix memory leak in iscsiadmWenchao Hao2020-12-301-1/+5
| | | | | | | | | | | | | | | | | | | | | | Memory allocated by iscsi_context_new() would not be freed if error occurred during parameters parser stage and goto free_ifaces is used to jump to resource clean. Since all resource clean is performed after verified, so change all goto free_ifaces to goto out where handles resource better. Signed-off-by: Wenchao Hao <haowenchao@huawei.com>
* | libopeniscsiusr: Fix memory leak in iscsi_sessions_get()Wenchao Hao2020-12-291-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If _iscsi_sids_get() gets 0 session, *session_count is 0, while calloc(*session_count, ...) might return a valid pointer although *session_count is 0. The memory allocated by calloc() would be freed in iscsi_session_free() where did not perform free operation if session_count is zero. So memory leak would occur if _iscsi_sids_get() gets 0 session, this patch just goto out on if _iscsi_sids_get() gets 0 session to avoid calloc() being called. Signed-off-by: Wenchao Hao <haowenchao@huawei.com>
* | libopeniscsiusr: Fix memory leak in iscsi_nodes_get()Wenchao Hao2020-12-291-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | If _scandir() gets 0 node, *node_count is 0, while calloc(*node_count, ...) might return a valid pointer although *node_count is 0. The memory allocated by calloc() would be freed in iscsi_nodes_free() where did not perform free operation if node_count is zero. So memory leak might occur if _scandir() get 0 node. Signed-off-by: Wenchao Hao <haowenchao@huawei.com>
* | Preparing for version 2.1.3Chris Leech2020-12-181-1/+1
| |
* | libopeniscsiusr: Compare with max int instead of max longKhem Raj2020-10-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This compares value member of int_list_tbl struct which is of unsigned int type. struct int_list_tbl { const char *name; unsigned int value; }; Clang compiler reports this comparison when -Wtautological-constant-out-of-range-compare is enabled | idbm.c:1042:2: error: result of comparison of constant 18446744073709551615 with expression of type 'unsigned int' is always true [-Werror,-Wtautological-constant-out-of-range-compare] | _rec_int_list(SESSION_CHAP_ALGS, recs, node, session.auth.chap_algs, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | idbm.c:263:23: note: expanded from macro '_rec_int_list' | if (_org->_name[_i] != ~0UL) { \ | ~~~~~~~~~~~~~~~ ^ ~~~~ Since max value for int can be less than unsinged long e.g. on LP64 its better to use UINT_MAX here Signed-off-by: Khem Raj <raj.khem@gmail.com>
* | Preparing for version 2.1.22.1.2coverity_scanLee Duncan2020-07-241-1/+1
| |
* | iscsi/libopeniscsiusr:add libopeniscsiuser_node.h to HEADERSwubo0092020-06-151-1/+2
|/
* Preparing for version 2.1.12.1.1new-versionLee Duncan2020-02-261-1/+1
|
* Fix memory leaks in libopeniscsiusr/idbm.cLee Duncan2020-02-201-4/+6
| | | | | Running "make check" in the libopeniscsiusr directory found two memory leaks. The fix was to free the memory.
* Merge pull request #183 from phmccarty/pc-fileChris Leech2020-01-081-1/+1
|\ | | | | Fix bug with libopeniscsiusr.pc
| * Fix bug with libopeniscsiusr.pcPatrick McCarty2020-01-081-1/+1
| | | | | | | | | | The library name is libopeniscsiusr, so the -l linker option should be `-lopeniscsiusr` instead of `-liscsiusr`.
* | configuration support for CHAP algorithmsChris Leech2019-12-194-0/+108
|/ | | | | | | | Introduces support for preference lists in configuration files, and uses that for the 'node.session.auth.chap_algs' setting. This is also re-used for discovery authentication, rather than have two different configurations.
* Preparing for version 2.1.02.1.0Lee Duncan2019-11-141-1/+1
| | | | | | | | | | | Updated Changelog and two include files. Note that this bumps the minor version number from 0 to 1, and starts the "patch" version number over again at 0. See https://semver.org for information on semantic versioning.
* Preparing for version 2.0.8782.0.878Lee Duncan2019-09-121-1/+1
| | | | Updated Changelog and two include files.
* Stop using /var directory for PIDfile and locksLee Duncan2019-05-141-1/+1
| | | | | Convert /var/run to /run, and convert /var/lock to /run/lock, as per modern requirements on use of the /var directory.
* When displaying interfaces, skip "iface.example"Lee Duncan2019-02-111-0/+3
| | | | | | | | This is a regression, in that "iface.example" was ignored in pre-libopeniscsiusr days. But now, if you run "iscsiadm -m iface -P1" you see a warning about iface.example not being a valid interface file. This commit skips that interface file in this case.
* Use pkg-config in Makefiles for newer libraries.Lee Duncan2018-11-121-1/+7
| | | | | | These two recently-added libraries can be in different locations on different distros, so use pkg-config to added the appropriate actions in the make files.
* Fix i586 build issues with string length overflow.Lee Duncan2018-11-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Gcc7 warns of possible string print overflow, on i586, when printing password length (via a macro), generating errors like: [ 59s] ^~~~~~~~~~~~~~~~~~~~ [ 59s] In file included from /usr/include/stdio.h:862:0, [ 59s] from idbm.h:27, [ 59s] from context.h:22, [ 59s] from idbm.c:59: [ 59s] /usr/include/bits/stdio2.h:64:10: note: '__builtin___snprintf_chk' output between 2 and 11 bytes into a destination of size 8 [ 59s] return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, [ 59s] ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~ [ 59s] __bos (__s), __fmt, __va_arg_pack ()); [ 59s] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [ 59s] cc1: all warnings being treated as errors [ 59s] make[1]: *** [<builtin>: idbm.o] Error 1 [ 59s] make[1]: Leaving directory The fix is to limit the size of the string printed, so that no overflow is possible. The print macros in usr/idbm.c were updated, as well, to match the newer version in libopeniscsiusr/idbm.c, also to help the i586 build.
* Preparing for version 2.0.8772.0.877Lee Duncan2018-10-171-1/+1
| | | | | Updated Changelog with "git shortlog 2.0.876..HEAD", and updated version number in two include files.
* Make reconnect to session on startup forever default.Lee Duncan2018-10-111-1/+1
| | | | | | | | | | | | The daemon has traditionally tried to recover stale sessions, at startup, in serial and in a forked process. A recent commit, b9afe4709900, added the ability to limit these retries, and it made the default 32. Commit 467946a945cc added back in the ability to retry forever, if the retry count was set to 0, but left the default at 32. This commit changes the default to 0, so as not to disrupt the expected reconnection behavior by default.