Add libgcrypt, check for it and perform global initialization

This commit is contained in:
Julien BLACHE 2010-02-05 18:38:39 +01:00
parent cb4320791b
commit 2f385bff2c
4 changed files with 30 additions and 2 deletions

View File

@ -31,6 +31,7 @@ General libraries:
- libevent 1.4+
- libavl
- MiniXML
- gcrypt 1.2.0+
- libflac (optional - FLAC support)
- taglib (optional - Musepack support)
- libplist 0.16+ (optional - iTunes XML support)

View File

@ -86,6 +86,8 @@ AC_CHECK_HEADER(antlr3.h, , AC_MSG_ERROR([antlr3.h not found]))
AC_CHECK_LIB([antlr3c], [antlr3BaseRecognizerNew], [ANTLR3C_LIBS="-lantlr3c"], AC_MSG_ERROR([ANTLR3 C runtime (libantlr3c) not found]))
AC_SUBST(ANTLR3C_LIBS)
AM_PATH_LIBGCRYPT([], , AC_MSG_ERROR([libgcrypt not found]))
if test x$use_flac = xtrue; then
PKG_CHECK_MODULES(FLAC, [ flac ])
fi

View File

@ -25,10 +25,10 @@ ANTLR_SOURCES = \
ANTLR_PRODUCTS =
forked_daapd_CPPFLAGS = -D_GNU_SOURCE @AVAHI_CFLAGS@ @SQLITE3_CFLAGS@ @FFMPEG_CFLAGS@ @CONFUSE_CFLAGS@ @TAGLIB_CFLAGS@ @MINIXML_CFLAGS@ @LIBPLIST_CFLAGS@ \
forked_daapd_CPPFLAGS = -D_GNU_SOURCE @AVAHI_CFLAGS@ @SQLITE3_CFLAGS@ @FFMPEG_CFLAGS@ @CONFUSE_CFLAGS@ @TAGLIB_CFLAGS@ @MINIXML_CFLAGS@ @LIBPLIST_CFLAGS@ @LIBGCRYPT_CFLAGS@ \
-DDATADIR="\"$(pkgdatadir)\"" -DCONFDIR="\"$(sysconfdir)\"" -DSTATEDIR="\"$(localstatedir)\""
forked_daapd_LDADD = @AVAHI_LIBS@ @SQLITE3_LIBS@ @FFMPEG_LIBS@ @CONFUSE_LIBS@ @FLAC_LIBS@ @TAGLIB_LIBS@ @LIBEVENT_LIBS@ @LIBAVL_LIBS@ @MINIXML_LIBS@ @ANTLR3C_LIBS@ @LIBPLIST_LIBS@
forked_daapd_LDADD = @AVAHI_LIBS@ @SQLITE3_LIBS@ @FFMPEG_LIBS@ @CONFUSE_LIBS@ @FLAC_LIBS@ @TAGLIB_LIBS@ @LIBEVENT_LIBS@ @LIBAVL_LIBS@ @MINIXML_LIBS@ @ANTLR3C_LIBS@ @LIBPLIST_LIBS@ @LIBGCRYPT_LIBS@
forked_daapd_SOURCES = main.c \
db.c db.h \
logger.c logger.h \

View File

@ -51,6 +51,9 @@
#include <event.h>
#include <libavformat/avformat.h>
#include <gcrypt.h>
GCRY_THREAD_OPTION_PTHREAD_IMPL;
#include "conffile.h"
#include "db.h"
#include "logger.h"
@ -425,6 +428,7 @@ main(int argc, char **argv)
char *logfile;
char *ffid;
char *pidfile;
const char *gcry_version;
sigset_t sigs;
int sigfd;
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
@ -552,6 +556,26 @@ main(int argc, char **argv)
/* Initialize ffmpeg */
av_register_all();
/* Initialize libgcrypt */
gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);
gcry_version = gcry_check_version(GCRYPT_VERSION);
if (!gcry_version)
{
DPRINTF(E_FATAL, L_MAIN, "libgcrypt version mismatch\n");
goto gcrypt_init_fail;
}
/* We aren't handling anything sensitive, so give up on secure
* memory, which is a scarce system resource.
*/
gcry_control(GCRYCTL_DISABLE_SECMEM, 0);
gcry_control(GCRYCTL_INITIALIZATION_FINISHED, 0);
DPRINTF(E_DBG, L_MAIN, "Initialized with gcrypt %s\n", gcry_version);
/* Block signals for all threads except the main one */
sigemptyset(&sigs);
sigaddset(&sigs, SIGINT);
@ -743,6 +767,7 @@ main(int argc, char **argv)
}
}
gcrypt_init_fail:
signal_block_fail:
DPRINTF(E_LOG, L_MAIN, "Exiting.\n");
conffile_unload();