1178825Sdfr/* 2233294Sstas * Copyright (c) 2006 Kungliga Tekniska H��gskolan 3233294Sstas * (Royal Institute of Technology, Stockholm, Sweden). 4233294Sstas * All rights reserved. 5178825Sdfr * 6233294Sstas * Redistribution and use in source and binary forms, with or without 7233294Sstas * modification, are permitted provided that the following conditions 8233294Sstas * are met: 9178825Sdfr * 10233294Sstas * 1. Redistributions of source code must retain the above copyright 11233294Sstas * notice, this list of conditions and the following disclaimer. 12178825Sdfr * 13233294Sstas * 2. Redistributions in binary form must reproduce the above copyright 14233294Sstas * notice, this list of conditions and the following disclaimer in the 15233294Sstas * documentation and/or other materials provided with the distribution. 16178825Sdfr * 17178825Sdfr * 3. Neither the name of KTH nor the names of its contributors may be 18178825Sdfr * used to endorse or promote products derived from this software without 19178825Sdfr * specific prior written permission. 20178825Sdfr * 21178825Sdfr * THIS SOFTWARE IS PROVIDED BY KTH AND ITS CONTRIBUTORS ``AS IS'' AND ANY 22178825Sdfr * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23178825Sdfr * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24178825Sdfr * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KTH OR ITS CONTRIBUTORS BE 25178825Sdfr * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26178825Sdfr * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27178825Sdfr * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 28178825Sdfr * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29178825Sdfr * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 30178825Sdfr * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 31178825Sdfr * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32178825Sdfr */ 33178825Sdfr 34233294Sstas/* $Id$ */ 35178825Sdfr 36178825Sdfr#ifdef HAVE_CONFIG_H 37178825Sdfr#include <config.h> 38178825Sdfr#endif 39178825Sdfr 40233294Sstas/* 41178825Sdfr * pthread support is disable because the pthread 42178825Sdfr * test have no "application pthread libflags" variable, 43178825Sdfr * when this is fixed pthread support can be enabled again. 44178825Sdfr */ 45178825Sdfr#undef ENABLE_PTHREAD_SUPPORT 46178825Sdfr 47178825Sdfr#include <sys/param.h> 48178825Sdfr#ifdef HAVE_SYS_UTSNAME_H 49178825Sdfr#include <sys/utsname.h> 50178825Sdfr#endif 51178825Sdfr 52178825Sdfr#ifdef HAVE_SYS_WAIT_H 53178825Sdfr#include <sys/wait.h> 54178825Sdfr#endif 55178825Sdfr 56178825Sdfr#include <assert.h> 57178825Sdfr#include <krb5.h> 58233294Sstas#include <gssapi/gssapi.h> 59233294Sstas#include <gssapi/gssapi_krb5.h> 60233294Sstas#include <gssapi/gssapi_spnego.h> 61178825Sdfr#include <unistd.h> 62178825Sdfr 63178825Sdfr#include <roken.h> 64178825Sdfr#include <getarg.h> 65178825Sdfr 66178825Sdfr#include "protocol.h" 67178825Sdfr 68178825Sdfrkrb5_error_code store_string(krb5_storage *, const char *); 69178825Sdfr 70178825Sdfr 71178825Sdfr#define ret16(_client, num) \ 72178825Sdfr do { \ 73178825Sdfr if (krb5_ret_int16((_client)->sock, &(num)) != 0) \ 74178825Sdfr errx(1, "krb5_ret_int16 " #num); \ 75178825Sdfr } while(0) 76178825Sdfr 77178825Sdfr#define ret32(_client, num) \ 78178825Sdfr do { \ 79178825Sdfr if (krb5_ret_int32((_client)->sock, &(num)) != 0) \ 80178825Sdfr errx(1, "krb5_ret_int32 " #num); \ 81178825Sdfr } while(0) 82178825Sdfr 83178825Sdfr#define retdata(_client, data) \ 84178825Sdfr do { \ 85178825Sdfr if (krb5_ret_data((_client)->sock, &(data)) != 0) \ 86178825Sdfr errx(1, "krb5_ret_data " #data); \ 87178825Sdfr } while(0) 88178825Sdfr 89178825Sdfr#define retstring(_client, data) \ 90178825Sdfr do { \ 91178825Sdfr if (krb5_ret_string((_client)->sock, &(data)) != 0) \ 92178825Sdfr errx(1, "krb5_ret_data " #data); \ 93178825Sdfr } while(0) 94178825Sdfr 95178825Sdfr 96178825Sdfr#define put32(_client, num) \ 97178825Sdfr do { \ 98178825Sdfr if (krb5_store_int32((_client)->sock, num) != 0) \ 99178825Sdfr errx(1, "krb5_store_int32 " #num); \ 100178825Sdfr } while(0) 101178825Sdfr 102178825Sdfr#define putdata(_client, data) \ 103178825Sdfr do { \ 104178825Sdfr if (krb5_store_data((_client)->sock, data) != 0) \ 105178825Sdfr errx(1, "krb5_store_data " #data); \ 106178825Sdfr } while(0) 107178825Sdfr 108178825Sdfr#define putstring(_client, str) \ 109178825Sdfr do { \ 110178825Sdfr if (store_string((_client)->sock, str) != 0) \ 111178825Sdfr errx(1, "krb5_store_str " #str); \ 112178825Sdfr } while(0) 113178825Sdfr 114178825Sdfrchar *** permutate_all(struct getarg_strings *, size_t *); 115