This commit is contained in:
Sevan Janiyan 2018-11-17 05:59:34 +00:00 committed by GitHub
commit 95dd13fae5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3154 changed files with 303257 additions and 60483 deletions

View File

@ -1,10 +1,8 @@
# $NetBSD: Makefile,v 1.3 2013/02/12 20:55:37 christos Exp $
# $NetBSD: Makefile,v 1.4 2017/05/21 15:28:37 riastradh Exp $
.include <bsd.own.mk>
.if (${MKCRYPTO} != "no")
#MINIX: Not yet imported: cpl
SUBDIR+= bsd
.endif
.include <bsd.subdir.mk>

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile.rules.inc,v 1.7 2012/09/05 19:31:04 christos Exp $
# $NetBSD: Makefile.rules.inc,v 1.8 2017/01/28 21:31:43 christos Exp $
SRCS+= ${HEIMSRCS:N*.et:N*.in:N*.asn1}
@ -72,7 +72,7 @@ NORMALIZE_SRC=-e "s@${NETBSDSRCDIR}@/usr/src@g"
.for x2c in ${ASN1_FILES.${src}}
${x2c:.x=.c}: ${x2c}
@${TOOL_SED} ${NORMALIZE_SRC} < ${x2c} > ${x2c}.r
@${TOOL_SED} ${NORMALIZE_SRC} < ${.ALLSRC} > ${x2c}.r
@cmp -s ${x2c}.r ${x2c:.x=.c} 2> /dev/null || cp ${x2c}.r ${x2c:.x=.c}
@rm -f ${x2c}.r
.endfor

View File

@ -1,11 +1,13 @@
# $NetBSD: Makefile.inc,v 1.2 2011/05/25 19:21:16 he Exp $
# $NetBSD: Makefile.inc,v 1.3 2017/01/28 21:31:43 christos Exp $
BINDIR=/usr/bin
LDADD+= -lkrb5 -lhx509 -lasn1 -lroken -lcom_err -lwind
LDADD+= -lheimbase ${LIBVERS}
LDADD+= -lcrypto -lcrypt
LDADD+= -lsqlite3
DPADD+= ${LIBKRB5} ${LIBHX509} ${LIBASN1} ${LIBROKEN} ${LIBCOM_ERR} ${LIBWIND}
DPADD+= ${LIBHEIMBASE} ${LIBVERS}
DPADD+= ${LIBCRYPTO} ${LIBCRYPT}
DPADD+= ${LIBSQLITE3}

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.2 2011/05/25 19:21:16 he Exp $
# $NetBSD: Makefile,v 1.3 2017/01/28 21:31:43 christos Exp $
.include <bsd.own.mk>
.include <${.CURDIR}/../../Makefile.inc>
@ -12,14 +12,15 @@ LINKS+= ${BINDIR}/kcc ${BINDIR}/klist
MAN= klist.1
HEIMSRCS= kcc-commands.in
HEIMSRCS= heimtools-commands.in
SRCS= copy_cred_cache.c \
kcc.c \
heimtools.c \
klist.c \
kswitch.c
CPPFLAGS+= -I${DESTDIR}/usr/include/krb5
CPPFLAGS+= -I${HEIMDIST}/kuser
LDADD+= -lkafs -lsl
LDADD+= -ledit -lterminfo

View File

@ -1,4 +1,4 @@
Copyright (c) 1995 - 2011 Kungliga Tekniska Högskolan
Copyright (c) 1995 - 2014 Kungliga Tekniska Högskolan
(Royal Institute of Technology, Stockholm, Sweden).
All rights reserved.

View File

@ -6,7 +6,7 @@ if KCM
kcm_dir = kcm
endif
SUBDIRS= include base lib kuser kdc admin kadmin kpasswd
SUBDIRS= include lib kuser kdc admin kadmin kpasswd
SUBDIRS+= $(kcm_dir) appl tools tests packages etc po
if HEIMDAL_DOCUMENTATION
@ -38,6 +38,7 @@ EXTRA_DIST = \
autogen.sh \
krb5.conf \
cf/make-proto.pl \
cf/roken-h-process.pl \
cf/install-catman.sh \
cf/ChangeLog \
cf/c-function.m4 \
@ -52,6 +53,13 @@ EXTRA_DIST = \
cf/krb-version.m4 \
cf/roken.m4 \
cf/valgrind-suppressions \
cf/maybe-valgrind.sh \
cf/symbol-version.py \
cf/w32-check-exported-symbols.pl \
cf/w32-def-from-dll.pl \
cf/w32-detect-vc-version.pl \
cf/w32-hh-toc-from-info.pl \
cf/w32-list-externs-from-objs.pl \
cf/vararray.m4
print-distdir:

View File

@ -1,3 +1,134 @@
Release Notes - Heimdal - Version Heimdal 7.1
Security
- kx509 realm-chopping security bug
- non-authorization of alias additions/removals in kadmind
(CVE-2016-2400)
Feature
- iprop has been revamped to fix a number of race conditions that could
lead to inconsistent replication
- Hierarchical capath support
- AES Encryption with HMAC-SHA2 for Kerberos 5
draft-ietf-kitten-aes-cts-hmac-sha2-11
- hcrypto is now thread safe on all platforms
- libhcrypto has new backends: CNG (Windows), PKCS#11 (mainly for
Solaris), and OpenSSL. OpenSSL is now a first-class libhcrypto backend.
OpenSSL 1.0.x and 1.1 are both supported. AES-NI used when supported by
backend
- HDB now supports LMDB
- Thread support on Windows
- RFC 6113 Generalized Framework for Kerberos Pre-Authentication (FAST)
- New GSS APIs:
. gss_localname
- Allow setting what encryption types a principal should have with
[kadmin] default_key_rules, see krb5.conf manpage for more info
- Unify libhcrypto with LTC (libtomcrypto)
- asn1_compile 64-bit INTEGER functionality
- HDB key history support including --keepold kadmin password option
- Improved cross-realm key rollover safety
- New krb5_kuserok() and krb5_aname_to_localname() plug-in interfaces
- Improved MIT compatibility
. kadm5 API
. Migration from MIT KDB via "mitdb" HDB backend
. Capable of writing the HDB in MIT dump format
- Improved Active Directory interoperability
. Enctype selection issues for PAC and other authz-data signatures
. Cross realm key rollover (kvno 0)
- New [kdc] enctype negotiation configuration:
. tgt-use-strongest-session-key
. svc-use-strongest-session-key
. preauth-use-strongest-session-key
. use-strongest-server-key
- The KDC process now uses a multi-process model improving
resiliency and performance
- Allow batch-mode kinit with password file
- SIGINFO support added to kinit cmd
- New kx509 configuration options:
. kx509_ca
. kca_service
. kx509_include_pkinit_san
. kx509_template
- Improved Heimdal library/plugin version safety
- Name canonicalization
. DNS resolver searchlist
. Improved referral support
. Support host:port host-based services
- Pluggable libheimbase interface for DBs
- Improve IPv6 Support
- LDAP
. Bind DN and password
. Start TLS
- klist --json
- DIR credential cache type
- Updated upstream SQLite and libedit
- Removed legacy applications: ftp, kx, login, popper, push, rcp, rsh,
telnet, xnlock
- Completely remove RAND_egd support
- Moved kadmin and ktutil to /usr/bin
- Stricter fcache checks (see fcache_strict_checking krb5.conf setting)
. use O_NOFOLLOW
. don't follow symlinks
. require cache files to be owned by the user
. require sensible permissions (not group/other readable)
- Implemented gss_store_cred()
- Many more
Bug fixes
- iprop has been revamped to fix a number of race conditions that could
lead to data loss
- Include non-loopback addresses assigned to loopback interfaces
when requesting tickets with addresses
- KDC 1DES session key selection (for AFS rxkad-k5 compatibility)
- Keytab file descriptor and lock leak
- Credential cache corruption bugs
(NOTE: The FILE ccache is still not entirely safe due to the
fundamentally unsafe design of POSIX file locking)
- gss_pseudo_random() interop bug
- Plugins are now preferentially loaded from the run-time install tree
- Reauthentication after password change in init_creds_password
- Memory leak in the client kadmin library
- TGS client requests renewable/forwardable/proxiable when possible
- Locking issues in DB1 and DB3 HDB backends
- Master HDB can remain locked while waiting for network I/O
- Renewal/refresh logic when kinit is provided with a command
- KDC handling of enterprise principals
- Use correct bit for anon-pkinit
- Many more
Acknowledgements
This release of Heimdal includes contributions from:
Abhinav Upadhyay Heath Kehoe Nico Williams
Andreas Schneider Henry Jacques Patrik Lundin
Andrew Bartlett Howard Chu Philip Boulain
Andrew Tridgell Igor Sobrado Ragnar Sundblad
Antoine Jacoutot Ingo Schwarze Remi Ferrand
Arran Cudbard-Bell Jakub Čajka Rod Widdowson
Arvid Requate James Le Cuirot Rok Papež
Asanka Herath James Lee Roland C. Dowdeswell
Ben Kaduk Jeffrey Altman Ross L Richardson
Benjamin Kaduk Jeffrey Clark Russ Allbery
Bernard Spil Jeffrey Hutzelman Samuel Cabrero
Brian May Jelmer Vernooij Samuel Thibault
Chas Williams Ken Dreyer Santosh Kumar Pradhan
Chaskiel Grundman Kiran S J Sean Davis
Dana Koch Kumar Thangavelu Sergio Gelato
Daniel Schepler Landon Fuller Simon Wilkinson
David Mulder Linus Nordberg Stef Walter
Douglas Bagnall Love Hörnquist Åstrand Stefan Metzmacher
Ed Maste Luke Howard Steffen Jaeckel
Eray Aslan Magnus Ahltorp Timothy Pearson
Florian Best Marc Balmer Tollef Fog Heen
Fredrik Pettai Marcin Cieślak Tony Acero
Greg Hudson Marco Molteni Uri Simchoni
Gustavo Zacarias Matthieu Hautreux Viktor Dukhovni
Günther Deschner Michael Meffie Volker Lendecke
Harald Barth Moritz Lenz
Release Notes - Heimdal - Version Heimdal 1.5.3
Bug fixes
@ -102,7 +233,7 @@ Release Notes - Heimdal - Version Heimdal 1.3
- Support for settin friendly name on credential caches
- Move to using doxygen to generate documentation.
- Sprinkling __attribute__((depricated)) for old function to be removed
- Sprinkling __attribute__((__deprecated__)) for old function to be removed
- Support to export LAST-REQUST information in AS-REQ
- Support for client deferrals in in AS-REQ
- Add seek support for krb5_storage.

View File

@ -29,12 +29,17 @@
# POSSIBILITY OF SUCH DAMAGE.
#
!if exist(thirdparty/NTMakefile)
!if exist("thirdparty\NTMakefile")
thirdparty=thirdparty
!endif
SUBDIRS = include lib\roken base lib kuser kdc admin kadmin kpasswd appl doc \
!ifdef APPVEYOR
SUBDIRS = include lib kuser kdc admin kadmin kpasswd appl doc \
tools tests packages etc
!else
SUBDIRS = include lib kuser kdc admin kadmin kpasswd appl doc \
tools tests packages etc $(thirdparty) packages\windows\installer
!endif
!include windows/NTMakefile.w32

View File

@ -0,0 +1,17 @@
-- in order of preference
- client: support KRB5_PADATA_ENCRYPTED_CHALLENGE in lib/krb5/init_creds_pw.c
- client: don't support ENC-TS in FAST
- client: plugin support for fast plugins
- kdc: plugin support for fast plugins
partly done with "struct kdc_patypes"
- kcm: support FAST armor ticket
-- using PK-INIT anonymous
-- using host key
- client: tgs-req fast support
- kdc: tgs-req fast support

View File

@ -2,11 +2,11 @@
include $(top_srcdir)/Makefile.am.common
AM_CPPFLAGS += $(INCLUDE_readline) $(INCLUDE_hcrypto)
AM_CPPFLAGS += $(INCLUDE_readline)
man_MANS = ktutil.8
man_MANS = ktutil.1
sbin_PROGRAMS = ktutil
bin_PROGRAMS = ktutil
dist_ktutil_SOURCES = \
add.c \

View File

@ -1,4 +1,4 @@
/* $NetBSD: add.c,v 1.1.1.2 2014/04/24 12:45:26 pettai Exp $ */
/* $NetBSD: add.c,v 1.2 2017/01/28 21:31:44 christos Exp $ */
/*
* Copyright (c) 1997-2005 Kungliga Tekniska Högskolan
@ -35,7 +35,7 @@
#include "ktutil_locl.h"
__RCSID("NetBSD");
__RCSID("$NetBSD: add.c,v 1.2 2017/01/28 21:31:44 christos Exp $");
static char *
readstring(const char *prompt, char *buf, size_t len)

View File

@ -1,4 +1,4 @@
/* $NetBSD: change.c,v 1.1.1.2 2014/04/24 12:45:26 pettai Exp $ */
/* $NetBSD: change.c,v 1.2 2017/01/28 21:31:44 christos Exp $ */
/*
* Copyright (c) 1997-2005 Kungliga Tekniska Högskolan
@ -35,7 +35,7 @@
#include "ktutil_locl.h"
__RCSID("NetBSD");
__RCSID("$NetBSD: change.c,v 1.2 2017/01/28 21:31:44 christos Exp $");
static krb5_error_code
change_entry (krb5_keytab keytab,

View File

@ -1,4 +1,4 @@
/* $NetBSD: copy.c,v 1.1.1.2 2014/04/24 12:45:26 pettai Exp $ */
/* $NetBSD: copy.c,v 1.2 2017/01/28 21:31:44 christos Exp $ */
/*
* Copyright (c) 1997-2004 Kungliga Tekniska Högskolan
@ -35,7 +35,7 @@
#include "ktutil_locl.h"
__RCSID("NetBSD");
__RCSID("$NetBSD: copy.c,v 1.2 2017/01/28 21:31:44 christos Exp $");
static krb5_boolean

View File

@ -1,4 +1,4 @@
/* $NetBSD: destroy.c,v 1.1.1.1 2011/04/13 18:14:32 elric Exp $ */
/* $NetBSD: destroy.c,v 1.2 2017/01/28 21:31:44 christos Exp $ */
/*
* Copyright (c) 2009 Kungliga Tekniska Högskolan

View File

@ -1,4 +1,4 @@
/* $NetBSD: get.c,v 1.1.1.2 2014/04/24 12:45:26 pettai Exp $ */
/* $NetBSD: get.c,v 1.2 2017/01/28 21:31:44 christos Exp $ */
/*
* Copyright (c) 1997-2004 Kungliga Tekniska Högskolan
@ -35,7 +35,7 @@
#include "ktutil_locl.h"
__RCSID("NetBSD");
__RCSID("$NetBSD: get.c,v 1.2 2017/01/28 21:31:44 christos Exp $");
static void*
open_kadmin_connection(char *principal,

View File

@ -206,7 +206,7 @@ command = {
short = "V"
type = "integer"
help = "key version to remove"
argument = "enctype"
argument = "kvno"
default = "0"
}
option = {

View File

@ -1,4 +1,4 @@
.\" $NetBSD: ktutil.8,v 1.4 2014/04/25 00:26:16 pettai Exp $
.\" $NetBSD: ktutil.1,v 1.2 2017/01/28 21:31:44 christos Exp $
.\"
.\" Copyright (c) 1997-2004 Kungliga Tekniska Högskolan
.\" (Royal Institute of Technology, Stockholm, Sweden).
@ -34,7 +34,7 @@
.\" Id
.\"
.Dd April 14, 2005
.Dt KTUTIL 8
.Dt KTUTIL 1
.Os
.Sh NAME
.Nm ktutil
@ -123,4 +123,4 @@ that is at least
(default one week) old.
.El
.Sh SEE ALSO
.Xr kadmin 8
.Xr kadmin 1

View File

@ -1,4 +1,4 @@
/* $NetBSD: ktutil.c,v 1.1.1.2 2014/04/24 12:45:26 pettai Exp $ */
/* $NetBSD: ktutil.c,v 1.2 2017/01/28 21:31:44 christos Exp $ */
/*
* Copyright (c) 1997-2004 Kungliga Tekniska Högskolan
@ -36,7 +36,7 @@
#include "ktutil_locl.h"
#include <err.h>
__RCSID("NetBSD");
__RCSID("$NetBSD: ktutil.c,v 1.2 2017/01/28 21:31:44 christos Exp $");
static int help_flag;
static int version_flag;

View File

@ -1,4 +1,4 @@
/* $NetBSD: ktutil_locl.h,v 1.1.1.2 2011/04/14 14:08:06 elric Exp $ */
/* $NetBSD: ktutil_locl.h,v 1.2 2017/01/28 21:31:44 christos Exp $ */
/*
* Copyright (c) 1997-2004 Kungliga Tekniska Högskolan

View File

@ -1,4 +1,4 @@
/* $NetBSD: list.c,v 1.1.1.2 2014/04/24 12:45:26 pettai Exp $ */
/* $NetBSD: list.c,v 1.2 2017/01/28 21:31:44 christos Exp $ */
/*
* Copyright (c) 1997-2004 Kungliga Tekniska Högskolan
@ -36,7 +36,7 @@
#include "ktutil_locl.h"
#include <krb5/rtbl.h>
__RCSID("NetBSD");
__RCSID("$NetBSD: list.c,v 1.2 2017/01/28 21:31:44 christos Exp $");
static int
do_list(struct list_options *opt, const char *keytab_str)
@ -134,11 +134,12 @@ do_list(struct list_options *opt, const char *keytab_str)
for (i = 0; i< entry.aliases->len; i++) {
krb5_unparse_name_fixed(context, entry.principal, buf, sizeof(buf));
rk_strpoolprintf(p, "%s%s", buf,
i + 1 < entry.aliases->len ? ", " : "");
p = rk_strpoolprintf(p, "%s%s", buf,
i + 1 < entry.aliases->len ? ", " : "");
}
rtbl_add_column_entry_by_id(table, 5, rk_strpoolcollect(p));
rtbl_add_column_entry_by_id(table, 5, (s = rk_strpoolcollect(p)));
free(s);
}
krb5_kt_free_entry(context, &entry);

View File

@ -1,4 +1,4 @@
/* $NetBSD: purge.c,v 1.1.1.2 2014/04/24 12:45:26 pettai Exp $ */
/* $NetBSD: purge.c,v 1.2 2017/01/28 21:31:44 christos Exp $ */
/*
* Copyright (c) 1997-2004 Kungliga Tekniska Högskolan
@ -35,7 +35,7 @@
#include "ktutil_locl.h"
__RCSID("NetBSD");
__RCSID("$NetBSD: purge.c,v 1.2 2017/01/28 21:31:44 christos Exp $");
/*
* keep track of the highest version for every principal.

View File

@ -1,4 +1,4 @@
/* $NetBSD: remove.c,v 1.1.1.2 2014/04/24 12:45:26 pettai Exp $ */
/* $NetBSD: remove.c,v 1.2 2017/01/28 21:31:44 christos Exp $ */
/*
* Copyright (c) 1997-2004 Kungliga Tekniska Högskolan
@ -35,7 +35,7 @@
#include "ktutil_locl.h"
__RCSID("NetBSD");
__RCSID("$NetBSD: remove.c,v 1.2 2017/01/28 21:31:44 christos Exp $");
int
kt_remove(struct remove_options *opt, int argc, char **argv)

View File

@ -1,4 +1,4 @@
/* $NetBSD: rename.c,v 1.1.1.2 2014/04/24 12:45:26 pettai Exp $ */
/* $NetBSD: rename.c,v 1.2 2017/01/28 21:31:44 christos Exp $ */
/*
* Copyright (c) 2001-2004 Kungliga Tekniska Högskolan
@ -35,7 +35,7 @@
#include "ktutil_locl.h"
__RCSID("NetBSD");
__RCSID("$NetBSD: rename.c,v 1.2 2017/01/28 21:31:44 christos Exp $");
int
kt_rename(struct rename_options *opt, int argc, char **argv)

View File

@ -0,0 +1,54 @@
#
# This file tells appveyor.com how to build Heimdal on Windows.
# Appveyor is a continuous integration (CI) service for github and other
# users, and is free for public repositories.
#
install:
- C:\msys64\usr\bin\bash -lc "pacman --needed --noconfirm -Sy pacman-mirrors"
- C:\msys64\usr\bin\bash -lc "pacman --noconfirm -Sy"
- C:\msys64\usr\bin\bash -lc "pacman --noconfirm -S autoconf automake bison flex"
build_script:
- set PSDKDir=C:\Program Files\Microsoft SDKs\Windows\v7.1
- call "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.Cmd" %1 %2 /xp
- set WIXDIR="c:\Program Files (x86)\Windows Installer XML v3.5"
# We're not doing any codesigning in the Appveyor build yet.
- SET CODESIGN_PKT=0000000000000000
- set PATH=%PATH%;C:\Python26;C:\Perl64\bin;C:\tools\cygwin\bin;C:\Program Files (x86)\HTML Help Workshop
- set PATH=%PATH%;C:/msys64/usr/bin
- set PATH=%PATH%;C:\program files (x86)\windows installer xml v3.5\bin;C:\cygwin\bin
- set dbg__type=Debug
- title Heimdal Build %CPU% %dbg__type%
- echo PATH=%PATH%
# Newer texinfo has no .exe's, so we have to invoke it as
# "perl ...\makeinfo ...". See doc/NTMakefile.
- nmake /f NTMakefile APPVEYOR=1 MAKEINFO=makeinfo NO_INSTALLERS=1
- 7z a heimdal-out.zip C:\projects\heimdal\out\
test_script:
# Packages are not validated in the Appveyor build, FYI.
- nmake /f NTMakefile APPVEYOR=1 MAKEINFO=makeinfo NO_INSTALLERS=1 test
artifacts:
- path: heimdal-out.zip
name: heimdal-out
on_failure:
- appveyor PushArtifact heimdal-out.zip
# To get RDP access to an appveyor worker for debugging a build, just
# uncomment these next two lines and the last two lines too.
#init:
# - ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
# Uncomment this to allow the RDP session to continue after the build
# finishes.
#
# There's a delete-me file on the desktop that one should delete when
# one is done with the worker. RDP sessions are capped at 60 minutes as
# of this writing.
#
#on_finish:
# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))

View File

@ -5,3 +5,5 @@
set -e
autoreconf -f -i || { echo "autoreconf failed: $?"; exit 1; }
find . \( -name '*-private.h' -o -name '*-protos.h' \) | xargs rm -f
perl -MJSON -e 'print foo;' || \
{ echo "you must install JSON perl module (cpan install JSON)"; exit 1; }

View File

@ -1,236 +0,0 @@
/* $NetBSD: array.c,v 1.1.1.2 2014/04/24 12:45:26 pettai Exp $ */
/*
* Copyright (c) 2010 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
* Portions Copyright (c) 2010 Apple Inc. 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. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include "baselocl.h"
/*
*
*/
struct heim_array_data {
size_t len;
heim_object_t *val;
};
static void
array_dealloc(heim_object_t ptr)
{
heim_array_t array = ptr;
size_t n;
for (n = 0; n < array->len; n++)
heim_release(array->val[n]);
free(array->val);
}
struct heim_type_data array_object = {
HEIM_TID_ARRAY,
"dict-object",
NULL,
array_dealloc,
NULL,
NULL,
NULL
};
/**
* Allocate an array
*
* @return A new allocated array, free with heim_release()
*/
heim_array_t
heim_array_create(void)
{
heim_array_t array;
array = _heim_alloc_object(&array_object, sizeof(*array));
if (array == NULL)
return NULL;
array->val = NULL;
array->len = 0;
return array;
}
/**
* Get type id of an dict
*
* @return the type id
*/
heim_tid_t
heim_array_get_type_id(void)
{
return HEIM_TID_ARRAY;
}
/**
* Append object to array
*
* @param array array to add too
* @param object the object to add
*
* @return zero if added, errno otherwise
*/
int
heim_array_append_value(heim_array_t array, heim_object_t object)
{
heim_object_t *ptr;
ptr = realloc(array->val, (array->len + 1) * sizeof(array->val[0]));
if (ptr == NULL)
return ENOMEM;
array->val = ptr;
array->val[array->len++] = heim_retain(object);
return 0;
}
/**
* Iterate over all objects in array
*
* @param array array to iterate over
* @param fn function to call on each object
* @param ctx context passed to fn
*/
void
heim_array_iterate_f(heim_array_t array, heim_array_iterator_f_t fn, void *ctx)
{
size_t n;
for (n = 0; n < array->len; n++)
fn(array->val[n], ctx);
}
#ifdef __BLOCKS__
/**
* Iterate over all objects in array
*
* @param array array to iterate over
* @param fn block to call on each object
*/
void
heim_array_iterate(heim_array_t array, void (^fn)(heim_object_t))
{
size_t n;
for (n = 0; n < array->len; n++)
fn(array->val[n]);
}
#endif
/**
* Get length of array
*
* @param array array to get length of
*
* @return length of array
*/
size_t
heim_array_get_length(heim_array_t array)
{
return array->len;
}
/**
* Copy value of array
*
* @param array array copy object from
* @param idx index of object, 0 based, must be smaller then
* heim_array_get_length()
*
* @return a retained copy of the object
*/
heim_object_t
heim_array_copy_value(heim_array_t array, size_t idx)
{
if (idx >= array->len)
heim_abort("index too large");
return heim_retain(array->val[idx]);
}
/**
* Delete value at idx
*
* @param array the array to modify
* @param idx the key to delete
*/
void
heim_array_delete_value(heim_array_t array, size_t idx)
{
heim_object_t obj;
if (idx >= array->len)
heim_abort("index too large");
obj = array->val[idx];
array->len--;
if (idx < array->len)
memmove(&array->val[idx], &array->val[idx + 1],
(array->len - idx) * sizeof(array->val[0]));
heim_release(obj);
}
#ifdef __BLOCKS__
/**
* Get value at idx
*
* @param array the array to modify
* @param idx the key to delete
*/
void
heim_array_filter(heim_array_t array, int (^block)(heim_object_t))
{
size_t n = 0;
while (n < array->len) {
if (block(array->val[n])) {
heim_array_delete_value(array, n);
} else {
n++;
}
}
}
#endif /* __BLOCKS__ */

