[PATCH] nss: Finish renaming of HAVE_BSD_NSS macro

Michal Privoznik posted 1 patch 3 years, 7 months ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/888d90f679bbde54e9f18ef9d342afbb2ff51a20.1598952418.git.mprivozn@redhat.com
tools/nss/libvirt_nss.c | 6 +++---
tools/nss/libvirt_nss.h | 4 ++--
2 files changed, 5 insertions(+), 5 deletions(-)
[PATCH] nss: Finish renaming of HAVE_BSD_NSS macro
Posted by Michal Privoznik 3 years, 7 months ago
When switching to meson, some of HAVE_* macros were renamed to
WITH_ because they did not reflect whether the build platform has
or doesn't have something, but whether we are building with some
functionality turned on or off. This is the case with
HAVE_BSD_NSS macro too. As a result, the NSS plugin built on BSD
did not expose nss_module_register() function which made the
plugin unusable:

https://www.redhat.com/archives/libvir-list/2020-September/msg00000.html

Fixes: c74268705557a6781788ba011492c15df2e3df11
Reported-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 tools/nss/libvirt_nss.c | 6 +++---
 tools/nss/libvirt_nss.h | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/tools/nss/libvirt_nss.c b/tools/nss/libvirt_nss.c
index 3b89f72742..6331c65131 100644
--- a/tools/nss/libvirt_nss.c
+++ b/tools/nss/libvirt_nss.c
@@ -37,7 +37,7 @@
 #include <time.h>
 
 
-#if defined(HAVE_BSD_NSS)
+#if defined(WITH_BSD_NSS)
 # include <nsswitch.h>
 #endif
 
@@ -451,7 +451,7 @@ NSS_NAME(gethostbyname4)(const char *name, struct gaih_addrtuple **pat,
 }
 #endif /* HAVE_STRUCT_GAIH_ADDRTUPLE */
 
-#if defined(HAVE_BSD_NSS)
+#if defined(WITH_BSD_NSS)
 NSS_METHOD_PROTOTYPE(_nss_compat_getaddrinfo);
 NSS_METHOD_PROTOTYPE(_nss_compat_gethostbyname2_r);
 
@@ -598,4 +598,4 @@ nss_module_register(const char *name __attribute__((unused)),
     *unregister = NULL;
     return methods;
 }
-#endif /* HAVE_BSD_NSS */
+#endif /* WITH_BSD_NSS */
diff --git a/tools/nss/libvirt_nss.h b/tools/nss/libvirt_nss.h
index 95ebafdc71..121b9e8722 100644
--- a/tools/nss/libvirt_nss.h
+++ b/tools/nss/libvirt_nss.h
@@ -84,8 +84,8 @@ NSS_NAME(gethostbyname4)(const char *name, struct gaih_addrtuple **pat,
                          int *herrnop, int32_t *ttlp);
 #endif /* HAVE_STRUCT_GAIH_ADDRTUPLE */
 
-#if defined(HAVE_BSD_NSS)
+#if defined(WITH_BSD_NSS)
 ns_mtab*
 nss_module_register(const char *name, unsigned int *size,
                     nss_module_unregister_fn *unregister);
-#endif /* HAVE_BSD_NSS */
+#endif /* WITH_BSD_NSS */
-- 
2.26.2

Re: [PATCH] nss: Finish renaming of HAVE_BSD_NSS macro
Posted by Daniel P. Berrangé 3 years, 7 months ago
On Tue, Sep 01, 2020 at 11:26:58AM +0200, Michal Privoznik wrote:
> When switching to meson, some of HAVE_* macros were renamed to
> WITH_ because they did not reflect whether the build platform has
> or doesn't have something, but whether we are building with some
> functionality turned on or off. This is the case with
> HAVE_BSD_NSS macro too. As a result, the NSS plugin built on BSD
> did not expose nss_module_register() function which made the
> plugin unusable:

I've always thought the whole  HAVE_ vs WITH_ distinction is a pretty
arbitrary and unhelpful part of autoconf.

Given this stat:

$ git grep WITH_ | grep meson | wc -l
261
$ git grep HAVE_ | grep meson | wc -l
31

I think we should try to eliminate 100% of using of HAVE_ so that all our
conditionals use WITH_


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

Re: [PATCH] nss: Finish renaming of HAVE_BSD_NSS macro
Posted by Michal Privoznik 3 years, 6 months ago
On 9/1/20 11:42 AM, Daniel P. Berrangé wrote:
> On Tue, Sep 01, 2020 at 11:26:58AM +0200, Michal Privoznik wrote:
>> When switching to meson, some of HAVE_* macros were renamed to
>> WITH_ because they did not reflect whether the build platform has
>> or doesn't have something, but whether we are building with some
>> functionality turned on or off. This is the case with
>> HAVE_BSD_NSS macro too. As a result, the NSS plugin built on BSD
>> did not expose nss_module_register() function which made the
>> plugin unusable:
> 
> I've always thought the whole  HAVE_ vs WITH_ distinction is a pretty
> arbitrary and unhelpful part of autoconf.
> 
> Given this stat:
> 
> $ git grep WITH_ | grep meson | wc -l
> 261
> $ git grep HAVE_ | grep meson | wc -l
> 31
> 
> I think we should try to eliminate 100% of using of HAVE_ so that all our
> conditionals use WITH_
> 

