]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
login,libblkid: use econf_readConfig rather than deprecated econf_readDirs
authorKarel Zak <kzak@redhat.com>
Thu, 21 Nov 2024 09:24:07 +0000 (10:24 +0100)
committerKarel Zak <kzak@redhat.com>
Thu, 21 Nov 2024 12:16:53 +0000 (13:16 +0100)
Fixes:

lib/logindefs.c: In function ‘load_defaults’:
lib/logindefs.c:257:9: warning: ‘econf_readDirs’ is deprecated: Use the econf_readConfig/econf_readConfigWithCallback instead [-Wdeprecated-declarations]
  257 |         error = econf_readDirs(&file,
      |         ^~~~~

libblkid/src/config.c: In function 'blkid_read_config':
libblkid/src/config.c:164:17: error: 'econf_readDirs' is deprecated: Use the econf_readConfig/econf_readConfigWithCallback instead [-Werror=deprecated-declarations]
  164 |                 error = econf_readDirs(&file,
      |                 ^~~~~

* check for econf_readConfig() by ./configure and moson

* add UL_VENDORDIR_PATH into pathnames.h to avoid #ifdef in code

* use #ifdef HAVE_ECONF_READCONFIG to switch between econf_readDirs()
  and the econf_readConfig()

Signed-off-by: Karel Zak <kzak@redhat.com>
configure.ac
include/pathnames.h
lib/logindefs.c
libblkid/src/config.c
meson.build

index cac5475415a177ed98c7a24efaca211aca5803c5..698da36c6ea85366b1755d338a54c2b84854659d 100644 (file)
@@ -2723,8 +2723,15 @@ AC_ARG_WITH([econf],
 
 have_econf=no
 AS_IF([test "x$with_econf" != xno], [
-  PKG_CHECK_MODULES([ECONF], [libeconf], [have_econf=yes], [have_econf=no])
-    AS_CASE([$with_econf:$have_econf],
+  PKG_CHECK_MODULES([ECONF], [libeconf],
+     [have_econf=yes
+      AC_CHECK_LIB([econf], [econf_readConfig], [
+         AC_DEFINE([HAVE_ECONF_READCONFIG], [1], [Define if econf_readConfig exist in -leconf])
+         ])
+     ],
+     [have_econf=no]
+  )
+  AS_CASE([$with_econf:$have_econf],
     [yes:no],
       [AC_MSG_ERROR([libeconf expected but libeconf not found])],
     [*:yes],
index 12628a5d182db50fb78662dd80e6b7b7cda5e36a..a30194b109be2e8c213bc42d2e15bf872ab79a21 100644 (file)
 /* Maximum number of PIDs system supports */
 #define _PATH_PROC_PIDMAX      "/proc/sys/kernel/pid_max"
 
+/* econf path */
+#if USE_VENDORDIR
+# define UL_VENDORDIR_PATH      _PATH_VENDORDIR
+#else
+# define UL_VENDORDIR_PATH      NULL
+#endif
+
 #endif /* PATHNAMES_H */
index 95631223aae45a8d95dc66c2a928e3cb8fbf5e2a..5f76ebd0f5b23ce61f5660ae91d4782b123eef4d 100644 (file)
@@ -254,14 +254,13 @@ static void load_defaults(void)
        if (file != NULL)
                free_getlogindefs_data();
 
-       error = econf_readDirs(&file,
-#if USE_VENDORDIR
-                       _PATH_VENDORDIR,
+#ifdef HAVE_ECONF_READCONFIG
+       error = econf_readConfig(&file, NULL,
+                       UL_VENDORDIR_PATH, "login", "defs", "= \t", "#");
 #else
-                       NULL,
+       error = econf_readDirs(&file,
+                       UL_VENDORDIR_PATH, "/etc", "login", "defs", "= \t", "#");
 #endif
-                       "/etc", "login", "defs", "= \t", "#");
-
        if (error)
          syslog(LOG_NOTICE, _("Error reading login.defs: %s"),
                 econf_errString(error));
index 2b089de75e6e3633bd1f0c0a3c04bb02667ec21d..dcc18f2dd3f980c7b5ab9f378613314c44903dcf 100644 (file)
@@ -23,7 +23,8 @@
 #include <stdint.h>
 #include <stdarg.h>
 #if defined (HAVE_LIBECONF)
-#include <libeconf.h>
+# include <libeconf.h>
+# include "pathnames.h"
 #endif
 
 #include "blkidP.h"
@@ -161,13 +162,13 @@ struct blkid_config *blkid_read_config(const char *filename)
                DBG(CONFIG, ul_debug("reading config file: %s.", filename));
                error = econf_readFile(&file, filename, "= \t", "#");
        } else {
-               error = econf_readDirs(&file,
-#if USE_VENDORDIR
-                                      _PATH_VENDORDIR,
+#ifdef HAVE_ECONF_READCONFIG
+               error = econf_readConfig(&file, NULL,
+                       UL_VENDORDIR_PATH, "blkid", "conf", "= \t", "#");
 #else
-                                      NULL,
+               error = econf_readDirs(&file,
+                       UL_VENDORDIR_PATH, "/etc", "blkid", "conf", "= \t", "#");
 #endif
-                                      "/etc", "blkid", "conf", "= \t", "#");
        }
 
        if (error) {
index addcca25342cb0f031436a4980ae451aef3520fa..b893656fe52944d425c0615849c81337665654ba 100644 (file)
@@ -431,6 +431,11 @@ lib_econf = dependency(
   required : get_option('econf'))
 conf.set('HAVE_LIBECONF', lib_econf.found() ? 1 : false)
 
+have = cc.has_function(
+  'econf_readConfig',
+  dependencies : lib_econf)
+conf.set('HAVE_ECONF_READCONFIG', have ? 1 : false)
+
 lib_audit = dependency(
   'audit',
   required : get_option('audit'))