View File

@ -1,561 +0,0 @@
/* $NetBSD: heimbase.c,v 1.1.1.2 2014/04/24 12:45:26 pettai Exp $ */
/*
* Copyright (c) 2010 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
* Portions Copyright (c) 2010 Apple Inc. 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. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include "baselocl.h"
#include <syslog.h>
static heim_base_atomic_type tidglobal = HEIM_TID_USER;
struct heim_base {
heim_type_t isa;
heim_base_atomic_type ref_cnt;
HEIM_TAILQ_ENTRY(heim_base) autorel;
heim_auto_release_t autorelpool;
uintptr_t isaextra[3];
};
/* specialized version of base */
struct heim_base_mem {
heim_type_t isa;
heim_base_atomic_type ref_cnt;
HEIM_TAILQ_ENTRY(heim_base) autorel;
heim_auto_release_t autorelpool;
const char *name;
void (*dealloc)(void *);
uintptr_t isaextra[1];
};
#define PTR2BASE(ptr) (((struct heim_base *)ptr) - 1)
#define BASE2PTR(ptr) ((void *)(((struct heim_base *)ptr) + 1))
#ifdef HEIM_BASE_NEED_ATOMIC_MUTEX
HEIMDAL_MUTEX _heim_base_mutex = HEIMDAL_MUTEX_INITIALIZER;
#endif
/*
* Auto release structure
*/
struct heim_auto_release {
HEIM_TAILQ_HEAD(, heim_base) pool;
HEIMDAL_MUTEX pool_mutex;
struct heim_auto_release *parent;
};
/**
* Retain object
*
* @param object to be released, NULL is ok
*
* @return the same object as passed in
*/
void *
heim_retain(void *ptr)
{
struct heim_base *p = PTR2BASE(ptr);
if (ptr == NULL || heim_base_is_tagged(ptr))
return ptr;
if (p->ref_cnt == heim_base_atomic_max)
return ptr;
if ((heim_base_atomic_inc(&p->ref_cnt) - 1) == 0)
heim_abort("resurection");
return ptr;
}
/**
* Release object, free is reference count reaches zero
*
* @param object to be released
*/
void
heim_release(void *ptr)
{
heim_base_atomic_type old;
struct heim_base *p = PTR2BASE(ptr);
if (ptr == NULL || heim_base_is_tagged(ptr))
return;
if (p->ref_cnt == heim_base_atomic_max)
return;
old = heim_base_atomic_dec(&p->ref_cnt) + 1;
if (old > 1)
return;
if (old == 1) {
heim_auto_release_t ar = p->autorelpool;
/* remove from autorel pool list */
if (ar) {
p->autorelpool = NULL;
HEIMDAL_MUTEX_lock(&ar->pool_mutex);
HEIM_TAILQ_REMOVE(&ar->pool, p, autorel);
HEIMDAL_MUTEX_unlock(&ar->pool_mutex);
}
if (p->isa->dealloc)
p->isa->dealloc(ptr);
free(p);
} else
heim_abort("over release");
}
static heim_type_t tagged_isa[9] = {
&_heim_number_object,
&_heim_null_object,
&_heim_bool_object,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL
};
heim_type_t
_heim_get_isa(heim_object_t ptr)
{
struct heim_base *p;
if (heim_base_is_tagged(ptr)) {
if (heim_base_is_tagged_object(ptr))
return tagged_isa[heim_base_tagged_object_tid(ptr)];
heim_abort("not a supported tagged type");
}
p = PTR2BASE(ptr);
return p->isa;
}
/**
* Get type ID of object
*
* @param object object to get type id of
*
* @return type id of object
*/
heim_tid_t
heim_get_tid(heim_object_t ptr)
{
heim_type_t isa = _heim_get_isa(ptr);
return isa->tid;
}
/**
* Get hash value of object
*
* @param object object to get hash value for
*
* @return a hash value
*/
unsigned long
heim_get_hash(heim_object_t ptr)
{
heim_type_t isa = _heim_get_isa(ptr);
if (isa->hash)
return isa->hash(ptr);
return (unsigned long)ptr;
}
/**
* Compare two objects, returns 0 if equal, can use used for qsort()
* and friends.
*
* @param a first object to compare
* @param b first object to compare
*
* @return 0 if objects are equal
*/
int
heim_cmp(heim_object_t a, heim_object_t b)
{
heim_tid_t ta, tb;
heim_type_t isa;
ta = heim_get_tid(a);
tb = heim_get_tid(b);
if (ta != tb)
return ta - tb;
isa = _heim_get_isa(a);
if (isa->cmp)
return isa->cmp(a, b);
return (uintptr_t)a - (uintptr_t)b;
}
/*
* Private - allocates an memory object
*/
static void
memory_dealloc(void *ptr)
{
struct heim_base_mem *p = (struct heim_base_mem *)PTR2BASE(ptr);
if (p->dealloc)
p->dealloc(ptr);
}
struct heim_type_data memory_object = {
HEIM_TID_MEMORY,
"memory-object",
NULL,
memory_dealloc,
NULL,
NULL,
NULL
};
void *
heim_alloc(size_t size, const char *name, heim_type_dealloc dealloc)
{
/* XXX use posix_memalign */
struct heim_base_mem *p = calloc(1, size + sizeof(*p));
if (p == NULL)
return NULL;
p->isa = &memory_object;
p->ref_cnt = 1;
p->name = name;
p->dealloc = dealloc;
return BASE2PTR(p);
}
heim_type_t
_heim_create_type(const char *name,
heim_type_init init,
heim_type_dealloc dealloc,
heim_type_copy copy,
heim_type_cmp cmp,
heim_type_hash hash)
{
heim_type_t type;
type = calloc(1, sizeof(*type));
if (type == NULL)
return NULL;
type->tid = heim_base_atomic_inc(&tidglobal);
type->name = name;
type->init = init;
type->dealloc = dealloc;
type->copy = copy;
type->cmp = cmp;
type->hash = hash;
return type;
}
heim_object_t
_heim_alloc_object(heim_type_t type, size_t size)
{
/* XXX should use posix_memalign */
struct heim_base *p = calloc(1, size + sizeof(*p));
if (p == NULL)
return NULL;
p->isa = type;
p->ref_cnt = 1;
return BASE2PTR(p);
}
heim_tid_t
_heim_type_get_tid(heim_type_t type)
{
return type->tid;
}
/**
* Call func once and only once
*
* @param once pointer to a heim_base_once_t
* @param ctx context passed to func
* @param func function to be called
*/
void
heim_base_once_f(heim_base_once_t *once, void *ctx, void (*func)(void *))
{
#ifdef HAVE_DISPATCH_DISPATCH_H
dispatch_once_f(once, ctx, func);
#else
static HEIMDAL_MUTEX mutex = HEIMDAL_MUTEX_INITIALIZER;
HEIMDAL_MUTEX_lock(&mutex);
if (*once == 0) {
*once = 1;
HEIMDAL_MUTEX_unlock(&mutex);
func(ctx);
HEIMDAL_MUTEX_lock(&mutex);
*once = 2;
HEIMDAL_MUTEX_unlock(&mutex);
} else if (*once == 2) {
HEIMDAL_MUTEX_unlock(&mutex);
} else {
HEIMDAL_MUTEX_unlock(&mutex);
while (1) {
struct timeval tv = { 0, 1000 };
select(0, NULL, NULL, NULL, &tv);
HEIMDAL_MUTEX_lock(&mutex);
if (*once == 2)
break;
HEIMDAL_MUTEX_unlock(&mutex);
}
HEIMDAL_MUTEX_unlock(&mutex);
}
#endif
}
/**
* Abort and log the failure (using syslog)
*/
void
heim_abort(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
heim_abortv(fmt, ap);
va_end(ap);
}
/**
* Abort and log the failure (using syslog)
*/
void
heim_abortv(const char *fmt, va_list ap)
{
static char str[1024];
vsnprintf(str, sizeof(str), fmt, ap);
syslog(LOG_ERR, "heim_abort: %s", str);
abort();
}
/*
*
*/
static int ar_created = 0;
static HEIMDAL_thread_key ar_key;
struct ar_tls {
struct heim_auto_release *head;
struct heim_auto_release *current;
HEIMDAL_MUTEX tls_mutex;
};
static void
ar_tls_delete(void *ptr)
{
struct ar_tls *tls = ptr;
if (tls->head)
heim_release(tls->head);
free(tls);
}
static void
init_ar_tls(void *ptr)
{
int ret;
HEIMDAL_key_create(&ar_key, ar_tls_delete, ret);
if (ret == 0)
ar_created = 1;
}
static struct ar_tls *
autorel_tls(void)
{
static heim_base_once_t once = HEIM_BASE_ONCE_INIT;
struct ar_tls *arp;
int ret;
heim_base_once_f(&once, NULL, init_ar_tls);
if (!ar_created)
return NULL;
arp = HEIMDAL_getspecific(ar_key);
if (arp == NULL) {
arp = calloc(1, sizeof(*arp));
if (arp == NULL)
return NULL;
HEIMDAL_setspecific(ar_key, arp, ret);
if (ret) {
free(arp);
return NULL;
}
}
return arp;
}
static void
autorel_dealloc(void *ptr)
{
heim_auto_release_t ar = ptr;
struct ar_tls *tls;
tls = autorel_tls();
if (tls == NULL)
heim_abort("autorelease pool released on thread w/o autorelease inited");
heim_auto_release_drain(ar);
if (!HEIM_TAILQ_EMPTY(&ar->pool))
heim_abort("pool not empty after draining");
HEIMDAL_MUTEX_lock(&tls->tls_mutex);
if (tls->current != ptr)
heim_abort("autorelease not releaseing top pool");
if (tls->current != tls->head)
tls->current = ar->parent;
HEIMDAL_MUTEX_unlock(&tls->tls_mutex);
}
static int
autorel_cmp(void *a, void *b)
{
return (a == b);
}
static unsigned long
autorel_hash(void *ptr)
{
return (unsigned long)ptr;
}
static struct heim_type_data _heim_autorel_object = {
HEIM_TID_AUTORELEASE,
"autorelease-pool",
NULL,
autorel_dealloc,
NULL,
autorel_cmp,
autorel_hash
};
/**
*
*/
heim_auto_release_t
heim_auto_release_create(void)
{
struct ar_tls *tls = autorel_tls();
heim_auto_release_t ar;
if (tls == NULL)
heim_abort("Failed to create/get autorelease head");
ar = _heim_alloc_object(&_heim_autorel_object, sizeof(struct heim_auto_release));
if (ar) {
HEIMDAL_MUTEX_lock(&tls->tls_mutex);
if (tls->head == NULL)
tls->head = ar;
ar->parent = tls->current;
tls->current = ar;
HEIMDAL_MUTEX_unlock(&tls->tls_mutex);
}
return ar;
}
/**
* Mark the current object as a
*/
void
heim_auto_release(heim_object_t ptr)
{
struct heim_base *p = PTR2BASE(ptr);
struct ar_tls *tls = autorel_tls();
heim_auto_release_t ar;
if (ptr == NULL || heim_base_is_tagged(ptr))
return;
/* drop from old pool */
if ((ar = p->autorelpool) != NULL) {
HEIMDAL_MUTEX_lock(&ar->pool_mutex);
HEIM_TAILQ_REMOVE(&ar->pool, p, autorel);
p->autorelpool = NULL;
HEIMDAL_MUTEX_unlock(&ar->pool_mutex);
}
if (tls == NULL || (ar = tls->current) == NULL)
heim_abort("no auto relase pool in place, would leak");
HEIMDAL_MUTEX_lock(&ar->pool_mutex);
HEIM_TAILQ_INSERT_HEAD(&ar->pool, p, autorel);
p->autorelpool = ar;
HEIMDAL_MUTEX_unlock(&ar->pool_mutex);
}
/**
*
*/
void
heim_auto_release_drain(heim_auto_release_t autorel)
{
heim_object_t obj;
/* release all elements on the tail queue */
HEIMDAL_MUTEX_lock(&autorel->pool_mutex);
while(!HEIM_TAILQ_EMPTY(&autorel->pool)) {
obj = HEIM_TAILQ_FIRST(&autorel->pool);
HEIMDAL_MUTEX_unlock(&autorel->pool_mutex);
heim_release(BASE2PTR(obj));
HEIMDAL_MUTEX_lock(&autorel->pool_mutex);
}
HEIMDAL_MUTEX_unlock(&autorel->pool_mutex);
}

View File

