2N/A/*
2N/A * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
2N/A */
2N/A/* Generic SASL plugin utility functions
2N/A * Rob Siemborski
2N/A * $Id: plugin_common.h,v 1.16 2003/04/07 16:03:43 rjs3 Exp $
2N/A */
2N/A
2N/A/*
2N/A * Copyright (c) 1998-2003 Carnegie Mellon University. All rights reserved.
2N/A *
2N/A * Redistribution and use in source and binary forms, with or without
2N/A * modification, are permitted provided that the following conditions
2N/A * are met:
2N/A *
2N/A * 1. Redistributions of source code must retain the above copyright
2N/A * notice, this list of conditions and the following disclaimer.
2N/A *
2N/A * 2. Redistributions in binary form must reproduce the above copyright
2N/A * notice, this list of conditions and the following disclaimer in
2N/A * the documentation and/or other materials provided with the
2N/A * distribution.
2N/A *
2N/A * 3. The name "Carnegie Mellon University" must not be used to
2N/A * endorse or promote products derived from this software without
2N/A * prior written permission. For permission or any other legal
2N/A * details, please contact
2N/A * Office of Technology Transfer
2N/A * Carnegie Mellon University
2N/A * 5000 Forbes Avenue
2N/A * Pittsburgh, PA 15213-3890
2N/A * (412) 268-4387, fax: (412) 268-7395
2N/A * tech-transfer@andrew.cmu.edu
2N/A *
2N/A * 4. Redistributions of any form whatsoever must retain the following
2N/A * acknowledgment:
2N/A * "This product includes software developed by Computing Services
2N/A * at Carnegie Mellon University (http://www.cmu.edu/computing/)."
2N/A *
2N/A * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
2N/A * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
2N/A * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
2N/A * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
2N/A * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
2N/A * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
2N/A * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
2N/A */
2N/A
2N/A#ifndef _PLUGIN_COMMON_H_
2N/A#define _PLUGIN_COMMON_H_
2N/A
2N/A#include <config.h>
2N/A
2N/A#ifndef macintosh
2N/A#ifdef WIN32
2N/A# include <winsock.h>
2N/A#else
2N/A# include <sys/socket.h>
2N/A# include <netinet/in.h>
2N/A# include <arpa/inet.h>
2N/A# include <netdb.h>
2N/A#endif /* WIN32 */
2N/A#endif /* macintosh */
2N/A
2N/A#include <sasl.h>
2N/A#include <saslutil.h>
2N/A#include <saslplug.h>
2N/A
2N/A#ifdef WIN32
2N/A#define PLUG_API __declspec(dllexport)
2N/A#else
2N/A#define PLUG_API extern
2N/A#endif
2N/A
2N/A#define SASL_CLIENT_PLUG_INIT( x ) \
2N/Aextern sasl_client_plug_init_t x##_client_plug_init; \
2N/APLUG_API int sasl_client_plug_init(const sasl_utils_t *utils, \
2N/A int maxversion, int *out_version, \
2N/A sasl_client_plug_t **pluglist, \
2N/A int *plugcount) { \
2N/A return x##_client_plug_init(utils, maxversion, out_version, \
2N/A pluglist, plugcount); \
2N/A}
2N/A
2N/A#define SASL_SERVER_PLUG_INIT( x ) \
2N/Aextern sasl_server_plug_init_t x##_server_plug_init; \
2N/APLUG_API int sasl_server_plug_init(const sasl_utils_t *utils, \
2N/A int maxversion, int *out_version, \
2N/A sasl_server_plug_t **pluglist, \
2N/A int *plugcount) { \
2N/A return x##_server_plug_init(utils, maxversion, out_version, \
2N/A pluglist, plugcount); \
2N/A}
2N/A
2N/A#define SASL_AUXPROP_PLUG_INIT( x ) \
2N/Aextern sasl_auxprop_init_t x##_auxprop_plug_init; \
2N/APLUG_API int sasl_auxprop_plug_init(const sasl_utils_t *utils, \
2N/A int maxversion, int *out_version, \
2N/A sasl_auxprop_plug_t **plug, \
2N/A const char *plugname) {\
2N/A return x##_auxprop_plug_init(utils, maxversion, out_version, \
2N/A plug, plugname); \
2N/A}
2N/A
2N/A#define SASL_CANONUSER_PLUG_INIT( x ) \
2N/Aextern sasl_canonuser_init_t x##_canonuser_plug_init; \
2N/APLUG_API int sasl_canonuser_init(const sasl_utils_t *utils, \
2N/A int maxversion, int *out_version, \
2N/A sasl_canonuser_plug_t **plug, \
2N/A const char *plugname) {\
2N/A return x##_canonuser_plug_init(utils, maxversion, out_version, \
2N/A plug, plugname); \
2N/A}
2N/A
2N/A/* note: msg cannot include additional variables, so if you want to
2N/A * do a printf-format string, then you need to call seterror yourself */
2N/A#define SETERROR( utils, msg ) (utils)->seterror( (utils)->conn, 0, (msg) )
2N/A
2N/A#ifndef MEMERROR
2N/A#ifdef _SUN_SDK_
2N/A#define MEMERROR( utils ) \
2N/A (utils)->seterror( (utils)->conn, 0, "Out of Memory")
2N/A#else
2N/A#define MEMERROR( utils ) \
2N/A (utils)->seterror( (utils)->conn, 0, \
2N/A "Out of Memory in " __FILE__ " near line %d", __LINE__ )
2N/A#endif /* _SUN_SDK_ */
2N/A#endif
2N/A
2N/A#ifndef PARAMERROR
2N/A#ifdef _SUN_SDK_
2N/A#define PARAMERROR( utils ) \
2N/A (utils)->seterror( (utils)->conn, 0, "Parameter Error")
2N/A#else
2N/A#define PARAMERROR( utils ) \
2N/A (utils)->seterror( (utils)->conn, 0, \
2N/A "Parameter Error in " __FILE__ " near line %d", __LINE__ )
2N/A#endif /* _SUN_SDK_ */
2N/A#endif
2N/A
2N/A#ifndef SASLINT_H
2N/Atypedef struct buffer_info
2N/A{
2N/A char *data;
2N/A unsigned curlen; /* Current length of data in buffer */
2N/A unsigned reallen; /* total length of buffer (>= curlen) */
2N/A} buffer_info_t;
2N/A#endif
2N/A
2N/Aint _plug_ipfromstring(const sasl_utils_t *utils, const char *addr,
2N/A struct sockaddr *out, socklen_t outlen);
2N/Aint _plug_iovec_to_buf(const sasl_utils_t *utils, const struct iovec *vec,
2N/A unsigned numiov, buffer_info_t **output);
2N/Aint _plug_buf_alloc(const sasl_utils_t *utils, char **rwbuf,
2N/A unsigned *curlen, unsigned newlen);
2N/Aint _plug_strdup(const sasl_utils_t * utils, const char *in,
2N/A char **out, int *outlen);
2N/Avoid _plug_free_string(const sasl_utils_t *utils, char **str);
2N/Avoid _plug_free_secret(const sasl_utils_t *utils, sasl_secret_t **secret);
2N/A
2N/A#define _plug_get_userid(utils, result, prompt_need) \
2N/A _plug_get_simple(utils, SASL_CB_USER, 0, result, prompt_need)
2N/A#define _plug_get_authid(utils, result, prompt_need) \
2N/A _plug_get_simple(utils, SASL_CB_AUTHNAME, 1, result, prompt_need)
2N/Aint _plug_get_simple(const sasl_utils_t *utils, unsigned int id, int required,
2N/A const char **result, sasl_interact_t **prompt_need);
2N/A
2N/Aint _plug_get_password(const sasl_utils_t *utils, sasl_secret_t **secret,
2N/A unsigned int *iscopy, sasl_interact_t **prompt_need);
2N/A
2N/Aint _plug_challenge_prompt(const sasl_utils_t *utils, unsigned int id,
2N/A const char *challenge, const char *promptstr,
2N/A const char **result, sasl_interact_t **prompt_need);
2N/A
2N/Aint _plug_get_realm(const sasl_utils_t *utils, const char **availrealms,
2N/A const char **realm, sasl_interact_t **prompt_need);
2N/A
2N/Aint _plug_make_prompts(const sasl_utils_t *utils,
2N/A#ifdef _INTEGRATED_SOLARIS_
2N/A void **h,
2N/A#endif /* _INTEGRATED_SOLARIS_ */
2N/A sasl_interact_t **prompts_res,
2N/A const char *user_prompt, const char *user_def,
2N/A const char *auth_prompt, const char *auth_def,
2N/A const char *pass_prompt, const char *pass_def,
2N/A const char *echo_chal,
2N/A const char *echo_prompt, const char *echo_def,
2N/A const char *realm_chal,
2N/A const char *realm_prompt, const char *realm_def);
2N/A
2N/Aint _plug_decode(const sasl_utils_t *utils,
2N/A void *context,
2N/A const char *input, unsigned inputlen,
2N/A char **output, unsigned *outputsize, unsigned *outputlen,
2N/A int (*decode_pkt)(void *context,
2N/A const char **input, unsigned *inputlen,
2N/A char **output, unsigned *outputlen));
2N/A
2N/Aint _plug_parseuser(const sasl_utils_t *utils,
2N/A char **user, char **realm, const char *user_realm,
2N/A const char *serverFQDN, const char *input);
2N/A
2N/A#ifdef _INTEGRATED_SOLARIS_
2N/A/* EXPORT DELETE START */
2N/A/* CRYPT DELETE START */
2N/Atypedef void reg_sun_t(void *);
2N/A
2N/A#define REG_PLUG( X, Y ) { \
2N/A reg_sun_t *func = NULL; \
2N/A unsigned int l; \
2N/A utils->getopt(utils->getopt_context, X, "reg_sun_plug", \
2N/A (const char **)&func, &l); \
2N/A if (func != NULL && l == 0) \
2N/A (*func)(Y); \
2N/A}
2N/A/* CRYPT DELETE END */
2N/A/* EXPORT DELETE END */
2N/A
2N/Aint use_locale(const char *lang_list, int is_client);
2N/Aconst char *convert_prompt(const sasl_utils_t *utils, void **h, const char *s);
2N/Achar *local_to_utf(const sasl_utils_t *utils, const char *s);
2N/A#endif /* _INTEGRATED_SOLARIS_ */
2N/A#endif /* _PLUGIN_COMMON_H_ */