From 824e15df882d8dda930a645e180887520c290ef2 Mon Sep 17 00:00:00 2001 From: no author Date: Wed, 9 Feb 2000 02:45:27 +0000 Subject: This commit was manufactured by cvs2svn to create tag 'V1_0_7_BETA1' git-svn-id: svn://anonsvn.mit.edu/krb5/tags/V1_0_7_BETA1@12029 dc483132-0cff-0310-8789-dd5450dbe970 --- README | 277 +++-- doc/.cvsignore | 95 +- doc/ChangeLog | 164 +++ doc/Makefile | 8 +- doc/admin.texinfo | 815 +++++++++++---- doc/api/ChangeLog | 6 + doc/api/krb5.tex | 2 +- doc/build.texinfo | 146 +-- doc/copyright.texinfo | 34 +- doc/definitions.texinfo | 4 +- doc/install.texinfo | 132 ++- doc/krb425.texinfo | 38 +- doc/krb5-protocol/krb5.constants | 10 +- doc/send-pr.texinfo | 221 ++-- doc/user-guide.texinfo | 103 +- src/ChangeLog | 25 + src/Makefile.in | 34 +- src/aclocal.m4 | 2 +- src/appl/bsd/ChangeLog | 171 ++++ src/appl/bsd/Makefile.in | 2 +- src/appl/bsd/configure.in | 4 +- src/appl/bsd/forward.c | 20 +- src/appl/bsd/kcmd.c | 68 +- src/appl/bsd/klogind.M | 20 + src/appl/bsd/krcp.c | 13 +- src/appl/bsd/krlogin.c | 8 +- src/appl/bsd/krlogind.c | 113 ++- src/appl/bsd/krshd.c | 166 ++- src/appl/bsd/kshd.M | 14 + src/appl/bsd/login.M | 2 +- src/appl/bsd/login.c | 106 +- src/appl/bsd/loginpaths.h | 15 + src/appl/bsd/v4rcp.c | 116 +-- src/appl/gss-sample/ChangeLog | 11 + src/appl/gss-sample/gss-client.c | 2 +- src/appl/gss-sample/gss-server.c | 1 + src/appl/gssftp/ftp/ChangeLog | 49 + src/appl/gssftp/ftp/Makefile.in | 2 +- src/appl/gssftp/ftp/cmds.c | 4 +- src/appl/gssftp/ftp/ftp.c | 10 +- src/appl/gssftp/ftp/glob.c | 13 +- src/appl/gssftp/ftp/secure.c | 4 +- src/appl/gssftp/ftpd/ChangeLog | 105 ++ src/appl/gssftp/ftpd/Makefile.in | 10 +- src/appl/gssftp/ftpd/configure.in | 13 +- src/appl/gssftp/ftpd/ftpcmd.y | 81 +- src/appl/gssftp/ftpd/ftpd.M | 13 + src/appl/gssftp/ftpd/ftpd.c | 164 ++- src/appl/gssftp/ftpd/logwtmp.c | 2 +- src/appl/gssftp/ftpd/popen.c | 12 +- src/appl/popper/Imakefile | 93 -- src/appl/sample/sserver/ChangeLog | 7 + src/appl/sample/sserver/sserver.M | 13 +- src/appl/simple/client/ChangeLog | 5 + src/appl/simple/client/sim_client.c | 4 +- src/appl/simple/server/ChangeLog | 5 + src/appl/simple/server/sim_server.c | 2 +- src/appl/telnet/libtelnet/ChangeLog | 13 + src/appl/telnet/libtelnet/forward.c | 11 +- src/appl/telnet/libtelnet/kerberos5.c | 4 +- src/appl/telnet/telnet/ChangeLog | 32 + src/appl/telnet/telnet/commands.c | 26 +- src/appl/telnet/telnet/configure.in | 11 +- src/appl/telnet/telnetd/ChangeLog | 67 ++ src/appl/telnet/telnetd/configure.in | 14 +- src/appl/telnet/telnetd/ext.h | 2 +- src/appl/telnet/telnetd/state.c | 18 +- src/appl/telnet/telnetd/sys_term.c | 15 +- src/appl/telnet/telnetd/telnetd.8 | 15 +- src/appl/telnet/telnetd/telnetd.c | 87 +- src/appl/telnet/telnetd/termios-tn.c | 3 + src/appl/user_user/ChangeLog | 5 + src/appl/user_user/client.c | 3 +- src/clients/kinit/ChangeLog | 4 + src/clients/kinit/kinit.M | 2 +- src/clients/klist/ChangeLog | 4 + src/clients/klist/klist.M | 2 +- src/clients/ksu/ChangeLog | 71 ++ src/clients/ksu/Makefile.in | 12 +- src/clients/ksu/authorization.c | 65 +- src/clients/ksu/ccache.c | 4 +- src/clients/ksu/configure.in | 17 +- src/clients/ksu/heuristic.c | 14 +- src/clients/ksu/krb_auth_su.c | 39 +- src/clients/ksu/ksu.h | 6 +- src/clients/ksu/main.c | 98 +- src/clients/ksu/setenv.c | 158 +++ src/clients/ksu/xmalloc.c | 68 ++ src/config-files/ChangeLog | 5 + src/config-files/kdc.conf | 8 +- src/config/ChangeLog | 5 + src/config/post.in | 2 +- src/include/ChangeLog | 5 + src/include/k5-int.h | 6 +- src/include/kerberosIV/ChangeLog | 4 + src/include/kerberosIV/Makefile.in | 3 +- src/include/krb5/k5-config.h | 311 ------ src/kadmin.v4/server/ChangeLog | 11 + src/kadmin.v4/server/kadm_ser_wrap.c | 2 +- src/kadmin.v4/server/kadm_server.c | 4 +- src/kadmin/cli/ChangeLog | 10 + src/kadmin/cli/kadmin.M | 17 +- src/kadmin/cli/kadmin.c | 2 +- src/kadmin/dbutil/ChangeLog | 5 + src/kadmin/dbutil/loadv4.c | 3 +- src/kadmin/passwd/ChangeLog | 24 + src/kadmin/passwd/configure.in | 22 +- src/kadmin/passwd/kpasswd.c | 2 +- src/kadmin/passwd/unit-test/Makefile.in | 6 +- src/kadmin/passwd/unit-test/kpasswd.0/changing.exp | 2 +- src/kadmin/server/ChangeLog | 11 + src/kadmin/server/ovsec_kadmd.c | 69 +- src/kadmin/testing/scripts/ChangeLog | 4 + src/kadmin/testing/scripts/save_files.sh | 2 +- src/kadmin/testing/util/ChangeLog | 13 + src/kadmin/testing/util/tcl_kadm5.c | 1 - src/kadmin/testing/util/tcl_ovsec_kadm.c | 1 - src/kadmin/testing/util/test.c | 4 +- src/kadmin/v4server/ChangeLog | 11 + src/kadmin/v4server/kadm_ser_wrap.c | 2 +- src/kadmin/v4server/kadm_server.c | 4 +- src/kadmin/v4server/unit-test/ChangeLog | 5 + src/kadmin/v4server/unit-test/lib/helpers.exp | 2 +- src/kdc/ChangeLog | 108 ++ src/kdc/dispatch.c | 4 +- src/kdc/do_as_req.c | 2 + src/kdc/do_tgs_req.c | 7 +- src/kdc/kdc_preauth.c | 22 +- src/kdc/kdc_util.c | 180 +++- src/kdc/kdc_util.h | 6 +- src/kdc/kerberos_v4.c | 32 +- src/kdc/main.c | 6 +- src/kdc/replay.c | 42 +- src/krb524/ChangeLog | 11 + src/krb524/cnv_tkt_skey.c | 2 +- src/krb524/krb524d.c | 2 +- src/lib/ChangeLog | 12 + src/lib/Makefile.in | 20 +- src/lib/crypto/ChangeLog | 14 + src/lib/crypto/configure.in | 68 +- src/lib/crypto/cryptoconf.c | 15 +- src/lib/des425/ChangeLog | 4 + src/lib/des425/configure.in | 2 +- src/lib/gssapi/ChangeLog | 4 + src/lib/gssapi/configure.in | 2 +- src/lib/gssapi/generic/ChangeLog | 50 + src/lib/gssapi/generic/Makefile.in | 8 +- src/lib/gssapi/generic/disp_major_status.c | 25 +- src/lib/gssapi/generic/gssapi.hin | 24 + src/lib/gssapi/generic/gssapi_generic.c | 10 + src/lib/gssapi/generic/gssapi_generic.h | 2 + src/lib/gssapi/generic/util_buffer.c | 4 +- src/lib/gssapi/generic/util_oid.c | 29 +- src/lib/gssapi/krb5/ChangeLog | 145 +++ src/lib/gssapi/krb5/Makefile.in | 6 + src/lib/gssapi/krb5/accept_sec_context.c | 42 +- src/lib/gssapi/krb5/acquire_cred.c | 32 +- src/lib/gssapi/krb5/canon_name.c | 41 + src/lib/gssapi/krb5/delete_sec_context.c | 4 +- src/lib/gssapi/krb5/duplicate_name.c | 65 ++ src/lib/gssapi/krb5/export_name.c | 87 ++ src/lib/gssapi/krb5/get_tkt_flags.c | 2 +- src/lib/gssapi/krb5/gssapiP_krb5.h | 27 +- src/lib/gssapi/krb5/gssapi_krb5.c | 24 +- src/lib/gssapi/krb5/gssapi_krb5.h | 2 + src/lib/gssapi/krb5/import_name.c | 53 +- src/lib/gssapi/krb5/import_sec_context.c | 21 + src/lib/gssapi/krb5/indicate_mechs.c | 8 +- src/lib/gssapi/krb5/init_sec_context.c | 89 +- src/lib/gssapi/krb5/inq_names.c | 8 + src/lib/gssapi/krb5/krb5_gss_glue.c | 36 + src/lib/gssapi/krb5/rel_cred.c | 8 +- src/lib/gssapi/krb5/ser_sctx.c | 4 +- src/lib/gssapi/krb5/wrap_size_limit.c | 23 +- src/lib/gssapi/mechglue/ChangeLog | 4 + src/lib/gssapi/mechglue/configure.in | 2 +- src/lib/kadm5/srv/ChangeLog | 22 + src/lib/kadm5/srv/Makefile.in | 2 +- src/lib/kadm5/srv/server_acl.c | 3 +- src/lib/kadm5/srv/svr_principal.c | 11 +- src/lib/kadm5/unit-test/ChangeLog | 4 + src/lib/kadm5/unit-test/Makefile.in | 5 +- src/lib/kdb/ChangeLog | 10 + src/lib/kdb/configure.in | 2 +- src/lib/kdb/keytab.c | 37 +- src/lib/krb4/ChangeLog | 50 + src/lib/krb4/configure.in | 2 +- src/lib/krb4/g_cnffile.c | 32 +- src/lib/krb4/g_krbhst.c | 4 +- src/lib/krb4/g_krbrlm.c | 6 +- src/lib/krb4/klog.c | 4 +- src/lib/krb4/log.c | 8 +- src/lib/krb4/realmofhost.c | 18 +- src/lib/krb4/stime.c | 4 +- src/lib/krb4/tf_util.c | 126 ++- src/lib/krb5/ChangeLog | 4 + src/lib/krb5/asn.1/ChangeLog | 27 + src/lib/krb5/asn.1/asn1_encode.c | 12 +- src/lib/krb5/asn.1/asn1_k_decode.c | 25 +- src/lib/krb5/asn.1/asn1buf.c | 6 +- src/lib/krb5/configure.in | 2 +- src/lib/krb5/error_tables/ChangeLog | 9 + src/lib/krb5/error_tables/asn1_err.et | 1 + src/lib/krb5/error_tables/krb5_err.et | 1 + src/lib/krb5/keytab/file/ChangeLog | 5 + src/lib/krb5/keytab/file/ktf_g_ent.c | 14 +- src/lib/krb5/krb/ChangeLog | 129 +++ src/lib/krb5/krb/Makefile.in | 4 +- src/lib/krb5/krb/brand.c | 15 + src/lib/krb5/krb/chk_trans.c | 24 +- src/lib/krb5/krb/conv_princ.c | 34 + src/lib/krb5/krb/deltat.c | 1063 ++++++++++++++++++++ src/lib/krb5/krb/fwd_tgt.c | 7 +- src/lib/krb5/krb/init_ctx.c | 28 +- src/lib/krb5/krb/preauth.c | 38 +- src/lib/krb5/krb/recvauth.c | 26 +- src/lib/krb5/krb/send_tgs.c | 3 +- src/lib/krb5/krb/sendauth.c | 5 +- src/lib/krb5/krb/str_conv.c | 553 ++++------ src/lib/krb5/krb/strftime.c | 415 ++++++++ src/lib/krb5/krb/strptime.c | 386 +++++++ src/lib/krb5/krb/t_kerb.c | 22 + src/lib/krb5/krb/t_ref_kerb.out | 2 +- src/lib/krb5/os/ChangeLog | 16 + src/lib/krb5/os/locate_kdc.c | 3 +- src/lib/krb5/os/promptusr.c | 2 +- src/lib/krb5/rcache/ChangeLog | 5 + src/lib/krb5/rcache/rc_io.c | 2 +- src/lib/krb5_16.def | 65 ++ src/lib/libkrb5.def | 65 -- src/lib/rpc/ChangeLog | 34 + src/lib/rpc/clnt_generic.c | 2 +- src/lib/rpc/clnt_simple.c | 3 +- src/lib/rpc/configure.in | 6 +- src/lib/rpc/get_myaddress.c | 41 + src/lib/rpc/getrpcport.c | 2 +- src/lib/rpc/svc.c | 27 +- src/lib/rpc/svc_auth_gssapi.c | 37 +- src/lib/rpc/types.hin | 4 +- src/lib/rpc/unit-test/ChangeLog | 4 + src/lib/rpc/unit-test/Makefile.in | 6 +- src/mac/ChangeLog | 8 + src/mac/Makefile.tmpl | 6 +- src/mac/SAP/GSSforSAP.r | 13 + src/mac/gss-sample/ChangeLog | 7 + src/mac/gss-sample/gss-client.c | 2 +- src/mac/libraries/ChangeLog | 6 + src/mac/libraries/KerberosHeaders.h | 6 +- src/mac/mkbindirs.sh | 13 + src/mac/version.r | 13 +- src/patchlevel.h | 3 +- src/slave/ChangeLog | 17 + src/slave/kprop.M | 8 +- src/slave/kprop.c | 2 +- src/slave/kpropd.M | 16 +- src/slave/kslave_update | 14 +- src/tests/dejagnu/ChangeLog | 4 + src/tests/dejagnu/Makefile.in | 5 +- src/tests/dejagnu/config/ChangeLog | 16 + src/tests/dejagnu/config/default.exp | 27 +- src/tests/dejagnu/krb-standalone/ChangeLog | 5 + src/tests/dejagnu/krb-standalone/gssftp.exp | 2 +- src/tests/gssapi/ChangeLog | 6 + src/tests/gssapi/t_imp_name.c | 6 +- src/tests/misc/test_getsockname.c | 2 +- src/util/ChangeLog | 24 + src/util/db2/ChangeLog | 10 + src/util/db2/hash/dbm.c | 4 +- src/util/db2/hash/hash.c | 12 +- src/util/db2/hash/hash.h | 2 +- src/util/db2/obj/ChangeLog | 4 + src/util/db2/obj/Makefile.in | 4 - src/util/et/ChangeLog | 4 + src/util/et/configure.in | 2 +- src/util/libupdate.sh | 4 +- src/util/makeshlib.sh | 7 +- src/util/mkrel | 131 ++- src/util/profile/ChangeLog | 18 + src/util/profile/prof_parse.c | 113 ++- src/util/profile/prof_tree.c | 20 +- src/util/pty/ChangeLog | 94 ++ src/util/pty/Makefile.in | 7 +- src/util/pty/cleanup.c | 2 + src/util/pty/configure.in | 1 + src/util/pty/getpty.c | 62 +- src/util/pty/libpty.h | 2 + src/util/pty/open_slave.c | 2 + src/util/pty/pty_err.et | 3 +- src/util/pty/sane_hostname.c | 99 ++ src/util/pty/update_utmp.c | 25 +- src/util/pty/update_wtmp.c | 14 +- src/util/send-pr/Makefile.in | 28 +- src/util/send-pr/send-pr.sh | 26 +- src/windows/cns/ChangeLog | 8 + src/windows/cns/Makefile.in | 14 +- src/windows/cns/cns.c | 4 + src/windows/cns/cns.def | 9 - src/windows/cns/krb5.def | 9 + src/windows/gss/ChangeLog | 8 +- src/windows/gss/gss-client.c | 2 +- src/windows/wintel/ChangeLog | 18 + src/windows/wintel/Makefile.in | 2 +- src/windows/wintel/auth.c | 2 +- src/windows/wintel/screen.c | 17 +- 304 files changed, 8395 insertions(+), 2670 deletions(-) delete mode 100644 src/appl/popper/Imakefile create mode 100644 src/clients/ksu/setenv.c create mode 100644 src/clients/ksu/xmalloc.c delete mode 100644 src/include/krb5/k5-config.h create mode 100644 src/lib/gssapi/krb5/canon_name.c create mode 100644 src/lib/gssapi/krb5/duplicate_name.c create mode 100644 src/lib/gssapi/krb5/export_name.c create mode 100644 src/lib/krb5/krb/brand.c create mode 100644 src/lib/krb5/krb/deltat.c create mode 100644 src/lib/krb5/krb/strftime.c create mode 100644 src/lib/krb5/krb/strptime.c create mode 100644 src/lib/krb5_16.def delete mode 100644 src/lib/libkrb5.def create mode 100644 src/mac/mkbindirs.sh create mode 100644 src/util/pty/sane_hostname.c delete mode 100644 src/windows/cns/cns.def create mode 100644 src/windows/cns/krb5.def diff --git a/README b/README index cc47bb5..43e70c9 100644 --- a/README +++ b/README @@ -1,51 +1,80 @@ -Beta test distribution READ-ME file. ------------------------------------ + Kerberos Version 5, Release 1.0 -THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR -IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED -WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + Release Notes -Files are copyright MIT, Cygnus Support, OpenVision, Oracle, Sun Soft, -and others. + The MIT Kerberos Team -The following copyright and permission notice applies to the -OpenVision Kerberos Administration system located in kadmin/create, -kadmin/dbutil, kadmin/server, lib/kadm, and portions of lib/rpc: +Unpacking the Source Distribution +--------------------------------- - Copyright, OpenVision Technologies, Inc., 1996, All Rights Reserved - - WARNING: Retrieving the OpenVision Kerberos Administration system - source code, as described below, indicates your acceptance of the - following terms. If you do not agree to the following terms, do not - retrieve the OpenVision Kerberos administration system. - - You may freely use and distribute the Source Code and Object Code - compiled from it, but this Source Code is provided to you "AS IS" - EXCLUSIVE OF ANY WARRANTY, INCLUDING, WITHOUT LIMITATION, ANY - WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, OR - ANY OTHER WARRANTY, WHETHER EXPRESS OR IMPLIED. IN NO EVENT WILL - OPENVISION HAVE ANY LIABILITY FOR ANY LOST PROFITS, LOSS OF DATA OR - COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY - SPECIAL, INDIRECT, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS - AGREEMENT, INCLUDING, WITHOUT LIMITATION, THOSE RESULTING FROM THE USE - OF THE SOURCE CODE, OR THE FAILURE OF THE SOURCE CODE TO PERFORM, OR - FOR ANY OTHER REASON. - - OpenVision retains all rights, title, and interest in the donated - Source Code. With respect to OpenVision's copyrights in the donated - Source Code, OpenVision also retains rights to derivative works - of the Source Code whether created by OpenVision or a third party. - - OpenVision Technologies, Inc. has donated this Kerberos - Administration system to MIT for inclusion in the standard - Kerberos 5 distribution. This donation underscores our - commitment to continuing Kerberos technology development - and our gratitude for the valuable work which has been - performed by MIT and the Kerberos community. +The source distribution of Kerberos 5 comes in three gzipped tarfiles, +krb5-1.0.src.tar.gz, krb5-1.0.doc.tar.gz, and krb5-1.0.crypto.tar.gz. +The krb5-1.0.doc.tar.gz contains the doc/ directory and this README +file. The krb5-1.0.src.tar.gz contains the src/ directory and this +README file, except for the crypto library sources, which are in +krb5-1.0.crypto.tar.gz. + +Instruction on how to extract the entire distribution follow. These +directions assume that you want to extract into a directory called +DIST. + +If you have the GNU tar program and gzip installed, you can simply do: + + mkdir DIST + cd DIST + gtar zxpf krb5-1.0.src.tar.gz + gtar zxpf krb5-1.0.crypto.tar.gz + gtar zxpf krb5-1.0.doc.tar.gz +If you don't have GNU tar, you will need to get the FSF gzip +distribution and use gzcat: + mkdir DIST + cd DIST + gzcat krb5-1.0.src.tar.gz | tar xpf - + gzcat krb5-1.0.crypto.tar.gz | tar xpf - + gzcat krb5-1.0.doc.tar.gz | tar xpf - -Now, with that out of the way, let me point you to a few things: +Both of these methods will extract the sources into DIST/krb5-1.0/src +and the documentation into DIST/krb5-1.0/doc. + +Unpacking the Binary Distribution +--------------------------------- + +Binary distributions of Kerberos V5 are provided merely as convenience +to those people who wish to try out Kerberos V5 without needing to do +a full compile of Kerberos. + +MIT and the MIT Kerberos V5 development team make no guarantees that +we will continue to supply binary distributions for future releases of +Kerberos V5, or for any operating system/platform in particular. +These binary distributions have been prepared by members of the MIT +Kerberos V5 development team, or by volunteers who have graciously +agreed to test the pre-release snapshot. Each binary build is PGP +signed by the person who prepared the binary distribution for that +particular platform. + +While the binary distribution is *supposed* to correspond exactly to +the 1.0 Kerberos V5 source release, you have no way of knowing whether +the person who prepared the binary release might have inserted a +trojan horse, or a trapdoor. For all you know, the binary +distribution might be mailing all of your Kerberos keys to +kremvax!boris. (The same is true for the source distribution, but at +least you can audit the code yourself!) + +For this reason, if you are planning on using Kerberos V5 in +production, we strongly suggest that you obtain the source +distribution and compile it from source yourself. + +The binary distributions have been compiled so that they will install +in /usr/local. To install, su to root and and type the command: + + cd /usr/local + gunzip < /tmp/krb5-1.0..tar.gz | tar xvf - + + +Building and Installing Kerberos 5 +---------------------------------- The first file you should look at is doc/install.ps; it contains the notes for building and installing Kerberos 5. The info file @@ -58,32 +87,168 @@ which contain the system administrator's guide, and the user's guide, respectively. They are also available as info files kerberos-admin.info and krb5-user.info, respectively. ->> << ->> Please report any problems/bugs/comments to 'krb5-bugs@mit.edu' << ->> << +Reporting Bugs +-------------- + +Please report any problems/bugs/comments using the krb5-send-pr +program. The krb5-send-pr program will be installed in the sbin +directory once you have successfully compiled and installed Kerberos +V5 (or if you have installed one of our binary distributions). + +If you are not able to use krb5-send-pr because you haven't been able +compile and install Kerberos V5 on any platform, you may send mail to +krb5-bugs@mit.edu. + +Notes and Major Changes +----------------------- + +* We are now using the GNATS system to track bug reports for Kerberos +V5. It is therefore helpful for people to use the krb5-send-pr +program when reporting bugs. The old interface of sending mail to +krb5-bugs@mit.edu will still work; however, bug reports sent in this +fashion may experience a delay in being processed. + +* The default keytab name has changed from /etc/v5srvtab to +/etc/krb5.keytab. + +* login.krb5 no longer defaults to getting krb4 tickets. + +* The Windows (win16) DLL, LIBKRB5.DLL, has been renamed to +KRB5_16.DLL. This change was necessary to distinguish it from the +win32 version, which will be named KRB5_32.DLL. Note that the +GSSAPI.DLL file has not been renamed, because this name was specified +in a draft standard for the Windows 16 GSSAPI bindings. (The 32-bit +version of the GSSAPI DLL will be named GSSAPI32.DLL.) + +* The directory structure used for installations has changed. In +particular, files previously located in $prefix/lib/krb5kdc are now +normally located in $sysconfdir/krb5kdc. With the normal configure +options, this means the KDC database goes in /usr/local/var/krb5kdc by +default. If you wish to have the old behavior, then you would use a +configure line like the following: + + configure --prefix=/usr/local --sysconfdir=/usr/local/lib +* kshd has been modified to accept krb4 encrypted rcp connections; for +this to work, the v4rcp program must be in the bin directory. +* The gssrpc library has symbol collisions with the rpc library in +some of the libcs in certain operating systems without shared +libraries, notably some ports of NetBSD and MkLinux. For those +platforms which have rpc in libc and also contain NIS in libc, +compiling with static libraries will not work because of this +conflict. NetBSD users can either upgrade to the current tree, which +includes shared libraries for more ports, choose not to build kadmind +or kadmin, or recompile NetBSD without NIS support. MkLinux users +must either recompile without NIS or not build the administration +system. + +Copyright Notice and Legal Administrivia +---------------------------------------- + +Copyright (C) 1996 by the Massachusetts Institute of Technology. + +All rights reserved. + +Export of this software from the United States of America may require +a specific license from the United States Government. It is the +responsibility of any person or organization contemplating export to +obtain such a license before exporting. + +WITHIN THAT CONSTRAINT, permission to use, copy, modify, and +distribute this software and its documentation for any purpose and +without fee is hereby granted, provided that the above copyright +notice appear in all copies and that both that copyright notice and +this permission notice appear in supporting documentation, and that +the name of M.I.T. not be used in advertising or publicity pertaining +to distribution of the software without specific, written prior +permission. M.I.T. makes no representations about the suitability of +this software for any purpose. It is provided "as is" without express +or implied warranty. + +THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED +WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + +Individual source code files are copyright MIT, Cygnus Support, +OpenVision, Oracle, Sun Soft, and others. + +Project Athena, Athena, Athena MUSE, Discuss, Hesiod, Kerberos, Moira, +and Zephyr are trademarks of the Massachusetts Institute of Technology +(MIT). No commercial use of these trademarks may be made without +prior written permission of MIT. + +"Commercial use" means use of a name in a product or other for-profit +manner. It does NOT prevent a commercial firm from referring to the +MIT trademarks in order to convey information (although in doing so, +recognition of their trademark status should be given). + +The following copyright and permission notice applies to the +OpenVision Kerberos Administration system located in kadmin/create, +kadmin/dbutil, kadmin/passwd, kadmin/server, lib/kadm5, and portions +of lib/rpc: + + Copyright, OpenVision Technologies, Inc., 1996, All Rights Reserved + + WARNING: Retrieving the OpenVision Kerberos Administration system + source code, as described below, indicates your acceptance of the + following terms. If you do not agree to the following terms, do not + retrieve the OpenVision Kerberos administration system. + + You may freely use and distribute the Source Code and Object Code + compiled from it, with or without modification, but this Source + Code is provided to you "AS IS" EXCLUSIVE OF ANY WARRANTY, + INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY OR + FITNESS FOR A PARTICULAR PURPOSE, OR ANY OTHER WARRANTY, WHETHER + EXPRESS OR IMPLIED. IN NO EVENT WILL OPENVISION HAVE ANY LIABILITY + FOR ANY LOST PROFITS, LOSS OF DATA OR COSTS OF PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES, OR FOR ANY SPECIAL, INDIRECT, OR + CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, INCLUDING, + WITHOUT LIMITATION, THOSE RESULTING FROM THE USE OF THE SOURCE + CODE, OR THE FAILURE OF THE SOURCE CODE TO PERFORM, OR FOR ANY + OTHER REASON. + + OpenVision retains all copyrights in the donated Source Code. OpenVision + also retains copyright to derivative works of the Source Code, whether + created by OpenVision or by a third party. The OpenVision copyright + notice must be preserved if derivative works are made based on the + donated Source Code. + + OpenVision Technologies, Inc. has donated this Kerberos + Administration system to MIT for inclusion in the standard + Kerberos 5 distribution. This donation underscores our + commitment to continuing Kerberos technology development + and our gratitude for the valuable work which has been + performed by MIT and the Kerberos community. + +Acknowledgements +---------------- Appreciation Time!!!! There are far too many people to try to thank them all; many people have contributed to the development of Kerberos -V5. This is only a partial listing.... +V5. This is only a partial listing.... + +Thanks to Paul Vixie and the Internet Software Consortium for funding +the work of Barry Jaspan. This funding was invaluable for the OV +administration server integration, as well as the 1.0 release +preparation process. Thanks to John Linn, Scott Foote, and all of the folks at OpenVision Technologies, Inc., who donated their administration server for use in the MIT release of Kerberos. -Thanks to Paul Vixie and the Internet Software Consortium for -supporting the OV administration server integration work. - -Thanks to Jeff Bigler, Mark Eichin, Mark Horowitz, Nancy Gilman, Ken +Thanks to Jeff Bigler, Mark Eichin, Marc Horowitz, Nancy Gilman, Ken Raeburn, and all of the folks at Cygnus Support, who provided innumerable bug fixes and portability enhancements to the Kerberos V5 -tree. Thanks especially ot Jeff Bigler, for the new user and system +tree. Thanks especially to Jeff Bigler, for the new user and system administrator's documentation. Thanks to Doug Engert from ANL for providing many bug fixes, as well as testing to ensure DCE interoperability. +Thanks to Ken Hornstein at NRL for providing many bug fixes and +suggestions. + Thanks to Sean Mullan and Bill Sommerfeld from Hewlett Packard for their many suggestions and bug fixes. @@ -92,15 +257,3 @@ past and present: Jay Berkenbilt, Richard Basch, John Carr, Don Davis, Nancy Gilman, Sam Hartman, Marc Horowitz, Barry Jaspan, John Kohl, Cliff Neuman, Kevin Mitchell, Paul Park, Ezra Peisach, Chris Provenzano, Jon Rochlis, Jeff Schiller, Harry Tsai, Ted Ts'o, Tom Yu. - -Note: - -Project Athena, Athena, Athena MUSE, Discuss, Hesiod, Kerberos, Moira, and -Zephyr are trademarks of the Massachusetts Institute of Technology (MIT). No -commercial use of these trademarks may be made without prior written -permission of MIT. - -FYI, "commercial use" means use of a name in a product or other for-profit -manner. It does NOT prevent a commercial firm from referring to the MIT -trademarks in order to convey information (although in doing so, recognition -of their trademark status should be given). diff --git a/doc/.cvsignore b/doc/.cvsignore index b2c6b12..47cc497 100644 --- a/doc/.cvsignore +++ b/doc/.cvsignore @@ -1,80 +1,15 @@ -admin_toc.html -admin.html -admin_foot.html -admin.log -admin.dvi -admin.aux -admin.toc -admin.cp -admin.fn -admin.vr -admin.tp -admin.ky -admin.pg -admin-guide.ps -kerberos-admin.info -kerberos-admin.info-1 -kerberos-admin.info-2 -install_toc.html -install.html -install_foot.html -install.log -install.dvi -install.aux -install.toc -install.cp -install.fn -install.vr -install.tp -install.ky -install.pg -install-guide.ps -krb5-install.info -krb5-install.info-1 -krb5-install.info-2 -user-guide_toc.html -user-guide.html -user-guide_foot.html -user-guide.log -user-guide.dvi -user-guide.aux -user-guide.toc -user-guide.cp -user-guide.fn -user-guide.vr -user-guide.tp -user-guide.ky -user-guide.pg -user-guide.ps -krb5-user.info -kdestroy1.ps -klist1.ps -kinit1.ps -kinit2.ps -rcp1.ps -ftp1.ps -ftp2.ps -ftp3.ps -ftp4.ps -ftp5.ps -ftp6.ps -ftp7.ps -ftp8.ps -rlogin1.ps -ksu1.ps -ksu2.ps -ksu3.ps -ksu4.ps -ksu5.ps -rlogin2.ps -rsh1.ps -rsh2.ps -telnet1.ps -telnet2.ps -telnet3.ps -telnet4.ps -telnet5.ps -telnet6.ps -telnet7.ps -telnet8.ps -telnet9.ps +*.html +*.info +*.info-* +*.log +*.dvi +*.aux +*.toc +*.cp +*.fn +*.vf +*.tp +*.ky +*.pg +*.vr +*.ps diff --git a/doc/ChangeLog b/doc/ChangeLog index 7b3a8bb..49002f2 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,167 @@ +Fri Dec 13 15:10:44 1996 Tom Yu + + * admin.texinfo (The User--Kerberos Interaction): The environment + variable is KRB5CCNAME, not KRB5_CCNAME. + (Getting DNS Information Correct): It's Domain Name System, not + Distributed Name Service. + +Thu Dec 12 18:36:20 1996 Tom Yu + + * user-guide.texinfo: Bump edition to 1.0. Nuke gratuitous + vfills. Change @value{PRODUCT} to explicit reference, to avoid + makeinfo bug that introduces a nul character. + + * krb425.texinfo: Bump edition to 1.0. + + * build.texinfo (OS Incompatibilities): Refer to krb5-send-pr + instead of mail to krb5-bugs. + (Options to Configure): Change options to indicate meta-names, + e.g. "--prefix=PREFIX"; also nuke leading slash on some + descriptions of options. + + * admin.texinfo: Add more explicit linebreaks to prevent overruns; + also break up a few long lines in example program output. + +Fri Dec 6 13:58:19 1996 Tom Yu + + * .cvsignore: Ignore by suffix rather than by file. + + * Makefile (admin-guide-info): + (admin-guide-info): Update to reflect new info file name. + + * admin.texinfo: Change info file name to krb5-admin.info for + consistency. + (Administrating Kerberos Database Entries): "-c credentials_cache" + -> "-c ccache" to avoid overrun. + (Privileges): Null instance example is joeuser@REALM, not + joeuser/null@REALM. + + * install.texinfo (Kerberos Realms): SAN_FRANCISCO.FUBAR.ORG -> + HOUSTON.FUBAR.ORG to prevent margin overrun. + (Create a kadmind Keytab): Add explicit linebreak to prevent + margin overrun. + (Overview of This Guide): + (Installing Kerberos V5): Remove references to windows and mac + client machines for now. + + * krb425.texinfo: Use krb425.info instead of + Kerberos-V4-to-V5.info in the interest of shorter filenames. + + * user-guide.texinfo (Introduction): Eliminate "Kerberos V5 is + based on Kerberos V5". + (Ticket Management): Fix ref to "/rsh". + (rsh): Add explicit linebreak to avoid margin overrun. + + * krb425.texinfo (Upgrading KDCs): Use ROOTDIR rather than + INSTALLDIR to get the proper pathname. + + * send-pr.texinfo: Fix some misspellings, also remove references + to things that are only really applicable for Cygnus. + +Wed Dec 4 23:47:28 1996 Tom Yu + + * krb425.texinfo (Upgrading Application Servers): v5srvtab -> + krb5.keytab + +Mon Dec 2 13:00:26 1996 Barry Jaspan + + * build.texinfo (The DejaGnu Tests): info about .k5login for + krb-root tests [krb5-doc/261] + + * install.texinfo (Add Administrators to the Kerberos Database): + note relationship between acl file and admin principals + [krb5-doc/251] + (Edit the Configuration Files): mention the logging stanza here, + too, and tell people to check it when they start the daemons + [krb5-doc/253] + + * build.texinfo (The KADM5 Tests): add section for the kadm5 tests + [krb5-doc/247] + +Fri Nov 29 19:47:38 1996 Tom Yu + + * build.texinfo (Unpacking the Sources): Mention that ./krb5-1.0 + is the default directory that the tarballs will unpack into. + Also, "/u1/krb5" -> "/u1/krb5-1.0". + (osconf.h): Remove reference to DEFAULT_LNAME_FILENAME, as we're + no longer using the aname database code. + (Options to Configure): Add mention of --localstatedir + (Shared Library Support): It's Solaris 2.4/SunOS 5.4, not Solaris + 5.4. + (Solaris 2.X): Shared libs work with gcc. + + * install.texinfo (Mapping Hostnames onto Kerberos Realms): Fix + spacing error. + + * admin.texinfo: Fix up old references to "/krb5". + + * send-pr.texinfo: krb5-send-pr is in PREFIX/sbin, not PREFIX/bin. + + * admin.texinfo: "/lib/krb5kdc" -> "/var/krb5kdc" + + * krb425.texinfo (Upgrading Application Servers): Change flag + "cygnus" to "CYGNUS". + + * install.texinfo (Please Read the Documentation): Change flag + "cygnus" to "CYGNUS". + + * admin.texinfo (domain_realm): Change flag "cygnus" to "CYGNUS". + + * definitions.texinfo: Change /usr/@value{LCPRODUCT} to /usr/local + to sync with default paths. + + * admin.texinfo (domain_realm): Conditionalize "COM" vs "EDU" in + example. + + * install.texinfo (Create Host Keys for the Slave KDCs): Change + -randpass to -randkey. [244] + +Thu Nov 28 18:54:02 1996 Tom Yu + + * krb425.texinfo: Change to use "@chapternewpage odd", also frob + copyright page as per other docs. Also, remove footnote claiming + that "Kerberos V5 is based on the MIT beta7 release". + + * admin.texinfo (capaths): Fix unquoted braces. + (appdefaults): Fix unquoted braces. + +Wed Nov 27 18:27:18 1996 Jeffrey C. G. Bigler + + * Makefile: Added send-pr.texinfo to ADMIN_INCLUDES and + INSTALL_INCLUDES. + + * admin.texinfo: Added chapter on config files. Changed bug + reporting section to include send-pr file. + + * install.texinfo: Changed bug reporting section to include + send-pr file. Added reference to Sysadmin Guide chapter on config + files. + + * send-pr.texinfo: Fixed this up to match our version of + krb5-send-pr. + +Tue Nov 26 18:34:11 1996 Tom Yu + + * install.texinfo: Fix a couple of references to "@value{COMPANY}" + so they don't commit MIT to doing user support; also fixed some + punctuation errors. + +Mon Nov 25 23:39:53 1996 Theodore Y. Ts'o + + * copyright.texinfo: Change lib/kadm to lib/kadm5, and add the + kadmin/passwd to the list of directories containing OV + code. + +Sun Nov 24 23:55:52 1996 Ezra Peisach (epeisach@mit.edu) + + * build.texinfo: Remove --with-kdb-db section as it does not + exist. Add --with-tcl info. + +Tue Nov 19 13:42:00 1996 Barry Jaspan + + * install.texinfo, build.texinfo: misc suggestions from jhawk + [krb5-doc/55] + Fri Nov 15 17:52:39 1996 Jeff Bigler * Makefile (krb425-guide): added section to make krb425 guide. diff --git a/doc/Makefile b/doc/Makefile index 92a3477..f8c2996 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -9,11 +9,11 @@ GZIP=gzip -9 MANPS=./man2ps ADMIN_INCLUDES=definitions.texinfo copyright.texinfo document-list.texinfo \ - glossary.texinfo + glossary.texinfo send-pr.texinfo ADMIN_DEPS=admin.texinfo $(ADMIN_INCLUDES) INSTALL_INCLUDES=definitions.texinfo copyright.texinfo document-list.texinfo \ - build.texinfo bug-report.texinfo + build.texinfo bug-report.texinfo send-pr.texinfo INSTALL_DEPS=install.texinfo $(INSTALL_INCLUDES) USER_GUIDE_INCLUDES=definitions.texinfo copyright.texinfo glossary.texinfo @@ -42,9 +42,9 @@ admin.html: $(ADMIN_DEPS) $(HTML) admin.texinfo .PHONY: admin-guide-info -admin-guide-info:: kerberos-admin.info +admin-guide-info:: krb5-admin.info -kerberos-admin.info: $(ADMIN_DEPS) +krb5-admin.info: $(ADMIN_DEPS) $(INFO) admin.texinfo .PHONY: install-guide-full diff --git a/doc/admin.texinfo b/doc/admin.texinfo index cca3e32..7e70d28 100644 --- a/doc/admin.texinfo +++ b/doc/admin.texinfo @@ -3,7 +3,7 @@ \input texinfo @c -*-texinfo-*- @c %**start of header @c guide -@setfilename kerberos-admin.info +@setfilename krb5-admin.info @settitle Kerberos V5 System Administrator's Guide @setchapternewpage odd @c chapter begins on next odd page @c @setchapternewpage on @c chapter begins on next page @@ -15,7 +15,8 @@ @end iftex @include definitions.texinfo -@set EDITION b7-1 +@set EDITION 1.0 +@set UPDATED November 27, 1996 @finalout @c don't print black warning boxes @@ -58,6 +59,7 @@ installation. * Copyright:: * Introduction:: * How Kerberos Works:: +* Configuration Files:: * Administrating Kerberos Database Entries:: * Application Servers:: * Backups of Secure Hosts:: @@ -116,7 +118,7 @@ The appendices include sample configuration files, the list of Kerberos error messages, and a complete list of the time zones understood by @code{kadmin}. -@node How Kerberos Works, Administrating Kerberos Database Entries, Introduction, Top +@node How Kerberos Works, Configuration Files, Introduction, Top @chapter How Kerberos Works This section provides a simplified description of a general user's @@ -282,8 +284,8 @@ ticket-granting ticket and the key which allows you to use it, encrypted by your password. If @samp{kinit} can decrypt the Kerberos reply using the password you provide, it stores this ticket in a credentials cache on your local machine for later use. The name of the credentials cache -can be specified in the @samp{KRB5_CCNAME} environment variable. If -this variable is not set, the name of the file will be +can be specified in the @samp{KRB5CCNAME} environment variable. If this +variable is not set, the name of the file will be @file{/tmp/krb5cc_}, where is your UNIX user-id, represented in decimal format. @end enumerate @@ -329,7 +331,582 @@ Following are definitions of some of the Kerberos terminology. @include glossary.texinfo -@node Administrating Kerberos Database Entries, Application Servers, How Kerberos Works, Top +@node Configuration Files, Administrating Kerberos Database Entries, How Kerberos Works, Top +@chapter Configuration Files + +@menu +* krb5.conf:: +* kdc.conf:: +@end menu + +@node krb5.conf, kdc.conf, Configuration Files, Configuration Files +@section krb5.conf + +The @code{krb5.conf} file contains Kerberos configuration information, +including the locations of KDCs and admin servers for the Kerberos +realms of interest, defaults for the current realm and for Kerberos +applications, and mappings of hostnames onto Kerberos realms. Normally, +you should install your @code{krb5.conf} file in the directory +@code{/etc}. You can override the default location by setting the +environment variable @samp{KRB5_CONFIG}. + +The @code{krb5.conf} file is set up in the style of a Windows INI file. +Sections are headed by the section name, in square brackets. Each +section may contain zero or more relations, of the form: + +@smallexample +foo = bar +@end smallexample + +@noindent +or + +@smallexample +@group +fubar = @{ + foo = bar + baz = quux +@} +@end group +@end smallexample + +The @code{krb5.conf} file may contain any or all of the following seven +sections: + +@table @b +@itemx libdefaults +Contains default values used by the Kerberos V5 library. + +@itemx appdefaults +Contains default values used by Kerberos V5 applications. + +@itemx realms +Contains subsections keyed by Kerberos realm names. Each subsection +describes realm-specific information, including where to find the +Kerberos servers for that realm. + +@itemx domain_realm +Contains relations which map domain names and subdomains onto Kerberos +realm names. This is used by programs to determine what realm a host +should be in, given its fully qualified domain name. + +@itemx logging +Contains relations which determine how Kerberos programs are to perform +logging. + +@itemx capaths +Contains the authentication paths used with direct (nonhierarchical) +cross-realm authentication. Entries in this section are used by the +client to determine the intermediate realms which may be used in +cross-realm authentication. It is also used by the end-service when +checking the transited field for trusted intermediate realms. + +@itemx kdc +For a KDC, may contain the location of the kdc.conf file. +@end table + +@menu +* libdefaults:: +* appdefaults:: +* realms (krb5.conf):: +* domain_realm:: +* logging:: +* capaths:: +* Sample krb5.conf File:: +@end menu + +@node libdefaults, appdefaults, krb5.conf, krb5.conf +@subsection [libdefaults] + +The @code{libdefaults} section may contain any of the following +relations: + +@table @b +@itemx default_realm +Identifies the default Kerberos realm for the client. Set its value to +your Kerberos realm. + +@itemx default_tgs_enctypes +Identifies the supported list of session key encryption types that +should be returned by the KDC. The list may be delimited with commas or +whitespace. Currently, the only supported encryption type is +"des-cbc-crc". Support for other encryption types is planned in the +future. + +@itemx default_tkt_enctypes +Identifies the supported list of session key encryption +types that should be requested by the client. The format is the same as +for @emph{default_tkt_enctypes}. Again, the only supported encryption +type is "des-cbc-crc". + +@itemx clockskew +Sets the maximum allowable amount of clockskew in seconds that the +library will tolerate before assuming that a Kerberos message is +invalid. The default value is 300 seconds, or five minutes. + +@itemx checksum_type +Used for compatability with DCE security servers which do not support +the default CKSUMTYPE_RSA_MD5 used by this version of Kerberos. A value +of 1 indicates the default checksum type. Use a value of 2 to use the +CKSUMTYPE_RSA_MD4 instead. This applies to DCE 1.1 and earlier. + +@itemx ccache_type +Use this parameter on systems which are DCE clients, to specify the type +of cache to be created by kinit, or when forwarded tickets are received. +DCE and Kerberos can share the cache, but some versions of DCE do not +support the default cache as created by this version of Kerberos. Use a +value of 1 on DCE 1.0.3a systems, and a value of 2 on DCE 1.1 systems. +@end table + +@node appdefaults, realms (krb5.conf), libdefaults, krb5.conf +@subsection [appdefaults] + +Each tag in the [appdefaults] section names a Kerberos V5 application. +The value of the tag is a subsection with relations that define the +default behaviors for that application. + +For example: + +@smallexample +@group +[appdefaults] + kinit = @{ + forwardable = true + @} + telnet = @{ + forward = true + encrypt = true + autologin = true + @} +@end group +@end smallexample + +The list of specifiable options for each application may be found in +that application's man pages. The application defaults specified here +are overridden by those specified in the [realms] section. + +@node realms (krb5.conf), domain_realm, appdefaults, krb5.conf +@subsection [realms] + +Each tag in the [realms] section of the file is the name of a Kerberos +realm. The value of the tag is a subsection with relations that define +the properties of that particular realm. For each realm, the following +tags may be specified in the realm's subsection: + +@table @b +@itemx kdc +The name of a host running a KDC for that realm. An optional port +number (separated from the hostname by a colon) may be included. + +@itemx admin_server +Identifies the host where the administration server is running. +Typically, this is the master Kerberos server. + +@itemx application defaults +Application defaults that are specific to a particular realm may be +specified within that realm's tag. Realm-specific application defaults +override the global defaults specified in the [appdefaults] section. +@end table + +@node domain_realm, logging, realms (krb5.conf), krb5.conf +@subsection [domain_realm] + +The [domain_realm] section provides a translation from a domain name or +hostname to a Kerberos realm name. The tag name can be a host name, or +a domain name, where domain names are indicated by a prefix of a period +(@samp{.}). The value of the relation is the Kerberos realm name for +that particular host or domain. Host names and domain names should be +in lower case. + +If no translation entry applies, the host's realm is considered to be +the hostname's domain portion converted to upper case. For example, the +following [domain_realm] section: + +@smallexample +@group +[domain_realm] +@ifset MIT + .mit.edu = ATHENA.MIT.EDU +@end ifset + @value{PRIMARYDOMAIN} = @value{PRIMARYREALM} + crash.@value{PRIMARYDOMAIN} = TEST.@value{PRIMARYREALM} + @value{SECONDDOMAIN} = @value{SECONDREALM} +@end group +@end smallexample + +@noindent +maps crash.@value{PRIMARYDOMAIN} into the TEST.@value{PRIMARYREALM} +realm. All other hosts in the @value{PRIMARYDOMAIN} domain will map by +default to the @value{PRIMARYREALM} realm, and all hosts in the +@value{SECONDDOMAIN} domain will map by default into the +@value{SECONDREALM} realm. Note the entries for the hosts +@value{PRIMARYDOMAIN} and @value{SECONDDOMAIN}. Without these entries, +@ifset CYGNUS +these hosts would be mapped into the Kerberos realms @samp{COM} and +@end ifset +@ifclear CYGNUS +these hosts would be mapped into the Kerberos realms @samp{EDU} and +@end ifclear +@samp{ORG}, respectively. + +@node logging, capaths, domain_realm, krb5.conf +@subsection [logging] +The [logging] section indicates how a particular entity is to perform +its logging. The relations in this section assign one or more values to +the entity name. Currently, the following entities are used: + +@table @b +@itemx admin_server +These entries specify how the administrative server +is to perform its logging. + +@itemx default +These entries specify how to perform logging in the +absence of explicit specifications otherwise. +@end table + +Values are of the following forms: + +@table @b +@itemx FILE= + +@itemx FILE: +This value causes the entity's logging messages to go to the specified +file. If the @samp{=} form is used, the file is overwritten. If the +@samp{:} form is used, the file is appended to. + +@itemx STDERR +This value causes the entity's logging messages to go to its standard +error stream. + +@itemx CONSOLE +This value causes the entity's logging messages to go to the console, if +the system supports it. + +@itemx DEVICE= +This causes the entity's logging messages to go to the specified device. + +@itemx SYSLOG[:[:]] +This causes the entity's logging messages to go to the system log. + +The @dfn{severity} argument specifies the default severity of system log +messages. This may be any of the following severities supported by the +@code{syslog(3)} call, minus the LOG_ prefix: LOG_EMERG, LOG_ALERT, +LOG_CRIT, LOG_ERR, LOG_WARNING, LOG_NOTICE, LOG_INFO, and LOG_DEBUG. +For example, a value of @samp{CRIT} would specify LOG_CRIT severity. + +The facility argument specifies the facility under which the messages +are logged. This may be any of the following facilities supported by +the syslog(3) call minus the LOG_ prefix: LOG_KERN, LOG_USER, LOG_MAIL, +LOG_DAEMON, LOG_AUTH, LOG_LPR, LOG_NEWS, LOG_UUCP, LOG_CRON, and +LOG_LOCAL0 through LOG_LOCAL7. + +If no severity is specified, the default is ERR. If no facility is +specified, the default is AUTH. +@end table + +In the following example, the logging messages from the KDC will go to +the console and to the system log under the facility LOG_DAEMON with +default severity of LOG_INFO; and the logging messages from the +administrative server will be appended to the file /var/adm/kadmin.log +and sent to the device /dev/tty04. + +@smallexample +@group +[logging] + kdc = CONSOLE + kdc = SYSLOG:INFO:DAEMON + admin_server = FILE:/var/adm/kadmin.log + admin_server = DEVICE=/dev/tty04 +@end group +@end smallexample + +@node capaths, Sample krb5.conf File, logging, krb5.conf +@subsection [capaths] + +In order to perform direct (non-hierarchical) cross-realm +authentication, a database is needed to construct the authentication +paths between the realms. This section defines that database. + +A client will use this section to find the authentication path between +its realm and the realm of the server. The server will use this section +to verify the authentication path used be the client, by checking the +transited field of the received ticket. + +There is a tag for each participating realm, and each tag has subtags +for each of the realms. The value of the subtags is an intermediate +realm which may participate in the cross-realm authentication. The +subtags may be repeated if there is more then one intermediate realm. A +value of "." means that the two realms share keys directly, and no +intermediate realms should be allowd to participate. + +There are n**2 possible entries in this table, but only those entries +which will be needed on the client or the server need to be present. +The client needs a tag for its local realm, with subtags for all the +realms of servers it will need to authenticate with. A server needs a +tag for each realm of the clients it will serve. + +For example, ANL.GOV, PNL.GOV, and NERSC.GOV all wish to use the ES.NET +realm as an intermediate realm. ANL has a sub realm of TEST.ANL.GOV +which will authenticate with NERSC.GOV but not PNL.GOV. The [capath] +section for ANL.GOV systems would look like this: + +@smallexample +@group +[capaths] + ANL.GOV = @{ + TEST.ANL.GOV = . + PNL.GOV = ES.NET + NERSC.GOV = ES.NET + ES.NET = . + @} + TEST.ANL.GOV = @{ + ANL.GOV = . + @} + PNL.GOV = @{ + ANL.GOV = ES.NET + @} + NERSC.GOV = @{ + ANL.GOV = ES.NET + @} + ES.NET = @{ + ANL.GOV = . + @} +@end group +@end smallexample + +The [capath] section of the configuration file used on NERSC.GOV systems +would look like this: + +@smallexample +@group +[capaths] + NERSC.GOV = @{ + ANL.GOV = ES.NET + TEST.ANL.GOV = ES.NET + TEST.ANL.GOV = ANL.GOV + PNL.GOV = ES.NET + ES.NET = . + @} + ANL.GOV = @{ + NERSC.GOV = ES.NET + @} + PNL.GOV = @{ + NERSC.GOV = ES.NET + @} + ES.NET = @{ + NERSC.GOV = . + @} + TEST.ANL.GOV = @{ + NERSC.GOV = ANL.GOV + NERSC.GOV = ES.NET + @} +@end group +@end smallexample + +In the above examples, the ordering is not important, except when the +same subtag name is used more then once. The client will use this to +determing the path. (It is not important to the server, since the +transited field is not sorted.) + +This feature is not currently supported by DCE. DCE security servers +can be used with Kerberized clients and servers, but versions prior to +DCE 1.1 did not fill in the transited field, and should be used with +caution. + +@node Sample krb5.conf File, , capaths, krb5.conf +@subsection Sample krb5.conf File + +Here is an example of a generic @code{krb5.conf} file: + +@smallexample +@group +[libdefaults] + ticket_lifetime = 600 + default_realm = @value{PRIMARYREALM} + default_tkt_enctypes = des-cbc-crc + default_tgs_enctypes = des-cbc-crc + +[realms] + @value{PRIMARYREALM} = @{ + kdc = @value{KDCSERVER}.@value{PRIMARYDOMAIN} + kdc = @value{KDCSLAVE1}.@value{PRIMARYDOMAIN} + kdc = @value{KDCSLAVE2}.@value{PRIMARYDOMAIN} + admin_server = @value{KDCSERVER}.@value{PRIMARYDOMAIN} + default_domain = @value{PRIMARYDOMAIN} + @} + @value{SECONDREALM} = @{ + kdc = @value{KDCSERVER}.@value{SECONDDOMAIN} + kdc = @value{KDCSLAVE1}.@value{SECONDDOMAIN} + admin_server = @value{KDCSERVER}.@value{SECONDDOMAIN} + @} + +[domain_realm] +@ifset MIT + .mit.edu = ATHENA.MIT.EDU +@end ifset + @value{PRIMARYDOMAIN} = @value{PRIMARYREALM} + +@end group +@end smallexample + +@iftex +@vfill +@end iftex + +@node kdc.conf, , krb5.conf, Configuration Files +@section kdc.conf + +The @code{kdc.conf} file contains KDC configuration information, +including defaults used when issuing Kerberos tickets. Normally, you +should install your @code{kdc.conf} file in the directory +@code{@value{ROOTDIR}/var/krb5kdc}. You can override the default +location by setting the environment variable @samp{KRB5_KDC_PROFILE}. + +The @code{kdc.conf} file is set up in the same format as the +@code{krb5.conf} file. (@xref{krb5.conf}.) The @code{kdc.conf} file +may contain any or all of the following three sections: + +@table @b +@itemx kdcdefaults +Contains default values for overall behavior of the KDC. + +@itemx realms +Contains subsections keyed by Kerberos realm names. Each subsection +describes realm-specific information, including where to find the +Kerberos servers for that realm. + +@itemx logging +Contains relations which determine how Kerberos programs are to perform +logging. +@end table + +@menu +* kdcdefaults:: +* realms (kdc.conf):: +* Sample kdc.conf File:: +@end menu + +@node kdcdefaults, realms (kdc.conf), kdc.conf, kdc.conf +@subsection [kdcdefaults] + +The following relation is defined in the [kdcdefaults] section: + +@table @b +@itemx kdc_ports +This relation lists the ports on which the Kerberos server should listen +by default. This list is a comma separated list of integers. If this +relation is not specified, the compiled-in default is usually port 88 +(the assigned Kerberos port) and port 750 (the port used by Kerberos +V4). +@end table + +@node realms (kdc.conf), Sample kdc.conf File, kdcdefaults, kdc.conf +@subsection [realms] + +Each tag in the [realms] section of the file names a Kerberos realm. +The value of the tag is a subsection where the relations in that +subsection define KDC parameters for that particular realm. + +For each realm, the following tags may be specified in the [realms] +subsection: + +@table @b +@itemx acl_file +(String.) Location of the access control list (acl) file that kadmin +uses to determine which principals are allowed which permissions on the +database. The default is @code{@value{ROOTDIR}/var/krb5kdc/kadm5.acl}. + +@itemx admin_keytab +(String.) Location of the keytab file that kadmin uses to authenticate +to the database. The default is +@code{@value{ROOTDIR}/var/krb5kdc/kadm5.keytab}. + +@itemx database_name +(String.) Location of the Kerberos database for this realm. The +default is @* @code{@value{ROOTDIR}/var/krb5kdc/principal}. + +@itemx default_principal_expiration +(Absolute time string.) Specifies the default expiration date of +principals created in this realm. + +@itemx default_principal_flags +(Flag string.) Specifies the default attributes of principals created +in this realm. + +@itemx dict_file +(String.) Location of the dictionary file containing strings that are +not allowed as passwords. The default is +@code{@value{ROOTDIR}/var/krb5kdc/kadm5.dict}. + +@itemx encryption_type +(Encryption type string.) Specifies the encryption type used for this +realm. Only "des-cbc-crc" is supported at this time. + +@itemx kadmind_port +(Port number.) Specifies the port that the kadmind daemon is to listen +for this realm. The assigned port for kadmind is 749. + +@itemx key_stash_file +(String.) Specifies the location where the master key has been stored +(via @code{kdb5_util stash}). The default is +@code{@value{ROOTDIR}/var/krb5kdc/.k5.@i{REALM}}, where @i{REALM} is the +Kerberos realm. + +@itemx kdc_ports +(String.) Specifies the list of ports that the KDC is to listen to for +this realm. By default, the value of kdc_ports as specified in the +[kdcdefaults] section is used. + +@itemx master_key_name +(String.) Specifies the name of the master key. + +@itemx master_key_type +(Key type string.) Specifies the master key's key type. Only +"des-cbc-crc" is supported at this time. + +@itemx max_life +(Delta time string.) Specifes the maximum time period for which a +ticket may be valid in this realm. + +@itemx max_renewable_life +(Delta time string.) Specifies the maximum time period during which a +valid ticket may be renewed in this realm. + +@itemx supported_enctypes +List of key:salt strings. Specifies the default key/salt combinations +of principals for this realm. Since only the encryption type +"des-cbc-crc" is supported, you should set this tag to +@samp{des-cbc-crc:normal}. +@end table + +@node Sample kdc.conf File, , realms (kdc.conf), kdc.conf +@subsection Sample kdc.conf File + +Here's an example of a @code{kdc.conf} file: + +@smallexample +@group +[kdcdefaults] + kdc_ports = 88 + +[realms] + @value{PRIMARYREALM} = @{ + kadmind_port = 749 + max_life = 10h 0m 0s + max_renewable_life = 7d 0h 0m 0s + master_key_type = des-cbc-crc + supported_enctypes = des-cbc-crc:normal + @} + +[logging] + kdc = FILE:@value{ROOTDIR}/var/krb5kdc/kdc.log + admin_server = FILE:@value{ROOTDIR}/var/krb5kdc/kadmin.log + +@end group +@end smallexample + +@node Administrating Kerberos Database Entries, Application Servers, Configuration Files, Top @chapter Administrating the Kerberos Database Your Kerberos database contains all of your realm's Kerberos principals, @@ -361,13 +938,13 @@ database dump and load, which are provided by @code{kdb5_util}). The remote version authenticates to the KADM5 server using the service principal @code{kadmin/admin}. If the credentials cache contains a -ticket for the @code{kadmin/admin} principal, and the @samp{-c -credentials_cache} option is specified, that ticket is used to -authenticate to KADM5. Otherwise, the @samp{-p} and @samp{-k} options -are used to specify the client Kerberos principal name used to -authenticate. Once kadmin has determined the principal name, it -requests a @code{kadmin/admin} Kerberos service ticket from the KDC, and -uses that service ticket to authenticate to KADM5. +ticket for the @code{kadmin/admin} principal, and the @samp{-c ccache} +option is specified, that ticket is used to authenticate to KADM5. +Otherwise, the @samp{-p} and @samp{-k} options are used to specify the +client Kerberos principal name used to authenticate. Once kadmin has +determined the principal name, it requests a @code{kadmin/admin} +Kerberos service ticket from the KDC, and uses that service ticket to +authenticate to KADM5. @menu * Kadmin Options:: @@ -514,7 +1091,7 @@ requires the ``inquire'' administrative privilege. The syntax is: @noindent The @code{get_principal} command has the alias @code{getprinc}. For example, suppose you wanted to view the attributes of the principals -@code{@value{RANDOMUSER1}/root@@@value{PRIMARYREALM}} and +@* @code{@value{RANDOMUSER1}/root@@@value{PRIMARYREALM}} and @code{systest@@@value{PRIMARYREALM}}. You would type: @smallexample @@ -629,7 +1206,7 @@ permissions are determined by the first matching entry. @smallexample @group */admin@@@value{PRIMARYREALM} * -@value{ADMINUSER}/null@@@value{PRIMARYREALM} ADMCIL +@value{ADMINUSER}@@@value{PRIMARYREALM} ADMCIL @value{ADMINUSER}/*@@@value{PRIMARYREALM} il @value{RANDOMUSER1}/root@@@value{PRIMARYREALM} cil */root@@@value{PRIMARYREALM} */*@@@value{PRIMARYREALM} i @@ -641,7 +1218,7 @@ has all administrative privileges. The user @code{@value{ADMINUSER}} has all permissions with his @code{admin} instance, @code{@value{ADMINUSER}/admin@@@value{PRIMARYREALM}} (matches the first line). He has no permissions at all with his @code{null} instance, -@code{@value{ADMINUSER}/null@@@value{PRIMARYREALM}} (matches the second +@code{@value{ADMINUSER}@@@value{PRIMARYREALM}} (matches the second line). He has @i{inquire} and @i{list} permissions with any other instance (matches the third line). When @code{@value{RANDOMUSER1}} is using her @code{root} @@ -649,7 +1226,7 @@ instance, @code{@value{RANDOMUSER1}/root@@@value{PRIMARYREALM}}, she has @i{change password}, @i{inquire}, and @i{list} privileges for any other principal that has the instance @code{root}. Finally, any principal in the realm @code{@value{PRIMARYREALM}} (except for -@code{@value{ADMINUSER}/null@@@value{PRIMARYREALM}}, as mentioned above) +@code{@value{ADMINUSER}@@@value{PRIMARYREALM}}, as mentioned above) has @i{inquire} privileges. @node Adding or Modifying Principals, Deleting Principals, Privileges, Principals @@ -741,14 +1318,14 @@ principal in the database. @item @{-|+@}allow_proxiable The ``-allow_proxiable'' option prohibits this principal from obtaining proxiable tickets. ``+allow_proxiable'' clears this flag. In effect, -``-allow_proxiable'' sets the KRB5_KDB_DISALLOW_PROXIABLE flag. on the -principal in the database. +``-allow_proxiable'' sets the @* KRB5_KDB_DISALLOW_PROXIABLE flag. on +the principal in the database. @item @{-|+@}allow_dup_skey The ``-allow_dup_skey'' option disables user-to-user authentication for this principal by prohibiting this principal from obtaining a session key for another user. ``+allow_dup_skey'' clears this flag. In effect, -``-allow_dup_skey'' sets the KRB5_KDB_DISALLOW_DUP_SKEY flag on the +``-allow_dup_skey'' sets the @* KRB5_KDB_DISALLOW_DUP_SKEY flag on the principal in the database. @item @{-|+@}requires_preauth @@ -767,8 +1344,8 @@ database. @item @{-|+@}allow_svr The ``-allow_svr'' flag prohibits the issuance of service tickets for this principal. ``+allow_svr'' clears this flag. In effect, -``-allow_svr'' sets the KRB5_KDB_DISALLOW_SVR flag on the principal in -the database. +``-allow_svr'' sets the @* KRB5_KDB_DISALLOW_SVR flag on the principal +in the database. @item @{-|+@}allow_tgs_req The ``-allow_tgs_req'' option specifies that a Ticket-Granting Service @@ -781,7 +1358,7 @@ principal in the database. @item @{-|+@}allow_tix The ``-allow_tix'' option forbids the issuance of any tickets for this principal. ``+allow_tix'' clears this flag. The default is -``+allow_tix''. In effect, ``-allow_tix'' sets the +``+allow_tix''. In effect, ``-allow_tix'' sets the @* KRB5_KDB_DISALLOW_ALL_TIX flag on the principal in the database. @item @{-|+@}needchange @@ -863,7 +1440,7 @@ kadmin:} If you will need cross-realm authentication, you need to add principals for the other realm's TGT to each realm. For example, if you need to do cross-realm authentication between the realms @value{PRIMARYREALM} and -@value{SECONDREALM}, you would need to add the principals +@value{SECONDREALM}, you would need to add the principals @* @samp{krbtgt/@value{SECONDREALM}@@@value{PRIMARYREALM}} and @samp{krbtgt/@value{PRIMARYREALM}@@@value{SECONDREALM}} to both databases. You need to be sure the passwords and the key version @@ -1312,8 +1889,9 @@ example: @smallexample @group @b{shell%} @value{ROOTDIR}/sbin/kdb5_util -r @value{PRIMARYREALM} create -s -@b{kdb5_util: No such file or directory while setting active database to '/krb5/principal' -Initializing database '@value{ROOTDIR}/lib/krb5kdc/principal' for +@b{kdb5_util: No such file or directory while setting active database to +@result{} '@value{ROOTDIR}/var/krb5kdc/principal' +Initializing database '@value{ROOTDIR}/var/krb5kdc/principal' for @result{} realm '@value{PRIMARYREALM}', master key name 'K/M@@@value{PRIMARYREALM}' You will be prompted for the database Master Password. @@ -1404,7 +1982,8 @@ for the kadmin @code{list_principals} (@pxref{Retrieving a List of Principals}) command. @end table -For example: +For example (The line beginning with @result{} is a continuation of the +previous line.): @smallexample @group @@ -1418,10 +1997,11 @@ kadmin:} @smallexample @group -@b{kadmin:} ktadd -k /krb5/kadmind.keytab kadmin/admin kadmin/changepw +@b{kadmin:} ktadd -k @value{ROOTDIR}/var/krb5kdc/kadmind.keytab +@result{} kadmin/admin kadmin/changepw @b{kadmin: Entry for principal kadmin/admin@@@value{PRIMARYREALM} with kvno 3, encryption type DES-CBC-CRC added to keytab - WRFILE:/krb5/kadmind.keytab. + WRFILE:@value{ROOTDIR}/var/krb5kdc/kadmind.keytab. kadmin:} @end group @end smallexample @@ -1466,9 +2046,9 @@ For example: @smallexample @group -@b{kadmin:} ktremove -k /krb5/kadmind.keytab kadmin/admin +@b{kadmin:} ktremove -k @value{ROOTDIR}/var/krb5kdc/kadmind.keytab kadmin/admin @b{kadmin: Entry for principal kadmin/admin with kvno 3 removed - from keytab WRFILE:/krb5/kadmind.keytab. + from keytab WRFILE:@value{ROOTDIR}/var/krb5kdc/kadmind.keytab. kadmin:} @end group @end smallexample @@ -1503,7 +2083,7 @@ to set up a cron job that adjusts the time on a regular basis. Several aspects of Kerberos rely on name service. In order for Kerberos to provide its high level of security, it is less forgiving of name service problems than some other parts of your network. It is important -that your Distributed Name Service (DNS) entries and your hosts have the +that your Domain Name System (DNS) entries and your hosts have the correct information. Each host's canonical name must be the fully-qualified host name @@ -1528,8 +2108,8 @@ Here is a sample @code{/etc/hosts} file: @end smallexample Additionally, on Solaris machines, you need to be sure the ``hosts'' -entry in the file @code{/etc/nsswitch.conf} includes the source ``dns'' -as well as ``file''. +entry in the file @* @code{/etc/nsswitch.conf} includes the source +``dns'' as well as ``file''. Finally, each host's keytab file must include a host/key pair for the host's canonical name. You can list the keys in a keytab file by @@ -1627,7 +2207,7 @@ suggests that you have rules that specifically name these applications and, if possible, list the allowed hosts. A reasonably good cookbook for configuring firewalls is available by FTP -from @code{ftp.livingston.com}, in the location: +from @* @code{ftp.livingston.com}, in the location: @code{/pub/firewall/firewall-1.1.ps.Z}. The book @cite{UNIX System Security}, by David Curry, is also a good starting point. @@ -1677,174 +2257,17 @@ Database from a Dump File}.) @node Bug Reporting, Appendix, Backups of Secure Hosts, Top @chapter Bug Reporting -In any complex software, there will be bugs. Please send bug reports or -other problems you may uncover to the e-mail address -@b{krb5-bugs@@mit.edu}. Please mention which version of the Kerberos V5 -distribution you are using, and whether you have made any private -changes. Bug reports that include proposed fixes are especially -welcome. If you do include fixes, please send them using either context -diffs or unified diffs (using @samp{diff -c} or @samp{diff -u}, -respectively). +@include send-pr.texinfo @node Appendix, , Bug Reporting, Top @appendix Appendix @menu -* Files:: -* krb5.conf:: -* kdc.conf:: * Errors:: * kadmin Time Zones:: @end menu -@node Files, krb5.conf, Appendix, Appendix -@appendixsec Files - -@node krb5.conf, kdc.conf, Files, Appendix -@appendixsec krb5.conf - -Normally, you should install your @code{krb5.conf} file in the directory -@code{/etc}. However, note that you can override this default through -the environment variable @samp{KRB5_CONFIG}. - -Here is an example of a generic @code{krb5.conf} file: - -@smallexample -@group -[libdefaults] - ticket_lifetime = 600 - default_realm = @value{PRIMARYREALM} - default_tkt_enctypes = des-cbc-crc - default_tgs_enctypes = des-cbc-crc - -[realms] - @value{PRIMARYREALM} = @{ - kdc = @value{KDCSERVER}.@value{PRIMARYDOMAIN}:88 - kdc = @value{KDCSLAVE1}.@value{PRIMARYDOMAIN}:88 - kdc = @value{KDCSLAVE2}.@value{PRIMARYDOMAIN}:88 - admin_server = @value{KDCSERVER}.@value{PRIMARYDOMAIN}:749 - default_domain = @value{PRIMARYDOMAIN} - @} - @} - -[domain_realm] - .@value{PRIMARYDOMAIN} = @value{PRIMARYREALM} - @value{PRIMARYDOMAIN} = @value{PRIMARYREALM} - -[logging] - kdc = FILE:/dev/ttyp9 - admin_server = FILE:/dev/ttyp9 - default = FILE:/dev/ttyp9 -@end group -@end smallexample - -@iftex -@vfill -@end iftex -@page - -Here is an example of a more extensive @code{krb5.conf} file, which -includes a second Kerberos realm and authentication to Kerberos V4 as -well as V5 KDCs in the realm @code{@value{PRIMARYREALM}}: - -@smallexample -@group -[libdefaults] - ticket_lifetime = 600 - default_realm = @value{PRIMARYREALM} - default_tkt_enctypes = des-cbc-crc - default_tgs_enctypes = des-cbc-crc - krb4_srvtab = /etc/srvtab - krb4_config = /usr/krb4/lib/krb.conf - krb4_realms = /usr/krb4/lib/krb.realms - -[realms] - @value{PRIMARYREALM} = @{ - kdc = @value{KDCSERVER}.@value{PRIMARYDOMAIN}:88 - kdc = @value{KDCSLAVE1}.@value{PRIMARYDOMAIN}:88 - kdc = @value{KDCSLAVE2}.@value{PRIMARYDOMAIN}:88 - admin_server = @value{KDCSERVER}.@value{PRIMARYDOMAIN}:749 - default_domain = @value{PRIMARYDOMAIN} - v4_instance_convert = @{ - bleep = @value{PRIMARYDOMAIN} - @} - @} - @value{SECONDREALM} = @{ - kdc = @value{KDCSERVER}.@value{SECONDDOMAIN} - kdc = @value{KDCSLAVE1}.@value{SECONDDOMAIN} - admin_server = @value{KDCSERVER}.@value{SECONDDOMAIN} - @} - -[domain_realm] - .@value{PRIMARYDOMAIN} = @value{PRIMARYREALM} - @value{PRIMARYDOMAIN} = @value{PRIMARYREALM} - .@value{SECONDDOMAIN} = @value{SECONDREALM} - @value{SECONDDOMAIN} = @value{SECONDREALM} -@end group -@end smallexample - -For the KDCs, add a section onto the end of the @code{krb5.conf} file -telling where the @code{kdc.conf} file is located, as in the following -example: - -@smallexample -@group -[kdc] - profile = @value{ROOTDIR}/lib/krb5kdc/kdc.conf - -[logging] - admin_server = FILE:@value{ROOTDIR}/lib/krb5kdc/kadmind.log - kdc = FILE:@value{ROOTDIR}/lib/krb5kdc/kdc.log - default = CONSOLE -@end group -@end smallexample - -@iftex -@vfill -@end iftex -@page - -@node kdc.conf, Errors, krb5.conf, Appendix -@appendixsec kdc.conf - -Normally, you should install your @code{kdc.conf} file in the directory -@code{@value{ROOTDIR}/lib/krb5kdc}. However, note that you can override -this default by a pointer in the KDC's @code{krb5.conf} file, or through -the environment variable @samp{KRB5_KDC_PROFILE}. - -Here's an example of a @code{kdc.conf} file: - -@smallexample -@group -[kdcdefaults] - kdc_ports = 88,750 - -[realms] - @value{PRIMARYREALM} = @{ - profile = /etc/krb5.conf - database_name = @value{ROOTDIR}/lib/krb5kdc/principal - admin_database_name = @value{ROOTDIR}/lib/krb5kdc/principal.kadm5 - admin_database_lockfile = @value{ROOTDIR}/lib/krb5kdc/principal.kadm5.lock - admin_keytab = @value{ROOTDIR}/lib/krb5kdc/kadm5.keytab - acl_file = @value{ROOTDIR}/lib/krb5kdc/kadm5.acl - dict_file = @value{ROOTDIR}/lib/krb5kdc/kadm5.dict - key_stash_file = @value{ROOTDIR}/lib/krb5kdc/.k5.@value{PRIMARYREALM} - kadmind_port = 749 - max_life = 10h 0m 0s - max_renewable_life = 7d 0h 0m 0s - master_key_type = des-cbc-crc - supported_enctypes = des-cbc-crc:normal - @} -@end group -@end smallexample - -To add Kerberos V4 support, change the @code{supported_enctypes} line to: - -@smallexample - supported_enctypes = des-cbc-crc:normal des-cbc-crc:v4 -@end smallexample - -@node Errors, kadmin Time Zones, kdc.conf, Appendix +@node Errors, kadmin Time Zones, Appendix, Appendix @appendixsec Kerberos Error Messages @menu @@ -1859,8 +2282,8 @@ To add Kerberos V4 support, change the @code{supported_enctypes} line to: @appendixsubsec Kerberos V5 Library Error Codes This is the Kerberos v5 library error code table. Protocol error codes -are ERROR_TABLE_BASE_krb5 + the protocol error code number; other error -codes start at ERROR_TABLE_BASE_krb5 + 128. +are @* ERROR_TABLE_BASE_krb5 + the protocol error code number; other +error codes start at ERROR_TABLE_BASE_krb5 + 128. @c error table numbering starts at 0 @enumerate 0 diff --git a/doc/api/ChangeLog b/doc/api/ChangeLog index 0f902ad..a26f66f 100644 --- a/doc/api/ChangeLog +++ b/doc/api/ChangeLog @@ -1,3 +1,9 @@ +1999-01-20 Theodore Ts'o + + * krb5.tex (krb5_mk_safe): Fix reference to a non-existent flag. + (KRB5_AUTH_CONTEXT_DO_TIME_NOTIME should have been + KRB5_AUTH_CONTEXT_DO_TIME). [krb5-doc/528] + Thu Jun 6 15:50:39 1996 Theodore Y. Ts'o * krb5.tex: Update function prototype for krb5_encrypt_tkt_part diff --git a/doc/api/krb5.tex b/doc/api/krb5.tex index 6cb7f94..b529c11 100644 --- a/doc/api/krb5.tex +++ b/doc/api/krb5.tex @@ -1479,7 +1479,7 @@ KRB5_AUTH_CONTEXT_RET_SEQUENCE & Copy sequence numbers\\ If timestamps are to be used (i.e., if KRB5_AUTH_CONTEXT_DO_TIME is set), an entry describing the message will be entered in the replay cache so that the caller may detect if this message is sent -back to him by an attacker. If KRB5_AUTH_CONTEXT_DO_TIME_NOTIME is not set, +back to him by an attacker. If KRB5_AUTH_CONTEXT_DO_TIME is not set, the \funcparam{auth_context} replay cache is not used. If sequence numbers are to be used (i.e., if either diff --git a/doc/build.texinfo b/doc/build.texinfo index 5852c06..bee77fe 100644 --- a/doc/build.texinfo +++ b/doc/build.texinfo @@ -37,14 +37,18 @@ link tree for your build tree. The first step in each of these build procedures is to unpack the source distribution. The Kerberos V5 distribution comes in two compressed tar -files. The first file, which is generally named @file{krb5.src.tar.gz}, -contains the sources for all of Kerberos except for the crypto library, -which is found in the file @file{krb5.crypto.tar.gz}. +files. The first file, which is generally named +@file{krb5-1.0.src.tar.gz}, contains the sources for all of Kerberos +except for the crypto library, which is found in the file +@file{krb5-1.0.crypto.tar.gz}. Both files should be unpacked in the same directory, such as -@file{/u1/krb5}. (In the rest of this document, we will assume that you -have chosen to unpack the Kerberos V5 source distribution in this -directory.) +@file{/u1/krb5-1.0}. (In the rest of this document, we will assume that +you have chosen to unpack the Kerberos V5 source distribution in this +directory. Note that the tarfiles will by default all unpack into the +@file{./krb5-1.0} directory, so that if your current directory is +@file{/u1} when you unpack the tarfiles, you will get +@file{/u1/krb5-1.0/src}, etc.) @node Doing the Build, Testing the Build, Unpacking the Sources, Building Kerberos V5 @@ -73,7 +77,7 @@ use the following abbreviated procedure. @enumerate @item - @code{cd /u1/krb5/src} + @code{cd /u1/krb5-1.0/src} @item @code{./configure} @item @@ -96,9 +100,9 @@ you might use the following procedure: @enumerate @item -@code{mkdir /u1/krb5/pmax} +@code{mkdir /u1/krb5-1.0/pmax} @item - @code{cd /u1/krb5/pmax} + @code{cd /u1/krb5-1.0/pmax} @item @code{../src/configure} @item @@ -118,11 +122,11 @@ you might use the following procedure: @enumerate @item - @code{mkdir /u1/krb5/solaris} + @code{mkdir /u1/krb5-1.0/solaris} @item - @code{cd /u1/krb5/solaris} + @code{cd /u1/krb5-1.0/solaris} @item - @code{/u1/krb5/src/util/lndir `pwd`/../src} + @code{/u1/krb5-1.0/src/util/lndir `pwd`/../src} @item @code{./configure} @item @@ -148,9 +152,10 @@ building Kerberos; see @ref{Doing the Build}.): @menu * The DejaGnu Tests:: +* The KADM5 Tests:: @end menu -@node The DejaGnu Tests, , Testing the Build, Testing the Build +@node The DejaGnu Tests, The KADM5 Tests, Testing the Build, Testing the Build @subsection The DejaGnu Tests Some of the built-in regression tests are setup to use the DejaGnu @@ -158,24 +163,52 @@ framework for running tests. These tests tend to be more comprehensive than the normal built-in tests as they setup test servers and test client/server activities. -DejaGnu may be found wherever GNU software is archived. +DejaGnu may be found wherever GNU software is archived. -Most of the tests are setup to run as a non-privledged user. There are -two series of tests (@samp{rlogind} and @samp{telnetd}) which require -the ability to @samp{rlogin} as root to the local machine. Admittedly, -this does require the use of a @file{.rhosts} file or some other -authenticated means. @footnote{If you are fortunate enough to have a -previous version of Kerberos V5 or V4 installed, and the Kerberos rlogin -is first in your path, you can setup @file{.k5login} or @file{.klogin} -respectively to allow you access.} +Most of the tests are setup to run as a non-privledged user. For some +of the krb-root tests to work properly, either (a) the user running the +tests must not have a .k5login file in the home directory or (b) the +.k5login file must contain an entry for @code{@@KRBTEST.COM}. +There are two series of tests (@samp{rlogind} and @samp{telnetd}) which +require the ability to @samp{rlogin} as root to the local +machine. Admittedly, this does require the use of a @file{.rhosts} file +or some authenticated means. @footnote{If you are fortunate enough to +have a previous version of Kerberos V5 or V4 installed, and the Kerberos +rlogin is first in your path, you can setup @file{.k5login} or +@file{.klogin} respectively to allow you access.} If you cannot obtain root access to your machine, all the other tests will still run. Note however, with DejaGnu 1.2, the "untested testcases" will cause the testsuite to exit with a non-zero exit status which @samp{make} will consider a failure of the testing process. Do not worry about this, as these tests are the last run when @samp{make check} is -executed from the top level of the build tree. - +executed from the top level of the build tree. This problem does not +exist with DejaGnu 1.3. + +@node The KADM5 Tests, , The DejaGnu Tests, Testing the Build +@subsection The KADM5 Tests + +Regression tests for the KADM5 system, including the GSS-RPC, KADM5 +client and server libraries, and kpasswd, are also included in this +release. Each set of KADM5 tests is contained in a sub-directory called +@code{unit-test} directly below the system being tested. For example, +lib/rpc/unit-test contains the tests for GSS-RPC. The tests are all +based on DejaGnu (but they are not actually called part of "The DejaGnu +tests," whose naming predates the inclusion of the KADM5 system). In +addition, they require the Tool Command Language (TCL) header files and +libraries to be available during compilation and some of the tests also +require Perl in order to operate. If all of these resources are not +available during configuration, the KADM5 tests will not run. The TCL +installation directory can be specified with the @code{--with-tcl} +configure option (see @xref{Options to Configure}). The runtest and +perl programs must be in the current execution path. + +If you install DejaGnu, TCL, or Perl after configuring and building +Kerberos and then want to run the KADM5 tests, you will need to +re-configure the tree and run @code{make} at the top level again to make +sure all the proper programs are built. To save time, you actually only +need to reconfigure and build in the directories src/kadmin/testing, +src/lib/rpc, src/lib/kadm5, and src/kpasswd. @node Options to Configure, osconf.h, Testing the Build, Building Kerberos V5 @section Options to Configure @@ -192,17 +225,25 @@ program. Provides help to configure. This will list the set of commonly used options for building Kerberos. -@item --prefix=DIR +@item --prefix=PREFIX By default, Kerberos will install the package's files rooted at `/usr/local' as in `/usr/local/bin', `/usr/local/sbin', etc. If you -desire a different location use this option. +desire a different location, use this option. -@item --exec-prefix=DIR +@item --exec-prefix=EXECPREFIX This option allows one to separate the architecture independent programs from the configuration files and manual pages. +@item --localstatedir=LOCALSTATEDIR + +This option sets the directory for locally modifiable single-machine +data. In Kerberos, this mostly is useful for setting a location for the +KDC data files, as they will be installed in +@code{LOCALSTATEDIR/krb5kdc}, which is by default +@code{PREFIX/var/krb5kdc}. + @item --with-cc=COMPILER Use @code{COMPILER} as the C compiler. @@ -239,10 +280,11 @@ builtin Kerberos V4 library. @item --with-krb4=KRB4DIR -This option enables Kerberos V4 backwards compatibility. The directory -specified by @code{KRB4DIR} specifies where the V4 header files should -be found (@file{/KRB4DIR/include}) as well as where the V4 Kerberos -library should be found (@file{/KRB4DIR/lib}). +This option enables Kerberos V4 backwards compatibility using a +pre-existing Kerberos V4 installation. The directory specified by +@code{KRB4DIR} specifies where the V4 header files should be found +(@file{KRB4DIR/include}) as well as where the V4 Kerberos library should +be found (@file{KRB4DIR/lib}). @item --without-krb4 @@ -280,22 +322,12 @@ you're using slave servers!!! It also causes the database to be modified (and thus needing to be locked) frequently. Please note that the implementors do not regularly test this feature. -@item --with-kdb-db=database - -The configuration process will try to determine a working set of -libraries required to implement the Kerberos database. Configure will -look for interfaces that use or emulate a @samp{ndbm} or @samp{dbm} -library. Failing that, a build in copy of the Berkeley DB code will be -used. You may decide to compile a different interface than the default -by specifying one of "ndbm", "dbm", or "db". +@item --with-tcl=TCLPATH -An important note on platforms where the @samp{ndbm} implementation is -based on @sc{GDBM} (such as the Linux Slackware distribution). @sc{GDBM} -has its own built in file locking which prevents simultaneous access to -the database from two separate processes in which one wants to modify -the database while the otherone only wants to read. (i.e. the KDC and -administrative servers). In this case, you will need to specify the use -of the Berkeley DB. +Some of the unit-tests in the build tree rely upon using a program in +Tcl. The directory specified by @code{TCLPATH} specifies where the Tcl +header file (@file{TCLPATH/include/tcl.h} as well as where the Tcl +library should be found (@file{TCLPATH/lib}). @end table @@ -330,11 +362,6 @@ realms, their KDCs, etc. The profile file format is no longer the same format as Kerberos V4's @file{krb.conf} file. -@item DEFAULT_LNAME_FILENAME - -The pathname to the database that maps authentication names to local -account names. See kdb5_anadd(8). - @item DEFAULT_KEYTAB_NAME The type and pathname to the default server keytab file (the equivalent @@ -371,7 +398,7 @@ of the libraries may be installed on the same system and continue to work. Currently the supported platforms are: NetBSD 1.0A, AIX 3.2.5, AIX 4.1, -Solaris 5.3, Alpha OSF/1 >= 2.1, HP-UX >= 9.X. +Solaris 2.4 (aka SunOS 5.4), Alpha OSF/1 >= 2.1, HP-UX >= 9.X. To enable shared libraries on the above platforms, run the configure script with the option @samp{--enable-shared}. @@ -390,9 +417,10 @@ one in the tree or you will be missing references. @section Operating System Incompatibilities This section details operating system incompatibilities with Kerberos V5 -which have been reported to the developers at MIT. If you find additional -incompatibilities, and/or discover work arounds to such problems, please -send a report to @b{krb5-bugs@@mit.edu}. Thanks! +which have been reported to the developers at MIT. If you find +additional incompatibilities, and/or discover work arounds to such +problems, please send a report via the @code{krb5-send-pr} program. +Thanks! @menu * AIX:: @@ -503,10 +531,6 @@ LD_LIBRARY_PATH environment variable when you compile it. Alternatively you can use the @code{-i} option to @samp{cc}, by using the specifying @code{--with-ccopts=-i} option to @samp{configure}. -Shared library support only works when using the Sunsoft C compiler. We -are currently using version 3.0.1. (The latest GCC may work; this -needs to be tested.) - @node SGI Irix 5.X, Ultrix 4.2/3, Solaris 2.X, OS Incompatibilities @subsection SGI Irix 5.X @@ -581,7 +605,7 @@ that you have made a change that will require that all the @code{--force} option: @example -% cd /u1/krb5/src +% cd /u1/krb5-1.0/src % ./util/reconf --force @end example @@ -601,7 +625,7 @@ Then follow the instructions for building packaged source trees (above). To install the binaries into a binary tree, do: @example -% cd /u1/krb5/src +% cd /u1/krb5-1.0/src % make all % make install DESTDIR=somewhere-else @end example diff --git a/doc/copyright.texinfo b/doc/copyright.texinfo index a91a9ad..04601e2 100644 --- a/doc/copyright.texinfo +++ b/doc/copyright.texinfo @@ -23,9 +23,9 @@ It is provided ``as is'' without express or implied warranty. @vskip 12pt @end iftex -The following copyright and permission notice applies to the -OpenVision Kerberos Administration system located in kadmin/create, -kadmin/dbutil, kadmin/server, lib/kadm, and portions of lib/rpc: +The following copyright and permission notice applies to the OpenVision +Kerberos Administration system located in kadmin/create, kadmin/dbutil, +kadmin/passwd, kadmin/server, lib/kadm5, and portions of lib/rpc: @quotation Copyright, OpenVision Technologies, Inc., 1996, All Rights Reserved @@ -36,20 +36,22 @@ terms. If you do not agree to the following terms, do not retrieve the OpenVision Kerberos administration system. You may freely use and distribute the Source Code and Object Code -compiled from it, but this Source Code is provided to you "AS IS" -EXCLUSIVE OF ANY WARRANTY, INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES -OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, OR ANY OTHER -WARRANTY, WHETHER EXPRESS OR IMPLIED. IN NO EVENT WILL OPENVISION HAVE -ANY LIABILITY FOR ANY LOST PROFITS, LOSS OF DATA OR COSTS OF PROCUREMENT -OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY SPECIAL, INDIRECT, OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, INCLUDING, WITHOUT -LIMITATION, THOSE RESULTING FROM THE USE OF THE SOURCE CODE, OR THE -FAILURE OF THE SOURCE CODE TO PERFORM, OR FOR ANY OTHER REASON. +compiled from it, with or without modification, but this Source Code is +provided to you "AS IS" EXCLUSIVE OF ANY WARRANTY, INCLUDING, WITHOUT +LIMITATION, ANY WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A +PARTICULAR PURPOSE, OR ANY OTHER WARRANTY, WHETHER EXPRESS OR IMPLIED. +IN NO EVENT WILL OPENVISION HAVE ANY LIABILITY FOR ANY LOST PROFITS, +LOSS OF DATA OR COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR +FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS +AGREEMENT, INCLUDING, WITHOUT LIMITATION, THOSE RESULTING FROM THE USE +OF THE SOURCE CODE, OR THE FAILURE OF THE SOURCE CODE TO PERFORM, OR FOR +ANY OTHER REASON. -OpenVision retains all rights, title, and interest in the donated Source -Code. With respect to OpenVision's copyrights in the donated Source -Code, OpenVision also retains rights to derivative works of the Source -Code whether created by OpenVision or a third party. +OpenVision retains all copyrights in the donated Source Code. OpenVision +also retains copyright to derivative works of the Source Code, whether +created by OpenVision or by a third party. The OpenVision copyright +notice must be preserved if derivative works are made based on the +donated Source Code. OpenVision Technologies, Inc. has donated this Kerberos Administration system to MIT for inclusion in the standard Kerberos 5 distribution. diff --git a/doc/definitions.texinfo b/doc/definitions.texinfo index 93cc3b9..19b2b0f 100644 --- a/doc/definitions.texinfo +++ b/doc/definitions.texinfo @@ -23,8 +23,8 @@ @set PREVRELEASE beta 7 @set INSTALLDIR /usr/@value{LCPRODUCT} @set PREVINSTALLDIR @value{INSTALLDIR} -@set ROOTDIR /usr/@value{LCPRODUCT} -@set BINDIR /usr/@value{LCPRODUCT}/bin +@set ROOTDIR /usr/local +@set BINDIR /usr/local/bin @set SECONDDOMAIN fubar.org @set SECONDREALM FUBAR.ORG @set UPDATED @today diff --git a/doc/install.texinfo b/doc/install.texinfo index 216abf9..f5c4396 100644 --- a/doc/install.texinfo +++ b/doc/install.texinfo @@ -16,7 +16,7 @@ @end iftex @include definitions.texinfo -@set EDITION b7-1 +@set EDITION 1.0 @finalout @c don't print black warning boxes @@ -123,10 +123,17 @@ installation procedure is somewhat involved, and requires forethought and planning. @value{COMPANY} has attempted to make this @value{PRODUCT} Installation Guide as concise as possible, rather than making it an exhaustive description of the details of Kerberos. +@ifset CYGNUS Consequently, everything in this guide appears because @value{COMPANY} believes that it is important. Please read and follow these instructions carefully, and if there is anything you do not understand or are not sure of, please don't hesitate to call us. +@end ifset +@ifset MIT +Consequently, everything in this guide appears because @value{COMPANY} +believes that it is important. Please read and follow these +instructions carefully. +@end ifset @node Overview of This Guide, , Please Read the Documentation, Introduction @section Overview of This Guide @@ -134,7 +141,7 @@ or are not sure of, please don't hesitate to call us. The next chapter describes the decisions you need to make before installing @value{PRODUCT}. -Chapter three describes installation procedures for each class of +Chapter four describes installation procedures for each class of Kerberos machines: @enumerate @@ -150,28 +157,20 @@ Slave KDCs. @end enumerate @item -Client machines (user machines): - -@enumerate A -@item -UNIX client machines. - -@item -Windows machines. - -@item -Macintoshes. -@end enumerate +UNIX client machines @item -application server machines +UNIX application server machines @end enumerate @noindent Note that a machine can be both a client machine and an application server. -Chapter four describes our problem reporting system. +Chapter five describes procedure for updating previous installations of +@value{PRODUCT}. + +Chapter six describes our problem reporting system. The appendices give sample configuration files. @@ -225,7 +224,7 @@ Kerberos realm @value{SECONDREALM}. If you need multiple Kerberos realms, @value{COMPANY} recommends that you use descriptive names which end with your domain name, such as -BOSTON.@value{SECONDREALM} and SAN_FRANCISCO.@value{SECONDREALM}. +BOSTON.@value{SECONDREALM} and HOUSTON.@value{SECONDREALM}. @node Mapping Hostnames onto Kerberos Realms, Ports for the KDC and Admin Services, Kerberos Realms, Realm Configuration Decisions @section Mapping Hostnames onto Kerberos Realms @@ -237,6 +236,12 @@ hostname-by-hostname basis. Since greater specificity takes precedence, you would do this by specifying the mappings for a given domain or subdomain and listing the exceptions. +The @value{PRODUCT} System Administrator's Guide contains a thorough +description of the parts of the @code{krb5.conf} file and what may be +specified in each. A sample @code{krb5.conf} file appears in +@ref{krb5.conf}. You should be able to use this file, substituting the +relevant information for your Kerberos instllation for the samples. + @node Ports for the KDC and Admin Services, Slave KDCs, Mapping Hostnames onto Kerberos Realms, Realm Configuration Decisions @section Ports for the KDC and Admin Services @@ -271,9 +276,10 @@ Have at least one slave KDC as a backup, for when the master KDC is down, is being upgraded, or is otherwise unavailable. @item -If your network is split such that a network outage is likely to cause -some segment or segments of the network to become cut off or isolated, -have a slave KDC accessible to each segment. +If your network is split such that a network outage is likely to cause a +network partition (some segment or segments of the network to become cut +off or isolated from other segments), have a slave KDC accessible to +each segment. @item If possible, have at least one slave KDC in a different building from @@ -304,7 +310,7 @@ effect. If the propagation time is longer than this maximum reasonable time (@i{e.g.,} you have a particularly large database, you have a lot of -slaves, and/or you experience frequent network delays), you may wish to +slaves, or you experience frequent network delays), you may wish to cut down on your propagation delay by performing the propagation in parallel. To do this, have the master KDC propagate the database to one set of slaves, and then have each of these slaves propagate the database @@ -326,20 +332,9 @@ The sections of this chapter describe procedures for installing The KDCs @item -Client machines - -@enumerate A -@item UNIX client machines @item -Windows machines - -@item -Macintoshes -@end enumerate - -@item UNIX Application Servers @end enumerate @@ -359,12 +354,12 @@ regular intervals. All database changes (such as password changes) are made on the master KDC. Slave KDCs provide Kerberos ticket-granting services, but not database -access. This allows clients to continue to obtain tickets when the -master KDC is unavailable. +administration. This allows clients to continue to obtain tickets when +the master KDC is unavailable. -@value{COMPANY}'s recommends that you install all of your KDCs to be -able to function as either the master or one of the slaves. This will -enable you to easily switch your master KDC with one of the slaves if +@value{COMPANY} recommends that you install all of your KDCs to be able +to function as either the master or one of the slaves. This will enable +you to easily switch your master KDC with one of the slaves if necessary. (@xref{Switching Master and Slave KDCs}.) This installation procedure is based on that recommendation. @@ -401,9 +396,20 @@ Modify the configuration files, @code{/etc/krb5.conf} (@pxref{krb5.conf}) and @code{@value{ROOTDIR}/var/krb5kdc/kdc.conf} (@pxref{kdc.conf}) to reflect the correct information (such as the hostnames and realm name) for your realm. @value{COMPANY} recommends -that you keep @code{krb5.conf} in @code{/etc}. The @code{krb5.conf} -file may contain a pointer to @code{kdc.conf}, which you need to change -if you want to move @code{kdc.conf} to another location. +that you keep @code{krb5.conf} in @code{/etc}. + +Among the settings in your @code{/etc/krb5.conf} file, be sure to create +a @code{[logging]} stanza so that the KDC and kadmind will generate +logging output. For example: + +@smallexample +@group +[logging] + kdc = FILE:/var/log/krb5kdc.log + admin_server = FILE:/var/log/kadmin.log + default = FILE:/var/log/krb5lib.log +@end group +@end smallexample @node Create the Database, Add Administrators to the Acl File, Edit the Configuration Files, Install the Master KDC @subsubsection Create the Database @@ -430,11 +436,10 @@ words that can be found in a dictionary, any common or popular name, especially a famous person (or cartoon character), your username in any form (@i{e.g.}, forward, backward, repeated twice, @i{etc.}), and any of the sample keys that appear in this manual. One example of a key which -would be good if it did not appear in this manual is ``MITiys4K5!'', -which represents the sentence ``@value{COMPANY} is your source for -Kerberos 5!'' (It's the first letter of each word, substituting the -numeral ``4'' for the word ``for'', and includes the punctuation mark at -the end.) +might be good if it did not appear in this manual is ``MITiys4K5!'', +which represents the sentence ``MIT is your source for Kerberos 5!'' +(It's the first letter of each word, substituting the numeral ``4'' for +the word ``for'', and includes the punctuation mark at the end.) The following is an example of how to create a Kerberos database and stash file on the master KDC, using the @code{kdb5_util} command. (The @@ -554,7 +559,10 @@ instance ``root'', you would add the following line to the acl file: Next you need to add administrative principals to the Kerberos database. (You must add at least one now.) To do this, use @code{kadmin.local} -@emph{on the master KDC}, as in the following example: +@emph{on the master KDC}. The administrative principals you create +should be the ones you added to the ACL file (see @xref{Add +Administrators to the Acl File}). In the following example, the +administration principal @code{admin/admin} is created: @smallexample @group @@ -575,6 +583,8 @@ kadmin.local:} @end group @end smallexample + + @node Create a kadmind Keytab, Start the Kerberos Daemons, Add Administrators to the Kerberos Database, Install the Master KDC @subsubsection Create a kadmind Keytab @@ -606,7 +616,7 @@ kadmin.local:} quit @noindent As specified in the @samp{-k} argument, @code{ktadd} will save the -extracted keytab as @code{@value{ROOTDIR}/var/krb5kdc/kadm5.keytab}. +extracted keytab as @* @code{@value{ROOTDIR}/var/krb5kdc/kadm5.keytab}. The filename you use must be the one specified in your @code{kdc.conf} file. @@ -628,6 +638,21 @@ these daemons to start up automatically at boot time, you can add them to the KDC's @code{/etc/rc} or @code{/etc/inittab} file. You need to have a stash file in order to do this. +You can verify that they started properly by checking for their startup +messages in the logging locations you defined in @code{/etc/krb5.conf} +(see @xref{Edit the Configuration Files}). For example: + +@smallexample +@b{shell%} tail /var/log/krb5kdc.log +Dec 02 12:35:47 beeblebrox krb5kdc[3187](info): commencing operation +@b{shell%} tail /var/log/kadmin.log +Dec 02 12:35:52 beeblebrox kadmind[3189](info): starting +@end smallexample + +Any errors the daemons encounter while starting will also be listed in +the logging output. + + @node Install the Slave KDCs, Back on the Master KDC, Install the Master KDC, Installing KDCs @subsection Install the Slave KDCs @@ -657,15 +682,15 @@ named @value{KDCSLAVE1}.@value{PRIMARYDOMAIN} and @smallexample @group @b{shell%} @value{ROOTDIR}/sbin/kadmin -@b{kadmin:} addprinc -randpass host/@value{KDCSERVER}.@value{PRIMARYDOMAIN} +@b{kadmin:} addprinc -randkey host/@value{KDCSERVER}.@value{PRIMARYDOMAIN} @b{WARNING: no policy specified for "host/@value{KDCSERVER}.@value{PRIMARYDOMAIN}@@@value{PRIMARYREALM}"; defaulting to no policy. Principal "host/@value{KDCSERVER}.@value{PRIMARYDOMAIN}@@@value{PRIMARYREALM}" created. -kadmin:} addprinc -randpass host/@value{KDCSLAVE1}.@value{PRIMARYDOMAIN} +kadmin:} addprinc -randkey host/@value{KDCSLAVE1}.@value{PRIMARYDOMAIN} @b{WARNING: no policy specified for "host/@value{KDCSLAVE1}.@value{PRIMARYDOMAIN}@@@value{PRIMARYREALM}"; defaulting to no policy. Principal "host/@value{KDCSLAVE1}.@value{PRIMARYDOMAIN}@@@value{PRIMARYREALM}" created.} -@b{kadmin:} addprinc -randpass host/@value{KDCSLAVE2}.@value{PRIMARYDOMAIN} +@b{kadmin:} addprinc -randkey host/@value{KDCSLAVE2}.@value{PRIMARYDOMAIN} @b{WARNING: no policy specified for "host/@value{KDCSLAVE2}.@value{PRIMARYDOMAIN}@@@value{PRIMARYREALM}"; defaulting to no policy. Principal "host/@value{KDCSLAVE2}.@value{PRIMARYDOMAIN}@@@value{PRIMARYREALM}" created. @@ -758,8 +783,8 @@ KDC: kerberos 88/udp kdc # Kerberos authentication (udp) kerberos 88/tcp kdc # Kerberos authentication (tcp) krb5_prop 754/tcp # Kerberos slave propagation -kerberos-adm 749/tcp # Kerberos 5 admin/changepw (tcp) -kerberos-adm 749/udp # Kerberos 5 admin/changepw (udp) +kerberos-adm 749/tcp # Kerberos 5 admin/changepw (tcp) +kerberos-adm 749/udp # Kerberos 5 admin/changepw (udp) eklogin 2105/tcp # Kerberos encrypted rlogin @end group @end smallexample @@ -1350,7 +1375,8 @@ terminology. @node Bug Reports for Kerberos V5, Files, Upgrading Existing Kerberos V5 Installations, Top @chapter Bug Reports for @value{PRODUCT} -@include bug-report.texinfo + +@include send-pr.texinfo @node Files, , Bug Reports for Kerberos V5, Top @appendix Files diff --git a/doc/krb425.texinfo b/doc/krb425.texinfo index 2ff2b3e..e78d4e6 100644 --- a/doc/krb425.texinfo +++ b/doc/krb425.texinfo @@ -3,11 +3,11 @@ @c definitions added by jcb. @c %**start of header @c guide -@setfilename Kerberos-V4-to-V5.info +@setfilename krb425.info @settitle Upgrading to Kerberos V5 from Kerberos V4 -@c @setchapternewpage odd @c chapter begins on next odd page -@setchapternewpage on @c chapter begins on next page -@smallbook @c Format for 7" X 9.25" paper +@setchapternewpage odd @c chapter begins on next odd page +@c @setchapternewpage on @c chapter begins on next page +@c @smallbook @c Format for 7" X 9.25" paper @c %**end of header @paragraphindent 0 @@ -16,7 +16,7 @@ @end iftex @include definitions.texinfo -@set EDITION 0.1 alpha +@set EDITION 1.0 @set UPDATED October 8, 1996 @finalout @c don't print black warning boxes @@ -34,15 +34,13 @@ @include copyright.texinfo @end titlepage -@node Top, Introduction, (dir), (dir) +@node Top, Copyright, (dir), (dir) @ifinfo This document describes how to convert to @value{PRODUCT} from Kerberos V4. -@include copyright.texinfo -@end ifinfo - @menu +* Copyright:: * Introduction:: * Configuration Files:: * Upgrading KDCs:: @@ -51,7 +49,13 @@ This document describes how to convert to @value{PRODUCT} from Kerberos V4. * Firewall Considerations:: @end menu -@node Introduction, Configuration Files, Top, Top +@node Copyright, Introduction, Top, Top +@unnumbered Copyright +@include copyright.texinfo + +@end ifinfo + +@node Introduction, Configuration Files, Copyright, Top @chapter Introduction As with most software upgrades, @value{PRODUCT} is generally backward @@ -173,7 +177,7 @@ Create a dump of the V4 database in the directory where your V5 database will reside by issuing the command: @smallexample -% kdb_util dump @value{INSTALLDIR}/lib/krb5kdc/v4-dump +% kdb_util dump @value{ROOTDIR}/var/krb5kdc/v4-dump @end smallexample @item @@ -266,6 +270,7 @@ telnet stream tcp nowait root @end group @end smallexample +@ifset CYGNUS @strong{N.B.}: As noted in the @value{PRODUCT} Installation Guide, if you have some clients running older versions of Kerberos V5 (beta 6@footnote{@value{PRODUCT} is based on the MIT beta 7 release.} or @@ -273,6 +278,15 @@ earlier), checksums were done differently in those versions, which will cause authentication to fail. To get around this problem, have the @code{klogind} and @code{kshd} daemons ignore checksums, by replacing each @code{-c} flag above with @code{-i}. +@end ifset +@ifclear CYGNUS +@strong{N.B.}: As noted in the @value{PRODUCT} Installation Guide, if +you have some clients running older versions of Kerberos V5 (beta 6 or +earlier), checksums were done differently in those versions, which will +cause authentication to fail. To get around this problem, have the +@code{klogind} and @code{kshd} daemons ignore checksums, by replacing +each @code{-c} flag above with @code{-i}. +@end ifclear For an @emph{insecure} server, make the changes described in the @value{PRODUCT} Installation Guide. @@ -288,7 +302,7 @@ follows: @group @b{#} @value{ROOTDIR}/sbin/ktutil @b{ktutil:} rst /etc/krb-srvtab -@b{ktutil:} wkt /etc/v5srvtab +@b{ktutil:} wkt /etc/krb5.keytab @b{ktutil:} q @b{#} @end group diff --git a/doc/krb5-protocol/krb5.constants b/doc/krb5-protocol/krb5.constants index ed70559..e7cc5b8 100644 --- a/doc/krb5-protocol/krb5.constants +++ b/doc/krb5-protocol/krb5.constants @@ -13,6 +13,8 @@ des-cbc-md4 2 8 0 8 des-cbc-md5 3 8 0 8 4 des3-cbc-md5 5 8 0 8 + 6 +des3-cbc-sha1 7 8 0 8 0x8003 -------------------------------+-------------------+------------- @@ -26,7 +28,10 @@ des-mac-k 5 8 rsa-md4-des-k 6 16 rsa-md5 7 16 rsa-md5-des 8 24 -rsa-md5-des3 9 24 + 9 + 10 +nist-sha1 11 20 +hmac-sha1-des3 12 20 -------------------------------+----------------- padata type |padata-type value @@ -42,6 +47,8 @@ PA-OSF-DCE 8 PA-CYBERSAFE-SECUREID 9 PA-AFS3-SALT 10 PA-ETYPE-INFO 11 +PAM-SAM-CHALLENGE 12 +PAM-SAM-RESPONSE 13 -------------------------------+------------- authorization data type |ad-type value @@ -120,6 +127,7 @@ KDC_ERR_KEY_EXPIRED 23 Password has expired - change to reset KDC_ERR_PREAUTH_FAILED 24 Pre-authentication information was invalid KDC_ERR_PREAUTH_REQUIRED 25 Additional pre-authentication required* KDC_ERR_SERVER_NOMATCH 26 Requested server and ticket don't match +KDC_ERR_MUST_USE_USER2USER 27 Server principal valid for user2user only KRB_AP_ERR_BAD_INTEGRITY 31 Integrity check on decrypted field failed KRB_AP_ERR_TKT_EXPIRED 32 Ticket expired KRB_AP_ERR_TKT_NYV 33 Ticket not yet valid diff --git a/doc/send-pr.texinfo b/doc/send-pr.texinfo index 628b141..9209ffd 100644 --- a/doc/send-pr.texinfo +++ b/doc/send-pr.texinfo @@ -1,88 +1,75 @@ -If you have problems installing @value{PRODUCT}, please use the -@code{send-pr} program to fill out a Problem Report. +In any complex software, there will be bugs. If you have successfully +built and installed @value{PRODUCT}, please use the +@code{krb5-send-pr} program to fill out a Problem Report. -The @code{send-pr} program is installed in the directory -@code{@value{ROOTDIR}/bin}. - -@need 1100 -Before using @code{send-pr} for the first time, you need to install your -customer support ID into the program, by typing the command: - -@smallexample -@b{shell%} install-sid @i{customerID} -@end smallexample +Bug reports that include proposed fixes are especially welcome. If you +do include fixes, please send them using either context diffs or unified +diffs (using @samp{diff -c} or @samp{diff -u}, respectively). -@noindent replacing @i{customerID} with your customer ID, which your -sales representative will supply. +The @code{krb5-send-pr} program is installed in the directory +@code{@value{ROOTDIR}/sbin}. -The @code{send-pr} program enters the problem report into our Problem -Report Management System (PRMS), which automatically assigns it to the -engineer best able to help you with problems in the assigned category. +The @code{krb5-send-pr} program enters the problem report into our +Problem Report Management System (PRMS), which automatically assigns it +to the engineer best able to help you with problems in the assigned +category. +@ifset CYGNUS The engineer will work with you via email, telephone, or both, and all email related to this Problem Report will be tracked by PRMS for future -reference. If the engineer does not reply to you after a certain time, -a reminder is automatically generated. If you need to talk to someone -else in our organization about the problem (@i{e.g.}, if the engineer -gets hit by a truck), we can find out what the current state is through -the PR number. @value{COMPANY} uses PRMS for almost all of the real -problems we handle. - -The @code{send-pr} program will try to intelligently fill in as many -fields as it can. You need to choose the @dfn{category}, @dfn{class}, -@dfn{severity}, and @dfn{priority} of the problem, as well as giving us -as much information as you can about its exact nature. +reference. If you need to talk to someone else in our organization +about the problem (@i{e.g.}, if the engineer gets hit by a truck), we +can find out what the current state is through the PR number. +@end ifset + +The @code{krb5-send-pr} program will try to intelligently fill in as +many fields as it can. You need to choose the @dfn{category}, +@dfn{class}, @dfn{severity}, and @dfn{priority} of the problem, as well +as giving us as much information as you can about its exact nature. @need 1000 The PR @b{category} will be one of: @smallexample @group -kerberos kerbnet doc help-request -info-request install query-pr id-request -send-pr +krb5-admin krb5-appl krb5-build krb5-clients +krb5-doc krb5-kdc krb5-libs krb5-misc +pty telnet test @end group @end smallexample -In general, if specific knowledge about Kerberos is requried to answer a -PR, use the @i{kerberos} or @i{doc} categories. The @i{install} -category is for problems retrieving the code off the media (@i{e.g.}, -the data on a tape seems to be corrupted.) Questions about the -installation procedures described in this document would fall under the -category @i{kerberos}. The @i{help-request} and @i{info-request} -categories are for general questions about your contract, or other -issues not necessarily related to @value{PRODUCT}. Use @i{query-pr} to -receive a current copy of your Problem Report, @i{id-request} if you -need a customer ID, and @i{send-pr} if you're having trouble using -send-pr. If your question is related to @value{PRODUCT} and you're not -sure what the most appropriate category should be, use @i{kerberos}. -The engineer can change the category if necessary. +@noindent +Choose the category that best describes the area under which your +problem falls. The @b{class} can be @dfn{sw-bug}, @dfn{doc-bug}, @dfn{change-request}, -or @dfn{support}. The first two are exactly as their names imply. The -@i{change-request} class is to inform us of changes, such as new email -addresses or new contact information. The @i{support} class is intended -for general questions about using the @value{PRODUCT} clients or -libraries. +or @dfn{support}. The first two are exactly as their names imply. Use +@i{change-request} when the software is behaving according to +specifications, but you want to request changes in some feature or +behavior. The @i{support} class is intended for more general questions +about building or using @value{PRODUCT}. The @b{severity} of the problem indicates the problem's impact on the -usability of the @value{PRODUCT} software package. If a problem is -@dfn{critical}, that means the product, component or concept is -completely non-operational, or some essential functionality is missing, -and no workaround is known. A @dfn{serious} problem is one in which the -product, component or concept is not working properly or significant -functionality is missing. Problems that would otherwise be considered -@i{critical} are rated @i{serious} when a workaround is known. A -@dfn{non-critical} problem is one that is indeed a problem, but one that -is having a minimal affect on your ability to use @value{PRODUCT}. -@i{E.g.}, The product, component or concept is working in general, but -lacks features, has irritating behavior, does something wrong, or -doesn't match its documentation. The default severity is @i{serious}. +usability of @value{PRODUCT}. If a problem is @dfn{critical}, that +means the product, component or concept is completely non-operational, +or some essential functionality is missing, and no workaround is known. +A @dfn{serious} problem is one in which the product, component or +concept is not working properly or significant functionality is missing. +Problems that would otherwise be considered @i{critical} are rated +@i{serious} when a workaround is known. A @dfn{non-critical} problem is +one that is indeed a problem, but one that is having a minimal effect on +your ability to use @value{PRODUCT}. @i{E.g.}, The product, component +or concept is working in general, but lacks features, has irritating +behavior, does something wrong, or doesn't match its documentation. The +default severity is @i{serious}. The @b{priority} indicates how urgent this particular problem is in relation to your work. Note that low priority does not imply low -importance. @value{COMPANY} considers all problems important, and -encourages its customers to be realistic about priority ratings. A -priority of @dfn{high} means a solution is needed as soon as possible. +importance. +@ifset CYGNUS +@value{COMPANY} considers all problems important, and +encourages its customers to be realistic about priority ratings. +@end ifset +A priority of @dfn{high} means a solution is needed as soon as possible. A priority of @dfn{medium} means the problem should be solved no later than the next release. A priority of @dfn{low} means the problem should be solved in a future release, but it is not important to your work how @@ -94,10 +81,8 @@ you are faced with a hard deadline. Conversely, a serious problem might have a low priority if the feature it is disabling is one that you do not need. -The @b{release} is as labeled on the software that was shipped. -@i{e.g.}, @code{kerbnet-@value{RELEASE}}. It is important that you tell -us which release you are using, and whether or not you have made any -private changes. +It is important that you fill in the @i{release} field and tell us +what changes you have made, if any. Bug reports that include proposed fixes are especially welcome. If you include proposed fixes, please send them using either context diffs @@ -113,50 +98,35 @@ look like this: @smallexample @group -To: bugs@@cygnus.com -Subject: "KDC reply did not match expectations" error -From: joe.smith@@toasters.com -Reply-To: joe.smith@@toasters.com -X-send-pr-version: 3.97-96q1 - ->Submitter-Id: toastersinc ->Confidential: yes ->Originator: Joe Smith (+1 415 903 1400) ->Organization: ------ -Joe Smith joe.smith@@toasters.com -Toasters, Inc. - ``The best UI in the world'' +To: krb5-bugs@@mit.edu +Subject: misspelled "Kerberos" in title of installation guide +From: jcb +Reply-To: jcb +Cc: +X-send-pr-version: 3.99 ->Synopsis: "KDC reply did not match expectations" error message + +>Submitter-Id: mit +>Originator: Jeffrey C. Gilman Bigler +>Organization: +mit +>Confidential: no +>Synopsis: Misspelled "Kerberos" in title of installation guide >Severity: non-critical >Priority: low ->Category: kerberos ->Class: sw-bug ->Release: kerbnet-1.0 +>Category: krb5-doc +>Class: doc-bug +>Release: 1.0-development >Environment: -NetBSD viola 1.1 NetBSD 1.1 (ATHENAADP) #0: Tue May 21 00:31:42 EDT 1996 -i386 -System: Intel P166 -Architecture: NetBSD - + +System: ULTRIX imbrium 4.2 0 RISC +Machine: mips >Description: - - Getting "KDC reply did not match expectations" message. This - does not seem to be affecting anything else. - + Misspelled "Kerberos" in title of "Kerboros V5 Installation Guide" >How-To-Repeat: - - - - - - It happens when I type kinit. - + N/A >Fix: - - - None. Sorry. + Correct the spelling. @end group @end smallexample @@ -164,40 +134,7 @@ Architecture: NetBSD @vfill @end iftex -@page -If the @code{send-pr} program does not work for you, you can use the -following template instead: - -@smallexample -@group -To: bugs@@cygnus.com -Subject: -From: -Reply-To: -X-send-pr-version: none (typed manually) - ->Submitter-Id: ->Originator: ->Organization: - ->Confidential: <[ yes | no ] (one line)> ->Synopsis: ->Severity: <[ non-critical | serious | critical ] (one line)> ->Priority: <[ low | medium | high ] (one line)> ->Category: ->Class: <[ sw-bug | doc-bug | change-request | support ] (one line)> ->Release: cns-9?q? ->Environment: - -System: -Architecture: - - ->Description: - ->How-To-Repeat: - ->Fix: - -@end group -@end smallexample +If the @code{krb5-send-pr} program does not work for you, or if you did +not get far enough in the process to have an installed and working +@code{krb5-send-pr}, you can generate your own form, using the above as +an example. diff --git a/doc/user-guide.texinfo b/doc/user-guide.texinfo index d068396..c60be11 100644 --- a/doc/user-guide.texinfo +++ b/doc/user-guide.texinfo @@ -14,7 +14,7 @@ @end iftex @include definitions.texinfo -@set EDITION b7-1 +@set EDITION 1.0 @finalout @c don't print black warning boxes @@ -67,9 +67,15 @@ This file describes how to use the @value{PRODUCT} client programs. @node Introduction, Kerberos V5 Tutorial, Copyright, Top @chapter Introduction +@ifset CYGNUS @value{PRODUCT} is based on the Kerberos V5 authentication system -developed at MIT. Kerberos is named for the three-headed watchdog from -Greek mythology, who guarded the entrance to the underworld. +developed at MIT. +@end ifset +@ifset MIT +Kerberos V5 is an authentication system developed at MIT. +@end ifset +Kerberos is named for the three-headed watchdog from Greek mythology, +who guarded the entrance to the underworld. Under Kerberos, a client (generally either a user or a service) sends a request for a ticket to the @i{Key Distribution Center} (KDC). The KDC @@ -98,10 +104,6 @@ used to. @value{PRODUCT} is a @dfn{single-sign-on} system, which means that you have to type your password only once per session, and Kerberos does the authenticating and encrypting transparently. -@iftex -@vfil -@end iftex -@need 2000 @menu * What is a Ticket?:: * What is a Kerberos Principal?:: @@ -130,10 +132,6 @@ new resort. The difference is that the @value{PRODUCT} programs notice that you have the weekend ski pass, and get the lift ticket for you, so you don't have to perform the transactions yourself. -@iftex -@vfil -@end iftex -@need 2000 @node What is a Kerberos Principal?, , What is a Ticket?, Introduction @section What is a Kerberos Principal? @@ -166,7 +164,7 @@ the realm @code{@value{PRIMARYREALM}}. @end itemize @node Kerberos V5 Tutorial, Kerberos V5 Reference, Introduction, Top -@chapter @value{PRODUCT} Tutorial +@chapter Kerberos V5 Tutorial This tutorial is intended to familiarize you with the @value{PRODUCT} client programs. We will represent your prompt as ``@code{shell%}''. @@ -215,7 +213,7 @@ versions, when you type their command names. On many systems, Kerberos is built into the login program, and you get tickets automatically when you log in. Other programs, such as -/@code{rsh}, @code{rcp}, @code{telnet}, and @code{rlogin}, can forward +@code{rsh}, @code{rcp}, @code{telnet}, and @code{rlogin}, can forward copies of your tickets to the remote host. Most of these programs also automatically destroy your tickets when they exit. However, @value{COMPANY} recommends that you explicitly destroy your Kerberos @@ -336,10 +334,6 @@ in an error. Note also that most systems specify a maximum ticket lifetime. If you request a longer ticket lifetime, it will be automatically truncated to the maximum lifetime. -@iftex -@vfil -@end iftex -@need 3000 @node Viewing Your Tickets with klist, Destroying Your Tickets with kdestroy, Obtaining Tickets with kinit, Ticket Management @subsection Viewing Your Tickets with klist @@ -397,9 +391,6 @@ host ticket for the host ticket, which telnet then presented to the host @code{@value{RANDOMHOST1}.@value{PRIMARYDOMAIN}}, and she was allowed to log in without typing her password. -@iftex -@vfil -@end iftex @need 3000 Suppose your Kerberos tickets allow you to log into a host in another @@ -488,10 +479,6 @@ shell%} @end group @end smallexample -@iftex -@vfil -@end iftex -@need 2000 @node Destroying Your Tickets with kdestroy, , Viewing Your Tickets with klist, Ticket Management @subsection Destroying Your Tickets with kdestroy @@ -524,10 +511,6 @@ shell%} @end group @end smallexample -@iftex -@vfil -@end iftex -@need 2000 @node Password Management, Kerberos V5 Applications, Ticket Management, Kerberos V5 Tutorial @section Password Management @@ -544,10 +527,6 @@ administrator, for any reason. You should change your password frequently, particularly any time you think someone may have found out what it is. -@iftex -@vfil -@end iftex -@need 2000 @menu * Changing Your Password:: * Password Advice:: @@ -613,11 +592,7 @@ this might be anywhere from a few minutes to an hour or more. If you need to get new Kerberos tickets shortly after changing your password, try the new password. If the new password doesn't work, try again using the old one. -@iftex -@vfil -@end iftex -@need 2000 @node Password Advice, Granting Access to Your Account, Changing Your Password, Password Management @subsection Password Advice @@ -650,9 +625,6 @@ listed in this manual include: @noindent Note: don't actually use any of the above passwords. They're only meant to show you how to make up a good password. Passwords that appear in a manual are the first ones intruders will try. -@iftex -@vfil -@end iftex @need 3800 @value{PRODUCT} allows your system administrators to automatically @@ -683,10 +655,6 @@ shell%} displayed if you choose a bad password, so the message you see may be different from the above example. -@iftex -@vfil -@end iftex -@need 2000 @node Granting Access to Your Account, , Password Advice, Password Management @subsection Granting Access to Your Account @@ -736,13 +704,8 @@ users to become root locally, or to log in remotely as @code{root}, without their having to give out the root password, and without anyone having to type the root password over the network. -@iftex -@vfil -@end iftex -@need 2000 - @node Kerberos V5 Applications, , Password Management, Kerberos V5 Tutorial -@section @value{PRODUCT} Applications +@section Kerberos V5 Applications @value{PRODUCT} is a @dfn{single-sign-on} system. This means that you only have to type your password once, and the @value{PRODUCT} programs @@ -758,10 +721,6 @@ space of a few seconds. The @value{PRODUCT} applications are versions of existing UNIX network programs with the Kerberos features added. -@iftex -@vfil -@end iftex -@need 2000 @menu * Overview of Additional Features:: * telnet:: @@ -795,10 +754,6 @@ This section of the tutorial assumes you are familiar with the non-Kerberos versions of these programs, and highlights the Kerberos functions added in the @value{PRODUCT} package. -@iftex -@vfil -@end iftex -@need 2000 @node telnet, rlogin, Overview of Additional Features, Kerberos V5 Applications @subsection telnet @@ -841,10 +796,6 @@ turns on encryption. turns off encryption. @end table -@iftex -@vfil -@end iftex - @need 4000 For example, if @code{@value{RANDOMUSER2}} wanted to use the standard UNIX telnet to connect to the machine @@ -879,9 +830,6 @@ was sent over the network unencrypted. If an intruder were watching network traffic at the time, that intruder would know @code{@value{RANDOMUSER2}}'s password. -@iftex -@vfil -@end iftex @need 4000 If, on the other hand, @code{@value{RANDOMUSER1}} wanted to use the @value{PRODUCT} telnet to connect to the machine @@ -915,9 +863,6 @@ destroys them when it exits. The full set of options to @value{PRODUCT} @code{telnet} are discussed in the Reference section of this manual. (@pxref{telnet Reference}) -@iftex -@vfil -@end iftex @need 2000 @node rlogin, FTP, telnet, Kerberos V5 Applications @subsection rlogin @@ -981,9 +926,6 @@ was sent over the network unencrypted. If an intruder were watching network traffic at the time, that intruder would know @code{@value{RANDOMUSER2}}'s password. -@iftex -@vfil -@end iftex @need 4000 If, on the other hand, @code{@value{RANDOMUSER1}} wanted to use @value{PRODUCT} rlogin to connect to the machine @@ -1013,10 +955,6 @@ destroys them when it exits. The full set of options to @value{PRODUCT} @code{rlogin} are discussed in the Reference section of this manual. (@pxref{rlogin Reference}) -@iftex -@vfil -@end iftex -@need 2000 @node FTP, rsh, rlogin, Kerberos V5 Applications @subsection FTP @@ -1077,14 +1015,9 @@ ftp> quit The full set of options to @value{PRODUCT} @code{FTP} are discussed in the Reference section of this manual. (@pxref{FTP Reference}) -@iftex -@vfil -@end iftex -@need 2000 @node rsh, rcp, FTP, Kerberos V5 Applications @subsection rsh -@need 1000 The @value{PRODUCT} @code{rsh} program works exactly like the standard UNIX rlogin program, with the following Kerberos features added: @@ -1118,7 +1051,7 @@ turns off encryption. @need 1800 For example, if your Kerberos tickets allowed you to run programs on the -host @code{@value{RANDOMHOST2}@@@value{SECONDDOMAIN}} as root, you could +host @* @code{@value{RANDOMHOST2}@@@value{SECONDDOMAIN}} as root, you could run the @samp{date} program as follows: @smallexample @@ -1135,10 +1068,6 @@ destroys them when it exits. The full set of options to @value{PRODUCT} @code{rsh} are discussed in the Reference section of this manual. (@pxref{rsh Reference}) -@iftex -@vfil -@end iftex -@need 2000 @node rcp, ksu, rsh, Kerberos V5 Applications @subsection rcp @@ -1170,10 +1099,6 @@ transparently. The full set of options to @value{PRODUCT} @code{rcp} are discussed in the Reference section of this manual. (@pxref{rcp Reference}) -@iftex -@vfil -@end iftex -@need 2000 @node ksu, , rcp, Kerberos V5 Applications @subsection ksu @@ -1353,7 +1278,7 @@ The full set of options to @value{PRODUCT} @code{ksu} are discussed in the Reference section of this manual. (@pxref{ksu Reference}) @node Kerberos V5 Reference, Kerberos Glossary, Kerberos V5 Tutorial, Top -@chapter @value{PRODUCT} Reference +@chapter Kerberos V5 Reference This section will include copies of the manual pages for the @value{PRODUCT} client programs. You can read the manual entry for any diff --git a/src/ChangeLog b/src/ChangeLog index f89bb96..4b9d5b9 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,28 @@ +Wed Mar 10 00:09:43 1999 Tom Yu + + * aclocal.m4 (enable_shared): Fix quoting bug that breaks shared + libs under HP/UX among others. + +Mon Nov 25 19:42:53 1996 Tom Yu + + * Makefile.in: Comment out distclean and realclean so no one will + be tempted to use them. [PR 222] + +Fri Nov 22 23:51:07 1996 Theodore Ts'o + + * Makefile.in: All changes for the Macintosh port. Translate '%' + characters in Macfile.tmpl to '/' characters. Include the + mac/SAP directory in the kerbsrc.mac.tar tarball. Rename + the kerbsrc.tar tarball to kerbsrc.mac.tar, so that the + target name in the Makefile matches the taget which is + actually generated. Use mac/mkbindirs.sh to build the + binary hierarchy for the Macintosh build process. + +Wed Nov 20 13:28:00 1996 Theodore Ts'o + + * Makefile.in (awk-windows-mac): Copy gssapi.hin to gssapi.h to + make Win16 build work. + Thu Nov 7 23:55:02 1996 Tom Yu * aclocal.m4 (LinkFileDir, LinkFile): AC_REQUIRE the AC_LN_S macro diff --git a/src/Makefile.in b/src/Makefile.in index 738aa40..a088101 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -63,11 +63,14 @@ clean-unix:: mostlyclean: clean -distclean: clean - rm -f Makefile config.status - -realclean: distclean - rm -f TAGS +# This doesn't work; if you think you need it, you should use a +# separate build directory. +# +# distclean: clean +# rm -f Makefile config.status +# +# realclean: distclean +# rm -f TAGS dist: $(DISTFILES) echo cpio-`sed -e '/version_string/!d' \ @@ -220,7 +223,7 @@ FILES= ./* \ WINFILES= windows/* windows/cns/* windows/wintel/* windows/gss/* MACFILES= mac/* mac/kconfig/* mac/libraries/* mac/telnet-k5-auth/* \ - mac/gss-sample/* config/* include/* include/krb5/* \ + mac/gss-sample/* mac/SAP/* config/* include/* include/krb5/* \ include/krb5/asn.1/* include/krb5/stock/* include/sys/* \ ./patchlevel.h @@ -235,7 +238,8 @@ CLEANUP= util/profile/profile.h util/profile/prof_err.[ch] \ include/adm_err.h include/profile.h include/krb5.h \ include/krb5/osconf.h \ lib/gssapi/generic/gssapi_err_generic.[ch] \ - lib/gssapi/krb5/gssapi_err_krb5.[ch] winfile.list macfile.list + lib/gssapi/krb5/gssapi_err_krb5.[ch] winfile.list macfile.list \ + lib/gssapi/generic/gssapi.h kerbsrc.win: kerbsrc.zip @@ -299,13 +303,22 @@ Macfile: macfile.list Makefile.sav -e 's/^/:bin:PPC:/' macsrcsk5` >> Macfile echo INCLUDES = `sed -n -e 's/\(.*:\)[^:]*\.h$$/-i \1/p' macfile.maclist | sort -u` >> Macfile echo "" >> Macfile - tr '/:\\' ':\304\266'< mac/Makefile.tmpl >> Macfile + tr '%/:\\' '/:\304\266'< mac/Makefile.tmpl >> Macfile + +mac-bin-dirs: + rm -rf bin + mkdir bin bin/68K bin/CFM-68K bin/PPC + sh mac/mkbindirs.sh bin/68K $(MAC_SUBDIRS) + sh mac/mkbindirs.sh bin/CFM-68K $(MAC_SUBDIRS) + sh mac/mkbindirs.sh bin/PPC $(MAC_SUBDIRS) -kerbsrc.mac: awk-windows-mac macfile.list Macfile +kerbsrc.mac.tar: awk-windows-mac macfile.list mac-bin-dirs Macfile cp mac/libraries/autoconf.h include/autoconf.h mv Macfile Makefile - tar cvf kerbsrc.tar Makefile include/autoconf.h `cat macfile.list` + tar cvf kerbsrc.mac.tar Makefile include/autoconf.h bin \ + `cat macfile.list` rm -f $(CLEANUP) + rm -rf bin rm -f include/autoconf.h Makefile macsrc* macfile.maclist mv Makefile.sav Makefile @@ -343,3 +356,4 @@ awk-windows-mac: cat $(PR)/profile.hin $(PR)prof_err.h > $(PR)profile.h cp $(PR)profile.h include/profile.h cp $(INC)/krb5/stock/osconf.h $(INC)/krb5 + cp $(GG)gssapi.hin $(GG)gssapi.h diff --git a/src/aclocal.m4 b/src/aclocal.m4 index 4576a98..9f79444 100644 --- a/src/aclocal.m4 +++ b/src/aclocal.m4 @@ -863,7 +863,7 @@ AC_SUBST(LD_SHLIBDIR_PREFIX) SHLIB_RPATH_DIRS= if test $krb5_cv_shlibs_use_dirs = yes ; then if test $krb5_cv_shlibs_use_colon_dirs = yes ; then - SHLIB_RPATH_DIRS="${krb5_cv_shlibs_dirhead}$(KRB5_SHLIBDIR)" + SHLIB_RPATH_DIRS="${krb5_cv_shlibs_dirhead}\$(KRB5_SHLIBDIR)" else SHLIB_RPATH_DIRS="${krb5_cv_shlibs_dirhead}\$(KRB5_SHLIBDIR)" fi diff --git a/src/appl/bsd/ChangeLog b/src/appl/bsd/ChangeLog index f9aa5ad..5fb74c8 100644 --- a/src/appl/bsd/ChangeLog +++ b/src/appl/bsd/ChangeLog @@ -1,3 +1,174 @@ +Fri Mar 12 19:01:35 1999 Tom Yu + + * Makefile.in (kshd): Add $(LOGINLIBS). + +Mon Mar 8 19:21:23 1999 Tom Yu + + * kshd.M: Resync manpage. + + * krshd.c: Rework hostname logging. + +Wed Feb 24 20:05:40 1999 Tom Yu + + * klogind.M: Resync manpage. + + * krlogind.c: Rework flags for hostname logging. + +Mon Feb 22 22:26:32 1999 Tom Yu + + * kcmd.c (kcmd): Fix up to not call sname_to_principal until after + all the addresses in hp have been iterated through to avoid + smashing. [krb5-appl/516] + +Wed Feb 17 17:24:11 1999 Tom Yu + + * klogind.M: Document things a little better, including new + options controlling hostname manipulation. + + * krlogind.c: Make use of pty_make_sane_hostname() for purposes of + manipulating hostname to pass to login. Also unconditionally + syslog IP address and full hostname of remote host. Add command + line options to control such behavior. + + * configure.in: Add arpa/nameser.h to CHECK_HEADERS. + +Fri Feb 12 10:20:20 1999 Theodore Y. Ts'o + + * login.c (read_env_vars_from_file): Fix so that it uses + passed-in filename instead of the hard-coded to + /etc/environment. [krb5-appl/691] + +Wed Jan 20 21:42:41 1999 Tom Yu + + * login.c (main): Call setluid(). + + * krshd.c (doit): Call setluid(). + + * configure.in: Check for setluid() rather than main() in + libsecurity. + +1998-10-06 Theodore Ts'o + + * krshd.c (doit): Apply ghudson's patch so that rshd passes the + port numbers for the local and foreign addresses so that + the V4 encrypted RCP will work correctly. [krb5-appl/638] + * v4rcp.c (answer_auth): Apply ghudson's patch so that if + KRB5LOCALPORT and KRB5REMOTEPORT are set, use them to set + the foreign and local ports so that encrypted rcp for the + same machine. [krb5-appl/638] + +Sat Aug 15 00:01:15 1998 Geoffrey King + + * krcp.c (error): Don't call rcmd_stream_write if iamremote is not + set, because it expects a valid file descriptor [krb5-appl/359]. + Also, remove mistakenly duplicated comment above the function. + +Mon Jul 27 00:06:20 1998 Geoffrey King + + * krlogin.c (main): Apply ghudson's patch so that rlogin -a + no longer dumps core. [krb5-appl/612] + +1998-05-26 Theodore Ts'o + + * login.c (dolastlog): BSD 4.4 systems don't have lastlog.h, but + still define struct lastlog somewhere. Included from Dima + Ruban's FreeBSD patches. + + * krlogin.c: Include sys/ioctl_compat.h if it is present (instead + of just for 386BSD). + + * loginpaths.h (LPATH): If the OS provides _PATH_DEFPATH, use it + to define LPATH and RPATH. + + * login.c: #include paths.h if present, and use it to set the + pathnames for certain common files. + + * configure.in (withval): Check for and + + +Sat May 16 16:07:42 1998 Tom Yu + + * login.c: Replace strcpy with strncpy in places. Add nul + termination to some existing invocations of strncpy. + +Tue Jan 20 21:42:06 1998 Tom Yu + + * krlogind.c (protocol): Declare pibuf and fibuf as being BUFSIZ + bytes long, rather than 1024. Fixes an Irix bug. [krb5-appl/527] + +Thu Nov 20 16:42:54 1997 Tom Yu + + * krlogind.c (recvauth): Fix args in call to + rd_and_store_for_creds. [krb5-appl/502] + +Mon Nov 17 20:55:31 1997 Tom Yu + + * krshd.c: Don't set checksum_ignored to 1 if checksum_required is + 0; also, if a krb5 client passes in a checksum, check it + regardless of whether checksum_required is true. [krb5-appl/500] + +Wed Nov 12 19:03:02 1997 Tom Yu + + * forward.c (rd_and_store_for_creds): Don't do the chown. Avoids + a security hole. [krb5-appl/494] + + * krshd.c (recvauth): chown the ccache explicitly, as + rd_and_store_for_creds no longer does so. [krb5-appl/494] + +Thu Nov 6 22:04:26 1997 Theodore Y. Ts'o + + * v4rcp.c: Use error_message(errno) instead of using + sys_errlist[errno]. This avoids the hair of deciding + whether or not we need to declare sys_errlist or use + strerror(), etc., since com_err has all of that complexity + anyway. Also fixed lots of -Wall nits. + +Mon Nov 3 15:25:48 1997 Tom Yu + + * krlogind.c (doit): Fix up potential buffer overrun. + [krb5-appl/488] + +Tue Mar 18 12:34:03 1997 Sam Hartman + + [326] * login.c(doit): Preserve terminal even without -p. + +Sat Dec 28 21:06:43 1996 Sam Hartman + + * login.c: Force environment variables like HOME to be set even if + -p given. + +Thu Feb 27 10:58:07 1997 Sam Hartman + + * krshd.c: Allow user to login with / as home directory if homedir + not found. [167] + +Fri Dec 6 00:53:08 1996 Theodore Y. Ts'o + + * v4rcp.c: Extend the platform-specific braindamage so that + FreeBSD works. This whole file is eventually going to + need serious rototilling to make it even vaguely correct. + [PR #284] + +Fri Dec 6 00:02:25 1996 Tom Yu + + * loginpaths.h: Add catch-all entries for LPATH and RPATH in case + we run across something that we haven't hardcoded paths for + yet. [267] + +Thu Dec 5 21:58:28 1996 Tom Yu + + * login.M: v5srvtab -> krb5.keytab [279] + +Sun Nov 24 23:35:22 1996 Ezra Peisach + + * login.c (try_afscall): Change to take pointer to function + instead of only calling setpag(). [krb5-appl/190] + +Fri Nov 22 15:46:46 1996 unknown + + * kcmd.c (kcmd): use sizeof instead of h_length to determine + number of bytes of addr to copy from DNS response [krb5-misc/211] + Thu Nov 14 14:30:28 1996 Barry Jaspan * krcp.c: don't print our own error message if kcmd returns -1 (it diff --git a/src/appl/bsd/Makefile.in b/src/appl/bsd/Makefile.in index c7a4963..e3fafdd 100644 --- a/src/appl/bsd/Makefile.in +++ b/src/appl/bsd/Makefile.in @@ -60,7 +60,7 @@ install:: fi kshd: krshd.o kcmd.o forward.o $(SETENVOBJ) $(LIBOBJS) $(DEPLIBS) - $(LD) $(LDFLAGS) $(LDARGS) -o kshd krshd.o kcmd.o forward.o $(SETENVOBJ) $(LIBOBJS) $(LIBS) + $(LD) $(LDFLAGS) $(LDARGS) -o kshd krshd.o kcmd.o forward.o $(SETENVOBJ) $(LIBOBJS) $(LOGINLIBS) $(LIBS) klogind: krlogind.o kcmd.o forward.o $(SETENVOBJ) $(LIBOBJS) $(DEPLIBS) $(LD) $(LDFLAGS) $(LDARGS) -o klogind krlogind.o kcmd.o forward.o $(SETENVOBJ) $(LIBOBJS) $(LIBS) diff --git a/src/appl/bsd/configure.in b/src/appl/bsd/configure.in index d8ca7c7..53380ec 100644 --- a/src/appl/bsd/configure.in +++ b/src/appl/bsd/configure.in @@ -31,7 +31,7 @@ case $krb5_cv_host in krb5_cv_has_streams=no ;; alpha-dec-osf*) - AC_CHECK_LIB(security,main, + AC_CHECK_LIB(security,setluid, AC_DEFINE(HAVE_SETLUID) LOGINLIBS="$LOGINLIBS -lsecurity" ) @@ -82,7 +82,7 @@ AC_FUNC_CHECK(tcsetpgrp,AC_DEFINE(HAVE_TCSETPGRP)) AC_FUNC_CHECK(setpgid,AC_DEFINE(HAVE_SETPGID)) AC_CHECK_HEADERS(unistd.h stdlib.h string.h sys/filio.h sys/sockio.h ) AC_CHECK_HEADERS(sys/label.h sys/tty.h ttyent.h lastlog.h sys/select.h ) -AC_CHECK_HEADERS(sys/ptyvar.h utmp.h sys/time.h) +AC_CHECK_HEADERS(sys/ptyvar.h utmp.h sys/time.h arpa/nameser.h sys/ioctl_compat.h paths.h) AC_HEADER_STDARG AC_REPLACE_FUNCS(getdtablesize) KRB5_SIGTYPE diff --git a/src/appl/bsd/forward.c b/src/appl/bsd/forward.c index 54594b9..e22fc1d 100644 --- a/src/appl/bsd/forward.c +++ b/src/appl/bsd/forward.c @@ -21,7 +21,6 @@ #if defined(KERBEROS) || defined(KRB5) #include -#include #include #include #include @@ -30,22 +29,18 @@ /* Decode, decrypt and store the forwarded creds in the local ccache. */ krb5_error_code -rd_and_store_for_creds(context, auth_context, inbuf, ticket, lusername, ccache) +rd_and_store_for_creds(context, auth_context, inbuf, ticket, ccache) krb5_context context; krb5_auth_context auth_context; krb5_data *inbuf; krb5_ticket *ticket; - char *lusername; krb5_ccache *ccache; { krb5_creds ** creds; krb5_error_code retval; char ccname[35]; - struct passwd *pwd; *ccache = NULL; - if (!(pwd = (struct passwd *) getpwnam(lusername))) - return ENOENT; if (retval = krb5_rd_cred(context, auth_context, inbuf, &creds, NULL)) return(retval); @@ -67,19 +62,6 @@ rd_and_store_for_creds(context, auth_context, inbuf, ticket, lusername, ccache) if (retval = krb5_cc_store_cred(context, *ccache, *creds)) goto cleanup; - if (retval = chown(ccname+5, pwd->pw_uid, -1)) { - /* - * If the file owner is the same as the user id then return ok. - * This is for testing only --proven - */ - struct stat statbuf; - - if (stat(ccname + 5, & statbuf) == 0) { - if (statbuf.st_uid == pwd->pw_uid) - retval = 0; - } - } - cleanup: krb5_free_creds(context, *creds); return retval; diff --git a/src/appl/bsd/kcmd.c b/src/appl/bsd/kcmd.c index 4b66c37..b8f6271 100644 --- a/src/appl/bsd/kcmd.c +++ b/src/appl/bsd/kcmd.c @@ -124,38 +124,7 @@ kcmd(sock, ahost, rport, locuser, remuser, cmd, fd2p, service, realm, fprintf(stderr, "%s: unknown host\n", *ahost); return (-1); } - - if ((host_save = (char *) malloc(strlen(hp->h_name) + 1)) == NULL) { - fprintf(stderr,"kcmd: no memory\n"); - return(-1); - } - - strcpy(host_save, hp->h_name); - /* If no service is given set to the default service */ - if (!service) service = default_service; - - sin_len = strlen(host_save) + strlen(service) - + (realm ? strlen(realm): 0) + 3; - if ( sin_len < 20 ) sin_len = 20; - - if (!(get_cred = (krb5_creds *)calloc(1, sizeof(krb5_creds)))) { - fprintf(stderr,"kcmd: no memory\n"); - return(-1); - } - status = krb5_sname_to_principal(bsd_context, host_save, service, - KRB5_NT_SRV_HST, &get_cred->server); - if (status) { - fprintf(stderr, "kcmd: krb5_sname_to_principal failed: %s\n", - error_message(status)); - return(-1); - } - - if (realm && *realm) { - (void) krb5_xfree(krb5_princ_realm(bsd_context,get_cred->server)->data); - krb5_princ_set_realm_length(bsd_context,get_cred->server,strlen(realm)); - krb5_princ_set_realm_data(bsd_context,get_cred->server,strdup(realm)); - } #ifdef POSIX_SIGNALS sigemptyset(&urgmask); sigaddset(&urgmask, SIGURG); @@ -176,11 +145,10 @@ kcmd(sock, ahost, rport, locuser, remuser, cmd, fd2p, service, realm, #else sigsetmask(oldmask); #endif /* POSIX_SIGNALS */ - krb5_free_creds(bsd_context, get_cred); return (-1); } sin.sin_family = hp->h_addrtype; - memcpy((caddr_t)&sin.sin_addr,hp->h_addr, hp->h_length); + memcpy((caddr_t)&sin.sin_addr,hp->h_addr, sizeof(sin.sin_addr)); sin.sin_port = rport; if (connect(s, (struct sockaddr *)&sin, sizeof (sin)) >= 0) break; @@ -200,22 +168,50 @@ kcmd(sock, ahost, rport, locuser, remuser, cmd, fd2p, service, realm, perror(0); hp->h_addr_list++; memcpy((caddr_t)&sin.sin_addr,hp->h_addr_list[0], - hp->h_length); + sizeof(sin.sin_addr)); fprintf(stderr, "Trying %s...\n", inet_ntoa(sin.sin_addr)); continue; } #endif /* !(defined(ultrix) || defined(sun)) */ - perror(host_save); + perror(hp->h_name); #ifdef POSIX_SIGNALS sigprocmask(SIG_SETMASK, &oldmask, (sigset_t*)0); #else sigsetmask(oldmask); #endif /* POSIX_SIGNALS */ - krb5_free_creds(bsd_context, get_cred); return (-1); } lport--; + /* If no service is given set to the default service */ + if (!service) service = default_service; + + if (!(get_cred = (krb5_creds *)calloc(1, sizeof(krb5_creds)))) { + fprintf(stderr,"kcmd: no memory\n"); + return(-1); + } + host_save = malloc(strlen(hp->h_name) + 1); + if (host_save == NULL) { + fprintf(stderr, "kcmd: no memory\n"); + free(get_cred); + return -1; + } + strcpy(host_save, hp->h_name); + status = krb5_sname_to_principal(bsd_context, host_save, service, + KRB5_NT_SRV_HST, &get_cred->server); + if (status) { + fprintf(stderr, "kcmd: krb5_sname_to_principal failed: %s\n", + error_message(status)); + return(-1); + } + + if (realm && *realm) { + free(krb5_princ_realm(bsd_context,get_cred->server)->data); + /*krb5_xfree(krb5_princ_realm(bsd_context,get_cred->server)->data);*/ + + krb5_princ_set_realm_length(bsd_context,get_cred->server,strlen(realm)); + krb5_princ_set_realm_data(bsd_context,get_cred->server,strdup(realm)); + } if (fd2p == 0) { write(s, "", 1); lport = 0; diff --git a/src/appl/bsd/klogind.M b/src/appl/bsd/klogind.M index 3db26c8..4acde79 100644 --- a/src/appl/bsd/klogind.M +++ b/src/appl/bsd/klogind.M @@ -12,6 +12,8 @@ klogind \- remote login server [ .B \-kr54cpPe ] +[ +[ \fB\-w\fP[\fBip\fP|\fImaxhostlen\fP[\fB,\fP[\fBno\fP]\fBstriplocal\fP]] ] .SH DESCRIPTION .I Klogind is the server for the @@ -124,6 +126,24 @@ size changes from the client are propagated to the pseudo terminal. .PP .I Klogind +supports the following options to control the form of the hostname +passed to login(1): + +.TP +\fB\-w \fP[\fBip\fP|\fImaxhostlen\fP[\fB,\fP[\fBno\fP]\fBstriplocal\fP]] +Controls the form of the remote hostname passed to login(1). +Specifying \fBip\fP results in the numeric IP address always being +passed to login(1). Specifying a number, \fImaxhostlen\fP, sets the +maximum length of the hostname passed to login(1) before it will be +passed as a numeric IP address. If \fImaxhostlen\fP is 0, then the +system default, as determined by the utmp or utmpx structures, is +used. The \fBnostriplocal\fP and \fBstriplocal\fP options, which must +be preceded by a comma, control whether or not the local host domain +is stripped from the remote hostname. By default, the equivalent of +\fBstriplocal\fP is in effect. + +.PP +.I Klogind supports three options which are used for testing purposes: diff --git a/src/appl/bsd/krcp.c b/src/appl/bsd/krcp.c index 6f76bd2..55b99bd 100644 --- a/src/appl/bsd/krcp.c +++ b/src/appl/bsd/krcp.c @@ -1144,8 +1144,6 @@ struct buffer *allocbuf(bp, fd, blksize) return (bp); } - - void #ifdef HAVE_STDARG_H error(char *fmt, ...) @@ -1170,8 +1168,9 @@ error(fmt, va_alist) (void) vsprintf(cp, fmt, ap); va_end(ap); - (void) des_write(rem, buf, strlen(buf)); - if (iamremote == 0) + if (iamremote) + (void) des_write(rem, buf, strlen(buf)); + else (void) write(2, buf+1, strlen(buf+1)); } @@ -1260,8 +1259,10 @@ char **save_argv(argc, argv) #endif - - +/* This function is mostly vestigial, since under normal operation + * the -x flag doesn't get set for the server process for encrypted + * rcp. It only gets called by beta clients attempting user-to-user + * authentication. */ void answer_auth(config_file, ccache_file) char *config_file; diff --git a/src/appl/bsd/krlogin.c b/src/appl/bsd/krlogin.c index 0e51620..829e611 100644 --- a/src/appl/bsd/krlogin.c +++ b/src/appl/bsd/krlogin.c @@ -120,7 +120,7 @@ char copyright[] = #define TIOCPKT_FLUSHWRITE 0x02 #endif -#ifdef __386BSD__ +#ifdef HAVE_SYS_IOCTL_COMPAT_H #include #endif @@ -585,7 +585,7 @@ main(argc, argv) authopts |= OPTS_FORWARDABLE_CREDS; status = kcmd(&sock, &host, debug_port, - null_local_username ? NULL : pwd->pw_name, + null_local_username ? "" : pwd->pw_name, name ? name : pwd->pw_name, term, 0, "host", krb_realm, &cred, @@ -614,10 +614,10 @@ main(argc, argv) } #else rem = rcmd(&host, debug_port, - null_local_username ? NULL : pwd->pw_name, + null_local_username ? "" : pwd->pw_name, name ? name : pwd->pw_name, term, 0); #endif /* KERBEROS */ - + if (rem < 0) exit(1); diff --git a/src/appl/bsd/krlogind.c b/src/appl/bsd/krlogind.c index 7773de5..5f9e3c2 100644 --- a/src/appl/bsd/krlogind.c +++ b/src/appl/bsd/krlogind.c @@ -246,7 +246,7 @@ krb5_ccache ccache = NULL; krb5_keytab keytab = NULL; -#define ARGSTR "k54ciepPD:S:M:L:?" +#define ARGSTR "k54ciepPD:S:M:L:w:?" #else /* !KERBEROS */ #define ARGSTR "rpPD:?" #define (*des_read) read @@ -274,11 +274,20 @@ char *login_program = LOGIN_PROGRAM; #define UT_NAMESIZE sizeof(((struct utmp *)0)->ut_name) #endif +#if HAVE_ARPA_NAMESER_H +#include +#endif + +#ifndef MAXDNAME +#define MAXDNAME 256 /*per the rfc*/ +#endif + char lusername[UT_NAMESIZE+1]; char rusername[UT_NAMESIZE+1]; char *krusername = 0; char term[64]; -char rhost_name[128]; +char rhost_name[MAXDNAME]; +char rhost_addra[16]; krb5_principal client; int reapchild(); @@ -314,6 +323,10 @@ int auth_ok = 0, auth_sent = 0; int do_encrypt = 0, passwd_if_fail = 0, passwd_req = 0; int checksum_required = 0, checksum_ignored = 0; +int stripdomain = 1; +int maxhostlen = 0; +int always_ip = 0; + int main(argc, argv) int argc; char **argv; @@ -411,6 +424,34 @@ int main(argc, argv) case 'L': login_program = optarg; break; + case 'u': + maxhostlen = atoi(optarg); + break; + case 'I': + always_ip = 1; + break; + case 'w': + if (!strcmp(optarg, "ip")) + always_ip = 1; + else { + char *cp; + cp = strchr(optarg, ','); + if (cp == NULL) + maxhostlen = atoi(optarg); + else if (*(++cp)) { + if (!strcmp(cp, "striplocal")) + stripdomain = 1; + else if (!strcmp(cp, "nostriplocal")) + stripdomain = 0; + else { + usage(); + exit(1); + } + *(--cp) = '\0'; + maxhostlen = atoi(optarg); + } + } + break; case '?': default: usage(); @@ -515,7 +556,9 @@ void doit(f, fromp) struct sigaction sa; #endif int retval; -int syncpipe[2]; + char *rhost_sane; + int syncpipe[2]; + netf = -1; alarm(60); read(f, &c, 1); @@ -539,15 +582,14 @@ int syncpipe[2]; fromp->sin_port = ntohs((u_short)fromp->sin_port); hp = gethostbyaddr((char *) &fromp->sin_addr, sizeof (struct in_addr), fromp->sin_family); - if (hp == 0) { - /* - * Only the name is used below. - */ - sprintf(rhost_name,"%s",inet_ntoa(fromp->sin_addr)); - } - - /* Save hostent information.... */ - else strcpy(rhost_name,hp->h_name); + strncpy(rhost_addra, inet_ntoa(fromp->sin_addr), sizeof (rhost_addra)); + rhost_addra[sizeof (rhost_addra) -1] = '\0'; + if (hp != NULL) { + /* Save hostent information.... */ + strncpy(rhost_name,hp->h_name,sizeof (rhost_name)); + rhost_name[sizeof (rhost_name) - 1] = '\0'; + } else + rhost_name[0] = '\0'; if (fromp->sin_family != AF_INET) fatal(f, "Permission denied - Malformed from address\n"); @@ -570,7 +612,7 @@ int syncpipe[2]; #if defined(KERBEROS) /* All validation, and authorization goes through do_krb_login() */ - do_krb_login(rhost_name); + do_krb_login(rhost_addra, rhost_name); #else getstr(f, rusername, sizeof(rusername), "remuser"); getstr(f, lusername, sizeof(lusername), "locuser"); @@ -660,11 +702,13 @@ int syncpipe[2]; pwd = (struct passwd *) getpwnam(lusername); if (pwd && (pwd->pw_uid == 0)) { if (passwd_req) - syslog(LOG_NOTICE, "ROOT login by %s (%s@%s) forcing password access", - krusername ? krusername : "", rusername, rhost_name); + syslog(LOG_NOTICE, "ROOT login by %s (%s@%s (%s)) forcing password access", + krusername ? krusername : "", + rusername, rhost_addra, rhost_name); else - syslog(LOG_NOTICE, "ROOT login by %s (%s@%s) ", - krusername ? krusername : "", rusername, rhost_name); + syslog(LOG_NOTICE, "ROOT login by %s (%s@%s (%s))", + krusername ? krusername : "", + rusername, rhost_addra, rhost_name); } #ifdef KERBEROS #if defined(LOG_REMOTE_REALM) && !defined(LOG_OTHER_USERS) && !defined(LOG_ALL_LOGINS) @@ -685,14 +729,14 @@ int syncpipe[2]; { if (passwd_req) syslog(LOG_NOTICE, - "login by %s (%s@%s) as %s forcing password access\n", + "login by %s (%s@%s (%s)) as %s forcing password access", krusername ? krusername : "", rusername, - rhost_name, lusername); + rhost_addra, rhost_name, lusername); else syslog(LOG_NOTICE, - "login by %s (%s@%s) as %s\n", + "login by %s (%s@%s (%s)) as %s", krusername ? krusername : "", rusername, - rhost_name, lusername); + rhost_addra, rhost_name, lusername); } #endif /* LOG_REMOTE_REALM || LOG_OTHER_USERS || LOG_ALL_LOGINS */ #endif /* KERBEROS */ @@ -715,15 +759,20 @@ int syncpipe[2]; *cp = '\0'; setenv("TERM",term, 1); } - + + retval = pty_make_sane_hostname(fromp, maxhostlen, + stripdomain, always_ip, + &rhost_sane); + if (retval) + fatalperror(2, "failed make_sane_hostname"); if (passwd_req) - execl(login_program, "login", "-p", "-h", rhost_name, + execl(login_program, "login", "-p", "-h", rhost_sane, lusername, 0); else - execl(login_program, "login", "-p", "-h", rhost_name, + execl(login_program, "login", "-p", "-h", rhost_sane, "-f", lusername, 0); #else /* USE_LOGIN_F */ - execl(login_program, "login", "-r", rhost_name, 0); + execl(login_program, "login", "-r", rhost_sane, 0); #endif /* USE_LOGIN_F */ fatalperror(2, login_program); @@ -847,7 +896,7 @@ int control(pty, cp, n) void protocol(f, p) int f, p; { - unsigned char pibuf[1024], fibuf[1024], *pbp, *fbp; + unsigned char pibuf[BUFSIZ], fibuf[BUFSIZ], *pbp, *fbp; register pcc = 0, fcc = 0; int cc; char cntl; @@ -1056,8 +1105,8 @@ void fatalperror(f, msg) #ifdef KERBEROS void -do_krb_login(host) - char *host; +do_krb_login(host_addr, hostname) + char *host_addr, *hostname; { krb5_error_code status; struct passwd *pwd; @@ -1075,8 +1124,8 @@ do_krb_login(host) krb5_free_ticket(bsd_context, ticket); if (status != 255) syslog(LOG_ERR, - "Authentication failed from %s: %s\n", - host,error_message(status)); + "Authentication failed from %s (%s): %s\n",host_addr, + hostname,error_message(status)); fatal(netf, "Kerberos authentication failed"); return; } @@ -1329,7 +1378,7 @@ void usage() { #ifdef KERBEROS syslog(LOG_ERR, - "usage: klogind [-ke45pP] [-D port] or [r/R][k/K][x/e][p/P]logind"); + "usage: klogind [-ke45pP] [-D port] [-w[ip|maxhostlen[,[no]striplocal]]] or [r/R][k/K][x/e][p/P]logind"); #else syslog(LOG_ERR, "usage: rlogind [-rpP] [-D port] or [r/R][p/P]logind"); @@ -1558,7 +1607,7 @@ recvauth(valid_checksum) if ((inbuf.length) && /* Forwarding being done, read creds */ (status = rd_and_store_for_creds(bsd_context, auth_context, &inbuf, - ticket, lusername, &ccache))) { + ticket, &ccache))) { fatal(netf, "Can't get forwarded credentials"); } return 0; diff --git a/src/appl/bsd/krshd.c b/src/appl/bsd/krshd.c index 8859e3a..8de25de 100644 --- a/src/appl/bsd/krshd.c +++ b/src/appl/bsd/krshd.c @@ -150,8 +150,15 @@ char copyright[] = #include "com_err.h" #include "loginpaths.h" -#define ARGSTR "ek54ciD:S:M:AP:?L:" +#if HAVE_ARPA_NAMESER_H +#include +#endif + +#ifndef MAXDNAME +#define MAXDNAME 256 /*per the rfc*/ +#endif +#define ARGSTR "ek54ciD:S:M:AP:?L:w:" #define RSHD_BUFSIZ 5120 @@ -176,6 +183,9 @@ int do_encrypt = 0; int anyport = 0; char *kprogdir = KPROGDIR; int netf; +int maxhostlen = 0; +int stripdomain = 1; +int always_ip = 0; #else /* !KERBEROS */ @@ -349,8 +359,30 @@ int main(argc, argv) case 'D': debug_port = atoi(optarg); break; - case '?': - default: + case 'w': + if (!strcmp(optarg, "ip")) + always_ip = 1; + else { + char *cp; + cp = strchr(optarg, ','); + if (cp == NULL) + maxhostlen = atoi(optarg); + else if (*(++cp)) { + if (!strcmp(cp, "striplocal")) + stripdomain = 1; + else if (!strcmp(cp, "nostriplocal")) + stripdomain = 0; + else { + usage(); + exit(1); + } + *(--cp) = '\0'; + maxhostlen = atoi(optarg); + } + } + break; + case '?': + default: usage(); exit(1); break; @@ -420,9 +452,6 @@ int main(argc, argv) syslog(LOG_WARNING , "setsockopt (SO_LINGER): %m"); #endif - if (!checksum_required && !checksum_ignored) - checksum_ignored = 1; - if (checksum_required&&checksum_ignored) { syslog(LOG_CRIT, "Checksums are required and ignored; these options are mutually exclusive--check the documentation."); fatal(fd, "Configuration error: mutually exclusive options specified"); @@ -446,8 +475,10 @@ char term[64] = "TERM=network"; char path_rest[] = RPATH; char remote_addr[64]; /* = "KRB5REMOTEADDR=" */ +char remote_port[64]; /* = "KRB5REMOTEPORT=" */ char local_addr[64]; /* = "KRB5LOCALADDR=" */ -#define ADDRPAD 0,0 /* remoteaddr, localaddr */ +char local_port[64]; /* = "KRB5LOCALPORT=" */ +#define ADDRPAD 0,0,0,0 #define KRBPAD 0 /* KRB5CCNAME, optional */ /* The following include extra space for TZ and MAXENV pointers... */ @@ -575,7 +606,9 @@ void doit(f, fromp) int s; struct hostent *hp; - char *hostname; + char hostname[MAXDNAME]; + char *sane_host; + char hostaddra[16]; short port; int pv[2], pw[2], px[2], cc; fd_set ready, readfrom; @@ -735,16 +768,23 @@ void doit(f, fromp) dup2(f, 2); hp = gethostbyaddr((char *)&fromp->sin_addr, sizeof (struct in_addr), fromp->sin_family); - if (hp){ - hostname = malloc(strlen(hp->h_name) + 1); - strcpy(hostname,hp->h_name); - } - else { - hostname = malloc(strlen((char *)inet_ntoa(fromp->sin_addr)) + 1); - strcpy(hostname,(char *)inet_ntoa(fromp->sin_addr)); + strncpy(hostaddra, inet_ntoa(fromp->sin_addr), sizeof (hostaddra)); + hostaddra[sizeof (hostaddra) - 1] = '\0'; + if (hp != NULL){ + strncpy(hostname, hp->h_name, sizeof (hostname)); + hostname[sizeof (hostname) - 1] = '\0'; } + else + hostname[0] = '\0'; #ifdef KERBEROS + status = pty_make_sane_hostname(fromp, maxhostlen, + stripdomain, always_ip, &sane_host); + if (status) { + error("failed make_sane_hostname: %s\n", error_message(status)); + exit(1); + } + if ((status = recvauth(f, fromaddr,&valid_checksum))) { error("Authentication failed: %s\n", error_message(status)); exit(1); @@ -776,8 +816,9 @@ void doit(f, fromp) pwd = getpwnam(locuser); if (pwd == (struct passwd *) 0 ) { syslog(LOG_ERR , - "Principal %s (%s@%s) for local user %s has no account.\n", - kremuser, remuser, hostname, locuser); /* xxx sprintf buffer in syslog*/ + "Principal %s (%s@%s (%s)) for local user %s has no account.\n", + kremuser, remuser, hostaddra, hostname, + locuser); /* xxx sprintf buffer in syslog*/ error("Login incorrect.\n"); exit(1); } @@ -828,18 +869,18 @@ void doit(f, fromp) endudb(); if (secflag) { if(getsysv(&sysv, sizeof(struct sysv)) != 0) { - loglogin(hostname, SLG_LLERR, 0, ue); + loglogin(sane_host, SLG_LLERR, 0, ue); error("Permission denied.\n"); exit(1); } if ((packet_level != ue->ue_deflvl) || ((packet_compart & ue->ue_comparts) != packet_compart )){ - loglogin(hostname, SLG_LLERR, 0, ue); + loglogin(sane_host, SLG_LLERR, 0, ue); error("Permission denied.\n"); exit(1); } if (ue->ue_disabled != 0) { - loglogin(hostname,SLG_LOCK,ue->ue_logfails,ue); + loglogin(sane_host,SLG_LOCK,ue->ue_logfails,ue); error("Permission denied.\n"); exit(1); } @@ -873,13 +914,13 @@ void doit(f, fromp) if (port) { /* Place entry into wtmp */ sprintf(ttyn,"krsh%1d",getpid()); - pty_logwtmp(ttyn,locuser,hostname); + pty_logwtmp(ttyn,locuser,sane_host); } /* We are simply execing a program over rshd : log entry into wtmp, as kexe(pid), then finish out the session right after that. Syslog should have the information as to what was exec'd */ else { - pty_logwtmp(ttyn,locuser,hostname); + pty_logwtmp(ttyn,locuser,sane_host); } #ifdef CRAY @@ -892,7 +933,7 @@ void doit(f, fromp) if (getusrv(&usrv)){ syslog(LOG_ERR,"Cannot getusrv"); error("Permission denied.\n"); - loglogin(hostname, SLG_LVERR, ue->ue_logfails,ue); + loglogin(sane_host, SLG_LVERR, ue->ue_logfails,ue); goto signout_please; } /* @@ -901,12 +942,12 @@ void doit(f, fromp) if((ue->ue_valcat & TFM_TRUSTED) || (sysv.sy_oldtfm && ((ue->ue_comparts & TRUSTED_SUBJECT) == TRUSTED_SUBJECT))) { - loglogin(hostname, SLG_TRSUB, ue->ue_logfails,ue); + loglogin(sane_host, SLG_TRSUB, ue->ue_logfails,ue); error("Permission denied.\n"); goto signout_please; } - loglogin(hostname, SLG_OKLOG, ue->ue_logfails,ue); + loglogin(sane_host, SLG_OKLOG, ue->ue_logfails,ue); /* Setup usrv structure with user udb info and packet_level and packet_compart. */ @@ -991,7 +1032,7 @@ void doit(f, fromp) } } if (nal_error) { - loglogin(hostname, SLG_LVERR, ue->ue_logfails,ue); + loglogin(sane_host, SLG_LVERR, ue->ue_logfails,ue); error("Permission denied.\n"); goto signout_please; } @@ -1001,7 +1042,7 @@ void doit(f, fromp) sethost(paddr); if (setusrv(&usrv) == -1) { - loglogin(hostname, SLG_LVERR, ue->ue_logfails,ue); + loglogin(sane_host, SLG_LVERR, ue->ue_logfails,ue); error("Permission denied.\n"); goto signout_please; } @@ -1014,11 +1055,11 @@ void doit(f, fromp) #endif /*CRAY*/ if (chdir(pwd->pw_dir) < 0) { - syslog(LOG_ERR , - "Principal %s (%s@%s) for local user %s has no home directory.\n", - kremuser, remuser, hostname, locuser); - error("No remote directory.\n"); + if(chdir("/") < 0) { + error("No remote directory.\n"); goto signout_please; + } + pwd->pw_dir = "/"; } #ifdef KERBEROS @@ -1028,8 +1069,8 @@ void doit(f, fromp) /* kuserok returns 0 if OK */ if (kuserok(v4_kdata, locuser)){ syslog(LOG_ERR , - "Principal %s (%s@%s) for local user %s failed kuserok.\n", - kremuser, remuser, hostname, locuser); + "Principal %s (%s@%s (%s)) for local user %s failed kuserok.\n", + kremuser, remuser, hostaddra, hostname, locuser); } else auth_sent |= AUTH_KRB4; } else @@ -1038,8 +1079,8 @@ void doit(f, fromp) /* krb5_kuserok returns 1 if OK */ if (!krb5_kuserok(bsd_context, client, locuser)){ syslog(LOG_ERR , - "Principal %s (%s@%s) for local user %s failed krb5_kuserok.\n", - kremuser, remuser, hostname, locuser); + "Principal %s (%s@%s (%s)) for local user %s failed krb5_kuserok.\n", + kremuser, remuser, hostaddra, hostname, locuser); } else auth_sent |= @@ -1049,7 +1090,8 @@ void doit(f, fromp) #else if (pwd->pw_passwd != 0 && *pwd->pw_passwd != '\0' && - ruserok(hostname, pwd->pw_uid == 0, remuser, locuser) < 0) { + ruserok(hostname[0] ? hostname : hostaddra, + pwd->pw_uid == 0, remuser, locuser) < 0) { error("Permission denied.\n"); goto signout_please; } @@ -1087,11 +1129,11 @@ void doit(f, fromp) pwd = (struct passwd *) getpwnam(locuser); if (pwd && (pwd->pw_uid == 0)) { #ifdef LOG_CMD - syslog(LOG_NOTICE, "Executing %s for principal %s (%s@%s) as ROOT", - cmdbuf, kremuser, remuser, hostname); + syslog(LOG_NOTICE, "Executing %s for principal %s (%s@%s (%s)) as ROOT", + cmdbuf, kremuser, remuser, hostaddra, hostname); #else - syslog(LOG_NOTICE ,"Access as ROOT by principal %s (%s@%s)", - kremuser, remuser, hostname); + syslog(LOG_NOTICE ,"Access as ROOT by principal %s (%s@%s (%s))", + kremuser, remuser, hostaddra, hostname); #endif } #if defined(KERBEROS) && defined(LOG_REMOTE_REALM) && !defined(LOG_OTHER_USERS) && !defined(LOG_ALL_LOGINS) @@ -1111,11 +1153,11 @@ void doit(f, fromp) #if defined(LOG_REMOTE_REALM) || defined(LOG_OTHER_USERS) || defined(LOG_ALL_LOGINS) { #ifdef LOG_CMD - syslog(LOG_NOTICE, "Executing %s for principal %s (%s@%s) as local user %s", - cmdbuf, kremuser, remuser, hostname, locuser); + syslog(LOG_NOTICE, "Executing %s for principal %s (%s@%s (%s)) as local user %s", + cmdbuf, kremuser, remuser, hostaddra, hostname, locuser); #else - syslog(LOG_NOTICE ,"Access as %s by principal %s (%s@%s)", - locuser, kremuser, remuser, hostname); + syslog(LOG_NOTICE ,"Access as %s by principal %s (%s@%s (%s))", + locuser, kremuser, remuser, hostaddra, hostname); #endif } #endif @@ -1316,6 +1358,13 @@ if(port) initgroups(pwd->pw_name, pwd->pw_gid); } #endif +#ifdef HAVE_SETLUID + /* + * If we're on a system which keeps track of login uids, then + * set the login uid. + */ + setluid((uid_t) pwd->pw_uid); +#endif /* HAVE_SETLUID */ (void) setuid((uid_t)pwd->pw_uid); /* if TZ is set in the parent, drag it in */ { @@ -1357,14 +1406,22 @@ if(port) { int i; - /* these two are covered by ADDRPAD */ + /* these four are covered by ADDRPAD */ sprintf(local_addr, "KRB5LOCALADDR=%s", inet_ntoa(localaddr.sin_addr)); for (i = 0; envinit[i]; i++); envinit[i] =local_addr; + sprintf(local_port, "KRB5LOCALPORT=%d", ntohs(localaddr.sin_port)); + for (; envinit[i]; i++); + envinit[i] =local_port; + sprintf(remote_addr, "KRB5REMOTEADDR=%s", inet_ntoa(fromp->sin_addr)); for (; envinit[i]; i++); envinit[i] =remote_addr; + + sprintf(remote_port, "KRB5REMOTEPORT=%d", ntohs(fromp->sin_port)); + for (; envinit[i]; i++); + envinit[i] =remote_port; } /* If we do anything else, make sure there is space in the array. */ @@ -1722,6 +1779,9 @@ recvauth(netf, peersin, valid_checksum) krb5_authenticator *authenticator; krb5_ticket *ticket; krb5_rcache rcache; + struct passwd *pwd; + uid_t uid; + gid_t gid; *valid_checksum = 0; len = sizeof(laddr); @@ -1827,7 +1887,7 @@ recvauth(netf, peersin, valid_checksum) &authenticator))) return status; - if (authenticator->checksum && checksum_required) { + if (authenticator->checksum && !checksum_ignored) { struct sockaddr_in adr; int adr_length = sizeof(adr); char * chksumbuf = (char *) malloc(strlen(cmdbuf)+strlen(locuser)+32); @@ -1877,12 +1937,24 @@ recvauth(netf, peersin, valid_checksum) } if (inbuf.length) { /* Forwarding being done, read creds */ + pwd = getpwnam(locuser); + if (!pwd) { + error("Login incorrect.\n"); + exit(1); + } + uid = pwd->pw_uid; + gid = pwd->pw_gid; if ((status = rd_and_store_for_creds(bsd_context, auth_context, &inbuf, - ticket, locuser, &ccache))) { + ticket, &ccache))) { error("Can't get forwarded credentials: %s\n", error_message(status)); exit(1); } + if (chown(krb5_cc_get_name(bsd_context, ccache), uid, gid) == -1) { + error("Can't chown forwarded credentials: %s\n", + error_message(errno)); + exit(1); + } } krb5_free_ticket(bsd_context, ticket); return 0; diff --git a/src/appl/bsd/kshd.M b/src/appl/bsd/kshd.M index df95c4d..43d0f7c 100644 --- a/src/appl/bsd/kshd.M +++ b/src/appl/bsd/kshd.M @@ -114,6 +114,20 @@ Don't allocate a reserved port for the stderr connection. .IP \fB\-P\ path\fP Use the argument to find the Kerberos binaries. Normally a compiled in argument is used. + +.TP +\fB\-w \fP[\fBip\fP|\fImaxhostlen\fP[\fB,\fP[\fBno\fP]\fBstriplocal\fP]] +Controls the form of the remote hostname passed to login(1). +Specifying \fBip\fP results in the numeric IP address always being +passed to login(1). Specifying a number, \fImaxhostlen\fP, sets the +maximum length of the hostname passed to login(1) before it will be +passed as a numeric IP address. If \fImaxhostlen\fP is 0, then the +system default, as determined by the utmp or utmpx structures, is +used. The \fBnostriplocal\fP and \fBstriplocal\fP options, which must +be preceded by a comma, control whether or not the local host domain +is stripped from the remote hostname. By default, the equivalent of +\fBstriplocal\fP is in effect. + .SH DIAGNOSTICS Except for the last one listed below, all diagnostic messages diff --git a/src/appl/bsd/login.M b/src/appl/bsd/login.M index 0603d16..f48fd0c 100644 --- a/src/appl/bsd/login.M +++ b/src/appl/bsd/login.M @@ -25,7 +25,7 @@ possible.) It will also attempt to run .I aklog to get \fIAFS\fP tokens for the user. The version 5 tickets will be tested against a local -.I v5srvtab +.I krb5.keytab if it is available, in order to verify the tickets, before letting the user in. However, if the password matches the entry in \fI/etc/passwd\fP the user will be unconditionally allowed (permitting diff --git a/src/appl/bsd/login.c b/src/appl/bsd/login.c index 7542a23..8a2baad 100644 --- a/src/appl/bsd/login.c +++ b/src/appl/bsd/login.c @@ -205,6 +205,10 @@ static const char * krb_get_err_text(kerror) #endif #endif +#ifdef HAVE_PATHS_H +#include +#endif + #include "loginpaths.h" #ifdef POSIX_TERMIOS @@ -232,12 +236,33 @@ static const char * krb_get_err_text(kerror) #define TTYGRPNAME "tty" /* name of group to own ttys */ +#if defined(_PATH_MAILDIR) +#define MAILDIR _PATH_MAILDIR +#else +#define MAILDIR "/usr/spool/mail" +#endif +#if defined(_PATH_NOLOGIN) +#define NOLOGIN _PATH_NOLOGIN +#else +#define NOLOGIN "/etc/nologin" +#endif +#if defined(_PATH_LASTLOG) +#define LASTLOG _PATH_LASTLOG +#else +#define LASTLOG "/usr/adm/lastlog" +#endif +#if defined(_PATH_BSHELL) +#define BSHELL _PATH_BSHELL +#else +#define BSHELL "/bin/sh" +#endif + +#if (defined(BSD) && (BSD >= 199103)) /* no /usr/ucb */ +#define QUOTAWARN "/usr/bin/quota" +#endif + #define MOTDFILE "/etc/motd" -#define MAILDIR "/usr/spool/mail" -#define NOLOGIN "/etc/nologin" #define HUSHLOGIN ".hushlogin" -#define LASTLOG "/usr/adm/lastlog" -#define BSHELL "/bin/sh" #if !defined(OQUOTA) && !defined(QUOTAWARN) #define QUOTAWARN "/usr/ucb/quota" /* warn user about quotas */ @@ -439,7 +464,7 @@ int unix_passwd_okay (pass) /* copy the first 8 chars of the password for unix crypt */ strncpy(user_pwcopy, pass, sizeof(user_pwcopy)); - user_pwcopy[8]='\0'; + user_pwcopy[sizeof(user_pwcopy) - 1]='\0'; namep = crypt(user_pwcopy, salt); memset (user_pwcopy, 0, sizeof(user_pwcopy)); /* ... and wipe the copy now that we have the string */ @@ -487,16 +512,19 @@ void k_init (ttyn) unlink(ccfile+strlen("FILE:")); } else { /* note it correctly */ - strcpy(ccfile, getenv(KRB5_ENV_CCNAME)); + strncpy(ccfile, getenv(KRB5_ENV_CCNAME), sizeof(ccfile)); + ccfile[sizeof(ccfile) - 1] = '\0'; } #ifdef KRB4_GET_TICKETS if (krb_get_lrealm(realm, 1) != KSUCCESS) { strncpy(realm, KRB_REALM, sizeof(realm)); + realm[sizeof(realm) - 1] = '\0'; } if (login_krb4_get_tickets || login_krb4_convert) { /* Set up the ticket file environment variable */ strncpy(tkfile, KRB_TK_DIR, sizeof(tkfile)); + tkfile[sizeof(tkfile) - 1] = '\0'; strncat(tkfile, strrchr(ttyn, '/')+1, sizeof(tkfile) - strlen(tkfile)); (void) unlink (tkfile); @@ -617,7 +645,8 @@ int try_krb5 (me_p, pass) } else { /* get_name pulls out just the name not the type */ - strcpy(ccfile, krb5_cc_get_name(kcontext, ccache)); + strncpy(ccfile, krb5_cc_get_name(kcontext, ccache), sizeof(ccfile)); + ccfile[sizeof(ccfile) - 1] = '\0'; krbflag = got_v5_tickets = 1; return 1; } @@ -708,7 +737,8 @@ try_convert524 (kcontext, me) return 0; } got_v4_tickets = 1; - strcpy(tkfile, tkt_string()); + strncpy(tkfile, tkt_string(), sizeof(tkfile)); + tkfile[sizeof(tkfile) - 1] = '\0'; return 1; } #endif @@ -729,7 +759,8 @@ try_krb4 (me, user_pwstring) case INTK_OK: kpass_ok = 1; krbflag = 1; - strcpy(tkfile, tkt_string()); + strncpy(tkfile, tkt_string(), sizeof(tkfile)); + tkfile[sizeof(tkfile) - 1] = '\0'; break; /* These errors should be silent */ /* So the Kerberos database can't be probed */ @@ -899,7 +930,8 @@ int verify_krb_v5_tgt (c) /* since krb5_sname_to_principal has done the work for us, just extract the name directly */ - strncpy(phost, krb5_princ_component(c, princ, 1)->data, BUFSIZ); + strncpy(phost, krb5_princ_component(c, princ, 1)->data, sizeof(phost)); + phost[sizeof(phost) - 1] = '\0'; /* Do we have host/ keys? */ /* (use default keytab, kvno IGNORE_VNO to get the first match, @@ -1023,7 +1055,8 @@ static sigtype sigsys () siglongjmp(setpag_buf, 1); } -static int try_afscall () +static int try_afscall (scall) + int (*scall)(); { handler sa, osa; volatile int retval = 0; @@ -1032,7 +1065,7 @@ static int try_afscall () handler_init (sa, sigsys); handler_swap (SIGSYS, sa, osa); if (sigsetjmp(setpag_buf, 1) == 0) { - setpag (); + (*scall)(); retval = 1; } handler_set (SIGSYS, osa); @@ -1105,7 +1138,7 @@ read_env_vars_from_file (filename) char *p, *eq; char tbuf[MAXPATHLEN+2]; - if ((fp = fopen("/etc/environment", "r")) != NULL) { + if ((fp = fopen(filename, "r")) != NULL) { while (fgets(tbuf, sizeof(tbuf), fp)) { if (tbuf[0] == '#') continue; @@ -1326,6 +1359,14 @@ int rewrite_ccache = 1; /*try to write out ccache*/ */ if (eflag) lgetstr(term, sizeof(term), "Terminal type"); + else if (!(kflag || Kflag )) /*Preserve terminal if not read over net */ + { + if (getenv("TERM")) { + strncpy(term, getenv("TERM"), sizeof(term)); + term[sizeof(term) - 1] = '\0'; + } + } + term_init (rflag || kflag || Kflag || eflag); for (cnt = getdtablesize(); cnt > 2; cnt--) @@ -1381,7 +1422,6 @@ int rewrite_ccache = 1; /*try to write out ccache*/ if (pwd == NULL || pwd->pw_uid) checknologin(); - /* * Allows automatic login by root. * If not invoked by root, disallow if the uid's differ. @@ -1724,11 +1764,12 @@ int rewrite_ccache = 1; /*try to write out ccache*/ #ifdef HAVE_SETLUID /* * If we're on a system which keeps track of login uids, then - * attempt to set the login uid, but don't get too unhappy when/if - * it doesn't succeed. + * set the login uid. If this fails this opens up a problem on DEC OSF + * with C2 enabled. */ - if ((uid_t) getluid() < (uid_t) 0) { - setluid((uid_t) pwd->pw_uid); + if (setluid((uid_t) pwd->pw_uid) < 0) { + perror("setuid"); + sleepexit(1); } #endif /* HAVE_SETLUID */ #ifdef _IBMR2 @@ -1828,19 +1869,21 @@ int rewrite_ccache = 1; /*try to write out ccache*/ read_env_vars_from_file ("/etc/TIMEZONE"); #else if (tz) - setenv ("TZ", tz, 0); + setenv ("TZ", tz, 1); #endif if (ccname) - setenv("KRB5CCNAME", ccname, 0); + setenv("KRB5CCNAME", ccname, 1); - setenv("HOME", pwd->pw_dir, 0); - setenv("PATH", LPATH, 0); - setenv("USER", pwd->pw_name, 0); - setenv("SHELL", pwd->pw_shell, 0); + setenv("HOME", pwd->pw_dir, 1); + setenv("PATH", LPATH, 1); + setenv("USER", pwd->pw_name, 1); + setenv("SHELL", pwd->pw_shell, 1); - if (term[0] == '\0') + if (term[0] == '\0') { (void) strncpy(term, stypeof(tty), sizeof(term)); + term[sizeof(term) - 1] = '\0'; + } if (term[0]) (void)setenv("TERM", term, 0); #ifdef KRB4_GET_TICKETS @@ -1922,8 +1965,9 @@ int rewrite_ccache = 1; /*try to write out ccache*/ handler_set (SIGTSTP, sa); tbuf[0] = '-'; - (void) strcpy(tbuf + 1, (p = strrchr(pwd->pw_shell, '/')) ? - p + 1 : pwd->pw_shell); + (void) strncpy(tbuf + 1, (p = strrchr(pwd->pw_shell, '/')) ? + p + 1 : pwd->pw_shell, sizeof(tbuf) - 1); + tbuf[sizeof(tbuf) - 1] = '\0'; execlp(pwd->pw_shell, tbuf, 0); fprintf(stderr, "login: no shell: "); perror(pwd->pw_shell); @@ -2180,7 +2224,7 @@ void dolastlog(quiet, tty) int quiet; char *tty; { -#ifdef HAVE_LASTLOG_H +#if defined(HAVE_LASTLOG_H) || (defined(BSD) && (BSD >= 199103)) struct lastlog ll; int fd; @@ -2202,9 +2246,11 @@ void dolastlog(quiet, tty) } (void)time(&ll.ll_time); (void) strncpy(ll.ll_line, tty, sizeof(ll.ll_line)); - if (hostname) + ll.ll_line[sizeof(ll.ll_line) - 1] = '\0'; + if (hostname) { (void) strncpy(ll.ll_host, hostname, sizeof(ll.ll_host)); - else + ll.ll_host[sizeof(ll.ll_host) - 1] = '\0'; + } else (void) memset(ll.ll_host, 0, sizeof(ll.ll_host)); (void)write(fd, (char *)&ll, sizeof(ll)); (void)close(fd); diff --git a/src/appl/bsd/loginpaths.h b/src/appl/bsd/loginpaths.h index 2f2de0b..41683ee 100644 --- a/src/appl/bsd/loginpaths.h +++ b/src/appl/bsd/loginpaths.h @@ -94,3 +94,18 @@ #define RPATH "/usr/bin:/bin" #endif #endif + +#ifdef _PATH_DEFPATH +#define LPATH _PATH_DEFPATH +#define RPATH _PATH_DEFPATH +#endif + +/* catch-all entries for operating systems we haven't looked up + hardcoded paths for */ +#ifndef LPATH +#define LPATH "/usr/bin:/bin" +#endif + +#ifndef RPATH +#define RPATH "/usr/bin:/bin" +#endif diff --git a/src/appl/bsd/v4rcp.c b/src/appl/bsd/v4rcp.c index 0a1ad33..425bf7f 100644 --- a/src/appl/bsd/v4rcp.c +++ b/src/appl/bsd/v4rcp.c @@ -37,8 +37,15 @@ static char sccsid[] = "@(#)rcp.c 5.10 (Berkeley) 9/20/88"; */ #ifdef KERBEROS #include "krb5.h" +#include "com_err.h" #endif +#ifdef HAVE_UNISTD_H +#include +#endif +#ifdef HAVE_STDLIB_H +#include +#endif #include #include #include @@ -55,9 +62,6 @@ static char sccsid[] = "@(#)rcp.c 5.10 (Berkeley) 9/20/88"; #include #include #include -#ifdef POSIX -#include -#endif #include #include #include @@ -65,6 +69,17 @@ static char sccsid[] = "@(#)rcp.c 5.10 (Berkeley) 9/20/88"; #ifdef KERBEROS #include #include + + +void sink(), source(), rsource(), usage(); +/*VARARGS*/ +void error(); +int response(); +#if !defined(HAS_UTIMES) +int utimes(); +#endif + + #if 0 #include #else @@ -304,15 +319,7 @@ int encryptflag = 0; kstream krem; int errs; -#ifdef POSIX -void lostconn(); -#else -int lostconn(); -#endif -int errno; -#ifndef __NetBSD__ -extern char *sys_errlist[]; -#endif +krb5_sigtype lostconn(); int iamremote, targetshouldbedirectory; int iamrecursive; int pflag; @@ -330,27 +337,18 @@ struct buffer { #define NULLBUF (struct buffer *) 0 -/*VARARGS*/ -int error(); - #define ga() (void) kstream_write (krem, "", 1) -main(argc, argv) +int main(argc, argv) int argc; char **argv; { - char *targ, *host, *src; - char *suser, *tuser, *thost; - int i; - char buf[BUFSIZ], cmd[50 + REALM_SZ]; char portarg[20], rcpportarg[20]; #ifdef ATHENA static char curhost[256]; #endif /* ATHENA */ #ifdef KERBEROS char realmarg[REALM_SZ + 5]; - long authopts; - char **orig_argv = save_argv(argc, argv); #endif /* KERBEROS */ portarg[0] = '\0'; @@ -450,9 +448,10 @@ main(argc, argv) #endif /* KERBEROS */ } usage(); + return 1; } -verifydir(cp) +void verifydir(cp) char *cp; { struct stat stb; @@ -462,11 +461,11 @@ verifydir(cp) return; errno = ENOTDIR; } - error("rcp: %s: %s.\n", cp, sys_errlist[errno]); + error("rcp: %s: %s.\n", cp, error_message(errno)); exit(1); } -source(argc, argv) +void source(argc, argv) int argc; char **argv; { @@ -481,7 +480,7 @@ source(argc, argv) for (x = 0; x < argc; x++) { name = argv[x]; if ((f = open(name, 0)) < 0) { - error("rcp: %s: %s\n", name, sys_errlist[errno]); + error("rcp: %s: %s\n", name, error_message(errno)); continue; } if (fstat(f, &stb) < 0) @@ -523,7 +522,7 @@ notreg: } } (void) sprintf(buf, "C%04o %ld %s\n", - stb.st_mode&07777, stb.st_size, last); + (unsigned int) stb.st_mode&07777, stb.st_size, last); kstream_write (krem, buf, strlen (buf)); if (response() < 0) { (void) close(f); @@ -546,7 +545,7 @@ notreg: if (readerr == 0) ga(); else - error("rcp: %s: %s\n", name, sys_errlist[readerr]); + error("rcp: %s: %s\n", name, error_message(readerr)); (void) response(); } } @@ -557,7 +556,7 @@ notreg: #include #endif -rsource(name, statp) +void rsource(name, statp) char *name; struct stat *statp; { @@ -572,7 +571,7 @@ rsource(name, statp) #endif if (d == 0) { - error("rcp: %s: %s\n", name, sys_errlist[errno]); + error("rcp: %s: %s\n", name, error_message(errno)); return; } last = strrchr(name, '/'); @@ -589,13 +588,14 @@ rsource(name, statp) return; } } - (void) sprintf(buf, "D%04o %d %s\n", statp->st_mode&07777, 0, last); + (void) sprintf(buf, "D%04o %d %s\n", + (unsigned int) statp->st_mode&07777, 0, last); kstream_write (krem, buf, strlen (buf)); if (response() < 0) { closedir(d); return; } - while (dp = readdir(d)) { + while ((dp = readdir(d))) { if (dp->d_ino == 0) continue; if (!strcmp(dp->d_name, ".") || !strcmp(dp->d_name, "..")) @@ -613,7 +613,7 @@ rsource(name, statp) (void) response(); } -response() +int response() { char resp, c, rbuf[BUFSIZ], *cp = rbuf; @@ -642,14 +642,10 @@ response() exit(1); } /*NOTREACHED*/ + return -1; } -#ifdef POSIX -void -#else -int -#endif -lostconn() +krb5_sigtype lostconn() { if (iamremote == 0) @@ -679,7 +675,7 @@ struct timeval *tvp; } #endif -sink(argc, argv) +void sink(argc, argv) int argc; char **argv; { @@ -738,7 +734,7 @@ sink(argc, argv) return; } -#define getnum(t) (t) = 0; while (isdigit(*cp)) (t) = (t) * 10 + (*cp++ - '0'); +#define getnum(t) (t) = 0; while (isdigit((int) *cp)) (t) = (t) * 10 + (*cp++ - '0'); if (*cp == 'T') { setimes++; cp++; @@ -781,7 +777,7 @@ sink(argc, argv) if (*cp++ != ' ') SCREWUP("mode not delimited"); size = 0; - while (isdigit(*cp)) + while (isdigit((int) *cp)) size = size * 10 + (*cp++ - '0'); if (*cp++ != ' ') SCREWUP("size not delimited"); @@ -807,13 +803,13 @@ sink(argc, argv) setimes = 0; if (utimes(nambuf, tv) < 0) error("rcp: can't set times on %s: %s\n", - nambuf, sys_errlist[errno]); + nambuf, error_message(errno)); } continue; } if ((of = open(nambuf, O_WRONLY|O_CREAT|O_TRUNC, mode)) < 0) { bad: - error("rcp: %s: %s\n", nambuf, sys_errlist[errno]); + error("rcp: %s: %s\n", nambuf, error_message(errno)); continue; } #ifdef NO_FCHMOD @@ -843,7 +839,7 @@ sink(argc, argv) error("rcp: dropped connection"); else error("rcp: %s\n", - sys_errlist[errno]); + error_message(errno)); exit(1); } amt -= j; @@ -863,7 +859,7 @@ sink(argc, argv) #ifndef __SCO__ if (ftruncate(of, size)) error("rcp: can't truncate %s: %s\n", - nambuf, sys_errlist[errno]); + nambuf, error_message(errno)); #endif (void) close(of); (void) response(); @@ -871,10 +867,10 @@ sink(argc, argv) setimes = 0; if (utimes(nambuf, tv) < 0) error("rcp: can't set times on %s: %s\n", - nambuf, sys_errlist[errno]); + nambuf, error_message(errno)); } if (wrerr) - error("rcp: %s: %s\n", nambuf, sys_errlist[errno]); + error("rcp: %s: %s\n", nambuf, error_message(errno)); else ga(); } @@ -893,7 +889,7 @@ allocbuf(bp, fd, blksize) struct stat stb; if (fstat(fd, &stb) < 0) { - error("rcp: fstat: %s\n", sys_errlist[errno]); + error("rcp: fstat: %s\n", error_message(errno)); return (NULLBUF); } size = roundup(stb.st_blksize, blksize); @@ -914,7 +910,7 @@ allocbuf(bp, fd, blksize) } /*VARARGS1*/ -error(fmt, a1, a2, a3, a4, a5) +void error(fmt, a1, a2, a3, a4, a5) char *fmt; int a1, a2, a3, a4, a5; { @@ -929,7 +925,7 @@ error(fmt, a1, a2, a3, a4, a5) (void) write(2, buf+1, strlen(buf+1)); } -usage() +void usage() { fprintf(stderr, "v4rcp: this program only acts as a server, and is not for user function.\n"); @@ -977,7 +973,7 @@ char *sp; void answer_auth() { - int sin_len, status; + int status; long authopts = KOPT_DO_MUTUAL; char instance[INST_SZ]; char version[9]; @@ -985,6 +981,8 @@ answer_auth() char *envaddr; #if 0 + int sin_len; + sin_len = sizeof (struct sockaddr_in); if (getpeername(rem, &foreign, &sin_len) < 0) { perror("getpeername"); @@ -997,26 +995,32 @@ answer_auth() exit(1); } #else - if (envaddr = getenv("KRB5LOCALADDR")) { + if ((envaddr = getenv("KRB5LOCALADDR"))) { #ifdef HAVE_INET_ATON inet_aton(envaddr, &local.sin_addr); #else local.sin_addr.s_addr = inet_addr(envaddr); #endif local.sin_family = AF_INET; - local.sin_port = 0; + if (envaddr = getenv("KRB5LOCALPORT")) + local.sin_port = htons(atoi(envaddr)); + else + local.sin_port = 0; } else { fprintf(stderr, "v4rcp: couldn't get local address (KRB5LOCALADDR)\n"); exit(1); } - if (envaddr = getenv("KRB5REMOTEADDR")) { + if ((envaddr = getenv("KRB5REMOTEADDR"))) { #ifdef HAVE_INET_ATON inet_aton(envaddr, &foreign.sin_addr); #else foreign.sin_addr.s_addr = inet_addr(envaddr); #endif foreign.sin_family = AF_INET; - foreign.sin_port = 0; + if (envaddr = getenv("KRB5REMOTEPORT")) + foreign.sin_port = htons(atoi(envaddr)); + else + foreign.sin_port = 0; } else { fprintf(stderr, "v4rcp: couldn't get remote address (KRB5REMOTEADDR)\n"); exit(1); diff --git a/src/appl/gss-sample/ChangeLog b/src/appl/gss-sample/ChangeLog index 5da0236..693fc45 100644 --- a/src/appl/gss-sample/ChangeLog +++ b/src/appl/gss-sample/ChangeLog @@ -1,3 +1,14 @@ +Sat Nov 7 01:36:00 1998 Theodore Y. Ts'o + + * gss-server.c (main): Fix file descriptor leak by adding missing + close() call. + +Fri Nov 22 15:48:02 1996 unknown + + * gss-client.c (connect_to_server): use sizeof instead of h_length + to determine number of bytes of addr to copy from DNS response + [krb5-misc/211] + Sun Oct 27 22:04:59 1996 Ezra Peisach * configure.in: Add USE_GSSAPI_LIBRARY diff --git a/src/appl/gss-sample/gss-client.c b/src/appl/gss-sample/gss-client.c index 170bc63..b91ea87 100644 --- a/src/appl/gss-sample/gss-client.c +++ b/src/appl/gss-sample/gss-client.c @@ -79,7 +79,7 @@ int connect_to_server(host, port) } saddr.sin_family = hp->h_addrtype; - memcpy((char *)&saddr.sin_addr, hp->h_addr, hp->h_length); + memcpy((char *)&saddr.sin_addr, hp->h_addr, sizeof(saddr.sin_addr)); saddr.sin_port = htons(port); if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) { diff --git a/src/appl/gss-sample/gss-server.c b/src/appl/gss-sample/gss-server.c index c2549e4..fa16766 100644 --- a/src/appl/gss-sample/gss-server.c +++ b/src/appl/gss-sample/gss-server.c @@ -494,6 +494,7 @@ main(argc, argv) /* this return value is not checked, because there's not really anything to do if it fails */ sign_server(s, server_creds); + close(s); } } while (!once); } diff --git a/src/appl/gssftp/ftp/ChangeLog b/src/appl/gssftp/ftp/ChangeLog index 9224e5d..7547baf 100644 --- a/src/appl/gssftp/ftp/ChangeLog +++ b/src/appl/gssftp/ftp/ChangeLog @@ -1,3 +1,52 @@ +Tue Mar 30 22:30:14 1999 Tom Yu + + * Makefile.in (KLIB): -lcom_err, not $(COMERRLIB) + +Thu Feb 25 23:05:03 1999 Tom Yu + + * secure.c (secure_putbuf): Revert Sam's last change; if + FUDGE_FACTOR is wrong, then badness can happen. Also, if + out_buf.length != nbytes+FUDGE_FACTOR, heap corruption could + happen. We really should be using gss_wrap_size_limit() or + something like that, but doing so would require substantial + amounts of reworking. [krb5-appl/685] + +Tue Dec 1 18:10:47 1998 Tom Yu + + * ftp.c (login): Unconditionally send password as PROT_P. + +Fri Aug 7 11:45:17 1998 Tom Yu + + * ftp.c (getreply): Restore proper setting of safe. This variable + was previously being set to the value of code rather than to the + boolean expression (code == 631), which it had been previously. + The bug resulted in all replies from the server being parsed as + krb_safe messages even when they were krb_priv messages. + +1998-04-21 Ken Raeburn + + * glob.c (ftpglob): Always allocate new storage, even if no magic + glob characters were found, because the caller will always free + the storage. + +Tue Apr 7 16:53:58 1998 Dan Winship + + * secure.c (secure_putbyte): Set nout = 0 *before* calling + secure_putbuf: if the transfer is aborted, the SIGURG handler will + longjmp out, so the line after the secure_putbuf will never get + executed, so nout would never be reset and the next transfer + would overrun ucbuf. + +Wed Apr 30 14:59:03 1997 Theodore Ts'o + + * cmds.c (getit): Fix Y2K bug in the parsing of the MDTM command. + [krb5-appl/399] + +Fri Nov 22 15:48:19 1996 unknown + + * ftp.c (hookup): use sizeof instead of h_length to determine + number of bytes of addr to copy from DNS response [krb5-misc/211] + Fri Sep 27 16:05:09 1996 Tom Yu * cmds.c (setpeer): Apply jik's fix so "-n" actually works as diff --git a/src/appl/gssftp/ftp/Makefile.in b/src/appl/gssftp/ftp/Makefile.in index 145ddc2..5a971fc 100644 --- a/src/appl/gssftp/ftp/Makefile.in +++ b/src/appl/gssftp/ftp/Makefile.in @@ -12,7 +12,7 @@ SRCS = cmds.c cmdtab.c domacro.c ftp.c getpass.c glob.c main.c pclose.c \ OBJS = cmds.o cmdtab.o domacro.o ftp.o getpass.o glob.o main.o pclose.o \ radix.o ruserpass.o secure.o -KLIB = -lgssapi_krb5 -lkrb5 -lcrypto $(COMERRLIB) +KLIB = -lgssapi_krb5 -lkrb5 -lcrypto -lcom_err DEPKLIB = $(TOPLIBD)/gssapi/libgssapi_krb5.a $(TOPLIBD)/libkrb5.a \ $(TOPLIBD)/libcrypto.a $(COMERRLIB) diff --git a/src/appl/gssftp/ftp/cmds.c b/src/appl/gssftp/ftp/cmds.c index 97bcc90..6759a25 100644 --- a/src/appl/gssftp/ftp/cmds.c +++ b/src/appl/gssftp/ftp/cmds.c @@ -819,9 +819,9 @@ usage: &yy, &mo, &day, &hour, &min, &sec); tm = gmtime(&stbuf.st_mtime); tm->tm_mon++; - if (tm->tm_year > yy%100) + if (tm->tm_year > yy-1900) return (1); - else if (tm->tm_year == yy%100) { + else if (tm->tm_year == yy-1900) { if (tm->tm_mon > mo) return (1); } else if (tm->tm_mon == mo) { diff --git a/src/appl/gssftp/ftp/ftp.c b/src/appl/gssftp/ftp/ftp.c index fb6a563..a5f34e7 100644 --- a/src/appl/gssftp/ftp/ftp.c +++ b/src/appl/gssftp/ftp/ftp.c @@ -155,7 +155,7 @@ hookup(host, port) } hisctladdr.sin_family = hp->h_addrtype; memcpy((caddr_t)&hisctladdr.sin_addr, hp->h_addr_list[0], - hp->h_length); + sizeof(hisctladdr.sin_addr)); (void) strncpy(hostnamebuf, hp->h_name, sizeof(hostnamebuf)); } hostname = hostnamebuf; @@ -177,7 +177,8 @@ hookup(host, port) perror((char *) 0); hp->h_addr_list++; memcpy((caddr_t)&hisctladdr.sin_addr, - hp->h_addr_list[0], hp->h_length); + hp->h_addr_list[0], + sizeof(hisctladdr.sin_addr)); fprintf(stdout, "Trying %s...\n", inet_ntoa(hisctladdr.sin_addr)); (void) close(s); @@ -291,7 +292,8 @@ login(host) if (pass == NULL) pass = mygetpass("Password:"); #ifndef NOENCRYPTION - if ((oldlevel = level) == PROT_S) level = PROT_P; + oldlevel = level; + level = PROT_P; #endif n = command("PASS %s", pass); #ifndef NOENCRYPTION @@ -590,7 +592,7 @@ getreply(expecteof) if (code != 631 && code != 632 && code != 633) { printf("Unknown reply: %d %s\n", code, obuf); n = '5'; - } else safe = code; + } else safe = (code == 631); if (obuf[0]) /* if there is a string to decode */ if (!auth_type) { printf("Cannot decode reply:\n%d %s\n", code, obuf); diff --git a/src/appl/gssftp/ftp/glob.c b/src/appl/gssftp/ftp/glob.c index 3a793d8..f92ee5e 100644 --- a/src/appl/gssftp/ftp/glob.c +++ b/src/appl/gssftp/ftp/glob.c @@ -104,8 +104,17 @@ ftpglob(v) vv[1] = 0; gflag = 0; rscan(vv, tglob); - if (gflag == 0) - return (copyblk(vv)); + if (gflag == 0) { + /* Caller will always free the contents, so make a copy. */ + size_t len = strlen (v) + 1; + vv[0] = malloc (len); + if (vv[0] == 0) { + globerr = "Can't allocate memory"; + return 0; + } + memcpy (vv[0], v, len); + return (copyblk(vv)); + } globerr = 0; gpath = agpath; gpathp = gpath; *gpathp = 0; diff --git a/src/appl/gssftp/ftp/secure.c b/src/appl/gssftp/ftp/secure.c index 183f10a..d0faf73 100644 --- a/src/appl/gssftp/ftp/secure.c +++ b/src/appl/gssftp/ftp/secure.c @@ -153,8 +153,8 @@ unsigned char c; ucbuf[nout++] = c; if (nout == MAX - FUDGE_FACTOR) { - ret = secure_putbuf(fd, ucbuf, nout); nout = 0; + ret = secure_putbuf(fd, ucbuf, MAX - FUDGE_FACTOR); return(ret?ret:c); } return (c); @@ -281,7 +281,7 @@ unsigned int nbyte; if (outbuf? (outbuf = realloc(outbuf, (unsigned) out_buf.length)): (outbuf = malloc((unsigned) out_buf.length))) { - bufsize = nbyte + FUDGE_FACTOR; + bufsize = out_buf.length; } else { bufsize = 0; secure_error("%s (in malloc of PROT buffer)", diff --git a/src/appl/gssftp/ftpd/ChangeLog b/src/appl/gssftp/ftpd/ChangeLog index 2a2e348..01937b7 100644 --- a/src/appl/gssftp/ftpd/ChangeLog +++ b/src/appl/gssftp/ftpd/ChangeLog @@ -1,3 +1,108 @@ +1999-04-13 + + * configure.in: Check to see if we need to pull in the util + library in order to find logwtmp(). (Needed for + Linux/glibc 2.1.) + +Tue Mar 30 22:30:40 1999 Tom Yu + + * Makefile.in (KLIB): -lcom_err, not $(COMERRLIB) + +Thu Mar 25 23:13:56 1999 Tom Yu + + * ftpd.c (login): Check that the luid is not the uid we want to + change to prior to calling setluid() so that we can run as + non-root. + +Wed Mar 24 17:11:32 1999 Tom Yu + + * configure.in: Check for sys/sockio.h. + + * ftpcmd.y (urgsafe_getc): New function; like getc() except it + retries once if SIOCATMARK returns TRUE. + (getline): Use urgsafe_getc() rather than getc() to avoid problems + with certain Mac clients that cause the urgent pointer to end up + in a location that results in EOF from getc(). + +Mon Mar 8 23:47:51 1999 Tom Yu + + * ftpd.M: Resync with reality. + + * Makefile.in (ftpd): Add libpty to link line. Remove mention of + logwtmp files. + + * ftpd.c: Fix up hostname logging to use + pty_make_sane_hostname(). + +Thu Feb 25 23:31:37 1999 Tom Yu + + * ftpd.c (reply): Don't call secure_gss_error() or secure_error() + from within reply() to avoid setting up an infinite + loop. [krb5-appl/684] + +Thu Feb 18 18:34:23 1999 Tom Yu + + * configure.in: Add check for setluid() in libsecurity. + + * ftpd.c (login): Add call to setluid() if necessary. + +Fri Feb 12 21:16:26 1999 Tom Yu + + * ftpd.c: strcat -> strncat + +Fri Oct 23 18:18:52 1998 Theodore Y. Ts'o + + * ftpcmd.y (cmd): Don't allow the PORT command to accept a port + number lower than 1024; this prevents some nasty ftp + "bounce attacks" to SMTP ports, etc. + +Fri May 8 18:06:52 1998 Theodore Y. Ts'o + + * ftpcmd.y (cmd): Fix Y2K problem in the MDTM command. + +Tue Apr 21 19:59:45 1998 Tom Yu + + * configure.in: Add CHECK_SIGNALS and CHECK_SETJMP to help with + changes in ftpd.c. + +Fri Apr 10 20:06:31 1998 Tom Yu + + * ftpd.c (receive_data): + (send_data): Add support for sigsetjmp(). + (main): Use sigaction() if we can to avoid SysV lossage. + (send_file_list): Oops missed a sigsetjmp() call. + (send_data): Add call to secure_flush() to send a zero length + buffer when aborting. + (send_file_list): Add call to secure_flush() to send a zero length + buffer when aborting. + + * ftpcmd.y (PBSZ): Remove restriction on shrinking buffer size. + +Thu Mar 5 13:59:47 1998 Dan Winship + + * ftpcmd.y (getline): Don't syslog passwords! (or newlines) + +Tue Feb 24 21:34:34 1998 Tom Yu + + * ftpcmd.y: Add production "nonguest" to catch things that + anonymous users aren't supposed to do. Replace "check_login" with + "nonguest" in a few places to prevent w4r3z d00dz from being + lame with world-writable incoming directories. + +Fri Feb 6 13:25:28 1998 Theodore Y. Ts'o + + * popen.c (ftpd_popen): Make sure you can't overrun the argv[] and + gargv[] arrays. (Patch submitted by dima@best.net). + +Sun Dec 21 18:17:53 1997 Tom Yu + + * logwtmp.c (ftp_logwtmp): Rename logwtmp to ftp_logwtmp to avoid + collision with native logwtmp. Also, return void rather than + int. + + * ftpd.c: Rename logwtmp to ftp_logwtmp to avoid collision with + native logwtmp. + Tue Nov 12 00:04:00 1996 Tom Yu * ftpd.c (ftpd_userok): Don't undconditionally return -1. diff --git a/src/appl/gssftp/ftpd/Makefile.in b/src/appl/gssftp/ftpd/Makefile.in index c6dec99..5e7a732 100644 --- a/src/appl/gssftp/ftpd/Makefile.in +++ b/src/appl/gssftp/ftpd/Makefile.in @@ -8,16 +8,19 @@ SETENVOBJ=@SETENVOBJ@ LIBOBJS=@LIBOBJS@ COMERRLIB=$(BUILDTOP)/util/et/libcom_err.a -SRCS = ftpd.c ftpcmd.y logwtmp.c popen.c vers.c \ +LOCAL_LIBRARIES=-lpty +DEPLOCAL_LIBRARIES=$(TOPLIBD)/../util/pty/libpty.a + +SRCS = ftpd.c ftpcmd.y popen.c vers.c \ $(srcdir)../ftp/glob.c \ $(srcdir)../ftp/radix.c \ $(srcdir)../ftp/secure.c \ $(srcdir)../../bsd/getdtablesize.c $(SETENVSRC) -OBJS = ftpd.o ftpcmd.o glob.o popen.o logwtmp.o vers.o radix.o \ +OBJS = ftpd.o ftpcmd.o glob.o popen.o vers.o radix.o \ secure.o $(LIBOBJS) $(SETENVOBJ) -KLIB = -lgssapi_krb5 -lkrb5 -lcrypto $(COMERRLIB) +KLIB = -lgssapi_krb5 -lkrb5 -lcrypto -lcom_err DEPKLIB = $(TOPLIBD)/gssapi/libgssapi_krb5.a $(TOPLIBD)/libkrb5.a \ $(TOPLIBD)/libcrypto.a $(COMERRLIB) @@ -68,7 +71,6 @@ secure.o: $(srcdir)/secure.h ftpd.o: $(srcdir)/ftpd.c ftpcmd.o: ftpcmd.c popen.o: $(srcdir)/popen.c -logwtmp.o: $(srcdir)/logwtmp.c vers.o: $(srcdir)/vers.c # NOPOSTFIX diff --git a/src/appl/gssftp/ftpd/configure.in b/src/appl/gssftp/ftpd/configure.in index e247201..75f8944 100644 --- a/src/appl/gssftp/ftpd/configure.in +++ b/src/appl/gssftp/ftpd/configure.in @@ -7,16 +7,19 @@ KRB5_SIGTYPE CHECK_UTMP CHECK_SIGPROCMASK CHECK_WAIT_TYPE +CHECK_SETJMP +CHECK_SIGNALS AC_CHECK_SIZEOF(short) AC_CHECK_SIZEOF(int) AC_CHECK_SIZEOF(long) DECLARE_SYS_ERRLIST AC_FUNC_VFORK AC_HEADER_STDARG -AC_CHECK_HEADERS(unistd.h stdlib.h string.h) +AC_CHECK_HEADERS(unistd.h stdlib.h string.h sys/sockio.h) AC_REPLACE_FUNCS(getdtablesize) AC_HAVE_FUNCS(getcwd getusershell seteuid setreuid setresuid) AC_CHECK_LIB(crypt,crypt) dnl +AC_CHECK_LIB(util,logwtmp) dnl dnl copied from appl/bsd/configure.in AC_MSG_CHECKING([setenv]) @@ -45,6 +48,14 @@ AC_DEFINE(HAVE_SHADOW) fi dnl dnl +case $krb5_cv_host in +alpha-dec-osf*) + AC_CHECK_LIB(security,setluid, + AC_DEFINE(HAVE_SETLUID) + LIBS="$LIBS -lsecurity" + ) + ;; +esac USE_ANAME KRB5_LIBRARIES V5_USE_SHARED_LIB diff --git a/src/appl/gssftp/ftpd/ftpcmd.y b/src/appl/gssftp/ftpd/ftpcmd.y index c014f35..19bdd27 100644 --- a/src/appl/gssftp/ftpd/ftpcmd.y +++ b/src/appl/gssftp/ftpd/ftpcmd.y @@ -49,6 +49,10 @@ static char sccsid[] = "@(#)ftpcmd.y 5.24 (Berkeley) 2/25/91"; #include #include #include +#include +#ifdef HAVE_SYS_SOCKIO_H +#include +#endif #include #include #include @@ -107,6 +111,8 @@ extern gss_ctx_id_t gcontext; #endif #endif +static struct sockaddr_in host_port; + extern struct sockaddr_in data_dest; extern int logged_in; extern struct passwd *pw; @@ -212,12 +218,22 @@ cmd: USER SP username CRLF } | PORT SP host_port CRLF = { - usedefault = 0; - if (pdata >= 0) { - (void) close(pdata); - pdata = -1; + /* + * Don't allow a port < 1024 if we're not + * connecting back to the original source address + * This prevents nastier forms of the bounce attack. + */ + if (ntohs(host_port.sin_port) < 1024) + reply(504, "Port number too low"); + else { + data_dest = host_port; + usedefault = 0; + if (pdata >= 0) { + (void) close(pdata); + pdata = -1; + } + reply(200, "PORT command successful."); } - reply(200, "PORT command successful."); } | PASV check_login CRLF = { @@ -243,8 +259,6 @@ cmd: USER SP username CRLF else if (strlen($3) > 10 || strlen($3) == 10 && strcmp($3,"4294967296") >= 0) reply(501, "Bad value for PBSZ: %s", $3); - else if (actualbuf >= (maxbuf =(unsigned int) atol($3))) - reply(200, "PBSZ=%u", actualbuf); else { if (ucbuf) (void) free(ucbuf); actualbuf = (unsigned int) atol($3); @@ -594,9 +608,10 @@ cmd: USER SP username CRLF struct tm *gmtime(); t = gmtime(&stbuf.st_mtime); reply(213, - "19%02d%02d%02d%02d%02d%02d", - t->tm_year, t->tm_mon+1, t->tm_mday, - t->tm_hour, t->tm_min, t->tm_sec); + "%4d%02d%02d%02d%02d%02d", + 1900+t->tm_year, t->tm_mon+1, + t->tm_mday, t->tm_hour, + t->tm_min, t->tm_sec); } } if ($4 != NULL) @@ -660,11 +675,11 @@ host_port: NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA = { register char *a, *p; - a = (char *)&data_dest.sin_addr; + a = (char *)&host_port.sin_addr; a[0] = $1; a[1] = $3; a[2] = $5; a[3] = $7; - p = (char *)&data_dest.sin_port; + p = (char *)&host_port.sin_port; p[0] = $9; p[1] = $11; - data_dest.sin_family = AF_INET; + host_port.sin_family = AF_INET; } ; @@ -906,6 +921,26 @@ lookup(p, cmd) return (0); } +/* + * urgsafe_getc - hacked up getc to ignore EOF if SIOCATMARK returns TRUE + */ +int +urgsafe_getc(f) + FILE *f; +{ + register int c; + int atmark; + + c = getc(f); + if (c == EOF) { + if (ioctl(fileno(f), SIOCATMARK, &atmark) != -1) { + c = getc(f); + syslog(LOG_DEBUG, "atmark: c=%d", c); + } + } + return c; +} + #include /* @@ -918,6 +953,7 @@ getline(s, n, iop) { register c; register char *cs; + int atmark; cs = s; /* tmpline may contain saved command from urgent mode interruption */ @@ -933,21 +969,23 @@ getline(s, n, iop) if (c == 0) tmpline[0] = '\0'; } - while ((c = getc(iop)) != EOF) { + while ((c = urgsafe_getc(iop)) != EOF) { c &= 0377; if (c == IAC) { - if ((c = getc(iop)) != EOF) { + if (debug) syslog(LOG_DEBUG, "got IAC"); + if ((c = urgsafe_getc(iop)) != EOF) { c &= 0377; + if (debug) syslog(LOG_DEBUG, "got IAC %d", c); switch (c) { case WILL: case WONT: - c = getc(iop); + c = urgsafe_getc(iop); printf("%c%c%c", IAC, DONT, 0377&c); (void) fflush(stdout); continue; case DO: case DONT: - c = getc(iop); + c = urgsafe_getc(iop); printf("%c%c%c", IAC, WONT, 0377&c); (void) fflush(stdout); continue; @@ -1085,8 +1123,13 @@ getline(s, n, iop) } #endif /* KERBEROS */ - if (debug) - syslog(LOG_DEBUG, "command: <%s>(%d)", s, strlen(s)); + if (debug) { + if (!strncmp(s, "PASS ", 5) && !guest) + syslog(LOG_DEBUG, "command: "); + else + syslog(LOG_DEBUG, "command: <%.*s>(%d)", + strlen(s) - 2, s, strlen(s)); + } return (s); } diff --git a/src/appl/gssftp/ftpd/ftpd.M b/src/appl/gssftp/ftpd/ftpd.M index 0a782e6..10f6d05 100644 --- a/src/appl/gssftp/ftpd/ftpd.M +++ b/src/appl/gssftp/ftpd/ftpd.M @@ -42,6 +42,7 @@ Internet File Transfer Protocol server [\fB\-d\fP] [\fB\-l\fP] [\fB\-t\fP \fItimeout\fP] [\fB\-T\fP \fImaxtimeout\fP] [\fB\-p\fP \fIport\fP] [\fB\-r\fP \fIrealm-file\fP] [\fB\-s\fP \fIsrvtab\fP] +[\fB\-w\fP[\fBip\fP|\fImaxhostlen\fP[\fB,\fP[\fBno\fP]\fBstriplocal\fP]]] .SH DESCRIPTION .B Ftpd is the @@ -95,6 +96,18 @@ Sets the name of the .I srvtab file to use. The default value is normally .IR /etc/krb-srvtab . +.TP +\fB\-w \fP[\fBip\fP|\fImaxhostlen\fP[\fB,\fP[\fBno\fP]\fBstriplocal\fP]] +Controls the form of the remote hostname passed to login(1). +Specifying \fBip\fP results in the numeric IP address always being +passed to login(1). Specifying a number, \fImaxhostlen\fP, sets the +maximum length of the hostname passed to login(1) before it will be +passed as a numeric IP address. If \fImaxhostlen\fP is 0, then the +system default, as determined by the utmp or utmpx structures, is +used. The \fBnostriplocal\fP and \fBstriplocal\fP options, which must +be preceded by a comma, control whether or not the local host domain +is stripped from the remote hostname. By default, the equivalent of +\fBstriplocal\fP is in effect. .PP The ftp server currently supports the following ftp requests; case is not distinguished. diff --git a/src/appl/gssftp/ftpd/ftpd.c b/src/appl/gssftp/ftpd/ftpd.c index b4a5794..0ebac7c 100644 --- a/src/appl/gssftp/ftpd/ftpd.c +++ b/src/appl/gssftp/ftpd/ftpd.c @@ -69,6 +69,14 @@ static char sccsid[] = "@(#)ftpd.c 5.40 (Berkeley) 7/2/91"; #include #endif #include +#ifndef POSIX_SETJMP +#undef sigjmp_buf +#undef sigsetjmp +#undef siglongjmp +#define sigjmp_buf jmp_buf +#define sigsetjmp(j,s) setjmp(j) +#define siglongjmp longjmp +#endif #include #include #include @@ -86,6 +94,7 @@ static char sccsid[] = "@(#)ftpd.c 5.40 (Berkeley) 7/2/91"; #include #endif #include "pathnames.h" +#include #ifndef L_SET #define L_SET 0 @@ -127,6 +136,7 @@ char *keyfile = KEYFILE; #ifdef GSSAPI #include #include +#include gss_ctx_id_t gcontext; gss_buffer_desc client_name; int gss_ok; /* GSSAPI authentication and userok authorization succeeded */ @@ -158,7 +168,8 @@ struct sockaddr_in his_addr; struct sockaddr_in pasv_addr; int data; -jmp_buf errcatch, urgcatch; +jmp_buf errcatch; +sigjmp_buf urgcatch; int logged_in; struct passwd *pw; int debug; @@ -185,6 +196,9 @@ int defumask = CMASK; /* default umask value */ char tmpline[FTP_BUFSIZ]; char hostname[MAXHOSTNAMELEN]; char remotehost[MAXHOSTNAMELEN]; +char rhost_addra[16]; +char *rhost_sane; + /* * Timeout intervals for retrying connections @@ -218,6 +232,10 @@ int initgroups(char* name, gid_t basegid) { } #endif +int stripdomain = 1; +int maxhostlen = 0; +int always_ip = 0; + main(argc, argv, envp) int argc; char *argv[]; @@ -317,6 +335,43 @@ main(argc, argv, envp) goto nextopt; } + case 'w': + { + char *optarg; + if (*++cp != '\0') + optarg = cp; + else if (argc > 1) { + argc--; + argv++; + optarg = *argv; + } else { + fprintf(stderr, "ftpd: -w expects arg\n"); + exit(1); + } + + if (!strcmp(optarg, "ip")) + always_ip = 1; + else { + char *cp; + cp = strchr(optarg, ','); + if (cp == NULL) + maxhostlen = atoi(optarg); + else if (*(++cp)) { + if (!strcmp(cp, "striplocal")) + stripdomain = 1; + else if (!strcmp(cp, "nostriplocal")) + stripdomain = 0; + else { + fprintf(stderr, + "ftpd: bad arg to -w\n"); + exit(1); + } + *(--cp) = '\0'; + maxhostlen = atoi(optarg); + } + } + goto nextopt; + } default: fprintf(stderr, "ftpd: Unknown flag -%c ignored.\n", *cp); @@ -399,9 +454,21 @@ nextopt: (void) signal(SIGPIPE, lostconn); (void) signal(SIGCHLD, SIG_IGN); #ifdef SIGURG +#ifdef POSIX_SIGNALS + { + struct sigaction sa; + + sigemptyset(&sa.sa_mask); + sa.sa_flags = 0; + sa.sa_handler = myoob; + if (sigaction(SIGURG, &sa, NULL) < 0) + syslog(LOG_ERR, "signal: %m"); + } +#else if ((long)signal(SIGURG, myoob) < 0) syslog(LOG_ERR, "signal: %m"); -#endif +#endif /* POSIX_SIGNALS */ +#endif /* SIGURG */ /* Try to handle urgent data inline */ #ifdef SO_OOBINLINE @@ -587,8 +654,8 @@ user(name) reply(530, "User %s access denied.", name); if (logging) syslog(LOG_NOTICE, - "FTP LOGIN REFUSED FROM %s, %s", - remotehost, name); + "FTP LOGIN REFUSED FROM %s, %s (%s)", + rhost_addra, remotehost, name); pw = (struct passwd *) NULL; return; } @@ -691,7 +758,7 @@ end_login() (void) seteuid((uid_t)0); if (logged_in) - logwtmp(ttyline, "", ""); + pty_logwtmp(ttyline, "", ""); pw = NULL; logged_in = 0; guest = 0; @@ -792,8 +859,8 @@ pass(passwd) pw = NULL; if (login_attempts++ >= 5) { syslog(LOG_NOTICE, - "repeated login failures from %s", - remotehost); + "repeated login failures from %s (%s)", + rhost_addra, remotehost); exit(0); } return; @@ -804,8 +871,8 @@ pass(passwd) (void) initgroups(pw->pw_name, pw->pw_gid); /* open wtmp before chroot */ - (void)sprintf(ttyline, "ftp%d", getpid()); - logwtmp(ttyline, pw->pw_name, remotehost); + (void) sprintf(ttyline, "ftp%d", getpid()); + pty_logwtmp(ttyline, pw->pw_name, rhost_sane); logged_in = 1; if (guest) { @@ -826,6 +893,18 @@ pass(passwd) } else lreply(230, "No directory! Logging in with home=/"); } +#ifdef HAVE_SETLUID + /* + * If we're on a system which keeps track of login uids, then + * set the login uid. If this fails this opens up a problem on DEC OSF + * with C2 enabled. + */ + if (((uid_t)getluid() != pw->pw_uid) + && setluid((uid_t)pw->pw_uid) < 0) { + reply(550, "Can't set luid."); + goto bad; + } +#endif if (seteuid((uid_t)pw->pw_uid) < 0) { reply(550, "Can't set uid."); goto bad; @@ -833,23 +912,24 @@ pass(passwd) if (guest) { reply(230, "Guest login ok, access restrictions apply."); #ifdef SETPROCTITLE - sprintf(proctitle, "%s: anonymous/%.*s", remotehost, - sizeof(proctitle) - sizeof(remotehost) - + sprintf(proctitle, "%s: anonymous/%.*s", rhost_sane, + sizeof(proctitle) - strlen(rhost_sane) - sizeof(": anonymous/"), passwd); setproctitle(proctitle); #endif /* SETPROCTITLE */ if (logging) - syslog(LOG_INFO, "ANONYMOUS FTP LOGIN FROM %s, %s", - remotehost, passwd); + syslog(LOG_INFO, + "ANONYMOUS FTP LOGIN FROM %s, %s (%s)", + rhost_addra, remotehost, passwd); } else { reply(230, "User %s logged in.", pw->pw_name); #ifdef SETPROCTITLE - sprintf(proctitle, "%s: %s", remotehost, pw->pw_name); + sprintf(proctitle, "%s: %s", rhost_sane, pw->pw_name); setproctitle(proctitle); #endif /* SETPROCTITLE */ if (logging) - syslog(LOG_INFO, "FTP LOGIN FROM %s, %s", - remotehost, pw->pw_name); + syslog(LOG_INFO, "FTP LOGIN FROM %s, %s (%s)", + rhost_addra, remotehost, pw->pw_name); } home = pw->pw_dir; /* home dir for globbing */ (void) umask(defumask); @@ -1143,8 +1223,9 @@ send_data(instr, outstr, blksize) int ret = 0; transflag++; - if (setjmp(urgcatch)) { + if (sigsetjmp(urgcatch, 1)) { transflag = 0; + (void)secure_flush(fileno(outstr)); return; } switch (type) { @@ -1225,7 +1306,7 @@ receive_data(instr, outstr) int ret = 0; transflag++; - if (setjmp(urgcatch)) { + if (sigsetjmp(urgcatch, 1)) { transflag = 0; return (-1); } @@ -1342,9 +1423,8 @@ statcmd() lreply(211, "%s FTP server status:", hostname, version); reply(0, " %s", version); - sprintf(str, " Connected to %s", remotehost); - if (!isdigit(remotehost[0])) - sprintf(&str[strlen(str)], " (%s)", inet_ntoa(his_addr.sin_addr)); + sprintf(str, " Connected to %s", remotehost[0] ? remotehost : ""); + sprintf(&str[strlen(str)], " (%s)", rhost_addra); reply(0, "%s", str); if (auth_type) reply(0, " Authentication type: %s", auth_type); if (logged_in) { @@ -1364,7 +1444,7 @@ statcmd() sprintf(&str[strlen(str)], ", FORM: %s", formnames[form]); if (type == TYPE_L) #if 1 - strcat(str, " 8"); + strncat(str, " 8", sizeof (str) - strlen(str) - 1); #else /* this is silly. -- eichin@cygnus.com */ #if NBBY == 8 @@ -1438,7 +1518,7 @@ reply(n, fmt, p0, p1, p2, p3, p4, p5) */ if (n) sprintf(in, "%d%c", n, cont_char); else in[0] = '\0'; - strcat(in, buf); + strncat(in, buf, sizeof (in) - strlen(in) - 1); #ifdef KERBEROS if (strcmp(auth_type, "KERBEROS_V4") == 0) if ((length = level == PROT_P ? @@ -1468,13 +1548,19 @@ reply(n, fmt, p0, p1, p2, p3, p4, p5) &in_buf, &conf_state, &out_buf); if (maj_stat != GSS_S_COMPLETE) { +#if 0 +/* Don't setup an infinite loop */ /* generally need to deal */ secure_gss_error(maj_stat, min_stat, (level==PROT_P)? "gss_seal ENC didn't complete": "gss_seal MIC didn't complete"); +#endif /* 0 */ } else if ((level == PROT_P) && !conf_state) { +#if 0 +/* Don't setup an infinite loop */ secure_error("GSSAPI didn't encrypt message"); +#endif /* 0 */ } else { memcpy(out, out_buf.value, length=out_buf.length); @@ -1644,21 +1730,31 @@ dolog(sin) sizeof (struct in_addr), AF_INET); time_t t, time(); extern char *ctime(); + krb5_error_code retval; - if (hp) + if (hp != NULL) { (void) strncpy(remotehost, hp->h_name, sizeof (remotehost)); - else - (void) strncpy(remotehost, inet_ntoa(sin->sin_addr), - sizeof (remotehost)); + remotehost[sizeof (remotehost) - 1] = '\0'; + } else + remotehost[0] = '\0'; + strncpy(rhost_addra, inet_ntoa(sin->sin_addr), sizeof (rhost_addra)); + rhost_addra[sizeof (rhost_addra) - 1] = '\0'; + retval = pty_make_sane_hostname(sin, maxhostlen, + stripdomain, always_ip, &rhost_sane); + if (retval) { + fprintf(stderr, "make_sane_hostname: %s\n", + error_message(retval)); + exit(1); + } #ifdef SETPROCTITLE - sprintf(proctitle, "%s: connected", remotehost); + sprintf(proctitle, "%s: connected", rhost_sane); setproctitle(proctitle); #endif /* SETPROCTITLE */ if (logging) { t = time((time_t *) 0); - syslog(LOG_INFO, "connection from %s at %s", - remotehost, ctime(&t)); + syslog(LOG_INFO, "connection from %s (%s) at %s", + rhost_addra, remotehost, ctime(&t)); } } @@ -1671,7 +1767,7 @@ dologout(status) { if (logged_in) { (void) seteuid((uid_t)0); - logwtmp(ttyline, "", ""); + pty_logwtmp(ttyline, "", ""); } /* beware of flushing buffers after a SIGPIPE */ _exit(status); @@ -1698,7 +1794,7 @@ myoob() tmpline[0] = '\0'; reply(426, "Transfer aborted. Data connection closed."); reply(226, "Abort successful"); - longjmp(urgcatch, 1); + siglongjmp(urgcatch, 1); } if (strcmp(cp, "STAT") == 0) { if (file_size != (off_t) -1) @@ -2139,8 +2235,9 @@ send_file_list(whichfiles) simple = 1; } - if (setjmp(urgcatch)) { + if (sigsetjmp(urgcatch, 1)) { transflag = 0; + (void)secure_flush(fileno(dout)); return; } while (dirname = *dirlist++) { @@ -2319,7 +2416,6 @@ char *s; } -#include /* ftpd_userok -- hide details of getting the name and verifying it */ /* returns 0 for OK */ ftpd_userok(client_name, name) diff --git a/src/appl/gssftp/ftpd/logwtmp.c b/src/appl/gssftp/ftpd/logwtmp.c index 36f7e13..846819a 100644 --- a/src/appl/gssftp/ftpd/logwtmp.c +++ b/src/appl/gssftp/ftpd/logwtmp.c @@ -59,7 +59,7 @@ static int fd = -1; * after first call, for use with ftp (which may chroot * after login, but before logout). */ -logwtmp(line, name, host) +void ftp_logwtmp(line, name, host) char *line, *name, *host; { struct utmp ut; diff --git a/src/appl/gssftp/ftpd/popen.c b/src/appl/gssftp/ftpd/popen.c index 89f29a2..ffafe05 100644 --- a/src/appl/gssftp/ftpd/popen.c +++ b/src/appl/gssftp/ftpd/popen.c @@ -58,6 +58,8 @@ static char sccsid[] = "@(#)popen.c 5.9 (Berkeley) 2/25/91"; static int *pids; static int fds; +#define MAX_ARGV 100 +#define MAX_GARGV 1000 FILE * ftpd_popen(program, type) @@ -66,7 +68,7 @@ ftpd_popen(program, type) register char *cp; FILE *iop; int argc, gargc, pdes[2], pid; - char **pop, *argv[100], *gargv[1000], *vv[2]; + char **pop, *argv[MAX_ARGV], *gargv[MAX_GARGV], *vv[2]; extern char **ftpglob(), **copyblk(); if (*type != 'r' && *type != 'w' || type[1]) @@ -83,10 +85,12 @@ ftpd_popen(program, type) return(NULL); /* break up string into pieces */ - for (argc = 0, cp = program;; cp = NULL) + for (argc = 0, cp = program; argc < MAX_ARGV - 1; cp = NULL) if (!(argv[argc++] = strtok(cp, " \t\n"))) break; - for (argc = 0; argv[argc]; argc++) argv[argc] = strdup(argv[argc]); + argv[MAX_ARGV-1] = NULL; + for (argc = 0; argv[argc]; argc++) + argv[argc] = strdup(argv[argc]); /* glob each piece */ gargv[0] = argv[0]; @@ -97,7 +101,7 @@ ftpd_popen(program, type) pop = copyblk(vv); } argv[argc] = (char *)pop; /* save to free later */ - while (*pop && gargc < 1000) + while (*pop && gargc < MAX_GARGV) gargv[gargc++] = *pop++; } gargv[gargc] = NULL; diff --git a/src/appl/popper/Imakefile b/src/appl/popper/Imakefile deleted file mode 100644 index d46dc30..0000000 --- a/src/appl/popper/Imakefile +++ /dev/null @@ -1,93 +0,0 @@ -# $Source$ -# $Author$ -# $Id$ -# -# Copyright 1991 by the Massachusetts Institute of Technology. -# All Rights Reserved. -# -# Export of this software from the United States of America may -# require a specific license from the United States Government. -# It is the responsibility of any person or organization contemplating -# export to obtain such a license before exporting. -# -# WITHIN THAT CONSTRAINT, permission to use, copy, modify, and -# distribute this software and its documentation for any purpose and -# without fee is hereby granted, provided that the above copyright -# notice appear in all copies and that both that copyright notice and -# this permission notice appear in supporting documentation, and that -# the name of M.I.T. not be used in advertising or publicity pertaining -# to distribution of the software without specific, written prior -# permission. M.I.T. makes no representations about the suitability of -# this software for any purpose. It is provided "as is" without express -# or implied warranty. -# -# - -# Options are: -# BIND43 - If you are using BSD 4.3 domain -# name service. -# DEBUG - Include the debugging code. Note: You -# still have to use the -d or -t flag to -# enable debugging. -# HAVE_VSPRINTF - If the vsprintf functions are -# available -# on your system. -# SYSLOG42 - For BSD 4.2 syslog (default is BSD 4.3 -# syslog). -# STRNCASECMP - If you do not have strncasecmp() -# KERBEROS - If you want authentication vis Kerberos -# (tom) -# KERBEROS_PASSWD_HACK - Use popper as passwd server -# NOSTATUS - Don't create a Mail(1)-like -# Status: header - -#if defined(OS_BSD_RENO) || defined(OS_Ultrix) || defined(OS_SunOS4) || defined(OS_BSD) -BINDDEF=-DBIND43 -#else -/* assume it's not there; not really critical since we are using Kerberos to - beef up the normal IP-address checking stuff */ -BINDDEF= -#endif - -#if 0 - -/* Zephyr stuff not needed yet, since spop isn't done yet. */ -DEFINES = -DHAVE_VSPRINTF -DKERBEROS -DKRB5 -DNOSTATUS -DDEBUG $(BINDDEF) $(ZEPHDEFS) -LOCAL_LIBRARIES = $(ZEPHLIBS) $(KLIB) -DEP_LIBS= $(ZEPHDEPLIB) $(DEPKLIB) - -#else - -DEFINES = -DHAVE_VSPRINTF -DKERBEROS -DKRB5 -DNOSTATUS -DDEBUG $(BINDDEF) -LOCAL_LIBRARIES = $(KLIB) -DEP_LIBS= $(DEPKLIB) - -#endif -OBJS = pop_dele.o pop_dropcopy.o pop_dropinfo.o \ - pop_get_command.o pop_get_subcommand.o pop_init.o \ - pop_last.o pop_list.o pop_log.o pop_lower.o \ - pop_msg.o pop_parse.o pop_pass.o pop_quit.o \ - pop_rset.o pop_send.o pop_stat.o pop_updt.o \ - pop_user.o pop_xtnd.o pop_xmit.o popper.o -SRCS = pop_dele.c pop_dropcopy.c pop_dropinfo.c \ - pop_get_command.c pop_get_subcommand.c pop_init.c \ - pop_last.c pop_list.c pop_log.c pop_lower.c \ - pop_msg.c pop_parse.c pop_pass.c pop_quit.c \ - pop_rset.c pop_send.c pop_stat.c pop_updt.c \ - pop_user.c pop_xtnd.c pop_xmit.c popper.c $(SPOP_SRCS) -#if 0 -SPOP_OBJS = pop_enter.o -SPOP_SRCS = pop_enter.c -#endif - -all:: popper - -NormalProgramTarget(popper,$(OBJS),$(DEP_LIBS),$(LOCAL_LIBRARIES),) -Krb5InstallServerProgram(popper) - -#if 0 -NormalProgramTarget(spop,$(SPOP_OBJS),$(DEP_LIBS),$(LOCAL_LIBRARIES),) -Krb5InstallServerProgram(spop) -#endif - -DependTarget() diff --git a/src/appl/sample/sserver/ChangeLog b/src/appl/sample/sserver/ChangeLog index ba1d297..be41b71 100644 --- a/src/appl/sample/sserver/ChangeLog +++ b/src/appl/sample/sserver/ChangeLog @@ -1,3 +1,10 @@ +Thu Dec 5 19:44:05 1996 Tom Yu + + * sserver.M: remove ref's to "/krb5" [PR 279] + + * sserver.M: v5srvtab -> krb5.keytab; also kdb5_edit -> kadmin [PR + 279] + Thu Nov 7 15:24:43 1996 Theodore Ts'o * sserver.c (main): Check the error return from diff --git a/src/appl/sample/sserver/sserver.M b/src/appl/sample/sserver/sserver.M index f0ea721..e879067 100644 --- a/src/appl/sample/sserver/sserver.M +++ b/src/appl/sample/sserver/sserver.M @@ -44,9 +44,8 @@ The service name used by \fIsserver\fP and \fIsclient\fP is \fBsample\fP. Hence, \fIsserver\fP will require that there be a keytab entry for the service "sample/hostname.domain.name@REALM.NAME". This keytab is generated using the -.IR krb5_edit(8) -program. The keytab file is installed in whatever -directory is defined by V5Srvtabdir (usually /etc) as "v5srvtab". +.IR kadmin(8) +program. The keytab file is usually installed as "/etc/krb5.keytab". .PP The .B \-S @@ -57,7 +56,7 @@ option allows for a different keytab than the default. using a line in /etc/inetd.conf that looks like this: .PP -sample stream tcp nowait root /krb5/sbin/sserver sserver +sample stream tcp nowait root /usr/local/sbin/sserver sserver .PP Since \fBsample\fP is normally not a port defined in /etc/services, you will usually have to add a line to /etc/services which looks like this: @@ -66,7 +65,7 @@ sample 13135/tcp .PP When using \fIsclient,\fP you will first have to have an entry in the Kerberos database, by using -.IR kdb5_edit(8), +.IR kadmin(8), and then you have to get Kerberos tickets, by using .IR kinit(8). @@ -109,10 +108,10 @@ didn't restart \fIinetd\fP after editing inetd.conf. .PP 4) \fIsclient\fP returns the error: .PP -/krb5/bin/sclient: Server not found in Kerberos database while using sendauth +sclient: Server not found in Kerberos database while using sendauth .PP This means that the "sample/hostname@LOCAL.REALM" service was not -defined in the Kerberos database; it should be created using \fIkdb5_edit,\fP +defined in the Kerberos database; it should be created using \fIkadmin,\fP and a keytab file needs to be generated to make the key for that service principal available for \fIssclient\fP. .PP diff --git a/src/appl/simple/client/ChangeLog b/src/appl/simple/client/ChangeLog index 275d42b..db1136c 100644 --- a/src/appl/simple/client/ChangeLog +++ b/src/appl/simple/client/ChangeLog @@ -1,3 +1,8 @@ +Fri Nov 22 15:48:30 1996 unknown + + * sim_client.c (main): use sizeof instead of h_length to determine + number of bytes of addr to copy from DNS response [krb5-misc/211] + Thu Nov 7 15:26:10 1996 Theodore Ts'o * sim_client.c (main): Check the error return from diff --git a/src/appl/simple/client/sim_client.c b/src/appl/simple/client/sim_client.c index 9def260..a573dfa 100644 --- a/src/appl/simple/client/sim_client.c +++ b/src/appl/simple/client/sim_client.c @@ -163,7 +163,7 @@ main(argc, argv) /* Set server's address */ (void) memset((char *)&s_sock, 0, sizeof(s_sock)); - memcpy((char *)&s_sock.sin_addr, host->h_addr, host->h_length); + memcpy((char *)&s_sock.sin_addr, host->h_addr, sizeof(s_sock.sin_addr)); #ifdef DEBUG printf("s_sock.sin_addr is %s\n", inet_ntoa(s_sock.sin_addr)); #endif @@ -198,7 +198,7 @@ main(argc, argv) fprintf(stderr, "%s: unknown host\n", hostname); exit(1); } - memcpy((char *)&c_sock.sin_addr, host->h_addr, host->h_length); + memcpy((char *)&c_sock.sin_addr, host->h_addr, sizeof(c_sock.sin_addr)); #endif diff --git a/src/appl/simple/server/ChangeLog b/src/appl/simple/server/ChangeLog index 58042da..6e30ce4 100644 --- a/src/appl/simple/server/ChangeLog +++ b/src/appl/simple/server/ChangeLog @@ -1,3 +1,8 @@ +Fri Nov 22 15:48:42 1996 unknown + + * sim_server.c (argv): use sizeof instead of h_length to determine + number of bytes of addr to copy from DNS response [krb5-misc/211] + Thu Nov 7 15:26:44 1996 Theodore Ts'o * sim_server.c (argv): Check the error return from diff --git a/src/appl/simple/server/sim_server.c b/src/appl/simple/server/sim_server.c index 551a4f3..255d786 100644 --- a/src/appl/simple/server/sim_server.c +++ b/src/appl/simple/server/sim_server.c @@ -151,7 +151,7 @@ char *argv[]; fprintf(stderr, "%s: host unknown\n", full_hname); exit(1); } - memcpy((char *)&s_sock.sin_addr, host->h_addr, host->h_length); + memcpy((char *)&s_sock.sin_addr, host->h_addr, sizeof(s_sock.sin_addr)); /* Open socket */ if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { diff --git a/src/appl/telnet/libtelnet/ChangeLog b/src/appl/telnet/libtelnet/ChangeLog index 38d2314..bf03b35 100644 --- a/src/appl/telnet/libtelnet/ChangeLog +++ b/src/appl/telnet/libtelnet/ChangeLog @@ -1,3 +1,16 @@ +Wed Feb 3 22:59:27 1999 Theodore Y. Ts'o + + * kerberos5.c: Increase size of str_data so that we can accept + mongo-gram tickets from Microsoft. [telnet/686] + +Thu Nov 20 17:13:42 1997 Tom Yu + + * forward.c (rd_and_store_for_creds): Fix up to no longer do the + chown [krb5-appl/502] + + * kerberos5.c (kerberos5_is): Fix up call to + rd_and_store_for_creds. [krb5-appl/502] + Thu Nov 7 15:29:09 1996 Theodore Ts'o * kerberos5.c (kerberos5_init): Check the error return from diff --git a/src/appl/telnet/libtelnet/forward.c b/src/appl/telnet/libtelnet/forward.c index a0ea5b3..2d13067 100644 --- a/src/appl/telnet/libtelnet/forward.c +++ b/src/appl/telnet/libtelnet/forward.c @@ -25,7 +25,6 @@ #if defined(KERBEROS) || defined(KRB5) #include -#include #include #include "k5-int.h" @@ -34,23 +33,18 @@ extern char *line; /* see sys_term.c */ /* Decode, decrypt and store the forwarded creds in the local ccache. */ krb5_error_code -rd_and_store_for_creds(context, auth_context, inbuf, ticket, lusername) +rd_and_store_for_creds(context, auth_context, inbuf, ticket) krb5_context context; krb5_auth_context auth_context; krb5_data *inbuf; krb5_ticket *ticket; - char *lusername; { krb5_creds **creds; krb5_error_code retval; char ccname[35]; krb5_ccache ccache = NULL; - struct passwd *pwd; char *tty; - if (!(pwd = (struct passwd *) getpwnam(lusername))) - return -1; - if (retval = krb5_rd_cred(context, auth_context, inbuf, &creds, NULL)) return(retval); @@ -66,9 +60,6 @@ rd_and_store_for_creds(context, auth_context, inbuf, ticket, lusername) if (retval = krb5_cc_store_cred(context, ccache, *creds)) goto cleanup; - if (retval = chown(ccname+5, pwd->pw_uid, -1)) - goto cleanup; - cleanup: krb5_free_creds(context, *creds); return retval; diff --git a/src/appl/telnet/libtelnet/kerberos5.c b/src/appl/telnet/libtelnet/kerberos5.c index 53d3816..4993894 100644 --- a/src/appl/telnet/libtelnet/kerberos5.c +++ b/src/appl/telnet/libtelnet/kerberos5.c @@ -92,7 +92,7 @@ void kerberos5_forward(); #endif /* FORWARD */ -static unsigned char str_data[1024] = { IAC, SB, TELOPT_AUTHENTICATION, 0, +static unsigned char str_data[2048] = { IAC, SB, TELOPT_AUTHENTICATION, 0, AUTHTYPE_KERBEROS_V5, }; /*static unsigned char str_name[1024] = { IAC, SB, TELOPT_AUTHENTICATION, TELQUAL_NAME, };*/ @@ -529,7 +529,7 @@ kerberos5_is(ap, data, cnt) if ((r = krb5_auth_con_genaddrs(telnet_context, auth_context, net, KRB5_AUTH_CONTEXT_GENERATE_REMOTE_FULL_ADDR)) || (r = rd_and_store_for_creds(telnet_context, auth_context, - &inbuf, ticket, UserNameRequested))) { + &inbuf, ticket))) { char errbuf[128]; diff --git a/src/appl/telnet/telnet/ChangeLog b/src/appl/telnet/telnet/ChangeLog index 8080dba..eb127ed 100644 --- a/src/appl/telnet/telnet/ChangeLog +++ b/src/appl/telnet/telnet/ChangeLog @@ -1,3 +1,35 @@ +Fri Apr 30 15:23:39 1999 Tom Yu + + * configure.in: Fix to define HAVE_SETUPTERM instead of + HAS_SETUPTERM (due to merge botch). + +1999-04-13 + + * configure.in: Check for setupterm() in libncurses in addition to + libcurses. (Will be needed for Linux/Redhat 6.0) + +Tue Nov 26 20:41:31 1996 Tom Yu + + * configure.in: Check for apra/inet.h + + * commands.c: Remove explicit declaration of inet_addr, and + declare INADDR_NONE to be 0xffffffff again, but mask off the lower + 32 bits while doing the compare. + +Sat Nov 23 00:33:58 1996 Sam Hartman + + * commands.c (tn): Patch from mycroft@mit.edu for Alpha NetBSD. + Comparing to -1 is not 64-bit clean. + [233] + (INADDR_NONE): Mycroft suggests using -1 not 0xffffffff if I have + to define it ourselves. [233] + + Fri Nov 22 15:48:57 1996 unknown + + * commands.c (sourceroute): use sizeof instead of h_length to + determine number of bytes of addr to copy from DNS response + [krb5-misc/211] + Thu Nov 14 14:25:51 1996 Theodore Ts'o * sys_bsd.c(intr): Added checks to intr_waiting and intr_happened diff --git a/src/appl/telnet/telnet/commands.c b/src/appl/telnet/telnet/commands.c index cfd975e..0b42efe 100644 --- a/src/appl/telnet/telnet/commands.c +++ b/src/appl/telnet/telnet/commands.c @@ -44,6 +44,9 @@ #endif /* defined(unix) */ #include #include +#ifdef HAVE_ARPA_INET_H +#include +#endif /* HAVE_ARPA_INET_H */ #ifdef CRAY #include #endif /* CRAY */ @@ -89,6 +92,9 @@ #ifndef MAXDNAME #define MAXDNAME 256 /*per the rfc*/ #endif +#ifndef INADDR_NONE +#define INADDR_NONE 0xffffffff +#endif #if defined(IPPROTO_IP) && defined(IP_TOS) int tos = -1; @@ -2352,8 +2358,6 @@ ayt_status() } #endif -unsigned long inet_addr(); - int tn(argc, argv) int argc; @@ -2443,10 +2447,10 @@ tn(argc, argv) } else { #endif temp = inet_addr(hostp); - if (temp != (unsigned long) -1) { + if (temp & 0xffffffff != INADDR_NONE) { sin.sin_addr.s_addr = temp; sin.sin_family = AF_INET; - (void) strcpy(_hostname, hostp); + (void) strcpy(_hostname, hostp); hostname = _hostname; } else { host = gethostbyname(hostp); @@ -2454,9 +2458,10 @@ tn(argc, argv) sin.sin_family = host->h_addrtype; #if defined(h_addr) /* In 4.3, this is a #define */ memcpy((caddr_t)&sin.sin_addr, - host->h_addr_list[0], host->h_length); + host->h_addr_list[0], sizeof(sin.sin_addr)); #else /* defined(h_addr) */ - memcpy((caddr_t)&sin.sin_addr, host->h_addr, host->h_length); + memcpy((caddr_t)&sin.sin_addr, host->h_addr, + sizeof(sin.sin_addr)); #endif /* defined(h_addr) */ strncpy(_hostname, host->h_name, sizeof(_hostname)); _hostname[sizeof(_hostname)-1] = '\0'; @@ -2546,9 +2551,9 @@ tn(argc, argv) perror((char *)0); host->h_addr_list++; memcpy((caddr_t)&sin.sin_addr, - host->h_addr_list[0], host->h_length); + host->h_addr_list[0], sizeof(sin.sin_addr)); memcpy((caddr_t)&hostaddr, - host->h_addr_list[0], host->h_length); + host->h_addr_list[0], sizeof(sin.sin_addr)); (void) NetClose(net); continue; } @@ -3055,9 +3060,10 @@ sourceroute(arg, cpp, lenp) } else if (host = gethostbyname(cp)) { #if defined(h_addr) memcpy((caddr_t)&sin_addr, - host->h_addr_list[0], host->h_length); + host->h_addr_list[0], sizeof(sin_addr)); #else - memcpy((caddr_t)&sin_addr, host->h_addr, host->h_length); + memcpy((caddr_t)&sin_addr, host->h_addr, + sizeof(sin_addr)); #endif } else { *cpp = cp; diff --git a/src/appl/telnet/telnet/configure.in b/src/appl/telnet/telnet/configure.in index 619153f..2a3146d 100644 --- a/src/appl/telnet/telnet/configure.in +++ b/src/appl/telnet/telnet/configure.in @@ -3,13 +3,13 @@ CONFIG_RULES AC_PROG_INSTALL AC_VFORK AC_CHECK_HEADERS(string.h arpa/nameser.h) -AC_HAVE_HEADERS(unistd.h sys/select.h stdlib.h) +AC_HAVE_HEADERS(unistd.h sys/select.h stdlib.h arpa/inet.h) AC_CHECK_LIB(termcap,main,AC_DEFINE(TERMCAP) LIBS="$LIBS -ltermcap", - AC_CHECK_LIB(curses,setupterm,LIBS="$LIBS -lcurses") -) -AC_CHECK_FUNCS(setupterm) dnl If we have it, use it so we don't get -dnl endless loop with tcgetent + AC_CHECK_LIB(curses,setupterm,LIBS="$LIBS -lcurses", + AC_CHECK_LIB(ncurses,setupterm,LIBS="$LIBS -lncurses") +)) +AC_CHECK_FUNCS(gettosbyname setupterm) AC_HEADER_CHECK(termios.h,AC_DEFINE(USE_TERMIO) ac_termio=1) if test -z "$ac_termio"; then AC_HEADER_CHECK(termio.h,AC_DEFINE(SYSV_TERMIO),ac_sysv_termio=1) @@ -28,7 +28,6 @@ AC_FUNC_CHECK(gettosbyname,AC_DEFINE(HAS_GETTOS)) AC_HEADER_CHECK(sys/filio.h,AC_DEFINE(FILIO_H)) AC_HEADER_CHECK(sys/stream.h,AC_DEFINE(STREAMS)) AC_FUNC_CHECK(cgetent,AC_DEFINE(HAS_CGETENT)) -AC_FUNC_CHECK(setupterm,AC_DEFINE(HAS_SETUPTERM)) CHECK_SIGNALS if test "$KRB4_LIB" = ''; then AC_MSG_RESULT(No Kerberos 4 authentication) diff --git a/src/appl/telnet/telnetd/ChangeLog b/src/appl/telnet/telnetd/ChangeLog index f537d11..9f0f54b 100644 --- a/src/appl/telnet/telnetd/ChangeLog +++ b/src/appl/telnet/telnetd/ChangeLog @@ -1,3 +1,70 @@ +Thu Apr 15 17:02:49 1999 Theodore Y. Ts'o + + * configure.in: Fix typo in test below; fixed name of the autoconf + cache variable which indicates if sys/streams.h exists. + +1999-04-13 + + * configure.in: Check for setupterm() in libncurses in addition to + libcurses. Only set STREAMSPTY if both grantpt and + sys/streams.h exists. (Will be needed for Linux/Redhat 6.0) + +Wed Mar 31 00:05:58 1999 Tom Yu + + * sys_term.c (getptyslave): Under AIX, ignore I_PUSH pckt + failure. + +Tue Mar 30 23:59:15 1999 Tom Yu + + * termios-tn.c: Include termio.h under AIX due to brokenness. + +Wed Feb 24 20:12:10 1999 Tom Yu + + * telnetd.8: Resync manpage. + + * telnetd.c: Rework flags controlling hostname logging. + +Mon Feb 22 18:27:38 1999 Tom Yu + + * telnetd.8: Document hostname logging changes. + + * telnetd.c: Add options to control logging of remote hostname to + login(1). + +Wed Feb 3 22:57:52 1999 Theodore Y. Ts'o + + * state.c: Increase size of subbufer so that we don't truncate + mongo-gram tickets from Microsoft. [telnet/688] + +Wed Jan 28 17:21:08 1998 Dan Winship + + * telnetd.c (doit): additional fix for previous terminaltype change + +Tue Jan 27 18:27:16 1998 Dan Winship + + * telnetd.c (getterminaltype): Null-terminate strings and avoid a + buffer overrun. + + * ext.h: make terminaltype a char[] instead of a char * for + telnetd.c change + + * state.c (suboption): redo handling of terminaltype + +Thu Dec 4 21:32:37 1997 Tom Yu + + * telnetd.c (doit): Fix up slave buffer length. + +Thu Oct 23 13:59:32 1997 Theodore Y. Ts'o + + * state.c (envvarok): Prohibit the passing of TERMCAP, TERMPATH, + TERMINFO, and HOME, since they can be used to exploit a + security in tgetent. + +Wed Apr 9 23:46:40 1997 Tom Yu + + * sys_term.c (start_login): Bounds check the constructed "speed" + passed in to login. + Thu Nov 7 15:32:06 1996 Theodore Ts'o * telnetd.c (main): Check the error return from diff --git a/src/appl/telnet/telnetd/configure.in b/src/appl/telnet/telnetd/configure.in index 5522101..5a90138 100644 --- a/src/appl/telnet/telnetd/configure.in +++ b/src/appl/telnet/telnetd/configure.in @@ -5,8 +5,9 @@ AC_CHECK_LIB(util,main) USE_ANAME AC_CHECK_LIB(termcap,main,AC_DEFINE(TERMCAP) LIBS="$LIBS -ltermcap", - AC_CHECK_LIB(curses,setupterm,LIBS="$LIBS -lcurses") -) + AC_CHECK_LIB(curses,setupterm,LIBS="$LIBS -lcurses", + AC_CHECK_LIB(ncurses,setupterm,LIBS="$LIBS -lncurses") +)) AC_HEADER_CHECK(termios.h,AC_DEFINE(USE_TERMIO) ac_termio=1) if test -z "$ac_termio"; then AC_HEADER_CHECK(termio.h,AC_DEFINE(SYSV_TERMIO),ac_sysv_termio=1) @@ -32,6 +33,13 @@ case $krb5_cv_host in *-*-hpux*) broken_streams=yes ;; +*-*-linux*) + # Someday Linux may have a Streams user-level interface, so checking + # for sys/stream.h may not always work. But I'm reasonably + # sure Linux will never require pushing magic streams modules onto + # pty's! :-) --- TYT + broken_streams=yes + ;; *-*-irix*) # Irix doesn't have a working granpt, and more over # you can't push anything onto a pty, so telnetd really @@ -39,7 +47,7 @@ case $krb5_cv_host in broken_streams=yes ;; esac -if test -z "$broken_streams" ; then +if test -z "$broken_streams" -a "$ac_cv_header_sys_stream_h" = yes; then AC_FUNC_CHECK(grantpt,AC_DEFINE(STREAMSPTY)) fi AC_HEADER_CHECK(sac.h,AC_DEFINE(HAS_SAC)) diff --git a/src/appl/telnet/telnetd/ext.h b/src/appl/telnet/telnetd/ext.h index 37e2a19..1e4963c 100644 --- a/src/appl/telnet/telnetd/ext.h +++ b/src/appl/telnet/telnetd/ext.h @@ -66,7 +66,7 @@ extern int auth_level; extern int auth_negotiated; /* Have we finished all authentication negotiation we plan to finish?*/ extern slcfun slctab[NSLC + 1]; /* slc mapping table */ -extern char *terminaltype; +extern char terminaltype[41]; /* * I/O data buffers, pointers, and counters. diff --git a/src/appl/telnet/telnetd/state.c b/src/appl/telnet/telnetd/state.c index 16e71d4..5bca871 100644 --- a/src/appl/telnet/telnetd/state.c +++ b/src/appl/telnet/telnetd/state.c @@ -50,7 +50,7 @@ static int envvarok P((char *)); * Buffer for sub-options, and macros * for suboptions buffer manipulations */ -unsigned char subbuffer[2048], *subpointer= subbuffer, *subend= subbuffer; +unsigned char subbuffer[4096], *subpointer= subbuffer, *subend= subbuffer; #define SB_CLEAR() subpointer = subbuffer #define SB_TERM() { subend = subpointer; SB_CLEAR(); } @@ -1140,7 +1140,7 @@ suboption() } /* end of case TELOPT_TSPEED */ case TELOPT_TTYPE: { /* Yaaaay! */ - static char terminalname[41]; + char *tt; if (his_state_is_wont(TELOPT_TTYPE)) /* Ignore if option disabled */ break; @@ -1151,20 +1151,18 @@ suboption() return; /* ??? XXX but, this is the most robust */ } - terminaltype = terminalname; + tt = terminaltype; - while ((terminaltype < (terminalname + sizeof terminalname-1)) && - !SB_EOF()) { + while ((tt < (terminaltype + sizeof(terminaltype) - 1)) && !SB_EOF()) { register int c; c = SB_GET(); if (isupper(c)) { c = tolower(c); } - *terminaltype++ = c; /* accumulate name */ + *tt++ = c; /* accumulate name */ } - *terminaltype = 0; - terminaltype = terminalname; + *tt = 0; break; } /* end of case TELOPT_TTYPE */ @@ -1645,6 +1643,10 @@ static int envvarok(varp) char *varp; { if (!strchr(varp, '=') && + strcmp(varp, "TERMCAP") && /* to prevent a security hole */ + strcmp(varp, "TERMINFO") && /* with tgetent */ + strcmp(varp, "TERMPATH") && + strcmp(varp, "HOME") && /* to prevent the tegetent bug */ strncmp(varp, "LD_", strlen("LD_")) && /* most systems */ strncmp(varp, "_RLD_", strlen("_RLD_")) && /* irix */ strncmp(varp, "KRB5", strlen("KRB5")) && /* v5 */ diff --git a/src/appl/telnet/telnetd/sys_term.c b/src/appl/telnet/telnetd/sys_term.c index a7c7ee5..ff5fd1d 100644 --- a/src/appl/telnet/telnetd/sys_term.c +++ b/src/appl/telnet/telnetd/sys_term.c @@ -927,9 +927,12 @@ getptyslave() #ifdef USE_TERMIO ttyfd = t; #endif - if (ioctl(pty, I_PUSH, "pckt") < 0) + if (ioctl(pty, I_PUSH, "pckt") < 0) { +#ifndef _AIX fatal(net, "I_PUSH pckt"); #endif + } +#endif /* * set up the tty modes as we like them to be. @@ -1289,7 +1292,7 @@ start_login(host, autologin, name) if (pty > 2) { register char *cp; - char speed[128]; + char speed[1024]; int isecho, israw, xpty, len; extern int def_rspeed; # ifndef LOGIN_HOST @@ -1326,7 +1329,13 @@ start_login(host, autologin, name) len = strlen(name)+1; write(xpty, name, len); write(xpty, name, len); - sprintf(speed, "%s/%d", (cp = getenv("TERM")) ? cp : "", + memset(speed, 0, sizeof(speed)); + strncpy(speed, + (cp = getenv("TERM")) ? cp : "", + sizeof(speed)-1-(10*sizeof(def_rspeed)/4)-1); + /* 1 for /, () for the number, 1 for trailing 0. */ + sprintf(speed + strlen(speed), + "/%d", (def_rspeed > 0) ? def_rspeed : 9600); len = strlen(speed)+1; write(xpty, speed, len); diff --git a/src/appl/telnet/telnetd/telnetd.8 b/src/appl/telnet/telnetd/telnetd.8 index f7daded..7c92106 100644 --- a/src/appl/telnet/telnetd/telnetd.8 +++ b/src/appl/telnet/telnetd/telnetd.8 @@ -42,8 +42,9 @@ protocol server [\fB\-edebug\fP] [\fB\-h\fP] [\fB\-I\fP\fIinitid\fP] [\fB\-l\fP] [\fB\-k\fP] [\fB\-n\fP] [\fB\-r\fP\fIlowpty-highpty\fP] [\fB\-s\fP] [\fB\-S\fP \fItos\fP] [\fB\-U\fP] [\fB\-X\fP \fIauthtype\fP] +[\fB\-w\fP [\fBip\fP|\fImaxhostlen\fP[\fB,\fP[\fBno\fP]\fBstriplocal\fP]]] [\fB\-debug\fP [\fIport\fP]] -.Sh DESCRIPTION +.SH DESCRIPTION The .B telnetd command is a server which supports the @@ -286,6 +287,18 @@ symbolic name via the .IR gethostbyaddr (3) routine. .TP +.B \-w \fP[\fBip\fP|\fImaxhostlen\fP[\fB,\fP[\fBno\fP]\fBstriplocal\fP]] +Controls the form of the remote hostname passed to login(1). +Specifying \fBip\fP results in the numeric IP address always being +passed to login(1). Specifying a number, \fImaxhostlen\fP, sets the +maximum length of the hostname passed to login(1) before it will be +passed as a numeric IP address. If \fImaxhostlen\fP is 0, then the +system default, as determined by the utmp or utmpx structures, is +used. The \fBnostriplocal\fP and \fBstriplocal\fP options, which must +be preceded by a comma, control whether or not the local host domain +is stripped from the remote hostname. By default, the equivalent of +\fBstriplocal\fP is in effect. +.TP \fB\-X\fP \fIauthtype\fP This option is only valid if .B telnetd diff --git a/src/appl/telnet/telnetd/telnetd.c b/src/appl/telnet/telnetd/telnetd.c index 0c61712..df3c4c9 100644 --- a/src/appl/telnet/telnetd/telnetd.c +++ b/src/appl/telnet/telnetd/telnetd.c @@ -140,6 +140,10 @@ int debug = 0; int keepalive = 1; char *progname; +int maxhostlen = 0; +int always_ip = 0; +int stripdomain = 1; + extern void usage P((void)); /* @@ -149,6 +153,7 @@ extern void usage P((void)); */ char valid_opts[] = { 'd', ':', 'h', 'k', 'L', ':', 'n', 'S', ':', 'U', + 'w', #ifdef AUTHENTICATION 'a', ':', 'X', ':', #endif @@ -416,6 +421,36 @@ main(argc, argv) auth_disable_name(optarg); break; #endif /* AUTHENTICATION */ + case 'w': + if (!strcmp(optarg, "ip")) + always_ip = 1; + else { + char *cp; + cp = strchr(optarg, ','); + if (cp == NULL) + maxhostlen = atoi(optarg); + else if (*(++cp)) { + if (!strcmp(cp, "striplocal")) + stripdomain = 1; + else if (!strcmp(cp, "nostriplocal")) + stripdomain = 0; + else { + usage(); + } + *(--cp) = '\0'; + maxhostlen = atoi(optarg); + } + } + break; + case 'u': + maxhostlen = atoi(optarg); + break; + case 'i': + always_ip = 1; + break; + case 'N': + stripdomain = 0; + break; default: fprintf(stderr, "telnetd: %c: unknown option\n", ch); @@ -625,7 +660,8 @@ usage() #ifdef AUTHENTICATION fprintf(stderr, " [-X auth-type]"); #endif - fprintf(stderr, " [-u utmp_hostname_length] [-U]"); + fprintf(stderr, " [-u utmp_hostname_length] [-U]\n"); + fprintf(stderr, " [-w [ip|maxhostlen[,[no]striplocal]]]\n"); fprintf(stderr, " [port]\n"); exit(1); } @@ -779,12 +815,14 @@ getterminaltype(name) * we have to just go with what we (might) have already gotten. */ if (his_state_is_will(TELOPT_TTYPE) && !terminaltypeok(terminaltype)) { - (void) strncpy(first, terminaltype, sizeof(first)); + (void) strncpy(first, terminaltype, sizeof(first) - 1); + first[sizeof(first) - 1] = '\0'; for(;;) { /* * Save the unknown name, and request the next name. */ - (void) strncpy(last, terminaltype, sizeof(last)); + (void) strncpy(last, terminaltype, sizeof(last) - 1); + last[sizeof(last) - 1] = '\0'; _gettermname(); if (terminaltypeok(terminaltype)) break; @@ -801,9 +839,12 @@ getterminaltype(name) * RFC1091 compliant telnets will cycle back to * the start of the list. */ - _gettermname(); - if (strncmp(first, terminaltype, sizeof(first)) != 0) - (void) strncpy(terminaltype, first, sizeof(first)); + _gettermname(); + if (strncmp(first, terminaltype, sizeof(first)) != 0) { + (void) strncpy(terminaltype, first, + sizeof(terminaltype) - 1); + terminaltype[sizeof(terminaltype) - 1] = '\0'; + } break; } } @@ -835,7 +876,7 @@ terminaltypeok(s) { char buf[1024]; - if (terminaltype == NULL) + if (!*s) return(1); /* @@ -860,6 +901,7 @@ terminaltypeok(s) char *hostname; char host_name[MAXDNAME]; char remote_host_name[MAXDNAME]; +char *rhost_sane; #ifndef convex extern void telnet P((int, int)); @@ -885,11 +927,9 @@ long retval; pty_init(); - if ((retval = pty_getpty(&pty, line, 20)) != 0 ) - { + if ((retval = pty_getpty(&pty, line, 17)) != 0) { fatal(net, error_message(retval)); - } - + } #if defined(_SC_CRAY_SECURE_SYS) /* @@ -907,6 +947,12 @@ pty_init(); } #endif /* _SC_CRAY_SECURE_SYS */ + retval = pty_make_sane_hostname(who, maxhostlen, + stripdomain, always_ip, + &rhost_sane); + if (retval) { + fatal(net, error_message(retval)); + } /* get name of connected client */ hp = gethostbyaddr((char *)&who->sin_addr, sizeof (struct in_addr), who->sin_family); @@ -914,24 +960,13 @@ pty_init(); if (hp == NULL && registerd_host_only) { fatal(net, "Couldn't resolve your address into a host name.\r\n\ Please contact your net administrator"); - } else if (hp ) { - host = hp->h_name; - } else { - host = inet_ntoa(who->sin_addr); } - /* - * We must make a copy because Kerberos is probably going - * to also do a gethost* and overwrite the static data... - */ - strncpy(remote_host_name, host, sizeof(remote_host_name)-1); - remote_host_name[sizeof(remote_host_name)-1] = 0; - host = remote_host_name; (void) gethostname(host_name, sizeof (host_name)); hostname = host_name; #if defined(AUTHENTICATION) || defined(ENCRYPTION) - auth_encrypt_init(hostname, host, "TELNETD", 1); + auth_encrypt_init(hostname, rhost_sane, "TELNETD", 1); #endif init_env(); @@ -949,13 +984,13 @@ pty_init(); */ *user_name = 0; level = getterminaltype(user_name); - setenv("TERM", terminaltype ? terminaltype : "network", 1); + setenv("TERM", *terminaltype ? terminaltype : "network", 1); /* * Start up the login process on the slave side of the terminal */ #ifndef convex - startslave(host, level, user_name); + startslave(rhost_sane, level, user_name); #if defined(_SC_CRAY_SECURE_SYS) if (secflag) { @@ -968,7 +1003,7 @@ pty_init(); telnet(net, pty); /* begin server processing */ #else - telnet(net, pty, host); + telnet(net, pty, rhost_sane); #endif /*NOTREACHED*/ } /* end of doit */ diff --git a/src/appl/telnet/telnetd/termios-tn.c b/src/appl/telnet/telnetd/termios-tn.c index 4712a33..7e2aa5c 100644 --- a/src/appl/telnet/telnetd/termios-tn.c +++ b/src/appl/telnet/telnetd/termios-tn.c @@ -5,6 +5,9 @@ #include #include #include +#if !defined(TCSETS) && defined(_AIX) /* kludge for AIX */ +#include +#endif int readstream_termios(cmd, ibuf, vstop, vstart, ixon) int cmd; diff --git a/src/appl/user_user/ChangeLog b/src/appl/user_user/ChangeLog index 62651d0..e005075 100644 --- a/src/appl/user_user/ChangeLog +++ b/src/appl/user_user/ChangeLog @@ -1,3 +1,8 @@ +Fri Nov 22 15:49:09 1996 unknown + + * client.c (argv): use sizeof instead of h_length to determine + number of bytes of addr to copy from DNS response [krb5-misc/211] + Thu Nov 7 15:36:15 1996 Theodore Ts'o * client.c (argv): diff --git a/src/appl/user_user/client.c b/src/appl/user_user/client.c index 4bee708..2cf85ae 100644 --- a/src/appl/user_user/client.c +++ b/src/appl/user_user/client.c @@ -128,7 +128,8 @@ char *argv[]; fprintf (stderr, "uu-client: unable to connect to \"%s\"\n", hname); return 5; } - memcpy ((char *)&serv_net_addr.sin_addr, host->h_addr_list[i++], host->h_length); + memcpy ((char *)&serv_net_addr.sin_addr, host->h_addr_list[i++], + sizeof(serv_net_addr.sin_addr)); if (connect(s, (struct sockaddr *)&serv_net_addr, sizeof (serv_net_addr)) == 0) break; com_err ("uu-client", errno, "connecting to \"%s\" (%s).", diff --git a/src/clients/kinit/ChangeLog b/src/clients/kinit/ChangeLog index c3bbbeb..f3d8f2d 100644 --- a/src/clients/kinit/ChangeLog +++ b/src/clients/kinit/ChangeLog @@ -1,3 +1,7 @@ +Thu Dec 5 21:59:08 1996 Tom Yu + + * kinit.M: v5srvtab -> krb5.keytab [279] + Wed Nov 6 09:31:35 1996 Theodore Y. Ts'o * kinit.c (main): Check the return code from krb5_init_context, diff --git a/src/clients/kinit/kinit.M b/src/clients/kinit/kinit.M index 86465b9..6681967 100644 --- a/src/clients/kinit/kinit.M +++ b/src/clients/kinit/kinit.M @@ -130,7 +130,7 @@ Location of the credentials (ticket) cache. /tmp/krb5cc_[uid] default credentials cache ([uid] is the decimal UID of the user). .TP -/etc/v5srvtab +/etc/krb5.keytab default location for the local host's .B keytab file. diff --git a/src/clients/klist/ChangeLog b/src/clients/klist/ChangeLog index 8b0051b..f72ff09 100644 --- a/src/clients/klist/ChangeLog +++ b/src/clients/klist/ChangeLog @@ -1,3 +1,7 @@ +Thu Dec 5 21:59:34 1996 Tom Yu + + * klist.M: v5srvtab -> krb5.keytab [279] + Wed Nov 6 12:02:59 1996 Theodore Ts'o * klist.c (main): Check the error return from krb5_init_context(), diff --git a/src/clients/klist/klist.M b/src/clients/klist/klist.M index acf80ab..99b42b9 100644 --- a/src/clients/klist/klist.M +++ b/src/clients/klist/klist.M @@ -107,7 +107,7 @@ Location of the credentials (ticket) cache. default location of the credentials cache ([uid] is the decimal UID of the user). .TP -/etc/v5srvtab +/etc/krb5.keytab default location of the .B keytab file. diff --git a/src/clients/ksu/ChangeLog b/src/clients/ksu/ChangeLog index 0de61a4..3271fc9 100644 --- a/src/clients/ksu/ChangeLog +++ b/src/clients/ksu/ChangeLog @@ -1,3 +1,74 @@ +2000-02-03 Ken Raeburn + + * krb_auth_su.c (krb5_get_tkt_via_passwd): Check length of + principal name before copying to fixed-size buffer. + + * ccache.c (krb5_ccache_filter): Fix speling error. + (krb5_get_login_princ): Check length of home directory pathname. + + * setenv.c: New file, copied from appl/bsd. + * Makefile.in (OBJS): Add @SETENVOBJ@. + (SRCS): Add setenv.c. + + * xmalloc.c: New file, providing versions of malloc, calloc, + realloc, and strdup that print messages and exit if memory + allocation fails. + * ksu.h (xmalloc, xrealloc, xcalloc, xstrdup): Declare. + * Makefile.in (SRCS, OBJS): Use it. + * authorization.c, ccache.c, heuristic.c, main.c: Change all calls + to malloc, calloc, realloc, and strdup to call x* versions if the + return value is not checked before use. + + * authorization.c (auth_cleanup): Ditch int arguments, check for + null pointers instead. + (krb5_authorization): Update calls. Initialize file pointers to + null. + (init_auth_names): Check for buffer overflow. + (fcmd_resolve): Ensure enough buffer space is allocated. + (find_first_cmd_that_exists): Likewise. Use strcat instead of + sprintf'ing a buffer into itself. + + * krb_auth_su.c (dump_principal, plain_dump_principal): Reformat + slightly. + + * main.c (main): Unset environment variable KRB5_CONFIG. Delete + -C option. Force an error if lifetime strings are over 14 + characters. Fix error message string if setluid fails. Cast pid + to long for printing. Call krb5_init_secure_context instead of + krb5_init_context and krb5_secure_config_files. + (main): Fix speling error. + (ontty): Check string size. + (get_dir_of_file): Argument now points to const. + * ksu.h (get_dir_of_file): Update declaration. + +Fri Mar 12 18:52:18 1999 Tom Yu + + * main.c (main): Fix cleanup code for setluid() failure. + +Thu Mar 4 18:46:55 1999 Tom Yu + + * heuristic.c (get_authorized_princ_names): Fix to not call + list_union() if cmd is NULL, otherwise freed memory gets + referenced. [krb5-clients/698] + +Mon Feb 22 19:17:15 1999 Tom Yu + + * configure.in: Actually AC_SUBST(KSU_LIBS). + +Thu Feb 18 22:33:58 1999 Tom Yu + + * Makefile.in (ksu): Add $(KSU_LIBS). + + * configure.in: Add check for setluid(). + + * main.c (main): Add call to setluid() on systems that have it. + +Wed Feb 4 20:46:49 1998 Tom Yu + + * krb_auth_su.c (krb5_verify_tkt_def): If using a pre-existing + credential cache, ensure that the host ticket has not yet + expired. Patch from vwelch@ncsa.uiuc.edu [krb5-clients/545]. + Sun Nov 10 20:10:53 1996 Sam Hartman * krb_auth_su.c (path_passwd;): If you don't have a srvtab, always diff --git a/src/clients/ksu/Makefile.in b/src/clients/ksu/Makefile.in index 5b161c6..b4d9931 100644 --- a/src/clients/ksu/Makefile.in +++ b/src/clients/ksu/Makefile.in @@ -1,23 +1,29 @@ DEFINES = -DGET_TGT_VIA_PASSWD -DPRINC_LOOK_AHEAD -DCMD_PATH='"/bin /local/bin"' CFLAGS = $(CCOPTS) $(DEFINES) $(DEFS) $(LOCALINCLUDE) +KSU_LIBS=@KSU_LIBS@ + SRCS = \ $(srcdir)/krb_auth_su.c \ $(srcdir)/ccache.c \ $(srcdir)/authorization.c \ $(srcdir)/main.c \ - $(srcdir)/heuristic.c + $(srcdir)/heuristic.c \ + $(srcdir)/setenv.c \ + $(srcdir)/xmalloc.c OBJS = \ krb_auth_su.o \ ccache.o \ authorization.o \ main.o \ - heuristic.o + heuristic.o \ + @SETENVOBJ@ \ + xmalloc.o all:: ksu ksu: $(OBJS) $(DEPLIBS) - $(LD) $(LDFLAGS) $(LDARGS) -o ksu $(OBJS) $(LIBS) + $(LD) $(LDFLAGS) $(LDARGS) -o ksu $(OBJS) $(LIBS) $(KSU_LIBS) clean:: $(RM) ksu diff --git a/src/clients/ksu/authorization.c b/src/clients/ksu/authorization.c index 39e7459..dd828e6 100644 --- a/src/clients/ksu/authorization.c +++ b/src/clients/ksu/authorization.c @@ -27,7 +27,7 @@ #include "ksu.h" -static void auth_cleanup PROTOTYPE((int, FILE *, int, FILE *, char *)); +static void auth_cleanup PROTOTYPE((FILE *, FILE *, char *)); krb5_boolean fowner(fp, uid) FILE *fp; @@ -76,9 +76,8 @@ krb5_error_code krb5_authorization(context, principal, luser, int k5login_flag =0; int k5users_flag =0; krb5_boolean retbool =FALSE; - FILE * login_fp, * users_fp; + FILE * login_fp = 0, * users_fp = 0; krb5_error_code retval = 0; - struct stat statbuf; struct stat st_temp; *ok =FALSE; @@ -128,8 +127,7 @@ krb5_error_code krb5_authorization(context, principal, luser, }else{ if(retval = k5users_lookup(users_fp,princname, cmd,&retbool,out_fcmd)){ - auth_cleanup(k5users_flag,users_fp, - k5login_flag,login_fp, princname); + auth_cleanup(users_fp, login_fp, princname); return retval; }else{ *ok =retbool; @@ -149,28 +147,26 @@ krb5_error_code krb5_authorization(context, principal, luser, "In krb5_authorization: principal to be authorized %s\n", princname); if (retval = k5login_lookup( login_fp, princname, &retbool)){ - auth_cleanup(k5users_flag,users_fp, - k5login_flag,login_fp, princname); + auth_cleanup(users_fp, login_fp, princname); return retval; } if (retbool) { if (cmd) - *out_fcmd = strdup(cmd); + *out_fcmd = xstrdup(cmd); } } if ((!k5users_flag) && (retbool == FALSE) ){ if(retval = k5users_lookup (users_fp, princname, cmd, &retbool, out_fcmd)){ - auth_cleanup(k5users_flag,users_fp, - k5login_flag,login_fp, princname); + auth_cleanup(users_fp, login_fp, princname); return retval; } } if (k5login_flag && k5users_flag){ - char * kuser = (char *) calloc (strlen(princname), sizeof(char)); + char * kuser = (char *) xcalloc (strlen(princname), sizeof(char)); if (!(krb5_aname_to_localname(context, principal, strlen(princname), kuser)) && (strcmp(kuser, luser) == 0)) { @@ -181,7 +177,7 @@ krb5_error_code krb5_authorization(context, principal, luser, } *ok =retbool; - auth_cleanup(k5users_flag,users_fp, k5login_flag,login_fp, princname); + auth_cleanup(users_fp, login_fp, princname); return 0; } @@ -278,7 +274,7 @@ krb5_error_code k5users_lookup (fp, princname, cmd, found, out_fcmd) if ((fcmd) && (!strcmp(fcmd, PERMIT_ALL_COMMANDS))){ if (get_next_token(&lp) == NULL){ - loc_fcmd =cmd ? strdup(cmd): NULL; + loc_fcmd =cmd ? xstrdup(cmd): NULL; loc_found = TRUE; } free (line); @@ -348,30 +344,30 @@ krb5_boolean fcmd_resolve(fcmd, out_fcmd, out_err) char * lp, * tc; int i=0; - tmp_fcmd = (char **) calloc (MAX_CMD, sizeof(char *)); + tmp_fcmd = (char **) xcalloc (MAX_CMD, sizeof(char *)); if (*fcmd == '/'){ /* must be full path */ - tmp_fcmd[0] = strdup(fcmd); + tmp_fcmd[0] = xstrdup(fcmd); tmp_fcmd[1] = NULL; *out_fcmd = tmp_fcmd; return TRUE; }else{ /* must be either full path or just the cmd name */ if (strchr(fcmd, '/')){ - err = (char *) calloc((strlen(fcmd) +200) ,sizeof(char)); + err = (char *) xcalloc((strlen(fcmd) +200) ,sizeof(char)); sprintf(err,"Error: bad entry - %s in %s file, must be either full path or just the cmd name\n", fcmd, KRB5_USERS_NAME); *out_err = err; return FALSE; } #ifndef CMD_PATH - err = (char *) calloc(2*(strlen(fcmd) +200) ,sizeof(char)); + err = (char *) xcalloc(2*(strlen(fcmd) +200) ,sizeof(char)); sprintf(err,"Error: bad entry - %s in %s file, since %s is just the cmd name, CMD_PATH must be defined \n", fcmd, KRB5_USERS_NAME, fcmd); *out_err = err; return FALSE; #else - path = strdup (CMD_PATH); + path = xstrdup (CMD_PATH); path_ptr = path; while ((*path_ptr == ' ') || (*path_ptr == '\t')) path_ptr ++; @@ -379,7 +375,7 @@ krb5_boolean fcmd_resolve(fcmd, out_fcmd, out_err) tc = get_first_token (path_ptr, &lp); if (! tc){ - err = (char *) calloc((strlen(fcmd) +200) ,sizeof(char)); + err = (char *) xcalloc((strlen(fcmd) +200) ,sizeof(char)); sprintf(err,"Error: bad entry - %s in %s file, CMD_PATH contains no paths \n", fcmd, KRB5_USERS_NAME); *out_err = err; return FALSE; @@ -388,13 +384,13 @@ krb5_boolean fcmd_resolve(fcmd, out_fcmd, out_err) i=0; do{ if (*tc != '/'){ /* must be full path */ - err = (char *) calloc((strlen(tc) +200) ,sizeof(char)); + err = (char *) xcalloc((strlen(tc) +200) ,sizeof(char)); sprintf(err,"Error: bad path %s in CMD_PATH for %s must start with '/' \n",tc, KRB5_USERS_NAME ); *out_err = err; return FALSE; } - out_path = (char *) calloc( MAXPATHLEN, sizeof (char)); + out_path = (char *) xcalloc( MAXPATHLEN, sizeof (char)); sprintf(out_path,"%s/%s",tc, fcmd ); tmp_fcmd[i] = out_path; @@ -502,7 +498,7 @@ krb5_boolean find_first_cmd_that_exists(fcmd_arr, cmd_out, err_out) tln = strlen(fcmd_arr[i]); if ( tln > max_ln) max_ln = tln; if (!stat (fcmd_arr[i], &st_temp )){ - *cmd_out = strdup(fcmd_arr[i]); + *cmd_out = xstrdup(fcmd_arr[i]); retbool = TRUE; break; } @@ -510,7 +506,7 @@ krb5_boolean find_first_cmd_that_exists(fcmd_arr, cmd_out, err_out) } if (retbool == FALSE ){ - err = (char *) calloc((80 +max_ln*i) ,sizeof(char)); + err = (char *) xcalloc((80 +max_ln*i) ,sizeof(char)); sprintf(err,"Error: not found -> "); for(j= 0; j < i; j ++){ sprintf(err,"%s %s ", err, fcmd_arr[j]); @@ -562,7 +558,7 @@ int match_commands (fcmd, cmd, match, cmd_out, err_out) }else{ if (!cmd_arr_cmp(fcmd_arr, cmd)){ /* found */ *match = TRUE; - *cmd_out = strdup(cmd); + *cmd_out = xstrdup(cmd); return 0; } else{ *match = FALSE; @@ -586,7 +582,7 @@ krb5_error_code get_line (fp, out_line) char * line, *r, *newline , *line_ptr; int chunk_count = 1; - line = (char *) calloc (BUFSIZ, sizeof (char )); + line = (char *) xcalloc (BUFSIZ, sizeof (char )); line_ptr = line; line[0] = '\0'; @@ -687,27 +683,32 @@ char * get_next_token (lnext) return out_ptr; } -static void auth_cleanup(k5users_flag, users_fp, k5login_flag, - login_fp, princname) - int k5users_flag; +static void auth_cleanup(users_fp, login_fp, princname) FILE *users_fp; - int k5login_flag; FILE *login_fp; char *princname; { free (princname); - if (!k5users_flag) fclose(users_fp); - if (!k5login_flag) fclose(login_fp); + if (users_fp) + fclose(users_fp); + if (login_fp) + fclose(login_fp); } void init_auth_names(pw_dir) char *pw_dir; { + if (strlen (k5login_path) + 2 + strlen (KRB5_LOGIN_NAME) >= MAXPATHLEN) { + fprintf (stderr, + "home directory name `%s' too long, can't search for .k5login\n", + pw_dir); + exit (1); + } if ((strlen(pw_dir) == 1) && (*pw_dir == '/')){ sprintf(k5login_path,"%s%s", pw_dir, KRB5_LOGIN_NAME); sprintf(k5users_path,"%s%s", pw_dir, KRB5_USERS_NAME); - }else{ + } else { sprintf(k5login_path,"%s/%s", pw_dir, KRB5_LOGIN_NAME); sprintf(k5users_path,"%s/%s", pw_dir, KRB5_USERS_NAME); } diff --git a/src/clients/ksu/ccache.c b/src/clients/ksu/ccache.c index 6997520..b98cc5d 100644 --- a/src/clients/ksu/ccache.c +++ b/src/clients/ksu/ccache.c @@ -64,7 +64,7 @@ krb5_creds ** cc_def_creds_arr = NULL; krb5_creds ** cc_other_creds_arr = NULL; struct stat st_temp; - cc_other = (krb5_ccache *) calloc(1, sizeof (krb5_ccache)); + cc_other = (krb5_ccache *) xcalloc(1, sizeof (krb5_ccache)); if ((retval = krb5_cc_resolve(context, cc_other_tag, cc_other))){ com_err (prog_name, retval, "resolving ccache %s", @@ -655,7 +655,7 @@ krb5_creds ** cc_def_creds_arr = NULL; krb5_creds ** cc_other_creds_arr = NULL; struct stat st_temp; - cc_other = (krb5_ccache *) calloc(1, sizeof (krb5_ccache)); + cc_other = (krb5_ccache *) xcalloc(1, sizeof (krb5_ccache)); if ((retval = krb5_cc_resolve(context, cc_other_tag, cc_other))){ com_err (prog_name, retval, "resolving ccache %s", diff --git a/src/clients/ksu/configure.in b/src/clients/ksu/configure.in index 9017d91..9da9455 100644 --- a/src/clients/ksu/configure.in +++ b/src/clients/ksu/configure.in @@ -3,8 +3,23 @@ CONFIG_RULES AC_PROG_INSTALL USE_ANAME AC_HEADER_STDARG -AC_CHECK_FUNCS(getusershell lstat ) +AC_CHECK_FUNCS(getusershell lstat setenv) AC_CHECK_HEADERS(unistd.h) +if test $ac_cv_func_setenv = no ; then + SETENVOBJ=setenv.o +else + SETENVOBJ= +fi +AC_SUBST(SETENVOBJ) +case $krb5_cv_host in +alpha-dec-osf*) + AC_CHECK_LIB(security,setluid, + AC_DEFINE(HAVE_SETLUID) + KSU_LIBS="$KSU_LIBS -lsecurity" + ) + ;; +esac +AC_SUBST(KSU_LIBS) USE_KRB5UTIL_LIBRARY KRB5_LIBRARIES V5_USE_SHARED_LIB diff --git a/src/clients/ksu/heuristic.c b/src/clients/ksu/heuristic.c index e0ee71d..0d31a4e 100644 --- a/src/clients/ksu/heuristic.c +++ b/src/clients/ksu/heuristic.c @@ -59,7 +59,7 @@ krb5_error_code get_all_princ_from_file (fp, plist) fprinc = get_first_token (line, &lp); if (fprinc ){ - temp_list[count] = strdup(fprinc); + temp_list[count] = xstrdup(fprinc); count ++; } @@ -253,17 +253,19 @@ get_authorized_princ_names(luser, cmd, princ_list) } } - if(retval = list_union(k5login_list, k5users_filt_list, &combined_list)){ - close_time(k5users_flag,users_fp, k5login_flag,login_fp); - return retval; - } - close_time(k5users_flag,users_fp, k5login_flag, login_fp); if (cmd) { + if (retval = list_union(k5login_list, + k5users_filt_list, &combined_list)){ + close_time(k5users_flag,users_fp, k5login_flag,login_fp); + return retval; + } *princ_list = combined_list; return 0; } else { + if (k5users_filt_list != NULL) + free(k5users_filt_list); *princ_list = k5login_list; return 0; } diff --git a/src/clients/ksu/krb_auth_su.c b/src/clients/ksu/krb_auth_su.c index b089fa1..93e4c9c 100644 --- a/src/clients/ksu/krb_auth_su.c +++ b/src/clients/ksu/krb_auth_su.c @@ -341,7 +341,17 @@ krb5_keyblock * tkt_ses_key; return(retval); } - + /* Check to make sure ticket hasn't expired */ + if (retval = krb5_check_exp(context, tkt->enc_part2->times)) { + if (auth_debug && (retval == KRB5KRB_AP_ERR_TKT_EXPIRED)) { + fprintf(stderr, + "krb5_verify_tkt_def: ticket has expired"); + } + krb5_free_ticket(context, tkt); + krb5_kt_free_entry(context, &ktentry); + krb5_free_keyblock(context, tkt_key); + return KRB5KRB_AP_ERR_TKT_EXPIRED; + } if (!krb5_principal_compare(context, client, tkt->enc_part2->client)) { krb5_free_ticket(context, tkt); @@ -473,29 +483,26 @@ void dump_principal (context, str, p) krb5_context context; char *str; krb5_principal p; -{ -char * stname; -krb5_error_code retval; +{ + char * stname; + krb5_error_code retval; - if ((retval = krb5_unparse_name(context, p, &stname))){ - fprintf(stderr," %s while unparsing name \n", - error_message(retval)); - } - fprintf(stderr, " %s: %s\n", str, stname ); + if ((retval = krb5_unparse_name(context, p, &stname))) { + fprintf(stderr, " %s while unparsing name\n", error_message(retval)); + } + fprintf(stderr, " %s: %s\n", str, stname); } void plain_dump_principal (context, p) krb5_context context; krb5_principal p; { -char * stname; -krb5_error_code retval; + char * stname; + krb5_error_code retval; - if ((retval = krb5_unparse_name(context, p, &stname))){ - fprintf(stderr," %s while unparsing name \n", - error_message(retval)); - } - fprintf(stderr, "%s ", stname ); + if ((retval = krb5_unparse_name(context, p, &stname))) + fprintf(stderr, " %s while unparsing name\n", error_message(retval)); + fprintf(stderr, "%s ", stname); } #if 0 diff --git a/src/clients/ksu/ksu.h b/src/clients/ksu/ksu.h index 2f6f968..c8ffaec 100644 --- a/src/clients/ksu/ksu.h +++ b/src/clients/ksu/ksu.h @@ -202,7 +202,7 @@ extern int standard_shell PROTOTYPE((char *)); extern krb5_error_code get_params PROTOTYPE((int *, int, char **, char ***)); -extern char *get_dir_of_file PROTOTYPE((char *)); +extern char *get_dir_of_file PROTOTYPE((const char *)); /* heuristic.c */ extern krb5_error_code get_all_princ_from_file PROTOTYPE((FILE *, char ***)); @@ -242,3 +242,7 @@ extern char *krb5_lname_file; /* Note: print this out just be sure that it gets set */ +extern const char out_of_memory_error[]; + +extern void *xmalloc (), *xrealloc (), *xcalloc(); +extern char *xstrdup (); diff --git a/src/clients/ksu/main.c b/src/clients/ksu/main.c index 8988c96..c595d20 100644 --- a/src/clients/ksu/main.c +++ b/src/clients/ksu/main.c @@ -123,10 +123,12 @@ char * dir_of_cc_source; options.rlife =0; options.princ =0; - params = (char **) calloc (2, sizeof (char *)); + params = (char **) xcalloc (2, sizeof (char *)); params[1] = NULL; + unsetenv ("KRB5_CONFIG"); + retval = krb5_init_context(&ksu_context); if (retval) { com_err(argv[0], retval, "while initializing krb5"); @@ -153,11 +155,11 @@ char * dir_of_cc_source; if (( argc == 1) || (argv[1][0] == '-')){ - target_user = strdup("root"); + target_user = xstrdup("root"); pargc = argc; pargv = argv; } else { - target_user = strdup(argv[1]); + target_user = xstrdup(argv[1]); pargc = argc -1; if ((pargv =(char **) calloc(pargc +1,sizeof(char *)))==NULL){ @@ -174,10 +176,12 @@ char * dir_of_cc_source; } - while(!done && ((option = getopt(pargc, pargv,"n:c:C:r:a:zZDfpkql:e:")) != EOF)){ + while(!done && ((option = getopt(pargc, pargv,"n:c:r:a:zZDfpkql:e:")) != -1)){ switch (option) { case 'r': options.opt |= KDC_OPT_RENEWABLE; + if (strlen (optarg) >= 14) + optarg = "bad-time"; retval = krb5_string_to_deltat(optarg, &options.rlife); if (retval != 0 || options.rlife == 0) { fprintf(stderr, "Bad lifetime value (%s hours?)\n", optarg); @@ -210,6 +214,8 @@ char * dir_of_cc_source; quiet =1; break; case 'l': + if (strlen (optarg) >= 14) + optarg = "bad-time"; retval = krb5_string_to_deltat(optarg, &options.lifetime); if (retval != 0 || options.lifetime == 0) { fprintf(stderr, "Bad lifetime value (%s hours?)\n", optarg); @@ -244,43 +250,9 @@ char * dir_of_cc_source; errflg++; } break; - case 'C': - if (cc_target_tag == NULL) { - cc_target_tag = strdup(optarg); - - if ((strlen(cc_target_tag) == 1) && - (*cc_target_tag == NO_TARGET_FILE)){ - use_source_cache = 1; - if(some_rest_copy || all_rest_copy){ - fprintf(stderr, - "-C . option is mutually exclusive with -z and -Z\n"); - errflg++; - } - } - else { - if ( strchr(cc_target_tag, ':')){ - cc_target_tag_tmp=strchr(cc_target_tag,':') + 1; - if(!stat(cc_target_tag_tmp, &st_temp )){ - fprintf(stderr,"File %s exists\n", - cc_target_tag_tmp); - errflg++; - } - } - else { - fprintf(stderr, - "malformed credential cache name %s\n", - cc_target_tag); - errflg++; - } - } - } else { - fprintf(stderr, "Only one -C option allowed\n"); - errflg++; - } - break; case 'c': if (cc_source_tag == NULL) { - cc_source_tag = strdup(optarg); + cc_source_tag = xstrdup(optarg); if ( strchr(cc_source_tag, ':')){ cc_source_tag_tmp = strchr(cc_source_tag, ':') + 1; @@ -303,7 +275,7 @@ char * dir_of_cc_source; } break; case 'e': - cmd = strdup(optarg); + cmd = xstrdup(optarg); if(auth_debug){printf("Before get_params optind=%d\n", optind);} if ((retval = get_params( & optind, pargc, pargv, ¶ms))){ com_err(prog_name, retval, "when gathering parameters"); @@ -356,13 +328,13 @@ char * dir_of_cc_source; } /* allocate space and copy the usernamane there */ - source_user = strdup(pwd->pw_name); + source_user = xstrdup(pwd->pw_name); source_uid = pwd->pw_uid; source_gid = pwd->pw_gid; if (!strcmp(SOURCE_USER_LOGIN, target_user)){ - target_user = strdup (source_user); + target_user = xstrdup (source_user); } if ((target_pwd = getpwnam(target_user)) == NULL){ @@ -378,9 +350,11 @@ char * dir_of_cc_source; if (cc_source_tag == NULL){ cc_source_tag = krb5_cc_default_name(ksu_context); - cc_source_tag_tmp = strchr(cc_source_tag, ':') + 1; - if (cc_source_tag_tmp == (char *) 1) + cc_source_tag_tmp = strchr(cc_source_tag, ':'); + if (cc_source_tag_tmp == 0) cc_source_tag_tmp = cc_source_tag; + else + cc_source_tag_tmp++; } if (krb5_seteuid(source_uid)) { com_err ( prog_name, errno, "while setting euid to source user"); @@ -459,15 +433,16 @@ char * dir_of_cc_source; if (cc_target_tag == NULL) { - cc_target_tag = (char *)calloc(KRB5_SEC_BUFFSIZE ,sizeof(char)); + cc_target_tag = (char *)xcalloc(KRB5_SEC_BUFFSIZE ,sizeof(char)); /* make sure that the new ticket file does not already exist This is run as source_uid because it is reasonable to require the source user to have write to where the target cache will be created.*/ do { - sprintf(cc_target_tag, "%s%d.%d", KRB5_SECONDARY_CACHE, - target_uid, gen_sym()); + sprintf(cc_target_tag, "%s%ld.%d", + KRB5_SECONDARY_CACHE, + (long) target_uid, gen_sym()); cc_target_tag_tmp = strchr(cc_target_tag, ':') + 1; }while ( !stat ( cc_target_tag_tmp, &st_temp)); @@ -530,8 +505,8 @@ char * dir_of_cc_source; } else{ cc_target = cc_source; - cc_target_tag = cc_source_tag; - cc_target_tag_tmp = cc_source_tag_tmp; + cc_target_tag = (char *) cc_source_tag; + cc_target_tag_tmp = (char *) cc_source_tag_tmp; if ((retval=krb5_find_princ_in_cache(ksu_context, cc_target,client, &stored))){ com_err (prog_name, retval, @@ -728,7 +703,7 @@ krb5_seteuid(0); /*So we have some chance of sweeping up*/ target_pwd = getpwnam(target_user); if (target_pwd->pw_shell) - shell = strdup(target_pwd->pw_shell); + shell = xstrdup(target_pwd->pw_shell); else { shell = _DEF_CSH; /* default is cshell */ } @@ -801,6 +776,19 @@ krb5_seteuid(0); /*So we have some chance of sweeping up*/ target_user, target_pwd->pw_uid); } +#ifdef HAVE_SETLUID + /* + * If we're on a system which keeps track of login uids, then + * set the login uid. If this fails this opens up a problem on DEC OSF + * with C2 enabled. + */ + if (setluid((uid_t) pwd->pw_uid) < 0) { + perror("setluid"); + sweep_up(ksu_context, use_source_cache, cc_target); + exit(1); + } +#endif /* HAVE_SETLUID */ + if (setuid(target_pwd->pw_uid) < 0) { perror("ksu: setuid"); sweep_up(ksu_context, use_source_cache, cc_target); @@ -849,7 +837,7 @@ krb5_seteuid(0); /*So we have some chance of sweeping up*/ switch ((child_pid = fork())) { default: if (auth_debug){ - printf(" The child pid is %d\n", child_pid); + printf(" The child pid is %ld\n", (long) child_pid); printf(" The parent pid is %d\n", getpid()); } while ((ret_pid = waitpid(child_pid, &statusp, WUNTRACED)) != -1) { @@ -918,7 +906,7 @@ static int set_env_var(name, value) char * env_var_buf; /* allocate extra two spaces, one for the = and one for the \0 */ - env_var_buf = (char *) calloc(2 + strlen(name) + strlen(value), + env_var_buf = (char *) xcalloc(2 + strlen(name) + strlen(value), sizeof(char)); sprintf(env_var_buf,"%s=%s",name, value); @@ -1010,18 +998,18 @@ void print_status (va_alist) char *get_dir_of_file(path) - char *path; + const char *path; { char * temp_path; char * ptr; - temp_path = strdup(path); + temp_path = xstrdup(path); if ((ptr = strrchr( temp_path, '/'))) { *ptr = '\0'; } else { free (temp_path); - temp_path = malloc(MAXPATHLEN); + temp_path = xmalloc(MAXPATHLEN); if (temp_path) getcwd(temp_path, MAXPATHLEN); } diff --git a/src/clients/ksu/setenv.c b/src/clients/ksu/setenv.c new file mode 100644 index 0000000..96d4a1e --- /dev/null +++ b/src/clients/ksu/setenv.c @@ -0,0 +1,158 @@ +/* + * Copyright (c) 1987 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the University of California, Berkeley. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +/* based on @(#)setenv.c 5.2 (Berkeley) 6/27/88 */ + +#include +#include + +/* + * setenv -- + * Set the value of the environmental variable "name" to be + * "value". If rewrite is set, replace any current value. + */ +setenv(name, value, rewrite) + register char *name, *value; + int rewrite; +{ + extern char **environ; + static int alloced; /* if allocated space before */ + register char *C; + int l_value, offset; + char *malloc(), *realloc(), *_findenv(); + + if (*value == '=') /* no `=' in value */ + ++value; + l_value = strlen(value); + if ((C = _findenv(name, &offset))) { /* find if already exists */ + if (!rewrite) + return(0); + if (strlen(C) >= l_value) { /* old larger; copy over */ + while (*C++ = *value++); + return(0); + } + } + else { /* create new slot */ + register int cnt; + register char **P; + + for (P = environ, cnt = 0; *P; ++P, ++cnt); + if (alloced) { /* just increase size */ + environ = (char **)realloc((char *)environ, + (u_int)(sizeof(char *) * (cnt + 2))); + if (!environ) + return(-1); + } + else { /* get new space */ + alloced = 1; /* copy old entries into it */ + P = (char **)malloc((u_int)(sizeof(char *) * + (cnt + 2))); + if (!P) + return(-1); + memcpy(P, environ, cnt * sizeof(char *)); + environ = P; + } + environ[cnt + 1] = NULL; + offset = cnt; + } + for (C = name; *C && *C != '='; ++C); /* no `=' in name */ + if (!(environ[offset] = /* name + `=' + value */ + malloc((u_int)((int)(C - name) + l_value + 2)))) + return(-1); + for (C = environ[offset]; (*C = *name++) &&( *C != '='); ++C); + for (*C++ = '='; *C++ = *value++;); + return(0); +} + +/* + * unsetenv(name) -- + * Delete environmental variable "name". + */ +void +unsetenv(name) + char *name; +{ + extern char **environ; + register char **P; + int offset; + char *_findenv(); + + while (_findenv(name, &offset)) /* if set multiple times */ + for (P = &environ[offset];; ++P) + if (!(*P = *(P + 1))) + break; +} +/* + * Copyright (c) 1987 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the University of California, Berkeley. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +/* based on @(#)getenv.c 5.5 (Berkeley) 6/27/88 */ + +/* + * getenv -- + * Returns ptr to value associated with name, if any, else NULL. + */ +char * +getenv(name) + char *name; +{ + int offset; + char *_findenv(); + + return(_findenv(name, &offset)); +} + +/* + * _findenv -- + * Returns pointer to value associated with name, if any, else NULL. + * Sets offset to be the offset of the name/value combination in the + * environmental array, for use by setenv(3) and unsetenv(3). + * Explicitly removes '=' in argument name. + * + * This routine *should* be a static; don't use it. + */ +char * +_findenv(name, offset) + register char *name; + int *offset; +{ + extern char **environ; + register int len; + register char **P, *C; + + for (C = name, len = 0; *C && *C != '='; ++C, ++len); + for (P = environ; *P; ++P) + if (!strncmp(*P, name, len)) + if (*(C = *P + len) == '=') { + *offset = P - environ; + return(++C); + } + return(NULL); +} diff --git a/src/clients/ksu/xmalloc.c b/src/clients/ksu/xmalloc.c new file mode 100644 index 0000000..425b44f --- /dev/null +++ b/src/clients/ksu/xmalloc.c @@ -0,0 +1,68 @@ +/* + * clients/ksu/xmalloc.c + * + * Copyright 1999 by the Massachusetts Institute of Technology. + * All Rights Reserved. + * + * Export of this software from the United States of America may + * require a specific license from the United States Government. + * It is the responsibility of any person or organization contemplating + * export to obtain such a license before exporting. + * + * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and + * distribute this software and its documentation for any purpose and + * without fee is hereby granted, provided that the above copyright + * notice appear in all copies and that both that copyright notice and + * this permission notice appear in supporting documentation, and that + * the name of M.I.T. not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. Furthermore if you modify this software you must label + * your software as modified software and not distribute it in such a + * fashion that it might be confused with the original M.I.T. software. + * M.I.T. makes no representations about the suitability of + * this software for any purpose. It is provided "as is" without express + * or implied warranty. + * + * + * Perform simple allocation/copy operations, exiting on failure. + */ + +#include "ksu.h" + +void *xmalloc (size_t sz) +{ + void *ret = malloc (sz); + if (ret == 0 && sz != 0) { + perror (prog_name); + exit (1); + } + return ret; +} + +void *xrealloc (void *old, size_t newsz) +{ + void *ret = realloc (old, newsz); + if (ret == 0 && newsz != 0) { + perror (prog_name); + exit (1); + } + return ret; +} + +void *xcalloc (size_t nelts, size_t eltsz) +{ + void *ret = calloc (nelts, eltsz); + if (ret == 0 && nelts != 0 && eltsz != 0) { + perror (prog_name); + exit (1); + } + return ret; +} + +char *xstrdup (const char *src) +{ + size_t len = strlen (src) + 1; + char *dst = xmalloc (len); + memcpy (dst, src, len); + return dst; +} diff --git a/src/config-files/ChangeLog b/src/config-files/ChangeLog index 26edc44..fd73b3e 100644 --- a/src/config-files/ChangeLog +++ b/src/config-files/ChangeLog @@ -1,3 +1,8 @@ +Tue Nov 26 19:24:34 1996 Theodore Y. Ts'o + + * kdc.conf: Fixed paths to use the GNU standard conventions. + [PR#246] + Thu Nov 14 23:08:37 1996 Tom Yu * krb5.conf.M: Note change in default_keytab_name. diff --git a/src/config-files/kdc.conf b/src/config-files/kdc.conf index c985669..cf8cbe1 100644 --- a/src/config-files/kdc.conf +++ b/src/config-files/kdc.conf @@ -3,10 +3,10 @@ [realms] ATHENA.MIT.EDU = { - database_name = /usr/local/lib/krb5kdc/principal - admin_keytab = FILE:/usr/local/lib/krb5kdc/kadm5.keytab - acl_file = /usr/local/lib/krb5kdc/kadm5.acl - key_stash_file = /usr/local/lib/krb5kdc/.k5stash + database_name = /usr/local/var/krb5kdc/principal + admin_keytab = FILE:/usr/local/var/krb5kdc/kadm5.keytab + acl_file = /usr/local/var/krb5kdc/kadm5.acl + key_stash_file = /usr/local/var/krb5kdc/.k5.ATHENA.MIT.EDU kdc_ports = 750,88 max_life = 10h 0m 0s max_renewable_life = 7d 0h 0m 0s diff --git a/src/config/ChangeLog b/src/config/ChangeLog index a1a776c..c52323c 100644 --- a/src/config/ChangeLog +++ b/src/config/ChangeLog @@ -1,3 +1,8 @@ +Tue Apr 8 11:09:20 1997 Theodore Ts'o + + * post.in: Fix recursion rule to make bash 2.x happy. + [krb5-build/403] (for patchlevel 1) + Mon Nov 11 20:53:01 1996 Tom Yu * pre.in (DEJAFLAGS): Change gmake-dependent $(shell uname foo) to diff --git a/src/config/post.in b/src/config/post.in index 277f92b..6dcb865 100644 --- a/src/config/post.in +++ b/src/config/post.in @@ -63,5 +63,5 @@ all-recurse clean-recurse install-recurse check-recurse Makefiles-recurse: else $$e; fi; \ else \ echo "Skipping missing directory $(CURRENT_DIR)$$i" ; \ - fi \ + fi; \ done diff --git a/src/include/ChangeLog b/src/include/ChangeLog index 3a2976d..8ff29d5 100644 --- a/src/include/ChangeLog +++ b/src/include/ChangeLog @@ -1,3 +1,8 @@ +Sat Nov 23 00:16:46 1996 Theodore Ts'o + + * k5-int.h: Remove DES3 and SHA support, since what's there isn't + fully correct. [PR#231] + Wed Nov 13 14:28:08 1996 Tom Yu * k5-int.h, krb5.hin: Revert kt_default_name changes. diff --git a/src/include/k5-int.h b/src/include/k5-int.h index f6f30ef..02cb5c2 100644 --- a/src/include/k5-int.h +++ b/src/include/k5-int.h @@ -145,12 +145,12 @@ #define PROVIDE_DES_CBC_CRC #define PROVIDE_DES_CBC_RAW #define PROVIDE_DES_CBC_CKSUM -#define PROVIDE_DES3_CBC_SHA -#define PROVIDE_DES3_CBC_RAW +/* #define PROVIDE_DES3_CBC_SHA */ +/* #define PROVIDE_DES3_CBC_RAW */ #define PROVIDE_CRC32 #define PROVIDE_RSA_MD4 #define PROVIDE_RSA_MD5 -#define PROVIDE_NIST_SHA +/* #define PROVIDE_NIST_SHA */ #ifndef _SIZE_T_DEFINED typedef unsigned int size_t; diff --git a/src/include/kerberosIV/ChangeLog b/src/include/kerberosIV/ChangeLog index 7475525..694a618 100644 --- a/src/include/kerberosIV/ChangeLog +++ b/src/include/kerberosIV/ChangeLog @@ -1,3 +1,7 @@ +Fri Nov 22 11:34:46 1996 Sam Hartman + + * Makefile.in: Install krb_err.h [218] + Thu Oct 31 17:27:08 1996 Sam Hartman * Makefile.in (install): Start installing headers again [36] diff --git a/src/include/kerberosIV/Makefile.in b/src/include/kerberosIV/Makefile.in index 669e341..0e4705f 100644 --- a/src/include/kerberosIV/Makefile.in +++ b/src/include/kerberosIV/Makefile.in @@ -1,4 +1,5 @@ -KRB4_HEADERS=krb.h des.h kadm.h mit-copyright.h +KRB4_HEADERS=krb.h des.h kadm.h mit-copyright.h \ + krb_err.h all:: diff --git a/src/include/krb5/k5-config.h b/src/include/krb5/k5-config.h deleted file mode 100644 index 9d2ec6c..0000000 --- a/src/include/krb5/k5-config.h +++ /dev/null @@ -1,311 +0,0 @@ -/* - * Copyright 1990,1991,1994,1995 by the Massachusetts Institute of Technology. - * All Rights Reserved. - * - * Export of this software from the United States of America may - * require a specific license from the United States Government. - * It is the responsibility of any person or organization contemplating - * export to obtain such a license before exporting. - * - * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and - * distribute this software and its documentation for any purpose and - * without fee is hereby granted, provided that the above copyright - * notice appear in all copies and that both that copyright notice and - * this permission notice appear in supporting documentation, and that - * the name of M.I.T. not be used in advertising or publicity pertaining - * to distribution of the software without specific, written prior - * permission. M.I.T. makes no representations about the suitability of - * this software for any purpose. It is provided "as is" without express - * or implied warranty. - * - * Configuration definition file. - */ - - -#ifndef KRB5_CONFIG__ -#define KRB5_CONFIG__ - -#ifdef _MSDOS -/* - * Machine-type definitions: PC Clone 386 running Microloss Windows - */ - -/* Kerberos Windows initialization file */ -#define KERBEROS_INI "kerberos.ini" -#define INI_FILES "Files" -#define INI_KRB_CCACHE "krb5cc" /* Location of the ccache */ -#define INI_KRB5_CONF "krb5.ini" /* Location of krb5.conf file */ - -#define KRB5_DBM_COMPAT__ /* Don't load dbm.h */ -#define KRB5_KDB5__ /* Don't load kdb.h */ -#define KRB5_KDB5_DBM__ /* Don't load kdb_dbm.h */ - -#define BITS16 -#define SIZEOF_INT 2 -#define SIZEOF_SHORT 2 -#define SIZEOF_LONG 4 -#define MAXHOSTNAMELEN 512 -#define MAXPATHLEN 256 /* Also for Windows temp files */ - -#define KRB5_USE_INET -#define MSDOS_FILESYSTEM -#define USE_STRING_H -#define HAVE_SRAND -#define HAVE_ERRNO -#define HAS_STRDUP -#define NO_USERID -#define NOFCHMOD -#define NOCHMOD -#define NO_PASSWORD -#define WM_KERBEROS5_CHANGED "Kerberos5 Changed" - -#define HAS_ANSI_VOLATILE -#define HAS_VOID_TYPE -#define KRB5_PROVIDE_PROTOTYPES -#define HAVE_STDARG_H -#define HAVE_SYS_TYPES_H - -#ifndef _SIZE_T_DEFINED -typedef unsigned int size_t; -#define _SIZE_T_DEFINED -#endif - -#ifndef KRB5_SYSTYPES__ -#define KRB5_SYSTYPES__ -#include -typedef unsigned long u_long; /* Not part of sys/types.h on the pc */ -typedef unsigned int u_int; -typedef unsigned short u_short; -typedef unsigned char u_char; -#endif /* KRB5_SYSTYPES__ */ - -#ifndef INTERFACE -#define INTERFACE __far __export __pascal -#define INTERFACE_C __far __export __cdecl -#endif - -/* - * The following defines are needed to make work - * in stdc mode (/Za flag). Winsock.h needs . - */ -#define FAR _far -#define NEAR _near -#define _far __far -#define _near __near -#define _pascal __pascal -#define _cdecl __cdecl -#define _huge __huge - -#ifdef NEED_WINDOWS -#include -#endif - -#ifdef NEED_LOWLEVEL_IO -/* Ugly. Microsoft, in stdc mode, doesn't support the low-level i/o - * routines directly. Rather, they only export the _ version. - * The following defines works around this problem. - */ -#include -#include -#include -#include -#include -#define O_RDONLY _O_RDONLY -#define O_WRONLY _O_WRONLY -#define O_RDWR _O_RDWR -#define O_APPEND _O_APPEND -#define O_CREAT _O_CREAT -#define O_TRUNC _O_TRUNC -#define O_EXCL _O_EXCL -#define O_TEXT _O_TEXT -#define O_BINARY _O_BINARY -#define O_NOINHERIT _O_NOINHERIT -#define stat _stat -#define unlink _unlink -#define lseek _lseek -#define write _write -#define open _open -#define close _close -#define read _read -#define fstat _fstat -#define mktemp _mktemp -#define dup _dup - -#define getpid _getpid -#endif - -#ifdef NEED_SYSERROR -/* Only needed by util/et/error_message.c but let's keep the source clean */ -#define sys_nerr _sys_nerr -#define sys_errlist _sys_errlist -#endif - -/* XXX these should be parameterized soon... */ -#define PROVIDE_DES_CBC_MD5 -#define PROVIDE_DES_CBC_CRC -#define PROVIDE_RAW_DES_CBC -#define PROVIDE_CRC32 -#define PROVIDE_DES_CBC_CKSUM -#define PROVIDE_RSA_MD4 -#define PROVIDE_RSA_MD5 -#define DEFAULT_PWD_STRING1 "Enter password:" -#define DEFAULT_PWD_STRING2 "Re-enter password for verification:" - -/* Functions with slightly different names on the PC -*/ -#define strcasecmp _stricmp -#define strdup _strdup -#define off_t _off_t - -#else /* Rest of include file is for non-Microloss-Windows */ - -#if defined(_MACINTOSH) -#include - -typedef struct { - int dummy; -} datum; - -#include - -#ifdef NEED_LOWLEVEL_IO -#include -#endif - -#ifndef _MWERKS -/* there is no for mpw */ -typedef unsigned long mode_t; -typedef unsigned long ino_t; -typedef unsigned long dev_t; -typedef short nlink_t; -typedef unsigned long uid_t; -typedef unsigned long gid_t; -typedef long off_t; -struct stat -{ - mode_t st_mode; /* File mode; see #define's below */ - ino_t st_ino; /* File serial number */ - dev_t st_dev; /* ID of device containing this file */ - nlink_t st_nlink; /* Number of links */ - uid_t st_uid; /* User ID of the file's owner */ - gid_t st_gid; /* Group ID of the file's group */ - dev_t st_rdev; /* Device type */ - off_t st_size; /* File size in bytes */ - unsigned long st_atime; /* Time of last access */ - unsigned long st_mtime; /* Time of last data modification */ - unsigned long st_ctime; /* Time of last file status change */ - long st_blksize; /* Optimal blocksize */ - long st_blocks; /* blocks allocated for file */ -}; - -int stat(const char *path, struct stat *buf); -int fstat(int fildes, struct stat *buf); - -#endif /* _MWERKS */ - -#define EFBIG 1000 - -#define NOFCHMOD 1 -#define NOCHMOD 1 -#define _MACSOCKAPI_ - -#define THREEPARAMOPEN(x,y,z) open(x,y) -#define MAXPATHLEN 255 - -/* protocol families same as address families */ -#define PF_INET AF_INET - -/* XXX these should be parameterized soon... */ -#define PROVIDE_DES_CBC_MD5 -#define PROVIDE_DES_CBC_CRC -#define PROVIDE_RAW_DES_CBC -#define PROVIDE_CRC32 -#define PROVIDE_DES_CBC_CKSUM -#define PROVIDE_RSA_MD4 -#define PROVIDE_RSA_MD5 - -#else /* _MACINTOSH */ -#define THREEPARAMOPEN(x,y,z) open(x,y,z) -#endif /* _MACINTOSH */ - -#ifndef KRB5_AUTOCONF__ -#define KRB5_AUTOCONF__ -#include "autoconf.h" -#endif - -#ifndef KRB5_SYSTYPES__ -#define KRB5_SYSTYPES__ - -#ifdef HAVE_SYS_TYPES_H /* From autoconf.h */ -#include -#else /* HAVE_SYS_TYPES_H */ -typedef unsigned long u_long; -typedef unsigned int u_int; -typedef unsigned short u_short; -typedef unsigned char u_char; -#endif /* HAVE_SYS_TYPES_H */ -#endif /* KRB5_SYSTYPES__ */ - -#ifdef SYSV -/* Change srandom and random to use rand and srand */ -/* Taken from the Sandia changes. XXX We should really just include */ -/* srandom and random into Kerberos release, since rand() is a really */ -/* bad random number generator.... [tytso:19920616.2231EDT] */ -#define random() rand() -#define srandom(a) srand(a) -#ifndef unicos61 -#define utimes(a,b) utime(a,b) -#endif /* unicos61 */ -#endif /* SYSV */ - -/* XXX these should be parameterized soon... */ -#define PROVIDE_DES_CBC_MD5 -#define PROVIDE_DES_CBC_CRC -#define PROVIDE_RAW_DES_CBC -#define PROVIDE_CRC32 -#define PROVIDE_DES_CBC_CKSUM -#define PROVIDE_RSA_MD4 -#define PROVIDE_RSA_MD5 - -#define DEFAULT_PWD_STRING1 "Enter password:" -#define DEFAULT_PWD_STRING2 "Re-enter password for verification:" - -#define KRB5_KDB_MAX_LIFE (60*60*24) /* one day */ -#define KRB5_KDB_MAX_RLIFE (60*60*24*7) /* one week */ -#define KRB5_KDB_EXPIRATION 2145830400 /* Thu Jan 1 00:00:00 2038 UTC */ - -/* - * For paranoid DOE types that don't want to give helpful error - * messages to the client....er, attacker - */ -#undef KRBCONF_VAGUE_ERRORS - -/* - * Define this if you want the KDC to modify the Kerberos database; - * this allows the last request information to be updated, as well as - * the failure count information. - * - * Note that this doesn't work if you're using slave servers!!! It - * also causes the database to be modified (and thus need to be - * locked) frequently. - */ -#undef KRBCONF_KDC_MODIFIES_KDB - -/* - * Windows requires a different api interface to each function. Here - * just define it as NULL. - */ -#define INTERFACE -#define INTERFACE_C -#define FAR -#define NEAR -#ifndef O_BINARY -#define O_BINARY 0 -#endif - -#ifndef HAS_LABS -#define labs(x) abs(x) -#endif - -#endif /* _MSDOS */ -#endif /* KRB5_CONFIG__ */ diff --git a/src/kadmin.v4/server/ChangeLog b/src/kadmin.v4/server/ChangeLog index 1bb368a..d0ee4cc 100644 --- a/src/kadmin.v4/server/ChangeLog +++ b/src/kadmin.v4/server/ChangeLog @@ -1,3 +1,14 @@ +1998-05-08 Theodore Ts'o + + * kadm_server.c (krb_log): Print the year using 4 digit to avoid + Y2K issues. + +Fri Nov 22 15:49:35 1996 unknown + + * kadm_ser_wrap.c (kadm_ser_init): use sizeof instead of h_length + to determine number of bytes of addr to copy from DNS response + [krb5-misc/211] + Thu Jun 13 22:09:02 1996 Tom Yu * configure.in: remove ref to ET_RULES diff --git a/src/kadmin.v4/server/kadm_ser_wrap.c b/src/kadmin.v4/server/kadm_ser_wrap.c index 7c373b3..bc8f0b5 100644 --- a/src/kadmin.v4/server/kadm_ser_wrap.c +++ b/src/kadmin.v4/server/kadm_ser_wrap.c @@ -72,7 +72,7 @@ kadm_ser_init(inter, realm) if ((hp = gethostbyname(hostname)) == NULL) return KADM_NO_HOSTNAME; memcpy((char *) &server_parm.admin_addr.sin_addr.s_addr, hp->h_addr, - hp->h_length); + sizeof(server_parm.admin_addr.sin_addr.s_addr)); server_parm.admin_addr.sin_port = sep->s_port; /* setting up the database */ mkey_name = KRB5_KDB_M_NAME; diff --git a/src/kadmin.v4/server/kadm_server.c b/src/kadmin.v4/server/kadm_server.c index e3ad1d6..4dc246a 100644 --- a/src/kadmin.v4/server/kadm_server.c +++ b/src/kadmin.v4/server/kadm_server.c @@ -95,8 +95,8 @@ static void krb_log(format,a1,a2,a3,a4,a5,a6,a7,a8,a9,a0) (void) time(&now); tm = localtime(&now); - fprintf(logfile,"%2d-%s-%02d %02d:%02d:%02d ",tm->tm_mday, - month_sname(tm->tm_mon + 1),tm->tm_year, + fprintf(logfile,"%2d-%s-%d %02d:%02d:%02d ",tm->tm_mday, + month_sname(tm->tm_mon + 1),1900+tm->tm_year, tm->tm_hour, tm->tm_min, tm->tm_sec); fprintf(logfile,format,a1,a2,a3,a4,a5,a6,a7,a8,a9,a0); fprintf(logfile,"\n"); diff --git a/src/kadmin/cli/ChangeLog b/src/kadmin/cli/ChangeLog index d06ca6e..bcdb670 100644 --- a/src/kadmin/cli/ChangeLog +++ b/src/kadmin/cli/ChangeLog @@ -1,3 +1,13 @@ +Thu Dec 5 19:30:22 1996 Tom Yu + + * kadmin.M: Missed a ref to /krb5. [279] + + * kadmin.M: Change example to no longer use /krb5. [PR 279] + + * kadmin.M: v5srvtab -> krb5.keytab [PR 279] + + * kadmin.c (DEFAULT_KEYTAB): v5srvtab -> krb5.keytab [PR 278] + Wed Nov 13 14:29:02 1996 Tom Yu * Makefile.in (clean-unix): Remove getdate.c and kadmin_ct.c. diff --git a/src/kadmin/cli/kadmin.M b/src/kadmin/cli/kadmin.M index f0f8913..a74874f 100644 --- a/src/kadmin/cli/kadmin.M +++ b/src/kadmin/cli/kadmin.M @@ -676,7 +676,7 @@ is added, ignoring multiple keys with the same encryption type but different salt types. If the .B \-k argument is not specified, the default keytab -.I /etc/v5srvtab +.I /etc/krb5.keytab is used. If the .B \-q option is specified, less verbose status information is displayed. @@ -695,13 +695,10 @@ command. .RS .TP EXAMPLE: -kadmin: ktadd -k /krb5/kadmind.keytab kadmin/admin kadmin/changepw -Entry for principal kadmin/admin@ATHENA.MIT.EDU with +kadmin: ktadd -k /tmp/foo-new-keytab host/foo.mit.edu +Entry for principal host/foo.mit.edu@ATHENA.MIT.EDU with kvno 3, encryption type DES-CBC-CRC added to keytab - WRFILE:/krb5/kadmind.keytab. -Entry for principal kadmin/changepw@ATHENA.MIT.EDU - with kvno 3, encryption type DES-CBC-CRC added to keytab - WRFILE:/krb5/kadmind.keytab. + WRFILE:/tmp/foo-new-keytab kadmin: .RE .fi @@ -716,7 +713,7 @@ parsed as an integer, and all entries whose kvno match that integer are removed. If the .B \-k argument is not specifeid, the default keytab -.I /etc/v5srvtab +.I /etc/krb5.keytab is used. If the .B \-q option is specified, less verbose status information is displayed. @@ -725,9 +722,9 @@ option is specified, less verbose status information is displayed. .RS .TP EXAMPLE: -kadmin: ktremove -k /krb5/kadmind.keytab kadmin/admin +kadmin: ktremove -k /usr/local/var/krb5kdc/kadmind.keytab kadmin/admin Entry for principal kadmin/admin with kvno 3 removed - from keytab WRFILE:/krb5/kadmind.keytab. + from keytab WRFILE:/usr/local/var/krb5kdc/kadmind.keytab. kadmin: .RE .fi diff --git a/src/kadmin/cli/kadmin.c b/src/kadmin/cli/kadmin.c index d8011f8..9c57c86 100644 --- a/src/kadmin/cli/kadmin.c +++ b/src/kadmin/cli/kadmin.c @@ -421,7 +421,7 @@ char *kadmin_startup(argc, argv) exit(1); } { -#define DEFAULT_KEYTAB "WRFILE:/etc/v5srvtab" +#define DEFAULT_KEYTAB "WRFILE:/etc/krb5.keytab" /* XXX krb5_defkeyname is an internal library global and should go away */ extern char *krb5_defkeyname; diff --git a/src/kadmin/dbutil/ChangeLog b/src/kadmin/dbutil/ChangeLog index 4d29322..b8b7c27 100644 --- a/src/kadmin/dbutil/ChangeLog +++ b/src/kadmin/dbutil/ChangeLog @@ -1,3 +1,8 @@ +Wed Mar 12 01:19:51 1997 Theodore Y. Ts'o + + * loadv4.c (argv): Check to see if the global_param's stash file + is non-NULL before trying to strdup() it. [PR#341, PR#394] + Wed Nov 13 00:06:40 1996 Mark Eichin * dump.c (load_db): lock the database directly (having fixed the diff --git a/src/kadmin/dbutil/loadv4.c b/src/kadmin/dbutil/loadv4.c index 2562eb9..9b70e97 100644 --- a/src/kadmin/dbutil/loadv4.c +++ b/src/kadmin/dbutil/loadv4.c @@ -192,7 +192,8 @@ char *argv[]; dbname = global_params.dbname; mkey_name = global_params.mkey_name; master_keyblock.enctype = global_params.enctype; - stash_file = strdup(global_params.stash_file); + if (global_params.stash_file) + stash_file = strdup(global_params.stash_file); rblock.max_life = global_params.max_life; rblock.max_rlife = global_params.max_rlife; rblock.expiration = global_params.expiration; diff --git a/src/kadmin/passwd/ChangeLog b/src/kadmin/passwd/ChangeLog index 5b50393..e984f67 100644 --- a/src/kadmin/passwd/ChangeLog +++ b/src/kadmin/passwd/ChangeLog @@ -1,3 +1,27 @@ +2000-02-02 Ken Raeburn + + * unit-test/kpasswd.0/changing.exp (D.15): Y2K fix. + +Wed Nov 27 13:50:03 1996 Theodore Y. Ts'o + + * configure.in: Link against kdb5 explicitly on all systems except + BSD systems, due to hairy shared library issues. [PR#257] + n.b., this is only a short-term fix for the 1.0 release. + The correct long-term fix is to not require kadm5 clients + to need to link against libkdb5 at all. + +Fri Nov 22 18:42:02 1996 Sam Hartman + + * configure.in: Do not link against kdb5 because this causes + NetBSD getpwuid to fail. [228] + + * kpasswd.c (kpasswd): Remove cast from uid_t to int. [228] + +Wed Nov 20 16:00:49 1996 Barry Jaspan + + * unit-test/Makefile.in (unit-test-): warn more loudly about unrun + tests + Wed Nov 13 19:23:15 1996 Tom Yu * unit-test/Makefile.in (clean): Remove logfiles. diff --git a/src/kadmin/passwd/configure.in b/src/kadmin/passwd/configure.in index 2331e44..874f338 100644 --- a/src/kadmin/passwd/configure.in +++ b/src/kadmin/passwd/configure.in @@ -7,8 +7,28 @@ AC_PROG_AWK USE_KADMCLNT_LIBRARY USE_GSSAPI_LIBRARY USE_GSSRPC_LIBRARY -USE_KDB5_LIBRARY USE_DYN_LIBRARY + +dnl +dnl The following is a kludge to get around a shared library problem +dnl for NetBSD and Linux. We have to include -lkdb5 under Linux, and +dnl we can't include -lkdb5 under NetBSD, due to various breakages in +dnl each system's shared library implementation +dnl +AC_MSG_CHECKING([for build host]) +AC_CACHE_VAL(krb5_cv_host, [export CC +AC_CANONICAL_HOST +krb5_cv_host=$host]) +AC_MSG_RESULT($krb5_cv_host) +case $krb5_cv_host in +*-*-*bsd*) + echo "Skipping USE KDB5 LIBRARY on BSD to avoid libdb incompatibilites" + ;; +*) + USE_KDB5_LIBRARY + ;; +esac + KRB5_LIBRARIES V5_USE_SHARED_LIB V5_AC_OUTPUT_MAKEFILE diff --git a/src/kadmin/passwd/kpasswd.c b/src/kadmin/passwd/kpasswd.c index e425280..48cb4cc 100644 --- a/src/kadmin/passwd/kpasswd.c +++ b/src/kadmin/passwd/kpasswd.c @@ -137,7 +137,7 @@ kpasswd(context, argc, argv) /* if either krb5_cc failed check the passwd file */ if (code != 0) { - pw = getpwuid((int) getuid()); + pw = getpwuid( getuid()); if (pw == NULL) { com_err(whoami, 0, string_text(KPW_STR_NOT_IN_PASSWD_FILE)); return(MISC_EXIT_STATUS); diff --git a/src/kadmin/passwd/unit-test/Makefile.in b/src/kadmin/passwd/unit-test/Makefile.in index f2192df..8ffc57f 100644 --- a/src/kadmin/passwd/unit-test/Makefile.in +++ b/src/kadmin/passwd/unit-test/Makefile.in @@ -1,8 +1,10 @@ check unit-test:: unit-test-@DO_TEST@ unit-test-: - @echo "The kpasswd tests require Perl, Tcl, and runtest" - @echo "No tests run here" + @echo "+++" + @echo "+++ WARNING: kpasswd unit tests not run." + @echo "+++ Either tcl, runtest, or Perl is unavailable." + @echo "+++" unit-test-ok:: unit-test-setup unit-test-body unit-test-cleanup diff --git a/src/kadmin/passwd/unit-test/kpasswd.0/changing.exp b/src/kadmin/passwd/unit-test/kpasswd.0/changing.exp index 4f0354c..cfa9e28 100644 --- a/src/kadmin/passwd/unit-test/kpasswd.0/changing.exp +++ b/src/kadmin/passwd/unit-test/kpasswd.0/changing.exp @@ -93,7 +93,7 @@ test_win {pol2} {successful change} pol2 pol222222 polbbbbbb test_3pass {pol2} {D.15: too soon to change password} pol2 \ polbbbbbb pol222222 pol222222 \ - 4 {Password cannot be changed because it was changed too recently. Please wait until .*199[0-9] before you change it. If you need to change your password before then, contact your system security administrator.} + 4 {Password cannot be changed because it was changed too recently. Please wait until .*[0-9] before you change it. If you need to change your password before then, contact your system security administrator.} verbose "(sleeping 30 seconds)" catch "exec sleep 30" diff --git a/src/kadmin/server/ChangeLog b/src/kadmin/server/ChangeLog index 6092176..b3e34ce 100644 --- a/src/kadmin/server/ChangeLog +++ b/src/kadmin/server/ChangeLog @@ -1,3 +1,14 @@ +Mon Mar 1 21:24:49 1999 Tom Yu + + * ovsec_kadmd.c (log_badverf): Actually make a real lookup table + for procedure numbers. Also, if we don't find the procedure + number, just log the number rather than falling off the end of an + array. + +Tue Nov 19 16:48:50 1996 Barry Jaspan + + * ovsec_kadmd.c: don't syslog \n's + Wed Nov 13 14:29:34 1996 Tom Yu * ovsec_kadmd.c (main): Note that krb5_defkeyname is an internal diff --git a/src/kadmin/server/ovsec_kadmd.c b/src/kadmin/server/ovsec_kadmd.c index 21514ac..a369ecb 100644 --- a/src/kadmin/server/ovsec_kadmd.c +++ b/src/kadmin/server/ovsec_kadmd.c @@ -183,7 +183,7 @@ int main(int argc, char *argv[]) if (ret = kadm5_get_config_params(context, NULL, NULL, ¶ms, ¶ms)) { - krb5_klog_syslog(LOG_ERR, "%s: %s while initializing, aborting\n", + krb5_klog_syslog(LOG_ERR, "%s: %s while initializing, aborting", whoami, error_message(ret)); fprintf(stderr, "%s: %s while initializing, aborting\n", whoami, error_message(ret)); @@ -197,7 +197,7 @@ int main(int argc, char *argv[]) if ((params.mask & REQUIRED_PARAMS) != REQUIRED_PARAMS) { krb5_klog_syslog(LOG_ERR, "%s: Missing required configuration values " - "while initializing, aborting\n", whoami, + "while initializing, aborting", whoami, (params.mask & REQUIRED_PARAMS) ^ REQUIRED_PARAMS); fprintf(stderr, "%s: Missing required configuration values " "(%x) while initializing, aborting\n", whoami, @@ -635,33 +635,58 @@ void log_badverf(gss_name_t client_name, gss_name_t server_name, struct svc_req *rqst, struct rpc_msg *msg, char *data) { - static const char *const proc_names[] = { - "kadm5_create_principal", - "kadm5_delete_principal", - "kadm5_modify_principal", - "kadm5_rename_principal", - "kadm5_get_principal", - "kadm5_chpass_principal", - "kadm5_randkey_principal", - "kadm5_create_policy", - "kadm5_delete_policy", - "kadm5_modify_policy", - "kadm5_get_policy", - "kadm5_get_privs", + struct procnames { + rpc_u_int32 proc; + const char *proc_name; }; + static const struct procnames proc_names[] = { + {1, "CREATE_PRINCIPAL"}, + {2, "DELETE_PRINCIPAL"}, + {3, "MODIFY_PRINCIPAL"}, + {4, "RENAME_PRINCIPAL"}, + {5, "GET_PRINCIPAL"}, + {6, "CHPASS_PRINCIPAL"}, + {7, "CHRAND_PRINCIPAL"}, + {8, "CREATE_POLICY"}, + {9, "DELETE_POLICY"}, + {10, "MODIFY_POLICY"}, + {11, "GET_POLICY"}, + {12, "GET_PRIVS"}, + {13, "INIT"}, + {14, "GET_PRINCS"}, + {15, "GET_POLS"}, + }; +#define NPROCNAMES (sizeof (proc_names) / sizeof (struct procnames)) OM_uint32 minor; gss_buffer_desc client, server; gss_OID gss_type; char *a; + rpc_u_int32 proc; + int i; + const char *procname; (void) gss_display_name(&minor, client_name, &client, &gss_type); (void) gss_display_name(&minor, server_name, &server, &gss_type); a = inet_ntoa(rqst->rq_xprt->xp_raddr.sin_addr); - krb5_klog_syslog(LOG_NOTICE, "WARNING! Forged/garbled request: %s, " - "claimed client = %s, server = %s, addr = %s", - proc_names[msg->rm_call.cb_proc], client.value, - server.value, a); + proc = msg->rm_call.cb_proc; + procname = NULL; + for (i = 0; i < NPROCNAMES; i++) { + if (proc_names[i].proc == proc) { + procname = proc_names[i].proc_name; + break; + } + } + if (procname != NULL) + krb5_klog_syslog(LOG_NOTICE, "WARNING! Forged/garbled request: %s, " + "claimed client = %s, server = %s, addr = %s", + procname, client.value, + server.value, a); + else + krb5_klog_syslog(LOG_NOTICE, "WARNING! Forged/garbled request: %d, " + "claimed client = %s, server = %s, addr = %s", + proc, client.value, + server.value, a); (void) gss_release_buffer(&minor, &client); (void) gss_release_buffer(&minor, &server); @@ -724,7 +749,7 @@ void log_badauth(OM_uint32 major, OM_uint32 minor, krb5_klog_syslog(LOG_NOTICE, "Authentication attempt failed: %s, GSS-API " "error strings are:", a); log_badauth_display_status(" ", major, minor); - krb5_klog_syslog(LOG_NOTICE, " GSS-API error strings complete.\n"); + krb5_klog_syslog(LOG_NOTICE, " GSS-API error strings complete."); } void log_badauth_display_status(char *msg, OM_uint32 major, OM_uint32 minor) @@ -752,11 +777,11 @@ void log_badauth_display_status_1(char *m, OM_uint32 code, int type, GSS_C_MECH_CODE, 1); } else krb5_klog_syslog(LOG_ERR, "GSS-API authentication error %s: " - "recursive failure!\n", msg); + "recursive failure!", msg); return; } - krb5_klog_syslog(LOG_NOTICE, "%s %s\n", m, (char *)msg.value); + krb5_klog_syslog(LOG_NOTICE, "%s %s", m, (char *)msg.value); (void) gss_release_buffer(&minor_stat, &msg); if (!msg_ctx) diff --git a/src/kadmin/testing/scripts/ChangeLog b/src/kadmin/testing/scripts/ChangeLog index 852bc20..fd53ba0 100644 --- a/src/kadmin/testing/scripts/ChangeLog +++ b/src/kadmin/testing/scripts/ChangeLog @@ -1,3 +1,7 @@ +Thu Dec 5 19:34:09 1996 Tom Yu + + * save_files.sh (files): Also save /etc/krb5.keytab. [PR 278] + Thu Nov 14 15:28:16 1996 Barry Jaspan * env-setup.shin, init_db, save_files.sh, start_servers, diff --git a/src/kadmin/testing/scripts/save_files.sh b/src/kadmin/testing/scripts/save_files.sh index 14fe892..7218203 100644 --- a/src/kadmin/testing/scripts/save_files.sh +++ b/src/kadmin/testing/scripts/save_files.sh @@ -15,7 +15,7 @@ done # /.secure/etc/passwd /etc/athena/inetd.conf" files="/etc/krb.conf /etc/krb.realms /etc/athena/krb.conf \ - /etc/athena/krb.realms /etc/v5srvtab" + /etc/athena/krb.realms /etc/v5srvtab /etc/krb5.keytab" name=`basename $0` diff --git a/src/kadmin/testing/util/ChangeLog b/src/kadmin/testing/util/ChangeLog index e324ed6..698414a 100644 --- a/src/kadmin/testing/util/ChangeLog +++ b/src/kadmin/testing/util/ChangeLog @@ -1,3 +1,16 @@ +Fri Dec 6 00:04:10 1996 Theodore Y. Ts'o + + * test.c: Change test looking for tcl 7.05 and greater to be tcl + 7.04 and greater, since BSDI ships with tcl 7.04, and + needs this change. [PR#282] + +Thu Dec 5 22:47:27 1996 Theodore Y. Ts'o + + * tcl_ovsec_kadm.c: + * tcl_kadm5.c: Remove #include of , which is not + guaranteed to be there. #include of is all you + need for malloc(), per ANSI. [PR#281] + Wed Nov 13 09:55:05 1996 Ezra Peisach * Makefile.in (clean): Remove built programs. diff --git a/src/kadmin/testing/util/tcl_kadm5.c b/src/kadmin/testing/util/tcl_kadm5.c index 2aa3663..409f023 100644 --- a/src/kadmin/testing/util/tcl_kadm5.c +++ b/src/kadmin/testing/util/tcl_kadm5.c @@ -4,7 +4,6 @@ #define USE_KADM5_API_VERSION 2 #include #include -#include #include #include #include diff --git a/src/kadmin/testing/util/tcl_ovsec_kadm.c b/src/kadmin/testing/util/tcl_ovsec_kadm.c index 0c6aaac..40a854e 100644 --- a/src/kadmin/testing/util/tcl_ovsec_kadm.c +++ b/src/kadmin/testing/util/tcl_ovsec_kadm.c @@ -4,7 +4,6 @@ #define USE_KADM5_API_VERSION 1 #include #include -#include #include #include #include diff --git a/src/kadmin/testing/util/test.c b/src/kadmin/testing/util/test.c index 75a0fc2..f9da052 100644 --- a/src/kadmin/testing/util/test.c +++ b/src/kadmin/testing/util/test.c @@ -1,8 +1,8 @@ #include -#define IS_TCL_7_5 ((TCL_MAJOR_VERSION * 100 + TCL_MINOR_VERSION) >= 705) +#define _TCL_MAIN ((TCL_MAJOR_VERSION * 100 + TCL_MINOR_VERSION) >= 704) -#if IS_TCL_7_5 +#if _TCL_MAIN int main(argc, argv) int argc; /* Number of command-line arguments. */ diff --git a/src/kadmin/v4server/ChangeLog b/src/kadmin/v4server/ChangeLog index 7572a63..6157fcb 100644 --- a/src/kadmin/v4server/ChangeLog +++ b/src/kadmin/v4server/ChangeLog @@ -1,3 +1,14 @@ +1998-05-08 Theodore Ts'o + + * kadm_server.c (krb_log): Print the year using 4 digit to avoid + Y2K issues. + +Fri Nov 22 15:49:27 1996 unknown + + * kadm_ser_wrap.c (endif ): use sizeof instead of h_length to + determine number of bytes of addr to copy from DNS response + [krb5-misc/211] + Wed Nov 13 19:24:00 1996 Tom Yu * Makefile.in (clean): Remove kadm_err.h and kadm_err.c. diff --git a/src/kadmin/v4server/kadm_ser_wrap.c b/src/kadmin/v4server/kadm_ser_wrap.c index 3d4c045..7ea289f 100644 --- a/src/kadmin/v4server/kadm_ser_wrap.c +++ b/src/kadmin/v4server/kadm_ser_wrap.c @@ -82,7 +82,7 @@ kadm_ser_init(inter, realm) if ((hp = gethostbyname(hostname)) == NULL) return KADM_NO_HOSTNAME; memcpy((char *) &server_parm.admin_addr.sin_addr.s_addr, hp->h_addr, - hp->h_length); + sizeof(server_parm.admin_addr.sin_addr.s_addr)); server_parm.admin_addr.sin_port = sep->s_port; /* setting up the database */ mkey_name = KRB5_KDB_M_NAME; diff --git a/src/kadmin/v4server/kadm_server.c b/src/kadmin/v4server/kadm_server.c index 81e43f1..aaa8eb4 100644 --- a/src/kadmin/v4server/kadm_server.c +++ b/src/kadmin/v4server/kadm_server.c @@ -110,8 +110,8 @@ static void krb_log(format,a1,a2,a3,a4,a5,a6,a7,a8,a9,a0) (void) time(&now); tm = localtime(&now); - fprintf(logfile,"%2d-%s-%02d %02d:%02d:%02d ",tm->tm_mday, - month_sname(tm->tm_mon + 1),tm->tm_year, + fprintf(logfile,"%2d-%s-%d %02d:%02d:%02d ",tm->tm_mday, + month_sname(tm->tm_mon + 1),1900+tm->tm_year, tm->tm_hour, tm->tm_min, tm->tm_sec); fprintf(logfile,format,a1,a2,a3,a4,a5,a6,a7,a8,a9,a0); fprintf(logfile,"\n"); diff --git a/src/kadmin/v4server/unit-test/ChangeLog b/src/kadmin/v4server/unit-test/ChangeLog index 239af0f..b7d494b 100644 --- a/src/kadmin/v4server/unit-test/ChangeLog +++ b/src/kadmin/v4server/unit-test/ChangeLog @@ -1,3 +1,8 @@ +2000-02-03 Ken Raeburn + + * lib/helpers.exp (unexpire): Put expiration time into the future + again. + Mon Nov 11 20:51:58 1996 Tom Yu * configure.in: Add AC_CANONICAL_HOST to deal with new pre.in. diff --git a/src/kadmin/v4server/unit-test/lib/helpers.exp b/src/kadmin/v4server/unit-test/lib/helpers.exp index 8338d37..a5f3465 100644 --- a/src/kadmin/v4server/unit-test/lib/helpers.exp +++ b/src/kadmin/v4server/unit-test/lib/helpers.exp @@ -215,7 +215,7 @@ proc unexpire { name fullname } { # While we're at it, make sure they aren't expired. exp_prog "$name: kadmin.local" $kadmin_local "" 0 { "kadmin.local:" { - send "modprinc -expire \"May 6, 1999\" $fullname\n" + send "modprinc -expire \"May 6, 2037\" $fullname\n" } } { -re "Principal .* modified." { send "quit\n" } diff --git a/src/kdc/ChangeLog b/src/kdc/ChangeLog index dd74460..c80ea51 100644 --- a/src/kdc/ChangeLog +++ b/src/kdc/ChangeLog @@ -1,3 +1,111 @@ +Tue Jul 21 20:29:38 1998 Tom Yu + + * replay.c (kdc_check_lookaside): + (kdc_insert_lookaside): Add code to originating address of packet, + as krb4 initial ticket requests don't contain an address. This + would cause a subtle problem wherein two simultaneous krb4 initial + ticket requests for the same principal originating from different + addresses would result in both replies containing the same + address. + + * kdc_util.h: Modify prototype for lookaside functions. + + * dispatch.c (dispatch): Update to new calling conventions of the + lookaside functions. + +Fri May 8 18:46:59 1998 Theodore Y. Ts'o + + * kerberos_v4.c (krb4_stime): Print 4 digit years in Krb4 log + entries to avoid Y2K issues. + +Fri Mar 20 17:13:46 1998 Tom Yu + + * kdc_util.c (add_to_transited): Check lengths, fix up comma + quoting somewhat (though things are still way broken). + +Thu Feb 5 19:09:06 1998 Tom Yu + + * kerberos_v4.c: Fix up call to klog, also delete logic to check + whether v4 processing is disabled (relies on code that is only in + the mainline). + +Wed Feb 4 14:15:20 1998 Theodore Y. Ts'o + + * kerberos_v4.c (process_v4): Check the length of the incoming V4 + packet before copying it into the KTEXT_ST variable. + (kerberos_v4): Make sure the strings in the V4 request + structures aren't no longer than they are allowed to be. + +Fri Jan 16 03:33:50 1998 Tom Yu + + * do_tgs_req.c: Add some explicit settings of errcode so that the + cleanup code doesn't try to construct a bogus error reply, which + was causing coredumps in the lookaside code. + +Mon Nov 24 19:57:48 1997 Theodore Y. Ts'o + + * do_tgs_req.c (process_tgs_req): Add check to make sure cname and + sname are non-NULL when syslogging an error because the + principals don't match. + + * kdc_util.c (limit_string): Check to make sure the input string + is non-NULL before operating on it. + +Mon Nov 10 20:03:14 1997 Theodore Y. Ts'o + + * kdc_util.c (kdc_process_tgs_req): If not using the reply cache, + properly handle a failure return from + krb5_rd_req_decode_anyflag(). + +Wed Sep 24 11:56:50 1997 Ezra Peisach + + * kdc_util.c (add_to_transited): Fix up memory leaks, clean out + new memory allocated, allocate buffers to max size + needed. [based on krb5-kdc/461 by Ken Hornstein]. + +Wed Jul 30 18:29:19 1997 Tom Yu + + * kdc_util.c: + * main.c: Don't use an rcache. + +Tue Jul 15 01:55:56 1997 Tom Yu + + * kdc_preauth.c (get_sam_edata): Don't goto cleanup if SAM is not + used; this prevents freeing an unallocated keyblock. + +Thu May 29 21:08:24 1997 Theodore Y. Ts'o + + * do_as_req.c (process_as_req), do_tgs_req (process_tgs_req): Use + limit_string() to make sure the length of cname and sname + are reasonable. + + * kdc_util.c (limit_string): New function which limits the strings + that will end up in log files to "reasonable" lengths. + +Wed Jan 1 22:56:16 1997 Ezra Peisach + + * kdc_preauth.c (get_sam_edata): Use proper interface to + krb5_db_get_principal. Also if SAM is not an option, do + not return as a possible type to client. [krb5-kdc/310] + +Sat Nov 23 17:26:22 1996 Mark Eichin + + * [krb5-libs/149] only generate requests that you can actually + handle. + + Tue Sep 3 22:53:56 1996 Mark Eichin + + * kdc_preauth.c (get_preauth_hint_list): detect ap->get_edata + return status and don't pass back hint if it failed. + (get_etype_info): malloc one more word in entry for end marker. + +Wed Nov 20 11:25:05 1996 Barry Jaspan + + * main.c (initialize_realms): krb5_aprof_init can succeed while + leaving aprof == NULL, but krb5_aprof_finish will fail. This is + just more grossness that needs to be redone when the kdc.conf + interface is reworked. + Thu Nov 7 12:27:21 1996 Theodore Ts'o * kdc_preauth.c (check_padata): Fixed error handling; in order for diff --git a/src/kdc/dispatch.c b/src/kdc/dispatch.c index a94173c..7446ea5 100644 --- a/src/kdc/dispatch.c +++ b/src/kdc/dispatch.c @@ -43,7 +43,7 @@ dispatch(pkt, from, portnum, response) /* decode incoming packet, and dispatch */ /* try the replay lookaside buffer */ - if (kdc_check_lookaside(pkt, response)) { + if (kdc_check_lookaside(pkt, from, response)) { /* a hit! */ krb5_klog_syslog(LOG_INFO, "DISPATCH: replay found and re-transmitted"); return 0; @@ -72,7 +72,7 @@ dispatch(pkt, from, portnum, response) retval = KRB5KRB_AP_ERR_MSG_TYPE; /* put the response into the lookaside buffer */ if (!retval) - kdc_insert_lookaside(pkt, *response); + kdc_insert_lookaside(pkt, from, *response); return retval; } diff --git a/src/kdc/do_as_req.c b/src/kdc/do_as_req.c index cf999fe..bb2ca80 100644 --- a/src/kdc/do_as_req.c +++ b/src/kdc/do_as_req.c @@ -99,6 +99,7 @@ krb5_data **response; /* filled in with a response packet */ status = "UNPARSING_CLIENT"; goto errout; } + limit_string(cname); if (!request->server) { status = "NULL_SERVER"; errcode = KRB5KDC_ERR_S_PRINCIPAL_UNKNOWN; @@ -108,6 +109,7 @@ krb5_data **response; /* filled in with a response packet */ status = "UNPARSING_SERVER"; goto errout; } + limit_string(sname); c_nprincs = 1; if ((errcode = krb5_db_get_principal(kdc_context, request->client, diff --git a/src/kdc/do_tgs_req.c b/src/kdc/do_tgs_req.c index 0ea2df1..242a6c3 100644 --- a/src/kdc/do_tgs_req.c +++ b/src/kdc/do_tgs_req.c @@ -130,6 +130,7 @@ krb5_data **response; /* filled in with a response packet */ } if (!header_ticket) { + errcode = KRB5_NO_TKT_SUPPLIED; /* XXX? */ status="UNEXPECTED NULL in header_ticket"; goto cleanup; } @@ -419,6 +420,7 @@ tgt_again: if (!(scratch.data = malloc(request->authorization_data.ciphertext.length))) { status = "AUTH_NOMEM"; + errcode = ENOMEM; goto cleanup; } /* do any necessary key pre-processing */ @@ -525,8 +527,11 @@ tgt_again: &tmp))) tmp = 0; krb5_klog_syslog(LOG_INFO, "TGS_REQ %s(%d): 2ND_TKT_MISMATCH: authtime %d, %s for %s, 2nd tkt client %s", - fromstring, portnum, authtime, cname, sname, + fromstring, portnum, authtime, + cname ? cname : "", + sname ? sname : "", tmp ? tmp : ""); + errcode = KRB5KDC_ERR_SERVER_NOMATCH; goto cleanup; } diff --git a/src/kdc/kdc_preauth.c b/src/kdc/kdc_preauth.c index 0350068..4c28b0b 100644 --- a/src/kdc/kdc_preauth.c +++ b/src/kdc/kdc_preauth.c @@ -203,8 +203,15 @@ void get_preauth_hint_list(request, client, server, e_data) memset(*pa, 0, sizeof(krb5_pa_data)); (*pa)->magic = KV5M_PA_DATA; (*pa)->pa_type = ap->type; - if (ap->get_edata) - (ap->get_edata)(kdc_context, request, client, server, *pa); + if (ap->get_edata) { + retval = (ap->get_edata)(kdc_context, request, client, server, *pa); + if (retval) { + /* just failed on this type, continue */ + free(*pa); + *pa = 0; + continue; + } + } pa++; } retval = encode_krb5_padata_sequence((const krb5_pa_data **) pa_data, @@ -433,7 +440,7 @@ get_etype_info(context, request, client, server, pa_data) salt.data = 0; - entry = malloc((client->n_key_data * 2) * sizeof(krb5_etype_info_entry *)); + entry = malloc((client->n_key_data * 2 + 1) * sizeof(krb5_etype_info_entry *)); if (entry == NULL) return ENOMEM; entry[0] = NULL; @@ -630,7 +637,8 @@ get_sam_edata(context, request, client, server, pa_data) { char *uname; - int npr = 1, more; + int npr = 1; + krb5_boolean more; krb5_db_entry assoc; krb5_key_data *assoc_key; krb5_principal newp; @@ -656,7 +664,7 @@ get_sam_edata(context, request, client, server, pa_data) strlen(sam_ptr->name); npr = 1; retval = krb5_db_get_principal(kdc_context, newp, &assoc, &npr, &more); - if(!retval) { + if(!retval && npr) { sc.sam_type = sam_ptr->sam_type; break; } @@ -690,7 +698,9 @@ get_sam_edata(context, request, client, server, pa_data) } /* now we can use encrypting_key... */ } - } + } else + /* SAM is not an option - so don't return as hint */ + return KRB5_PREAUTH_BAD_TYPE; krb5_princ_component(kdc_context,newp,probeslot)->data = 0; krb5_princ_component(kdc_context,newp,probeslot)->length = 0; diff --git a/src/kdc/kdc_util.c b/src/kdc/kdc_util.c index a711a27..02c4034 100644 --- a/src/kdc/kdc_util.c +++ b/src/kdc/kdc_util.c @@ -207,10 +207,11 @@ kdc_process_tgs_req(request, from, pkt, ticket, subkey) if ((retval = krb5_auth_con_setaddrs(kdc_context, auth_context, NULL, from->address)) ) goto cleanup_auth_context; - +#ifdef USE_RCACHE if ((retval = krb5_auth_con_setrcache(kdc_context, auth_context, kdc_rcache))) goto cleanup_auth_context; +#endif /* if ((retval = kdc_get_server_key(apreq->ticket, &key, &kvno))) @@ -232,6 +233,7 @@ kdc_process_tgs_req(request, from, pkt, ticket, subkey) apreq->ticket->server, kdc_active_realm->realm_keytab, NULL, ticket))) { +#ifdef USE_RCACHE /* * I'm not so sure that this is right, but it's better than nothing * at all. @@ -255,7 +257,10 @@ kdc_process_tgs_req(request, from, pkt, ticket, subkey) goto cleanup_auth_context; } } else - goto cleanup_auth_context; + goto cleanup_auth_context; +#else + goto cleanup_auth_context; +#endif } /* "invalid flag" tickets can must be used to validate */ @@ -315,7 +320,9 @@ cleanup_authenticator: cleanup_auth_context: /* We do not want the free of the auth_context to close the rcache */ +#ifdef USE_RCACHE (void) krb5_auth_con_setrcache(kdc_context, auth_context, 0); +#endif krb5_auth_con_free(kdc_context, auth_context); cleanup: @@ -530,9 +537,10 @@ add_to_transited(tgt_trans, new_trans, tgs, client, server) krb5_principal client; krb5_principal server; { + krb5_error_code retval; char *realm; char *trans; - char *otrans; + char *otrans, *otrans_ptr; /* The following are for stepping through the transited field */ @@ -541,6 +549,7 @@ add_to_transited(tgt_trans, new_trans, tgs, client, server) char current[MAX_REALM_LN]; char exp[MAX_REALM_LN]; /* Expanded current realm name */ + int i; int clst, nlst; /* count of last character in current and next */ int pl, pl1; /* prefix length */ int added; /* TRUE = new realm has been added */ @@ -553,35 +562,52 @@ add_to_transited(tgt_trans, new_trans, tgs, client, server) realm[krb5_princ_realm(kdc_context, tgs)->length] = '\0'; if (!(otrans = (char *) malloc(tgt_trans->length+1))) { + free(realm); return(ENOMEM); } memcpy(otrans, tgt_trans->data, tgt_trans->length); otrans[tgt_trans->length] = '\0'; - - if (!(trans = (char *) malloc(strlen(realm) + strlen(otrans) + 1))) { - return(ENOMEM); + /* Keep track of start so we can free */ + otrans_ptr = otrans; + + /* +1 for null, + +1 for extra comma which may be added between + +1 for potential space when leading slash in realm */ + if (!(trans = (char *) malloc(strlen(realm) + strlen(otrans) + 3))) { + retval = ENOMEM; + goto fail; } if (new_trans->data) free(new_trans->data); new_trans->data = trans; + new_trans->length = 0; + + trans[0] = '\0'; /* For the purpose of appending, the realm preceding the first */ /* realm in the transited field is considered the null realm */ prev[0] = '\0'; - /***** In next statement, need to keep reading if the , was quoted *****/ /* read field into current */ - - if (sscanf(otrans, "%[^,]", current) == 1) { - otrans += strlen(current); - } - else { - current[0] = '\0'; + for (i = 0; *otrans != '\0';) { + if (*otrans == '\\') + if (*(++otrans) == '\0') + break; + else + continue; + if (*otrans == ',') { + otrans++; + break; + } + current[i++] = *otrans++; + if (i >= MAX_REALM_LN) { + retval = KRB5KRB_AP_ERR_ILL_CR_TKT; + goto fail; + } } + current[i] = '\0'; - if (otrans[0] == ',') otrans++; - added = (krb5_princ_realm(kdc_context, client)->length == strlen(realm) && !strncmp(krb5_princ_realm(kdc_context, client)->data, realm, strlen(realm))) || (krb5_princ_realm(kdc_context, server)->length == strlen(realm) && @@ -597,29 +623,43 @@ add_to_transited(tgt_trans, new_trans, tgs, client, server) } else if ((current[0] == '/') && (prev[0] == '/')) { strcpy(exp, prev); + if (strlen(exp) + strlen(current) + 1 >= MAX_REALM_LN) { + retval = KRB5KRB_AP_ERR_ILL_CR_TKT; + goto fail; + } strcat(exp, current); } else if (current[clst] == '.') { strcpy(exp, current); + if (strlen(exp) + strlen(current) + 1 >= MAX_REALM_LN) { + retval = KRB5KRB_AP_ERR_ILL_CR_TKT; + goto fail; + } strcat(exp, prev); } else { strcpy(exp, current); } - /***** next statement, need to keep reading if the , was quoted *****/ /* read field into next */ - - if (sscanf(otrans, "%[^,]", next) == 1) { - otrans += strlen(next); - nlst = strlen(next) - 1; - } - else { - next[0] = '\0'; - nlst = 0; + for (i = 0; *otrans != '\0';) { + if (*otrans == '\\') + if (*(++otrans) == '\0') + break; + else + continue; + if (*otrans == ',') { + otrans++; + break; + } + next[i++] = *otrans++; + if (i >= MAX_REALM_LN) { + retval = KRB5KRB_AP_ERR_ILL_CR_TKT; + goto fail; + } } - - if (otrans[0] == ',') otrans++; + next[i] = '\0'; + nlst = i - 1; if (!strcmp(exp, realm)) added = TRUE; @@ -640,6 +680,10 @@ add_to_transited(tgt_trans, new_trans, tgs, client, server) if ((next[nlst] != '.') && (next[0] != '/') && (pl = subrealm(exp, realm))) { added = TRUE; + if (strlen(current) + (pl>0?pl:-pl) + 2 >= MAX_REALM_LN) { + retval = KRB5KRB_AP_ERR_ILL_CR_TKT; + goto fail; + } strcat(current, ","); if (pl > 0) { strncat(current, realm, pl); @@ -663,6 +707,10 @@ add_to_transited(tgt_trans, new_trans, tgs, client, server) added = TRUE; current[0] = '\0'; if ((pl1 = subrealm(prev,realm))) { + if (strlen(current) + (pl1>0?pl1:-pl1) + 1 >= MAX_REALM_LN) { + retval = KRB5KRB_AP_ERR_ILL_CR_TKT; + goto fail; + } if (pl1 > 0) { strncat(current, realm, pl1); } @@ -672,10 +720,22 @@ add_to_transited(tgt_trans, new_trans, tgs, client, server) } else { /* If not a subrealm */ if ((realm[0] == '/') && prev[0]) { - strcat(current, " "); + if (strlen(current) + 2 >= MAX_REALM_LN) { + retval = KRB5KRB_AP_ERR_ILL_CR_TKT; + goto fail; + } + strcat(current, " "); } + if (strlen(current) + strlen(realm) + 1 >= MAX_REALM_LN) { + retval = KRB5KRB_AP_ERR_ILL_CR_TKT; + goto fail; + } strcat(current, realm); } + if (strlen(current) + (pl>0?pl:-pl) + 2 >= MAX_REALM_LN) { + retval = KRB5KRB_AP_ERR_ILL_CR_TKT; + goto fail; + } strcat(current,","); if (pl > 0) { strncat(current, exp, pl); @@ -686,7 +746,17 @@ add_to_transited(tgt_trans, new_trans, tgs, client, server) } } - if (new_trans->length != 0) strcat(trans, ","); + if (new_trans->length != 0) { + if (strlen(trans) + 2 >= MAX_REALM_LN) { + retval = KRB5KRB_AP_ERR_ILL_CR_TKT; + goto fail; + } + strcat(trans, ","); + } + if (strlen(trans) + strlen(current) + 1 >= MAX_REALM_LN) { + retval = KRB5KRB_AP_ERR_ILL_CR_TKT; + goto fail; + } strcat(trans, current); new_trans->length = strlen(trans) + 1; @@ -695,13 +765,33 @@ add_to_transited(tgt_trans, new_trans, tgs, client, server) } if (!added) { - if (new_trans->length != 0) strcat(trans, ","); - if((realm[0] == '/') && trans[0]) strcat(trans, " "); + if (new_trans->length != 0) { + if (strlen(trans) + 2 >= MAX_REALM_LN) { + retval = KRB5KRB_AP_ERR_ILL_CR_TKT; + goto fail; + } + strcat(trans, ","); + } + if((realm[0] == '/') && trans[0]) { + if (strlen(trans) + 2 >= MAX_REALM_LN) { + retval = KRB5KRB_AP_ERR_ILL_CR_TKT; + goto fail; + } + strcat(trans, " "); + } + if (strlen(trans) + strlen(realm) + 1 >= MAX_REALM_LN) { + retval = KRB5KRB_AP_ERR_ILL_CR_TKT; + goto fail; + } strcat(trans, realm); new_trans->length = strlen(trans) + 1; } - return(0); + retval = 0; +fail: + free(realm); + free(otrans_ptr); + return (retval); } /* @@ -912,7 +1002,7 @@ krb5_data *data; { unsigned char *estream; /* end of stream */ int classes; /* # classes seen so far this level */ - int levels = 0; /* levels seen so far */ + unsigned int levels = 0; /* levels seen so far */ int lastlevel = 1000; /* last level seen */ int length; /* various lengths */ int tag; /* tag number */ @@ -1375,8 +1465,26 @@ get_salt_from_key(context, client, client_key, salt) return 0; } +/* + * Limit strings to a "reasonable" length to prevent crowding out of + * other useful information in the log entry + */ +#define NAME_LENGTH_LIMIT 128 - - - - +void limit_string(char *name) +{ + int i; + + if (!name) + return; + + if (strlen(name) < NAME_LENGTH_LIMIT) + return; + + i = NAME_LENGTH_LIMIT-4; + name[i++] = '.'; + name[i++] = '.'; + name[i++] = '.'; + name[i] = '\0'; + return; +} diff --git a/src/kdc/kdc_util.h b/src/kdc/kdc_util.h index b869f6f..c9e0d23 100644 --- a/src/kdc/kdc_util.h +++ b/src/kdc/kdc_util.h @@ -145,8 +145,10 @@ krb5_error_code return_padata krb5_key_data *client_key, krb5_keyblock *encrypting_key)); /* replay.c */ -krb5_boolean kdc_check_lookaside PROTOTYPE((krb5_data *, krb5_data **)); -void kdc_insert_lookaside PROTOTYPE((krb5_data *, krb5_data *)); +krb5_boolean kdc_check_lookaside PROTOTYPE((krb5_data *, krb5_fulladdr *, + krb5_data **)); +void kdc_insert_lookaside PROTOTYPE((krb5_data *, krb5_fulladdr *, + krb5_data *)); /* which way to convert key? */ #define CONVERT_INTO_DB 0 diff --git a/src/kdc/kerberos_v4.c b/src/kdc/kerberos_v4.c index db074d9..cea4bf0 100644 --- a/src/kdc/kerberos_v4.c +++ b/src/kdc/kerberos_v4.c @@ -82,6 +82,7 @@ char * v4_klog KRB5_PROTOTYPE((int, const char *, ...)); #else char * v4_klog KRB5_PROTOTYPE((int, char *, va_dcl)); #endif +#define klog v4_klog /* take this out when we don't need it anymore */ int krbONE = 1; @@ -104,7 +105,7 @@ static Principal a_name_data; /* for requesting user */ static Principal s_name_data; /* for services requested */ static C_Block session_key; -static char log_text[128]; +static char log_text[512]; static char *lt; static int more; @@ -190,6 +191,10 @@ krb5_data **resp; /* convert v5 packet structure to v5's. * this copy is gross, but necessary: */ + if (pkt->length > MAX_KTXT_LEN) { + (void) klog(L_KRB_PERR, "V4 request too long."); + return KRB5KRB_ERR_FIELD_TOOLONG; + } v4_pkt.length = pkt->length; memcpy( v4_pkt.dat, pkt->data, pkt->length); @@ -218,7 +223,6 @@ int type_2_v5err[] = { 0, /* 0 No error */ KRB_AP_ERR_BADVERSION /* L_KRB_PWARN 16 Protocol warning messages */ }; #endif -#define klog v4_klog #ifdef HAVE_STDARG_H char * v4_klog( int type, const char *format, ...) #else @@ -448,6 +452,21 @@ kerb_get_principal(name, inst, principal, maxn, more) *more = (int) more5 || (nprinc > maxn); return( nprinc); } + +static void str_length_check(str, max_size) + char *str; + int max_size; +{ + int i; + char *cp; + + for (i=0, cp = str; i < max_size-1; i++, cp++) { + if (*cp == 0) + return; + } + *cp = 0; +} + void kerberos_v4(client, pkt) struct sockaddr_in *client; @@ -528,8 +547,11 @@ kerberos_v4(client, pkt) /* set up and correct for byte order and alignment */ req_name_ptr = (char *) pkt_a_name(pkt); + str_length_check(req_name_ptr, ANAME_SZ); req_inst_ptr = (char *) pkt_a_inst(pkt); + str_length_check(req_inst_ptr, INST_SZ); req_realm_ptr = (char *) pkt_a_realm(pkt); + str_length_check(req_realm_ptr, REALM_SZ); memcpy(&req_time_ws, pkt_time_ws(pkt), sizeof(req_time_ws)); /* time has to be diddled */ if (swap_bytes) { @@ -540,7 +562,9 @@ kerberos_v4(client, pkt) req_life = (u_long) (*ptr++); service = ptr; + str_length_check(service, SNAME_SZ); instance = ptr + strlen(service) + 1; + str_length_check(instance, INST_SZ); rpkt = &rpkt_st; @@ -672,7 +696,9 @@ kerberos_v4(client, pkt) req_life = (u_long) (*ptr++); service = ptr; + str_length_check(service, SNAME_SZ); instance = ptr + strlen(service) + 1; + str_length_check(instance, INST_SZ); klog(L_APPL_REQ, "APPL Request %s.%s@%s on %s for %s.%s", ad->pname, ad->pinst, ad->prealm, @@ -872,7 +898,7 @@ static char *krb4_stime(t) adjusted_time = *t /* - CONVERT_TIME_EPOCH */; tm = localtime(&adjusted_time); - (void) sprintf(st,"%2d-%s-%02d %02d:%02d:%02d",tm->tm_mday, + (void) sprintf(st,"%4d-%s-%02d %02d:%02d:%02d",tm->tm_mday+1900, month_sname(tm->tm_mon + 1),tm->tm_year, tm->tm_hour, tm->tm_min, tm->tm_sec); return st; diff --git a/src/kdc/main.c b/src/kdc/main.c index dd4ae76..2dff8fc 100644 --- a/src/kdc/main.c +++ b/src/kdc/main.c @@ -721,7 +721,9 @@ initialize_realms(kcontext, argc, argv) hierarchy[2] = (char *) NULL; if (krb5_aprof_get_string(aprof, hierarchy, TRUE, &default_ports)) default_ports = 0; - krb5_aprof_finish(aprof); + /* aprof_init can return 0 with aprof == NULL */ + if (aprof) + krb5_aprof_finish(aprof); } if (default_ports == 0) default_ports = strdup(DEFAULT_KDC_PORTLIST); @@ -803,6 +805,7 @@ initialize_realms(kcontext, argc, argv) } } +#ifdef USE_RCACHE /* * Now handle the replay cache. */ @@ -810,6 +813,7 @@ initialize_realms(kcontext, argc, argv) com_err(argv[0], retval, "while initializing KDC replay cache"); exit(1); } +#endif /* Ensure that this is set for our first request. */ kdc_active_realm = kdc_realmlist[0]; diff --git a/src/kdc/replay.c b/src/kdc/replay.c index 1ec38a3..ffd14fe 100644 --- a/src/kdc/replay.c +++ b/src/kdc/replay.c @@ -36,6 +36,7 @@ typedef struct _krb5_kdc_replay_ent { time_t db_age; krb5_data *req_packet; krb5_data *reply_packet; + krb5_address *addr; /* XXX should these not be pointers? */ } krb5_kdc_replay_ent; static krb5_kdc_replay_ent root_ptr = {0}; @@ -46,13 +47,16 @@ static int max_hits_per_entry = 0; static int num_entries = 0; #define STALE_TIME 2*60 /* two minutes */ -#define STALE(ptr) ((abs((ptr)->timein - timenow) >= STALE_TIME) || \ +#define STALE(ptr) ((abs((ptr)->timein - timenow) >= STALE_TIME) || \ ((ptr)->db_age != db_age)) -#define MATCH(ptr) (((ptr)->req_packet->length == inpkt->length) && \ - !memcmp((ptr)->req_packet->data, inpkt->data, inpkt->length) && \ +#define MATCH(ptr) (((ptr)->req_packet->length == inpkt->length) && \ + !memcmp((ptr)->req_packet->data, inpkt->data, \ + inpkt->length) && \ + ((ptr)->addr->length == from->address->length) && \ + !memcmp((ptr)->addr->contents, from->address, \ + from->address->length)&& \ ((ptr)->db_age == db_age)) - /* XXX Todo: quench the size of the queue... */ @@ -61,9 +65,10 @@ static int num_entries = 0; FALSE if the caller should do the work */ krb5_boolean -kdc_check_lookaside(inpkt, outpkt) -register krb5_data *inpkt; -register krb5_data **outpkt; +kdc_check_lookaside(inpkt, from, outpkt) + register krb5_data *inpkt; + register krb5_fulladdr *from; + register krb5_data **outpkt; { krb5_int32 timenow; register krb5_kdc_replay_ent *eptr, *last, *hold; @@ -71,7 +76,7 @@ register krb5_data **outpkt; if (krb5_timeofday(kdc_context, &timenow) || krb5_db_get_age(kdc_context, 0, &db_age)) - return FALSE; + return FALSE; calls++; @@ -98,6 +103,7 @@ register krb5_data **outpkt; max_hits_per_entry = max(max_hits_per_entry, eptr->num_hits); krb5_free_data(kdc_context, eptr->req_packet); krb5_free_data(kdc_context, eptr->reply_packet); + krb5_free_address(kdc_context, eptr->addr); hold = eptr; last->next = eptr->next; eptr = last; @@ -115,9 +121,10 @@ register krb5_data **outpkt; already there, and can fail softly due to other weird errors. */ void -kdc_insert_lookaside(inpkt, outpkt) -register krb5_data *inpkt; -register krb5_data *outpkt; +kdc_insert_lookaside(inpkt, from, outpkt) + register krb5_data *inpkt; + register krb5_fulladdr *from; + register krb5_data *outpkt; { register krb5_kdc_replay_ent *eptr; krb5_int32 timenow; @@ -125,7 +132,7 @@ register krb5_data *outpkt; if (krb5_timeofday(kdc_context, &timenow) || krb5_db_get_age(kdc_context, 0, &db_age)) - return; + return; /* this is a new entry */ eptr = (krb5_kdc_replay_ent *)calloc(1, sizeof(*eptr)); @@ -133,6 +140,11 @@ register krb5_data *outpkt; return; eptr->timein = timenow; eptr->db_age = db_age; + /* + * This is going to hurt a lot malloc()-wise due to the need to + * allocate memory for the krb5_data and krb5_address elements. + * ARGH! + */ if (krb5_copy_data(kdc_context, inpkt, &eptr->req_packet)) { krb5_xfree(eptr); return; @@ -142,6 +154,12 @@ register krb5_data *outpkt; krb5_xfree(eptr); return; } + if (krb5_copy_addr(kdc_context, from->address, &eptr->addr)) { + krb5_free_data(kdc_context, eptr->req_packet); + krb5_free_data(kdc_context, eptr->reply_packet); + free(eptr); + return; + } eptr->next = root_ptr.next; root_ptr.next = eptr; num_entries++; diff --git a/src/krb524/ChangeLog b/src/krb524/ChangeLog index dbc3c84..7f5856d 100644 --- a/src/krb524/ChangeLog +++ b/src/krb524/ChangeLog @@ -1,3 +1,14 @@ +Thu Dec 5 23:27:00 1996 Tom Yu + + * krb524d.c (main): Ignore SIGHUP for now. [27] + +Thu Dec 5 23:12:29 1996 Theodore Y. Ts'o + + * cnv_tkt_skey.c (krb524_convert_tkt_skey): Change the issue time + of the V4 ticket to be the current time (since the + lifetime of the V4 ticket was calculated assuming that the + issue time would be the current time). [PR#283,PR#22] + Mon Nov 11 16:23:32 1996 Mark Eichin * krb524d.c (do_connection): only free v4/v5 keyblock contents and diff --git a/src/krb524/cnv_tkt_skey.c b/src/krb524/cnv_tkt_skey.c index a7d5e54..19bb386 100644 --- a/src/krb524/cnv_tkt_skey.c +++ b/src/krb524/cnv_tkt_skey.c @@ -161,7 +161,7 @@ int krb524_convert_tkt_skey(context, v5tkt, v4tkt, v5_skey, v4_skey) (char *) v5etkt->session->contents, lifetime, /* issue_data */ - v5etkt->times.starttime, + server_time, sname, sinst, v4_skey->contents); diff --git a/src/krb524/krb524d.c b/src/krb524/krb524d.c index 2c4d3f8..7d6e9ba 100644 --- a/src/krb524/krb524d.c +++ b/src/krb524/krb524d.c @@ -119,7 +119,7 @@ int main(argc, argv) } signal(SIGINT, request_exit); - signal(SIGHUP, request_exit); + signal(SIGHUP, SIG_IGN); signal(SIGTERM, request_exit); if (use_keytab) diff --git a/src/lib/ChangeLog b/src/lib/ChangeLog index c7e7fb6..791ed2b 100644 --- a/src/lib/ChangeLog +++ b/src/lib/ChangeLog @@ -1,3 +1,15 @@ +Sat Nov 23 00:25:25 1996 Theodore Ts'o + + * libkrb5.def: Renamed to krb5_16.def [PR#204] + + * Makefile.in (all-windows): Change name of dll from krb5_16.dll, + which will be the final name of the DLL. [PR#204] + +Wed Nov 20 18:28:47 1996 Theodore Y. Ts'o + + * Makefile.in (clean-windows): Change the name of the Windows (16) + dll to be krb516.dll, instead of libkrb5.dll + Fri Jul 12 20:32:29 1996 Theodore Y. Ts'o * win_glue.c: Added TIMEBOMB_INFO string which tells the user the diff --git a/src/lib/Makefile.in b/src/lib/Makefile.in index f0eaef8..b8cd398 100644 --- a/src/lib/Makefile.in +++ b/src/lib/Makefile.in @@ -19,10 +19,10 @@ clean-unix:: $(RM) $(CLEANLIBS) clean-windows:: - $(RM) libkrb5.dll libkrb5.lib libkrb5.bak libkrb5.map winsock.lib + $(RM) krb5_16.dll krb5_16.lib krb5_16.bak krb5_16.map winsock.lib $(RM) gssapi.dll gssapi.lib gssapi.bak gssapi.map # -# Windows stuff to make libkrb5.dll and libkrb5.lib. Currently it +# Windows stuff to make krb5_16.dll and krb5_16.lib. Currently it # combines crypto, krb5, kadm and the util/et directories. # ALIB = kadm\kadm.lib @@ -34,7 +34,7 @@ PLIB = $(BUILDTOP)\util\profile\profile.lib WLIB = .\winsock.lib LIBS = $(ALIB) $(CLIB) $(KLIB) $(GLIB) $(ETLIB) $(PLIB) $(WLIB) -lib-windows: winsock.lib libkrb5.lib gssapi.lib +lib-windows: winsock.lib krb5_16.lib gssapi.lib gssapi.lib:: gssapi.dll implib /nologo gssapi.lib gssapi.dll @@ -44,13 +44,13 @@ gssapi.dll:: $(GLIB) $(LIBS) gssapi.def win_glue.obj $(LIBS) ldllcew libw oldnames, gssapi.def rc /nologo /p /k gssapi.dll -libkrb5.lib:: libkrb5.dll - implib /nologo libkrb5.lib libkrb5.dll +krb5_16.lib:: krb5_16.dll + implib /nologo krb5_16.lib krb5_16.dll -libkrb5.dll:: $(LIBS) libkrb5.def win_glue.obj - link /co /seg:400 /noe /nod /nol win_glue, libkrb5.dll, libkrb5.map, \ - $(LIBS) ldllcew libw oldnames, libkrb5.def - rc /nologo /p /k libkrb5.dll +krb5_16.dll:: $(LIBS) krb5_16.def win_glue.obj + link /co /seg:400 /noe /nod /nol win_glue, krb5_16.dll, krb5_16.map, \ + $(LIBS) ldllcew libw oldnames, krb5_16.def + rc /nologo /p /k krb5_16.dll sap_glue.obj: win_glue.c $(CC) $(CFLAGS) -DSAP_TIMEBOMB -I$(VERS_DIR) /c \ @@ -83,7 +83,7 @@ all-windows:: @echo Making in lib cd .. -all-windows:: libkrb5.lib gssapi.lib +all-windows:: krb5_16.lib gssapi.lib clean-windows:: @echo Making clean in lib\crypto diff --git a/src/lib/crypto/ChangeLog b/src/lib/crypto/ChangeLog index 6803199..ecdb1d4 100644 --- a/src/lib/crypto/ChangeLog +++ b/src/lib/crypto/ChangeLog @@ -1,3 +1,17 @@ +Sat Nov 23 00:22:20 1996 Theodore Ts'o + + * cryptoconf.c: Also zero out the entries in cryptoconf, to make + sure no one tries to use triple DES and SHA. + +Fri Nov 22 20:49:13 1996 Theodore Ts'o + + * configure.in (enableval): Disable triple DES and SHA, since + what's there isn't the final triple DES. [PR#231] + +Mon Nov 18 20:38:24 1996 Ezra Peisach + [krb5-libs/201] + * configure.in: Set shared library version to 1.0. + Thu Jun 6 00:04:38 1996 Theodore Y. Ts'o * Makefile.in (all-windows): Don't pass $(LIBCMD) on the command diff --git a/src/lib/crypto/configure.in b/src/lib/crypto/configure.in index 9e04510..53f9fcc 100644 --- a/src/lib/crypto/configure.in +++ b/src/lib/crypto/configure.in @@ -19,17 +19,17 @@ if test "$enableval" = yes; then else AC_MSG_RESULT(Disabling DES_CBC_MD5) fi -AC_ARG_ENABLE([des3-cbc-sha], -[ --enable-des3-cbc-sha enable DES3_CBC_SHA (DEFAULT). - --disable-des3-cbc-sha disable DES3_CBC_SHA.], -, -enableval=yes)dnl -if test "$enableval" = yes; then - AC_MSG_RESULT(Enabling DES3_CBC_SHA) - AC_DEFINE(PROVIDE_DES3_CBC_SHA) -else - AC_MSG_RESULT(Disabling DES3_CBC_SHA) -fi +dnl AC_ARG_ENABLE([des3-cbc-sha], +dnl [ --enable-des3-cbc-sha enable DES3_CBC_SHA (DEFAULT). +dnl --disable-des3-cbc-sha disable DES3_CBC_SHA.], +dnl , +dnl enableval=yes)dnl +dnl if test "$enableval" = yes; then +dnl AC_MSG_RESULT(Enabling DES3_CBC_SHA) +dnl AC_DEFINE(PROVIDE_DES3_CBC_SHA) +dnl else +dnl AC_MSG_RESULT(Disabling DES3_CBC_SHA) +dnl fi AC_ARG_WITH([des-cbc-crc], [ --enable-des-cbc-crc enable DES_CBC_CRC (DEFAULT). --disable-des-cbc-crc disable DES_CBC_CRC.], @@ -52,17 +52,17 @@ if test "$enableval" = yes; then else AC_MSG_RESULT(Disabling DES_CBC_RAW) fi -AC_ARG_WITH([des3-cbc-raw], -[ --enable-des3-cbc-raw enable DES3_CBC_RAW (DEFAULT). - --disable-des3-cbc-raw disable DES3_CBC_RAW.], -, -enableval=yes)dnl -if test "$enableval" = yes; then - AC_MSG_RESULT(Enabling DES3_CBC_RAW) - AC_DEFINE(PROVIDE_DES3_CBC_RAW) -else - AC_MSG_RESULT(Disabling DES3_CBC_RAW) -fi +dnl AC_ARG_WITH([des3-cbc-raw], +dnl [ --enable-des3-cbc-raw enable DES3_CBC_RAW (DEFAULT). +dnl --disable-des3-cbc-raw disable DES3_CBC_RAW.], +dnl , +dnl enableval=yes)dnl +dnl if test "$enableval" = yes; then +dnl AC_MSG_RESULT(Enabling DES3_CBC_RAW) +dnl AC_DEFINE(PROVIDE_DES3_CBC_RAW) +dnl else +dnl AC_MSG_RESULT(Disabling DES3_CBC_RAW) +dnl fi AC_ARG_WITH([des-cbc-cksum], [ --enable-des-cbc-cksum enable DES_CBC_CKSUM (DEFAULT). --disable-des-cbc-cksum disable DES_CBC_CKSUM.], @@ -107,20 +107,20 @@ if test "$enableval" = yes; then else AC_MSG_RESULT(Disabling RSA_MD5) fi -AC_ARG_WITH([nist-sha], -[ --enable-nist-sha enable NIST_SHA (DEFAULT). - --disable-nist-sha disable NIST_SHA.], -, -enableval=yes)dnl -if test "$enableval" = yes; then - AC_MSG_RESULT(Enabling NIST_SHA) - AC_DEFINE(PROVIDE_NIST_SHA) -else - AC_MSG_RESULT(Disabling NIST_SHA) -fi +dnl AC_ARG_WITH([nist-sha], +dnl [ --enable-nist-sha enable NIST_SHA (DEFAULT). +dnl --disable-nist-sha disable NIST_SHA.], +dnl , +dnl enableval=yes)dnl +dnl if test "$enableval" = yes; then +dnl AC_MSG_RESULT(Enabling NIST_SHA) +dnl AC_DEFINE(PROVIDE_NIST_SHA) +dnl else +dnl AC_MSG_RESULT(Disabling NIST_SHA) +dnl fi V5_SHARED_LIB_OBJS SubdirLibraryRule([${OBJS}]) DO_SUBDIRS -V5_MAKE_SHARED_LIB(libcrypto,0.1,.., ./crypto) +V5_MAKE_SHARED_LIB(libcrypto,1.0,.., ./crypto) V5_AC_OUTPUT_MAKEFILE diff --git a/src/lib/crypto/cryptoconf.c b/src/lib/crypto/cryptoconf.c index 768c6cf..62be745 100644 --- a/src/lib/crypto/cryptoconf.c +++ b/src/lib/crypto/cryptoconf.c @@ -53,8 +53,10 @@ #ifdef PROVIDE_NIST_SHA #include "shs.h" -#define SHA_CKENTRY &nist_sha_cksumtable_entry -#define HMAC_SHA_CKENTRY &hmac_sha_cksumtable_entry +/* #define SHA_CKENTRY &nist_sha_cksumtable_entry */ +/* #define HMAC_SHA_CKENTRY &hmac_sha_cksumtable_entry */ +#define SHA_CKENTRY 0 +#define HMAC_SHA_CKENTRY 0 #else #define SHA_CKENTRY 0 #define HMAC_SHA_CKENTRY 0 @@ -109,7 +111,11 @@ #include "des_int.h" #define _DES_DONE__ #endif -#define DES3_CBC_SHA_CSENTRY &krb5_des3_sha_cst_entry +/* Don't try to enable triple DES unless you know what you are doing; */ +/* the current implementation of triple DES is NOT the final and */ +/* correct implementation.!!! */ +/* #define DES3_CBC_SHA_CSENTRY &krb5_des3_sha_cst_entry */ +#define DES3_CBC_SHA_CSENTRY 0 #else #define DES3_CBC_SHA_CSENTRY 0 #endif @@ -119,7 +125,8 @@ #include "des_int.h" #define _DES_DONE__ #endif -#define DES3_CBC_RAW_CSENTRY &krb5_des3_raw_cst_entry +/* #define DES3_CBC_RAW_CSENTRY &krb5_des3_raw_cst_entry */ +#define DES3_CBC_RAW_CSENTRY 0 #else #define DES3_CBC_RAW_CSENTRY 0 #endif diff --git a/src/lib/des425/ChangeLog b/src/lib/des425/ChangeLog index c0c8faa..8b1457e 100644 --- a/src/lib/des425/ChangeLog +++ b/src/lib/des425/ChangeLog @@ -1,3 +1,7 @@ +Mon Nov 18 20:39:02 1996 Ezra Peisach + + * configure.in: Set shared library version to 1.0. [krb5-libs/201] + Wed Aug 7 12:50:36 1996 Ezra Peisach * new_rnd_key.c (des_set_sequence_number): Change cast to diff --git a/src/lib/des425/configure.in b/src/lib/des425/configure.in index 08126b0..07072c9 100644 --- a/src/lib/des425/configure.in +++ b/src/lib/des425/configure.in @@ -29,5 +29,5 @@ AC_SUBST(CRYPTO_SH_VERS) KRB5_SH_VERS=$krb5_cv_shlib_version_libkrb5 AC_SUBST(KRB5_SH_VERS) KRB5_RUN_FLAGS -V5_MAKE_SHARED_LIB(libdes425,0.1,.., ./des425) +V5_MAKE_SHARED_LIB(libdes425,1.0,.., ./des425) V5_AC_OUTPUT_MAKEFILE diff --git a/src/lib/gssapi/ChangeLog b/src/lib/gssapi/ChangeLog index 505b5d3..b29cc37 100644 --- a/src/lib/gssapi/ChangeLog +++ b/src/lib/gssapi/ChangeLog @@ -1,3 +1,7 @@ +Mon Nov 18 20:39:41 1996 Ezra Peisach + + * configure.in: Set shared library version to 1.0. [krb5-libs/201] + Tue Jul 23 22:50:22 1996 Theodore Y. Ts'o * Makefile.in (MAC_SUBDIRS): Remove mechglue from the list of diff --git a/src/lib/gssapi/configure.in b/src/lib/gssapi/configure.in index 164582c..f2bb704 100644 --- a/src/lib/gssapi/configure.in +++ b/src/lib/gssapi/configure.in @@ -7,7 +7,7 @@ AC_PROG_ARCHIVE_ADD AC_PROG_RANLIB AC_PROG_INSTALL DO_SUBDIRS -V5_MAKE_SHARED_LIB(libgssapi_krb5,0.1,.., ./gssapi) +V5_MAKE_SHARED_LIB(libgssapi_krb5,1.0,.., ./gssapi) CRYPTO_SH_VERS=$krb5_cv_shlib_version_libcrypto AC_SUBST(CRYPTO_SH_VERS) COMERR_SH_VERS=$krb5_cv_shlib_version_libcom_err diff --git a/src/lib/gssapi/generic/ChangeLog b/src/lib/gssapi/generic/ChangeLog index 9934708..b299518 100644 --- a/src/lib/gssapi/generic/ChangeLog +++ b/src/lib/gssapi/generic/ChangeLog @@ -1,3 +1,53 @@ +Sun May 24 22:01:29 1998 Theodore Y. Ts'o + + * util_buffer.c (g_make_string_buffer): Don't include the trailing + NULL of the string in the gss buffer's length. + +1998-05-18 Theodore Ts'o + + * util_ordering.c (g_order_free): + * rel_oid_set.c (generic_gss_release_oid_set): + * disp_major_status.c: General lint cleanup. + + * util_oid.c (g_copy_OID_set): Copy the OID set with entirely + dynamic memory (don't alias the contents of the OID set). + +Wed Apr 1 16:33:27 1998 Tom Yu + + * disp_major_status.c (g_display_major_status): Fix a typo in + previous. + +1998-03-31 Theodore Ts'o + + * disp_major_status.c (display_unknown): Change to not return + GSS_S_CONTINUE_NEEDED, per the standard C bindings + specification. + +Tue Jul 29 22:54:40 1997 Theodore Y. Ts'o + + * gssapi_generic.c: Add support for the new OID value for + host-based service name. + +Fri Mar 28 03:43:58 1997 Theodore Y. Ts'o + + * gssapi_generic.c, gssapi_generic.h: Added definition for the + generic gsspi OID type "gss_nt_exported_name". + +Thu Mar 27 15:36:32 1997 Theodore Ts'o + + * gssapi.hin: Add the GSS_C_PROT_READY_FLAG and GSS_C_TRANS_FLAG + Add prototypes for the V2 functions gss_export_name(), + gss_duplicate_name(), and gss_canonicalize_name(). + +Wed Nov 20 13:59:58 1996 Ezra Peisach + + * Makefile.in (install): Install gssapi.h from the build tree. + +Tue Nov 19 16:43:16 1996 Tom Yu + + * Makefile.in (gssapi.h): grep USE_.*_H out from autoconf.h as + well (some stuff was depending on USE_STRING_H). + Mon Nov 18 12:38:34 1996 Tom Yu *gssapi.h: Renamed to gssapi.hin. diff --git a/src/lib/gssapi/generic/Makefile.in b/src/lib/gssapi/generic/Makefile.in index 1e1aa7e..87b414f 100644 --- a/src/lib/gssapi/generic/Makefile.in +++ b/src/lib/gssapi/generic/Makefile.in @@ -37,6 +37,7 @@ gssapi.h: gssapi.hin echo "/* It contains some choice pieces of autoconf.h */" >> $@ grep SIZEOF $(BUILDTOP)/include/krb5/autoconf.h >> $@ grep 'HAVE_.*_H' $(BUILDTOP)/include/krb5/autoconf.h >> $@ + grep 'USE_.*_H' $(BUILDTOP)/include/krb5/autoconf.h >> $@ echo "/* End of gssapi.h prologue. */" cat $(srcdir)/gssapi.hin >> $@ @@ -84,7 +85,8 @@ OBJS = \ $(OBJS): $(HDRS) $(ETHDRS) -EXPORTED_HEADERS= gssapi.h gssapi_generic.h +EXPORTED_HEADERS= gssapi_generic.h +EXPORTED_BUILT_HEADERS= gssapi.h all-unix:: shared $(SRCS) $(ETHDRS) $(OBJS) @@ -116,5 +118,9 @@ install:: do $(INSTALL_DATA) $(srcdir)/$$f \ $(DESTDIR)$(KRB5_INCDIR)/gssapi/$$f ; \ done + @set -x; for f in $(EXPORTED_BUILT_HEADERS) ; \ + do $(INSTALL_DATA) $$f \ + $(DESTDIR)$(KRB5_INCDIR)/gssapi/$$f ; \ + done depend:: $(ETSRCS) diff --git a/src/lib/gssapi/generic/disp_major_status.c b/src/lib/gssapi/generic/disp_major_status.c index 4dd91d2..e2df893 100644 --- a/src/lib/gssapi/generic/disp_major_status.c +++ b/src/lib/gssapi/generic/disp_major_status.c @@ -22,6 +22,7 @@ #include "gssapiP_generic.h" #include +#include /* * $Id$ @@ -120,7 +121,7 @@ int display_unknown(kind, value, buffer) sprintf(str, unknown_error, kind, value); - buffer->length = len; + buffer->length = strlen(str); buffer->value = str; return(1); @@ -135,7 +136,7 @@ static OM_uint32 display_calling(minor_status, code, status_string) { const char *str; - if (str = GSS_CALLING_ERROR_STR(code)) { + if ((str = GSS_CALLING_ERROR_STR(code))) { if (! g_make_string_buffer(str, status_string)) { *minor_status = ENOMEM; return(GSS_S_FAILURE); @@ -160,7 +161,7 @@ static OM_uint32 display_routine(minor_status, code, status_string) { const char *str; - if (str = GSS_ROUTINE_ERROR_STR(code)) { + if ((str = GSS_ROUTINE_ERROR_STR(code))) { if (! g_make_string_buffer(str, status_string)) { *minor_status = ENOMEM; return(GSS_S_FAILURE); @@ -185,7 +186,7 @@ static OM_uint32 display_bit(minor_status, code, status_string) { const char *str; - if (str = GSS_SINFO_STR(code)) { + if ((str = GSS_SINFO_STR(code))) { if (! g_make_string_buffer(str, status_string)) { *minor_status = ENOMEM; return(GSS_S_FAILURE); @@ -234,14 +235,14 @@ OM_uint32 g_display_major_status(minor_status, status_value, /*** do routine error */ if (*message_context == 0) { - if (tmp = GSS_ROUTINE_ERROR(status_value)) { + if ((tmp = GSS_ROUTINE_ERROR(status_value))) { status_value -= tmp; - if (ret = display_routine(minor_status, tmp, status_string)) + if ((ret = display_routine(minor_status, tmp, status_string))) return(ret); *minor_status = 0; if (status_value) { (*message_context)++; - return(GSS_S_CONTINUE_NEEDED); + return(GSS_S_COMPLETE); } else { *message_context = 0; return(GSS_S_COMPLETE); @@ -256,14 +257,14 @@ OM_uint32 g_display_major_status(minor_status, status_value, /*** do calling error */ if (*message_context == 1) { - if (tmp = GSS_CALLING_ERROR(status_value)) { + if ((tmp = GSS_CALLING_ERROR(status_value))) { status_value -= tmp; - if (ret = display_calling(minor_status, tmp, status_string)) + if ((ret = display_calling(minor_status, tmp, status_string))) return(ret); *minor_status = 0; if (status_value) { (*message_context)++; - return(GSS_S_CONTINUE_NEEDED); + return(GSS_S_COMPLETE); } else { *message_context = 0; return(GSS_S_COMPLETE); @@ -295,7 +296,7 @@ OM_uint32 g_display_major_status(minor_status, status_value, for (bit=0; (((OM_uint32) 1)<length = strlen(str)+1; + buffer->length = strlen(str); - if ((buffer->value = (void *) xmalloc(buffer->length)) == NULL) { + if ((buffer->value = (void *) xmalloc(buffer->length+1)) == NULL) { buffer->length = 0; return(0); } diff --git a/src/lib/gssapi/generic/util_oid.c b/src/lib/gssapi/generic/util_oid.c index 8843a7f..f908a1d 100644 --- a/src/lib/gssapi/generic/util_oid.c +++ b/src/lib/gssapi/generic/util_oid.c @@ -32,7 +32,9 @@ g_copy_OID_set(in, out) gss_OID_set *out; { gss_OID_set copy; - size_t i; + gss_OID new_oid; + size_t i; + size_t len; *out = NULL; @@ -41,15 +43,34 @@ g_copy_OID_set(in, out) return(0); copy->count = in->count; + len = sizeof(gss_OID_desc) * copy->count; if ((copy->elements = - (gss_OID_desc *) xmalloc(sizeof(gss_OID_desc)*copy->count)) == NULL) { + (gss_OID_desc *) xmalloc( len )) == NULL) { xfree(copy); return(0); } - for (i=0; icount; i++) - copy->elements[i] = in->elements[i]; + memset( copy->elements, 0, len ); + + for (i=0; icount; i++) { + len = in->elements[i].length; + new_oid = &(copy->elements[i]); + new_oid->elements = xmalloc( len ); + if ( new_oid->elements == NULL ) { + while( i>0 ) { + i--; + new_oid = &(copy->elements[i]); + if ( new_oid->elements!=NULL ) + xfree( new_oid->elements ); + } + xfree( copy->elements ); + xfree( copy ); + return( 0 ); + } + memcpy( new_oid->elements, in->elements[i].elements, len ); + new_oid->length = len; + } *out = copy; return(1); diff --git a/src/lib/gssapi/krb5/ChangeLog b/src/lib/gssapi/krb5/ChangeLog index fb51f0d..5d138b0 100644 --- a/src/lib/gssapi/krb5/ChangeLog +++ b/src/lib/gssapi/krb5/ChangeLog @@ -1,3 +1,148 @@ +Fri Apr 23 00:31:17 1999 Theodore Y. Ts'o + + * wrap_size_limit.c (krb5_gss_wrap_size_limit): Fix wrap_size + limit so that it correctly calculates its results, and + underestimates the correct size instead of overestimating + it, and not returning zero all the time. (Which it used + to do after the March 25 fix.) + +Fri Mar 26 22:17:20 1999 Theodore Y. Ts'o + + * acquire_cred.c (krb5_gss_acquire_cred): Don't use strcmp to + compare against principal components (they aren't null + terminated!) + +Thu Mar 25 22:43:54 1999 Theodore Y. Ts'o + + * gssapi_krb5.c: Rearrange OID's so that the V1V2 mechanism set + returns all three mechanism ID's recognized by this + implementation, with the RFC1964 OID first (and thus + preferred). + + * import_sec_context.c (krb5_gss_convert_static_mech_oid): Make + the old convert_static_oid() function globally accessible + with a namespace compliant name, since init_sec_context() + needs to be able to use this function. + + * indicate_mechs.c (krb5_gss_indicate_mechs): Return the both + mechanism set OID, since we should return all the + mechanisms that we support. + + * init_sec_context.c (krb5_gss_init_sec_context): Make + ctx->mech_used use a static OID, since it is returned by + gss_inquire_context which must return a static OID. + + * wrap_size_limit.c (krb5_gss_wrap_size_limit): Fix bug where we + would overestimate the size of the allowable input message + by one byte, because we weren't passing the right estimate + of the wrapped data to g_token_size(). + +1998-06-08 Theodore Ts'o + + * gssapi_krb5.c, gssapi_krb5.h: Export the oid of static + arrays as krb5_gss_oid_array since it's needed by + gss_import_sec_context. + + * import_sec_context.c: Fix up the OID of the mechanism in the + imported security context so that we use the static + OID if at all possible. This is needed since + gss_inquire_context() must return a static OID. + +Tue Jul 29 22:56:04 1997 Theodore Y. Ts'o + + * inq_names.c (krb5_gss_inquire_names_for_mech): Add the + the new OID value for the host-based service name and + the exported name OID to the list of OID's supported by + this mechanism. + + * import_name.c (krb5_gss_import_name): Add support for the new + OID value for the host-based service name. + +Mon Mar 31 21:22:19 1997 Theodore Y. Ts'o + + * krb5_gss_glue.c: Add GSSAPI V2 calls to the glue layer. + +Fri Mar 28 03:52:14 1997 Theodore Y. Ts'o + + * import_name.c (krb5_gss_import_name): Add support for importing + the exported name call + +Thu Mar 27 15:52:04 1997 Theodore Ts'o + + * Makefile.in: Add canon_name.c, duplicate_name.c, export_name.c + to the GSSAPI library. + + * canon_name.c (krb5_gss_canonicalize_name): New GSSAPI V2 function + + * duplicate_name.c (krb5_gss_duplicate_name): New GSSAPI V2 function + + * export_name.c (krb5_gss_export_name): New GSSAPI V2 function + + * gssapiP_krb5.h (KG_IMPLFLAGS): Add support for + GSS_C_PROT_STATE_READY and GSS_C_TRANS_FLAG + +Fri Jul 24 21:13:53 1998 Tom Yu + + * wrap_size_limit.c (krb5_gss_wrap_size_limit): Fix to round down + by 8 even if the req_output_size-ohlen is a multiple of 8, since + the wrap token is always padded regardless of whether it's a + mutiple of 8 bytes. + +Thu Feb 5 22:39:44 1998 Theodore Y. Ts'o + + * wrap_size_limit.c (krb5_gss_wrap_size_limit): Fix bug where if + the output header size is greater than the maximum + requested output size, return 0 rather than a very large + unsigned number. :-) + +Wed Jan 21 19:14:09 1998 Tom Yu + + * gssapiP_krb5.h: Add rcache member to the creds + structure. [krb5-libs/370] + + * accept_sec_context.c (krb5_gss_accept_sec_context): Actually set + an rcache in auth context from the one saved in the creds + structure. [krb5-libs/370] + + * acquire_cred.c (acquire_accept_cred): Set up an rcache for use + later. [krb5-libs/370] + + * delete_sec_context.c (krb5_gss_delete_sec_context): Don't delete + the rcache when freeing the auth_context. [krb5-libs/370] + + * rel_cred.c (krb5_gss_release_cred): Properly close the + rcache. [krb5-libs/370] + +Tue Mar 25 01:00:55 1997 Theodore Y. Ts'o + + * init_sec_context.c (krb5_gss_init_sec_context): A zero-length + token should be treated like a GSS_C_NO_BUFFER during the + initial context establishment. [krb5-libs/352] + +Wed Nov 20 19:55:29 1996 Marc Horowitz + + * init_sec_context.c (make_ap_rep, krb5_gss_init_sec_context), + accept_sec_context.c (krb5_gss_accept_sec_context): fix up use of + gss flags. under some circumstances, the context would not have + checked for replay or sequencing, even if those features were + requested. + + * init_sec_context.c (make_ap_req), (krb5_gss_init_sec_context): + If delegation is requested, but forwarding the credentials fails, + instead of aborting the context setup, just don't forward + credentials. + + * gssapiP_krb5.h (krb5_gss_ctx_id_t), ser_sctx.c + (kg_ctx_externalize, kg_ctx_internalize), init_sec_context.c + (krb5_gss_init_sec_context), get_tkt_flags.c + (gss_krb5_get_tkt_flags), accept_sec_context.c + (krb5_gss_accept_sec_context): rename ctx->flags to + ctx->krb_flags, to disambiguate it from ctx->gss_flags + + * accept_sec_context.c (krb5_gss_accept_sec_context): If the subkey + isn't present in the authenticator, then use the session key + instead. + Sat Oct 19 00:38:22 1996 Theodore Y. Ts'o * ser_sctx.c (kg_oid_externalize, kg_oid_internalize, diff --git a/src/lib/gssapi/krb5/Makefile.in b/src/lib/gssapi/krb5/Makefile.in index d48db02..f5ffdd0 100644 --- a/src/lib/gssapi/krb5/Makefile.in +++ b/src/lib/gssapi/krb5/Makefile.in @@ -33,11 +33,14 @@ gssapi_err_krb5.c: gssapi_err_krb5.et SRCS = \ $(srcdir)/accept_sec_context.c \ $(srcdir)/acquire_cred.c \ + $(srcdir)/canon_name.c \ $(srcdir)/compare_name.c \ $(srcdir)/context_time.c \ $(srcdir)/delete_sec_context.c \ $(srcdir)/disp_name.c \ $(srcdir)/disp_status.c \ + $(srcdir)/duplicate_name.c \ + $(srcdir)/export_name.c \ $(srcdir)/export_sec_context.c \ $(srcdir)/get_tkt_flags.c \ $(srcdir)/gssapi_krb5.c \ @@ -73,11 +76,14 @@ SRCS = \ OBJS = \ accept_sec_context.$(OBJEXT) \ acquire_cred.$(OBJEXT) \ + canon_name.$(OBJEXT) \ compare_name.$(OBJEXT) \ context_time.$(OBJEXT) \ delete_sec_context.$(OBJEXT) \ disp_name.$(OBJEXT) \ disp_status.$(OBJEXT) \ + duplicate_name.$(OBJEXT) \ + export_name.$(OBJEXT) \ export_sec_context.$(OBJEXT) \ get_tkt_flags.$(OBJEXT) \ gssapi_krb5.$(OBJEXT) \ diff --git a/src/lib/gssapi/krb5/accept_sec_context.c b/src/lib/gssapi/krb5/accept_sec_context.c index 2346069..20b800b 100644 --- a/src/lib/gssapi/krb5/accept_sec_context.c +++ b/src/lib/gssapi/krb5/accept_sec_context.c @@ -237,6 +237,14 @@ krb5_gss_accept_sec_context(minor_status, context_handle, /* decode the message */ + if ((code = krb5_auth_con_init(context, &auth_context))) { + *minor_status = code; + return(GSS_S_FAILURE); + } + if ((code = krb5_auth_con_setrcache(context, auth_context, cred->rcache))) { + *minor_status = code; + return(GSS_S_FAILURE); + } if ((code = krb5_rd_req(context, &auth_context, &ap_req, cred->princ, cred->keytab, NULL, &ticket))) { *minor_status = code; @@ -384,8 +392,7 @@ krb5_gss_accept_sec_context(minor_status, context_handle, ctx->mech_used = mech_used; ctx->auth_context = auth_context; ctx->initiate = 0; - ctx->gss_flags = GSS_C_CONF_FLAG | GSS_C_INTEG_FLAG | - (gss_flags & (GSS_C_MUTUAL_FLAG | GSS_C_DELEG_FLAG)); + ctx->gss_flags = KG_IMPLFLAGS(gss_flags); ctx->seed_init = 0; ctx->big_endian = bigend; @@ -417,6 +424,29 @@ krb5_gss_accept_sec_context(minor_status, context_handle, return(GSS_S_FAILURE); } + /* use the session key if the subkey isn't present */ + + if (ctx->subkey == NULL) { + if ((code = krb5_auth_con_getkey(context, auth_context, + &ctx->subkey))) { + krb5_free_principal(context, ctx->there); + krb5_free_principal(context, ctx->here); + xfree(ctx); + *minor_status = code; + return(GSS_S_FAILURE); + } + } + + if (ctx->subkey == NULL) { + krb5_free_principal(context, ctx->there); + krb5_free_principal(context, ctx->here); + xfree(ctx); + /* this isn't a very good error, but it's not clear to me this + can actually happen */ + *minor_status = KRB5KDC_ERR_NULL_KEY; + return(GSS_S_FAILURE); + } + switch(ctx->subkey->enctype) { case ENCTYPE_DES_CBC_MD5: case ENCTYPE_DES_CBC_CRC: @@ -464,7 +494,7 @@ krb5_gss_accept_sec_context(minor_status, context_handle, } ctx->endtime = ticket->enc_part2->times.endtime; - ctx->flags = ticket->enc_part2->flags; + ctx->krb_flags = ticket->enc_part2->flags; krb5_free_ticket(context, ticket); /* Done with ticket */ @@ -487,8 +517,8 @@ krb5_gss_accept_sec_context(minor_status, context_handle, } g_order_init(&(ctx->seqstate), ctx->seq_recv, - (gss_flags & GSS_C_REPLAY_FLAG) != 0, - (gss_flags & GSS_C_SEQUENCE_FLAG) != 0); + (ctx->gss_flags & GSS_C_REPLAY_FLAG) != 0, + (ctx->gss_flags & GSS_C_SEQUENCE_FLAG) != 0); /* at this point, the entire context structure is filled in, so it can be released. */ @@ -545,7 +575,7 @@ krb5_gss_accept_sec_context(minor_status, context_handle, *time_rec = ctx->endtime - now; if (ret_flags) - *ret_flags = KG_IMPLFLAGS(gss_flags); + *ret_flags = ctx->gss_flags; ctx->established = 1; diff --git a/src/lib/gssapi/krb5/acquire_cred.c b/src/lib/gssapi/krb5/acquire_cred.c index 06acb88..b2743a8 100644 --- a/src/lib/gssapi/krb5/acquire_cred.c +++ b/src/lib/gssapi/krb5/acquire_cred.c @@ -118,6 +118,15 @@ acquire_accept_cred(context, minor_status, desired_name, output_princ, cred) /* hooray. we made it */ cred->keytab = kt; + + /* Open the replay cache for this principal. */ + if ((code = krb5_get_server_rcache(context, + krb5_princ_component(context, princ, 0), + &cred->rcache))) { + *minor_status = code; + return(GSS_S_FAILURE); + } + return(GSS_S_COMPLETE); } @@ -138,7 +147,7 @@ acquire_init_cred(context, minor_status, desired_name, output_princ, cred) { krb5_error_code code; krb5_ccache ccache; - krb5_principal princ; + krb5_principal princ, tmp_princ; krb5_flags flags; krb5_cc_cursor cur; krb5_creds creds; @@ -196,12 +205,20 @@ acquire_init_cred(context, minor_status, desired_name, output_princ, cred) got_endtime = 0; + code = krb5_build_principal_ext(context, &tmp_princ, + krb5_princ_realm(context, princ)->length, + krb5_princ_realm(context, princ)->data, + 6, "krbtgt", + krb5_princ_realm(context, princ)->length, + krb5_princ_realm(context, princ)->data, + 0); + if (code) { + (void)krb5_cc_close(context, ccache); + *minor_status = code; + return(GSS_S_FAILURE); + } while (!(code = krb5_cc_next_cred(context, ccache, &cur, &creds))) { - if ((creds.server->length == 2) && - (strcmp(creds.server->realm.data, princ->realm.data) == 0) && - (strcmp((char *) creds.server->data[0].data, "krbtgt") == 0) && - (strcmp((char *) creds.server->data[1].data, - princ->realm.data) == 0)) { + if (krb5_principal_compare(context, tmp_princ, creds.server)) { cred->tgt_expire = creds.times.endtime; got_endtime = 1; *minor_status = 0; @@ -215,7 +232,8 @@ acquire_init_cred(context, minor_status, desired_name, output_princ, cred) } krb5_free_cred_contents(context, &creds); } - + krb5_free_principal(context, tmp_princ); + if (code && code != KRB5_CC_END) { /* this means some error occurred reading the ccache */ (void)krb5_cc_end_seq_get(context, ccache, &cur); diff --git a/src/lib/gssapi/krb5/canon_name.c b/src/lib/gssapi/krb5/canon_name.c new file mode 100644 index 0000000..8dff894 --- /dev/null +++ b/src/lib/gssapi/krb5/canon_name.c @@ -0,0 +1,41 @@ +/* + * lib/gssapi/krb5/canon_name.c + * + * Copyright 1997 by the Massachusetts Institute of Technology. + * All Rights Reserved. + * + * Export of this software from the United States of America may + * require a specific license from the United States Government. + * It is the responsibility of any person or organization contemplating + * export to obtain such a license before exporting. + * + * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and + * distribute this software and its documentation for any purpose and + * without fee is hereby granted, provided that the above copyright + * notice appear in all copies and that both that copyright notice and + * this permission notice appear in supporting documentation, and that + * the name of M.I.T. not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. M.I.T. makes no representations about the suitability of + * this software for any purpose. It is provided "as is" without express + * or implied warranty. + * + */ + +#include "gssapiP_krb5.h" + +/* This is trivial since we're a single mechanism implementation */ + +OM_uint32 krb5_gss_canonicalize_name(OM_uint32 *minor_status, + const gss_name_t input_name, + const gss_OID mech_type, + gss_name_t *output_name) +{ + if (!g_OID_equal(gss_mech_krb5, mech_type) && + !g_OID_equal(gss_mech_krb5_old, mech_type)) { + *minor_status = 0; + return(GSS_S_BAD_MECH); + } + + return(gss_duplicate_name(minor_status, input_name, output_name)); +} diff --git a/src/lib/gssapi/krb5/delete_sec_context.c b/src/lib/gssapi/krb5/delete_sec_context.c index b38dfbe..f991bdb 100644 --- a/src/lib/gssapi/krb5/delete_sec_context.c +++ b/src/lib/gssapi/krb5/delete_sec_context.c @@ -92,8 +92,10 @@ krb5_gss_delete_sec_context(minor_status, context_handle, output_token) krb5_free_principal(context, ctx->there); krb5_free_keyblock(context, ctx->subkey); - if (ctx->auth_context) + if (ctx->auth_context) { + (void)krb5_auth_con_setrcache(context, ctx->auth_context, NULL); krb5_auth_con_free(context, ctx->auth_context); + } if (ctx->mech_used) gss_release_oid(minor_status, &ctx->mech_used); diff --git a/src/lib/gssapi/krb5/duplicate_name.c b/src/lib/gssapi/krb5/duplicate_name.c new file mode 100644 index 0000000..93e9503 --- /dev/null +++ b/src/lib/gssapi/krb5/duplicate_name.c @@ -0,0 +1,65 @@ +/* + * lib/gssapi/krb5/duplicate_name.c + * + * Copyright 1997 by the Massachusetts Institute of Technology. + * All Rights Reserved. + * + * Export of this software from the United States of America may + * require a specific license from the United States Government. + * It is the responsibility of any person or organization contemplating + * export to obtain such a license before exporting. + * + * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and + * distribute this software and its documentation for any purpose and + * without fee is hereby granted, provided that the above copyright + * notice appear in all copies and that both that copyright notice and + * this permission notice appear in supporting documentation, and that + * the name of M.I.T. not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. M.I.T. makes no representations about the suitability of + * this software for any purpose. It is provided "as is" without express + * or implied warranty. + * + */ + +#include "gssapiP_krb5.h" + +OM_uint32 krb5_gss_duplicate_name(OM_uint32 *minor_status, + const gss_name_t input_name, + gss_name_t *dest_name) +{ + krb5_context context; + krb5_error_code code; + krb5_principal princ, outprinc; + + if (GSS_ERROR(kg_get_context(minor_status, &context))) + return(GSS_S_FAILURE); + + if (! kg_validate_name(input_name)) { + if (minor_status) + *minor_status = (OM_uint32) G_VALIDATE_FAILED; + return(GSS_S_CALL_BAD_STRUCTURE|GSS_S_BAD_NAME); + } + + princ = input_name; + if ((code = krb5_copy_principal(context, princ, &outprinc))) { + *minor_status = code; + return(GSS_S_FAILURE); + } + + if (! kg_save_name((gss_name_t) outprinc)) { + krb5_free_principal(context, outprinc); + *minor_status = (OM_uint32) G_VALIDATE_FAILED; + return(GSS_S_FAILURE); + } + + *dest_name = (gss_name_t) outprinc; + return(GSS_S_COMPLETE); + +} + + + + + + diff --git a/src/lib/gssapi/krb5/export_name.c b/src/lib/gssapi/krb5/export_name.c new file mode 100644 index 0000000..23cb080 --- /dev/null +++ b/src/lib/gssapi/krb5/export_name.c @@ -0,0 +1,87 @@ +/* + * lib/gssapi/krb5/export_name.c + * + * Copyright 1997 by the Massachusetts Institute of Technology. + * All Rights Reserved. + * + * Export of this software from the United States of America may + * require a specific license from the United States Government. + * It is the responsibility of any person or organization contemplating + * export to obtain such a license before exporting. + * + * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and + * distribute this software and its documentation for any purpose and + * without fee is hereby granted, provided that the above copyright + * notice appear in all copies and that both that copyright notice and + * this permission notice appear in supporting documentation, and that + * the name of M.I.T. not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. M.I.T. makes no representations about the suitability of + * this software for any purpose. It is provided "as is" without express + * or implied warranty. + * + */ + +#include "gssapiP_krb5.h" + +OM_uint32 krb5_gss_export_name(OM_uint32 *minor_status, + const gss_name_t input_name, + gss_buffer_t exported_name) +{ + krb5_context context; + krb5_error_code code; + int length; + char *str, *cp; + + if (GSS_ERROR(kg_get_context(minor_status, &context))) + return(GSS_S_FAILURE); + + exported_name->length = 0; + exported_name->value = NULL; + + if (! kg_validate_name(input_name)) { + if (minor_status) + *minor_status = (OM_uint32) G_VALIDATE_FAILED; + return(GSS_S_CALL_BAD_STRUCTURE|GSS_S_BAD_NAME); + } + + if ((code = krb5_unparse_name(context, (krb5_principal) input_name, + &str))) { + *minor_status = code; + return(GSS_S_FAILURE); + } + + length = strlen(str); + exported_name->length = 10 + length + gss_mech_krb5->length; + exported_name->value = malloc(exported_name->length); + if (!exported_name->value) { + free(str); + *minor_status = ENOMEM; + return(GSS_S_FAILURE); + } + cp = exported_name->value; + + /* Note: we assume the OID will be less than 128 bytes... */ + *cp++ = 0x04; *cp++ = 0x01; + *cp++ = (gss_mech_krb5->length+2) >> 8; + *cp++ = (gss_mech_krb5->length+2) & 0xFF; + *cp++ = 0x06; + *cp++ = (gss_mech_krb5->length) & 0xFF; + memcpy(cp, gss_mech_krb5->elements, gss_mech_krb5->length); + cp += gss_mech_krb5->length; + *cp++ = length >> 24; + *cp++ = length >> 16; + *cp++ = length >> 8; + *cp++ = length & 0xFF; + memcpy(cp, str, length); + + free(str); + + return(GSS_S_COMPLETE); +} + + + + + + diff --git a/src/lib/gssapi/krb5/get_tkt_flags.c b/src/lib/gssapi/krb5/get_tkt_flags.c index 5dd9106..eebf06d 100644 --- a/src/lib/gssapi/krb5/get_tkt_flags.c +++ b/src/lib/gssapi/krb5/get_tkt_flags.c @@ -48,7 +48,7 @@ gss_krb5_get_tkt_flags(minor_status, context_handle, ticket_flags) } if (ticket_flags) - *ticket_flags = ctx->flags; + *ticket_flags = ctx->krb_flags; *minor_status = 0; return(GSS_S_COMPLETE); diff --git a/src/lib/gssapi/krb5/gssapiP_krb5.h b/src/lib/gssapi/krb5/gssapiP_krb5.h index ee327ba..55714f0 100644 --- a/src/lib/gssapi/krb5/gssapiP_krb5.h +++ b/src/lib/gssapi/krb5/gssapiP_krb5.h @@ -68,6 +68,7 @@ #define KG_TOK_DEL_CTX 0x0102 #define KG_IMPLFLAGS(x) (GSS_C_INTEG_FLAG | GSS_C_CONF_FLAG | \ + GSS_C_TRANS_FLAG | GSS_C_PROT_READY_FLAG | \ ((x) & (GSS_C_MUTUAL_FLAG | GSS_C_REPLAY_FLAG | \ GSS_C_SEQUENCE_FLAG | GSS_C_DELEG_FLAG))) @@ -91,6 +92,7 @@ typedef struct _krb5_gss_cred_id_rec { /* ccache (init) data */ krb5_ccache ccache; krb5_timestamp tgt_expire; + krb5_rcache rcache; } krb5_gss_cred_id_rec, *krb5_gss_cred_id_t; typedef struct _krb5_gss_enc_desc { @@ -113,7 +115,7 @@ typedef struct _krb5_gss_ctx_id_rec { krb5_gss_enc_desc enc; krb5_gss_enc_desc seq; krb5_timestamp endtime; - krb5_flags flags; + krb5_flags krb_flags; krb5_int32 seq_send; krb5_int32 seq_recv; void *seqstate; @@ -502,4 +504,27 @@ PROTOTYPE( (OM_uint32 *, /* minor_status */ gss_OID_set * /* name_types */ )); +OM_uint32 krb5_gss_canonicalize_name +PROTOTYPE( (OM_uint32 *, /* minor_status */ + const gss_name_t, /* input_name */ + const gss_OID, /* mech_type */ + gss_name_t * /* output_name */ + )); + +OM_uint32 krb5_gss_export_name +PROTOTYPE( (OM_uint32 *, /* minor_status */ + const gss_name_t, /* input_name */ + gss_buffer_t /* exported_name */ + )); + +OM_uint32 krb5_gss_duplicate_name +PROTOTYPE( (OM_uint32 *, /* minor_status */ + const gss_name_t, /* input_name */ + gss_name_t * /* dest_name */ + )); + +gss_OID krb5_gss_convert_static_mech_oid +PROTOTYPE( (gss_OID FAR oid + )); + #endif /* _GSSAPIP_KRB5_H_ */ diff --git a/src/lib/gssapi/krb5/gssapi_krb5.c b/src/lib/gssapi/krb5/gssapi_krb5.c index 9b631a1..b6df489 100644 --- a/src/lib/gssapi/krb5/gssapi_krb5.c +++ b/src/lib/gssapi/krb5/gssapi_krb5.c @@ -53,28 +53,28 @@ * except the last in each value's encoding. */ -static const gss_OID_desc oids[] = { - /* this is the unofficial, wrong OID */ - {5, "\053\005\001\005\002"}, +const gss_OID_desc krb5_gss_oid_array[] = { /* this is the official, rfc-specified OID */ {9, "\052\206\110\206\367\022\001\002\002"}, + /* this is the unofficial, wrong OID */ + {5, "\053\005\001\005\002"}, {10, "\052\206\110\206\367\022\001\002\002\001"}, {10, "\052\206\110\206\367\022\001\002\002\002"}, }; -const gss_OID_desc * const gss_mech_krb5_old = oids+0; -const gss_OID_desc * const gss_mech_krb5 = oids+1; -const gss_OID_desc * const gss_nt_krb5_name = oids+2; -const gss_OID_desc * const gss_nt_krb5_principal = oids+3; +const gss_OID_desc * const gss_mech_krb5 = krb5_gss_oid_array+0; +const gss_OID_desc * const gss_mech_krb5_old = krb5_gss_oid_array+1; +const gss_OID_desc * const gss_nt_krb5_name = krb5_gss_oid_array+2; +const gss_OID_desc * const gss_nt_krb5_principal = krb5_gss_oid_array+3; static const gss_OID_set_desc oidsets[] = { - {1, (gss_OID) oids+0}, - {1, (gss_OID) oids+1}, - {2, (gss_OID) oids+0}, + {1, (gss_OID) krb5_gss_oid_array+0}, + {1, (gss_OID) krb5_gss_oid_array+1}, + {2, (gss_OID) krb5_gss_oid_array+0}, }; -const gss_OID_set_desc * const gss_mech_set_krb5_old = oidsets+0; -const gss_OID_set_desc * const gss_mech_set_krb5 = oidsets+1; +const gss_OID_set_desc * const gss_mech_set_krb5 = oidsets+0; +const gss_OID_set_desc * const gss_mech_set_krb5_old = oidsets+1; const gss_OID_set_desc * const gss_mech_set_krb5_both = oidsets+2; void *kg_vdb = NULL; diff --git a/src/lib/gssapi/krb5/gssapi_krb5.h b/src/lib/gssapi/krb5/gssapi_krb5.h index 71182f2..cf64874 100644 --- a/src/lib/gssapi/krb5/gssapi_krb5.h +++ b/src/lib/gssapi/krb5/gssapi_krb5.h @@ -39,6 +39,8 @@ extern const gss_OID_set_desc * const gss_mech_set_krb5_both; extern const gss_OID_desc * const gss_nt_krb5_name; extern const gss_OID_desc * const gss_nt_krb5_principal; +extern const gss_OID_desc krb5_gss_oid_array[]; + #define gss_krb5_nt_general_name gss_nt_krb5_name #define gss_krb5_nt_principal gss_nt_krb5_principal #define gss_krb5_nt_service_name gss_nt_service_name diff --git a/src/lib/gssapi/krb5/import_name.c b/src/lib/gssapi/krb5/import_name.c index 5c2c6f4..539d891 100644 --- a/src/lib/gssapi/krb5/import_name.c +++ b/src/lib/gssapi/krb5/import_name.c @@ -54,7 +54,8 @@ krb5_gss_import_name(minor_status, input_name_buffer, krb5_context context; krb5_principal princ; krb5_error_code code; - char *stringrep, *tmp; + char *stringrep, *tmp, *tmp2, *cp; + OM_uint32 length; #ifndef NO_PASSWORD struct passwd *pw; #endif @@ -70,7 +71,8 @@ krb5_gss_import_name(minor_status, input_name_buffer, /* Go find the appropriate string rep to pass into parse_name */ if ((input_name_type != GSS_C_NULL_OID) && - g_OID_equal(input_name_type, gss_nt_service_name)) { + (g_OID_equal(input_name_type, gss_nt_service_name) || + g_OID_equal(input_name_type, gss_nt_service_name_v2))) { char *service, *host; if ((tmp = @@ -83,7 +85,7 @@ krb5_gss_import_name(minor_status, input_name_buffer, tmp[input_name_buffer->length] = 0; service = tmp; - if (host = strchr(tmp, '@')) { + if ((host = strchr(tmp, '@'))) { *host = '\0'; host++; } @@ -115,6 +117,7 @@ krb5_gss_import_name(minor_status, input_name_buffer, *minor_status = ENOMEM; return(GSS_S_FAILURE); } + tmp2 = 0; memcpy(tmp, input_name_buffer->value, input_name_buffer->length); tmp[input_name_buffer->length] = 0; @@ -135,7 +138,40 @@ krb5_gss_import_name(minor_status, input_name_buffer, else *minor_status = (OM_uint32) G_NOUSER; #endif - } else { + } else if (g_OID_equal(input_name_type, gss_nt_exported_name)) { + cp = tmp; + if (*cp++ != 0x04) + goto fail_name; + if (*cp++ != 0x01) + goto fail_name; + if (*cp++ != 0x00) + goto fail_name; + length = *cp++; + if (length != gss_mech_krb5->length+2) + goto fail_name; + if (*cp++ != 0x06) + goto fail_name; + length = *cp++; + if (length != gss_mech_krb5->length) + goto fail_name; + if (memcmp(cp, gss_mech_krb5->elements, length) != 0) + goto fail_name; + cp += length; + length = *cp++; + length = (length << 8) | *cp++; + length = (length << 8) | *cp++; + length = (length << 8) | *cp++; + tmp2 = malloc(length+1); + if (tmp2 == NULL) { + xfree(tmp); + *minor_status = ENOMEM; + return GSS_S_FAILURE; + } + strncpy(tmp2, cp, length); + tmp2[length] = 0; + + stringrep = tmp2; + } else { return(GSS_S_BAD_NAMETYPE); } @@ -143,9 +179,16 @@ krb5_gss_import_name(minor_status, input_name_buffer, if (stringrep) code = krb5_parse_name(context, (char *) stringrep, &princ); - else + else { + fail_name: + xfree(tmp); + if (tmp2) + xfree(tmp2); return(GSS_S_BAD_NAME); + } + if (tmp2) + xfree(tmp2); xfree(tmp); } diff --git a/src/lib/gssapi/krb5/import_sec_context.c b/src/lib/gssapi/krb5/import_sec_context.c index c1d1bfa..141736b 100644 --- a/src/lib/gssapi/krb5/import_sec_context.c +++ b/src/lib/gssapi/krb5/import_sec_context.c @@ -27,6 +27,26 @@ */ #include "gssapiP_krb5.h" +/* + * Fix up the OID of the mechanism so that uses the static version of + * the OID if possible. + */ +gss_OID krb5_gss_convert_static_mech_oid(oid) + gss_OID FAR oid; +{ + const gss_OID_desc *p; + OM_uint32 minor_status; + + for (p = krb5_gss_oid_array; p->length; p++) { + if ((oid->length == p->length) && + (memcmp(oid->elements, p->elements, p->length) == 0)) { + gss_release_oid(&minor_status, &oid); + return p; + } + } + return oid; +} + OM_uint32 krb5_gss_import_sec_context(minor_status, interprocess_token, context_handle) OM_uint32 *minor_status; @@ -65,6 +85,7 @@ krb5_gss_import_sec_context(minor_status, interprocess_token, context_handle) *minor_status = (OM_uint32) G_VALIDATE_FAILED; return(GSS_S_FAILURE); } + ctx->mech_used = krb5_gss_convert_static_mech_oid(ctx->mech_used); *context_handle = (gss_ctx_id_t) ctx; diff --git a/src/lib/gssapi/krb5/indicate_mechs.c b/src/lib/gssapi/krb5/indicate_mechs.c index bc53b44..4f38a3e 100644 --- a/src/lib/gssapi/krb5/indicate_mechs.c +++ b/src/lib/gssapi/krb5/indicate_mechs.c @@ -32,6 +32,12 @@ krb5_gss_indicate_mechs(minor_status, mech_set) gss_OID_set *mech_set; { *minor_status = 0; - *mech_set = (gss_OID_set) gss_mech_set_krb5; + + if (! g_copy_OID_set(gss_mech_set_krb5_both, mech_set)) { + *mech_set = GSS_C_NO_OID_SET; + *minor_status = ENOMEM; + return(GSS_S_FAILURE); + } + return(GSS_S_COMPLETE); } diff --git a/src/lib/gssapi/krb5/init_sec_context.c b/src/lib/gssapi/krb5/init_sec_context.c index 690d5af..efe1b79 100644 --- a/src/lib/gssapi/krb5/init_sec_context.c +++ b/src/lib/gssapi/krb5/init_sec_context.c @@ -30,15 +30,15 @@ static krb5_error_code make_ap_req(context, auth_context, cred, server, endtime, chan_bindings, - req_flags, flags, mech_type, token) + req_flags, krb_flags, mech_type, token) krb5_context context; krb5_auth_context * auth_context; krb5_gss_cred_id_t cred; krb5_principal server; krb5_timestamp *endtime; gss_channel_bindings_t chan_bindings; - OM_uint32 req_flags; - krb5_flags *flags; + OM_uint32 *req_flags; + krb5_flags *krb_flags; gss_OID mech_type; gss_buffer_t token; { @@ -74,8 +74,7 @@ make_ap_req(context, auth_context, cred, server, endtime, chan_bindings, /* build the checksum field */ - if(*flags && GSS_C_DELEG_FLAG) { - + if (*req_flags & GSS_C_DELEG_FLAG) { /* first get KRB_CRED message, so we know its length */ /* clear the time check flag that was set in krb5_auth_con_init() */ @@ -83,20 +82,27 @@ make_ap_req(context, auth_context, cred, server, endtime, chan_bindings, krb5_auth_con_setflags(context, *auth_context, con_flags & ~KRB5_AUTH_CONTEXT_DO_TIME); - if ((code = krb5_fwd_tgt_creds(context, *auth_context, 0, + code = krb5_fwd_tgt_creds(context, *auth_context, 0, cred->princ, server, cred->ccache, 1, - &credmsg))) - return(code); + &credmsg); /* turn KRB5_AUTH_CONTEXT_DO_TIME back on */ krb5_auth_con_setflags(context, *auth_context, con_flags); - if(credmsg.length+28 > KRB5_INT16_MAX) { - krb5_xfree(credmsg.data); - return(KRB5KRB_ERR_FIELD_TOOLONG); - } + if (code) { + /* don't fail here; just don't accept/do the delegation + request */ + *req_flags &= ~GSS_C_DELEG_FLAG; + + checksum_data.length = 24; + } else { + if (credmsg.length+28 > KRB5_INT16_MAX) { + krb5_xfree(credmsg.data); + return(KRB5KRB_ERR_FIELD_TOOLONG); + } - checksum_data.length = 28+credmsg.length; + checksum_data.length = 28+credmsg.length; + } } else { checksum_data.length = 24; } @@ -115,7 +121,7 @@ make_ap_req(context, auth_context, cred, server, endtime, chan_bindings, TWRITE_INT(ptr, md5.length, 0); TWRITE_STR(ptr, (unsigned char *) md5.contents, md5.length); - TWRITE_INT(ptr, KG_IMPLFLAGS(req_flags), 0); + TWRITE_INT(ptr, *req_flags, 0); /* done with this, free it */ xfree(md5.contents); @@ -151,7 +157,7 @@ make_ap_req(context, auth_context, cred, server, endtime, chan_bindings, mk_req_flags = AP_OPTS_USE_SUBKEY; - if (req_flags & GSS_C_MUTUAL_FLAG) + if (*req_flags & GSS_C_MUTUAL_FLAG) mk_req_flags |= AP_OPTS_MUTUAL_REQUIRED; if ((code = krb5_mk_req_extended(context, auth_context, mk_req_flags, @@ -160,7 +166,7 @@ make_ap_req(context, auth_context, cred, server, endtime, chan_bindings, /* store the interesting stuff from creds and authent */ *endtime = out_creds->times.endtime; - *flags = out_creds->ticket_flags; + *krb_flags = out_creds->ticket_flags; /* build up the token */ @@ -264,15 +270,15 @@ krb5_gss_init_sec_context(minor_status, claimant_cred_handle, err = 0; if (mech_type == GSS_C_NULL_OID) { - mech_type = cred->rfc_mech?gss_mech_krb5:gss_mech_krb5_old; - } else if (g_OID_equal(mech_type, gss_mech_krb5)) { - if (!cred->rfc_mech) - err = 1; - } else if (g_OID_equal(mech_type, gss_mech_krb5_old)) { - if (!cred->prerfc_mech) - err = 1; - } else - err = 1; + mech_type = cred->rfc_mech?gss_mech_krb5:gss_mech_krb5_old; + } else if (g_OID_equal(mech_type, gss_mech_krb5)) { + if (!cred->rfc_mech) + err = 1; + } else if (g_OID_equal(mech_type, gss_mech_krb5_old)) { + if (!cred->prerfc_mech) + err = 1; + } else + err = 1; if (err) { *minor_status = 0; @@ -298,9 +304,9 @@ krb5_gss_init_sec_context(minor_status, claimant_cred_handle, return(GSS_S_NO_CRED); } - /* complain if the input token is nonnull */ + /* complain if the input token is non-null */ - if (input_token != GSS_C_NO_BUFFER) { + if (input_token != GSS_C_NO_BUFFER && input_token->length != 0) { *minor_status = 0; return(GSS_S_DEFECTIVE_TOKEN); } @@ -315,12 +321,18 @@ krb5_gss_init_sec_context(minor_status, claimant_cred_handle, /* fill in the ctx */ memset(ctx, 0, sizeof(krb5_gss_ctx_id_rec)); - ctx->mech_used = mech_type; + if (generic_gss_copy_oid(minor_status, mech_type, &ctx->mech_used) + != GSS_S_COMPLETE) { + free(ctx); + return(GSS_S_FAILURE); + } + /* + * Now try to make it static if at all possible.... + */ + ctx->mech_used = krb5_gss_convert_static_mech_oid(ctx->mech_used); ctx->auth_context = NULL; ctx->initiate = 1; - ctx->gss_flags = ((req_flags & (GSS_C_MUTUAL_FLAG | GSS_C_DELEG_FLAG)) | - GSS_C_CONF_FLAG | GSS_C_INTEG_FLAG); - ctx->flags = req_flags & GSS_C_DELEG_FLAG; + ctx->gss_flags = KG_IMPLFLAGS(req_flags); ctx->seed_init = 0; ctx->big_endian = 0; /* all initiators do little-endian, as per spec */ ctx->seqstate = 0; @@ -352,7 +364,8 @@ krb5_gss_init_sec_context(minor_status, claimant_cred_handle, if ((code = make_ap_req(context, &(ctx->auth_context), cred, ctx->there, &ctx->endtime, input_chan_bindings, - req_flags, &ctx->flags, mech_type, &token))) { + &ctx->gss_flags, &ctx->krb_flags, mech_type, + &token))) { krb5_free_principal(context, ctx->here); krb5_free_principal(context, ctx->there); xfree(ctx); @@ -438,7 +451,7 @@ krb5_gss_init_sec_context(minor_status, claimant_cred_handle, *output_token = token; if (ret_flags) - *ret_flags = KG_IMPLFLAGS(req_flags); + *ret_flags = ctx->gss_flags; if (actual_mech_type) *actual_mech_type = mech_type; @@ -452,8 +465,8 @@ krb5_gss_init_sec_context(minor_status, claimant_cred_handle, } else { ctx->seq_recv = ctx->seq_send; g_order_init(&(ctx->seqstate), ctx->seq_recv, - (req_flags & GSS_C_REPLAY_FLAG) != 0, - (req_flags & GSS_C_SEQUENCE_FLAG) != 0); + (ctx->gss_flags & GSS_C_REPLAY_FLAG) != 0, + (ctx->gss_flags & GSS_C_SEQUENCE_FLAG) != 0); ctx->established = 1; /* fall through to GSS_S_COMPLETE */ } @@ -477,7 +490,7 @@ krb5_gss_init_sec_context(minor_status, claimant_cred_handle, if ((ctx->established) || (((gss_cred_id_t) cred) != claimant_cred_handle) || - ((req_flags & GSS_C_MUTUAL_FLAG) == 0)) { + ((ctx->gss_flags & GSS_C_MUTUAL_FLAG) == 0)) { (void)krb5_gss_delete_sec_context(minor_status, context_handle, NULL); /* XXX this minor status is wrong if an arg was changed */ @@ -534,8 +547,8 @@ krb5_gss_init_sec_context(minor_status, claimant_cred_handle, /* store away the sequence number */ ctx->seq_recv = ap_rep_data->seq_number; g_order_init(&(ctx->seqstate), ctx->seq_recv, - (req_flags & GSS_C_REPLAY_FLAG) != 0, - (req_flags & GSS_C_SEQUENCE_FLAG) !=0); + (ctx->gss_flags & GSS_C_REPLAY_FLAG) != 0, + (ctx->gss_flags & GSS_C_SEQUENCE_FLAG) !=0); /* free the ap_rep_data */ krb5_free_ap_rep_enc_part(context, ap_rep_data); diff --git a/src/lib/gssapi/krb5/inq_names.c b/src/lib/gssapi/krb5/inq_names.c index 948346d..9c5f474 100644 --- a/src/lib/gssapi/krb5/inq_names.c +++ b/src/lib/gssapi/krb5/inq_names.c @@ -71,6 +71,14 @@ krb5_gss_inquire_names_for_mech(minor_status, mechanism, name_types) name_types) ) == GSS_S_COMPLETE) && ((major = gss_add_oid_set_member(minor_status, + (gss_OID) gss_nt_service_name_v2, + name_types) + ) == GSS_S_COMPLETE) && + ((major = gss_add_oid_set_member(minor_status, + (gss_OID) gss_nt_exported_name, + name_types) + ) == GSS_S_COMPLETE) && + ((major = gss_add_oid_set_member(minor_status, (gss_OID) gss_nt_krb5_name, name_types) ) == GSS_S_COMPLETE) diff --git a/src/lib/gssapi/krb5/krb5_gss_glue.c b/src/lib/gssapi/krb5/krb5_gss_glue.c index fe3b020..b50a285 100644 --- a/src/lib/gssapi/krb5/krb5_gss_glue.c +++ b/src/lib/gssapi/krb5/krb5_gss_glue.c @@ -534,3 +534,39 @@ gss_wrap_size_limit(minor_status, context_handle, conf_req_flag, conf_req_flag, qop_req, req_output_size, max_input_size)); } + +/* V2 interface */ +OM_uint32 INTERFACE +gss_canonicalize_name(minor_status, input_name, mech_type, output_name) + OM_uint32 *minor_status; + const gss_name_t input_name; + const gss_OID mech_type; + gss_name_t *output_name; +{ + return krb5_gss_canonicalize_name(minor_status, input_name, + mech_type, output_name); +} + + +/* V2 interface */ +OM_uint32 INTERFACE +gss_export_name(minor_status, input_name, exported_name) + OM_uint32 *minor_status; + const gss_name_t input_name; + gss_buffer_t exported_name; +{ + return krb5_gss_export_name(minor_status, input_name, exported_name); +} + +/* V2 interface */ +OM_uint32 INTERFACE +gss_duplicate_name(minor_status, input_name, dest_name) + OM_uint32 *minor_status; + const gss_name_t input_name; + gss_name_t *dest_name; +{ + return krb5_gss_duplicate_name(minor_status, input_name, dest_name); +} + + + diff --git a/src/lib/gssapi/krb5/rel_cred.c b/src/lib/gssapi/krb5/rel_cred.c index df30198..0d81399 100644 --- a/src/lib/gssapi/krb5/rel_cred.c +++ b/src/lib/gssapi/krb5/rel_cred.c @@ -29,7 +29,7 @@ krb5_gss_release_cred(minor_status, cred_handle) { krb5_context context; krb5_gss_cred_id_t cred; - krb5_error_code code1, code2; + krb5_error_code code1, code2, code3; if (GSS_ERROR(kg_get_context(minor_status, &context))) return(GSS_S_FAILURE); @@ -54,6 +54,10 @@ krb5_gss_release_cred(minor_status, cred_handle) else code2 = 0; + if (cred->rcache) + code3 = krb5_rc_close(context, cred->rcache); + else + code3 = 0; if (cred->princ) krb5_free_principal(context, cred->princ); xfree(cred); @@ -65,6 +69,8 @@ krb5_gss_release_cred(minor_status, cred_handle) *minor_status = code1; if (code2) *minor_status = code2; + if (code3) + *minor_status = code3; return(*minor_status?GSS_S_FAILURE:GSS_S_COMPLETE); } diff --git a/src/lib/gssapi/krb5/ser_sctx.c b/src/lib/gssapi/krb5/ser_sctx.c index 259cce5..22b5c36 100644 --- a/src/lib/gssapi/krb5/ser_sctx.c +++ b/src/lib/gssapi/krb5/ser_sctx.c @@ -515,7 +515,7 @@ kg_ctx_externalize(kcontext, arg, buffer, lenremain) &bp, &remain); (void) krb5_ser_pack_int32((krb5_int32) ctx->endtime, &bp, &remain); - (void) krb5_ser_pack_int32((krb5_int32) ctx->flags, + (void) krb5_ser_pack_int32((krb5_int32) ctx->krb_flags, &bp, &remain); (void) krb5_ser_pack_int32((krb5_int32) ctx->seq_send, &bp, &remain); @@ -632,7 +632,7 @@ kg_ctx_internalize(kcontext, argp, buffer, lenremain) (void) krb5_ser_unpack_int32(&ibuf, &bp, &remain); ctx->endtime = (krb5_timestamp) ibuf; (void) krb5_ser_unpack_int32(&ibuf, &bp, &remain); - ctx->flags = (krb5_flags) ibuf; + ctx->krb_flags = (krb5_flags) ibuf; (void) krb5_ser_unpack_int32(&ctx->seq_send, &bp, &remain); (void) krb5_ser_unpack_int32(&ctx->seq_recv, &bp, &remain); (void) krb5_ser_unpack_int32(&ibuf, &bp, &remain); diff --git a/src/lib/gssapi/krb5/wrap_size_limit.c b/src/lib/gssapi/krb5/wrap_size_limit.c index 8c47d0f..4b304af 100644 --- a/src/lib/gssapi/krb5/wrap_size_limit.c +++ b/src/lib/gssapi/krb5/wrap_size_limit.c @@ -39,8 +39,9 @@ krb5_gss_wrap_size_limit(minor_status, context_handle, conf_req_flag, { krb5_context context; krb5_gss_ctx_id_rec *ctx; - OM_uint32 cfsize; OM_uint32 ohlen; + OM_uint32 data_size, conflen; + int overhead; if (GSS_ERROR(kg_get_context(minor_status, &context))) return(GSS_S_FAILURE); @@ -64,12 +65,24 @@ krb5_gss_wrap_size_limit(minor_status, context_handle, conf_req_flag, } /* Calculate the token size and subtract that from the output size */ - cfsize = (conf_req_flag) ? kg_confounder_size(&ctx->enc) : 0; + overhead = 7 + ctx->mech_used->length; + data_size = req_output_size; + if (conf_req_flag) { + conflen = kg_confounder_size(&ctx->enc); + data_size = (conflen + data_size + 8) & (~7); + } ohlen = g_token_size((gss_OID) ctx->mech_used, - (unsigned int) cfsize + ctx->cksum_size + 14); + (unsigned int) (data_size + ctx->cksum_size + 14)) + - req_output_size; - /* Cannot have trailer length that will cause us to pad over our length */ - *max_input_size = (req_output_size - ohlen) & (~7); + if (ohlen+overhead < req_output_size) + /* + * Cannot have trailer length that will cause us to pad over + * our length + */ + *max_input_size = (req_output_size - ohlen - overhead) & (~7); + else + *max_input_size = 0; *minor_status = 0; return(GSS_S_COMPLETE); } diff --git a/src/lib/gssapi/mechglue/ChangeLog b/src/lib/gssapi/mechglue/ChangeLog index 97558b1..9f8fb1b 100644 --- a/src/lib/gssapi/mechglue/ChangeLog +++ b/src/lib/gssapi/mechglue/ChangeLog @@ -1,3 +1,7 @@ +Mon Nov 18 20:43:54 1996 Ezra Peisach + + * configure.in: Shared library version number to 1.0. [krb5-libs/201] + Wed Jun 12 00:50:32 1996 Theodore Ts'o * Makefile.in: Remove include of config/windows.in; that's done diff --git a/src/lib/gssapi/mechglue/configure.in b/src/lib/gssapi/mechglue/configure.in index 73cf30e..bd9b4db 100644 --- a/src/lib/gssapi/mechglue/configure.in +++ b/src/lib/gssapi/mechglue/configure.in @@ -13,7 +13,7 @@ case $host in *-*-aix*) # don't build libgssapi.a on AIX ;; *) - V5_MAKE_SHARED_LIB(libgssapi,0.1,.., ./mechglue) + V5_MAKE_SHARED_LIB(libgssapi,1.0,.., ./mechglue) AppendRule([install:: libgssapi.[$](LIBEXT) [$](INSTALL_DATA) libgssapi.[$](LIBEXT) [$](DESTDIR)[$](KRB5_LIBDIR)[$](S)libgssapi.[$](LIBEXT)]) LinkFileDir([$](TOPLIBD)/libgssapi.[$](LIBEXT),libgssapi.[$](LIBEXT),./gssapi/mechglue) diff --git a/src/lib/kadm5/srv/ChangeLog b/src/lib/kadm5/srv/ChangeLog index 9a08922..84a43cb 100644 --- a/src/lib/kadm5/srv/ChangeLog +++ b/src/lib/kadm5/srv/ChangeLog @@ -1,3 +1,25 @@ +Wed Mar 10 19:41:31 1999 Tom Yu + + * Makefile.in (SHLIB_LIBS): Remove -ldb to avoid HP/UX build + problems. + +Sun Mar 9 13:40:33 1997 Tom Yu + + * svr_principal.c (add_to_history): Don't call realloc() on a NULL + pointer, lest non-ANSI compliant systems like SunOS fail. + +Tue Nov 26 03:04:04 1996 Sam Hartman + + * server_acl.c (acl_load_acl_file): Fix coredump by allowing + catchall_entry to be null, but do not reference it if it is. + Thanks to marc. [242] + +Mon Nov 25 17:53:20 1996 Barry Jaspan + + * server_acl.c: set acl_catchall_entry to "" instead of NULL, + since it is presumed to contain something, but we don't want any + default entry [krb5-admin/237] + Wed Nov 13 19:20:36 1996 Tom Yu * Makefile.in (clean-unix): Remove shared/*. diff --git a/src/lib/kadm5/srv/Makefile.in b/src/lib/kadm5/srv/Makefile.in index 58f9da8..b9f58ab 100644 --- a/src/lib/kadm5/srv/Makefile.in +++ b/src/lib/kadm5/srv/Makefile.in @@ -56,7 +56,7 @@ DEPLIBS=$(TOPLIBD)/libgssrpc.$(SHEXT).$(GSSRPC_VER) \ $(TOPLIBD)/libcom_err.$(SHEXT).$(COMERR_VER) \ $(TOPLIBD)/libdyn.$(SHEXT).$(DYN_VER) -SHLIB_LIBS=-lgssrpc -lgssapi_krb5 -lkdb5 -ldb -lkrb5 -lcrypto -lcom_err -ldyn +SHLIB_LIBS=-lgssrpc -lgssapi_krb5 -lkdb5 -lkrb5 -lcrypto -lcom_err -ldyn SHLIB_LDFLAGS= $(LDFLAGS) @SHLIB_RPATH_DIRS@ SHLIB_LIBDIRS= @SHLIB_LIBDIRS@ diff --git a/src/lib/kadm5/srv/server_acl.c b/src/lib/kadm5/srv/server_acl.c index 16a7f4e..3e731fe 100644 --- a/src/lib/kadm5/srv/server_acl.c +++ b/src/lib/kadm5/srv/server_acl.c @@ -276,7 +276,8 @@ char tmpbuf[10]; } else { com_err(acl_acl_file, errno, acl_cantopen_msg); - if (acl_list_head = acl_parse_line(acl_catchall_entry)) { + if (acl_catchall_entry && + (acl_list_head = acl_parse_line(acl_catchall_entry))) { acl_list_tail = acl_list_head; } else { diff --git a/src/lib/kadm5/srv/svr_principal.c b/src/lib/kadm5/srv/svr_principal.c index f4a21f3..5ff1b49 100644 --- a/src/lib/kadm5/srv/svr_principal.c +++ b/src/lib/kadm5/srv/svr_principal.c @@ -964,9 +964,14 @@ static kadm5_ret_t add_to_history(krb5_context context, /* resize the adb->old_keys array if necessary */ if (adb->old_key_len < pol->pw_history_num-1) { - adb->old_keys = (osa_pw_hist_ent *) - realloc(adb->old_keys, - (adb->old_key_len+1)*sizeof(osa_pw_hist_ent)); + if (adb->old_keys == NULL) { + adb->old_keys = (osa_pw_hist_ent *) + malloc((adb->old_key_len + 1) * sizeof (osa_pw_hist_ent)); + } else { + adb->old_keys = (osa_pw_hist_ent *) + realloc(adb->old_keys, + (adb->old_key_len + 1) * sizeof (osa_pw_hist_ent)); + } if (adb->old_keys == NULL) return(ENOMEM); diff --git a/src/lib/kadm5/unit-test/ChangeLog b/src/lib/kadm5/unit-test/ChangeLog index aba10a9..d169ba8 100644 --- a/src/lib/kadm5/unit-test/ChangeLog +++ b/src/lib/kadm5/unit-test/ChangeLog @@ -1,3 +1,7 @@ +Wed Nov 20 15:59:34 1996 Barry Jaspan + + * Makefile.in (check-): warn more loudly about unrun tests + Mon Nov 11 20:51:27 1996 Tom Yu * configure.in: Add AC_CANONICAL_HOST to deal with new pre.in. diff --git a/src/lib/kadm5/unit-test/Makefile.in b/src/lib/kadm5/unit-test/Makefile.in index 455f428..333c663 100644 --- a/src/lib/kadm5/unit-test/Makefile.in +++ b/src/lib/kadm5/unit-test/Makefile.in @@ -49,7 +49,10 @@ server-iter-test: iter-test.o $(SRVDEPLIBS) check:: check-@DO_TEST@ check-:: - @echo "Either tcl, runtest, or Perl is unavailable. Kadm5 unit tests not run" + @echo "+++" + @echo "+++ WARNING: lib/kadm5 unit tests not run." + @echo "+++ Either tcl, runtest, or Perl is unavailable." + @echo "+++" check-ok unit-test:: unit-test-client unit-test-server diff --git a/src/lib/kdb/ChangeLog b/src/lib/kdb/ChangeLog index 3f74707..f31fb7a 100644 --- a/src/lib/kdb/ChangeLog +++ b/src/lib/kdb/ChangeLog @@ -1,3 +1,13 @@ +Sun Mar 16 21:20:00 1997 Tom Yu + + * keytab.c: Don't assume dbm_db_get_mkey() and dbe_find_enctype + won't error out. Also, some gcc -Wall warning + cleanups. [krb5-kdc/361] + +Mon Nov 18 20:40:12 1996 Ezra Peisach + + * configure.in: Set shared library version to 1.0. [krb5-libs/201] + Tue Nov 12 23:41:55 1996 Mark Eichin * kdb_dbm.c: Ditch DB_OPENCLOSE conditionals, and fix the real diff --git a/src/lib/kdb/configure.in b/src/lib/kdb/configure.in index 75c4e40..8f04d98 100644 --- a/src/lib/kdb/configure.in +++ b/src/lib/kdb/configure.in @@ -20,7 +20,7 @@ KRB5_RUN_FLAGS V5_USE_SHARED_LIB KRB5_LIBRARIES V5_SHARED_LIB_OBJS -V5_MAKE_SHARED_LIB(libkdb5,0.1,.., ./kdb) +V5_MAKE_SHARED_LIB(libkdb5,1.0,.., ./kdb) AppendRule([all-unix:: ../libkdb5.a]) KRB5_SH_VERS=$krb5_cv_shlib_version_libkrb5 AC_SUBST(KRB5_SH_VERS) diff --git a/src/lib/kdb/keytab.c b/src/lib/kdb/keytab.c index c32b742..82ed08e 100644 --- a/src/lib/kdb/keytab.c +++ b/src/lib/kdb/keytab.c @@ -110,35 +110,44 @@ krb5_ktkdb_get_entry(context, id, principal, kvno, enctype, entry) /* Open database */ /* krb5_dbm_db_init(context); */ - if (kerror = krb5_dbm_db_open_database(context)) + if ((kerror = krb5_dbm_db_open_database(context))) return(kerror); /* get_principal */ - if (kerror = krb5_dbm_db_get_principal(context, principal, &db_entry, - &n, &more)) { + kerror = krb5_dbm_db_get_principal(context, principal, & + db_entry, &n, &more); + if (kerror) { krb5_dbm_db_close_database(context); return(kerror); } - - if (n != 1) - { + if (n != 1) { krb5_dbm_db_close_database(context); return KRB5_KT_NOTFOUND; - } + } + /* match key */ - krb5_dbm_db_get_mkey(context, id->ops, &master_key); - krb5_dbe_find_enctype(context, &db_entry, enctype, -1, kvno, &key_data); - if (kerror = krb5_dbekd_decrypt_key_data(context, master_key, key_data, - &entry->key, NULL)) + /* WTF??? 2nd arg to dbm_db_get_mkey appears to be unused! -tlyu */ + kerror = krb5_dbm_db_get_mkey(context, id->ops, &master_key); + if (kerror) + goto error; + + kerror = krb5_dbe_find_enctype(context, &db_entry, + enctype, -1, kvno, &key_data); + if (kerror) + goto error; + + kerror = krb5_dbekd_decrypt_key_data(context, master_key, + key_data, &entry->key, NULL); + if (kerror) goto error; - if (kerror = krb5_copy_principal(context, principal, &entry->principal)) + kerror = krb5_copy_principal(context, principal, &entry->principal); + if (kerror) goto error; /* Close database */ -error:; + error: krb5_dbe_free_contents(context, &db_entry); krb5_dbm_db_close_database(context); return(kerror); } - diff --git a/src/lib/krb4/ChangeLog b/src/lib/krb4/ChangeLog index 27ab65f..183237a 100644 --- a/src/lib/krb4/ChangeLog +++ b/src/lib/krb4/ChangeLog @@ -1,3 +1,53 @@ +Thu Apr 15 20:18:38 1999 Tom Yu + + * g_cnffile.c (krb__get_srvtabname): Fix to actually extract + krb5_srvtab value from profile, instead of always ignoring it. + +1998-11-13 Theodore Ts'o + + * g_cnffile.c: Use krb5__krb4_context instead of init'ing and + free'ing a krb5_context each time we need to read data + from the configuration file. We also define + krb5__krb4_context in g_cnnfile.c, since it's a likely + that any use of the krb4 library will pull in that file. + +Fri Aug 7 11:04:03 1998 Tom Yu + + * tf_util.c (tf_init): Add call to getuid() to initialize me. + +Thu Jul 9 19:35:01 1998 Matthew D Hancher + + * tf_util.c (tf_init): Fixed a potential race condition in the opening + of v4 ticket files. tf_init() was calling lstat() followed by fopen(). + Now it calls fopen() and then calls lstat() and fstat() to check file + ownership and to check that it opened the file it thought it did. I + patched the shared memory code similarly, but since nothing uses it I + don't have a good way to test it properly. + +1998-05-08 Theodore Ts'o + + * stime.c (krb_stime): + * log.c (krb_new_log, krb_log): + * klog.c (klog): Print the year using 4 digits to avoid Y2K issues. + +Sun Apr 5 19:51:21 1998 Tom Yu + + * g_cnffile.c (krb__get_srvtabname): Fix up to not free context + unless it is valid. + +Wed Apr 9 23:15:39 1997 Tom Yu + + * realmofhost.c (krb_realmofhost): Add bounds checking to various + things. + + * g_krbhst.c (krb_get_krbhst): Fix to bound fscanf and sscanf. + + * g_krbrlm.c (krb_get_lrealm): Fix to bound fscanf. + +Mon Nov 18 20:40:39 1996 Ezra Peisach + + * configure.in: Set shared library version to 1.0. [krb5-libs/201] + Thu Nov 7 12:33:06 1996 Theodore Y. Ts'o * g_in_tkt.c: diff --git a/src/lib/krb4/configure.in b/src/lib/krb4/configure.in index 4e3dd8c..2a4c8b3 100644 --- a/src/lib/krb4/configure.in +++ b/src/lib/krb4/configure.in @@ -44,7 +44,7 @@ AC_HAVE_FUNCS(strsave seteuid setreuid setresuid) AC_PROG_AWK V5_SHARED_LIB_OBJS SubdirLibraryRule([$(OBJS)]) -V5_MAKE_SHARED_LIB(libkrb4,0.1,.., ./krb4) +V5_MAKE_SHARED_LIB(libkrb4,1.0,.., ./krb4) CopyHeader(krb_err.h,$(EHDRDIR)) CRYPTO_SH_VERS=$krb5_cv_shlib_version_libcrypto AC_SUBST(CRYPTO_SH_VERS) diff --git a/src/lib/krb4/g_cnffile.c b/src/lib/krb4/g_cnffile.c index a212beb..dfc342d 100644 --- a/src/lib/krb4/g_cnffile.c +++ b/src/lib/krb4/g_cnffile.c @@ -19,28 +19,32 @@ #include #include "k5-int.h" +krb5_context krb5__krb4_context = 0; + static FILE* krb__v5_get_file(s) char *s; { FILE *cnffile = 0; - krb5_context context; const char* names[3]; char **full_name = 0, **cpp; krb5_error_code retval; - krb5_init_context(&context); + if (!krb5__krb4_context) + krb5_init_context(&krb5__krb4_context); names[0] = "libdefaults"; names[1] = s; names[2] = 0; - retval = profile_get_values(context->profile, names, &full_name); - if (retval == 0 && full_name && full_name[0]) { + if (krb5__krb4_context) { + retval = profile_get_values(krb5__krb4_context->profile, names, + &full_name); + if (retval == 0 && full_name && full_name[0]) { cnffile = fopen(full_name[0],"r"); for (cpp = full_name; *cpp; cpp++) krb5_xfree(*cpp); krb5_xfree(full_name); + } } - krb5_free_context(context); return cnffile; } @@ -48,26 +52,28 @@ char * krb__get_srvtabname(default_srvtabname) char *default_srvtabname; { - krb5_context context; const char* names[3]; char **full_name = 0, **cpp; krb5_error_code retval; char *retname; - krb5_init_context(&context); + if (!krb5__krb4_context) + krb5_init_context(&krb5__krb4_context); names[0] = "libdefaults"; names[1] = "krb4_srvtab"; names[2] = 0; - retval = profile_get_values(context->profile, names, &full_name); - if (retval == 0 && full_name && full_name[0]) { + if (krb5__krb4_context) { + retval = profile_get_values(krb5__krb4_context->profile, names, + &full_name); + if (retval == 0 && full_name && full_name[0]) { retname = strdup(full_name[0]); for (cpp = full_name; *cpp; cpp++) - krb5_xfree(*cpp); + krb5_xfree(*cpp); krb5_xfree(full_name); - } else { - retname = strdup(default_srvtabname); + return retname; + } } - krb5_free_context(context); + retname = strdup(default_srvtabname); return retname; } diff --git a/src/lib/krb4/g_krbhst.c b/src/lib/krb4/g_krbhst.c index eaab289..ef97d39 100644 --- a/src/lib/krb4/g_krbhst.c +++ b/src/lib/krb4/g_krbhst.c @@ -75,7 +75,7 @@ krb_get_krbhst(h,r,n) cnffile = krb__get_cnffile(); if (!cnffile) return get_krbhst_default(h, r, n); - if (fscanf(cnffile,"%s",tr) == EOF) + if (fscanf(cnffile,"%39s",tr) == EOF) /* XXX assumes REALM_SZ == 40 */ return get_krbhst_default(h, r, n); /* run through the file, looking for the nth server for this realm */ for (i = 1; i <= n;) { @@ -83,7 +83,7 @@ krb_get_krbhst(h,r,n) (void) fclose(cnffile); return get_krbhst_default(h, r, n); } - if (sscanf(linebuf, "%s %s", tr, h) != 2) + if (sscanf(linebuf, "%39s %1023s", tr, h) != 2) /* REALM_SZ == 40 */ continue; if (!strcmp(tr,r)) i++; diff --git a/src/lib/krb4/g_krbrlm.c b/src/lib/krb4/g_krbrlm.c index f83beba..6896c2a 100644 --- a/src/lib/krb4/g_krbrlm.c +++ b/src/lib/krb4/g_krbrlm.c @@ -51,7 +51,11 @@ krb_get_lrealm(r,n) return(KFAILURE); } - if (fscanf(cnffile,"%s",r) != 1) { + /* + * XXX This assumes REALM_SZ == 40, + * and that r is 40 characters long. + */ + if (fscanf(cnffile,"%39s",r) != 1) { (void) fclose(cnffile); return(KFAILURE); } diff --git a/src/lib/krb4/klog.c b/src/lib/krb4/klog.c index f838fb7..a1a5371 100644 --- a/src/lib/krb4/klog.c +++ b/src/lib/krb4/klog.c @@ -87,8 +87,8 @@ char * klog(type,format,a1,a2,a3,a4,a5,a6,a7,a8,a9,a0) (void) time(&now); tm = localtime(&now); - fprintf(logfile,"%2d-%s-%02d %02d:%02d:%02d ",tm->tm_mday, - month_sname(tm->tm_mon + 1),tm->tm_year, + fprintf(logfile,"%2d-%s-%d %02d:%02d:%02d ",tm->tm_mday, + month_sname(tm->tm_mon + 1),1900+tm->tm_year, tm->tm_hour, tm->tm_min, tm->tm_sec); fprintf(logfile,"%s\n",logtxt); (void) fclose(logfile); diff --git a/src/lib/krb4/log.c b/src/lib/krb4/log.c index b419544..930225e 100644 --- a/src/lib/krb4/log.c +++ b/src/lib/krb4/log.c @@ -68,8 +68,8 @@ void krb_log(format,a1,a2,a3,a4,a5,a6,a7,a8,a9,a0) (void) time(&now); tm = localtime(&now); - fprintf(logfile,"%2d-%s-%02d %02d:%02d:%02d ",tm->tm_mday, - month_sname(tm->tm_mon + 1),tm->tm_year, + fprintf(logfile,"%2d-%s-%d %02d:%02d:%02d ",tm->tm_mday, + month_sname(tm->tm_mon + 1),1900+tm->tm_year, tm->tm_hour, tm->tm_min, tm->tm_sec); fprintf(logfile,format,a1,a2,a3,a4,a5,a6,a7,a8,a9,a0); fprintf(logfile,"\n"); @@ -114,8 +114,8 @@ krb_new_log(t,string) if (t) { tm = localtime(&t); - fprintf(logfile,"\n%2d-%s-%02d %02d:%02d:%02d %s",tm->tm_mday, - month_sname(tm->tm_mon + 1),tm->tm_year, + fprintf(logfile,"\n%2d-%s-%d %02d:%02d:%02d %s",tm->tm_mday, + month_sname(tm->tm_mon + 1),1900+tm->tm_year, tm->tm_hour, tm->tm_min, tm->tm_sec, string); } else { diff --git a/src/lib/krb4/realmofhost.c b/src/lib/krb4/realmofhost.c index cff11cc..e4529d5 100644 --- a/src/lib/krb4/realmofhost.c +++ b/src/lib/krb4/realmofhost.c @@ -48,7 +48,11 @@ char *host; char *domain; FILE *trans_file; FILE *krb__get_realmsfile(); - char trans_host[MAXHOSTNAMELEN+1]; + /* + * This used to be MAXHOSTNAMELEN, but we don't know how big + * that will necessarily be on all systems, so assume 1024. + */ + char trans_host[1025]; char trans_realm[REALM_SZ+1]; int retval; struct hostent *h; @@ -111,24 +115,28 @@ char *host; /* loop while not exact match, and more entries to read */ while (1) { - if ((retval = fscanf(trans_file, "%s %s", + /* XXX REALM_SZ == 40 */ + if ((retval = fscanf(trans_file, "%1023s %40s", trans_host, trans_realm)) != 2) { if (retval == EOF) break; continue; /* ignore broken lines */ } - trans_host[MAXHOSTNAMELEN] = '\0'; + trans_host[(MAXHOSTNAMELEN <= 1023) ? MAXHOSTNAMELEN : 1023] + = '\0'; trans_realm[REALM_SZ] = '\0'; if (trans_host[0] == '.') { /* want domain match only */ - if (domain && !strcasecmp (trans_host, domain)) { + if (domain && (strlen(trans_host) == strlen(domain)) + && !strcasecmp (trans_host, domain)) { /* got domain match, save for later */ (void) strcpy (ret_realm, trans_realm); continue; } } else { /* want exact match of hostname */ - if (!strcasecmp (trans_host, lhost)) { + if ((strlen(lhost) == strlen(trans_host)) && + !strcasecmp (trans_host, lhost)) { (void) strcpy (ret_realm, trans_realm); break; } diff --git a/src/lib/krb4/stime.c b/src/lib/krb4/stime.c index f90fbc5..780455c 100644 --- a/src/lib/krb4/stime.c +++ b/src/lib/krb4/stime.c @@ -32,8 +32,8 @@ char *krb_stime(t) adjusted_time = *t - CONVERT_TIME_EPOCH; tm = localtime(&adjusted_time); - (void) sprintf(st,"%2d-%s-%02d %02d:%02d:%02d",tm->tm_mday, - month_sname(tm->tm_mon + 1),tm->tm_year, + (void) sprintf(st,"%2d-%s-%d %02d:%02d:%02d",tm->tm_mday, + month_sname(tm->tm_mon + 1),1900+tm->tm_year, tm->tm_hour, tm->tm_min, tm->tm_sec); return st; } diff --git a/src/lib/krb4/tf_util.c b/src/lib/krb4/tf_util.c index 05902fa..2e62672 100644 --- a/src/lib/krb4/tf_util.c +++ b/src/lib/krb4/tf_util.c @@ -184,13 +184,15 @@ int tf_init(tf_name, rw) { int wflag; uid_t me, getuid(); - struct stat stat_buf; + struct stat stat_buf, stat_buffd; #ifdef TKT_SHMEM char shmidname[MAXPATHLEN]; FILE *sfp; int shmid; #endif + me = getuid(); + switch (rw) { case R_TKT_FIL: wflag = 0; @@ -207,25 +209,9 @@ int tf_init(tf_name, rw) if (tf_name == 0) tf_name = tkt_string(); - if (lstat(tf_name, &stat_buf) < 0) - switch (errno) { - case ENOENT: - return NO_TKT_FIL; - default: - return TKT_FIL_ACC; - } - me = getuid(); - if ((stat_buf.st_uid != me && me != 0) || - ((stat_buf.st_mode & S_IFMT) != S_IFREG)) - return TKT_FIL_ACC; #ifdef TKT_SHMEM (void) strcpy(shmidname, tf_name); (void) strcat(shmidname, ".shm"); - if (stat(shmidname,&stat_buf) < 0) - return(TKT_FIL_ACC); - if ((stat_buf.st_uid != me && me != 0) || - ((stat_buf.st_mode & S_IFMT) != S_IFREG)) - return TKT_FIL_ACC; #endif /* TKT_SHMEM */ /* @@ -240,15 +226,51 @@ int tf_init(tf_name, rw) #ifdef TKT_SHMEM sfp = fopen(shmidname, "r"); /* only need read/write on the actual tickets */ - if (sfp == 0) - return TKT_FIL_ACC; + if (sfp == 0) { + switch(errno) { + case ENOENT: + return NO_TKT_FIL; + default: + return TKT_FIL_ACC; + } + } + + /* lstat() and fstat() the file to check that the file we opened is the * + * one we think it is, and to check ownership. */ + if ((fstat(sfp->_file, &stat_buffd) < 0) || + (lstat(shmidname, &stat_buf) < 0)) { + (void) close(fd); + fd = -1; + switch(errno) { + case ENOENT: + return NO_TKT_FIL; + default: + return TKT_FIL_ACC; + } + } + /* Check that it's the right file */ + if ((stat_buf.st_ino != stat_buffd.st_ino) || + (stat_buf.st_dev != stat_buffd.st_dev)) { + (void) close(fd); + fd = -1; + return TKT_FIL_ACC; + } + /* Check ownership */ + if ((stat_buffd.st_uid != me && me != 0) || + ((stat_buffd.st_mode & S_IFMT) != S_IFREG)) { + (void) close(fd); + fd = -1; + return TKT_FIL_ACC; + } + + + shmid = -1; { char buf[BUFSIZ]; int val; /* useful for debugging fscanf */ /* We provide our own buffer here since some STDIO libraries barf on unbuffered input with fscanf() */ - setbuf(sfp, buf); if ((val = fscanf(sfp,"%d",&shmid)) != 1) { (void) fclose(sfp); @@ -280,6 +302,38 @@ int tf_init(tf_name, rw) if (wflag) { fd = open(tf_name, O_RDWR, 0600); if (fd < 0) { + switch(errno) { + case ENOENT: + return NO_TKT_FIL; + default: + return TKT_FIL_ACC; + } + } + /* lstat() and fstat() the file to check that the file we opened is the * + * one we think it is, and to check ownership. */ + if ((fstat(fd, &stat_buffd) < 0) || + (lstat(tf_name, &stat_buf) < 0)) { + (void) close(fd); + fd = -1; + switch(errno) { + case ENOENT: + return NO_TKT_FIL; + default: + return TKT_FIL_ACC; + } + } + /* Check that it's the right file */ + if ((stat_buf.st_ino != stat_buffd.st_ino) || + (stat_buf.st_dev != stat_buffd.st_dev)) { + (void) close(fd); + fd = -1; + return TKT_FIL_ACC; + } + /* Check ownership */ + if ((stat_buffd.st_uid != me && me != 0) || + ((stat_buffd.st_mode & S_IFMT) != S_IFREG)) { + (void) close(fd); + fd = -1; return TKT_FIL_ACC; } if (flock(fd, LOCK_EX | LOCK_NB) < 0) { @@ -299,6 +353,38 @@ int tf_init(tf_name, rw) fd = open(tf_name, O_RDONLY, 0600); if (fd < 0) { + switch(errno) { + case ENOENT: + return NO_TKT_FIL; + default: + return TKT_FIL_ACC; + } + } + /* lstat() and fstat() the file to check that the file we opened is the * + * one we think it is, and to check ownership. */ + if ((fstat(fd, &stat_buffd) < 0) || + (lstat(tf_name, &stat_buf) < 0)) { + (void) close(fd); + fd = -1; + switch(errno) { + case ENOENT: + return NO_TKT_FIL; + default: + return TKT_FIL_ACC; + } + } + /* Check that it's the right file */ + if ((stat_buf.st_ino != stat_buffd.st_ino) || + (stat_buf.st_dev != stat_buffd.st_dev)) { + (void) close(fd); + fd = -1; + return TKT_FIL_ACC; + } + /* Check ownership */ + if ((stat_buffd.st_uid != me && me != 0) || + ((stat_buffd.st_mode & S_IFMT) != S_IFREG)) { + (void) close(fd); + fd = -1; return TKT_FIL_ACC; } if (flock(fd, LOCK_SH | LOCK_NB) < 0) { diff --git a/src/lib/krb5/ChangeLog b/src/lib/krb5/ChangeLog index 00b17c7..e77f6b9 100644 --- a/src/lib/krb5/ChangeLog +++ b/src/lib/krb5/ChangeLog @@ -1,3 +1,7 @@ +Mon Nov 18 20:42:39 1996 Ezra Peisach + + * configure.in: Set shared library version to 1.0. [krb5-libs/201] + Wed Oct 23 01:15:40 1996 Theodore Y. Ts'o * configure.in, Makefile.in: Check to see if the -lgen library diff --git a/src/lib/krb5/asn.1/ChangeLog b/src/lib/krb5/asn.1/ChangeLog index 8aa3684..e6f9777 100644 --- a/src/lib/krb5/asn.1/ChangeLog +++ b/src/lib/krb5/asn.1/ChangeLog @@ -1,3 +1,30 @@ +Thu Dec 3 19:41:06 1998 Tom Yu + + * asn1_k_decode.c (asn1_decode_krb5_flags): Fix previous to + properly left-justify bit strings less than 32 bits. + + * asn1_k_decode.c (asn1_decode_krb5_flags): Modify to deal with + BIT STRING values that are not exactly 32 bits. Throw away bits + beyond number 31 in a bit string for now. Deal with masking out + unused bits. + +1998-10-27 Marc Horowitz + + * asn1buf.c (asn1buf_sync): interoperation testing against heimdal + revealed a bug. if extra fields are present in a SEQUENCE, they + are not ignored and skipped. This caused the decoder to get out + of sync. + +Thu Apr 16 17:01:27 1998 Tom Yu + + * asn1_encode.c (asn1_encode_generaltime): Sanity check the return + from gmtime() to avoid overruns. + +Wed Jan 14 20:57:33 1998 Tom Yu + + * asn1buf.c (asn12krb5_buf): Check return value of + calloc. [krb5-libs/518] + Thu Nov 14 20:57:55 1996 Theodore Y. Ts'o * asn1_k_encode.c (asn1_encode_principal_name): Be liberal about diff --git a/src/lib/krb5/asn.1/asn1_encode.c b/src/lib/krb5/asn.1/asn1_encode.c index 16c25ca..826fc94 100644 --- a/src/lib/krb5/asn.1/asn1_encode.c +++ b/src/lib/krb5/asn.1/asn1_encode.c @@ -203,7 +203,17 @@ asn1_error_code asn1_encode_generaltime(buf, val, retlen) gmt_time = val + EPOCH; gtime = gmtime(&gmt_time); - /* Time encoding: YYYYMMDDhhmmssZ */ + /* + * Time encoding: YYYYMMDDhhmmssZ + * + * Sanity check this just to be paranoid, as gmtime can return NULL, + * and some bogus implementations might overrun on the sprintf. + */ + if (gtime == NULL || + gtime->tm_year > 9999 || gtime->tm_mon > 11 || + gtime->tm_mday > 31 || gtime->tm_hour > 23 || + gtime->tm_min > 59 || gtime->tm_sec > 59) + return ASN1_BAD_GMTIME; sprintf(s, "%04d%02d%02d%02d%02d%02dZ", 1900+gtime->tm_year, gtime->tm_mon+1, gtime->tm_mday, gtime->tm_hour, gtime->tm_min, gtime->tm_sec); diff --git a/src/lib/krb5/asn.1/asn1_k_decode.c b/src/lib/krb5/asn.1/asn1_k_decode.c index 475bc06..090fcc3 100644 --- a/src/lib/krb5/asn.1/asn1_k_decode.c +++ b/src/lib/krb5/asn.1/asn1_k_decode.c @@ -272,7 +272,7 @@ asn1_error_code asn1_decode_krb5_flags(buf, val) krb5_flags * val; { setup(); - asn1_octet o; + asn1_octet unused, o; int i; krb5_flags f=0; unused_var(taglen); @@ -281,17 +281,28 @@ asn1_error_code asn1_decode_krb5_flags(buf, val) if(retval) return retval; if(class != UNIVERSAL || construction != PRIMITIVE || tagnum != ASN1_BITSTRING) return ASN1_BAD_ID; - if(length != 5) return ASN1_BAD_LENGTH; - retval = asn1buf_remove_octet(buf,&o); /* # of padding bits */ - if(retval) return retval; /* should be 0 */ - if(o != 0) return ASN1_BAD_FORMAT; + retval = asn1buf_remove_octet(buf,&unused); /* # of padding bits */ + if(retval) return retval; + + /* Number of unused bits must be between 0 and 7. */ + if (unused > 7) return ASN1_BAD_FORMAT; + length--; - for(i=0; i<4; i++){ + for(i = 0; i < length; i++) { retval = asn1buf_remove_octet(buf,&o); if(retval) return retval; - f = (f<<8) | ((krb5_flags)o&0xFF); + /* ignore bits past number 31 */ + if (i < 4) + f = (f<<8) | ((krb5_flags)o&0xFF); + } + if (length <= 4) { + /* Mask out unused bits, but only if necessary. */ + f &= ~(krb5_flags)0 << unused; } + /* left-justify */ + if (length < 4) + f <<= (4 - length) * 8; *val = f; return 0; } diff --git a/src/lib/krb5/asn.1/asn1buf.c b/src/lib/krb5/asn.1/asn1buf.c index 822b263..2ee95c4 100644 --- a/src/lib/krb5/asn.1/asn1buf.c +++ b/src/lib/krb5/asn.1/asn1buf.c @@ -91,7 +91,7 @@ void asn1buf_sync(buf, subbuf) asn1buf * buf; asn1buf * subbuf; { - buf->next = subbuf->next; + buf->next = subbuf->bound + 1; } asn1_error_code asn1buf_destroy(buf) @@ -231,6 +231,10 @@ asn1_error_code asn12krb5_buf(buf, code) (*code)->length = 0; (*code)->length = asn1buf_len(buf); (*code)->data = (char*)calloc(((*code)->length)+1,sizeof(char)); + if ((*code)->data == NULL) { + free(*code); + return ENOMEM; + } for(i=0; i < (*code)->length; i++) ((*code)->data)[i] = (buf->base)[((*code)->length)-i-1]; ((*code)->data)[(*code)->length] = '\0'; diff --git a/src/lib/krb5/configure.in b/src/lib/krb5/configure.in index c612ed7..2ac53bd 100644 --- a/src/lib/krb5/configure.in +++ b/src/lib/krb5/configure.in @@ -16,7 +16,7 @@ dnl AC_CHECK_LIB(gen,compile,SHLIB_GEN=-lgen,SHLIB_GEN='') AC_SUBST(SHLIB_GEN) dnl -V5_MAKE_SHARED_LIB(libkrb5,0.1,.., ./krb5) +V5_MAKE_SHARED_LIB(libkrb5,1.0,.., ./krb5) CRYPTO_SH_VERS=$krb5_cv_shlib_version_libcrypto AC_SUBST(CRYPTO_SH_VERS) COMERR_SH_VERS=$krb5_cv_shlib_version_libcom_err diff --git a/src/lib/krb5/error_tables/ChangeLog b/src/lib/krb5/error_tables/ChangeLog index 0b60e42..caccd26 100644 --- a/src/lib/krb5/error_tables/ChangeLog +++ b/src/lib/krb5/error_tables/ChangeLog @@ -1,3 +1,12 @@ +Thu Apr 16 20:51:40 1998 Tom Yu + + * asn1_err.et (ASN1_BAD_GMTIME): Add code for case where bad + values are returned from gmtime(). + +Tue Nov 19 17:06:26 1996 Barry Jaspan + + * krb5_err.et: add KRB5_KT_KVNONOTFOUND [krb5-libs/198] + Wed Nov 6 11:15:32 1996 Theodore Ts'o * krb5_err.et: Make the KRB5_CONFIG_CANTOPEN and diff --git a/src/lib/krb5/error_tables/asn1_err.et b/src/lib/krb5/error_tables/asn1_err.et index 9d823c1..f0136cf 100644 --- a/src/lib/krb5/error_tables/asn1_err.et +++ b/src/lib/krb5/error_tables/asn1_err.et @@ -9,4 +9,5 @@ error_code ASN1_BAD_ID, "ASN.1 identifier doesn't match expected value" error_code ASN1_BAD_LENGTH, "ASN.1 length doesn't match expected value" error_code ASN1_BAD_FORMAT, "ASN.1 badly-formatted encoding" error_code ASN1_PARSE_ERROR, "ASN.1 parse error" +error_code ASN1_BAD_GMTIME, "ASN.1 bad return from gmtime" end diff --git a/src/lib/krb5/error_tables/krb5_err.et b/src/lib/krb5/error_tables/krb5_err.et index 06af955..1b42232 100644 --- a/src/lib/krb5/error_tables/krb5_err.et +++ b/src/lib/krb5/error_tables/krb5_err.et @@ -300,5 +300,6 @@ error_code KRB5_CONFIG_NODEFREALM, "Configuration file does not specify default error_code KRB5_SAM_UNSUPPORTED, "Bad SAM flags in obtain_sam_padata" error_code KRB5_KT_NAME_TOOLONG, "Keytab name too long" +error_code KRB5_KT_KVNONOTFOUND, "Key version number for principal in key table is incorrect" end diff --git a/src/lib/krb5/keytab/file/ChangeLog b/src/lib/krb5/keytab/file/ChangeLog index c37f709..f14e2a0 100644 --- a/src/lib/krb5/keytab/file/ChangeLog +++ b/src/lib/krb5/keytab/file/ChangeLog @@ -1,3 +1,8 @@ +Tue Nov 19 17:06:59 1996 Barry Jaspan + + * ktf_g_ent.c (krb5_ktfile_get_entry): return KRB5_KT_KVNONOTFOUND + when appropriate [krb5-libs/198] + Wed Jul 24 17:10:11 1996 Theodore Y. Ts'o * ktf_g_name.c (krb5_ktfile_get_name): Use the error code diff --git a/src/lib/krb5/keytab/file/ktf_g_ent.c b/src/lib/krb5/keytab/file/ktf_g_ent.c index 4805d5c..e42dcdb 100644 --- a/src/lib/krb5/keytab/file/ktf_g_ent.c +++ b/src/lib/krb5/keytab/file/ktf_g_ent.c @@ -40,6 +40,7 @@ krb5_ktfile_get_entry(context, id, principal, kvno, enctype, entry) { krb5_keytab_entry cur_entry, new_entry; krb5_error_code kerror = 0; + int found_wrong_kvno = 0; /* Open the keyfile for reading */ if ((kerror = krb5_ktfileint_openr(context, id))) @@ -92,14 +93,21 @@ krb5_ktfile_get_entry(context, id, principal, kvno, enctype, entry) krb5_kt_free_entry(context, &cur_entry); cur_entry = new_entry; break; - } + } else + found_wrong_kvno++; } } else { krb5_kt_free_entry(context, &new_entry); } } - if (kerror == KRB5_KT_END) - kerror = cur_entry.principal ? 0 : KRB5_KT_NOTFOUND; + if (kerror == KRB5_KT_END) { + if (cur_entry.principal) + kerror = 0; + else if (found_wrong_kvno) + kerror = KRB5_KT_KVNONOTFOUND; + else + kerror = KRB5_KT_NOTFOUND; + } if (kerror) { (void) krb5_ktfileint_close(context, id); krb5_kt_free_entry(context, &cur_entry); diff --git a/src/lib/krb5/krb/ChangeLog b/src/lib/krb5/krb/ChangeLog index c702d0a..a1a5bac 100644 --- a/src/lib/krb5/krb/ChangeLog +++ b/src/lib/krb5/krb/ChangeLog @@ -1,3 +1,132 @@ +2000-02-01 Ken Raeburn + + * init_ctx.c (init_common): Renamed from krb5_init_context, now + static. New argument SECURE provides initialization of + profile_secure field. + (krb5_init_context): Call it. + (krb5_init_secure_context): New function. + + * str_conv.c (krb5_deltat_to_string): Always write to a local + temporary buffer that's guaranteed to be large enough, then see if + the supplied output buffer is big enough. + (krb5_string_to_deltat): Deleted. + * deltat.c: New file. + + * str_conv.c: Removed most static char arrays, substituting the + values in place. + (krb5_string_to_timestamp): Move atime_format_table inside here. + (krb5_timestamp_to_sfstring): Move sftime_format_table inside + here. + + * str_conv.c: If strftime or strptime are not available, include + the renamed NetBSD versions, and define the function names as + macros to map them to the replacement names. + (__P, _CurrentTimeLocale, dummy_locale_info, TM_YEAR_BASE, + DAYSPERLYEAR, DAYSPERNYEAR, DAYSPERWEEK, isleap, tzname, tzset): + Define some dummies for strftime/strptime to use. + (strptime): Deleted old stub version. + (krb5_timestamp_to_string, krb5_timestamp_to_sfstring): Always + assume strftime is available. + (krb5_string_to_timestamp): Assume strptime is always available. + * strftime.c, strptime.c: New files, based on NetBSD versions. + Modified to rename the functions and not export any symbols. + +Mon Mar 8 22:39:01 1999 Tom Yu + + * sendauth.c (krb5_sendauth): Set credspout to NULL if it's + destined to be returned to avoid freeing it. Also, + unconditionally free credspout if it's non-NULL so that if someone + doesn't pass in a ticket and doesn't give us a non-NULL out_creds, + we don't leak it. [krb5-libs/699] + +Fri Jan 29 22:46:37 1999 Tom Yu + + * recvauth.c (krb5_recvauth): Add some bookkeeping flags so we + know how much stuff to free upon cleanup. Fix the up cleanup + code. + +Wed Jul 15 11:46:05 1998 Ezra Peisach + + * t_ref_kerb.out: Fix test case for zephyr principal to reflect + addition to conv_princ.c + +Tue Jul 7 17:06:13 1998 Theodore Y. Ts'o + + * conv_princ.c: Add additional commonly seen Kerberos V4 services + to the hard-coded list. + +Tue Jul 7 16:59:03 1998 Tom Yu + + * chk_trans.c: Fix up previous fix; short-circuit out when + trans->length == 0. + +Wed Jul 1 17:59:26 1998 Theodore Y. Ts'o + + * chk_trans.c (krb5_check_transited_list): Fix use of an + uninitialized variable; apparently the code was depending + on the stack garbage being non-zero(!) + +1998-05-12 Theodore Ts'o + + * str_conv.c (krb5_timestamp_to_sfstring): Make sure the date + string printed uses 4 digit years. + +1998-05-08 Theodore Ts'o + + * str_conv.c (krb5_string_to_timestamp, strptime): Fix routines to + be able to properly parse Y2K dates. + + * t_kerb.c: Add ability to test krb5_string_to_timestamp + +Mon Mar 16 19:50:55 1998 Tom Yu + + * chk_trans.c (krb5_check_transited_list): Check lengths when + appending to next and prev. + +Wed Jan 14 20:58:52 1998 Tom Yu + + * preauth.c (handle_sam_labels): Check return value of + malloc. [krb5-libs/518] + +Wed Oct 22 00:29:33 1997 Theodore Y. Ts'o + + * send_tgs.c (krb5_send_tgs): Don't send a zero endtime; if the + requested endtime is zero, set it equal to the TGT endtime. + +Sat Dec 21 01:26:11 1996 Theodore Y. Ts'o + + * brand.c: New file, which allows a release engineer to "brand" + the krb5 library or a binary application program + statically linked against the krb5 library. This file is + statically included by init_ctx.c, to force it be in a + binary library or application program. + +Tue Mar 25 00:32:55 1997 Theodore Y. Ts'o + + * preauth.c (obtain_sam_padata): Fix handling of the sam-timestamp + and sam-usec fields, which should always be set if the + nonce is not available, not just SAM_USE_SAD_AS_KEY is + being used. [krb5-libs/325] + +Wed Feb 12 20:47:30 1997 Tom Yu + + * fwd_tgt.c (krb5_fwd_tgt_creds): Use the client's realm rather + than the server's realm for constructing the tgs principal. + Remove TC_MATCH_SRV_NAMEONLY from call to retrieve_cred() because + we want to get an exact match. + +Tue Apr 8 10:31:30 1997 Theodore Ts'o + + * sendauth.c (krb5_sendauth): Don't free credspout if it is to be + returned in out_creds (#PR 357) + +Thu Nov 21 13:54:01 1996 Ezra Peisach + + * recvauth.c (krb5_recvauth): If there is an error, and the server + argument to krb5_recvauth is NULL, create a dummy server + entry for the krb5_error structure so that krb5_mk_error + will not die with missing required fields. [krb5-libs/209] + Wed Nov 13 14:30:47 1996 Tom Yu * init_ctx.c: Revert previous kt_default_name changes. diff --git a/src/lib/krb5/krb/Makefile.in b/src/lib/krb5/krb/Makefile.in index 939c1a5..dc96e03 100644 --- a/src/lib/krb5/krb/Makefile.in +++ b/src/lib/krb5/krb/Makefile.in @@ -28,6 +28,7 @@ OBJS= addr_comp.$(OBJEXT) \ cp_key_cnt.$(OBJEXT) \ decode_kdc.$(OBJEXT) \ decrypt_tk.$(OBJEXT) \ + deltat.$(OBJEXT) \ encode_kdc.$(OBJEXT) \ encrypt_tk.$(OBJEXT) \ free_rtree.$(OBJEXT) \ @@ -101,6 +102,7 @@ SRCS= $(srcdir)/addr_comp.c \ $(srcdir)/cp_key_cnt.c \ $(srcdir)/decode_kdc.c \ $(srcdir)/decrypt_tk.c \ + $(srcdir)/deltat.c \ $(srcdir)/encode_kdc.c \ $(srcdir)/encrypt_tk.c \ $(srcdir)/free_rtree.c \ @@ -166,7 +168,7 @@ COMERRLIB=$(TOPLIBD)/libcom_err.a T_WALK_RTREE_OBJS= t_walk_rtree.o walk_rtree.o tgtname.o unparse.o \ free_rtree.o bld_pr_ext.o -T_KERB_OBJS= t_kerb.o conv_princ.o unparse.o +T_KERB_OBJS= t_kerb.o conv_princ.o unparse.o str_conv.o T_SER_OBJS= t_ser.o ser_actx.o ser_adata.o ser_addr.o ser_auth.o ser_cksum.o \ ser_ctx.o ser_eblk.o ser_key.o ser_princ.o serialize.o diff --git a/src/lib/krb5/krb/brand.c b/src/lib/krb5/krb/brand.c new file mode 100644 index 0000000..de48d58 --- /dev/null +++ b/src/lib/krb5/krb/brand.c @@ -0,0 +1,15 @@ +/* + * This file is used to put a "release brand" on a Krb5 library before + * it is released via some release engineering process. This gives us + * an easy way to tell where a binary came from. + * + * It currently is manually maintained, because there's no good way to + * automatically have CVS do the right thing. We could put RCS tags + * in every single file, but that (a) takes up lots of space, since we + * have lots of files in the Kerberos library, and (b) it makes CVS + * merges a real pain. + */ + +/* Format: "KRB5_BRAND: " */ + +static char krb5_brand[] = "KRB5_BRAND: Unbranded release"; diff --git a/src/lib/krb5/krb/chk_trans.c b/src/lib/krb5/krb/chk_trans.c index 0961d6a..c2ac716 100644 --- a/src/lib/krb5/krb/chk_trans.c +++ b/src/lib/krb5/krb/chk_trans.c @@ -40,9 +40,16 @@ krb5_data *realm2; krb5_error_code retval = 0; krb5_principal *tgs_list; - if (!trans || !trans->data) return(0); + if (trans == NULL || trans->data == NULL || trans->length == 0) + return(0); trans_length = trans->data[trans->length-1] ? - trans->length : trans->length - 1; + trans->length : trans->length - 1; + + for (i = 0; i < trans_length; i++) + if (trans->data[i] == '\0') { + /* Realms may not contain ASCII NUL character. */ + return(KRB5KRB_AP_ERR_ILL_CR_TKT); + } if ((retval = krb5_walk_realm_tree(context, realm1, realm2, &tgs_list, KRB5_REALM_BRANCH_CHAR))) { @@ -51,19 +58,28 @@ krb5_data *realm2; memset(prev, 0, MAX_REALM_LN + 1); memset(next, 0, MAX_REALM_LN + 1), nextp = next; - for (i = 0; i <= trans_length; i++) { + for (i = 0; i < trans_length; i++) { if (i < trans_length-1 && trans->data[i] == '\\') { i++; *nextp++ = trans->data[i]; + if (nextp - next > MAX_REALM_LN) { + retval = KRB5KRB_AP_ERR_ILL_CR_TKT; + goto finish; + } continue; } if (i < trans_length && trans->data[i] != ',') { *nextp++ = trans->data[i]; + if (nextp - next > MAX_REALM_LN) { + retval = KRB5KRB_AP_ERR_ILL_CR_TKT; + goto finish; + } continue; } if (strlen(next) > 0) { if (next[0] != '/') { - if (*(nextp-1) == '.') strcat(next, prev); + if (*(nextp-1) == '.' && strlen(next) + strlen(prev) <= MAX_REALM_LN) + strcat(next, prev); retval = KRB5KRB_AP_ERR_ILL_CR_TKT; for (j = 0; tgs_list[j]; j++) { if (strlen(next) == (size_t) krb5_princ_realm(context, tgs_list[j])->length && diff --git a/src/lib/krb5/krb/conv_princ.c b/src/lib/krb5/krb/conv_princ.c index d11fac3..e1833b3 100644 --- a/src/lib/krb5/krb/conv_princ.c +++ b/src/lib/krb5/krb/conv_princ.c @@ -67,6 +67,40 @@ static const struct krb_convert sconv_list[] = { {"imap", "imap", DO_REALM_CONVERSION}, {"ftp", "ftp", DO_REALM_CONVERSION}, {"ecat", "ecat", DO_REALM_CONVERSION}, + {"daemon", "daemon", DO_REALM_CONVERSION}, + {"gnats", "gnats", DO_REALM_CONVERSION}, + {"moira", "moira", DO_REALM_CONVERSION}, + {"prms", "prms", DO_REALM_CONVERSION}, + {"mandarin", "mandarin", DO_REALM_CONVERSION}, + {"register", "register", DO_REALM_CONVERSION}, + {"changepw", "changepw", DO_REALM_CONVERSION}, + {"sms", "sms", DO_REALM_CONVERSION}, + {"afpserver", "afpserver", DO_REALM_CONVERSION}, + {"gdss", "gdss", DO_REALM_CONVERSION}, + {"news", "news", DO_REALM_CONVERSION}, + {"abs", "abs", DO_REALM_CONVERSION}, + {"nfs", "nfs", DO_REALM_CONVERSION}, + {"tftp", "tftp", DO_REALM_CONVERSION}, + {"zephyr", "zephyr", DO_REALM_CONVERSION}, + {"http", "http", DO_REALM_CONVERSION}, + {"khttp", "khttp", DO_REALM_CONVERSION}, + {"pgpsigner", "pgpsigner", DO_REALM_CONVERSION}, + {"irc", "irc", DO_REALM_CONVERSION}, + {"mandarin-agent", "mandarin-agent", DO_REALM_CONVERSION}, + {"write", "write", DO_REALM_CONVERSION}, + {"palladium", "palladium", DO_REALM_CONVERSION}, + {"news", "news", DO_REALM_CONVERSION}, + {"abs", "abs", DO_REALM_CONVERSION}, + {"nfs", "nfs", DO_REALM_CONVERSION}, + {"tftp", "tftp", DO_REALM_CONVERSION}, + {"zephyr", "zephyr", DO_REALM_CONVERSION}, + {"http", "http", DO_REALM_CONVERSION}, + {"khttp", "khttp", DO_REALM_CONVERSION}, + {"pgpsigner", "pgpsigner", DO_REALM_CONVERSION}, + {"irc", "irc", DO_REALM_CONVERSION}, + {"mandarin-agent", "mandarin-agent", DO_REALM_CONVERSION}, + {"write", "write", DO_REALM_CONVERSION}, + {"palladium", "palladium", DO_REALM_CONVERSION}, {0, 0, 0}, }; diff --git a/src/lib/krb5/krb/deltat.c b/src/lib/krb5/krb/deltat.c new file mode 100644 index 0000000..dbf9900 --- /dev/null +++ b/src/lib/krb5/krb/deltat.c @@ -0,0 +1,1063 @@ + +/* A Bison parser, made from ../../../../asrc/lib/krb5/krb/x-deltat.y + by GNU Bison version 1.27 + */ + +#define YYBISON 1 /* Identify Bison output. */ + +#define NUM 257 +#define LONGNUM 258 +#define WS 259 + +#line 38 "../../../../asrc/lib/krb5/krb/x-deltat.y" + + +#include +#include +#include "k5-int.h" + +#if 0 +#define NBITS(TYPE) (8*sizeof(TYPE)) +#define LOG10_2 0.30103 +#define LOG10_MAX(TYPE) (LOG10_2 * NBITS(TYPE)) +#define BUFFERSIZE(TYPE) (1 /* \0 */ + (int) (1 + LOG10_MAX(TYPE))) +#endif + +struct param { + krb5_deltat delta; + char *p; +}; + +#define YYPARSE_PARAM tmv + +#define DO(D,H,M,S) \ + { \ + ((struct param *)tmv)->delta = (((D * 24) + H) * 60 + M) * 60 + S; \ + } + +static int mylex (int *, char **); +#define YYLEX_PARAM (&((struct param *)tmv)->p) +#undef yylex +#define yylex(U, P) mylex (&(U)->val, (P)) + +#undef yyerror +#define yyerror(MSG) + +static int yyparse (void *); + + +#line 77 "../../../../asrc/lib/krb5/krb/x-deltat.y" +typedef union { int val; } YYSTYPE; +#include + +#ifndef __cplusplus +#ifndef __STDC__ +#define const +#endif +#endif + + + +#define YYFINAL 41 +#define YYFLAG -32768 +#define YYNTBASE 12 + +#define YYTRANSLATE(x) ((unsigned)(x) <= 259 ? yytranslate[x] : 21) + +static const char yytranslate[] = { 0, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 5, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 6, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 7, + 2, 2, 2, 8, 2, 2, 2, 2, 9, 2, + 2, 2, 2, 2, 10, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 1, 3, 4, 11 +}; + +#if YYDEBUG != 0 +static const short yyprhs[] = { 0, + 0, 2, 4, 6, 8, 11, 12, 14, 17, 21, + 25, 29, 32, 40, 46, 50, 52, 56, 58, 62, + 64 +}; + +static const short yyrhs[] = { 17, + 0, 3, 0, 4, 0, 13, 0, 5, 13, 0, + 0, 11, 0, 15, 14, 0, 16, 7, 18, 0, + 16, 8, 19, 0, 16, 9, 20, 0, 16, 10, + 0, 16, 5, 3, 6, 3, 6, 3, 0, 16, + 6, 3, 6, 3, 0, 16, 6, 3, 0, 19, + 0, 16, 8, 19, 0, 20, 0, 16, 9, 20, + 0, 15, 0, 16, 10, 0 +}; + +#endif + +#if YYDEBUG != 0 +static const short yyrline[] = { 0, + 88, 89, 89, 90, 90, 91, 91, 92, 93, 95, + 96, 97, 98, 99, 100, 103, 105, 106, 108, 109, + 111 +}; +#endif + + +#if YYDEBUG != 0 || defined (YYERROR_VERBOSE) + +static const char * const yytname[] = { "$","error","$undefined.","NUM","LONGNUM", +"'-'","':'","'d'","'h'","'m'","'s'","WS","start","posnum","num","ws","wsnum", +"deltat","opt_hms","opt_ms","opt_s", NULL +}; +#endif + +static const short yyr1[] = { 0, + 12, 13, 13, 14, 14, 15, 15, 16, 17, 17, + 17, 17, 17, 17, 17, 18, 18, 19, 19, 20, + 20 +}; + +static const short yyr2[] = { 0, + 1, 1, 1, 1, 2, 0, 1, 2, 3, 3, + 3, 2, 7, 5, 3, 1, 3, 1, 3, 1, + 2 +}; + +static const short yydefact[] = { 6, + 7, 0, 0, 1, 2, 3, 0, 4, 8, 0, + 0, 6, 6, 6, 12, 5, 0, 15, 20, 0, + 9, 16, 18, 0, 10, 0, 11, 0, 0, 6, + 6, 21, 0, 14, 17, 19, 0, 13, 0, 0, + 0 +}; + +static const short yydefgoto[] = { 39, + 8, 9, 19, 24, 4, 21, 22, 23 +}; + +static const short yypact[] = { -9, +-32768, 12, -1,-32768,-32768,-32768, 7,-32768,-32768, 10, + 16, -9, -9, -9,-32768,-32768, 20, 21, 12, 13, +-32768,-32768,-32768, 15,-32768, 18,-32768, 26, 27, -9, + -9,-32768, 28,-32768,-32768,-32768, 29,-32768, 33, 35, +-32768 +}; + +static const short yypgoto[] = {-32768, + 30,-32768, 36, 0,-32768,-32768, -12, -11 +}; + + +#define YYLAST 37 + + +static const short yytable[] = { 3, + 25, 1, 27, 10, 11, 12, 13, 14, 15, 5, + 6, 20, 17, 26, 5, 6, 7, 35, 18, 36, + 30, 31, 32, 31, 32, 28, 29, 32, 33, 34, + 26, 38, 40, 37, 41, 2, 16 +}; + +static const short yycheck[] = { 0, + 13, 11, 14, 5, 6, 7, 8, 9, 10, 3, + 4, 12, 3, 14, 3, 4, 5, 30, 3, 31, + 8, 9, 10, 9, 10, 6, 6, 10, 3, 3, + 31, 3, 0, 6, 0, 0, 7 +}; +#define YYPURE 1 + +/* -*-C-*- Note some compilers choke on comments on `#line' lines. */ +#line 3 "/mit/gnu/share/bison.simple" +/* This file comes from bison-1.27. */ + +/* Skeleton output parser for bison, + Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ + +/* This is the parser code that is written into each bison parser + when the %semantic_parser declaration is not specified in the grammar. + It was written by Richard Stallman by simplifying the hairy parser + used when %semantic_parser is specified. */ + +#ifndef YYSTACK_USE_ALLOCA +#ifdef alloca +#define YYSTACK_USE_ALLOCA +#else /* alloca not defined */ +#ifdef __GNUC__ +#define YYSTACK_USE_ALLOCA +#define alloca __builtin_alloca +#else /* not GNU C. */ +#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386)) +#define YYSTACK_USE_ALLOCA +#include +#else /* not sparc */ +/* We think this test detects Watcom and Microsoft C. */ +/* This used to test MSDOS, but that is a bad idea + since that symbol is in the user namespace. */ +#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__) +#if 0 /* No need for malloc.h, which pollutes the namespace; + instead, just don't use alloca. */ +#include +#endif +#else /* not MSDOS, or __TURBOC__ */ +#if defined(_AIX) +/* I don't know what this was needed for, but it pollutes the namespace. + So I turned it off. rms, 2 May 1997. */ +/* #include */ + #pragma alloca +#define YYSTACK_USE_ALLOCA +#else /* not MSDOS, or __TURBOC__, or _AIX */ +#if 0 +#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up, + and on HPUX 10. Eventually we can turn this on. */ +#define YYSTACK_USE_ALLOCA +#define alloca __builtin_alloca +#endif /* __hpux */ +#endif +#endif /* not _AIX */ +#endif /* not MSDOS, or __TURBOC__ */ +#endif /* not sparc */ +#endif /* not GNU C */ +#endif /* alloca not defined */ +#endif /* YYSTACK_USE_ALLOCA not defined */ + +#ifdef YYSTACK_USE_ALLOCA +#define YYSTACK_ALLOC alloca +#else +#define YYSTACK_ALLOC malloc +#endif + +/* Note: there must be only one dollar sign in this file. + It is replaced by the list of actions, each action + as one case of the switch. */ + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY -2 +#define YYEOF 0 +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrlab1 +/* Like YYERROR except do call yyerror. + This remains here temporarily to ease the + transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ +#define YYFAIL goto yyerrlab +#define YYRECOVERING() (!!yyerrstatus) +#define YYBACKUP(token, value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { yychar = (token), yylval = (value); \ + yychar1 = YYTRANSLATE (yychar); \ + YYPOPSTACK; \ + goto yybackup; \ + } \ + else \ + { yyerror ("syntax error: cannot back up"); YYERROR; } \ +while (0) + +#define YYTERROR 1 +#define YYERRCODE 256 + +#ifndef YYPURE +#define YYLEX yylex() +#endif + +#ifdef YYPURE +#ifdef YYLSP_NEEDED +#ifdef YYLEX_PARAM +#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM) +#else +#define YYLEX yylex(&yylval, &yylloc) +#endif +#else /* not YYLSP_NEEDED */ +#ifdef YYLEX_PARAM +#define YYLEX yylex(&yylval, YYLEX_PARAM) +#else +#define YYLEX yylex(&yylval) +#endif +#endif /* not YYLSP_NEEDED */ +#endif + +/* If nonreentrant, generate the variables here */ + +#ifndef YYPURE + +int yychar; /* the lookahead symbol */ +YYSTYPE yylval; /* the semantic value of the */ + /* lookahead symbol */ + +#ifdef YYLSP_NEEDED +YYLTYPE yylloc; /* location data for the lookahead */ + /* symbol */ +#endif + +int yynerrs; /* number of parse errors so far */ +#endif /* not YYPURE */ + +#if YYDEBUG != 0 +int yydebug; /* nonzero means print parse trace */ +/* Since this is uninitialized, it does not stop multiple parsers + from coexisting. */ +#endif + +/* YYINITDEPTH indicates the initial size of the parser's stacks */ + +#ifndef YYINITDEPTH +#define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH is the maximum size the stacks can grow to + (effective only if the built-in stack extension method is used). */ + +#if YYMAXDEPTH == 0 +#undef YYMAXDEPTH +#endif + +#ifndef YYMAXDEPTH +#define YYMAXDEPTH 10000 +#endif + +/* Define __yy_memcpy. Note that the size argument + should be passed with type unsigned int, because that is what the non-GCC + definitions require. With GCC, __builtin_memcpy takes an arg + of type size_t, but it can handle unsigned int. */ + +#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ +#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT) +#else /* not GNU C or C++ */ +#ifndef __cplusplus + +/* This is the most reliable way to avoid incompatibilities + in available built-in functions on various systems. */ +static void +__yy_memcpy (to, from, count) + char *to; + char *from; + unsigned int count; +{ + register char *f = from; + register char *t = to; + register int i = count; + + while (i-- > 0) + *t++ = *f++; +} + +#else /* __cplusplus */ + +/* This is the most reliable way to avoid incompatibilities + in available built-in functions on various systems. */ +static void +__yy_memcpy (char *to, char *from, unsigned int count) +{ + register char *t = to; + register char *f = from; + register int i = count; + + while (i-- > 0) + *t++ = *f++; +} + +#endif +#endif + +#line 216 "/mit/gnu/share/bison.simple" + +/* The user can define YYPARSE_PARAM as the name of an argument to be passed + into yyparse. The argument should have type void *. + It should actually point to an object. + Grammar actions can access the variable by casting it + to the proper pointer type. */ + +#ifdef YYPARSE_PARAM +#ifdef __cplusplus +#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM +#define YYPARSE_PARAM_DECL +#else /* not __cplusplus */ +#define YYPARSE_PARAM_ARG YYPARSE_PARAM +#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; +#endif /* not __cplusplus */ +#else /* not YYPARSE_PARAM */ +#define YYPARSE_PARAM_ARG +#define YYPARSE_PARAM_DECL +#endif /* not YYPARSE_PARAM */ + +/* Prevent warning if -Wstrict-prototypes. */ +#ifdef __GNUC__ +#ifdef YYPARSE_PARAM +int yyparse (void *); +#else +int yyparse (void); +#endif +#endif + +int +yyparse(YYPARSE_PARAM_ARG) + YYPARSE_PARAM_DECL +{ + register int yystate; + register int yyn; + register short *yyssp; + register YYSTYPE *yyvsp; + int yyerrstatus; /* number of tokens to shift before error messages enabled */ + int yychar1 = 0; /* lookahead token as an internal (translated) token number */ + + short yyssa[YYINITDEPTH]; /* the state stack */ + YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ + + short *yyss = yyssa; /* refer to the stacks thru separate pointers */ + YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ + +#ifdef YYLSP_NEEDED + YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */ + YYLTYPE *yyls = yylsa; + YYLTYPE *yylsp; + +#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) +#else +#define YYPOPSTACK (yyvsp--, yyssp--) +#endif + + int yystacksize = YYINITDEPTH; + int yyfree_stacks = 0; + +#ifdef YYPURE + int yychar; + YYSTYPE yylval; + int yynerrs; +#ifdef YYLSP_NEEDED + YYLTYPE yylloc; +#endif +#endif + + YYSTYPE yyval; /* the variable used to return */ + /* semantic values from the action */ + /* routines */ + + int yylen; + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Starting parse\n"); +#endif + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss - 1; + yyvsp = yyvs; +#ifdef YYLSP_NEEDED + yylsp = yyls; +#endif + +/* Push a new state, which is found in yystate . */ +/* In all cases, when you get here, the value and location stacks + have just been pushed. so pushing a state here evens the stacks. */ +yynewstate: + + *++yyssp = yystate; + + if (yyssp >= yyss + yystacksize - 1) + { + /* Give user a chance to reallocate the stack */ + /* Use copies of these so that the &'s don't force the real ones into memory. */ + YYSTYPE *yyvs1 = yyvs; + short *yyss1 = yyss; +#ifdef YYLSP_NEEDED + YYLTYPE *yyls1 = yyls; +#endif + + /* Get the current used size of the three stacks, in elements. */ + int size = yyssp - yyss + 1; + +#ifdef yyoverflow + /* Each stack pointer address is followed by the size of + the data in use in that stack, in bytes. */ +#ifdef YYLSP_NEEDED + /* This used to be a conditional around just the two extra args, + but that might be undefined if yyoverflow is a macro. */ + yyoverflow("parser stack overflow", + &yyss1, size * sizeof (*yyssp), + &yyvs1, size * sizeof (*yyvsp), + &yyls1, size * sizeof (*yylsp), + &yystacksize); +#else + yyoverflow("parser stack overflow", + &yyss1, size * sizeof (*yyssp), + &yyvs1, size * sizeof (*yyvsp), + &yystacksize); +#endif + + yyss = yyss1; yyvs = yyvs1; +#ifdef YYLSP_NEEDED + yyls = yyls1; +#endif +#else /* no yyoverflow */ + /* Extend the stack our own way. */ + if (yystacksize >= YYMAXDEPTH) + { + yyerror("parser stack overflow"); + if (yyfree_stacks) + { + free (yyss); + free (yyvs); +#ifdef YYLSP_NEEDED + free (yyls); +#endif + } + return 2; + } + yystacksize *= 2; + if (yystacksize > YYMAXDEPTH) + yystacksize = YYMAXDEPTH; +#ifndef YYSTACK_USE_ALLOCA + yyfree_stacks = 1; +#endif + yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp)); + __yy_memcpy ((char *)yyss, (char *)yyss1, + size * (unsigned int) sizeof (*yyssp)); + yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp)); + __yy_memcpy ((char *)yyvs, (char *)yyvs1, + size * (unsigned int) sizeof (*yyvsp)); +#ifdef YYLSP_NEEDED + yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp)); + __yy_memcpy ((char *)yyls, (char *)yyls1, + size * (unsigned int) sizeof (*yylsp)); +#endif +#endif /* no yyoverflow */ + + yyssp = yyss + size - 1; + yyvsp = yyvs + size - 1; +#ifdef YYLSP_NEEDED + yylsp = yyls + size - 1; +#endif + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Stack size increased to %d\n", yystacksize); +#endif + + if (yyssp >= yyss + yystacksize - 1) + YYABORT; + } + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Entering state %d\n", yystate); +#endif + + goto yybackup; + yybackup: + +/* Do appropriate processing given the current state. */ +/* Read a lookahead token if we need one and don't already have one. */ +/* yyresume: */ + + /* First try to decide what to do without reference to lookahead token. */ + + yyn = yypact[yystate]; + if (yyn == YYFLAG) + goto yydefault; + + /* Not known => get a lookahead token if don't already have one. */ + + /* yychar is either YYEMPTY or YYEOF + or a valid token in external form. */ + + if (yychar == YYEMPTY) + { +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Reading a token: "); +#endif + yychar = YYLEX; + } + + /* Convert token to internal form (in yychar1) for indexing tables with */ + + if (yychar <= 0) /* This means end of input. */ + { + yychar1 = 0; + yychar = YYEOF; /* Don't call YYLEX any more */ + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Now at end of input.\n"); +#endif + } + else + { + yychar1 = YYTRANSLATE(yychar); + +#if YYDEBUG != 0 + if (yydebug) + { + fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); + /* Give the individual parser a way to print the precise meaning + of a token, for further debugging info. */ +#ifdef YYPRINT + YYPRINT (stderr, yychar, yylval); +#endif + fprintf (stderr, ")\n"); + } +#endif + } + + yyn += yychar1; + if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) + goto yydefault; + + yyn = yytable[yyn]; + + /* yyn is what to do for this token type in this state. + Negative => reduce, -yyn is rule number. + Positive => shift, yyn is new state. + New state is final state => don't bother to shift, + just return success. + 0, or most negative number => error. */ + + if (yyn < 0) + { + if (yyn == YYFLAG) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + else if (yyn == 0) + goto yyerrlab; + + if (yyn == YYFINAL) + YYACCEPT; + + /* Shift the lookahead token. */ + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); +#endif + + /* Discard the token being shifted unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + *++yyvsp = yylval; +#ifdef YYLSP_NEEDED + *++yylsp = yylloc; +#endif + + /* count tokens shifted since error; after three, turn off error status. */ + if (yyerrstatus) yyerrstatus--; + + yystate = yyn; + goto yynewstate; + +/* Do the default action for the current state. */ +yydefault: + + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + +/* Do a reduction. yyn is the number of a rule to reduce with. */ +yyreduce: + yylen = yyr2[yyn]; + if (yylen > 0) + yyval = yyvsp[1-yylen]; /* implement default value of the action */ + +#if YYDEBUG != 0 + if (yydebug) + { + int i; + + fprintf (stderr, "Reducing via rule %d (line %d), ", + yyn, yyrline[yyn]); + + /* Print the symbols being reduced, and their result. */ + for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) + fprintf (stderr, "%s ", yytname[yyrhs[i]]); + fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); + } +#endif + + + switch (yyn) { + +case 5: +#line 90 "../../../../asrc/lib/krb5/krb/x-deltat.y" +{ yyval.val = - yyvsp[0].val; ; + break;} +case 8: +#line 92 "../../../../asrc/lib/krb5/krb/x-deltat.y" +{ yyval.val = yyvsp[0].val; ; + break;} +case 9: +#line 94 "../../../../asrc/lib/krb5/krb/x-deltat.y" +{ DO (yyvsp[-2].val, 0, 0, yyvsp[0].val); ; + break;} +case 10: +#line 95 "../../../../asrc/lib/krb5/krb/x-deltat.y" +{ DO ( 0, yyvsp[-2].val, 0, yyvsp[0].val); ; + break;} +case 11: +#line 96 "../../../../asrc/lib/krb5/krb/x-deltat.y" +{ DO ( 0, 0, yyvsp[-2].val, yyvsp[0].val); ; + break;} +case 12: +#line 97 "../../../../asrc/lib/krb5/krb/x-deltat.y" +{ DO ( 0, 0, 0, yyvsp[-1].val); ; + break;} +case 13: +#line 98 "../../../../asrc/lib/krb5/krb/x-deltat.y" +{ DO (yyvsp[-6].val, yyvsp[-4].val, yyvsp[-2].val, yyvsp[0].val); ; + break;} +case 14: +#line 99 "../../../../asrc/lib/krb5/krb/x-deltat.y" +{ DO ( 0, yyvsp[-4].val, yyvsp[-2].val, yyvsp[0].val); ; + break;} +case 15: +#line 100 "../../../../asrc/lib/krb5/krb/x-deltat.y" +{ DO ( 0, yyvsp[-2].val, yyvsp[0].val, 0); ; + break;} +case 17: +#line 105 "../../../../asrc/lib/krb5/krb/x-deltat.y" +{ yyval.val = yyvsp[-2].val * 3600 + yyvsp[0].val; ; + break;} +case 19: +#line 108 "../../../../asrc/lib/krb5/krb/x-deltat.y" +{ yyval.val = yyvsp[-2].val * 60 + yyvsp[0].val; ; + break;} +case 20: +#line 110 "../../../../asrc/lib/krb5/krb/x-deltat.y" +{ yyval.val = 0; ; + break;} +} + /* the action file gets copied in in place of this dollarsign */ +#line 542 "/mit/gnu/share/bison.simple" + + yyvsp -= yylen; + yyssp -= yylen; +#ifdef YYLSP_NEEDED + yylsp -= yylen; +#endif + +#if YYDEBUG != 0 + if (yydebug) + { + short *ssp1 = yyss - 1; + fprintf (stderr, "state stack now"); + while (ssp1 != yyssp) + fprintf (stderr, " %d", *++ssp1); + fprintf (stderr, "\n"); + } +#endif + + *++yyvsp = yyval; + +#ifdef YYLSP_NEEDED + yylsp++; + if (yylen == 0) + { + yylsp->first_line = yylloc.first_line; + yylsp->first_column = yylloc.first_column; + yylsp->last_line = (yylsp-1)->last_line; + yylsp->last_column = (yylsp-1)->last_column; + yylsp->text = 0; + } + else + { + yylsp->last_line = (yylsp+yylen-1)->last_line; + yylsp->last_column = (yylsp+yylen-1)->last_column; + } +#endif + + /* Now "shift" the result of the reduction. + Determine what state that goes to, + based on the state we popped back to + and the rule number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTBASE] + *yyssp; + if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTBASE]; + + goto yynewstate; + +yyerrlab: /* here on detecting error */ + + if (! yyerrstatus) + /* If not already recovering from an error, report this error. */ + { + ++yynerrs; + +#ifdef YYERROR_VERBOSE + yyn = yypact[yystate]; + + if (yyn > YYFLAG && yyn < YYLAST) + { + int size = 0; + char *msg; + int x, count; + + count = 0; + /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ + for (x = (yyn < 0 ? -yyn : 0); + x < (sizeof(yytname) / sizeof(char *)); x++) + if (yycheck[x + yyn] == x) + size += strlen(yytname[x]) + 15, count++; + msg = (char *) malloc(size + 15); + if (msg != 0) + { + strcpy(msg, "parse error"); + + if (count < 5) + { + count = 0; + for (x = (yyn < 0 ? -yyn : 0); + x < (sizeof(yytname) / sizeof(char *)); x++) + if (yycheck[x + yyn] == x) + { + strcat(msg, count == 0 ? ", expecting `" : " or `"); + strcat(msg, yytname[x]); + strcat(msg, "'"); + count++; + } + } + yyerror(msg); + free(msg); + } + else + yyerror ("parse error; also virtual memory exceeded"); + } + else +#endif /* YYERROR_VERBOSE */ + yyerror("parse error"); + } + + goto yyerrlab1; +yyerrlab1: /* here on error raised explicitly by an action */ + + if (yyerrstatus == 3) + { + /* if just tried and failed to reuse lookahead token after an error, discard it. */ + + /* return failure if at end of input */ + if (yychar == YYEOF) + YYABORT; + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); +#endif + + yychar = YYEMPTY; + } + + /* Else will try to reuse lookahead token + after shifting the error token. */ + + yyerrstatus = 3; /* Each real token shifted decrements this */ + + goto yyerrhandle; + +yyerrdefault: /* current state does not do anything special for the error token. */ + +#if 0 + /* This is wrong; only states that explicitly want error tokens + should shift them. */ + yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ + if (yyn) goto yydefault; +#endif + +yyerrpop: /* pop the current state because it cannot handle the error token */ + + if (yyssp == yyss) YYABORT; + yyvsp--; + yystate = *--yyssp; +#ifdef YYLSP_NEEDED + yylsp--; +#endif + +#if YYDEBUG != 0 + if (yydebug) + { + short *ssp1 = yyss - 1; + fprintf (stderr, "Error: state stack now"); + while (ssp1 != yyssp) + fprintf (stderr, " %d", *++ssp1); + fprintf (stderr, "\n"); + } +#endif + +yyerrhandle: + + yyn = yypact[yystate]; + if (yyn == YYFLAG) + goto yyerrdefault; + + yyn += YYTERROR; + if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) + goto yyerrdefault; + + yyn = yytable[yyn]; + if (yyn < 0) + { + if (yyn == YYFLAG) + goto yyerrpop; + yyn = -yyn; + goto yyreduce; + } + else if (yyn == 0) + goto yyerrpop; + + if (yyn == YYFINAL) + YYACCEPT; + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Shifting error token, "); +#endif + + *++yyvsp = yylval; +#ifdef YYLSP_NEEDED + *++yylsp = yylloc; +#endif + + yystate = yyn; + goto yynewstate; + + yyacceptlab: + /* YYACCEPT comes here. */ + if (yyfree_stacks) + { + free (yyss); + free (yyvs); +#ifdef YYLSP_NEEDED + free (yyls); +#endif + } + return 0; + + yyabortlab: + /* YYABORT comes here. */ + if (yyfree_stacks) + { + free (yyss); + free (yyvs); +#ifdef YYLSP_NEEDED + free (yyls); +#endif + } + return 1; +} +#line 113 "../../../../asrc/lib/krb5/krb/x-deltat.y" + + +static int +mylex (int *intp, char **pp) +{ + int num, c; +#define P (*pp) + char *orig_p = P; + +#ifdef isascii + if (!isascii (*P)) + return 0; +#endif + switch (c = *P++) { + case '-': + case ':': + case 'd': + case 'h': + case 'm': + case 's': + return c; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + /* XXX assumes ASCII */ + num = c - '0'; + while (isdigit (*P)) { + num *= 10; + num += *P++ - '0'; + } + *intp = num; + return (P - orig_p > 2) ? LONGNUM : NUM; + case ' ': + case '\t': + case '\n': + while (isspace (*P)) + P++; + return WS; + default: + return YYEOF; + } +} + +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV +krb5_string_to_deltat(string, deltatp) + char FAR * string; + krb5_deltat FAR * deltatp; +{ + struct param p; + p.delta = 0; + p.p = string; + if (yyparse (&p)) + return EINVAL; + *deltatp = p.delta; + return 0; +} diff --git a/src/lib/krb5/krb/fwd_tgt.c b/src/lib/krb5/krb/fwd_tgt.c index 6e10ad2..5fe226b 100644 --- a/src/lib/krb5/krb/fwd_tgt.c +++ b/src/lib/krb5/krb/fwd_tgt.c @@ -77,8 +77,8 @@ krb5_fwd_tgt_creds(context, auth_context, rhost, client, server, cc, goto errout; if ((retval = krb5_build_principal_ext(context, &creds.server, - server->realm.length, - server->realm.data, + client->realm.length, + client->realm.data, KRB5_TGS_NAME_SIZE, KRB5_TGS_NAME, client->realm.length, @@ -93,8 +93,7 @@ krb5_fwd_tgt_creds(context, auth_context, rhost, client, server, cc, } /* fetch tgt directly from cache */ - retval = krb5_cc_retrieve_cred (context, cc, KRB5_TC_MATCH_SRV_NAMEONLY, - &creds, &tgt); + retval = krb5_cc_retrieve_cred (context, cc, 0, &creds, &tgt); if (retval) goto errout; diff --git a/src/lib/krb5/krb/init_ctx.c b/src/lib/krb5/krb/init_ctx.c index 19aaf66..ba8feb7 100644 --- a/src/lib/krb5/krb/init_ctx.c +++ b/src/lib/krb5/krb/init_ctx.c @@ -16,7 +16,10 @@ * this permission notice appear in supporting documentation, and that * the name of M.I.T. not be used in advertising or publicity pertaining * to distribution of the software without specific, written prior - * permission. M.I.T. makes no representations about the suitability of + * permission. Furthermore if you modify this software you must label + * your software as modified software and not distribute it in such a + * fashion that it might be confused with the original M.I.T. software. + * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" without express * or implied warranty. * @@ -30,11 +33,28 @@ extern void krb5_win_do_init(); #endif -krb5_error_code INTERFACE +static krb5_error_code init_common (); + +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_init_context(context) krb5_context *context; { - krb5_context ctx; + return init_common (context, FALSE); +} + +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV +krb5_init_secure_context(context) + krb5_context *context; +{ + return init_common (context, TRUE); +} + +static krb5_error_code +init_common (context, secure) + krb5_context *context; + krb5_boolean secure; +{ + krb5_context ctx = 0; krb5_error_code retval; int tmp; @@ -57,6 +77,8 @@ krb5_init_context(context) /* Initialize error tables */ krb5_init_ets(ctx); + ctx->profile_secure = secure; + /* Set the default encryption types, possible defined in krb5/conf */ if ((retval = krb5_set_default_in_tkt_ktypes(ctx, NULL))) goto cleanup; diff --git a/src/lib/krb5/krb/preauth.c b/src/lib/krb5/krb/preauth.c index a5f593b..4689e3f 100644 --- a/src/lib/krb5/krb/preauth.c +++ b/src/lib/krb5/krb/preauth.c @@ -470,10 +470,14 @@ char *handle_sam_labels(sc) p = prompt1 = malloc(label_len + strlen(sep1) + challenge_len + strlen(sep2) + prompt_len+ strlen(sep3) + 1); - strncpy(p, label, label_len); p += label_len; - strcpy(p, sep1); p += strlen(sep1); - strncpy(p, challenge, challenge_len); p += challenge_len; - strcpy(p, sep2); p += strlen(sep2); + if (p == NULL) + return NULL; + if (challenge_len) { + strncpy(p, label, label_len); p += label_len; + strcpy(p, sep1); p += strlen(sep1); + strncpy(p, challenge, challenge_len); p += challenge_len; + strcpy(p, sep2); p += strlen(sep2); + } strncpy(p, prompt, prompt_len); p += prompt_len; strcpy(p, sep3); /* p += strlen(sep3); */ return prompt1; @@ -518,11 +522,25 @@ obtain_sam_padata(context, in_padata, etype_info, def_enc_key, } enc_sam_response_enc.sam_nonce = sam_challenge->sam_nonce; + if (!sam_challenge->sam_nonce) { + retval = krb5_us_timeofday(context, + &enc_sam_response_enc.sam_timestamp, + &enc_sam_response_enc.sam_usec); + sam_response.sam_patimestamp = enc_sam_response_enc.sam_timestamp; + } + if (retval) + return retval; if (sam_challenge->sam_flags & KRB5_SAM_SEND_ENCRYPTED_SAD) { /* encrypt passcode in key by stuffing it here */ int pcsize = 256; char *passcode = malloc(pcsize+1); + if (passcode == NULL) + return ENOMEM; prompt = handle_sam_labels(sam_challenge); + if (prompt == NULL) { + free(passcode); + return ENOMEM; + } retval = krb5_read_password(context, prompt, 0, passcode, &pcsize); free(prompt); @@ -533,17 +551,9 @@ obtain_sam_padata(context, in_padata, etype_info, def_enc_key, enc_sam_response_enc.sam_passcode.data = passcode; enc_sam_response_enc.sam_passcode.length = pcsize; } else if (sam_challenge->sam_flags & KRB5_SAM_USE_SAD_AS_KEY) { - if (sam_challenge->sam_nonce) { - /* use nonce in the next AS request? */ - } else { - retval = krb5_us_timeofday(context, - &enc_sam_response_enc.sam_timestamp, - &enc_sam_response_enc.sam_usec); - sam_response.sam_patimestamp = enc_sam_response_enc.sam_timestamp; - } - if (retval) - return retval; prompt = handle_sam_labels(sam_challenge); + if (prompt == NULL) + return ENOMEM; retval = sam_get_pass_from_user(context, etype_info, key_proc, key_seed, request, &sam_use_key, prompt); diff --git a/src/lib/krb5/krb/recvauth.c b/src/lib/krb5/krb/recvauth.c index d6d6772..ef40e1f 100644 --- a/src/lib/krb5/krb/recvauth.c +++ b/src/lib/krb5/krb/recvauth.c @@ -57,6 +57,8 @@ krb5_recvauth(context, auth_context, krb5_rcache rcache = 0; krb5_octet response; krb5_data null_server; + int need_error_free = 0; + int local_rcache = 0, local_authcon = 0; /* * Zero out problem variable. If problem is set at the end of @@ -140,8 +142,10 @@ krb5_recvauth(context, auth_context, if (*auth_context == NULL) { problem = krb5_auth_con_init(context, &new_auth_context); *auth_context = new_auth_context; + local_authcon = 1; } - if ((!problem) && ((*auth_context)->rcache == NULL)) { + krb5_auth_con_getrcache(context, *auth_context, &rcache); + if ((!problem) && rcache == NULL) { /* * Setup the replay cache. */ @@ -155,6 +159,7 @@ krb5_recvauth(context, auth_context, } if (!problem) problem = krb5_auth_con_setrcache(context, *auth_context, rcache); + local_rcache = 1; } if (!problem) { problem = krb5_rd_req(context, auth_context, &inbuf, server, @@ -173,7 +178,14 @@ krb5_recvauth(context, auth_context, memset((char *)&error, 0, sizeof(error)); krb5_us_timeofday(context, &error.stime, &error.susec); - error.server = server; + if(server) + error.server = server; + else { + /* If this fails - ie. ENOMEM we are hosed + we cannot even send the error if we wanted to... */ + (void) krb5_parse_name(context, "????", &error.server); + need_error_free = 1; + } error.error = problem - ERROR_TABLE_BASE_krb5; if (error.error > 127) @@ -190,6 +202,9 @@ krb5_recvauth(context, auth_context, goto cleanup; } free(error.text.data); + if(need_error_free) + krb5_free_principal(context, error.server); + } else { outbuf.length = 0; outbuf.data = 0; @@ -216,9 +231,12 @@ krb5_recvauth(context, auth_context, cleanup:; if (retval) { - if (rcache) + if (local_authcon) { + krb5_auth_con_free(context, *auth_context); + } else if (local_rcache && rcache != NULL) { krb5_rc_close(context, rcache); - krb5_auth_con_free(context, *auth_context); + krb5_auth_con_setrcache(context, *auth_context, NULL); + } } return retval; } diff --git a/src/lib/krb5/krb/send_tgs.c b/src/lib/krb5/krb/send_tgs.c index ac4e277..3247c8e 100644 --- a/src/lib/krb5/krb/send_tgs.c +++ b/src/lib/krb5/krb/send_tgs.c @@ -199,7 +199,8 @@ krb5_send_tgs(context, kdcoptions, timestruct, ktypes, sname, addrs, tgsreq.server = (krb5_principal) sname; tgsreq.from = timestruct->starttime; - tgsreq.till = timestruct->endtime; + tgsreq.till = timestruct->endtime ? timestruct->endtime : + in_cred->times.endtime; tgsreq.rtime = timestruct->renew_till; if ((retval = krb5_timeofday(context, &time_now))) return(retval); diff --git a/src/lib/krb5/krb/sendauth.c b/src/lib/krb5/krb/sendauth.c index d77afdc..58a0ee8 100644 --- a/src/lib/krb5/krb/sendauth.c +++ b/src/lib/krb5/krb/sendauth.c @@ -213,12 +213,13 @@ krb5_sendauth(context, auth_context, } retval = 0; /* Normal return */ if (out_creds) { - *out_creds = credsp; + *out_creds = credsp; + credspout = NULL; } error_return: krb5_free_cred_contents(context, &creds); - if (credspout) + if (credspout != NULL) krb5_free_creds(context, credspout); if (!ccache && use_ccache) krb5_cc_close(context, use_ccache); diff --git a/src/lib/krb5/krb/str_conv.c b/src/lib/krb5/krb/str_conv.c index 76a79a8..166b277 100644 --- a/src/lib/krb5/krb/str_conv.c +++ b/src/lib/krb5/krb/str_conv.c @@ -1,7 +1,7 @@ /* * lib/kadm/str_conv.c * - * Copyright 1995 by the Massachusetts Institute of Technology. + * Copyright 1995, 2000 by the Massachusetts Institute of Technology. * All Rights Reserved. * * Export of this software from the United States of America may @@ -16,7 +16,10 @@ * this permission notice appear in supporting documentation, and that * the name of M.I.T. not be used in advertising or publicity pertaining * to distribution of the software without specific, written prior - * permission. M.I.T. makes no representations about the suitability of + * permission. Furthermore if you modify this software you must label + * your software as modified software and not distribute it in such a + * fashion that it might be confused with the original M.I.T. software. + * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" without express * or implied warranty. * @@ -49,6 +52,8 @@ #include "k5-int.h" +/* Salt type conversions */ + /* * Local data structures. */ @@ -70,15 +75,6 @@ struct cksumtype_lookup_entry { const char * cst_output; /* How to spit it out */ }; -struct deltat_match_entry { - const char * dt_scan_format; /* sscanf format */ - int dt_nmatch; /* Number to match */ - int dt_dindex; /* Day index */ - int dt_hindex; /* Hour index */ - int dt_mindex; /* Minute index */ - int dt_sindex; /* Second index */ -}; - /* * Local strings */ @@ -98,20 +94,6 @@ static const char enctype_descbcmd5_out[] = "DES cbc mode with RSA-MD5"; static const char enctype_des3cbcsha_out[] = "DES-3 cbc mode with NIST-SHA"; static const char enctype_descbcraw_out[] = "DES cbc mode raw"; -/* Salttype strings */ -static const char stype_v5_in[] = "normal"; -static const char stype_v4_in[] = "v4"; -static const char stype_norealm_in[] = "norealm"; -static const char stype_olrealm_in[] = "onlyrealm"; -static const char stype_special_in[] = "special"; -static const char stype_afs3_in[] = "afs3"; -static const char stype_v5_out[] = "Version 5"; -static const char stype_v4_out[] = "Version 4"; -static const char stype_norealm_out[] = "Version 5 - No Realm"; -static const char stype_olrealm_out[] = "Version 5 - Realm Only"; -static const char stype_special_out[] = "Special"; -static const char stype_afs3_out[] = "AFS version 3"; - /* Checksum type strings */ static const char cstype_crc32_in[] = "crc32"; static const char cstype_md4_in[] = "md4"; @@ -130,52 +112,6 @@ static const char cstype_md5des_out[] = "RSA-MD5 with DES cbc mode"; static const char cstype_sha_out[] = "NIST-SHA"; static const char cstype_hmacsha_out[] = "HMAC-SHA"; -/* Absolute time strings */ -static const char atime_full_digits[] = "%y%m%d%H%M%S"; -static const char atime_full_digits_d[] = "%y.%m.%d.%H.%M.%S"; -static const char atime_nsec_digits[] = "%y%m%d%H%M"; -static const char atime_rel_hms[] = "%H%M%S"; -static const char atime_rel_hm[] = "%H%M"; -static const char atime_rel_col_hms[] = "%T"; -static const char atime_rel_col_hm[] = "%R"; -static const char atime_ldep_sfmt[] = "%x:%X"; -static const char atime_full_text[] = "%d-%b-%Y:%T"; -static const char atime_full_text_nos[] = "%d-%b-%Y:%R"; -#if !HAVE_STRPTIME -static const char ascan_full_digits[] = "%02d%02d%02d%02d%02d%02d"; -static const char ascan_full_digits_d[] = "%02d.%02d.%02d.%02d.%02d.%02d"; -static const char ascan_nsec_digits[] = "%02d%02d%02d%02d%02d"; -static const char ascan_rel_hms[] = "%02d%02d%02d"; -static const char ascan_rel_hm[] = "%02d%02d"; -static const char ascan_rel_col_hms[] = "%02d:%02d:%02d"; -static const char ascan_rel_col_hm[] = "%02d:%02d"; -#endif /* !HAVE_STRPTIME */ -#ifdef HAVE_STRFTIME -static const char sftime_ldep_time[] = "%c"; -static const char sftime_med_fmt[] = "%d %b %y %T"; -static const char sftime_short_fmt[] = "%x %X"; -static const char sftime_last_fmt[] = "%d/%m/%y %R"; -#endif /* HAVE_STRFTIME */ -static const char sftime_default_fmt[] = "%02d/%02d/%02d %02d:%02d"; -static const size_t sftime_default_len = 2+1+2+1+2+1+2+1+2+1; - -/* Delta time strings */ -static const char dtscan_dhms_notext[] = "%d-%02d:%02d:%02d"; -static const char dtscan_dhms_stext[] = "%dd%dh%dm%ds"; -static const char dtscan_hms_notext[] = "%d:%02d:%02d"; -static const char dtscan_hms_stext[] = "%dh%dm%ds"; -static const char dtscan_hm_notext[] = "%d:%02d"; -static const char dtscan_hm_stext[] = "%dh%dm"; -static const char dtscan_days[] = "%d%[d]"; -static const char dtscan_hours[] = "%d%[h]"; -static const char dtscan_minutes[] = "%d%[m]"; -static const char dtscan_seconds[] = "%d%[s]"; -static const char dt_day_singular[] = "day"; -static const char dt_day_plural[] = "days"; -static const char dt_output_donly[] = "%d %s"; -static const char dt_output_dhms[] = "%d %s %02d:%02d:%02d"; -static const char dt_output_hms[] = "%d:%02d:%02d"; - /* * Lookup tables. */ @@ -195,14 +131,14 @@ static const int enctype_table_nents = sizeof(enctype_table)/ sizeof(enctype_table[0]); static const struct salttype_lookup_entry salttype_table[] = { -/* salt type input specifier output string */ -/*----------------------------- ----------------------- ------------------*/ -{ KRB5_KDB_SALTTYPE_NORMAL, stype_v5_in, stype_v5_out }, -{ KRB5_KDB_SALTTYPE_V4, stype_v4_in, stype_v4_out }, -{ KRB5_KDB_SALTTYPE_NOREALM, stype_norealm_in, stype_norealm_out }, -{ KRB5_KDB_SALTTYPE_ONLYREALM, stype_olrealm_in, stype_olrealm_out }, -{ KRB5_KDB_SALTTYPE_SPECIAL, stype_special_in, stype_special_out }, -{ KRB5_KDB_SALTTYPE_AFS3, stype_afs3_in, stype_afs3_out } +/* salt type input specifier output string */ +/*----------------------------- --------------- ---------------*/ +{ KRB5_KDB_SALTTYPE_NORMAL, "normal", "Version 5" }, +{ KRB5_KDB_SALTTYPE_V4, "v4", "Version 4" }, +{ KRB5_KDB_SALTTYPE_NOREALM, "norealm", "Version 5 - No Realm" }, +{ KRB5_KDB_SALTTYPE_ONLYREALM, "onlyrealm", "Version 5 - Realm Only" }, +{ KRB5_KDB_SALTTYPE_SPECIAL, "special", "Special" }, +{ KRB5_KDB_SALTTYPE_AFS3, "afs3", "AFS version 3" } }; static const int salttype_table_nents = sizeof(salttype_table)/ sizeof(salttype_table[0]); @@ -222,146 +158,7 @@ static const struct cksumtype_lookup_entry cksumtype_table[] = { static const int cksumtype_table_nents = sizeof(cksumtype_table)/ sizeof(cksumtype_table[0]); -static const char * const atime_format_table[] = { -atime_full_digits, /* yymmddhhmmss */ -atime_full_digits_d, /* yy.mm.dd.hh.mm.ss */ -atime_nsec_digits, /* yymmddhhmm */ -atime_rel_hms, /* hhmmss */ -atime_rel_hm, /* hhmm */ -atime_rel_col_hms, /* hh:mm:ss */ -atime_rel_col_hm, /* hh:mm */ -/* The following not really supported unless native strptime present */ -atime_ldep_sfmt, /*locale-dependent short format */ -atime_full_text, /* dd-month-yyyy:hh:mm:ss */ -atime_full_text_nos /* dd-month-yyyy:hh:mm */ -}; -static const int atime_format_table_nents = sizeof(atime_format_table)/ - sizeof(atime_format_table[0]); - -#ifdef HAVE_STRFTIME -static const char * const sftime_format_table[] = { -sftime_ldep_time, /* Default locale-dependent date and time */ -sftime_med_fmt, /* dd mon yy hh:mm:ss */ -sftime_short_fmt, /* locale-dependent short format */ -sftime_last_fmt /* dd/mm/yy hh:mm */ -}; -static const int sftime_format_table_nents = sizeof(sftime_format_table)/ - sizeof(sftime_format_table[0]); -#endif /* HAVE_STRFTIME */ - -static const struct deltat_match_entry deltat_table[] = { -/* scan format nmatch daypos hourpos minpos secpos */ -/*--------------------- ------- ------- ------- ------- --------*/ -{ dtscan_dhms_notext, 4, 0, 1, 2, 3 }, -{ dtscan_dhms_stext, 4, 0, 1, 2, 3 }, -{ dtscan_hms_notext, 3, -1, 0, 1, 2 }, -{ dtscan_hms_stext, 3, -1, 0, 1, 2 }, -{ dtscan_hm_notext, 2, -1, -1, 0, 1 }, -{ dtscan_hm_stext, 2, -1, -1, 0, 1 }, -{ dtscan_days, 2, 0, -1, -1, -1 }, -{ dtscan_hours, 2, -1, 0, -1, -1 }, -{ dtscan_minutes, 2, -1, -1, 0, -1 }, -{ dtscan_seconds, 2, -1, -1, -1, 0 } -}; -static const int deltat_table_nents = sizeof(deltat_table)/ - sizeof(deltat_table[0]); - -#if !HAVE_STRPTIME -/* - * Rudimentary version of strptime for systems which don't have it. - */ -static char * -strptime(buf, format, tm) - char *buf; - const char *format; - struct tm *tm; -{ - int year, month, day, hour, minute, second; - char *bp; - time_t now; - - /* - * We only understand the following fixed formats: - * %y%m%d%H%M%S - * %y.%m.%d.%H.%M.%S - * %y%m%d%H%M - * %H%M%S - * %H%M - * %T - * %R - */ - bp = (char *) NULL; - if (!strcmp(format, atime_full_digits) && - (sscanf(buf, ascan_full_digits, - &year, &month, &day, &hour, &minute, &second) == 6)) { - tm->tm_year = year; - tm->tm_mon = month - 1; - tm->tm_mday = day; - tm->tm_hour = hour; - tm->tm_min = minute; - tm->tm_sec = second; - bp = &buf[strlen(atime_full_digits)]; - } - else if (!strcmp(format,atime_full_digits_d) && - (sscanf(buf, ascan_full_digits_d, - &year, &month, &day, &hour, &minute, &second) == 6)) { - tm->tm_year = year; - tm->tm_mon = month - 1; - tm->tm_mday = day; - tm->tm_hour = hour; - tm->tm_min = minute; - tm->tm_sec = second; - bp = &buf[strlen(atime_full_digits_d)]; - } - else if (!strcmp(format, atime_nsec_digits) && - (sscanf(buf, ascan_nsec_digits, - &year, &month, &day, &hour, &minute) == 5)) { - tm->tm_year = year; - tm->tm_mon = month - 1; - tm->tm_mday = day; - tm->tm_hour = hour; - tm->tm_min = minute; - tm->tm_sec = 0; - bp = &buf[strlen(atime_nsec_digits)]; - } - else if (!strcmp(format, atime_rel_hms) && - (sscanf(buf, ascan_rel_hms, &hour, &minute, &second) == 3)) { - now = time((time_t *) NULL); - memcpy(tm, localtime(&now), sizeof(struct tm)); - tm->tm_hour = hour; - tm->tm_min = minute; - tm->tm_sec = second; - bp = &buf[strlen(atime_rel_hms)]; - } - else if (!strcmp(format, atime_rel_hm) && - (sscanf(buf, ascan_rel_hm, &hour, &minute) == 2)) { - now = time((time_t *) NULL); - memcpy(tm, localtime(&now), sizeof(struct tm)); - tm->tm_hour = hour; - tm->tm_min = minute; - bp = &buf[strlen(atime_rel_hm)]; - } - else if (!strcmp(format, atime_rel_col_hms) && - (sscanf(buf, ascan_rel_col_hms, &hour, &minute, &second) == 3)) { - now = time((time_t *) NULL); - memcpy(tm, localtime(&now), sizeof(struct tm)); - tm->tm_hour = hour; - tm->tm_min = minute; - tm->tm_sec = second; - bp = &buf[strlen(atime_rel_col_hms)]; - } - else if (!strcmp(format, atime_rel_col_hm) && - (sscanf(buf, ascan_rel_col_hm, &hour, &minute) == 2)) { - now = time((time_t *) NULL); - memcpy(tm, localtime(&now), sizeof(struct tm)); - tm->tm_hour = hour; - tm->tm_min = minute; - bp = &buf[strlen(atime_rel_col_hm)]; - } - return(bp); -} -#endif /* HAVE_STRPTIME */ - + /* * String to internal datatype routines. * @@ -388,8 +185,8 @@ krb5_string_to_enctype(string, enctypep) krb5_error_code krb5_string_to_salttype(string, salttypep) - char * string; - krb5_int32 * salttypep; + char * string; + krb5_int32 * salttypep; { int i; int found; @@ -424,78 +221,6 @@ krb5_string_to_cksumtype(string, cksumtypep) return((found) ? 0 : EINVAL); } -krb5_error_code -krb5_string_to_timestamp(string, timestampp) - char * string; - krb5_timestamp * timestampp; -{ - int i; - int found; - struct tm timebuf; - time_t now; - char *s; - - found = 0; - now = time((time_t *) NULL); - for (i=0; i= 0) - days = svalues[deltat_table[i].dt_dindex]; - if (deltat_table[i].dt_hindex >= 0) - hours = svalues[deltat_table[i].dt_hindex]; - if (deltat_table[i].dt_mindex >= 0) - minutes = svalues[deltat_table[i].dt_mindex]; - if (deltat_table[i].dt_sindex >= 0) - seconds = svalues[deltat_table[i].dt_sindex]; - found = 1; - break; - } - } - if (found) { - dt = days; - dt *= 24; - dt += hours; - dt *= 60; - dt += minutes; - dt *= 60; - dt += seconds; - *deltatp = dt; - } - return((found) ? 0 : EINVAL); -} - /* * Internal datatype to string routines. * @@ -582,53 +307,118 @@ krb5_cksumtype_to_string(cksumtype, buffer, buflen) else return(EINVAL); } + +/* (absolute) time conversions */ -krb5_error_code +#ifndef HAVE_STRFTIME +#undef strftime +#define strftime my_strftime +static size_t strftime (char *, size_t, const char *, const struct tm *); +#endif + +#ifndef HAVE_STRPTIME +#undef strptime +#define strptime my_strptime +static char *strptime (const char *, const char *, struct tm *); +#endif + +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV +krb5_string_to_timestamp(string, timestampp) + char FAR * string; + krb5_timestamp FAR * timestampp; +{ + int i; + struct tm timebuf; + time_t now, ret_time; + char *s; + static const char * const atime_format_table[] = { + "%Y%m%d%H%M%S", /* yyyymmddhhmmss */ + "%Y.%m.%d.%H.%M.%S", /* yyyy.mm.dd.hh.mm.ss */ + "%y%m%d%H%M%S", /* yymmddhhmmss */ + "%y.%m.%d.%H.%M.%S", /* yy.mm.dd.hh.mm.ss */ + "%y%m%d%H%M", /* yymmddhhmm */ + "%H%M%S", /* hhmmss */ + "%H%M", /* hhmm */ + "%T", /* hh:mm:ss */ + "%R", /* hh:mm */ + /* The following not really supported unless native strptime present */ + "%x:%X", /* locale-dependent short format */ + "%d-%b-%Y:%T", /* dd-month-yyyy:hh:mm:ss */ + "%d-%b-%Y:%R" /* dd-month-yyyy:hh:mm */ + }; + static const int atime_format_table_nents = + sizeof(atime_format_table)/sizeof(atime_format_table[0]); + + + now = time((time_t *) NULL); + for (i=0; i\n\0 */ - buffer[strlen(buffer)-1] = '\0'; - return(0); - } - return(ENOMEM); -#endif /* HAVE_STRFTIME */ + return(0); } -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_timestamp_to_sfstring(timestamp, buffer, buflen, pad) krb5_timestamp timestamp; - char * buffer; + char FAR * buffer; size_t buflen; - char * pad; + char FAR * pad; { struct tm *tmp; size_t i; size_t ndone; - - tmp = localtime((time_t *) ×tamp); + time_t timestamp2 = timestamp; + + static const char * const sftime_format_table[] = { + "%c", /* Default locale-dependent date and time */ + "%d %b %Y %T", /* dd mon yyyy hh:mm:ss */ + "%x %X", /* locale-dependent short format */ + "%d/%m/%Y %R" /* dd/mm/yyyy hh:mm */ + }; + static const int sftime_format_table_nents = + sizeof(sftime_format_table)/sizeof(sftime_format_table[0]); + + tmp = localtime(×tamp2); ndone = 0; -#if HAVE_STRFTIME for (i=0; i= sftime_default_len) { - sprintf(buffer, sftime_default_fmt, - tmp->tm_mday, tmp->tm_mon+1, tmp->tm_year, - tmp->tm_hour, tmp->tm_min, tmp->tm_sec); + sprintf(buffer, "%02d/%02d/%4d %02d:%02d", + tmp->tm_mday, tmp->tm_mon+1, 1900+tmp->tm_year, + tmp->tm_hour, tmp->tm_min); ndone = strlen(buffer); } } @@ -639,47 +429,114 @@ krb5_timestamp_to_sfstring(timestamp, buffer, buflen, pad) } return((ndone) ? 0 : ENOMEM); } + +/* relative time (delta-t) conversions */ -krb5_error_code +/* string->deltat is in deltat.y */ + +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_deltat_to_string(deltat, buffer, buflen) krb5_deltat deltat; - char * buffer; + char FAR * buffer; size_t buflen; { int days, hours, minutes, seconds; krb5_deltat dt; - krb5_error_code retval; - days = (int) (deltat / (24*3600l)); - dt = deltat % (24*3600l); + /* + * We want something like ceil(log10(2**(nbits-1))) + 1. That log + * value is log10(2)*(nbits-1) or log10(2**8)*(nbits-1)/8. So, + * 2.4... is log10(256), rounded up. Add one to handle leading + * minus, and one more to force int cast to round the value up. + * This doesn't include room for a trailing nul. + * + * This will break if bytes are more than 8 bits. + */ +#define MAX_CHARS_FOR_INT_TYPE(TYPE) ((int) (2 + 2.408241 * sizeof (TYPE))) + char tmpbuf[MAX_CHARS_FOR_INT_TYPE(int) * 4 + 8]; + + days = (int) (deltat / (24*3600L)); + dt = deltat % (24*3600L); hours = (int) (dt / 3600); dt %= 3600; minutes = (int) (dt / 60); seconds = (int) (dt % 60); - retval = 0; - if (days) { - if (hours || minutes || seconds) { - if (buflen < (strlen(dt_output_dhms)+strlen(dt_day_plural))) - retval = ENOMEM; - else - sprintf(buffer, dt_output_dhms, days, - (days > 1) ? dt_day_plural : dt_day_singular, - hours, minutes, seconds); - } - else { - if (buflen < (strlen(dt_output_donly)+strlen(dt_day_plural))) - retval = ENOMEM; - else - sprintf(buffer, dt_output_donly, days, - (days > 1) ? dt_day_plural : dt_day_singular); - } - } - else { - if (buflen < strlen(dt_output_hms)) - retval = ENOMEM; - else - sprintf(buffer, dt_output_hms, hours, minutes, seconds); - } - return(retval); + memset (tmpbuf, 0, sizeof (tmpbuf)); + if (days == 0) + sprintf(buffer, "%d:%02d:%02d", hours, minutes, seconds); + else if (hours || minutes || seconds) + sprintf(buffer, "%d %s %02d:%02d:%02d", days, + (days > 1) ? "days" : "day", + hours, minutes, seconds); + else + sprintf(buffer, "%d %s", days, + (days > 1) ? "days" : "day"); + if (tmpbuf[sizeof(tmpbuf)-1] != 0) + /* Something must be very wrong with my math above, or the + assumptions going into it... */ + abort (); + if (strlen (tmpbuf) > buflen) + return ENOMEM; + else + strncpy (buffer, tmpbuf, buflen); + return 0; } + +#undef __P +#define __P(X) X + +#if !defined (HAVE_STRFTIME) || !defined (HAVE_STRPTIME) +#undef _CurrentTimeLocale +#define _CurrentTimeLocale (&dummy_locale_info) + +struct dummy_locale_info_t { + char d_t_fmt[15]; + char t_fmt_ampm[12]; + char t_fmt[9]; + char d_fmt[9]; + char day[7][10]; + char abday[7][4]; + char mon[12][10]; + char abmon[12][4]; + char am_pm[2][3]; +}; +static const struct dummy_locale_info_t dummy_locale_info = { + "%a %b %d %X %Y", /* %c */ + "%I:%M:%S %p", /* %r */ + "%H:%M:%S", /* %X */ + "%m/%d/%y", /* %x */ + { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", + "Saturday" }, + { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }, + { "January", "February", "March", "April", "May", "June", + "July", "August", "September", "October", "November", "December" }, + { "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }, + { "AM", "PM" }, +}; +#undef TM_YEAR_BASE +#define TM_YEAR_BASE 1900 +#endif + +#ifndef HAVE_STRFTIME +#undef DAYSPERLYEAR +#define DAYSPERLYEAR 366 +#undef DAYSPERNYEAR +#define DAYSPERNYEAR 365 +#undef DAYSPERWEEK +#define DAYSPERWEEK 7 +#undef isleap +#define isleap(N) ((N % 4) == 0 && (N % 100 != 0 || N % 400 == 0)) +#undef tzname +#define tzname my_tzname +static const char *const tzname[2] = { 0, 0 }; +#undef tzset +#define tzset() + +#include "strftime.c" +#endif + +#ifndef HAVE_STRPTIME +#include "strptime.c" +#endif diff --git a/src/lib/krb5/krb/strftime.c b/src/lib/krb5/krb/strftime.c new file mode 100644 index 0000000..f2a5cb7 --- /dev/null +++ b/src/lib/krb5/krb/strftime.c @@ -0,0 +1,415 @@ +/* $NetBSD: strftime.c,v 1.8 1999/02/07 17:33:30 augustss Exp $ */ + +/* + * Copyright (c) 1989 The Regents of the University of California. + * 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +#if 0 +static char *sccsid = "@(#)strftime.c 5.11 (Berkeley) 2/24/91"; +#else +__RCSID("$NetBSD: strftime.c,v 1.8 1999/02/07 17:33:30 augustss Exp $"); +#endif +#endif /* LIBC_SCCS and not lint */ + +#include +#include + +static int _add __P((const char *, char **, const char *)); +static int _conv __P((int, int, int, char **, const char *)); +static int _secs __P((const struct tm *, char **, const char *)); +static size_t _fmt __P((const char *, const struct tm *, char **, + const char *)); + +static size_t +strftime(s, maxsize, format, t) + char *s; + size_t maxsize; + const char *format; + const struct tm *t; +{ + char *pt; + + tzset(); + if (maxsize < 1) + return (0); + + pt = s; + if (_fmt(format, t, &pt, s + maxsize)) { + *pt = '\0'; + return (pt - s); + } else + return (0); +} + +#define SUN_WEEK(t) (((t)->tm_yday + 7 - \ + ((t)->tm_wday)) / 7) +#define MON_WEEK(t) (((t)->tm_yday + 7 - \ + ((t)->tm_wday ? (t)->tm_wday - 1 : 6)) / 7) + +static size_t +_fmt(format, t, pt, ptlim) + const char *format; + const struct tm *t; + char **pt; + const char * const ptlim; +{ + for (; *format; ++format) { + if (*format == '%') { + ++format; + if (*format == 'E') { + /* Alternate Era */ + ++format; + } else if (*format == 'O') { + /* Alternate numeric symbols */ + ++format; + } + switch (*format) { + case '\0': + --format; + break; + case 'A': + if (t->tm_wday < 0 || t->tm_wday > 6) + return (0); + if (!_add(_CurrentTimeLocale->day[t->tm_wday], + pt, ptlim)) + return (0); + continue; + + case 'a': + if (t->tm_wday < 0 || t->tm_wday > 6) + return (0); + if (!_add(_CurrentTimeLocale->abday[t->tm_wday], + pt, ptlim)) + return (0); + continue; + case 'B': + if (t->tm_mon < 0 || t->tm_mon > 11) + return (0); + if (!_add(_CurrentTimeLocale->mon[t->tm_mon], + pt, ptlim)) + return (0); + continue; + case 'b': + case 'h': + if (t->tm_mon < 0 || t->tm_mon > 11) + return (0); + if (!_add(_CurrentTimeLocale->abmon[t->tm_mon], + pt, ptlim)) + return (0); + continue; + case 'C': + if (!_conv((t->tm_year + TM_YEAR_BASE) / 100, + 2, '0', pt, ptlim)) + return (0); + continue; + case 'c': + if (!_fmt(_CurrentTimeLocale->d_t_fmt, t, pt, + ptlim)) + return (0); + continue; + case 'D': + if (!_fmt("%m/%d/%y", t, pt, ptlim)) + return (0); + continue; + case 'd': + if (!_conv(t->tm_mday, 2, '0', pt, ptlim)) + return (0); + continue; + case 'e': + if (!_conv(t->tm_mday, 2, ' ', pt, ptlim)) + return (0); + continue; + case 'H': + if (!_conv(t->tm_hour, 2, '0', pt, ptlim)) + return (0); + continue; + case 'I': + if (!_conv(t->tm_hour % 12 ? + t->tm_hour % 12 : 12, 2, '0', pt, ptlim)) + return (0); + continue; + case 'j': + if (!_conv(t->tm_yday + 1, 3, '0', pt, ptlim)) + return (0); + continue; + case 'k': + if (!_conv(t->tm_hour, 2, ' ', pt, ptlim)) + return (0); + continue; + case 'l': + if (!_conv(t->tm_hour % 12 ? + t->tm_hour % 12: 12, 2, ' ', pt, ptlim)) + return (0); + continue; + case 'M': + if (!_conv(t->tm_min, 2, '0', pt, ptlim)) + return (0); + continue; + case 'm': + if (!_conv(t->tm_mon + 1, 2, '0', pt, ptlim)) + return (0); + continue; + case 'n': + if (!_add("\n", pt, ptlim)) + return (0); + continue; + case 'p': + if (!_add(_CurrentTimeLocale->am_pm[t->tm_hour + >= 12], pt, ptlim)) + return (0); + continue; + case 'R': + if (!_fmt("%H:%M", t, pt, ptlim)) + return (0); + continue; + case 'r': + if (!_fmt(_CurrentTimeLocale->t_fmt_ampm, t, pt, + ptlim)) + return (0); + continue; + case 'S': + if (!_conv(t->tm_sec, 2, '0', pt, ptlim)) + return (0); + continue; + case 's': + if (!_secs(t, pt, ptlim)) + return (0); + continue; + case 'T': + if (!_fmt("%H:%M:%S", t, pt, ptlim)) + return (0); + continue; + case 't': + if (!_add("\t", pt, ptlim)) + return (0); + continue; + case 'U': + if (!_conv(SUN_WEEK(t), 2, '0', pt, ptlim)) + return (0); + continue; + case 'u': + if (!_conv(t->tm_wday ? t->tm_wday : 7, 1, '0', + pt, ptlim)) + return (0); + continue; + case 'V': /* ISO 8601 week number */ + case 'G': /* ISO 8601 year (four digits) */ + case 'g': /* ISO 8601 year (two digits) */ +/* +** From Arnold Robbins' strftime version 3.0: "the week number of the +** year (the first Monday as the first day of week 1) as a decimal number +** (01-53)." +** (ado, 1993-05-24) +** +** From "http://www.ft.uni-erlangen.de/~mskuhn/iso-time.html" by Markus Kuhn: +** "Week 01 of a year is per definition the first week which has the +** Thursday in this year, which is equivalent to the week which contains +** the fourth day of January. In other words, the first week of a new year +** is the week which has the majority of its days in the new year. Week 01 +** might also contain days from the previous year and the week before week +** 01 of a year is the last week (52 or 53) of the previous year even if +** it contains days from the new year. A week starts with Monday (day 1) +** and ends with Sunday (day 7). For example, the first week of the year +** 1997 lasts from 1996-12-30 to 1997-01-05..." +** (ado, 1996-01-02) +*/ + { + int year; + int yday; + int wday; + int w; + + year = t->tm_year + TM_YEAR_BASE; + yday = t->tm_yday; + wday = t->tm_wday; + for ( ; ; ) { + int len; + int bot; + int top; + + len = isleap(year) ? + DAYSPERLYEAR : + DAYSPERNYEAR; + /* + ** What yday (-3 ... 3) does + ** the ISO year begin on? + */ + bot = ((yday + 11 - wday) % + DAYSPERWEEK) - 3; + /* + ** What yday does the NEXT + ** ISO year begin on? + */ + top = bot - + (len % DAYSPERWEEK); + if (top < -3) + top += DAYSPERWEEK; + top += len; + if (yday >= top) { + ++year; + w = 1; + break; + } + if (yday >= bot) { + w = 1 + ((yday - bot) / + DAYSPERWEEK); + break; + } + --year; + yday += isleap(year) ? + DAYSPERLYEAR : + DAYSPERNYEAR; + } +#ifdef XPG4_1994_04_09 + if ((w == 52 + && t->tm_mon == TM_JANUARY) + || (w == 1 + && t->tm_mon == TM_DECEMBER)) + w = 53; +#endif /* defined XPG4_1994_04_09 */ + if (*format == 'V') { + if (!_conv(w, 2, '0', + pt, ptlim)) + return (0); + } else if (*format == 'g') { + if (!_conv(year % 100, 2, '0', + pt, ptlim)) + return (0); + } else if (!_conv(year, 4, '0', + pt, ptlim)) + return (0); + } + continue; + case 'W': + if (!_conv(MON_WEEK(t), 2, '0', pt, ptlim)) + return (0); + continue; + case 'w': + if (!_conv(t->tm_wday, 1, '0', pt, ptlim)) + return (0); + continue; + case 'x': + if (!_fmt(_CurrentTimeLocale->d_fmt, t, pt, + ptlim)) + return (0); + continue; + case 'X': + if (!_fmt(_CurrentTimeLocale->t_fmt, t, pt, + ptlim)) + return (0); + continue; + case 'y': + if (!_conv((t->tm_year + TM_YEAR_BASE) % 100, + 2, '0', pt, ptlim)) + return (0); + continue; + case 'Y': + if (!_conv((t->tm_year + TM_YEAR_BASE), 4, '0', + pt, ptlim)) + return (0); + continue; + case 'Z': + if (tzname[t->tm_isdst ? 1 : 0] && + !_add(tzname[t->tm_isdst ? 1 : 0], pt, + ptlim)) + return (0); + continue; + case '%': + /* + * X311J/88-090 (4.12.3.5): if conversion char is + * undefined, behavior is undefined. Print out the + * character itself as printf(3) does. + */ + default: + break; + } + } + if (*pt == ptlim) + return (0); + *(*pt)++ = *format; + } + return (ptlim - *pt); +} + +static int +_secs(t, pt, ptlim) + const struct tm *t; + char **pt; + const char * const ptlim; +{ + char buf[15]; + time_t s; + char *p; + struct tm tmp; + + buf[sizeof (buf) - 1] = '\0'; + /* Make a copy, mktime(3) modifies the tm struct. */ + tmp = *t; + s = mktime(&tmp); + for (p = buf + sizeof(buf) - 2; s > 0 && p > buf; s /= 10) + *p-- = (char)(s % 10 + '0'); + return (_add(++p, pt, ptlim)); +} + +static int +_conv(n, digits, pad, pt, ptlim) + int n, digits; + int pad; + char **pt; + const char * const ptlim; +{ + char buf[10]; + char *p; + + buf[sizeof (buf) - 1] = '\0'; + for (p = buf + sizeof(buf) - 2; n > 0 && p > buf; n /= 10, --digits) + *p-- = n % 10 + '0'; + while (p > buf && digits-- > 0) + *p-- = pad; + return (_add(++p, pt, ptlim)); +} + +static int +_add(str, pt, ptlim) + const char *str; + char **pt; + const char * const ptlim; +{ + + for (;; ++(*pt)) { + if (*pt == ptlim) + return (0); + if ((**pt = *str++) == '\0') + return (1); + } +} diff --git a/src/lib/krb5/krb/strptime.c b/src/lib/krb5/krb/strptime.c new file mode 100644 index 0000000..ac52d5c --- /dev/null +++ b/src/lib/krb5/krb/strptime.c @@ -0,0 +1,386 @@ +/* $NetBSD: strptime.c,v 1.18 1999/04/29 02:58:30 tv Exp $ */ + +/*- + * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code was contributed to The NetBSD Foundation by Klaus Klein. + * + * 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +__RCSID("$NetBSD: strptime.c,v 1.18 1999/04/29 02:58:30 tv Exp $"); +#endif + +#include +#include +#include + +#undef _ctloc +#define _ctloc(x) _CurrentTimeLocale->x + +/* + * We do not implement alternate representations. However, we always + * check whether a given modifier is allowed for a certain conversion. + */ +#define ALT_E 0x01 +#define ALT_O 0x02 +#define LEGAL_ALT(x) { if (alt_format & ~(x)) return (0); } + + +static int conv_num __P((const char **, int *, int, int)); + + +static char * +strptime(buf, fmt, tm) + const char *buf, *fmt; + struct tm *tm; +{ + char c; + const char *bp; + size_t len = 0; + int alt_format, i, split_year = 0; + + bp = buf; + + while ((c = *fmt) != '\0') { + /* Clear `alternate' modifier prior to new conversion. */ + alt_format = 0; + + /* Eat up white-space. */ + if (isspace(c)) { + while (isspace(*bp)) + bp++; + + fmt++; + continue; + } + + if ((c = *fmt++) != '%') + goto literal; + + +again: switch (c = *fmt++) { + case '%': /* "%%" is converted to "%". */ +literal: + if (c != *bp++) + return (0); + break; + + /* + * "Alternative" modifiers. Just set the appropriate flag + * and start over again. + */ + case 'E': /* "%E?" alternative conversion modifier. */ + LEGAL_ALT(0); + alt_format |= ALT_E; + goto again; + + case 'O': /* "%O?" alternative conversion modifier. */ + LEGAL_ALT(0); + alt_format |= ALT_O; + goto again; + + /* + * "Complex" conversion rules, implemented through recursion. + */ + case 'c': /* Date and time, using the locale's format. */ + LEGAL_ALT(ALT_E); + if (!(bp = strptime(bp, _ctloc(d_t_fmt), tm))) + return (0); + break; + + case 'D': /* The date as "%m/%d/%y". */ + LEGAL_ALT(0); + if (!(bp = strptime(bp, "%m/%d/%y", tm))) + return (0); + break; + + case 'R': /* The time as "%H:%M". */ + LEGAL_ALT(0); + if (!(bp = strptime(bp, "%H:%M", tm))) + return (0); + break; + + case 'r': /* The time in 12-hour clock representation. */ + LEGAL_ALT(0); + if (!(bp = strptime(bp, _ctloc(t_fmt_ampm), tm))) + return (0); + break; + + case 'T': /* The time as "%H:%M:%S". */ + LEGAL_ALT(0); + if (!(bp = strptime(bp, "%H:%M:%S", tm))) + return (0); + break; + + case 'X': /* The time, using the locale's format. */ + LEGAL_ALT(ALT_E); + if (!(bp = strptime(bp, _ctloc(t_fmt), tm))) + return (0); + break; + + case 'x': /* The date, using the locale's format. */ + LEGAL_ALT(ALT_E); + if (!(bp = strptime(bp, _ctloc(d_fmt), tm))) + return (0); + break; + + /* + * "Elementary" conversion rules. + */ + case 'A': /* The day of week, using the locale's form. */ + case 'a': + LEGAL_ALT(0); + for (i = 0; i < 7; i++) { + /* Full name. */ + len = strlen(_ctloc(day[i])); + if (strncasecmp(_ctloc(day[i]), bp, len) == 0) + break; + + /* Abbreviated name. */ + len = strlen(_ctloc(abday[i])); + if (strncasecmp(_ctloc(abday[i]), bp, len) == 0) + break; + } + + /* Nothing matched. */ + if (i == 7) + return (0); + + tm->tm_wday = i; + bp += len; + break; + + case 'B': /* The month, using the locale's form. */ + case 'b': + case 'h': + LEGAL_ALT(0); + for (i = 0; i < 12; i++) { + /* Full name. */ + len = strlen(_ctloc(mon[i])); + if (strncasecmp(_ctloc(mon[i]), bp, len) == 0) + break; + + /* Abbreviated name. */ + len = strlen(_ctloc(abmon[i])); + if (strncasecmp(_ctloc(abmon[i]), bp, len) == 0) + break; + } + + /* Nothing matched. */ + if (i == 12) + return (0); + + tm->tm_mon = i; + bp += len; + break; + + case 'C': /* The century number. */ + LEGAL_ALT(ALT_E); + if (!(conv_num(&bp, &i, 0, 99))) + return (0); + + if (split_year) { + tm->tm_year = (tm->tm_year % 100) + (i * 100); + } else { + tm->tm_year = i * 100; + split_year = 1; + } + break; + + case 'd': /* The day of month. */ + case 'e': + LEGAL_ALT(ALT_O); + if (!(conv_num(&bp, &tm->tm_mday, 1, 31))) + return (0); + break; + + case 'k': /* The hour (24-hour clock representation). */ + LEGAL_ALT(0); + /* FALLTHROUGH */ + case 'H': + LEGAL_ALT(ALT_O); + if (!(conv_num(&bp, &tm->tm_hour, 0, 23))) + return (0); + break; + + case 'l': /* The hour (12-hour clock representation). */ + LEGAL_ALT(0); + /* FALLTHROUGH */ + case 'I': + LEGAL_ALT(ALT_O); + if (!(conv_num(&bp, &tm->tm_hour, 1, 12))) + return (0); + if (tm->tm_hour == 12) + tm->tm_hour = 0; + break; + + case 'j': /* The day of year. */ + LEGAL_ALT(0); + if (!(conv_num(&bp, &i, 1, 366))) + return (0); + tm->tm_yday = i - 1; + break; + + case 'M': /* The minute. */ + LEGAL_ALT(ALT_O); + if (!(conv_num(&bp, &tm->tm_min, 0, 59))) + return (0); + break; + + case 'm': /* The month. */ + LEGAL_ALT(ALT_O); + if (!(conv_num(&bp, &i, 1, 12))) + return (0); + tm->tm_mon = i - 1; + break; + + case 'p': /* The locale's equivalent of AM/PM. */ + LEGAL_ALT(0); + /* AM? */ + if (strcasecmp(_ctloc(am_pm[0]), bp) == 0) { + if (tm->tm_hour > 11) + return (0); + + bp += strlen(_ctloc(am_pm[0])); + break; + } + /* PM? */ + else if (strcasecmp(_ctloc(am_pm[1]), bp) == 0) { + if (tm->tm_hour > 11) + return (0); + + tm->tm_hour += 12; + bp += strlen(_ctloc(am_pm[1])); + break; + } + + /* Nothing matched. */ + return (0); + + case 'S': /* The seconds. */ + LEGAL_ALT(ALT_O); + if (!(conv_num(&bp, &tm->tm_sec, 0, 61))) + return (0); + break; + + case 'U': /* The week of year, beginning on sunday. */ + case 'W': /* The week of year, beginning on monday. */ + LEGAL_ALT(ALT_O); + /* + * XXX This is bogus, as we can not assume any valid + * information present in the tm structure at this + * point to calculate a real value, so just check the + * range for now. + */ + if (!(conv_num(&bp, &i, 0, 53))) + return (0); + break; + + case 'w': /* The day of week, beginning on sunday. */ + LEGAL_ALT(ALT_O); + if (!(conv_num(&bp, &tm->tm_wday, 0, 6))) + return (0); + break; + + case 'Y': /* The year. */ + LEGAL_ALT(ALT_E); + if (!(conv_num(&bp, &i, 0, 9999))) + return (0); + + tm->tm_year = i - TM_YEAR_BASE; + break; + + case 'y': /* The year within 100 years of the epoch. */ + LEGAL_ALT(ALT_E | ALT_O); + if (!(conv_num(&bp, &i, 0, 99))) + return (0); + + if (split_year) { + tm->tm_year = ((tm->tm_year / 100) * 100) + i; + break; + } + split_year = 1; + if (i <= 68) + tm->tm_year = i + 2000 - TM_YEAR_BASE; + else + tm->tm_year = i + 1900 - TM_YEAR_BASE; + break; + + /* + * Miscellaneous conversions. + */ + case 'n': /* Any kind of white-space. */ + case 't': + LEGAL_ALT(0); + while (isspace(*bp)) + bp++; + break; + + + default: /* Unknown/unsupported conversion. */ + return (0); + } + + + } + + /* LINTED functional specification */ + return ((char *)bp); +} + + +static int +conv_num(buf, dest, llim, ulim) + const char **buf; + int *dest; + int llim, ulim; +{ + int result = 0; + + /* The limit also determines the number of valid digits. */ + int rulim = ulim; + + if (**buf < '0' || **buf > '9') + return (0); + + do { + result *= 10; + result += *(*buf)++ - '0'; + rulim /= 10; + } while ((result * 10 <= ulim) && rulim && **buf >= '0' && **buf <= '9'); + + if (result < llim || result > ulim) + return (0); + + *dest = result; + return (1); +} diff --git a/src/lib/krb5/krb/t_kerb.c b/src/lib/krb5/krb/t_kerb.c index 3a960b8..b4d1781 100644 --- a/src/lib/krb5/krb/t_kerb.c +++ b/src/lib/krb5/krb/t_kerb.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -14,6 +15,22 @@ #include "com_err.h" +void test_string_to_timestamp(ctx, time) + krb5_context ctx; + char *time; +{ + krb5_timestamp timestamp; + time_t t; + krb5_error_code retval; + + retval = krb5_string_to_timestamp(time, ×tamp); + if (retval) { + com_err("krb5_string_to_timestamp", retval, 0); + return; + } + t = (time_t) timestamp; + printf("Parsed time was %s", ctime(&t)); +} void test_425_conv_principal(ctx, name, inst, realm) krb5_context ctx; @@ -82,6 +99,7 @@ void usage(progname) fprintf(stderr, "%s: Usage: %s 425_conv_principal \n", progname); + fprintf(stderr, "\t%s string_to_timestamp