@ -1,190 +0,0 @@
/* $NetBSD: heimbase.h,v 1.1.1.2 2014/04/24 12:45:26 pettai Exp $ */
/*
* Copyright (c) 2010 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
* Portions Copyright (c) 2010 Apple Inc. 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. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef HEIM_BASE_H
#define HEIM_BASE_H 1
#include <sys/types.h>
#include <krb5/krb5-types.h>
#include <stdarg.h>
#include <stdbool.h>
typedef void * heim_object_t;
typedef unsigned int heim_tid_t;
typedef heim_object_t heim_bool_t;
typedef heim_object_t heim_null_t;
#define HEIM_BASE_ONCE_INIT 0
typedef long heim_base_once_t; /* XXX arch dependant */
#if !defined(__has_extension)
#define __has_extension(x) 0
#endif
#define HEIM_REQUIRE_GNUC(m,n,p) \
(((__GNUC__ * 10000) + (__GNUC_MINOR__ * 100) + __GNUC_PATCHLEVEL__) >= \
(((m) * 10000) + ((n) * 100) + (p)))
#if __has_extension(__builtin_expect) || HEIM_REQUIRE_GNUC(3,0,0)
#define heim_builtin_expect(_op,_res) __builtin_expect(_op,_res)
#else
#define heim_builtin_expect(_op,_res) (_op)
#endif
void * heim_retain(heim_object_t);
void heim_release(heim_object_t);
typedef void (*heim_type_dealloc)(void *);
void *
heim_alloc(size_t size, const char *name, heim_type_dealloc dealloc);
heim_tid_t
heim_get_tid(heim_object_t object);
int
heim_cmp(heim_object_t a, heim_object_t b);
unsigned long
heim_get_hash(heim_object_t ptr);
void
heim_base_once_f(heim_base_once_t *, void *, void (*)(void *));
void
heim_abort(const char *fmt, ...)
HEIMDAL_NORETURN_ATTRIBUTE
HEIMDAL_PRINTF_ATTRIBUTE((printf, 1, 2));
void
heim_abortv(const char *fmt, va_list ap)
HEIMDAL_NORETURN_ATTRIBUTE
HEIMDAL_PRINTF_ATTRIBUTE((printf, 1, 0));
#define heim_assert(e,t) \
(heim_builtin_expect(!(e), 0) ? heim_abort(t ":" #e) : (void)0)
/*
*
*/
heim_null_t
heim_null_create(void);
heim_bool_t
heim_bool_create(int);
int
heim_bool_val(heim_bool_t);
/*
* Array
*/
typedef struct heim_array_data *heim_array_t;
heim_array_t heim_array_create(void);
heim_tid_t heim_array_get_type_id(void);
typedef void (*heim_array_iterator_f_t)(heim_object_t, void *);
int heim_array_append_value(heim_array_t, heim_object_t);
void heim_array_iterate_f(heim_array_t, heim_array_iterator_f_t, void *);
#ifdef __BLOCKS__
void heim_array_iterate(heim_array_t, void (^)(heim_object_t));
#endif
size_t heim_array_get_length(heim_array_t);
heim_object_t
heim_array_copy_value(heim_array_t, size_t);
void heim_array_delete_value(heim_array_t, size_t);
#ifdef __BLOCKS__
void heim_array_filter(heim_array_t, int (^)(heim_object_t));
#endif
/*
* Dict
*/
typedef struct heim_dict_data *heim_dict_t;
heim_dict_t heim_dict_create(size_t size);
heim_tid_t heim_dict_get_type_id(void);
typedef void (*heim_dict_iterator_f_t)(heim_object_t, heim_object_t, void *);
int heim_dict_add_value(heim_dict_t, heim_object_t, heim_object_t);
void heim_dict_iterate_f(heim_dict_t, heim_dict_iterator_f_t, void *);
#ifdef __BLOCKS__
void heim_dict_iterate(heim_dict_t, void (^)(heim_object_t, heim_object_t));
#endif
heim_object_t
heim_dict_copy_value(heim_dict_t, heim_object_t);
void heim_dict_delete_key(heim_dict_t, heim_object_t);
/*
* String
*/
typedef struct heim_string_data *heim_string_t;
heim_string_t heim_string_create(const char *);
heim_tid_t heim_string_get_type_id(void);
const char * heim_string_get_utf8(heim_string_t);
/*
* Number
*/
typedef struct heim_number_data *heim_number_t;
heim_number_t heim_number_create(int);
heim_tid_t heim_number_get_type_id(void);
int heim_number_get_int(heim_number_t);
/*
*
*/
typedef struct heim_auto_release * heim_auto_release_t;
heim_auto_release_t heim_auto_release_create(void);
void heim_auto_release_drain(heim_auto_release_t);
void heim_auto_release(heim_object_t);
#endif /* HEIM_BASE_H */

View File

@ -1,149 +0,0 @@
/* $NetBSD: json.c,v 1.1.1.2 2014/04/24 12:45:26 pettai Exp $ */
/*
* Copyright (c) 2010 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
* Portions Copyright (c) 2010 Apple Inc. 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. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include "baselocl.h"
int
heim_base2json(heim_object_t obj,
void (*out)(char *, void *), void *ctx)
{
heim_tid_t type = heim_get_tid(obj);
__block int fail = 0, needcomma = 0;
switch (type) {
case HEIM_TID_ARRAY:
out("[ ", ctx);
heim_array_iterate(obj, ^(heim_object_t sub) {
if (needcomma)
out(", ", ctx);
fail |= heim_base2json(sub, out, ctx);
needcomma = 1;
});
out("]", ctx);
break;
case HEIM_TID_DICT:
out("{ ", ctx);
heim_dict_iterate(obj, ^(heim_object_t key, heim_object_t value) {
if (needcomma)
out(", ", ctx);
fail |= heim_base2json(key, out, ctx);
out(" = ", ctx);
fail |= heim_base2json(value, out, ctx);
needcomma = 1;
});
out("}", ctx);
break;
case HEIM_TID_STRING:
out("\"", ctx);
out(heim_string_get_utf8(obj), ctx);
out("\"", ctx);
break;
case HEIM_TID_NUMBER: {
char num[16];
snprintf(num, sizeof(num), "%d", heim_number_get_int(obj));
out(num, ctx);
break;
}
case HEIM_TID_NULL:
out("null", ctx);
break;
case HEIM_TID_BOOL:
out(heim_bool_val(obj) ? "true" : "false", ctx);
break;
default:
return 1;
}
return fail;
}
static int
parse_dict(heim_dict_t dict, char * const *pp, size_t *len)
{
const char *p = *pp;
while (*len) {
(*len)--;
if (*p == '\n') {
p += 1;
} else if (isspace(*p)) {
p += 1;
} else if (*p == '}') {
*pp = p + 1;
return 0;
} else {
}
}
return ENOENT;
}
heim_object_t
heim_json2base(const void *data, size_t length)
{
heim_array_t stack;
heim_object_t o = NULL;
const char *p = data;
unsigned long lineno = 1;
while (length) {
length--;
if (*p == '\n') {
lineno++;
} else if (isspace((int)*p)) {
;
} else if (*p == '{') {
o = heim_dict_create();
if ((ret = parse_dict(&p, &length)) != 0)
goto out;
} else
abort();
}
out:
if (ret && o) {
heim_release(o);
o = NULL;
}
return o;
}

View File

@ -1,154 +0,0 @@
/* $NetBSD: test_base.c,v 1.1.1.2 2014/04/24 12:45:26 pettai Exp $ */
/*
* Copyright (c) 2010 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
* Portions Copyright (c) 2010 Apple Inc. 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. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <stdio.h>
#include <err.h>
#include <krb5/heimbase.h>
#include "heimbasepriv.h"
static void
memory_free(heim_object_t obj)
{
}
static int
test_memory(void)
{
void *ptr;
ptr = heim_alloc(10, "memory", memory_free);
heim_retain(ptr);
heim_release(ptr);
heim_retain(ptr);
heim_release(ptr);
heim_release(ptr);
ptr = heim_alloc(10, "memory", NULL);
heim_release(ptr);
return 0;
}
static int
test_dict(void)
{
heim_dict_t dict;
heim_number_t a1 = heim_number_create(1);
heim_string_t a2 = heim_string_create("hejsan");
heim_number_t a3 = heim_number_create(3);
heim_string_t a4 = heim_string_create("foosan");
dict = heim_dict_create(10);
heim_dict_add_value(dict, a1, a2);
heim_dict_add_value(dict, a3, a4);
heim_dict_delete_key(dict, a3);
heim_dict_delete_key(dict, a1);
heim_release(a1);
heim_release(a2);
heim_release(a3);
heim_release(a4);
heim_release(dict);
return 0;
}
static int
test_auto_release(void)
{
heim_auto_release_t ar1, ar2;
heim_number_t n1;
heim_string_t s1;
ar1 = heim_auto_release_create();
s1 = heim_string_create("hejsan");
heim_auto_release(s1);
n1 = heim_number_create(1);
heim_auto_release(n1);
ar2 = heim_auto_release_create();
n1 = heim_number_create(1);
heim_auto_release(n1);
heim_release(ar2);
heim_release(ar1);
return 0;
}
static int
test_string(void)
{
heim_string_t s1, s2;
const char *string = "hejsan";
s1 = heim_string_create(string);
s2 = heim_string_create(string);
if (heim_cmp(s1, s2) != 0) {
printf("the same string is not the same\n");
exit(1);
}
heim_release(s1);
heim_release(s2);
return 0;
}
int
main(int argc, char **argv)
{
int res = 0;
res |= test_memory();
res |= test_dict();
res |= test_auto_release();
res |= test_string();
return res;
}

View File

@ -1,28 +0,0 @@
HEIMDAL_BASE_1.0 {
global:
heim_abort;
heim_alloc;
heim_array_append_value;
heim_array_copy_value;
heim_array_create;
heim_array_delete_value;
heim_array_get_length;
heim_array_iterate_f;
heim_auto_release;
heim_auto_release_create;
heim_auto_release_drain;
heim_base_once_f;
heim_cmp;
heim_dict_add_value;
heim_dict_copy_value;
heim_dict_create;
heim_dict_delete_key;
heim_dict_iterate_f;
heim_release;
heim_retain;
heim_string_create;
heim_string_get_utf8;
heim_number_create;
local:
*;
};

View File

@ -1,6 +1,6 @@
# Id
SUFFIXES = .et .h
SUFFIXES = .et .h .pc.in .pc
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/include -I$(top_srcdir)/include
@ -45,10 +45,8 @@ LIB_tgetent = @LIB_tgetent@
LIB_com_err = @LIB_com_err@
LIB_door_create = @LIB_door_create@
HESIODLIB = @HESIODLIB@
HESIODINCLUDE = @HESIODINCLUDE@
INCLUDE_hesiod = @INCLUDE_hesiod@
LIB_hesiod = @LIB_hesiod@
LIB_openssl_crypto = @LIB_openssl_crypto@
INCLUDE_openssl_crypto = @INCLUDE_openssl_crypto@
INCLUDE_krb4 = @INCLUDE_krb4@
LIB_krb4 = @LIB_krb4@
@ -66,17 +64,31 @@ libexec_heimdaldir = $(libexecdir)/heimdal
install-suid-programs:
@foo='$(bin_SUIDS)'; \
for file in $$foo; do \
x=$(DESTDIR)$(bindir)/$$file; \
if chown 0:0 $$x && chmod u+s $$x; then :; else \
echo "*"; \
echo "* Failed to install $$x setuid root"; \
echo "*"; \
fi; done
x=$(DESTDIR)$(bindir)/$$file; \
if chown 0:0 $$x && chmod u+s $$x; then :; else \
echo "*"; \
echo "* Failed to install $$x setuid root"; \
echo "*"; \
fi; \
done
install-exec-hook: install-suid-programs
install-exec-local: install-suid-programs
install-build-headers:: $(include_HEADERS) $(dist_include_HEADERS) $(nodist_include_HEADERS) $(build_HEADERZ) $(nobase_include_HEADERS)
@foo='$(include_HEADERS) $(dist_include_HEADERS) $(nodist_include_HEADERS) $(build_HEADERZ)'; \
codesign-all:
@if [ X"$$CODE_SIGN_IDENTITY" != X ] ; then \
foo='$(bin_PROGRAMS) $(sbin_PROGRAMS) $(libexec_PROGRAMS)' ; \
for file in $$foo ; do \
echo "CODESIGN $$file" ; \
codesign -f -s "$$CODE_SIGN_IDENTITY" $$file || exit 1 ; \
done ; \
fi
all-local: codesign-all
install-build-headers:: $(include_HEADERS) $(dist_include_HEADERS) $(nodist_include_HEADERS) $(build_HEADERZ) $(nobase_include_HEADERS) $(noinst_HEADERS)
@foo='$(include_HEADERS) $(dist_include_HEADERS) $(nodist_include_HEADERS) $(build_HEADERZ) $(noinst_HEADERS)'; \
for f in $$foo; do \
f=`basename $$f`; \
if test -f "$(srcdir)/$$f"; then file="$(srcdir)/$$f"; \
@ -84,7 +96,7 @@ install-build-headers:: $(include_HEADERS) $(dist_include_HEADERS) $(nodist_incl
if cmp -s $$file $(buildinclude)/$$f 2> /dev/null ; then \
: ; else \
echo " $(CP) $$file $(buildinclude)/$$f"; \
$(CP) $$file $(buildinclude)/$$f; \
$(CP) $$file $(buildinclude)/$$f || true; \
fi ; \
done ; \
foo='$(nobase_include_HEADERS)'; \
@ -137,7 +149,7 @@ SUFFIXES += .x .z .hx
.hx.h:
@cmp -s $< $@ 2> /dev/null || cp $< $@
SUFFIXES += .1 .3 .5 .8 .cat1 .cat3 .cat5 .cat8
SUFFIXES += .1 .3 .5 .7 .8 .cat1 .cat3 .cat5 .cat7 .cat8
NROFF_MAN = groff -mandoc -Tascii
#NROFF_MAN = nroff -man
@ -147,6 +159,8 @@ NROFF_MAN = groff -mandoc -Tascii
$(NROFF_MAN) $< > $@
.5.cat5:
$(NROFF_MAN) $< > $@
.7.cat7:
$(NROFF_MAN) $< > $@
.8.cat8:
$(NROFF_MAN) $< > $@
@ -191,6 +205,19 @@ dist-cat5-mans:
$(NROFF_MAN) $(srcdir)/$$i > $(distdir)/$$x; \
done
dist-cat7-mans:
@foo='$(man7_MANS)'; \
bar='$(man_MANS)'; \
for i in $$bar; do \
case $$i in \
*.7) foo="$$foo $$i";; \
esac; done ;\
for i in $$foo; do \
x=`echo $$i | sed 's/\.[^.]*$$/.cat7/'`; \
echo "$(NROFF_MAN) $(srcdir)/$$i > $(distdir)/$$x"; \
$(NROFF_MAN) $(srcdir)/$$i > $(distdir)/$$x; \
done
dist-cat8-mans:
@foo='$(man8_MANS)'; \
bar='$(man_MANS)'; \
@ -204,13 +231,13 @@ dist-cat8-mans:
$(NROFF_MAN) $(srcdir)/$$i > $(distdir)/$$x; \
done
dist-hook: dist-cat1-mans dist-cat3-mans dist-cat5-mans dist-cat8-mans
dist-hook: dist-cat1-mans dist-cat3-mans dist-cat5-mans dist-cat7-mans dist-cat8-mans
install-cat-mans:
$(SHELL) $(top_srcdir)/cf/install-catman.sh install "$(INSTALL_DATA)" "$(mkinstalldirs)" "$(srcdir)" "$(DESTDIR)$(mandir)" '$(CATMANEXT)' $(man_MANS) $(man1_MANS) $(man3_MANS) $(man5_MANS) $(man8_MANS)
$(SHELL) $(top_srcdir)/cf/install-catman.sh install "$(INSTALL_DATA)" "$(mkinstalldirs)" "$(srcdir)" "$(DESTDIR)$(mandir)" '$(CATMANEXT)' $(man_MANS) $(man1_MANS) $(man3_MANS) $(man5_MANS) $(man7_MANS) $(man8_MANS)
uninstall-cat-mans:
$(SHELL) $(top_srcdir)/cf/install-catman.sh uninstall "$(INSTALL_DATA)" "$(mkinstalldirs)" "$(srcdir)" "$(DESTDIR)$(mandir)" '$(CATMANEXT)' $(man_MANS) $(man1_MANS) $(man3_MANS) $(man5_MANS) $(man8_MANS)
$(SHELL) $(top_srcdir)/cf/install-catman.sh uninstall "$(INSTALL_DATA)" "$(mkinstalldirs)" "$(srcdir)" "$(DESTDIR)$(mandir)" '$(CATMANEXT)' $(man_MANS) $(man1_MANS) $(man3_MANS) $(man5_MANS) $(man7_MANS) $(man8_MANS)
install-data-hook: install-cat-mans
uninstall-hook: uninstall-cat-mans
@ -221,7 +248,11 @@ uninstall-hook: uninstall-cat-mans
.et.c:
$(COMPILE_ET) $<
if NO_AFS
LIB_kafs =
else
LIB_kafs = $(top_builddir)/lib/kafs/libkafs.la $(AIX_EXTRA_KAFS)
endif
if KRB5
LIB_krb5 = $(top_builddir)/lib/krb5/libkrb5.la \
@ -229,7 +260,7 @@ LIB_krb5 = $(top_builddir)/lib/krb5/libkrb5.la \
LIB_gssapi = $(top_builddir)/lib/gssapi/libgssapi.la
endif
LIB_heimbase = $(top_builddir)/base/libheimbase.la
LIB_heimbase = $(top_builddir)/lib/base/libheimbase.la
if DCE
LIB_kdfs = $(top_builddir)/lib/kdfs/libkdfs.la
@ -255,3 +286,10 @@ distdir-in-tree: $(DISTFILES) $(INFO_DEPS)
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) distdir-in-tree) ; \
fi ; \
done
#silent-rules
heim_verbose = $(heim_verbose_$(V))
heim_verbose_ = $(heim_verbose_$(AM_DEFAULT_VERBOSITY))
heim_verbose_0 = @echo " GEN "$@;

View File

@ -3,12 +3,12 @@ dnl
dnl CHECK_COMPILE_ET
AC_DEFUN([CHECK_COMPILE_ET], [
AC_CHECK_PROG(COMPILE_ET, compile_et, [compile_et])
AC_CHECK_PROG(COMPILE_ET, compile_et, [compile_et], [no])
krb_cv_compile_et="no"
krb_cv_com_err_need_r=""
krb_cv_compile_et_cross=no
if test "${COMPILE_ET}" = "compile_et"; then
if test "${COMPILE_ET}" != "no"; then
dnl We have compile_et. Now let's see if it supports `prefix' and `index'.
AC_MSG_CHECKING(whether compile_et has the features we need)
@ -28,7 +28,8 @@ if ${COMPILE_ET} conftest_et.et >/dev/null 2>&1; then
CPPFLAGS="-I/usr/include/et ${CPPFLAGS}"
fi
dnl Check that the `prefix' and `index' directives were honored.
AC_RUN_IFELSE([
AC_LANG(C)
AC_RUN_IFELSE([AC_LANG_SOURCE([
#include <com_err.h>
#include <string.h>
#include "conftest_et.h"
@ -37,7 +38,7 @@ int main(int argc, char **argv){
#error compile_et does not handle error_table N M
#endif
return (CONFTEST_CODE2 - CONFTEST_CODE1) != 127;}
], [krb_cv_compile_et="yes"],[CPPFLAGS="${save_CPPFLAGS}"],
])], [krb_cv_compile_et="yes"],[CPPFLAGS="${save_CPPFLAGS}"],
[krb_cv_compile_et="yes" krb_cv_compile_et_cross=yes] )
fi
AC_MSG_RESULT(${krb_cv_compile_et})

View File

@ -0,0 +1,40 @@
dnl Id
dnl
dnl check for getpwuid_r, and if it's posix or not
AC_DEFUN([AC_CHECK_GETPWUID_R_POSIX],[
AC_FIND_FUNC_NO_LIBS(getpwuid_r,c_r)
if test "$ac_cv_func_getpwuid_r" = yes; then
AC_CACHE_CHECK(if getpwuid_r is posix,ac_cv_func_getpwuid_r_posix,
ac_libs="$LIBS"
LIBS="$LIBS $LIB_getpwuid_r"
AC_RUN_IFELSE([AC_LANG_SOURCE([[
#define _POSIX_PTHREAD_SEMANTICS
#include <pwd.h>
int main(int argc, char **argv)
{
struct passwd pw, *pwd;
return getpwuid_r(0, &pw, 0, 0, &pwd) < 0;
}
]])],[ac_cv_func_getpwuid_r_posix=yes],[ac_cv_func_getpwuid_r_posix=no],[:])
LIBS="$ac_libs")
AC_CACHE_CHECK(if _POSIX_PTHREAD_SEMANTICS is needed,ac_cv_func_getpwuid_r_posix_def,
ac_libs="$LIBS"
LIBS="$LIBS $LIB_getpwuid_r"
AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <pwd.h>
int main(int argc, char **argv)
{
struct passwd pw, *pwd;
return getpwuid_r(0, &pw, 0, 0, &pwd) < 0;
}
]])],[ac_cv_func_getpwuid_r_posix_def=no],[ac_cv_func_getpwuid_r_posix_def=yes],[:])
LIBS="$ac_libs")
if test "$ac_cv_func_getpwuid_r_posix" = yes; then
AC_DEFINE(POSIX_GETPWUID_R, 1, [Define if getpwuid_r has POSIX flavour.])
fi
if test "$ac_cv_func_getpwuid_r_posix" = yes -a "$ac_cv_func_getpwuid_r_posix_def" = yes; then
AC_DEFINE(_POSIX_PTHREAD_SEMANTICS, 1, [Define to get POSIX getpwuid_r in some systems.])
fi
fi
])

View File

@ -1,53 +0,0 @@
dnl
dnl See if there is any X11 present
dnl
dnl Id
AC_DEFUN([KRB_CHECK_X],[
AC_PATH_XTRA
# try to figure out if we need any additional ld flags, like -R
# and yes, the autoconf X test is utterly broken
if test "$no_x" != yes; then
AC_CACHE_CHECK(for special X linker flags,krb_cv_sys_x_libs_rpath,[
ac_save_libs="$LIBS"
ac_save_cflags="$CFLAGS"
CFLAGS="$CFLAGS $X_CFLAGS"
krb_cv_sys_x_libs_rpath=""
krb_cv_sys_x_libs=""
for rflag in "" "-R" "-R " "-rpath "; do
if test "$rflag" = ""; then
foo="$X_LIBS"
else
foo=""
for flag in $X_LIBS; do
case $flag in
-L*)
foo="$foo $flag `echo $flag | sed \"s/-L/$rflag/\"`"
;;
*)
foo="$foo $flag"
;;
esac
done
fi
LIBS="$ac_save_libs $foo $X_PRE_LIBS -lX11 $X_EXTRA_LIBS"
AC_RUN_IFELSE([
#include <X11/Xlib.h>
foo(void)
{
XOpenDisplay(NULL);
}
main(int argc, char **argv)
{
return 0;
}
],krb_cv_sys_x_libs_rpath="$rflag"; krb_cv_sys_x_libs="$foo"; break,:,
krb_cv_sys_x_libs_rpath="" ; krb_cv_sys_x_libs="" ; break)
done
LIBS="$ac_save_libs"
CFLAGS="$ac_save_cflags"
])
X_LIBS="$krb_cv_sys_x_libs"
fi
])

View File

@ -1,64 +0,0 @@
dnl Id
dnl
dnl check for Xau{Read,Write}Auth and XauFileName
dnl
AC_DEFUN([AC_CHECK_XAU],[
save_CFLAGS="$CFLAGS"
CFLAGS="$X_CFLAGS $CFLAGS"
save_LIBS="$LIBS"
dnl LIBS="$X_LIBS $X_PRE_LIBS $X_EXTRA_LIBS $LIBS"
LIBS="$X_PRE_LIBS $X_EXTRA_LIBS $LIBS"
save_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS $X_LIBS"
## check for XauWriteAuth first, so we detect the case where
## XauReadAuth is in -lX11, but XauWriteAuth is only in -lXau this
## could be done by checking for XauReadAuth in -lXau first, but this
## breaks in IRIX 6.5
AC_FIND_FUNC_NO_LIBS(XauWriteAuth, X11 Xau,[#include <X11/Xauth.h>],[0,0])
ac_xxx="$LIBS"
LIBS="$LIB_XauWriteAuth $LIBS"
AC_FIND_FUNC_NO_LIBS(XauReadAuth, X11 Xau,[#include <X11/Xauth.h>],[0])
LIBS="$LIB_XauReadAauth $LIBS"
AC_FIND_FUNC_NO_LIBS(XauFileName, X11 Xau,[#include <X11/Xauth.h>])
LIBS="$ac_xxx"
## set LIB_XauReadAuth to union of these tests, since this is what the
## Makefiles are using
case "$ac_cv_funclib_XauWriteAuth" in
yes) ;;
no) ;;
*) if test "$ac_cv_funclib_XauReadAuth" = yes; then
if test "$ac_cv_funclib_XauFileName" = yes; then
LIB_XauReadAuth="$LIB_XauWriteAuth"
else
LIB_XauReadAuth="$LIB_XauWriteAuth $LIB_XauFileName"
fi
else
if test "$ac_cv_funclib_XauFileName" = yes; then
LIB_XauReadAuth="$LIB_XauReadAuth $LIB_XauWriteAuth"
else
LIB_XauReadAuth="$LIB_XauReadAuth $LIB_XauWriteAuth $LIB_XauFileName"
fi
fi
;;
esac
if test "$AUTOMAKE" != ""; then
AM_CONDITIONAL(NEED_WRITEAUTH, test "$ac_cv_func_XauWriteAuth" != "yes")
else
AC_SUBST(NEED_WRITEAUTH_TRUE)
AC_SUBST(NEED_WRITEAUTH_FALSE)
if test "$ac_cv_func_XauWriteAuth" != "yes"; then
NEED_WRITEAUTH_TRUE=
NEED_WRITEAUTH_FALSE='#'
else
NEED_WRITEAUTH_TRUE='#'
NEED_WRITEAUTH_FALSE=
fi
fi
CFLAGS=$save_CFLAGS
LIBS=$save_LIBS
LDFLAGS=$save_LDFLAGS
])

View File

@ -6,17 +6,21 @@ dnl - own-built libhcrypto
m4_define([test_headers], [
#undef KRB5 /* makes md4.h et al unhappy */
#ifdef HAVE_OPENSSL
#ifdef HAVE_HCRYPTO_W_OPENSSL
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#include <openssl/evp.h>
#include <openssl/bn.h>
#include <openssl/md4.h>
#include <openssl/md5.h>
#include <openssl/sha.h>
#include <openssl/des.h>
#include <openssl/rc4.h>
#include <openssl/aes.h>
#include <openssl/rsa.h>
#include <openssl/dsa.h>
#include <openssl/dh.h>
#include <openssl/ec.h>
#include <openssl/engine.h>
#include <openssl/ui.h>
@ -50,7 +54,7 @@ m4_define([test_body], [
EVP_CIPHER_iv_length(((EVP_CIPHER*)0));
UI_UTIL_read_pw_string(0,0,0,0);
RAND_status();
#ifdef HAVE_OPENSSL
#ifdef HAVE_HCRYPTO_W_OPENSSL
EC_KEY_new();
#endif
@ -59,119 +63,102 @@ m4_define([test_body], [
DES_cbc_encrypt(0, 0, 0, schedule, 0, 0);
RC4(0, 0, 0, 0);])
AC_DEFUN([KRB_CRYPTO],[
crypto_lib=unknown
AC_ARG_WITH([hcrypto-default-backend],
AS_HELP_STRING([--with-hcrypto-default-backend=cc|pkcs11_hcrypto|ossl|w32crypto|hcrypto],
[specify the default hcrypto backend]),
[
CFLAGS="${CFLAGS} -DHCRYPTO_DEF_PROVIDER=${withval}"
case "$withval" in
cc) AC_DEFINE(HCRYPTO_DEF_PROVIDER, [cc], [Define to one of cc, pkcs11, ossl, w32crypto, or hcrypto to set a default hcrypto provider]);;
pkcs11_hcrypto) AC_DEFINE(HCRYPTO_DEF_PROVIDER, [pkcs11_hcrypto], [Define to one of cc, pkcs11, ossl, w32crypto, or hcrypto to set a default hcrypto provider]);;
ossl) AC_DEFINE(HCRYPTO_DEF_PROVIDER, [ossl], [Define to one of cc, pkcs11, ossl, w32crypto, or hcrypto to set a default hcrypto provider]);;
w32crypto) AC_DEFINE(HCRYPTO_DEF_PROVIDER, [w32crypto], [Define to one of cc, pkcs11, ossl, w32crypto, or hcrypto to set a default hcrypto provider]);;
hcrypto) AC_DEFINE(HCRYPTO_DEF_PROVIDER, [hcrypto], [Define to one of cc, pkcs11, ossl, w32crypto, or hcrypto to set a default hcrypto provider]);;
*) echo "Invalid hcrypto provider name ($withval)"; exit 5;;
esac
],
[])
AC_ARG_WITH([hcrypto-fallback],
AS_HELP_STRING([--without-hcrypto-fallback],
[disable fallback on hcrypto for unavailable algorithms]),
[AC_DEFINE([HCRYPTO_FALLBACK],0,[Set to 1 to allow fallback to hcrypto for unavailable algorithms])],
[AC_DEFINE([HCRYPTO_FALLBACK],1,[Set to 1 to allow fallback to hcrypto for unavailable algorithms])])
AC_WITH_ALL([openssl])
DIR_hcrypto=
AC_MSG_CHECKING([for crypto library])
openssl=no
if test "$crypto_lib" = "unknown" -a "$with_krb4" != "no"; then
save_CPPFLAGS="$CPPFLAGS"
save_LIBS="$LIBS"
cdirs= clibs=
for i in $LIB_krb4; do
case "$i" in
-L*) cdirs="$cdirs $i";;
-l*) clibs="$clibs $i";;
esac
done
ires=
for i in $INCLUDE_krb4; do
CFLAGS="-DHAVE_OPENSSL $i $save_CFLAGS"
for j in $cdirs; do
for k in $clibs; do
LIBS="$j $k $save_LIBS"
AC_LINK_IFELSE([AC_LANG_PROGRAM([test_headers],
[test_body])],
[openssl=yes ires="$i" lres="$j $k"; break 3])
done
done
CFLAGS="$i $save_CFLAGS"
for j in $cdirs; do
for k in $clibs; do
LIBS="$j $k $save_LIBS"
AC_LINK_IFELSE([AC_LANG_PROGRAM([test_headers],[test_body])],
[openssl=no ires="$i" lres="$j $k"; break 3])
done
done
done
CFLAGS="$save_CFLAGS"
LIBS="$save_LIBS"
if test "$ires" -a "$lres"; then
INCLUDE_hcrypto="$ires"
LIB_hcrypto="$lres"
crypto_lib=krb4
AC_MSG_RESULT([same as krb4])
LIB_hcrypto_a='$(LIB_hcrypto)'
LIB_hcrypto_so='$(LIB_hcrypto)'
LIB_hcrypto_appl='$(LIB_hcrypto)'
fi
if test "$with_openssl" = "yes"; then
with_openssl=/usr
fi
if test "$crypto_lib" = "unknown" -a "$with_openssl" != "no"; then
save_CFLAGS="$CFLAGS"
save_LIBS="$LIBS"
INCLUDE_hcrypto=
LIB_hcrypto=
if test "$with_openssl" != "no"; then
saved_CFLAGS="${CFLAGS}"
saved_LDFLAGS="${LDFLAGS}"
INCLUDE_openssl_crypto=
LIB_openssl_crypto=
if test "$with_openssl_include" != ""; then
INCLUDE_hcrypto="-I${with_openssl_include}"
INCLUDE_openssl_crypto="-I${with_openssl_include}"
else
INCLUDE_openssl_crypto="-I${with_openssl}/include"
fi
if test "$with_openssl_lib" != ""; then
LIB_hcrypto="-L${with_openssl_lib}"
LIB_openssl_crypto="-L${with_openssl_lib}"
elif test "${with_openssl}" != "/usr" -a -d "${with_openssl}/lib"; then
LIB_openssl_crypto="-L${with_openssl}/lib"
fi
CFLAGS="-DHAVE_OPENSSL ${INCLUDE_hcrypto} ${CFLAGS}"
saved_LIB_hcrypto="$LIB_hcrypto"
for lres in "" "-ldl" "-lnsl -lsocket" "-lnsl -lsocket -ldl"; do
LIB_hcrypto="${saved_LIB_hcrypto} -lcrypto $lres"
LIB_hcrypto_a="$LIB_hcrypto"
LIB_hcrypto_so="$LIB_hcrypto"
LIB_hcrypto_appl="$LIB_hcrypto"
LIBS="${LIBS} ${LIB_hcrypto}"
AC_LINK_IFELSE([AC_LANG_PROGRAM([test_headers],[test_body])], [
crypto_lib=libcrypto openssl=yes
AC_MSG_RESULT([libcrypto])
])
if test "$crypto_lib" = libcrypto ; then
break;
fi
done
CFLAGS="$save_CFLAGS"
LIBS="$save_LIBS"
CFLAGS="-DHAVE_HCRYPTO_W_OPENSSL ${INCLUDE_openssl_crypto} ${CFLAGS}"
LDFLAGS="${LIB_openssl_crypto} ${LDFLAGS}"
AC_CHECK_LIB([crypto], [OPENSSL_init],
[LIB_openssl_crypto="${LIB_openssl_crypto} -lcrypto"; openssl=yes], [openssl=no], [])
# These cases are just for static linking on older OSes,
# presumably.
if test "$openssl" = "no"; then
AC_CHECK_LIB([crypto], [OPENSSL_init],
[LIB_openssl_crypto="${LIB_openssl_crypto} -lcrypto -ldl"; openssl=yes], [openssl=no], [-ldl])
fi
if test "$openssl" = "no"; then
AC_CHECK_LIB([crypto], [OPENSSL_init],
[LIB_openssl_crypto="${LIB_openssl_crypto} -lcrypto -ldl -lnsl"; openssl=yes], [openssl=no], [-ldl -lnsl])
fi
if test "$openssl" = "no"; then
AC_CHECK_LIB([crypto], [OPENSSL_init],
[LIB_openssl_crypto="${LIB_openssl_crypto} -lcrypto -ldl -lnsl -lsocket"; openssl=yes], [openssl=no], [-ldl -lnsl -lsocket])
fi
if test "$openssl" = "no"; then
INCLUDE_openssl_crypto=
LIB_openssl_crypto=
fi
CFLAGS="${saved_CFLAGS}"
LDFLAGS="${saved_LDFLAGS}"
fi
if test "$crypto_lib" = "unknown"; then
LIB_hcrypto='$(top_builddir)/lib/hcrypto/libhcrypto.la'
LIB_hcrypto_a='$(top_builddir)/lib/hcrypto/.libs/libhcrypto.a'
LIB_hcrypto_so='$(top_builddir)/lib/hcrypto/.libs/libhcrypto.so'
LIB_hcrypto_appl="-lhcrypto"
DIR_hcrypto='hcrypto'
LIB_hcrypto='$(top_builddir)/lib/hcrypto/libhcrypto.la'
LIB_hcrypto_a='$(top_builddir)/lib/hcrypto/.libs/libhcrypto.a'
LIB_hcrypto_so='$(top_builddir)/lib/hcrypto/.libs/libhcrypto.so'
LIB_hcrypto_appl="-lhcrypto"
AC_MSG_RESULT([included libhcrypto])
AC_MSG_RESULT([included libhcrypto])
AC_ARG_WITH(pkcs11-module,
AS_HELP_STRING([--with-pkcs11-module=path],
[use PKCS11 module in path]),
[pkcs11_module="$withval"],
[])
fi
if test "$with_krb4" != no -a "$crypto_lib" != krb4; then
AC_MSG_ERROR([the crypto library used by krb4 lacks features
required by Kerberos 5; to continue, you need to install a newer
Kerberos 4 or configure --without-krb4])
if test "$pkcs11_module" != ""; then
AC_DEFINE_UNQUOTED(PKCS11_MODULE_PATH, "$pkcs11_module", [path to PKCS11 module])
openssl=no
fi
if test "$openssl" = "yes"; then
AC_DEFINE([HAVE_OPENSSL], 1, [define to use openssl's libcrypto])
AC_DEFINE([HAVE_HCRYPTO_W_OPENSSL], 1, [define to use openssl's libcrypto as the default backend for libhcrypto])
fi
AM_CONDITIONAL(HAVE_OPENSSL, test "$openssl" = yes)dnl
AM_CONDITIONAL(HAVE_HCRYPTO_W_OPENSSL, test "$openssl" = yes)dnl
AC_SUBST(DIR_hcrypto)
AC_SUBST(INCLUDE_hcrypto)
AC_SUBST(INCLUDE_openssl_crypto)
AC_SUBST(LIB_openssl_crypto)
AC_SUBST(LIB_hcrypto)
AC_SUBST(LIB_hcrypto_a)
AC_SUBST(LIB_hcrypto_so)

View File

@ -4,6 +4,11 @@ dnl tests for various db libraries
dnl
AC_DEFUN([rk_DB],[
AC_ARG_WITH(db-type-preference,
AS_HELP_STRING([--with-db-type-preference=list],
[specify HDB backend DB type preference as whitespace-separated list of db1, db3, lmdb, and/or sqlite]),
[db_type_preference="$withval"],
[db_type_preference="lmdb db3 db1 sqlite"])
AC_ARG_WITH(berkeley-db,
AS_HELP_STRING([--with-berkeley-db],
[enable support for berkeley db @<:@default=check@:>@]),
@ -22,7 +27,14 @@ AC_ARG_ENABLE(ndbm-db,
[if you don't want ndbm db]),[
])
have_ndbm=no
AC_ARG_ENABLE(mdb-db,
AS_HELP_STRING([--disable-mdb-db],
[if you don't want LMDB]),[
])
have_db1=no
have_db3=no
have_lmdb=no
db_type=unknown
AS_IF([test "x$with_berkeley_db" != xno],
@ -47,7 +59,7 @@ AS_IF([test "x$with_berkeley_db" != xno],
dnl db_create is used by db3 and db4 and db5
AC_FIND_FUNC_NO_LIBS(db_create, [$dbheader] db5 db4 db3 db, [
AC_FIND_FUNC_NO_LIBS(db_create, [$dbheader] db-5 db5 db4 db3 db, [
#include <stdio.h>
#ifdef HAVE_DBHEADER
#include <$dbheader/db.h>
@ -65,11 +77,11 @@ dnl db_create is used by db3 and db4 and db5
],[NULL, NULL, 0])
if test "$ac_cv_func_db_create" = "yes"; then
db_type=db3
have_db3=yes
if test "$ac_cv_funclib_db_create" != "yes"; then
DBLIB="$ac_cv_funclib_db_create"
DB3LIB="$ac_cv_funclib_db_create"
else
DBLIB=""
DB3LIB=""
fi
AC_DEFINE(HAVE_DB3, 1, [define if you have a berkeley db3/4/5 library])
fi
@ -88,11 +100,11 @@ dnl dbopen is used by db1/db2
],[NULL, 0, 0, 0, NULL])
if test "$ac_cv_func_dbopen" = "yes"; then
db_type=db1
have_db1=yes
if test "$ac_cv_funclib_dbopen" != "yes"; then
DBLIB="$ac_cv_funclib_dbopen"
DB1LIB="$ac_cv_funclib_dbopen"
else
DBLIB=""
DB1LIB=""
fi
AC_DEFINE(HAVE_DB1, 1, [define if you have a berkeley db1/2 library])
fi
@ -109,9 +121,9 @@ dnl test for ndbm compatability
if test "$ac_cv_func_dbm_firstkey" = "yes"; then
if test "$ac_cv_funclib_dbm_firstkey" != "yes"; then
LIB_NDBM="$ac_cv_funclib_dbm_firstkey"
NDBMLIB="$ac_cv_funclib_dbm_firstkey"
else
LIB_NDBM=""
NDBMLIB=""
fi
AC_DEFINE(HAVE_DB_NDBM, 1, [define if you have ndbm compat in db])
AC_DEFINE(HAVE_NEW_DB, 1, [Define if NDBM really is DB (creates files *.db)])
@ -123,6 +135,23 @@ dnl test for ndbm compatability
]) # fi berkeley db
AS_IF([test "x$enable_mdb_db" != xno],
[AC_CHECK_HEADER(lmdb.h, [
AC_CHECK_LIB(lmdb, mdb_env_create, have_lmdb=yes; LMDBLIB="-llmdb"
AC_DEFINE(HAVE_LMDB, 1, [define if you have the LMDB library]))])])
for db_type in unknown $db_type_preference; do
if eval test \"x\$have_${db_type}\" = xyes -o ${db_type} = sqlite; then
break
fi
db_type=unknown
done
AS_IF([test "x$have_db3" = xyes -a "$db_type" = unknown], db_type=db3, db_type="$db_type")
AS_IF([test "x$have_db1" = xyes -a "$db_type" = unknown], db_type=db1, db_type="$db_type")
AS_IF([test "x$have_lmdb" = xyes -a "$db_type" = unknown], db_type=lmdb, db_type="$db_type")
if test "$enable_ndbm_db" != "no"; then
if test "$db_type" = "unknown" -o "$ac_cv_func_dbm_firstkey" = ""; then
@ -144,16 +173,12 @@ if test "$enable_ndbm_db" != "no"; then
if test "$ac_cv_func_dbm_firstkey" = "yes"; then
if test "$ac_cv_funclib_dbm_firstkey" != "yes"; then
LIB_NDBM="$ac_cv_funclib_dbm_firstkey"
NDBMLIB="$ac_cv_funclib_dbm_firstkey"
else
LIB_NDBM=""
NDBMLIB=""
fi
AC_DEFINE(HAVE_NDBM, 1, [define if you have a ndbm library])dnl
have_ndbm=yes
if test "$db_type" = "unknown"; then
db_type=ndbm
DBLIB="$LIB_NDBM"
fi
else
$as_unset ac_cv_func_dbm_firstkey
@ -171,15 +196,14 @@ if test "$enable_ndbm_db" != "no"; then
if test "$ac_cv_func_dbm_firstkey" = "yes"; then
if test "$ac_cv_funclib_dbm_firstkey" != "yes"; then
LIB_NDBM="$ac_cv_funclib_dbm_firstkey"
NDBMLIB="$ac_cv_funclib_dbm_firstkey"
else
LIB_NDBM=""
NDBMLIB=""
fi
AC_DEFINE(HAVE_NDBM, 1, [define if you have a ndbm library])dnl
have_ndbm=yes
if test "$db_type" = "unknown"; then
db_type=ndbm
DBLIB="$LIB_NDBM"
fi
fi
fi
@ -216,9 +240,10 @@ int main(int argc, char **argv)
fi],[AC_MSG_RESULT([no])],[AC_MSG_RESULT([no-cross])])
fi
AM_CONDITIONAL(HAVE_DB1, test "$db_type" = db1)dnl
AM_CONDITIONAL(HAVE_DB3, test "$db_type" = db3)dnl
AM_CONDITIONAL(HAVE_NDBM, test "$db_type" = ndbm)dnl
AM_CONDITIONAL(HAVE_DB1, test "$have_db1" = yes)dnl
AM_CONDITIONAL(HAVE_DB3, test "$have_db3" = yes)dnl
AM_CONDITIONAL(HAVE_LMDB, test "$have_lmdb" = yes)dnl
AM_CONDITIONAL(HAVE_NDBM, test "$have_ndbm" = yes)dnl
AM_CONDITIONAL(HAVE_DBHEADER, test "$dbheader" != "")dnl
## it's probably not correct to include LDFLAGS here, but we might
@ -229,7 +254,15 @@ for i in $LDFLAGS; do
-L*) z="$z $i";;
esac
done
DBLIB="$z $DBLIB"
AC_SUBST(DBLIB)dnl
AC_SUBST(LIB_NDBM)dnl
DB3LIB="$z $DB3LIB"
DB1LIB="$z $DB1LIB"
LMDBLIB="$z $LMDBLIB"
NDMBLIB="$z $NDBMLIB"
AC_SUBST(DB3LIB)dnl
AC_SUBST(DB1LIB)dnl
AC_SUBST(LMDBLIB)dnl
AC_SUBST(NDBMLIB)dnl
AC_SUBST(NDBMLIB)dnl
AC_SUBST(db_type)dnl
AC_SUBST(db_type_preference)dnl
])

View File

@ -1,20 +1,23 @@
AC_DEFUN([rk_LIBDISPATCH],[
AC_CHECK_HEADERS([dispatch/dispatch.h])
AC_CHECK_PROGS(GCD_MIG, mig, no)
AC_FIND_FUNC_NO_LIBS(dispatch_async_f, dispatch,
[#ifdef HAVE_DISPATCH_DISPATCH_H
#include <dispatch/dispatch.h>
#endif],[0,0,0])
if test "$GCD_MIG" != no; then
AC_CHECK_HEADERS([dispatch/dispatch.h])
AC_FIND_FUNC_NO_LIBS(dispatch_async_f, dispatch,
[#ifdef HAVE_DISPATCH_DISPATCH_H
#include <dispatch/dispatch.h>
#endif],[0,0,0])
if test "$ac_cv_func_dispatch_async_f" = yes -a "$GCD_MIG" != no; then
AC_DEFINE([HAVE_GCD], 1, [Define if os support gcd.])
libdispatch=yes
else
libdispatch=no
fi
if test "$ac_cv_func_dispatch_async_f" = yes ; then
AC_DEFINE([HAVE_GCD], 1, [Define if os support gcd.])
libdispatch=yes
else
libdispatch=no
fi
AM_CONDITIONAL(have_gcd, test "$libdispatch" = yes -a "$GCD_MIG" != no)
AM_CONDITIONAL(have_gcd, test "$libdispatch" = yes)
])
])

View File

@ -9,3 +9,11 @@ AC_DEFUN([rk_DLOPEN], [
#endif],[0,0])
AM_CONDITIONAL(HAVE_DLOPEN, test "$ac_cv_funclib_dlopen" != no)
])
AC_DEFUN([rk_DLADDR], [
AC_FIND_FUNC_NO_LIBS(dladdr, dl,[
#ifdef HAVE_DLFCN_H
#include <dlfcn.h>
#endif],[0,0])
AM_CONDITIONAL(HAVE_DLADDR, test "$ac_cv_funclib_dladdr" != no)
])

View File

@ -53,7 +53,6 @@ case "$ac_res" in
;;
*)
eval "ac_cv_func_$1=yes"
eval "ac_cv_lib_`echo "$ac_res" | sed 's/-l//'`=yes"
AC_DEFINE_UNQUOTED($ac_tr_func)
AC_DEFINE_UNQUOTED($ac_tr_lib)
AC_MSG_RESULT([yes, in $ac_res])

View File

@ -14,7 +14,7 @@ catinstall="${INSTALL_CATPAGES-yes}"
for f in "$@"; do
echo $f
base=`echo "$f" | sed 's/\.[^.]*$//'`
base=`echo "$f" | sed 's~\.[^.]*$~~; s~.*/~~'`
section=`echo "$f" | sed 's/^[^.]*\.//'`
mandir="$manbase/man$section"
catdir="$manbase/cat$section"

View File

@ -151,4 +151,4 @@ sin6.sin6_addr = in6addr_loopback;
[Define if you have the in6addr_loopback variable])
fi
fi
])
])

View File

@ -0,0 +1,21 @@
dnl
dnl perl and some of its module are required to build some headers
dnl
AC_DEFUN([AC_KRB_PROG_PERL],
[AC_CHECK_PROGS(PERL, perl, perl)
if test "$PERL" = ""; then
AC_MSG_ERROR([perl not found - Cannot build Heimdal without perl])
fi
])
AC_DEFUN([AC_KRB_PERL_MOD],
[
AC_MSG_CHECKING([for Perl5 module $1])
if ! $PERL -M$1 -e 'exit(0);' >/dev/null 2>&1; then
AC_MSG_RESULT([no])
AC_MSG_ERROR([perl module $1 not found - Cannot build Heimdal without perl module $1])
else
AC_MSG_RESULT([yes])
fi
])

View File

@ -4,16 +4,31 @@
use Getopt::Std;
use File::Compare;
use JSON;
my $comment = 0;
my $doxygen = 0;
my $funcdoc = 0;
my $if_0 = 0;
my $brace = 0;
my $line = "";
my $debug = 0;
my $oproto = 1;
my $private_func_re = "^_";
my %depfunction = ();
my %depfunction;
my %exported;
my %deprecated;
my $apple = 0;
my %documentation;
getopts('x:m:o:p:dqE:R:P:') || die "foo";
if($opt_a) {
$apple = 1;
}
if($opt_a) {
$apple = 1;
}
if($opt_d) {
$debug = 1;
@ -52,18 +67,20 @@ if($opt_m) {
}
if($opt_x) {
open(EXP, $opt_x);
while(<EXP>) {
chomp;
s/\#.*//g;
s/\s+/ /g;
if(/^([a-zA-Z0-9_]+)\s?(.*)$/) {
$exported{$1} = $2;
} else {
print $_, "\n";
my $EXP;
local $/;
open(EXP, '<', $opt_x) || die "open ${opt_x}";
my $obj = JSON->new->utf8->decode(<EXP>);
close $EXP;
foreach my $x (keys %$obj) {
if (defined $obj->{$x}->{"export"}) {
$exported{$x} = $obj->{$x};
}
if (defined $obj->{$x}->{"deprecated"}) {
$deprecated{$x} = $obj->{$x}->{"deprecated"};
}
}
close EXP;
}
while(<>) {
@ -72,8 +89,10 @@ while(<>) {
# Handle C comments
s@/\*.*\*/@@;
s@//.*/@@;
if ( s@/\*.*@@) { $comment = 1;
} elsif ($comment && s@.*\*/@@) { $comment = 0;
if ( s@/\*\*(.*)@@) { $comment = 1; $doxygen = 1; $funcdoc = $1;
} elsif ( s@/\*.*@@) { $comment = 1;
} elsif ($comment && s@.*\*/@@) { $comment = 0; $doxygen = 0;
} elsif ($doxygen) { $funcdoc .= $_; next;
} elsif ($comment) { next; }
if(/^\#if 0/) {
@ -117,6 +136,10 @@ while(<>) {
$attr .= " $2";
$_ = "$1 $3";
}
if(m/(.*)\s(HEIMDAL_\w+_ATTRIBUTE)\s?(\(.*\))?(.*)/) {
$attr .= " $2$3";
$_ = "$1 $4";
}
# remove outer ()
s/\s*\(/</;
s/\)\s?$/>/;
@ -165,6 +188,22 @@ while(<>) {
if($attr ne "") {
$_ .= "\n $attr";
}
if ($funcdoc) {
$documentation{$f} = $funcdoc;
}
$funcdoc = undef;
if ($apple && exists $exported{$f}) {
$ios = $exported{$f}{ios};
$ios = "NA" if (!defined $ios);
$mac = $exported{$f}{macos};
$mac = "NA" if (!defined $mac);
die "$f neither" if ($mac eq "NA" and $ios eq "NA");
$_ = $_ . " __OSX_AVAILABLE_STARTING(__MAC_${mac}, __IPHONE_${ios})";
}
if (exists $deprecated{$f}) {
$_ = $_ . " GSSAPI_DEPRECATED_FUNCTION(\"$deprecated{$f}\")";
$depfunction{GSSAPI_DEPRECATED_FUNCTION} = 1;
}
$_ = $_ . ";";
$funcs{$f} = $_;
}
@ -182,6 +221,9 @@ while(<>) {
}
}
die "reached end of code and still in doxygen comment" if ($doxygen);
die "reached end of code and still in comment" if ($comment);
sub foo {
local ($arg) = @_;
$_ = $arg;
@ -211,6 +253,7 @@ $private_h = "";
$public_h_header .= "/* This is a generated file */
#ifndef $block
#define $block
#ifndef DOXY
";
if ($oproto) {
@ -258,20 +301,32 @@ if($oproto) {
}
$private_h_trailer = "";
foreach(sort keys %funcs){
if(/^(main)$/) { next }
if(/^(DllMain|main)$/) { next }
if ($funcs{$_} =~ /\^/) {
$beginblock = "#ifdef __BLOCKS__\n";
$endblock = "#endif /* __BLOCKS__ */\n";
} else {
$beginblock = $endblock = "";
}
if(!defined($exported{$_}) && /$private_func_re/) {
$private_h .= $beginblock . $funcs{$_} . "\n" . $endblock . "\n";
# if we have an export table and doesn't have content, or matches private RE
if((scalar(keys(%exported)) ne 0 && !exists $exported{$_} ) || /$private_func_re/) {
$private_h .= $beginblock;
# if ($apple and not /$private_func_re/) {
# $private_h .= "#define $_ __ApplePrivate_${_}\n";
# }
$private_h .= $funcs{$_} . "\n" ;
$private_h .= $endblock . "\n";
if($funcs{$_} =~ /__attribute__/) {
$private_attribute_seen = 1;
}
} else {
if($documentation{$_}) {
$public_h .= "/**\n";
$public_h .= "$documentation{$_}";
$public_h .= " */\n\n";
}
if($flags{"function-blocking"}) {
$fupper = uc $_;
if($exported{$_} =~ /proto/) {
@ -396,7 +451,7 @@ $private_h_trailer .= $undepstr;
if ($public_h ne "" && $flags{"header"}) {
$public_h = $public_h_header . $public_h .
$public_h_trailer . "#endif /* $block */\n";
$public_h_trailer . "#endif /* DOXY */\n#endif /* $block */\n";
}
if ($private_h ne "" && $flags{"header"}) {
$private_h = $private_h_header . $private_h .

View File

@ -56,7 +56,7 @@ doit=1
libtool="${tobjdir}/libtool --mode=execute"
valgrind="valgrind --leak-check=full --trace-children=yes --quiet -q --num-callers=30 --suppressions=${tsrcdir}/cf/valgrind-suppressions"
valgrind="valgrind --leak-check=full --quiet -q --num-callers=30 --suppressions=${tsrcdir}/cf/valgrind-suppressions"
if head -10 "$1" | grep 'Generated by ltmain.sh' > /dev/null ; then
uselibtool=1

View File

@ -12,4 +12,4 @@ static /**/const char *const rcsid[] = { (const char *)rcsid, "@(#)" msg }
#define MaxHostNameLen (64+4)
#define MaxPathLen (1024+4)
])])
])])

View File

@ -18,4 +18,4 @@ if test "$ac_cv_func_$2_proto_compat" = yes; then
$3])
fi
undefine([foo])
])
])

View File

@ -12,12 +12,12 @@ case "$host" in
*-*-solaris2*)
native_pthread_support=yes
if test "$GCC" = yes; then
PTHREAD_CFLAGS=-pthreads
PTHREAD_LIBADD=-pthreads
PTHREAD_CFLAGS="-D_REENTRANT -D_TS_ERRNO"
PTHREAD_LIBADD=-lpthread
else
PTHREAD_CFLAGS=-mt
PTHREAD_CFLAGS="-mt -D_REENTRANT -D_TS_ERRNO"
PTHREAD_LDADD=-mt
PTHREAD_LIBADD=-mt
PTHREAD_LIBADD="-mt -lpthread"
fi
;;
*-*-netbsd[[12]]*)
@ -30,7 +30,9 @@ case "$host" in
dnl heim_threads.h knows this
PTHREAD_LIBADD="-lpthread"
;;
*-*-freebsd[[56789]]*)
*-*-freebsd[[1234]])
;;
*-*-freebsd*)
native_pthread_support=yes
PTHREAD_LIBADD="-pthread"
;;
@ -39,6 +41,11 @@ case "$host" in
PTHREAD_CFLAGS=-pthread
PTHREAD_LIBADD=-pthread
;;
*-*-gnu*)
native_pthread_support=yes
PTHREADS_CFLAGS=-pthread
PTHREAD_LIBADD="-pthread -lpthread"
;;
*-*-linux* | *-*-linux-gnu)
case `uname -r` in
2.*|3.*)
@ -56,6 +63,17 @@ case "$host" in
*-*-aix*)
dnl AIX is disabled since we don't handle the utmp/utmpx
dnl problems that aix causes when compiling with pthread support
dnl (2016-11-14, we longer use utmp). Original logic was:
dnl if test "$GCC" = yes; then
dnl native_pthread_support=yes
dnl PTHREADS_LIBS="-pthread"
dnl elif expr "$CC" : ".*_r" > /dev/null ; then
dnl native_pthread_support=yes
dnl PTHREADS_CFLAGS=""
dnl PTHREADS_LIBS=""
dnl else
dnl native_pthread_support=no
dnl fi
native_pthread_support=no
;;
mips-sgi-irix6.[[5-9]]) # maybe works for earlier versions too
@ -85,6 +103,12 @@ else
PTHREAD_LIBADD=""
fi
AM_CONDITIONAL(ENABLE_PTHREAD_SUPPORT, test "$enable_pthread_support" != no)
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
LDADD="$LDADD $PTHREAD_LDADD"
LIBADD="$LIBADD $PTHREAD_LIBADD"
AC_SUBST(PTHREAD_CFLAGS)
AC_SUBST(PTHREAD_LDADD)
AC_SUBST(PTHREAD_LIBADD)

