Skip to content

Commit

Permalink
Added options to enable/disable local files, HTTP, and FTP support. F…
Browse files Browse the repository at this point in the history
…TP is disabled by default (lsh123#577)
  • Loading branch information
lsh123 authored and github-actions[bot] committed Jun 13, 2024
1 parent 740df98 commit d9397cf
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 17 deletions.
63 changes: 63 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1882,6 +1882,54 @@ if test "z$build_on_windows" = "zyes" ; then
fi
fi

dnl ==========================================================================
dnl See do we need files support
dnl ==========================================================================
AC_MSG_CHECKING(for files support)
AC_ARG_ENABLE([files], [AS_HELP_STRING([--enable-files],[enable files support (yes)])])
if test "z$enable_files" = "zno" ; then
XMLSEC_DEFINES="$XMLSEC_DEFINES -DXMLSEC_NO_FILES=1"
XMLSEC_NO_FILES="1"
AC_MSG_RESULT([no (tests will be broken!)])
else
XMLSEC_NO_FILES="0"
AC_MSG_RESULT([yes])
fi
AM_CONDITIONAL(XMLSEC_NO_FILES, test "z$XMLSEC_NO_FILES" = "z1")
AC_SUBST(XMLSEC_NO_FILES)

dnl ==========================================================================
dnl See do we need FTP support
dnl ==========================================================================
AC_MSG_CHECKING(for FTP support)
AC_ARG_ENABLE([ftp], [AS_HELP_STRING([--enable-ftp],[enable FTP support (no, deprecated)])])
if test "z$enable_ftp" = "zyes" ; then
XMLSEC_NO_FTP="0"
AC_MSG_RESULT([yes (deprecated)])
else
XMLSEC_DEFINES="$XMLSEC_DEFINES -DXMLSEC_NO_FTP=1"
XMLSEC_NO_FTP="1"
AC_MSG_RESULT([disabled])
fi
AM_CONDITIONAL(XMLSEC_NO_FTP, test "z$XMLSEC_NO_FTP" = "z1")
AC_SUBST(XMLSEC_NO_FTP)

dnl ==========================================================================
dnl See do we need HTTP support
dnl ==========================================================================
AC_MSG_CHECKING(for HTTP support)
AC_ARG_ENABLE([http], [AS_HELP_STRING([--enable-http],[enable HTTP support (yes)])])
if test "z$enable_http" = "zno" ; then
XMLSEC_DEFINES="$XMLSEC_DEFINES -DXMLSEC_NO_HTTP=1"
XMLSEC_NO_HTTP="1"
AC_MSG_RESULT([no])
else
XMLSEC_NO_HTTP="0"
AC_MSG_RESULT([yes])
fi
AM_CONDITIONAL(XMLSEC_NO_HTTP, test "z$XMLSEC_NO_HTTP" = "z1")
AC_SUBST(XMLSEC_NO_HTTP)

dnl ==========================================================================
dnl See do we need MD5 support
dnl ==========================================================================
Expand Down Expand Up @@ -2020,6 +2068,21 @@ if test "z$enable_dsa" = "zno" ; then
XMLSEC_DEFINES="$XMLSEC_DEFINES -DXMLSEC_NO_DSA=1"
XMLSEC_NO_DSA="1"
AC_MSG_RESULT([disabled])
dnl ==========================================================================
dnl See do we need MD5 support
dnl ==========================================================================
AC_MSG_CHECKING(for MD5 support)
AC_ARG_ENABLE([md5], [AS_HELP_STRING([--enable-md5],[enable MD5 support (no, deprecated)])])
if test "z$enable_md5" = "zyes" ; then
XMLSEC_NO_MD5="0"
AC_MSG_RESULT([yes (deprecated)])
else
XMLSEC_DEFINES="$XMLSEC_DEFINES -DXMLSEC_NO_MD5=1"
XMLSEC_NO_MD5="1"
AC_MSG_RESULT([disabled])
fi
AM_CONDITIONAL(XMLSEC_NO_MD5, test "z$XMLSEC_NO_MD5" = "z1")
AC_SUBST(XMLSEC_NO_MD5)
else
XMLSEC_NO_DSA="0"
AC_MSG_RESULT([yes])
Expand Down
45 changes: 28 additions & 17 deletions src/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,23 @@
#include <libxml/tree.h>
#include <libxml/xmlIO.h>

#ifdef LIBXML_HTTP_ENABLED
#include <libxml/nanohttp.h>
/* check if we want HTTP and FTP support */
#ifndef LIBXML_HTTP_ENABLED
#define XMLSEC_NO_HTTP 1
#endif /* LIBXML_HTTP_ENABLED */

#ifdef LIBXML_FTP_ENABLED
#include <libxml/nanoftp.h>
#ifndef LIBXML_FTP_ENABLED
#define XMLSEC_NO_FTP 1
#endif /* LIBXML_FTP_ENABLED */

#ifndef XMLSEC_NO_HTTP
#include <libxml/nanohttp.h>
#endif /* XMLSEC_NO_HTTP */

#ifndef XMLSEC_NO_FTP
#include <libxml/nanoftp.h>
#endif /* XMLSEC_NO_FTP */

#include <xmlsec/xmlsec.h>
#include <xmlsec/keys.h>
#include <xmlsec/transforms.h>
Expand Down Expand Up @@ -162,13 +171,14 @@ xmlSecIOInit(void) {
return(-1);
}

#ifdef LIBXML_FTP_ENABLED
#ifndef XMLSEC_NO_FTP
xmlNanoFTPInit();
#endif /* LIBXML_FTP_ENABLED */
#endif /* XMLSEC_NO_FTP */

#ifdef LIBXML_HTTP_ENABLED
#ifndef XMLSEC_NO_HTTP
xmlNanoHTTPInit();
#endif /* LIBXML_HTTP_ENABLED */
#endif /* #ifndef XMLSEC_NO_HTTP
*/

ret = xmlSecIORegisterDefaultCallbacks();
if(ret < 0) {
Expand All @@ -188,13 +198,13 @@ xmlSecIOInit(void) {
void
xmlSecIOShutdown(void) {

#ifdef LIBXML_HTTP_ENABLED
#ifndef XMLSEC_NO_HTTP
xmlNanoHTTPCleanup();
#endif /* LIBXML_HTTP_ENABLED */
#endif /* XMLSEC_NO_HTTP */

#ifdef LIBXML_FTP_ENABLED
#ifndef XMLSEC_NO_FTP
xmlNanoFTPCleanup();
#endif /* LIBXML_FTP_ENABLED */
#endif /* XMLSEC_NO_FTP */

xmlSecPtrListFinalize(&xmlSecAllIOCallbacks);
}
Expand Down Expand Up @@ -257,31 +267,33 @@ int
xmlSecIORegisterDefaultCallbacks(void) {
int ret;

#ifndef XMLSEC_NO_FILES
/* Callbacks added later are picked up first */
ret = xmlSecIORegisterCallbacks(xmlFileMatch, xmlFileOpen,
xmlFileRead, xmlFileClose);
if(ret < 0) {
xmlSecInternalError("xmlSecIORegisterCallbacks(file)", NULL);
return(-1);
}
#endif /* XMLSEC_NO_FILES */

#ifdef LIBXML_HTTP_ENABLED
#ifndef XMLSEC_NO_HTTP
ret = xmlSecIORegisterCallbacks(xmlIOHTTPMatch, xmlIOHTTPOpen,
xmlIOHTTPRead, xmlIOHTTPClose);
if(ret < 0) {
xmlSecInternalError("xmlSecIORegisterCallbacks(http)", NULL);
return(-1);
}
#endif /* LIBXML_HTTP_ENABLED */
#endif /* XMLSEC_NO_HTTP */

#ifdef LIBXML_FTP_ENABLED
#ifndef XMLSEC_NO_FTP
ret = xmlSecIORegisterCallbacks(xmlIOFTPMatch, xmlIOFTPOpen,
xmlIOFTPRead, xmlIOFTPClose);
if(ret < 0) {
xmlSecInternalError("xmlSecIORegisterCallbacks(ftp)", NULL);
return(-1);
}
#endif /* LIBXML_FTP_ENABLED */
#endif /* XMLSEC_NO_FTP */

/* done */
return(0);
Expand Down Expand Up @@ -504,4 +516,3 @@ xmlSecTransformInputURIPopBin(xmlSecTransformPtr transform, xmlSecByte* data,
}
return(0);
}

0 comments on commit d9397cf

Please sign in to comment.