155682Smarkm/*
2233294Sstas * Copyright (c) 1997 - 2004 Kungliga Tekniska H��gskolan
3233294Sstas * (Royal Institute of Technology, Stockholm, Sweden).
4233294Sstas * All rights reserved.
555682Smarkm *
6233294Sstas * Redistribution and use in source and binary forms, with or without
7233294Sstas * modification, are permitted provided that the following conditions
8233294Sstas * are met:
955682Smarkm *
10233294Sstas * 1. Redistributions of source code must retain the above copyright
11233294Sstas *    notice, this list of conditions and the following disclaimer.
1255682Smarkm *
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.
1655682Smarkm *
17233294Sstas * 3. Neither the name of the Institute nor the names of its contributors
18233294Sstas *    may be used to endorse or promote products derived from this software
19233294Sstas *    without specific prior written permission.
2055682Smarkm *
21233294Sstas * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
22233294Sstas * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23233294Sstas * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24233294Sstas * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
25233294Sstas * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26233294Sstas * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27233294Sstas * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28233294Sstas * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29233294Sstas * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30233294Sstas * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31233294Sstas * SUCH DAMAGE.
3255682Smarkm */
3355682Smarkm
34233294Sstas/* $Id$ */
3555682Smarkm
3655682Smarkm#ifdef HAVE_CONFIG_H
3755682Smarkm#include <config.h>
3855682Smarkm#endif
3955682Smarkm
4055682Smarkm#include <stdio.h>
4155682Smarkm#include <assert.h>
4255682Smarkm#include <stdarg.h>
4355682Smarkm#include <ctype.h>
4455682Smarkm#ifdef HAVE_SYS_TYPES_H
4555682Smarkm#include <sys/types.h>
4655682Smarkm#endif
4755682Smarkm#ifdef HAVE_UNISTD_H
4855682Smarkm#include <unistd.h>
4955682Smarkm#endif
5055682Smarkm#ifdef HAVE_SYS_WAIT_H
5155682Smarkm#include <sys/wait.h>
5255682Smarkm#endif
5355682Smarkm#ifdef HAVE_SYS_SELECT_H
5455682Smarkm#include <sys/select.h>
5555682Smarkm#endif
5655682Smarkm#ifdef HAVE_SYS_SOCKET_H
5755682Smarkm#include <sys/socket.h>
5855682Smarkm#endif
5955682Smarkm#ifdef HAVE_NETINET_IN_H
6055682Smarkm#include <netinet/in.h>
6155682Smarkm#endif
6255682Smarkm#ifdef HAVE_NETINET_IN6_H
6355682Smarkm#include <netinet/in6.h>
6455682Smarkm#endif
6555682Smarkm#ifdef HAVE_NETINET6_IN6_H
6655682Smarkm#include <netinet6/in6.h>
6755682Smarkm#endif
6855682Smarkm#ifdef HAVE_ARPA_INET_H
6955682Smarkm#include <arpa/inet.h>
7055682Smarkm#endif
7155682Smarkm
7255682Smarkm#ifdef HAVE_PWD_H
7355682Smarkm#include <pwd.h>
7455682Smarkm#endif
7555682Smarkm#ifdef HAVE_SHADOW_H
7655682Smarkm#include <shadow.h>
7755682Smarkm#endif
7855682Smarkm#ifdef HAVE_NETDB_H
7955682Smarkm#include <netdb.h>
8055682Smarkm#endif
81120945Snectar#ifdef HAVE_LIMITS_H
82120945Snectar#include <limits.h>
83120945Snectar#endif
8455682Smarkm#include <errno.h>
8555682Smarkm
8655682Smarkm#ifdef HAVE_SYS_PARAM_H
8755682Smarkm#include <sys/param.h>
8855682Smarkm#endif
8955682Smarkm
9055682Smarkm#ifdef HAVE_SYSLOG_H
9155682Smarkm#include <syslog.h>
9255682Smarkm#endif
9355682Smarkm#ifdef HAVE_PATHS_H
9455682Smarkm#include <paths.h>
9555682Smarkm#endif
9655682Smarkm#include <err.h>
9755682Smarkm#include <roken.h>
9855682Smarkm#include <getarg.h>
99102644Snectar#ifdef KRB5
10055682Smarkm#include <krb5.h>
101178825Sdfr/* XXX */
102233294Sstasstruct hx509_certs_data;
103178825Sdfrstruct krb5_pk_identity;
104178825Sdfrstruct krb5_pk_cert;
105178825Sdfrstruct ContentInfo;
106233294Sstasstruct AlgorithmIdentifier;
107178825Sdfrstruct _krb5_krb_auth_data;
108178825Sdfrstruct krb5_dh_moduli;
109233294Sstasstruct _krb5_key_data;
110233294Sstasstruct _krb5_encryption_type;
111233294Sstasstruct _krb5_key_type;
112178825Sdfr#include "crypto-headers.h"
113103423Snectar#include <krb5-private.h> /* for _krb5_{get,put}_int */
114102644Snectar#endif
115233294Sstas#if defined(KRB5)
11655682Smarkm#include <kafs.h>
11755682Smarkm#endif
11855682Smarkm
11955682Smarkm#ifndef _PATH_BSHELL
12055682Smarkm#define _PATH_BSHELL	"/bin/sh"
12155682Smarkm#endif
12255682Smarkm
12355682Smarkm#ifndef _PATH_DEFPATH
12455682Smarkm#define _PATH_DEFPATH	"/usr/bin:/bin"
12555682Smarkm#endif
12655682Smarkm
127178825Sdfr#include "loginpaths.h"
12872445Sassar
12955682Smarkm/*
13055682Smarkm *
13155682Smarkm */
13255682Smarkm
133233294Sstasenum auth_method { AUTH_KRB5, AUTH_BROKEN };
13455682Smarkm
13555682Smarkmextern enum auth_method auth_method;
13655682Smarkmextern int do_encrypt;
137102644Snectar#ifdef KRB5
13855682Smarkmextern krb5_context context;
13955682Smarkmextern krb5_keyblock *keyblock;
14055682Smarkmextern krb5_crypto crypto;
141103423Snectarextern int key_usage;
142103423Snectarextern void *ivec_in[2];
143103423Snectarextern void *ivec_out[2];
144178825Sdfrvoid init_ivecs(int, int);
145102644Snectar#endif
14655682Smarkm
147103423Snectar#define KCMD_OLD_VERSION "KCMDV0.1"
148103423Snectar#define KCMD_NEW_VERSION "KCMDV0.2"
14955682Smarkm
15055682Smarkm#define USERNAME_SZ 16
151120945Snectar#ifndef ARG_MAX
152120945Snectar#define ARG_MAX 8192
153120945Snectar#endif
15455682Smarkm
155103423Snectar#define RSH_BUFSIZ (5 * 1024) /* MIT kcmd can't handle larger buffers */
156178825Sdfr#define RSHD_BUFSIZ (16 * 1024) /* Old maxize for Heimdal 0.4 rsh */
15755682Smarkm
15855682Smarkm#define PATH_RSH BINDIR "/rsh"
15955682Smarkm
160233294Sstas#if defined(KRB5)
161103423Snectarssize_t do_read (int, void*, size_t, void*);
162103423Snectarssize_t do_write (int, void*, size_t, void*);
163102644Snectar#else
164103423Snectar#define do_write(F, B, L, I) write((F), (B), (L))
165103423Snectar#define do_read(F, B, L, I) read((F), (B), (L))
166102644Snectar#endif
167