nfs-utils/0002-conffile-don-t-report-error-from-conf_init_file.patch
Neil Brown 2bd1d69add - Update to version 2.6.4
- https://kernel.org/pub/linux/utils/nfs-utils/2.6.4/2.6.4-Changelog
  - includes fixes for bsc#1210997
- Removed patchs from this release
  - 0001-export-fix-handling-of-error-from-match_fsid.patch
- Added some upstream patches
  - 0001-exportfs-remove-warning-if-neither-subtree_check-or-.patch
  - 0002-conffile-don-t-report-error-from-conf_init_file.patch
  - 0003-conffile-allow-usr-etc-to-provide-any-config-files-e.patch
  - 0004-fsidd-call-anonymous-sockets-by-their-name-only-don-.patch
  These fix minor bugs and allow config files to be in /usr/etc.
  So also move config files to /usr/etc and create directories
  foo.conf.d for each config file, so other config file can easily
  be addded.
  (boo#1216740)

OBS-URL: https://build.opensuse.org/package/show/Base:System/nfs-utils?expand=0&rev=281
2023-12-08 03:33:59 +00:00

180 lines
5.0 KiB
Diff

From ed4dc834e1722b9217fae27da1adf29ab21d6a93 Mon Sep 17 00:00:00 2001
From: NeilBrown <neilb@suse.de>
Date: Mon, 27 Nov 2023 10:30:43 -0500
Subject: [PATCH] conffile: don't report error from conf_init_file()
conf_init_file() currently reports an error if the main config file
doesn't exist - even if there are conf files in the conf.d directory.
This is only used by nfsconfcli.c. However this is not needed. If
there is a real error, and error message is already logged.
If it is simply that the file doesn't exist, that isn't really an error.
So remove the error messages and change conf_init_file() to not return
any status.
Also fix up assorted nearby white-space issues.
Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Steve Dickson <steved@redhat.com>
---
support/include/conffile.h | 2 +-
support/nfs/conffile.c | 32 ++++++++++++++------------------
tools/nfsconf/nfsconfcli.c | 15 ++-------------
3 files changed, 17 insertions(+), 32 deletions(-)
diff --git a/support/include/conffile.h b/support/include/conffile.h
index c4a3ca62860e..c04cd1ec5c0c 100644
--- a/support/include/conffile.h
+++ b/support/include/conffile.h
@@ -62,7 +62,7 @@ extern char *conf_get_str(const char *, const char *);
extern char *conf_get_str_with_def(const char *, const char *, char *);
extern char *conf_get_section(const char *, const char *, const char *);
extern char *conf_get_entry(const char *, const char *, const char *);
-extern int conf_init_file(const char *);
+extern void conf_init_file(const char *);
extern void conf_cleanup(void);
extern int conf_match_num(const char *, const char *, int);
extern int conf_remove(int, const char *, const char *);
diff --git a/support/nfs/conffile.c b/support/nfs/conffile.c
index fd4a17ad4293..6b813dd95147 100644
--- a/support/nfs/conffile.c
+++ b/support/nfs/conffile.c
@@ -658,7 +658,7 @@ conf_load_file(const char *conf_file)
return 0;
}
-static void
+static void
conf_init_dir(const char *conf_file)
{
struct dirent **namelist = NULL;
@@ -669,14 +669,14 @@ conf_init_dir(const char *conf_file)
dname = malloc(strlen(conf_file) + 3);
if (dname == NULL) {
xlog(L_WARNING, "conf_init_dir: malloc: %s", strerror(errno));
- return;
+ return;
}
sprintf(dname, "%s.d", conf_file);
n = scandir(dname, &namelist, NULL, versionsort);
if (n < 0) {
if (errno != ENOENT) {
- xlog(L_WARNING, "conf_init_dir: scandir %s: %s",
+ xlog(L_WARNING, "conf_init_dir: scandir %s: %s",
dname, strerror(errno));
}
free(dname);
@@ -691,7 +691,7 @@ conf_init_dir(const char *conf_file)
for (i = 0; i < n; i++ ) {
struct dirent *d = namelist[i];
- switch (d->d_type) {
+ switch (d->d_type) {
case DT_UNKNOWN:
case DT_REG:
case DT_LNK:
@@ -701,13 +701,13 @@ conf_init_dir(const char *conf_file)
}
if (*d->d_name == '.')
continue;
-
+
fname_len = strlen(d->d_name);
path_len = (fname_len + dname_len);
if (!fname_len || path_len > PATH_MAX) {
xlog(L_WARNING, "conf_init_dir: Too long file name: %s in %s",
d->d_name, dname);
- continue;
+ continue;
}
/*
@@ -715,7 +715,7 @@ conf_init_dir(const char *conf_file)
* that end with CONF_FILE_EXT
*/
if (fname_len <= CONF_FILE_EXT_LEN) {
- xlog(D_GENERAL, "conf_init_dir: %s: name too short",
+ xlog(D_GENERAL, "conf_init_dir: %s: name too short",
d->d_name);
continue;
}
@@ -746,31 +746,29 @@ conf_init_dir(const char *conf_file)
free(namelist[i]);
free(namelist);
free(dname);
-
+
return;
}
-int
+void
conf_init_file(const char *conf_file)
{
unsigned int i;
- int ret;
for (i = 0; i < sizeof conf_bindings / sizeof conf_bindings[0]; i++)
LIST_INIT (&conf_bindings[i]);
TAILQ_INIT (&conf_trans_queue);
- if (conf_file == NULL)
- conf_file=NFS_CONFFILE;
+ if (conf_file == NULL)
+ conf_file = NFS_CONFFILE;
/*
- * First parse the give config file
- * then parse the config.conf.d directory
+ * First parse the give config file
+ * then parse the config.conf.d directory
* (if it exists)
- *
*/
- ret = conf_load_file(conf_file);
+ conf_load_file(conf_file);
/*
* When the same variable is set in both files
@@ -779,8 +777,6 @@ conf_init_file(const char *conf_file)
* have the final say.
*/
conf_init_dir(conf_file);
-
- return ret;
}
/*
diff --git a/tools/nfsconf/nfsconfcli.c b/tools/nfsconf/nfsconfcli.c
index b2ef96d1c600..bd9d52701aa6 100644
--- a/tools/nfsconf/nfsconfcli.c
+++ b/tools/nfsconf/nfsconfcli.c
@@ -135,19 +135,8 @@ int main(int argc, char **argv)
return 1;
}
- if (mode != MODE_SET && mode != MODE_UNSET) {
- if (conf_init_file(confpath)) {
- /* config file was missing or had an error, warn about it */
- if (verbose || mode != MODE_ISSET) {
- fprintf(stderr, "Error loading config file %s\n",
- confpath);
- }
-
- /* this isnt fatal for --isset */
- if (mode != MODE_ISSET)
- return 1;
- }
- }
+ if (mode != MODE_SET && mode != MODE_UNSET)
+ conf_init_file(confpath);
/* --dump mode, output the current configuration */
if (mode == MODE_DUMP) {
--
2.43.0