Check for zlib.h in addition to libz.

This commit is contained in:
Todd C. Miller
2010-06-16 16:51:46 -04:00
parent d018936b4e
commit ebc152ce8f
6 changed files with 585 additions and 442 deletions

View File

@@ -558,8 +558,8 @@
/* Define to 1 if you have the `waitpid' function. */ /* Define to 1 if you have the `waitpid' function. */
#undef HAVE_WAITPID #undef HAVE_WAITPID
/* Define to 1 if you the `zlib' library. */ /* Define to 1 if you have the <zlib.h> header file. */
#undef HAVE_ZLIB #undef HAVE_ZLIB_H
/* Define to 1 if you have the `_getpty' function. */ /* Define to 1 if you have the `_getpty' function. */
#undef HAVE__GETPTY #undef HAVE__GETPTY

991
configure vendored

File diff suppressed because it is too large Load Diff

View File

@@ -1272,11 +1272,11 @@ AC_ARG_ENABLE(env_debug,
AC_ARG_ENABLE(zlib, AC_ARG_ENABLE(zlib,
[AS_HELP_STRING([--enable-zlib[[=PATH]]], [Whether to enable or disable zlib])], [AS_HELP_STRING([--enable-zlib[[=PATH]]], [Whether to enable or disable zlib])],
[ case "$enableval" in [ case "$enableval" in
yes) AC_DEFINE(HAVE_ZLIB) yes) AC_DEFINE(HAVE_ZLIB_H)
ZLIB="-lz" ZLIB="-lz"
;; ;;
no) ;; no) ;;
*) AC_DEFINE(HAVE_ZLIB) *) AC_DEFINE(HAVE_ZLIB_H)
CPPFLAGS="${CPPFLAGS} -I${enableval}/include" CPPFLAGS="${CPPFLAGS} -I${enableval}/include"
SUDO_APPEND_LIBPATH(ZLIB, [$enableval/lib]) SUDO_APPEND_LIBPATH(ZLIB, [$enableval/lib])
ZLIB="${ZLIB} -lz" ZLIB="${ZLIB} -lz"
@@ -1285,8 +1285,7 @@ AC_ARG_ENABLE(zlib,
]) ])
if test X"$enable_zlib" = X""; then if test X"$enable_zlib" = X""; then
AC_CHECK_LIB(z, gzdopen, [ AC_CHECK_LIB(z, gzdopen, [
AC_DEFINE(HAVE_ZLIB) AC_CHECK_HEADERS(zlib.h, [ZLIB="-lz"])
ZLIB="-lz"
]) ])
fi fi
@@ -2867,7 +2866,6 @@ AH_TEMPLATE(WITHOUT_PASSWD, [Define to avoid using the passwd/shadow file for au
AH_TEMPLATE(sig_atomic_t, [Define to `int' if <signal.h> does not define.]) AH_TEMPLATE(sig_atomic_t, [Define to `int' if <signal.h> does not define.])
AH_TEMPLATE(__signed, [Define to `signed' or nothing if compiler does not support a signed type qualifier.]) AH_TEMPLATE(__signed, [Define to `signed' or nothing if compiler does not support a signed type qualifier.])
AH_TEMPLATE(USING_NONUNIX_GROUPS, [Define to 1 if using a non-Unix group lookup implementation.]) AH_TEMPLATE(USING_NONUNIX_GROUPS, [Define to 1 if using a non-Unix group lookup implementation.])
AH_TEMPLATE(HAVE_ZLIB, [Define to 1 if you the `zlib' library.])
dnl dnl
dnl Bits to copy verbatim into config.h.in dnl Bits to copy verbatim into config.h.in

View File

@@ -473,7 +473,7 @@ init_defaults(void)
def_timestamp_timeout = TIMEOUT; def_timestamp_timeout = TIMEOUT;
def_passwd_timeout = PASSWORD_TIMEOUT; def_passwd_timeout = PASSWORD_TIMEOUT;
def_passwd_tries = TRIES_FOR_PASSWORD; def_passwd_tries = TRIES_FOR_PASSWORD;
#ifdef HAVE_ZLIB #ifdef HAVE_ZLIB_H
def_compress_io = TRUE; def_compress_io = TRUE;
#endif #endif

View File

@@ -47,7 +47,7 @@
#include <signal.h> #include <signal.h>
#include <pwd.h> #include <pwd.h>
#include <grp.h> #include <grp.h>
#ifdef HAVE_ZLIB #ifdef HAVE_ZLIB_H
# include <zlib.h> # include <zlib.h>
#endif #endif
@@ -55,7 +55,7 @@
union io_fd { union io_fd {
FILE *f; FILE *f;
#ifdef HAVE_ZLIB #ifdef HAVE_ZLIB_H
gzFile g; gzFile g;
#endif #endif
void *v; void *v;
@@ -196,7 +196,7 @@ open_io_fd(char *pathbuf, int len, const char *suffix, int docompress)
fd = open(pathbuf, O_CREAT|O_EXCL|O_WRONLY, S_IRUSR|S_IWUSR); fd = open(pathbuf, O_CREAT|O_EXCL|O_WRONLY, S_IRUSR|S_IWUSR);
if (fd != -1) { if (fd != -1) {
fcntl(fd, F_SETFD, FD_CLOEXEC); fcntl(fd, F_SETFD, FD_CLOEXEC);
#ifdef HAVE_ZLIB #ifdef HAVE_ZLIB_H
if (docompress) if (docompress)
vfd = gzdopen(fd, "w"); vfd = gzdopen(fd, "w");
else else
@@ -304,7 +304,7 @@ sudoers_io_close(int exit_status, int error)
for (i = 0; i < IOFD_MAX; i++) { for (i = 0; i < IOFD_MAX; i++) {
if (io_fds[i].v == NULL) if (io_fds[i].v == NULL)
continue; continue;
#ifdef HAVE_ZLIB #ifdef HAVE_ZLIB_H
if (def_compress_io) if (def_compress_io)
gzclose(io_fds[i].g); gzclose(io_fds[i].g);
else else
@@ -329,7 +329,7 @@ sudoers_io_log(const char *buf, unsigned int len, int idx)
gettimeofday(&now, NULL); gettimeofday(&now, NULL);
#ifdef HAVE_ZLIB #ifdef HAVE_ZLIB_H
if (def_compress_io) if (def_compress_io)
gzwrite(io_fds[idx].g, buf, len); gzwrite(io_fds[idx].g, buf, len);
else else
@@ -338,7 +338,7 @@ sudoers_io_log(const char *buf, unsigned int len, int idx)
delay.tv_sec = now.tv_sec; delay.tv_sec = now.tv_sec;
delay.tv_usec = now.tv_usec; delay.tv_usec = now.tv_usec;
timevalsub(&delay, &last_time); timevalsub(&delay, &last_time);
#ifdef HAVE_ZLIB #ifdef HAVE_ZLIB_H
if (def_compress_io) if (def_compress_io)
gzprintf(io_fds[IOFD_TIMING].g, "%d %f %d\n", idx, gzprintf(io_fds[IOFD_TIMING].g, "%d %f %d\n", idx,
delay.tv_sec + ((double)delay.tv_usec / 1000000), len); delay.tv_sec + ((double)delay.tv_usec / 1000000), len);

View File

@@ -76,7 +76,7 @@
#ifdef HAVE_REGCOMP #ifdef HAVE_REGCOMP
# include <regex.h> # include <regex.h>
#endif #endif
#ifdef HAVE_ZLIB #ifdef HAVE_ZLIB_H
# include <zlib.h> # include <zlib.h>
#endif #endif
#include <signal.h> #include <signal.h>
@@ -107,7 +107,7 @@ extern int optind;
union io_fd { union io_fd {
FILE *f; FILE *f;
#ifdef HAVE_ZLIB #ifdef HAVE_ZLIB_H
gzFile g; gzFile g;
#endif #endif
void *v; void *v;
@@ -337,7 +337,7 @@ main(int argc, char *argv[])
/* /*
* Timing file consists of line of the format: "%f %d\n" * Timing file consists of line of the format: "%f %d\n"
*/ */
#ifdef HAVE_ZLIB #ifdef HAVE_ZLIB_H
while (gzgets(io_fds[IOFD_TIMING].g, buf, sizeof(buf)) != NULL) { while (gzgets(io_fds[IOFD_TIMING].g, buf, sizeof(buf)) != NULL) {
#else #else
while (fgets(buf, sizeof(buf), io_fds[IOFD_TIMING].f) != NULL) { while (fgets(buf, sizeof(buf), io_fds[IOFD_TIMING].f) != NULL) {
@@ -379,7 +379,7 @@ main(int argc, char *argv[])
len = sizeof(buf); len = sizeof(buf);
else else
len = nbytes; len = nbytes;
#ifdef HAVE_ZLIB #ifdef HAVE_ZLIB_H
nread = gzread(io_fds[idx].g, buf, len); nread = gzread(io_fds[idx].g, buf, len);
#else #else
nread = fread(buf, 1, len, io_fds[idx].f); nread = fread(buf, 1, len, io_fds[idx].f);
@@ -439,7 +439,7 @@ open_io_fd(char *path, int len, const char *suffix)
path[len] = '\0'; path[len] = '\0';
strlcat(path, suffix, PATH_MAX); strlcat(path, suffix, PATH_MAX);
#ifdef HAVE_ZLIB #ifdef HAVE_ZLIB_H
return gzopen(path, "r"); return gzopen(path, "r");
#else #else
return fopen(path, "r"); return fopen(path, "r");