From: Todd C. Miller Date: Wed, 16 Jun 2010 20:40:02 +0000 (-0400) Subject: Check for zlib.h in addition to libz. X-Git-Tag: SUDO_1_7_3~44 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fdb440c746604f084fdfe7e665c2a6145e739035;p=sudo Check for zlib.h in addition to libz. --HG-- branch : 1.7 --- diff --git a/config.h.in b/config.h.in index 792b40c5e..36f488f52 100644 --- a/config.h.in +++ b/config.h.in @@ -577,8 +577,8 @@ /* Define to 1 if you have the `waitpid' function. */ #undef HAVE_WAITPID -/* Define to 1 if you the `zlib' library. */ -#undef HAVE_ZLIB +/* Define to 1 if you have the header file. */ +#undef HAVE_ZLIB_H /* Define to 1 if you have the `_getpty' function. */ #undef HAVE__GETPTY diff --git a/configure b/configure index 5b854c47c..7613516c7 100755 --- a/configure +++ b/configure @@ -18059,12 +18059,12 @@ _ACEOF # Check whether --enable-zlib was given. if test "${enable_zlib+set}" = set; then : enableval=$enable_zlib; case "$enableval" in - yes) $as_echo "#define HAVE_ZLIB 1" >>confdefs.h + yes) $as_echo "#define HAVE_ZLIB_H 1" >>confdefs.h ZLIB="-lz" ;; no) ;; - *) $as_echo "#define HAVE_ZLIB 1" >>confdefs.h + *) $as_echo "#define HAVE_ZLIB_H 1" >>confdefs.h CPPFLAGS="${CPPFLAGS} -I${enableval}/include" @@ -18127,9 +18127,18 @@ fi $as_echo "$ac_cv_lib_z_gzdopen" >&6; } if test "x$ac_cv_lib_z_gzdopen" = x""yes; then : - $as_echo "#define HAVE_ZLIB 1" >>confdefs.h + for ac_header in zlib.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default" +if test "x$ac_cv_header_zlib_h" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_ZLIB_H 1 +_ACEOF + ZLIB="-lz" +fi + +done - ZLIB="-lz" fi @@ -20467,8 +20476,6 @@ fi - - diff --git a/configure.in b/configure.in index 2ad34a48a..ee956112d 100644 --- a/configure.in +++ b/configure.in @@ -2669,11 +2669,11 @@ if test "${with_iologdir-yes}" != "no"; then AC_ARG_ENABLE(zlib, [AS_HELP_STRING([--enable-zlib[[=PATH]]], [Whether to enable or disable zlib])], [ case "$enableval" in - yes) AC_DEFINE(HAVE_ZLIB) + yes) AC_DEFINE(HAVE_ZLIB_H) ZLIB="-lz" ;; no) ;; - *) AC_DEFINE(HAVE_ZLIB) + *) AC_DEFINE(HAVE_ZLIB_H) CPPFLAGS="${CPPFLAGS} -I${enableval}/include" SUDO_APPEND_LIBPATH(ZLIB, [$enableval/lib]) ZLIB="${ZLIB} -lz" @@ -2682,8 +2682,7 @@ if test "${with_iologdir-yes}" != "no"; then ]) if test X"$enable_zlib" = X""; then AC_CHECK_LIB(z, gzdopen, [ - AC_DEFINE(HAVE_ZLIB) - ZLIB="-lz" + AC_CHECK_HEADERS(zlib.h, [ZLIB="-lz"]) ]) fi ], [ @@ -2856,7 +2855,6 @@ AH_TEMPLATE(WITHOUT_PASSWD, [Define to avoid using the passwd/shadow file for au AH_TEMPLATE(sig_atomic_t, [Define to `int' if does not define.]) 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(HAVE_ZLIB, [Define to 1 if you the `zlib' library.]) dnl dnl Bits to copy verbatim into config.h.in diff --git a/defaults.c b/defaults.c index 247167795..daa30019f 100644 --- a/defaults.c +++ b/defaults.c @@ -469,7 +469,7 @@ init_defaults() def_timestamp_timeout = TIMEOUT; def_passwd_timeout = PASSWORD_TIMEOUT; def_passwd_tries = TRIES_FOR_PASSWORD; -#ifdef HAVE_ZLIB +#ifdef HAVE_ZLIB_H def_compress_io = TRUE; #endif diff --git a/iolog.c b/iolog.c index e67bd3fed..3391a76ca 100644 --- a/iolog.c +++ b/iolog.c @@ -47,7 +47,7 @@ #include #include #include -#ifdef HAVE_ZLIB +#ifdef HAVE_ZLIB_H # include #endif @@ -55,7 +55,7 @@ union io_fd { FILE *f; -#ifdef HAVE_ZLIB +#ifdef HAVE_ZLIB_H gzFile g; #endif void *v; @@ -206,7 +206,7 @@ open_io_fd(pathbuf, len, suffix, docompress) fd = open(pathbuf, O_CREAT|O_EXCL|O_WRONLY, S_IRUSR|S_IWUSR); if (fd != -1) { fcntl(fd, F_SETFD, FD_CLOEXEC); -#ifdef HAVE_ZLIB +#ifdef HAVE_ZLIB_H if (docompress) vfd = gzdopen(fd, "w"); else @@ -307,7 +307,7 @@ io_log_close() for (i = 0; i < IOFD_MAX; i++) { if (io_fds[i].v == NULL) continue; -#ifdef HAVE_ZLIB +#ifdef HAVE_ZLIB_H if (def_compress_io) gzclose(io_fds[i].g); else @@ -329,7 +329,7 @@ log_io(buf, len, idx) sigprocmask(SIG_BLOCK, &ttyblock, &omask); -#ifdef HAVE_ZLIB +#ifdef HAVE_ZLIB_H if (def_compress_io) gzwrite(io_fds[idx].g, buf, len); else @@ -338,7 +338,7 @@ log_io(buf, len, idx) delay.tv_sec = now.tv_sec; delay.tv_usec = now.tv_usec; timevalsub(&delay, &last_time); -#ifdef HAVE_ZLIB +#ifdef HAVE_ZLIB_H if (def_compress_io) gzprintf(io_fds[IOFD_TIMING].g, "%d %f %d\n", idx, delay.tv_sec + ((double)delay.tv_usec / 1000000), len); diff --git a/sudoreplay.c b/sudoreplay.c index 357f1a2a5..75dbc8e40 100644 --- a/sudoreplay.c +++ b/sudoreplay.c @@ -76,7 +76,7 @@ #ifdef HAVE_REGCOMP # include #endif -#ifdef HAVE_ZLIB +#ifdef HAVE_ZLIB_H # include #endif #include @@ -110,7 +110,7 @@ char **Argv; union io_fd { FILE *f; -#ifdef HAVE_ZLIB +#ifdef HAVE_ZLIB_H gzFile g; #endif void *v; @@ -341,7 +341,7 @@ main(argc, argv) /* * 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) { #else while (fgets(buf, sizeof(buf), io_fds[IOFD_TIMING].f) != NULL) { @@ -383,7 +383,7 @@ main(argc, argv) len = sizeof(buf); else len = nbytes; -#ifdef HAVE_ZLIB +#ifdef HAVE_ZLIB_H nread = gzread(io_fds[idx].g, buf, len); #else nread = fread(buf, 1, len, io_fds[idx].f); @@ -444,7 +444,7 @@ open_io_fd(char *path, int len, const char *suffix) path[len] = '\0'; strlcat(path, suffix, PATH_MAX); -#ifdef HAVE_ZLIB +#ifdef HAVE_ZLIB_H return gzopen(path, "r"); #else return fopen(path, "r");