1
  /   ˆ{‹„„-i[D<†ªoZƒ›Ù«Ä513_‘I|¥‰ÓMdœv ©ƒ†ü+=ÃÂ     ‹      Å”_oÓ0Åß÷)Œx«oÿmH›4šJTêÚª+B!äØNâÍ±#Û¥ŒO�Û´ZA­/ðÇùåÞsŽsC_eóÑêÓbŒÞ¯î¦hñáÝt2B¸ðq0ÈVYû`Hº=€ñ#\…Ð\l6²ëJX-¡
µ‚Nñ@D8½ Û½ôÑJ2¯ˆ´L'FÈïÈì:x%d¬Ü¬s­øa„­=xiD¡´$BÖ–Tžpk›ØHXî;Þë=„ÆYq]€³6ÀÚ;Ð*Éµj¼„F¯Ke<…¶T{I4·âi«´÷UÅæ»pX¾·]º”†
}cZ•&ÁÁ68¥ª.‘w<Á ¸5rÍÌ#)U�Ó!ÁŸ'£ù—ÈA¨¶o§”¡ÊÉ"ÁoGÉìfžd8�±ZR`§™»ÈÜâtÊ|@µªPRœ…ï[ø^ý8_0k™LzîT”5Ï(D‹ÇV¹Õ¾aÑëetP¹cªEÄKi0þK‹Ûåx¶Ê&Ë6±-ñ¬î_�1NÌIP¦œäÁº§}­ž×&÷ÍÍáí:UV§uÐIò/RY›Gc7æ8˜úÉHâ“½lò B´ìä×ôI—<0‡Ó€cc¿9éwûƒN·×é^¡^ïzø¡3à¹¼;où?Ø…ÝpShC?%Pé    A   ˆl–Ãa¾”Êa,j‚ÆÁq¡)‹Fÿ�þY}ØÖnG›’‘ð�à?Ç„N…¿Æ_ˆI|¥�+ÅÄ 9{    /* sample-server.c -- sample SASL server
 * Rob Earhart
 */
/* 
 * Copyright (c) 1998-2016 Carnegie Mellon University.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer. 
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. The name "Carnegie Mellon University" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For permission or any other legal
 *    details, please contact  
 *      Carnegie Mellon University
 *      Center for Technology Transfer and Enterprise Creation
 *      4615 Forbes Avenue
 *      Suite 302
 *      Pittsburgh, PA  15213
 *      (412) 268-7393, fax: (412) 268-7395
 *      innovation@andrew.cmu.edu
 *
 * 4. Redistributions of any form whatsoever must retain the following
 *    acknowledgment:
 *    "This product includes software developed by Computing Services
 *     at Carnegie Mellon University (http://www.cmu.edu/computing/)."
 *
 * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
 * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
 * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
 * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
 * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#include <config.h>
#include <limits.h>
#include <stdio.h>

#ifdef HAVE_GETOPT_H
#include <getopt.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif

#ifdef WIN32
# include <winsock2.h>
__declspec(dllimport) char *optarg;
__declspec(dllimport) int optind;
__declspec(dllimport) int getsubopt(char **optionp, const char * const *tokens, char **valuep);
#define HAVE_GETSUBOPT
#else /* WIN32 */
# include <netinet/in.h>
#endif /* WIN32 */
#include <sasl.h>
#include <saslplug.h>
#include <saslutil.h>

#ifndef HAVE_GETSUBOPT
int getsubopt(char **optionp, const char * const *tokens, char **valuep);
#endif

static const char *progname = NULL;
static int verbose;

/* Note: if this is changed, change it in samp_read(), too. */
#define SAMPLE_SEC_BUF_SIZE (2048)

static const char
message[] = "Come here Watson, I want you.";

char buf[SAMPLE_SEC_BUF_SIZE];

static const char *bit_subopts[] = {
#define OPT_MIN (0)
  "min",
#define OPT_MAX (1)
  "max",
  NULL
};

static const char *ext_subopts[] = {
#define OPT_EXT_SSF (0)
  "ssf",
#define OPT_EXT_ID (1)
  "id",
  NULL
};

static const char *flag_subopts[] = {
#define OPT_NOPLAIN (0)
  "noplain",
#define OPT_NOACTIVE (1)
  "noactive",
#define OPT_NODICT (2)
  "nodict",
#define OPT_FORWARDSEC (3)
  "forwardsec",
#define OPT_NOANONYMOUS (4)
  "noanonymous",
#define OPT_PASSCRED (5)
  "passcred",
  NULL
};

static const char *ip_subopts[] = {
#define OPT_IP_LOCAL (0)
  "local",
#define OPT_IP_REMOTE (1)
  "remote",
  NULL
};

char *mech = NULL,
  *iplocal = NULL,
  *ipremote = 