summaryrefslogtreecommitdiff
path: root/libopeniscsiusr
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* Use libkmod instead of fork/exec of modprobe.Lee Duncan2018-10-091-38/+0
| | | | | There is no reason to continue to use fork/exec to probe for modules, so remove the code that supported this.
* Limit session relogin attempts using config value.Lee Duncan2018-09-264-1/+7
| | | | | | | Add new configuration value session.relogin_max, which will default to 32. The limits the session-recovery relogin attempts to about 64 seconds (2 seconds between attempts) instead of an infinite number of retries.
* Handle ENOTCONN error separately when reading sysfs values.Lee Duncan2018-09-261-0/+31
| | | | | | This error happens when the daemon is attempting to reconnect a session when starting up, so should not be considered an internal error.
* Fix bug in error message when reading sysfs numbers.Lee Duncan2018-09-261-1/+1
| | | | | | The message printed when ENOENT was returned for a number-type sysfs value was missing the attribute name parameter.
* Fix reading of sysfs signed integers when negative.Lee Duncan2018-09-261-5/+27
| | | | | | | | | The code for reading all sysfs integer types (of all sizes) did not work when reading signed integers and the return value was negative. So when the default was -1 and the value was not present, the code tried to return -1. But the logic for checking against "max value" was incorrect, causing INT_MAX to be returned instead of -1.
* Fix incorrect sysfs logic for port and ip address.Lee Duncan2018-09-261-10/+8
| | | | | | If "port" is available and "persistent_port" is not, then correctly use the one that is present for both values. Likewise for "address" and "persistent_address".
* Allow reading sysfs "port" to fail gracefully.Lee Duncan2018-09-261-2/+2
| | | | | Do not consider it a fatal error if reading sysfs value for "port" fails, since we allow failure for "address".
* context.h: add missing stdarg.h includeFloris Bos2018-07-291-0/+1
| | | | | | | | | | | | | | | Fix compilation error on uclibc based systems: == In file included from idbm.c:59:0: context.h:27:25: error: unknown type name ‘va_list’ const char *format, va_list args); ^ <builtin>: recipe for target 'idbm.o' failed make[1]: *** [idbm.o] Error 1 == Signed-off-by: Floris Bos <bos@je-eigen-domein.nl>
* Merge pull request #106 from phmccarty/lib-symlinksChris Leech2018-06-181-2/+2
|\ | | | | Fix installation of libopeniscsiusr symlinks
| * Fix installation of libopeniscsiusr symlinksPatrick McCarty2018-05-291-2/+2
| | | | | | | | | | | | | | The install(1) command dereferences symlinks when copying to the target location, so use an alternate approach to create symlinks from scratch instead. Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
* | libopeniscsiusr: Fix compile error on GCC 8.Gris Ge2018-06-141-2/+7
| | | | | | | | | | | | | | | | Fix compile warnings (will be treated as error): * `strncpy` for stringop-truncation warning: Use memcpy instead and manually add trailing '\0'. Signed-off-by: Gris Ge <fge@redhat.com>
* | libopeniscsiusr: use asprintf and remove PATH_MAX stack buffersChris Leech2018-06-146-108/+110
| | | | | | | | | | | | This replaces the use of snprintf to a stack buffer with asprintf when creating path strings, moving temporary buffers to the heap and avoiding truncation issues.
* | libopeniscsiusr: setup ipv6 records based on iface nameChris Leech2018-06-141-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | The is_ipv6 flag (runtime iface rec representation only, not on disk) was being set when creating ifaces from sysfs, but not when reading them in from an iface record file. This caused ipv6 iface records to be reported as malformed and ignored. Fix that with a name check for an "ipv6" substring. Old code also looked at other fields, this is enough to fix iface records created from sysfs for be2iscsi and qla4xxx. Further fixes might be required for other IPv6 configurations.
* | libopeniscsiusr: clear errno before calling strtollChris Leech2018-06-141-0/+1
| | | | | | | | | | errno must be set to 0 before calling strtoll or error checking will have false positives
* | libopeniscsiusr: hosts can have multiple ifacesChris Leech2018-06-145-33/+106
| | | | | | | | | | | | | | Both be2iscsi and qla4xxx export multiple iface ojbects in sysfs per host to represent the number of network configurations (ipv4/ipv6) that can be supported. Fix the libopeniscsiusr code to create and manage multiple offload iface records per host, as the old code did.
* | libopeniscsiusr: fixes err on prefix_lenChris Leech2018-06-133-1/+8
| | | | | | | | | | | | | | The iface.prefix_len field might be present in existing records created with older versions of the Open-iSCSI tools. Need to not start throwing errors after an update.