Commit 375ebc63 authored by Russ Allbery's avatar Russ Allbery

Update to rra-c-util 2.6

* Fix portability to bundled Heimdal on OpenBSD.
* Fix portability for missing krb5_get_init_creds_opt_free.

Also update util/messages.[ch] so that it will compile with more
warnings enabled.
parent 2c391919
......@@ -21,6 +21,11 @@ krb5-sync 2.1 (unreleased)
new plugin capabilities or configuration. Thanks to Sam Hartman for
the port.
Update to rra-c-util 2.6:
* Fix portability to bundled Heimdal on OpenBSD.
* Fix portability for missing krb5_get_init_creds_opt_free.
krb5-sync 2.0 (2010-02-15)
Dropped support for AFS synchronization and all Kerberos v4 support.
......
......@@ -2,7 +2,7 @@ dnl Find the compiler and linker flags for Kerberos v5.
dnl
dnl Finds the compiler and linker flags for linking with Kerberos v5
dnl libraries. Provides the --with-krb5, --with-krb5-include, and
dnl --with-krb5-lib configure options to specify non-standards paths to the
dnl --with-krb5-lib configure options to specify non-standard paths to the
dnl Kerberos libraries. Uses krb5-config where available unless reduced
dnl dependencies is requested.
dnl
......@@ -13,6 +13,9 @@ dnl Kerberos libraries, saving the current values first, and
dnl RRA_LIB_KRB5_RESTORE to restore those settings to before the last
dnl RRA_LIB_KRB5_SWITCH.
dnl
dnl If KRB5_CPPFLAGS, KRB5_LDFLAGS, or KRB5_LIBS are set before calling these
dnl macros, their values will be added to whatever the macros discover.
dnl
dnl Provides the RRA_LIB_KRB5_OPTIONAL macro, which should be used if Kerberos
dnl support is optional. This macro will still always set the substitution
dnl variables, but they'll be empty unless --with-krb5 is given. Also,
......@@ -25,8 +28,12 @@ dnl change library ordering in that case.
dnl
dnl Depends on RRA_ENABLE_REDUCED_DEPENDS and RRA_SET_LDFLAGS.
dnl
dnl Also provides RRA_FUNC_KRB5_GET_INIT_CREDS_OPT_FREE_ARGS, which checks
dnl whether krb5_get_init_creds_opt_free takes one argument or two. Defines
dnl HAVE_KRB5_GET_INIT_CREDS_OPT_FREE_2_ARGS if it takes two arguments.
dnl
dnl Written by Russ Allbery <rra@stanford.edu>
dnl Copyright 2005, 2006, 2007, 2008, 2009
dnl Copyright 2005, 2006, 2007, 2008, 2009, 2010
dnl Board of Trustees, Leland Stanford Jr. University
dnl
dnl See LICENSE for licensing terms.
......@@ -99,10 +106,11 @@ AC_DEFUN([_RRA_LIB_KRB5_MANUAL],
[AC_CHECK_LIB([nsl], [socket], [LIBS="-lnsl -lsocket $LIBS"], ,
[-lsocket])])
AC_SEARCH_LIBS([crypt], [crypt])
AC_SEARCH_LIBS([rk_simple_execve], [roken])
rra_krb5_extra="$LIBS"
LIBS="$rra_krb5_save_LIBS"
AC_CHECK_LIB([krb5], [krb5_init_context],
[KRB5_LIBS="-lkrb5 -lasn1 -lroken -lcrypto -lcom_err $rra_krb5_extra"],
[KRB5_LIBS="-lkrb5 -lasn1 -lcom_err -lcrypto $rra_krb5_extra"],
[AC_CHECK_LIB([krb5support], [krb5int_getspecific],
[rra_krb5_extra="-lkrb5support $rra_krb5_extra"],
[AC_CHECK_LIB([pthreads], [pthread_setspecific],
......@@ -125,7 +133,7 @@ AC_DEFUN([_RRA_LIB_KRB5_MANUAL],
[AS_IF([test x"$1" = xtrue],
[AC_MSG_ERROR([cannot find usable Kerberos v5 library])])],
[$rra_krb5_extra])],
[-lasn1 -lroken -lcrypto -lcom_err $rra_krb5_extra])
[-lasn1 -lcom_err -lcrypto $rra_krb5_extra])
LIBS="$KRB5_LIBS $LIBS"
AC_CHECK_FUNCS([krb5_get_error_message],
[AC_CHECK_FUNCS([krb5_free_error_message])],
......@@ -200,9 +208,6 @@ AC_DEFUN([RRA_LIB_KRB5],
[rra_krb5_root=
rra_krb5_libdir=
rra_krb5_includedir=
KRB5_CPPFLAGS=
KRB5_LDFLAGS=
KRB5_LIBS=
AC_SUBST([KRB5_CPPFLAGS])
AC_SUBST([KRB5_LDFLAGS])
AC_SUBST([KRB5_LIBS])
......@@ -230,9 +235,6 @@ AC_DEFUN([RRA_LIB_KRB5_OPTIONAL],
rra_krb5_libdir=
rra_krb5_includedir=
rra_use_kerberos=
KRB5_CPPFLAGS=
KRB5_LDFLAGS=
KRB5_LIBS=
AC_SUBST([KRB5_CPPFLAGS])
AC_SUBST([KRB5_LDFLAGS])
AC_SUBST([KRB5_LIBS])
......@@ -261,3 +263,20 @@ AC_DEFUN([RRA_LIB_KRB5_OPTIONAL],
[_RRA_LIB_KRB5_INTERNAL([false])])])
AS_IF([test x"$KRB5_LIBS" != x],
[AC_DEFINE([HAVE_KERBEROS], 1, [Define to enable Kerberos features.])])])
dnl Check whether krb5_get_init_creds_opt_free takes one argument or two.
dnl Early Heimdal used to take a single argument. Defines
dnl HAVE_KRB5_GET_INIT_CREDS_OPT_FREE_2_ARGS if it takes two arguments.
dnl
dnl Should be called with RRA_LIB_KRB5_SWITCH active.
AC_DEFUN([RRA_FUNC_KRB5_GET_INIT_CREDS_OPT_FREE_ARGS],
[AC_CACHE_CHECK([if krb5_get_init_creds_opt_free takes two arguments],
[rra_cv_func_krb5_get_init_creds_opt_free_args],
[AC_TRY_COMPILE([#include <krb5.h>],
[krb5_get_init_creds_opt *opts; krb5_context c;
krb5_get_init_creds_opt_free(c, opts);],
[rra_cv_func_krb5_get_init_creds_opt_free_args=yes],
[rra_cv_func_krb5_get_init_creds_opt_free_args=no])])
AS_IF([test $rra_cv_func_krb5_get_init_creds_opt_free_args = yes],
[AC_DEFINE([HAVE_KRB5_GET_INIT_CREDS_OPT_FREE_2_ARGS], 1,
[Define if krb5_get_init_creds_opt_free takes two arguments.])])])
......@@ -97,7 +97,8 @@ krb5_free_error_message(krb5_context ctx UNUSED, const char *msg)
* assumes that an all-zero bit pattern will create a NULL pointer.
*/
krb5_error_code
krb5_get_init_creds_opt_alloc(krb5_context ctx, krb5_get_init_creds_opt **opts)
krb5_get_init_creds_opt_alloc(krb5_context ctx UNUSED,
krb5_get_init_creds_opt **opts)
{
*opts = calloc(1, sizeof(krb5_get_init_creds_opt));
if (*opts == NULL)
......
......@@ -23,10 +23,17 @@
#ifndef PORTABLE_KRB5_H
#define PORTABLE_KRB5_H 1
#include <config.h>
/*
* Allow inclusion of config.h to be skipped, since sometimes we have to use a
* stripped-down version of config.h with a different name.
*/
#ifndef CONFIG_H_INCLUDED
# include <config.h>
#endif
#include <portable/macros.h>
#include <krb5.h>
#include <stdlib.h>
BEGIN_DECLS
......@@ -55,13 +62,21 @@ void krb5_free_error_message(krb5_context, const char *);
#endif
/*
* Both current MIT and current Heimdal prefer _opt_alloc, but older versions
* of both require allocating your own struct and calling _opt_init.
* Both current MIT and current Heimdal prefer _opt_alloc and _opt_free, but
* older versions of both require allocating your own struct and calling
* _opt_init.
*/
#ifndef HAVE_KRB5_GET_INIT_CREDS_OPT_ALLOC
krb5_error_code krb5_get_init_creds_opt_alloc(krb5_context,
krb5_get_init_creds_opt **);
#endif
#ifdef HAVE_KRB5_GET_INIT_CREDS_OPT_FREE
# ifndef HAVE_KRB5_GET_INIT_CREDS_OPT_FREE_2_ARGS
# define krb5_get_init_creds_opt_free(c, o) krb5_get_init_creds_opt_free(o)
# endif
#else
# define krb5_get_init_creds_opt_free(c, o) free(o)
#endif
/* Heimdal-specific. */
#ifndef HAVE_KRB5_GET_INIT_CREDS_OPT_SET_DEFAULT_FLAGS
......@@ -70,7 +85,7 @@ krb5_error_code krb5_get_init_creds_opt_alloc(krb5_context,
/*
* Heimdal provides a nice function that just returns a const char *. On MIT,
* there's an accessor macro that returns the krb5_data pointer, wihch
* there's an accessor macro that returns the krb5_data pointer, which
* requires more work to get at the underlying char *.
*/
#ifndef HAVE_KRB5_PRINCIPAL_GET_REALM
......
......@@ -16,7 +16,7 @@
* #include <unistd.h>
*
* Missing functions are provided via #define or prototyped if available from
* the util helper library. Also provides some standard #defines.
* the portable helper library. Also provides some standard #defines.
*
* Written by Russ Allbery <rra@stanford.edu>
* This work is hereby placed in the public domain by its author.
......
......@@ -8,7 +8,6 @@
#ifndef UTIL_MACROS_H
#define UTIL_MACROS_H 1
#include <config.h>
#include <portable/macros.h>
/* Used for unused parameters to silence gcc warnings. */
......
......@@ -107,9 +107,9 @@ const char *message_program_name = NULL;
* handler list, the count of handlers, and the argument list.
*/
static void
message_handlers(message_handler_func **list, int count, va_list args)
message_handlers(message_handler_func **list, unsigned int count, va_list args)
{
int i;
unsigned int i;
if (*list != stdout_handlers && *list != stderr_handlers)
free(*list);
......@@ -127,7 +127,7 @@ message_handlers(message_handler_func **list, int count, va_list args)
*/
#define HANDLER_FUNCTION(type) \
void \
message_handlers_ ## type(int count, ...) \
message_handlers_ ## type(unsigned int count, ...) \
{ \
va_list args; \
\
......@@ -145,7 +145,7 @@ HANDLER_FUNCTION(die)
* Print a message to stdout, supporting message_program_name.
*/
void
message_log_stdout(int len UNUSED, const char *fmt, va_list args, int err)
message_log_stdout(size_t len UNUSED, const char *fmt, va_list args, int err)
{
if (message_program_name != NULL)
fprintf(stdout, "%s: ", message_program_name);
......@@ -162,7 +162,7 @@ message_log_stdout(int len UNUSED, const char *fmt, va_list args, int err)
* stdout so that errors and regular output occur in the right order.
*/
void
message_log_stderr(int len UNUSED, const char *fmt, va_list args, int err)
message_log_stderr(size_t len UNUSED, const char *fmt, va_list args, int err)
{
fflush(stdout);
if (message_program_name != NULL)
......@@ -183,7 +183,7 @@ message_log_stderr(int len UNUSED, const char *fmt, va_list args, int err)
* log the errno information.
*/
static void
message_log_syslog(int pri, int len, const char *fmt, va_list args, int err)
message_log_syslog(int pri, size_t len, const char *fmt, va_list args, int err)
{
char *buffer;
......@@ -218,11 +218,11 @@ message_log_syslog(int pri, int len, const char *fmt, va_list args, int err)
* Do the same sort of wrapper to generate all of the separate syslog logging
* functions.
*/
#define SYSLOG_FUNCTION(name, type) \
void \
message_log_syslog_ ## name(int l, const char *f, va_list a, int e) \
{ \
message_log_syslog(LOG_ ## type, l, f, a, e); \
#define SYSLOG_FUNCTION(name, type) \
void \
message_log_syslog_ ## name(size_t l, const char *f, va_list a, int e) \
{ \
message_log_syslog(LOG_ ## type, l, f, a, e); \
}
SYSLOG_FUNCTION(debug, DEBUG)
SYSLOG_FUNCTION(info, INFO)
......@@ -243,7 +243,7 @@ debug(const char *format, ...)
{
va_list args;
message_handler_func *log;
int length;
ssize_t length;
if (debug_handlers == NULL)
return;
......@@ -254,7 +254,7 @@ debug(const char *format, ...)
return;
for (log = debug_handlers; *log != NULL; log++) {
va_start(args, format);
(**log)(length, format, args, 0);
(**log)((size_t) length, format, args, 0);
va_end(args);
}
}
......@@ -264,7 +264,7 @@ notice(const char *format, ...)
{
va_list args;
message_handler_func *log;
int length;
ssize_t length;
va_start(args, format);
length = vsnprintf(NULL, 0, format, args);
......@@ -273,7 +273,7 @@ notice(const char *format, ...)
return;
for (log = notice_handlers; *log != NULL; log++) {
va_start(args, format);
(**log)(length, format, args, 0);
(**log)((size_t) length, format, args, 0);
va_end(args);
}
}
......@@ -283,7 +283,7 @@ sysnotice(const char *format, ...)
{
va_list args;
message_handler_func *log;
int length;
ssize_t length;
int error = errno;
va_start(args, format);
......@@ -293,7 +293,7 @@ sysnotice(const char *format, ...)
return;
for (log = notice_handlers; *log != NULL; log++) {
va_start(args, format);
(**log)(length, format, args, error);
(**log)((size_t) length, format, args, error);
va_end(args);
}
}
......@@ -303,7 +303,7 @@ warn(const char *format, ...)
{
va_list args;
message_handler_func *log;
int length;
ssize_t length;
va_start(args, format);
length = vsnprintf(NULL, 0, format, args);
......@@ -312,7 +312,7 @@ warn(const char *format, ...)
return;
for (log = warn_handlers; *log != NULL; log++) {
va_start(args, format);
(**log)(length, format, args, 0);
(**log)((size_t) length, format, args, 0);
va_end(args);
}
}
......@@ -322,7 +322,7 @@ syswarn(const char *format, ...)
{
va_list args;
message_handler_func *log;
int length;
ssize_t length;
int error = errno;
va_start(args, format);
......@@ -332,7 +332,7 @@ syswarn(const char *format, ...)
return;
for (log = warn_handlers; *log != NULL; log++) {
va_start(args, format);
(**log)(length, format, args, error);
(**log)((size_t) length, format, args, error);
va_end(args);
}
}
......@@ -342,7 +342,7 @@ die(const char *format, ...)
{
va_list args;
message_handler_func *log;
int length;
ssize_t length;
va_start(args, format);
length = vsnprintf(NULL, 0, format, args);
......@@ -350,7 +350,7 @@ die(const char *format, ...)
if (length >= 0)
for (log = die_handlers; *log != NULL; log++) {
va_start(args, format);
(**log)(length, format, args, 0);
(**log)((size_t) length, format, args, 0);
va_end(args);
}
exit(message_fatal_cleanup ? (*message_fatal_cleanup)() : 1);
......@@ -361,7 +361,7 @@ sysdie(const char *format, ...)
{
va_list args;
message_handler_func *log;
int length;
ssize_t length;
int error = errno;
va_start(args, format);
......@@ -370,7 +370,7 @@ sysdie(const char *format, ...)
if (length >= 0)
for (log = die_handlers; *log != NULL; log++) {
va_start(args, format);
(**log)(length, format, args, error);
(**log)((size_t) length, format, args, error);
va_end(args);
}
exit(message_fatal_cleanup ? (*message_fatal_cleanup)() : 1);
......
......@@ -49,35 +49,35 @@ void sysdie(const char *, ...)
* of those handlers. These functions are not thread-safe; they set global
* variables.
*/
void message_handlers_debug(int count, ...);
void message_handlers_notice(int count, ...);
void message_handlers_warn(int count, ...);
void message_handlers_die(int count, ...);
void message_handlers_debug(unsigned int count, ...);
void message_handlers_notice(unsigned int count, ...);
void message_handlers_warn(unsigned int count, ...);
void message_handlers_die(unsigned int count, ...);
/*
* Some useful handlers, intended to be passed to message_handlers_*. All
* handlers take the length of the formatted message, the format, a variadic
* argument list, and the errno setting if any.
*/
void message_log_stdout(int, const char *, va_list, int)
void message_log_stdout(size_t, const char *, va_list, int)
__attribute((__nonnull__));
void message_log_stderr(int, const char *, va_list, int)
void message_log_stderr(size_t, const char *, va_list, int)
__attribute((__nonnull__));
void message_log_syslog_debug(int, const char *, va_list, int)
void message_log_syslog_debug(size_t, const char *, va_list, int)
__attribute((__nonnull__));
void message_log_syslog_info(int, const char *, va_list, int)
void message_log_syslog_info(size_t, const char *, va_list, int)
__attribute((__nonnull__));
void message_log_syslog_notice(int, const char *, va_list, int)
void message_log_syslog_notice(size_t, const char *, va_list, int)
__attribute((__nonnull__));
void message_log_syslog_warning(int, const char *, va_list, int)
void message_log_syslog_warning(size_t, const char *, va_list, int)
__attribute((__nonnull__));
void message_log_syslog_err(int, const char *, va_list, int)
void message_log_syslog_err(size_t, const char *, va_list, int)
__attribute((__nonnull__));
void message_log_syslog_crit(int, const char *, va_list, int)
void message_log_syslog_crit(size_t, const char *, va_list, int)
__attribute((__nonnull__));
/* The type of a message handler. */
typedef void (*message_handler_func)(int, const char *, va_list, int);
typedef void (*message_handler_func)(size_t, const char *, va_list, int);
/* If non-NULL, called before exit and its return value passed to exit. */
extern int (*message_fatal_cleanup)(void);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment