Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

configure.ac: Move header and function checks to the end of the file #860

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

alejandro-colomar
Copy link
Collaborator

This allows checking functions that come from libraries like libbsd.

@alejandro-colomar
Copy link
Collaborator Author

alejandro-colomar commented Dec 2, 2023

I'm not sure if I moved too much, or if I did anything wrong if that has other consequences. Please review carefully.

@alejandro-colomar alejandro-colomar marked this pull request as draft December 2, 2023 19:03
@alejandro-colomar alejandro-colomar marked this pull request as ready for review December 4, 2023 11:11
This allows checking functions that come from libraries like libbsd.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
@ikerexxe
Copy link
Collaborator

I'm not sure if I moved too much, or if I did anything wrong if that has other consequences. Please review carefully.

I'd like to, but this is beyond my autoconf knowledge. I don't know which would be the consequences for such a change.

@alejandro-colomar
Copy link
Collaborator Author

@thesamesam Can you review, please? :)

Copy link
Contributor

@vapier vapier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the goal is to allow 3rd party libs (like libbsd) to provide coverage, i think it'd make sense to organize those at the top. then again, having a large flat configure.ac like this (~800 lines) makes it hard to organize and keep organized. feels like it should be split up into some m4 files so that the configure.ac is easier to follow. all of the shadow configure options that are independent of OS checks for example would be easy to pull out, and then make sure that they only do things like AC_ARG_ENABLE/AC_ARG_WITH, and don't call any CHECK funcs.

getspnam_r \
rpmatch \
memset_explicit explicit_bzero stpecpy stpeprintf)
AC_SYS_LARGEFILE
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AC_SYS_LARGEFILE should come asap. it should already be called before header probes. it will change CPPFLAGS which could, at least in theory, affect header inclusion behavior.

AC_CHECK_HEADERS(crypt.h utmp.h \
termio.h sgtty.h sys/ioctl.h paths.h \
sys/capability.h sys/random.h \
gshadow.h lastlog.h rpc/key_prot.h acl/libacl.h \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

acl/libacl.h shouldn't be probed like this. plus, it's already probed below as part of the larger libacl detection. ideally all of that would be deleted in favor of PKG_CHECK_MODULES calls ... doing that would also help cut down on noise by turning ~30 lines into like <5.

termio.h sgtty.h sys/ioctl.h paths.h \
sys/capability.h sys/random.h \
gshadow.h lastlog.h rpc/key_prot.h acl/libacl.h \
attr/libattr.h attr/error_context.h)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here -- these attr/ probes should be deleted since libattr is detected below, including these headers

rpmatch \
memset_explicit explicit_bzero stpecpy stpeprintf)
AC_SYS_LARGEFILE

dnl Checks for typedefs, structures, and compiler characteristics.

AC_CHECK_MEMBERS([struct utmp.ut_type,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think some of these tests below could be affected by which headers are detected. worth double checking config.log to see what the generated tests are with the default set of header includes.

@@ -704,6 +685,25 @@ if test "$with_skey" = "yes"; then
]])],[AC_DEFINE(SKEY_BSD_STYLE, 1, [Define to support newer BSD S/Key API])],[])
fi

dnl Checks for header files.
AC_CHECK_HEADERS(crypt.h utmp.h \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not exactly a new issue, but this (and funcs below) should ideally be using the _ONCE variant to avoid double-checking for the headers

@ikerexxe
Copy link
Collaborator

I read vapier's message and then I noticed

This allows checking functions that come from libraries like libbsd.

I just want to remind you that Fedora and its derivatives don't allow any base OS package to have libbsd dependency. We already discussed this topic at #839. So, unless the functions that you will use are provided by some other library (i.e. glibc) this way of working in general is a no-go for me.

@vapier
Copy link
Contributor

vapier commented Dec 14, 2023

i don't see the problem. the configure script has --with-libbsd / --without-libbsd options already. if a distro (e.g. Fedora) doesn't want a package like shadow to depend on a specific library like libbsd, then they need to explicitly pass the corresponding --without-libbsd option. if they aren't doing that, it's a bug in their packaging scripts.

plus, shadow is already in this situation: libbsd is probed by default and automatically used if it provides readpassphrase and the host C library does not (which glibc doesn't). so if Fedora wanted to avoid depending on libbsd linkage, it already needs to pass the flag.

somewhat related, the default for libbsd should be "maybe", not "yes".

@alejandro-colomar
Copy link
Collaborator Author

I read vapier's message and then I noticed

This allows checking functions that come from libraries like libbsd.

I just want to remind you that Fedora and its derivatives don't allow any base OS package to have libbsd dependency. We already discussed this topic at #839. So, unless the functions that you will use are provided by some other library (i.e. glibc) this way of working in general is a no-go for me.

It was precisely for that: I was going to provide an alternative definition for some libbsd functions if they were not available.

I could use the current test for libbsd, but I thought of testing the functions instead, which would be more precise.

@alejandro-colomar
Copy link
Collaborator Author

I'll convert to draft, to address the issues raised by @vapier . BTW, thanks for the review!

@alejandro-colomar alejandro-colomar marked this pull request as draft December 14, 2023 16:46
@ikerexxe
Copy link
Collaborator

It was precisely for that: I was going to provide an alternative definition for some libbsd functions if they were not available.

Perfect, perfect. A big kudos to you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants