Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package open-iscsi for openSUSE:Factory checked in at 2021-03-18 22:54:04 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/open-iscsi (Old) and /work/SRC/openSUSE:Factory/.open-iscsi.new.2401 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "open-iscsi" Thu Mar 18 22:54:04 2021 rev:103 rq:878613 version:unknown Changes: -------- --- /work/SRC/openSUSE:Factory/open-iscsi/open-iscsi.changes 2021-02-03 19:55:30.165658694 +0100 +++ /work/SRC/openSUSE:Factory/.open-iscsi.new.2401/open-iscsi.changes 2021-03-18 22:54:05.847476186 +0100 @@ -1,0 +2,14 @@ +Thu Mar 11 21:29:25 UTC 2021 - Lee Duncan <ldun...@suse.com> + +- Updated to latest upstream 2.1.4 as 2.1.4-suse, which contains + these changes not already present: + * Enable iscsi.service asynchronous logins, cleanup services + (bsc#1183421) + * libopeniscsiusr: dont error loudly if a session isn't found when + working through iscsi_sessions_get() + * libopeniscsiusr: skip over removed sessions + * libopeniscsiusr: fix error messages + * Avoid hardcoding pkg-config to fix cross build + * Fix iscsistart login issue when target is delayed. + +------------------------------------------------------------------- Old: ---- open-iscsi-2.1.3-suse.tar.bz2 New: ---- open-iscsi-2.1.4-suse.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ open-iscsi.spec ++++++ --- /var/tmp/diff_new_pack.6JeXHk/_old 2021-03-18 22:54:06.427476812 +0100 +++ /var/tmp/diff_new_pack.6JeXHk/_new 2021-03-18 22:54:06.431476817 +0100 @@ -17,10 +17,10 @@ %define iscsi_minor_release 1 -%define iscsi_patch_release 3 +%define iscsi_patch_release 4 %define iscsi_patch_release_suse %{iscsi_patch_release}-suse Name: open-iscsi -Version: 2.1.3 +Version: 2.1.4 Release: 0 Summary: Linux iSCSI Software Initiator License: GPL-2.0-or-later ++++++ open-iscsi-2.1.3-suse.tar.bz2 -> open-iscsi-2.1.4-suse.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/open-iscsi-2.1.3-suse/Changelog new/open-iscsi-2.1.4-suse/Changelog --- old/open-iscsi-2.1.3-suse/Changelog 2020-12-31 19:27:39.000000000 +0100 +++ new/open-iscsi-2.1.4-suse/Changelog 2021-03-12 17:47:04.000000000 +0100 @@ -1,3 +1,42 @@ +open-iscsi-2.1.3 - open-iscsi-2.1.4 + +Abhinav Rajagopalan (1): + Fix typo in util.py + +Chris Leech (3): + libopeniscsiusr: fix error messages + libopeniscsiusr: skip over removed sessions + libopeniscsiusr: dont error loudly if a session isn't found when working through iscsi_sessions_get() + +Fabian M??ller (1): + iscsid: Add NO_SYSTEMD to CFLAGS + +Helmut Grohne (1): + Avoid hardcoding pkg-config to fix cross build + +John Schaeffer (1): + Add etc/systemd/iscsi-init.service to SYSTEMDFILES Makefile variable + +Lee Duncan (4): + iscsid: Do not allow conflicting pid-file options + Fix iscsiadm segfault when exiting + Fix iscsistart login issue when target is delayed. + Enable iscsi.service asynchronous logins, cleanup services + +Matwey V. Kornilov (1): + Wants=network-online.target in iscsi.service + +Patrick Lawrence (1): + Change mkdir permissions to 0770, adjust usmask + +Wenchao Hao (4): + idbm: Fix memory leak and NULL pointer dereference in idbm_rec_update_param() + libopeniscsiusr: Fix memory leak in iscsi_nodes_get() + libopeniscsiusr: Fix memory leak in iscsi_sessions_get() + iscsiadm: Fix memory leak in iscsiadm + +--------------------------------------------------------------------------- + open-iscsi-2.1.2 - open-iscsi-2.1.3 Chris Leech (4): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/open-iscsi-2.1.3-suse/Makefile new/open-iscsi-2.1.4-suse/Makefile --- old/open-iscsi-2.1.3-suse/Makefile 2020-12-31 19:27:39.000000000 +0100 +++ new/open-iscsi-2.1.4-suse/Makefile 2021-03-12 17:47:04.000000000 +0100 @@ -29,8 +29,8 @@ IFACEFILES = etc/iface.example RULESFILES = utils/50-iscsi-firmware-login.rules SYSTEMDFILES = etc/systemd/iscsi.service \ - etc/systemd/iscsid.service etc/systemd/iscsid.socket \ etc/systemd/iscsi-init.service \ + etc/systemd/iscsid.service etc/systemd/iscsid.socket \ etc/systemd/iscsiuio.service etc/systemd/iscsiuio.socket export DESTDIR prefix INSTALL diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/open-iscsi-2.1.3-suse/doc/iscsid.8 new/open-iscsi-2.1.4-suse/doc/iscsid.8 --- old/open-iscsi-2.1.3-suse/doc/iscsid.8 2020-12-31 19:27:39.000000000 +0100 +++ new/open-iscsi-2.1.4-suse/doc/iscsid.8 2021-03-12 17:47:04.000000000 +0100 @@ -24,23 +24,28 @@ .BI [-f|--foreground] run .B iscsid -in the foreground. +in the foreground. Implies +.BR --no-pid-file . .TP -.BI [-d|--debug=]\fIdebug_level\fP +.BI [-d|--debug=] debug_level print debugging information. Valid values for debug_level are 0 to 8. .TP -.BI [-u|--uid=]\fIuid\fP -run under user ID \fIuid\fR (default is the current user ID) +.BI [-u|--uid=] uid +run under user ID \fIuid\fR (default is the current user ID). .TP -.BI [-g|--gid=]\fIgid\fP +.BI [-g|--gid=] gid run under user group ID \fIgid\fR (default is the current user group ID). .TP -.BI [-n|--no-pid-file]\fP -do not write a process ID file. +.BI [-n|--no-pid-file] +do not write a process ID file. Conflicts with the +.BI --pid= +option. .TP -.BI [-p|--pid=]\fIpid\-file\fP +.BI [-p|--pid=] pid\-file write process ID to \fIpid\-file\fR rather than the default -\fI/run/iscsid.pid\fR +\fI/run/iscsid.pid\fR. Conflicts with the +.BI --no-pid-file +option. .TP .BI [-h|--help] display this help and exit diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/open-iscsi-2.1.3-suse/etc/systemd/iscsi.service new/open-iscsi-2.1.4-suse/etc/systemd/iscsi.service --- old/open-iscsi-2.1.3-suse/etc/systemd/iscsi.service 2020-12-31 19:27:39.000000000 +0100 +++ new/open-iscsi-2.1.4-suse/etc/systemd/iscsi.service 2021-03-12 17:47:04.000000000 +0100 @@ -4,10 +4,11 @@ Before=remote-fs.target After=network-online.target iscsid.service Requires=iscsid.socket iscsi-init.service +Wants=network-online.target [Service] Type=oneshot -ExecStart=/sbin/iscsiadm -m node --loginall=automatic +ExecStart=/sbin/iscsiadm -m node --loginall=automatic -W ExecStop=/sbin/iscsiadm -m node --logoutall=automatic ExecStop=/sbin/iscsiadm -m node --logoutall=manual SuccessExitStatus=21 15 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/open-iscsi-2.1.3-suse/iscsiuio/configure.ac new/open-iscsi-2.1.4-suse/iscsiuio/configure.ac --- old/open-iscsi-2.1.3-suse/iscsiuio/configure.ac 2020-12-31 19:27:39.000000000 +0100 +++ new/open-iscsi-2.1.4-suse/iscsiuio/configure.ac 2021-03-12 17:47:04.000000000 +0100 @@ -67,10 +67,21 @@ AC_ARG_WITH([systemd], AS_HELP_STRING([--without-systemd], [Build without systemd]), [case "${withval}" in - yes) LDFLAGS="`pkg-config --libs libsystemd`" ;; - no) CFLAGS="${CFLAGS} -DNO_SYSTEMD" ;; + yes) with_libsystemd=yes ;; + no) wth_libsystemd=no ;; *) AC_MSG_ERROR([bad value $withval for --with-systemd]) ;; - esac],[LDFLAGS="`pkg-config --libs libsystemd`"]) + esac],[with_libsystemd=auto]) +AS_IF([test "$with_libsystemd" != no],[ + PKG_CHECK_MODULES([LIBSYSTEMD],[libsystemd],[LDFLAGS=$LIBSYSTEMD_LIBS],[ + if test "$with_libsystemd" = yes; then + AC_MSG_ERROR([could not find libsystemd using pkg-config]) + else + CFLAGS="${CFLAGS} -DNO_SYSTEMD" + fi + ]) +],[ + CFLAGS="${CFLAGS} -DNO_SYSTEMD" +]) AC_CONFIG_COMMANDS([default],[[ if [ -n "$SOURCE_DATE_EPOCH" ] ; then diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/open-iscsi-2.1.3-suse/libopeniscsiusr/context.c new/open-iscsi-2.1.4-suse/libopeniscsiusr/context.c --- old/open-iscsi-2.1.3-suse/libopeniscsiusr/context.c 2020-12-31 19:27:39.000000000 +0100 +++ new/open-iscsi-2.1.4-suse/libopeniscsiusr/context.c 2021-03-12 17:47:04.000000000 +0100 @@ -55,8 +55,12 @@ void iscsi_context_free(struct iscsi_context *ctx) { - if (ctx != NULL) + if (ctx == NULL) + return; + + if (ctx->db) _idbm_free(ctx->db); + free(ctx); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/open-iscsi-2.1.3-suse/libopeniscsiusr/idbm.c new/open-iscsi-2.1.4-suse/libopeniscsiusr/idbm.c --- old/open-iscsi-2.1.3-suse/libopeniscsiusr/idbm.c 2020-12-31 19:27:39.000000000 +0100 +++ new/open-iscsi-2.1.4-suse/libopeniscsiusr/idbm.c 2021-03-12 17:47:04.000000000 +0100 @@ -322,7 +322,7 @@ } if (access(LOCK_DIR, F_OK) != 0) { - if (mkdir(LOCK_DIR, 0660) != 0) { + if (mkdir(LOCK_DIR, 0770) != 0) { _error(ctx, "Could not open %s: %d %s", LOCK_DIR, errno, _strerror(errno, strerr_buff)); return LIBISCSI_ERR_IDBM; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/open-iscsi-2.1.3-suse/libopeniscsiusr/iface.c new/open-iscsi-2.1.4-suse/libopeniscsiusr/iface.c --- old/open-iscsi-2.1.3-suse/libopeniscsiusr/iface.c 2020-12-31 19:27:39.000000000 +0100 +++ new/open-iscsi-2.1.4-suse/libopeniscsiusr/iface.c 2021-03-12 17:47:04.000000000 +0100 @@ -326,7 +326,7 @@ _good(_idbm_lock(ctx), rc, out); if ((access(IFACE_CONFIG_DIR, F_OK) != 0) && - (mkdir(IFACE_CONFIG_DIR, 0660) != 0)) { + (mkdir(IFACE_CONFIG_DIR, 0770) != 0)) { errno_save = errno; _idbm_unlock(ctx); _error(ctx, "Could not make %s folder(%d %s). " diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/open-iscsi-2.1.3-suse/libopeniscsiusr/libopeniscsiusr/libopeniscsiusr.h new/open-iscsi-2.1.4-suse/libopeniscsiusr/libopeniscsiusr/libopeniscsiusr.h --- old/open-iscsi-2.1.3-suse/libopeniscsiusr/libopeniscsiusr/libopeniscsiusr.h 2020-12-31 19:27:39.000000000 +0100 +++ new/open-iscsi-2.1.4-suse/libopeniscsiusr/libopeniscsiusr/libopeniscsiusr.h 2021-03-12 17:47:04.000000000 +0100 @@ -288,7 +288,7 @@ * Output pointer of 'struct iscsi_session' pointer. Its memory * should be freed by iscsi_session_free(). * If this pointer is NULL, your program will be terminated by assert. - * If specified iSCSI session does not exists, this pointer will be set to + * If specified iSCSI session does not exist, this pointer will be set to * NULL with LIBISCSI_OK returned. * * Return: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/open-iscsi-2.1.3-suse/libopeniscsiusr/node.c new/open-iscsi-2.1.4-suse/libopeniscsiusr/node.c --- old/open-iscsi-2.1.3-suse/libopeniscsiusr/node.c 2020-12-31 19:27:39.000000000 +0100 +++ new/open-iscsi-2.1.4-suse/libopeniscsiusr/node.c 2021-03-12 17:47:04.000000000 +0100 @@ -109,6 +109,15 @@ _good(_scandir(ctx, NODE_CONFIG_DIR, &namelist, &n), rc, out); _debug(ctx, "Got %d target from %s nodes folder", n, NODE_CONFIG_DIR); + /* + * If continue with n == 0, calloc() might return a memory which failed + * to be freed in iscsi_nodes_free() + * + * So here just goto out to exit if n == 0 + */ + if (n == 0) + goto out; + *node_count = n & UINT32_MAX; *nodes = (struct iscsi_node **) calloc(*node_count, sizeof(struct iscsi_node *)); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/open-iscsi-2.1.3-suse/libopeniscsiusr/session.c new/open-iscsi-2.1.4-suse/libopeniscsiusr/session.c --- old/open-iscsi-2.1.3-suse/libopeniscsiusr/session.c 2020-12-31 19:27:39.000000000 +0100 +++ new/open-iscsi-2.1.4-suse/libopeniscsiusr/session.c 2021-03-12 17:47:04.000000000 +0100 @@ -101,8 +101,8 @@ _iscsi_getter_func_gen(iscsi_session, port, int32_t); _iscsi_getter_func_gen(iscsi_session, iface, struct iscsi_iface *); -int iscsi_session_get(struct iscsi_context *ctx, uint32_t sid, - struct iscsi_session **se) +int _iscsi_session_get(struct iscsi_context *ctx, uint32_t sid, + struct iscsi_session **se, bool verbose) { int rc = LIBISCSI_OK; char *sysfs_se_dir_path = NULL; @@ -127,18 +127,24 @@ _alloc_null_check(ctx, *se , rc, out); if (! _file_exists(sysfs_se_dir_path)) { - _info(ctx, "Sysfs path '%s' does not exists", + _info(ctx, "Sysfs path '%s' does not exist", sysfs_se_dir_path); rc = LIBISCSI_ERR_SESS_NOT_FOUND; } if (! _file_exists(sysfs_con_dir_path)) { - _info(ctx, "Sysfs path '%s' does not exists", + _info(ctx, "Sysfs path '%s' does not exist", sysfs_se_dir_path); rc = LIBISCSI_ERR_SESS_NOT_FOUND; } if (rc == LIBISCSI_ERR_SESS_NOT_FOUND) { - _error(ctx, "Specified SID %" PRIu32, "does not exists", - sid); + /* don't complain loudly if called through iscsi_sessions_get() + * the caller is not looking for a specific session, + * and the list could be changing as we work through it + */ + if (verbose) { + _error(ctx, "Specified SID %" PRIu32 " does not exist", + sid); + } goto out; } @@ -240,12 +246,18 @@ return rc; } +int iscsi_session_get(struct iscsi_context *ctx, uint32_t sid, + struct iscsi_session **se) { + return _iscsi_session_get(ctx, sid, se, true); +} + int iscsi_sessions_get(struct iscsi_context *ctx, struct iscsi_session ***sessions, uint32_t *session_count) { int rc = LIBISCSI_OK; uint32_t i = 0; + uint32_t j = 0; uint32_t *sids = NULL; assert(ctx != NULL); @@ -256,15 +268,30 @@ *session_count = 0; _good(_iscsi_sids_get(ctx, &sids, session_count), rc ,out); + if (!*session_count) + goto out; *sessions = calloc (*session_count, sizeof(struct iscsi_session *)); _alloc_null_check(ctx, *sessions, rc, out); for (i = 0; i < *session_count; ++i) { _debug(ctx, "sid %" PRIu32, sids[i]); - _good(iscsi_session_get(ctx, sids[i], &((*sessions)[i])), - rc, out); + rc = _iscsi_session_get(ctx, sids[i], &((*sessions)[j]), false); + if (rc == LIBISCSI_OK) { + /* if session info was successfully read from sysfs, advance the sessions pointer */ + j++; + } else { + /* if not, just ignore the issue and keep trying with the next session ID, + * there's always going to be an inherent race against session removal when collecting + * attribute data from sysfs + */ + _debug(ctx, "Problem reading session %" PRIu32 ", skipping.", sids[i]); + rc = LIBISCSI_OK; + } } + /* reset session count and sessions array length to what we were able to read from sysfs */ + *session_count = j; + *sessions = reallocarray(*sessions, *session_count, sizeof(struct iscsi_session *)); out: free(sids); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/open-iscsi-2.1.3-suse/libopeniscsiusr/sysfs.c new/open-iscsi-2.1.4-suse/libopeniscsiusr/sysfs.c --- old/open-iscsi-2.1.3-suse/libopeniscsiusr/sysfs.c 2020-12-31 19:27:39.000000000 +0100 +++ new/open-iscsi-2.1.4-suse/libopeniscsiusr/sysfs.c 2021-03-12 17:47:04.000000000 +0100 @@ -169,11 +169,11 @@ if (default_value == NULL) { rc = LIBISCSI_ERR_SYSFS_LOOKUP; _error(ctx, "Failed to read '%s': " - "file '%s' does not exists", prop_name, + "file '%s' does not exist", prop_name, file_path); } else { _info(ctx, "Failed to read '%s': " - "file '%s' does not exists, " + "file '%s' does not exist, " "using default value %s", prop_name, file_path, default_value); memcpy(buff, (void *) default_value, @@ -244,13 +244,13 @@ if (! ignore_error) { rc = LIBISCSI_ERR_SYSFS_LOOKUP; _error(ctx, "Failed to read '%s': " - "file '%s' does not exists", + "file '%s' does not exist", prop_name, file_path); goto out; } else { _info(ctx, "Failed to read '%s': " - "File '%s' does not exists, using ", + "File '%s' does not exist, using ", "default value %lld", prop_name, file_path, default_value); *val = default_value; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/open-iscsi-2.1.3-suse/libopeniscsiusr/version.h new/open-iscsi-2.1.4-suse/libopeniscsiusr/version.h --- old/open-iscsi-2.1.3-suse/libopeniscsiusr/version.h 2020-12-31 19:27:39.000000000 +0100 +++ new/open-iscsi-2.1.4-suse/libopeniscsiusr/version.h 2021-03-12 17:47:04.000000000 +0100 @@ -25,6 +25,6 @@ * This may not be the same value as the kernel versions because * some other maintainer could merge a patch without going through us */ -#define ISCSI_VERSION_STR "2.1.3" +#define ISCSI_VERSION_STR "2.1.4" #endif /* End of __ISCSI_OPEN_USR_VERSION_H__ */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/open-iscsi-2.1.3-suse/test/harness/util.py new/open-iscsi-2.1.4-suse/test/harness/util.py --- old/open-iscsi-2.1.3-suse/test/harness/util.py 2020-12-31 19:27:39.000000000 +0100 +++ new/open-iscsi-2.1.4-suse/test/harness/util.py 2021-03-12 17:47:04.000000000 +0100 @@ -152,7 +152,7 @@ # now validate stuff if self.version_request: - print('%s Version %s, harnes version %s' % \ + print('%s Version %s, harness version %s' % \ (prog_name, parent_version, lib_version)) sys.exit(0) Global.verbosity = self.verbosity @@ -176,7 +176,7 @@ Global.partition = '%s-part1' % Global.device else: print('Error: must start with "/dev" or "/dev/disk/by-{id,path}": %s' % \ - Global.device, file=sys.sttderr) + Global.device, file=sys.stderr) sys.exit(1) if self.subtest_list: if not user_spec_to_list(self.subtest_list): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/open-iscsi-2.1.3-suse/usr/Makefile new/open-iscsi-2.1.4-suse/usr/Makefile --- old/open-iscsi-2.1.3-suse/usr/Makefile 2020-12-31 19:27:39.000000000 +0100 +++ new/open-iscsi-2.1.4-suse/usr/Makefile 2021-03-12 17:47:04.000000000 +0100 @@ -44,6 +44,8 @@ LDFLAGS += $(shell $(PKG_CONFIG) --libs libkmod) ifeq ($(NO_SYSTEMD),) LDFLAGS += $(shell $(PKG_CONFIG) --libs libsystemd) +else +CFLAGS += -DNO_SYSTEMD endif PROGRAMS = iscsid iscsiadm iscsistart diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/open-iscsi-2.1.3-suse/usr/idbm.c new/open-iscsi-2.1.4-suse/usr/idbm.c --- old/open-iscsi-2.1.3-suse/usr/idbm.c 2020-12-31 19:27:39.000000000 +0100 +++ new/open-iscsi-2.1.4-suse/usr/idbm.c 2021-03-12 17:47:04.000000000 +0100 @@ -1014,8 +1014,8 @@ int i; int passwd_done = 0; char passwd_len[8]; - char *tmp_value, *token; - bool *found; + char *tmp_value, *token, *tmp; + bool *found = NULL; int *tmp_data; setup_passwd_len: @@ -1079,12 +1079,25 @@ if (!info[i].data) continue; tbl = (void *)info[i].opts[0]; - /* strsep is destructive, make a copy to work with */ + /* + * strsep is destructive, make a copy to work with + * tmp_value would be modified in strsep() too, so + * here make a copy of tmp_value to tmp + */ tmp_value = strdup(value); + if (!tmp_value) + return ISCSI_ERR_NOMEM; + tmp = tmp_value; + k = 0; tmp_data = malloc(info[i].data_len); + if (!tmp_data) + goto free_tmp; memset(tmp_data, ~0, info[i].data_len); + found = calloc(info[i].numopts, sizeof(bool)); + if (!found) + goto free_tmp_data; next_token: while ((token = strsep(&tmp_value, ", \n"))) { if (!strlen(token)) @@ -1113,7 +1126,7 @@ " for '%s'", token, info[i].name); } memcpy(info[i].data, tmp_data, info[i].data_len); - free(tmp_value); + free(tmp); free(tmp_data); tmp_value = NULL; tmp_data = NULL; @@ -1135,8 +1148,17 @@ return ISCSI_ERR_INVAL; +free_tmp_data: + free(tmp_data); + +free_tmp: + free(tmp); + return ISCSI_ERR_NOMEM; + updated: strlcpy((char*)info[i].value, value, VALUE_MAXVAL); + if (found) + free(found); #define check_password_param(_param) \ if (!passwd_done && !strcmp(#_param, name)) { \ @@ -1433,7 +1455,7 @@ } if (access(LOCK_DIR, F_OK) != 0) { - if (mkdir(LOCK_DIR, 0660) != 0) { + if (mkdir(LOCK_DIR, 0770) != 0) { log_error("Could not open %s: %s", LOCK_DIR, strerror(errno)); return ISCSI_ERR_IDBM; @@ -2115,7 +2137,7 @@ } mkdir_portal: - if (mkdir(portal, 0660) != 0) { + if (mkdir(portal, 0770) != 0) { log_error("Could not make dir %s err %d", portal, errno); return NULL; @@ -2150,7 +2172,7 @@ snprintf(portal, PATH_MAX, "%s", NODE_CONFIG_DIR); if (access(portal, F_OK) != 0) { - if (mkdir(portal, 0660) != 0) { + if (mkdir(portal, 0770) != 0) { log_error("Could not make %s: %s", portal, strerror(errno)); rc = ISCSI_ERR_IDBM; @@ -2160,7 +2182,7 @@ snprintf(portal, PATH_MAX, "%s/%s", NODE_CONFIG_DIR, rec->name); if (access(portal, F_OK) != 0) { - if (mkdir(portal, 0660) != 0) { + if (mkdir(portal, 0770) != 0) { log_error("Could not make %s: %s", portal, strerror(errno)); rc = ISCSI_ERR_IDBM; @@ -2220,7 +2242,7 @@ snprintf(portal, PATH_MAX, "%s/%s/%s,%d,%d", NODE_CONFIG_DIR, rec->name, rec->conn[0].address, rec->conn[0].port, rec->tpgt); if (stat(portal, &statb)) { - if (mkdir(portal, 0660) != 0) { + if (mkdir(portal, 0770) != 0) { log_error("Could not make dir %s: %s", portal, strerror(errno)); rc = ISCSI_ERR_IDBM; @@ -2272,7 +2294,7 @@ snprintf(portal, PATH_MAX, "%s", disc_type_to_config_vals[rec->type].config_root); if (access(portal, F_OK) != 0) { - if (mkdir(portal, 0660) != 0) { + if (mkdir(portal, 0770) != 0) { log_error("Could not make %s: %s", portal, strerror(errno)); rc = ISCSI_ERR_IDBM; @@ -2331,7 +2353,7 @@ break; case DISCOVERY_TYPE_FW: if (access(FW_CONFIG_DIR, F_OK) != 0) { - if (mkdir(FW_CONFIG_DIR, 0660) != 0) { + if (mkdir(FW_CONFIG_DIR, 0770) != 0) { log_error("Could not make %s: %s", FW_CONFIG_DIR, strerror(errno)); rc = ISCSI_ERR_IDBM; @@ -2345,7 +2367,7 @@ break; case DISCOVERY_TYPE_STATIC: if (access(STATIC_CONFIG_DIR, F_OK) != 0) { - if (mkdir(STATIC_CONFIG_DIR, 0660) != 0) { + if (mkdir(STATIC_CONFIG_DIR, 0770) != 0) { log_error("Could not make %s; %s", STATIC_CONFIG_DIR, strerror(errno)); rc = ISCSI_ERR_IDBM; @@ -2359,7 +2381,7 @@ break; case DISCOVERY_TYPE_ISNS: if (access(ISNS_CONFIG_DIR, F_OK) != 0) { - if (mkdir(ISNS_CONFIG_DIR, 0660) != 0) { + if (mkdir(ISNS_CONFIG_DIR, 0770) != 0) { log_error("Could not make %s: %s", ISNS_CONFIG_DIR, strerror(errno)); rc = ISCSI_ERR_IDBM; @@ -3004,7 +3026,7 @@ { /* make sure root db dir is there */ if (access(ISCSI_CONFIG_ROOT, F_OK) != 0) { - if (mkdir(ISCSI_CONFIG_ROOT, 0660) != 0) { + if (mkdir(ISCSI_CONFIG_ROOT, 0770) != 0) { log_error("Could not make %s %d", ISCSI_CONFIG_ROOT, errno); return errno; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/open-iscsi-2.1.3-suse/usr/iface.c new/open-iscsi-2.1.4-suse/usr/iface.c --- old/open-iscsi-2.1.3-suse/usr/iface.c 2020-12-31 19:27:39.000000000 +0100 +++ new/open-iscsi-2.1.4-suse/usr/iface.c 2021-03-12 17:47:04.000000000 +0100 @@ -551,7 +551,7 @@ return; if (access(IFACE_CONFIG_DIR, F_OK) != 0) { - if (mkdir(IFACE_CONFIG_DIR, 0660) != 0) { + if (mkdir(IFACE_CONFIG_DIR, 0770) != 0) { log_error("Could not make %s. HW/OFFLOAD iscsi " "may not be supported", IFACE_CONFIG_DIR); idbm_unlock(); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/open-iscsi-2.1.3-suse/usr/iscsiadm.c new/open-iscsi-2.1.4-suse/usr/iscsiadm.c --- old/open-iscsi-2.1.3-suse/usr/iscsiadm.c 2020-12-31 19:27:39.000000000 +0100 +++ new/open-iscsi-2.1.4-suse/usr/iscsiadm.c 2021-03-12 17:47:04.000000000 +0100 @@ -3582,11 +3582,11 @@ struct sigaction sa_old; struct sigaction sa_new; LIST_HEAD(ifaces); - struct iface_rec *iface = NULL, *tmp; + struct iface_rec *iface = NULL, *tmp_iface; struct node_rec *rec = NULL; uint32_t host_no = MAX_HOST_NO + 1; uint64_t index = ULLONG_MAX; - struct user_param *param; + struct user_param *param, *tmp_param; LIST_HEAD(params); struct iscsi_context *ctx = NULL; int librc = LIBISCSI_OK; @@ -3610,7 +3610,7 @@ sa_new.sa_flags = 0; sigaction(SIGINT, &sa_new, &sa_old ); - umask(0177); + umask(0077); /* enable stdout logging */ log_init(program_name, 1024, log_do_log_std, NULL); @@ -3627,7 +3627,7 @@ "Priority must be greater than or " "equal to zero.", killiscsid); rc = ISCSI_ERR_INVAL; - goto free_ifaces; + goto out; } break; case 't': @@ -3639,7 +3639,7 @@ log_error("can not recognize operation: '%s'", optarg); rc = ISCSI_ERR_INVAL; - goto free_ifaces; + goto out; } break; case 'n': @@ -3651,7 +3651,7 @@ case 'H': host_no = parse_host_info(optarg, &rc); if (rc) - goto free_ifaces; + goto out; break; case 'r': sid = iscsi_sysfs_get_sid_from_path(optarg); @@ -3659,7 +3659,7 @@ log_error("invalid sid '%s'", optarg); rc = ISCSI_ERR_INVAL; - goto free_ifaces; + goto out; } break; case 'R': @@ -3710,7 +3710,7 @@ mode = str_to_mode(optarg); rc = verify_mode_params(argc, argv, mode); if (ISCSI_SUCCESS != rc) - goto free_ifaces; + goto out; break; case 'C': sub_mode = str_to_submode(optarg); @@ -3739,11 +3739,11 @@ printf("Invalid iface name %s. Must be from " "1 to %d characters.\n", optarg, ISCSI_MAX_IFACE_LEN - 1); - goto free_ifaces; + goto out; } else if (!iface || rc) { printf("Could not add iface %s.", optarg); rc = ISCSI_ERR_INVAL; - goto free_ifaces; + goto out; } list_add_tail(&iface->list, &ifaces); @@ -3760,7 +3760,7 @@ log_error("Invalid index %s. %s.", optarg, strerror(errno)); rc = ISCSI_ERR_INVAL; - goto free_ifaces; + goto out; } break; case 'A': @@ -3778,7 +3778,7 @@ if (!param) { log_error("Cannot allocate memory for params."); rc = ISCSI_ERR_NOMEM; - goto free_ifaces; + goto out; } list_add_tail(¶m->list, ¶ms); name = NULL; @@ -3789,12 +3789,12 @@ if (optopt) { log_error("unrecognized character '%c'", optopt); rc = ISCSI_ERR_INVAL; - goto free_ifaces; + goto out; } if (killiscsid >= 0) { kill_iscsid(killiscsid, timeout); - goto free_ifaces; + goto out; } if (mode < 0) @@ -3802,14 +3802,14 @@ if (mode == MODE_FW) { rc = exec_fw_op(NULL, NULL, info_level, do_login, op); - goto free_ifaces; + goto out; } increase_max_files(); if (idbm_init(get_config_file)) { log_warning("exiting due to idbm configuration error"); rc = ISCSI_ERR_IDBM; - goto free_ifaces; + goto out; } switch (mode) { @@ -4070,12 +4070,11 @@ free(rec); iscsi_sessions_free(ses, se_count); idbm_terminate(); -free_ifaces: - list_for_each_entry_safe(iface, tmp, &ifaces, list) { + list_for_each_entry_safe(iface, tmp_iface, &ifaces, list) { list_del(&iface->list); free(iface); } - list_for_each_entry(param, ¶ms, list) { + list_for_each_entry_safe(param, tmp_param, ¶ms, list) { list_del(¶m->list); idbm_free_user_param(param); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/open-iscsi-2.1.3-suse/usr/iscsid.c new/open-iscsi-2.1.4-suse/usr/iscsid.c --- old/open-iscsi-2.1.3-suse/usr/iscsid.c 2020-12-31 19:27:39.000000000 +0100 +++ new/open-iscsi-2.1.4-suse/usr/iscsid.c 2021-03-12 17:47:04.000000000 +0100 @@ -63,7 +63,7 @@ static char program_name[] = "iscsid"; static pid_t log_pid; static gid_t gid; -static int daemonize = 1; +static bool daemonize = true; static int mgmt_ipc_fd; static int sessions_to_recover = 0; @@ -381,6 +381,8 @@ struct sigaction sa_new; int control_fd; pid_t pid; + bool pid_file_specified = false; + bool no_pid_file_specified = false; while ((ch = getopt_long(argc, argv, "c:i:fd:nu:g:p:vh", long_options, &longindex)) >= 0) { @@ -392,7 +394,7 @@ initiatorname_file = optarg; break; case 'f': - daemonize = 0; + daemonize = false; break; case 'd': log_level = atoi(optarg); @@ -405,9 +407,11 @@ break; case 'n': pid_file = NULL; + no_pid_file_specified = true; break; case 'p': pid_file = optarg; + pid_file_specified = true; break; case 'v': printf("%s version %s\n", program_name, @@ -422,6 +426,17 @@ } } + if (pid_file_specified) { + if (no_pid_file_specified) { + fprintf(stderr, "error: Conflicting PID-file options requested\n"); + usage(1); + } + if (!daemonize) { + fprintf(stderr, "error: PID file specified but unused in foreground mode\n"); + usage(1); + } + } + /* initialize logger */ log_pid = log_init(program_name, DEFAULT_AREA_SIZE, daemonize ? log_do_log_daemon : log_do_log_std, NULL); @@ -442,7 +457,7 @@ exit(ISCSI_ERR); } - umask(0177); + umask(0077); mgmt_ipc_fd = -1; control_fd = -1; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/open-iscsi-2.1.3-suse/usr/iscsistart.c new/open-iscsi-2.1.4-suse/usr/iscsistart.c --- old/open-iscsi-2.1.3-suse/usr/iscsistart.c 2020-12-31 19:27:39.000000000 +0100 +++ new/open-iscsi-2.1.4-suse/usr/iscsistart.c 2021-03-12 17:47:04.000000000 +0100 @@ -241,12 +241,25 @@ /* * Need to handle race where iscsid proc is starting up while we are * trying to connect. Retry with exponential backoff, start from 50 ms. + * + * NOTE: another race condition can occur if the system is just coming + * up, where our login request will be sent, but the login response + * takes a while. In such a case, if we timeout and give up, the + * login response may still show up once we give up, in which case + * it seems to get iscsistart into a state where it cannot try to + * login again because it thinks there's already a session. So make + * sure our timeout is long enough, on each try, to give the response + * a chance to show up. The old value of 1 second was not enough, + * so we multiply that by 10, which seems reasonable for initial + * login. */ for (msec = 50; msec <= 15000; msec <<= 1) { - rc = iscsid_exec_req(&req, &rsp, 0, ISCSID_REQ_TIMEOUT); + int tmo = ISCSID_REQ_TIMEOUT * 10; + + rc = iscsid_exec_req(&req, &rsp, 0, tmo); if (rc == 0) { return rc; - } else if (rc == ISCSI_ERR_ISCSID_NOTCONN) { + } else if (rc == ISCSI_ERR_SESSION_NOT_CONNECTED) { ts.tv_sec = msec / 1000; ts.tv_nsec = (msec % 1000) * 1000000L; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/open-iscsi-2.1.3-suse/usr/version.h new/open-iscsi-2.1.4-suse/usr/version.h --- old/open-iscsi-2.1.3-suse/usr/version.h 2020-12-31 19:27:39.000000000 +0100 +++ new/open-iscsi-2.1.4-suse/usr/version.h 2021-03-12 17:47:04.000000000 +0100 @@ -6,7 +6,7 @@ * This may not be the same value as the kernel versions because * some other maintainer could merge a patch without going through us */ -#define ISCSI_VERSION_STR "2.1.3" +#define ISCSI_VERSION_STR "2.1.4" #define ISCSI_VERSION_FILE "/sys/module/scsi_transport_iscsi/version" #endif ++++++ open-iscsi-SUSE-latest.diff.bz2 ++++++ --- /var/tmp/diff_new_pack.6JeXHk/_old 2021-03-18 22:54:06.803477219 +0100 +++ /var/tmp/diff_new_pack.6JeXHk/_new 2021-03-18 22:54:06.803477219 +0100 @@ -1,561 +0,0 @@ -diff --git a/Makefile b/Makefile -index c4f33889616d..4ccf706adcfd 100644 ---- a/Makefile -+++ b/Makefile -@@ -29,8 +29,8 @@ ETCFILES = etc/iscsid.conf - IFACEFILES = etc/iface.example - RULESFILES = utils/50-iscsi-firmware-login.rules - SYSTEMDFILES = etc/systemd/iscsi.service \ -- etc/systemd/iscsid.service etc/systemd/iscsid.socket \ - etc/systemd/iscsi-init.service \ -+ etc/systemd/iscsid.service etc/systemd/iscsid.socket \ - etc/systemd/iscsiuio.service etc/systemd/iscsiuio.socket - - export DESTDIR prefix INSTALL -diff --git a/doc/iscsid.8 b/doc/iscsid.8 -index 6f9218f74c4c..db996b410545 100644 ---- a/doc/iscsid.8 -+++ b/doc/iscsid.8 -@@ -24,23 +24,28 @@ Read initiator name from \fIiname\-file\fR rather than the default - .BI [-f|--foreground] - run - .B iscsid --in the foreground. -+in the foreground. Implies -+.BR --no-pid-file . - .TP --.BI [-d|--debug=]\fIdebug_level\fP -+.BI [-d|--debug=] debug_level - print debugging information. Valid values for debug_level are 0 to 8. - .TP --.BI [-u|--uid=]\fIuid\fP --run under user ID \fIuid\fR (default is the current user ID) -+.BI [-u|--uid=] uid -+run under user ID \fIuid\fR (default is the current user ID). - .TP --.BI [-g|--gid=]\fIgid\fP -+.BI [-g|--gid=] gid - run under user group ID \fIgid\fR (default is the current user group ID). - .TP --.BI [-n|--no-pid-file]\fP --do not write a process ID file. -+.BI [-n|--no-pid-file] -+do not write a process ID file. Conflicts with the -+.BI --pid= -+option. - .TP --.BI [-p|--pid=]\fIpid\-file\fP -+.BI [-p|--pid=] pid\-file - write process ID to \fIpid\-file\fR rather than the default --\fI/run/iscsid.pid\fR -+\fI/run/iscsid.pid\fR. Conflicts with the -+.BI --no-pid-file -+option. - .TP - .BI [-h|--help] - display this help and exit -diff --git a/libopeniscsiusr/context.c b/libopeniscsiusr/context.c -index fe92155eb0a3..c5e869f498dd 100644 ---- a/libopeniscsiusr/context.c -+++ b/libopeniscsiusr/context.c -@@ -55,8 +55,12 @@ struct iscsi_context *iscsi_context_new(void) - - void iscsi_context_free(struct iscsi_context *ctx) - { -- if (ctx != NULL) -+ if (ctx == NULL) -+ return; -+ -+ if (ctx->db) - _idbm_free(ctx->db); -+ - free(ctx); - } - -diff --git a/libopeniscsiusr/idbm.c b/libopeniscsiusr/idbm.c -index 060196fc7afc..0910c63ba56b 100644 ---- a/libopeniscsiusr/idbm.c -+++ b/libopeniscsiusr/idbm.c -@@ -322,7 +322,7 @@ int _idbm_lock(struct iscsi_context *ctx) - } - - if (access(LOCK_DIR, F_OK) != 0) { -- if (mkdir(LOCK_DIR, 0660) != 0) { -+ if (mkdir(LOCK_DIR, 0770) != 0) { - _error(ctx, "Could not open %s: %d %s", LOCK_DIR, errno, - _strerror(errno, strerr_buff)); - return LIBISCSI_ERR_IDBM; -diff --git a/libopeniscsiusr/iface.c b/libopeniscsiusr/iface.c -index e7938a5e4709..4d573fb72a1c 100644 ---- a/libopeniscsiusr/iface.c -+++ b/libopeniscsiusr/iface.c -@@ -326,7 +326,7 @@ int iscsi_default_iface_setup(struct iscsi_context *ctx) - _good(_idbm_lock(ctx), rc, out); - - if ((access(IFACE_CONFIG_DIR, F_OK) != 0) && -- (mkdir(IFACE_CONFIG_DIR, 0660) != 0)) { -+ (mkdir(IFACE_CONFIG_DIR, 0770) != 0)) { - errno_save = errno; - _idbm_unlock(ctx); - _error(ctx, "Could not make %s folder(%d %s). " -diff --git a/libopeniscsiusr/node.c b/libopeniscsiusr/node.c -index 6bec201df603..0bf357bf7d3d 100644 ---- a/libopeniscsiusr/node.c -+++ b/libopeniscsiusr/node.c -@@ -109,6 +109,15 @@ int iscsi_nodes_get(struct iscsi_context *ctx, struct iscsi_node ***nodes, - - _good(_scandir(ctx, NODE_CONFIG_DIR, &namelist, &n), rc, out); - _debug(ctx, "Got %d target from %s nodes folder", n, NODE_CONFIG_DIR); -+ /* -+ * If continue with n == 0, calloc() might return a memory which failed -+ * to be freed in iscsi_nodes_free() -+ * -+ * So here just goto out to exit if n == 0 -+ */ -+ if (n == 0) -+ goto out; -+ - *node_count = n & UINT32_MAX; - *nodes = (struct iscsi_node **) calloc(*node_count, - sizeof(struct iscsi_node *)); -diff --git a/libopeniscsiusr/session.c b/libopeniscsiusr/session.c -index 98601dcf807e..7ace4d6b9141 100644 ---- a/libopeniscsiusr/session.c -+++ b/libopeniscsiusr/session.c -@@ -256,6 +256,8 @@ int iscsi_sessions_get(struct iscsi_context *ctx, - *session_count = 0; - - _good(_iscsi_sids_get(ctx, &sids, session_count), rc ,out); -+ if (!*session_count) -+ goto out; - - *sessions = calloc (*session_count, sizeof(struct iscsi_session *)); - _alloc_null_check(ctx, *sessions, rc, out); -diff --git a/test/harness/util.py b/test/harness/util.py -index f6c2a3275ae5..d2a7b631a133 100644 ---- a/test/harness/util.py -+++ b/test/harness/util.py -@@ -152,7 +152,7 @@ def new_parseArgs(self, argv): - - # now validate stuff - if self.version_request: -- print('%s Version %s, harnes version %s' % \ -+ print('%s Version %s, harness version %s' % \ - (prog_name, parent_version, lib_version)) - sys.exit(0) - Global.verbosity = self.verbosity -@@ -176,7 +176,7 @@ def new_parseArgs(self, argv): - Global.partition = '%s-part1' % Global.device - else: - print('Error: must start with "/dev" or "/dev/disk/by-{id,path}": %s' % \ -- Global.device, file=sys.sttderr) -+ Global.device, file=sys.stderr) - sys.exit(1) - if self.subtest_list: - if not user_spec_to_list(self.subtest_list): -diff --git a/usr/Makefile b/usr/Makefile -index 0de5e436c798..cdaf458198cf 100644 ---- a/usr/Makefile -+++ b/usr/Makefile -@@ -44,6 +44,8 @@ ISCSI_LIB = -L$(TOPDIR)/libopeniscsiusr -lopeniscsiusr - LDFLAGS += $(shell $(PKG_CONFIG) --libs libkmod) - ifeq ($(NO_SYSTEMD),) - LDFLAGS += $(shell $(PKG_CONFIG) --libs libsystemd) -+else -+CFLAGS += -DNO_SYSTEMD - endif - PROGRAMS = iscsid iscsiadm iscsistart - -diff --git a/usr/idbm.c b/usr/idbm.c -index f8b50f10309c..b94b61701a13 100644 ---- a/usr/idbm.c -+++ b/usr/idbm.c -@@ -1014,8 +1014,8 @@ int idbm_rec_update_param(recinfo_t *info, char *name, char *value, - int i; - int passwd_done = 0; - char passwd_len[8]; -- char *tmp_value, *token; -- bool *found; -+ char *tmp_value, *token, *tmp; -+ bool *found = NULL; - int *tmp_data; - - setup_passwd_len: -@@ -1079,12 +1079,25 @@ setup_passwd_len: - if (!info[i].data) - continue; - tbl = (void *)info[i].opts[0]; -- /* strsep is destructive, make a copy to work with */ -+ /* -+ * strsep is destructive, make a copy to work with -+ * tmp_value would be modified in strsep() too, so -+ * here make a copy of tmp_value to tmp -+ */ - tmp_value = strdup(value); -+ if (!tmp_value) -+ return ISCSI_ERR_NOMEM; -+ tmp = tmp_value; -+ - k = 0; - tmp_data = malloc(info[i].data_len); -+ if (!tmp_data) -+ goto free_tmp; - memset(tmp_data, ~0, info[i].data_len); -+ - found = calloc(info[i].numopts, sizeof(bool)); -+ if (!found) -+ goto free_tmp_data; - - next_token: while ((token = strsep(&tmp_value, ", \n"))) { - if (!strlen(token)) -@@ -1113,7 +1126,7 @@ next_token: while ((token = strsep(&tmp_value, ", \n"))) { - " for '%s'", token, info[i].name); - } - memcpy(info[i].data, tmp_data, info[i].data_len); -- free(tmp_value); -+ free(tmp); - free(tmp_data); - tmp_value = NULL; - tmp_data = NULL; -@@ -1135,8 +1148,17 @@ next_token: while ((token = strsep(&tmp_value, ", \n"))) { - - return ISCSI_ERR_INVAL; - -+free_tmp_data: -+ free(tmp_data); -+ -+free_tmp: -+ free(tmp); -+ return ISCSI_ERR_NOMEM; -+ - updated: - strlcpy((char*)info[i].value, value, VALUE_MAXVAL); -+ if (found) -+ free(found); - - #define check_password_param(_param) \ - if (!passwd_done && !strcmp(#_param, name)) { \ -@@ -1433,7 +1455,7 @@ int idbm_lock(void) - } - - if (access(LOCK_DIR, F_OK) != 0) { -- if (mkdir(LOCK_DIR, 0660) != 0) { -+ if (mkdir(LOCK_DIR, 0770) != 0) { - log_error("Could not open %s: %s", LOCK_DIR, - strerror(errno)); - return ISCSI_ERR_IDBM; -@@ -2115,7 +2137,7 @@ static FILE *idbm_open_rec_w(char *portal, char *config) - } - - mkdir_portal: -- if (mkdir(portal, 0660) != 0) { -+ if (mkdir(portal, 0770) != 0) { - log_error("Could not make dir %s err %d", - portal, errno); - return NULL; -@@ -2150,7 +2172,7 @@ static int idbm_rec_write(node_rec_t *rec, bool disable_lock) - - snprintf(portal, PATH_MAX, "%s", NODE_CONFIG_DIR); - if (access(portal, F_OK) != 0) { -- if (mkdir(portal, 0660) != 0) { -+ if (mkdir(portal, 0770) != 0) { - log_error("Could not make %s: %s", portal, - strerror(errno)); - rc = ISCSI_ERR_IDBM; -@@ -2160,7 +2182,7 @@ static int idbm_rec_write(node_rec_t *rec, bool disable_lock) - - snprintf(portal, PATH_MAX, "%s/%s", NODE_CONFIG_DIR, rec->name); - if (access(portal, F_OK) != 0) { -- if (mkdir(portal, 0660) != 0) { -+ if (mkdir(portal, 0770) != 0) { - log_error("Could not make %s: %s", portal, - strerror(errno)); - rc = ISCSI_ERR_IDBM; -@@ -2220,7 +2242,7 @@ mkdir_portal: - snprintf(portal, PATH_MAX, "%s/%s/%s,%d,%d", NODE_CONFIG_DIR, - rec->name, rec->conn[0].address, rec->conn[0].port, rec->tpgt); - if (stat(portal, &statb)) { -- if (mkdir(portal, 0660) != 0) { -+ if (mkdir(portal, 0770) != 0) { - log_error("Could not make dir %s: %s", - portal, strerror(errno)); - rc = ISCSI_ERR_IDBM; -@@ -2272,7 +2294,7 @@ idbm_discovery_write(discovery_rec_t *rec) - snprintf(portal, PATH_MAX, "%s", - disc_type_to_config_vals[rec->type].config_root); - if (access(portal, F_OK) != 0) { -- if (mkdir(portal, 0660) != 0) { -+ if (mkdir(portal, 0770) != 0) { - log_error("Could not make %s: %s", portal, - strerror(errno)); - rc = ISCSI_ERR_IDBM; -@@ -2331,7 +2353,7 @@ static int setup_disc_to_node_link(char *disc_portal, node_rec_t *rec) - break; - case DISCOVERY_TYPE_FW: - if (access(FW_CONFIG_DIR, F_OK) != 0) { -- if (mkdir(FW_CONFIG_DIR, 0660) != 0) { -+ if (mkdir(FW_CONFIG_DIR, 0770) != 0) { - log_error("Could not make %s: %s", - FW_CONFIG_DIR, strerror(errno)); - rc = ISCSI_ERR_IDBM; -@@ -2345,7 +2367,7 @@ static int setup_disc_to_node_link(char *disc_portal, node_rec_t *rec) - break; - case DISCOVERY_TYPE_STATIC: - if (access(STATIC_CONFIG_DIR, F_OK) != 0) { -- if (mkdir(STATIC_CONFIG_DIR, 0660) != 0) { -+ if (mkdir(STATIC_CONFIG_DIR, 0770) != 0) { - log_error("Could not make %s; %s", - STATIC_CONFIG_DIR, strerror(errno)); - rc = ISCSI_ERR_IDBM; -@@ -2359,7 +2381,7 @@ static int setup_disc_to_node_link(char *disc_portal, node_rec_t *rec) - break; - case DISCOVERY_TYPE_ISNS: - if (access(ISNS_CONFIG_DIR, F_OK) != 0) { -- if (mkdir(ISNS_CONFIG_DIR, 0660) != 0) { -+ if (mkdir(ISNS_CONFIG_DIR, 0770) != 0) { - log_error("Could not make %s: %s", - ISNS_CONFIG_DIR, strerror(errno)); - rc = ISCSI_ERR_IDBM; -@@ -3004,7 +3026,7 @@ int idbm_init(idbm_get_config_file_fn *fn) - { - /* make sure root db dir is there */ - if (access(ISCSI_CONFIG_ROOT, F_OK) != 0) { -- if (mkdir(ISCSI_CONFIG_ROOT, 0660) != 0) { -+ if (mkdir(ISCSI_CONFIG_ROOT, 0770) != 0) { - log_error("Could not make %s %d", ISCSI_CONFIG_ROOT, - errno); - return errno; -diff --git a/usr/iface.c b/usr/iface.c -index 11f3d2ac8778..21d52b307191 100644 ---- a/usr/iface.c -+++ b/usr/iface.c -@@ -551,7 +551,7 @@ void iface_setup_host_bindings(void) - return; - - if (access(IFACE_CONFIG_DIR, F_OK) != 0) { -- if (mkdir(IFACE_CONFIG_DIR, 0660) != 0) { -+ if (mkdir(IFACE_CONFIG_DIR, 0770) != 0) { - log_error("Could not make %s. HW/OFFLOAD iscsi " - "may not be supported", IFACE_CONFIG_DIR); - idbm_unlock(); -diff --git a/usr/iscsiadm.c b/usr/iscsiadm.c -index ea1643bb2586..41b7e6f25539 100644 ---- a/usr/iscsiadm.c -+++ b/usr/iscsiadm.c -@@ -3582,11 +3582,11 @@ main(int argc, char **argv) - struct sigaction sa_old; - struct sigaction sa_new; - LIST_HEAD(ifaces); -- struct iface_rec *iface = NULL, *tmp; -+ struct iface_rec *iface = NULL, *tmp_iface; - struct node_rec *rec = NULL; - uint32_t host_no = MAX_HOST_NO + 1; - uint64_t index = ULLONG_MAX; -- struct user_param *param; -+ struct user_param *param, *tmp_param; - LIST_HEAD(params); - struct iscsi_context *ctx = NULL; - int librc = LIBISCSI_OK; -@@ -3610,7 +3610,7 @@ main(int argc, char **argv) - sa_new.sa_flags = 0; - sigaction(SIGINT, &sa_new, &sa_old ); - -- umask(0177); -+ umask(0077); - - /* enable stdout logging */ - log_init(program_name, 1024, log_do_log_std, NULL); -@@ -3627,7 +3627,7 @@ main(int argc, char **argv) - "Priority must be greater than or " - "equal to zero.", killiscsid); - rc = ISCSI_ERR_INVAL; -- goto free_ifaces; -+ goto out; - } - break; - case 't': -@@ -3639,7 +3639,7 @@ main(int argc, char **argv) - log_error("can not recognize operation: '%s'", - optarg); - rc = ISCSI_ERR_INVAL; -- goto free_ifaces; -+ goto out; - } - break; - case 'n': -@@ -3651,7 +3651,7 @@ main(int argc, char **argv) - case 'H': - host_no = parse_host_info(optarg, &rc); - if (rc) -- goto free_ifaces; -+ goto out; - break; - case 'r': - sid = iscsi_sysfs_get_sid_from_path(optarg); -@@ -3659,7 +3659,7 @@ main(int argc, char **argv) - log_error("invalid sid '%s'", - optarg); - rc = ISCSI_ERR_INVAL; -- goto free_ifaces; -+ goto out; - } - break; - case 'R': -@@ -3710,7 +3710,7 @@ main(int argc, char **argv) - mode = str_to_mode(optarg); - rc = verify_mode_params(argc, argv, mode); - if (ISCSI_SUCCESS != rc) -- goto free_ifaces; -+ goto out; - break; - case 'C': - sub_mode = str_to_submode(optarg); -@@ -3739,11 +3739,11 @@ main(int argc, char **argv) - printf("Invalid iface name %s. Must be from " - "1 to %d characters.\n", - optarg, ISCSI_MAX_IFACE_LEN - 1); -- goto free_ifaces; -+ goto out; - } else if (!iface || rc) { - printf("Could not add iface %s.", optarg); - rc = ISCSI_ERR_INVAL; -- goto free_ifaces; -+ goto out; - } - - list_add_tail(&iface->list, &ifaces); -@@ -3760,7 +3760,7 @@ main(int argc, char **argv) - log_error("Invalid index %s. %s.", - optarg, strerror(errno)); - rc = ISCSI_ERR_INVAL; -- goto free_ifaces; -+ goto out; - } - break; - case 'A': -@@ -3778,7 +3778,7 @@ main(int argc, char **argv) - if (!param) { - log_error("Cannot allocate memory for params."); - rc = ISCSI_ERR_NOMEM; -- goto free_ifaces; -+ goto out; - } - list_add_tail(¶m->list, ¶ms); - name = NULL; -@@ -3789,12 +3789,12 @@ main(int argc, char **argv) - if (optopt) { - log_error("unrecognized character '%c'", optopt); - rc = ISCSI_ERR_INVAL; -- goto free_ifaces; -+ goto out; - } - - if (killiscsid >= 0) { - kill_iscsid(killiscsid, timeout); -- goto free_ifaces; -+ goto out; - } - - if (mode < 0) -@@ -3802,14 +3802,14 @@ main(int argc, char **argv) - - if (mode == MODE_FW) { - rc = exec_fw_op(NULL, NULL, info_level, do_login, op); -- goto free_ifaces; -+ goto out; - } - - increase_max_files(); - if (idbm_init(get_config_file)) { - log_warning("exiting due to idbm configuration error"); - rc = ISCSI_ERR_IDBM; -- goto free_ifaces; -+ goto out; - } - - switch (mode) { -@@ -4070,12 +4070,11 @@ out: - free(rec); - iscsi_sessions_free(ses, se_count); - idbm_terminate(); --free_ifaces: -- list_for_each_entry_safe(iface, tmp, &ifaces, list) { -+ list_for_each_entry_safe(iface, tmp_iface, &ifaces, list) { - list_del(&iface->list); - free(iface); - } -- list_for_each_entry(param, ¶ms, list) { -+ list_for_each_entry_safe(param, tmp_param, ¶ms, list) { - list_del(¶m->list); - idbm_free_user_param(param); - } -diff --git a/usr/iscsid.c b/usr/iscsid.c -index 3544870e813a..dc54fec39764 100644 ---- a/usr/iscsid.c -+++ b/usr/iscsid.c -@@ -63,7 +63,7 @@ struct iscsi_daemon_config *dconfig = &daemon_config; - static char program_name[] = "iscsid"; - static pid_t log_pid; - static gid_t gid; --static int daemonize = 1; -+static bool daemonize = true; - static int mgmt_ipc_fd; - static int sessions_to_recover = 0; - -@@ -381,6 +381,8 @@ int main(int argc, char *argv[]) - struct sigaction sa_new; - int control_fd; - pid_t pid; -+ bool pid_file_specified = false; -+ bool no_pid_file_specified = false; - - while ((ch = getopt_long(argc, argv, "c:i:fd:nu:g:p:vh", long_options, - &longindex)) >= 0) { -@@ -392,7 +394,7 @@ int main(int argc, char *argv[]) - initiatorname_file = optarg; - break; - case 'f': -- daemonize = 0; -+ daemonize = false; - break; - case 'd': - log_level = atoi(optarg); -@@ -405,9 +407,11 @@ int main(int argc, char *argv[]) - break; - case 'n': - pid_file = NULL; -+ no_pid_file_specified = true; - break; - case 'p': - pid_file = optarg; -+ pid_file_specified = true; - break; - case 'v': - printf("%s version %s\n", program_name, -@@ -422,6 +426,17 @@ int main(int argc, char *argv[]) - } - } - -+ if (pid_file_specified) { -+ if (no_pid_file_specified) { -+ fprintf(stderr, "error: Conflicting PID-file options requested\n"); -+ usage(1); -+ } -+ if (!daemonize) { -+ fprintf(stderr, "error: PID file specified but unused in foreground mode\n"); -+ usage(1); -+ } -+ } -+ - /* initialize logger */ - log_pid = log_init(program_name, DEFAULT_AREA_SIZE, - daemonize ? log_do_log_daemon : log_do_log_std, NULL); -@@ -442,7 +457,7 @@ int main(int argc, char *argv[]) - exit(ISCSI_ERR); - } - -- umask(0177); -+ umask(0077); - - mgmt_ipc_fd = -1; - control_fd = -1;