View File

@ -15,4 +15,4 @@ AH_BOTTOM([#ifdef VOID_RETSIGTYPE
#else
#define SIGRETURN(x) return (RETSIGTYPE)(x)
#endif])
])
])

View File

@ -17,7 +17,7 @@ AC_REQUIRE([AC_PROG_CC])
AC_REQUIRE([AC_PROG_AWK])
AC_REQUIRE([AC_OBJEXT])
AC_REQUIRE([AC_EXEEXT])
AC_REQUIRE([AC_PROG_LIBTOOL])
AC_REQUIRE([LT_INIT])
AC_REQUIRE([AC_MIPS_ABI])
@ -28,7 +28,10 @@ dnl C characteristics
AC_REQUIRE([AC_C___ATTRIBUTE__])
AC_REQUIRE([AC_C_INLINE])
AC_REQUIRE([AC_C_CONST])
rk_WFLAGS(-Wall -Wmissing-prototypes -Wpointer-arith -Wbad-function-cast -Wmissing-declarations -Wnested-externs)
rk_WFLAGS(-Wall -Wextra -Wno-sign-compare -Wno-unused-parameter -Wmissing-prototypes -Wpointer-arith -Wbad-function-cast -Wmissing-declarations -Wnested-externs -Wshadow)
dnl -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wstrict-prototypes
dnl -Wcast-qual -Wswitch -Wformat=2 -Wwrite-strings
AC_REQUIRE([rk_DB])
@ -68,7 +71,9 @@ AC_CHECK_HEADERS([\
search.h \
shadow.h \
stdint.h \
sys/auxv.h \
sys/bswap.h \
sys/errno.h \
sys/ioctl.h \
sys/mman.h \
sys/param.h \
@ -180,6 +185,7 @@ AC_CHECK_FUNCS([ \
asprintf \
atexit \
cgetent \
getauxval \
getconfattr \
getprogname \
getrlimit \
@ -266,6 +272,14 @@ AC_FIND_FUNC_NO_LIBS(bswap32,,
#include <sys/bswap.h>
#endif],0)
AC_FIND_FUNC_NO_LIBS(bswap64,,
[#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_BSWAP_H
#include <sys/bswap.h>
#endif],0)
AC_FIND_FUNC_NO_LIBS(pidfile,util,
[#ifdef HAVE_UTIL_H
#include <util.h>
@ -303,14 +317,12 @@ AC_FIND_IF_NOT_BROKEN(gai_strerror,,
#include <ws2tcpip.h>
#endif],[0])
dnl Darwin is weird, and in some senses not unix, launchd doesn't want
dnl servers to use daemon(), so its deprecated.
AC_CHECK_LIB(util, emalloc)
case "$host_os" in
darwin*)
;;
*)
AC_DEFINE([SUPPORT_DETACH], 1,
[Define if os support want to detach is daemonens.])
AC_BROKEN([daemon]) ;;
esac
@ -347,6 +359,7 @@ AC_BROKEN([ \
localtime_r \
lstat \
memmove \
memset_s \
mkstemp \
putenv \
rcmd \
@ -370,6 +383,8 @@ AC_BROKEN([ \
strsep \
strsep_copy \
strtok_r \
strtoll \
strtoull \
strupr \
swab \
tsearch \
@ -391,6 +406,14 @@ AM_CONDITIONAL(have_fnmatch_h,
AC_FOREACH([rk_func], [strndup strsep strtok_r],
[AC_NEED_PROTO([#include <string.h>], rk_func)])
AC_CHECK_FUNC([strtoll],
[AC_DEFINE_UNQUOTED(HAVE_STRTOLL, 1,
[Define if you have the function strtoll.])])
AC_CHECK_FUNC([strtoull],
[AC_DEFINE_UNQUOTED(HAVE_STRTOULL, 1,
[Define if you have the function strtoull.])])
AC_FOREACH([rk_func], [strsvis strsvisx strunvis strvis strvisx svis unvis vis],
[AC_NEED_PROTO([#ifdef HAVE_VIS_H
#include <vis.h>

View File

@ -1,10 +1,10 @@
#!/usr/bin/perl
require 'getopts.pl';
use Getopt::Std;
my $debug = 0;
Getopts('dc:p:o:') || die "foo";
getopts('dc:p:o:') || die "foo";
if ($opt_d) {
$debug = 1;
@ -145,12 +145,15 @@ sub parse_if
if (m/^\s*$/) {
print "end $_\n" if ($debug);
return 1;
} elsif (m/^\(([^&]+)\&\&(.*)\)\s*\|\|\s*\(([^&]+)\&\&(.*)\)$/) {
print "($1 and $2) or ($3 and $4)\n" if ($debug);
return ((parse_if($1) and parse_if($2)) or (parse_if($3) and parse_if($4)));
} elsif (m/^([^&]+)\&\&(.*)$/) {
print "$1 and $2\n" if ($debug);
return parse_if($1) and parse_if($2);
} elsif (m/^([^\|]+)\|\|(.*)$/) {
print "$1 or $2\n" if ($debug);
return parse_if($1) or parse_if($2);
return (parse_if($1) or parse_if($2));
} elsif (m/^\s*(\!)?\s*defined\((\w+)\)/) {
($neg, $var) = ($1, $2);
print "def: ${neg}-defined(${var})\n" if ($debug);

View File

@ -8,7 +8,12 @@ case "$host" in
*-*-solaris2.7)
sunos=57
;;
*-*-solaris2.[[89]] | *-*-solaris2.1[[0-9]])
*-*-solaris2.1[[1-9]])
AC_DEFINE([__EXTENSIONS__], [1],
[Enable general extensions on Solaris.])
sunos=511
;;
*-*-solaris2.[[89]] | *-*-solaris2.10)
sunos=58
;;
*-*-solaris2*)
@ -19,4 +24,4 @@ if test "$sunos" != no; then
AC_DEFINE_UNQUOTED(SunOS, $sunos,
[Define to what version of SunOS you are running.])
fi
])
])

View File

@ -1,6 +1,6 @@
dnl Id
dnl
dnl rk_TEST_PACKAGE(package,headers,libraries,extra libs,
dnl rk_TEST_PACKAGE(package,program,libraries,extra libs,
dnl default locations, conditional, config-program, headers)
AC_DEFUN([rk_TEST_PACKAGE],[

View File

@ -1,4 +1,3 @@
# Id
{
linux db init brokenness
Memcheck:Param
@ -82,3 +81,88 @@
obj:/lib/ld-2.5.so
obj:/lib/ld-2.5.so
}
{
glibc sed leak 1
Memcheck:Leak
fun:calloc
obj:/bin/sed
obj:/bin/sed
obj:/bin/sed
obj:/bin/sed
obj:/bin/sed
fun:(below main)
}
{
Heimdal one-time init leak 1
Memcheck:Leak
...
fun:heim_base_once_f
...
}
{
Heimdal one-time init leak 2
Memcheck:Leak
fun:pthread_once
...
}
{
Heimdal one-time init leak 3
Memcheck:Leak
fun:calloc
fun:_heim_alloc_object
fun:heim_dict_create
fun:_krb5_load_plugins
fun:init_context_once
fun:once_callback_caller
fun:pthread_once
fun:heim_base_once_f
fun:krb5_init_context
fun:main
}
{
Heimdal one-time init leak 4
Memcheck:Leak
fun:calloc
fun:heim_dict_create
fun:_krb5_load_plugins
fun:init_context_once
fun:once_callback_caller
fun:pthread_once
fun:heim_base_once_f
fun:krb5_init_context
fun:main
}
{
Heimdal ipropd-master leak 1
Memcheck:Leak
...
fun:krb5_kt_resolve
fun:main
obj:*ipropd-master
}
{
Heimdal ipropd-master leak 2
Memcheck:Leak
...
fun:kadm5_init_with_skey_ctx
fun:main
obj:*ipropd-master
}
{
Heimdal ipropd-slave leak 1
Memcheck:Leak
...
fun:krb5_auth_con_init
...
fun:krb5_sendauth
fun:main
obj:*ipropd-slave
}
{
Heimdal ipropd-slave leak 2
Memcheck:Leak
...
fun:kadm5_init_with_password_ctx
fun:main
obj:*ipropd-slave
}

View File

@ -36,4 +36,4 @@ AC_SUBST(VERSIONING)
AM_CONDITIONAL(versionscript,test $doversioning = yes)
AC_SUBST(LDFLAGS_VERSION_SCRIPT)
])
])

View File

@ -9,21 +9,25 @@ AC_ARG_ENABLE(developer,
if test "X$enable_developer" = Xyes; then
dwflags="-Werror"
fi
AM_CONDITIONAL(DEVELOPER_MODE, test "X$enable_developer" = Xyes)
WFLAGS_NOUNUSED=""
WFLAGS_NOIMPLICITINT=""
if test -z "$WFLAGS" -a "$GCC" = "yes"; then
# -Wno-implicit-int for broken X11 headers
# leave these out for now:
# -Wcast-align doesn't work well on alpha osf/1
# -Wmissing-prototypes -Wpointer-arith -Wbad-function-cast
# -Wmissing-declarations -Wnested-externs
# -Wstrict-overflow=5
WFLAGS="ifelse($#, 0,-Wall, $1) $dwflags"
WFLAGS_NOUNUSED="-Wno-unused"
WFLAGS_NOIMPLICITINT="-Wno-implicit-int"
#
# WFLAGS_LITE can be appended to WFLAGS to turn off a host of warnings
# that fail for various bits of older code in appl/. Let's not use it
# for the main libraries, though.
WFLAGS_LITE="-Wno-extra -Wno-missing-field-initializers -Wno-strict-aliasing -Wno-shadow"
# -Wno-unused-result (not supported on gcc-4.2)
fi
AC_SUBST(WFLAGS)dnl
AC_SUBST(WFLAGS_NOUNUSED)dnl
AC_SUBST(WFLAGS_NOIMPLICITINT)dnl
AC_SUBST(WFLAGS_LITE)dnl
])

View File

@ -39,4 +39,4 @@ no) ;;
fi
;;
esac
])
])

View File

@ -1,20 +1,25 @@
dnl Process this file with autoconf to produce a configure script.
AC_REVISION(Revision)
AC_REVISION($Revision: 1.2.4.1 $)
AC_PREREQ(2.62)
test -z "$CFLAGS" && CFLAGS="-g"
AC_INIT([Heimdal],[1.5.3],[heimdal-bugs@h5l.org])
AC_INIT([Heimdal],[7.99.1],[https://github.com/heimdal/heimdal/issues])
AC_CONFIG_SRCDIR([kuser/kinit.c])
AC_CONFIG_HEADERS(include/config.h)
AC_CONFIG_MACRO_DIR([cf])
AM_INIT_AUTOMAKE([foreign 1.10.3])
AM_INIT_AUTOMAKE([foreign 1.11])
AM_MAINTAINER_MODE
LT_PREREQ([2.2])
LT_INIT([shared static win32-dll])
dnl Checks for programs.
AC_PROG_CC
AM_PROG_CC_C_O
AC_PROG_CPP
AC_PROG_LIBTOOL
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
AC_PREFIX_DEFAULT(/usr/heimdal)
@ -40,6 +45,17 @@ AC_DEFINE([_GNU_SOURCE], 1,
AC_OBJEXT
AC_EXEEXT
dnl
dnl this is needed when der-protos.h or der-private.h has to be generated
dnl
if ! test -f "$srcdir/lib/asn1/der-protos.h" ||
! test -f "$srcdir/lib/asn1/der-private.h"; then
AC_KRB_PROG_PERL
AC_KRB_PERL_MOD(Getopt::Std)
AC_KRB_PERL_MOD(File::Compare)
AC_KRB_PERL_MOD(JSON)
fi
dnl AC_KRB_PROG_YACC
AC_PROG_YACC
AM_PROG_LEX
@ -53,9 +69,6 @@ libdir="$libdir$abilibdirext"
AC_C___ATTRIBUTE__
LT_PREREQ([2.2])
LT_INIT([shared static win32-dll])
AM_CONDITIONAL(ENABLE_SHARED, test "$enable_shared" = "yes")
rk_VERSIONSCRIPT
@ -98,7 +111,6 @@ AC_SUBST([ASN1_COMPILE_DEP])
AC_SUBST([SLC])
AC_SUBST([SLC_DEP])
dnl ---
AC_DEFINE(HEIM_WEAK_CRYPTO, 1, [Define if you want support for weak crypto])
@ -199,12 +211,6 @@ DIR_hdbdir="$with_hdbdir"
AC_SUBST([DIR_hdbdir])
dnl no kerberos4 any more
with_krb4=no
AC_SUBST(INCLUDE_krb4)
AC_SUBST(LIB_krb4)
AM_CONDITIONAL(KRB4, false)
AM_CONDITIONAL(KRB5, true)
AM_CONDITIONAL(do_roken_rename, true)
@ -246,6 +252,7 @@ if test "$enable_afs_support" = no; then
NO_AFS="1"
fi
AC_SUBST(NO_AFS)dnl
AM_CONDITIONAL(NO_AFS, test "$enable_afs_support" = no)
rk_DB
@ -280,6 +287,12 @@ fi
rk_CHECK_MAN
AC_CHECK_HEADERS([\
readline/readline.h \
readline.h \
editline/readline.h \
])
rk_TEST_PACKAGE(readline,
[#include <stdio.h>
#if defined(HAVE_READLINE_READLINE_H)
@ -295,22 +308,16 @@ rk_TEST_PACKAGE(libedit,
#include <readline/readline.h>
#elif defined(HAVE_READLINE_H)
#include <readline.h>
#elif defined(HAVE_EDITLINE_READLINE_H)
#include <editline/readline.h>
#endif
],-ledit,,, READLINE,, [readline.h readline/readline.h])
],-ledit,,, READLINE,, [readline.h readline/readline.h editline/readline.h])
AC_CONFIG_SUBDIRS([lib/libedit])
rk_TEST_PACKAGE(hesiod,[#include <hesiod.h>],-lhesiod,,, HESIOD)
KRB_C_BIGENDIAN
AC_C_INLINE
KRB_CHECK_X
AM_CONDITIONAL(HAVE_X, test "$no_x" != yes)
AC_CHECK_XAU
dnl AM_C_PROTOTYPES
dnl Checks for typedefs, structures, and compiler characteristics.
@ -328,7 +335,6 @@ AC_HEADER_STDC
AC_CHECK_HEADERS([\
CommonCrypto/CommonDigest.h \
CommonCrypto/CommonCryptor.h \
arpa/ftp.h \
arpa/telnet.h \
bind/bitypes.h \
bsdsetjmp.h \
@ -379,8 +385,6 @@ AC_CHECK_HEADERS([\
tmpdir.h \
udb.h \
util.h \
utmp.h \
utmpx.h \
])
dnl On Solaris 8 there's a compilation warning for term.h because
@ -464,9 +468,11 @@ AC_CHECK_FUNCS([ \
arc4random \
backtrace \
fcntl \
fork \
getpeereid \
getpeerucred \
grantpt \
kill \
mktime \
ptsname \
rand \
@ -489,6 +495,7 @@ AC_CHECK_FUNCS([ \
umask \
unlockpt \
vhangup \
waitpid \
yp_get_default_domain \
])
@ -504,8 +511,10 @@ AC_MSG_RESULT($ac_rk_have___sync_add_and_fetch)
AC_FUNC_MMAP
KRB_CAPABILITIES
rk_DLADDR
AC_CHECK_GETPWNAM_R_POSIX
AC_CHECK_GETPWUID_R_POSIX
dnl detect doors on solaris
if test "$enable_pthread_support" != no; then
@ -537,26 +546,6 @@ AC_CHECK_FUNCS(getudbnam setlim)
dnl AC_KRB_FUNC_GETCWD_BROKEN
dnl
dnl Check for fields in struct utmp
dnl
AC_HAVE_STRUCT_FIELD(struct utmp, ut_addr, [#include <utmp.h>])
AC_HAVE_STRUCT_FIELD(struct utmp, ut_host, [#include <utmp.h>])
AC_HAVE_STRUCT_FIELD(struct utmp, ut_id, [#include <utmp.h>])
AC_HAVE_STRUCT_FIELD(struct utmp, ut_pid, [#include <utmp.h>])
AC_HAVE_STRUCT_FIELD(struct utmp, ut_type, [#include <utmp.h>])
AC_HAVE_STRUCT_FIELD(struct utmp, ut_user, [#include <utmp.h>])
AC_HAVE_STRUCT_FIELD(struct utmpx, ut_host, [#include <utmpx.h>])
AC_HAVE_STRUCT_FIELD(struct utmpx, ut_id, [#include <utmpx.h>])
AC_HAVE_STRUCT_FIELD(struct utmpx, ut_line, [#include <utmpx.h>])
AC_HAVE_STRUCT_FIELD(struct utmpx, ut_pid, [#include <utmpx.h>])
AC_HAVE_STRUCT_FIELD(struct utmpx, ut_tv, [#include <utmpx.h>])
AC_HAVE_STRUCT_FIELD(struct utmpx, ut_type, [#include <utmpx.h>])
AC_HAVE_STRUCT_FIELD(struct utmpx, ut_user, [#include <utmpx.h>])
AC_HAVE_STRUCT_FIELD(struct utmpx, ut_exit, [#include <utmpx.h>])
AC_HAVE_STRUCT_FIELD(struct utmpx, ut_syslen, [#include <utmpx.h>])
AC_CHECK_TYPES([int8_t, int16_t, int32_t, int64_t,
u_int8_t, u_int16_t, u_int32_t, u_int64_t,
uint8_t, uint16_t, uint32_t, uint64_t],,,[
@ -613,7 +602,7 @@ AC_CONFIG_FILES(Makefile \
include/hcrypto/Makefile \
include/kadm5/Makefile \
lib/Makefile \
base/Makefile \
lib/base/Makefile \
lib/asn1/Makefile \
lib/com_err/Makefile \
lib/hcrypto/Makefile \
@ -641,24 +630,10 @@ AC_CONFIG_FILES(Makefile \
kdc/Makefile \
appl/Makefile \
appl/afsutil/Makefile \
appl/ftp/Makefile \
appl/ftp/common/Makefile \
appl/ftp/ftp/Makefile \
appl/ftp/ftpd/Makefile \
appl/dbutils/Makefile \
appl/gssmask/Makefile \
appl/kx/Makefile \
appl/login/Makefile \
appl/otp/Makefile \
appl/popper/Makefile \
appl/push/Makefile \
appl/rsh/Makefile \
appl/rcp/Makefile \
appl/su/Makefile \
appl/xnlock/Makefile \
appl/telnet/Makefile \
appl/telnet/libtelnet/Makefile \
appl/telnet/telnet/Makefile \
appl/telnet/telnetd/Makefile \
appl/test/Makefile \
appl/kf/Makefile \
appl/dceutils/Makefile \

View File

@ -24,6 +24,11 @@ hdb.dxy: hdb.din Makefile
chmod +x hdb.dxy.tmp
mv hdb.dxy.tmp hdb.dxy
base.dxy: base.din Makefile
$(dxy_subst) < $(srcdir)/base.din > base.dxy.tmp
chmod +x base.dxy.tmp
mv base.dxy.tmp base.dxy
hx509.dxy: hx509.din Makefile
$(dxy_subst) < $(srcdir)/hx509.din > hx509.dxy.tmp
chmod +x hx509.dxy.tmp
@ -50,6 +55,7 @@ wind.dxy: wind.din Makefile
mv wind.dxy.tmp wind.dxy
texi_subst = sed -e 's,[@]dbdir[@],$(localstatedir),g' \
-e 's,[@]dbtype[@],$(db_type),g' \
-e 's,[@]PACKAGE_VERSION[@],$(PACKAGE_VERSION),g'
vars.texi: vars.tin Makefile
@ -57,16 +63,23 @@ vars.texi: vars.tin Makefile
chmod +x vars.texi.tmp
mv vars.texi.tmp vars.texi
PROJECTS = hcrypto hdb hx509 gssapi krb5 ntlm wind
PROJECTS = base hdb hx509 gssapi krb5 ntlm wind
doxyout doxygen: hdb.dxy hx509.dxy hcrypto.dxy gssapi.dxy krb5.dxy ntlm.dxy wind.dxy
PROJECTS += hcrypto
doxyout doxygen: base.dxy hdb.dxy hx509.dxy hcrypto.dxy gssapi.dxy krb5.dxy ntlm.dxy wind.dxy
@find $(srcdir)/doxyout -type d ! -perm -200 -exec chmod u+w {} ';' ; \
rm -rf $(srcdir)/doxyout ; \
mkdir $(srcdir)/doxyout ; \
for a in $(PROJECTS) ; do \
echo $$a ; \
doxygen $$a.dxy; \
(cd $(srcdir)/doxyout && find $$a/man -type f > $$a/manpages ) ; \
(cd $(srcdir)/doxyout && \
find $$a/man -name '_*' -type f -print | \
perl -lne unlink && \
find $$a/html -name 'dir_*.html' -type f -print | \
perl -lne unlink && \
find $$a/man -type f > $$a/manpages ) ; \
done
install-data-hook: install-doxygen-manpage
@ -123,6 +136,7 @@ EXTRA_DIST = \
hcrypto.din \
header.html \
heimdal.css \
base.din \
hx509.din \
krb5.din \
ntlm.din \
@ -131,10 +145,14 @@ EXTRA_DIST = \
layman.asc \
doxytmpl.dxy \
wind.din \
base.hhp \
heimdal.hhp \
hx509.hhp \
vars.tin
CLEANFILES = \
hcrypto.dxy* \
base.dxy* \
hx509.dxy* \
hdb.dxy* \
gssapi.dxy* \

View File

@ -57,10 +57,15 @@ hx509_TEXINFOS = \
{}.tin{$(OBJ)}.texi:
$(SED) -e "s,[@]dbdir[@],x,g" \
-e "s,[@]dbtype[@],sqlite,g" < $** > $@ \
-e "s,[@]PACKAGE_VERSION[@],$(VER_PACKAGE_VERSION),g" < $** > $@
MAKEINFOFLAGS = --css-include=$(SRCDIR)/heimdal.css
!ifdef APPVEYOR
MAKEINFO = $(PERL) C:\msys64\usr\bin\makeinfo
!endif
######################################################################
# Build heimdal.chm

View File

@ -1,7 +1,5 @@
@c Id
@c $NetBSD: ack.texi,v 1.1.1.3 2014/04/24 12:45:26 pettai Exp $
@node Acknowledgments, Copyrights and Licenses, Migration, Top
@c $NetBSD: ack.texi,v 1.2 2017/01/28 21:31:44 christos Exp $
@comment node-name, next, previous, up
@appendix Acknowledgments
@ -78,6 +76,7 @@ Bugfixes, documentation, encouragement, and code has been contributed by:
@item Johan Gadsjö
@item Johan Ihrén
@item John Center
@item Julian Ospald
@item Jun-ichiro itojun Hagino
@item KAMADA Ken'ichi
@item Kamen Mazdrashki
@ -115,6 +114,7 @@ Bugfixes, documentation, encouragement, and code has been contributed by:
@item Simon Wilkinson
@item Stefan Metzmacher
@item Ted Percival
@item Timothy Pearson
@item Tom Payerle
@item Victor Guerra
@item Zeqing Xia

View File

@ -1,5 +1,5 @@
@c Id
@c $NetBSD: apps.texi,v 1.1.1.2 2011/04/14 14:08:08 elric Exp $
@c $NetBSD: apps.texi,v 1.2 2017/01/28 21:31:44 christos Exp $
@node Applications, Things in search for a better place, Setting up a realm, Top

View File

@ -0,0 +1,15 @@
# Doxyfile 1.5.3
PROJECT_NAME = Heimdal base library
PROJECT_NUMBER = @PACKAGE_VERSION@
OUTPUT_DIRECTORY = @srcdir@/doxyout/base
INPUT = @srcdir@/../lib/base
WARN_IF_UNDOCUMENTED = YES
PERL_PATH = /usr/bin/perl
HTML_HEADER = "@srcdir@/header.html"
HTML_FOOTER = "@srcdir@/footer.html"
@INCLUDE = "@srcdir@/doxytmpl.dxy"

View File

@ -0,0 +1,8 @@
[OPTIONS]
Compatibility=1.1 or later
Compiled file=heimbase.chm
Contents file=toc.hhc
Default topic=index.html
Display compile progress=No
Language=0x409 English (United States)
Title=Heimdal Base

View File

@ -1,5 +1,5 @@
@c $NetBSD: copyright.texi,v 1.1.1.2 2014/04/24 12:45:26 pettai Exp $
@c $NetBSD: copyright.texi,v 1.2 2017/01/28 21:31:44 christos Exp $
@macro copynext{}
@vskip 20pt plus 1fil
@end macro
@ -218,6 +218,9 @@ SUCH DAMAGE.
@verbatim
Copyright (c) 2003-2011, PADL Software Pty Ltd.
Copyright (c) 2004, Andrew Bartlett.
Copyright (c) 2003 - 2008, Kungliga Tekniska Högskolan
Copyright (c) 2015, Timothy Pearson.
All rights reserved.
Redistribution and use in source and binary forms, with or without
@ -444,7 +447,7 @@ Windows support
@verbatim
Copyright (c) 2009, Secure Endpoints Inc.
Copyright (c) 2009-2015, Secure Endpoints Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without

View File

@ -26,7 +26,6 @@ SHORT_NAMES = NO
JAVADOC_AUTOBRIEF = NO
QT_AUTOBRIEF = NO
MULTILINE_CPP_IS_BRIEF = NO
DETAILS_AT_TOP = NO
INHERIT_DOCS = YES
SEPARATE_MEMBER_PAGES = NO
TAB_SIZE = 8
@ -65,7 +64,6 @@ GENERATE_DEPRECATEDLIST= YES
ENABLED_SECTIONS =
MAX_INITIALIZER_LINES = 30
SHOW_USED_FILES = YES
SHOW_DIRECTORIES = NO
FILE_VERSION_FILTER =
#---------------------------------------------------------------------------
# configuration options related to warning and progress messages
@ -105,8 +103,7 @@ FILE_PATTERNS = *.c \
*.inc \
*.m \
*.mm \
*.dox \
*.py
*.dox
RECURSIVE = YES
EXCLUDE =
EXCLUDE_SYMLINKS = NO
@ -142,7 +139,6 @@ GENERATE_HTML = YES
HTML_OUTPUT = html
HTML_FILE_EXTENSION = .html
HTML_STYLESHEET =
HTML_ALIGN_MEMBERS = YES
GENERATE_HTMLHELP = NO
HTML_DYNAMIC_SECTIONS = NO
CHM_FILE =
@ -190,8 +186,6 @@ MAN_LINKS = YES
#---------------------------------------------------------------------------
GENERATE_XML = NO
XML_OUTPUT = xml
XML_SCHEMA =
XML_DTD =
XML_PROGRAMLISTING = YES
#---------------------------------------------------------------------------
# configuration options for the AutoGen Definitions output
@ -213,7 +207,7 @@ EXPAND_ONLY_PREDEF = NO
SEARCH_INCLUDES = YES
INCLUDE_PATH =
INCLUDE_FILE_PATTERNS =
PREDEFINED =
PREDEFINED = DOXY
EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = YES
#---------------------------------------------------------------------------
@ -227,7 +221,6 @@ EXTERNAL_GROUPS = YES
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
CLASS_DIAGRAMS = NO
MSCGEN_PATH = /Applications/Doxygen.app/Contents/Resources/
HIDE_UNDOC_RELATIONS = YES
HAVE_DOT = YES
CLASS_GRAPH = YES
@ -242,7 +235,6 @@ CALLER_GRAPH = NO
GRAPHICAL_HIERARCHY = YES
DIRECTORY_GRAPH = YES
DOT_IMAGE_FORMAT = png
DOT_PATH = /Applications/Doxygen.app/Contents/Resources/
DOTFILE_DIRS =
DOT_GRAPH_MAX_NODES = 50
MAX_DOT_GRAPH_DEPTH = 1000

View File

@ -5,4 +5,4 @@ Contents file=toc.hhc
Default topic=index.html
Display compile progress=No
Language=0x409 English (United States)
Title=Heimdal
Title=Heimdal

View File

@ -1,5 +1,5 @@
\input texinfo @c -*- texinfo -*-
@c $NetBSD: heimdal.texi,v 1.1.1.3 2014/04/24 12:45:26 pettai Exp $
@c $NetBSD: heimdal.texi,v 1.2 2017/01/28 21:31:44 christos Exp $
@c %**start of header
@c Id
@setfilename heimdal.info

View File

@ -5,4 +5,4 @@ Contents file=toc.hhc
Default topic=index.html
Display compile progress=No
Language=0x409 English (United States)
Title=HX509
Title=HX509

View File

@ -1,5 +1,5 @@
\input texinfo @c -*- texinfo -*-
@c $NetBSD: hx509.texi,v 1.1.1.3 2014/04/24 12:45:26 pettai Exp $
@c $NetBSD: hx509.texi,v 1.2 2017/01/28 21:31:44 christos Exp $
@c %**start of header
@c Id
@setfilename hx509.info

View File

@ -1,5 +1,5 @@
@node Building and Installing, Setting up a realm, What is Kerberos?, Top
@c $NetBSD: install.texi,v 1.1.1.1 2011/04/13 18:14:33 elric Exp $
@c $NetBSD: install.texi,v 1.2 2017/01/28 21:31:44 christos Exp $
@comment node-name, next, previous, up
@chapter Building and Installing

View File

@ -1,5 +1,5 @@
@c Id
@c $NetBSD: intro.texi,v 1.1.1.3 2014/04/24 12:45:26 pettai Exp $
@c $NetBSD: intro.texi,v 1.2 2017/01/28 21:31:44 christos Exp $
@node Introduction, What is Kerberos?, Top, Top
@c @node Introduction, What is Kerberos?, Top, Top

View File

@ -1,5 +1,5 @@
@c Id
@c $NetBSD: kerberos4.texi,v 1.1.1.3 2014/04/24 12:45:26 pettai Exp $
@c $NetBSD: kerberos4.texi,v 1.2 2017/01/28 21:31:44 christos Exp $
@node Kerberos 4 issues, Windows compatibility, Things in search for a better place, Top
@comment node-name, next, previous, up

View File

@ -1,19 +1,39 @@
@c Id
@c $NetBSD: migration.texi,v 1.1.1.2 2011/04/14 14:08:08 elric Exp $
@c $NetBSD: migration.texi,v 1.2 2017/01/28 21:31:44 christos Exp $
@node Migration, Acknowledgments, Programming with Kerberos, Top
@chapter Migration
@section Migration from MIT Kerberos to Heimdal
hpropd can read MIT Kerberos dump, the format is the same as used in
mit-kerberos 1.0b7, and to dump that format use the following command:
@samp{kdb5_util dump -b7}.
hpropd can read MIT Kerberos dump in "kdb5_util load_dump version 5" or
version 6 format. Simply run:
@samp{kdb5_util dump}.
To load the MIT Kerberos dump file, use the following command:
@samp{/usr/heimdal/libexec/hprop --database=dump-file --master-key=/var/db/krb5kdc/mit_stash --source=mit-dump --decrypt --stdout | /usr/heimdal/libexec/hpropd --stdin}
kadmin can dump in MIT Kerberos format. Simply run:
@samp{kadmin -l dump -f MIT}.
The Heimdal KDC and kadmind, as well as kadmin -l and the libkadm5srv
library can read and write MIT KDBs, and can read MIT stash files. To
build with KDB support requires having a standalone libdb from MIT
Kerberos and associated headers, then you can configure Heildal as
follows:
@samp{./configure ... CPPFLAGS=-I/path-to-mit-db-headers LDFLAGS="-L/path-to-mit-db-object -Wl,-rpath -Wl,/path-to-mit-db-object" LDLIBS=-ldb}
At this time support for MIT Kerberos KDB dump/load format and direct
KDB access does not include support for PKINIT, or K/M key history,
constrained delegation, and other advanced features.
Heimdal supports using multiple HDBs at once, with all write going to
just one HDB. This allows for entries to be moved to a native HDB from
an MIT KDB over time as those entries are changed. Or you can use hprop
and hpropd.
@section General issues
When migrating from a Kerberos 4 KDC.

View File

@ -1,5 +1,5 @@
@c Id
@c $NetBSD: misc.texi,v 1.1.1.2 2011/04/14 14:08:08 elric Exp $
@c $NetBSD: misc.texi,v 1.2 2017/01/28 21:31:44 christos Exp $
@node Things in search for a better place, Kerberos 4 issues, Applications, Top
@chapter Things in search for a better place

View File

@ -1,32 +0,0 @@
OIDs used by Heimdal project.
Contact heimdal-contact@h5l.org
Oid Name
1.2.752.43.13 Heimdal GSS-API extentions
1.2.752.43.14 Heimdal GSS-API mechs
1.2.752.43.16 Heimdal Internal crypto ops
1.2.752.43.13.1 GSS_KRB5_COPY_CCACHE_X
1.2.752.43.13.2 GSS_KRB5_GET_TKT_FLAGS_X
1.2.752.43.13.3 GSS_KRB5_EXTRACT_AUTHZ_DATA_FROM_SEC_CONTEXT_X
1.2.752.43.13.4 GSS_KRB5_COMPAT_DES3_MIC_X
1.2.752.43.13.5 GSS_KRB5_REGISTER_ACCEPTOR_IDENTITY_X
1.2.752.43.13.6 GSS_KRB5_EXPORT_LUCID_CONTEXT_X
1.2.752.43.13.6.1 GSS_KRB5_EXPORT_LUCID_CONTEXT_V1_X
1.2.752.43.13.7 GSS_KRB5_SET_DNS_CANONICALIZE_X
1.2.752.43.13.8 GSS_KRB5_GET_SUBKEY_X
1.2.752.43.13.9 GSS_KRB5_GET_INITIATOR_SUBKEY_X
1.2.752.43.13.10 GSS_KRB5_GET_ACCEPTOR_SUBKEY_X
1.2.752.43.13.11 GSS_KRB5_SEND_TO_KDC_X
1.2.752.43.13.12 GSS_KRB5_GET_AUTHTIME_X
1.2.752.43.13.13 GSS_KRB5_GET_SERVICE_KEYBLOCK_X
1.2.752.43.13.14 GSS_KRB5_SET_ALLOWABLE_ENCTYPES_X
1.2.752.43.13.15 GSS_KRB5_SET_DEFAULT_REALM_X
1.2.752.43.13.16 GSS_KRB5_CCACHE_NAME_X
1.2.752.43.13.17 GSS_KRB5_CRED_NO_CI_FLAGS_X
1.2.752.43.13.18 GSS_KRB5_IMPORT_CRED_X
1.2.752.43.14.1 GSS_SASL_DIGEST_MD5_MECHANISM

View File

@ -1,5 +1,5 @@
@c Id
@c $NetBSD: programming.texi,v 1.1.1.2 2011/04/14 14:08:09 elric Exp $
@c $NetBSD: programming.texi,v 1.2 2017/01/28 21:31:44 christos Exp $
@node Programming with Kerberos, Migration, Windows compatibility, Top
@chapter Programming with Kerberos

View File

@ -1,5 +1,5 @@
@c Id
@c $NetBSD: setup.texi,v 1.1.1.3 2014/04/24 12:45:27 pettai Exp $
@c $NetBSD: setup.texi,v 1.2 2017/01/28 21:31:44 christos Exp $
@node Setting up a realm, Applications, Building and Installing, Top
@ -109,7 +109,7 @@ SRV-record for your realm, or your Kerberos server has DNS CNAME
@cindex KRB5_CONFIG
If you want to use a different configuration file then the default you
can point a file with the enviroment variable @samp{KRB5_CONFIG}.
can point a file with the environment variable @samp{KRB5_CONFIG}.
@example
env KRB5_CONFIG=$HOME/etc/krb5.conf kinit user@@REALM
@ -124,8 +124,30 @@ Make sure the directory has restrictive permissions.
@example
# mkdir /var/heimdal
# chmod og-rwx /var/heimdal
@end example
Heimdal supports various database backends: lmdb (LMDB), db3 (Berkeley
DB 3.x, 4.x, or 5.x), db1 (Berkeley DB 2.x), sqlite (SQLite3), and ldap
(LDAP). The default is @value{dbtype}, and is selected at build time
from one of lmdb, db3, or db1.
These defaults can be overriden in the 'database' key in the @samp{kdc}
section of the configuration.
@example
[kdc]
database = @{
dbname = lmdb:/path/to/db-file
realm = REALM
acl_file = /path/to/kadmind.acl
mkey_file = /path/to/mkey
log_file = /path/to/iprop-log-file
@}
@end example
To use LDAP, see @xref{Using LDAP to store the database}.
The keys of all the principals are stored in the database. If you
choose to, these can be encrypted with a master key. You do not have to
remember this key (or password), but just to enter it once and it will
@ -597,6 +619,18 @@ slave# /usr/heimdal/libexec/ipropd-slave master &
To manage the iprop log file you should use the @command{iprop-log}
command. With it you can dump, truncate and replay the logfile.
@subsection Status of iprop master and slave
Both the master and slave provides status of the world as they see it.
The master write outs the current status of the slaves, last seen and
their version number in @file{/var/heimdal/slaves-stats}.
The slave write out the current status in @file{/var/heimdal/ipropd-slave-status}.
These locations can be changed with command line options, and in the
case of @command{ipropd_master}, the configuration file.
@node Encryption types and salting, Credential cache server - KCM, Incremental propagation, Setting up a realm
@section Encryption types and salting
@cindex Salting
@ -1042,7 +1076,8 @@ Its also possible to configure the ldap backend as a shared module,
see option --hdb-openldap-module to configure.
@item
Configure OpenLDAP with @kbd{--enable-local} to enable the local transport.
Optionally configure OpenLDAP with @kbd{--enable-local} to enable the
local transport.
@item
Add the hdb schema to the LDAP server, it's included in the source-tree
@ -1053,8 +1088,8 @@ include /usr/local/etc/openldap/schema/hdb.schema
@end example
@item
Configure the LDAP server ACLs to accept writes from clients over the
local transport. For example:
Configure the LDAP server ACLs to accept writes from clients. For
example:
@example
access to *
@ -1074,10 +1109,15 @@ krb5Principal aux object with krb5PrincipalName set so that the
Another option is to create an admins group and add the dn to that
group.
Since Heimdal talks to the LDAP server over a UNIX domain socket, and
uses external sasl authentication, it's not possible to require
security layer quality (ssf in cyrus-sasl lingo). So that requirement
has to be turned off in OpenLDAP @command{slapd} configuration file
If a non-local LDAP connection is used, the authz-regexp is not
needed as Heimdal will bind to LDAP over the network using
provided credentials.
Since Heimdal talks to the LDAP server over a UNIX domain socket when
configured for ldapi:///, and uses external sasl authentication, it's
not possible to require security layer quality (ssf in cyrus-sasl lingo).
So that requirement has to be turned off in OpenLDAP @command{slapd}
configuration file
@file{slapd.conf}.
@example
@ -1105,9 +1145,14 @@ enter the path to the kadmin acl file:
@example
[kdc]
# Optional configuration
hdb-ldap-structural-object = inetOrgPerson
hdb-ldap-url = ldapi:/// (default), ldap://hostname or ldaps://hostname
hdb-ldap-secret-file = /path/to/file/containing/ldap/credentials
hdb-ldap-start-tls = false
database = @{
dbname = ldap:ou=KerberosPrincipals,dc=example,dc=com
hdb-ldap-structural-object = inetOrgPerson
acl_file = /path/to/kadmind.acl
mkey_file = /path/to/mkey
@}
@ -1118,7 +1163,18 @@ directory to have the raw keys inside it. The
hdb-ldap-structural-object is not necessary if you do not need Samba
comatibility.
If connecting to a server over a non-local transport, the @samp{hdb-ldap-url}
and @samp{hdb-ldap-secret-file} options must be provided. The
@samp{hdb-ldap-secret-file} must contain the bind credentials:
@example
[kdc]
hdb-ldap-bind-dn = uid=heimdal,dc=services,dc=example,dc=com
hdb-ldap-bind-password = secretBindPassword
@end example
The @samp{hdb-ldap-secret-file} and should be protected with appropriate
file permissions
@item
Once you have built Heimdal and started the LDAP server, run kadmin
@ -1249,8 +1305,8 @@ certificates to get the initial ticket (usually the krbtgt
ticket-granting ticket).
To use PK-INIT you must first have a PKI. If you don't have one, it is
time to create it. You should first read the whole chapter of the
document to see the requirements imposed on the CA software.
time to create it. You should first read the whole current chapter of
the document to see the requirements imposed on the CA software.
A mapping between the PKI certificate and what principals that
certificate is allowed to use must exist. There are several ways to do
@ -1260,20 +1316,23 @@ the mapping in the principals entry in the kerberos database.
@section Certificates
This section documents the requirements on the KDC and client
certificates and the format used in the id-pkinit-san OtherName
extention.
This and following subsection documents the requirements on the KDC
and client certificates and the format used in the id-pkinit-san
OtherName extension.
On how to create certificates, you should read @ref{Use OpenSSL to
create certificates}.
@subsection KDC certificate
The certificate for the KDC has serveral requirements.
The certificate for the KDC has several requirements.
First, the certificate should have an Extended Key Usage (EKU)
id-pkkdcekuoid (1.3.6.1.5.2.3.5) set. Second, there must be a
subjectAltName otherName using OID id-pkinit-san (1.3.6.1.5.2.2) in
the type field and a DER encoded KRB5PrincipalName that matches the
name of the TGS of the target realm. Also, if the certificate has a
nameConstraints extention with a Generalname with dNSName or iPAdress,
nameConstraints extension with a Generalname with dNSName or iPAdress,
it must match the hostname or adress of the KDC.
The client is not required by the standard to check the server
@ -1292,7 +1351,7 @@ secret.
@subsection Client certificate
The client certificate may need to have a EKU id-pkekuoid
(1.3.6.1.5.2.3.4) set depending on the certifiate on the KDC.
(1.3.6.1.5.2.3.4) set depending on the configuration on the KDC.
It possible to store the principal (if allowed by the KDC) in the
certificate and thus delegate responsibility to do the mapping between
@ -1307,7 +1366,7 @@ This behavior is controlled by KDC configuration option:
@subsubsection Using KRB5PrincipalName in id-pkinit-san
The OtherName extention in the GeneralName is used to do the mapping
The OtherName extension in the GeneralName is used to do the mapping
between certificate and principal. For the KDC certificate, this
stores the krbtgt principal name for that KDC. For the client
certificate, this stores the principal for which that certificate is
@ -1435,8 +1494,6 @@ Credentials cache: API:4
Mar 26 23:40:10 Mar 27 09:40:10 krbtgt/EXAMPLE.ORG@@EXAMPLE.ORG
@end example
TODO: Write about the KDC.
@section Configure the client
@example
@ -1455,6 +1512,45 @@ TODO: Write about the KDC.
@section Configure the KDC
Configuration options for the KDC.
@table @asis
@item enable-pkinit = bool
Enable PKINIT for this KDC.
@item pkinit_identity = string
Identity that the KDC will use when talking to clients. Mandatory.
@item pkinit_anchors = string
Trust anchors that the KDC will use when evaluating the trust of the
client certificate. Mandatory.
@item pkinit_pool = strings ...
Extra certificate the KDC will use when building trust chains if it
can't find enough certificates in the request from the client.
@item pkinit_allow_proxy_certificate = bool
Allow clients to use proxy certificates. The root certificate
of the client's End Entity certificate is used for authorisation.
@item pkinit_win2k_require_binding = bool
Require windows clients up be upgrade to not allow cut and paste
attack on encrypted data, applies to Windows XP and windows 2000
servers.
@item pkinit_principal_in_certificate = bool
Enable the KDC to use id-pkinit-san to determine to determine the
mapping between a certificate and principal.
@end table
@example
[kdc]
enable-pkinit = yes
@ -1469,7 +1565,7 @@ TODO: Write about the KDC.
@subsection Using pki-mapping file
Note that the file name is space sensitive.
Note that the file contents are space sensitive.
@example
# cat /var/heimdal/pki-mapping
@ -1480,6 +1576,13 @@ lha@@EXAMPLE.ORG:CN=Love,UID=lha
@subsection Using the Kerberos database
You can also store the subject of the certificate in the principal
entry in the kerberos database.
@example
kadmin modify --pkinit-acl="CN=baz,DC=test,DC=h5l,DC=se" user@@REALM
@end example
@section Use hxtool to create certificates
@subsection Generate certificates
@ -1548,6 +1651,7 @@ hxtool validate FILE:user.pem
@end example
@section Use OpenSSL to create certificates
@anchor{Use OpenSSL to create certificates}
This section tries to give the CA owners hints how to create
certificates using OpenSSL (or CA software based on OpenSSL).

View File

@ -4,4 +4,5 @@
@c
@set dbdir @dbdir@
@set dbtype @dbtype@
@set PACKAGE_VERSION @PACKAGE_VERSION@

View File

@ -1,5 +1,5 @@
@c Id
@c $NetBSD: whatis.texi,v 1.1.1.3 2014/04/24 12:45:27 pettai Exp $
@c $NetBSD: whatis.texi,v 1.2 2017/01/28 21:31:44 christos Exp $
@node What is Kerberos?, Building and Installing, Introduction, Top
@chapter What is Kerberos?

View File

@ -1,5 +1,5 @@
@c Id
@c $NetBSD: win2k.texi,v 1.1.1.3 2014/04/24 12:45:27 pettai Exp $
@c $NetBSD: win2k.texi,v 1.2 2017/01/28 21:31:44 christos Exp $
@node Windows compatibility, Programming with Kerberos, Kerberos 4 issues, Top

View File

@ -13,7 +13,7 @@ nodist_include_HEADERS = krb5-types.h
noinst_HEADERS = heim_threads.h crypto-headers.h
EXTRA_DIST = NTMakefile krb5-types.cross
EXTRA_DIST = NTMakefile krb5-types.cross config.h.w32
if !CROSS_COMPILE
@ -28,18 +28,20 @@ krb5-types.h: krb5-types.cross
endif
CLEANFILES = \
asn1.h \
an2ln_plugin.h \
asn1-common.h \
asn1-template.h \
asn1.h \
asn1_err.h \
base64.h \
ccache_plugin.h \
cms_asn1.h \
crmf_asn1.h \
com_err.h \
com_right.h \
ccache_plugin.h \
der-protos.h \
crmf_asn1.h \
db_plugin.h \
der-private.h \
der-protos.h \
der.h \
digest_asn1.h \
editline.h \
@ -47,6 +49,8 @@ CLEANFILES = \
getarg.h \
glob.h \
gssapi.h \
gssapi_mech.h \
hdb-private.h \
hdb-protos.h \
hdb.h \
hdb_asn1.h \
@ -58,11 +62,14 @@ CLEANFILES = \
heimntlm-protos.h \
heimntlm.h \
hex.h \
hx509-private.h \
hx509-protos.h \
hx509.h \
hx509_err.h \
k524_err.h \
kafs.h \
kcm-protos.h \
kdc-private.h \
kdc-protos.h \
kdc.h \
krb5-private.h \
@ -76,6 +83,7 @@ CLEANFILES = \
kx509_asn1.h \
kx509_err.h \
locate_plugin.h \
login-protos.h \
ntlm_err.h \
ocsp_asn1.h \
otp.h \
@ -94,6 +102,8 @@ CLEANFILES = \
rtbl.h \
send_to_kdc_plugin.h \
sl.h \
sqlite3.h \
sqlite3ext.h \
test-mem.h \
vers.h \
vis.h \

View File

@ -61,6 +61,7 @@ while(<>) {
if ("$(KRB5)") { print "#define KRB5 1\n"; }
if ("$(KRB4)") { print "#define KRB4 1\n"; }
if ("$(WEAK_CRYPTO)") { print "#define HEIM_WEAK_CRYPTO 1\n"; }
if ("$(HCRYPTO_FALLBACK)") { print "#define HCRYPTO_FALLBACK 1\n"; } else { print "#define HCRYPTO_FALLBACK 0\n"; }
if ("$(PKINIT)") { print "#define PKINIT 1\n"; }
if ("$(NO_AFS)") { print "#define NO_AFS 1\n"; }
if ("$(OPENLDAP)") { print "#define OPENLDAP 1\n"; }
@ -75,6 +76,7 @@ while(<>) {
if ("$(ENV_HACK)") { print "#define ENV_HACK 1\n"; }
if ("$(HAVE_KCM)") { print "#define HAVE_KCM 1\n"; }
if ("$(HAVE_SCC)") { print "#define HAVE_SCC 1\n"; }
if ("$(HAVE_STDINT_H)") { print "#define HAVE_STDINT_H 1\n"; }
if ("$(DIR_hdbdir)") { print "#define HDB_DB_DIR \"".'$(DIR_hdbdir)'."\"\n"; }
if ("$(HAVE_MSLSA_CACHE)") { print "#define HAVE_MSLSA_CACHE 1\n"; }
if ("$(NO_LOCALNAME)") { print "#define NO_LOCALNAME 1\n"; }
@ -84,14 +86,14 @@ while(<>) {
if ("$(VER_PRERELEASE)") { print "#define VER_PRERELEASE 1\n"; }
if ("$(VER_PRIVATE)") { print "#define VER_PRIVATE \"$(VER_PRIVATE)\"\n"; }
if ("$(VER_SPECIAL)") { print "#define VER_SPECIAL \"$(VER_SPECIAL)\"\n"; }
if ("$(BUILD)" =~ "dbg") { print "#define VER_DEBUG 1\n"; }
if ("$(BUILD)" eq "dbg") { print "#define VER_DEBUG 1\n"; }
print "#define HOST \"$(COMPUTERNAME)\"\n";
} else {
s/\@PACKAGE\@/$(VER_PACKAGE)/;
s/\@PACKAGE_NAME\@/$(VER_PACKAGE_NAME)/;
s/\@PACKAGE_BUGREPORT\@/$(VER_PACKAGE_BUGREPORT:@=\@)/;
s{\@PACKAGE_BUGREPORT\@}{$(VER_PACKAGE_BUGREPORT:@=\@)};
s/\@PACKAGE_VERSION\@/$(VER_PACKAGE_VERSION)/;
s/\@PACKAGE_COPYRIGHT\@/$(VER_PACKAGE_COPYRIGHT)/;
s/\@PACKAGE_COMPANY\@/$(VER_PACKAGE_COMPANY)/;

View File

@ -1,4 +1,4 @@
/* $NetBSD: bits.c,v 1.1.1.3 2014/04/24 12:45:27 pettai Exp $ */
/* $NetBSD: bits.c,v 1.2 2017/01/28 21:31:44 christos Exp $ */
/*
* Copyright (c) 1997-2002 Kungliga Tekniska Högskolan
@ -37,7 +37,7 @@
#ifdef HAVE_CONFIG_H
#include <config.h>
__RCSID("NetBSD");
__RCSID("$NetBSD: bits.c,v 1.2 2017/01/28 21:31:44 christos Exp $");
#endif
#include <stdio.h>
#include <string.h>
@ -70,13 +70,13 @@ __RCSID("NetBSD");
#endif
static void
try_signed(FILE *f, int len) __attribute__ ((unused));
try_signed(FILE *f, int len) __attribute__ ((__unused__));
static void
try_unsigned(FILE *f, int len) __attribute__ ((unused));
try_unsigned(FILE *f, int len) __attribute__ ((__unused__));
static int
print_bt(FILE *f, int flag) __attribute__ ((unused));
print_bt(FILE *f, int flag) __attribute__ ((__unused__));
static void
try_signed(FILE *f, int len)
@ -120,7 +120,8 @@ int main(int argc, char **argv)
{
FILE *f;
int flag;
const char *fn, *hb;
char *p = NULL;
const char *hb;
if (argc > 1 && strcmp(argv[1], "--version") == 0) {
printf("some version");
@ -128,14 +129,11 @@ int main(int argc, char **argv)
}
if(argc < 2){
fn = "bits.h";
hb = "__BITS_H__";
f = stdout;
} else {
char *p;
fn = argv[1];
p = malloc(strlen(fn) + 5);
sprintf(p, "__%s__", fn);
p = malloc(strlen(argv[1]) + 5);
sprintf(p, "__%s__", argv[1]);
hb = p;
for(; *p; p++){
if(!isalnum((unsigned char)*p))
@ -143,9 +141,6 @@ int main(int argc, char **argv)
}
f = fopen(argv[1], "w");
}
fprintf(f, "/* %s -- this file was generated for %s by\n", fn, HOST);
fprintf(f, " %*s %s */\n\n", (int)strlen(fn), "",
"Id");
fprintf(f, "#ifndef %s\n", hb);
fprintf(f, "#define %s\n", hb);
fprintf(f, "\n");
@ -257,39 +252,57 @@ int main(int argc, char **argv)
#endif /* KRB5 */
fprintf(f, "#if !defined(__has_extension)\n");
fprintf(f, "#define __has_extension(x) 0\n");
fprintf(f, "#endif\n\n");
fprintf(f, "#ifndef KRB5TYPES_REQUIRE_GNUC\n");
fprintf(f, "#define KRB5TYPES_REQUIRE_GNUC(m,n,p) \\\n");
fprintf(f, " (((__GNUC__ * 10000) + (__GNUC_MINOR__ * 100) + __GNUC_PATCHLEVEL__) >= \\\n");
fprintf(f, " (((m) * 10000) + ((n) * 100) + (p)))\n");
fprintf(f, "#endif\n\n");
fprintf(f, "#ifndef HEIMDAL_DEPRECATED\n");
fprintf(f, "#if defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1 )))\n");
fprintf(f, "#define HEIMDAL_DEPRECATED __attribute__((deprecated))\n");
fprintf(f, "#if __has_extension(deprecated) || KRB5TYPES_REQUIRE_GNUC(3,1,0)\n");
fprintf(f, "#define HEIMDAL_DEPRECATED __attribute__ ((__deprecated__))\n");
fprintf(f, "#elif defined(_MSC_VER) && (_MSC_VER>1200)\n");
fprintf(f, "#define HEIMDAL_DEPRECATED __declspec(deprecated)\n");
fprintf(f, "#else\n");
fprintf(f, "#define HEIMDAL_DEPRECATED\n");
fprintf(f, "#endif\n");
fprintf(f, "#endif\n");
fprintf(f, "#endif\n\n");
fprintf(f, "#ifndef HEIMDAL_PRINTF_ATTRIBUTE\n");
fprintf(f, "#if defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1 )))\n");
fprintf(f, "#define HEIMDAL_PRINTF_ATTRIBUTE(x) __attribute__((format x))\n");
fprintf(f, "#if __has_extension(format) || KRB5TYPES_REQUIRE_GNUC(3,1,0)\n");
fprintf(f, "#define HEIMDAL_PRINTF_ATTRIBUTE(x) __attribute__ ((__format__ x))\n");
fprintf(f, "#else\n");
fprintf(f, "#define HEIMDAL_PRINTF_ATTRIBUTE(x)\n");
fprintf(f, "#endif\n");
fprintf(f, "#endif\n");
fprintf(f, "#endif\n\n");
fprintf(f, "#ifndef HEIMDAL_NORETURN_ATTRIBUTE\n");
fprintf(f, "#if defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1 )))\n");
fprintf(f, "#define HEIMDAL_NORETURN_ATTRIBUTE __attribute__((noreturn))\n");
fprintf(f, "#if __has_extension(noreturn) || KRB5TYPES_REQUIRE_GNUC(3,1,0)\n");
fprintf(f, "#define HEIMDAL_NORETURN_ATTRIBUTE __attribute__ ((__noreturn__))\n");
fprintf(f, "#else\n");
fprintf(f, "#define HEIMDAL_NORETURN_ATTRIBUTE\n");
fprintf(f, "#endif\n");
fprintf(f, "#endif\n");
fprintf(f, "#endif\n\n");
fprintf(f, "#ifndef HEIMDAL_UNUSED_ATTRIBUTE\n");
fprintf(f, "#if defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1 )))\n");
fprintf(f, "#define HEIMDAL_UNUSED_ATTRIBUTE __attribute__((unused))\n");
fprintf(f, "#if __has_extension(unused) || KRB5TYPES_REQUIRE_GNUC(3,1,0)\n");
fprintf(f, "#define HEIMDAL_UNUSED_ATTRIBUTE __attribute__ ((__unused__))\n");
fprintf(f, "#else\n");
fprintf(f, "#define HEIMDAL_UNUSED_ATTRIBUTE\n");
fprintf(f, "#endif\n");
fprintf(f, "#endif\n\n");
fprintf(f, "#ifndef HEIMDAL_WARN_UNUSED_RESULT_ATTRIBUTE\n");
fprintf(f, "#if __has_extension(warn_unused_result) || KRB5TYPES_REQUIRE_GNUC(3,3,0)\n");
fprintf(f, "#define HEIMDAL_WARN_UNUSED_RESULT_ATTRIBUTE __attribute__ ((__warn_unused_result__))\n");
fprintf(f, "#else\n");
fprintf(f, "#define HEIMDAL_WARN_UNUSED_RESULT_ATTRIBUTE\n");
fprintf(f, "#endif\n");
fprintf(f, "#endif\n\n");
fprintf(f, "#endif /* %s */\n", hb);

View File

@ -1,5 +1,5 @@
/***********************************************************************
* Copyright (c) 2009, Secure Endpoints Inc.
* Copyright (c) 2009-2016, Secure Endpoints Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -133,9 +133,6 @@ static const char *const rcsid[] = { (const char *)rcsid, "@(#)" msg }
/* Define to 1 if you have the `arc4random' function. */
/* #undef HAVE_ARC4RANDOM */
/* Define to 1 if you have the <arpa/ftp.h> header file. */
/* #undef HAVE_ARPA_FTP_H */
/* Define to 1 if you have the <arpa/inet.h> header file. */
/* #undef HAVE_ARPA_INET_H */
@ -303,6 +300,10 @@ static const char *const rcsid[] = { (const char *)rcsid, "@(#)" msg }
/* MSVC doesn't provide a <dlfcn.h>, but we implement it in lib/roken. */
#define HAVE_DLOPEN 1
/* Define to 1 if you have the `dladdr' function. */
/* MSVC doesn't provide a <dlfcn.h>, but we implement it in lib/roken. */
#define HAVE_DLADDR 1
/* Define to 1 if you have the `dn_expand' function. */
/* #undef HAVE_DN_EXPAND */
@ -648,8 +649,8 @@ static const char *const rcsid[] = { (const char *)rcsid, "@(#)" msg }
/* Define to 1 if you have the `openpty' function. */
/* #define HAVE_OPENPTY 1 */
/* define to use openssl's libcrypto */
/* #undef HAVE_OPENSSL */
/* define to 1 to use openssl's libcrypto as a (default) backend for libhcrypto */
/* #undef HAVE_HCRYPTO_W_OPENSSL */
/* Define to enable basic OSF C2 support. */
/* #undef HAVE_OSFC2 */
@ -917,30 +918,6 @@ static const char *const rcsid[] = { (const char *)rcsid, "@(#)" msg }
/* Define if struct tm has field tm_zone. */
/* #undef HAVE_STRUCT_TM_TM_ZONE */
/* Define if struct utmpx has field ut_exit. */
/* #undef HAVE_STRUCT_UTMPX_UT_EXIT */
/* Define if struct utmpx has field ut_syslen. */
/* #undef HAVE_STRUCT_UTMPX_UT_SYSLEN */
/* Define if struct utmp has field ut_addr. */
/* #define HAVE_STRUCT_UTMP_UT_ADDR 1 */
/* Define if struct utmp has field ut_host. */
/* #define HAVE_STRUCT_UTMP_UT_HOST 1 */
/* Define if struct utmp has field ut_id. */
/* #define HAVE_STRUCT_UTMP_UT_ID 1 */
/* Define if struct utmp has field ut_pid. */
/* #define HAVE_STRUCT_UTMP_UT_PID 1 */
/* Define if struct utmp has field ut_type. */
/* #define HAVE_STRUCT_UTMP_UT_TYPE 1 */
/* Define if struct utmp has field ut_user. */
/* #define HAVE_STRUCT_UTMP_UT_USER 1 */
/* define if struct winsize is declared in sys/termios.h */
/* #define HAVE_STRUCT_WINSIZE 1 */
@ -1162,12 +1139,6 @@ static const char *const rcsid[] = { (const char *)rcsid, "@(#)" msg }
/* Define to 1 if you have the <util.h> header file. */
/* #undef HAVE_UTIL_H */
/* Define to 1 if you have the <utmpx.h> header file. */
/* #define HAVE_UTMPX_H 1 */
/* Define to 1 if you have the <utmp.h> header file. */
/* #define HAVE_UTMP_H 1 */
/* Define to 1 if the system has the type `u_int16_t'. */
/* #define HAVE_U_INT16_T 1 */
@ -1236,15 +1207,6 @@ static const char *const rcsid[] = { (const char *)rcsid, "@(#)" msg }
/* define if struct winsize has ws_ypixel */
/* #define HAVE_WS_YPIXEL 1 */
/* Define to 1 if you have the `XauFileName' function. */
/* #undef HAVE_XAUFILENAME */
/* Define to 1 if you have the `XauReadAuth' function. */
/* #undef HAVE_XAUREADAUTH */
/* Define to 1 if you have the `XauWriteAuth' function. */
/* #undef HAVE_XAUWRITEAUTH */
/* Define to 1 if you have the `yp_get_default_domain' function. */
/* #undef HAVE_YP_GET_DEFAULT_DOMAIN */
@ -1263,9 +1225,6 @@ static const char *const rcsid[] = { (const char *)rcsid, "@(#)" msg }
/* Define if you have the `__progname' variable. */
/* #define HAVE___PROGNAME 1 */
/* Define if you have the hesiod package. */
/* #undef HESIOD */
/* Define if you are running IRIX 4. */
/* #undef IRIX4 */
@ -1359,9 +1318,6 @@ static const char *const rcsid[] = { (const char *)rcsid, "@(#)" msg }
/* Define if you don't want to use mmap. */
#define NO_MMAP 1
/* Define if EGD rand method is not defined */
#define NO_RAND_EGD_METHOD 1
/* Define if the Unix rand method is not defined */
#define NO_RAND_UNIX_METHOD 1

View File

@ -1,4 +1,4 @@
/* $NetBSD: crypto-headers.h,v 1.1.1.1 2011/04/13 18:14:34 elric Exp $ */
/* $NetBSD: crypto-headers.h,v 1.2 2017/01/28 21:31:44 christos Exp $ */
#ifndef __crypto_header__
#define __crypto_header__
@ -7,7 +7,8 @@
#error "need config.h"
#endif
#ifdef HAVE_OPENSSL
#ifdef HAVE_HCRYPTO_W_OPENSSL
#define OPENSSL_DES_LIBDES_COMPATIBILITY
@ -32,7 +33,7 @@
#define BN_is_negative(bn) ((bn)->neg != 0)
#endif
#else /* !HAVE_OPENSSL */
#else /* !HAVE_HCRYPTO_W_OPENSSL */
#ifdef KRB5
#include <krb5/krb5-types.h>
@ -50,10 +51,7 @@
#include <hcrypto/engine.h>
#include <hcrypto/pkcs12.h>
#include <hcrypto/hmac.h>
#include <hcrypto/ec.h>
#include <hcrypto/ecdsa.h>
#include <hcrypto/ecdh.h>
#endif /* HAVE_OPENSSL */
#endif
#endif /* __crypto_header__ */

View File

@ -25,6 +25,7 @@ CLEANFILES = \
rc4.h \
rsa.h \
sha.h \
ui.h
ui.h \
undef.h
EXTRA_DIST = NTMakefile

View File

@ -1,7 +1,7 @@
/* $NetBSD: heim_threads.h,v 1.1.1.3 2014/04/24 12:45:27 pettai Exp $ */
/* $NetBSD: heim_threads.h,v 1.2 2017/01/28 21:31:44 christos Exp $ */
/*
* Copyright (c) 2003 Kungliga Tekniska Högskolan
* Copyright (c) 2003-2016 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@ -48,6 +48,24 @@
#ifndef HEIM_THREADS_H
#define HEIM_THREADS_H 1
#ifdef _MSC_VER
#define HEIMDAL_THREAD_LOCAL __declspec(thread)
#else
#if defined(__clang__) || defined(__GNUC__) || defined(__SUNPRO_CC) || defined(__lint__)
#define HEIMDAL_THREAD_LOCAL __thread
#else
#error "thread-local attribute not defined for your compiler"
#endif /* clang or gcc */
#endif /* _MSC_VER */
/* For testing the for-Windows implementation of thread keys on non-Windows */
typedef unsigned long HEIM_PRIV_thread_key;
/* assume headers already included */
#if defined(__NetBSD__) && __NetBSD_Version__ >= 106120000 && __NetBSD_Version__< 299001200 && defined(ENABLE_PTHREAD_SUPPORT)
@ -83,6 +101,9 @@
#define HEIMDAL_getspecific(k) thr_getspecific(k)
#define HEIMDAL_key_delete(k) thr_keydelete(k)
#define HEIMDAL_THREAD_ID thr_t
#define HEIMDAL_THREAD_create(t,f,a) thr_create((t), 0, (f), (a))
#elif defined(ENABLE_PTHREAD_SUPPORT) && (!defined(__NetBSD__) || __NetBSD_Version__ >= 299001200)
#include <pthread.h>
@ -94,8 +115,8 @@
#define HEIMDAL_MUTEX_unlock(m) pthread_mutex_unlock(m)
#define HEIMDAL_MUTEX_destroy(m) pthread_mutex_destroy(m)
#define HEIMDAL_RWLOCK rwlock_t
#define HEIMDAL_RWLOCK_INITIALIZER RWLOCK_INITIALIZER
#define HEIMDAL_RWLOCK pthread_rwlock_t
#define HEIMDAL_RWLOCK_INITIALIZER PTHREAD_RWLOCK_INITIALIZER
#define HEIMDAL_RWLOCK_init(l) pthread_rwlock_init(l, NULL)
#define HEIMDAL_RWLOCK_rdlock(l) pthread_rwlock_rdlock(l)
#define HEIMDAL_RWLOCK_wrlock(l) pthread_rwlock_wrlock(l)
@ -104,11 +125,172 @@
#define HEIMDAL_RWLOCK_unlock(l) pthread_rwlock_unlock(l)
#define HEIMDAL_RWLOCK_destroy(l) pthread_rwlock_destroy(l)
#ifdef HEIM_BASE_MAINTAINER
#define HEIMDAL_thread_key unsigned long
#define HEIM_PRIV_thread_key HEIMDAL_thread_key
#define HEIMDAL_key_create(k,d,r) do { r = heim_w32_key_create(k,d); } while(0)
#define HEIMDAL_setspecific(k,s,r) do { r = heim_w32_setspecific(k,s); } while(0)
#define HEIMDAL_getspecific(k) (heim_w32_getspecific(k))
#define HEIMDAL_key_delete(k) (heim_w32_delete_key(k))
#else
#define HEIMDAL_thread_key pthread_key_t
#define HEIMDAL_key_create(k,d,r) do { r = pthread_key_create(k,d); } while(0)
#define HEIMDAL_setspecific(k,s,r) do { r = pthread_setspecific(k,s); } while(0)
#define HEIMDAL_getspecific(k) pthread_getspecific(k)
#define HEIMDAL_key_delete(k) pthread_key_delete(k)
#endif
#define HEIMDAL_THREAD_ID pthread_t
#define HEIMDAL_THREAD_create(t,f,a) pthread_create((t), 0, (f), (a))
#elif defined(_WIN32)
typedef struct heim_mutex {
HANDLE h;
} heim_mutex_t;
static inline int
heim_mutex_init(heim_mutex_t *m)
{
m->h = CreateSemaphore(NULL, 1, 1, NULL);
if (m->h == INVALID_HANDLE_VALUE)
return EAGAIN;
return 0;
}
static inline int
heim_mutex_lock(heim_mutex_t *m)
{
HANDLE h, new_h;
int created = 0;
h = InterlockedCompareExchangePointer(&m->h, m->h, m->h);
if (h == INVALID_HANDLE_VALUE || h == NULL) {
created = 1;
new_h = CreateSemaphore(NULL, 0, 1, NULL);
if (new_h == INVALID_HANDLE_VALUE)
return EAGAIN;
if (InterlockedCompareExchangePointer(&m->h, new_h, h) != h) {
created = 0;
CloseHandle(new_h);
}
}
if (!created)
WaitForSingleObject(m->h, INFINITE);
return 0;
}
static inline int
heim_mutex_unlock(heim_mutex_t *m)
{
if (ReleaseSemaphore(m->h, 1, NULL) == FALSE)
return EPERM;
return 0;
}
static inline int
heim_mutex_destroy(heim_mutex_t *m)
{
HANDLE h;
h = InterlockedCompareExchangePointer(&m->h, INVALID_HANDLE_VALUE, m->h);
if (h != INVALID_HANDLE_VALUE)
CloseHandle(h);
return 0;
}
#define HEIMDAL_MUTEX heim_mutex_t
#define HEIMDAL_MUTEX_INITIALIZER { INVALID_HANDLE_VALUE }
#define HEIMDAL_MUTEX_init(m) heim_mutex_init((m))
#define HEIMDAL_MUTEX_lock(m) heim_mutex_lock((m))
#define HEIMDAL_MUTEX_unlock(m) heim_mutex_unlock((m))
#define HEIMDAL_MUTEX_destroy(m) heim_mutex_destroy((m))
typedef struct heim_rwlock {
SRWLOCK lock;
int exclusive;
} heim_rwlock_t;
static inline int
heim_rwlock_init(heim_rwlock_t *l)
{
InitializeSRWLock(&l->lock);
l->exclusive = 0;
return 0;
}
static inline int
heim_rwlock_rdlock(heim_rwlock_t *l)
{
AcquireSRWLockShared(&l->lock);
return 0;
}
static inline int
heim_rwlock_wrlock(heim_rwlock_t *l)
{
AcquireSRWLockExclusive(&l->lock);
l->exclusive = 1;
return 0;
}
static inline int
heim_rwlock_tryrdlock(heim_rwlock_t *l)
{
if (TryAcquireSRWLockShared(&l->lock))
return 0;
return EBUSY;
}
static inline int
heim_rwlock_trywrlock(heim_rwlock_t *l)
{
if (TryAcquireSRWLockExclusive(&l->lock))
return 0;
return EBUSY;
}
static inline int
heim_rwlock_unlock(heim_rwlock_t *l)
{
if (l->exclusive) {
l->exclusive = 0;
ReleaseSRWLockExclusive(&(l)->lock);
} else {
ReleaseSRWLockShared(&(l)->lock);
}
return 0;
}
static inline int
heim_rwlock_destroy(heim_rwlock_t *l)
{
/* SRW locks cannot be destroyed so re-initialize */
InitializeSRWLock(&l->lock);
l->exclusive = 0;
return 0;
}
#define HEIMDAL_RWLOCK heim_rwlock_t
#define HEIMDAL_RWLOCK_INITIALIZER {SRWLOCK_INIT, 0}
#define HEIMDAL_RWLOCK_init(l) heim_rwlock_init((l))
#define HEIMDAL_RWLOCK_rdlock(l) heim_rwlock_rdlock((l))
#define HEIMDAL_RWLOCK_wrlock(l) heim_rwlock_wrlock((l))
#define HEIMDAL_RWLOCK_tryrdlock(l) heim_rwlock_tryrdlock((l))
#define HEIMDAL_RWLOCK_trywrlock(l) heim_rwlock_trywrlock((l))
#define HEIMDAL_RWLOCK_unlock(l) heim_rwlock_unlock((l))
#define HEIMDAL_RWLOCK_destroy(l) heim_rwlock_destroy((l))
#define HEIMDAL_thread_key unsigned long
#define HEIM_PRIV_thread_key HEIMDAL_thread_key
#define HEIMDAL_key_create(k,d,r) do { r = heim_w32_key_create(k,d); } while(0)
#define HEIMDAL_setspecific(k,s,r) do { r = heim_w32_setspecific(k,s); } while(0)
#define HEIMDAL_getspecific(k) (heim_w32_getspecific(k))
#define HEIMDAL_key_delete(k) (heim_w32_delete_key(k))
#define HEIMDAL_THREAD_ID DWORD
#define HEIMDAL_THREAD_create(t,f,a) \
((CreateThread(0, 0, (f), (a), 0, (t)) == INVALID_HANDLE_VALUE) ? EINVAL : 0)
#elif defined(HEIMDAL_DEBUG_THREADS)
@ -134,6 +316,9 @@
#define HEIMDAL_internal_thread_key 1
#define HEIMDAL_THREAD_ID int
#define HEIMDAL_THREAD_create(t,f,a) abort()
#else /* no thread support, no debug case */
#define HEIMDAL_MUTEX int
@ -153,6 +338,9 @@
#define HEIMDAL_RWLOCK_unlock(l) do { } while(0)
#define HEIMDAL_RWLOCK_destroy(l) do { } while(0)
#define HEIMDAL_THREAD_ID int
#define HEIMDAL_THREAD_create(t,f,a) abort()
#define HEIMDAL_internal_thread_key 1
#endif /* no thread support */
@ -174,4 +362,9 @@ typedef struct heim_thread_key {
#undef HEIMDAL_internal_thread_key
#endif /* HEIMDAL_internal_thread_key */
int heim_w32_key_create(HEIM_PRIV_thread_key *, void (*)(void *));
int heim_w32_delete_key(HEIM_PRIV_thread_key);
int heim_w32_setspecific(HEIM_PRIV_thread_key, void *);
void *heim_w32_getspecific(HEIM_PRIV_thread_key);
#endif /* HEIM_THREADS_H */

View File

@ -24,7 +24,7 @@ typedef ssize_t krb5_ssize_t;
#ifndef HEIMDAL_DEPRECATED
#if __has_extension(deprecated) || KRB5TYPES_REQUIRE_GNUC(3,1,0)
#define HEIMDAL_DEPRECATED __attribute__((deprecated))
#define HEIMDAL_DEPRECATED __attribute__ ((__deprecated__))
#elif defined(_MSC_VER) && (_MSC_VER>1200)
#define HEIMDAL_DEPRECATED __declspec(deprecated)
#else
@ -34,7 +34,7 @@ typedef ssize_t krb5_ssize_t;
#ifndef HEIMDAL_PRINTF_ATTRIBUTE
#if __has_extension(format) || KRB5TYPES_REQUIRE_GNUC(3,1,0)
#define HEIMDAL_PRINTF_ATTRIBUTE(x) __attribute__((format x))
#define HEIMDAL_PRINTF_ATTRIBUTE(x) __attribute__ ((__format__ x))
#else
#define HEIMDAL_PRINTF_ATTRIBUTE(x)
#endif
@ -42,7 +42,7 @@ typedef ssize_t krb5_ssize_t;
#ifndef HEIMDAL_NORETURN_ATTRIBUTE
#if __has_extension(noreturn) || KRB5TYPES_REQUIRE_GNUC(3,1,0)
#define HEIMDAL_NORETURN_ATTRIBUTE __attribute__((noreturn))
#define HEIMDAL_NORETURN_ATTRIBUTE __attribute__ ((__noreturn__))
#else
#define HEIMDAL_NORETURN_ATTRIBUTE
#endif
@ -50,12 +50,18 @@ typedef ssize_t krb5_ssize_t;
#ifndef HEIMDAL_UNUSED_ATTRIBUTE
#if __has_extension(unused) || KRB5TYPES_REQUIRE_GNUC(3,1,0)
#define HEIMDAL_UNUSED_ATTRIBUTE __attribute__((unused))
#define HEIMDAL_UNUSED_ATTRIBUTE __attribute__ ((__unused__))
#else
#define HEIMDAL_UNUSED_ATTRIBUTE
#endif
#endif
#ifndef HEIMDAL_WARN_UNUSED_RESULT_ATTRIBUTE
#if __has_extension(__warn_unused_result__) || KRB5TYPES_REQUIRE_GNUC(3,3,0)
#define HEIMDAL_WARN_UNUSED_RESULT_ATTRIBUTE __attribute__ ((__warn_unused_result__))
#endif
#endif
typedef int krb5_socket_t;
#endif /* __krb5_types_h__ */

View File

@ -2,13 +2,13 @@
include $(top_srcdir)/Makefile.am.common
AM_CPPFLAGS += $(INCLUDE_libintl) $(INCLUDE_readline) $(INCLUDE_hcrypto) -I$(srcdir)/../lib/krb5 -I$(top_builddir)/include/gssapi
AM_CPPFLAGS += $(INCLUDE_libintl) $(INCLUDE_readline) -I$(srcdir)/../lib/krb5 -I$(top_builddir)/include/gssapi
sbin_PROGRAMS = kadmin
bin_PROGRAMS = kadmin
libexec_PROGRAMS = kadmind
man_MANS = kadmin.8 kadmind.8
man_MANS = kadmin.1 kadmind.8
noinst_PROGRAMS = add_random_users
@ -65,7 +65,7 @@ LDADD_common = \
$(LIB_hcrypto) \
$(top_builddir)/lib/asn1/libasn1.la \
$(LIB_roken) \
$(DBLIB)
$(DB3LIB) $(DB1LIB) $(LMDBLIB) $(NDBMLIB)
kadmind_LDADD = $(top_builddir)/lib/kadm5/libkadm5srv.la \
../lib/gssapi/libgssapi.la \

View File

@ -1,4 +1,4 @@
/* $NetBSD: add-random-users.c,v 1.1.1.1 2011/04/13 18:14:34 elric Exp $ */
/* $NetBSD: add-random-users.c,v 1.2 2017/01/28 21:31:44 christos Exp $ */
/*
* Copyright (c) 2000 - 2001 Kungliga Tekniska Högskolan
@ -79,8 +79,7 @@ read_words (const char *filename, char ***ret_w)
}
static void
add_user (krb5_context context, void *kadm_handle,
unsigned nwords, char **words)
add_user (krb5_context ctx, void *hndl, unsigned nwords, char **words)
{
kadm5_principal_ent_rec princ;
char name[64];
@ -96,14 +95,14 @@ add_user (krb5_context context, void *kadm_handle,
mask = KADM5_PRINCIPAL;
memset(&princ, 0, sizeof(princ));
ret = krb5_parse_name(context, name, &princ.principal);
ret = krb5_parse_name(ctx, name, &princ.principal);
if (ret)
krb5_err(context, 1, ret, "krb5_parse_name");
krb5_err(ctx, 1, ret, "krb5_parse_name");
ret = kadm5_create_principal (kadm_handle, &princ, mask, name);
ret = kadm5_create_principal (hndl, &princ, mask, name);
if (ret)
krb5_err (context, 1, ret, "kadm5_create_principal");
kadm5_free_principal_ent(kadm_handle, &princ);
krb5_err (ctx, 1, ret, "kadm5_create_principal");
kadm5_free_principal_ent(hndl, &princ);
printf ("%s\n", name);
}
@ -112,37 +111,38 @@ add_users (const char *filename, unsigned n)
{
krb5_error_code ret;
int i;
void *kadm_handle;
krb5_context context;
void *hndl;
krb5_context ctx;
unsigned nwords;
char **words;
ret = krb5_init_context(&context);
ret = krb5_init_context(&ctx);
if (ret)
errx (1, "krb5_init_context failed: %d", ret);
ret = kadm5_s_init_with_password_ctx(context,
ret = kadm5_s_init_with_password_ctx(ctx,
KADM5_ADMIN_SERVICE,
NULL,
KADM5_ADMIN_SERVICE,
NULL, 0, 0,
&kadm_handle);
&hndl);
if(ret)
krb5_err(context, 1, ret, "kadm5_init_with_password");
krb5_err(ctx, 1, ret, "kadm5_init_with_password");
nwords = read_words (filename, &words);
for (i = 0; i < n; ++i)
add_user (context, kadm_handle, nwords, words);
kadm5_destroy(kadm_handle);
krb5_free_context(context);
add_user (ctx, hndl, nwords, words);
kadm5_destroy(hndl);
krb5_free_context(ctx);
free(words);
}
static int version_flag = 0;
static int help_flag = 0;
static struct getargs args[] = {
{ "version", 0, arg_flag, &version_flag },
{ "help", 0, arg_flag, &help_flag }
{ "version", 0, arg_flag, &version_flag, NULL, NULL },
{ "help", 0, arg_flag, &help_flag, NULL, NULL }
};
static void

View File

@ -1,4 +1,4 @@
/* $NetBSD: add_enctype.c,v 1.1.1.1 2011/04/13 18:14:34 elric Exp $ */
/* $NetBSD: add_enctype.c,v 1.2 2017/01/28 21:31:44 christos Exp $ */
/*
* Copyright (c) 1999-2006 Kungliga Tekniska Högskolan
@ -57,7 +57,7 @@ add_enctype(struct add_enctype_options*opt, int argc, char **argv)
return 0;
}
memset (&princ, 0, sizeof(princ));
memset(&princ, 0, sizeof(princ));
princ_name = argv[0];
n_etypes = argc - 1;
etypes = malloc (n_etypes * sizeof(*etypes));
@ -67,7 +67,7 @@ add_enctype(struct add_enctype_options*opt, int argc, char **argv)
}
argv++;
for (i = 0; i < n_etypes; ++i) {
ret = krb5_string_to_enctype (context, argv[i], &etypes[i]);
ret = krb5_string_to_enctype(context, argv[i], &etypes[i]);
if (ret) {
krb5_warnx (context, "bad enctype \"%s\"", argv[i]);
goto out2;
@ -76,20 +76,27 @@ add_enctype(struct add_enctype_options*opt, int argc, char **argv)
ret = krb5_parse_name(context, princ_name, &princ_ent);
if (ret) {
krb5_warn (context, ret, "krb5_parse_name %s", princ_name);
krb5_warn(context, ret, "krb5_parse_name %s", princ_name);
goto out2;
}
/* The principal might have zero keys, but it will still have a kvno! */
ret = kadm5_get_principal(kadm_handle, princ_ent, &princ,
KADM5_PRINCIPAL | KADM5_KEY_DATA);
KADM5_KVNO | KADM5_PRINCIPAL | KADM5_KEY_DATA);
if (ret) {
krb5_free_principal (context, princ_ent);
krb5_warnx (context, "no such principal: %s", princ_name);
krb5_free_principal(context, princ_ent);
krb5_warnx(context, "no such principal: %s", princ_name);
goto out2;
}
new_key_data = malloc((princ.n_key_data + n_etypes)
* sizeof(*new_key_data));
/* Check that we got key data */
if (kadm5_all_keys_are_bogus(princ.n_key_data, princ.key_data)) {
krb5_warnx(context, "user lacks get-keys privilege");
goto out;
}
new_key_data = calloc(princ.n_key_data + n_etypes,
sizeof(*new_key_data));
if (new_key_data == NULL) {
krb5_warnx (context, "out of memory");
goto out;
@ -100,6 +107,7 @@ add_enctype(struct add_enctype_options*opt, int argc, char **argv)
for (j = 0; j < n_etypes; ++j) {
if (etypes[j] == key->key_data_type[0]) {
/* XXX Should this be an error? The admin can del_enctype... */
krb5_warnx(context, "enctype %d already exists",
(int)etypes[j]);
free(new_key_data);
@ -115,7 +123,7 @@ add_enctype(struct add_enctype_options*opt, int argc, char **argv)
memset(&new_key_data[n], 0, sizeof(new_key_data[n]));
new_key_data[n].key_data_ver = 2;
new_key_data[n].key_data_kvno = 0;
new_key_data[n].key_data_kvno = princ.kvno;
ret = krb5_generate_random_keyblock (context, etypes[i], &keyblock);
if (ret) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: ank.c,v 1.1.1.2 2014/04/24 12:45:27 pettai Exp $ */
/* $NetBSD: ank.c,v 1.2 2017/01/28 21:31:44 christos Exp $ */
/*
* Copyright (c) 1997-2006 Kungliga Tekniska Högskolan
@ -70,6 +70,7 @@ add_one_principal (const char *name,
int rand_password,
int use_defaults,
char *password,
char *policy,
krb5_key_data *key_data,
const char *max_ticket_life,
const char *max_renewable_life,
@ -96,7 +97,7 @@ add_one_principal (const char *name,
ret = set_entry(context, &princ, &mask,
max_ticket_life, max_renewable_life,
expiration, pw_expiration, attributes);
expiration, pw_expiration, attributes, policy);
if (ret)
goto out;
@ -126,10 +127,18 @@ add_one_principal (const char *name,
} else if(password == NULL) {
char *princ_name;
char *prompt;
int aret;
krb5_unparse_name(context, princ_ent, &princ_name);
asprintf (&prompt, "%s's Password: ", princ_name);
ret = krb5_unparse_name(context, princ_ent, &princ_name);
if (ret)
goto out;
aret = asprintf (&prompt, "%s's Password: ", princ_name);
free (princ_name);
if (aret == -1) {
ret = ENOMEM;
krb5_set_error_message(context, ret, "out of memory");
goto out;
}
ret = UI_UTIL_read_pw_string (pwbuf, sizeof(pwbuf), prompt, 1);
free (prompt);
if (ret) {
@ -160,11 +169,18 @@ add_one_principal (const char *name,
free(new_keys);
kadm5_get_principal(kadm_handle, princ_ent, &princ,
KADM5_PRINCIPAL | KADM5_KVNO | KADM5_ATTRIBUTES);
krb5_free_principal(context, princ_ent);
princ_ent = princ.principal;
princ.attributes &= (~KRB5_KDB_DISALLOW_ALL_TIX);
/*
* Updating kvno w/o key data and vice-versa gives _kadm5_setup_entry()
* and _kadm5_set_keys2() headaches. But we used to, so we handle
* this in in those two functions. Might as well leave this code as
* it was then.
*/
princ.kvno = 1;
kadm5_modify_principal(kadm_handle, &princ,
KADM5_ATTRIBUTES | KADM5_KVNO);
kadm5_free_principal_ent(kadm_handle, &princ);
} else if (key_data) {
ret = kadm5_chpass_principal_with_key (kadm_handle, princ_ent,
3, key_data);
@ -173,9 +189,10 @@ add_one_principal (const char *name,
}
kadm5_get_principal(kadm_handle, princ_ent, &princ,
KADM5_PRINCIPAL | KADM5_ATTRIBUTES);
krb5_free_principal(context, princ_ent);
princ_ent = princ.principal;
princ.attributes &= (~KRB5_KDB_DISALLOW_ALL_TIX);
kadm5_modify_principal(kadm_handle, &princ, KADM5_ATTRIBUTES);
kadm5_free_principal_ent(kadm_handle, &princ);
} else if (rand_password) {
char *princ_name;
@ -184,8 +201,7 @@ add_one_principal (const char *name,
free (princ_name);
}
out:
if (princ_ent)
krb5_free_principal (context, princ_ent);
kadm5_free_principal_ent(kadm_handle, &princ); /* frees princ_ent */
if(default_ent)
kadm5_free_principal_ent (kadm_handle, default_ent);
if (password != NULL)
@ -247,6 +263,7 @@ add_new_key(struct add_options *opt, int argc, char **argv)
opt->random_password_flag,
opt->use_defaults_flag,
opt->password_string,
opt->policy_string,
kdp,
opt->max_ticket_life_string,
opt->max_renewable_life_string,

View File

@ -1,4 +1,4 @@
/* $NetBSD: check.c,v 1.1.1.2 2014/04/24 12:45:27 pettai Exp $ */
/* $NetBSD: check.c,v 1.2 2017/01/28 21:31:44 christos Exp $ */
/*
* Copyright (c) 2005 Kungliga Tekniska Högskolan
@ -53,7 +53,7 @@ get_check_entry(const char *name, kadm5_principal_ent_rec *ent)
}
memset(ent, 0, sizeof(*ent));
ret = kadm5_get_principal(kadm_handle, principal, ent, 0);
ret = kadm5_get_principal(kadm_handle, principal, ent, KADM5_ATTRIBUTES);
krb5_free_principal(context, principal);
if(ret)
return 1;
@ -186,6 +186,35 @@ check(void *opt, int argc, char **argv)
kadm5_free_principal_ent(kadm_handle, &ent);
/*
* Check default@REALM
*
* Check that disallow-all-tix is set on the default principal
* (or that the entry doesn't exists)
*/
if (asprintf(&p, "default@%s", realm) == -1) {
krb5_warn(context, errno, "asprintf");
goto fail;
}
ret = get_check_entry(p, &ent);
if (ret == 0) {
if ((ent.attributes & KRB5_KDB_DISALLOW_ALL_TIX) == 0) {
printf("default template entry is not disabled\n");
ret = EINVAL;
}
kadm5_free_principal_ent(kadm_handle, &ent);
} else {
ret = 0;
}
free(p);
if (ret)
goto fail;
/*
* Check for duplicate afs keys
*/

View File

@ -1,4 +1,4 @@
/* $NetBSD: cpw.c,v 1.1.1.2 2014/04/24 12:45:27 pettai Exp $ */
/* $NetBSD: cpw.c,v 1.2 2017/01/28 21:31:44 christos Exp $ */
/*
* Copyright (c) 1997 - 2004 Kungliga Tekniska Högskolan
@ -37,6 +37,7 @@
#include "kadmin-commands.h"
struct cpw_entry_data {
int keepold;
int random_key;
int random_password;
char *password;
@ -44,14 +45,15 @@ struct cpw_entry_data {
};
static int
set_random_key (krb5_principal principal)
set_random_key (krb5_principal principal, int keepold)
{
krb5_error_code ret;
int i;
krb5_keyblock *keys;
int num_keys;
ret = kadm5_randkey_principal(kadm_handle, principal, &keys, &num_keys);
ret = kadm5_randkey_principal_3(kadm_handle, principal, keepold, 0, NULL,
&keys, &num_keys);
if(ret)
return ret;
for(i = 0; i < num_keys; i++)
@ -61,13 +63,13 @@ set_random_key (krb5_principal principal)
}
static int
set_random_password (krb5_principal principal)
set_random_password (krb5_principal principal, int keepold)
{
krb5_error_code ret;
char pw[128];
random_password (pw, sizeof(pw));
ret = kadm5_chpass_principal(kadm_handle, principal, pw);
ret = kadm5_chpass_principal_3(kadm_handle, principal, keepold, 0, NULL, pw);
if (ret == 0) {
char *princ_name;
@ -81,18 +83,23 @@ set_random_password (krb5_principal principal)
}
static int
set_password (krb5_principal principal, char *password)
set_password (krb5_principal principal, char *password, int keepold)
{
krb5_error_code ret = 0;
char pwbuf[128];
int aret;
if(password == NULL) {
char *princ_name;
char *prompt;
krb5_unparse_name(context, principal, &princ_name);
asprintf(&prompt, "%s's Password: ", princ_name);
ret = krb5_unparse_name(context, principal, &princ_name);
if (ret)
return ret;
aret = asprintf(&prompt, "%s's Password: ", princ_name);
free (princ_name);
if (aret == -1)
return ENOMEM;
ret = UI_UTIL_read_pw_string(pwbuf, sizeof(pwbuf), prompt, 1);
free (prompt);
if(ret){
@ -101,18 +108,19 @@ set_password (krb5_principal principal, char *password)
password = pwbuf;
}
if(ret == 0)
ret = kadm5_chpass_principal(kadm_handle, principal, password);
ret = kadm5_chpass_principal_3(kadm_handle, principal, keepold, 0, NULL,
password);
memset(pwbuf, 0, sizeof(pwbuf));
return ret;
}
static int
set_key_data (krb5_principal principal, krb5_key_data *key_data)
set_key_data (krb5_principal principal, krb5_key_data *key_data, int keepold)
{
krb5_error_code ret;
ret = kadm5_chpass_principal_with_key (kadm_handle, principal,
3, key_data);
ret = kadm5_chpass_principal_with_key_3(kadm_handle, principal, keepold,
3, key_data);
return ret;
}
@ -122,13 +130,13 @@ do_cpw_entry(krb5_principal principal, void *data)
struct cpw_entry_data *e = data;
if (e->random_key)
return set_random_key (principal);
return set_random_key (principal, e->keepold);
else if (e->random_password)
return set_random_password (principal);
return set_random_password (principal, e->keepold);
else if (e->key_data)
return set_key_data (principal, e->key_data);
return set_key_data (principal, e->key_data, e->keepold);
else
return set_password (principal, e->password);
return set_password (principal, e->password, e->keepold);
}
int
@ -140,6 +148,7 @@ cpw_entry(struct passwd_options *opt, int argc, char **argv)
int num;
krb5_key_data key_data[3];
data.keepold = opt->keepold_flag;
data.random_key = opt->random_key_flag;
data.random_password = opt->random_password_flag;
data.password = opt->password_string;

View File

@ -1,4 +1,4 @@
/* $NetBSD: del.c,v 1.1.1.1 2011/04/13 18:14:35 elric Exp $ */
/* $NetBSD: del.c,v 1.2 2017/01/28 21:31:44 christos Exp $ */
/*
* Copyright (c) 1997 - 2004 Kungliga Tekniska Högskolan

View File

@ -1,4 +1,4 @@
/* $NetBSD: del_enctype.c,v 1.1.1.1 2011/04/13 18:14:35 elric Exp $ */
/* $NetBSD: del_enctype.c,v 1.2 2017/01/28 21:31:44 christos Exp $ */
/*
* Copyright (c) 1999-2006 Kungliga Tekniska Högskolan
@ -51,6 +51,7 @@ del_enctype(void *opt, int argc, char **argv)
krb5_key_data *new_key_data;
int n_etypes;
krb5_enctype *etypes;
krb5_key_data *key;
memset (&princ, 0, sizeof(princ));
princ_name = argv[0];
@ -83,6 +84,11 @@ del_enctype(void *opt, int argc, char **argv)
goto out2;
}
if (kadm5_all_keys_are_bogus(princ.n_key_data, princ.key_data)) {
krb5_warnx(context, "user lacks get-keys privilege");
goto out;
}
new_key_data = malloc(princ.n_key_data * sizeof(*new_key_data));
if (new_key_data == NULL && princ.n_key_data != 0) {
krb5_warnx (context, "out of memory");
@ -90,14 +96,15 @@ del_enctype(void *opt, int argc, char **argv)
}
for (i = 0, j = 0; i < princ.n_key_data; ++i) {
krb5_key_data *key = &princ.key_data[i];
int docopy = 1;
key = &princ.key_data[i];
for (k = 0; k < n_etypes; ++k)
for (k = 0; k < n_etypes; ++k) {
if (etypes[k] == key->key_data_type[0]) {
docopy = 0;
break;
}
}
if (docopy) {
new_key_data[j++] = *key;
} else {
@ -108,6 +115,10 @@ del_enctype(void *opt, int argc, char **argv)
}
free (princ.key_data);
if (j == 0) {
free(new_key_data);
new_key_data = NULL;
}
princ.n_key_data = j;
princ.key_data = new_key_data;

View File

@ -1,4 +1,4 @@
/* $NetBSD: dump.c,v 1.1.1.1 2011/04/13 18:14:35 elric Exp $ */
/* $NetBSD: dump.c,v 1.2 2017/01/28 21:31:44 christos Exp $ */
/*
* Copyright (c) 1997-2004 Kungliga Tekniska Högskolan
@ -44,32 +44,42 @@ dump(struct dump_options *opt, int argc, char **argv)
{
krb5_error_code ret;
FILE *f;
struct hdb_print_entry_arg parg;
HDB *db = NULL;
if(!local_flag) {
if (!local_flag) {
krb5_warnx(context, "dump is only available in local (-l) mode");
return 0;
}
db = _kadm5_s_get_db(kadm_handle);
if(argc == 0)
if (argc == 0)
f = stdout;
else
f = fopen(argv[0], "w");
if(f == NULL) {
if (f == NULL) {
krb5_warn(context, errno, "open: %s", argv[0]);
goto out;
}
ret = db->hdb_open(context, db, O_RDONLY, 0600);
if(ret) {
if (ret) {
krb5_warn(context, ret, "hdb_open");
goto out;
}
if (!opt->format_string || strcmp(opt->format_string, "Heimdal") == 0) {
parg.fmt = HDB_DUMP_HEIMDAL;
} else if (opt->format_string && strcmp(opt->format_string, "MIT") == 0) {
parg.fmt = HDB_DUMP_MIT;
fprintf(f, "kdb5_util load_dump version 5\n"); /* 5||6, either way */
} else {
krb5_errx(context, 1, "Supported dump formats: Heimdal and MIT");
}
parg.out = f;
hdb_foreach(context, db, opt->decrypt_flag ? HDB_F_DECRYPT : 0,
hdb_print_entry, f);
hdb_print_entry, &parg);
db->hdb_close(context, db);
out:

View File

@ -1,4 +1,4 @@
/* $NetBSD: ext.c,v 1.1.1.1 2011/04/13 18:14:35 elric Exp $ */
/* $NetBSD: ext.c,v 1.2 2017/01/28 21:31:44 christos Exp $ */
/*
* Copyright (c) 1997 - 2006 Kungliga Tekniska Högskolan
@ -38,6 +38,7 @@
struct ext_keytab_data {
krb5_keytab keytab;
int random_key_flag;
};
static int
@ -48,43 +49,76 @@ do_ext_keytab(krb5_principal principal, void *data)
struct ext_keytab_data *e = data;
krb5_keytab_entry *keys = NULL;
krb5_keyblock *k = NULL;
int i, n_k;
size_t i;
int n_k = 0;
uint32_t mask;
char *unparsed = NULL;
ret = kadm5_get_principal(kadm_handle, principal, &princ,
KADM5_PRINCIPAL|KADM5_KVNO|KADM5_KEY_DATA);
if(ret)
mask = KADM5_PRINCIPAL;
if (!e->random_key_flag)
mask |= KADM5_KVNO | KADM5_KEY_DATA;
ret = kadm5_get_principal(kadm_handle, principal, &princ, mask);
if (ret)
return ret;
if (princ.n_key_data) {
keys = malloc(sizeof(*keys) * princ.n_key_data);
ret = krb5_unparse_name(context, principal, &unparsed);
if (ret)
goto out;
if (!e->random_key_flag) {
if (princ.n_key_data == 0) {
krb5_warnx(context, "principal has no keys, or user lacks "
"get-keys privilege for %s", unparsed);
goto out;
}
/*
* kadmin clients and servers from master between 1.5 and 1.6
* can have corrupted a principal's keys in the HDB. If some
* are bogus but not all are, then that must have happened.
*
* If all keys are bogus then the server may be a pre-1.6,
* post-1.5 server and the client lacks get-keys privilege, or
* the keys are corrupted. We can't tell here.
*/
if (kadm5_all_keys_are_bogus(princ.n_key_data, princ.key_data)) {
krb5_warnx(context, "user lacks get-keys privilege for %s",
unparsed);
goto out;
}
if (kadm5_some_keys_are_bogus(princ.n_key_data, princ.key_data)) {
krb5_warnx(context, "some keys for %s are corrupted in the HDB",
unparsed);
}
keys = calloc(sizeof(*keys), princ.n_key_data);
if (keys == NULL) {
kadm5_free_principal_ent(kadm_handle, &princ);
krb5_clear_error_message(context);
return ENOMEM;
ret = krb5_enomem(context);
goto out;
}
for (i = 0; i < princ.n_key_data; i++) {
krb5_key_data *kd = &princ.key_data[i];
/* Don't extract bogus keys */
if (kadm5_all_keys_are_bogus(1, kd))
continue;
keys[i].principal = princ.principal;
keys[i].vno = kd->key_data_kvno;
keys[i].keyblock.keytype = kd->key_data_type[0];
keys[i].keyblock.keyvalue.length = kd->key_data_length[0];
keys[i].keyblock.keyvalue.data = kd->key_data_contents[0];
keys[i].timestamp = time(NULL);
n_k++;
}
n_k = princ.n_key_data;
} else {
} else if (e->random_key_flag) {
ret = kadm5_randkey_principal(kadm_handle, principal, &k, &n_k);
if (ret) {
kadm5_free_principal_ent(kadm_handle, &princ);
return ret;
}
keys = malloc(sizeof(*keys) * n_k);
if (ret)
goto out;
keys = calloc(sizeof(*keys), n_k);
if (keys == NULL) {
kadm5_free_principal_ent(kadm_handle, &princ);
krb5_clear_error_message(context);
return ENOMEM;
ret = krb5_enomem(context);
goto out;
}
for (i = 0; i < n_k; i++) {
keys[i].principal = principal;
@ -94,19 +128,24 @@ do_ext_keytab(krb5_principal principal, void *data)
}
}
for(i = 0; i < n_k; i++) {
if (n_k == 0)
krb5_warn(context, ret, "no keys written to keytab for %s", unparsed);
for (i = 0; i < n_k; i++) {
ret = krb5_kt_add_entry(context, e->keytab, &keys[i]);
if(ret)
krb5_warn(context, ret, "krb5_kt_add_entry(%d)", i);
if (ret)
krb5_warn(context, ret, "krb5_kt_add_entry(%lu)", (unsigned long)i);
}
out:
kadm5_free_principal_ent(kadm_handle, &princ);
if (k) {
memset(k, 0, n_k * sizeof(*k));
for (i = 0; i < n_k; i++)
memset(k[i].keyvalue.data, 0, k[i].keyvalue.length);
free(k);
}
if (keys)
free(keys);
kadm5_free_principal_ent(kadm_handle, &princ);
free(unparsed);
free(keys);
return 0;
}
@ -127,6 +166,8 @@ ext_keytab(struct ext_keytab_options *opt, int argc, char **argv)
return 1;
}
data.random_key_flag = opt->random_key_flag;
for(i = 0; i < argc; i++) {
ret = foreach_principal(argv[i], do_ext_keytab, "ext", &data);
if (ret)

Some files were not shown because too many files have changed in this diff Show More