File usr_etc.patch of Package open-iscsi
diff -ur a/doc/iscsiadm.8.template b/doc/iscsiadm.8.template
--- a/doc/iscsiadm.8.template 2025-04-14 21:44:31.000000000 +0200
+++ b/doc/iscsiadm.8.template 2025-06-11 15:25:52.646153409 +0200
@@ -695,7 +695,7 @@
\fBsh#\fR iscsiadm \-\-mode session \-\-print
.SH FILES
.TP
-@HOMEDIR@/iscsid.conf
+@HOMEDIR@/iscsid.conf or <vendordir>/iscsi/iscsid.conf if it is not available
The configuration file read by \fBiscsid\fR and \fBiscsiadm\fR on startup.
.TP
@HOMEDIR@/initiatorname.iscsi
diff -ur a/doc/iscsid.8.template b/doc/iscsid.8.template
--- a/doc/iscsid.8.template 2025-04-14 21:44:31.000000000 +0200
+++ b/doc/iscsid.8.template 2025-06-11 15:25:52.646153409 +0200
@@ -15,7 +15,7 @@
.TP
.BI [-c|--config=]\fIconfig\-file\fP
Read configuration from \fIconfig\-file\fR rather than the default
-\fI@HOMEDIR@/iscsid.conf\fR file.
+\fI@HOMEDIR@/iscsid.conf\fR or \fI<vendordir>/iscsi/iscsid.conf\fR file.
.TP
.BI [-i|--initiatorname=]\fIiname\-file\fP
Read initiator name from \fIiname\-file\fR rather than the default
@@ -55,7 +55,7 @@
.SH FILES
.TP
-@HOMEDIR@/iscsid.conf
+@HOMEDIR@/iscsid.conf or <vendordir>/iscsi/iscsid.conf if it is not available
The configuration file read by
.B iscsid
and
diff -ur a/doc/iscsistart.8.template b/doc/iscsistart.8.template
--- a/doc/iscsistart.8.template 2025-04-14 21:44:31.000000000 +0200
+++ b/doc/iscsistart.8.template 2025-06-11 15:25:52.646153409 +0200
@@ -14,7 +14,7 @@
.TP
.BI [-c|--config=]\fIconfig\-file\fP
Read configuration from \fIconfig\-file\fR rather than the default
-\fI@HOMEDIR@/iscsid.conf\fR file.
+\fI@HOMEDIR@/iscsid.conf\fR file or \fI<vendordir>/iscsi/iscsid.conf\fR if it is not available.
.TP
.BI [-i|--initiatorname=]\fIname\fP
Set InitiatorName to name (Required if not using iBFT or OF)
diff -ur a/etc/Makefile b/etc/Makefile
--- a/etc/Makefile 2025-04-14 21:44:31.000000000 +0200
+++ b/etc/Makefile 2025-06-11 15:25:52.646153409 +0200
@@ -18,6 +18,7 @@
initddir ?= $(etcdir)/init.d
HOMEDIR ?= $(etcdir)/iscsi
+VENDORDIR ?=
SED ?= sed
INSTALL = install
@@ -38,7 +39,11 @@
IFACE_FILES = iface.example
IFACE_DEST_FILES = $(addprefix $(DESTDIR)$(DBROOT)/ifaces/,$(IFACE_FILES))
ETC_FILES = iscsid.conf
+ifneq (,$(VENDORDIR))
+ETC_DEST_FILES = $(addprefix $(DESTDIR)$(VENDORDIR)/iscsi/,$(ETC_FILES))
+else
ETC_DEST_FILES = $(addprefix $(DESTDIR)$(HOMEDIR)/,$(ETC_FILES))
+endif
INAME_DEST_FILE = $(DESTDIR)$(HOMEDIR)/initiatorname.iscsi
@@ -54,10 +59,17 @@
$(IFACE_DEST_FILES): $(DESTDIR)$(DBROOT)/ifaces/%: %
$(INSTALL) -m 644 $? $@
+ifneq (,$(VENDORDIR))
+install_etc: $(DESTDIR)$(VENDORDIR)/iscsi/ $(ETC_DEST_FILES)
+
+$(ETC_DEST_FILES): $(DESTDIR)$(VENDORDIR)/iscsi/%: %
+ $(INSTALL) -m 644 $? $@
+else
install_etc: $(DESTDIR)$(HOMEDIR) $(ETC_DEST_FILES)
$(ETC_DEST_FILES): $(DESTDIR)$(HOMEDIR)/%: %
$(INSTALL) -m 644 $? $@
+endif
install_initd_distro = $(INSTALL) -m 755 $(1) $(DESTDIR)$(initddir)/open-iscsi/
diff -ur a/etc/meson.build b/etc/meson.build
--- a/etc/meson.build 2025-04-14 21:44:31.000000000 +0200
+++ b/etc/meson.build 2025-06-11 15:33:59.891188338 +0200
@@ -6,7 +6,7 @@
iscsi_etc_iface_file_src = files('iface.example')
# for our config file
-iscsi_etc_config_file_src = files('iscsid.conf')
+iscsi_config_file_src = files('iscsid.conf')
# templated etc files
iscsi_etc_files_arr = {}
Nur in b/etc: meson.build~.
Nur in a: .gitattributes.
Nur in a: .gitignore.
diff -ur a/Makefile b/Makefile
--- a/Makefile 2025-04-14 21:44:31.000000000 +0200
+++ b/Makefile 2025-06-11 15:25:52.650153409 +0200
@@ -18,11 +18,12 @@
HOMEDIR = $(etcdir)/iscsi
DBROOT = $(etcdir)/iscsi
RULESDIR = $(etcdir)/udev/rules.d
+VENDORDIR ?=
INSTALL = /usr/bin/install
# pass these on to sub-Makefiles
-export DESTDIR prefix INSTALL SBINDIR HOMEDIR DBROOT RULESDIR ISCSI_VERSION_STR
+export DESTDIR prefix INSTALL SBINDIR HOMEDIR DBROOT RULESDIR VENDORDIR ISCSI_VERSION_STR
# Compatibility: parse old OPTFLAGS argument
ifdef OPTFLAGS
diff -ur a/meson.build b/meson.build
--- a/meson.build 2025-04-14 21:44:31.000000000 +0200
+++ b/meson.build 2025-06-11 15:32:29.135188892 +0200
@@ -19,6 +19,7 @@
fs = import('fs')
# handle options
+vendordir = get_option('vendordir')
no_systemd = get_option('no_systemd')
home_dir = get_option('homedir')
if not fs.is_absolute(home_dir)
@@ -60,7 +61,6 @@
conf.set('DBROOT', db_root)
conf.set('IQN_PREFIX', iqn_prefix)
-
# set up general C args
genl_cargs = [
'-D_GNU_SOURCE',
@@ -75,6 +75,10 @@
genl_cargs += '-DNO_SYSTEMD'
endif
+if vendordir != ''
+ genl_cargs += '-DVENDORDIR="@0@"'.format(vendordir)
+endif
+
#
# set up include directories
#
@@ -91,6 +95,14 @@
systemd_dep = dependency('libsystemd')
endif
+lib_econf = dependency(
+ 'libeconf',
+ required : false)
+
+if vendordir != '' and not lib_econf.found()
+ error('Need libeconf if vendordir is defined.')
+endif
+
# libressl doesn't support SHA3
cc = meson.get_compiler('c')
if cc.has_function('EVP_sha3_256', dependencies: crypto_dep)
@@ -186,6 +198,10 @@
if not no_systemd
usr_deps += systemd_dep
endif
+if vendordir != ''
+ usr_deps += lib_econf
+endif
+
# handle two libs that won't be found with "dependency()"
usr_deps += cc.find_library('rt')
usr_deps += cc.find_library('isns', required: get_option('isns'))
@@ -275,7 +291,11 @@
install_data(iscsi_etc_iface_file_src, install_dir: db_root / 'ifaces')
# the iscsid.conf config file
-install_data(iscsi_etc_config_file_src, install_dir: home_dir)
+if vendordir != ''
+ install_data(iscsi_config_file_src, install_dir: vendordir / 'iscsi')
+else
+ install_data(iscsi_config_file_src, install_dir: home_dir)
+endif
# create a *unique* initiatorname file
if not meson.is_cross_build()
Nur in b: meson.build~.
diff -ur a/meson_options.txt b/meson_options.txt
--- a/meson_options.txt 2025-04-14 21:44:31.000000000 +0200
+++ b/meson_options.txt 2025-06-11 15:25:52.650153409 +0200
@@ -30,3 +30,7 @@
# default iqn prefix use for iscsi-iname
option('iqn_prefix', type: 'string', value: 'iqn.2016-04.com.open-iscsi',
description: 'Set the prefix used by iscsi-iname to generate iSCSI names')
+
+option('vendordir',
+ type: 'string',
+ description : 'Directory for distribution provided configuration files')
diff -ur a/README b/README
--- a/README 2025-04-14 21:44:31.000000000 +0200
+++ b/README 2025-06-11 15:25:52.650153409 +0200
@@ -162,6 +162,8 @@
of meson)
-Disns_supported=<BOOL> Enable/disable iSNS support [true]
(set to "false" to disable use of open-isns)
+-Dvendordir=<DIR> Directory for distribution provided configuration files
+ (e.g. "/usr/etc")
Building open-iscsi/iscsiuio using make/autoconf (Deprecated)
@@ -170,13 +172,13 @@
simply run:
make [<MAKE-OPTIONS>]
- make [DESTDIR=<SOME-DIR>] install
+ make [DESTDIR=<SOME-DIR>|VENDORDIR=<SOME_DIR>] install
Where MAKE-OPTIONS are from:
- * SBINDIR=<some-dir> [/usr/bin] for executables
- * DBROOT=<some-dir> [/etc/iscsi] for iscsi database files
- * HOMEDIR=<some-dir> [/etc/iscsi] for iscsi config files
-
+ * SBINDIR=<some-dir> [/usr/bin] for executables
+ * DBROOT=<some-dir> [/etc/iscsi] for iscsi database files
+ * HOMEDIR=<some-dir> [/etc/iscsi] for iscsi config files
+ * VENDORDIR=<some-dir> Directory for distribution provided configuration files like iscsid.conf
4. Open-iSCSI daemon
====================
@@ -1238,8 +1240,9 @@
6. Configuration
================
-The default configuration file is /etc/iscsi/iscsid.conf, but the
-directory is configurable with the top-level make option "homedir".
+The default configuration file is /etc/iscsi/iscsid.conf or
+<vendordir>/iscsi/iscsid.conf (see 6.1) if it is not available.
+But the directory is configurable with the top-level make option "homedir".
The remainder of this document will assume the /etc/iscsi directory.
This file contains only configuration that could be overwritten by iSCSI
discovery, or manually updated via iscsiadm utility. Its OK if this file
@@ -1251,6 +1254,25 @@
installed in the appropriate man page directories and need to be manually
copied into e.g. /usr/local/share/man8.
+6.1 Vendor defined iscsid.conf
+==============================
+/etc/iscsi/iscsid.conf can be changed by the user/admin at any time. The disadvantage
+is that this file is also a part of distribution/vendor packages and could overwrite the
+indivial admin settings while package update again.
+For that reason open-iscsi can be compiled with a defined vendor directory (opion vendordir)
+in which a iscsid.conf is defined and which cannot be changed by the admin. This file will
+be updated while any vendor update process.
+The admin defined settings in /etc/iscsi/iscsid.conf have a higher priority than
+<vendordir>/iscsi/iscsid.conf. So <vendordir>/iscsi/iscsid.conf will be ignored completely if
+/etc/iscsi/iscsid.conf exists.
+It is also possible to change single values of iscsid.conf only and taking the rest from
+<vendordir>/iscsi/iscsid.conf. These single values can be defined in so called "Drop-ins" which
+is quite simple. The mechanism and the corresponding directories have been defined
+by the Linux Userspace API Group and are fully supported:
+https://github.com/uapi-group/specifications/blob/main/specs/configuration_files_specification.md
+
+Remark: It is up to the vendor/distributor to define the <vendordir>. E.g. in openSUSE <vendordir>
+is "/usr/etc".
7. Getting Started
==================
Nur in a: .travis.yml.
diff -ur a/usr/idbm.c b/usr/idbm.c
--- a/usr/idbm.c 2025-04-14 21:44:31.000000000 +0200
+++ b/usr/idbm.c 2025-06-11 15:25:52.650153409 +0200
@@ -45,6 +45,10 @@
#include "fw_context.h"
#include "iscsi_err.h"
+#ifdef VENDORDIR
+#include <libeconf.h>
+#endif
+
// GLOB_ONLYDIR is not defined under musl
#ifndef GLOB_ONLYDIR
#define GLOB_ONLYDIR 0x100
@@ -1211,6 +1215,35 @@
return ISCSI_ERR_INVAL;
}
+#ifdef VENDORDIR
+void idbm_recinfo_config_econf(recinfo_t *info, econf_file *file)
+{
+ econf_err error;
+ size_t counter = 0;
+ char **keys;
+
+ error = econf_getKeys (file, NULL, &counter , &keys);
+ if (error && error != ECONF_NOKEY) {
+ log_error("econf_getKeys error:%s", econf_errString(error));
+ return;
+ }
+ for (size_t i = 0; i < counter; i++) {
+ char *value;
+ error = econf_getStringValue(file, NULL, keys[i], &value);
+ if (error) {
+ log_error("couldn't fetch %s correctly: %s",
+ keys[i],
+ econf_errString(error));
+ } else {
+ idbm_rec_update_param(info, keys[i], value, 0);
+ free (value);
+ }
+ }
+
+ econf_freeArray (keys);
+}
+#endif
+
void idbm_recinfo_config(recinfo_t *info, FILE *f)
{
char name[NAME_MAXVAL];
@@ -1284,7 +1317,6 @@
static void idbm_sync_config(void)
{
char *config_file;
- FILE *f;
/* in case of no configuration file found we just
* initialize default node and default discovery records
@@ -1308,6 +1340,32 @@
return;
}
+#ifdef VENDORDIR
+ econf_file *file = NULL;
+ econf_err error;
+
+ if ( strcmp(config_file, CONFIG_FILE) == 0) {
+ /* Standard configuration file iscsid.conf. So we are reading vendor entries too */
+ error = econf_readConfig( &file,
+ ISCSI,
+ VENDORDIR,
+ "iscsid", "conf", "= \t", "#");
+ } else {
+ /* All other configuration files */
+ error = econf_readFile(&file, config_file, "= \t", "#");
+ }
+
+ if (error) {
+ log_error("parse error:%s", econf_errString(error));
+ } else {
+ idbm_recinfo_config_econf(db->dinfo_st, file);
+ idbm_recinfo_config_econf(db->dinfo_isns, file);
+ idbm_recinfo_config_econf(db->ninfo, file);
+ econf_freeFile( file );
+ }
+#else
+ FILE *f;
+
f = fopen(config_file, "r");
if (!f) {
log_debug(1, "cannot open configuration file %s. "
@@ -1321,6 +1379,7 @@
idbm_recinfo_config(db->dinfo_isns, f);
idbm_recinfo_config(db->ninfo, f);
fclose(f);
+#endif
/* update password lengths */
if (*db->drec_st.u.sendtargets.auth.password)
diff -ur a/usr/initiator.h b/usr/initiator.h
--- a/usr/initiator.h 2025-04-14 21:44:31.000000000 +0200
+++ b/usr/initiator.h 2025-06-11 15:25:52.650153409 +0200
@@ -34,8 +34,12 @@
#include "list.h"
#include "log.h"
+#ifndef ISCSI
+#define ISCSI "iscsi"
+#endif
+
#ifndef ISCSI_CONFIG_ROOT
-#define ISCSI_CONFIG_ROOT "/etc/iscsi/"
+#define ISCSI_CONFIG_ROOT "/etc/"ISCSI"/"
#endif
#define CONFIG_FILE ISCSI_CONFIG_ROOT"/iscsid.conf"
diff -ur a/usr/iscsi_util.c b/usr/iscsi_util.c
--- a/usr/iscsi_util.c 2025-04-14 21:44:31.000000000 +0200
+++ b/usr/iscsi_util.c 2025-06-11 15:25:52.650153409 +0200
@@ -39,6 +39,11 @@
#include "session_info.h"
#include "iscsi_util.h"
+#ifdef VENDORDIR
+#include <libeconf.h>
+#include "initiator.h"
+#endif
+
#ifndef PR_SET_IO_FLUSHER
#define PR_SET_IO_FLUSHER 57
#endif
@@ -217,14 +222,40 @@
*/
char *cfg_get_string_param(char *pathname, const char *key)
{
- FILE *f = NULL;
- char *line, buffer[1024];
- char *value = NULL, *param, *comment;
+ char *value = NULL;
if (!pathname) {
log_error("No pathname to load %s from", key);
return NULL;
}
+#ifdef VENDORDIR
+ econf_file *file = NULL;
+ econf_err error;
+ if ( strcmp(pathname, CONFIG_FILE) == 0) {
+ /* Standard configuration file iscsid.conf. So we are reading vendor entries too */
+ error = econf_readConfig( &file,
+ ISCSI,
+ VENDORDIR,
+ "iscsid", "conf", "= \t", "#");
+ } else {
+ /* All other configuration files */
+ error = econf_readFile(&file, pathname, "= \t", "#");
+ log_error("can't open %s configuration file %s", key, pathname);
+ }
+
+ if (error) {
+ log_error("parse error:%s", econf_errString(error));
+ } else {
+ if ((error = econf_getStringValue(file, NULL, key, &value)))
+ log_error("couldn't fetch %s correctly: %s",
+ key,
+ econf_errString(error));
+ econf_freeFile( file );
+ }
+#else
+ FILE *f = NULL;
+ char *line, buffer[1024];
+ char *param, *comment;
if ((f = fopen(pathname, "r"))) {
while ((line = fgets(buffer, sizeof (buffer), f))) {
@@ -264,11 +295,11 @@
break;
}
fclose(f);
- if (value)
- log_debug(5, "%s=%s", key, value);
} else
log_error("can't open %s configuration file %s", key, pathname);
-
+#endif
+ if (value)
+ log_debug(5, "%s=%s", key, value);
return value;
}
diff -ur a/usr/Makefile b/usr/Makefile
--- a/usr/Makefile 2025-04-14 21:44:31.000000000 +0200
+++ b/usr/Makefile 2025-06-11 15:25:52.650153409 +0200
@@ -40,6 +40,7 @@
DBROOT ?= $(etcdir)/iscsi
HOMEDIR ?= $(etcdir)/iscsi
+VENDORDIR ?=
PKG_CONFIG ?= /usr/bin/pkg-config
@@ -60,6 +61,11 @@
endif
CFLAGS += -DISCSI_DB_ROOT=\"$(DBROOT)\"
CFLAGS += -DISCSI_CONFIG_ROOT=\"$(HOMEDIR)\"
+ifneq (,$(VENDORDIR))
+CFLAGS += -DVENDORDIR=\"$(VENDORDIR)\"
+LDFLAGS += $(shell $(PKG_CONFIG) --libs libeconf)
+endif
+
PROGRAMS = iscsid iscsiadm iscsistart
PROGRAMS_DEST = $(addprefix $(DESTDIR)$(SBINDIR)/,$(PROGRAMS))