I'm up for this. Let me see if I can write a patch for that.

Michal

Re: [PATCH] nss: Finish renaming of HAVE_BSD_NSS macro
Posted by Jiri Denemark 3 years, 7 months ago
On Tue, Sep 01, 2020 at 11:26:58 +0200, Michal Privoznik wrote:
> When switching to meson, some of HAVE_* macros were renamed to
> WITH_ because they did not reflect whether the build platform has
> or doesn't have something, but whether we are building with some
> functionality turned on or off. This is the case with
> HAVE_BSD_NSS macro too. As a result, the NSS plugin built on BSD
> did not expose nss_module_register() function which made the
> plugin unusable:
> 
> https://www.redhat.com/archives/libvir-list/2020-September/msg00000.html
> 
> Fixes: c74268705557a6781788ba011492c15df2e3df11
> Reported-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---
>  tools/nss/libvirt_nss.c | 6 +++---
>  tools/nss/libvirt_nss.h | 4 ++--
>  2 files changed, 5 insertions(+), 5 deletions(-)

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>

Re: [PATCH] nss: Finish renaming of HAVE_BSD_NSS macro
Posted by Roman Bogorodskiy 3 years, 7 months ago
  Michal Privoznik wrote:

> When switching to meson, some of HAVE_* macros were renamed to
> WITH_ because they did not reflect whether the build platform has
> or doesn't have something, but whether we are building with some
> functionality turned on or off. This is the case with
> HAVE_BSD_NSS macro too. As a result, the NSS plugin built on BSD
> did not expose nss_module_register() function which made the
> plugin unusable:
> 
> https://www.redhat.com/archives/libvir-list/2020-September/msg00000.html
> 
> Fixes: c74268705557a6781788ba011492c15df2e3df11
> Reported-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>

Reviewed-by: Roman Bogorodskiy <bogorodskiy@gmail.com>

> ---
>  tools/nss/libvirt_nss.c | 6 +++---
>  tools/nss/libvirt_nss.h | 4 ++--
>  2 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/tools/nss/libvirt_nss.c b/tools/nss/libvirt_nss.c
> index 3b89f72742..6331c65131 100644
> --- a/tools/nss/libvirt_nss.c
> +++ b/tools/nss/libvirt_nss.c
> @@ -37,7 +37,7 @@
>  #include <time.h>
>  
>  
> -#if defined(HAVE_BSD_NSS)
> +#if defined(WITH_BSD_NSS)
>  # include <nsswitch.h>
>  #endif
>  
> @@ -451,7 +451,7 @@ NSS_NAME(gethostbyname4)(const char *name, struct gaih_addrtuple **pat,
>  }
>  #endif /* HAVE_STRUCT_GAIH_ADDRTUPLE */
>  
> -#if defined(HAVE_BSD_NSS)
> +#if defined(WITH_BSD_NSS)
>  NSS_METHOD_PROTOTYPE(_nss_compat_getaddrinfo);
>  NSS_METHOD_PROTOTYPE(_nss_compat_gethostbyname2_r);
>  
> @@ -598,4 +598,4 @@ nss_module_register(const char *name __attribute__((unused)),
>      *unregister = NULL;
>      return methods;
>  }
> -#endif /* HAVE_BSD_NSS */
> +#endif /* WITH_BSD_NSS */
> diff --git a/tools/nss/libvirt_nss.h b/tools/nss/libvirt_nss.h
> index 95ebafdc71..121b9e8722 100644
> --- a/tools/nss/libvirt_nss.h
> +++ b/tools/nss/libvirt_nss.h
> @@ -84,8 +84,8 @@ NSS_NAME(gethostbyname4)(const char *name, struct gaih_addrtuple **pat,
>                           int *herrnop, int32_t *ttlp);
>  #endif /* HAVE_STRUCT_GAIH_ADDRTUPLE */
>  
> -#if defined(HAVE_BSD_NSS)
> +#if defined(WITH_BSD_NSS)
>  ns_mtab*
>  nss_module_register(const char *name, unsigned int *size,
>                      nss_module_unregister_fn *unregister);
> -#endif /* HAVE_BSD_NSS */
> +#endif /* WITH_BSD_NSS */
> -- 
> 2.26.2
> 

Roman Bogorodskiy