Skip to content

PHPC-633: Add SSL/SASL support to phpinfo() output #265

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ PHP_ARG_WITH(libmongoc, whether to use system libmongoc,
PHP_SETUP_OPENSSL(MONGODB_SHARED_LIBADD)
MONGOC_ENABLE_SSL=1
AC_SUBST(MONGOC_ENABLE_SSL)
AC_DEFINE(HAVE_MONGOC_SSL, 1, "Whether SSL is enabled in the bundled libmongoc")
fi


Expand Down Expand Up @@ -419,6 +420,7 @@ if test "$PHP_MONGODB_SASL" != "no"; then
PHP_ADD_LIBRARY_WITH_PATH(sasl2, $MONGODB_SASL_DIR/$PHP_LIBDIR, MONGODB_SHARED_LIBADD)
MONGOC_ENABLE_SASL=1
AC_SUBST(MONGOC_ENABLE_SASL)
AC_DEFINE(HAVE_MONGOC_SASL, 1, "Whether SASL is enabled in the bundled libmongoc")
], [
if test "$MONGODB_SASL" != "auto"; then
AC_MSG_ERROR([MONGO SASL check failed. Please check config.log for more information.])
Expand Down
3 changes: 3 additions & 0 deletions config.w32
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ if (PHP_MONGODB != "no") {

if (!CHECK_LIB("libsasl.lib", "mongodb", PHP_MONGODB)) {
WARNING("mongodb libsasl support not enabled, libs not found");
} else {
AC_DEFINE("HAVE_MONGOC_SASL", 1);
}
if (CHECK_LIB("ssleay32.lib", "mongodb", PHP_MONGODB) && CHECK_LIB("libeay32.lib", "mongodb", PHP_MONGODB) && CHECK_HEADER_ADD_INCLUDE("openssl/ssl.h", "CFLAGS_MONGOC")) {
AC_DEFINE("HAVE_MONGOC_SSL", 1);
}

FSO.CopyFile(configure_module_dirname + "/win32/bson-config.h", configure_module_dirname + "/src/libbson/src/bson/bson-config.h", true);
Expand Down
10 changes: 10 additions & 0 deletions php_phongo.c
Original file line number Diff line number Diff line change
Expand Up @@ -2583,6 +2583,16 @@ PHP_MINFO_FUNCTION(mongodb)
#else
/* Bundled libraries, buildtime = runtime */
php_info_print_table_row(2, "libmongoc version", MONGOC_VERSION_S);
# if HAVE_MONGOC_SSL
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd suggest using the mongoc defines for this instead: MONGOC_ENABLE_SSL, MONGOC_ENABLE_SASL.
This should be updated later to print out with ssl lib it is using, maybe add a note to PHPC-542 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These constants were not defined in the .h files that I needed it to be in:

src/libmongoc/src/mongoc/mongoc-config.h:#define MONGOC_ENABLE_SSL 1
win32/mongoc-config.h:#define MONGOC_ENABLE_SSL 1

And I don't want to expose vendored library's defines outside of it. Having specific defines for them makes for a cleaner separation.

Copy link
Contributor

Choose a reason for hiding this comment

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

So when compiling against system mongoc these well say no sasl and ssl support.
That doesn't look right.

php_info_print_table_row(2, "libmongoc SSL support", "yes");
# else
php_info_print_table_row(2, "libmongoc SSL support", "no");
# endif
# if HAVE_MONGOC_SASL
php_info_print_table_row(2, "libmongoc SASL support", "yes");
# else
php_info_print_table_row(2, "libmongoc SASL support", "no");
# endif
#endif
#ifdef HAVE_SYSTEM_LIBBSON
php_info_print_table_row(2, "libbson headers version", BSON_VERSION_S);
Expand Down
2 changes: 2 additions & 0 deletions tests/functional/phpinfo-1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ mongodb support => enabled
mongodb version => 1.%d.%d%S
mongodb stability => %s
libmongoc version => 1.%s
libmongoc SSL support => %s
libmongoc SASL support => %s
libbson version => 1.%s

Directive => Local Value => Master Value
Expand Down
2 changes: 2 additions & 0 deletions tests/functional/phpinfo-2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ mongodb support => enabled
mongodb version => 1.%d.%d%S
mongodb stability => %s
libmongoc version => 1.%s
libmongoc SSL support => %s
libmongoc SASL support => %s
libbson version => 1.%s

Directive => Local Value => Master Value
Expand Down