diff options
183 files changed, 4567 insertions, 7801 deletions
@@ -1,4 +1,4 @@ - Kerberos Version 5, Release 1.3.5 + Kerberos Version 5, Release 1.4.1 Release Notes The MIT Kerberos Team @@ -6,21 +6,16 @@ Unpacking the Source Distribution --------------------------------- -The source distribution of Kerberos 5 comes in a gzipped tarfile, -krb5-1.3.5.tar.gz. Instructions on how to extract the entire -distribution follow. +The source distribution of Kerberos 5 comes in a tarfile, +krb5-1.4.1-signed.tar. The tarfile contains a gzipped tarfile, +krb5-1.4.1.tar.gz, and its corresponding PGP signature, +krb5-1.4.1.tar.gz.asc. -If you have the GNU tar program and gzip installed, you can simply do: +You will need the GNU gzip program, and preferably, the GNU tar +program, to extract the source distribution. - gtar zxpf krb5-1.3.5.tar.gz - -If you don't have GNU tar, you will need to get the FSF gzip -distribution and use gzcat: - - gzcat krb5-1.3.5.tar.gz | tar xpf - - -Both of these methods will extract the sources into krb5-1.3.5/src and -the documentation into krb5-1.3.5/doc. +The distribution will extract into a subdirectory "krb5-1.4.1" of the +current directory. Building and Installing Kerberos 5 ---------------------------------- @@ -59,940 +54,435 @@ http://krbdev.mit.edu/rt/ and logging in as "guest" with password "guest". -Major changes in 1.3.5 ----------------------- - -* [2682] Fix ftpd hang caused by empty PASS command. - -* [2686] Fix double-free errors. [MITKRB5-SA-2004-002] - -* [2687] Fix denial-of-service vulnerability in ASN.1 - decoder. [MITKRB5-SA-2004-003] - -Minor changes in 1.3.5 ----------------------- - -* [2016] Fix build problem in fake-addrinfo.h by including stdio.h so - that sprintf() gets prototyped where needed on some platforms. - -* [2353] Add missing prototype for gss_krb5int_unseal_token_v3(). - -* [2607] Fix enctype filtering and some memory leaks in MSLSA ccache. - -* [2608] Remove incorrect localization in MSLSA ccache which was - resulting in crashes. - -* [2619] Update MSLSA ccache to support new LSA flag. - -* [2623] Update MSLSA ccache to reflect differences in registry layout - between Windows client and server OSes. - -* [2624] Do not ignore the cache when obtaining TGTs from the MSLSA if - the requested enctype is the NULL enctype. - -* [2626] Add Terminal Server compatibility for KfW. - -* [2627] Fix cc_mslsa thread safety. - -* [2634] Remove the caching of the ccache principal name from - krb5_context. - -* [2643] Fix another problem with krb4 ticket backdating. - -* [2675] Add new WiX-based MSI installer for KfW. - -* [2677] Add "-c ccache" option to kvno; use consistent memory - management to avoid crashes on Windows. - -* [2689] Misc MSLSA ccache fixes. - -* [2691] Improve documentation of ANSI C requirement. - -Major changes in 1.3.4 ----------------------- - -* [2024, 2583, 2584] Fixed buffer overflows in - krb5_aname_to_localname(). [MITKRB-SA-2004-001] - -Minor changes in 1.3.4 ----------------------- - -* [957] The auth_to_local rules now allow for the client realm to be - examined. - -* [2527, 2528, 2531] Keytab file names lacking a "FILE:" prefix now work - under Windows. - -* [2533] Updated installer scripts for Windows. - -* [2534] Fixed memory leak for when an incorrect password is input to - krb5_get_init_creds_password(). - -* [2535] Added missing newline to dnssrv.c. - -* [2551, 2564] Use compile-time checks to determine endianness. - -* [2558] krb5_send_tgs() now correctly sets message_type after - receiving a KRB_ERROR message. - -* [2561, 2574] Fixed memory allocation errors in the MSLSA ccache. - -* [2562] The Windows installer works around cases where DLLs cannot be - unloaded. - -* [2585] Documentation correctly describes AES support in GSSAPI. - -Major changes in 1.3.3 ----------------------- - -* [2284] Fixed accept_sec_context to use a replay cache in the - GSS_C_NO_CREDENTIAL case. Reported by Cesar Garcia. - -* [2426] Fixed a spurious SIGPIPE that happened in the TCP sendto_kdc - code on AIX. Thanks to Bill Dodd. - -* [2430] Fixed a crash in the MSLSA ccache. - -* [2453] The AES string-to-key function no longer returns a pointer to - stack memory when given a password longer than 64 characters. - -Minor changes in 1.3.3 ----------------------- - -* [2277] In sendto_kdc, a socket leak on connection failure was fixed. - Thanks to Bill Dodd. - -* [2384] A memory leak in the TCP handling code in the KDC has been - fixed. Thanks to Will Fiveash. - -* [2521] The Windows NSIS installer scripts are in the source tree. - -* [2522] The MSLSA ccache now supports Windows 9x. - -Major changes in 1.3.2 +Important notice regarding Kerberos 4 support +--------------------------------------------- + +In the past few years, several developments have shown the inadequacy +of the security of version 4 of the Kerberos protocol. These +developments have led the MIT Kerberos Team to begin the process of +ending support for version 4 of the Kerberos protocol. The plan +involves the eventual removal of Kerberos 4 support from the MIT +implementation of Kerberos. + +The Data Encryption Standard (DES) has reached the end of its useful +life. DES is the only encryption algorithm supported by Kerberos 4, +and the increasingly obvious inadequacy of DES motivates the +retirement of the Kerberos 4 protocol. The National Institute of +Standards and Technology (NIST), which had previously certified DES as +a US government encryption standard, has officially announced[1] its +intention to withdraw the specification of DES. + +NIST's action reflects the long-held opinion of the cryptographic +community that DES has too small a key space to be secure. Breaking +DES encryption by an exhaustive search of its key space is within the +means of some individuals, many companies, and all major governments. +Consequently, DES cannot be considered secure for any long-term keys, +particularly the ticket-granting key that is central to Kerberos. + +Serious protocol flaws[2] have been found in Kerberos 4. These flaws +permit attacks which require far less effort than an exhaustive search +of the DES key space. These flaws make Kerberos 4 cross-realm +authentication an unacceptable security risk and raise serious +questions about the security of the entire Kerberos 4 protocol. + +The known insecurity of DES, combined with the recently discovered +protocol flaws, make it extremely inadvisable to rely on the security +of version 4 of the Kerberos protocol. These factors motivate the MIT +Kerberos Team to remove support for Kerberos version 4 from the MIT +implementation of Kerberos. + +The process of ending Kerberos 4 support began with release 1.3 of MIT +Kerberos 5. In release 1.3, the KDC support for version 4 of the +Kerberos protocol is disabled by default. Release 1.4 of MIT Kerberos +continues to include Kerberos 4 support (also disabled by default in +the KDC), but we intend to completely remove Kerberos 4 support from +some future release of MIT Kerberos, possibly as early as the 1.5 +release of MIT Kerberos. + +The MIT Kerberos Team has ended active development of Kerberos 4, +except for the eventual removal of all Kerberos 4 functionality. We +will continue to provide critical security fixes for Kerberos 4, but +routine bug fixes and feature enhancements are at an end. + +We recommend that any sites which have not already done so begin a +migration to Kerberos 5. Kerberos 5 provides significant advantages +over Kerberos 4, including support for strong encryption, +extensibility, improved cross-vendor interoperability, and ongoing +development and enhancement. + +If you have questions or issues regarding migration to Kerberos 5, we +recommend discussing them on the kerberos@mit.edu mailing list. + + References + +[1] National Institute of Standards and Technology. Announcing + Proposed Withdrawal of Federal Information Processing Standard + (FIPS) for the Data Encryption Standard (DES) and Request for + Comments. Federal Register 04-16894, 69 FR 44509-44510, 26 July + 2004. DOCID:fr26jy04-31. + +[2] Tom Yu, Sam Hartman, and Ken Raeburn. The Perils of + Unauthenticated Encryption: Kerberos Version 4. In Proceedings of + the Network and Distributed Systems Security Symposium. The + Internet Society, February 2004. + http://web.mit.edu/tlyu/papers/krb4peril-ndss04.pdf + +---------------------------------------------------------------------- + +Major changes in 1.4.1 ---------------------- -* [2040, 1471, 2067, 2077, 2079, 2166, 2167, 2220, 2266] Support for - AES in GSSAPI has been implemented. This corresponds to the - in-progress work in the IETF (CFX). +* [2913] The kadmin client library now performs authentication flavor + fallback in a useful way when attempting to contact a pre-1.4 kadmin + daemon. -* [2049, 2139, 2148, 2153, 2182, 2183, 2184, 2190, 2202] Added a new - ccache type "MSLSA:" for read-only access to the MS Windows LSA - cache. +* [2988] Fix telnet client buffer overflow vulnerabilities. + [MITKRB5-SA-2005-001] -* [982] On windows, krb5.exe now has a checkbox to request addressless - tickets. - -* [2189, 2234] To avoid compatibility problems, unrecognized TGS - options will now be ignored. Thanks to Wyllys Ingersoll for finding - a problem with a previous fix. - -* [2218] 128-bit AES has been added to the default enctypes. - -* [2223, 2229] AES cryptosystem now chains IVs. This WILL break - backwards compatibility for the kcmd applications, if they are using - AES session keys. Thanks to Wyllys Ingersoll for finding a problem - with a previous fix. - -Minor changes in 1.3.2 +Minor changes in 1.4.1 ---------------------- -* [1437] Applied patch from Stephen Grau so kinit returns non-zero - status under certain failure conditions where it had previously - returned zero. - -* [1586] On Windows, the krb4 CREDENTIALS structure has been changed - to align with KfW's version of the structure. - -* [1613] Applied patch from Dave Shrimpton to avoid truncation of - dates output from the kadmin CLI when long time zone names are - used. - -* [1622] krshd no longer calls syslog from inside a signal handler, in - an effort to avoid deadlocks on exit. - -* [1649] A com_err test program compiles properly on Darwin now. - -* [1692] A new configuration file tag "master_kdc" has been added to - allow master KDCs to be designated separately from admin servers. - -* [1702] krb5_get_host_realm() and krb5_free_host_realm() are no - longer marked as KRB5_PRIVATE. - -* [1711] Applied patch from Harry McGavran Jr to allow fake-addrinfo.h - to compile on libc5 Linux platforms. - -* [1712] Applied patch from Cesar Garcia to fix lifetime computation - in krb524 ticket conversion. - -* [1714] Fixed a 64-bit endianness bug in ticket starttime encoding in - krb524d. Found by Cesar Garcia. - -* [1715] kadmind4 and v5passwdd are no longer installed on Mac OS X. - -* [1718] The krb4 library configure script now recognizes - OpenDarwin/x86. Bug found by Rob Braun. - -* [1721] krb5_get_init_creds_password() no longer returns a spurious - KRB5_REALM_UNKNOWN if DNS SRV record support is turned off. - -* [1730] krb_mk_auth() no longer overzealously clears the key - schedule. - -* [1731] A double-free related to reading forwarded credentials has - been fixed. Found by Joseph Galbraith. - -* [1770] Applied patch from Maurice Massar to fix a foreachaddr() - problem that was causing the KDC to segfault on startup. - -* [1790] The Linux build uses $(CC) to create shared libraries, - avoiding a libgcc problem when building libdb. - -* [1792] The lib/kadm5 unit tests now work around a Solaris 9 - pty-close bug. - -* [1793] The test suite works around some Tru64 and Irix RPATH - issues, which previously could prevent tests from running on a build - with shared libraries enabled. - -* [1799] kadmind supports callouts to the Apple password server. - -* [1893] KRB-SAFE messages from older releases can now be read - successfully. Prior 1.3.x releases did not save the encoded - KRB-SAFE message, and experienced problems when re-encoding. Found - by Scooter Morris. - -* [1962] MS LSA tickets with short remaining lifetimes will be - rejected in favor of retrieving tickets bypassing the LSA cache. - -* [1973] sendto_kdc.c now closes sockets with closesocket() instead of - close(), avoiding a descriptor leak on Windows. +Please see -* [1979] An erroneously short initial sequence number mask has been - fixed. +http://krbdev.mit.edu/rt/NoAuth/krb5-1.4/fixed-1.4.1.html -* [2028] KfW now displays a kinit dialog when GSS fails to find - tickets. +for a complete list. +* [2888] On Windows, restore library state to uninialized when library + is unloaded. -* [2051] Missing exports have been added to krb4_32.def on Windows. +* [2906] Map ns_rr_class to ns_rr_cl for some versions of BIND. -* [2058] Some problems with krb4 ticket lifetime backdating have - fixed. +* [2916] Perform some cleanup on library unload to avoid leaks. -* [2060] GSSAPI's idea of the default ccache is less sticky now. +* [2918] krb5_get_init_creds_password() now correctly handles an empty + string passed in as a password argument. -* [2068] The profile library includes prof-int.h before conditionals - that rely on it. +* [2924] gss_mech_xxx symbols are now exported on Windows. -* [2084] The resolver library is no longer referenced by library code - if not building with DNS SRV record support. +* [2942] Fix null pointer deref possible in threaded program calls to + profile library. -* [2085] Updated Windows README file to reflect current compilation - requirements, etc. +* [2949] The delta-time parser no longer conflicts with some symbols + in HP-UX header files. -* [2104] On Windows, only define strcasecmp and strncasecmp - replacement macros if said functions are missing. +* [2950] Deleted profile nodes are now correctly skipped by the + iterator. -* [2106] Return an error for unimplemented ccache functions, rather - than calling through a null pointer. +* [2953] Handle variant gmtime_r() on HP-UX 10. -* [2118] Applied patch from Will Fiveash to use correct parameter for - KDC TCP listening sockets. +* [2955] Conditionalize the use of reverse DNS lookups in + krb5_sname_to_principal(). -* [2144,2230] Memory management errors in the Windows gss.exe test - client have been fixed. +* [2960] gssapi.h no longer leaks preprocessor symbols. -* [2171] krb5_locate_kpasswd() now correctly calls htons() on the - kpasswd port number. Found by Arlene Berry. +* [2961] Fix some missing build dependencies in util/ss. -* [2180] The profile library now includes pthread.h when compiled with - USE_PTHREADS. +* [2962] Fix case of @MAINT@ substitution breaking Windows build. -* [2181, 2224] A timeout has been added to gss-server, and a missing - parameter to sign_server() has been added. +* [2963] On windows, fix dangerous 64-bit time_t * to long * + conversions. -* [2196] config.{guess,sub} have been updated from autoconf-2.59. - -* [2204] Windows gss.exe now has support for specifying credentials - cache, as well as some minor bugfixes. - -* [2210] GSSAPI accept_sec_context() no longer unconditionally sets - INTEG and CONF flags in contradiction to what the initiator sent. - -* [2212] The GSS sample application has some additional options to - support testing of SSPI vs GSSAPI. - -* [2217] Windows gss.exe has new UI elements to support more flag - settings. - -* [2225] In the gss sample client, some extraneous parameters have - been removed from client_establish_context(). - -* [2228] Copyright notices updated in GSS sample apps. - -* [2233] On Windows compiles with KRB5_KFW_COMPILE, the lib path for - krbcc32.lib is now correct. - -* [2195, 2236, 2241, 2245] The Solaris 9 pty-close bug, which was - affecting the test suite, has been worked around by hacking - scheduler priorities. See the installation notes for details. - Thanks to Bill Sommerfeld for some useful hints. - -* [2258] An incorrect memcpy() statement in fakeka has been fixed. - Reported by David Thompson. - -Notes, Major Changes, and Known Bugs for 1.3.1 ----------------------------------------------- - -* [1681] The incorrect encoding of the ETYPE-INFO2 preauthentication - hint is no longer emitted, and the both the incorrect and the - correct encodings of ETYPE-INFO2 are now accepted. We STRONGLY - encourage deploying krb5-1.3.1 in preference to 1.3, especially on - client installations, as the 1.3 release did not conform to the - internet-draft for the revised Kerberos protocol in its encoding of - ETYPE-INFO2. - -* [1683] The non-caching getaddrinfo() API on Mac OS X, which was - causing significant slowdowns under some circumstances, has been - worked around. - -Minor changes in 1.3.1 ----------------------- - -* [1015] gss_accept_sec_context() now passes correct arguments to - TREAD_STR() when reading options beyond the forwarded credential - option. Thanks to Emily Ratliff. - -* [1365] The GSSAPI initiator credentials are no longer cached inside - the GSSAPI library. - -* [1651] A buffer overflow in krb_get_admhst() has been fixed. - -* [1655] krb5_get_permitted_enctypes() and krb5_set_real_time() are - now exported for use by Samba. - -* [1656] gss_init_sec_context() no longer leaks credentials under some +* [2964] Fix invalid return value from krb5_c_is_keyed_cksum() during error conditions. -* [1657] krb_get_lrealm() no longer returns "ATHENA.MIT.EDU" - inappropriately. - -* [1664] The crypto library no longer has bogus dependencies on - com_err. - -* [1665] krb5_init_context() no longer multiply registers error tables - when called more than once, preventing a memory leak. - -* [1666] The GSS_C_NT_* symbols are now exported from gssapi32.dll on - Windows. - -* [1667] ms2mit now imports any tickets with supported enctypes, and - does not import invalid tickets. - -* [1677] krb5_gss_register_acceptor_identity() no longer has an - off-by-one in its memory allocation. - -* [1679] krb5_principal2salt is now exported on all platforms. - -* [1684] The file credentials cache is now supported if USE_CCAPI is - defined, i.e., for KfM and KfW. +* [2971] thread_termination now correctly frees thread-specific data. -* [1691] Documentation for the obsolete kdc_supported_enctypes config - variable has been removed. +* [2974] krb5_get_init_creds_keytab() no longer produces spurious + KRB5_REALM_UNKNOWN errors when a master KDC is not listed in the + configuration. -Notes, Major Changes, and Known Bugs for 1.3 --------------------------------------------- +* [2975] Fix missing semicolon in x-deltat.y which was causing some + versions of Bison to produce un-compilable C files. -* We now install the compile_et program, so other packages can use the - installed com_err library with their own error tables. (If you use - our com_err code, that is; see below.) +* [2981] Restores some shared library support for HP-UX 10. -* The header files we install now assume ANSI/ISO C ('89, not '99). - We have stopped testing on SunOS 4, even with gcc. Some of our code - now has C89-based assumptions, like free(NULL) being well defined, - that will probably frustrate any attempts to run this code under SunOS - 4 or other pre-C89 systems. +* [2992] Fix some Makefile quoting problems which were preventing + gssapi_krb5.h from being created on AIX 5. -* Some new code, bug fixes, and cleanup for IPv6 support. Most of the - code should support IPv6 transparently now. The RPC code (and - therefore the admin system, which is based on it) does not yet - support IPv6. The support for Kerberos 4 may work with IPv6 in very - limited ways, if the address checking is turned off. The FTP client - and server do not have support for the new protocol messages needed - for IPv6 support (RFC 2428). +* [3000] Cast null pointer arguments to variadic functions, which is + necessary on some 64-bit platforms. -* We have upgraded to autoconf 2.52 (or later), and the syntax for - specifying certain configuration options have changed. For example, - autoconf 2.52 configure scripts let you specify command-line options - like "configure CC=/some/path/foo-cc", so we have removed some of - our old options like --with-cc in favor of this approach. +Major changes in 1.4 +-------------------- -* The client libraries can now use TCP to connect to the KDC. This - may be necessary when talking to Microsoft KDCs (domain controllers), - if they issue you tickets with lots of PAC data. +* [841] Merged Athena telnetd changes for creating a new option for + requiring encryption. -* If you have versions of the com_err or ss installed locally, you can - use the --with-system-et and --with-system-ss configure options to - use them rather than using the versions supplied here. Note that - the interfaces are assumed to be similar to those we supply; in - particular, some older, divergent versions of the com_err library - may not work with the krb5 sources. Many configure-time variables - can be used to help the compiler and linker find the installed - packages; see the build documentation for details. +* [1349, 2578, 2601, 2606, 2613, 2743, 2775, 2778, 2877] Add + implementation of the RPCSEC_GSS authentication flavor to the RPC + library. Thanks to Kevin Coffman and the CITI group at the + University of Michigan. -* The AES cryptosystem has been implemented. However, support in the - Kerberos GSSAPI mechanism has not been written (or even fully - specified), so it's not fully enabled. See the documentation for - details. +* [2061] The kadmind4 backwards-compatibility admin server and the + v5passwdd backwards-compatibility password-changing server have been + removed. -Major changes listed by ticket ID ---------------------------------- - -* [492] PRNG breakage on 64-bit platforms no longer an issue due to - new PRNG implementation. - -* [523] Client library is now compatible with the RC4-based - cryptosystem used by Windows 2000. - -* [709] krb4 long lifetime support has been implemented. - -* [880] krb5_gss_register_acceptor_identity() implemented (is called - gsskrb5_register_acceptor_identity() by Heimdal). - -* [1087] ftpd no longer requires channel bindings, allowing easier use - of ftp from behind a NAT. - -* [1156, 1209] It is now possible to use the system com_err to build - this release. - -* [1174] TCP support added to client library. - -* [1175] TCP support added to the KDC, but is disabled by default. - -* [1176] autoconf-2.5x is now required by the build system. - -* [1184] It is now possible to use the system Berkeley/Sleepycat DB - library to build this release. - -* [1189, 1251] The KfM krb4 library source base has been merged. - -* [1190] The default KDC master key type is now triple-DES. KDCs - being updated may need their config files updated if they are not - already specifying the master key type. - -* [1190] The default ticket lifetime and default maximum renewable - ticket lifetime have been extended to one day and one week, - respectively. - -* [1191] A new script, k5srvutil, may be used to manipulate keytabs in - ways similar to the krb4 ksrvutil utility. - -* [1281] The "fakeka" program, which emulates the AFS kaserver, has - been integrated. Thanks to Ken Hornstein. - -* [1343] The KDC now defaults to not answering krb4 requests. - -* [1344] Addressless tickets are requested by default now. - -* [1372] There is no longer a need to create a special keytab for - kadmind. The legacy administration daemons "kadmind4" and - "v5passwdd" will still require a keytab, though. - -* [1377, 1442, 1443] The Microsoft set-password protocol has been - implemented. Thanks to Paul Nelson. - -* [1385, 1395, 1410] The krb4 protocol vulnerabilities - [MITKRB5-SA-2003-004] have been worked around. Note that this will - disable krb4 cross-realm functionality, as well as krb4 triple-DES - functionality. Please see doc/krb4-xrealm.txt for details of the - patch. - -* [1393] The xdrmem integer overflows [MITKRB5-SA-2003-003] have - been fixed. - -* [1397] The krb5_principal buffer bounds problems - [MITKRB5-SA-2003-005] have been fixed. Thanks to Nalin Dahyabhai. - -* [1415] Subsession key negotiation has been fixed to allow for - server-selected subsession keys in the future. - -* [1418, 1429, 1446, 1484, 1486, 1487, 1535, 1621] The AES - cryptosystem has been implemented. It is not usable for GSSAPI, - though. - -* [1491] The client-side functionality of the krb524 library has been - moved into the krb5 library. - -* [1550] SRV record support exists for Kerberos v4. - -* [1551] The heuristic for locating the Kerberos v4 KDC by prepending - "kerberos." to the realm name if no config file or DNS information - is available has been removed. - -* [1568, 1067] A krb524 stub library is built on Windows. - -Minor changes listed by ticket ID ---------------------------------- - -* [90] default_principal_flags documented. - -* [175] Docs refer to appropriate example domains/IPs now. - -* [299] kadmin no longer complains about missing kdc.conf parameters - when it really means krb5.conf parameters. - -* [318] Run-time load path for tcl is set now when linking test - programs. - -* [443] --includedir honored now. - -* [479] unused argument in try_krb4() in login.c deleted. - -* [590] The des_read_pw_string() function in libdes425 has been - aligned with the original krb4 and CNS APIs. - -* [608] login.krb5 handles SIGHUP more sanely now and thus avoids - getting the session into a weird state w.r.t. job control. - -* [620] krb4 encrypted rcp should work a little better now. Thanks to - Greg Hudson. - -* [647] libtelnet/kerberos5.c no longer uses internal include files. - -* [673] Weird echoing of admin password in kadmin client worked around - by not using buffered stdio calls to read passwords. - -* [677] The build system has been reworked to allow the user to set - CFLAGS, LDFLAGS, CPPFLAGS, etc. reasonably. - -* [680] Related to [673], rewrite krb5_prompter_posix() to no longer - use longjmp(), thus avoiding some bugs relating to non-restoration - of terminal settings. - -* [697] login.krb5 no longer zeroes out the terminal window size. - -* [710] decomp_ticket() in libkrb4 now looks up the local realm name - more correctly. Thanks to Booker Bense. - -* [771] .rconf files are excluded from the release now. - -* [772] LOG_AUTHPRIV syslog facility is now usable for logging on - systems that support it. - -* [844] krshd now syslogs using the LOG_AUTH facility. - -* [850] Berekely DB build is better integrated into the krb5 library - build process. - -* [866] lib/krb5/os/localaddr.c and kdc/network.c use a common source - for local address enumeration now. - -* [882] gss-client now correctly deletes the context on error. +* [1303, 2740, 2755, 2781, 2782, 2812, 2858, 2859, 2874, 2875, 2878, + 2879, 2884, 2893] Thread safety for krb5 libraries. -* [919] kdc/network.c problems relating to SIOCGIFCONF have been - fixed. +* [2410] Yarrow code now uses AES. -* [922] An overflow in the string-to-time conversion routines has been - fixed. +* [2678, 2802] New client commands kcpytkt and kdeltkt for Windows. -* [933] krb524d now handles single-DES session keys other than of type - des-cbc-crc. +* [2688] New command mit2ms on Windows. -* [935] des-cbc-md4 now included in default enctypes. +* [2762] Merged Athena changes to allow ftpd to require encrypted + passwords. -* [939] A minor grammatical error has been fixed in a telnet client - error message. +* [2587] Incorporate gss_krb5_set_allowable_enctypes() and + gss_krb5_export_lucid_sec_context(), which are needed for NFSv4, + from Kevin Coffman. -* [953] des3 no longer failing on Windows due to SHA1 implementation - problems. +* [2841] Fix heap buffer overflow in password history + mechanism. [MITKRB5-SA-2004-004] -* [964] kdb_init_hist() no longer fails if master_key_enctype is not - in supported_enctypes. +Minor changes in 1.4 +-------------------- -* [970] A minor inconsistency in ccache.tex has been fixed. +Please see -* [971] option parsing bugs rendered irrelevant by removal of unused - gss mechanism. +http://krbdev.mit.edu/rt/NoAuth/krb5-1.4/fixed-1.4.html -* [976] make install mentioned in build documentation. +for a complete list. -* [986] Related to [677], problems with the ordering of LDFLAGS - initialization rendered irrelevant by use of native autoconf - idioms. +* [249] Install example config files. -* [992] Related to [677], quirks with --with-cc no longer relevant as - AC_PROG_CC is used instead now. +* [427] PATH environment variable won't be overwritten by login.krb5 + if already set. -* [999] The kdc_default_options configuration variable is now honored. - Thanks to Emily Ratliff. +* [696] Sample KDC propagation script fixed. -* [1006] Client library, as well as KDC, now perform reasonable - sorting of ETYPE-INFO preauthentication data. +* [868] Fixed search for res_search() and friends. -* [1055] NULL pointer dereferences in code calling - krb5_change_password() have been fixed. +* [927] Compilation on Tru64 now detects GNU linker and chooses + whether to use -oldstyle_liblookup accordingly. -* [1063] Initial credentials acquisition failures related to client - host having a large number of local network interfaces should be - fixed now. +* [1044] port-sockets.h explicitly declares h_errno if the declaration + is missing. -* [1064] Incorrect option parsing in the gssapi library is no longer - relevant due to removal of the "v2" mechanism. +* [1210] KDC cleans up some per-listener state upon process + termination to avoid spurious memory leak indications. -* [1065, 1225] krb5_get_init_creds_password() should properly warn about - password expiration. +* [1335] The server side of the Horowitz password-change protocol now + checks for minimum password life. -* [1066] printf() argument mismatches in rpc unit tests fixed. +* [1345, 2730, 2757] patchlevel.h is now the master version file. -* [1085] The krb5.conf manpage has been re-synchronized with other - documentation. +* [1364] GNU sed is no longer required to make depend on Irix. -* [1102] gssapi_generic.h should now work with C++. +* [1383] SRV record support now handles "." target and adds trailing + dots to avoid spurious multiple hostname queries. -* [1135] The kadm5 ACL system is better documented. +* [1497] A memory leak in the krb5 context serializer has been fixed. -* [1136] Some documentation for the setup of cross-realm - authentication has been added. +* [1570] Some team procedures now documented. -* [1164] krb5_auth_con_gen_addrs() now properly returns errno instead - of -1 if getpeername() fails. +* [1588] Automatic rebuilding of configure scripts, etc. are only done + if --enable-maintainer-mode is passed to configure. -* [1173] Address-less forwardable tickets will remain address-less - when forwarded. +* [1623] Memory management in the ftp client has been cleaned up. -* [1178, 1228, 1244, 1246, 1249] Test suite has been stabilized - somewhat. +* [1724] DNS SRV record lookup support is unconditionally built on + Unix. -* [1188] As part of the modernization of our usage of autoconf, - AC_CONFIG_FILES is now used instead of passing a list of files to - AC_OUTPUT. +* [1791] Replacement for daemon() is compiled separately each time it + is needed, rather than ending up in the krb5 library. -* [1194] configure will no longer recurse out of the top of the source - tree when attempting to locate the top of the source tree. +* [1806] Default to building shared libraries on most platforms that + support them. -* [1192] Documentation for the krb5 afs functionality of krb524d has - been written. +* [1847] Fixed daemon() replacement to build on Tru64. -* [1195] Example krb5.conf file modified to include all enctypes - supported by the release. +* [1850] Fixed some 0 vs NULL issues. -* [1202] The KDC no longer rejects unrecognized flags. +* [2066] AES-only configuration now tested in test suite. -* [1203] krb5_get_init_creds_keytab() no longer does a double-free. +* [2219] Fixed memory leak in KDC preauth handling. -* [1211] The ASN.1 code no longer passes (harmless) uninitialized - values around. +* [2256] Use $(CC) rather than ld to build shared libs on Tru64 and + Irix. -* [1212] libkadm5 now allows for persistent exclusive database locks. +* [2276] Support for the non-standard enctype + ENCTYPE_LOCAL_DES3_HMAC_SHA1 has been removed. -* [1217] krb5_read_password() and des_read_password() are now - implemented via krb5_prompter_posix(). +* [2285] Test suite checks TCP access to KDC. -* [1224] For SAM challenges, omitted optional strings are no longer - encoded as zero-length strings. +* [2295] Minor stylistic cleanup in gss-client. -* [1226] Client-side support for SAM hardware-based preauth - implemented. +* [2296, 2370, 2424] krb5_get_init_creds() APIs avoid multiple queries + to master KDC. -* [1229] The keytab search logic no longer fails prematurely if an - incorrect encryption type is found. Thanks to Wyllys Ingersoll. +* [2379] Remove _XOPEN_EXTENDED hack previously used for HP-UX. -* [1232] If the master KDC cannot be resolved, but a slave is - reachable, the client library now returns the real error from the - slave rather than the resolution failure from the master. Thanks to - Ben Cox. +* [2432] Only sanity-check setutent() API if utmpx.h is not present, + as this was preventing recent NetBSD from configuring. -* [1234] Assigned numbers for SAM preauth have been corrected. - sam-pk-for-sad implementation has been aligned. +* [2525] kvno.exe installed on Windows. -* [1237] Profile-sharing optimizations from KfM have been merged. +* [2529] Fix some internal type inconsistencies in gssapi library. -* [1240] Windows calling conventions for krb5int_c_combine_keys() have - been aligned. +* [2530] Fix KRB5_CALLCONV usage in krb5_cc_resolve(). -* [1242] Build system incompatibilities with Debian's chimeric - autoconf installation have been worked around. +* [2537] Apply fix from John Hascall to make krb5_get_in_tkt() + emulation actually honor the lifetimes in the input credentials. -* [1256] Incorrect sizes passed to memset() in combine_keys() - operations have been corrected. +* [2539] Create manpage for krb524d. -* [1260] Client credential lookup now gets new service tickets in - preference to attempting to use expired ticketes. Thanks to Ben - Cox. +* [2573] The rcache code no longer attempts to close a negative file + descriptor from a failed open. -* [1262, 1572] Sequence numbers are now unsigned; negative sequence - numbers will be accepted for the purposes of backwards - compatibility. +* [2591] The gssapi library now requires that the initiator's channel + bindings match those provided by the acceptor, if the acceptor + provides them at all. -* [1263] A heuristic for matching the incorrectly encoded sequence - numbers emitted by Heimdal implementations has been written. +* [2592] Fix some HP-UX 11 compilation issues. -* [1284] kshd accepts connections by IPv6 now. +* [2598] Fix some HP-UX 11 foreachaddr() issues. -* [1292] kvno manpage title fixed. +* [2600] gss_accept_sec_context() no longer leaks rcaches. -* [1293] Source files no longer explicitly attempt to declare errno. +* [2603] Clean up some issues relating to use of reserved namespace in + k5-platform.h. -* [1304] kadmind4 no longer leaves sa_flags uninitialized. +* [2614] Rewrite handling of whitespace in profile library to better + handle whitespace around tag names. -* [1305] Expired tickets now cause KfM to pop up a password dialog. +* [2629] Fix double-negation of a preprocessor test in osconf.h. -* [1309] krb5_send_tgs() no longer leaks the storage associated with - the TGS-REQ. +* [2637] krb5int_zap_data() uses SecureZeroMemory on Windows instead + of memset(). -* [1310] kadm5_get_either() no longer leaks regexp library memory. +* [2654] krb5_get_init_creds() checks for overflow/underflow on 32-bit + timestamps. -* [1311] Output from krb5-config no longer contains spurious uses of - $(PURE). +* [2655] krb5_get_init_creds() no longer issues requests where the + renew_until time precedes the expiration time. -* [1324] The KDC no longer logs an inappropriate "no matching key" - error when an encrypted timestamp preauth password is incorrect. +* [2656] krb5_get_init_creds() supports ticket_lifetime libdefault. -* [1334] The KDC now returns a clockskew error when the timestamp in - the encrypted timestamp preauth is out of bounds, rather than just - returning a preauthentcation failure. +* [2657] Default ccache name is evaluated more lazily. -* [1342] gawk is no longer required for building kerbsrc.zip for the - Windows build. +* [2661] Handle return of ai_canonname=NULL from getaddrinfo(). -* [1346] gss_krb5_ccache_name() no longer attempts to return a pointer - to freed memory. +* [2665] Fix leak in cc_resolve, reported by Paul Moore. -* [1351] The filename globbing vulnerability [CERT VU#258721] in the - ftp client's handling of filenames beginning with "|" or "-" - returned from the "mget" command has been fixed. +* [2674] libkadm5 acl_init() API renamed to avoid conflict with MacOS + X acl API. -* [1352] GSS_C_PROT_READY_FLAG is no longer asserted inappropriately - during GSSAPI context establishment. +* [2684, 2710, 2728] Use BIND 8 parsing API when available. -* [1356] krb5_gss_accept_sec_context() no longer attempts to validate - a null credential if one is passed in. +* [2685] The profile library iterators no longer get confused when + modifications are made to the in-memory profile. -* [1362] The "-a user" option to telnetd now does the right thing. - Thanks to Nathan Neulinger. +* [2694] The krb5-config script now has a manpage. -* [1363] ksu no longer inappropriately syslogs to stderr. +* [2704] New ccache API flag to request only information, not actual + credentials. -* [1357] krb__get_srvtab_name() no longer leaks memory. +* [2705] Support for upcoming read/write MSLSA ccache. -* [1370] GSS_C_NO_CREDENTIAL now accepts any principal in the keytab. +* [2706] resolv.h is included when searching for res_search() and + friends, to account for symbol renaming. -* [1373] Handling of SAM preauth no longer attempts to stuff a size_t - into an unsigned int. +* [2715] The install-strip make target no longer attempts to strip + scripts. -* [1387] BIND versions later than 8 now supported. +* [2718] Fix memory leak in arcfour string_to_key. Reported by + Derrick Schommer. -* [1392] The getaddrinfo() wrapper should work better on AIX. +* [2719] Fix memory leak in rd_cred.c. Reported by Derrick Schommer. -* [1400] If DO_TIME is not set in the auth_context, and no replay - cache is available, no replay cache will be used. +* [2725] Fix memory leak in mk_req_extended(). Reported by Derrick + Schommer. -* [1406, 1108] libdb is no longer installed. If you installed - krb5-1.3-alpha1, you should ensure that no spurious libdb is left in - your install tree. +* [2729] Add some new version strings for Windows. -* [1412] ETYPE_INFO handling no longer goes into an infinite loop. +* [2734] The ticket_lifetime libdefault now uses units of seconds by + default, if no units are provided. -* [1414] libtelnet is now built using the same library build framework - as the rest of the tree. +* [2741] The profile library's error tables aren't loaded on MacOS X. -* [1417] A minor memory leak in krb5_read_password() has been fixed. +* [2750] Calls to the profile library which set values no longer fail + if the file is not writable. -* [1419] A memory leak in asn1_decode_kdc_req_body() has been fixed. +* [2751] The profile library has a new API to detect whether the + default profile is writable. -* [1435] inet_ntop() is now emulated when needed. +* [2753] An initial C implementation of CCAPI has been done. -* [1439] krb5_free_pwd_sequences() now correctly frees the entire - sequence of elements. +* [2754] fake-addrinfo.h includes errno.h earlier. -* [1440] errno is no longer explicitly declared. +* [2756] The profile library calls stat() less frequently on files. -* [1441] kadmind should now return useful errors if an unrecognized - version is received in a changepw request. +* [2760, 2780] The keytab implementation checks for cases where + fopen() can return NULL without setting errno. Reported by Roland + Dowdeswell. -* [1454, 1480, 1517, 1525] The etype-info2 preauth type is now - supported. +* [2770] com_err now creates valid prototypes for generated files. + Reported by Jeremy Allison. -* [1459] (KfM/KLL internal) config file resolution can now be - prevented from accessing the user's homedir. +* [2772, 2797] The krb4 library now honors the dns_fallback libdefault + setting. -* [1463] Preauth handling in the KDC has been reorganized. +* [2776, 2779] Solaris patches exist for the pty-close race condition + bug. We check for these patches now checked, and don't apply the + priocntl hack if they are present. -* [1470] Double-free in client-side preauth code fixed. +* [2783] ftpcmds.y unconditionally defines NBBY to 8. -* [1473] Ticket forwarding when the TGS and the end service have - different enctypes should work somewhat better now. +* [2793] locate_kdc.c can compile if KRB5_DNS_LOOKUP isn't defined, + though we removed the configure-time option for this. -* [1474] ASN.1 testsuite memory management has been cleaned up a - little to allow for memory leak checking. +* [2795] Fixed some addrinfo problems that affected Irix. -* [1476] Documentation updated to reflect default krb4 mode. +* [2796, 2840] Calling conventions for some API functions for Windows + have been fixed. -* [1482] RFC-1964 OIDs now provided using the suggested symbolic - names. +* [2805] Windows NSIS installer script updated. -* [1483, 1528] KRB5_DEPRECATED is now false by default on all - platforms. +* [2808] Support library renamed on Windows. -* [1488] The KDC will now return integrity errors if a decryption - error is responsible for preauthentication failure. +* [2815] krb5-config updated to reference new support library. -* [1492] The autom4te.cache directories are now deleted from the - release tarfiles. +* [2814, 2816] Some MSLSA ccache features depending on non-public SDK + features were backed out. -* [1501] Writable keytabs are registered by default. +* [2818] Don't create empty array for addresses in MSLSA ccache. -* [1515] The check for cross-realm TGTs no longer reads past the end - of an array. +* [2832] Fix shared library build on sparc64-netbsd. -* [1518] The kdc_default_options option is now actually honored. +* [2833, 2834, 2835] Add support for generating/installing debugging + symbols on Windows. -* [1519] The changepw protocol implementation in kadmind now logs - password changes. +* [2838] Fix termination of incorrect string in telnetd. -* [1520] Documentation of OS-specific build options has been updated. +* [2854] Fix memory leak in ccache. -* [1536] A missing prototype for krb5_db_iterate_ext() has been - added. +* [2857] Fix memory leak in asn1_decode_generaltime(). -* [1537] An incorrect path to kdc.conf show in the kdc.conf manpage - has been fixed. +* [2861] Minor documenation fixes. -* [1540] verify_as_reply() will only check the "renew-till" time - against the "till" time if the RENEWABLE is not set in the request. +* [2864] Fix IPv6 support on Windows. -* [1547] gssftpd no longer uses vfork(), as this was causing problems - under RedHat 9. +* [2865] New API function krb5_is_thread_safe() to test for thread + safety. -* [1549] SRV records with a value of "." are now interpreted as a lack - of support for the protocol. +* [2870, 2881] Fix crash in MSLSA ccache. -* [1553] The undocumented (and confusing!) kdc_supported_enctypes - kdc.conf variable is no longer used. +* [2871] Handle read() returning -1 in prng.c. -* [1560] Some spurious double-colons in password prompts have been - fixed. +* [2872] Fix memory leak in DNS lookup code. -* [1571] The test suite tries a little harder to get a root shell. +* [2887] Fix null pointer dereference in krb5_unparse_name(). -* [1573] The KfM build process now sets localstatedir=/var/db. +* [2892] Fix some gcc-4.0 compatibility problems. -* [1576, 1575] The client library no longer requests RENEWABLE_OK if - the renew lifetime is greater than the ticket lifetime. - -* [1587] A more standard autoconf test to locate the C compiler allows - for gcc to be found by default without additional configuration - arguments. - -* [1593] Replay cache filenames are now escaped with hyphens, not - backslashes. - -* [1598] MacOS 9 support removed from in-tree com_err. - -* [1602] Fixed a memory leak in make_ap_req_v1(). Thanks to Kent Wu. - -* [1604] Fixed a memory leak in krb5_gss_init_sec_context(), and an - uninitialized memory reference in kg_unseal_v1(). Thanks to Kent - Wu. - -* [1607] kerberos-iv SRV records are now documented. - -* [1610] Fixed AES credential delegation under GSSAPI. - -* [1618] ms2mit no longer inserts local addresses into tickets - converted from the MS ccache if they began as addressless tickets. - -* [1619] etype_info parser (once again) accepts extra field emitted by - Heimdal. - -* [1643] Some typos in kdc.conf.M have been fixed. - -* [1648] For consistency, leading spaces before preprocessor - directives in profile.h have been removed. - ---[ DELETE BEFORE RELEASE ---changes to unreleased code, etc.--- ]-- - -* [1054] KRB-CRED messages for RC4 are encrypted now. - -* [1177] krb5-1-2-2-branch merged onto trunk. - -* [1193] Punted comment about reworking key storage architecture. - -* [1208] install-headers target implemented. - -* [1223] asn1_decode_oid, asn1_encode_oid implemented - -* [1248] RC4 is explicitly excluded from combine_keys. - -* [1276] Generated dependencies handle --without-krb4 properly now. - -* [1339] An inadvertent change to the krb4 get_adm_hst API (strcpy vs - strncpy etc.) has been fixed. - -* [1384, 1413] Use of autoconf-2.52 in util/reconf will now cause a - warning. - -* [1388] DNS support is turned on in KfM. - -* [1391] Fix kadmind startup failure with krb4 vuln patch. - -* [1409] get_ad_tkt() now prompts for password if there are no tickets - (in KfM). - -* [1447] vts_long() and vts_short() work now. - -* [1462] KfM adds exports of set_pw calls. - -* [1477] compile_et output not used in err_txt.c. - -* [1495] KfM now exports string_to_key_with_params. - -* [1512, 1522] afs_string_to_key now works with etype_info2. - -* [1514] krb5int_populate_gic_opt returns void now. - -* [1521] Using an afs3 salt for an AES key no longer causes - segfaults. - -* [1533] krb524.h no longer contains invalid Mac pragmas. - -* [1546] krb_mk_req_creds() no longer zeros the session key. - -* [1554] The krb4 string-to-key iteration now accounts correctly for - the decrypt-in-place semantics of libdes425. - -* [1557] KerberosLoginPrivate.h is now correctly included for the use - of __KLAllowHomeDirectoryAccess() in init_os_ctx.c (for KfM). - -* [1558] KfM exports the new krb524 interface. - -* [1563] krb__get_srvtaname() no longer returns a pointer that is - free()d upon a subsequent call. - -* [1569] A debug statement has been removed from krb524init. - -* [1592] Document possible file rename lossage when building against - system libdb. - -* [1594] Darwin gets an explicit dependency of err_txt.o on - krb_err.c. - -* [1596] Calling conventions, etc. tweaked for KfW build of - krb524.dll. - -* [1600] Minor tweaks to README to improve notes on IPv6, etc. - -* [1605] Fixed a leak of subkeys in krb5_rd_rep(). - -* [1630] krb5_get_in_tkt_with_keytab() works now; previously borken by - reimplementation in terms of krb5_get_init_creds(). - -* [1642] KfM build now inherits CFLAGS and LDFLAGS from parent project. +* [2891] lib/kdb/keytab.c no longer accesses an uninitialized variable. Copyright Notice and Legal Administrivia ---------------------------------------- -Copyright (C) 1985-2004 by the Massachusetts Institute of Technology. +Copyright (C) 1985-2005 by the Massachusetts Institute of Technology. All rights reserved. @@ -1130,49 +620,64 @@ src/lib/crypto/aes has the following copyright: in respect of any properties, including, but not limited to, correctness and fitness for purpose. - - -Acknowledgements ----------------- +---- The implementation of the RPCSEC_GSS authentication flavor in +src/lib/rpc has the following copyright: + + Copyright (c) 2000 The Regents of the University of Michigan. + All rights reserved. + + Copyright (c) 2000 Dug Song <dugsong@UMICH.EDU>. + All rights reserved, all wrongs reversed. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of the 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 ``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. + +Acknowledgments +--------------- 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.... -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 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 to Jeff Bigler, for the new user and system -administrator's documentation. +Thanks to Kevin Coffman and the CITI group at the University of +Michigan for providing patches for implementing RPCSEC_GSS +authentication in the RPC library. -Thanks to Doug Engert from ANL for providing many bug fixes, as well -as testing to ensure DCE interoperability. +Thanks to Derrick Schommer for reporting multiple memory leaks. -Thanks to Ken Hornstein at NRL for providing many bug fixes and -suggestions, and for working on SAM preauthentication. +Thanks to Quanah Gibson-Mount of Stanford University for helping +exercise the thread support code. -Thanks to Matt Crawford at FNAL for bugfixes and enhancements. +Thanks to Michael Tautschnig for reporting the heap buffer overflow in +the password history mechanism. [MITKRB5-SA-2004-004] -Thanks to Sean Mullan and Bill Sommerfeld from Hewlett Packard for -their many suggestions and bug fixes. +Thanks to Wyllys Ingersoll for finding a buffer-size problem in the +RPCSEC_GSS implementation. -Thanks to Nalin Dahyabhai of RedHat and Chris Evans for locating and -providing patches for numerous buffer overruns. - -Thanks to Christopher Thompson and Marcus Watts for discovering the -ftpd security bug. - -Thanks to Paul Nelson of Thursby Software Systems for implementing the -Microsoft set password protocol. +Thanks to iDEFENSE for bringing to our attention the vulnerabilities +in the telnet client. [MITKRB5-SA-2005-001] Thanks to the members of the Kerberos V5 development team at MIT, both past and present: Danilo Almeida, Jeffrey Altman, Jay Berkenbilt, @@ -1183,3 +688,10 @@ Peter Litwack, Scott McGuire, Kevin Mitchell, Cliff Neuman, Paul Park, Ezra Peisach, Chris Provenzano, Ken Raeburn, Jon Rochlis, Jeff Schiller, Jen Selby, Brad Thompson, Harry Tsai, Ted Ts'o, Marshall Vale, Tom Yu. + +Very special thanks go to Marshall Vale, our departing team leader. +Over the past few years, Marshall has been extremely valuable to us as +mentor, advisor, manager, and friend. Marshall's devotion as a +champion of Kerberos has helped our team immensely through many trials +and hardships. We will miss him tremendously, and we wish him the +best in his future endeavors. diff --git a/doc/ChangeLog b/doc/ChangeLog index 985d2e0..ed586d5 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,25 @@ +2005-02-11 Tom Yu <tlyu@mit.edu> + + * kadm5/api-unit-test.tex (ovsec_kadm_init): Update to reflect + changed expected error codes for init 152, 153 tests. + +2005-01-03 Ken Raeburn <raeburn@mit.edu> + + * build.texinfo (The util Directory): Add the new support + library. + (Installing the Binaries): Discuss parallel builds under GNU + make. + + * implementor.texinfo (Host Address Lookup): Document Mac OS X + issues. + + * threads.txt, thread-safety.txt: Updates. + +2004-11-19 Tom Yu <tlyu@mit.edu> + + * build.texinfo (Solaris 9): Document Solaris patches for pty + close bug. + 2004-10-06 Ken Raeburn <raeburn@mit.edu> * implementor.texinfo, thread-safe.txt, threads.txt: Various diff --git a/doc/build.texinfo b/doc/build.texinfo index 4babbe7..fc60d7a 100644 --- a/doc/build.texinfo +++ b/doc/build.texinfo @@ -212,7 +212,8 @@ functions which parse the Kerberos configuration files (@code{krb5.conf} and @code{kdc.conf}). Also in this directory are the Kerberos error table library and utilities (@i{et}), the Sub-system library and utilities (@i{ss}), database utilities (@i{db2}), pseudo-terminal utilities -(@i{pty}), and bug-reporting program @code{send-pr}. +(@i{pty}), bug-reporting program @code{send-pr}, and a generic +support library @code{support} used by several of our other libraries. @node Build Requirements, Unpacking the Sources, Organization of the Source Directory, Building Kerberos V5 @section Build Requirements @@ -233,6 +234,8 @@ will need a @samp{make} program which supports @samp{VPATH}, or you will need to use a tool such as @samp{lndir} to produce a symbolic link tree for your build tree. +@c Library support... + @node Unpacking the Sources, Doing the Build, Build Requirements, Building Kerberos V5 @section Unpacking the Sources @@ -367,6 +370,11 @@ libraries into @code{DESTDIR/PREFIX/lib}, etc. Note that if you want to test the build (see @ref{Testing the Build}), you usually do not need to do a @code{make install} first. +Some implementations of @samp{make} allow multiple commands to be run in +parallel, for faster builds. We test our Makefiles in parallel builds with +GNU @samp{make} only; they may not be compatible with other parallel build +implementations. + @node Testing the Build, Options to Configure, Installing the Binaries, Building Kerberos V5 @section Testing the Build @@ -895,6 +903,12 @@ Run something like as root, where @code{nnnn} is the pid of the shell whose priority limit you wish to raise. +Sun has released kernel patches for this race condition. Apply patch +117171-11 for sparc, or patch 117172-11 for x86. Later revisions of +the patches should also work. It is not necessary to run ``make +check'' from a shell with elevated priority limits once the patch has +been applied. + @node SGI Irix 5.X, Ultrix 4.2/3, Solaris 9, OS Incompatibilities @subsection SGI Irix 5.X diff --git a/doc/implementor.texinfo b/doc/implementor.texinfo index d9e00a6..6609676 100644 --- a/doc/implementor.texinfo +++ b/doc/implementor.texinfo @@ -395,6 +395,25 @@ is, both of which are wrong. No known bugs here, but as of IRIX 6.5.7, the version we're using at MIT, these functions had not been implemented. +@item Mac OS X +Two problems have been found with @code{getaddrinfo} on Mac OS X, at +least under version 10.3. First, while @code{gethostbyname} data is +cached to make multiple lookups of the same name (@i{e.g.}, by +different parts of the code that need to know about the same server +host), @code{getaddrinfo} results are not cached, so multiple queries +mean multiple DNS requests, which means more delays if the DNS servers +are not close by and fast to respond. We've implemented a cache of +our own to work around this, though it only applies to multiple +lookups in a short period of time within the same application process, +and it's only implemented for the Mac at the moment. + +Second, the Mac libraries will generate a DNS SRV RR query; as far as +I [Ken] can tell this is a bug, but Apple seems to consider it a +feature. (Call @code{getaddrinfo("example.com", "telnet", ...)} and +you get a SRV record query, but the spec on SRV records says you must +not use them unless the specification for the service in question says +to.) Yet more network traffic for each name to look up. + @item NetBSD As of NetBSD 1.5, this function is not thread-safe. In 1.5X (intermediate code snapshot between 1.5 and 1.6 releases), the diff --git a/doc/kadm5/api-unit-test.tex b/doc/kadm5/api-unit-test.tex index 3e3f6e2..5b10327 100644 --- a/doc/kadm5/api-unit-test.tex +++ b/doc/kadm5/api-unit-test.tex @@ -588,7 +588,8 @@ credential for CHANGEPW_SERVICE.} \numtest{152}{ \Version{KADM5_API_VERSION_2} -\Reason{init_with_creds fails with KADM5_GSS_ERROR when given an open +\Reason{init_with_creds fails with KRB5_FCC_NOFILE (was + KADM5_GSS_ERROR) when given an open ccache with no credentials.} \Conditions{RPC} \Status{Implemented} @@ -596,7 +597,8 @@ ccache with no credentials.} \numtest{153}{ \Version{KADM5_API_VERSION_2} -\Reason{init_with_creds fails with KADM5_GSS_ERROR when given an open +\Reason{init_with_creds fails with KRB5_CC_NOTFOUND (was + KADM5_GSS_ERROR) when given an open ccache without credentials for ADMIN_SERVICE or CHANGEPW_SERVICE.} \Conditions{RPC} \Status{Implemented} diff --git a/doc/thread-safe.txt b/doc/thread-safe.txt index 9e30706..0996b32 100644 --- a/doc/thread-safe.txt +++ b/doc/thread-safe.txt @@ -140,10 +140,11 @@ Uses: ctype macros Uses: getaddrinfo, getnameinfo. According to current specifications, getaddrinfo should be thread-safe; some implementations are not, and -we're not attempting to figure out which ones. +we're not attempting to figure out which ones. NetBSD 1.6, for +example, had an unsafe implementation. Uses: res_ninit, res_nsearch. If these aren't available, the non-'n' -versions will be used, and they are not thread-safe. +versions will be used, and they are sometimes not thread-safe. Uses: mkstemp, mktemp -- Are these, or our uses of them, likely to be thread-safe? @@ -158,17 +159,24 @@ Uses: tcgetattr, tcsetattr. This is also in the password-prompting code. These are fine as long as no other threads are accessing the same terminal at the same time. +Uses: fopen. This is thread-safe, actually, but a multi-threaded +server is likely to be using lots of file descriptors. On 32-bit +Solaris platforms, fopen will not work if the next available file +descriptor number is 256 or higher. This can cause the keytab code to +fail. + Statics: prompter.c: interrupt flag Statics: ccdefops.c: default operations table pointer -Statics: ktdefname.c: variable to override default keytab name, NEEDS LOCKING +Statics: ktdefname.c: variable to override default keytab name, NO +LOCKING. DON'T TOUCH THESE VARIABLES, at least in threaded programs. Statics: conv_creds.c: debug variable Statics: sendto_kdc.c: debug variable, in export list for KDC -Statics: parse.c: default realm cache, NOT THREAD SAFE +Statics: parse.c: default realm cache, changed to not cache Statics: krb5_libinit.c: lib init aux data @@ -183,8 +191,6 @@ always increment" Statics: ktbase.c, ccbase.c, rc_base.c: type registries and mutexes. -Needs work: keytab locking - ---------------- libgssapi_krb5 diff --git a/doc/threads.txt b/doc/threads.txt index 1b655ea..b161daf 100644 --- a/doc/threads.txt +++ b/doc/threads.txt @@ -16,6 +16,16 @@ object while other threads may still be using it. (Any internal data modification in those objects will be protected by mutexes or other means, within the krb5 library.) +The simple, exposed data structures in krb5.h like krb5_principal are +not protected; they should not be used in one thread while another +thread might be modifying them. (TO DO: Build a list of which calls +keep references to supplied data or return references to +otherwise-referenced data, as opposed to everything making copies.) + + + +[ This part is a little outdated already. ] + // Between these two, we should be able to do pure compile-time // and pure run-time initialization. // POSIX: partial initializer is PTHREAD_MUTEX_INITIALIZER, @@ -57,6 +67,7 @@ means, within the krb5 library.) int k5_setspecific(k5_key_t, const void *); ... stuff to signal library termination ... +This is **NOT** an exported interface, and is subject to change. On many platforms with weak reference support, we can declare certain symbols to be weak, and test the addresses before calling them. The @@ -70,12 +81,21 @@ AIX 4.3.3 doesn't support weak references. However, it looks like calling dlsym(NULL) causes the pthread library to get loaded, so we're going to just go ahead and link against it anyways. +On Tru64 we also link against the thread library always. + For now, the basic model is: If weak references supported, use them. - Else, assume support is present. + Else, assume support is present; if that means explicitly pulling in + the thread library, so be it. + + +The locking described above may not be sufficient, at least for good +performance. At some point we may want to switch to read/write locks, +so multiple threads can grovel over a data structure at once as long +as they don't change it. See also notes in src/include/k5-thread.h. diff --git a/src/ChangeLog b/src/ChangeLog index fe47c6a..e053ae0 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,25 @@ +2005-01-12 Tom Yu <tlyu@mit.edu> + + * aclocal.m4 (AC_LIBRARY_NET): Also check for res_ndestroy. + +2004-12-16 Ezra Peisach <epeisach@bu.edu> + + * krb5-config.in: Add krb5support library. + +2004-12-15 Jeffrey Altman <jaltman@mit.edu> + + * Makefile.in: build/clean/install/etc kcpytkt,kdeltkt,ms2mit + +2004-11-19 Tom Yu <tlyu@mit.edu> + + * aclocal.m4 (KRB5_AC_PRIOCNTL_HACK): Check for Solaris patch + 117171-11 (sparc) or 117172-11 (x86), which fixes the Solaris 9 + bug which can cause final pty output to be on close. + +2004-11-18 Tom Yu <tlyu@mit.edu> + + * Makefile.in (install-headers-mkdirs): Create KRB5_INCDIR/gssrpc. + 2004-10-06 Tom Yu <tlyu@mit.edu> * Makefile.in (INSTALLMKDIRS): Add EXAMPLEDIR. diff --git a/src/Makefile.in b/src/Makefile.in index 225868e..3a94a76 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -74,6 +74,7 @@ install-mkdirs: install-headers-mkdirs: $(srcdir)/config/mkinstalldirs $(DESTDIR)$(KRB5_INCDIR) $(srcdir)/config/mkinstalldirs $(DESTDIR)$(KRB5_INCDIR)/gssapi + $(srcdir)/config/mkinstalldirs $(DESTDIR)$(KRB5_INCDIR)/gssrpc $(srcdir)/config/mkinstalldirs $(DESTDIR)$(KRB5_INCDIR)/kerberosIV install-headers-prerecurse: install-headers-mkdirs @@ -145,6 +146,7 @@ WINMAKEFILES=Makefile \ clients\Makefile clients\kdestroy\Makefile \ clients\kinit\Makefile clients\klist\Makefile \ clients\kpasswd\Makefile clients\kvno\Makefile \ + clients\kcpytkt\Makefile clients\kdeltkt\Makefile \ include\Makefile include\krb5\Makefile \ krb524\Makefile \ lib\Makefile lib\crypto\Makefile \ @@ -196,6 +198,10 @@ WINMAKEFILES=Makefile \ ##DOS## $(WCONFIG) config < $@.in > $@ ##DOS##clients\kvno\Makefile: clients\kvno\Makefile.in $(MKFDEP) ##DOS## $(WCONFIG) config < $@.in > $@ +##DOS##clients\kcpytkt\Makefile: clients\kcpytkt\Makefile.in $(MKFDEP) +##DOS## $(WCONFIG) config < $@.in > $@ +##DOS##clients\kdeltkt\Makefile: clients\kdeltkt\Makefile.in $(MKFDEP) +##DOS## $(WCONFIG) config < $@.in > $@ ##DOS##include\Makefile: include\Makefile.in $(MKFDEP) ##DOS## $(WCONFIG) config < $@.in > $@ ##DOS##include\krb5\Makefile: include\krb5\Makefile.in $(MKFDEP) @@ -329,7 +335,7 @@ ren2long: ZIP=zip FILES= ./* \ clients/* clients/kdestroy/* clients/kinit/* clients/klist/* \ - clients/kpasswd/* \ + clients/kpasswd/* clients/kcpytkt/* clients/kdeltkt/* \ config/* include/* include/kerberosIV/* \ include/krb5/* include/krb5/stock/* include/sys/* krb524/* lib/* \ lib/crypto/* lib/crypto/crc32/* lib/crypto/des/* lib/crypto/dk/* \ @@ -533,11 +539,14 @@ install-windows:: $(CP) windows\gss\$(OUTPRE)gss.exe "$(KRB_INSTALL_DIR)\bin\." $(CP) appl\gss-sample\$(OUTPRE)gss-server.exe "$(KRB_INSTALL_DIR)\bin\." $(CP) appl\gss-sample\$(OUTPRE)gss-client.exe "$(KRB_INSTALL_DIR)\bin\." + $(CP) windows\ms2mit\$(OUTPRE)ms2mit.exe "$(KRB_INSTALL_DIR)\bin\." $(CP) appl\gssftp\ftp\$(OUTPRE)ftp.exe "$(KRB_INSTALL_DIR)\bin\." $(CP) clients\kvno\$(OUTPRE)kvno.exe "$(KRB_INSTALL_DIR)\bin\." $(CP) clients\klist\$(OUTPRE)klist.exe "$(KRB_INSTALL_DIR)\bin\." $(CP) clients\kinit\$(OUTPRE)kinit.exe "$(KRB_INSTALL_DIR)\bin\." $(CP) clients\kdestroy\$(OUTPRE)kdestroy.exe "$(KRB_INSTALL_DIR)\bin\." + $(CP) clients\kcpytkt\$(OUTPRE)kcpytkt.exe "$(KRB_INSTALL_DIR)\bin\." + $(CP) clients\kdeltkt\$(OUTPRE)kdeltkt.exe "$(KRB_INSTALL_DIR)\bin\." $(CP) clients\kpasswd\$(OUTPRE)kpasswd.exe "$(KRB_INSTALL_DIR)\bin\." @if exist "$(KRB_INSTALL_DIR)\bin\krb4_32.dll" del "$(KRB_INSTALL_DIR)\bin\krb4_32.dll" @if exist "$(KRB_INSTALL_DIR)\lib\krb4_32.lib" del "$(KRB_INSTALL_DIR)\lib\krb4_32.lib" diff --git a/src/aclocal.m4 b/src/aclocal.m4 index a060ac9..d135d5c 100644 --- a/src/aclocal.m4 +++ b/src/aclocal.m4 @@ -1379,7 +1379,7 @@ AC_DEFUN(AC_LIBRARY_NET, [ # This may get us a gethostby* that doesn't respect nsswitch. AC_CHECK_LIB(resolv, main) _KRB5_AC_CHECK_RES_FUNCS(res_nsearch res_search ns_initparse dnl -ns_name_uncompress dn_skipname) +ns_name_uncompress dn_skipname res_ndestroy) if test $krb5_cv_func_res_nsearch = no \ && test $krb5_cv_func_res_search = no; then # Attempt to link with res_search(), in case it's not prototyped. @@ -1636,14 +1636,37 @@ dnl KRB5_AC_PRIOCNTL_HACK dnl dnl AC_DEFUN([KRB5_AC_PRIOCNTL_HACK], +[AC_REQUIRE([AC_PROG_AWK])dnl +AC_REQUIRE([AC_LANG_COMPILER_REQUIRE])dnl +AC_CACHE_CHECK([whether to use priocntl hack], [krb5_cv_priocntl_hack], [case $krb5_cv_host in *-*-solaris2.9*) - PRIOCNTL_HACK=1 + if test "$cross_compiling" = yes; then + krb5_cv_priocntl_hack=yes + else + # Solaris patch 117171-11 (sparc) or 117172-11 (x86) + # fixes the Solaris 9 bug where final pty output + # gets lost on close. + if showrev -p | $AWK 'BEGIN { e = 1 } +/Patch: 11717[[12]]/ { x = index[]([$]2, "-"); +if (substr[]([$]2, x + 1, length([$]2) - x) >= 11) +{ e = 0 } else { e = 1 } } +END { exit e; }'; then + krb5_cv_priocntl_hack=no + else + krb5_cv_priocntl_hack=yes + fi + fi ;; *) - PRIOCNTL_HACK=0 + krb5_cv_priocntl_hack=no ;; -esac +esac]) +if test "$krb5_cv_priocntl_hack" = yes; then + PRIOCNTL_HACK=1 +else + PRIOCNTL_HACK=0 +fi AC_SUBST(PRIOCNTL_HACK)]) dnl dnl diff --git a/src/appl/bsd/ChangeLog b/src/appl/bsd/ChangeLog index fcf9517..c5e5bc8 100644 --- a/src/appl/bsd/ChangeLog +++ b/src/appl/bsd/ChangeLog @@ -1,3 +1,10 @@ +2005-04-05 Ken Raeburn <raeburn@mit.edu> + + * krlogind.c (doit): Change 0 to (char*)NULL in execl* calls. + Patch provided by Michael Calmer. + * krshd.c (doit): Likewise. + * login.c (main): Likewise. + 2004-10-01 Ken Raeburn <raeburn@mit.edu> * kcmd.c (kcmd_connect): Set *addrfamilyp with the address family diff --git a/src/appl/bsd/krlogind.c b/src/appl/bsd/krlogind.c index d2979e1..02bed8e 100644 --- a/src/appl/bsd/krlogind.c +++ b/src/appl/bsd/krlogind.c @@ -833,12 +833,12 @@ void doit(f, fromp) fatalperror(f, "failed make_sane_hostname"); if (passwd_req) execl(login_program, "login", "-p", "-h", rhost_sane, - lusername, 0); + lusername, (char *)NULL); else execl(login_program, "login", "-p", "-h", rhost_sane, - "-f", lusername, 0); + "-f", lusername, (char *)NULL); #else /* USE_LOGIN_F */ - execl(login_program, "login", "-r", rhost_sane, 0); + execl(login_program, "login", "-r", rhost_sane, (char *)NULL); #endif /* USE_LOGIN_F */ syslog(LOG_ERR, "failed exec of %s: %s", login_program, error_message(errno)); diff --git a/src/appl/bsd/krshd.c b/src/appl/bsd/krshd.c index 9fde43d..808adf5 100644 --- a/src/appl/bsd/krshd.c +++ b/src/appl/bsd/krshd.c @@ -1521,10 +1521,10 @@ void doit(f, fromp) cp = pwd->pw_shell; if (do_encrypt && !strncmp(cmdbuf, "-x ", 3)) { - execl(pwd->pw_shell, cp, "-c", (char *)cmdbuf + 3, 0); + execl(pwd->pw_shell, cp, "-c", (char *)cmdbuf + 3, (char *)NULL); } else { - execl(pwd->pw_shell, cp, "-c", cmdbuf, 0); + execl(pwd->pw_shell, cp, "-c", cmdbuf, (char *)NULL); } perror(pwd->pw_shell); perror(cp); diff --git a/src/appl/bsd/login.c b/src/appl/bsd/login.c index 6282a42..b49baba 100644 --- a/src/appl/bsd/login.c +++ b/src/appl/bsd/login.c @@ -1861,7 +1861,7 @@ int main(argc, argv) (void) strncpy(tbuf+1, p?(p+1):pwd->pw_shell, sizeof(tbuf) - 1); tbuf[sizeof(tbuf) - 1] = '\0'; - execlp(pwd->pw_shell, tbuf, 0); + execlp(pwd->pw_shell, tbuf, (char *)NULL); fprintf(stderr, "login: no shell: "); perror(pwd->pw_shell); exit(0); diff --git a/src/appl/gssftp/ftpd/ChangeLog b/src/appl/gssftp/ftpd/ChangeLog index 6ead450..2817768 100644 --- a/src/appl/gssftp/ftpd/ChangeLog +++ b/src/appl/gssftp/ftpd/ChangeLog @@ -1,3 +1,24 @@ +2005-01-13 Ezra Peisach <epeisach@mit.edu> + + * ftpd.c: GCC 4.0 fixes... Move static declaration of gunique out + of function. + +2004-11-26 Sam Hartman <hartmans@mit.edu> + + * ftpcmd.y: nbby should be 8 for anything platform we care about. + The previous test broke on Debian BSD, so the test has been + removed. + +2004-11-03 Tom Yu <tlyu@mit.edu> + + * ftpcmd.y (getline): Merge Athena change to reject MICed + password. + + * ftpd.M: Document '-E'. + + * ftpd.c (main): Merge Athena's '-E' changes to prohibit + unencrypted passwords. + 2004-09-22 Tom Yu <tlyu@mit.edu> * Makefile.in (ftpd): Use UTIL_LIB. diff --git a/src/appl/gssftp/ftpd/Makefile.in b/src/appl/gssftp/ftpd/Makefile.in index 67e601e..f2bc655 100644 --- a/src/appl/gssftp/ftpd/Makefile.in +++ b/src/appl/gssftp/ftpd/Makefile.in @@ -105,4 +105,5 @@ $(OUTPRE)secure.$(OBJEXT): $(srcdir)/../ftp/secure.c \ $(KRB_ERR_H_DEP) $(COM_ERR_DEPS) $(BUILDTOP)/include/profile.h \ $(srcdir)/../arpa/ftp.h $(OUTPRE)getdtablesize.$(OBJEXT): $(srcdir)/../../bsd/getdtablesize.c +$(OUTPRE)setenv.$(OBJEXT): $(srcdir)/../../bsd/setenv.c diff --git a/src/appl/gssftp/ftpd/ftpcmd.y b/src/appl/gssftp/ftpd/ftpcmd.y index db50d5b..096014b 100644 --- a/src/appl/gssftp/ftpd/ftpcmd.y +++ b/src/appl/gssftp/ftpd/ftpcmd.y @@ -96,15 +96,8 @@ extern gss_ctx_id_t gcontext; #endif #ifndef NBBY -#ifdef linux #define NBBY 8 #endif -#ifdef __pyrsoft -#ifdef MIPSEB -#define NBBY 8 -#endif -#endif -#endif static struct sockaddr_in host_port; @@ -124,6 +117,7 @@ extern int ccc_ok; extern int timeout; extern int maxtimeout; extern int pdata; +extern int authlevel; extern char hostname[], remotehost[]; extern char proctitle[]; extern char *globerr; @@ -1150,6 +1144,18 @@ getline(s, n, iop) } #endif /* GSSAPI */ /* Other auth types go here ... */ + + /* A password should never be MICed, but the CNS ftp + * client and the pre-6/98 Krb5 client did this if you + * authenticated but didn't encrypt. + */ + if (authlevel && mic && !strncmp(s, "PASS", 4)) { + lreply(530, "There is a problem with your ftp client. Password refused."); + reply(530, "Enable encryption before logging in, or update your ftp program."); + *s = 0; + return s; + } + } #if defined KRB5_KRB4_COMPAT || defined GSSAPI /* or other auth types */ else { /* !auth_type */ diff --git a/src/appl/gssftp/ftpd/ftpd.M b/src/appl/gssftp/ftpd/ftpd.M index dc75e9b..b26a4bd 100644 --- a/src/appl/gssftp/ftpd/ftpd.M +++ b/src/appl/gssftp/ftpd/ftpd.M @@ -36,8 +36,8 @@ ftpd \- DARPA Internet File Transfer Protocol server .SH SYNOPSIS .B ftpd -[\fB\-A \fP|\fB -a\fP] [\fB\-C\fP] [\fB\-c\fP] [\fB\-d\fP] [\fB\-l\fP] -[\fB\-v\fP] [\fB\-T\fP \fImaxtimeout\fP] [\fB\-t\fP \fItimeout\fP] +[\fB\-A \fP|\fB -a\fP] [\fB\-C\fP] [\fB\-c\fP] [\fB\-d\fP] [\fB-E\fP] +[\fB\-l\fP] [\fB\-v\fP] [\fB\-T\fP \fImaxtimeout\fP] [\fB\-t\fP \fItimeout\fP] [\fB\-p\fP \fIport\fP] [\fB\-U\fP \fIftpusers-file\fP] [\fB\-u\fP \fIumask\fP] [\fB\-r\fP \fIrealm-file\fP] [\fB\-s\fP \fIsrvtab\fP] [\fB\-w\fP{\fBip\fP|\fImaxhostlen\fP[\fB,\fP{\fBstriplocal\fP|\fBnostriplocal\fP}]}] @@ -77,6 +77,9 @@ less secure connections, and should probably only be used when debugging. .B \-d Debugging information is written to the syslog. (Identical to -v) .TP +.B \-E +Don't allow passwords to be typed across unencrypted connections. +.TP .B \-l Each .IR ftp (1) diff --git a/src/appl/gssftp/ftpd/ftpd.c b/src/appl/gssftp/ftpd/ftpd.c index 6048278..6655e0d 100644 --- a/src/appl/gssftp/ftpd/ftpd.c +++ b/src/appl/gssftp/ftpd/ftpd.c @@ -260,6 +260,7 @@ static void end_login(void); static int disallowed_user(char *); static int restricted_user(char *); static int checkuser(char *); +static char *gunique(char *); #ifdef SETPROCTITLE char **Argv = NULL; /* pointer to argument vector */ @@ -293,9 +294,9 @@ main(argc, argv, envp) extern char *optarg; extern int optopt; #ifdef KRB5_KRB4_COMPAT - char *option_string = "AaCcdlp:r:s:T:t:U:u:vw:"; + char *option_string = "AaCcdElp:r:s:T:t:U:u:vw:"; #else /* !KRB5_KRB4_COMPAT */ - char *option_string = "AaCcdlp:r:T:t:U:u:vw:"; + char *option_string = "AaCcdElp:r:T:t:U:u:vw:"; #endif /* KRB5_KRB4_COMPAT */ ftpusers = _PATH_FTPUSERS_DEFAULT; @@ -328,6 +329,11 @@ main(argc, argv, envp) debug = 1; break; + case 'E': + if (!authlevel) + authlevel = AUTHLEVEL_AUTHENTICATE; + break; + case 'l': logging ++; break; @@ -1274,7 +1280,6 @@ store_file(name, fmode, unique) FILE *fout, *din; struct stat st; int (*closefunc)(); - static char *gunique(); if (logging > 1) syslog(LOG_NOTICE, "put %s", path_expand(name)); diff --git a/src/appl/telnet/libtelnet/ChangeLog b/src/appl/telnet/libtelnet/ChangeLog index 9e5c888..a02cd8d 100644 --- a/src/appl/telnet/libtelnet/ChangeLog +++ b/src/appl/telnet/libtelnet/ChangeLog @@ -1,3 +1,13 @@ +2004-12-20 Tom Yu <tlyu@mit.edu> + + * kerberos.c (kerberos4_status): Null-terminate the correct + string. Reported by Marcin Garski. + +2004-11-15 Tom Yu <tlyu@mit.edu> + + * auth-proto.h, auth.c: Merge Athena changes for requiring + encrypted connections. + 2004-06-04 Ken Raeburn <raeburn@mit.edu> * Makefile.in (LIBBASE): Renamed from LIB. diff --git a/src/appl/telnet/libtelnet/auth-proto.h b/src/appl/telnet/libtelnet/auth-proto.h index 68cae7e..6b49570 100644 --- a/src/appl/telnet/libtelnet/auth-proto.h +++ b/src/appl/telnet/libtelnet/auth-proto.h @@ -67,7 +67,8 @@ void auth_send_retry (void); void auth_is (unsigned char *, int); void auth_reply (unsigned char *, int); void auth_finished (Authenticator *, int); -int auth_wait (char *); +void auth_wait (char *); +int auth_check (char *); int auth_must_encrypt (void); void auth_disable_name (char *); void auth_gen_printsub (unsigned char *, int, unsigned char *, unsigned int); diff --git a/src/appl/telnet/libtelnet/auth.c b/src/appl/telnet/libtelnet/auth.c index 9c1b0b0..28b8ae8 100644 --- a/src/appl/telnet/libtelnet/auth.c +++ b/src/appl/telnet/libtelnet/auth.c @@ -85,6 +85,7 @@ int auth_debug_mode = 0; int auth_has_failed = 0; int auth_enable_encrypt = 0; +int auth_client_non_unix = 0; static char *Name = "Noname"; static int Server = 0; static Authenticator *authenticated = 0; @@ -337,15 +338,28 @@ auth_request() authenticating = 1; while (ap->type) { if (i_support & ~i_wont_support & typemask(ap->type)) { - if (auth_debug_mode) { - printf(">>>%s: Sending type %d %d\r\n", - Name, ap->type, ap->way); + if (ap->type == AUTHTYPE_KERBEROS_V4 || + !auth_client_non_unix) { + if (auth_debug_mode) { + printf(">>>%s: Sending type %d %d\r\n", + Name, ap->type, ap->way); + } + *e++ = ap->type; + *e++ = ap->way; } - *e++ = ap->type; - *e++ = ap->way; } ++ap; } + if (auth_client_non_unix) { + ap = authenticators; + while (ap->type) { + if (i_support & ~i_wont_support & typemask(ap->type)) { + *e++ = ap->type; + *e++ = ap->way; + } + ++ap; + } + } *e++ = IAC; *e++ = SE; net_write(str_request, e - str_request); @@ -562,7 +576,7 @@ auth_intr(sig) auth_finished(0, AUTH_REJECT); } - int + void auth_wait(name) char *name; { @@ -570,7 +584,7 @@ auth_wait(name) printf(">>>%s: in auth_wait.\r\n", Name); if (Server && !authenticating) - return(0); + return; (void) signal(SIGALRM, auth_intr); alarm(30); @@ -579,7 +593,12 @@ auth_wait(name) break; alarm(0); (void) signal(SIGALRM, SIG_DFL); +} + int +auth_check(name) + char *name; +{ /* * Now check to see if the user is valid or not */ diff --git a/src/appl/telnet/libtelnet/kerberos.c b/src/appl/telnet/libtelnet/kerberos.c index 8d4c7f3..7e0d736 100644 --- a/src/appl/telnet/libtelnet/kerberos.c +++ b/src/appl/telnet/libtelnet/kerberos.c @@ -619,7 +619,7 @@ kerberos4_status(ap, kname, level) if (UserNameRequested) { /* the name buffer comes from telnetd/telnetd{-ktd}.c */ strncpy(kname, UserNameRequested, 255); - name[255] = '\0'; + kname[255] = '\0'; } if (UserNameRequested && !kuserok(&adat, UserNameRequested)) { diff --git a/src/appl/telnet/telnet/ChangeLog b/src/appl/telnet/telnet/ChangeLog index 91d5259..3e090ca 100644 --- a/src/appl/telnet/telnet/ChangeLog +++ b/src/appl/telnet/telnet/ChangeLog @@ -1,3 +1,15 @@ +2005-04-05 Ken Raeburn <raeburn@mit.edu> + + * commands.c (shell): Change 0 to (char*)NULL in execl calls. + Patch provided by Michael Calmer. + +2005-03-28 Tom Yu <tlyu@mit.edu> + + * telnet.c (slc_add_reply, slc_end_reply): Fix buffer overflow + vulnerability by checking lengths. + (env_opt_add): Ensure buffer allocation is sufficiently large, + accounting for expansion during IAC quoting. + 2004-03-04 Ken Raeburn <raeburn@mit.edu> * configure.in: Deleted; configure this dir from parent now. diff --git a/src/appl/telnet/telnet/commands.c b/src/appl/telnet/telnet/commands.c index a637e9e..cb3390d 100644 --- a/src/appl/telnet/telnet/commands.c +++ b/src/appl/telnet/telnet/commands.c @@ -1467,9 +1467,9 @@ shell(argc, argv) else shellname++; if (argc > 1) - execl(shellp, shellname, "-c", &saveline[1], 0); + execl(shellp, shellname, "-c", &saveline[1], (char *)NULL); else - execl(shellp, shellname, 0); + execl(shellp, shellname, (char *)NULL); perror("Execl"); _exit(1); } diff --git a/src/appl/telnet/telnet/telnet.c b/src/appl/telnet/telnet/telnet.c index a92bbd5..6215fc1 100644 --- a/src/appl/telnet/telnet/telnet.c +++ b/src/appl/telnet/telnet/telnet.c @@ -1475,6 +1475,8 @@ slc_add_reply(func, flags, value) unsigned char flags; cc_t value; { + if ((slc_replyp - slc_reply) + 6 > sizeof(slc_reply)) + return; if ((*slc_replyp++ = func) == IAC) *slc_replyp++ = IAC; if ((*slc_replyp++ = flags) == IAC) @@ -1488,11 +1490,12 @@ slc_end_reply() { register int len; - *slc_replyp++ = IAC; - *slc_replyp++ = SE; len = slc_replyp - slc_reply; - if (len <= 6) + if (len <= 4 || (len + 2 > sizeof(slc_reply))) return; + *slc_replyp++ = IAC; + *slc_replyp++ = SE; + len += 2; if (NETROOM() > len) { ring_supply_data(&netoring, slc_reply, slc_replyp - slc_reply); printsub('>', &slc_reply[2], slc_replyp - slc_reply - 2); @@ -1645,6 +1648,7 @@ env_opt_add(ep) register unsigned char *ep; { register unsigned char *vp, c; + unsigned int len, olen, elen; if (opt_reply == NULL) /*XXX*/ return; /*XXX*/ @@ -1662,19 +1666,19 @@ env_opt_add(ep) return; } vp = env_getvalue(ep); - if (opt_replyp + (vp ? strlen((char *)vp) : 0) + - strlen((char *)ep) + 6 > opt_replyend) + elen = 2 * (vp ? strlen((char *)vp) : 0) + + 2 * strlen((char *)ep) + 6; + if ((opt_replyend - opt_replyp) < elen) { - register unsigned int len; - opt_replyend += OPT_REPLY_SIZE; - len = opt_replyend - opt_reply; + len = opt_replyend - opt_reply + elen; + olen = opt_replyp - opt_reply; opt_reply = (unsigned char *)realloc(opt_reply, len); if (opt_reply == NULL) { /*@*/ printf("env_opt_add: realloc() failed!!!\n"); opt_reply = opt_replyp = opt_replyend = NULL; return; } - opt_replyp = opt_reply + len - (opt_replyend - opt_replyp); + opt_replyp = opt_reply + olen; opt_replyend = opt_reply + len; } if (opt_welldefined((char *) ep)) diff --git a/src/appl/telnet/telnetd/ChangeLog b/src/appl/telnet/telnetd/ChangeLog index 1902a32..760cbb2 100644 --- a/src/appl/telnet/telnetd/ChangeLog +++ b/src/appl/telnet/telnetd/ChangeLog @@ -1,3 +1,15 @@ +2004-11-15 Tom Yu <tlyu@mit.edu> + + * ext.h: New variable "must_encrypt". + + * telnetd.8: Update for changed command-line options. + + * telnetd.c (getterminaltype): Merge Athena changes to require + encrypted connections. + + * utility.c (ttsuck): Merge Athena changes to work around some + client timing bugs. + 2004-09-22 Tom Yu <tlyu@mit.edu> * Makefile.in (telnetd): Use UTIL_LIB. diff --git a/src/appl/telnet/telnetd/ext.h b/src/appl/telnet/telnetd/ext.h index 9fe38ef..7b77a44 100644 --- a/src/appl/telnet/telnetd/ext.h +++ b/src/appl/telnet/telnetd/ext.h @@ -88,6 +88,10 @@ extern char *unptyip; /* pointer to remaining characters in buffer */ extern int pty, net; extern int SYNCHing; /* we are in TELNET SYNCH mode */ +#ifdef ENCRYPTION +extern int must_encrypt; +#endif + extern void _termstat (void), add_slc (int, int, int), diff --git a/src/appl/telnet/telnetd/telnetd.8 b/src/appl/telnet/telnetd/telnetd.8 index 9426a0c..78700cb 100644 --- a/src/appl/telnet/telnetd/telnetd.8 +++ b/src/appl/telnet/telnetd/telnetd.8 @@ -39,7 +39,7 @@ protocol server .SH SYNOPSIS .B /usr/libexec/telnetd [\fB\-a\fP \fIauthmode\fP] [\fB\-B\fP] [\fB\-D\fP] [\fIdebugmode\fP] -[\fB\-edebug\fP] [\fB\-h\fP] [\fB\-I\fP\fIinitid\fP] [\fB\-l\fP] +[\fB\-e\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]]] @@ -163,6 +163,9 @@ Displays the data stream received by .B ptydata Displays data written to the pty. .TP +.B encrypt +Enables encryption debugging code. +.TP .B exercise Has not been implemented yet. .RE @@ -175,12 +178,10 @@ Enables debugging on each socket created by in .IR socket (2)). .TP -.B \-edebug -If +.B \-e +This option causes .B telnetd -has been compiled with support for data encryption, then the -.B edebug -option may be used to enable encryption debugging code. +to refuse unencrypted connections. .TP .B \-h Disables the printing of host-specific information before login has been diff --git a/src/appl/telnet/telnetd/telnetd.c b/src/appl/telnet/telnetd/telnetd.c index 5633d56..a90fa5c 100644 --- a/src/appl/telnet/telnetd/telnetd.c +++ b/src/appl/telnet/telnetd/telnetd.c @@ -173,7 +173,7 @@ char valid_opts[] = { 'D', ':', #endif #ifdef ENCRYPTION - 'e', ':', + 'e', #endif #if defined(CRAY) && defined(NEWINIT) 'I', ':', @@ -308,6 +308,9 @@ main(argc, argv) diagnostic |= TD_PTYDATA; } else if (!strcmp(optarg, "options")) { diagnostic |= TD_OPTIONS; + } else if (!strcmp(optarg, "encrypt")) { + extern int encrypt_debug_mode; + encrypt_debug_mode = 1; } else { usage(); /* NOT REACHED */ @@ -317,13 +320,7 @@ main(argc, argv) #ifdef ENCRYPTION case 'e': - if (strcmp(optarg, "debug") == 0) { - extern int encrypt_debug_mode; - encrypt_debug_mode = 1; - break; - } - usage(); - /* NOTREACHED */ + must_encrypt = 1; break; #endif /* ENCRYPTION */ @@ -694,8 +691,12 @@ usage() static void encrypt_failure() { - char *lerror_message = - "Encryption was not successfully negotiated. Goodbye.\r\n\r\n"; + char *lerror_message; + + if (auth_must_encrypt()) + lerror_message = "Encryption was not successfully negotiated. Goodbye.\r\n\r\n"; + else + lerror_message = "Unencrypted connection refused. Goodbye.\r\n\r\n"; netputs(lerror_message); netflush(); @@ -720,6 +721,7 @@ getterminaltype(name) settimer(baseline); #if defined(AUTHENTICATION) + ttsuck(); /* * Handle the Authentication option before we do anything else. */ @@ -727,7 +729,7 @@ getterminaltype(name) while (his_will_wont_is_changing(TELOPT_AUTHENTICATION)) ttloop(); if (his_state_is_will(TELOPT_AUTHENTICATION)) { - retval = auth_wait(name); + auth_wait(name); } #endif @@ -760,15 +762,25 @@ getterminaltype(name) if (his_state_is_will(TELOPT_ENCRYPT)) { encrypt_wait(); } - if (auth_must_encrypt()) { + if (must_encrypt || auth_must_encrypt()) { time_t timeout = time(0) + 60; if (my_state_is_dont(TELOPT_ENCRYPT) || - my_state_is_wont(TELOPT_ENCRYPT)) + my_state_is_wont(TELOPT_ENCRYPT) || + his_state_is_wont(TELOPT_AUTHENTICATION)) encrypt_failure(); - if (!EncryptStartInput() || !EncryptStartOutput()) - encrypt_failure(); + while (!EncryptStartInput()) { + if (time (0) > timeout) + encrypt_failure(); + ttloop(); + } + + while (!EncryptStartOutput()) { + if (time (0) > timeout) + encrypt_failure(); + ttloop(); + } while (!encrypt_is_encrypting()) { if (time(0) > timeout) @@ -865,7 +877,11 @@ getterminaltype(name) } } } - return(retval); +#ifdef AUTHENTICATION + return(auth_check(name)); +#else + return(-1); +#endif } /* end of getterminaltype */ static void diff --git a/src/appl/telnet/telnetd/utility.c b/src/appl/telnet/telnetd/utility.c index fc8ff76..f4568ec 100644 --- a/src/appl/telnet/telnetd/utility.c +++ b/src/appl/telnet/telnetd/utility.c @@ -90,6 +90,67 @@ read_again: } } /* end of ttloop */ +/* + * ttsuck - This is a horrible kludge to deal with a bug in + * HostExplorer. HostExplorer thinks it knows how to do krb5 auth, but + * it doesn't really. So if you offer it krb5 as an auth choice before + * krb4, it will sabotage the connection. So we peek ahead into the + * input stream to see if the client is a UNIX client, and then + * (later) offer krb5 first only if it is. Since no Mac/PC telnet + * clients do auto switching between krb4 and krb5 like the UNIX + * client does, it doesn't matter what order they see the choices in + * (except for HostExplorer). + * + * It is actually not possible to do this without looking ahead into + * the input stream: the client and server both try to begin + * auth/encryption negotiation as soon as possible, so if we let the + * server process things normally, it will already have sent the list + * of supported auth types before seeing the NEW-ENVIRON option. If + * you change the code to hold off sending the list of supported auth + * types until after it knows whether or not the remote side supports + * NEW-ENVIRON, then the auth negotiation and encryption negotiation + * race conditions won't interact properly, and encryption negotiation + * will reliably fail. + */ + + void +ttsuck() +{ + extern int auth_client_non_unix; + int nread; + struct timeval tv; + fd_set fds; + char *p, match[] = {IAC, WILL, TELOPT_NEW_ENVIRON}; + + if (nfrontp-nbackp) { + netflush(); + } + tv.tv_sec = 1; + tv.tv_usec = 0; + FD_SET(net, &fds); + + while (select(net + 1, &fds, NULL, NULL, &tv) == 1) + { + nread = read(net, netibuf + ncc, sizeof(netibuf) - ncc); + if (nread <= 0) + break; + ncc += nread; + } + + auth_client_non_unix = 1; + for (p = netibuf; p < netibuf + ncc; p++) + { + if (!memcmp(p, match, sizeof(match))) + { + auth_client_non_unix = 0; + break; + } + } + + if (ncc > 0) + telrcv(); +} + /* * Check a descriptor to see if out of band data exists on it. */ diff --git a/src/clients/ChangeLog b/src/clients/ChangeLog index 4666914..6437936 100644 --- a/src/clients/ChangeLog +++ b/src/clients/ChangeLog @@ -1,3 +1,7 @@ +2004-12-15 Jeffrey Altman <jaltman@mit.edu> + + * Makefile.in: output status info for kcpytkt, kdeltkt + 2004-08-20 Jeffrey Altman <jaltman@mit.edu> * Add kcpytkt and kdeltkt directories diff --git a/src/clients/Makefile.in b/src/clients/Makefile.in index f68d6ff..f1c8be6 100644 --- a/src/clients/Makefile.in +++ b/src/clients/Makefile.in @@ -22,8 +22,10 @@ all-windows:: @echo Making all in clients\kvno cd ..\kvno $(MAKE) -$(MFLAGS) + @echo Making all in clients\kcpytkt cd ..\kcpytkt $(MAKE) -$(MFLAGS) + @echo Making all in clients\kdeltkt cd ..\kdeltkt $(MAKE) -$(MFLAGS) cd .. @@ -44,8 +46,10 @@ clean-windows:: @echo Making clean in clients\kvno cd ..\kvno $(MAKE) -$(MFLAGS) clean + @echo Making clean in clients\kcpytkt cd ..\kcpytkt $(MAKE) -$(MFLAGS) clean + @echo Making clean in clients\kdeltkt cd ..\kdeltkt $(MAKE) -$(MFLAGS) clean cd .. diff --git a/src/clients/kdeltkt/ChangeLog b/src/clients/kdeltkt/ChangeLog index 1909231..35a2595 100644 --- a/src/clients/kdeltkt/ChangeLog +++ b/src/clients/kdeltkt/ChangeLog @@ -1,3 +1,7 @@ +2004-12-15 Jeffrey Altman <jaltman@mit.edu> + + * Makefile.in: correct the makefile to build kdeltkt, not kvno + 2004-08-19 Jeffrey Altman <jaltman@mit.edu> * kdeltkt.c, kdeltkt.M: Create a new application. diff --git a/src/clients/kdeltkt/Makefile.in b/src/clients/kdeltkt/Makefile.in index 0921594..d7d371a 100644 --- a/src/clients/kdeltkt/Makefile.in +++ b/src/clients/kdeltkt/Makefile.in @@ -1,26 +1,26 @@ thisconfigdir=./.. -myfulldir=clients/kvno +myfulldir=clients/kdeltkt mydir=kvno BUILDTOP=$(REL)..$(S).. PROG_LIBPATH=-L$(TOPLIBD) PROG_RPATH=$(KRB5_LIBDIR) -all-unix:: kvno -all-windows:: $(OUTPRE)kvno.exe +all-unix:: kdeltkt +all-windows:: $(OUTPRE)kdeltkt.exe all-mac:: -kvno: kvno.o $(KRB4COMPAT_DEPLIBS) - $(CC_LINK) -o $@ kvno.o $(KRB4COMPAT_LIBS) +kdeltkt: kdeltkt.o $(KRB4COMPAT_DEPLIBS) + $(CC_LINK) -o $@ kdeltkt.o $(KRB4COMPAT_LIBS) -$(OUTPRE)kvno.exe: $(OUTPRE)kvno.obj $(BUILDTOP)\util\windows\$(OUTPRE)getopt.obj $(KLIB) $(CLIB) +$(OUTPRE)kdeltkt.exe: $(OUTPRE)kdeltkt.obj $(BUILDTOP)\util\windows\$(OUTPRE)getopt.obj $(KLIB) $(CLIB) link $(EXE_LINKOPTS) /out:$@ $** clean-unix:: - $(RM) kvno.o kvno + $(RM) kdeltkt.o kdeltkt install-unix:: - for f in kvno; do \ + for f in kdeltkt; do \ $(INSTALL_PROGRAM) $$f \ $(DESTDIR)$(CLIENT_BINDIR)/`echo $$f|sed '$(transform)'`; \ $(INSTALL_DATA) $(srcdir)/$$f.M \ diff --git a/src/config/ChangeLog b/src/config/ChangeLog index 0461237..b8221ff 100644 --- a/src/config/ChangeLog +++ b/src/config/ChangeLog @@ -1,3 +1,46 @@ +2005-03-25 Ken Raeburn <raeburn@mit.edu> + + * lib.in (hpux10.exports): New target, constructed similar to + osf1.exports but with HP-UX 10.x linker options, no initializers, + and "errno" explicitly added to the export list. + * shlib.conf (*-*-hpux*): Combine PICFLAGS setting with + SHLIB_EXPFLAGS and LDCOMBINE setting. Add linker option "-c + hpux10.exports" to LDCOMBINE. Set SHLIB_EXPORT_FILE_DEP to + hpux10.exports. Set use_linker_fini_option. + +2005-02-08 Ken Raeburn <raeburn@mit.edu> + + * lib.in (config.status): Change target to be in $thisconfigdir + rather than local. + (osf1.exports): Create a temporary file then rename into place. + Add options for library init/fini symbols, handling multiple + values. + + * shlib.conf (case alpha*-dec-osf*): Don't handle init/fini + symbols here. + (case mips-sgi-irix*): Handle multiple init/fini symbols. Always + set $initfini before it gets used. + (case *-*-solaris*, not gcc): Handle multiple init/fini symbols. + (case *-*-aix*): Handle multiple fini symbols. + +2004-12-17 Jeffrey Altman <jaltman@mit.edu> + + * win-pre.in: add -debug switch to LOPTS if DEBUG_SYMBOLS + +2004-12-17 Ken Raeburn <raeburn@mit.edu> + + * shlib.conf (*-*-netbsd*): Use -fPIC instead of -fpic, which + won't work on sparc64 at least. + +2004-12-15 Jeffrey Altman <jaltman@mit.edu> + + * win-pre.in; optionally build debug symbols for release builds + and rename krb5support_32.dll to k5sprt32.dll + +2004-11-19 Tom Yu <tlyu@mit.edu> + + * pre.in (KRB5_INCSUBDIRS): Add KRB5_INCDIR/gssrpc. + 2004-10-06 Tom Yu <tlyu@mit.edu> * pre.in (datadir, EXAMPLEDIR): Add directory for examples. diff --git a/src/config/lib.in b/src/config/lib.in index 7ebdb3f..ef159f5 100644 --- a/src/config/lib.in +++ b/src/config/lib.in @@ -57,7 +57,32 @@ binutils.versions: $(SHLIB_EXPORT_FILE) Makefile echo >> binutils.versions "};" osf1.exports: $(SHLIB_EXPORT_FILE) Makefile - sed "s/^/-exported_symbol /" < $(SHLIB_EXPORT_FILE) > osf1.exports + $(RM) osf1.tmp osf1.exports + sed "s/^/-exported_symbol /" < $(SHLIB_EXPORT_FILE) > osf1.tmp + for f in . $(LIBINITFUNC); do \ + if test "$$f" != "." ; then \ + echo " -init $$f"__auxinit >> osf1.tmp; \ + else :; fi; \ + done + a=""; \ + for f in . $(LIBFINIFUNC); do \ + if test "$$f" != "." ; then \ + a="-fini $$f $$a"; \ + else :; fi; \ + done; echo " $$a" >> osf1.tmp; \ + mv -f osf1.tmp osf1.exports + +hpux10.exports: $(SHLIB_EXPORT_FILE) Makefile + $(RM) hpux10.tmp hpux10.exports + sed "s/^/+e /" < $(SHLIB_EXPORT_FILE) > hpux10.tmp + a=""; \ + for f in . $(LIBFINIFUNC); do \ + if test "$$f" != .; then \ + a="+I $${f}__auxfini $$a"; \ + else :; fi; \ + done; echo "$$a" >> hpux10.tmp + echo "+e errno" >> hpux10.tmp + mv -f hpux10.tmp hpux10.exports lib$(LIBBASE)$(PFLIBEXT): $(PFOBJLISTS) $(RM) $@ @@ -120,7 +145,7 @@ install-profiled: $(RANLIB) $(DESTDIR)$(KRB5_LIBDIR)/lib$(LIBBASE)$(PFLIBEXT) Makefile: $(SRCTOP)/config/lib.in -config.status: $(SRCTOP)/config/shlib.conf +$(thisconfigdir)/config.status: $(SRCTOP)/config/shlib.conf # Use the following if links need to be made to $(TOPLIBD): # all-unix:: all-liblinks diff --git a/src/config/pre.in b/src/config/pre.in index 7d3e7a0..fca306d 100644 --- a/src/config/pre.in +++ b/src/config/pre.in @@ -205,7 +205,8 @@ KRB5_SHLIBDIR = @libdir@$(SHLIB_TAIL_COMP) KRB5_INCDIR = @includedir@ KRB5_INCSUBDIRS = \ $(KRB5_INCDIR)/gssapi \ - $(KRB5_INCDIR)/kerberosIV + $(KRB5_INCDIR)/kerberosIV \ + $(KRB5_INCDIR)/gssrpc # # Macros used by the KADM5 (OV-based) unit test system. diff --git a/src/config/shlib.conf b/src/config/shlib.conf index 3205bb3..3261b67 100644 --- a/src/config/shlib.conf +++ b/src/config/shlib.conf @@ -38,7 +38,7 @@ alpha*-dec-osf*) SHLIBEXT=.so # Alpha OSF/1 doesn't need separate PIC objects SHOBJEXT=.o - INIT_FINI_PREP='if test -z "$(LIBINITFUNC)"; then initfini=""; else initfini="-Wl,-init,$(LIBINITFUNC)__auxinit"; fi; if test -z "$(LIBFINIFUNC)";then :;else initfini="$$initfini -Wl,-fini,$(LIBFINIFUNC)"; fi' + INIT_FINI_PREP=initfini= LDCOMBINE='$(CC) $(PTHREAD_CFLAGS) -shared -Wl,-expect_unresolved -Wl,\* -Wl,-update_registry -Wl,$(BUILDTOP)/so_locations -Wl,-soname -Wl,lib$(LIBBASE)$(SHLIBSEXT) -Wl,-hidden -Wl,-input,osf1.exports $$initfini' SHLIB_EXPORT_FILE_DEP=osf1.exports use_linker_init_option=yes @@ -75,27 +75,42 @@ alpha*-dec-osf*) # on the commandline of the linker will determine which path # (compiled-in or SHLIB_PATH) will be searched first. # +# +I initproc routine gets called at load and unload time for +# shl_load calls, but appears to never be called for link-time +# specified libraries. +# +e sym exports symbol and supposedly prevents other symbols +# from being exported, according to the man page, but the +# latter bit doesn't actually seem to work +# -O +dpv should display any routines eliminated as unused, but -b +# apparently turns that off *-*-hpux*) - if test "$krb5_cv_prog_gcc" = yes; then - PICFLAGS=-fPIC - else - PICFLAGS=+z - fi INSTALL_SHLIB='$(INSTALL)' SHLIBEXT=.sl SHLIBVEXT='.$(LIBMAJOR).$(LIBMINOR)' SHLIBSEXT='.$(LIBMAJOR)' RPATH_FLAG='-Wl,+b,' if test "$krb5_cv_prog_gcc" = yes; then + PICFLAGS=-fPIC SHLIB_EXPFLAGS='-Wl,+s -Wl,+b,$(SHLIB_RDIRS) $(SHLIB_DIRS) $(SHLIB_EXPLIBS)' - LDCOMBINE='gcc -fPIC -shared -Wl,+h,lib$(LIBBASE)$(SHLIBSEXT)' + LDCOMBINE='gcc -fPIC -shared -Wl,+h,lib$(LIBBASE)$(SHLIBSEXT) -Wl,-c,hpux10.exports' else + PICFLAGS=+z SHLIB_EXPFLAGS='+s +b $(SHLIB_RDIRS) $(SHLIB_DIRS) $(SHLIB_EXPLIBS)' - LDCOMBINE='ld -b +h lib$(LIBBASE)$(SHLIBSEXT)' + LDCOMBINE='ld -b +h lib$(LIBBASE)$(SHLIBSEXT) -c hpux10.exports' fi CC_LINK_SHARED='$(CC) $(PROG_LIBPATH) -Wl,+s $(RPATH_FLAG)$(PROG_RPATH) $(CFLAGS) $(LDFLAGS)' CC_LINK_STATIC='$(CC) $(PROG_LIBPATH) $(CFLAGS) $(LDFLAGS)' RUN_ENV='SHLIB_PATH=`echo $(PROG_LIBPATH) | sed -e "s/-L//g" -e "s/ /:/g"`; export SHLIB_PATH;' + SHLIB_EXPORT_FILE_DEP=hpux10.exports + # Do *not* set use_linker_init_option=yes here, because in the + # case where the library is specified at program link time, the + # initialization function appears not to get called, only for + # shl_load. But for finalization functions, the shl_load case + # is the one we care about. + # + # Not setting use_linker_init_option here should cause compilation + # failures if the user tries to disable delayed initialization. + use_linker_fini_option=yes ;; mips-sgi-irix6.3) # This is a Kludge; see below @@ -139,10 +154,11 @@ mips-sgi-irix*) SHOBJEXT=.o if test "$krb5_cv_prog_gcc" = yes; then LDCOMBINE_TAIL="" + INIT_FINI_PREP="initfini=" else use_linker_init_option=yes use_linker_fini_option=yes - INIT_FINI_PREP='if test -z "$(LIBINITFUNC)"; then initfini=""; else initfini="-Wl,-init,$(LIBINITFUNC)__auxinit"; fi; if test -z "$(LIBFINIFUNC)";then :;else initfini="$$initfini -Wl,-fini,$(LIBFINIFUNC)"; fi' + INIT_FINI_PREP='initfini=; for f in . $(LIBINITFUNC); do if test $$f = .; then :; else initfini="$$initfini -Wl,-init,$${f}__auxinit"; fi; done; for f in . $(LIBFINIFUNC); do if test $$f = .; then :; else initfini="$$initfini -Wl,-fini,$${f}"; fi; done' LDCOMBINE_TAIL='-Wl,-exports_file -Wl,$(SHLIB_EXPORT_FILE)' fi LDCOMBINE='$(CC) -shared -Wl,-ignore_unresolved -Wl,-update_registry -Wl,$(BUILDTOP)/so_locations -Wl,-soname -Wl,lib$(LIBBASE)$(SHLIBSEXT) $$initfini' @@ -204,7 +220,7 @@ mips-*-netbsd*) ;; *-*-netbsd*) - PICFLAGS=-fpic + PICFLAGS=-fPIC SHLIBVEXT='.so.$(LIBMAJOR).$(LIBMINOR)' SHLIBEXT=.so LDCOMBINE='ld -Bshareable' @@ -279,6 +295,7 @@ mips-*-netbsd*) LDCOMBINE='$(CC) -dy -G -z text -h lib$(LIBBASE)$(SHLIBSEXT) $$initfini' # INIT_FINI_PREP='if test -z "$(LIBINITFUNC)"; then initfini=; else initfini="-Wl,-z,initarray=$(LIBINITFUNC)__auxinit"; fi ; if test -z "$(LIBFINIFUNC)"; then :; else initfini="$$initfini -Wl,-z,finiarray=$(LIBFINIFUNC)" ; fi' + INIT_FINI_PREP='initfini=; for f in . $(LIBINITFUNC); do if test $$f = .; then :; else initfini="$$initfini -Wl,-z,initarray=$${f}__auxinit"; fi; done; for f in . $(LIBFINIFUNC); do if test $$f = .; then :; else initfini="$$initfini -Wl,-z,finiarray=$$f"; fi; done' use_linker_init_option=yes use_linker_fini_option=yes fi @@ -351,16 +368,17 @@ mips-*-netbsd*) SHLIB_EXPFLAGS=' $(SHLIB_DIRS) $(SHLIB_EXPLIBS)' PROFFLAGS=-pg if test "$krb5_cv_prog_gcc" = "yes" ; then + wl_prefix=-Wl, RPATH_FLAG='-Wl,-blibpath:' LDCOMBINE='$(CC) -shared -v -o shr.o.$(LIBMAJOR).$(LIBMINOR) $$objlist -nostartfiles -Xlinker -bgcbypass:1 -Xlinker -bfilelist -Xlinker -bM:SRE -Xlinker -bE:$(SHLIB_EXPORT_FILE) -Xlinker -bernotok $(SHLIB_EXPFLAGS) -lc $$initfini' - INIT_FINI_PREP='if test -z "$(LIBFINIFUNC)"; then initfini=""; else initfini="-Wl,-binitfini::$(LIBFINIFUNC):3"; fi' - use_linker_fini_option=yes else + wl_prefix= RPATH_FLAG=-blibpath: LDCOMBINE='/bin/ld -o shr.o.$(LIBMAJOR).$(LIBMINOR) $$objlist -H512 -T512 -bnoentry -bgcbypass:1 -bnodelcsect -bfilelist -bM:SRE -bE:$(SHLIB_EXPORT_FILE) -bernotok $(SHLIB_EXPFLAGS) -lc $$initfini' - INIT_FINI_PREP='if test -z "$(LIBFINIFUNC)"; then initfini=""; else initfini="-binitfini::$(LIBFINIFUNC):3"; fi' - use_linker_fini_option=yes fi + # Assume initialization always delayed. + INIT_FINI_PREP="wl=${wl_prefix}; "'i=1; initfini=; for f in . $(LIBFINIFUNC); do if test $$f != .; then initfini="$$initfini $${wl}-binitfini::$$f:$$i"; else :; fi; i=`expr $$i + 1`; done' + use_linker_fini_option=yes MAKE_SHLIB_COMMAND="${INIT_FINI_PREP} && ${LDCOMBINE}"' && ar cq $@ shr.o.$(LIBMAJOR).$(LIBMINOR) && chmod +x $@ && rm -f shr.o.$(LIBMAJOR).$(LIBMINOR)' RPATH_TAIL=:/usr/lib:/lib CC_LINK_SHARED='$(CC) $(PROG_LIBPATH) $(RPATH_FLAG)$(PROG_RPATH):'"$RPATH_TAIL"' $(CFLAGS) $(LDFLAGS)' diff --git a/src/config/win-pre.in b/src/config/win-pre.in index 37f22fd..73e7bea 100644 --- a/src/config/win-pre.in +++ b/src/config/win-pre.in @@ -142,6 +142,10 @@ LOPTS=-nologo -incremental:no # CCOPTS2 was for non-DLL compiles (EXEs, for example) # !ifdef NODEBUG +!ifdef DEBUG_SYMBOL +CCOPTS=/ZI $(CCOPTS) +LOPTS=$(LOPTS) -debug +!endif CCOPTS=/Os /MD $(CCOPTS) LOPTS=$(LOPTS) !else @@ -170,7 +174,7 @@ CLIB=$(BUILDTOP)\lib\$(OUTPRE)comerr32.lib PLIB=$(BUILDTOP)\lib\$(OUTPRE)xpprof32.lib KLIB=$(BUILDTOP)\lib\$(OUTPRE)krb5_32.lib K4LIB=$(BUILDTOP)\lib\$(OUTPRE)krb4_32.lib -SLIB=$(BUILDTOP)\lib\$(OUTPRE)krb5support_32.lib +SLIB=$(BUILDTOP)\lib\$(OUTPRE)k5sprt32.lib GLIB=$(BUILDTOP)\lib\$(OUTPRE)gssapi32.lib WLIB= diff --git a/src/include/ChangeLog b/src/include/ChangeLog index f3e2ae9..7ecb536 100644 --- a/src/include/ChangeLog +++ b/src/include/ChangeLog @@ -1,3 +1,77 @@ +2005-03-25 Ken Raeburn <raeburn@mit.edu> + + * k5-platform.h: Expand on init/fini comments some more. + (MAKE_FINI_FUNCTION): Add an HP-UX specific variant that defines + an auxiliary function fitting the signature of HP-UX 10 library + combined initializer/finalizer functions. + +2005-03-04 Ken Raeburn <raeburn@mit.edu> + + * configure.in: Check return type of gmtime_r, and define + GMTIME_R_RETURNS_INT if it returns int. If the return type can't + be determined, pretend the function isn't there. + +2005-02-08 Ken Raeburn <raeburn@mit.edu> + + * k5-platform.h (PROGRAM_EXITING) [__GNUC__ && !_WIN32 && + CONSTRUCTOR_ATTR_WORKS]: Define as zero. + +2005-01-04 Jeffrey Altman <jaltman@mit.edu> + + * win-mac.h: define NEED_INSIXADDR_ANY for ipv6 symbol + +2005-01-21 Ezra Peisach <epeisach@mit.edu> + + * k5-thread.h (k5_os_mutex_lock): Under Irix, invoke + k5_pthread_mutex_lock() with the k5_os_mutex, not the + pthread_mutex_t. + (k5_pthread_assert_locked,unlocked): If DEBUG_THREADS not use, provide + correct prototype. Add missing close paren. + +2005-01-14 Ken Raeburn <raeburn@mit.edu> + + * k5-thread.h [HAVE_PTHREAD && HAVE_PRAGMA_WEAK_REF]: Mark + pthread_self and pthread_equal as weak references. + +2005-01-13 Ken Raeburn <raeburn@mit.edu> + + * k5-thread.h (k5_os_mutex) [pthread case]: Add new field "owner" + if DEBUG_THREADS. + (k5_pthread_mutex_lock, k5_pthread_mutex_unlock, + k5_pthread_assert_locked): New macros/functions; if DEBUG_THREADS, + and thread support loaded, set or check the owner field. + (K5_OS_MUTEX_PARTIAL_INITIALIZER) [pthread case && DEBUG_THREADS]: + Set the owner field. If PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP + is defined, use it. + (k5_os_mutex_lock, k5_os_mutex_unlock, k5_os_mutex_assert_locked) + [pthread case]: Use k5_pthread_ versions. + (k5_mutex_destroy): Update the location data with the mutex + locked, before destroying it. + (k5_mutex_unlock): Update the location data while the mutex is + still locked, and check the assertion that the mutex really is + locked. Convert inline function to macro. + + * k5-thread.h (krb5int_mutex_lock_update_stats, + krb5int_mutex_unlock_update_stats, krb5int_mutex_report_stats) + [!DEBUG_THREADS_STATS]: Declare KRB5_CALLCONV. + +2005-01-04 Jeffrey Altman <jaltman@mit.edu> + + * krb5.hin: add prototype for krb5_is_thread_safe + +2004-12-21 Tom Yu <tlyu@mit.edu> + + * krb5.hin: Flag krb5_principal2salt as KRB5_CALLCONV_WRONG. + +2004-12-08 Ken Raeburn <raeburn@mit.edu> + + * k5-int.h (KRB5INT_ACCESS_STRUCT_VERSION): Bump to 9. + (struct _krb5int_access): Add function pointer field use_dns_kdc. + +2004-10-29 Ken Raeburn <raeburn@mit.edu> + + * fake-addrinfo.h: Include errno.h earlier. + 2004-10-28 Ken Raeburn <raeburn@mit.edu> * k5-thread.h (return_after_yield, k5_mutex_lock) [__GNUC__]: Add diff --git a/src/include/configure.in b/src/include/configure.in index 071ff55..450eea5 100644 --- a/src/include/configure.in +++ b/src/include/configure.in @@ -98,6 +98,29 @@ if test "$ac_cv_func_getpwuid_r" = yes; then fi fi +if test "$ac_cv_func_gmtime_r" = yes; then + AC_MSG_CHECKING([whether gmtime_r returns int]) + AC_CACHE_VAL(krb5_cv_gmtime_r_returns_int, + [AC_TRY_COMPILE([#include <time.h> + extern int gmtime_r ();], [1;], return_int=yes, return_int=no) + AC_TRY_COMPILE([#include <time.h> + extern struct tm *gmtime_r ();], [1;], return_ptr=yes, return_ptr=no) + case $return_int/$return_ptr in + yes/no) krb5_cv_gmtime_r_returns_int=yes ;; + no/yes) krb5_cv_gmtime_r_returns_int=no ;; + *) # Can't figure it out, punt the function. + ac_cv_func_gmtime_r=no ;; + esac]) + if test "$ac_cv_func_gmtime_r" = no; then + AC_MSG_RESULT(unknown -- ignoring gmtime_r) + else + AC_MSG_RESULT($krb5_cv_gmtime_r_returns_int) + if test "$krb5_cv_gmtime_r_returns_int" = yes; then + AC_DEFINE(GMTIME_R_RETURNS_INT,1,[Define if gmtime_r returns int instead of struct tm pointer, as on old HP-UX systems.]) + fi + fi +fi + AC_CHECK_FUNC(getservbyname_r,[ ac_cv_func_getservbyname_r=yes if test "$ac_cv_func_getservbyname_r" = yes; then diff --git a/src/include/fake-addrinfo.h b/src/include/fake-addrinfo.h index cc23a3f..9ed8d40 100644 --- a/src/include/fake-addrinfo.h +++ b/src/include/fake-addrinfo.h @@ -105,6 +105,7 @@ #include "k5-thread.h" #include <stdio.h> /* for sprintf */ +#include <errno.h> #ifdef S_SPLINT_S /*@-incondefs@*/ @@ -967,7 +968,6 @@ fake_getaddrinfo (const char *name, const char *serv, } #ifdef NEED_FAKE_GETNAMEINFO -#include <errno.h> static inline int fake_getnameinfo (const struct sockaddr *sa, socklen_t len, char *host, socklen_t hostlen, @@ -1058,7 +1058,6 @@ fake_getnameinfo (const struct sockaddr *sa, socklen_t len, } #endif -#include <errno.h> #if defined(HAVE_FAKE_GETADDRINFO) || defined(NEED_FAKE_GETNAMEINFO) static inline diff --git a/src/include/k5-int.h b/src/include/k5-int.h index 3373a65..8d2262a 100644 --- a/src/include/k5-int.h +++ b/src/include/k5-int.h @@ -1672,7 +1672,7 @@ void krb5int_free_srv_dns_data(struct srv_dns_entry *); /* To keep happy libraries which are (for now) accessing internal stuff */ /* Make sure to increment by one when changing the struct */ -#define KRB5INT_ACCESS_STRUCT_VERSION 8 +#define KRB5INT_ACCESS_STRUCT_VERSION 9 #ifndef ANAME_SZ struct ktext; /* from krb.h, for krb524 support */ @@ -1704,6 +1704,7 @@ typedef struct _krb5int_access { const char *protocol, struct srv_dns_entry **answers); void (*free_srv_dns_data)(struct srv_dns_entry *); + int (*use_dns_kdc)(krb5_context); /* krb4 compatibility stuff -- may be null if not enabled */ krb5_int32 (*krb_life_to_time)(krb5_int32, int); diff --git a/src/include/k5-platform.h b/src/include/k5-platform.h index e0793f6..b178622 100644 --- a/src/include/k5-platform.h +++ b/src/include/k5-platform.h @@ -44,14 +44,23 @@ At top level, before the functions are defined or even declared: MAKE_INIT_FUNCTION(init_fn); MAKE_FINI_FUNCTION(fini_fn); + Then: int init_fn(void) { ... } void fini_fn(void) { if (INITIALIZER_RAN(init_fn)) ... } - In code, in the same file: err = CALL_INIT_FUNCTION(init_fn); To trigger or verify the initializer invocation from another file, - an additional function must be created. + a helper function must be created. + + This model handles both the load-time execution (Windows) and + delayed execution (pthread_once) approaches, and should be able to + guarantee in both cases that the init function is run once, in one + thread, before other stuff in the library is done; furthermore, the + finalization code should only run if the initialization code did. + (Maybe I could've made the "if INITIALIZER_RAN" test implicit, via + another function hidden in macros, but this is hairy enough + already.) The init_fn and fini_fn names should be chosen such that any exported names staring with those names, and optionally followed by @@ -59,6 +68,21 @@ the library in question. + There's also PROGRAM_EXITING() currently always defined as zero. + If there's some trivial way to find out if the fini function is + being called because the program that the library is linked into is + exiting, we can just skip all the work because the resources are + about to be freed up anyways. Generally this is likely to be the + same as distinguishing whether the library was loaded dynamically + while the program was running, or loaded as part of program + startup. On most platforms, I don't think we can distinguish these + cases easily, and it's probably not worth expending any significant + effort. (Note in particular that atexit() won't do, because if the + library is explicitly loaded and unloaded, it would have to be able + to deregister the atexit callback function. Also, the system limit + on atexit callbacks may be small.) + + Implementation outline: Windows: MAKE_FINI_FUNCTION creates a symbol with a magic name that @@ -78,6 +102,11 @@ just check the flag) and returns the stored error code (or the pthread_once error). + (That's the basic idea. With some debugging assert() calls and + such, it's a bit more complicated. And we also need to handle + doing the pthread test at run time on systems where that works, so + we use the k5_once_t stuff instead.) + UNIX, with compiler support: MAKE_FINI_FUNCTION declares the function as a destructor, and the run time linker support or whatever will cause it to be invoked when the library is unloaded, @@ -91,12 +120,20 @@ UNIX, no library finalization support: The finalization function never runs, and we leak memory. Tough. + DELAY_INITIALIZER will be defined by the configure script if we + want to use k5_once instead of load-time initialization. That'll + be the preferred method on most systems except Windows, where we + have to initialize some mutexes. + + For maximum flexibility in defining the macros, the function name parameter should be a simple name, not even a macro defined as another name. The function should have a unique name, and should conform to whatever namespace is used by the library in question. + (We do have export lists, but (1) they're not used for all + platforms, and (2) they're not used for static libraries.) If the macro expansion needs the function to have been declared, it must include a declaration. If it is not necessary for the symbol @@ -110,7 +147,8 @@ This is going to be compiler- and environment-specific, and may require some support at library build time, and/or "asm" - statements. + statements. But through macro expansion and auxiliary functions, + we should be able to handle most things except #pragma. It's okay for this code to require that the library be built with the same compiler and compiler options throughout, but @@ -129,7 +167,12 @@ work, we'll only have memory leaks in a load/use/unload cycle. If anyone (like, say, the OS vendor) complains about this, they can tell us how to get a shared library finalization function invoked - automatically. */ + automatically. + + Currently there's --disable-delayed-initialization for preventing + the initialization from being delayed on UNIX, but that's mainly + just for testing the linker options for initialization, and will + probably be removed at some point. */ /* Helper macros. */ @@ -194,8 +237,11 @@ static inline int k5_call_init_function(k5_init_t *i) multiple active threads mucking around in our library at this point. So ignore the once_t object and just look at the flag. - XXX Could we have problems with memory coherence between - processors if we don't invoke mutex/once routines? */ + XXX Could we have problems with memory coherence between processors + if we don't invoke mutex/once routines? Probably not, the + application code should already be coordinating things such that + the library code is not in use by this point, and memory + synchronization will be needed there. */ # define INITIALIZER_RAN(NAME) \ (JOIN__2(NAME, once).did_run && JOIN__2(NAME, once).error == 0) @@ -206,6 +252,7 @@ static inline int k5_call_init_function(k5_init_t *i) /* Run initializer at load time, via GCC/C++ hook magic. */ # ifdef USE_LINKER_INIT_OPTION + /* Both gcc and linker option?? Favor gcc. */ # define MAYBE_DUMMY_INIT(NAME) \ void JOIN__2(NAME, auxinit) () { } # else @@ -232,6 +279,8 @@ typedef struct { int error; unsigned char did_run; } k5_init_t; : (abort(),0)) # define INITIALIZER_RAN(NAME) (JOIN__2(NAME,ran).did_run == 3 && JOIN__2(NAME, ran).error == 0) +# define PROGRAM_EXITING() (0) + #elif defined(USE_LINKER_INIT_OPTION) || defined(_WIN32) /* Run initializer at load time, via linker magic, or in the @@ -271,9 +320,35 @@ typedef struct { int error; unsigned char did_run; } k5_init_t; matter what compiler we're using. Do it the same way regardless. */ -# define MAKE_FINI_FUNCTION(NAME) \ +# ifdef __hpux + + /* On HP-UX, we need this auxiliary function. At dynamic load or + unload time (but *not* program startup and termination for + link-time specified libraries), the linker-indicated function + is called with a handle on the library and a flag indicating + whether it's being loaded or unloaded. + + The "real" fini function doesn't need to be exported, so + declare it static. + + As usual, the final declaration is just for syntactic + convenience, so the top-level invocation of this macro can be + followed by a semicolon. */ + +# include <dl.h> +# define MAKE_FINI_FUNCTION(NAME) \ + static void NAME(void); \ + void JOIN__2(NAME, auxfini)(shl_t, int); /* silence gcc warnings */ \ + void JOIN__2(NAME, auxfini)(shl_t h, int l) { if (!l) NAME(); } \ + static void NAME(void) + +# else /* not hpux */ + +# define MAKE_FINI_FUNCTION(NAME) \ void NAME(void) +# endif + #elif defined(__GNUC__) && defined(DESTRUCTOR_ATTR_WORKS) /* If we're using gcc, if the C++ support works, the compiler should build executables and shared libraries that support the use of diff --git a/src/include/k5-thread.h b/src/include/k5-thread.h index 5fecf08..9ac5219 100644 --- a/src/include/k5-thread.h +++ b/src/include/k5-thread.h @@ -301,7 +301,7 @@ static inline int k5_os_nothread_mutex_unlock(k5_os_nothread_mutex *m) { return 0; } # define k5_os_nothread_mutex_assert_locked(M) ((void)0) -# define k5_os_nothread_mutex_assert_unlocked(M) ((void(0) +# define k5_os_nothread_mutex_assert_unlocked(M) ((void)0) #endif @@ -367,6 +367,8 @@ typedef k5_os_nothread_mutex k5_os_mutex; # pragma weak pthread_mutex_unlock # pragma weak pthread_mutex_destroy # pragma weak pthread_mutex_init +# pragma weak pthread_self +# pragma weak pthread_equal # ifdef HAVE_PTHREAD_MUTEXATTR_SETROBUST_NP_IN_THREAD_LIB # pragma weak pthread_mutexattr_setrobust_np # endif @@ -423,17 +425,53 @@ typedef pthread_once_t k5_once_t; typedef struct { pthread_mutex_t p; +#ifdef DEBUG_THREADS + pthread_t owner; +#endif #ifdef USE_PTHREAD_LOCK_ONLY_IF_LOADED k5_os_nothread_mutex n; #endif } k5_os_mutex; +#ifdef DEBUG_THREADS +# ifdef __GNUC__ +# define k5_pthread_mutex_lock(M) \ + ({ \ + k5_os_mutex *_m2 = (M); \ + int _r2 = pthread_mutex_lock(&_m2->p); \ + if (_r2 == 0) _m2->owner = pthread_self(); \ + _r2; \ + }) +# else +static inline int +k5_pthread_mutex_lock(k5_os_mutex *m) +{ + int r = pthread_mutex_lock(&m->p); + if (r) + return r; + m->owner = pthread_self(); + return 0; +} +# endif +# define k5_pthread_assert_locked(M) \ + (K5_PTHREADS_LOADED \ + ? assert(pthread_equal((M)->owner, pthread_self())) \ + : (void)0) +# define k5_pthread_mutex_unlock(M) \ + (k5_pthread_assert_locked(M), \ + (M)->owner = (pthread_t) 0, \ + pthread_mutex_unlock(&(M)->p)) +#else +# define k5_pthread_mutex_lock(M) pthread_mutex_lock(&(M)->p) +static inline void k5_pthread_assert_locked(k5_os_mutex *m) { } +# define k5_pthread_mutex_unlock(M) pthread_mutex_unlock(&(M)->p) +#endif + /* Define as functions to: (1) eliminate "statement with no effect" warnings for "0" (2) encourage type-checking in calling code */ static inline void k5_pthread_assert_unlocked(pthread_mutex_t *m) { } -static inline void k5_pthread_assert_locked(pthread_mutex_t *m) { } #if defined(DEBUG_THREADS_SLOW) && HAVE_SCHED_H && (HAVE_SCHED_YIELD || HAVE_PRAGMA_WEAK_REF) # include <sched.h> @@ -481,8 +519,18 @@ static inline int return_after_yield(int r) #ifdef USE_PTHREAD_LOCK_ONLY_IF_LOADED -# define K5_OS_MUTEX_PARTIAL_INITIALIZER \ +# if defined(PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP) && defined(DEBUG_THREADS) +# define K5_OS_MUTEX_PARTIAL_INITIALIZER \ + { PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP, (pthread_t) 0, \ + K5_OS_NOTHREAD_MUTEX_PARTIAL_INITIALIZER } +# elif defined(DEBUG_THREADS) +# define K5_OS_MUTEX_PARTIAL_INITIALIZER \ + { PTHREAD_MUTEX_INITIALIZER, (pthread_t) 0, \ + K5_OS_NOTHREAD_MUTEX_PARTIAL_INITIALIZER } +# else +# define K5_OS_MUTEX_PARTIAL_INITIALIZER \ { PTHREAD_MUTEX_INITIALIZER, K5_OS_NOTHREAD_MUTEX_PARTIAL_INITIALIZER } +# endif # define k5_os_mutex_finish_init(M) \ k5_os_nothread_mutex_finish_init(&(M)->n) @@ -499,12 +547,12 @@ static inline int return_after_yield(int r) # define k5_os_mutex_lock(M) \ return_after_yield(K5_PTHREADS_LOADED \ - ? pthread_mutex_lock(&(M)->p) \ + ? k5_pthread_mutex_lock(M) \ : k5_os_nothread_mutex_lock(&(M)->n)) # define k5_os_mutex_unlock(M) \ (MAYBE_SCHED_YIELD(), \ (K5_PTHREADS_LOADED \ - ? pthread_mutex_unlock(&(M)->p) \ + ? k5_pthread_mutex_unlock(M) \ : k5_os_nothread_mutex_unlock(&(M)->n))) # define k5_os_mutex_assert_unlocked(M) \ @@ -513,22 +561,32 @@ static inline int return_after_yield(int r) : k5_os_nothread_mutex_assert_unlocked(&(M)->n)) # define k5_os_mutex_assert_locked(M) \ (K5_PTHREADS_LOADED \ - ? k5_pthread_assert_locked(&(M)->p) \ + ? k5_pthread_assert_locked(M) \ : k5_os_nothread_mutex_assert_locked(&(M)->n)) #else -# define K5_OS_MUTEX_PARTIAL_INITIALIZER \ +# ifdef DEBUG_THREADS +# ifdef PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP +# define K5_OS_MUTEX_PARTIAL_INITIALIZER \ + { PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP, (pthread_t) 0 } +# else +# define K5_OS_MUTEX_PARTIAL_INITIALIZER \ + { PTHREAD_MUTEX_INITIALIZER, (pthread_t) 0 } +# endif +# else +# define K5_OS_MUTEX_PARTIAL_INITIALIZER \ { PTHREAD_MUTEX_INITIALIZER } +# endif static inline int k5_os_mutex_finish_init(k5_os_mutex *m) { return 0; } # define k5_os_mutex_init(M) pthread_mutex_init(&(M)->p, 0) # define k5_os_mutex_destroy(M) pthread_mutex_destroy(&(M)->p) -# define k5_os_mutex_lock(M) return_after_yield(pthread_mutex_lock(&(M)->p)) -# define k5_os_mutex_unlock(M) (MAYBE_SCHED_YIELD(),pthread_mutex_unlock(&(M)->p)) +# define k5_os_mutex_lock(M) return_after_yield(k5_pthread_mutex_lock(M)) +# define k5_os_mutex_unlock(M) (MAYBE_SCHED_YIELD(),k5_pthread_mutex_unlock(M)) # define k5_os_mutex_assert_unlocked(M) k5_pthread_assert_unlocked(&(M)->p) -# define k5_os_mutex_assert_locked(M) k5_pthread_assert_locked(&(M)->p) +# define k5_os_mutex_assert_locked(M) k5_pthread_assert_locked(M) #endif /* is pthreads always available? */ @@ -614,7 +672,7 @@ static inline int k5_mutex_finish_init_1(k5_mutex_t *m, k5_debug_loc l) #define k5_mutex_finish_init(M) k5_mutex_finish_init_1((M), K5_DEBUG_LOC) #define k5_mutex_destroy(M) \ (k5_os_mutex_assert_unlocked(&(M)->os), \ - (M)->loc_last = K5_DEBUG_LOC, \ + k5_mutex_lock(M), (M)->loc_last = K5_DEBUG_LOC, k5_mutex_unlock(M), \ k5_os_mutex_destroy(&(M)->os)) #ifdef __GNUC__ #define k5_mutex_lock(M) \ @@ -637,16 +695,10 @@ static inline int k5_mutex_lock_1(k5_mutex_t *m, k5_debug_loc l) } #define k5_mutex_lock(M) k5_mutex_lock_1(M, K5_DEBUG_LOC) #endif -static inline int k5_mutex_unlock_1(k5_mutex_t *m, k5_debug_loc l) -{ - int err = 0; - err = k5_os_mutex_unlock(&m->os); - if (err) - return err; - m->loc_last = l; - return err; -} -#define k5_mutex_unlock(M) k5_mutex_unlock_1(M, K5_DEBUG_LOC) +#define k5_mutex_unlock(M) \ + (k5_mutex_assert_locked(M), \ + (M)->loc_last = K5_DEBUG_LOC, \ + k5_os_mutex_unlock(&(M)->os)) #define k5_mutex_assert_locked(M) k5_os_mutex_assert_locked(&(M)->os) #define k5_mutex_assert_unlocked(M) k5_os_mutex_assert_unlocked(&(M)->os) diff --git a/src/include/krb5.hin b/src/include/krb5.hin index 58fbfaa..46f3a14 100644 --- a/src/include/krb5.hin +++ b/src/include/krb5.hin @@ -1369,6 +1369,8 @@ krb5_boolean krb5_is_permitted_enctype (krb5_context, krb5_enctype); #endif +krb5_boolean KRB5_CALLCONV krb5_is_thread_safe(void); + /* libkrb.spec */ #if KRB5_PRIVATE krb5_error_code krb5_kdc_rep_decrypt_proc @@ -1656,7 +1658,7 @@ krb5_error_code KRB5_CALLCONV krb5_kt_add_entry (krb5_context, krb5_keytab, krb5_keytab_entry * ); -krb5_error_code krb5_principal2salt +krb5_error_code KRB5_CALLCONV_WRONG krb5_principal2salt (krb5_context, krb5_const_principal, krb5_data *); #if KRB5_PRIVATE diff --git a/src/include/win-mac.h b/src/include/win-mac.h index 353d2be..0b58a9c 100644 --- a/src/include/win-mac.h +++ b/src/include/win-mac.h @@ -77,6 +77,7 @@ typedef unsigned char u_char; /* if __STDC_VERSION__ >= 199901L this shouldn't be needed */ #define inline __inline #define KRB5_USE_INET6 +#define NEED_INSIXADDR_ANY #define ENABLE_THREADS #define WM_KERBEROS5_CHANGED "Kerberos5 Changed" diff --git a/src/kadmin/cli/ChangeLog b/src/kadmin/cli/ChangeLog index 1fe06ba..1e2ef44 100644 --- a/src/kadmin/cli/ChangeLog +++ b/src/kadmin/cli/ChangeLog @@ -1,3 +1,10 @@ +2005-02-11 Tom Yu <tlyu@mit.edu> + + * kadmin.c (kadmin_startup): New flag "-N" to prevent fallback to + AUTH_GSSAPI. + + * kadmin.M: Describe "-O" and "-N" flags. + 2004-09-17 Tom Yu <tlyu@mit.edu> * Makefile.in (install): Use $(INSTALL_SCRIPT) for scripts. diff --git a/src/kadmin/cli/kadmin.M b/src/kadmin/cli/kadmin.M index a35106c..d9d6abd 100644 --- a/src/kadmin/cli/kadmin.M +++ b/src/kadmin/cli/kadmin.M @@ -5,6 +5,7 @@ kadmin \- Kerberos V5 database administration program .TP .B kadmin .ad l +[\fB\-O\fP | \fB\-N\fP] [\fB\-r\fP \fIrealm\fP] [\fB\-p\fP \fIprincipal\fP] [\fB\-q\fP \fIquery\fP] .br [[\fB-c\fP \fIcache_name\fP] | [\fB-k\fP [\fB-t\fP @@ -140,7 +141,12 @@ to prompt for the master database password. \fB\-e\fP \fIenc:salt_list\fP Sets the list of encryption types and salt types to be used for any new keys created. - +.TP +.B \-O +Force use of old AUTH_GSSAPI authentication flavor. +.TP +.B \-N +Prevent fallback to AUTH_GSSAPI authentication flavor. .SH DATE FORMAT Various commands in kadmin can take a variety of date formats, specifying durations or absolute times. Examples of valid formats are: diff --git a/src/kadmin/cli/kadmin.c b/src/kadmin/cli/kadmin.c index 9b9294d..957659d 100644 --- a/src/kadmin/cli/kadmin.c +++ b/src/kadmin/cli/kadmin.c @@ -193,7 +193,7 @@ char *kadmin_startup(argc, argv) exit(1); } - while ((optchar = getopt(argc, argv, "r:p:kq:w:d:s:mc:t:e:O")) != EOF) { + while ((optchar = getopt(argc, argv, "r:p:kq:w:d:s:mc:t:e:ON")) != EOF) { switch (optchar) { case 'r': def_realm = optarg; @@ -244,6 +244,9 @@ char *kadmin_startup(argc, argv) case 'O': params.mask |= KADM5_CONFIG_OLD_AUTH_GSSAPI; break; + case 'N': + params.mask |= KADM5_CONFIG_AUTH_NOFALLBACK; + break; default: usage(); } diff --git a/src/kadmin/testing/util/ChangeLog b/src/kadmin/testing/util/ChangeLog index 868eeb9..f34d8f8 100644 --- a/src/kadmin/testing/util/ChangeLog +++ b/src/kadmin/testing/util/ChangeLog @@ -1,3 +1,8 @@ +2005-02-10 Tom Yu <tlyu@mit.edu> + + * tcl_kadm5.c (unparse_err): Add entries for KRB5_CC_NOTFOUND and + KRB5_FCC_NOFILE, to handle changes in client_init.c. + 2004-07-28 Ken Raeburn <raeburn@mit.edu> * tcl_kadm5.c (parse_flags, parse_keysalts, parse_key_data, diff --git a/src/kadmin/testing/util/tcl_kadm5.c b/src/kadmin/testing/util/tcl_kadm5.c index 21e029b..a6b9452 100644 --- a/src/kadmin/testing/util/tcl_kadm5.c +++ b/src/kadmin/testing/util/tcl_kadm5.c @@ -410,6 +410,9 @@ static Tcl_DString *unparse_err(kadm5_ret_t code) case KRB5KDC_ERR_C_PRINCIPAL_UNKNOWN: code_string = "KRB5KDC_ERR_C_PRINCIPAL_UNKNOWN"; break; case KRB5_CONFIG_BADFORMAT: code_string = "KRB5_CONFIG_BADFORMAT"; break; + case KRB5_CC_NOTFOUND: code_string = "KRB5_CC_NOTFOUND"; break; + case KRB5_FCC_NOFILE: code_string = "KRB5_FCC_NOFILE"; break; + case EINVAL: code_string = "EINVAL"; break; case ENOENT: code_string = "ENOENT"; break; diff --git a/src/krb5-config.in b/src/krb5-config.in index 5ae2410..b0d8c0c 100644 --- a/src/krb5-config.in +++ b/src/krb5-config.in @@ -212,7 +212,7 @@ if test -n "$do_libs"; then fi if test $library = 'krb5'; then - lib_flags="$lib_flags -lkrb5 -lk5crypto -lcom_err $LIBS $GEN_LIB" + lib_flags="$lib_flags -lkrb5 -lk5crypto -lkrb5support -lcom_err $LIBS $GEN_LIB" fi echo $lib_flags diff --git a/src/lib/.cvsignore b/src/lib/.cvsignore index 31ed3b0..2a089b4 100644 --- a/src/lib/.cvsignore +++ b/src/lib/.cvsignore @@ -1 +1 @@ -krb5support32.def +k5sprt32.def diff --git a/src/lib/ChangeLog b/src/lib/ChangeLog index d8ddd19..a31df26 100644 --- a/src/lib/ChangeLog +++ b/src/lib/ChangeLog @@ -1,3 +1,20 @@ +2005-02-16 Jeffrey Altman <jaltman@mit.edu> + + * gssapi32.def: export the missing DATA symbols + +2005-01-03 Jeffrey Altman <jaltman@mit.edu> + + * krb5_32.def: export krb5_is_thread_safe() + +2004-12-18 Jeffrey Altman <jaltman@mit.edu> + + * krb5_32.def: mark krb5_principal2salt as using the wrong + calling convention. + +2004-12-15 Jeffrey Altman <jaltman@mit.edu> + + *.cvsignore, Makefile.in: rename krb5support32.def to k5sprt32.def + 2004-09-24 Tom Yu <tlyu@mit.edu> * Makefile.in (RCFLAGS): Add -I$(SRCTOP) to get patchlevel.h. diff --git a/src/lib/Makefile.in b/src/lib/Makefile.in index 909fadc..67867c7 100644 --- a/src/lib/Makefile.in +++ b/src/lib/Makefile.in @@ -28,7 +28,7 @@ clean-windows:: ##MIT##MITLIBS=$(VS_LIB) ##MIT##MITFLAGS=-I$(VS_INC) /DVERSERV=1 -SLIBS = $(BUILDTOP)\util\support\$(OUTPRE)krb5support_32.lib +SLIBS = $(BUILDTOP)\util\support\$(OUTPRE)k5sprt32.lib CLIBS = $(BUILDTOP)\util\et\$(OUTPRE)comerr.lib PLIBS = $(BUILDTOP)\util\profile\$(OUTPRE)profile.lib KLIBS = krb5\$(OUTPRE)krb5.lib crypto\$(OUTPRE)crypto.lib \ @@ -37,7 +37,7 @@ KLIBS = krb5\$(OUTPRE)krb5.lib crypto\$(OUTPRE)crypto.lib \ GLIBS = gssapi\$(OUTPRE)gssapi.lib K4LIBS = krb4\$(OUTPRE)krb4.lib -SDEF = krb5support32.def +SDEF = k5sprt32.def CDEF = comerr32.def PDEF = xpprof32.def KDEF = krb5_32.def diff --git a/src/lib/crypto/ChangeLog b/src/lib/crypto/ChangeLog index c283504..fa03524 100644 --- a/src/lib/crypto/ChangeLog +++ b/src/lib/crypto/ChangeLog @@ -1,3 +1,45 @@ +2005-03-15 Jeffrey Altman <jaltman@mit.edu> + + * keyed_cksum.c: (krb5_c_is_keyed_cksum): this is a boolean + function. It should not return -1U on error. Instead return + 0 (false) so that the caller doesn't think it succeeded. + + The only two callers are rd_safe and mk_safe. Neither checks + for special cases. + +2005-01-13 Ken Raeburn <raeburn@mit.edu> + + * prng.c (krb5int_prng_init): Incorporate do_yarrow_init body. + Don't check inited variable. + (inited): Variable deleted. + (krb5_c_random_make_octets, krb5int_prng_cleanup): Don't check + it. + (do_yarrow_init): Deleted. + +2005-01-12 Tom Yu <tlyu@mit.edu> + + * prng.c (read_entropy_from_device): Use ssize_t, not size_t, so + read() returning -1 doesn't cause trouble. + +2004-11-17 Ken Raeburn <raeburn@mit.edu> + + * prng.c (do_yarrow_init): Move mutex initialization here. + (krb5int_prng_init): Don't do it here. + +2004-11-15 Sam Hartman <hartmans@mit.edu> + + * t_prng.expected t_prng.reseedtest-expected : Update expected + PRNG test output and confirm that reseeds and gates happen correctly. + +2004-10-29 Ken Raeburn <raeburn@mit.edu> + + * prng.c (yarrow_lock): Rename to krb5int_yarrow_lock via macro, + and change to be non-static. + (krb5int_prng_init): Call do_yarrow_init here. + (krb5_c_random_add_entropy): Don't call it here. Don't lock the + mutex, either. + (krb5_c_random_make_octets): Don't lock the mutex. + 2004-06-16 Ken Raeburn <raeburn@mit.edu> * Makefile.in (MAC_SUBDIRS): Don't set. diff --git a/src/lib/crypto/keyed_cksum.c b/src/lib/crypto/keyed_cksum.c index 7056f8f..4d50c2c 100644 --- a/src/lib/crypto/keyed_cksum.c +++ b/src/lib/crypto/keyed_cksum.c @@ -45,7 +45,7 @@ krb5_c_is_keyed_cksum(krb5_cksumtype ctype) /* ick, but it's better than coredumping, which is what the old code would have done */ - return -1U; + return 0; /* error case */ } krb5_boolean KRB5_CALLCONV diff --git a/src/lib/crypto/prng.c b/src/lib/crypto/prng.c index f9ea869..54a68e0 100644 --- a/src/lib/crypto/prng.c +++ b/src/lib/crypto/prng.c @@ -30,8 +30,9 @@ #include "yarrow.h" static Yarrow_CTX y_ctx; -static int inited, init_error; -static k5_mutex_t yarrow_lock = K5_MUTEX_PARTIAL_INITIALIZER; +static int init_error; +#define yarrow_lock krb5int_yarrow_lock +k5_mutex_t yarrow_lock = K5_MUTEX_PARTIAL_INITIALIZER; /* Helper function to estimate entropy based on sample length * and where it comes from. @@ -58,30 +59,25 @@ return (0); int krb5int_prng_init(void) { - return k5_mutex_finish_init(&yarrow_lock); -} - -static void do_yarrow_init(void) -{ unsigned i; int yerr; + yerr = k5_mutex_finish_init(&yarrow_lock); + if (yerr) + return yerr; + yerr = krb5int_yarrow_init (&y_ctx, NULL); - if ((yerr != YARROW_OK) && (yerr != YARROW_NOT_SEEDED)) { - init_error = yerr; - return; - } + if ((yerr != YARROW_OK) && (yerr != YARROW_NOT_SEEDED)) + return KRB5_CRYPTO_INTERNAL; for (i=0; i < KRB5_C_RANDSOURCE_MAX; i++ ) { unsigned source_id; - if (krb5int_yarrow_new_source (&y_ctx, &source_id) != YARROW_OK ) { - init_error = 17; - return; - } + if (krb5int_yarrow_new_source (&y_ctx, &source_id) != YARROW_OK ) + return KRB5_CRYPTO_INTERNAL; assert (source_id == i); } - inited=1; - init_error = 0; + + return 0; } krb5_error_code KRB5_CALLCONV @@ -95,21 +91,11 @@ krb5_c_random_add_entropy (krb5_context context, unsigned int randsource, if (yerr) return yerr; /* Now, finally, feed in the data. */ - yerr = k5_mutex_lock(&yarrow_lock); - if (yerr) - return yerr; - if (!inited) - do_yarrow_init(); - if (init_error) { - k5_mutex_unlock(&yarrow_lock); - return KRB5_CRYPTO_INTERNAL; - } yerr = krb5int_yarrow_input (&y_ctx, randsource, data->data, data->length, entropy_estimate (randsource, data->length)); - k5_mutex_unlock(&yarrow_lock); if (yerr != YARROW_OK) - return (KRB5_CRYPTO_INTERNAL); + return (KRB5_CRYPTO_INTERNAL); return (0); } @@ -123,17 +109,12 @@ krb5_error_code KRB5_CALLCONV krb5_c_random_make_octets(krb5_context context, krb5_data *data) { int yerr; - assert (inited); - yerr = k5_mutex_lock(&yarrow_lock); - if (yerr) - return yerr; yerr = krb5int_yarrow_output (&y_ctx, data->data, data->length); if (yerr == YARROW_NOT_SEEDED) { yerr = krb5int_yarrow_reseed (&y_ctx, YARROW_SLOW_POOL); if (yerr == YARROW_OK) yerr = krb5int_yarrow_output (&y_ctx, data->data, data->length); } - k5_mutex_unlock(&yarrow_lock); if ( yerr != YARROW_OK) return (KRB5_CRYPTO_INTERNAL); return(0); @@ -141,10 +122,8 @@ krb5_c_random_make_octets(krb5_context context, krb5_data *data) void krb5int_prng_cleanup (void) { - if (inited) - krb5int_yarrow_final (&y_ctx); + krb5int_yarrow_final (&y_ctx); k5_mutex_destroy(&yarrow_lock); - inited = 0; } @@ -195,7 +174,7 @@ read_entropy_from_device (krb5_context context, const char *device) return 0; } for (left = sizeof (buf); left > 0;) { - size_t count; + ssize_t count; count = read (fd, &buf, (unsigned) left); if (count <= 0) { close(fd); diff --git a/src/lib/crypto/t_prng.expected b/src/lib/crypto/t_prng.expected index 70b8b5a..f7f1650 100644 --- a/src/lib/crypto/t_prng.expected +++ b/src/lib/crypto/t_prng.expected @@ -1,4 +1,4 @@ -18086b1e91f730facb2d6e1b -c562653b24814eb3651b1e68301a3c14b96302bb -6d017f7aef74662ed8dd51eef14281eaad223298db370bfaca -30c04231cb3de404e4b8a5359a74066fd963291d7986be835834ab07870c097682a953bfff38784780eef844de47fb36c34f8e034c96cfa64d9cb5decee472138236e9fb79e9fe1fba6b7757b970f22477d167832206900473f09f3e8c822db6d9a8273340ed6743d99638d6cf192d821b6f33d23278b1a929f303a80865c426d01add11b2f2416babd13e70b44d8eeb731c09c7163af9d1a23cbe20ddb08b0f67ecaa2eed511263a67e9c12e59ef113f0b9e4e4e140b43896078a7571c61826ba099b3dd8c4b096a9785b4434e97ea99e662ba6fdb60a41547ccae4c67d3e1f3ef515198e91f009c75c9e80fda90d13ee29d8aad5d87cc2437ce60e6ce55700837fb0815bfd2495f8aa1a33fe67c1ae28a885506a78ca6257f5a5f2a8042e28680acc83b1aecb3a9cb51911126f2f0deaf14fcfa5f165e9a5c3f8f2d1c3f4683b2d75927a7bc802d63b680a5e22768cc0439854ccd49e58a002794f541bddd6ef6fbd4f9869843a72d0ae9d438c90353a46c0c9863a16b1de206c717ab7ce6ea6f648a38efa12b70bbe3388b35adec7a789ea98de217520d7d6ce699841e17e5946bf5a8b3c7a2c3e2d6767422baf3159ff08d913ec78011ab7d34bc24af26c24a8d46f7261c7705a7b270e27590c29583c659a0df8dada4e7a0532f115040165d18f74a55a4f39bb1dcfd865e94a488ca910cc447e121b2a19450239e75d24 +d2f8fbd707a8ece5cb11a02f +eb4cb6e06236ea1c0529f7acbfca8d78cb85bb1d +a244005ae870604342b0386025874ec4306c1dd483c118621b +63e6408afdf9fd225839a7afcc6da6ae494fb4f82bd21ea06bb17ca0848bdae8cea671f545aac52699951caba960c536024b4102f47d61d61fd7b17582a4cf50ba7d215062558f71483249e079689893f3bf25def7f45f9e852281269904d401d6719e3115f6410088c6c5171e878494362684d2116633bb9ea8d9ed5faec73cb076c44d5d639bc2c8ae3de54f0e1e092d5ea439e607e9cd73053bbdf40723f5b48f298fdeeef845e22e06f2f6362fc67fba366e638a7988999d456dcc3d53b23388d685620a7c446d28cd94b13049761b64779db5412e78ac4bab2aacf103fd1b9ceb7213d43710d6a46fd4223fa20e0a68d3e16a82cbadea650ba815dc9ee99b4eb8e2acdac866a05d90ab9de3246db0560fb4b36633bb642c3ea9bf358937dda743f9cef1148791c2cac58995b8eb8fdb1c0cce1686e04ebef5ae7aae36691faafbe8920d3c013f125b687eb019faefa70fc750c52e2e2e33f426824bf1da31268a9bb8d9501f2290375755f8bf77b46639346b4011b78ce9d81105c7791ec5991a2f1eab037488b604df1a21c5c4e36a7c76dca5884d36e30fe8d30d0e7d93fab72062219390655eace2b434b0e2cd21ec9c5a8aa13e783afadcdf386fc43b960c518acb38d7e3da2f67695c1c1c25c4f251b40f4c2e42e89f6f642c32e66159f6ce24aa910fb5d95e3a899a4de5efcf570996e1a662d14362b65d00524df79cd56be93bd572526e4dfd1cf9f7586bc021105cf5456b28c1f45a6d354d000a113e15f64aa0b5253830c07afc8fa47b58dbba8bbae1645b2093035f2387036229dec6f7141b444b8bb7d0382a742bd5c746ba2d7af3af1cadb2dd90bda87d5daed2d2eebd243c7b2d06955d0cc7fe1061d4cfa3b061aaeb97084d9f9a7ec9dbe9e642f4f090d57b5ea1bd8b393f00896d3dc7089e1fc4c2fed7336c2a8c6d119a682c6cc4ae1ccedd30292f2c5570bf4d6287ce8e20b8b34e7fc38e87273f588cd33b8c913defaee5f6bf8fdeda72531c845a6f97a84d5e9b9a6497d4c48614dee7693df35faedc008fded852be8d4bffd475476336e54ed48a827b99d3f0e39019a40d43aef5ae522ec6e280f6a8e7d2713f3c3188bed2476a84af5a5afefa0fa178ed07de0e073693e8790f8bbd0cf9183e48f140b556e723565c382cf7a4c186748189a14e603e4ac70e2b80c266334231207721d16d834a973b48cfec584620624686603cfd66d55dbf8dd8eccd99d85f041c624ec3a7bec314af95d2313afd43cc5cc19249cf85b7ab0b5a4530b597341e7477b249fef1a07eb0d8fa790e9bce752e8b2f7086e98ab44751e0a1b37f29682ce67c0de7a2fd036f26ed719fc343bbf49432aec651d884c99c24d5943c747f7ec3b48d4c2236a8cb6151794daeda073774cc88ff121fdd423b81ef2f34c8f281ca2e5366faee87ff7a623484f2937cc0680ed76ead32b43cb6c67a21f8089b435f38a404d267397c6435cfac16591a3573d9e92f8c4a8028719c22662b903ddb16e08ea7bb2d6b8938c06bdddb4d174c7f2c5d812ed3a34ba8859a1ae841b3b9d5522372018c9aa55b048df826f05a087f185808cb66899f320783a1c4aa2dcd5f2665405ba7e5726e122b67559a39da30956e49fe7711d1b2506e159c5ea42ce0a1ad497220ee3b3e5ebcb73db975bd08e8be56e5f4533b8295b10d4b0fef466de6540f8fe10530c9716d83a12f5ffbba5b4dbc50ed89388d04e7a15d3d9d251041ed5303efa2525bc62a5aeb821f7838676811784584534be8a7fc667f09c3fe1bbf7d0aad29324f562086ecb8326829413867 diff --git a/src/lib/crypto/t_prng.reseedtest-expected b/src/lib/crypto/t_prng.reseedtest-expected index af9b02b..d7b5080 100644 --- a/src/lib/crypto/t_prng.reseedtest-expected +++ b/src/lib/crypto/t_prng.reseedtest-expected @@ -1 +1 @@ -7a2f63cdd9b0bfae94b75ee554be49ff8e7bc82e +fd543f42aded9bd725c9b05682cd0f504c1b33d1 diff --git a/src/lib/crypto/t_prng.seed b/src/lib/crypto/t_prng.seed index 0b3c703..79f4f64 100644 --- a/src/lib/crypto/t_prng.seed +++ b/src/lib/crypto/t_prng.seed @@ -22,4 +22,4 @@ de 7c f0 c5 6a 37 0b 34 f4 0c 3a 19 31 eb 66 f1 ae 5f c6 a3 64 3f 2e a9 76 e1 87 93 df b6 94 86 bd 96 57 3f 31 e6 88 8c -512 +1290 diff --git a/src/lib/crypto/yarrow/ChangeLog b/src/lib/crypto/yarrow/ChangeLog index 38d6fe7..cf08dc9 100644 --- a/src/lib/crypto/yarrow/ChangeLog +++ b/src/lib/crypto/yarrow/ChangeLog @@ -1,3 +1,47 @@ +2005-01-13 Ken Raeburn <raeburn@mit.edu> + + * yarrow.c (yarrow_reseed_locked): Renamed from + krb5int_yarrow_reseed and made static. + (Yarrow_detect_fork, yarrow_input_maybe_locking, + krb5int_yarrow_output_Block): Call it. + (krb5int_yarrow_reseed): New function, grabs lock and calls the + old version. + (krb5int_yarrow_final): Hold the lock until after clearing the + Yarrow context data. + +2005-01-13 Ezra Peisach <epeisach@mit.edu> + + * yarrow.c: Declare yarrow_gate_locked static before first use. + +2004-11-22 Ken Raeburn <raeburn@mit.edu> + + * yarrow.c (yarrow_input_maybe_locking): Renamed from + yarrow_input_maybe_locking, made static. New argument indicates + whether or not to do locking. + (krb5int_yarrow_input): New wrapper function. + (yarrow_input_locked): New wrapper function. + (Yarrow_detect_fork): Call yarrow_input_locked. + +2004-11-15 Sam Hartman <hartmans@mit.edu> + + * ycipher.h: Use AES256 not 3des + +2004-11-01 Ken Raeburn <raeburn@mit.edu> + + * yarrow.c (krb5int_yarrow_input, krb5int_yarrow_final): Don't + check for forking here. + (yarrow_output_locked): Split out from krb5int_yarrow_output, + without locking. + (krb5int_yarrow_output): Do locking and call yarrow_output_locked. + (yarrow_gate_locked): New function; uses yarrow_output_locked. + (krb5int_yarrow_output_Block): Use yarrow_gate_locked. + +2004-10-29 Ken Raeburn <raeburn@mit.edu> + + * ylock.h: Include k5-thread.h. + (krb5int_yarrow_lock): Declare. + (LOCK, UNLOCK): Define as macros using the k5_mutex_ macros. + 2004-06-04 Ken Raeburn <raeburn@mit.edu> * yarrow.c (yarrow_str_error): Now const. diff --git a/src/lib/crypto/yarrow/yarrow.c b/src/lib/crypto/yarrow/yarrow.c index c9f4188..29c10f7 100644 --- a/src/lib/crypto/yarrow/yarrow.c +++ b/src/lib/crypto/yarrow/yarrow.c @@ -71,6 +71,8 @@ static int Yarrow_Load_State( Yarrow_CTX *y ); static int Yarrow_Save_State( Yarrow_CTX *y ); #endif +static int yarrow_gate_locked(Yarrow_CTX* y); + static const byte zero_block[CIPHER_BLOCK_SIZE] = { 0, }; static const char* const yarrow_str_error[] = { @@ -117,10 +119,17 @@ static void krb5int_yarrow_init_Limits(Yarrow_CTX* y) } } +static int yarrow_reseed_locked( Yarrow_CTX* y, int pool ); + /* if the program was forked, the child must not operate on the same PRNG state */ #ifdef YARROW_DETECT_FORK +static int +yarrow_input_locked( Yarrow_CTX* y, unsigned source_id, + const void *sample, + size_t size, size_t entropy_bits ); + static int Yarrow_detect_fork(Yarrow_CTX *y) { pid_t newpid; @@ -135,12 +144,12 @@ static int Yarrow_detect_fork(Yarrow_CTX *y) * Then we reseed. This doesn't really increase entropy, but does make the * streams distinct assuming we already have good entropy*/ y->pid = newpid; - TRY (krb5int_yarrow_input (y, 0, &newpid, - sizeof (newpid), 0)); - TRY (krb5int_yarrow_input (y, 0, &newpid, - sizeof (newpid), 0)); - TRY (krb5int_yarrow_reseed (y, YARROW_FAST_POOL)); - } + TRY (yarrow_input_locked (y, 0, &newpid, + sizeof (newpid), 0)); + TRY (yarrow_input_locked (y, 0, &newpid, + sizeof (newpid), 0)); + TRY (yarrow_reseed_locked (y, YARROW_FAST_POOL)); + } CATCH: EXCEP_RET; @@ -241,10 +250,11 @@ int krb5int_yarrow_init(Yarrow_CTX* y, const char *filename) EXCEP_RET; } -YARROW_DLL -int krb5int_yarrow_input( Yarrow_CTX* y, unsigned source_id, - const void* sample, - size_t size, size_t entropy_bits ) +static +int yarrow_input_maybe_locking( Yarrow_CTX* y, unsigned source_id, + const void* sample, + size_t size, size_t entropy_bits, + int do_lock ) { EXCEP_DECL; int ret; @@ -254,7 +264,6 @@ int krb5int_yarrow_input( Yarrow_CTX* y, unsigned source_id, size_t estimate; if (!y) { THROW( YARROW_BAD_ARG ); } - TRY( Yarrow_detect_fork( y ) ); if (source_id >= y->num_sources) { THROW( YARROW_BAD_SOURCE ); } @@ -265,8 +274,10 @@ int krb5int_yarrow_input( Yarrow_CTX* y, unsigned source_id, THROW( YARROW_BAD_SOURCE ); } - TRY( LOCK() ); - locked = 1; + if (do_lock) { + TRY( LOCK() ); + locked = 1; + } /* hash in the sample */ @@ -295,7 +306,7 @@ int krb5int_yarrow_input( Yarrow_CTX* y, unsigned source_id, { if (source->entropy[YARROW_FAST_POOL] >= y->fast_thresh) { - ret = krb5int_yarrow_reseed(y, YARROW_FAST_POOL); + ret = yarrow_reseed_locked(y, YARROW_FAST_POOL); if ( ret != YARROW_OK && ret != YARROW_NOT_SEEDED ) { THROW( ret ); @@ -312,7 +323,7 @@ int krb5int_yarrow_input( Yarrow_CTX* y, unsigned source_id, if (y->slow_k_of_n >= y->slow_k_of_n_thresh) { y->slow_k_of_n = 0; - ret = krb5int_yarrow_reseed(y, YARROW_SLOW_POOL); + ret = yarrow_reseed_locked(y, YARROW_SLOW_POOL); if ( ret != YARROW_OK && ret != YARROW_NOT_SEEDED ) { THROW( ret ); @@ -332,6 +343,24 @@ int krb5int_yarrow_input( Yarrow_CTX* y, unsigned source_id, } YARROW_DLL +int krb5int_yarrow_input( Yarrow_CTX* y, unsigned source_id, + const void* sample, + size_t size, size_t entropy_bits ) +{ + return yarrow_input_maybe_locking(y, source_id, sample, size, + entropy_bits, 1); +} + +static int +yarrow_input_locked( Yarrow_CTX* y, unsigned source_id, + const void *sample, + size_t size, size_t entropy_bits ) +{ + return yarrow_input_maybe_locking(y, source_id, sample, size, + entropy_bits, 0); +} + +YARROW_DLL int krb5int_yarrow_new_source(Yarrow_CTX* y, unsigned* source_id) { EXCEP_DECL; @@ -395,7 +424,7 @@ static int krb5int_yarrow_output_Block( Yarrow_CTX* y, void* out ) if (y->out_count >= y->Pg) { y->out_count = 0; - TRY( krb5int_yarrow_gate( y ) ); + TRY( yarrow_gate_locked( y ) ); /* require new seed after reaching gates_limit */ @@ -408,7 +437,7 @@ static int krb5int_yarrow_output_Block( Yarrow_CTX* y, void* out ) TRACE( printf( "OUTPUT LIMIT REACHED," ); ); - TRY( krb5int_yarrow_reseed( y, YARROW_SLOW_POOL ) ); + TRY( yarrow_reseed_locked( y, YARROW_SLOW_POOL ) ); } } @@ -478,11 +507,23 @@ int krb5int_yarrow_status( Yarrow_CTX* y, int *num_sources, unsigned *source_id, EXCEP_RET; } +static int yarrow_output_locked(Yarrow_CTX*, void*, size_t); + YARROW_DLL int krb5int_yarrow_output( Yarrow_CTX* y, void* out, size_t size ) { EXCEP_DECL; - int locked = 0; + TRY( LOCK() ); + TRY( yarrow_output_locked(y, out, size)); +CATCH: + UNLOCK(); + EXCEP_RET; +} + +static +int yarrow_output_locked( Yarrow_CTX* y, void* out, size_t size ) +{ + EXCEP_DECL; size_t left; char* outp; size_t use; @@ -495,8 +536,6 @@ int krb5int_yarrow_output( Yarrow_CTX* y, void* out, size_t size ) left = size; outp = out; - TRY( LOCK() ); - if (y->out_left > 0) { use = min(left, y->out_left); @@ -521,8 +560,30 @@ int krb5int_yarrow_output( Yarrow_CTX* y, void* out, size_t size ) } CATCH: - if ( locked ) { TRY( UNLOCK() ); } + EXCEP_RET; +} + +static int yarrow_gate_locked(Yarrow_CTX* y) +{ + EXCEP_DECL; + byte new_K[CIPHER_KEY_SIZE]; + + if (!y) { THROW( YARROW_BAD_ARG ); } + TRACE( printf( "GATE[" ); ); + + /* K <- Next k bits of PRNG output */ + + TRY( yarrow_output_locked(y, new_K, CIPHER_KEY_SIZE) ); + mem_copy(y->K, new_K, CIPHER_KEY_SIZE); + + /* need to resetup the key schedule as the key has changed */ + + TRY (krb5int_yarrow_cipher_init(&y->cipher, y->K)); + + CATCH: + TRACE( printf( "]," ); ); + mem_zero(new_K, sizeof(new_K)); EXCEP_RET; } @@ -608,7 +669,7 @@ static int Yarrow_Save_State( Yarrow_CTX *y ) #endif -int krb5int_yarrow_reseed(Yarrow_CTX* y, int pool) +static int yarrow_reseed_locked(Yarrow_CTX* y, int pool) { EXCEP_DECL; HASH_CTX* fast_pool = &y->pool[YARROW_FAST_POOL]; @@ -755,6 +816,14 @@ int krb5int_yarrow_reseed(Yarrow_CTX* y, int pool) EXCEP_RET; } +int krb5int_yarrow_reseed(Yarrow_CTX* y, int pool) +{ + int r; + LOCK(); + r = yarrow_reseed_locked(y, pool); + UNLOCK(); + return r; +} int krb5int_yarrow_stretch(const byte* m, size_t size, byte* out, size_t out_size) { @@ -837,7 +906,6 @@ int krb5int_yarrow_final(Yarrow_CTX* y) int locked = 0; if (!y) { THROW( YARROW_BAD_ARG ); } - TRY( Yarrow_detect_fork(y) ); TRY( LOCK() ); locked = 1; @@ -849,9 +917,9 @@ int krb5int_yarrow_final(Yarrow_CTX* y) #endif CATCH: - if ( locked ) { TRY( UNLOCK() ); } krb5int_yarrow_cipher_final(&y->cipher); mem_zero( y, sizeof(Yarrow_CTX) ); + if ( locked ) { TRY( UNLOCK() ); } EXCEP_RET; } diff --git a/src/lib/crypto/yarrow/ycipher.h b/src/lib/crypto/yarrow/ycipher.h index c858c6d..96999c0 100644 --- a/src/lib/crypto/yarrow/ycipher.h +++ b/src/lib/crypto/yarrow/ycipher.h @@ -17,15 +17,15 @@ typedef struct * call the enc_provider function to get the info. */ -#define yarrow_enc_provider krb5int_enc_des3 +#define yarrow_enc_provider krb5int_enc_aes256 -#define CIPHER_BLOCK_SIZE 8 -#define CIPHER_KEY_SIZE 21 +#define CIPHER_BLOCK_SIZE 16 +#define CIPHER_KEY_SIZE 32 #if defined( YARROW_NO_MATHLIB ) /* see macros at end for functions evaluated */ -#define POW_CIPHER_KEY_SIZE 72057594037927936.0 -#define POW_CIPHER_BLOCK_SIZE 18446744073709551616.0 +#define POW_CIPHER_KEY_SIZE 115792089237316195423570985008687907853269984665640564039457584007913129639936.0 +#define POW_CIPHER_BLOCK_SIZE 340282366920938463463374607431768211456.0 #endif diff --git a/src/lib/crypto/yarrow/ylock.h b/src/lib/crypto/yarrow/ylock.h index 21d3911..9c032dc 100644 --- a/src/lib/crypto/yarrow/ylock.h +++ b/src/lib/crypto/yarrow/ylock.h @@ -11,8 +11,14 @@ * and YARROW_LOCKING on failure */ - +#if 0 static int LOCK( void ) { return (YARROW_OK); } static int UNLOCK( void ) { return (YARROW_OK); } +#else +#include "k5-thread.h" +extern k5_mutex_t krb5int_yarrow_lock; +#define LOCK() (k5_mutex_lock(&krb5int_yarrow_lock) ? YARROW_LOCKING : YARROW_OK) +#define UNLOCK() (k5_mutex_unlock(&krb5int_yarrow_lock) ? YARROW_LOCKING : YARROW_OK) +#endif #endif /* YLOCK_H */ diff --git a/src/lib/gssapi/ChangeLog b/src/lib/gssapi/ChangeLog index 90ac10e..979a91e 100644 --- a/src/lib/gssapi/ChangeLog +++ b/src/lib/gssapi/ChangeLog @@ -1,3 +1,20 @@ +2005-04-07 Tom Yu <tlyu@mit.edu> + + * configure.in: Use awk to work around Makefile quoting problems. + +2005-02-08 Ken Raeburn <raeburn@mit.edu> + + * Makefile.in (LIBINITFUNC, LIBFINIFUNC): Define. + +2005-02-02 Ken Raeburn <raeburn@mit.edu> + + * configure.in: Check for xom.h. Set include_xom to a C include + directive or comment, and substitute it in the Makefiles. + +2005-01-17 Jeffrey Altman <jaltman@mit.edu> + + * gss_libinit.c: implement cleanup of mutexes, static vars, etc for Windows + 2004-07-29 Sam Hartman <hartmans@mit.edu> * libgssapi_krb5.exports: Add lucid context routines and gss_krb5_set_allowable_enctypes diff --git a/src/lib/gssapi/Makefile.in b/src/lib/gssapi/Makefile.in index a8f53db..16ff510 100644 --- a/src/lib/gssapi/Makefile.in +++ b/src/lib/gssapi/Makefile.in @@ -26,6 +26,8 @@ SRCS=\ LIBBASE=gssapi_krb5 LIBMAJOR=2 LIBMINOR=2 +LIBINITFUNC=gssint_lib_init +LIBFINIFUNC=gssint_lib_fini STOBJLISTS=OBJS.ST generic/OBJS.ST krb5/OBJS.ST SUBDIROBJLISTS=generic/OBJS.ST krb5/OBJS.ST SHLIB_EXPDEPS=\ diff --git a/src/lib/gssapi/configure.in b/src/lib/gssapi/configure.in index 72ab798..98bfcf0 100644 --- a/src/lib/gssapi/configure.in +++ b/src/lib/gssapi/configure.in @@ -7,8 +7,13 @@ AC_CHECK_SIZEOF(short) AC_CHECK_SIZEOF(int) AC_CHECK_SIZEOF(long) AC_CHECK_HEADER(stdint.h,[ - include_stdint="\\#include <stdint.h>"], ) + include_stdint='awk '\''END{printf("%cinclude <stdint.h>\n", 35);}'\'' < /dev/null'], + include_stdint='echo "/* no stdint.h */"') AC_SUBST(include_stdint) +AC_CHECK_HEADER(xom.h,[ + include_xom='awk '\''END{printf("%cinclude <xom.h>\n", 35);}'\'' < /dev/null'], [ + include_xom='echo "/* no xom.h */"']) +AC_SUBST(include_xom) KRB5_BUILD_LIBOBJS KRB5_BUILD_LIBRARY_WITH_DEPS V5_AC_OUTPUT_MAKEFILE(. generic krb5) diff --git a/src/lib/gssapi/generic/ChangeLog b/src/lib/gssapi/generic/ChangeLog index 7643a97..4480d31 100644 --- a/src/lib/gssapi/generic/ChangeLog +++ b/src/lib/gssapi/generic/ChangeLog @@ -1,3 +1,19 @@ +2005-04-07 Tom Yu <tlyu@mit.edu> + + * Makefile.in (gssapi.h): Use awk hack to work around quoting + problem. + +2005-02-02 Ken Raeburn <raeburn@mit.edu> + + * Makefile.in (gssapi.h): Change SIZEOF symbols to start with GSS_ + when extracting from autoconf.h. Don't look for HAVE_ or USE_ + symbols. Add ${include_xom} to the prologue. + (include_xom): New variable. + * gssapi.hin: Always include stddef.h unconditionally. Don't + conditionally include xom.h here. + (GSS_SIZEOF_INT, GSS_SIZEOF_LONG, GSS_SIZEOF_SHORT): Don't + define, except on Windows. + 2004-06-22 Ken Raeburn <raeburn@mit.edu> * gssapi.hin: Don't test macintosh or __MWERKS__. diff --git a/src/lib/gssapi/generic/Makefile.in b/src/lib/gssapi/generic/Makefile.in index 9691e1a..a7d997b 100644 --- a/src/lib/gssapi/generic/Makefile.in +++ b/src/lib/gssapi/generic/Makefile.in @@ -37,14 +37,15 @@ $(OUTPRE)gssapi_err_generic.$(OBJEXT): gssapi_err_generic.c gssapi_err_generic.h: gssapi_err_generic.et gssapi_err_generic.c: gssapi_err_generic.et +include_xom=@include_xom@ +##DOS##include_xom= gssapi.h: gssapi.hin @echo "Creating gssapi.h" ; \ h=gss$$$$; $(RM) $$h; \ (echo "/* This is the gssapi.h prologue. */"; \ 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; \ + sed -n "/SIZEOF/s//GSS_&/p" < $(BUILDTOP)/include/krb5/autoconf.h; \ + $(include_xom); \ echo "/* End of gssapi.h prologue. */"; \ cat $(srcdir)/gssapi.hin )> $$h && \ (set -x; $(MV) $$h $@) ; e=$$?; $(RM) $$h; exit $$e diff --git a/src/lib/gssapi/generic/gssapi.hin b/src/lib/gssapi/generic/gssapi.hin index 1c14444..83fe62b 100644 --- a/src/lib/gssapi/generic/gssapi.hin +++ b/src/lib/gssapi/generic/gssapi.hin @@ -44,6 +44,9 @@ extern "C" { #if defined(_MSDOS) || defined(_WIN32) #include <win-mac.h> +#define GSS_SIZEOF_SHORT SIZEOF_SHORT +#define GSS_SIZEOF_LONG SIZEOF_LONG +#define GSS_SIZEOF_INT SIZEOF_INT #endif #ifndef KRB5_CALLCONV @@ -51,16 +54,10 @@ extern "C" { #define KRB5_CALLCONV_C #endif -#define GSS_SIZEOF_INT SIZEOF_INT -#define GSS_SIZEOF_LONG SIZEOF_LONG -#define GSS_SIZEOF_SHORT SIZEOF_SHORT - /* * First, include stddef.h to get size_t defined. */ -#if HAVE_STDDEF_H #include <stddef.h> -#endif /* HAVE_STDDEF_H */ /* * POSIX says that sys/types.h is where size_t is defined. @@ -68,13 +65,6 @@ extern "C" { #include <sys/types.h> /* - * If the platform supports the xom.h header file, it should be included here. - */ -#if HAVE_XOM_H -#include <xom.h> -#endif /* HAVE_XOM_H */ - -/* * $Id$ */ diff --git a/src/lib/gssapi/gss_libinit.c b/src/lib/gssapi/gss_libinit.c index a43989f..d45ac44 100644 --- a/src/lib/gssapi/gss_libinit.c +++ b/src/lib/gssapi/gss_libinit.c @@ -41,7 +41,10 @@ void gssint_lib_fini(void) remove_error_table(&et_k5g_error_table); remove_error_table(&et_ggss_error_table); #endif + k5_key_delete(K5_KEY_GSS_KRB5_SET_CCACHE_OLD_NAME); + k5_key_delete(K5_KEY_GSS_KRB5_CCACHE_NAME); k5_mutex_destroy(&kg_vdb.mutex); + k5_mutex_destroy(&gssint_krb5_keytab_lock); } OM_uint32 gssint_initialize_library (void) diff --git a/src/lib/gssapi/krb5/ChangeLog b/src/lib/gssapi/krb5/ChangeLog index 3237548..edcd9a2 100644 --- a/src/lib/gssapi/krb5/ChangeLog +++ b/src/lib/gssapi/krb5/ChangeLog @@ -1,3 +1,14 @@ +2005-04-07 Tom Yu <tlyu@mit.edu> + + * Makefile.in (gssapi_krb5.h): Use awk hack to work around quoting + problem. + +2005-01-13 Jeffrey Altman <jaltman@mit.edu> + + * init_sec_context.c, acquire_cred.c: fix calls to + krb5_gss_release_cred() to pass in the correct type. + This fixes a mutex leak. + 2004-08-27 Tom Yu <tlyu@mit.edu> * init_sec_context.c (make_ap_req_v1): Free checksum data diff --git a/src/lib/gssapi/krb5/Makefile.in b/src/lib/gssapi/krb5/Makefile.in index ae58e65..37b6307 100644 --- a/src/lib/gssapi/krb5/Makefile.in +++ b/src/lib/gssapi/krb5/Makefile.in @@ -210,7 +210,7 @@ gssapi_krb5.h: gssapi_krb5.hin @echo "Creating gssapi.h" ; \ h=gss$$$$; $(RM) $$h; \ (echo "/* This is the gssapi_krb5.h prologue. */"; \ - echo "$(include_stdint)" ; \ + $(include_stdint) ; \ echo "/* End of gssapi_krb5.h prologue. */"; \ cat $(srcdir)/gssapi_krb5.hin )> $$h && \ (set -x; $(MV) $$h $@) ; e=$$?; $(RM) $$h; exit $$e diff --git a/src/lib/gssapi/krb5/acquire_cred.c b/src/lib/gssapi/krb5/acquire_cred.c index 12d2cac..56d6a47 100644 --- a/src/lib/gssapi/krb5/acquire_cred.c +++ b/src/lib/gssapi/krb5/acquire_cred.c @@ -444,6 +444,7 @@ krb5_gss_acquire_cred(minor_status, desired_name, time_req, if ((cred_usage != GSS_C_INITIATE) && (cred_usage != GSS_C_ACCEPT) && (cred_usage != GSS_C_BOTH)) { + k5_mutex_destroy(&cred->lock); xfree(cred); *minor_status = (OM_uint32) G_BAD_USAGE; krb5_free_context(context); @@ -460,7 +461,8 @@ krb5_gss_acquire_cred(minor_status, desired_name, time_req, != GSS_S_COMPLETE) { if (cred->princ) krb5_free_principal(context, cred->princ); - xfree(cred); + k5_mutex_destroy(&cred->lock); + xfree(cred); /* minor_status set by acquire_accept_cred() */ krb5_free_context(context); return(ret); @@ -481,7 +483,8 @@ krb5_gss_acquire_cred(minor_status, desired_name, time_req, krb5_kt_close(context, cred->keytab); if (cred->princ) krb5_free_principal(context, cred->princ); - xfree(cred); + k5_mutex_destroy(&cred->lock); + xfree(cred); /* minor_status set by acquire_init_cred() */ krb5_free_context(context); return(ret); @@ -496,7 +499,8 @@ krb5_gss_acquire_cred(minor_status, desired_name, time_req, (void)krb5_cc_close(context, cred->ccache); if (cred->keytab) (void)krb5_kt_close(context, cred->keytab); - xfree(cred); + k5_mutex_destroy(&cred->lock); + xfree(cred); *minor_status = code; krb5_free_context(context); return(GSS_S_FAILURE); @@ -519,7 +523,8 @@ krb5_gss_acquire_cred(minor_status, desired_name, time_req, (void)krb5_kt_close(context, cred->keytab); if (cred->princ) krb5_free_principal(context, cred->princ); - xfree(cred); + k5_mutex_destroy(&cred->lock); + xfree(cred); *minor_status = code; krb5_free_context(context); return(GSS_S_FAILURE); @@ -548,6 +553,7 @@ krb5_gss_acquire_cred(minor_status, desired_name, time_req, (void)krb5_kt_close(context, cred->keytab); if (cred->princ) krb5_free_principal(context, cred->princ); + k5_mutex_destroy(&cred->lock); xfree(cred); /* *minor_status set above */ krb5_free_context(context); @@ -566,6 +572,7 @@ krb5_gss_acquire_cred(minor_status, desired_name, time_req, (void)krb5_kt_close(context, cred->keytab); if (cred->princ) krb5_free_principal(context, cred->princ); + k5_mutex_destroy(&cred->lock); xfree(cred); *minor_status = (OM_uint32) G_VALIDATE_FAILED; krb5_free_context(context); diff --git a/src/lib/gssapi/krb5/init_sec_context.c b/src/lib/gssapi/krb5/init_sec_context.c index 3ffb515..4f40559 100644 --- a/src/lib/gssapi/krb5/init_sec_context.c +++ b/src/lib/gssapi/krb5/init_sec_context.c @@ -925,7 +925,7 @@ krb5_gss_init_sec_context(minor_status, claimant_cred_handle, if (err) { k5_mutex_unlock(&cred->lock); if (claimant_cred_handle == GSS_C_NO_CREDENTIAL) - krb5_gss_release_cred(minor_status, (gss_cred_id_t)cred); + krb5_gss_release_cred(minor_status, (gss_cred_id_t)&cred); *minor_status = 0; if (*context_handle == GSS_C_NO_CONTEXT) krb5_free_context(context); @@ -962,7 +962,7 @@ krb5_gss_init_sec_context(minor_status, claimant_cred_handle, } if (claimant_cred_handle == GSS_C_NO_CREDENTIAL) - krb5_gss_release_cred(&tmp_min_stat, (gss_cred_id_t)cred); + krb5_gss_release_cred(&tmp_min_stat, (gss_cred_id_t)&cred); return(major_status); } diff --git a/src/lib/gssapi32.def b/src/lib/gssapi32.def index e951cb9..073d96a 100644 --- a/src/lib/gssapi32.def +++ b/src/lib/gssapi32.def @@ -72,14 +72,22 @@ EXPORTS ; ; GSS-API variables ; - gss_nt_user_name DATA + gss_nt_krb5_name DATA + gss_nt_krb5_principal DATA + gss_nt_user_name DATA gss_nt_machine_uid_name DATA gss_nt_string_uid_name DATA - gss_nt_service_name DATA - GSS_C_NT_USER_NAME DATA - GSS_C_NT_MACHINE_UID_NAME DATA - GSS_C_NT_STRING_UID_NAME DATA - GSS_C_NT_HOSTBASED_SERVICE DATA - GSS_C_NT_HOSTBASED_SERVICE_X DATA - GSS_C_NT_ANONYMOUS DATA - GSS_C_NT_EXPORT_NAME DATA + gss_nt_service_name DATA + GSS_C_NT_USER_NAME DATA + GSS_C_NT_MACHINE_UID_NAME DATA + GSS_C_NT_STRING_UID_NAME DATA + GSS_C_NT_HOSTBASED_SERVICE DATA + GSS_C_NT_HOSTBASED_SERVICE_X DATA + GSS_C_NT_ANONYMOUS DATA + GSS_C_NT_EXPORT_NAME DATA + krb5_gss_oid_array DATA + gss_mech_krb5 DATA + gss_mech_krb5_old DATA + gss_mech_set_krb5 DATA + gss_mech_set_krb5_old DATA + gss_mech_set_krb5_both DATA diff --git a/src/lib/kadm5/adb_err.et b/src/lib/kadm5/adb_err.et deleted file mode 100644 index 3948025..0000000 --- a/src/lib/kadm5/adb_err.et +++ /dev/null @@ -1,16 +0,0 @@ -error_table adb -error_code OSA_ADB_NOERR, "No Error" -error_code OSA_ADB_DUP, "Principal or policy already exists" -error_code OSA_ADB_NOENT, "Principal or policy does not exist" -error_code OSA_ADB_DBINIT, "Database not initialized" -error_code OSA_ADB_BAD_POLICY, "Invalid policy name" -error_code OSA_ADB_BAD_PRINC, "Invalid principal name" -error_code OSA_ADB_BAD_DB, "Database inconsistency detected" -error_code OSA_ADB_XDR_FAILURE, "XDR encoding error" -error_code OSA_ADB_FAILURE, "Failure!" -error_code OSA_ADB_BADLOCKMODE, "Bad lock mode" -error_code OSA_ADB_CANTLOCK_DB, "Cannot lock database" -error_code OSA_ADB_NOTLOCKED, "Database not locked" -error_code OSA_ADB_NOLOCKFILE, "KADM5 administration database lock file missing" -error_code OSA_ADB_NOEXCL_PERM, "Insufficient permission to lock file" -end diff --git a/src/lib/kadm5/admin.h b/src/lib/kadm5/admin.h index 866cfb0..4051601 100644 --- a/src/lib/kadm5/admin.h +++ b/src/lib/kadm5/admin.h @@ -123,6 +123,7 @@ typedef long kadm5_ret_t; #define KADM5_CONFIG_KPASSWD_PORT 0x080000 #define KADM5_CONFIG_OLD_AUTH_GSSAPI 0x100000 #define KADM5_CONFIG_NO_AUTH 0x200000 +#define KADM5_CONFIG_AUTH_NOFALLBACK 0x400000 /* * permission bits diff --git a/src/lib/kadm5/clnt/ChangeLog b/src/lib/kadm5/clnt/ChangeLog index 6d0a14e..fc2dfca 100644 --- a/src/lib/kadm5/clnt/ChangeLog +++ b/src/lib/kadm5/clnt/ChangeLog @@ -1,3 +1,13 @@ +2005-02-11 Tom Yu <tlyu@mit.edu> + + * client_init.c (kadm5_get_init_creds, kadm5_gic_iter) + (kadm5_setup_gss, kadm5_rpc_auth): New functions, containing parts + of _kadm5_init_any. + (_kadm5_init_any): Bits broken out into helper functions. + (kadm5_get_init_creds): Fall back from kadmin/fqdn to kadmin/admin + if NULL service name passed in. + (kadm5_rpc_auth): Fall back from RPCSEC_GSS to AUTH_GSSAPI. + 2004-10-25 Tom Yu <tlyu@mit.edu> * client_init.c (_kadm5_init_any): Pass req_flags and cred to diff --git a/src/lib/kadm5/clnt/client_init.c b/src/lib/kadm5/clnt/client_init.c index d3c63bd..f103154 100644 --- a/src/lib/kadm5/clnt/client_init.c +++ b/src/lib/kadm5/clnt/client_init.c @@ -55,8 +55,6 @@ #define ADM_CCACHE "/tmp/ovsec_adm.XXXXXX" -static int old_auth_gssapi = 0; - enum init_type { INIT_PASS, INIT_SKEY, INIT_CREDS }; static kadm5_ret_t _kadm5_init_any(char *client_name, @@ -69,6 +67,32 @@ static kadm5_ret_t _kadm5_init_any(char *client_name, krb5_ui_4 api_version, void **server_handle); +static kadm5_ret_t +kadm5_get_init_creds(kadm5_server_handle_t handle, + char *client_name, enum init_type init_type, + char *pass, krb5_ccache ccache_in, + char *svcname_in, char *realm, + char *full_svcname, unsigned int full_svcname_len); + +static kadm5_ret_t +kadm5_gic_iter(kadm5_server_handle_t handle, + enum init_type init_type, + krb5_ccache ccache, + krb5_principal client, char *pass, + char *svcname, char *realm, + char *full_svcname, unsigned int full_svcname_len); + +static kadm5_ret_t +kadm5_setup_gss(kadm5_server_handle_t handle, + kadm5_config_params *params_in, + char *client_name, char *full_svcname); + +static void +kadm5_rpc_auth(kadm5_server_handle_t handle, + kadm5_config_params *params_in, + gss_cred_id_t gss_client_creds, + gss_name_t gss_target); + kadm5_ret_t kadm5_init_with_creds(char *client_name, krb5_ccache ccache, char *service_name, @@ -120,16 +144,6 @@ kadm5_ret_t kadm5_init_with_skey(char *client_name, char *keytab, api_version, server_handle); } -/* - * Try no preauthentication first; then try the encrypted timestamp - * (stolen from krb5 kinit.c) - */ -static int preauth_search_list[] = { - 0, - KRB5_PADATA_ENC_UNIX_TIME, - -1 -}; - static kadm5_ret_t _kadm5_init_any(char *client_name, enum init_type init_type, char *pass, @@ -143,27 +157,15 @@ static kadm5_ret_t _kadm5_init_any(char *client_name, struct sockaddr_in addr; struct hostent *hp; int fd; - int i; - char full_service_name[BUFSIZ], *ccname_orig; - const char *c_ccname_orig; + char full_svcname[BUFSIZ]; char *realm; - krb5_creds creds; - krb5_ccache ccache = NULL; - krb5_timestamp now; - OM_uint32 gssstat, minor_stat; - gss_buffer_desc input_name; - gss_name_t gss_client; - gss_name_t gss_target; - gss_cred_id_t gss_client_creds = GSS_C_NO_CREDENTIAL; - kadm5_server_handle_t handle; kadm5_config_params params_local; int code = 0; generic_ret *r; - char svcname[MAXHOSTNAMELEN + 8]; initialize_ovk_error_table(); initialize_adb_error_table(); @@ -198,7 +200,6 @@ static kadm5_ret_t _kadm5_init_any(char *client_name, free(handle); return EINVAL; } - memset((char *) &creds, 0, sizeof(creds)); /* * Verify the version numbers before proceeding; we can't use @@ -268,54 +269,136 @@ static kadm5_ret_t _kadm5_init_any(char *client_name, return KADM5_MISSING_KRB5_CONF_PARAMS; } - /* NULL service_name means use host-based. */ - if (service_name == NULL) { + /* + * Get credentials. Also does some fallbacks in case kadmin/fqdn + * principal doesn't exist. + */ + code = kadm5_get_init_creds(handle, client_name, init_type, pass, + ccache_in, service_name, realm, + full_svcname, sizeof(full_svcname)); + if (code) + goto error; + /* + * We have ticket; open the RPC connection. + */ + + hp = gethostbyname(handle->params.admin_server); + if (hp == (struct hostent *) NULL) { + code = KADM5_BAD_SERVER_NAME; + goto cleanup; + } + + memset(&addr, 0, sizeof(addr)); + addr.sin_family = hp->h_addrtype; + (void) memcpy((char *) &addr.sin_addr, (char *) hp->h_addr, + sizeof(addr.sin_addr)); + addr.sin_port = htons((u_short) handle->params.kadmind_port); + + fd = RPC_ANYSOCK; + + handle->clnt = clnttcp_create(&addr, KADM, KADMVERS, &fd, 0, 0); + if (handle->clnt == NULL) { + code = KADM5_RPC_ERROR; +#ifdef DEBUG + clnt_pcreateerror("clnttcp_create"); +#endif + goto error; + } + handle->lhandle->clnt = handle->clnt; + + /* now that handle->clnt is set, we can check the handle */ + if ((code = _kadm5_check_handle((void *) handle))) + goto error; + + /* + * The RPC connection is open; establish the GSS-API + * authentication context. + */ + code = kadm5_setup_gss(handle, params_in, client_name, full_svcname); + if (code) + goto error; + + r = init_1(&handle->api_version, handle->clnt); + if (r == NULL) { + code = KADM5_RPC_ERROR; +#ifdef DEBUG + clnt_perror(handle->clnt, "init_1 null resp"); +#endif + goto error; + } + if (r->code) { + code = r->code; + goto error; + } + + *server_handle = (void *) handle; + + goto cleanup; + +error: + /* + * Note that it is illegal for this code to execute if "handle" + * has not been allocated and initialized. I.e., don't use "goto + * error" before the block of code at the top of the function + * that allocates and initializes "handle". + */ + if (handle->cache_name) + free(handle->cache_name); + if(handle->clnt && handle->clnt->cl_auth) + AUTH_DESTROY(handle->clnt->cl_auth); + if(handle->clnt) + clnt_destroy(handle->clnt); + +cleanup: + if (code) + free(handle); + + return code; +} + +/* + * kadm5_get_init_creds + * + * Get initial credentials for authenticating to server. Perform + * fallback from kadmin/fqdn to kadmin/admin if svcname_in is NULL. + */ +static kadm5_ret_t +kadm5_get_init_creds(kadm5_server_handle_t handle, + char *client_name, enum init_type init_type, + char *pass, krb5_ccache ccache_in, + char *svcname_in, char *realm, + char *full_svcname, unsigned int full_svcname_len) +{ + kadm5_ret_t code; + krb5_principal client; + krb5_ccache ccache; + char svcname[BUFSIZ]; + + client = NULL; + ccache = NULL; + /* NULL svcname means use host-based. */ + if (svcname_in == NULL) { code = kadm5_get_admin_service_name(handle->context, handle->params.realm, svcname, sizeof(svcname)); if (code) { - krb5_free_context(handle->context); - free(handle); - return KADM5_MISSING_KRB5_CONF_PARAMS; + code = KADM5_MISSING_KRB5_CONF_PARAMS; + goto error; } - service_name = svcname; + } else { + strncpy(svcname, svcname_in, sizeof(svcname)); + svcname[sizeof(svcname)-1] = '\0'; } /* - * Acquire a service ticket for service_name@realm in the name of + * Acquire a service ticket for svcname@realm in the name of * client_name, using password pass (which could be NULL), and * create a ccache to store them in. If INIT_CREDS, use the * ccache we were provided instead. */ - - if ((code = krb5_parse_name(handle->context, client_name, &creds.client))) - goto error; - - if (realm) { - if(strlen(service_name) + strlen(realm) + 1 >= sizeof(full_service_name)) { - goto error; - } - sprintf(full_service_name, "%s@%s", service_name, realm); - } else { - /* krb5_princ_realm(creds.client) is not null terminated */ - if(strlen(service_name) + krb5_princ_realm(handle->context, creds.client)->length + 1 >= sizeof(full_service_name)) { - goto error; - } - strcpy(full_service_name, service_name); - strcat(full_service_name, "@"); - strncat(full_service_name, krb5_princ_realm(handle->context, - creds.client)->data, - krb5_princ_realm(handle->context, creds.client)->length); - } - - if ((code = krb5_parse_name(handle->context, full_service_name, - &creds.server))) + code = krb5_parse_name(handle->context, client_name, &client); + if (code) goto error; - /* XXX temporarily fix a bug in krb5_cc_get_type */ -#undef krb5_cc_get_type -#define krb5_cc_get_type(context, cache) ((cache)->ops->prefix) - - if (init_type == INIT_CREDS) { ccache = ccache_in; handle->cache_name = (char *) @@ -329,161 +412,184 @@ static kadm5_ret_t _kadm5_init_any(char *client_name, krb5_cc_get_type(handle->context, ccache), krb5_cc_get_name(handle->context, ccache)); } else { -#if 0 - handle->cache_name = - (char *) malloc(strlen(ADM_CCACHE)+strlen("FILE:")+1); - if (handle->cache_name == NULL) { - code = ENOMEM; - goto error; - } - sprintf(handle->cache_name, "FILE:%s", ADM_CCACHE); - mktemp(handle->cache_name + strlen("FILE:")); -#else - { - static int counter = 0; - handle->cache_name = malloc(sizeof("MEMORY:kadm5_") - + 3*sizeof(counter)); - sprintf(handle->cache_name, "MEMORY:kadm5_%u", counter++); - } -#endif - - if ((code = krb5_cc_resolve(handle->context, handle->cache_name, - &ccache))) + static int counter = 0; + + handle->cache_name = malloc(sizeof("MEMORY:kadm5_") + + 3*sizeof(counter)); + sprintf(handle->cache_name, "MEMORY:kadm5_%u", counter++); + + code = krb5_cc_resolve(handle->context, handle->cache_name, + &ccache); + if (code) goto error; - - if ((code = krb5_cc_initialize (handle->context, ccache, - creds.client))) + + code = krb5_cc_initialize (handle->context, ccache, client); + if (code) goto error; handle->destroy_cache = 1; } handle->lhandle->cache_name = handle->cache_name; - - if ((code = krb5_timeofday(handle->context, &now))) - goto error; - - /* - * Get a ticket, use the method specified in init_type. - */ - - creds.times.starttime = 0; /* start timer at KDC */ - creds.times.endtime = 0; /* endtime will be limited by service */ - if (init_type == INIT_PASS) { - for (i=0; preauth_search_list[i] >= 0; i++) { - code = krb5_get_in_tkt_with_password(handle->context, - 0, /* no options */ - 0, /* default addresses */ - 0, /* enctypes */ - NULL, /* XXX preauth */ - pass, - ccache, - &creds, - NULL); - if (code != KRB5KDC_ERR_PREAUTH_FAILED && - code != KRB5KDC_ERR_PREAUTH_REQUIRED && - code != KRB5KRB_ERR_GENERIC) - break; - } - } else if (init_type == INIT_SKEY) { - krb5_keytab kt = NULL; - - if (pass && (code = krb5_kt_resolve(handle->context, pass, &kt))) - ; - else { - for (i=0; preauth_search_list[i] >= 0; i++) { - code = krb5_get_in_tkt_with_keytab(handle->context, - 0, /* no options */ - 0, /* default addrs */ - 0, /* enctypes */ - NULL, /* XXX preauth */ - kt, - ccache, - &creds, - NULL); - if (code != KRB5KDC_ERR_PREAUTH_FAILED && - code != KRB5KDC_ERR_PREAUTH_REQUIRED && - code != KRB5KRB_ERR_GENERIC) - break; - } - - if (pass) krb5_kt_close(handle->context, kt); - } + code = kadm5_gic_iter(handle, init_type, ccache, + client, pass, svcname, realm, + full_svcname, full_svcname_len); + if ((code == KRB5KDC_ERR_S_PRINCIPAL_UNKNOWN + || code == KRB5_CC_NOTFOUND) && svcname_in == NULL) { + /* Retry with old host-independent service princpal. */ + code = kadm5_gic_iter(handle, init_type, ccache, + client, pass, + KADM5_ADMIN_SERVICE, realm, + full_svcname, full_svcname_len); } - /* Improved error messages */ if (code == KRB5KRB_AP_ERR_BAD_INTEGRITY) code = KADM5_BAD_PASSWORD; if (code == KRB5KDC_ERR_S_PRINCIPAL_UNKNOWN) code = KADM5_SECURE_PRINC_MISSING; - if (code != 0) goto error; - -#ifdef ZEROPASSWD - if (pass != NULL) - memset(pass, 0, strlen(pass)); -#endif +error: + if (ccache != NULL && init_type != INIT_CREDS) + krb5_cc_close(handle->context, ccache); + return code; +} - /* - * We have ticket; open the RPC connection. - */ +/* + * kadm5_gic_iter + * + * Perform one iteration of attempting to get credentials. This + * includes searching existing ccache for requested service if + * INIT_CREDS. + */ +static kadm5_ret_t +kadm5_gic_iter(kadm5_server_handle_t handle, + enum init_type init_type, + krb5_ccache ccache, + krb5_principal client, char *pass, + char *svcname, char *realm, + char *full_svcname, unsigned int full_svcname_len) +{ + kadm5_ret_t code; + krb5_context ctx; + krb5_keytab kt; + krb5_get_init_creds_opt opt; + krb5_creds mcreds, outcreds; + + ctx = handle->context; + kt = NULL; + memset(full_svcname, 0, full_svcname_len); + memset(&opt, 0, sizeof(opt)); + memset(&mcreds, 0, sizeof(mcreds)); + memset(&outcreds, 0, sizeof(outcreds)); + + code = ENOMEM; + if (realm) { + if ((strlen(svcname) + strlen(realm) + 1) >= full_svcname_len) + goto error; + sprintf(full_svcname, "%s@%s", svcname, realm); + } else { + /* krb5_princ_realm(client) is not null terminated */ + if ((strlen(svcname) + krb5_princ_realm(ctx, client)->length + 1) + >= full_svcname_len) + goto error; - hp = gethostbyname(handle->params.admin_server); - if (hp == (struct hostent *) NULL) { - code = KADM5_BAD_SERVER_NAME; - goto cleanup; + strcpy(full_svcname, svcname); + strcat(full_svcname, "@"); + strncat(full_svcname, + krb5_princ_realm(ctx, client)->data, + krb5_princ_realm(ctx, client)->length); } - memset(&addr, 0, sizeof(addr)); - addr.sin_family = hp->h_addrtype; - (void) memcpy((char *) &addr.sin_addr, (char *) hp->h_addr, - sizeof(addr.sin_addr)); - addr.sin_port = htons((u_short) handle->params.kadmind_port); - - fd = RPC_ANYSOCK; - - handle->clnt = clnttcp_create(&addr, KADM, KADMVERS, &fd, 0, 0); - if (handle->clnt == NULL) { - code = KADM5_RPC_ERROR; -#ifdef DEBUG - clnt_pcreateerror("clnttcp_create"); -#endif - goto error; + if (init_type != INIT_CREDS) + krb5_get_init_creds_opt_init(&opt); + + if (init_type == INIT_PASS) { + code = krb5_get_init_creds_password(ctx, &outcreds, client, pass, + krb5_prompter_posix, + NULL, 0, + full_svcname, &opt); + if (code) + goto error; + } else if (init_type == INIT_SKEY) { + if (pass) { + code = krb5_kt_resolve(ctx, pass, &kt); + if (code) + goto error; + } + code = krb5_get_init_creds_keytab(ctx, &outcreds, client, kt, + 0, full_svcname, &opt); + if (pass) + krb5_kt_close(ctx, kt); + if (code) + goto error; + } else if (init_type == INIT_CREDS) { + mcreds.client = client; + code = krb5_parse_name(ctx, full_svcname, &mcreds.server); + if (code) + goto error; + code = krb5_cc_retrieve_cred(ctx, ccache, 0, + &mcreds, &outcreds); + krb5_free_principal(ctx, mcreds.server); + if (code) + goto error; } - handle->lhandle->clnt = handle->clnt; + if (init_type != INIT_CREDS) { + /* Caller has initialized ccache. */ + code = krb5_cc_store_cred(ctx, ccache, &outcreds); + if (code) + goto error; + } +error: + krb5_free_cred_contents(ctx, &outcreds); + return code; +} - /* now that handle->clnt is set, we can check the handle */ - if ((code = _kadm5_check_handle((void *) handle))) - goto error; +/* + * kadm5_setup_gss + * + * Acquire GSSAPI credentials and set up RPC auth flavor. + */ +static kadm5_ret_t +kadm5_setup_gss(kadm5_server_handle_t handle, + kadm5_config_params *params_in, + char *client_name, char *full_svcname) +{ + kadm5_ret_t code; + OM_uint32 gssstat, minor_stat; + gss_buffer_desc buf; + gss_name_t gss_client; + gss_name_t gss_target; + gss_cred_id_t gss_client_creds; + const char *c_ccname_orig; + char *ccname_orig; - /* - * The RPC connection is open; establish the GSS-API - * authentication context. - */ + code = KADM5_GSS_ERROR; + gss_client_creds = GSS_C_NO_CREDENTIAL; + ccname_orig = NULL; - /* use the kadm5 cache */ + /* Temporarily use the kadm5 cache. */ gssstat = gss_krb5_ccache_name(&minor_stat, handle->cache_name, &c_ccname_orig); if (gssstat != GSS_S_COMPLETE) { - code = KADM5_GSS_ERROR; - goto error; + code = KADM5_GSS_ERROR; + goto error; } if (c_ccname_orig) ccname_orig = strdup(c_ccname_orig); else - ccname_orig = 0; + ccname_orig = 0; - input_name.value = full_service_name; - input_name.length = strlen((char *)input_name.value) + 1; - gssstat = gss_import_name(&minor_stat, &input_name, + buf.value = full_svcname; + buf.length = strlen((char *)buf.value) + 1; + gssstat = gss_import_name(&minor_stat, &buf, (gss_OID) gss_nt_krb5_name, &gss_target); if (gssstat != GSS_S_COMPLETE) { code = KADM5_GSS_ERROR; goto error; } - input_name.value = client_name; - input_name.length = strlen((char *)input_name.value) + 1; - gssstat = gss_import_name(&minor_stat, &input_name, + buf.value = client_name; + buf.length = strlen((char *)buf.value) + 1; + gssstat = gss_import_name(&minor_stat, &buf, (gss_OID) gss_nt_krb5_name, &gss_client); if (gssstat != GSS_S_COMPLETE) { code = KADM5_GSS_ERROR; @@ -493,105 +599,92 @@ static kadm5_ret_t _kadm5_init_any(char *client_name, gssstat = gss_acquire_cred(&minor_stat, gss_client, 0, GSS_C_NULL_OID_SET, GSS_C_INITIATE, &gss_client_creds, NULL, NULL); - (void) gss_release_name(&minor_stat, &gss_client); if (gssstat != GSS_S_COMPLETE) { code = KADM5_GSS_ERROR; goto error; } - - if (params_in != NULL && - (params_in->mask & KADM5_CONFIG_OLD_AUTH_GSSAPI)) { - handle->clnt->cl_auth = auth_gssapi_create(handle->clnt, - &gssstat, - &minor_stat, - gss_client_creds, - gss_target, - (gss_OID) gss_mech_krb5, - GSS_C_MUTUAL_FLAG - | GSS_C_REPLAY_FLAG, - 0, - NULL, - NULL, - NULL); - } else if (params_in == NULL || - !(params_in->mask & KADM5_CONFIG_NO_AUTH)) { - struct rpc_gss_sec sec; - sec.mech = gss_mech_krb5; - sec.qop = GSS_C_QOP_DEFAULT; - sec.svc = RPCSEC_GSS_SVC_PRIVACY; - sec.cred = gss_client_creds; - sec.req_flags = GSS_C_MUTUAL_FLAG | GSS_C_REPLAY_FLAG; - handle->clnt->cl_auth = authgss_create(handle->clnt, - gss_target, &sec); - } - (void) gss_release_name(&minor_stat, &gss_target); + /* + * Do actual creation of RPC auth handle. Implements auth flavor + * fallback. + */ + kadm5_rpc_auth(handle, params_in, gss_client_creds, gss_target); + +error: + if (gss_client_creds != GSS_C_NO_CREDENTIAL) + (void) gss_release_cred(&minor_stat, &gss_client_creds); + if (gss_client) + gss_release_name(&minor_stat, &gss_client); + if (gss_target) + gss_release_name(&minor_stat, &gss_target); + + /* Revert to prior gss_krb5 ccache. */ if (ccname_orig) { gssstat = gss_krb5_ccache_name(&minor_stat, ccname_orig, NULL); if (gssstat) { - code = KADM5_GSS_ERROR; - goto error; + return KADM5_GSS_ERROR; } free(ccname_orig); } else { gssstat = gss_krb5_ccache_name(&minor_stat, NULL, NULL); if (gssstat) { - code = KADM5_GSS_ERROR; - goto error; + return KADM5_GSS_ERROR; } } - - if (handle->clnt->cl_auth == NULL) { - code = KADM5_GSS_ERROR; - goto error; - } - r = init_1(&handle->api_version, handle->clnt); - if (r == NULL) { - code = KADM5_RPC_ERROR; -#ifdef DEBUG - clnt_perror(handle->clnt, "init_1 null resp"); -#endif - goto error; - } - if (r->code) { - code = r->code; - goto error; + if (handle->clnt->cl_auth == NULL) { + return KADM5_GSS_ERROR; } + return 0; +} - *server_handle = (void *) handle; - - if (init_type != INIT_CREDS) - krb5_cc_close(handle->context, ccache); +/* + * kadm5_rpc_auth + * + * Create RPC auth handle. Do auth flavor fallback if needed. + */ +static void +kadm5_rpc_auth(kadm5_server_handle_t handle, + kadm5_config_params *params_in, + gss_cred_id_t gss_client_creds, + gss_name_t gss_target) +{ + OM_uint32 gssstat, minor_stat; + struct rpc_gss_sec sec; - goto cleanup; - -error: - /* - * Note that it is illegal for this code to execute if "handle" - * has not been allocated and initialized. I.e., don't use "goto - * error" before the block of code at the top of the function - * that allocates and initializes "handle". - */ - if (handle->cache_name) - free(handle->cache_name); - if (handle->destroy_cache && ccache) - krb5_cc_destroy(handle->context, ccache); - if(handle->clnt && handle->clnt->cl_auth) - AUTH_DESTROY(handle->clnt->cl_auth); - if(handle->clnt) - clnt_destroy(handle->clnt); + /* Allow unauthenticated option for testing. */ + if (params_in != NULL && (params_in->mask & KADM5_CONFIG_NO_AUTH)) + return; -cleanup: - krb5_free_cred_contents(handle->context, &creds); - if (gss_client_creds != GSS_C_NO_CREDENTIAL) - (void) gss_release_cred(&minor_stat, &gss_client_creds); + /* Use RPCSEC_GSS by default. */ + if (params_in == NULL || + !(params_in->mask & KADM5_CONFIG_OLD_AUTH_GSSAPI)) { + sec.mech = gss_mech_krb5; + sec.qop = GSS_C_QOP_DEFAULT; + sec.svc = RPCSEC_GSS_SVC_PRIVACY; + sec.cred = gss_client_creds; + sec.req_flags = GSS_C_MUTUAL_FLAG | GSS_C_REPLAY_FLAG; - if (code) - free(handle); + handle->clnt->cl_auth = authgss_create(handle->clnt, + gss_target, &sec); + if (handle->clnt->cl_auth != NULL) + return; + } - return code; + if (params_in != NULL && (params_in->mask & KADM5_CONFIG_AUTH_NOFALLBACK)) + return; + + /* Fall back to old AUTH_GSSAPI. */ + handle->clnt->cl_auth = auth_gssapi_create(handle->clnt, + &gssstat, + &minor_stat, + gss_client_creds, + gss_target, + (gss_OID) gss_mech_krb5, + GSS_C_MUTUAL_FLAG + | GSS_C_REPLAY_FLAG, + 0, NULL, NULL, NULL); } kadm5_ret_t diff --git a/src/lib/kadm5/srv/ChangeLog b/src/lib/kadm5/srv/ChangeLog index dcadace..eeba868 100644 --- a/src/lib/kadm5/srv/ChangeLog +++ b/src/lib/kadm5/srv/ChangeLog @@ -1,3 +1,13 @@ +2004-12-20 Tom Yu <tlyu@mit.edu> + + * svr_principal.c (add_to_history): Rewrite somewhat, using + temporary variables to make things somewhat more readable. Fix + buffer overflow case where the next pointer points into + unallocated space but resizing wasn't done, i.e., when someone + decreases the policy history count to the exact "right" number. + Fix some memory leaks. To avoid losing entries, shift some + entries forward after growing the array. + 2004-08-21 Tom Yu <tlyu@mit.edu> * libkadm5srv.exports: Update for previous renaming. diff --git a/src/lib/kadm5/srv/adb_free.c b/src/lib/kadm5/srv/adb_free.c deleted file mode 100644 index cfc107d..0000000 --- a/src/lib/kadm5/srv/adb_free.c +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright 1993 OpenVision Technologies, Inc., All Rights Reserved - * - * $Header$ - * - * $Log$ - * Revision 1.3 2000/06/01 02:02:03 tritan - * Check for existance of <memory.h>. - * (from Nathan Neulinger <nneul@umr.edu>) - * - * Revision 1.2 1996/10/18 19:45:49 bjaspan - * * svr_misc_free.c, server_dict.c, adb_policy.c, adb_free.c: - * include stdlib.h instead of malloc.h [krb5-admin/35] - * - * Revision 1.1 1996/07/24 22:23:09 tlyu - * * Makefile.in, configure.in: break out server lib into a - * subdirectory - * - * Revision 1.8 1996/07/22 20:35:16 marc - * this commit includes all the changes on the OV_9510_INTEGRATION and - * OV_MERGE branches. This includes, but is not limited to, the new openvision - * admin system, and major changes to gssapi to add functionality, and bring - * the implementation in line with rfc1964. before committing, the - * code was built and tested for netbsd and solaris. - * - * Revision 1.7.4.1 1996/07/18 03:08:07 marc - * merged in changes from OV_9510_BP to OV_9510_FINAL1 - * - * Revision 1.7.2.1 1996/06/20 02:16:25 marc - * File added to the repository on a branch - * - * Revision 1.7 1996/05/12 06:21:57 marc - * don't use <absolute paths> for "internal header files" - * - * Revision 1.6 1993/12/13 21:15:56 shanzer - * fixed memory leak - * ., - * - * Revision 1.5 1993/12/06 22:20:37 marc - * fixup free functions to use xdr to free the underlying struct - * - * Revision 1.4 1993/11/15 00:29:46 shanzer - * check to make sure pointers are somewhat vaid before freeing. - * - * Revision 1.3 1993/11/09 04:02:24 shanzer - * added some includefiles - * changed bzero to memset - * - * Revision 1.2 1993/11/04 01:54:24 shanzer - * added rcs header .. - * - */ - -#if !defined(lint) && !defined(__CODECENTER__) -static char *rcsid = "$Header$"; -#endif - -#include "adb.h" -#ifdef HAVE_MEMORY_H -#include <memory.h> -#endif -#include <stdlib.h> - -void -osa_free_princ_ent(osa_princ_ent_t val) -{ - XDR xdrs; - - xdrmem_create(&xdrs, NULL, 0, XDR_FREE); - - xdr_osa_princ_ent_rec(&xdrs, val); - free(val); -} - -void -osa_free_policy_ent(osa_policy_ent_t val) -{ - XDR xdrs; - - xdrmem_create(&xdrs, NULL, 0, XDR_FREE); - - xdr_osa_policy_ent_rec(&xdrs, val); - free(val); -} - diff --git a/src/lib/kadm5/srv/adb_openclose.c b/src/lib/kadm5/srv/adb_openclose.c deleted file mode 100644 index 7bb671e..0000000 --- a/src/lib/kadm5/srv/adb_openclose.c +++ /dev/null @@ -1,410 +0,0 @@ -/* - * Copyright 1993 OpenVision Technologies, Inc., All Rights Reserved - * - * $Header$ - */ - -#if !defined(lint) && !defined(__CODECENTER__) -static char *rcsid = "$Header$"; -#endif - -#include <sys/file.h> -#include <fcntl.h> -#include <unistd.h> -#include "adb.h" -#include <stdlib.h> - -#define MAX_LOCK_TRIES 5 - -struct _locklist { - osa_adb_lock_ent lockinfo; - struct _locklist *next; -}; - -osa_adb_ret_t osa_adb_create_db(char *filename, char *lockfilename, - int magic) -{ - int lf; - DB *db; - BTREEINFO btinfo; - - memset(&btinfo, 0, sizeof(btinfo)); - btinfo.flags = 0; - btinfo.cachesize = 0; - btinfo.psize = 4096; - btinfo.lorder = 0; - btinfo.minkeypage = 0; - btinfo.compare = NULL; - btinfo.prefix = NULL; - db = dbopen(filename, O_RDWR | O_CREAT | O_EXCL, 0600, DB_BTREE, &btinfo); - if (db == NULL) - return errno; - if (db->close(db) < 0) - return errno; - - /* only create the lock file if we successfully created the db */ - lf = THREEPARAMOPEN(lockfilename, O_RDWR | O_CREAT | O_EXCL, 0600); - if (lf == -1) - return errno; - (void) close(lf); - - return OSA_ADB_OK; -} - -osa_adb_ret_t osa_adb_destroy_db(char *filename, char *lockfilename, - int magic) -{ - /* the admin databases do not contain security-critical data */ - if (unlink(filename) < 0 || - unlink(lockfilename) < 0) - return errno; - return OSA_ADB_OK; -} - -osa_adb_ret_t osa_adb_rename_db(char *filefrom, char *lockfrom, - char *fileto, char *lockto, int magic) -{ - osa_adb_db_t fromdb, todb; - osa_adb_ret_t ret; - - /* make sure todb exists */ - if ((ret = osa_adb_create_db(fileto, lockto, magic)) && - ret != EEXIST) - return ret; - - if ((ret = osa_adb_init_db(&fromdb, filefrom, lockfrom, magic))) - return ret; - if ((ret = osa_adb_init_db(&todb, fileto, lockto, magic))) { - (void) osa_adb_fini_db(fromdb, magic); - return ret; - } - if ((ret = osa_adb_get_lock(fromdb, OSA_ADB_PERMANENT))) { - (void) osa_adb_fini_db(fromdb, magic); - (void) osa_adb_fini_db(todb, magic); - return ret; - } - if ((ret = osa_adb_get_lock(todb, OSA_ADB_PERMANENT))) { - (void) osa_adb_fini_db(fromdb, magic); - (void) osa_adb_fini_db(todb, magic); - return ret; - } - if ((rename(filefrom, fileto) < 0)) { - (void) osa_adb_fini_db(fromdb, magic); - (void) osa_adb_fini_db(todb, magic); - return errno; - } - /* - * Do not release the lock on fromdb because it is being renamed - * out of existence; no one can ever use it again. - */ - if ((ret = osa_adb_release_lock(todb))) { - (void) osa_adb_fini_db(fromdb, magic); - (void) osa_adb_fini_db(todb, magic); - return ret; - } - - (void) osa_adb_fini_db(fromdb, magic); - (void) osa_adb_fini_db(todb, magic); - return 0; -} - -osa_adb_ret_t osa_adb_init_db(osa_adb_db_t *dbp, char *filename, - char *lockfilename, int magic) -{ - osa_adb_db_t db; - static struct _locklist *locklist = NULL; - struct _locklist *lockp; - krb5_error_code code; - - if (dbp == NULL || filename == NULL) - return EINVAL; - - db = (osa_adb_princ_t) malloc(sizeof(osa_adb_db_ent)); - if (db == NULL) - return ENOMEM; - - memset(db, 0, sizeof(*db)); - db->info.hash = NULL; - db->info.bsize = 256; - db->info.ffactor = 8; - db->info.nelem = 25000; - db->info.lorder = 0; - - db->btinfo.flags = 0; - db->btinfo.cachesize = 0; - db->btinfo.psize = 4096; - db->btinfo.lorder = 0; - db->btinfo.minkeypage = 0; - db->btinfo.compare = NULL; - db->btinfo.prefix = NULL; - /* - * A process is allowed to open the same database multiple times - * and access it via different handles. If the handles use - * distinct lockinfo structures, things get confused: lock(A), - * lock(B), release(B) will result in the kernel unlocking the - * lock file but handle A will still think the file is locked. - * Therefore, all handles using the same lock file must share a - * single lockinfo structure. - * - * It is not sufficient to have a single lockinfo structure, - * however, because a single process may also wish to open - * multiple different databases simultaneously, with different - * lock files. This code used to use a single static lockinfo - * structure, which means that the second database opened used - * the first database's lock file. This was Bad. - * - * We now maintain a linked list of lockinfo structures, keyed by - * lockfilename. An entry is added when this function is called - * with a new lockfilename, and all subsequent calls with that - * lockfilename use the existing entry, updating the refcnt. - * When the database is closed with fini_db(), the refcnt is - * decremented, and when it is zero the lockinfo structure is - * freed and reset. The entry in the linked list, however, is - * never removed; it will just be reinitialized the next time - * init_db is called with the right lockfilename. - */ - - /* find or create the lockinfo structure for lockfilename */ - lockp = locklist; - while (lockp) { - if (strcmp(lockp->lockinfo.filename, lockfilename) == 0) - break; - else - lockp = lockp->next; - } - if (lockp == NULL) { - /* doesn't exist, create it, add to list */ - lockp = (struct _locklist *) malloc(sizeof(*lockp)); - if (lockp == NULL) { - free(db); - return ENOMEM; - } - memset(lockp, 0, sizeof(*lockp)); - lockp->next = locklist; - locklist = lockp; - } - - /* now initialize lockp->lockinfo if necessary */ - if (lockp->lockinfo.lockfile == NULL) { - if ((code = krb5_init_context(&lockp->lockinfo.context))) { - free(db); - return((osa_adb_ret_t) code); - } - - /* - * needs be open read/write so that write locking can work with - * POSIX systems - */ - lockp->lockinfo.filename = strdup(lockfilename); - if ((lockp->lockinfo.lockfile = fopen(lockfilename, "r+")) == NULL) { - /* - * maybe someone took away write permission so we could only - * get shared locks? - */ - if ((lockp->lockinfo.lockfile = fopen(lockfilename, "r")) - == NULL) { - free(db); - return OSA_ADB_NOLOCKFILE; - } - } - lockp->lockinfo.lockmode = lockp->lockinfo.lockcnt = 0; - } - - /* lockp is set, lockinfo is initialized, update the reference count */ - db->lock = &lockp->lockinfo; - db->lock->refcnt++; - - db->opencnt = 0; - db->filename = strdup(filename); - db->magic = magic; - - *dbp = db; - - return OSA_ADB_OK; -} - -osa_adb_ret_t osa_adb_fini_db(osa_adb_db_t db, int magic) -{ - if (db->magic != magic) - return EINVAL; - if (db->lock->refcnt == 0) { - /* barry says this can't happen */ - return OSA_ADB_FAILURE; - } else { - db->lock->refcnt--; - } - - if (db->lock->refcnt == 0) { - /* - * Don't free db->lock->filename, it is used as a key to - * find the lockinfo entry in the linked list. If the - * lockfile doesn't exist, we must be closing the database - * after trashing it. This has to be allowed, so don't - * generate an error. - */ - if (db->lock->lockmode != OSA_ADB_PERMANENT) - (void) fclose(db->lock->lockfile); - db->lock->lockfile = NULL; - krb5_free_context(db->lock->context); - } - - db->magic = 0; - free(db->filename); - free(db); - return OSA_ADB_OK; -} - -osa_adb_ret_t osa_adb_get_lock(osa_adb_db_t db, int mode) -{ - int tries, gotlock, perm, krb5_mode, ret; - - if (db->lock->lockmode >= mode) { - /* No need to upgrade lock, just incr refcnt and return */ - db->lock->lockcnt++; - return(OSA_ADB_OK); - } - - perm = 0; - switch (mode) { - case OSA_ADB_PERMANENT: - perm = 1; - case OSA_ADB_EXCLUSIVE: - krb5_mode = KRB5_LOCKMODE_EXCLUSIVE; - break; - case OSA_ADB_SHARED: - krb5_mode = KRB5_LOCKMODE_SHARED; - break; - default: - return(EINVAL); - } - - for (gotlock = tries = 0; tries < MAX_LOCK_TRIES; tries++) { - if ((ret = krb5_lock_file(db->lock->context, - fileno(db->lock->lockfile), - krb5_mode|KRB5_LOCKMODE_DONTBLOCK)) == 0) { - gotlock++; - break; - } else if (ret == EBADF && mode == OSA_ADB_EXCLUSIVE) - /* tried to exclusive-lock something we don't have */ - /* write access to */ - return OSA_ADB_NOEXCL_PERM; - - sleep(1); - } - - /* test for all the likely "can't get lock" error codes */ - if (ret == EACCES || ret == EAGAIN || ret == EWOULDBLOCK) - return OSA_ADB_CANTLOCK_DB; - else if (ret != 0) - return ret; - - /* - * If the file no longer exists, someone acquired a permanent - * lock. If that process terminates its exclusive lock is lost, - * but if we already had the file open we can (probably) lock it - * even though it has been unlinked. So we need to insist that - * it exist. - */ - if (access(db->lock->filename, F_OK) < 0) { - (void) krb5_lock_file(db->lock->context, - fileno(db->lock->lockfile), - KRB5_LOCKMODE_UNLOCK); - return OSA_ADB_NOLOCKFILE; - } - - /* we have the shared/exclusive lock */ - - if (perm) { - if (unlink(db->lock->filename) < 0) { - /* somehow we can't delete the file, but we already */ - /* have the lock, so release it and return */ - - ret = errno; - (void) krb5_lock_file(db->lock->context, - fileno(db->lock->lockfile), - KRB5_LOCKMODE_UNLOCK); - - /* maybe we should return CANTLOCK_DB.. but that would */ - /* look just like the db was already locked */ - return ret; - } - - /* this releases our exclusive lock.. which is okay because */ - /* now no one else can get one either */ - (void) fclose(db->lock->lockfile); - } - - db->lock->lockmode = mode; - db->lock->lockcnt++; - return OSA_ADB_OK; -} - -osa_adb_ret_t osa_adb_release_lock(osa_adb_db_t db) -{ - int ret, fd; - - if (!db->lock->lockcnt) /* lock already unlocked */ - return OSA_ADB_NOTLOCKED; - - if (--db->lock->lockcnt == 0) { - if (db->lock->lockmode == OSA_ADB_PERMANENT) { - /* now we need to create the file since it does not exist */ - fd = THREEPARAMOPEN(db->lock->filename,O_RDWR | O_CREAT | O_EXCL, - 0600); - if ((db->lock->lockfile = fdopen(fd, "w+")) == NULL) - return OSA_ADB_NOLOCKFILE; - } else if ((ret = krb5_lock_file(db->lock->context, - fileno(db->lock->lockfile), - KRB5_LOCKMODE_UNLOCK))) - return ret; - - db->lock->lockmode = 0; - } - return OSA_ADB_OK; -} - -osa_adb_ret_t osa_adb_open_and_lock(osa_adb_princ_t db, int locktype) -{ - int ret; - - ret = osa_adb_get_lock(db, locktype); - if (ret != OSA_ADB_OK) - return ret; - if (db->opencnt) - goto open_ok; - - db->db = dbopen(db->filename, O_RDWR, 0600, DB_BTREE, &db->btinfo); - if (db->db != NULL) - goto open_ok; - switch (errno) { -#ifdef EFTYPE - case EFTYPE: -#endif - case EINVAL: - db->db = dbopen(db->filename, O_RDWR, 0600, DB_HASH, &db->info); - if (db->db != NULL) - goto open_ok; - default: - (void) osa_adb_release_lock(db); - if (errno == EINVAL) - return OSA_ADB_BAD_DB; - return errno; - } -open_ok: - db->opencnt++; - return OSA_ADB_OK; -} - -osa_adb_ret_t osa_adb_close_and_unlock(osa_adb_princ_t db) -{ - if (--db->opencnt) - return osa_adb_release_lock(db); - if(db->db != NULL && db->db->close(db->db) == -1) { - (void) osa_adb_release_lock(db); - return OSA_ADB_FAILURE; - } - - db->db = NULL; - - return(osa_adb_release_lock(db)); -} diff --git a/src/lib/kadm5/srv/adb_policy.c b/src/lib/kadm5/srv/adb_policy.c deleted file mode 100644 index f081551..0000000 --- a/src/lib/kadm5/srv/adb_policy.c +++ /dev/null @@ -1,410 +0,0 @@ -/* - * Copyright 1993 OpenVision Technologies, Inc., All Rights Reserved - * - * $Header$ - */ - -#if !defined(lint) && !defined(__CODECENTER__) -static char *rcsid = "$Header$"; -#endif - -#include <sys/file.h> -#include <fcntl.h> -#include "adb.h" -#include <stdlib.h> -#include <string.h> -#include <errno.h> - - -#define OPENLOCK(db, mode) \ -{ \ - int olret; \ - if (db == NULL) \ - return EINVAL; \ - else if (db->magic != OSA_ADB_POLICY_DB_MAGIC) \ - return OSA_ADB_DBINIT; \ - else if ((olret = osa_adb_open_and_lock(db, mode)) != OSA_ADB_OK) \ - return olret; \ - } - -#define CLOSELOCK(db) \ -{ \ - int cl_ret; \ - if ((cl_ret = osa_adb_close_and_unlock(db)) != OSA_ADB_OK) \ - return cl_ret; \ -} - -osa_adb_ret_t osa_adb_create_policy_db(kadm5_config_params *params) -{ - return osa_adb_create_db(params->admin_dbname, - params->admin_lockfile, - OSA_ADB_POLICY_DB_MAGIC); -} - -osa_adb_ret_t osa_adb_rename_policy_db(kadm5_config_params *fromparams, - kadm5_config_params *toparams) -{ - return osa_adb_rename_db(fromparams->admin_dbname, - fromparams->admin_lockfile, - toparams->admin_dbname, - toparams->admin_lockfile, - OSA_ADB_POLICY_DB_MAGIC); -} - -osa_adb_ret_t osa_adb_destroy_policy_db(kadm5_config_params *params) -{ - return osa_adb_destroy_db(params->admin_dbname, - params->admin_lockfile, - OSA_ADB_POLICY_DB_MAGIC); -} - -osa_adb_ret_t osa_adb_open_policy(osa_adb_princ_t *dbp, - kadm5_config_params *rparams) -{ - return osa_adb_init_db(dbp, rparams->admin_dbname, - rparams->admin_lockfile, - OSA_ADB_POLICY_DB_MAGIC); -} - -osa_adb_ret_t osa_adb_close_policy(osa_adb_princ_t db) -{ - return osa_adb_fini_db(db, OSA_ADB_POLICY_DB_MAGIC); -} - -/* - * Function: osa_adb_create_policy - * - * Purpose: create a policy entry in the policy db. - * - * Arguments: - * entry (input) pointer to the entry to be added - * <return value> OSA_ADB_OK on success, else error code. - * - * Requires: - * entry have a valid name. - * - * Effects: - * creates the entry in the db - * - * Modifies: - * the policy db. - * - */ -osa_adb_ret_t -osa_adb_create_policy(osa_adb_policy_t db, osa_policy_ent_t entry) -{ - DBT dbkey; - DBT dbdata; - XDR xdrs; - int ret; - - OPENLOCK(db, OSA_ADB_EXCLUSIVE); - - if(entry->name == NULL) { - ret = EINVAL; - goto error; - } - dbkey.data = entry->name; - dbkey.size = (strlen(entry->name) + 1); - - switch(db->db->get(db->db, &dbkey, &dbdata, 0)) { - case 0: - ret = OSA_ADB_DUP; - goto error; - case 1: - break; - default: - ret = errno; - goto error; - } - xdralloc_create(&xdrs, XDR_ENCODE); - if(!xdr_osa_policy_ent_rec(&xdrs, entry)) { - xdr_destroy(&xdrs); - ret = OSA_ADB_XDR_FAILURE; - goto error; - } - dbdata.data = xdralloc_getdata(&xdrs); - dbdata.size = xdr_getpos(&xdrs); - switch(db->db->put(db->db, &dbkey, &dbdata, R_NOOVERWRITE)) { - case 0: - if((db->db->sync(db->db, 0)) == -1) - ret = OSA_ADB_FAILURE; - ret = OSA_ADB_OK; - break; - case 1: - ret = OSA_ADB_DUP; - break; - default: - ret = OSA_ADB_FAILURE; - break; - } - xdr_destroy(&xdrs); - -error: - CLOSELOCK(db); - return ret; -} - -/* - * Function: osa_adb_destroy_policy - * - * Purpose: destroy a policy entry - * - * Arguments: - * db (input) database handle - * name (input) name of policy - * <return value> OSA_ADB_OK on success, or error code. - * - * Requires: - * db being valid. - * name being non-null. - * Effects: - * deletes policy from db. - * - * Modifies: - * policy db. - * - */ -osa_adb_ret_t -osa_adb_destroy_policy(osa_adb_policy_t db, kadm5_policy_t name) -{ - DBT dbkey; - int status, ret; - - OPENLOCK(db, OSA_ADB_EXCLUSIVE); - - if(name == NULL) { - ret = EINVAL; - goto error; - } - dbkey.data = name; - dbkey.size = (strlen(name) + 1); - - status = db->db->del(db->db, &dbkey, 0); - switch(status) { - case 1: - ret = OSA_ADB_NOENT; - goto error; - case 0: - if ((db->db->sync(db->db, 0)) == -1) { - ret = OSA_ADB_FAILURE; - goto error; - } - ret = OSA_ADB_OK; - break; - default: - ret = OSA_ADB_FAILURE; - goto error; - } - -error: - CLOSELOCK(db); - return ret; -} - -/* - * Function: osa_adb_get_policy - * - * Purpose: retrieve policy - * - * Arguments: - * db (input) db handle - * name (input) name of policy - * entry (output) policy entry - * <return value> 0 on success, error code on failure. - * - * Requires: - * Effects: - * Modifies: - */ -osa_adb_ret_t -osa_adb_get_policy(osa_adb_policy_t db, kadm5_policy_t name, - osa_policy_ent_t *entry) -{ - DBT dbkey; - DBT dbdata; - XDR xdrs; - int ret; - char *aligned_data; - - OPENLOCK(db, OSA_ADB_SHARED); - - if(name == NULL) { - ret = EINVAL; - goto error; - } - dbkey.data = name; - dbkey.size = (strlen(dbkey.data) + 1); - dbdata.data = NULL; - dbdata.size = 0; - switch((db->db->get(db->db, &dbkey, &dbdata, 0))) { - case 1: - ret = OSA_ADB_NOENT; - goto error; - case 0: - break; - default: - ret = OSA_ADB_FAILURE; - goto error; - } - if (!(*(entry) = (osa_policy_ent_t)malloc(sizeof(osa_policy_ent_rec)))) { - ret = ENOMEM; - goto error; - } - if (!(aligned_data = (char *) malloc(dbdata.size))) { - ret = ENOMEM; - goto error; - } - memcpy(aligned_data, dbdata.data, dbdata.size); - memset(*entry, 0, sizeof(osa_policy_ent_rec)); - xdrmem_create(&xdrs, aligned_data, dbdata.size, XDR_DECODE); - if (!xdr_osa_policy_ent_rec(&xdrs, *entry)) - ret = OSA_ADB_FAILURE; - else ret = OSA_ADB_OK; - xdr_destroy(&xdrs); - free(aligned_data); - -error: - CLOSELOCK(db); - return ret; -} - -/* - * Function: osa_adb_put_policy - * - * Purpose: update a policy in the dababase - * - * Arguments: - * db (input) db handle - * entry (input) policy entry - * <return value> 0 on success error code on failure. - * - * Requires: - * [requires] - * - * Effects: - * [effects] - * - * Modifies: - * [modifies] - * - */ -osa_adb_ret_t -osa_adb_put_policy(osa_adb_policy_t db, osa_policy_ent_t entry) -{ - DBT dbkey; - DBT dbdata; - DBT tmpdb; - XDR xdrs; - int ret; - - OPENLOCK(db, OSA_ADB_EXCLUSIVE); - - if(entry->name == NULL) { - ret = EINVAL; - goto error; - } - dbkey.data = entry->name; - dbkey.size = (strlen(entry->name) + 1); - switch(db->db->get(db->db, &dbkey, &tmpdb, 0)) { - case 0: - break; - case 1: - ret = OSA_ADB_NOENT; - goto error; - default: - ret = OSA_ADB_FAILURE; - goto error; - } - xdralloc_create(&xdrs, XDR_ENCODE); - if(!xdr_osa_policy_ent_rec(&xdrs, entry)) { - xdr_destroy(&xdrs); - ret = OSA_ADB_XDR_FAILURE; - goto error; - } - dbdata.data = xdralloc_getdata(&xdrs); - dbdata.size = xdr_getpos(&xdrs); - switch(db->db->put(db->db, &dbkey, &dbdata, 0)) { - case 0: - if((db->db->sync(db->db, 0)) == -1) - ret = OSA_ADB_FAILURE; - ret = OSA_ADB_OK; - break; - default: - ret = OSA_ADB_FAILURE; - break; - } - xdr_destroy(&xdrs); - -error: - CLOSELOCK(db); - return ret; -} - -/* - * Function: osa_adb_iter_policy - * - * Purpose: iterate over the policy database. - * - * Arguments: - * db (input) db handle - * func (input) fucntion pointer to call - * data opaque data type - * <return value> 0 on success error code on failure - * - * Requires: - * Effects: - * Modifies: - */ -osa_adb_ret_t -osa_adb_iter_policy(osa_adb_policy_t db, osa_adb_iter_policy_func func, - void *data) -{ - DBT dbkey, - dbdata; - XDR xdrs; - int ret; - osa_policy_ent_t entry; - char *aligned_data; - - OPENLOCK(db, OSA_ADB_EXCLUSIVE); /* hmmm */ - - if((ret = db->db->seq(db->db, &dbkey, &dbdata, R_FIRST)) == -1) { - ret = errno; - goto error; - } - - while (ret == 0) { - if (!(entry = (osa_policy_ent_t) malloc(sizeof(osa_policy_ent_rec)))) { - ret = ENOMEM; - goto error; - } - - if(!(aligned_data = (char *) malloc(dbdata.size))) { - ret = ENOMEM; - goto error; - } - memcpy(aligned_data, dbdata.data, dbdata.size); - - memset(entry, 0, sizeof(osa_policy_ent_rec)); - xdrmem_create(&xdrs, aligned_data, dbdata.size, XDR_DECODE); - if(!xdr_osa_policy_ent_rec(&xdrs, entry)) { - xdr_destroy(&xdrs); - free(aligned_data); - ret = OSA_ADB_FAILURE; - goto error; - } - (*func)(data, entry); - xdr_destroy(&xdrs); - free(aligned_data); - osa_free_policy_ent(entry); - ret = db->db->seq(db->db, &dbkey, &dbdata, R_NEXT); - } - if(ret == -1) - ret = errno; - else ret = OSA_ADB_OK; - -error: - CLOSELOCK(db); - return ret; -} diff --git a/src/lib/kadm5/srv/svr_principal.c b/src/lib/kadm5/srv/svr_principal.c index c567f83..7dc2d8f 100644 --- a/src/lib/kadm5/srv/svr_principal.c +++ b/src/lib/kadm5/srv/svr_principal.c @@ -989,35 +989,46 @@ void free_history_entry(krb5_context context, osa_pw_hist_ent *hist) * array where the next element should be written, and must be [0, * adb->old_key_len). */ -#define KADM_MOD(x) (x + adb->old_key_next) % adb->old_key_len static kadm5_ret_t add_to_history(krb5_context context, osa_princ_ent_t adb, kadm5_policy_ent_t pol, osa_pw_hist_ent *pw) { osa_pw_hist_ent *histp; - int i; + uint32_t nhist; + unsigned int i, knext, nkeys; + nhist = pol->pw_history_num; /* A history of 1 means just check the current password */ - if (pol->pw_history_num == 1) + if (nhist <= 1) return 0; + nkeys = adb->old_key_len; + knext = adb->old_key_next; /* resize the adb->old_keys array if necessary */ - if (adb->old_key_len < pol->pw_history_num-1) { + if (nkeys + 1 < nhist) { if (adb->old_keys == NULL) { adb->old_keys = (osa_pw_hist_ent *) - malloc((adb->old_key_len + 1) * sizeof (osa_pw_hist_ent)); + malloc((nkeys + 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)); + (nkeys + 1) * sizeof (osa_pw_hist_ent)); } if (adb->old_keys == NULL) return(ENOMEM); - memset(&adb->old_keys[adb->old_key_len],0,sizeof(osa_pw_hist_ent)); - adb->old_key_len++; - } else if (adb->old_key_len > pol->pw_history_num-1) { + memset(&adb->old_keys[nkeys], 0, sizeof(osa_pw_hist_ent)); + nkeys = ++adb->old_key_len; + /* + * To avoid losing old keys, shift forward each entry after + * knext. + */ + for (i = nkeys - 1; i > knext; i--) { + adb->old_keys[i] = adb->old_keys[i - 1]; + } + memset(&adb->old_keys[knext], 0, sizeof(osa_pw_hist_ent)); + } else if (nkeys + 1 > nhist) { /* * The policy must have changed! Shrink the array. * Can't simply realloc() down, since it might be wrapped. @@ -1027,46 +1038,64 @@ static kadm5_ret_t add_to_history(krb5_context context, * where N = pw_history_num - 1 is the length of the * shortened list. Matt Crawford, FNAL */ + /* + * M = adb->old_key_len, N = pol->pw_history_num - 1 + * + * tmp[0] .. tmp[N-1] = old[(knext-N)%M] .. old[(knext-1)%M] + */ int j; - histp = (osa_pw_hist_ent *) - malloc((pol->pw_history_num - 1) * sizeof (osa_pw_hist_ent)); - if (histp) { - for (i = 0; i < pol->pw_history_num - 1; i++) { - /* We need the number we use the modulus operator on to be - positive, so after subtracting pol->pw_history_num-1, we - add back adb->old_key_len. */ - j = KADM_MOD(i - (pol->pw_history_num - 1) + adb->old_key_len); - histp[i] = adb->old_keys[j]; + osa_pw_hist_t tmp; + + tmp = (osa_pw_hist_ent *) + malloc((nhist - 1) * sizeof (osa_pw_hist_ent)); + if (tmp == NULL) + return ENOMEM; + for (i = 0; i < nhist - 1; i++) { + /* + * Add nkeys once before taking remainder to avoid + * negative values. + */ + j = (i + nkeys + knext - (nhist - 1)) % nkeys; + tmp[i] = adb->old_keys[j]; + } + /* Now free the ones we don't keep (the oldest ones) */ + for (i = 0; i < nkeys - (nhist - 1); i++) { + j = (i + nkeys + knext) % nkeys; + histp = &adb->old_keys[j]; + for (j = 0; j < histp->n_key_data; j++) { + krb5_free_key_data_contents(context, &histp->key_data[j]); } - /* Now free the ones we don't keep (the oldest ones) */ - for (i = 0; i < adb->old_key_len - (pol->pw_history_num - 1); i++) - for (j = 0; j < adb->old_keys[KADM_MOD(i)].n_key_data; j++) - krb5_free_key_data_contents(context, - &adb->old_keys[KADM_MOD(i)].key_data[j]); - free((void *)adb->old_keys); - adb->old_keys = histp; - adb->old_key_len = pol->pw_history_num - 1; - adb->old_key_next = 0; - } else { - return(ENOMEM); + free(histp->key_data); } + free((void *)adb->old_keys); + adb->old_keys = tmp; + nkeys = adb->old_key_len = nhist - 1; + knext = adb->old_key_next = 0; } + /* + * If nhist decreased since the last password change, and nkeys+1 + * is less than the previous nhist, it is possible for knext to + * index into unallocated space. This condition would not be + * caught by the resizing code above. + */ + if (knext + 1 > nkeys) + knext = adb->old_key_next = 0; /* free the old pw history entry if it contains data */ - histp = &adb->old_keys[adb->old_key_next]; + histp = &adb->old_keys[knext]; for (i = 0; i < histp->n_key_data; i++) krb5_free_key_data_contents(context, &histp->key_data[i]); - + free(histp->key_data); + /* store the new entry */ - adb->old_keys[adb->old_key_next] = *pw; + adb->old_keys[knext] = *pw; /* update the next pointer */ - if (++adb->old_key_next == pol->pw_history_num-1) - adb->old_key_next = 0; + if (++adb->old_key_next == nhist - 1) + adb->old_key_next = 0; return(0); } -#undef KADM_MOD #ifdef USE_PASSWORD_SERVER diff --git a/src/lib/kadm5/unit-test/ChangeLog b/src/lib/kadm5/unit-test/ChangeLog index 7b54c00..4b0777e 100644 --- a/src/lib/kadm5/unit-test/ChangeLog +++ b/src/lib/kadm5/unit-test/ChangeLog @@ -1,3 +1,10 @@ +2005-02-10 Tom Yu <tlyu@mit.edu> + + * api.2/init-v2.exp: Handle improved error codes from + client_init.c. + (test152): Expect KRB5_FCC_NOFILE. + (test153): Expect KRB5_CC_NOTFOUND. + 2004-08-20 Tom Yu <tlyu@mit.edu> * Makefile.in (init-test): Don't use local copy of client_init.o diff --git a/src/lib/kadm5/unit-test/api.2/init-v2.exp b/src/lib/kadm5/unit-test/api.2/init-v2.exp index 0893009..1e3ef74 100644 --- a/src/lib/kadm5/unit-test/api.2/init-v2.exp +++ b/src/lib/kadm5/unit-test/api.2/init-v2.exp @@ -605,7 +605,7 @@ proc test152 {} { kadm5_init_with_creds testuser null $KADM5_ADMIN_SERVICE \ null $KADM5_STRUCT_VERSION $KADM5_API_VERSION_2 \ server_handle - } "GSS_ERROR" + } "KRB5_FCC_NOFILE" } if {$RPC} test152 @@ -618,7 +618,7 @@ proc test153 {} { kadm5_init_with_creds testuser null $KADM5_ADMIN_SERVICE \ null $KADM5_STRUCT_VERSION $KADM5_API_VERSION_2 \ server_handle - } "GSS_ERROR" + } "KRB5_CC_NOTFOUND" } if {$RPC} test153 diff --git a/src/lib/kdb/fetch_mkey.c b/src/lib/kdb/fetch_mkey.c deleted file mode 100644 index 5d63b8c..0000000 --- a/src/lib/kdb/fetch_mkey.c +++ /dev/null @@ -1,182 +0,0 @@ -/* - * lib/kdb/fetch_mkey.c - * - * Copyright 1990 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. - * - * - * krb5_db_fetch_mkey(): - * Fetch a database master key from somewhere. - */ - -/* - * Copyright (C) 1998 by the FundsXpress, INC. - * - * 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 FundsXpress. not be used in advertising or publicity pertaining - * to distribution of the software without specific, written prior - * permission. FundsXpress 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. - */ - -#include "k5-int.h" - -/* these are available to other funcs, and the pointers may be reassigned */ - -char *krb5_mkey_pwd_prompt1 = KRB5_KDC_MKEY_1; -char *krb5_mkey_pwd_prompt2 = KRB5_KDC_MKEY_2; - -/* - * Get the KDC database master key from somewhere, filling it into *key. - * - * key->enctype should be set to the desired key type. - * - * if fromkeyboard is TRUE, then the master key is read as a password - * from the user's terminal. In this case, - * eblock should point to a block with an appropriate string_to_key function. - * if twice is TRUE, the password is read twice for verification. - * - * mname is the name of the key sought; this can be used by the string_to_key - * function or by some other method to isolate the desired key. - * - */ - -#ifndef min -#define min(a,b) (((a) < (b)) ? (a) : (b)) -#endif - -krb5_error_code -krb5_db_fetch_mkey(context, mname, etype, fromkeyboard, twice, keyfile, - salt, key) - krb5_context context; - krb5_principal mname; - krb5_enctype etype; - krb5_boolean fromkeyboard; - krb5_boolean twice; - char *keyfile; - krb5_data * salt; - krb5_keyblock * key; -{ - krb5_error_code retval; - char password[BUFSIZ]; - krb5_data pwd; - unsigned int size = sizeof(password); - - if (fromkeyboard) { - krb5_data scratch; - - if ((retval = krb5_read_password(context, krb5_mkey_pwd_prompt1, - twice ? krb5_mkey_pwd_prompt2 : 0, - password, &size))) - return(retval); - - pwd.data = password; - pwd.length = size; - if (!salt) { - retval = krb5_principal2salt(context, mname, &scratch); - if (retval) - return retval; - } - retval = krb5_c_string_to_key(context, etype, &pwd, salt?salt:&scratch, - key); - - if (!salt) - krb5_xfree(scratch.data); - memset(password, 0, sizeof(password)); /* erase it */ - return retval; - - } else { - /* from somewhere else */ - krb5_ui_2 enctype; - char defkeyfile[MAXPATHLEN+1]; - krb5_data *realm = krb5_princ_realm(context, mname); - FILE *kf; - - retval = 0; - key->magic = KV5M_KEYBLOCK; - (void) strcpy(defkeyfile, DEFAULT_KEYFILE_STUB); - (void) strncat(defkeyfile, realm->data, - min(sizeof(defkeyfile)-sizeof(DEFAULT_KEYFILE_STUB)-1, - realm->length)); - defkeyfile[sizeof(defkeyfile) - 1] = '\0'; - -#ifdef ANSI_STDIO - if (!(kf = fopen((keyfile) ? keyfile : defkeyfile, "rb"))) -#else - if (!(kf = fopen((keyfile) ? keyfile : defkeyfile, "r"))) -#endif - return KRB5_KDB_CANTREAD_STORED; - if (fread((krb5_pointer) &enctype, 2, 1, kf) != 1) { - retval = KRB5_KDB_CANTREAD_STORED; - goto errout; - } - if (key->enctype == ENCTYPE_UNKNOWN) - key->enctype = enctype; - else if (enctype != key->enctype) { - retval = KRB5_KDB_BADSTORED_MKEY; - goto errout; - } - if (fread((krb5_pointer) &key->length, - sizeof(key->length), 1, kf) != 1) { - retval = KRB5_KDB_CANTREAD_STORED; - goto errout; - } - if (!key->length || ((int) key->length) < 0) { - retval = KRB5_KDB_BADSTORED_MKEY; - goto errout; - } - - if (!(key->contents = (krb5_octet *)malloc(key->length))) { - retval = ENOMEM; - goto errout; - } - if (fread((krb5_pointer) key->contents, - sizeof(key->contents[0]), key->length, kf) - != key->length) { - retval = KRB5_KDB_CANTREAD_STORED; - memset(key->contents, 0, key->length); - free(key->contents); - key->contents = 0; - } else - retval = 0; - - errout: - (void) fclose(kf); - return retval; - } -} diff --git a/src/lib/kdb/kdb_compat.h b/src/lib/kdb/kdb_compat.h deleted file mode 100644 index 540d4a2..0000000 --- a/src/lib/kdb/kdb_compat.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * lib/kdb/kdb_compat.h - * - * Copyright 1994 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. - * - * - * KDC Database interface definitions. - */ - - -typedef struct _old_krb5_encrypted_keyblock { - krb5_enctype enctype; - int length; - krb5_octet *contents; -} old_krb5_encrypted_keyblock; - -typedef struct old_krb5_principal_data { - krb5_magic magic; - krb5_data realm; - krb5_data *data; /* An array of strings */ - krb5_int32 length; - krb5_int32 type; -} old_krb5_principal_data; - -typedef old_krb5_principal_data *old_krb5_principal; - - -/* - * Note --- this structure cannot be modified without changing the - * database version number in libkdb.a - */ -typedef struct _old_krb5_db_entry { - old_krb5_principal principal; - old_krb5_encrypted_keyblock key; - krb5_kvno kvno; - krb5_deltat max_life; - krb5_deltat max_renewable_life; - krb5_kvno mkvno; /* master encryption key vno */ - - krb5_timestamp expiration; /* This is when the client expires */ - krb5_timestamp pw_expiration; /* This is when its password does */ - krb5_timestamp last_pwd_change; /* Last time of password change */ - krb5_timestamp last_success; /* Last successful password */ - - krb5_timestamp last_failed; /* Last failed password attempt */ - krb5_kvno fail_auth_count; /* # of failed password attempts */ - - old_krb5_principal mod_name; - krb5_timestamp mod_date; - krb5_flags attributes; - krb5_int32 salt_type:8, - salt_length:24; - krb5_octet *salt; - old_krb5_encrypted_keyblock alt_key; - krb5_int32 alt_salt_type:8, - alt_salt_length:24; - krb5_octet *alt_salt; - - krb5_int32 expansion[8]; -} old_krb5_db_entry; - diff --git a/src/lib/kdb/kdb_db2.c b/src/lib/kdb/kdb_db2.c deleted file mode 100644 index bcd08a2..0000000 --- a/src/lib/kdb/kdb_db2.c +++ /dev/null @@ -1,1434 +0,0 @@ -/* - * lib/kdb/kdb_db2.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. 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. - * - */ - -/* - * Copyright (C) 1998 by the FundsXpress, INC. - * - * 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 FundsXpress. not be used in advertising or publicity pertaining - * to distribution of the software without specific, written prior - * permission. FundsXpress 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. - */ - -#if HAVE_UNISTD_H -#include <unistd.h> -#endif - -#include "k5-int.h" -#include <db.h> -#include <stdio.h> -#include <errno.h> -#include <utime.h> - -#define OLD_COMPAT_VERSION_1 - -#ifdef OLD_COMPAT_VERSION_1 -#include "kdb_compat.h" -#endif - -#include "kdb_db2.h" - -static char *gen_dbsuffix - (char *, char * ); -static krb5_error_code krb5_db2_db_start_update - (krb5_context); -static krb5_error_code krb5_db2_db_end_update - (krb5_context); -static krb5_error_code krb5_db2_db_set_hashfirst - (krb5_context, int); - -static char default_db_name[] = DEFAULT_KDB_FILE; - -/* - * Locking: - * - * There are two distinct locking protocols used. One is designed to - * lock against processes (the admin_server, for one) which make - * incremental changes to the database; the other is designed to lock - * against utilities (kdb5_edit, kpropd, kdb5_convert) which replace the - * entire database in one fell swoop. - * - * The first locking protocol is implemented using flock() in the - * krb_dbl_lock() and krb_dbl_unlock routines. - * - * The second locking protocol is necessary because DBM "files" are - * actually implemented as two separate files, and it is impossible to - * atomically rename two files simultaneously. It assumes that the - * database is replaced only very infrequently in comparison to the time - * needed to do a database read operation. - * - * A third file is used as a "version" semaphore; the modification - * time of this file is the "version number" of the database. - * At the start of a read operation, the reader checks the version - * number; at the end of the read operation, it checks again. If the - * version number changed, or if the semaphore was nonexistant at - * either time, the reader sleeps for a second to let things - * stabilize, and then tries again; if it does not succeed after - * KRB5_DBM_MAX_RETRY attempts, it gives up. - * - * On update, the semaphore file is deleted (if it exists) before any - * update takes place; at the end of the update, it is replaced, with - * a version number strictly greater than the version number which - * existed at the start of the update. - * - * If the system crashes in the middle of an update, the semaphore - * file is not automatically created on reboot; this is a feature, not - * a bug, since the database may be inconsistant. Note that the - * absence of a semaphore file does not prevent another _update_ from - * taking place later. Database replacements take place automatically - * only on slave servers; a crash in the middle of an update will be - * fixed by the next slave propagation. A crash in the middle of an - * update on the master would be somewhat more serious, but this would - * likely be noticed by an administrator, who could fix the problem and - * retry the operation. - */ - -#define free_dbsuffix(name) free(name) - -/* - * Routines to deal with context. - */ -#define k5db2_inited(c) (c && c->db_context && \ - ((krb5_db2_context *) c->db_context)->db_inited) - -/* - * Restore the default context. - */ -static void -k5db2_clear_context(dbctx) - krb5_db2_context *dbctx; -{ - /* - * Free any dynamically allocated memory. File descriptors and locks - * are the caller's problem. - */ - if (dbctx->db_lf_name) - free(dbctx->db_lf_name); - if (dbctx->db_name && (dbctx->db_name != default_db_name)) - free(dbctx->db_name); - /* - * Clear the structure and reset the defaults. - */ - memset((char *) dbctx, 0, sizeof(krb5_db2_context)); - dbctx->db_name = default_db_name; - dbctx->db_nb_locks = FALSE; -} - -static krb5_error_code -k5db2_init_context(context) - krb5_context context; -{ - krb5_db2_context *db_ctx; - - if (context->db_context == NULL) { - db_ctx = (krb5_db2_context *) malloc(sizeof(krb5_db2_context)); - if (db_ctx == NULL) - return ENOMEM; - else { - memset((char *) db_ctx, 0, sizeof(krb5_db2_context)); - k5db2_clear_context((krb5_db2_context *)db_ctx); - context->db_context = (void *) db_ctx; - } - } - return(0); -} - -/* - * Utility routine: generate name of database file. - */ - -static char * -gen_dbsuffix(db_name, sfx) - char *db_name; - char *sfx; -{ - char *dbsuffix; - - if (sfx == NULL) - return((char *) NULL); - - dbsuffix = malloc (strlen(db_name) + strlen(sfx) + 1); - if (!dbsuffix) - return(0); - (void) strcpy(dbsuffix, db_name); - (void) strcat(dbsuffix, sfx); - return dbsuffix; -} - -static DB * -k5db2_dbopen(dbc, fname, flags, mode) - krb5_db2_context *dbc; - char *fname; - int flags; - int mode; -{ - DB *db; - BTREEINFO bti; - HASHINFO hashi; - - bti.flags = 0; - bti.cachesize = 0; - bti.psize = 4096; - bti.lorder = 0; - bti.minkeypage = 0; - bti.compare = NULL; - bti.prefix = NULL; - - hashi.bsize = 4096; - hashi.cachesize = 0; - hashi.ffactor = 40; - hashi.hash = NULL; - hashi.lorder = 0; - hashi.nelem = 1; - - db = dbopen(fname, flags, mode, - dbc->hashfirst ? DB_HASH : DB_BTREE, - dbc->hashfirst ? (void *) &hashi : (void *) &bti); - if (db != NULL) - return db; - switch (errno) { -#ifdef EFTYPE - case EFTYPE: -#endif - case EINVAL: - db = dbopen(fname, flags, mode, - dbc->hashfirst ? DB_BTREE : DB_HASH, - dbc->hashfirst ? (void *) &bti : (void *) &hashi); - if (db != NULL) - dbc->hashfirst = !dbc->hashfirst; - default: - return db; - } -} - -static krb5_error_code -krb5_db2_db_set_hashfirst(context, hashfirst) - krb5_context context; - int hashfirst; -{ - krb5_db2_context *dbc; - - if (k5db2_inited(context)) - return KRB5_KDB_DBNOTINITED; - dbc = (krb5_db2_context *) context->db_context; - dbc->hashfirst = hashfirst; - return 0; -} - -/* - * initialization for data base routines. - */ - -krb5_error_code -krb5_db2_db_init(context) - krb5_context context; -{ - char *filename = NULL; - krb5_db2_context *db_ctx; - krb5_error_code retval; - - if (k5db2_inited(context)) - return 0; - - /* Check for presence of our context, if not present, allocate one. */ - if ((retval = k5db2_init_context(context))) - return(retval); - - db_ctx = context->db_context; - db_ctx->db = NULL; - - if (!(filename = gen_dbsuffix(db_ctx->db_name, KDB2_LOCK_EXT))) - return ENOMEM; - db_ctx->db_lf_name = filename; /* so it gets freed by clear_context */ - - /* - * should be opened read/write so that write locking can work with - * POSIX systems - */ - if ((db_ctx->db_lf_file = open(filename, O_RDWR, 0666)) < 0) { - if ((db_ctx->db_lf_file = open(filename, O_RDONLY, 0666)) < 0) { - retval = errno; - goto err_out; - } - } - db_ctx->db_inited++; - - if ((retval = krb5_db2_db_get_age(context, NULL, &db_ctx->db_lf_time))) - goto err_out; - - return 0; - -err_out: - db_ctx->db = NULL; - k5db2_clear_context(db_ctx); - return (retval); -} - -/* - * gracefully shut down database--must be called by ANY program that does - * a krb5_db2_db_init - */ -krb5_error_code -krb5_db2_db_fini(context) - krb5_context context; -{ - krb5_error_code retval = 0; - krb5_db2_context *db_ctx; - - db_ctx = (krb5_db2_context *) context->db_context; - - if (k5db2_inited(context)) { - if (close(db_ctx->db_lf_file)) - retval = errno; - else - retval = 0; - } - if (db_ctx) { - k5db2_clear_context(db_ctx); - free(context->db_context); - context->db_context = NULL; - } - return retval; -} - -krb5_error_code -krb5_db2_db_open_database(context) - krb5_context context; -{ - if (!k5db2_inited(context)) - return KRB5_KDB_DBNOTINITED; - return 0; -} - -krb5_error_code -krb5_db2_db_close_database(context) - krb5_context context; -{ - if (!k5db2_inited(context)) - return KRB5_KDB_DBNOTINITED; - return 0; -} - -/* - * Set/Get the master key associated with the database - */ -krb5_error_code -krb5_db2_db_set_mkey(context, key) - krb5_context context; - krb5_keyblock *key; -{ - krb5_db2_context *db_ctx; - - if (!k5db2_inited(context)) - return(KRB5_KDB_DBNOTINITED); - - db_ctx = context->db_context; - db_ctx->db_master_key = key; - return 0; -} - -krb5_error_code -krb5_db2_db_get_mkey(context, key) - krb5_context context; - krb5_keyblock **key; -{ - krb5_db2_context *db_ctx; - - if (!k5db2_inited(context)) - return(KRB5_KDB_DBNOTINITED); - - db_ctx = context->db_context; - *key = db_ctx->db_master_key; - - return 0; -} - -/* - * Set the "name" of the current database to some alternate value. - * - * Passing a null pointer as "name" will set back to the default. - * If the alternate database doesn't exist, nothing is changed. - * - * XXX rethink this - */ - -krb5_error_code -krb5_db2_db_set_name(context, name) - krb5_context context; - char *name; -{ - DB *db; - krb5_db2_context *db_ctx; - krb5_error_code kret; - - if (k5db2_inited(context)) - return KRB5_KDB_DBINITED; - - /* Check for presence of our context, if not present, allocate one. */ - if ((kret = k5db2_init_context(context))) - return(kret); - - if (name == NULL) - name = default_db_name; - - db_ctx = context->db_context; - db = k5db2_dbopen(db_ctx, name, O_RDONLY, 0); - if (db == NULL) - return errno; - - db_ctx->db_name = strdup(name); - (*db->close)(db); - return 0; -} - -/* - * Return the last modification time of the database. - * - * Think about using fstat. - */ - -krb5_error_code -krb5_db2_db_get_age(context, db_name, age) - krb5_context context; - char *db_name; - time_t *age; -{ - krb5_db2_context *db_ctx; - struct stat st; - - if (!k5db2_inited(context)) - return(KRB5_KDB_DBNOTINITED); - db_ctx = (krb5_db2_context *) context->db_context; - if (fstat (db_ctx->db_lf_file, &st) < 0) - *age = -1; - else - *age = st.st_mtime; - return 0; -} - -/* - * Remove the semaphore file; indicates that database is currently - * under renovation. - * - * This is only for use when moving the database out from underneath - * the server (for example, during slave updates). - */ - -static krb5_error_code -krb5_db2_db_start_update(context) - krb5_context context; -{ - return 0; -} - -static krb5_error_code -krb5_db2_db_end_update(context) - krb5_context context; -{ - krb5_error_code retval; - krb5_db2_context *db_ctx; - struct stat st; - time_t now; - struct utimbuf utbuf; - - if (!k5db2_inited(context)) - return(KRB5_KDB_DBNOTINITED); - - retval = 0; - db_ctx = context->db_context; - now = time((time_t *) NULL); - if (fstat(db_ctx->db_lf_file, &st) == 0) { - if (st.st_mtime >= now) { - utbuf.actime = st.st_mtime+1; - utbuf.modtime = st.st_mtime+1; - if (utime(db_ctx->db_lf_name, &utbuf)) - retval = errno; - } - else { - if (utime(db_ctx->db_lf_name, (struct utimbuf *) NULL)) - retval = errno; - } - } - else - retval = errno; - if (!retval) { - if (fstat(db_ctx->db_lf_file, &st) == 0) - db_ctx->db_lf_time = st.st_mtime; - else - retval = errno; - } - return(retval); -} - -krb5_error_code -krb5_db2_db_lock(context, mode) - krb5_context context; - int mode; -{ - krb5_db2_context *db_ctx; - int krb5_lock_mode; - DB *db; - krb5_error_code retval; - time_t mod_time; - - if (!k5db2_inited(context)) - return KRB5_KDB_DBNOTINITED; - - db_ctx = (krb5_db2_context *) context->db_context; - if (db_ctx->db_locks_held && (db_ctx->db_lock_mode >= mode)) { - /* No need to upgrade lock, just return */ - db_ctx->db_locks_held++; - return(0); - } - - if ((mode != KRB5_LOCKMODE_SHARED) && (mode != KRB5_LOCKMODE_EXCLUSIVE)) - return KRB5_KDB_BADLOCKMODE; - - if (db_ctx->db_nb_locks) - krb5_lock_mode = mode | KRB5_LOCKMODE_DONTBLOCK; - else - krb5_lock_mode = mode; - retval = krb5_lock_file(context, db_ctx->db_lf_file, krb5_lock_mode); - switch (retval) { - case EBADF: - if (mode == KRB5_LOCKMODE_EXCLUSIVE) - return KRB5_KDB_CANTLOCK_DB; - default: - return retval; - case 0: - break; - } - - if ((retval = krb5_db2_db_get_age(context, NULL, &mod_time))) - goto lock_error; - - db = k5db2_dbopen(db_ctx, db_ctx->db_name, - mode == KRB5_LOCKMODE_SHARED ? O_RDONLY : O_RDWR, - 0600); - if (db) { - db_ctx->db_lf_time = mod_time; - db_ctx->db = db; - } else { - retval = errno; - db_ctx->db = NULL; - goto lock_error; - } - - db_ctx->db_lock_mode = mode; - db_ctx->db_locks_held++; - return 0; - -lock_error:; - db_ctx->db_lock_mode = 0; - db_ctx->db_locks_held = 0; - (void) krb5_db2_db_unlock(context); - return retval; -} - -krb5_error_code -krb5_db2_db_unlock(context) - krb5_context context; -{ - krb5_db2_context *db_ctx; - DB *db; - krb5_error_code retval; - - if (!k5db2_inited(context)) - return KRB5_KDB_DBNOTINITED; - - db_ctx = (krb5_db2_context *) context->db_context; - if (!db_ctx->db_locks_held) /* lock already unlocked */ - return KRB5_KDB_NOTLOCKED; - db = db_ctx->db; - if (--(db_ctx->db_locks_held) == 0) { - (*db->close)(db); - db_ctx->db = NULL; - - retval = krb5_lock_file(context, db_ctx->db_lf_file, - KRB5_LOCKMODE_UNLOCK); - db_ctx->db_lock_mode = 0; - return(retval); - } - return 0; -} - -/* - * Create the database, assuming it's not there. - */ -krb5_error_code -krb5_db2_db_create(context, db_name, flags) - krb5_context context; - char *db_name; - krb5_int32 flags; -{ - register krb5_error_code retval = 0; - char *okname; - int fd; - krb5_db2_context *db_ctx; - DB *db; - - if ((retval = k5db2_init_context(context))) - return(retval); - - db_ctx = (krb5_db2_context *) context->db_context; - switch (flags) { - case KRB5_KDB_CREATE_HASH: - if ((retval = krb5_db2_db_set_hashfirst(context, TRUE))) - return retval; - break; - case KRB5_KDB_CREATE_BTREE: - case 0: - if ((retval = krb5_db2_db_set_hashfirst(context, FALSE))) - return retval; - break; - default: - return KRB5_KDB_BAD_CREATEFLAGS; - } - db = k5db2_dbopen(db_ctx, db_name, O_RDWR|O_CREAT|O_EXCL, 0600); - if (db == NULL) - retval = errno; - else - (*db->close)(db); - if (retval == 0) { - okname = gen_dbsuffix(db_name, KDB2_LOCK_EXT); - if (!okname) - retval = ENOMEM; - else { - fd = open (okname, O_CREAT|O_RDWR|O_TRUNC, 0600); - if (fd < 0) - retval = errno; - else - close(fd); - free_dbsuffix(okname); - } - } - return retval; -} - -/* - * Destroy the database. Zero's out all of the files, just to be sure. - */ -static krb5_error_code -destroy_file_suffix(dbname, suffix) - char *dbname; - char *suffix; -{ - char *filename; - struct stat statb; - int nb,fd; - unsigned int j; - off_t pos; - char buf[BUFSIZ]; - char zbuf[BUFSIZ]; - int dowrite; - - filename = gen_dbsuffix(dbname, suffix); - if (filename == 0) - return ENOMEM; - if ((fd = open(filename, O_RDWR, 0)) < 0) { - free(filename); - return errno; - } - /* fstat() will probably not fail unless using a remote filesystem - (which is inappropriate for the kerberos database) so this check - is mostly paranoia. */ - if (fstat(fd, &statb) == -1) { - int retval = errno; - free(filename); - return retval; - } - /* - * Stroll through the file, reading in BUFSIZ chunks. If everything - * is zero, then we're done for that block, otherwise, zero the block. - * We would like to just blast through everything, but some DB - * implementations make holey files and writing data to the holes - * causes actual blocks to be allocated which is no good, since - * we're just about to unlink it anyways. - */ - memset(zbuf, 0, BUFSIZ); - pos = 0; - while (pos < statb.st_size) { - dowrite = 0; - nb = read(fd, buf, BUFSIZ); - if (nb < 0) { - int retval = errno; - free(filename); - return retval; - } - for (j=0; j<nb; j++) { - if (buf[j] != '\0') { - dowrite = 1; - break; - } - } - /* For signedness */ - j = nb; - if (dowrite) { - lseek(fd, pos, SEEK_SET); - nb = write(fd, zbuf, j); - if (nb < 0) { - int retval = errno; - free(filename); - return retval; - } - } - pos += nb; - } - /* ??? Is fsync really needed? I don't know of any non-networked - filesystem which will discard queued writes to disk if a file - is deleted after it is closed. --jfc */ -#ifndef NOFSYNC - fsync(fd); -#endif - close(fd); - - if (unlink(filename)) { - free(filename); - return(errno); - } - free(filename); - return(0); -} - -/* - * Since the destroy operation happens outside the init/fini bracket, we - * have some tomfoolery to undergo here. If we're operating under no - * database context, then we initialize with the default. If the caller - * wishes a different context (e.g. different dispatch table), it's their - * responsibility to call kdb5_db_set_dbops() before this call. That will - * set up the right dispatch table values (e.g. name extensions). - * - * Not quite valid due to ripping out of dbops... - */ -krb5_error_code -krb5_db2_db_destroy(context, dbname) - krb5_context context; - char *dbname; -{ - krb5_error_code retval1, retval2; - krb5_boolean tmpcontext; - - tmpcontext = 0; - if (!context->db_context) { - tmpcontext = 1; - if ((retval1 = k5db2_init_context(context))) - return(retval1); - } - - retval1 = retval2 = 0; - retval1 = destroy_file_suffix(dbname, ""); - retval2 = destroy_file_suffix(dbname, KDB2_LOCK_EXT); - - if (tmpcontext) { - k5db2_clear_context((krb5_db2_context *) context->db_context); - free(context->db_context); - context->db_context = NULL; - } - - if (retval1 || retval2) - return (retval1 ? retval1 : retval2); - else - return 0; -} - -/* - * "Atomically" rename the database in a way that locks out read - * access in the middle of the rename. - * - * Not perfect; if we crash in the middle of an update, we don't - * necessarily know to complete the transaction the rename, but... - * - * Since the rename operation happens outside the init/fini bracket, we - * have to go through the same stuff that we went through up in db_destroy. - */ -krb5_error_code -krb5_db2_db_rename(context, from, to) - krb5_context context; - char *from; - char *to; -{ - DB *db; - char *fromok; - krb5_error_code retval; - krb5_db2_context *s_context, *db_ctx; - - s_context = context->db_context; - context->db_context = NULL; - if ((retval = k5db2_init_context(context))) - return retval; - db_ctx = (krb5_db2_context *) context->db_context; - - /* - * Create the database if it does not already exist; the - * files must exist because krb5_db2_db_lock, called below, - * will fail otherwise. - */ - db = k5db2_dbopen(db_ctx, to, O_RDWR|O_CREAT, 0600); - if (db == NULL) { - retval = errno; - goto errout; - } - else - (*db->close)(db); - /* - * Set the database to the target, so that other processes sharing - * the target will stop their activity, and notice the new database. - */ - retval = krb5_db2_db_set_name(context, to); - if (retval) - goto errout; - - db_ctx->db_lf_name = gen_dbsuffix(db_ctx->db_name, KDB2_LOCK_EXT); - if (db_ctx->db_lf_name == NULL) { - retval = ENOMEM; - goto errout; - } - db_ctx->db_lf_file = open(db_ctx->db_lf_name, O_RDWR|O_CREAT, 0600); - if (db_ctx->db_lf_file < 0) { - retval = errno; - goto errout; - } - - db_ctx->db_inited = 1; - - retval = krb5_db2_db_get_age(context, NULL, &db_ctx->db_lf_time); - if (retval) - goto errout; - - fromok = gen_dbsuffix(from, KDB2_LOCK_EXT); - if (fromok == NULL) { - retval = ENOMEM; - goto errout; - } - - if ((retval = krb5_db2_db_lock(context, KRB5_LOCKMODE_EXCLUSIVE))) - goto errfromok; - - if ((retval = krb5_db2_db_start_update(context))) - goto errfromok; - - if (rename(from, to)) { - retval = errno; - goto errfromok; - } - if (unlink(fromok)) { - retval = errno; - goto errfromok; - } - retval = krb5_db2_db_end_update(context); -errfromok: - free_dbsuffix(fromok); -errout: - if (context->db_context) { - if (db_ctx->db_lf_file >= 0) { - krb5_db2_db_unlock(context); - close(db_ctx->db_lf_file); - } - k5db2_clear_context((krb5_db2_context *) context->db_context); - free(context->db_context); - } - - context->db_context = s_context; - (void) krb5_db2_db_unlock(context); /* unlock saved context db */ - - return retval; -} - -/* - * look up a principal in the data base. - * returns number of entries found, and whether there were - * more than requested. - */ - -krb5_error_code -krb5_db2_db_get_principal(context, searchfor, entries, nentries, more) - krb5_context context; - krb5_const_principal searchfor; - krb5_db_entry *entries; /* filled in */ - int *nentries; /* how much room/how many found */ - krb5_boolean *more; /* are there more? */ -{ - krb5_db2_context *db_ctx; - krb5_error_code retval; - DB *db; - DBT key, contents; - krb5_data keydata, contdata; - int trynum, dbret; - - *more = FALSE; - *nentries = 0; - - if (!k5db2_inited(context)) - return KRB5_KDB_DBNOTINITED; - - db_ctx = (krb5_db2_context *) context->db_context; - for (trynum = 0; trynum < KRB5_DB2_MAX_RETRY; trynum++) { - if ((retval = krb5_db2_db_lock(context, KRB5_LOCKMODE_SHARED))) { - if (db_ctx->db_nb_locks) - return(retval); - sleep(1); - continue; - } - break; - } - if (trynum == KRB5_DB2_MAX_RETRY) - return KRB5_KDB_DB_INUSE; - - /* XXX deal with wildcard lookups */ - retval = krb5_encode_princ_dbkey(context, &keydata, searchfor); - if (retval) - goto cleanup; - key.data = keydata.data; - key.size = keydata.length; - - db = db_ctx->db; - dbret = (*db->get)(db, &key, &contents, 0); - retval = errno; - krb5_free_data_contents(context, &keydata); - switch (dbret) { - case 1: - retval = 0; - case -1: - default: - *nentries = 0; - goto cleanup; - case 0: - contdata.data = contents.data; - contdata.length = contents.size; - retval = krb5_decode_princ_contents(context, &contdata, entries); - if (!retval) - *nentries = 1; - break; - } - -cleanup: - (void) krb5_db2_db_unlock(context); /* unlock read lock */ - return retval; -} - -/* - Free stuff returned by krb5_db2_db_get_principal. - */ -void -krb5_db2_db_free_principal(context, entries, nentries) - krb5_context context; - krb5_db_entry *entries; - int nentries; -{ - register int i; - for (i = 0; i < nentries; i++) - krb5_dbe_free_contents(context, &entries[i]); - return; -} - -/* - Stores the *"nentries" entry structures pointed to by "entries" in the - database. - - *"nentries" is updated upon return to reflect the number of records - acutally stored; the first *"nstored" records will have been stored in the - database (even if an error occurs). - - */ - -krb5_error_code -krb5_db2_db_put_principal(context, entries, nentries) - krb5_context context; - krb5_db_entry *entries; - register int *nentries; /* number of entry structs to update */ -{ - int i, n, dbret; - DB *db; - DBT key, contents; - krb5_data contdata, keydata; - krb5_error_code retval; - krb5_db2_context *db_ctx; - - n = *nentries; - *nentries = 0; - if (!k5db2_inited(context)) - return KRB5_KDB_DBNOTINITED; - - db_ctx = (krb5_db2_context *) context->db_context; - if ((retval = krb5_db2_db_lock(context, KRB5_LOCKMODE_EXCLUSIVE))) - return retval; - - db = db_ctx->db; - if ((retval = krb5_db2_db_start_update(context))) { - (void)krb5_db2_db_unlock(context); - return retval; - } - - /* for each one, stuff temps, and do replace/append */ - for (i = 0; i < n; i++) { - retval = krb5_encode_princ_contents(context, &contdata, entries); - if (retval) - break; - contents.data = contdata.data; - contents.size = contdata.length; - retval = krb5_encode_princ_dbkey(context, &keydata, entries->princ); - if (retval) { - krb5_free_data_contents(context, &contdata); - break; - } - - key.data = keydata.data; - key.size = keydata.length; - dbret = (*db->put)(db, &key, &contents, 0); - retval = dbret ? errno : 0; - krb5_free_data_contents(context, &keydata); - krb5_free_data_contents(context, &contdata); - if (retval) - break; - entries++; /* bump to next struct */ - } - - (void)krb5_db2_db_end_update(context); - (void)krb5_db2_db_unlock(context); /* unlock database */ - *nentries = i; - return(retval); -} - -/* - * delete a principal from the data base. - * returns number of entries removed - */ - -krb5_error_code -krb5_db2_db_delete_principal(context, searchfor, nentries) - krb5_context context; - krb5_const_principal searchfor; - int *nentries; /* how many found & deleted */ -{ - krb5_error_code retval; - krb5_db_entry entry; - krb5_db2_context *db_ctx; - DB *db; - DBT key, contents; - krb5_data keydata, contdata; - int i, dbret; - - if (!k5db2_inited(context)) - return KRB5_KDB_DBNOTINITED; - - db_ctx = (krb5_db2_context *) context->db_context; - if ((retval = krb5_db2_db_lock(context, KRB5_LOCKMODE_EXCLUSIVE))) - return(retval); - - if ((retval = krb5_db2_db_start_update(context))) { - (void) krb5_db2_db_unlock(context); /* unlock write lock */ - return(retval); - } - - if ((retval = krb5_encode_princ_dbkey(context, &keydata, searchfor))) - goto cleanup; - key.data = keydata.data; - key.size = keydata.length; - - db = db_ctx->db; - dbret = (*db->get)(db, &key, &contents, 0); - retval = errno; - switch (dbret) { - case 1: - retval = KRB5_KDB_NOENTRY; - case -1: - default: - *nentries = 0; - goto cleankey; - case 0: - ; - } - memset((char *)&entry, 0, sizeof(entry)); - contdata.data = contents.data; - contdata.length = contents.size; - retval = krb5_decode_princ_contents(context, &contdata, &entry); - if (retval) - goto cleankey; - *nentries = 1; - - /* Clear encrypted key contents */ - for (i = 0; i < entry.n_key_data; i++) { - if (entry.key_data[i].key_data_length[0]) { - memset((char *)entry.key_data[i].key_data_contents[0], 0, - (unsigned) entry.key_data[i].key_data_length[0]); - } - } - - retval = krb5_encode_princ_contents(context, &contdata, &entry); - krb5_dbe_free_contents(context, &entry); - if (retval) - goto cleankey; - - contents.data = contdata.data; - contents.size = contdata.length; - dbret = (*db->put)(db, &key, &contents, 0); - retval = dbret ? errno : 0; - krb5_free_data_contents(context, &contdata); - if (retval) - goto cleankey; - dbret = (*db->del)(db, &key, 0); - retval = dbret ? errno : 0; -cleankey: - krb5_free_data_contents(context, &keydata); - -cleanup: - (void) krb5_db2_db_end_update(context); - (void) krb5_db2_db_unlock(context); /* unlock write lock */ - return retval; -} - -krb5_error_code -krb5_db2_db_iterate_ext(context, func, func_arg, backwards, recursive) - krb5_context context; - krb5_error_code (*func) (krb5_pointer, krb5_db_entry *); - krb5_pointer func_arg; - int backwards, recursive; -{ - krb5_db2_context *db_ctx; - DB *db; - DBT key, contents; - krb5_data contdata; - krb5_db_entry entries; - krb5_error_code retval; - int dbret; - void *cookie; - - cookie = NULL; - if (!k5db2_inited(context)) - return KRB5_KDB_DBNOTINITED; - - db_ctx = (krb5_db2_context *) context->db_context; - retval = krb5_db2_db_lock(context, KRB5_LOCKMODE_SHARED); - - if (retval) - return retval; - - db = db_ctx->db; - if (recursive && db->type != DB_BTREE) { - (void)krb5_db2_db_unlock(context); - return KRB5_KDB_UK_RERROR; /* Not optimal, but close enough. */ - } - - if (!recursive) { - dbret = (*db->seq)(db, &key, &contents, - backwards ? R_LAST : R_FIRST); - } else { -#ifdef HAVE_BT_RSEQ - dbret = bt_rseq(db, &key, &contents, &cookie, - backwards ? R_LAST : R_FIRST); -#else - (void)krb5_db2_db_unlock(context); - return KRB5_KDB_UK_RERROR; /* Not optimal, but close enough. */ -#endif - } - while (dbret == 0) { - contdata.data = contents.data; - contdata.length = contents.size; - retval = krb5_decode_princ_contents(context, &contdata, &entries); - if (retval) - break; - retval = (*func)(func_arg, &entries); - krb5_dbe_free_contents(context, &entries); - if (retval) - break; - if (!recursive) { - dbret = (*db->seq)(db, &key, &contents, - backwards ? R_PREV : R_NEXT); - } else { -#ifdef HAVE_BT_RSEQ - dbret = bt_rseq(db, &key, &contents, &cookie, - backwards ? R_PREV : R_NEXT); -#else - (void)krb5_db2_db_unlock(context); - return KRB5_KDB_UK_RERROR; /* Not optimal, but close enough. */ -#endif - } - } - switch (dbret) { - case 1: - case 0: - break; - case -1: - default: - retval = errno; - } - (void) krb5_db2_db_unlock(context); - return retval; -} - -krb5_error_code -krb5_db2_db_iterate(context, func, func_arg) - krb5_context context; - krb5_error_code (*func) (krb5_pointer, krb5_db_entry *); - krb5_pointer func_arg; -{ - return krb5_db2_db_iterate_ext(context, func, func_arg, 0, 0); -} - -krb5_boolean -krb5_db2_db_set_lockmode(context, mode) - krb5_context context; - krb5_boolean mode; -{ - krb5_boolean old; - krb5_db2_context *db_ctx; - - old = mode; - if ((db_ctx = (krb5_db2_context *) context->db_context)) { - old = db_ctx->db_nb_locks; - db_ctx->db_nb_locks = mode; - } - return old; -} - -/* - * Context serialization operations. - * - * Ick, this is really gross. --- tlyu - */ - -/* - * kdb5_context_size() - Determine size required to serialize. - */ -static krb5_error_code -kdb5_context_size(kcontext, arg, sizep) - krb5_context kcontext; - krb5_pointer arg; - size_t *sizep; -{ - krb5_error_code kret; - size_t required; - krb5_db2_context *dbctx; - - /* - * The database context requires at minimum: - * krb5_int32 for KV5M_DB_CONTEXT - * krb5_int32 for db_inited - * krb5_int32 for database lockfile non-blocking flag - * krb5_int32 for database lockfile lock count - * krb5_int32 for database lockfile lock mode - * krb5_int32 for length of database name. - * krb5_int32 for KV5M_DB_CONTEXT - */ - kret = EINVAL; - if ((dbctx = (krb5_db2_context *) arg)) { - required = (sizeof(krb5_int32) * 7); - if (dbctx->db_inited && dbctx->db_name) - required += strlen(dbctx->db_name); - kret = 0; - *sizep += required; - } - return(kret); -} - -/* - * kdb5_context_externalize() - Externalize the database context. - */ -static krb5_error_code -kdb5_context_externalize(kcontext, arg, buffer, lenremain) - krb5_context kcontext; - krb5_pointer arg; - krb5_octet **buffer; - size_t *lenremain; -{ - krb5_error_code kret; - krb5_db2_context *dbctx; - size_t required; - krb5_octet *bp; - size_t remain; - - required = 0; - bp = *buffer; - remain = *lenremain; - kret = EINVAL; - if ((dbctx = (krb5_db2_context *) arg)) { - kret = ENOMEM; - if (!kdb5_context_size(kcontext, arg, &required) && - (required <= remain)) { - /* Write magic number */ - (void) krb5_ser_pack_int32(KV5M_DB_CONTEXT, &bp, &remain); - - /* Write inited flag */ - (void) krb5_ser_pack_int32((krb5_int32) dbctx->db_inited, - &bp, &remain); - - /* Write blocking lock lockmode */ - (void) krb5_ser_pack_int32((krb5_int32) dbctx->db_nb_locks, - &bp, &remain); - - /* Write lock count */ - (void) krb5_ser_pack_int32((krb5_int32) - (dbctx->db_inited) ? - dbctx->db_locks_held : 0, - &bp, &remain); - - /* Write lock mode */ - (void) krb5_ser_pack_int32((krb5_int32) - (dbctx->db_inited) ? - dbctx->db_lock_mode : 0, - &bp, &remain); - - /* Write length of database name */ - (void) krb5_ser_pack_int32((dbctx->db_inited && dbctx->db_name) ? - (krb5_int32) strlen(dbctx->db_name) : 0, - &bp, &remain); - if (dbctx->db_inited && dbctx->db_name) - (void) krb5_ser_pack_bytes((krb5_octet *) dbctx->db_name, - strlen(dbctx->db_name), - &bp, &remain); - - /* Write trailer */ - (void) krb5_ser_pack_int32(KV5M_DB_CONTEXT, &bp, &remain); - kret = 0; - *buffer = bp; - *lenremain = remain; - } - } - return(kret); -} - -/* - * kdb5_context_internalize() - Internalize the database context. - */ -static krb5_error_code -kdb5_context_internalize(kcontext, argp, buffer, lenremain) - krb5_context kcontext; - krb5_pointer *argp; - krb5_octet **buffer; - size_t *lenremain; -{ - krb5_error_code kret; - krb5_context tmpctx; - krb5_db2_context *dbctx; - krb5_int32 ibuf; - krb5_octet *bp; - size_t remain; - krb5_int32 iflag; - krb5_int32 nb_lockmode; - krb5_int32 lockcount; - krb5_int32 lockmode; - krb5_int32 dbnamelen; - krb5_boolean nb_lock; - char *dbname; - - bp = *buffer; - remain = *lenremain; - kret = EINVAL; - dbctx = (krb5_db2_context *) NULL; - /* Read our magic number */ - if (krb5_ser_unpack_int32(&ibuf, &bp, &remain)) - ibuf = 0; - if (ibuf == KV5M_DB_CONTEXT) { - kret = ENOMEM; - - if (!(kret = krb5_ser_unpack_int32(&iflag, &bp, &remain)) && - !(kret = krb5_ser_unpack_int32(&nb_lockmode, &bp, &remain)) && - !(kret = krb5_ser_unpack_int32(&lockcount, &bp, &remain)) && - !(kret = krb5_ser_unpack_int32(&lockmode, &bp, &remain)) && - !(kret = krb5_ser_unpack_int32(&dbnamelen, &bp, &remain)) && - !(kret = krb5_init_context(&tmpctx))) { - if (iflag) { - dbname = (char *) NULL; - if (dbnamelen && - (dbname = (char *) malloc((size_t) (dbnamelen+1)))) { - kret = krb5_ser_unpack_bytes((krb5_octet *) dbname, - (size_t) dbnamelen, - &bp, &remain); - if (!kret) - dbname[dbnamelen] = '\0'; - } - if (!kret && - (!dbname || !(kret = krb5_db_set_name(tmpctx, dbname))) && - !(kret = krb5_db_init(tmpctx))) { - dbctx = (krb5_db2_context *) tmpctx->db_context; - (void) krb5_db2_db_set_lockmode(tmpctx, 0); - if (lockmode) - kret = krb5_db_lock(tmpctx, lockmode); - if (!kret && lockmode) - dbctx->db_locks_held = lockcount; - nb_lock = nb_lockmode & 0xff; - (void) krb5_db2_db_set_lockmode(tmpctx, nb_lock); - } - if (dbname) - krb5_xfree(dbname); - } - if (!kret) - kret = krb5_ser_unpack_int32(&ibuf, &bp, &remain); - if (kret || (ibuf != KV5M_DB_CONTEXT)) - kret = EINVAL; - - if (kret) { - if (dbctx) - krb5_db_fini(tmpctx); - } - else - tmpctx->db_context = NULL; - krb5_free_context(tmpctx); - } - } - if (!kret) { - *buffer = bp; - *lenremain = remain; - *argp = (krb5_pointer) dbctx; - } - return(kret); -} - -/* Dispatch entry */ -static const krb5_ser_entry kdb5_context_ser_entry = { - KV5M_DB_CONTEXT, /* Type */ - kdb5_context_size, /* Sizer routine */ - kdb5_context_externalize, /* Externalize routine */ - kdb5_context_internalize /* Externalize routine */ -}; - -/* - * Register serializer. - */ -krb5_error_code -krb5_ser_db_context_init(kcontext) - krb5_context kcontext; -{ - return(krb5_register_serializer(kcontext, &kdb5_context_ser_entry)); -} diff --git a/src/lib/kdb/kdb_db2.h b/src/lib/kdb/kdb_db2.h deleted file mode 100644 index 80f9495..0000000 --- a/src/lib/kdb/kdb_db2.h +++ /dev/null @@ -1,130 +0,0 @@ -/* - * lib/kdb/kdb_db2.h - * - * 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. 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. - * - * - * KDC Database backend definitions for Berkely DB. - */ -#ifndef KRB5_KDB_DB2_H - -/* renaming kludge */ -#define krb5_db2_db_set_name krb5_db_set_name -#define krb5_db2_db_set_nonblocking krb5_db_set_nonblocking -#define krb5_db2_db_init krb5_db_init -#define krb5_db2_db_fini krb5_db_fini -#define krb5_db2_db_get_age krb5_db_get_age -#define krb5_db2_db_create krb5_db_create -#define krb5_db2_db_destroy krb5_db_destroy -#define krb5_db2_db_rename krb5_db_rename -#define krb5_db2_db_get_principal krb5_db_get_principal -#define krb5_db2_db_free_principal krb5_db_free_principal -#define krb5_db2_db_put_principal krb5_db_put_principal -#define krb5_db2_db_delete_principal krb5_db_delete_principal -#define krb5_db2_db_iterate_ext krb5_db_iterate_ext -#define krb5_db2_db_iterate krb5_db_iterate -#define krb5_db2_db_lock krb5_db_lock -#define krb5_db2_db_unlock krb5_db_unlock -#define krb5_db2_db_set_lockmode krb5_db_set_lockmode -#define krb5_db2_db_close_database krb5_db_close_database -#define krb5_db2_db_open_database krb5_db_open_database -#define krb5_db2_db_set_mkey krb5_db_set_mkey -#define krb5_db2_db_get_mkey krb5_db_get_mkey - -typedef struct _krb5_db2_context { - krb5_boolean db_inited; /* Context initialized */ - char * db_name; /* Name of database */ - DB * db; /* DB handle */ - krb5_boolean hashfirst; /* Try hash database type first */ - char * db_lf_name; /* Name of lock file */ - int db_lf_file; /* File descriptor of lock file */ - time_t db_lf_time; /* Time last updated */ - int db_locks_held; /* Number of times locked */ - int db_lock_mode; /* Last lock mode, e.g. greatest*/ - krb5_boolean db_nb_locks; /* [Non]Blocking lock modes */ - krb5_keyblock *db_master_key; /* Master key of database */ -} krb5_db2_context; - -#define KRB5_DB2_MAX_RETRY 5 - -#define KDB2_LOCK_EXT ".ok" - -krb5_error_code krb5_db2_db_set_name - (krb5_context, - char * ); -krb5_error_code krb5_db2_db_init - (krb5_context); -krb5_error_code krb5_db2_db_fini - (krb5_context); -krb5_error_code krb5_db2_db_get_age - (krb5_context, - char *, - time_t * ); -krb5_error_code krb5_db2_db_create - (krb5_context, - char *, - krb5_int32); -krb5_error_code krb5_db2_db_destroy - (krb5_context, - char * ); -krb5_error_code krb5_db2_db_rename - (krb5_context, - char *, - char * ); -krb5_error_code krb5_db2_db_get_principal - (krb5_context, - krb5_const_principal, - krb5_db_entry *, - int *, - krb5_boolean * ); -void krb5_db2_db_free_principal - (krb5_context, - krb5_db_entry *, - int ); -krb5_error_code krb5_db2_db_put_principal - (krb5_context, - krb5_db_entry *, - int * ); -krb5_error_code krb5_db2_db_iterate_ext - (krb5_context, - krb5_error_code (*) (krb5_pointer, - krb5_db_entry *), - krb5_pointer, int, int ); -krb5_error_code krb5_db2_db_iterate - (krb5_context, - krb5_error_code (*) (krb5_pointer, - krb5_db_entry *), - krb5_pointer ); -krb5_error_code krb5_db2_db_set_nonblocking - (krb5_context, - krb5_boolean, - krb5_boolean * ); -krb5_boolean krb5_db2_db_set_lockmode - (krb5_context, - krb5_boolean ); -krb5_error_code krb5_db2_db_open_database - (krb5_context); -krb5_error_code krb5_db2_db_close_database - (krb5_context); - -#endif /* KRB5_KDB_DB2_H */ diff --git a/src/lib/kdb/kdb_xdr.c b/src/lib/kdb/kdb_xdr.c deleted file mode 100644 index fb0a41e..0000000 --- a/src/lib/kdb/kdb_xdr.c +++ /dev/null @@ -1,814 +0,0 @@ -/* - * lib/kdb/kdb_xdr.c - * - * Copyright 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. 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. - * - */ - -#include "k5-int.h" -#include <string.h> -#include <stdio.h> -#include <errno.h> - -#define safe_realloc(p,n) ((p)?(realloc(p,n)):(malloc(n))) - -krb5_error_code -krb5_dbe_create_key_data(context, entry) - krb5_context context; - krb5_db_entry * entry; -{ - if ((entry->key_data = - (krb5_key_data *) safe_realloc(entry->key_data, - (sizeof(krb5_key_data)* - (entry->n_key_data + 1)))) == NULL) - return(ENOMEM); - - - memset(entry->key_data + entry->n_key_data, 0, sizeof(krb5_key_data)); - entry->n_key_data++; - - return 0; -} - -krb5_error_code -krb5_dbe_update_tl_data(context, entry, new_tl_data) - krb5_context context; - krb5_db_entry * entry; - krb5_tl_data * new_tl_data; -{ - krb5_tl_data * tl_data; - krb5_octet * tmp; - - /* copy the new data first, so we can fail cleanly if malloc() - fails */ - - if ((tmp = (krb5_octet *) malloc(new_tl_data->tl_data_length)) == NULL) - return(ENOMEM); - - /* Find an existing entry of the specified type and point at - it, or NULL if not found */ - - for (tl_data = entry->tl_data; tl_data; tl_data = tl_data->tl_data_next) - if (tl_data->tl_data_type == new_tl_data->tl_data_type) - break; - - /* if necessary, chain a new record in the beginning and point at it */ - - if (!tl_data) { - if ((tl_data = (krb5_tl_data *) calloc(1, sizeof(krb5_tl_data))) - == NULL) { - free(tmp); - return(ENOMEM); - } - tl_data->tl_data_next = entry->tl_data; - entry->tl_data = tl_data; - entry->n_tl_data++; - } - - /* fill in the record */ - - if (tl_data->tl_data_contents) - free(tl_data->tl_data_contents); - - tl_data->tl_data_type = new_tl_data->tl_data_type; - tl_data->tl_data_length = new_tl_data->tl_data_length; - tl_data->tl_data_contents = tmp; - memcpy(tmp, new_tl_data->tl_data_contents, tl_data->tl_data_length); - - return(0); -} - -krb5_error_code -krb5_dbe_lookup_tl_data(context, entry, ret_tl_data) - krb5_context context; - krb5_db_entry * entry; - krb5_tl_data * ret_tl_data; -{ - krb5_tl_data *tl_data; - - for (tl_data = entry->tl_data; tl_data; tl_data = tl_data->tl_data_next) { - if (tl_data->tl_data_type == ret_tl_data->tl_data_type) { - *ret_tl_data = *tl_data; - return(0); - } - } - - /* if the requested record isn't found, return zero bytes. - if it ever means something to have a zero-length tl_data, - this code and its callers will have to be changed */ - - ret_tl_data->tl_data_length = 0; - ret_tl_data->tl_data_contents = NULL; - return(0); -} - -krb5_error_code -krb5_dbe_update_last_pwd_change(context, entry, stamp) - krb5_context context; - krb5_db_entry * entry; - krb5_timestamp stamp; -{ - krb5_tl_data tl_data; - krb5_octet buf[4]; /* this is the encoded size of an int32 */ - - tl_data.tl_data_type = KRB5_TL_LAST_PWD_CHANGE; - tl_data.tl_data_length = sizeof(buf); - krb5_kdb_encode_int32((krb5_int32) stamp, buf); - tl_data.tl_data_contents = buf; - - return(krb5_dbe_update_tl_data(context, entry, &tl_data)); -} - -krb5_error_code -krb5_dbe_lookup_last_pwd_change(context, entry, stamp) - krb5_context context; - krb5_db_entry * entry; - krb5_timestamp * stamp; -{ - krb5_tl_data tl_data; - krb5_error_code code; - krb5_int32 tmp; - - tl_data.tl_data_type = KRB5_TL_LAST_PWD_CHANGE; - - if ((code = krb5_dbe_lookup_tl_data(context, entry, &tl_data))) - return(code); - - if (tl_data.tl_data_length != 4) { - *stamp = 0; - return(0); - } - - krb5_kdb_decode_int32(tl_data.tl_data_contents, tmp); - - *stamp = (krb5_timestamp) tmp; - - return(0); -} - -/* it seems odd that there's no function to remove a tl_data, but if - I need one, I'll add one */ - -krb5_error_code -krb5_dbe_update_mod_princ_data(context, entry, mod_date, mod_princ) - krb5_context context; - krb5_db_entry * entry; - krb5_timestamp mod_date; - krb5_const_principal mod_princ; -{ - krb5_tl_data tl_data; - - krb5_error_code retval = 0; - krb5_octet * nextloc = 0; - char * unparse_mod_princ = 0; - unsigned int unparse_mod_princ_size; - - if ((retval = krb5_unparse_name(context, mod_princ, - &unparse_mod_princ))) - return(retval); - - unparse_mod_princ_size = strlen(unparse_mod_princ) + 1; - - if ((nextloc = (krb5_octet *) malloc(unparse_mod_princ_size + 4)) - == NULL) { - free(unparse_mod_princ); - return(ENOMEM); - } - - tl_data.tl_data_type = KRB5_TL_MOD_PRINC; - tl_data.tl_data_length = unparse_mod_princ_size + 4; - tl_data.tl_data_contents = nextloc; - - /* Mod Date */ - krb5_kdb_encode_int32(mod_date, nextloc); - - /* Mod Princ */ - memcpy(nextloc+4, unparse_mod_princ, unparse_mod_princ_size); - - retval = krb5_dbe_update_tl_data(context, entry, &tl_data); - - free(unparse_mod_princ); - free(nextloc); - - return(retval); -} - -krb5_error_code -krb5_dbe_lookup_mod_princ_data(context, entry, mod_time, mod_princ) - krb5_context context; - krb5_db_entry * entry; - krb5_timestamp * mod_time; - krb5_principal * mod_princ; -{ - krb5_tl_data tl_data; - krb5_error_code code; - - tl_data.tl_data_type = KRB5_TL_MOD_PRINC; - - if ((code = krb5_dbe_lookup_tl_data(context, entry, &tl_data))) - return(code); - - if ((tl_data.tl_data_length < 5) || - (tl_data.tl_data_contents[tl_data.tl_data_length-1] != '\0')) - return(KRB5_KDB_TRUNCATED_RECORD); - - /* Mod Date */ - krb5_kdb_decode_int32(tl_data.tl_data_contents, *mod_time); - - /* Mod Princ */ - if ((code = krb5_parse_name(context, - (const char *) (tl_data.tl_data_contents+4), - mod_princ))) - return(code); - - return(0); -} - -krb5_error_code -krb5_encode_princ_dbkey(context, key, principal) - krb5_context context; - krb5_data *key; - krb5_const_principal principal; -{ - char *princ_name; - krb5_error_code retval; - - if (!(retval = krb5_unparse_name(context, principal, &princ_name))) { - /* need to store the NULL for decoding */ - key->length = strlen(princ_name)+1; - key->data = princ_name; - } - return(retval); -} - -void -krb5_free_princ_dbkey(context, key) - krb5_context context; - krb5_data *key; -{ - (void) krb5_free_data_contents(context, key); -} - -krb5_error_code -krb5_encode_princ_contents(context, content, entry) - krb5_context context; - krb5_data * content; - krb5_db_entry * entry; -{ - int i, j; - unsigned int unparse_princ_size; - char * unparse_princ; - char * nextloc; - krb5_tl_data * tl_data; - krb5_error_code retval; - krb5_int16 psize16; - - /* - * Generate one lump of data from the krb5_db_entry. - * This data must be independent of byte order of the machine, - * compact and extensible. - */ - - /* - * First allocate enough space for all the data. - * Need 2 bytes for the length of the base structure - * then 36 [ 8 * 4 + 2 * 2] bytes for the base information - * [ attributes, max_life, max_renewable_life, expiration, - * pw_expiration, last_success, last_failed, fail_auth_count ] - * [ n_key_data, n_tl_data ] - * then XX bytes [ e_length ] for the extra data [ e_data ] - * then XX bytes [ 2 for length + length for string ] for the principal, - * then (4 [type + length] + tl_data_length) bytes per tl_data - * then (4 + (4 + key_data_length) per key_data_contents) bytes per key_data - */ - content->length = entry->len + entry->e_length; - - if ((retval = krb5_unparse_name(context, entry->princ, &unparse_princ))) - return(retval); - - unparse_princ_size = strlen(unparse_princ) + 1; - content->length += unparse_princ_size; - content->length += 2; - - i = 0; - /* tl_data is a linked list */ - for (tl_data = entry->tl_data; tl_data; tl_data = tl_data->tl_data_next) { - content->length += tl_data->tl_data_length; - content->length += 4; /* type, length */ - i++; - } - - if (i != entry->n_tl_data) { - retval = KRB5_KDB_TRUNCATED_RECORD; - goto epc_error; - } - - /* key_data is an array */ - for (i = 0; i < entry->n_key_data; i++) { - content->length += 4; /* Version, KVNO */ - for (j = 0; j < entry->key_data[i].key_data_ver; j++) { - content->length += entry->key_data[i].key_data_length[j]; - content->length += 4; /* type + length */ - } - } - - if ((content->data = malloc(content->length)) == NULL) { - retval = ENOMEM; - goto epc_error; - } - - /* - * Now we go through entry again, this time copying data - * These first entries are always saved regardless of version - */ - nextloc = content->data; - - /* Base Length */ - krb5_kdb_encode_int16(entry->len, nextloc); - nextloc += 2; - - /* Attributes */ - krb5_kdb_encode_int32(entry->attributes, nextloc); - nextloc += 4; - - /* Max Life */ - krb5_kdb_encode_int32(entry->max_life, nextloc); - nextloc += 4; - - /* Max Renewable Life */ - krb5_kdb_encode_int32(entry->max_renewable_life, nextloc); - nextloc += 4; - - /* When the client expires */ - krb5_kdb_encode_int32(entry->expiration, nextloc); - nextloc += 4; - - /* When its passwd expires */ - krb5_kdb_encode_int32(entry->pw_expiration, nextloc); - nextloc += 4; - - /* Last successful passwd */ - krb5_kdb_encode_int32(entry->last_success, nextloc); - nextloc += 4; - - /* Last failed passwd attempt */ - krb5_kdb_encode_int32(entry->last_failed, nextloc); - nextloc += 4; - - /* # of failed passwd attempt */ - krb5_kdb_encode_int32(entry->fail_auth_count, nextloc); - nextloc += 4; - - /* # tl_data strutures */ - krb5_kdb_encode_int16(entry->n_tl_data, nextloc); - nextloc += 2; - - /* # key_data strutures */ - krb5_kdb_encode_int16(entry->n_key_data, nextloc); - nextloc += 2; - - /* Put extended fields here */ - if (entry->len != KRB5_KDB_V1_BASE_LENGTH) - abort(); - - /* Any extra data that this version doesn't understand. */ - if (entry->e_length) { - memcpy(nextloc, entry->e_data, entry->e_length); - nextloc += entry->e_length; - } - - /* - * Now we get to the principal. - * To squeze a few extra bytes out it is always assumed to come - * after the base type. - */ - psize16 = (krb5_int16) unparse_princ_size; - krb5_kdb_encode_int16(psize16, nextloc); - nextloc += 2; - (void) memcpy(nextloc, unparse_princ, unparse_princ_size); - nextloc += unparse_princ_size; - - /* tl_data is a linked list, of type, legth, contents */ - for (tl_data = entry->tl_data; tl_data; tl_data = tl_data->tl_data_next) { - krb5_kdb_encode_int16(tl_data->tl_data_type, nextloc); - nextloc += 2; - krb5_kdb_encode_int16(tl_data->tl_data_length, nextloc); - nextloc += 2; - - memcpy(nextloc, tl_data->tl_data_contents, tl_data->tl_data_length); - nextloc += tl_data->tl_data_length; - } - - /* key_data is an array */ - for (i = 0; i < entry->n_key_data; i++) { - krb5_kdb_encode_int16(entry->key_data[i].key_data_ver, nextloc); - nextloc += 2; - krb5_kdb_encode_int16(entry->key_data[i].key_data_kvno, nextloc); - nextloc += 2; - - for (j = 0; j < entry->key_data[i].key_data_ver; j++) { - krb5_int16 type = entry->key_data[i].key_data_type[j]; - krb5_ui_2 length = entry->key_data[i].key_data_length[j]; - - krb5_kdb_encode_int16(type, nextloc); - nextloc += 2; - krb5_kdb_encode_int16(length, nextloc); - nextloc += 2; - - if (length) { - memcpy(nextloc, entry->key_data[i].key_data_contents[j],length); - nextloc += length; - } - } - } - -epc_error:; - free(unparse_princ); - return retval; -} - -void -krb5_free_princ_contents(context, contents) - krb5_context context; - krb5_data *contents; -{ - krb5_free_data_contents(context, contents); - return; -} - -krb5_error_code -krb5_decode_princ_contents(context, content, entry) - krb5_context context; - krb5_data * content; - krb5_db_entry * entry; -{ - int sizeleft, i; - char * nextloc; - krb5_tl_data ** tl_data; - krb5_int16 i16; - - krb5_error_code retval; - - /* Zero out entry and NULL pointers */ - memset(entry, 0, sizeof(krb5_db_entry)); - - /* - * undo the effects of encode_princ_contents. - * - * The first part is decoding the base type. If the base type is - * bigger than the original base type then the additional fields - * need to be filled in. If the base type is larger than any - * known base type the additional data goes in e_data. - */ - - /* First do the easy stuff */ - nextloc = content->data; - sizeleft = content->length; - if ((sizeleft -= KRB5_KDB_V1_BASE_LENGTH) < 0) - return KRB5_KDB_TRUNCATED_RECORD; - - /* Base Length */ - krb5_kdb_decode_int16(nextloc, entry->len); - nextloc += 2; - - /* Attributes */ - krb5_kdb_decode_int32(nextloc, entry->attributes); - nextloc += 4; - - /* Max Life */ - krb5_kdb_decode_int32(nextloc, entry->max_life); - nextloc += 4; - - /* Max Renewable Life */ - krb5_kdb_decode_int32(nextloc, entry->max_renewable_life); - nextloc += 4; - - /* When the client expires */ - krb5_kdb_decode_int32(nextloc, entry->expiration); - nextloc += 4; - - /* When its passwd expires */ - krb5_kdb_decode_int32(nextloc, entry->pw_expiration); - nextloc += 4; - - /* Last successful passwd */ - krb5_kdb_decode_int32(nextloc, entry->last_success); - nextloc += 4; - - /* Last failed passwd attempt */ - krb5_kdb_decode_int32(nextloc, entry->last_failed); - nextloc += 4; - - /* # of failed passwd attempt */ - krb5_kdb_decode_int32(nextloc, entry->fail_auth_count); - nextloc += 4; - - /* # tl_data strutures */ - krb5_kdb_decode_int16(nextloc, entry->n_tl_data); - nextloc += 2; - - if (entry->n_tl_data < 0) - return KRB5_KDB_TRUNCATED_RECORD; - - /* # key_data strutures */ - krb5_kdb_decode_int16(nextloc, entry->n_key_data); - nextloc += 2; - - if (entry->n_key_data < 0) - return KRB5_KDB_TRUNCATED_RECORD; - - /* Check for extra data */ - if (entry->len > KRB5_KDB_V1_BASE_LENGTH) { - entry->e_length = entry->len - KRB5_KDB_V1_BASE_LENGTH; - if ((entry->e_data = (krb5_octet *)malloc(entry->e_length))) { - memcpy(entry->e_data, nextloc, entry->e_length); - nextloc += entry->e_length; - } else { - return ENOMEM; - } - } - - /* - * Get the principal name for the entry - * (stored as a string which gets unparsed.) - */ - if ((sizeleft -= 2) < 0) { - retval = KRB5_KDB_TRUNCATED_RECORD; - goto error_out; - } - - i = 0; - krb5_kdb_decode_int16(nextloc, i16); - i = (int) i16; - nextloc += 2; - - if ((retval = krb5_parse_name(context, nextloc, &(entry->princ)))) - goto error_out; - if (((size_t) i != (strlen(nextloc) + 1)) || (sizeleft < i)) { - retval = KRB5_KDB_TRUNCATED_RECORD; - goto error_out; - } - sizeleft -= i; - nextloc += i; - - /* tl_data is a linked list */ - tl_data = &entry->tl_data; - for (i = 0; i < entry->n_tl_data; i++) { - if ((sizeleft -= 4) < 0) { - retval = KRB5_KDB_TRUNCATED_RECORD; - goto error_out; - } - if ((*tl_data = (krb5_tl_data *) - malloc(sizeof(krb5_tl_data))) == NULL) { - retval = ENOMEM; - goto error_out; - } - (*tl_data)->tl_data_next = NULL; - (*tl_data)->tl_data_contents = NULL; - krb5_kdb_decode_int16(nextloc, (*tl_data)->tl_data_type); - nextloc += 2; - krb5_kdb_decode_int16(nextloc, (*tl_data)->tl_data_length); - nextloc += 2; - - if ((sizeleft -= (*tl_data)->tl_data_length) < 0) { - retval = KRB5_KDB_TRUNCATED_RECORD; - goto error_out; - } - if (((*tl_data)->tl_data_contents = (krb5_octet *) - malloc((*tl_data)->tl_data_length)) == NULL) { - retval = ENOMEM; - goto error_out; - } - memcpy((*tl_data)->tl_data_contents,nextloc,(*tl_data)->tl_data_length); - nextloc += (*tl_data)->tl_data_length; - tl_data = &((*tl_data)->tl_data_next); - } - - /* key_data is an array */ - if (entry->n_key_data && ((entry->key_data = (krb5_key_data *) - malloc(sizeof(krb5_key_data) * entry->n_key_data)) == NULL)) { - retval = ENOMEM; - goto error_out; - } - for (i = 0; i < entry->n_key_data; i++) { - krb5_key_data * key_data; - int j; - - if ((sizeleft -= 4) < 0) { - retval = KRB5_KDB_TRUNCATED_RECORD; - goto error_out; - } - key_data = entry->key_data + i; - memset(key_data, 0, sizeof(krb5_key_data)); - krb5_kdb_decode_int16(nextloc, key_data->key_data_ver); - nextloc += 2; - krb5_kdb_decode_int16(nextloc, key_data->key_data_kvno); - nextloc += 2; - - /* key_data_ver determins number of elements and how to unparse them. */ - if (key_data->key_data_ver <= KRB5_KDB_V1_KEY_DATA_ARRAY) { - for (j = 0; j < key_data->key_data_ver; j++) { - if ((sizeleft -= 4) < 0) { - retval = KRB5_KDB_TRUNCATED_RECORD; - goto error_out; - } - krb5_kdb_decode_int16(nextloc, key_data->key_data_type[j]); - nextloc += 2; - krb5_kdb_decode_int16(nextloc, key_data->key_data_length[j]); - nextloc += 2; - - if ((sizeleft -= key_data->key_data_length[j]) < 0) { - retval = KRB5_KDB_TRUNCATED_RECORD; - goto error_out; - } - if (key_data->key_data_length[j]) { - if ((key_data->key_data_contents[j] = (krb5_octet *) - malloc(key_data->key_data_length[j])) == NULL) { - retval = ENOMEM; - goto error_out; - } - memcpy(key_data->key_data_contents[j], nextloc, - key_data->key_data_length[j]); - nextloc += key_data->key_data_length[j]; - } - } - } else { - /* This isn't right. I'll fix it later */ - abort(); - } - } - return 0; - -error_out:; - krb5_dbe_free_contents(context, entry); - return retval; -} - -void -krb5_dbe_free_contents(context, entry) - krb5_context context; - krb5_db_entry * entry; -{ - krb5_tl_data * tl_data_next; - krb5_tl_data * tl_data; - int i, j; - - if (entry->e_data) - free(entry->e_data); - if (entry->princ) - krb5_free_principal(context, entry->princ); - for (tl_data = entry->tl_data; tl_data; tl_data = tl_data_next) { - tl_data_next = tl_data->tl_data_next; - if (tl_data->tl_data_contents) - free(tl_data->tl_data_contents); - free(tl_data); - } - if (entry->key_data) { - for (i = 0; i < entry->n_key_data; i++) { - for (j = 0; j < entry->key_data[i].key_data_ver; j++) { - if (entry->key_data[i].key_data_length[j]) { - if (entry->key_data[i].key_data_contents[j]) { - memset(entry->key_data[i].key_data_contents[j], - 0, - (unsigned) entry->key_data[i].key_data_length[j]); - free (entry->key_data[i].key_data_contents[j]); - } - } - entry->key_data[i].key_data_contents[j] = NULL; - entry->key_data[i].key_data_length[j] = 0; - entry->key_data[i].key_data_type[j] = 0; - } - } - free(entry->key_data); - } - memset(entry, 0, sizeof(*entry)); - return; -} - -/* - * Given a particular enctype and optional salttype and kvno, find the - * most appropriate krb5_key_data entry of the database entry. - * - * If stype or kvno is negative, it is ignored. - * If kvno is 0 get the key which is maxkvno for the princ and matches - * the other attributes. - */ -krb5_error_code -krb5_dbe_search_enctype(kcontext, dbentp, start, ktype, stype, kvno, kdatap) - krb5_context kcontext; - krb5_db_entry *dbentp; - krb5_int32 *start; - krb5_int32 ktype; - krb5_int32 stype; - krb5_int32 kvno; - krb5_key_data **kdatap; -{ - int i, idx; - int maxkvno; - krb5_key_data *datap; - krb5_error_code ret; - - ret = 0; - if (kvno == -1 && stype == -1 && ktype == -1) - kvno = 0; - - if (kvno == 0) { - /* Get the max key version */ - for (i = 0; i < dbentp->n_key_data; i++) { - if (kvno < dbentp->key_data[i].key_data_kvno) { - kvno = dbentp->key_data[i].key_data_kvno; - } - } - } - - maxkvno = -1; - datap = (krb5_key_data *) NULL; - for (i = *start; i < dbentp->n_key_data; i++) { - krb5_boolean similar; - krb5_int32 db_stype; - - ret = 0; - if (dbentp->key_data[i].key_data_ver > 1) { - db_stype = dbentp->key_data[i].key_data_type[1]; - } else { - db_stype = KRB5_KDB_SALTTYPE_NORMAL; - } - - /* - * Filter out non-permitted enctypes. - */ - if (!krb5_is_permitted_enctype(kcontext, - dbentp->key_data[i].key_data_type[0])) { - ret = KRB5_KDB_NO_PERMITTED_KEY; - continue; - } - - - if (ktype > 0) { - if ((ret = krb5_c_enctype_compare(kcontext, (krb5_enctype) ktype, - dbentp->key_data[i].key_data_type[0], - &similar))) - return(ret); - } - - if (((ktype <= 0) || similar) && - ((db_stype == stype) || (stype < 0))) { - if (kvno >= 0) { - if (kvno == dbentp->key_data[i].key_data_kvno) { - datap = &dbentp->key_data[i]; - idx = i; - maxkvno = kvno; - break; - } - } else { - if (dbentp->key_data[i].key_data_kvno > maxkvno) { - maxkvno = dbentp->key_data[i].key_data_kvno; - datap = &dbentp->key_data[i]; - idx = i; - } - } - } - } - if (maxkvno < 0) - return ret ? ret : KRB5_KDB_NO_MATCHING_KEY; - *kdatap = datap; - *start = idx+1; - return 0; -} - -krb5_error_code -krb5_dbe_find_enctype(kcontext, dbentp, ktype, stype, kvno, kdatap) - krb5_context kcontext; - krb5_db_entry *dbentp; - krb5_int32 ktype; - krb5_int32 stype; - krb5_int32 kvno; - krb5_key_data **kdatap; -{ - krb5_int32 start = 0; - - return krb5_dbe_search_enctype(kcontext, dbentp, &start, ktype, stype, - kvno, kdatap); -} - - diff --git a/src/lib/kdb/store_mkey.c b/src/lib/kdb/store_mkey.c deleted file mode 100644 index 587850e..0000000 --- a/src/lib/kdb/store_mkey.c +++ /dev/null @@ -1,106 +0,0 @@ -/* - * lib/kdb/store_mkey.c - * - * Copyright 1990 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. - * - * - * krb5_db_store_mkey(): - * Store a database master key in a file. - */ - - -#include <errno.h> -#include "k5-int.h" - -/* Just in case sysincl.h didn't get it */ - -#ifndef MAXPATHLEN -#define MAXPATHLEN 1024 -#endif - -/* - * Put the KDC database master key into a file. If keyfile is NULL, - * then a default name derived from the principal name mname is used. - */ - -#ifndef min -#define min(a,b) (((a) < (b)) ? (a) : (b)) -#endif - -krb5_error_code -krb5_db_store_mkey(context, keyfile, mname, key) - krb5_context context; - char *keyfile; - krb5_principal mname; - krb5_keyblock *key; -{ - FILE *kf; - krb5_error_code retval = 0; - krb5_ui_2 enctype; - char defkeyfile[MAXPATHLEN+1]; - krb5_data *realm = krb5_princ_realm(context, mname); -#if HAVE_UMASK - mode_t oumask; -#endif - - if (!keyfile) { - (void) strcpy(defkeyfile, DEFAULT_KEYFILE_STUB); - (void) strncat(defkeyfile, realm->data, - min(sizeof(defkeyfile)-sizeof(DEFAULT_KEYFILE_STUB)-1, - realm->length)); - defkeyfile[sizeof(defkeyfile) - 1] = '\0'; - keyfile = defkeyfile; - } - -#if HAVE_UMASK - oumask = umask(077); -#endif -#ifdef ANSI_STDIO - if (!(kf = fopen(keyfile, "wb"))) -#else - if (!(kf = fopen(keyfile, "w"))) -#endif - { -#if HAVE_UMASK - (void) umask(oumask); -#endif - return errno; - } - enctype = key->enctype; - if ((fwrite((krb5_pointer) &enctype, - 2, 1, kf) != 1) || - (fwrite((krb5_pointer) &key->length, - sizeof(key->length), 1, kf) != 1) || - (fwrite((krb5_pointer) key->contents, - sizeof(key->contents[0]), (unsigned) key->length, - kf) != key->length)) { - retval = errno; - (void) fclose(kf); - } - if (fclose(kf) == EOF) - retval = errno; -#if HAVE_UMASK - (void) umask(oumask); -#endif - return retval; -} diff --git a/src/lib/kdb/t_kdb.c b/src/lib/kdb/t_kdb.c deleted file mode 100644 index 769d3e6..0000000 --- a/src/lib/kdb/t_kdb.c +++ /dev/null @@ -1,1091 +0,0 @@ -/* - * lib/kdb/t_kdb.c - * - * Copyright 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. 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. - * - */ - -/* - * t_kdb.c - Test [and optionally obtain timing information about] the - * Kerberos database functions. - */ - -#define KDB5_DISPATCH -#include "k5-int.h" -#include <ctype.h> -#include <sys/time.h> -#include <sys/wait.h> -#include "com_err.h" - -#if HAVE_SRAND48 -#define RAND() lrand48() -#define SRAND(a) srand48(a) -#define RAND_TYPE long -#elif HAVE_SRAND -#define RAND() rand() -#define SRAND(a) srand(a) -#define RAND_TYPE int -#elif HAVE_SRANDOM -#define RAND() random() -#define SRAND(a) srandom(a) -#define RAND_TYPE long -#else /* no random */ -need a random number generator -#endif /* no random */ - -#define T_KDB_N_PASSES 100 -#define T_KDB_DEF_DB "test_db" -#define MAX_PNAME_LEN 1024 -#define MAX_PRINC_COMPS 8 -#define MAX_COMP_SIZE 32 - -#define RANDOM(a,b) (a + (RAND() % (b-a))) - -enum dbtype { DB_UFO, DB_DEFAULT, DB_BERKELEY, DB_DBM }; - -char *programname = (char *) NULL; -krb5_data mprinc_data_entries[] = { - { 0, sizeof("master")-1, "master"}, - { 0, sizeof("key")-1, "key"} -}; - -krb5_principal_data master_princ_data = { - 0, /* Magic number */ - { 0, sizeof("test.realm")-1, "test.realm"}, /* Realm */ - mprinc_data_entries, /* Name/instance */ - sizeof(mprinc_data_entries)/ - sizeof(mprinc_data_entries[0]), /* Number */ - KRB5_NT_SRV_INST /* Type */ -}; - -struct timeval tstart_time, tend_time; -struct timezone dontcare; -krb5_principal *recorded_principals = (krb5_principal *) NULL; -char **recorded_names = (char **) NULL; - -#ifdef BERK_DB_DBM -extern DBM *db_dbm_open (char *, int, int); -extern void db_dbm_close (DBM *); -extern datum db_dbm_fetch (DBM *, datum); -extern datum db_dbm_firstkey (DBM *); -extern datum db_dbm_nextkey (DBM *); -extern int db_dbm_delete (DBM *, datum); -extern int db_dbm_store (DBM *, datum, datum, int); -extern int db_dbm_error (DBM *); -extern int db_dbm_clearerr (DBM *); -extern int db_dbm_dirfno (DBM *); - -static kdb5_dispatch_table berkeley_dispatch = { - "Berkeley Hashed Database", - ".db", /* Index file name ext */ - (char *) NULL, /* Data file name ext */ - ".ok", /* Lock file name ext */ - db_dbm_open, /* Open Database */ - db_dbm_close, /* Close Database */ - db_dbm_fetch, /* Fetch Key */ - db_dbm_firstkey, /* Fetch First Key */ - db_dbm_nextkey, /* Fetch Next Key */ - db_dbm_delete, /* Delete Key */ - db_dbm_store, /* Store Key */ - db_dbm_error, /* Get Database Error */ - db_dbm_clearerr, /* Clear Database Error */ - db_dbm_dirfno, /* Get Database FD num */ - (int (*)()) NULL /* Get Database FD num */ -}; -#endif - -#if defined(NDBM) || defined(ODBM) -/* - * The following prototypes are necessary in case dbm_error and - * dbm_clearerr are in the library but not prototyped - * (e.g. NetBSD-1.0) - */ -#ifdef MISSING_ERROR_PROTO -int dbm_error (DBM *); -#endif -#ifdef MISSING_CLEARERR_PROTO -int dbm_clearerr (DBM *); -#endif - -static kdb5_dispatch_table dbm_dispatch = { - "Stock [N]DBM Database", - ".dir", /* Index file name ext */ - ".pag", /* Data file name ext */ - ".ok", /* Lock file name ext */ - dbm_open, /* Open Database */ - dbm_close, /* Close Database */ - dbm_fetch, /* Fetch Key */ - dbm_firstkey, /* Fetch First Key */ - dbm_nextkey, /* Fetch Next Key */ - dbm_delete, /* Delete Key */ - dbm_store, /* Store Key */ - /* - * The following are #ifdef'd because they have the potential to be - * macros rather than functions. - */ -#ifdef dbm_error - (int (*)()) NULL, /* Get Database Error */ -#else /* dbm_error */ -#ifdef HAVE_DBM_ERROR - dbm_error, /* Get Database Error */ -#else - (int (*)()) NULL, /* Get Database Error */ -#endif -#endif /* dbm_error */ -#ifdef dbm_clearerr - (int (*)()) NULL, /* Clear Database Error */ -#else /* dbm_clearerr */ -#ifdef HAVE_DBM_CLEARERR - dbm_clearerr, /* Clear Database Error */ -#else - (int (*)()) NULL, /* Clear Database Error */ -#endif -#endif /* dbm_clearerr */ -#ifdef dbm_dirfno - (int (*)()) NULL, /* Get Database FD num */ -#else /* dbm_dirfno */ - dbm_dirfno, /* Get Database FD num */ -#endif /* dbm_dirfno */ -#ifdef dbm_pagfno - (int (*)()) NULL, /* Get Database FD num */ -#else /* dbm_pagfno */ - dbm_pagfno, /* Get Database FD num */ -#endif /* dbm_pagfno */ -}; -#endif /* NDBM || ODBM */ - - -/* - * Timer macros. - */ -#define swatch_on() ((void) gettimeofday(&tstart_time, &dontcare)) -#define swatch_eltime() ((gettimeofday(&tend_time, &dontcare)) ? -1.0 : \ - (((float) (tend_time.tv_sec - \ - tstart_time.tv_sec)) + \ - (((float) (tend_time.tv_usec - \ - tstart_time.tv_usec))/1000000.0))) - -/* - * Free all principals and names in the recorded names list. - */ -static void -free_principals(kcontext, nentries) - krb5_context kcontext; - int nentries; -{ - int i; - if (recorded_principals) { - for (i=0; i<nentries; i++) { - if (recorded_principals[i]) - krb5_free_principal(kcontext, recorded_principals[i]); - } - free(recorded_principals); - } - recorded_principals = (krb5_principal *) NULL; - - if (recorded_names) { - for (i=0; i<nentries; i++) { - if (recorded_names[i]) - free(recorded_names[i]); - } - free(recorded_names); - } - recorded_names = (char **) NULL; -} - -/* - * Initialize the recorded names list. - */ -static void -init_princ_recording(kcontext, nentries) - krb5_context kcontext; - int nentries; -{ - recorded_principals = (krb5_principal *) - malloc(nentries * sizeof(krb5_principal)); - if (!recorded_principals) - abort(); - memset((char *) recorded_principals, 0, - nentries * sizeof(krb5_principal)); - recorded_names = (char **) malloc(nentries * sizeof(char *)); - if (!recorded_names) - abort(); - memset((char *) recorded_names, 0, nentries * sizeof(char *)); -} - -/* - * Record a principal and name. - */ -static void -record_principal(slotno, princ, pname) - int slotno; - krb5_principal princ; - char *pname; -{ - recorded_principals[slotno] = princ; - recorded_names[slotno] = (char *) malloc(strlen(pname)+1); - if (recorded_names[slotno]) - strcpy(recorded_names[slotno], pname); -} - -#define playback_principal(slotno) (recorded_principals[slotno]) -#define playback_name(slotno) (recorded_names[slotno]) - -/* - * See if a principal already exists. - */ -static krb5_boolean -principal_found(nvalid, pname) - int nvalid; - char *pname; -{ - krb5_boolean found; - int i; - - found = 0; - for (i=0; i<nvalid; i++) { - if (!strcmp(recorded_names[i], pname)) { - found = 1; - break; - } - } - return(found); -} - -/* - * Add a principal to the database. - */ -static krb5_error_code -add_principal(kcontext, principal, mkey, key) - krb5_context kcontext; - krb5_principal principal; - krb5_keyblock * mkey; - krb5_keyblock * key; -{ - krb5_error_code kret; - krb5_db_entry dbent; - krb5_keyblock * rkey = NULL, lkey; - krb5_timestamp timenow; - int nentries = 1; - - memset((char *) &dbent, 0, sizeof(dbent)); - dbent.len = KRB5_KDB_V1_BASE_LENGTH; - - dbent.attributes = KRB5_KDB_DEF_FLAGS; - dbent.max_life = KRB5_KDB_MAX_LIFE; - dbent.expiration = KRB5_KDB_EXPIRATION; - dbent.max_renewable_life = KRB5_KDB_MAX_RLIFE; - - if ((kret = krb5_copy_principal(kcontext, principal, &dbent.princ))) - goto out; - - if ((kret = krb5_timeofday(kcontext, &timenow))) - goto out; - if ((kret = krb5_dbe_update_mod_princ_data(kcontext, &dbent, - timenow, principal))) - goto out; - - if (!key) { - kret = krb5_c_make_random_key (kcontext, mkey->enctype, &lkey); - if (kret) - goto out; - rkey = &lkey; - } else - rkey = key; - - if ((kret = krb5_dbe_create_key_data(kcontext, &dbent))) - goto out; - if ((kret = krb5_dbekd_encrypt_key_data(kcontext, mkey, rkey, NULL, 1, - &dbent.key_data[0]))) - goto out; - - if (!key) - krb5_free_keyblock_contents(kcontext, rkey); - - kret = krb5_db_put_principal(kcontext, &dbent, &nentries); - if ((!kret) && (nentries != 1)) - kret = KRB5_KDB_UK_SERROR; - out: - krb5_dbe_free_contents(kcontext, &dbent); - return(kret); -} - -/* - * Generate a principal name. - */ -static krb5_error_code -gen_principal(kcontext, realm, do_rand, n, princp, namep) - krb5_context kcontext; - char *realm; - int do_rand; - int n; - krb5_principal *princp; - char **namep; -{ - static char pnamebuf[MAX_PNAME_LEN]; - static char *instnames[] = { - "instance1", "xxx2", "whereami3", "ABCDEFG4", "foofoo5" }; - static char *princnames[] = { - "princ1", "user2", "service3" }; - - krb5_error_code kret; - char *instname; - char *princbase; - int ncomps; - int i, complen, j; - char *cp; - - if (do_rand) { - ncomps = RANDOM(1,MAX_PRINC_COMPS); - cp = pnamebuf; - for (i=0; i<ncomps; i++) { - complen = RANDOM(1,MAX_COMP_SIZE); - for (j=0; j<complen; j++) { - *cp = (char) RANDOM(0,256); - while (!isalnum(*cp & 0xff)) - *cp = (char) RANDOM(0,256); - cp++; - if(cp + strlen(realm) >= pnamebuf + sizeof(pnamebuf)) - break; - } - if(cp + strlen(realm) >= pnamebuf + sizeof(pnamebuf)) - break; - *cp = '/'; - cp++; - } - if(cp + strlen(realm) < pnamebuf + sizeof(pnamebuf)) { - cp[-1] = '@'; - strcpy(cp, realm); - } else { - strcpy(cp , ""); - } - } - else { - instname = instnames[n % (sizeof(instnames)/sizeof(instnames[0]))]; - princbase = princnames[n % (sizeof(princnames)/sizeof(princnames[0]))]; - sprintf(pnamebuf, "%s%d/%s@%s", princbase, n, instname, realm); - } - kret = krb5_parse_name(kcontext, pnamebuf, princp); - *namep = (!kret) ? pnamebuf : (char *) NULL; - return(kret); -} - -/* - * Find a principal in the database. - */ -static krb5_error_code -find_principal(kcontext, principal, docompare) - krb5_context kcontext; - krb5_principal principal; - krb5_boolean docompare; -{ - krb5_error_code kret; - krb5_db_entry dbent; - krb5_principal mod_princ; - krb5_timestamp mod_time; - int how_many; - krb5_boolean more; - - more = 0; - how_many = 1; - if ((kret = krb5_db_get_principal(kcontext, principal, &dbent, - &how_many, &more))) - return(kret); - if (how_many == 0) - return(KRB5_KDB_NOENTRY); - - if ((kret = krb5_dbe_lookup_mod_princ_data(kcontext, &dbent, - &mod_time, &mod_princ))) - - return(kret); - - if (docompare) { - if ((dbent.max_life != KRB5_KDB_MAX_LIFE) || - (dbent.max_renewable_life != KRB5_KDB_MAX_RLIFE) || - (dbent.expiration != KRB5_KDB_EXPIRATION) || - (dbent.attributes != KRB5_KDB_DEF_FLAGS) || - !krb5_principal_compare(kcontext, principal, dbent.princ) || - !krb5_principal_compare(kcontext, principal, mod_princ)) - kret = KRB5_PRINC_NOMATCH; - } - - krb5_db_free_principal(kcontext, &dbent, how_many); - krb5_free_principal(kcontext, mod_princ); - if (!kret) - return(((how_many == 1) && (more == 0)) ? 0 : KRB5KRB_ERR_GENERIC); - else - return(kret); - -} - -/* - * Delete a principal. - */ -static krb5_error_code -delete_principal(kcontext, principal) - krb5_context kcontext; - krb5_principal principal; -{ - krb5_error_code kret; - int num2delete; - - num2delete = 1; - if ((kret = krb5_db_delete_principal(kcontext, principal, &num2delete))) - return(kret); - return((num2delete == 1) ? 0 : KRB5KRB_ERR_GENERIC); -} - -static int -do_testing(db, passes, verbose, timing, rcases, check, save_db, dontclean, - ptest, hash) - char *db; - int passes; - int verbose; - int timing; - int rcases; - int check; - int save_db; - int dontclean; - int ptest; - int hash; -{ - krb5_error_code kret; - krb5_context kcontext; - char *op, *linkage, *oparg; - krb5_principal master_princ; - int master_princ_set = 0; - char *mkey_name; - char *realm; - char *mkey_fullname; - char *master_passwd; - krb5_data salt_data; - krb5_encrypt_block master_encblock; - krb5_keyblock master_keyblock; - krb5_data passwd; - krb5_pointer rseed; - krb5_boolean db_open, db_created; - int passno; - krb5_principal principal; - char *pname; - float elapsed; - krb5_keyblock stat_kb; - krb5_int32 crflags; - - mkey_name = "master/key"; - realm = master_princ_data.realm.data; - mkey_fullname = (char *) NULL; - master_princ = (krb5_principal) NULL; - master_passwd = "master_password"; - db_open = 0; - db_created = 0; - linkage = ""; - oparg = ""; - crflags = hash ? KRB5_KDB_CREATE_HASH : KRB5_KDB_CREATE_BTREE; - - memset(&master_keyblock, 0, sizeof(master_keyblock)); - - /* Set up some initial context */ - op = "initializing krb5"; - kret = krb5_init_context(&kcontext); - if (kret) - goto goodbye; - - /* - * The database had better not exist. - */ - op = "making sure database doesn't exist"; - if (!(kret = krb5_db_set_name(kcontext, db))) { - kret = EEXIST; - goto goodbye; - } - - /* Set up the master key name */ - op = "setting up master key name"; - if ((kret = krb5_db_setup_mkey_name(kcontext, mkey_name, realm, - &mkey_fullname, &master_princ))) - goto goodbye; - - master_princ_set = 1; - if (verbose) - fprintf(stdout, "%s: Initializing '%s', master key is '%s'\n", - programname, db, mkey_fullname); - - free(mkey_fullname); - mkey_fullname = 0; - - op = "salting master key"; - if ((kret = krb5_principal2salt(kcontext, master_princ, &salt_data))) - goto goodbye; - - op = "converting master key"; - krb5_use_enctype(kcontext, &master_encblock, DEFAULT_KDC_ENCTYPE); - master_keyblock.enctype = DEFAULT_KDC_ENCTYPE; - passwd.length = strlen(master_passwd); - passwd.data = master_passwd; - if ((kret = krb5_string_to_key(kcontext, &master_encblock, - &master_keyblock, &passwd, &salt_data))) - goto goodbye; - /* Clean up */ - free(salt_data.data); - - /* Process master key */ - op = "processing master key"; - if ((kret = krb5_process_key(kcontext, &master_encblock, - &master_keyblock))) - goto goodbye; - - /* Initialize random key generator */ - op = "initializing random key generator"; - if ((kret = krb5_init_random_key(kcontext, - &master_encblock, - &master_keyblock, - &rseed))) - goto goodbye; - - /* Create database */ - op = "creating database"; - if ((kret = krb5_db_create(kcontext, db, crflags))) - goto goodbye; - - db_created = 1; - - /* Set this database as active. */ - op = "setting active database"; - if ((kret = krb5_db_set_name(kcontext, db))) - goto goodbye; - - /* Initialize database */ - op = "initializing database"; - if ((kret = krb5_db_init(kcontext))) - goto goodbye; - - db_open = 1; - op = "adding master principal"; - if ((kret = add_principal(kcontext, - master_princ, - &master_keyblock, - &master_keyblock))) - goto goodbye; - - - stat_kb.enctype = DEFAULT_KDC_ENCTYPE; - stat_kb.length = 8; - stat_kb.contents = (krb5_octet *) "helpmeee"; - - /* We are now ready to proceed to test. */ - if (verbose) - fprintf(stdout, "%s: Beginning %stest\n", - programname, (rcases) ? "random " : ""); - init_princ_recording(kcontext, passes); - if (rcases) { - struct tacc { - float t_time; - int t_number; - } accumulated[3]; - int i, nvalid, discrim, highwater, coinflip; - krb5_keyblock *kbp; - - /* Generate random cases */ - for (i=0; i<3; i++) { - accumulated[i].t_time = 0.0; - accumulated[i].t_number = 0; - } - - /* - * Generate principal names. - */ - if (verbose > 1) - fprintf(stdout, "%s: generating %d names\n", - programname, passes); - for (passno=0; passno<passes; passno++) { - op = "generating principal name"; - do { - if ((kret = gen_principal(kcontext, realm, rcases, - passno, &principal, &pname))) - goto goodbye; - } while (principal_found(passno-1, pname)); - record_principal(passno, principal, pname); - } - - /* Prime the database with some number of entries */ - nvalid = passes/4; - if (nvalid < 10) - nvalid = 10; - if (nvalid > passes) - nvalid = passes; - - if (verbose > 1) - fprintf(stdout, "%s: priming database with %d principals\n", - programname, nvalid); - highwater = 0; - for (passno=0; passno<nvalid; passno++) { - op = "adding principal"; - coinflip = RANDOM(0,2); - kbp = (coinflip) ? &stat_kb : (krb5_keyblock *) NULL; - if (timing) { - swatch_on(); - } - if ((kret = add_principal(kcontext, playback_principal(passno), - &master_keyblock, kbp))) { - linkage = "initially "; - oparg = playback_name(passno); - goto cya; - } - if (timing) { - elapsed = swatch_eltime(); - accumulated[0].t_time += elapsed; - accumulated[0].t_number++; - } - if (verbose > 4) - fprintf(stderr, "*A(%s)\n", playback_name(passno)); - highwater++; - } - - if (verbose > 1) - fprintf(stderr, "%s: beginning random loop\n", programname); - /* Loop through some number of times and pick random operations */ - for (i=0; i<3*passes; i++) { - discrim = RANDOM(0,100); - - /* Add a principal 25% of the time, if possible */ - if ((discrim < 25) && (nvalid < passes)) { - op = "adding principal"; - coinflip = RANDOM(0,2); - kbp = (coinflip) ? &stat_kb : (krb5_keyblock *) NULL; - if (timing) { - swatch_on(); - } - if ((kret = add_principal(kcontext, - playback_principal(nvalid), - &master_keyblock, kbp))) { - oparg = playback_name(nvalid); - goto cya; - } - if (timing) { - elapsed = swatch_eltime(); - accumulated[0].t_time += elapsed; - accumulated[0].t_number++; - } - if (verbose > 4) - fprintf(stderr, "*A(%s)\n", playback_name(nvalid)); - nvalid++; - if (nvalid > highwater) - highwater = nvalid; - } - /* Delete a principal 15% of the time, if possible */ - else if ((discrim > 85) && (nvalid > 10)) { - op = "deleting principal"; - if (timing) { - swatch_on(); - } - if ((kret = delete_principal(kcontext, - playback_principal(nvalid-1)))) { - oparg = playback_name(nvalid-1); - goto cya; - } - if (timing) { - elapsed = swatch_eltime(); - accumulated[2].t_time += elapsed; - accumulated[2].t_number++; - } - if (verbose > 4) - fprintf(stderr, "XD(%s)\n", playback_name(nvalid-1)); - nvalid--; - } - /* Otherwise, find a principal */ - else { - op = "looking up principal"; - passno = RANDOM(0, nvalid); - if (timing) { - swatch_on(); - } - if ((kret = find_principal(kcontext, - playback_principal(passno), - check))) { - oparg = playback_name(passno); - goto cya; - } - if (timing) { - elapsed = swatch_eltime(); - accumulated[1].t_time += elapsed; - accumulated[1].t_number++; - } - if (verbose > 4) - fprintf(stderr, "-S(%s)\n", playback_name(passno)); - } - } - - if (!dontclean) { - /* Clean up the remaining principals */ - if (verbose > 1) - fprintf(stdout, "%s: deleting remaining %d principals\n", - programname, nvalid); - for (passno=0; passno<nvalid; passno++) { - op = "deleting principal"; - if (timing) { - swatch_on(); - } - if ((kret = delete_principal(kcontext, - playback_principal(passno)))) { - linkage = "finally "; - oparg = playback_name(passno); - goto cya; - } - if (timing) { - elapsed = swatch_eltime(); - accumulated[2].t_time += elapsed; - accumulated[2].t_number++; - } - if (verbose > 4) - fprintf(stderr, "XD(%s)\n", playback_name(passno)); - } - } - cya: - if (verbose) - fprintf(stdout, - "%s: highwater mark was %d principals\n", - programname, highwater); - if (accumulated[0].t_number && timing) - fprintf(stdout, - "%s: performed %8d additions in %9.4f seconds (%9.4f/add)\n", - programname, accumulated[0].t_number, - accumulated[0].t_time, - accumulated[0].t_time / (float) accumulated[0].t_number); - if (accumulated[1].t_number && timing) - fprintf(stdout, - "%s: performed %8d lookups in %9.4f seconds (%9.4f/search)\n", - programname, accumulated[1].t_number, - accumulated[1].t_time, - accumulated[1].t_time / (float) accumulated[1].t_number); - if (accumulated[2].t_number && timing) - fprintf(stdout, - "%s: performed %8d deletions in %9.4f seconds (%9.4f/delete)\n", - programname, accumulated[2].t_number, - accumulated[2].t_time, - accumulated[2].t_time / (float) accumulated[2].t_number); - if (kret) - goto goodbye; - } - else { - /* - * Generate principal names. - */ - for (passno=0; passno<passes; passno++) { - op = "generating principal name"; - if ((kret = gen_principal(kcontext, realm, rcases, - passno, &principal, &pname))) - goto goodbye; - record_principal(passno, principal, pname); - } - /* - * Add principals. - */ - if (timing) { - swatch_on(); - } - for (passno=0; passno<passes; passno++) { - op = "adding principal"; - if ((kret = add_principal(kcontext, playback_principal(passno), - &master_keyblock, &stat_kb))) - goto goodbye; - if (verbose > 4) - fprintf(stderr, "*A(%s)\n", playback_name(passno)); - } - if (timing) { - elapsed = swatch_eltime(); - fprintf(stdout, - "%s: added %d principals in %9.4f seconds (%9.4f/add)\n", - programname, passes, elapsed, elapsed/((float) passes)); - } - - /* - * Lookup principals. - */ - if (timing) { - swatch_on(); - } - for (passno=0; passno<passes; passno++) { - op = "looking up principal"; - if ((kret = find_principal(kcontext, playback_principal(passno), - check))) - goto goodbye; - if (verbose > 4) - fprintf(stderr, "-S(%s)\n", playback_name(passno)); - } - if (timing) { - elapsed = swatch_eltime(); - fprintf(stdout, - "%s: found %d principals in %9.4f seconds (%9.4f/search)\n", - programname, passes, elapsed, elapsed/((float) passes)); - } - - /* - * Delete principals. - */ - if (!dontclean) { - if (timing) { - swatch_on(); - } - for (passno=passes-1; passno>=0; passno--) { - op = "deleting principal"; - if ((kret = delete_principal(kcontext, - playback_principal(passno)))) - goto goodbye; - if (verbose > 4) - fprintf(stderr, "XD(%s)\n", playback_name(passno)); - } - if (timing) { - elapsed = swatch_eltime(); - fprintf(stdout, - "%s: deleted %d principals in %9.4f seconds (%9.4f/delete)\n", - programname, passes, elapsed, - elapsed/((float) passes)); - } - } - - } - - goodbye: - if(master_princ_set) { - krb5_free_principal(kcontext, master_princ); - } - if (kret) - fprintf(stderr, "%s: error while %s %s%s(%s)\n", - programname, op, linkage, oparg, error_message(kret)); - - if (!kret && ptest) { - int nper; - pid_t children[32], child; - int nprocs, existat, i, j, fd; - - nprocs = ptest + 1; - if (nprocs > 32) - nprocs = 32; - - nper = passes / nprocs; - unlink("./test.lock"); - for (i=0; i<nprocs; i++) { - child = fork(); - if (child == 0) { - /* Child */ - int base; - krb5_context ccontext; - struct stat stbuf; - - while (stat("./test.lock", &stbuf) == -1) - kret = krb5_init_context(&ccontext); - if (kret) { - com_err(programname, kret, "while initializing krb5"); - exit(1); - } - if ((kret = krb5_db_set_name(ccontext, db)) || - (kret = krb5_db_init(ccontext))) - exit(1); - base = i*nper; - for (j=0; j<nper; j++) { - if ((kret = add_principal(ccontext, - playback_principal(base+j), - &master_keyblock, - &stat_kb))) { - fprintf(stderr, - "%ld: (%d,%d) Failed add of %s with %s\n", - (long) getpid(), i, j, playback_name(base+j), - error_message(kret)); - break; - } - if (verbose > 4) - fprintf(stderr, "*A[%ld](%s)\n", (long) getpid(), - playback_name(base+j)); - } - for (j=0; (j<nper) && (!kret); j++) { - if ((kret = find_principal(ccontext, - playback_principal(base+j), - check))) { - fprintf(stderr, - "%ld: (%d,%d) Failed lookup of %s with %s\n", - (long) getpid(), i, j, playback_name(base+j), - error_message(kret)); - break; - } - if (verbose > 4) - fprintf(stderr, "-S[%ld](%s)\n", (long) getpid(), - playback_name(base+j)); - } - for (j=0; (j<nper) && (!kret); j++) { - if ((kret = delete_principal(ccontext, - playback_principal(base+j)))) { - fprintf(stderr, - "%ld: (%d,%d) Failed delete of %s with %s\n", - (long) getpid(), i, j, playback_name(base+j), - error_message(kret)); - break; - } - if (verbose > 4) - fprintf(stderr, "XD[%ld](%s)\n", (long) getpid(), - playback_name(base+j)); - } - krb5_db_fini(ccontext); - krb5_free_context(ccontext); - exit((kret) ? 1 : 0); - } - else - children[i] = child; - } - fd = open("./test.lock", O_CREAT|O_RDWR|O_EXCL, 0666); - close(fd); - sleep(1); - unlink("./test.lock"); - for (i=0; i<nprocs; i++) { - if (waitpid(children[i], &existat, 0) == children[i]) { - if (verbose) - fprintf(stderr, "%ld finished with %d\n", - (long) children[i], existat); - if (existat) - kret = KRB5KRB_ERR_GENERIC; - } - else - fprintf(stderr, "Wait for %ld failed\n", (long) children[i]); - } - } - - free_principals(kcontext, passes); - if (db_open) - (void) krb5_db_fini(kcontext); - if (db_created) { - if (!kret && !save_db) { - krb5_db_destroy(kcontext, db); - krb5_db_fini(kcontext); - } else { - if (kret && verbose) - fprintf(stderr, "%s: database not deleted because of error\n", - programname); - } - } - - krb5_free_keyblock_contents(kcontext, &master_keyblock); - krb5_free_context(kcontext); - - return((kret) ? 1 : 0); -} - -/* - * usage: - * t_kdb [-t] - Get timing information. - * [-r] - Generate random cases. - * [-n <num>] - Use <num> as the number of passes. - * [-c] - Check contents. - * [-v] - Verbose output. - * [-d <dbname>] - Database name. - * [-s] - Save database even on successful completion. - * [-D] - Leave database dirty. - */ -int -main(argc, argv) - int argc; - char *argv[]; -{ - int option; - extern char *optarg; - - int do_time, do_random, num_passes, check_cont, verbose, error; - int save_db, dont_clean, do_ptest, hash; - char *db_name; - - programname = argv[0]; - if (strrchr(programname, (int) '/')) - programname = strrchr(programname, (int) '/') + 1; - SRAND((RAND_TYPE)time((void *) NULL)); - - /* Default values. */ - do_time = 0; - do_random = 0; - num_passes = T_KDB_N_PASSES; - check_cont = 0; - verbose = 0; - db_name = T_KDB_DEF_DB; - save_db = 0; - dont_clean = 0; - error = 0; - do_ptest = 0; - hash = 0; - - /* Parse argument list */ - while ((option = getopt(argc, argv, "cd:n:prstvDh")) != -1) { - switch (option) { - case 'c': - check_cont = 1; - break; - case 'd': - db_name = optarg; - break; - case 'n': - if (sscanf(optarg, "%d", &num_passes) != 1) { - fprintf(stderr, "%s: %s is not a valid number for %c option\n", - programname, optarg, option); - error++; - } - break; - case 'p': - do_ptest++; - break; - case 'r': - do_random = 1; - break; - case 's': - save_db = 1; - break; - case 't': - do_time = 1; - break; - case 'v': - verbose++; - break; - case 'D': - dont_clean = 1; - break; - case 'h': - hash = 1; - break; - default: - error++; - break; - } - } - if (error) - fprintf(stderr, "%s: usage is %s [-cprstv] [-d <dbname>] [-n <num>]\n", - programname, programname); - else - error = do_testing(db_name, - num_passes, - verbose, - do_time, - do_random, - check_cont, - save_db, - dont_clean, - do_ptest, - hash); - return(error); -} - - diff --git a/src/lib/kdb/t_krb5.conf b/src/lib/kdb/t_krb5.conf deleted file mode 100644 index 5882d97..0000000 --- a/src/lib/kdb/t_krb5.conf +++ /dev/null @@ -1,29 +0,0 @@ -[libdefaults] - ticket_lifetime = 600 - default_realm = ATHENA.MIT.EDU - -[realms] - ATHENA.MIT.EDU = { - kdc = KERBEROS-2.MIT.EDU:88 - kdc = KERBEROS.MIT.EDU - kdc = KERBEROS-1.MIT.EDU - admin_server = KERBEROS.MIT.EDU - default_domain = MIT.EDU - v4_instance_convert = { - mit = mit.edu - lithium = lithium.lcs.mit.edu - } - } - CYGNUS.COM = { - kdc = KERBEROS-1.CYGNUS.COM - kdc = KERBEROS.CYGNUS.COM - admin_server = KERBEROS.MIT.EDU - } - -[domain_realm] - .mit.edu = ATHENA.MIT.EDU - mit.edu = ATHENA.MIT.EDU - .media.mit.edu = MEDIA-LAB.MIT.EDU - media.mit.edu = MEDIA-LAB.MIT.EDU - .ucsc.edu = CATS.UCSC.EDU - diff --git a/src/lib/kdb/verify_mky.c b/src/lib/kdb/verify_mky.c deleted file mode 100644 index 452dc45..0000000 --- a/src/lib/kdb/verify_mky.c +++ /dev/null @@ -1,81 +0,0 @@ -/* - * lib/kdb/verify_mky.c - * - * Copyright 1990,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. 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. - * - * - * krb5_db_verify_master_key(); - */ - -#include "k5-int.h" - -/* - * Verify that the master key in *mkey matches the database entry - * for mprinc. - */ - -krb5_error_code -krb5_db_verify_master_key(context, mprinc, mkey) - krb5_context context; - krb5_principal mprinc; - krb5_keyblock *mkey; -{ - krb5_error_code retval; - krb5_db_entry master_entry; - int nprinc; - krb5_boolean more; - krb5_keyblock tempkey; - - nprinc = 1; - if ((retval = krb5_db_get_principal(context, mprinc, - &master_entry, &nprinc, &more))) - return(retval); - - if (nprinc != 1) { - if (nprinc) - krb5_db_free_principal(context, &master_entry, nprinc); - return(KRB5_KDB_NOMASTERKEY); - } else if (more) { - krb5_db_free_principal(context, &master_entry, nprinc); - return(KRB5KDC_ERR_PRINCIPAL_NOT_UNIQUE); - } - - if ((retval = krb5_dbekd_decrypt_key_data(context, mkey, - &master_entry.key_data[0], - &tempkey, NULL))) { - krb5_db_free_principal(context, &master_entry, nprinc); - return retval; - } - - if (mkey->length != tempkey.length || - memcmp((char *)mkey->contents, - (char *)tempkey.contents,mkey->length)) { - retval = KRB5_KDB_BADMASTERKEY; - } - - memset((char *)tempkey.contents, 0, tempkey.length); - krb5_xfree(tempkey.contents); - krb5_db_free_principal(context, &master_entry, nprinc); - - return retval; -} diff --git a/src/lib/krb4/ChangeLog b/src/lib/krb4/ChangeLog index 63ef3ec..b9258c7 100644 --- a/src/lib/krb4/ChangeLog +++ b/src/lib/krb4/ChangeLog @@ -1,3 +1,8 @@ +2004-12-08 Ken Raeburn <raeburn@mit.edu> + + * RealmsConfig-glue.c (krb_get_krbhst): Check if DNS should be + used for getting KDC names before actually using it. + 2004-07-16 Ken Raeburn <raeburn@mit.edu> * macsock.c: Deleted. diff --git a/src/lib/krb4/RealmsConfig-glue.c b/src/lib/krb4/RealmsConfig-glue.c index 0635284..dbdfe54 100644 --- a/src/lib/krb4/RealmsConfig-glue.c +++ b/src/lib/krb4/RealmsConfig-glue.c @@ -536,21 +536,24 @@ krb_get_krbhst( if (err) break; - realmdat.data = realm; - realmdat.length = strlen(realm); - err = k5.make_srv_query_realm(&realmdat, "_kerberos-iv", "_udp", &srv); - if (err) - break; + if (k5.use_dns_kdc(krb5__krb4_context)) { + realmdat.data = realm; + realmdat.length = strlen(realm); + err = k5.make_srv_query_realm(&realmdat, "_kerberos-iv", "_udp", + &srv); + if (err) + break; - if (srv == 0) - break; + if (srv == 0) + break; - if (dnscache.srv) - k5.free_srv_dns_data(dnscache.srv); - dnscache.srv = srv; - strncpy(dnscache.realm, realm, REALM_SZ); - dnscache.when = now; - goto get_from_dnscache; + if (dnscache.srv) + k5.free_srv_dns_data(dnscache.srv); + dnscache.srv = srv; + strncpy(dnscache.realm, realm, REALM_SZ); + dnscache.when = now; + goto get_from_dnscache; + } } while (0); #endif return KFAILURE; diff --git a/src/lib/krb5.saber.source b/src/lib/krb5.saber.source deleted file mode 100644 index a4c374a..0000000 --- a/src/lib/krb5.saber.source +++ /dev/null @@ -1,18 +0,0 @@ -setopt load_flags -I/usr/athena/include -I/u2/krb5/include -I/mit/krb5/src/include -DNARROW_PROTOTYPES -load /mit/krb5/src/lib/cryptoconf.c /mit/krb5/src/lib/syslog.c /mit/krb5/src/lib/strdup.c - -load /mit/krb5/src/lib/krb/addr_comp.c /mit/krb5/src/lib/krb/addr_order.c /mit/krb5/src/lib/krb/addr_srch.c /u2/krb5/lib/krb/bld_pr_ext.o /u2/krb5/lib/krb/bld_princ.o /mit/krb5/src/lib/krb/conv_princ.c /mit/krb5/src/lib/krb/copy_addrs.c /mit/krb5/src/lib/krb/copy_auth.c /mit/krb5/src/lib/krb/copy_athctr.c /mit/krb5/src/lib/krb/copy_checksum.c /mit/krb5/src/lib/krb/copy_creds.c /mit/krb5/src/lib/krb/copy_data.c /mit/krb5/src/lib/krb/copy_key.c /mit/krb5/src/lib/krb/copy_princ.c /mit/krb5/src/lib/krb/copy_tick.c /mit/krb5/src/lib/krb/cp_key_cnt.c /mit/krb5/src/lib/krb/decode_kdc.c /mit/krb5/src/lib/krb/decrypt_tk.c /mit/krb5/src/lib/krb/encode_kdc.c /mit/krb5/src/lib/krb/encrypt_tk.c /mit/krb5/src/lib/krb/free_rtree.c /mit/krb5/src/lib/krb/faddr_ordr.c /mit/krb5/src/lib/krb/gc_frm_kdc.c /mit/krb5/src/lib/krb/gc_via_tgt.c /mit/krb5/src/lib/krb/gc_2tgt.c /mit/krb5/src/lib/krb/gen_seqnum.c /mit/krb5/src/lib/krb/gen_subkey.c /mit/krb5/src/lib/krb/get_creds.c /mit/krb5/src/lib/krb/get_in_tkt.c /mit/krb5/src/lib/krb/in_tkt_pwd.c /mit/krb5/src/lib/krb/in_tkt_sky.c /mit/krb5/src/lib/krb/kdc_rep_dc.c /mit/krb5/src/lib/krb/krbconfig.c /mit/krb5/src/lib/krb/mk_error.c /mit/krb5/src/lib/krb/mk_priv.c /mit/krb5/src/lib/krb/mk_rep.c /mit/krb5/src/lib/krb/mk_req.c /mit/krb5/src/lib/krb/mk_req_ext.c /mit/krb5/src/lib/krb/mk_safe.c /mit/krb5/src/lib/krb/parse.c /mit/krb5/src/lib/krb/pr_to_salt.c /mit/krb5/src/lib/krb/princ_comp.c /mit/krb5/src/lib/krb/rd_error.c /mit/krb5/src/lib/krb/rd_priv.c /mit/krb5/src/lib/krb/rd_rep.c /mit/krb5/src/lib/krb/rd_req.c /mit/krb5/src/lib/krb/rd_req_sim.c /mit/krb5/src/lib/krb/rd_req_dec.c /mit/krb5/src/lib/krb/rd_safe.c /mit/krb5/src/lib/krb/recvauth.c /mit/krb5/src/lib/krb/sendauth.c /mit/krb5/src/lib/krb/send_tgs.c /mit/krb5/src/lib/krb/srv_rcache.c /mit/krb5/src/lib/krb/tgtname.c /mit/krb5/src/lib/krb/unparse.c /mit/krb5/src/lib/krb/walk_rtree.c - -load -DPEPSY_LINKABLE_FUNCS -I/usr/athena/include -I/u2/krb5/include -I/mit/krb5/src/include -DNARROW_PROTOTYPES /u2/krb5/src/lib/asn.1/KRB5_tables.c /mit/krb5/src/lib/asn.1/encode.c /mit/krb5/src/lib/asn.1/decode.c /mit/krb5/src/lib/asn.1/adat2kadat.c /mit/krb5/src/lib/asn.1/addr2kaddr.c /mit/krb5/src/lib/asn.1/adr2kadr.c /mit/krb5/src/lib/asn.1/aprp2kaprp.c /mit/krb5/src/lib/asn.1/aprq2kaprq.c /mit/krb5/src/lib/asn.1/arep2karep.c /mit/krb5/src/lib/asn.1/auth2kauth.c /mit/krb5/src/lib/asn.1/cvt_flags.c /mit/krb5/src/lib/asn.1/ck2kck.c /mit/krb5/src/lib/asn.1/edat2kedat.c /mit/krb5/src/lib/asn.1/ekrp2kekrp.c /mit/krb5/src/lib/asn.1/enck2kkey.c /mit/krb5/src/lib/asn.1/err2kerr.c /mit/krb5/src/lib/asn.1/etpt2ketpt.c /mit/krb5/src/lib/asn.1/g2unix.c /mit/krb5/src/lib/asn.1/kadat2adat.c /mit/krb5/src/lib/asn.1/kaddr2addr.c /mit/krb5/src/lib/asn.1/kadr2adr.c /mit/krb5/src/lib/asn.1/kaprp2aprp.c /mit/krb5/src/lib/asn.1/kaprq2aprq.c /mit/krb5/src/lib/asn.1/karep2arep.c /mit/krb5/src/lib/asn.1/kauth2auth.c /mit/krb5/src/lib/asn.1/kck2ck.c /mit/krb5/src/lib/asn.1/kdcr2kkdcr.c /mit/krb5/src/lib/asn.1/kdcr2ktgsr.c /mit/krb5/src/lib/asn.1/kedat2edat.c /mit/krb5/src/lib/asn.1/kekrp2ekrp.c /mit/krb5/src/lib/asn.1/kerr2err.c /mit/krb5/src/lib/asn.1/ketpt2etpt.c /mit/krb5/src/lib/asn.1/kkdcr2kdcr.c /mit/krb5/src/lib/asn.1/kkey2enck.c /mit/krb5/src/lib/asn.1/klsrq2lsrq.c /mit/krb5/src/lib/asn.1/kprep2prep.c /mit/krb5/src/lib/asn.1/kprin2prin.c /mit/krb5/src/lib/asn.1/kpriv2priv.c /mit/krb5/src/lib/asn.1/ksafe2safe.c /mit/krb5/src/lib/asn.1/ktran2tran.c /mit/krb5/src/lib/asn.1/ktgrq2tgrq.c /mit/krb5/src/lib/asn.1/ktgsr2kdcr.c /mit/krb5/src/lib/asn.1/ktkt2tkt.c /mit/krb5/src/lib/asn.1/lsrq2klsrq.c /mit/krb5/src/lib/asn.1/prep2kprep.c /mit/krb5/src/lib/asn.1/prin2kprin.c /mit/krb5/src/lib/asn.1/priv2kpriv.c /mit/krb5/src/lib/asn.1/qbuf2data.c /mit/krb5/src/lib/asn.1/safe2ksafe.c /mit/krb5/src/lib/asn.1/tran2ktran.c /mit/krb5/src/lib/asn.1/tgrq2ktgrq.c /mit/krb5/src/lib/asn.1/tkt2ktkt.c /mit/krb5/src/lib/asn.1/u2gen.c /mit/krb5/src/lib/asn.1/kasrp2kdcr.c /mit/krb5/src/lib/asn.1/kpwd2pwd.c /mit/krb5/src/lib/asn.1/kpwds2pwds.c /mit/krb5/src/lib/asn.1/pwd2kpwd.c /mit/krb5/src/lib/asn.1/pwds2kpwds.c - -load /mit/krb5/src/lib/free/f_addr.c /mit/krb5/src/lib/free/f_address.c /mit/krb5/src/lib/free/f_arep_enc.c /mit/krb5/src/lib/free/f_ap_rep.c /mit/krb5/src/lib/free/f_ap_req.c /mit/krb5/src/lib/free/f_authdata.c /mit/krb5/src/lib/free/f_authent.c /mit/krb5/src/lib/free/f_cksum.c /mit/krb5/src/lib/free/f_creds.c /mit/krb5/src/lib/free/f_cred_cnt.c /mit/krb5/src/lib/free/f_enc_kdc.c /mit/krb5/src/lib/free/f_enc_tkt.c /mit/krb5/src/lib/free/f_error.c /mit/krb5/src/lib/free/f_kdc_rep.c /mit/krb5/src/lib/free/f_kdc_req.c /mit/krb5/src/lib/free/f_keyblock.c /mit/krb5/src/lib/free/f_last_req.c /mit/krb5/src/lib/free/f_padata.c /mit/krb5/src/lib/free/f_princ.c /mit/krb5/src/lib/free/f_priv.c /mit/krb5/src/lib/free/f_priv_enc.c /mit/krb5/src/lib/free/f_safe.c /mit/krb5/src/lib/free/f_ticket.c /mit/krb5/src/lib/free/f_tickets.c /mit/krb5/src/lib/free/f_tgt_cred.c /mit/krb5/src/lib/free/f_tkt_auth.c - -load /mit/krb5/src/lib/keytab/ktadd.c /mit/krb5/src/lib/keytab/ktbase.c /mit/krb5/src/lib/keytab/ktdefault.c /mit/krb5/src/lib/keytab/ktfr_entry.c /mit/krb5/src/lib/keytab/ktremove.c /mit/krb5/src/lib/keytab/read_servi.c - -load /mit/krb5/src/lib/keytab/file/ktf_add.c /mit/krb5/src/lib/keytab/file/ktf_endget.c /mit/krb5/src/lib/keytab/file/ktf_next.c /mit/krb5/src/lib/keytab/file/ktf_resolv.c /mit/krb5/src/lib/keytab/file/ktf_wops.c /mit/krb5/src/lib/keytab/file/ktf_close.c /mit/krb5/src/lib/keytab/file/ktf_get_en.c /mit/krb5/src/lib/keytab/file/ktf_ops.c /mit/krb5/src/lib/keytab/file/ktf_ssget.c /mit/krb5/src/lib/keytab/file/ktf_wreslv.c /mit/krb5/src/lib/keytab/file/ktf_defops.c /mit/krb5/src/lib/keytab/file/ktf_get_na.c /mit/krb5/src/lib/keytab/file/ktf_remove.c /mit/krb5/src/lib/keytab/file/ktf_util.c - -load /mit/krb5/src/lib/ccache/ccbase.c /mit/krb5/src/lib/ccache/ccdefault.c /mit/krb5/src/lib/ccache/ccdefops.c - -load /mit/krb5/src/lib/ccache/file/fcc_close.c /mit/krb5/src/lib/ccache/file/fcc_destry.c /mit/krb5/src/lib/ccache/file/fcc_eseq.c /mit/krb5/src/lib/ccache/file/fcc_gennew.c /mit/krb5/src/lib/ccache/file/fcc_getnam.c /mit/krb5/src/lib/ccache/file/fcc_gprin.c /mit/krb5/src/lib/ccache/file/fcc_init.c /mit/krb5/src/lib/ccache/file/fcc_nseq.c /mit/krb5/src/lib/ccache/file/fcc_read.c /mit/krb5/src/lib/ccache/file/fcc_reslv.c /mit/krb5/src/lib/ccache/file/fcc_retrv.c /mit/krb5/src/lib/ccache/file/fcc_sseq.c /mit/krb5/src/lib/ccache/file/fcc_store.c /mit/krb5/src/lib/ccache/file/fcc_skip.c /mit/krb5/src/lib/ccache/file/fcc_ops.c /mit/krb5/src/lib/ccache/file/fcc_write.c /mit/krb5/src/lib/ccache/file/fcc_sflags.c /mit/krb5/src/lib/ccache/file/fcc_defops.c /mit/krb5/src/lib/ccache/file/fcc_errs.c /mit/krb5/src/lib/ccache/file/fcc_maybe.c - -load -I. -I/usr/athena/include -I/u2/krb5/include -I/mit/krb5/src/include -DNARROW_PROTOTYPES /mit/krb5/src/lib/rcache/rc_base.c /mit/krb5/src/lib/rcache/rc_dfl.c /mit/krb5/src/lib/rcache/rc_io.c /mit/krb5/src/lib/rcache/rcdef.c /mit/krb5/src/lib/rcache/rc_conv.c diff --git a/src/lib/krb5/ChangeLog b/src/lib/krb5/ChangeLog index 050d9da..e1fc665 100644 --- a/src/lib/krb5/ChangeLog +++ b/src/lib/krb5/ChangeLog @@ -1,3 +1,15 @@ +2005-02-08 Ken Raeburn <raeburn@mit.edu> + + * Makefile.in (LIBINITFUNC, LIBFINIFUNC): Define. + +2005-01-17 Jeffrey Altman <jaltman@mit.edu> + + * krb5_libinit.c: implement library cleanup of mutexes, static vars, etc + +2005-01-04 Jeffrey Altman <jaltman@mit.edu> + + * libkrb5.exports: add krb5_is_thread_safe + 2004-08-08 Ken Raeburn <raeburn@mit.edu> * libkrb5.exports: Remove memory ccache symbols except ops table. diff --git a/src/lib/krb5/Makefile.in b/src/lib/krb5/Makefile.in index 736caf8..737e2a4 100644 --- a/src/lib/krb5/Makefile.in +++ b/src/lib/krb5/Makefile.in @@ -20,6 +20,8 @@ STLIBOBJS=krb5_libinit.o LIBBASE=krb5 LIBMAJOR=3 LIBMINOR=2 +LIBINITFUNC=profile_library_initializer krb5int_lib_init +LIBFINIFUNC=profile_library_finalizer krb5int_lib_fini STOBJLISTS= \ OBJS.ST \ diff --git a/src/lib/krb5/asn.1/ChangeLog b/src/lib/krb5/asn.1/ChangeLog index e7ea803..9d9d2bb 100644 --- a/src/lib/krb5/asn.1/ChangeLog +++ b/src/lib/krb5/asn.1/ChangeLog @@ -1,3 +1,13 @@ +2005-03-04 Ken Raeburn <raeburn@mit.edu> + + * asn1_encode.c (asn1_encode_generaltime): If gmtime_r returns int + instead of pointer, do the appropriate error checking. + +2004-12-28 Ezra Peisach <epeisach@mit.edu> + + * asn1_decode.c (asn1_decode_generaltime): Fix memory leak when + time sent is "19700101000000Z". + 2004-08-31 Tom Yu <tlyu@mit.edu> * asn1buf.c: Fix denial-of-service bug. diff --git a/src/lib/krb5/asn.1/asn1_decode.c b/src/lib/krb5/asn.1/asn1_decode.c index 60ae088..d31ce3e 100644 --- a/src/lib/krb5/asn.1/asn1_decode.c +++ b/src/lib/krb5/asn.1/asn1_decode.c @@ -238,6 +238,7 @@ asn1_error_code asn1_decode_generaltime(asn1buf *buf, time_t *val) } if(s[0] == '1' && !memcmp("19700101000000Z", s, 15)) { t = 0; + free(s); goto done; } #define c2i(c) ((c)-'0') diff --git a/src/lib/krb5/asn.1/asn1_encode.c b/src/lib/krb5/asn.1/asn1_encode.c index 4f9e694..c5e3452 100644 --- a/src/lib/krb5/asn.1/asn1_encode.c +++ b/src/lib/krb5/asn.1/asn1_encode.c @@ -242,8 +242,13 @@ asn1_error_code asn1_encode_generaltime(asn1buf *buf, time_t val, * and some bogus implementations might overrun on the sprintf. */ #ifdef HAVE_GMTIME_R +# ifdef GMTIME_R_RETURNS_INT + if (gmtime_r(&gmt_time, >imebuf) != 0) + return ASN1_BAD_GMTIME; +# else if (gmtime_r(&gmt_time, >imebuf) == NULL) return ASN1_BAD_GMTIME; +# endif #else gtime = gmtime(&gmt_time); if (gtime == NULL) diff --git a/src/lib/krb5/ccache/ChangeLog b/src/lib/krb5/ccache/ChangeLog index 757ce38..47e6759 100644 --- a/src/lib/krb5/ccache/ChangeLog +++ b/src/lib/krb5/ccache/ChangeLog @@ -1,3 +1,42 @@ +2005-01-13 Ken Raeburn <raeburn@mit.edu> + + * cc_file.c (struct _krb5_fcc_data): Fields disk_file_lock, + file_is_locked deleted. + (krb5_fcc_open_file, krb5_fcc_close_file, dereference, + krb5_fcc_resolve, krb5_fcc_generate_new, krb5_fcc_set_flags): + Don't set or check them. + +2005-01-11 Jeffrey Altman <jaltman@mit.edu> + + * cc_mslsa.c: + - do not free krb5_creds if krb5_copy_creds fails + - cause MSTicketToMITTicket to return failure if + krb5_copy_data fails + +2004-12-25 Ezra Peisach <epeisach@mit.edu> + + * cc_file.c (krb5_fcc_close): Free the cache id. + (dereference): When removing fcc_set entry from list, free the + pointer as well. + +2004-12-16 Jeffrey Altman <jaltman@mit.edu> + * cc_mslsa.c: + Temporarily deactivate support for KerbSubmitTicketMessage + and KerbQueryTicketCacheEx2Message until the new Platform SDK + becomes publicly available. + +2004-12-15 Jeffrey Altman <jaltman@mit.edu> + + * cc_mslsa.c: + - Activate support for KerbSubmitTicketMessage + - Activate support for KerbQueryTicketCacheEx2Message + - Add locale support for regions which use MultiByte characters + +2004-11-19 Ken Raeburn <raeburn@mit.edu> + + * cc_mslsa.c (MSCredToMITCred): Don't create an empty array for + addresses, just use a null pointer now. + 2004-10-07 Jeffrey Altman <jaltman@mit.edu> * cc_mslsa.c: Fix the forced setting of the Initial Ticket Flag on Win2000 and add it to XP and 2003 SP1 diff --git a/src/lib/krb5/ccache/cc_file.c b/src/lib/krb5/ccache/cc_file.c index f247c42..0529e4b 100644 --- a/src/lib/krb5/ccache/cc_file.c +++ b/src/lib/krb5/ccache/cc_file.c @@ -264,10 +264,6 @@ typedef struct _krb5_fcc_data { that can be changed. (Filename is fixed after initialization.) */ k5_mutex_t lock; - /* Grab this one before trying to get an advisory lock on the disk - file, since the facility is per-process, not per-thread. */ - k5_mutex_t disk_file_lock; - int file_is_locked; int file; krb5_flags flags; int mode; /* needed for locking code */ @@ -1172,9 +1168,7 @@ krb5_fcc_close_file (krb5_context context, krb5_fcc_data *data) return KRB5_FCC_INTERNAL; retval = krb5_unlock_file(context, data->file); - k5_mutex_unlock(&data->disk_file_lock); ret = close (data->file); - data->file_is_locked = 0; data->file = NO_FILE; if (retval) return retval; @@ -1212,11 +1206,7 @@ krb5_fcc_open_file (krb5_context context, krb5_ccache id, int mode) if (data->file != NO_FILE) { /* Don't know what state it's in; shut down and start anew. */ - if (data->file_is_locked) { - (void) krb5_unlock_file(context, data->file); - k5_mutex_unlock(&data->disk_file_lock); - data->file_is_locked = 0; - } + (void) krb5_unlock_file(context, data->file); (void) close (data->file); data->file = NO_FILE; } @@ -1245,17 +1235,10 @@ krb5_fcc_open_file (krb5_context context, krb5_ccache id, int mode) lock_flag = KRB5_LOCKMODE_SHARED; else lock_flag = KRB5_LOCKMODE_EXCLUSIVE; - retval = k5_mutex_lock(&data->disk_file_lock); - if (retval) { - close(f); - return retval; - } if ((retval = krb5_lock_file(context, f, lock_flag))) { - k5_mutex_unlock(&data->disk_file_lock); (void) close(f); return retval; } - data->file_is_locked = 1; if (mode == FCC_OPEN_AND_ERASE) { /* write the version number */ @@ -1378,8 +1361,6 @@ done: if (retval) { data->file = -1; (void) krb5_unlock_file(context, f); - (void) k5_mutex_unlock(&data->disk_file_lock); - data->file_is_locked = 0; (void) close(f); } return retval; @@ -1486,9 +1467,13 @@ static krb5_error_code dereference(krb5_context context, krb5_fcc_data *data) assert(*fccsp != NULL); (*fccsp)->refcount--; if ((*fccsp)->refcount == 0) { + struct fcc_set *temp; data = (*fccsp)->data; + temp = *fccsp; *fccsp = (*fccsp)->next; + free(temp); k5_mutex_unlock(&krb5int_cc_file_mutex); + k5_mutex_assert_unlocked(&data->lock); free(data->filename); zap(data->buf, sizeof(data->buf)); if (data->file >= 0) { @@ -1496,9 +1481,7 @@ static krb5_error_code dereference(krb5_context context, krb5_fcc_data *data) krb5_fcc_close_file(context, data); k5_mutex_unlock(&data->lock); } - k5_mutex_assert_unlocked(&data->lock); k5_mutex_destroy(&data->lock); - k5_mutex_destroy(&data->disk_file_lock); free(data); } else k5_mutex_unlock(&krb5int_cc_file_mutex); @@ -1517,6 +1500,7 @@ static krb5_error_code KRB5_CALLCONV krb5_fcc_close(krb5_context context, krb5_ccache id) { dereference(context, (krb5_fcc_data *) id->data); + krb5_xfree(id); return KRB5_OK; } @@ -1730,25 +1714,14 @@ krb5_fcc_resolve (krb5_context context, krb5_ccache *id, const char *residual) free(data); return kret; } - kret = k5_mutex_init(&data->disk_file_lock); - if (kret) { - k5_mutex_unlock(&krb5int_cc_file_mutex); - k5_mutex_unlock(&data->lock); - k5_mutex_destroy(&data->lock); - free(data->filename); - free(data); - return kret; - } /* data->version,mode filled in for real later */ data->version = data->mode = 0; - data->file_is_locked = 0; data->flags = KRB5_TC_OPENCLOSE; data->file = -1; data->valid_bytes = 0; setptr = malloc(sizeof(struct fcc_set)); if (setptr == NULL) { k5_mutex_unlock(&krb5int_cc_file_mutex); - k5_mutex_destroy(&data->disk_file_lock); k5_mutex_destroy(&data->lock); free(data->filename); free(data); @@ -2010,12 +1983,6 @@ krb5_fcc_generate_new (krb5_context context, krb5_ccache *id) retcode = k5_mutex_init(&data->lock); if (retcode) goto err_out; - retcode = k5_mutex_init(&data->disk_file_lock); - if (retcode) { - k5_mutex_destroy(&data->lock); - goto err_out; - } - data->file_is_locked = 0; /* Set up the filename */ strcpy(((krb5_fcc_data *) lid->data)->filename, scratch); @@ -2233,7 +2200,9 @@ krb5_fcc_set_flags(krb5_context context, krb5_ccache id, krb5_flags flags) /* XXX This should check for illegal combinations, if any.. */ if (flags & KRB5_TC_OPENCLOSE) { /* asking to turn on OPENCLOSE mode */ - if (!OPENCLOSE(id)) + if (!OPENCLOSE(id) + /* XXX Is this test necessary? */ + && ((krb5_fcc_data *) id->data)->file != NO_FILE) (void) krb5_fcc_close_file (context, ((krb5_fcc_data *) id->data)); } else { /* asking to turn off OPENCLOSE mode, meaning it must be diff --git a/src/lib/krb5/ccache/cc_mslsa.c b/src/lib/krb5/ccache/cc_mslsa.c index c12f581..fdd3f10 100644 --- a/src/lib/krb5/ccache/cc_mslsa.c +++ b/src/lib/krb5/ccache/cc_mslsa.c @@ -44,7 +44,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * Implementation of microsoft windows lsa credentials cache + * Implementation of microsoft windows lsa read-only credentials cache */ #ifdef _WIN32 @@ -69,11 +69,11 @@ #define MAX_MSPRINC_SIZE 1024 /* THREAD SAFETY - * The functions is_windows_2000(), is_windows_xp(), - * does_retrieve_ticket_cache_ticket() and does_query_ticket_cache_ex2() - * contain static variables to cache the responses of the tests being - * performed. There is no harm in the test being performed more than - * once since the result will always be the same. + * The functions is_windows_2000(), is_windows_xp(), and + * does_retrieve_ticket_cache_ticket() contain static variables to cache + * the responses of the tests being performed. There is no harm in the + * test being performed more than once since the result will always be the + * same. */ static BOOL @@ -189,9 +189,18 @@ UnicodeToANSI(LPTSTR lpInputString, LPSTR lpszOutputString, int nOutStringLen) GetCPInfo(CP_ACP, &CodePageInfo); - if (CodePageInfo.MaxCharSize > 1) + if (CodePageInfo.MaxCharSize > 1) { // Only supporting non-Unicode strings - return FALSE; + int reqLen = WideCharToMultiByte(CP_ACP, 0, (LPCWSTR) lpInputString, -1, + NULL, 0, NULL, NULL); + if ( reqLen > nOutStringLen) + { + return FALSE; + } else { + WideCharToMultiByte(CP_ACP, 0, (LPCWSTR) lpInputString, -1, + lpszOutputString, nOutStringLen, NULL, NULL); + } + } else if (((LPBYTE) lpInputString)[1] == '\0') { // Looks like unicode, better translate it @@ -200,12 +209,13 @@ UnicodeToANSI(LPTSTR lpInputString, LPSTR lpszOutputString, int nOutStringLen) } else lstrcpyA(lpszOutputString, (LPSTR) lpInputString); + return TRUE; } // UnicodeToANSI static VOID WINAPI -ANSIToUnicode(LPSTR lpInputString, LPTSTR lpszOutputString, int nOutStringLen) +ANSIToUnicode(LPSTR lpInputString, LPTSTR lpszOutputString, int nOutStringLen) { CPINFO CodePageInfo; @@ -214,12 +224,9 @@ ANSIToUnicode(LPSTR lpInputString, LPTSTR lpszOutputString, int nOutStringLen) GetCPInfo(CP_ACP, &CodePageInfo); - if (CodePageInfo.MaxCharSize > 1) - // It must already be a Unicode string - return; - else if (((LPBYTE) lpInputString)[1] != '\0') + if (CodePageInfo.MaxCharSize > 1 || ((LPBYTE) lpInputString)[1] != '\0') { - // Looks like ANSI, better translate it + // Looks like ANSI or MultiByte, better translate it MultiByteToWideChar(CP_ACP, 0, (LPCSTR) lpInputString, -1, (LPWSTR) lpszOutputString, nOutStringLen); } @@ -243,9 +250,9 @@ MITPrincToMSPrinc(krb5_context context, krb5_principal principal, UNICODE_STRING } } -static void +static BOOL UnicodeStringToMITPrinc(UNICODE_STRING *service, WCHAR *realm, krb5_context context, - krb5_principal *principal) + krb5_principal *principal) { WCHAR princbuf[512]; char aname[512]; @@ -255,14 +262,17 @@ UnicodeStringToMITPrinc(UNICODE_STRING *service, WCHAR *realm, krb5_context cont princbuf[service->Length/sizeof(WCHAR)]=0; wcscat(princbuf, L"@"); wcscat(princbuf, realm); - UnicodeToANSI(princbuf, aname, sizeof(aname)); - krb5_parse_name(context, aname, principal); + if (UnicodeToANSI(princbuf, aname, sizeof(aname))) { + krb5_parse_name(context, aname, principal); + return TRUE; + } + return FALSE; } -static void +static BOOL KerbExternalNameToMITPrinc(KERB_EXTERNAL_NAME *msprinc, WCHAR *realm, krb5_context context, - krb5_principal *principal) + krb5_principal *principal) { WCHAR princbuf[512],tmpbuf[128]; char aname[512]; @@ -278,8 +288,11 @@ KerbExternalNameToMITPrinc(KERB_EXTERNAL_NAME *msprinc, WCHAR *realm, krb5_conte } wcscat(princbuf, L"@"); wcscat(princbuf, realm); - UnicodeToANSI(princbuf, aname, sizeof(aname)); - krb5_parse_name(context, aname, principal); + if (UnicodeToANSI(princbuf, aname, sizeof(aname))) { + krb5_parse_name(context, aname, principal); + return TRUE; + } + return FALSE; } static time_t @@ -320,18 +333,25 @@ MSFlagsToMITFlags(ULONG msflags, ULONG *mitflags) *mitflags=msflags; } -static void +static BOOL MSTicketToMITTicket(KERB_EXTERNAL_TICKET *msticket, krb5_context context, krb5_data *ticket) { - krb5_data tmpdata, *newdata; + krb5_data tmpdata, *newdata = 0; + krb5_error_code rc; + tmpdata.magic=KV5M_DATA; tmpdata.length=msticket->EncodedTicketSize; tmpdata.data=msticket->EncodedTicket; // this is ugly and will break krb5_free_data() // now that this is being done within the library it won't break krb5_free_data() - krb5_copy_data(context, &tmpdata, &newdata); + rc = krb5_copy_data(context, &tmpdata, &newdata); + if (rc) + return FALSE; + memcpy(ticket, newdata, sizeof(krb5_data)); + krb5_xfree(newdata); + return TRUE; } /* @@ -376,7 +396,7 @@ PreserveInitialTicketIdentity(void) } -static void +static BOOL MSCredToMITCred(KERB_EXTERNAL_TICKET *msticket, UNICODE_STRING ClientRealm, krb5_context context, krb5_creds *creds) { @@ -387,65 +407,25 @@ MSCredToMITCred(KERB_EXTERNAL_TICKET *msticket, UNICODE_STRING ClientRealm, // construct Client Principal wcsncpy(wrealm, ClientRealm.Buffer, ClientRealm.Length/sizeof(WCHAR)); wrealm[ClientRealm.Length/sizeof(WCHAR)]=0; - KerbExternalNameToMITPrinc(msticket->ClientName, wrealm, context, &creds->client); + if (!KerbExternalNameToMITPrinc(msticket->ClientName, wrealm, context, &creds->client)) + return FALSE; // construct Service Principal wcsncpy(wrealm, msticket->DomainName.Buffer, msticket->DomainName.Length/sizeof(WCHAR)); wrealm[msticket->DomainName.Length/sizeof(WCHAR)]=0; - KerbExternalNameToMITPrinc(msticket->ServiceName, wrealm, context, &creds->server); + if (!KerbExternalNameToMITPrinc(msticket->ServiceName, wrealm, context, &creds->server)) + return FALSE; MSSessionKeyToMITKeyblock(&msticket->SessionKey, context, &creds->keyblock); MSFlagsToMITFlags(msticket->TicketFlags, &creds->ticket_flags); creds->times.starttime=FileTimeToUnixTime(&msticket->StartTime); creds->times.endtime=FileTimeToUnixTime(&msticket->EndTime); creds->times.renew_till=FileTimeToUnixTime(&msticket->RenewUntil); + creds->addresses = NULL; - /* MS Tickets are addressless. MIT requires an empty address - * not a NULL list of addresses. - */ - creds->addresses = (krb5_address **)malloc(sizeof(krb5_address *)); - memset(creds->addresses, 0, sizeof(krb5_address *)); - - MSTicketToMITTicket(msticket, context, &creds->ticket); -} - -#ifdef HAVE_CACHE_INFO_EX2 -/* CacheInfoEx2ToMITCred is used when we do not need the real ticket */ -static void -CacheInfoEx2ToMITCred(KERB_TICKET_CACHE_INFO_EX2 *info, - krb5_context context, krb5_creds *creds) -{ - WCHAR wrealm[128]; - ZeroMemory(creds, sizeof(krb5_creds)); - creds->magic=KV5M_CREDS; - - // construct Client Principal - wcsncpy(wrealm, info->ClientRealm.Buffer, info->ClientRealm.Length/sizeof(WCHAR)); - wrealm[info->ClientRealm.Length/sizeof(WCHAR)]=0; - UnicodeStringToMITPrinc(&info->ClientName, wrealm, context, &creds->client); - - // construct Service Principal - wcsncpy(wrealm, info->ServerRealm.Buffer, - info->ServerRealm.Length/sizeof(WCHAR)); - wrealm[info->ServerRealm.Length/sizeof(WCHAR)]=0; - UnicodeStringToMITPrinc(&info->ServerName, wrealm, context, &creds->server); - - creds->keyblock.magic = KV5M_KEYBLOCK; - creds->keyblock.enctype = info->SessionKeyType; - creds->ticket_flags = info->TicketFlags; - MSFlagsToMITFlags(info->TicketFlags, &creds->ticket_flags); - creds->times.starttime=FileTimeToUnixTime(&info->StartTime); - creds->times.endtime=FileTimeToUnixTime(&info->EndTime); - creds->times.renew_till=FileTimeToUnixTime(&info->RenewTime); - - /* MS Tickets are addressless. MIT requires an empty address - * not a NULL list of addresses. - */ - creds->addresses = (krb5_address **)malloc(sizeof(krb5_address *)); - memset(creds->addresses, 0, sizeof(krb5_address *)); + return MSTicketToMITTicket(msticket, context, &creds->ticket); } -#endif /* HAVE_CACHE_INFO_EX2 */ static BOOL PackageConnectLookup(HANDLE *pLogonHandle, ULONG *pPackageId) @@ -547,62 +527,6 @@ does_retrieve_ticket_cache_ticket (void) return fCachesTicket; } -#ifdef HAVE_CACHE_INFO_EX2 -static BOOL -does_query_ticket_cache_ex2 (void) -{ - static BOOL fChecked = FALSE; - static BOOL fEx2Response = FALSE; - - if (!fChecked) - { - NTSTATUS Status = 0; - NTSTATUS SubStatus = 0; - HANDLE LogonHandle; - ULONG PackageId; - ULONG RequestSize; - PKERB_QUERY_TKT_CACHE_REQUEST pCacheRequest = NULL; - PKERB_QUERY_TKT_CACHE_EX2_RESPONSE pCacheResponse = NULL; - ULONG ResponseSize; - - RequestSize = sizeof(*pCacheRequest) + 1; - - if (!PackageConnectLookup(&LogonHandle, &PackageId)) - return FALSE; - - pCacheRequest = (PKERB_QUERY_TKT_CACHE_REQUEST) LocalAlloc(LMEM_ZEROINIT, RequestSize); - if (!pCacheRequest) { - CloseHandle(LogonHandle); - return FALSE; - } - - pCacheRequest->MessageType = KerbQueryTicketCacheEx2Message; - pCacheRequest->LogonId.LowPart = 0; - pCacheRequest->LogonId.HighPart = 0; - - Status = LsaCallAuthenticationPackage( LogonHandle, - PackageId, - pCacheRequest, - RequestSize, - &pCacheResponse, - &ResponseSize, - &SubStatus - ); - - LocalFree(pCacheRequest); - CloseHandle(LogonHandle); - - if (!(FAILED(Status) || FAILED(SubStatus))) { - LsaFreeReturnBuffer(pCacheResponse); - fEx2Response = TRUE; - } - fChecked = TRUE; - } - - return fEx2Response; -} -#endif /* HAVE_CACHE_INFO_EX2 */ - static DWORD ConcatenateUnicodeStrings(UNICODE_STRING *pTarget, UNICODE_STRING Source1, UNICODE_STRING Source2) { @@ -942,117 +866,6 @@ PurgeTicketXP( HANDLE LogonHandle, ULONG PackageId, return TRUE; } -#ifdef KERB_SUBMIT_TICKET -static BOOL -KerbSubmitTicket( HANDLE LogonHandle, ULONG PackageId, - krb5_context context, krb5_creds *cred) -{ - NTSTATUS Status = 0; - NTSTATUS SubStatus = 0; - KERB_SUBMIT_TKT_REQUEST * pSubmitRequest; - DWORD dwRequestLen; - krb5_auth_context auth_context; - krb5_keyblock * keyblock = 0; - krb5_replay_data replaydata; - krb5_data * krb_cred = 0; - krb5_error_code rc; - - if (krb5_auth_con_init(context, &auth_context)) { - return FALSE; - } - - if (krb5_auth_con_setflags(context, auth_context, - KRB5_AUTH_CONTEXT_RET_TIME)) { - return FALSE; - } - - krb5_auth_con_getsendsubkey(context, auth_context, &keyblock); - if (keyblock == NULL) - krb5_auth_con_getkey(context, auth_context, &keyblock); -#ifdef TESTING - /* do not use this code unless testing the LSA */ - if (keyblock == NULL) { - keyblock = (krb5_keyblock *)malloc(sizeof(krb5_keyblock)); - keyblock->enctype = ENCTYPE_ARCFOUR_HMAC; - keyblock->length = 16; - keyblock->contents = (krb5_octet *)malloc(16); - keyblock->contents[0] = 0xde; - keyblock->contents[1] = 0xad; - keyblock->contents[2] = 0xbe; - keyblock->contents[3] = 0xef; - keyblock->contents[4] = 0xfe; - keyblock->contents[5] = 0xed; - keyblock->contents[6] = 0xf0; - keyblock->contents[7] = 0xd; - keyblock->contents[8] = 0xde; - keyblock->contents[9] = 0xad; - keyblock->contents[10] = 0xbe; - keyblock->contents[11] = 0xef; - keyblock->contents[12] = 0xfe; - keyblock->contents[13] = 0xed; - keyblock->contents[14] = 0xf0; - keyblock->contents[15] = 0xd; - krb5_auth_con_setsendsubkey(context, auth_context, keyblock); - } -#endif - rc = krb5_mk_1cred(context, auth_context, cred, &krb_cred, &replaydata); - if (rc) { - krb5_auth_con_free(context, auth_context); - if (keyblock) - krb5_free_keyblock(context, keyblock); - if (krb_cred) - krb5_free_data(context, krb_cred); - return FALSE; - } - - dwRequestLen = sizeof(KERB_SUBMIT_TKT_REQUEST) + krb_cred->length + (keyblock ? keyblock->length : 0); - - pSubmitRequest = (PKERB_SUBMIT_TKT_REQUEST)malloc(dwRequestLen); - memset(pSubmitRequest, 0, dwRequestLen); - - pSubmitRequest->MessageType = KerbSubmitTicketMessage; - pSubmitRequest->LogonId.LowPart = 0; - pSubmitRequest->LogonId.HighPart = 0; - pSubmitRequest->Flags = 0; - - if (keyblock) { - pSubmitRequest->Key.KeyType = keyblock->enctype; - pSubmitRequest->Key.Length = keyblock->length; - pSubmitRequest->Key.Offset = sizeof(KERB_SUBMIT_TKT_REQUEST)+krb_cred->length; - } else { - pSubmitRequest->Key.KeyType = ENCTYPE_NULL; - pSubmitRequest->Key.Length = 0; - pSubmitRequest->Key.Offset = 0; - } - pSubmitRequest->KerbCredSize = krb_cred->length; - pSubmitRequest->KerbCredOffset = sizeof(KERB_SUBMIT_TKT_REQUEST); - memcpy(((CHAR *)pSubmitRequest)+sizeof(KERB_SUBMIT_TKT_REQUEST), - krb_cred->data, krb_cred->length); - if (keyblock) - memcpy(((CHAR *)pSubmitRequest)+sizeof(KERB_SUBMIT_TKT_REQUEST)+krb_cred->length, - keyblock->contents, keyblock->length); - krb5_free_data(context, krb_cred); - - Status = LsaCallAuthenticationPackage( LogonHandle, - PackageId, - pSubmitRequest, - dwRequestLen, - NULL, - NULL, - &SubStatus - ); - free(pSubmitRequest); - if (keyblock) - krb5_free_keyblock(context, keyblock); - krb5_auth_con_free(context, auth_context); - - if (FAILED(Status) || FAILED(SubStatus)) { - return FALSE; - } - return TRUE; -} -#endif /* KERB_SUBMIT_TICKET */ - /* * A simple function to determine if there is an exact match between two tickets * We rely on the fact that the external tickets contain the raw Kerberos ticket. @@ -1474,41 +1287,6 @@ GetQueryTktCacheResponseXP( HANDLE LogonHandle, ULONG PackageId, return FALSE; } -#ifdef HAVE_CACHE_INFO_EX2 -static BOOL -GetQueryTktCacheResponseEX2( HANDLE LogonHandle, ULONG PackageId, - PKERB_QUERY_TKT_CACHE_EX2_RESPONSE * ppResponse) -{ - NTSTATUS Status = 0; - NTSTATUS SubStatus = 0; - - KERB_QUERY_TKT_CACHE_REQUEST CacheRequest; - PKERB_QUERY_TKT_CACHE_EX2_RESPONSE pQueryResponse = NULL; - ULONG ResponseSize; - - CacheRequest.MessageType = KerbQueryTicketCacheEx2Message; - CacheRequest.LogonId.LowPart = 0; - CacheRequest.LogonId.HighPart = 0; - - Status = LsaCallAuthenticationPackage( - LogonHandle, - PackageId, - &CacheRequest, - sizeof(CacheRequest), - &pQueryResponse, - &ResponseSize, - &SubStatus - ); - - if ( !(FAILED(Status) || FAILED(SubStatus)) ) { - *ppResponse = pQueryResponse; - return TRUE; - } - - return FALSE; -} -#endif /* HAVE_CACHE_INFO_EX2 */ - static BOOL GetMSCacheTicketFromMITCred( HANDLE LogonHandle, ULONG PackageId, krb5_context context, krb5_creds *creds, @@ -1622,8 +1400,8 @@ GetMSCacheTicketFromCacheInfoW2K( HANDLE LogonHandle, ULONG PackageId, */ if ( tktinfo->TicketFlags & KERB_TICKET_FLAGS_initial ) (*ticket)->TicketFlags |= KERB_TICKET_FLAGS_initial; - return(TRUE); + return(TRUE); } static BOOL @@ -1679,72 +1457,6 @@ GetMSCacheTicketFromCacheInfoXP( HANDLE LogonHandle, ULONG PackageId, /* otherwise return ticket */ *ticket = &(pTicketResponse->Ticket); - - /* set the initial flag if we were attempting to retrieve one - * because Windows won't necessarily return the initial ticket - * to us. - */ - if ( tktinfo->TicketFlags & KERB_TICKET_FLAGS_initial ) - (*ticket)->TicketFlags |= KERB_TICKET_FLAGS_initial; - - return(TRUE); - -} - -#ifdef HAVE_CACHE_INFO_EX2 -static BOOL -GetMSCacheTicketFromCacheInfoEX2( HANDLE LogonHandle, ULONG PackageId, - PKERB_TICKET_CACHE_INFO_EX2 tktinfo, PKERB_EXTERNAL_TICKET *ticket) -{ - NTSTATUS Status = 0; - NTSTATUS SubStatus = 0; - ULONG RequestSize; - PKERB_RETRIEVE_TKT_REQUEST pTicketRequest = NULL; - PKERB_RETRIEVE_TKT_RESPONSE pTicketResponse = NULL; - ULONG ResponseSize; - - RequestSize = sizeof(*pTicketRequest) + tktinfo->ServerName.Length; - - pTicketRequest = (PKERB_RETRIEVE_TKT_REQUEST) LocalAlloc(LMEM_ZEROINIT, RequestSize); - if (!pTicketRequest) - return FALSE; - - pTicketRequest->MessageType = KerbRetrieveEncodedTicketMessage; - pTicketRequest->LogonId.LowPart = 0; - pTicketRequest->LogonId.HighPart = 0; - pTicketRequest->TargetName.Length = tktinfo->ServerName.Length; - pTicketRequest->TargetName.MaximumLength = tktinfo->ServerName.Length; - pTicketRequest->TargetName.Buffer = (PWSTR) (pTicketRequest + 1); - memcpy(pTicketRequest->TargetName.Buffer,tktinfo->ServerName.Buffer, tktinfo->ServerName.Length); - pTicketRequest->CacheOptions = KERB_RETRIEVE_TICKET_CACHE_TICKET; - pTicketRequest->EncryptionType = tktinfo->SessionKeyType; - pTicketRequest->TicketFlags = 0; - if ( tktinfo->TicketFlags & KERB_TICKET_FLAGS_forwardable ) - pTicketRequest->TicketFlags |= KDC_OPT_FORWARDABLE; - if ( tktinfo->TicketFlags & KERB_TICKET_FLAGS_forwarded ) - pTicketRequest->TicketFlags |= KDC_OPT_FORWARDED; - if ( tktinfo->TicketFlags & KERB_TICKET_FLAGS_proxiable ) - pTicketRequest->TicketFlags |= KDC_OPT_PROXIABLE; - if ( tktinfo->TicketFlags & KERB_TICKET_FLAGS_renewable ) - pTicketRequest->TicketFlags |= KDC_OPT_RENEWABLE; - - Status = LsaCallAuthenticationPackage( - LogonHandle, - PackageId, - pTicketRequest, - RequestSize, - &pTicketResponse, - &ResponseSize, - &SubStatus - ); - - LocalFree(pTicketRequest); - - if (FAILED(Status) || FAILED(SubStatus)) - return(FALSE); - - /* otherwise return ticket */ - *ticket = &(pTicketResponse->Ticket); /* set the initial flag if we were attempting to retrieve one * because Windows won't necessarily return the initial ticket @@ -1755,7 +1467,6 @@ GetMSCacheTicketFromCacheInfoEX2( HANDLE LogonHandle, ULONG PackageId, return(TRUE); } -#endif /* HAVE_CACHE_INFO_EX2 */ static krb5_error_code KRB5_CALLCONV krb5_lcc_close (krb5_context, krb5_ccache id); @@ -1819,9 +1530,6 @@ typedef struct _krb5_lcc_cursor { union { PKERB_QUERY_TKT_CACHE_RESPONSE w2k; PKERB_QUERY_TKT_CACHE_EX_RESPONSE xp; -#ifdef HAVE_CACHE_INFO_EX2 - PKERB_QUERY_TKT_CACHE_EX2_RESPONSE ex2; -#endif /* HAVE_CACHE_INFO_EX2 */ } response; unsigned int index; PKERB_EXTERNAL_TICKET mstgt; @@ -1856,22 +1564,11 @@ krb5_lcc_resolve (krb5_context context, krb5_ccache *id, const char *residual) HANDLE LogonHandle; ULONG PackageId; KERB_EXTERNAL_TICKET *msticket; + krb5_error_code retval = KRB5_OK; if (!is_windows_2000()) return KRB5_FCC_NOFILE; -#ifdef COMMENT - /* In at least one case on Win2003 it appears that it is possible - * for the logon session to be authenticated via NTLM and yet for - * there to be Kerberos credentials obtained by the LSA on behalf - * of the logged in user. Therefore, we are removing this test - * which was meant to avoid the need to perform GetMSTGT() when - * there was no possibility of credentials being found. - */ - if (!IsKerberosLogon()) - return KRB5_FCC_NOFILE; -#endif - if (!PackageConnectLookup(&LogonHandle, &PackageId)) return KRB5_FCC_NOFILE; @@ -1911,10 +1608,12 @@ krb5_lcc_resolve (krb5_context context, krb5_ccache *id, const char *residual) if (GetMSTGT(context, data->LogonHandle, data->PackageId, &msticket, FALSE)) { /* convert the ticket */ krb5_creds creds; - MSCredToMITCred(msticket, msticket->DomainName, context, &creds); + if (!MSCredToMITCred(msticket, msticket->DomainName, context, &creds)) + retval = KRB5_FCC_INTERNAL; LsaFreeReturnBuffer(msticket); - krb5_copy_principal(context, creds.client, &data->princ); + if (retval == KRB5_OK) + krb5_copy_principal(context, creds.client, &data->princ); krb5_free_cred_contents(context,&creds); } else if (!does_retrieve_ticket_cache_ticket()) { krb5_xfree(data->cc_name); @@ -1929,7 +1628,7 @@ krb5_lcc_resolve (krb5_context context, krb5_ccache *id, const char *residual) * if cache is non-existent/unusable */ *id = lid; - return KRB5_OK; + return retval; } /* @@ -2021,8 +1720,8 @@ krb5_lcc_destroy(krb5_context context, krb5_ccache id) if (id) { data = (krb5_lcc_data *) id->data; - return PurgeAllTickets(data->LogonHandle, data->PackageId) ? KRB5_OK : KRB5_FCC_INTERNAL; - } + return PurgeAllTickets(data->LogonHandle, data->PackageId) ? KRB5_OK : KRB5_FCC_INTERNAL; + } return KRB5_FCC_INTERNAL; } @@ -2063,16 +1762,6 @@ krb5_lcc_start_seq_get(krb5_context context, krb5_ccache id, krb5_cc_cursor *cur return KRB5_CC_NOTFOUND; } -#ifdef HAVE_CACHE_INFO_EX2 - if ( does_query_ticket_cache_ex2() ) { - if ( !GetQueryTktCacheResponseEX2(data->LogonHandle, data->PackageId, &lcursor->response.ex2) ) { - LsaFreeReturnBuffer(lcursor->mstgt); - free(lcursor); - *cursor = 0; - return KRB5_FCC_INTERNAL; - } - } else -#endif /* HAVE_CACHE_INFO_EX2 */ if ( is_windows_xp() ) { if ( !GetQueryTktCacheResponseXP(data->LogonHandle, data->PackageId, &lcursor->response.xp) ) { LsaFreeReturnBuffer(lcursor->mstgt); @@ -2125,33 +1814,6 @@ krb5_lcc_next_cred(krb5_context context, krb5_ccache id, krb5_cc_cursor *cursor, data = (krb5_lcc_data *)id->data; next_cred: -#ifdef HAVE_CACHE_INFO_EX2 - if ( does_query_ticket_cache_ex2() ) { - if ( lcursor->index >= lcursor->response.ex2->CountOfTickets ) { - if (retval == KRB5_OK) - return KRB5_CC_END; - else { - LsaFreeReturnBuffer(lcursor->mstgt); - LsaFreeReturnBuffer(lcursor->response.ex2); - free(*cursor); - *cursor = 0; - return retval; - } - } - - if ( data->flags & KRB5_TC_NOTICKET ) { - CacheInfoEx2ToMITCred( &lcursor->response.ex2->Tickets[lcursor->index++], - context, creds); - return KRB5_OK; - } else { - if (!GetMSCacheTicketFromCacheInfoEX2(data->LogonHandle, data->PackageId, - &lcursor->response.ex2->Tickets[lcursor->index++],&msticket)) { - retval = KRB5_FCC_INTERNAL; - goto next_cred; - } - } - } else -#endif /* HAVE_CACHE_INFO_EX2 */ if ( is_windows_xp() ) { if ( lcursor->index >= lcursor->response.xp->CountOfTickets ) { if (retval == KRB5_OK) @@ -2197,18 +1859,15 @@ krb5_lcc_next_cred(krb5_context context, krb5_ccache id, krb5_cc_cursor *cursor, } /* convert the ticket */ -#ifdef HAVE_CACHE_INFO_EX2 - if ( does_query_ticket_cache_ex2() ) { - MSCredToMITCred(msticket, lcursor->response.ex2->Tickets[lcursor->index-1].ClientRealm, context, creds); - } else -#endif /* HAVE_CACHE_INFO_EX2 */ if ( is_windows_xp() ) { - MSCredToMITCred(msticket, lcursor->response.xp->Tickets[lcursor->index-1].ClientRealm, context, creds); + if (!MSCredToMITCred(msticket, lcursor->response.xp->Tickets[lcursor->index-1].ClientRealm, context, creds)) + retval = KRB5_FCC_INTERNAL; } else { - MSCredToMITCred(msticket, lcursor->mstgt->DomainName, context, creds); + if (!MSCredToMITCred(msticket, lcursor->mstgt->DomainName, context, creds)) + retval = KRB5_FCC_INTERNAL; } LsaFreeReturnBuffer(msticket); - return KRB5_OK; + return retval; } /* @@ -2234,11 +1893,6 @@ krb5_lcc_end_seq_get(krb5_context context, krb5_ccache id, krb5_cc_cursor *curso if ( lcursor ) { LsaFreeReturnBuffer(lcursor->mstgt); -#ifdef HAVE_CACHE_INFO_EX2 - if ( does_query_ticket_cache_ex2() ) - LsaFreeReturnBuffer(lcursor->response.ex2); - else -#endif /* HAVE_CACHE_INFO_EX2 */ if ( is_windows_xp() ) LsaFreeReturnBuffer(lcursor->response.xp); else @@ -2301,7 +1955,6 @@ static krb5_error_code KRB5_CALLCONV krb5_lcc_get_principal(krb5_context context, krb5_ccache id, krb5_principal *princ) { krb5_lcc_data *data = (krb5_lcc_data *)id->data; - krb5_error_code kret = KRB5_OK; if (!is_windows_2000()) return KRB5_FCC_NOFILE; @@ -2317,7 +1970,11 @@ krb5_lcc_get_principal(krb5_context context, krb5_ccache id, krb5_principal *pri if (GetMSTGT(context, data->LogonHandle, data->PackageId, &msticket, FALSE)) { /* convert the ticket */ krb5_creds creds; - MSCredToMITCred(msticket, msticket->DomainName, context, &creds); + if (!MSCredToMITCred(msticket, msticket->DomainName, context, &creds)) + { + LsaFreeReturnBuffer(msticket); + return KRB5_FCC_INTERNAL; + } LsaFreeReturnBuffer(msticket); krb5_copy_principal(context, creds.client, &data->princ); @@ -2336,7 +1993,7 @@ krb5_lcc_retrieve(krb5_context context, krb5_ccache id, krb5_flags whichfields, krb5_error_code kret = KRB5_OK; krb5_lcc_data *data = (krb5_lcc_data *)id->data; KERB_EXTERNAL_TICKET *msticket = 0, *mstgt = 0, *mstmp = 0; - krb5_creds * mcreds_noflags; + krb5_creds * mcreds_noflags = 0; krb5_creds fetchcreds; if (!is_windows_2000()) @@ -2350,7 +2007,9 @@ krb5_lcc_retrieve(krb5_context context, krb5_ccache id, krb5_flags whichfields, return KRB5_OK; /* if not, we must try to get a ticket without specifying any flags or etypes */ - krb5_copy_creds(context, mcreds, &mcreds_noflags); + kret = krb5_copy_creds(context, mcreds, &mcreds_noflags); + if (kret) + goto cleanup; mcreds_noflags->ticket_flags = 0; mcreds_noflags->keyblock.enctype = 0; @@ -2364,8 +2023,6 @@ krb5_lcc_retrieve(krb5_context context, krb5_ccache id, krb5_flags whichfields, if ( !kret ) goto cleanup; - - /* if not, obtain a ticket using the request flags and enctype even though it may not * be stored in the LSA cache for future use. */ @@ -2384,7 +2041,11 @@ krb5_lcc_retrieve(krb5_context context, krb5_ccache id, krb5_flags whichfields, if ( PreserveInitialTicketIdentity() ) GetMSTGT(context, data->LogonHandle, data->PackageId, &mstgt, FALSE); - MSCredToMITCred(msticket, mstgt ? mstgt->DomainName : msticket->DomainName, context, &fetchcreds); + if (!MSCredToMITCred(msticket, mstgt ? mstgt->DomainName : msticket->DomainName, context, &fetchcreds)) + { + kret = KRB5_FCC_INTERNAL; + goto cleanup; + } } else { /* We can obtain the correct client realm for a ticket by walking the * cache contents until we find the matching service ticket. @@ -2410,7 +2071,12 @@ krb5_lcc_retrieve(krb5_context context, krb5_ccache id, krb5_flags whichfields, mstmp = 0; } - MSCredToMITCred(msticket, mstmp ? pResponse->Tickets[i].ClientRealm : msticket->DomainName, context, &fetchcreds); + if (!MSCredToMITCred(msticket, mstmp ? pResponse->Tickets[i].ClientRealm : msticket->DomainName, context, &fetchcreds)) + { + LsaFreeReturnBuffer(pResponse); + kret = KRB5_FCC_INTERNAL; + goto cleanup; + } LsaFreeReturnBuffer(pResponse); } @@ -2452,26 +2118,22 @@ krb5_lcc_store(krb5_context context, krb5_ccache id, krb5_creds *creds) krb5_error_code kret = KRB5_OK; krb5_lcc_data *data = (krb5_lcc_data *)id->data; KERB_EXTERNAL_TICKET *msticket = 0, *msticket2 = 0; - krb5_creds * creds_noflags; + krb5_creds * creds_noflags = 0; if (!is_windows_2000()) return KRB5_FCC_NOFILE; -#ifdef KERB_SUBMIT_TICKET - /* we can use the new KerbSubmitTicketMessage to store the ticket */ - if (KerbSubmitTicket( data->LogonHandle, data->PackageId, context, creds )) - return KRB5_OK; -#endif /* KERB_SUBMIT_TICKET */ - /* If not, lets try to obtain a matching ticket from the KDC */ if ( creds->ticket_flags != 0 && creds->keyblock.enctype != 0 ) { /* if not, we must try to get a ticket without specifying any flags or etypes */ - krb5_copy_creds(context, creds, &creds_noflags); - creds_noflags->ticket_flags = 0; - creds_noflags->keyblock.enctype = 0; + kret = krb5_copy_creds(context, creds, &creds_noflags); + if (kret == 0) { + creds_noflags->ticket_flags = 0; + creds_noflags->keyblock.enctype = 0; - GetMSCacheTicketFromMITCred(data->LogonHandle, data->PackageId, context, creds_noflags, &msticket2); - krb5_free_creds(context, creds_noflags); + GetMSCacheTicketFromMITCred(data->LogonHandle, data->PackageId, context, creds_noflags, &msticket2); + krb5_free_creds(context, creds_noflags); + } } GetMSCacheTicketFromMITCred(data->LogonHandle, data->PackageId, context, creds, &msticket); diff --git a/src/lib/krb5/keytab/ChangeLog b/src/lib/krb5/keytab/ChangeLog index 7536397..7907333 100644 --- a/src/lib/krb5/keytab/ChangeLog +++ b/src/lib/krb5/keytab/ChangeLog @@ -1,3 +1,34 @@ +2004-11-26 Ken Raeburn <raeburn@mit.edu> + + * kt_file.c (krb5_ktfile_wresolve): Initialize mutex here too. + +2004-11-23 Ken Raeburn <raeburn@mit.edu> + + * kt_file.c (struct _krb5_ktfile_data): Add mutex and buffer. + (KTFILEBUFP, KTLOCK, KTUNLOCK, KTCHECKLOCK): New macros. + (krb5_ktfile_resolve): Initialize mutex. + (krb5_ktfile_close): Zap data buffer before freeing. + (krb5_ktfile_get_entry, krb5_ktfile_start_seq_get, + krb5_ktfile_get_next, krb5_ktfile_end_get, krb5_ktfile_add, + krb5_ktfile_remove): Lock and unlock the mutex. + (krb5_ktfileint_open): Check that the mutex is locked. Set the + stdio buffer to the new buffer in the ktfile data. + (krb5_ktfileint_write_entry, krb5_ktfileint_find_slot): Check that + the mutex is locked. Don't call setbuf. Flush the stdio buffer + after writing. + +2004-11-23 Tom Yu <tlyu@mit.edu> + + * kt_file.c (krb5_ktfileint_open): Update previous change by + explicitly setting errno=0 prior to calling fopen(). Also, return + EMFILE, not ENFILE, for compatibility with Solaris 8, which does + set errno when out of file descriptors. + +2004-11-19 Tom Yu <tlyu@mit.edu> + + * kt_file.c (krb5_ktfileint_open): Patch from Roland Dowdeswell to + return ENFILE when fopen() returns NULL but doesn't set errno. + 2004-06-22 Ken Raeburn <raeburn@mit.edu> * kt_file.c (krb5_ktf_keytab_externalize, diff --git a/src/lib/krb5/keytab/kt_file.c b/src/lib/krb5/keytab/kt_file.c index c6f94f2..6fb9f7b 100644 --- a/src/lib/krb5/keytab/kt_file.c +++ b/src/lib/krb5/keytab/kt_file.c @@ -52,7 +52,9 @@ typedef struct _krb5_ktfile_data { char *name; /* Name of the file */ FILE *openf; /* open file, if any. */ + char iobuf[BUFSIZ]; /* so we can zap it later */ int version; /* Version number of keytab */ + k5_mutex_t lock; /* Protect openf, version */ } krb5_ktfile_data; /* @@ -61,7 +63,11 @@ typedef struct _krb5_ktfile_data { #define KTPRIVATE(id) ((krb5_ktfile_data *)(id)->data) #define KTFILENAME(id) (((krb5_ktfile_data *)(id)->data)->name) #define KTFILEP(id) (((krb5_ktfile_data *)(id)->data)->openf) +#define KTFILEBUFP(id) (((krb5_ktfile_data *)(id)->data)->iobuf) #define KTVERSION(id) (((krb5_ktfile_data *)(id)->data)->version) +#define KTLOCK(id) k5_mutex_lock(&((krb5_ktfile_data *)(id)->data)->lock) +#define KTUNLOCK(id) k5_mutex_unlock(&((krb5_ktfile_data *)(id)->data)->lock) +#define KTCHECKLOCK(id) k5_mutex_assert_locked(&((krb5_ktfile_data *)(id)->data)->lock) extern const struct _krb5_kt_ops krb5_ktf_ops; extern const struct _krb5_kt_ops krb5_ktf_writable_ops; @@ -175,6 +181,7 @@ krb5_error_code KRB5_CALLCONV krb5_ktfile_resolve(krb5_context context, const char *name, krb5_keytab *id) { krb5_ktfile_data *data; + krb5_error_code err; if ((*id = (krb5_keytab) malloc(sizeof(**id))) == NULL) return(ENOMEM); @@ -185,7 +192,14 @@ krb5_ktfile_resolve(krb5_context context, const char *name, krb5_keytab *id) return(ENOMEM); } + err = k5_mutex_init(&data->lock); + if (err) { + krb5_xfree(*id); + return err; + } + if ((data->name = (char *)calloc(strlen(name) + 1, sizeof(char))) == NULL) { + k5_mutex_destroy(&data->lock); krb5_xfree(data); krb5_xfree(*id); return(ENOMEM); @@ -217,6 +231,8 @@ krb5_ktfile_close(krb5_context context, krb5_keytab id) */ { krb5_xfree(KTFILENAME(id)); + zap(KTFILEBUFP(id), BUFSIZ); + k5_mutex_destroy(&((krb5_ktfile_data *)id->data)->lock); krb5_xfree(id->data); id->ops = 0; krb5_xfree(id); @@ -230,7 +246,9 @@ krb5_ktfile_close(krb5_context context, krb5_keytab id) */ krb5_error_code KRB5_CALLCONV -krb5_ktfile_get_entry(krb5_context context, krb5_keytab id, krb5_const_principal principal, krb5_kvno kvno, krb5_enctype enctype, krb5_keytab_entry *entry) +krb5_ktfile_get_entry(krb5_context context, krb5_keytab id, + krb5_const_principal principal, krb5_kvno kvno, + krb5_enctype enctype, krb5_keytab_entry *entry) { krb5_keytab_entry cur_entry, new_entry; krb5_error_code kerror = 0; @@ -238,9 +256,15 @@ krb5_ktfile_get_entry(krb5_context context, krb5_keytab id, krb5_const_principal krb5_boolean similar; int kvno_offset = 0; + kerror = KTLOCK(id); + if (kerror) + return kerror; + /* Open the keyfile for reading */ - if ((kerror = krb5_ktfileint_openr(context, id))) + if ((kerror = krb5_ktfileint_openr(context, id))) { + KTUNLOCK(id); return(kerror); + } /* * For efficiency and simplicity, we'll use a while true that @@ -347,13 +371,16 @@ krb5_ktfile_get_entry(krb5_context context, krb5_keytab id, krb5_const_principal } if (kerror) { (void) krb5_ktfileint_close(context, id); + KTUNLOCK(id); krb5_kt_free_entry(context, &cur_entry); return kerror; } if ((kerror = krb5_ktfileint_close(context, id)) != 0) { + KTUNLOCK(id); krb5_kt_free_entry(context, &cur_entry); return kerror; } + KTUNLOCK(id); *entry = cur_entry; return 0; } @@ -399,15 +426,23 @@ krb5_ktfile_start_seq_get(krb5_context context, krb5_keytab id, krb5_kt_cursor * krb5_error_code retval; long *fileoff; - if ((retval = krb5_ktfileint_openr(context, id))) + retval = KTLOCK(id); + if (retval) return retval; + if ((retval = krb5_ktfileint_openr(context, id))) { + KTUNLOCK(id); + return retval; + } + if (!(fileoff = (long *)malloc(sizeof(*fileoff)))) { krb5_ktfileint_close(context, id); + KTUNLOCK(id); return ENOMEM; } *fileoff = ftell(KTFILEP(id)); *cursorp = (krb5_kt_cursor)fileoff; + KTUNLOCK(id); return 0; } @@ -423,12 +458,20 @@ krb5_ktfile_get_next(krb5_context context, krb5_keytab id, krb5_keytab_entry *en krb5_keytab_entry cur_entry; krb5_error_code kerror; - if (fseek(KTFILEP(id), *fileoff, 0) == -1) + kerror = KTLOCK(id); + if (kerror) + return kerror; + if (fseek(KTFILEP(id), *fileoff, 0) == -1) { + KTUNLOCK(id); return KRB5_KT_END; - if ((kerror = krb5_ktfileint_read_entry(context, id, &cur_entry))) + } + if ((kerror = krb5_ktfileint_read_entry(context, id, &cur_entry))) { + KTUNLOCK(id); return kerror; + } *fileoff = ftell(KTFILEP(id)); *entry = cur_entry; + KTUNLOCK(id); return 0; } @@ -439,8 +482,13 @@ krb5_ktfile_get_next(krb5_context context, krb5_keytab id, krb5_keytab_entry *en krb5_error_code KRB5_CALLCONV krb5_ktfile_end_get(krb5_context context, krb5_keytab id, krb5_kt_cursor *cursor) { + krb5_error_code kerror; + krb5_xfree(*cursor); - return krb5_ktfileint_close(context, id); + KTLOCK(id); + kerror = krb5_ktfileint_close(context, id); + KTUNLOCK(id); + return kerror; } /* @@ -745,6 +793,7 @@ krb5_error_code KRB5_CALLCONV krb5_ktfile_wresolve(krb5_context context, const char *name, krb5_keytab *id) { krb5_ktfile_data *data; + krb5_error_code err; if ((*id = (krb5_keytab) malloc(sizeof(**id))) == NULL) return(ENOMEM); @@ -755,7 +804,14 @@ krb5_ktfile_wresolve(krb5_context context, const char *name, krb5_keytab *id) return(ENOMEM); } + err = k5_mutex_init(&data->lock); + if (err) { + krb5_xfree(*id); + return err; + } + if ((data->name = (char *)calloc(strlen(name) + 1, sizeof(char))) == NULL) { + k5_mutex_destroy(&data->lock); krb5_xfree(data); krb5_xfree(*id); return(ENOMEM); @@ -780,12 +836,20 @@ krb5_ktfile_add(krb5_context context, krb5_keytab id, krb5_keytab_entry *entry) { krb5_error_code retval; - if ((retval = krb5_ktfileint_openw(context, id))) + retval = KTLOCK(id); + if (retval) return retval; - if (fseek(KTFILEP(id), 0, 2) == -1) + if ((retval = krb5_ktfileint_openw(context, id))) { + KTUNLOCK(id); + return retval; + } + if (fseek(KTFILEP(id), 0, 2) == -1) { + KTUNLOCK(id); return KRB5_KT_END; + } retval = krb5_ktfileint_write_entry(context, id, entry); krb5_ktfileint_close(context, id); + KTUNLOCK(id); return retval; } @@ -800,7 +864,12 @@ krb5_ktfile_remove(krb5_context context, krb5_keytab id, krb5_keytab_entry *entr krb5_error_code kerror; krb5_int32 delete_point; + kerror = KTLOCK(id); + if (kerror) + return kerror; + if ((kerror = krb5_ktfileint_openw(context, id))) { + KTUNLOCK(id); return kerror; } @@ -829,6 +898,7 @@ krb5_ktfile_remove(krb5_context context, krb5_keytab id, krb5_keytab_entry *entr if (kerror) { (void) krb5_ktfileint_close(context, id); + KTUNLOCK(id); return kerror; } @@ -839,7 +909,7 @@ krb5_ktfile_remove(krb5_context context, krb5_keytab id, krb5_keytab_entry *entr } else { kerror = krb5_ktfileint_close(context, id); } - + KTUNLOCK(id); return kerror; } @@ -999,6 +1069,8 @@ krb5_ktfileint_open(krb5_context context, krb5_keytab id, int mode) krb5_kt_vno kt_vno; int writevno = 0; + KTCHECKLOCK(id); + errno = 0; KTFILEP(id) = fopen(KTFILENAME(id), (mode == KRB5_LOCKMODE_EXCLUSIVE) ? fopen_mode_rbplus : fopen_mode_rb); @@ -1006,12 +1078,13 @@ krb5_ktfileint_open(krb5_context context, krb5_keytab id, int mode) if ((mode == KRB5_LOCKMODE_EXCLUSIVE) && (errno == ENOENT)) { /* try making it first time around */ krb5_create_secure_file(context, KTFILENAME(id)); + errno = 0; KTFILEP(id) = fopen(KTFILENAME(id), fopen_mode_rbplus); if (!KTFILEP(id)) - return errno; + return errno ? errno : EMFILE; writevno = 1; } else /* some other error */ - return errno; + return errno ? errno : EMFILE; } if ((kerror = krb5_lock_file(context, fileno(KTFILEP(id)), mode))) { (void) fclose(KTFILEP(id)); @@ -1019,7 +1092,7 @@ krb5_ktfileint_open(krb5_context context, krb5_keytab id, int mode) return kerror; } /* assume ANSI or BSD-style stdio */ - setbuf(KTFILEP(id), NULL); + setbuf(KTFILEP(id), KTFILEBUFP(id)); /* get the vno and verify it */ if (writevno) { @@ -1067,6 +1140,7 @@ krb5_ktfileint_close(krb5_context context, krb5_keytab id) { krb5_error_code kerror; + KTCHECKLOCK(id); if (!KTFILEP(id)) return 0; kerror = krb5_unlock_file(context, fileno(KTFILEP(id))); @@ -1082,6 +1156,7 @@ krb5_ktfileint_delete_entry(krb5_context context, krb5_keytab id, krb5_int32 del krb5_int32 len; char iobuf[BUFSIZ]; + KTCHECKLOCK(id); if (fseek(KTFILEP(id), delete_point, SEEK_SET)) { return errno; } @@ -1140,6 +1215,7 @@ krb5_ktfileint_internal_read_entry(krb5_context context, krb5_keytab id, krb5_ke char *tmpdata; krb5_data *princ; + KTCHECKLOCK(id); memset(ret_entry, 0, sizeof(krb5_keytab_entry)); ret_entry->magic = KV5M_KEYTAB_ENTRY; @@ -1356,8 +1432,8 @@ krb5_ktfileint_write_entry(krb5_context context, krb5_keytab id, krb5_keytab_ent krb5_int32 size_needed; krb5_int32 commit_point; int i; - char iobuf[BUFSIZ]; + KTCHECKLOCK(id); retval = krb5_ktfileint_size_entry(context, entry, &size_needed); if (retval) return retval; @@ -1365,10 +1441,8 @@ krb5_ktfileint_write_entry(krb5_context context, krb5_keytab id, krb5_keytab_ent if (retval) return retval; - setbuf(KTFILEP(id), iobuf); - /* fseek to synchronise buffered I/O on the key table. */ - + /* XXX Without the weird setbuf crock, can we get rid of this now? */ if (fseek(KTFILEP(id), 0L, SEEK_CUR) < 0) { return errno; @@ -1382,7 +1456,6 @@ krb5_ktfileint_write_entry(krb5_context context, krb5_keytab id, krb5_keytab_ent if (!xfwrite(&count, sizeof(count), 1, KTFILEP(id))) { abend: - setbuf(KTFILEP(id), 0); return KRB5_KT_IOERR; } size = krb5_princ_realm(context, entry->principal)->length; @@ -1457,14 +1530,13 @@ krb5_ktfileint_write_entry(krb5_context context, krb5_keytab id, krb5_keytab_ent } if (!xfwrite(entry->key.contents, sizeof(krb5_octet), entry->key.length, KTFILEP(id))) { - memset(iobuf, 0, sizeof(iobuf)); - setbuf(KTFILEP(id), 0); - return KRB5_KT_IOERR; + goto abend; } + if (fflush(KTFILEP(id))) + goto abend; + retval = krb5_sync_disk_file(context, KTFILEP(id)); - (void) memset(iobuf, 0, sizeof(iobuf)); - setbuf(KTFILEP(id), 0); if (retval) { return retval; @@ -1478,6 +1550,8 @@ krb5_ktfileint_write_entry(krb5_context context, krb5_keytab id, krb5_keytab_ent if (!xfwrite(&size_needed, sizeof(size_needed), 1, KTFILEP(id))) { goto abend; } + if (fflush(KTFILEP(id))) + goto abend; retval = krb5_sync_disk_file(context, KTFILEP(id)); return retval; @@ -1536,6 +1610,7 @@ krb5_ktfileint_find_slot(krb5_context context, krb5_keytab id, krb5_int32 *size_ krb5_boolean found = FALSE; char iobuf[BUFSIZ]; + KTCHECKLOCK(id); /* * Skip over file version number */ @@ -1552,11 +1627,10 @@ krb5_ktfileint_find_slot(krb5_context context, krb5_keytab id, krb5_int32 *size_ /* * Hit the end of file, reserve this slot. */ - setbuf(KTFILEP(id), 0); size = 0; /* fseek to synchronise buffered I/O on the key table. */ - + /* XXX Without the weird setbuf hack, can we nuke this now? */ if (fseek(KTFILEP(id), 0L, SEEK_CUR) < 0) { return errno; @@ -1607,7 +1681,6 @@ krb5_ktfileint_find_slot(krb5_context context, krb5_keytab id, krb5_int32 *size_ * Make sure we zero any trailing data. */ zero_point = ftell(KTFILEP(id)); - setbuf(KTFILEP(id), iobuf); while ((size = xfread(iobuf, 1, sizeof(iobuf), KTFILEP(id)))) { if (size != sizeof(iobuf)) { remainder = size % sizeof(krb5_int32); @@ -1623,6 +1696,7 @@ krb5_ktfileint_find_slot(krb5_context context, krb5_keytab id, krb5_int32 *size_ memset(iobuf, 0, (size_t) size); xfwrite(iobuf, 1, (size_t) size, KTFILEP(id)); + fflush(KTFILEP(id)); if (feof(KTFILEP(id))) { break; } @@ -1633,7 +1707,6 @@ krb5_ktfileint_find_slot(krb5_context context, krb5_keytab id, krb5_int32 *size_ } } - setbuf(KTFILEP(id), 0); if (fseek(KTFILEP(id), zero_point, SEEK_SET)) { return errno; } diff --git a/src/lib/krb5/krb/ChangeLog b/src/lib/krb5/krb/ChangeLog index 46483ac..bca1601 100644 --- a/src/lib/krb5/krb/ChangeLog +++ b/src/lib/krb5/krb/ChangeLog @@ -1,3 +1,52 @@ +2005-03-22 Tom Yu <tlyu@mit.edu> + + * x-deltat.y (wsnum): Add missing semicolon following YYERROR, + which was preventing bison-1.75 from producing compilable C + output. + + * gic_keytab.c (krb5_get_init_creds_keytab): When calling + krb5_get_init_creds() for the second time (with use_master=1), + also accept KRB5_REALM_UNKNOWN as a soft error, and use the result + from the first call to krb5_get_init_creds(). This can happen + when no master KDC is configured. + +2005-03-14 Jeffrey Altman <jaltman@mit.edu> + + * Makefile.in: fix maintainer mode since it is not supported on + Windows. + +2005-03-03 Ken Raeburn <raeburn@mit.edu> + + * x-deltat.y (tok_WS): Renamed terminal from "WS", which conflicts + with HP-UX 10 header files. Updated all productions. + (mylex): Updated. + * Makefile.in ($(srcdir)/deltat.c): Enable dependencies in + maintainer mode. + * deltat.c: Updated. + +2005-02-09 Tom Yu <tlyu@mit.edu> + + * gic_pwd.c (krb5_get_init_creds_password): Fix so empty password + string causes prompting and doesn't cause truncation of password + to zero characters. + +2005-01-17 Jeffrey Altman <jaltman@mit.edu> + * unparse.c: krb5_unparse_name, krb5_unparse_name_ext() + prevent null pointer dereferencing if either 'name' or 'size' + are NULL. + +2005-01-15 Jeffrey Altman <jaltman@mit.edu> + + * cp_key_cnt.c, copy_princ.c: + prevent krb5_copy_principal() and krb5_copy_keyblock() from + calling malloc(0). On platforms in which malloc(0) returns + NULL, these functions will return an ENOMEM error the way + they were written. + +2005-01-03 Ken Raeburn <raeburn@mit.edu> + + * parse.c (krb5_parse_name): Don't cache the default realm name. + 2004-10-26 Tom Yu <tlyu@mit.edu> * mk_req_ext.c (krb5_mk_req_extended): Free keyblock before diff --git a/src/lib/krb5/krb/Makefile.in b/src/lib/krb5/krb/Makefile.in index 10b39b1..2c5572c 100644 --- a/src/lib/krb5/krb/Makefile.in +++ b/src/lib/krb5/krb/Makefile.in @@ -277,7 +277,10 @@ SRCS= $(srcdir)/addr_comp.c \ # Someday, when we have a "maintainer mode", do this right: BISON=bison BISONFLAGS=-v # -v -> .output; -d -> .h -$(srcdir)/deltat.c : # x-deltat.y +DELTAT_DEP=@MAINT@ x-deltat.y +##WIN32##DELTAT_DEP= + +$(srcdir)/deltat.c : $(DELTAT_DEP) $(BISON) $(BISONFLAGS) -o $(srcdir)/deltat.c $(srcdir)/x-deltat.y ##DOS##LIBOBJS = $(OBJS) diff --git a/src/lib/krb5/krb/copy_princ.c b/src/lib/krb5/krb/copy_princ.c index 569e55b..f623236 100644 --- a/src/lib/krb5/krb/copy_princ.c +++ b/src/lib/krb5/krb/copy_princ.c @@ -60,32 +60,36 @@ krb5_copy_principal(krb5_context context, krb5_const_principal inprinc, krb5_pri for (i = 0; i < nelems; i++) { unsigned int len = krb5_princ_component(context, inprinc, i)->length; krb5_princ_component(context, tempprinc, i)->length = len; - if (((krb5_princ_component(context, tempprinc, i)->data = - malloc(len)) == 0) && len) { - while (--i >= 0) - free(krb5_princ_component(context, tempprinc, i)->data); - free (tempprinc->data); - free (tempprinc); - return ENOMEM; - } - if (len) + if (len) { + if (((krb5_princ_component(context, tempprinc, i)->data = + malloc(len)) == 0)) { + while (--i >= 0) + free(krb5_princ_component(context, tempprinc, i)->data); + free (tempprinc->data); + free (tempprinc); + return ENOMEM; + } memcpy(krb5_princ_component(context, tempprinc, i)->data, krb5_princ_component(context, inprinc, i)->data, len); + } else + krb5_princ_component(context, tempprinc, i)->data = 0; } - tempprinc->realm.data = + if (tempprinc->realm.length) { + tempprinc->realm.data = malloc(tempprinc->realm.length = inprinc->realm.length); - if (!tempprinc->realm.data && tempprinc->realm.length) { + if (!tempprinc->realm.data) { for (i = 0; i < nelems; i++) - free(krb5_princ_component(context, tempprinc, i)->data); + free(krb5_princ_component(context, tempprinc, i)->data); free(tempprinc->data); free(tempprinc); return ENOMEM; - } - if (tempprinc->realm.length) + } memcpy(tempprinc->realm.data, inprinc->realm.data, inprinc->realm.length); - + } else + tempprinc->realm.data = 0; + *outprinc = tempprinc; return 0; } diff --git a/src/lib/krb5/krb/cp_key_cnt.c b/src/lib/krb5/krb/cp_key_cnt.c index b39a6a9..150be0a 100644 --- a/src/lib/krb5/krb/cp_key_cnt.c +++ b/src/lib/krb5/krb/cp_key_cnt.c @@ -36,9 +36,12 @@ krb5_error_code KRB5_CALLCONV krb5_copy_keyblock_contents(krb5_context context, const krb5_keyblock *from, krb5_keyblock *to) { *to = *from; - to->contents = (krb5_octet *)malloc(to->length); - if (!to->contents) - return ENOMEM; - memcpy((char *)to->contents, (char *)from->contents, to->length); + if (to->length) { + to->contents = (krb5_octet *)malloc(to->length); + if (!to->contents) + return ENOMEM; + memcpy((char *)to->contents, (char *)from->contents, to->length); + } else + to->contents = 0; return 0; } diff --git a/src/lib/krb5/krb/deltat.c b/src/lib/krb5/krb/deltat.c index 7f8fe16..a12e42d 100644 --- a/src/lib/krb5/krb/deltat.c +++ b/src/lib/krb5/krb/deltat.c @@ -1,15 +1,74 @@ +/* A Bison parser, made by GNU Bison 1.875c. */ -/* A Bison parser, made from ./x-deltat.y - by GNU Bison version 1.28 */ +/* Skeleton parser for Yacc-like parsing with Bison, + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. -#define YYBISON 1 /* Identify Bison output. */ + 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. */ -#define NUM 257 -#define LONGNUM 258 -#define OVERFLOW 259 -#define WS 260 +/* Written by Richard Stallman by simplifying the original so called + ``semantic'' parser. */ -#line 38 "./x-deltat.y" +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 1 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + NUM = 258, + LONGNUM = 259, + OVERFLOW = 260, + tok_WS = 261 + }; +#endif +#define NUM 258 +#define LONGNUM 259 +#define OVERFLOW 260 +#define tok_WS 261 + + + + +/* Copy the first part of user declarations. */ +#line 38 "../../../../src/lib/krb5/krb/x-deltat.y" #include <ctype.h> @@ -94,439 +153,730 @@ static int mylex (int *, char **); static int yyparse (void *); -#line 125 "./x-deltat.y" -typedef union { int val; } YYSTYPE; -#include <stdio.h> -#ifndef __cplusplus -#ifndef __STDC__ -#define const +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 #endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 #endif +#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) +#line 125 "../../../../src/lib/krb5/krb/x-deltat.y" +typedef union YYSTYPE { int val; } YYSTYPE; +/* Line 191 of yacc.c. */ +#line 175 "../../../../src/lib/krb5/krb/deltat.c" +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif -#define YYFINAL 42 -#define YYFLAG -32768 -#define YYNTBASE 13 - -#define YYTRANSLATE(x) ((unsigned)(x) <= 260 ? yytranslate[x] : 22) - -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, 6, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 7, 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, 8, - 2, 2, 2, 9, 2, 2, 2, 2, 10, 2, - 2, 2, 2, 2, 11, 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, 5, 12 -}; -#if YYDEBUG != 0 -static const short yyprhs[] = { 0, - 0, 2, 4, 6, 8, 11, 12, 14, 17, 20, - 24, 28, 32, 35, 43, 49, 53, 55, 57, 61, - 63, 67, 69 -}; +/* Copy the second part of user declarations. */ -static const short yyrhs[] = { 18, - 0, 3, 0, 4, 0, 14, 0, 6, 14, 0, - 0, 12, 0, 16, 15, 0, 16, 5, 0, 17, - 8, 19, 0, 17, 9, 20, 0, 17, 10, 21, - 0, 17, 11, 0, 17, 6, 3, 7, 3, 7, - 3, 0, 17, 7, 3, 7, 3, 0, 17, 7, - 3, 0, 17, 0, 20, 0, 17, 9, 20, 0, - 21, 0, 17, 10, 21, 0, 16, 0, 17, 11, - 0 -}; -#endif +/* Line 214 of yacc.c. */ +#line 187 "../../../../src/lib/krb5/krb/deltat.c" -#if YYDEBUG != 0 -static const short yyrline[] = { 0, - 136, 137, 137, 138, 138, 139, 139, 140, 141, 142, - 144, 145, 146, 147, 148, 149, 150, 153, 155, 157, - 159, 161, 163 -}; -#endif +#if ! defined (yyoverflow) || YYERROR_VERBOSE +/* The parser invokes alloca or malloc; define the necessary symbols. */ -#if YYDEBUG != 0 || defined (YYERROR_VERBOSE) +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# define YYSTACK_ALLOC alloca +# endif +# else +# if defined (alloca) || defined (_ALLOCA_H) +# define YYSTACK_ALLOC alloca +# else +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) +# else +# if defined (__STDC__) || defined (__cplusplus) +# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# endif +# define YYSTACK_ALLOC malloc +# define YYSTACK_FREE free +# endif +#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ + + +#if (! defined (yyoverflow) \ + && (! defined (__cplusplus) \ + || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + short yyss; + YYSTYPE yyvs; + }; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (short) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined (__GNUC__) && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + register YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (0) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (0) -static const char * const yytname[] = { "$","error","$undefined.","NUM","LONGNUM", -"OVERFLOW","'-'","':'","'d'","'h'","'m'","'s'","WS","start","posnum","num","ws", -"wsnum","deltat","opt_hms","opt_ms","opt_s", NULL -}; #endif -static const short yyr1[] = { 0, - 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, - 18, 18, 18, 18, 18, 18, 18, 19, 19, 20, - 20, 21, 21 -}; +#if defined (__STDC__) || defined (__cplusplus) + typedef signed char yysigned_char; +#else + typedef short yysigned_char; +#endif -static const short yyr2[] = { 0, - 1, 1, 1, 1, 2, 0, 1, 2, 2, 3, - 3, 3, 2, 7, 5, 3, 1, 1, 3, 1, - 3, 1, 2 +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 6 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 37 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 13 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 10 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 24 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 42 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 261 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const unsigned 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, 6, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 7, 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, + 8, 2, 2, 2, 9, 2, 2, 2, 2, 10, + 2, 2, 2, 2, 2, 11, 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, 2, 3, 4, + 5, 12 }; -static const short yydefact[] = { 6, - 7, 0, 17, 1, 2, 3, 9, 0, 4, 8, - 0, 0, 6, 6, 6, 13, 5, 0, 16, 22, - 0, 10, 18, 20, 0, 11, 0, 12, 0, 0, - 6, 6, 23, 0, 15, 19, 21, 0, 14, 0, - 0, 0 +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const unsigned char yyprhs[] = +{ + 0, 0, 3, 5, 7, 9, 11, 14, 15, 17, + 20, 23, 27, 31, 35, 38, 46, 52, 56, 58, + 60, 64, 66, 70, 72 }; -static const short yydefgoto[] = { 40, - 9, 10, 20, 25, 4, 22, 23, 24 +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yysigned_char yyrhs[] = +{ + 14, 0, -1, 19, -1, 3, -1, 4, -1, 15, + -1, 6, 15, -1, -1, 12, -1, 17, 16, -1, + 17, 5, -1, 18, 8, 20, -1, 18, 9, 21, + -1, 18, 10, 22, -1, 18, 11, -1, 18, 6, + 3, 7, 3, 7, 3, -1, 18, 7, 3, 7, + 3, -1, 18, 7, 3, -1, 18, -1, 21, -1, + 18, 9, 21, -1, 22, -1, 18, 10, 22, -1, + 17, -1, 18, 11, -1 }; -static const short yypact[] = { -10, --32768, 18, -2,-32768,-32768,-32768,-32768, 13,-32768,-32768, - 11, 16, -10, -10, -10,-32768,-32768, 20, 21, 18, - 1,-32768,-32768,-32768, 15,-32768, 19,-32768, 26, 28, - -10, -10,-32768, 27,-32768,-32768,-32768, 30,-32768, 35, - 36,-32768 +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const unsigned char yyrline[] = +{ + 0, 136, 136, 137, 137, 138, 138, 139, 139, 140, + 141, 143, 144, 145, 146, 147, 148, 149, 150, 154, + 155, 158, 159, 162, 163 }; +#endif -static const short yypgoto[] = {-32768, - 29,-32768, 38, 0,-32768,-32768, -13, -12 +#if YYDEBUG || YYERROR_VERBOSE +/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "NUM", "LONGNUM", "OVERFLOW", "'-'", + "':'", "'d'", "'h'", "'m'", "'s'", "tok_WS", "$accept", "start", + "posnum", "num", "ws", "wsnum", "deltat", "opt_hms", "opt_ms", "opt_s", 0 }; +#endif +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const unsigned short yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 45, 58, 100, 104, + 109, 115, 261 +}; +# endif -#define YYLAST 38 - - -static const short yytable[] = { 3, - 26, 1, 28, 11, 12, 13, 14, 15, 16, 31, - 32, 33, 21, 18, 27, 5, 6, 36, 19, 37, - 5, 6, 7, 8, 32, 33, 29, 30, 34, 33, - 35, 27, 39, 38, 41, 42, 17, 2 +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const unsigned char yyr1[] = +{ + 0, 13, 14, 15, 15, 16, 16, 17, 17, 18, + 18, 19, 19, 19, 19, 19, 19, 19, 19, 20, + 20, 21, 21, 22, 22 }; -static const short yycheck[] = { 0, - 14, 12, 15, 6, 7, 8, 9, 10, 11, 9, - 10, 11, 13, 3, 15, 3, 4, 31, 3, 32, - 3, 4, 5, 6, 10, 11, 7, 7, 3, 11, - 3, 32, 3, 7, 0, 0, 8, 0 +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const unsigned char yyr2[] = +{ + 0, 2, 1, 1, 1, 1, 2, 0, 1, 2, + 2, 3, 3, 3, 2, 7, 5, 3, 1, 1, + 3, 1, 3, 1, 2 }; -#define YYPURE 1 -/* -*-C-*- Note some compilers choke on comments on `#line' lines. */ -#line 3 "/usr/share/bison.simple" -/* This file comes from bison-1.28. */ +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const unsigned char yydefact[] = +{ + 7, 8, 0, 0, 18, 2, 1, 3, 4, 10, + 0, 5, 9, 0, 0, 7, 7, 7, 14, 6, + 0, 17, 23, 0, 11, 19, 21, 0, 12, 0, + 13, 0, 0, 7, 7, 24, 0, 16, 20, 22, + 0, 15 +}; -/* Skeleton output parser for bison, - Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. +/* YYDEFGOTO[NTERM-NUM]. */ +static const yysigned_char yydefgoto[] = +{ + -1, 2, 11, 12, 22, 27, 5, 24, 25, 26 +}; - 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. +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -16 +static const yysigned_char yypact[] = +{ + -10, -16, 14, 7, -2, -16, -16, -16, -16, -16, + 21, -16, -16, 13, 25, -10, -10, -10, -16, -16, + 22, 23, 7, 12, -16, -16, -16, 16, -16, 8, + -16, 28, 29, -10, -10, -16, 26, -16, -16, -16, + 32, -16 +}; - 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. +/* YYPGOTO[NTERM-NUM]. */ +static const yysigned_char yypgoto[] = +{ + -16, -16, 27, -16, 36, 0, -16, -16, -15, -14 +}; - 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. */ +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -1 +static const unsigned char yytable[] = +{ + 4, 28, 1, 30, 13, 14, 15, 16, 17, 18, + 7, 8, 9, 10, 6, 23, 20, 29, 38, 35, + 39, 33, 34, 35, 7, 8, 34, 35, 21, 31, + 32, 36, 37, 40, 29, 41, 3, 19 +}; -/* 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. */ +static const unsigned char yycheck[] = +{ + 0, 16, 12, 17, 6, 7, 8, 9, 10, 11, + 3, 4, 5, 6, 0, 15, 3, 17, 33, 11, + 34, 9, 10, 11, 3, 4, 10, 11, 3, 7, + 7, 3, 3, 7, 34, 3, 0, 10 +}; -/* 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. */ +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const unsigned char yystos[] = +{ + 0, 12, 14, 17, 18, 19, 0, 3, 4, 5, + 6, 15, 16, 6, 7, 8, 9, 10, 11, 15, + 3, 3, 17, 18, 20, 21, 22, 18, 21, 18, + 22, 7, 7, 9, 10, 11, 3, 3, 21, 22, + 7, 3 +}; -#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 <alloca.h> -#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 <malloc.h> +#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) +# define YYSIZE_T __SIZE_TYPE__ #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 <malloc.h> */ - #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 */ +#if ! defined (YYSIZE_T) && defined (size_t) +# define YYSIZE_T size_t #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 +#if ! defined (YYSIZE_T) +# if defined (__STDC__) || defined (__cplusplus) +# include <stddef.h> /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# endif +#endif +#if ! defined (YYSIZE_T) +# define YYSIZE_T unsigned int #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 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. +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* 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) \ + +#define YYBACKUP(Token, Value) \ do \ if (yychar == YYEMPTY && yylen == 1) \ - { yychar = (token), yylval = (value); \ - yychar1 = YYTRANSLATE (yychar); \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ YYPOPSTACK; \ goto yybackup; \ } \ else \ - { yyerror ("syntax error: cannot back up"); YYERROR; } \ + { \ + yyerror ("syntax error: cannot back up");\ + YYERROR; \ + } \ while (0) #define YYTERROR 1 #define YYERRCODE 256 -#ifndef YYPURE -#define YYLEX yylex() -#endif +/* YYLLOC_DEFAULT -- Compute the default location (before the actions + are run). */ -#ifdef YYPURE -#ifdef YYLSP_NEEDED -#ifdef YYLEX_PARAM -#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM) -#else -#define YYLEX yylex(&yylval, &yylloc) +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + ((Current).first_line = (Rhs)[1].first_line, \ + (Current).first_column = (Rhs)[1].first_column, \ + (Current).last_line = (Rhs)[N].last_line, \ + (Current).last_column = (Rhs)[N].last_column) #endif -#else /* not YYLSP_NEEDED */ + +/* YYLEX -- calling `yylex' with the right arguments. */ + #ifdef YYLEX_PARAM -#define YYLEX yylex(&yylval, YYLEX_PARAM) +# define YYLEX yylex (&yylval, YYLEX_PARAM) #else -#define YYLEX yylex(&yylval) -#endif -#endif /* not YYLSP_NEEDED */ +# define YYLEX yylex (&yylval) #endif -/* If nonreentrant, generate the variables here */ - -#ifndef YYPURE +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include <stdio.h> /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (0) + +# define YYDSYMPRINT(Args) \ +do { \ + if (yydebug) \ + yysymprint Args; \ +} while (0) + +# define YYDSYMPRINTF(Title, Token, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yysymprint (stderr, \ + Token, Value); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (0) -int yychar; /* the lookahead symbol */ -YYSTYPE yylval; /* the semantic value of the */ - /* lookahead symbol */ +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ -#ifdef YYLSP_NEEDED -YYLTYPE yylloc; /* location data for the lookahead */ - /* symbol */ +#if defined (__STDC__) || defined (__cplusplus) +static void +yy_stack_print (short *bottom, short *top) +#else +static void +yy_stack_print (bottom, top) + short *bottom; + short *top; #endif +{ + YYFPRINTF (stderr, "Stack now"); + for (/* Nothing. */; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} -int yynerrs; /* number of parse errors so far */ -#endif /* not YYPURE */ +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (0) -#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 */ +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ +#if defined (__STDC__) || defined (__cplusplus) +static void +yy_reduce_print (int yyrule) +#else +static void +yy_reduce_print (yyrule) + int yyrule; +#endif +{ + int yyi; + unsigned int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ", + yyrule - 1, yylno); + /* Print the symbols being reduced, and their result. */ + for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) + YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]); + YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]); +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (Rule); \ +} while (0) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YYDSYMPRINT(Args) +# define YYDSYMPRINTF(Title, Token, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ #ifndef YYINITDEPTH -#define YYINITDEPTH 200 +# 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). */ +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ -#if YYMAXDEPTH == 0 -#undef YYMAXDEPTH +#if defined (YYMAXDEPTH) && YYMAXDEPTH == 0 +# undef YYMAXDEPTH #endif #ifndef YYMAXDEPTH -#define YYMAXDEPTH 10000 +# 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; + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined (__GLIBC__) && defined (_STRING_H) +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +static YYSIZE_T +# if defined (__STDC__) || defined (__cplusplus) +yystrlen (const char *yystr) +# else +yystrlen (yystr) + const char *yystr; +# endif { - register char *f = from; - register char *t = to; - register int i = count; + register const char *yys = yystr; - while (i-- > 0) - *t++ = *f++; + while (*yys++ != '\0') + continue; + + return yys - yystr - 1; } +# endif +# endif + +# ifndef yystpcpy +# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +static char * +# if defined (__STDC__) || defined (__cplusplus) +yystpcpy (char *yydest, const char *yysrc) +# else +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +# endif +{ + register char *yyd = yydest; + register const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +#endif /* !YYERROR_VERBOSE */ -#else /* __cplusplus */ + + +#if YYDEBUG +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ -/* This is the most reliable way to avoid incompatibilities - in available built-in functions on various systems. */ +#if defined (__STDC__) || defined (__cplusplus) static void -__yy_memcpy (char *to, char *from, unsigned int count) +yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) +#else +static void +yysymprint (yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + YYSTYPE *yyvaluep; +#endif { - register char *t = to; - register char *f = from; - register int i = count; + /* Pacify ``unused variable'' warnings. */ + (void) yyvaluep; + + if (yytype < YYNTOKENS) + { + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); +# ifdef YYPRINT + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# endif + } + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); - while (i-- > 0) - *t++ = *f++; + switch (yytype) + { + default: + break; + } + YYFPRINTF (yyoutput, ")"); } +#endif /* ! YYDEBUG */ +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yydestruct (int yytype, YYSTYPE *yyvaluep) +#else +static void +yydestruct (yytype, yyvaluep) + int yytype; + YYSTYPE *yyvaluep; #endif -#endif +{ + /* Pacify ``unused variable'' warnings. */ + (void) yyvaluep; + + switch (yytype) + { + + default: + break; + } +} -#line 217 "/usr/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. */ +/* Prevent warnings from -Wmissing-prototypes. */ #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 +# if defined (__STDC__) || defined (__cplusplus) +int yyparse (void *YYPARSE_PARAM); +# else +int yyparse (); +# endif +#else /* ! YYPARSE_PARAM */ +#if defined (__STDC__) || defined (__cplusplus) int yyparse (void); +#else +int yyparse (); #endif -#endif +#endif /* ! YYPARSE_PARAM */ + + + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +# if defined (__STDC__) || defined (__cplusplus) +int yyparse (void *YYPARSE_PARAM) +# else +int yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +# endif +#else /* ! YYPARSE_PARAM */ +#if defined (__STDC__) || defined (__cplusplus) +int +yyparse (void) +#else int -yyparse(YYPARSE_PARAM_ARG) - YYPARSE_PARAM_DECL +yyparse () + +#endif +#endif { + /* The lookahead symbol. */ +int yychar; + +/* The semantic value of the lookahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + register int yystate; register int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Lookahead token as an internal (translated) token number. */ + int yytoken = 0; + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + short yyssa[YYINITDEPTH]; + short *yyss = yyssa; 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 */ + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + register YYSTYPE *yyvsp; - 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; + YYSIZE_T yystacksize = YYINITDEPTH; -#ifdef YYPURE - int yychar; - YYSTYPE yylval; - int yynerrs; -#ifdef YYLSP_NEEDED - YYLTYPE yylloc; -#endif -#endif + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; - YYSTYPE yyval; /* the variable used to return */ - /* semantic values from the action */ - /* routines */ + /* When reducing, the number of symbols on the RHS of the reduced + rule. */ int yylen; -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Starting parse\n"); -#endif + YYDPRINTF ((stderr, "Starting parse\n")); yystate = 0; yyerrstatus = 0; @@ -538,110 +888,96 @@ yyparse(YYPARSE_PARAM_ARG) so that they stay on the same level as the state stack. The wasted elements are never initialized. */ - yyssp = yyss - 1; + yyssp = yyss; 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: + goto yysetstate; - *++yyssp = yystate; +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. so pushing a state here evens the stacks. + */ + yyssp++; - 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 + yysetstate: + *yyssp = yystate; + if (yyss + yystacksize - 1 <= yyssp) + { /* Get the current used size of the three stacks, in elements. */ - int size = yyssp - yyss + 1; + YYSIZE_T yysize = 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 + { + /* 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; + + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. 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, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } #else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyoverflowlab; +# else /* 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; - } + if (YYMAXDEPTH <= yystacksize) + goto yyoverflowlab; yystacksize *= 2; - if (yystacksize > YYMAXDEPTH) + if (YYMAXDEPTH < yystacksize) 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 + + { + short *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyoverflowlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif #endif /* no yyoverflow */ - yyssp = yyss + size - 1; - yyvsp = yyvs + size - 1; -#ifdef YYLSP_NEEDED - yylsp = yyls + size - 1; -#endif + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Stack size increased to %d\n", yystacksize); -#endif - if (yyssp >= yyss + yystacksize - 1) + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) YYABORT; } -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Entering state %d\n", yystate); -#endif + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); goto yybackup; - yybackup: + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: /* Do appropriate processing given the current state. */ /* Read a lookahead token if we need one and don't already have one. */ @@ -650,413 +986,398 @@ yynewstate: /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; - if (yyn == YYFLAG) + if (yyn == YYPACT_NINF) 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. */ - + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ if (yychar == YYEMPTY) { -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Reading a token: "); -#endif + YYDPRINTF ((stderr, "Reading a token: ")); yychar = YYLEX; } - /* Convert token to internal form (in yychar1) for indexing tables with */ - - if (yychar <= 0) /* This means end of input. */ + if (yychar <= YYEOF) { - yychar1 = 0; - yychar = YYEOF; /* Don't call YYLEX any more */ - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Now at end of input.\n"); -#endif + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); } 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 + yytoken = YYTRANSLATE (yychar); + YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc); } - yyn += yychar1; - if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) 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 <= 0) { - if (yyn == YYFLAG) + if (yyn == 0 || yyn == YYTABLE_NINF) 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 + YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken])); /* 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--; + + /* 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: +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: yyn = yydefact[yystate]; if (yyn == 0) goto yyerrlab; + goto yyreduce; + -/* Do a reduction. yyn is the number of a rule to reduce with. */ +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ yyreduce: + /* yyn is the number of a rule to reduce with. */ yylen = yyr2[yyn]; - if (yylen > 0) - yyval = yyvsp[1-yylen]; /* implement default value of the action */ -#if YYDEBUG != 0 - if (yydebug) + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) { - int i; + case 6: +#line 138 "../../../../src/lib/krb5/krb/x-deltat.y" + { yyval.val = - yyvsp[0].val; ;} + break; + + case 9: +#line 140 "../../../../src/lib/krb5/krb/x-deltat.y" + { yyval.val = yyvsp[0].val; ;} + break; + + case 10: +#line 141 "../../../../src/lib/krb5/krb/x-deltat.y" + { YYERROR ;} + break; + + case 11: +#line 143 "../../../../src/lib/krb5/krb/x-deltat.y" + { DO (yyvsp[-2].val, 0, 0, yyvsp[0].val); ;} + break; + + case 12: +#line 144 "../../../../src/lib/krb5/krb/x-deltat.y" + { DO ( 0, yyvsp[-2].val, 0, yyvsp[0].val); ;} + break; + + case 13: +#line 145 "../../../../src/lib/krb5/krb/x-deltat.y" + { DO ( 0, 0, yyvsp[-2].val, yyvsp[0].val); ;} + break; + + case 14: +#line 146 "../../../../src/lib/krb5/krb/x-deltat.y" + { DO ( 0, 0, 0, yyvsp[-1].val); ;} + break; + + case 15: +#line 147 "../../../../src/lib/krb5/krb/x-deltat.y" + { DO (yyvsp[-6].val, yyvsp[-4].val, yyvsp[-2].val, yyvsp[0].val); ;} + break; + + case 16: +#line 148 "../../../../src/lib/krb5/krb/x-deltat.y" + { DO ( 0, yyvsp[-4].val, yyvsp[-2].val, yyvsp[0].val); ;} + break; + + case 17: +#line 149 "../../../../src/lib/krb5/krb/x-deltat.y" + { DO ( 0, yyvsp[-2].val, yyvsp[0].val, 0); ;} + break; + + case 18: +#line 150 "../../../../src/lib/krb5/krb/x-deltat.y" + { DO ( 0, 0, 0, yyvsp[0].val); ;} + break; + + case 20: +#line 155 "../../../../src/lib/krb5/krb/x-deltat.y" + { if (HOUR_NOT_OK(yyvsp[-2].val)) YYERROR; + DO_SUM(yyval.val, yyvsp[-2].val * 3600, yyvsp[0].val); ;} + break; + + case 22: +#line 159 "../../../../src/lib/krb5/krb/x-deltat.y" + { if (MIN_NOT_OK(yyvsp[-2].val)) YYERROR; + DO_SUM(yyval.val, yyvsp[-2].val * 60, yyvsp[0].val); ;} + break; + + case 23: +#line 162 "../../../../src/lib/krb5/krb/x-deltat.y" + { yyval.val = 0; ;} + break; - 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 138 "./x-deltat.y" -{ yyval.val = - yyvsp[0].val; ; - break;} -case 8: -#line 140 "./x-deltat.y" -{ yyval.val = yyvsp[0].val; ; - break;} -case 9: -#line 141 "./x-deltat.y" -{ YYERROR ; - break;} -case 10: -#line 143 "./x-deltat.y" -{ DO (yyvsp[-2].val, 0, 0, yyvsp[0].val); ; - break;} -case 11: -#line 144 "./x-deltat.y" -{ DO ( 0, yyvsp[-2].val, 0, yyvsp[0].val); ; - break;} -case 12: -#line 145 "./x-deltat.y" -{ DO ( 0, 0, yyvsp[-2].val, yyvsp[0].val); ; - break;} -case 13: -#line 146 "./x-deltat.y" -{ DO ( 0, 0, 0, yyvsp[-1].val); ; - break;} -case 14: -#line 147 "./x-deltat.y" -{ DO (yyvsp[-6].val, yyvsp[-4].val, yyvsp[-2].val, yyvsp[0].val); ; - break;} -case 15: -#line 148 "./x-deltat.y" -{ DO ( 0, yyvsp[-4].val, yyvsp[-2].val, yyvsp[0].val); ; - break;} -case 16: -#line 149 "./x-deltat.y" -{ DO ( 0, yyvsp[-2].val, yyvsp[0].val, 0); ; - break;} -case 17: -#line 150 "./x-deltat.y" -{ DO ( 0, 0, 0, yyvsp[0].val); ; - break;} -case 19: -#line 155 "./x-deltat.y" -{ if (HOUR_NOT_OK(yyvsp[-2].val)) YYERROR; - DO_SUM(yyval.val, yyvsp[-2].val * 3600, yyvsp[0].val); ; - break;} -case 21: -#line 159 "./x-deltat.y" -{ if (MIN_NOT_OK(yyvsp[-2].val)) YYERROR; - DO_SUM(yyval.val, yyvsp[-2].val * 60, yyvsp[0].val); ; - break;} -case 22: -#line 162 "./x-deltat.y" -{ yyval.val = 0; ; - break;} -} - /* the action file gets copied in in place of this dollarsign */ -#line 543 "/usr/share/bison.simple" +/* Line 993 of yacc.c. */ +#line 1156 "../../../../src/lib/krb5/krb/deltat.c" 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 + + YY_STACK_PRINT (yyss, yyssp); *++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. */ + /* 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 = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) yystate = yytable[yystate]; else - yystate = yydefgoto[yyn - YYNTBASE]; + yystate = yydefgoto[yyn - YYNTOKENS]; goto yynewstate; -yyerrlab: /* here on detecting error */ - if (! yyerrstatus) - /* If not already recovering from an error, report this error. */ +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) { ++yynerrs; - -#ifdef YYERROR_VERBOSE +#if YYERROR_VERBOSE yyn = yypact[yystate]; - if (yyn > YYFLAG && yyn < YYLAST) + if (YYPACT_NINF < yyn && 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) + YYSIZE_T yysize = 0; + int yytype = YYTRANSLATE (yychar); + const char* yyprefix; + char *yymsg; + int yyx; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 0; + + yyprefix = ", expecting "; + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]); + yycount += 1; + if (yycount == 5) + { + yysize = 0; + break; + } + } + yysize += (sizeof ("syntax error, unexpected ") + + yystrlen (yytname[yytype])); + yymsg = (char *) YYSTACK_ALLOC (yysize); + if (yymsg != 0) { - strcpy(msg, "parse error"); + char *yyp = yystpcpy (yymsg, "syntax error, unexpected "); + yyp = yystpcpy (yyp, yytname[yytype]); - if (count < 5) + if (yycount < 5) { - count = 0; - for (x = (yyn < 0 ? -yyn : 0); - x < (sizeof(yytname) / sizeof(char *)); x++) - if (yycheck[x + yyn] == x) + yyprefix = ", expecting "; + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) { - strcat(msg, count == 0 ? ", expecting `" : " or `"); - strcat(msg, yytname[x]); - strcat(msg, "'"); - count++; + yyp = yystpcpy (yyp, yyprefix); + yyp = yystpcpy (yyp, yytname[yyx]); + yyprefix = " or "; } } - yyerror(msg); - free(msg); + yyerror (yymsg); + YYSTACK_FREE (yymsg); } else - yyerror ("parse error; also virtual memory exceeded"); + yyerror ("syntax error; also virtual memory exhausted"); } else #endif /* YYERROR_VERBOSE */ - yyerror("parse error"); + yyerror ("syntax 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 + /* If just tried and failed to reuse lookahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* If at end of input, pop the error token, + then the rest of the stack, then return failure. */ + if (yychar == YYEOF) + for (;;) + { + YYPOPSTACK; + if (yyssp == yyss) + YYABORT; + YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); + yydestruct (yystos[*yyssp], yyvsp); + } + } + else + { + YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc); + yydestruct (yytoken, &yylval); + yychar = YYEMPTY; - yychar = YYEMPTY; + } } - /* Else will try to reuse lookahead token - after shifting the error token. */ - - yyerrstatus = 3; /* Each real token shifted decrements this */ + /* Else will try to reuse lookahead token after shifting the error + token. */ + goto yyerrlab1; - goto yyerrhandle; -yyerrdefault: /* current state does not do anything special for the error token. */ +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: -#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; +#ifdef __GNUC__ + /* Pacify GCC when the user code never invokes YYERROR and the label + yyerrorlab therefore never appears in user code. */ + if (0) + goto yyerrorlab; #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 + yyvsp -= yylen; + yyssp -= yylen; + yystate = *yyssp; + goto yyerrlab1; -#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: +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ - yyn = yypact[yystate]; - if (yyn == YYFLAG) - goto yyerrdefault; + for (;;) + { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } - yyn += YYTERROR; - if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) - goto yyerrdefault; + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; - yyn = yytable[yyn]; - if (yyn < 0) - { - if (yyn == YYFLAG) - goto yyerrpop; - yyn = -yyn; - goto yyreduce; + YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); + yydestruct (yystos[yystate], yyvsp); + YYPOPSTACK; + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); } - else if (yyn == 0) - goto yyerrpop; if (yyn == YYFINAL) YYACCEPT; -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Shifting error token, "); -#endif + YYDPRINTF ((stderr, "Shifting error token, ")); *++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); + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*----------------------------------------------. +| yyoverflowlab -- parser overflow comes here. | +`----------------------------------------------*/ +yyoverflowlab: + yyerror ("parser stack overflow"); + yyresult = 2; + /* Fall through. */ #endif - } - return 0; - yyabortlab: - /* YYABORT comes here. */ - if (yyfree_stacks) - { - free (yyss); - free (yyvs); -#ifdef YYLSP_NEEDED - free (yyls); +yyreturn: +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); #endif - } - return 1; + return yyresult; } -#line 165 "./x-deltat.y" + + +#line 165 "../../../../src/lib/krb5/krb/x-deltat.y" static int @@ -1105,7 +1426,7 @@ mylex (krb5_int32 *intp, char **pp) case '\n': while (isspace ((int) *P)) P++; - return WS; + return tok_WS; default: return YYEOF; } @@ -1122,3 +1443,5 @@ krb5_string_to_deltat(char *string, krb5_deltat *deltatp) *deltatp = p.delta; return 0; } + + diff --git a/src/lib/krb5/krb/gic_keytab.c b/src/lib/krb5/krb/gic_keytab.c index a3cd443..ba704e6 100644 --- a/src/lib/krb5/krb/gic_keytab.c +++ b/src/lib/krb5/krb/gic_keytab.c @@ -127,7 +127,9 @@ krb5_get_init_creds_keytab(krb5_context context, krb5_creds *creds, krb5_princip /* if the master is unreachable, return the error from the slave we were able to contact */ - if ((ret2 == KRB5_KDC_UNREACH) || (ret2 == KRB5_REALM_CANT_RESOLVE)) + if ((ret2 == KRB5_KDC_UNREACH) || + (ret2 == KRB5_REALM_CANT_RESOLVE) || + (ret2 == KRB5_REALM_UNKNOWN)) goto cleanup; ret = ret2; diff --git a/src/lib/krb5/krb/gic_pwd.c b/src/lib/krb5/krb/gic_pwd.c index de0f47d..f2837ef 100644 --- a/src/lib/krb5/krb/gic_pwd.c +++ b/src/lib/krb5/krb/gic_pwd.c @@ -104,7 +104,7 @@ krb5_get_init_creds_password(krb5_context context, krb5_creds *creds, krb5_princ pw0.data = pw0array; - if (password) { + if (password && password[0]) { if ((pw0.length = strlen(password)) > sizeof(pw0array)) { ret = EINVAL; goto cleanup; diff --git a/src/lib/krb5/krb/parse.c b/src/lib/krb5/krb/parse.c index 50f7b22..cd23d14 100644 --- a/src/lib/krb5/krb/parse.c +++ b/src/lib/krb5/krb/parse.c @@ -73,8 +73,8 @@ krb5_parse_name(krb5_context context, const char *name, krb5_principal *nprincip const char *parsed_realm = NULL; int fcompsize[FCOMPNUM]; unsigned int realmsize = 0; - static char *default_realm = NULL; - static int default_realm_size = 0; + char *default_realm = NULL; + int default_realm_size = 0; char *tmpdata; krb5_principal principal; krb5_error_code retval; @@ -211,6 +211,7 @@ krb5_parse_name(krb5_context context, const char *name, krb5_principal *nprincip if (tmpdata == 0) { krb5_xfree(principal->data); krb5_xfree(principal); + krb5_xfree(default_realm); return ENOMEM; } krb5_princ_set_realm_length(context, principal, realmsize); @@ -224,6 +225,7 @@ krb5_parse_name(krb5_context context, const char *name, krb5_principal *nprincip krb5_xfree(krb5_princ_realm(context, principal)->data); krb5_xfree(principal->data); krb5_xfree(principal); + krb5_xfree(default_realm); return(ENOMEM); } krb5_princ_component(context, principal, i)->data = tmpdata2; @@ -276,6 +278,7 @@ krb5_parse_name(krb5_context context, const char *name, krb5_principal *nprincip principal->magic = KV5M_PRINCIPAL; principal->realm.magic = KV5M_DATA; *nprincipal = principal; + krb5_xfree(default_realm); return(0); } diff --git a/src/lib/krb5/krb/unparse.c b/src/lib/krb5/krb/unparse.c index 6f1a3c9..badb5bf 100644 --- a/src/lib/krb5/krb/unparse.c +++ b/src/lib/krb5/krb/unparse.c @@ -26,7 +26,7 @@ * * krb5_unparse_name() routine * - * Rewritten by Theodore Ts'o to propoerly unparse principal names + * Rewritten by Theodore Ts'o to properly unparse principal names * which have the component or realm separator as part of one of their * components. */ @@ -66,7 +66,7 @@ krb5_unparse_name_ext(krb5_context context, krb5_const_principal principal, regi krb5_int32 nelem; register unsigned int totalsize = 0; - if (!principal) + if (!principal || !name) return KRB5_PARSE_MALFORMED; cp = krb5_princ_realm(context, principal)->data; @@ -99,17 +99,17 @@ krb5_unparse_name_ext(krb5_context context, krb5_const_principal principal, regi * We need only n-1 seperators for n components, but we need * an extra byte for the NULL at the end. */ - if (*name) { - if (*size < (totalsize)) { - *size = totalsize; - *name = realloc(*name, totalsize); - } - } else { - *name = malloc(totalsize); - if (size) - *size = totalsize; - } - + if (size) { + if (*name && (*size < totalsize)) { + *name = realloc(*name, totalsize); + } else { + *name = malloc(totalsize); + } + *size = totalsize; + } else { + *name = malloc(totalsize); + } + if (!*name) return ENOMEM; @@ -191,7 +191,8 @@ krb5_unparse_name_ext(krb5_context context, krb5_const_principal principal, regi krb5_error_code KRB5_CALLCONV krb5_unparse_name(krb5_context context, krb5_const_principal principal, register char **name) { - *name = NULL; + if (name) /* name == NULL will return error from _ext */ + *name = NULL; return(krb5_unparse_name_ext(context, principal, name, NULL)); } diff --git a/src/lib/krb5/krb/x-deltat.y b/src/lib/krb5/krb/x-deltat.y index 819602f..ccd956d 100644 --- a/src/lib/krb5/krb/x-deltat.y +++ b/src/lib/krb5/krb/x-deltat.y @@ -125,7 +125,7 @@ static int yyparse (void *); %union { int val; } %token <val> NUM LONGNUM OVERFLOW -%token '-' ':' 'd' 'h' 'm' 's' WS +%token '-' ':' 'd' 'h' 'm' 's' tok_WS %type <val> num opt_hms opt_ms opt_s wsnum posnum @@ -136,9 +136,9 @@ static int yyparse (void *); start: deltat; posnum: NUM | LONGNUM ; num: posnum | '-' posnum { $$ = - $2; } ; -ws: /* nothing */ | WS ; +ws: /* nothing */ | tok_WS ; wsnum: ws num { $$ = $2; } - | ws OVERFLOW { YYERROR }; + | ws OVERFLOW { YYERROR; }; deltat: wsnum 'd' opt_hms { DO ($1, 0, 0, $3); } | wsnum 'h' opt_ms { DO ( 0, $1, 0, $3); } @@ -210,7 +210,7 @@ mylex (krb5_int32 *intp, char **pp) case '\n': while (isspace ((int) *P)) P++; - return WS; + return tok_WS; default: return YYEOF; } diff --git a/src/lib/krb5/krb5_libinit.c b/src/lib/krb5/krb5_libinit.c index 8290c14..ece79cf 100644 --- a/src/lib/krb5/krb5_libinit.c +++ b/src/lib/krb5/krb5_libinit.c @@ -69,9 +69,11 @@ void krb5int_lib_fini(void) if (!INITIALIZER_RAN(krb5int_lib_init) || PROGRAM_EXITING()) return; - krb5int_rc_terminate(); - krb5int_kt_finalize(); + k5_mutex_destroy(&krb5int_us_time_mutex); + krb5int_cc_finalize(); + krb5int_kt_finalize(); + krb5int_rc_terminate(); #if defined(_WIN32) || defined(USE_CCAPI) krb5_stdcc_shutdown(); diff --git a/src/lib/krb5/libkrb5.exports b/src/lib/krb5/libkrb5.exports index 204296a..f16b45c 100644 --- a/src/lib/krb5/libkrb5.exports +++ b/src/lib/krb5/libkrb5.exports @@ -458,6 +458,7 @@ krb5_init_keyblock krb5_init_secure_context krb5_internalize_opaque krb5_is_permitted_enctype +krb5_is_thread_safe krb5_kdc_rep_decrypt_proc krb5_kt_add_entry krb5_kt_close diff --git a/src/lib/krb5/os/ChangeLog b/src/lib/krb5/os/ChangeLog index ea1a5a7..1823a2f 100644 --- a/src/lib/krb5/os/ChangeLog +++ b/src/lib/krb5/os/ChangeLog @@ -1,3 +1,48 @@ +2005-03-22 Tom Yu <tlyu@mit.edu> + + * dnsglue.h: Define ns_rr_class to ns_rr_cl if ns_rr_class doesn't + exist. + +2005-03-05 Jeffrey Altman <jaltman@mit.edu> + + * sn2princ.c (krb5_sname_to_principal): + conditionalize the use of reverse dns lookups. The default + is to use the existing behavior. rdns can be disabled by + specifying [libdefaults] rdns=false + +2005-01-12 Tom Yu <tlyu@mit.edu> + + * dnsglue.c (krb5int_dns_fini): Reorder to make more correct. + (krb5int_dns_init): Rework error handling. Call res_ndestroy() or + res_nclose() as appropriate to avoid leaking resources allocated + by res_ninit(). + +2005-01-03 Jeffrey Altman <jaltman@mit.edu> + + * thread_safe.c: (new file) krb5_is_thread_safe() + +2004-12-08 Ken Raeburn <raeburn@mit.edu> + + * accessor.c (krb5int_accessor): Set new field use_dns_kdc. + +2004-12-06 Tom Yu <tlyu@mit.edu> + + * locate_kdc.c (krb5_locate_srv_dns_1): Don't compile if + KRB5_DNS_LOOKUP is not defined. + +2004-11-19 Ken Raeburn <raeburn@mit.edu> + + * locate_kdc.c (krb5int_add_host_to_list): If debugging, log the + requested family and socket type. If AI_NUMERICSERV is defined, + set it in ai_flags. If getaddrinfo returns an error with + debugging enabled, log the error. + (krb5_locate_srv_conf_1): When logging an error from + add_host_to_list, include the corresponding error string. + + * t_locate_kdc.c: Include port-sockets.h, instead of sys/socket.h, + netdb.h, netinet/in.h, and arpa/inet.h. + * Makefile.in ($(OUTPRE)t_locate_kdc.exe): New target. + 2004-10-20 Ken Raeburn <raeburn@mit.edu> * locate_kdc.c: Include stdarg.h. diff --git a/src/lib/krb5/os/Makefile.in b/src/lib/krb5/os/Makefile.in index 66d0dcd..3a0706b 100644 --- a/src/lib/krb5/os/Makefile.in +++ b/src/lib/krb5/os/Makefile.in @@ -49,6 +49,7 @@ STLIBOBJS= \ send524.o \ sendto_kdc.o \ sn2princ.o \ + thread_safe.o \ timeofday.o \ toffset.o \ unlck_file.o \ @@ -94,6 +95,7 @@ OBJS= \ $(OUTPRE)send524.$(OBJEXT) \ $(OUTPRE)sendto_kdc.$(OBJEXT) \ $(OUTPRE)sn2princ.$(OBJEXT) \ + $(OUTPRE)thread_safe.$(OBJEXT) \ $(OUTPRE)timeofday.$(OBJEXT) \ $(OUTPRE)toffset.$(OBJEXT) \ $(OUTPRE)unlck_file.$(OBJEXT) \ @@ -139,6 +141,7 @@ SRCS= \ $(srcdir)/send524.c \ $(srcdir)/sendto_kdc.c \ $(srcdir)/sn2princ.c \ + $(srcdir)/thread_safe.c \ $(srcdir)/timeofday.c \ $(srcdir)/toffset.c \ $(srcdir)/unlck_file.c \ @@ -185,6 +188,10 @@ t_locate_kdc: t_locate_kdc.o $(CC_LINK) $(ALL_CFLAGS) -o t_locate_kdc t_locate_kdc.o \ $(KRB5_BASE_LIBS) t_locate_kdc.o: t_locate_kdc.c locate_kdc.c +$(OUTPRE)t_locate_kdc.exe: $(OUTPRE)t_locate_kdc.obj \ + $(OUTPRE)dnssrv.obj $(OUTPRE)dnsglue.obj \ + $(KLIB) $(PLIB) $(CLIB) $(SLIB) + link $(EXE_LINKOPTS) -out:$@ $** ws2_32.lib $(DNSLIBS) LCLINT=lclint LCLINTOPTS= -warnposix \ @@ -477,6 +484,12 @@ sn2princ.so sn2princ.po $(OUTPRE)sn2princ.$(OBJEXT): sn2princ.c $(SRCTOP)/includ $(BUILDTOP)/include/krb5.h $(COM_ERR_DEPS) $(BUILDTOP)/include/profile.h \ $(SRCTOP)/include/port-sockets.h $(SRCTOP)/include/socket-utils.h \ $(SRCTOP)/include/krb5/kdb.h $(SRCTOP)/include/fake-addrinfo.h +thread_safe.so thread_safe.po $(OUTPRE)thread_safe.$(OBJEXT): thread_safe.c $(SRCTOP)/include/k5-int.h \ + $(BUILDTOP)/include/krb5/osconf.h $(BUILDTOP)/include/krb5/autoconf.h \ + $(SRCTOP)/include/k5-platform.h $(SRCTOP)/include/k5-thread.h \ + $(BUILDTOP)/include/krb5.h $(COM_ERR_DEPS) $(BUILDTOP)/include/profile.h \ + $(SRCTOP)/include/port-sockets.h $(SRCTOP)/include/socket-utils.h \ + $(SRCTOP)/include/krb5/kdb.h timeofday.so timeofday.po $(OUTPRE)timeofday.$(OBJEXT): timeofday.c $(SRCTOP)/include/k5-int.h \ $(BUILDTOP)/include/krb5/osconf.h $(BUILDTOP)/include/krb5/autoconf.h \ $(SRCTOP)/include/k5-platform.h $(SRCTOP)/include/k5-thread.h \ @@ -510,9 +523,9 @@ write_msg.so write_msg.po $(OUTPRE)write_msg.$(OBJEXT): write_msg.c $(SRCTOP)/in t_an_to_ln.so t_an_to_ln.po $(OUTPRE)t_an_to_ln.$(OBJEXT): t_an_to_ln.c $(BUILDTOP)/include/krb5.h \ $(COM_ERR_DEPS) t_gifconf.so t_gifconf.po $(OUTPRE)t_gifconf.$(OBJEXT): t_gifconf.c -t_locate_kdc.so t_locate_kdc.po $(OUTPRE)t_locate_kdc.$(OBJEXT): t_locate_kdc.c $(COM_ERR_DEPS) \ - locate_kdc.c $(SRCTOP)/include/fake-addrinfo.h $(SRCTOP)/include/port-sockets.h \ - $(BUILDTOP)/include/krb5/autoconf.h $(SRCTOP)/include/socket-utils.h \ +t_locate_kdc.so t_locate_kdc.po $(OUTPRE)t_locate_kdc.$(OBJEXT): t_locate_kdc.c $(SRCTOP)/include/port-sockets.h \ + $(BUILDTOP)/include/krb5/autoconf.h $(COM_ERR_DEPS) \ + locate_kdc.c $(SRCTOP)/include/fake-addrinfo.h $(SRCTOP)/include/socket-utils.h \ $(SRCTOP)/include/k5-platform.h $(SRCTOP)/include/k5-thread.h \ $(SRCTOP)/include/k5-int.h $(BUILDTOP)/include/krb5/osconf.h \ $(BUILDTOP)/include/krb5.h $(BUILDTOP)/include/profile.h \ diff --git a/src/lib/krb5/os/accessor.c b/src/lib/krb5/os/accessor.c index 4e907b1..078e036 100644 --- a/src/lib/krb5/os/accessor.c +++ b/src/lib/krb5/os/accessor.c @@ -45,9 +45,11 @@ krb5int_accessor(krb5int_access *internals, krb5_int32 version) #ifdef KRB5_DNS_LOOKUP internals_temp.make_srv_query_realm = krb5int_make_srv_query_realm; internals_temp.free_srv_dns_data = krb5int_free_srv_dns_data; + internals_temp.use_dns_kdc = _krb5_use_dns_kdc; #else internals_temp.make_srv_query_realm = 0; internals_temp.free_srv_dns_data = 0; + internals_temp.use_dns_kdc = 0; #endif #ifdef KRB5_KRB4_COMPAT internals_temp.krb_life_to_time = krb5int_krb_life_to_time; diff --git a/src/lib/krb5/os/dnsglue.c b/src/lib/krb5/os/dnsglue.c index dba1b86..5d2db36 100644 --- a/src/lib/krb5/os/dnsglue.c +++ b/src/lib/krb5/os/dnsglue.c @@ -65,7 +65,7 @@ krb5int_dns_init(struct krb5int_dns_state **dsp, struct __res_state statbuf; #endif struct krb5int_dns_state *ds; - int len; + int len, ret; size_t nextincr, maxincr; unsigned char *p; @@ -73,6 +73,7 @@ krb5int_dns_init(struct krb5int_dns_state **dsp, if (ds == NULL) return -1; + ret = -1; ds->nclass = nclass; ds->ntype = ntype; ds->ansp = NULL; @@ -86,8 +87,8 @@ krb5int_dns_init(struct krb5int_dns_state **dsp, #endif #if HAVE_RES_NSEARCH - len = res_ninit(&statbuf); - if (len < 0) + ret = res_ninit(&statbuf); + if (ret < 0) return -1; #endif @@ -96,8 +97,8 @@ krb5int_dns_init(struct krb5int_dns_state **dsp, ? malloc(nextincr) : realloc(ds->ansp, nextincr); if (p == NULL && ds->ansp != NULL) { - free(ds->ansp); - return -1; + ret = -1; + goto errout; } ds->ansp = p; ds->ansmax = nextincr; @@ -109,28 +110,45 @@ krb5int_dns_init(struct krb5int_dns_state **dsp, len = res_search(host, ds->nclass, ds->ntype, ds->ansp, ds->ansmax); #endif - if (len > maxincr) - return -1; + if (len > maxincr) { + ret = -1; + goto errout; + } while (nextincr < len) nextincr *= 2; if (len < 0 || nextincr > maxincr) { - free(ds->ansp); - return -1; + ret = -1; + goto errout; } } while (len > ds->ansmax); ds->anslen = len; #if HAVE_NS_INITPARSE - len = ns_initparse(ds->ansp, ds->anslen, &ds->msg); + ret = ns_initparse(ds->ansp, ds->anslen, &ds->msg); #else - len = initparse(ds); + ret = initparse(ds); #endif - if (len < 0) { - free(ds->ansp); - return -1; + if (ret < 0) + goto errout; + + ret = 0; + +errout: +#if HAVE_RES_NSEARCH +#if HAVE_RES_NDESTROY + res_ndestroy(&statbuf); +#else + res_nclose(&statbuf); +#endif +#endif + if (ret < 0) { + if (ds->ansp != NULL) { + free(ds->ansp); + ds->ansp = NULL; + } } - return 0; + return ret; } #if HAVE_NS_INITPARSE @@ -190,10 +208,11 @@ int krb5int_dns_expand(struct krb5int_dns_state *ds, void krb5int_dns_fini(struct krb5int_dns_state *ds) { + if (ds == NULL) + return; if (ds->ansp != NULL) free(ds->ansp); - if (ds != NULL) - free(ds); + free(ds); } /* diff --git a/src/lib/krb5/os/dnsglue.h b/src/lib/krb5/os/dnsglue.h index d2d1927..9fa293c 100644 --- a/src/lib/krb5/os/dnsglue.h +++ b/src/lib/krb5/os/dnsglue.h @@ -80,6 +80,15 @@ #endif +#if HAVE_NS_INITPARSE +/* + * Solaris 7 has ns_rr_cl rather than ns_rr_class. + */ +#if !defined(ns_rr_class) && defined(ns_rr_cl) +#define ns_rr_class ns_rr_cl +#endif +#endif + #if HAVE_RES_NSEARCH /* * Some BIND 8 / BIND 9 implementations disable the BIND 4 style diff --git a/src/lib/krb5/os/locate_kdc.c b/src/lib/krb5/os/locate_kdc.c index 25334dd..1fafbca 100644 --- a/src/lib/krb5/os/locate_kdc.c +++ b/src/lib/krb5/os/locate_kdc.c @@ -260,17 +260,24 @@ krb5int_add_host_to_list (struct addrlist *lp, const char *hostname, int err; char portbuf[10], secportbuf[10]; - Tprintf ("adding hostname %s, ports %d,%d\n", hostname, - ntohs (port), ntohs (secport)); + Tprintf ("adding hostname %s, ports %d,%d, family %d, socktype %d\n", + hostname, ntohs (port), ntohs (secport), + family, socktype); memset(&hint, 0, sizeof(hint)); hint.ai_family = family; hint.ai_socktype = socktype; +#ifdef AI_NUMERICSERV + hint.ai_flags = AI_NUMERICSERV; +#endif sprintf(portbuf, "%d", ntohs(port)); sprintf(secportbuf, "%d", ntohs(secport)); err = getaddrinfo (hostname, portbuf, &hint, &addrs); - if (err) + if (err) { + Tprintf ("\tgetaddrinfo(\"%s\", \"%s\", ...)\n\treturns %d: %s\n", + hostname, portbuf, err, gai_strerror (err)); return translate_ai_error (err); + } anext = 0; for (a = addrs; a != 0 && err == 0; a = anext) { anext = a->ai_next; @@ -460,7 +467,8 @@ krb5_locate_srv_conf_1(krb5_context context, const krb5_data *realm, SOCK_STREAM, family); } if (code) { - Tprintf ("error %d returned from add_host_to_list\n", code); + Tprintf ("error %d (%s) returned from add_host_to_list\n", code, + error_message (code)); if (hostlist) profile_free_list (hostlist); if (masterlist) @@ -495,6 +503,7 @@ krb5_locate_srv_conf(krb5_context context, const krb5_data *realm, } #endif +#ifdef KRB5_DNS_LOOKUP static krb5_error_code krb5_locate_srv_dns_1 (const krb5_data *realm, const char *service, @@ -534,8 +543,9 @@ krb5_locate_srv_dns_1 (const krb5_data *realm, (strcmp("_tcp", protocol) ? SOCK_DGRAM : SOCK_STREAM), family); - if (code) + if (code) { break; + } if (entry == head) { free(entry->host); free(entry); @@ -548,6 +558,7 @@ krb5_locate_srv_dns_1 (const krb5_data *realm, krb5int_free_srv_dns_data(head); return code; } +#endif /* * Wrapper function for the two backends diff --git a/src/lib/krb5/os/sn2princ.c b/src/lib/krb5/os/sn2princ.c index 240f14e..dea1b3c 100644 --- a/src/lib/krb5/os/sn2princ.c +++ b/src/lib/krb5/os/sn2princ.c @@ -36,6 +36,31 @@ #include <sys/param.h> #endif +#if !defined(DEFAULT_RDNS_LOOKUP) +#define DEFAULT_RDNS_LOOKUP 1 +#endif + +static int +maybe_use_reverse_dns (krb5_context context, int defalt) +{ + krb5_error_code code; + char * value = NULL; + int use_rdns = 0; + + code = profile_get_string(context->profile, "libdefaults", + "rdns", 0, 0, &value); + if (code) + return defalt; + + if (value == 0) + return defalt; + + use_rdns = _krb5_conf_boolean(value); + profile_release_string(value); + return use_rdns; +} + + krb5_error_code KRB5_CALLCONV krb5_sname_to_principal(krb5_context context, const char *hostname, const char *sname, krb5_int32 type, krb5_principal *ret_princ) { @@ -93,26 +118,29 @@ krb5_sname_to_principal(krb5_context context, const char *hostname, const char * freeaddrinfo(ai); return ENOMEM; } - /* - * Do a reverse resolution to get the full name, just in - * case there's some funny business going on. If there - * isn't an in-addr record, give up. - */ - /* XXX: This is *so* bogus. There are several cases where - this won't get us the canonical name of the host, but - this is what we've trained people to expect. We'll - probably fix it at some point, but let's try to - preserve the current behavior and only shake things up - once when it comes time to fix this lossage. */ - err = getnameinfo(ai->ai_addr, ai->ai_addrlen, - hnamebuf, sizeof(hnamebuf), 0, 0, NI_NAMEREQD); - freeaddrinfo(ai); - if (err == 0) { - free(remote_host); - remote_host = strdup(hnamebuf); - if (!remote_host) - return ENOMEM; - } + + if (maybe_use_reverse_dns(context, DEFAULT_RDNS_LOOKUP)) { + /* + * Do a reverse resolution to get the full name, just in + * case there's some funny business going on. If there + * isn't an in-addr record, give up. + */ + /* XXX: This is *so* bogus. There are several cases where + this won't get us the canonical name of the host, but + this is what we've trained people to expect. We'll + probably fix it at some point, but let's try to + preserve the current behavior and only shake things up + once when it comes time to fix this lossage. */ + err = getnameinfo(ai->ai_addr, ai->ai_addrlen, + hnamebuf, sizeof(hnamebuf), 0, 0, NI_NAMEREQD); + freeaddrinfo(ai); + if (err == 0) { + free(remote_host); + remote_host = strdup(hnamebuf); + if (!remote_host) + return ENOMEM; + } + } } else /* type == KRB5_NT_UNKNOWN */ { remote_host = strdup(hostname); } diff --git a/src/lib/krb5/os/t_locate_kdc.c b/src/lib/krb5/os/t_locate_kdc.c index 03dac07..7d5d554 100644 --- a/src/lib/krb5/os/t_locate_kdc.c +++ b/src/lib/krb5/os/t_locate_kdc.c @@ -1,11 +1,7 @@ #include <stdio.h> #include <string.h> #include <sys/types.h> -#include <sys/socket.h> -#include <netdb.h> -#include <netinet/in.h> -#include <arpa/inet.h> - +#include "port-sockets.h" #include <com_err.h> #define TEST diff --git a/src/lib/kdb/setup_mkey.c b/src/lib/krb5/os/thread_safe.c index 61f1ef3..faac234 100644 --- a/src/lib/kdb/setup_mkey.c +++ b/src/lib/krb5/os/thread_safe.c @@ -1,7 +1,7 @@ /* - * lib/kdb/setup_mkey.c + * lib/krb5/os/thread_safec * - * Copyright 1990 by the Massachusetts Institute of Technology. + * Copyright 2005 by the Massachusetts Institute of Technology. * All Rights Reserved. * * Export of this software from the United States of America may @@ -24,51 +24,17 @@ * or implied warranty. * * - * krb5_kdb_setup_mkey() + * krb5_is_thread_safe() function. */ #include "k5-int.h" -/* - * Given a key name and a realm name, construct a principal which can be used - * to fetch the master key from the database. - * - * If the key name is NULL, the default key name will be used. - */ - -#define REALM_SEP_STRING "@" - -krb5_error_code -krb5_db_setup_mkey_name(context, keyname, realm, fullname, principal) - krb5_context context; - const char *keyname; - const char *realm; - char **fullname; - krb5_principal *principal; +krb5_boolean KRB5_CALLCONV +krb5_is_thread_safe(void) { - krb5_error_code retval; - size_t keylen; - size_t rlen = strlen(realm); - char *fname; - - if (!keyname) - keyname = KRB5_KDB_M_NAME; /* XXX external? */ - - keylen = strlen(keyname); - - fname = malloc(keylen+rlen+strlen(REALM_SEP_STRING)+1); - if (!fname) - return ENOMEM; - - strcpy(fname, keyname); - strcat(fname, REALM_SEP_STRING); - strcat(fname, realm); - - if ((retval = krb5_parse_name(context, fname, principal))) - return retval; - if (fullname) - *fullname = fname; - else - free(fname); +#if defined(ENABLE_THREADS) + return 1; +#else return 0; +#endif } diff --git a/src/lib/krb5/rcache/ChangeLog b/src/lib/krb5/rcache/ChangeLog index 24b04b0..597ce15 100644 --- a/src/lib/krb5/rcache/ChangeLog +++ b/src/lib/krb5/rcache/ChangeLog @@ -1,3 +1,8 @@ +2005-01-15 Jeffrey Altman <jaltman@mit.edu> + + * rc_dfl.c: Move the extraction of the struct dfl_data + from the krb5_rcache after obtaining the lock, not before. + 2004-08-03 Ken Raeburn <raeburn@mit.edu> * rc-int.h (struct _krb5_rc_ops): Add new member, diff --git a/src/lib/krb5/rcache/rc_dfl.c b/src/lib/krb5/rcache/rc_dfl.c index 586716a..a334002 100644 --- a/src/lib/krb5/rcache/rc_dfl.c +++ b/src/lib/krb5/rcache/rc_dfl.c @@ -182,10 +182,10 @@ krb5_rc_dfl_get_span(krb5_context context, krb5_rcache id, krb5_error_code err; struct dfl_data *t; - t = (struct dfl_data *) id->data; err = k5_mutex_lock(&id->lock); if (err) return err; + t = (struct dfl_data *) id->data; *lifespan = t->lifespan; k5_mutex_unlock(&id->lock); return 0; @@ -514,7 +514,6 @@ krb5_error_code KRB5_CALLCONV krb5_rc_dfl_recover_or_init(krb5_context context, krb5_rcache id, krb5_deltat lifespan) { - struct dfl_data *t = (struct dfl_data *)id->data; krb5_error_code retval; retval = k5_mutex_lock(&id->lock); @@ -561,7 +560,7 @@ krb5_error_code KRB5_CALLCONV krb5_rc_dfl_store(krb5_context context, krb5_rcache id, krb5_donot_replay *rep) { krb5_error_code ret; - struct dfl_data *t = (struct dfl_data *)id->data; + struct dfl_data *t; krb5_int32 now; ret = krb5_timeofday(context, &now); @@ -582,6 +581,7 @@ krb5_rc_dfl_store(krb5_context context, krb5_rcache id, krb5_donot_replay *rep) case 0: break; default: /* wtf? */ ; } + t = (struct dfl_data *)id->data; #ifndef NOIOSTUFF ret = krb5_rc_io_store(context, t, rep); if (ret) { diff --git a/src/lib/krb5_32.def b/src/lib/krb5_32.def index 58b4390..0125d26 100644 --- a/src/lib/krb5_32.def +++ b/src/lib/krb5_32.def @@ -168,6 +168,7 @@ krb5_c_string_to_key_with_params krb5_init_keyblock krb5_init_random_key krb5_init_secure_context + krb5_is_thread_safe krb5_kt_add_entry krb5_kt_close krb5_kt_default @@ -193,7 +194,7 @@ krb5_c_string_to_key_with_params krb5_os_localaddr krb5_parse_name krb5_principal_compare - krb5_principal2salt + krb5_principal2salt ; KRB5_CALLCONV_WRONG krb5_process_key krb5_prompter_posix krb5_random_key @@ -211,8 +212,8 @@ krb5_c_string_to_key_with_params krb5_sendauth krb5_set_default_realm krb5_set_default_tgs_enctypes -krb5_set_password -krb5_set_password_using_ccache + krb5_set_password + krb5_set_password_using_ccache krb5_set_principal_realm krb5_set_real_time krb5_sname_to_principal diff --git a/src/lib/rpc/ChangeLog b/src/lib/rpc/ChangeLog index d3070b4..def5183 100644 --- a/src/lib/rpc/ChangeLog +++ b/src/lib/rpc/ChangeLog @@ -1,3 +1,22 @@ +2005-01-14 Tom Yu <tlyu@mit.edu> + + * xdr.c (xdr_bytes): Revert previous; the problem was actually in + xdr_rpc_gss_buf. + + * authgss_prot.c (xdr_rpc_gss_wrap_data): Use xdr_alloc to avoid + size limit issues. Use (unsigned int)-1 instead of MAX_NETOBJ_SZ. + (xdr_rpc_gss_unwrap_data): Use (unsigned int)-1 instead of + MAX_NETOBJ_SZ. + (xdr_rpc_gss_buf): Set tmplen even if doing XDR_FREE. + + * xdr.c (xdr_bytes): Don't assign from *sizep if XDR_FREE, since + it'll be uninitialized then. Shuts up Purify. + +2004-11-18 Tom Yu <tlyu@mit.edu> + + * Makefile.in (install-unix): Install into KRB5_INCDIR/gssrpc, + rather than just KRB5_INCDIR. + 2004-10-25 Tom Yu <tlyu@mit.edu> * auth_gss.c (authgss_get_private_data): New function. diff --git a/src/lib/rpc/Makefile.in b/src/lib/rpc/Makefile.in index b303bb3..b9bd4c6 100644 --- a/src/lib/rpc/Makefile.in +++ b/src/lib/rpc/Makefile.in @@ -191,10 +191,10 @@ install-unix:: install-libs install-unix:: for i in $(SRC_HDRS); do \ - (set -x; $(INSTALL_DATA) $(srcdir)/$$i $(DESTDIR)$(KRB5_INCDIR)$(S)$$i) ; \ + (set -x; $(INSTALL_DATA) $(srcdir)/$$i $(DESTDIR)$(KRB5_INCDIR)$(S)gssrpc$(S)$$i) ; \ done for i in $(BUILD_HDRS); do \ - (set -x; $(INSTALL_DATA) $$i $(DESTDIR)$(KRB5_INCDIR)$(S)$$i) ; \ + (set -x; $(INSTALL_DATA) $$i $(DESTDIR)$(KRB5_INCDIR)$(S)gssrpc$(S)$$i) ; \ done BUILD_HDRS = types.h diff --git a/src/lib/rpc/authgss_prot.c b/src/lib/rpc/authgss_prot.c index 0e8029a..ab6e7fe 100644 --- a/src/lib/rpc/authgss_prot.c +++ b/src/lib/rpc/authgss_prot.c @@ -52,7 +52,7 @@ xdr_rpc_gss_buf(XDR *xdrs, gss_buffer_t buf, u_int maxsize) bool_t xdr_stat; u_int tmplen; - if (xdrs->x_op == XDR_ENCODE) { + if (xdrs->x_op != XDR_DECODE) { if (buf->length > UINT_MAX) return (FALSE); else @@ -129,54 +129,37 @@ xdr_rpc_gss_wrap_data(XDR *xdrs, xdrproc_t xdr_func, caddr_t xdr_ptr, gss_ctx_id_t ctx, gss_qop_t qop, rpc_gss_svc_t svc, uint32_t seq) { + XDR tmpxdrs; gss_buffer_desc databuf, wrapbuf; OM_uint32 maj_stat, min_stat; - u_int start, end; int conf_state; bool_t xdr_stat; - u_int tmplen; - /* Skip databody length. */ - start = XDR_GETPOS(xdrs); - if (start > UINT_MAX - 4) - return (FALSE); - XDR_SETPOS(xdrs, start + 4); + xdralloc_create(&tmpxdrs, XDR_ENCODE); + + xdr_stat = FALSE; /* Marshal rpc_gss_data_t (sequence number + arguments). */ - if (!xdr_u_int32(xdrs, &seq) || !(*xdr_func)(xdrs, xdr_ptr)) - return (FALSE); - end = XDR_GETPOS(xdrs); - if (end < start + 4) - return (FALSE); + if (!xdr_u_int32(&tmpxdrs, &seq) || !(*xdr_func)(&tmpxdrs, xdr_ptr)) + goto errout; /* Set databuf to marshalled rpc_gss_data_t. */ - databuf.length = end - start - 4; - XDR_SETPOS(xdrs, start + 4); - databuf.value = XDR_INLINE(xdrs, (int)databuf.length); + databuf.length = xdr_getpos(&tmpxdrs); + databuf.value = xdralloc_getdata(&tmpxdrs); - xdr_stat = FALSE; - if (svc == RPCSEC_GSS_SVC_INTEGRITY) { - /* Marshal databody_integ length. */ - XDR_SETPOS(xdrs, start); - if (databuf.length > UINT_MAX) - return (FALSE); - else - tmplen = databuf.length; + if (!xdr_rpc_gss_buf(xdrs, &databuf, (unsigned int)-1)) + goto errout; - if (!xdr_u_int(xdrs, &tmplen)) - return (FALSE); - /* Checksum rpc_gss_data_t. */ maj_stat = gss_get_mic(&min_stat, ctx, qop, &databuf, &wrapbuf); if (maj_stat != GSS_S_COMPLETE) { log_debug("gss_get_mic failed"); - return (FALSE); + goto errout; } /* Marshal checksum. */ - XDR_SETPOS(xdrs, end); - xdr_stat = xdr_rpc_gss_buf(xdrs, &wrapbuf, MAX_NETOBJ_SZ); + xdr_stat = xdr_rpc_gss_buf(xdrs, &wrapbuf, (unsigned int)-1); gss_release_buffer(&min_stat, &wrapbuf); } else if (svc == RPCSEC_GSS_SVC_PRIVACY) { @@ -185,13 +168,14 @@ xdr_rpc_gss_wrap_data(XDR *xdrs, xdrproc_t xdr_func, caddr_t xdr_ptr, &conf_state, &wrapbuf); if (maj_stat != GSS_S_COMPLETE) { log_status("gss_wrap", maj_stat, min_stat); - return (FALSE); + goto errout; } /* Marshal databody_priv. */ - XDR_SETPOS(xdrs, start); - xdr_stat = xdr_rpc_gss_buf(xdrs, &wrapbuf, MAX_NETOBJ_SZ); + xdr_stat = xdr_rpc_gss_buf(xdrs, &wrapbuf, (unsigned int)-1); gss_release_buffer(&min_stat, &wrapbuf); } +errout: + xdr_destroy(&tmpxdrs); return (xdr_stat); } @@ -216,12 +200,12 @@ xdr_rpc_gss_unwrap_data(XDR *xdrs, xdrproc_t xdr_func, caddr_t xdr_ptr, if (svc == RPCSEC_GSS_SVC_INTEGRITY) { /* Decode databody_integ. */ - if (!xdr_rpc_gss_buf(xdrs, &databuf, MAX_NETOBJ_SZ)) { + if (!xdr_rpc_gss_buf(xdrs, &databuf, (unsigned int)-1)) { log_debug("xdr decode databody_integ failed"); return (FALSE); } /* Decode checksum. */ - if (!xdr_rpc_gss_buf(xdrs, &wrapbuf, MAX_NETOBJ_SZ)) { + if (!xdr_rpc_gss_buf(xdrs, &wrapbuf, (unsigned int)-1)) { gss_release_buffer(&min_stat, &databuf); log_debug("xdr decode checksum failed"); return (FALSE); @@ -239,7 +223,7 @@ xdr_rpc_gss_unwrap_data(XDR *xdrs, xdrproc_t xdr_func, caddr_t xdr_ptr, } else if (svc == RPCSEC_GSS_SVC_PRIVACY) { /* Decode databody_priv. */ - if (!xdr_rpc_gss_buf(xdrs, &wrapbuf, MAX_NETOBJ_SZ)) { + if (!xdr_rpc_gss_buf(xdrs, &wrapbuf, (unsigned int)-1)) { log_debug("xdr decode databody_priv failed"); return (FALSE); } diff --git a/src/mac/MacOSX/Projects/GSS.pbexp b/src/mac/MacOSX/Projects/GSS.pbexp index e61e856..6c2e413 100644 --- a/src/mac/MacOSX/Projects/GSS.pbexp +++ b/src/mac/MacOSX/Projects/GSS.pbexp @@ -94,3 +94,17 @@ _gss_nt_exported_name # _GSS_KRB5_NT_PRINCIPAL_NAME + +# +# GSS-API krb5 symbols from gssapi_krb5.h +# + +_gss_mech_krb5 +_gss_mech_krb5_old +_gss_mech_set_krb5 +_gss_mech_set_krb5_both +_gss_mech_set_krb5_old + +_gss_nt_krb5_name +_gss_nt_krb5_principal +_krb5_gss_oid_array diff --git a/src/mac/MacOSX/Projects/Kerberos5.pbproj/project.pbxproj b/src/mac/MacOSX/Projects/Kerberos5.pbproj/project.pbxproj index 66c6311..853af0e 100644 --- a/src/mac/MacOSX/Projects/Kerberos5.pbproj/project.pbxproj +++ b/src/mac/MacOSX/Projects/Kerberos5.pbproj/project.pbxproj @@ -1755,6 +1755,12 @@ refType = 4; sourceTree = "<group>"; }; + A14E78E90725B12A00A025E3 = { + fileRef = F517327003F1B65901120114; + isa = PBXBuildFile; + settings = { + }; + }; A166BCC3040D36F8004AA618 = { fileEncoding = 4; isa = PBXFileReference; @@ -3201,7 +3207,7 @@ DYLIB_CURRENT_VERSION = 1; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = ../Sources/mac/MacOSX/Headers/Kerberos5Prefix.h; - HEADER_SEARCH_PATHS = "$(BUILT_PRODUCTS_DIR)/Kerberos5.intermediates/include"; + HEADER_SEARCH_PATHS = "$(SRCROOT)/../Sources/lib/crypto/des $(SRCROOT)/../Sources/include $(SRCROOT)/../Sources/include/krb5 $(BUILT_PRODUCTS_DIR)/Kerberos5.intermediates/include $(BUILT_PRODUCTS_DIR)/Kerberos5.intermediates/include/krb5"; LIBRARY_STYLE = STATIC; PRODUCT_NAME = KerberosDES; REZ_EXECUTABLE = YES; @@ -3226,6 +3232,7 @@ buildActionMask = 2147483647; files = ( A1AB1DEF05DDC40100526345, + A14E78E90725B12A00A025E3, ); isa = PBXHeadersBuildPhase; runOnlyForDeploymentPostprocessing = 0; @@ -3377,7 +3384,7 @@ DYLIB_CURRENT_VERSION = 1; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = ../Sources/mac/MacOSX/Headers/Kerberos5Prefix.h; - HEADER_SEARCH_PATHS = "$(SRCROOT)/../../Common/Headers $(SRCROOT)/../../KerberosErrors/Headers/Kerberos $(BUILT_PRODUCTS_DIR)/Kerberos5.intermediates/include"; + HEADER_SEARCH_PATHS = "$(SRCROOT)/../../Common/Headers $(SRCROOT)/../../KerberosErrors/Headers/Kerberos $(SRCROOT)/../Sources/include $(BUILT_PRODUCTS_DIR)/Kerberos5.intermediates/include $(BUILT_PRODUCTS_DIR)/Kerberos5.intermediates/include/krb5"; LIBRARY_STYLE = STATIC; PRODUCT_NAME = KerberosProfile; REZ_EXECUTABLE = YES; @@ -3524,7 +3531,7 @@ DYLIB_CURRENT_VERSION = 1; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = ../Sources/mac/MacOSX/Headers/Kerberos5Prefix.h; - HEADER_SEARCH_PATHS = "$(BUILT_PRODUCTS_DIR)/Kerberos5.intermediates $(BUILT_PRODUCTS_DIR)/Kerberos5.intermediates/include $(BUILT_PRODUCTS_DIR)/Kerberos5.intermediates/ErrorTables $(SRCROOT)/../../Common/Headers $(SRCROOT)/../../KerberosErrors/Headers $(SRCROOT)/../../KerberosDebug/Headers $(SRCROOT)/../../KerberosErrors/Headers/Kerberos $(SRCROOT)/../../CredentialsCache/Headers $(SRCROOT)/../../CredentialsCache/Headers/Kerberos $(SRCROOT)/../../KerberosLogin/Headers $(SRCROOT)/../../KerberosLogin/Headers/Kerberos"; + HEADER_SEARCH_PATHS = "$(SRCROOT)/../Sources/include $(SRCROOT)/../Sources/include/krb5 $(SRCROOT)/../Sources/include/kerberosIV $(BUILT_PRODUCTS_DIR)/Kerberos5.intermediates $(BUILT_PRODUCTS_DIR)/Kerberos5.intermediates/include $(BUILT_PRODUCTS_DIR)/Kerberos5.intermediates/include/krb5 $(BUILT_PRODUCTS_DIR)/Kerberos5.intermediates/ErrorTables $(SRCROOT)/../../Common/Headers $(SRCROOT)/../../KerberosErrors/Headers $(SRCROOT)/../../KerberosDebug/Headers $(SRCROOT)/../../KerberosErrors/Headers/Kerberos $(SRCROOT)/../../CredentialsCache/Headers $(SRCROOT)/../../CredentialsCache/Headers/Kerberos $(SRCROOT)/../../KerberosLogin/Headers $(SRCROOT)/../../KerberosLogin/Headers/Kerberos"; LIBRARY_STYLE = STATIC; PRODUCT_NAME = Kerberos4; REZ_EXECUTABLE = YES; @@ -3985,7 +3992,7 @@ DYLIB_CURRENT_VERSION = 1; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = ../Sources/mac/MacOSX/Headers/Kerberos5Prefix.h; - HEADER_SEARCH_PATHS = "$(BUILT_PRODUCTS_DIR)/Kerberos5.intermediates $(BUILT_PRODUCTS_DIR)/Kerberos5.intermediates/include $(SRCROOT)/../Sources/include $(SRCROOT)/../../KerberosErrors/Headers $(SRCROOT)/../../KerberosErrors/Headers/Kerberos $(SRCROOT)/../../CredentialsCache/Headers $(SRCROOT)/../../CredentialsCache/Headers/Kerberos $(SRCROOT)/../../KerberosLogin/Headers $(SRCROOT)/../../KerberosLogin/Headers/Kerberos"; + HEADER_SEARCH_PATHS = "$(SRCROOT)/../Sources/ $(SRCROOT)/../Sources/include $(SRCROOT)/../Sources/include/krb5 $(SRCROOT)/../Sources/lib/crypto/aes $(SRCROOT)/../Sources/lib/crypto $(SRCROOT)/../Sources/lib/crypto/arcfour $(SRCROOT)/../Sources/lib/crypto/enc_provider $(SRCROOT)/../Sources/lib/crypto/crc32 $(SRCROOT)/../Sources/lib/crypto/des $(SRCROOT)/../Sources/lib/crypto/dk $(SRCROOT)/../Sources/lib/crypto/hash_provider $(SRCROOT)/../Sources/lib/crypto/keyhash_provider $(SRCROOT)/../Sources/lib/crypto/md4 $(SRCROOT)/../Sources/lib/crypto/md5 $(SRCROOT)/../Sources/lib/crypto/old $(SRCROOT)/../Sources/lib/crypto/raw $(SRCROOT)/../Sources/lib/crypto/sha1 $(SRCROOT)/../Sources/lib/crypto/yarrow $(SRCROOT)/../Sources/lib/krb5/os $(SRCROOT)/../Sources/lib/krb5/keytab $(SRCROOT)/../Sources/lib/krb5/rcache $(SRCROOT)/../Sources/lib/krb5/ccache $(SRCROOT)/../Sources/lib/krb5/ccache/ccapi $(BUILT_PRODUCTS_DIR)/Kerberos5.intermediates $(BUILT_PRODUCTS_DIR)/Kerberos5.intermediates/include $(BUILT_PRODUCTS_DIR)/Kerberos5.intermediates/include/krb5 $(BUILT_PRODUCTS_DIR)/Kerberos5.intermediates/ErrorTables $(SRCROOT)/../Sources/include $(SRCROOT)/../../KerberosErrors/Headers $(SRCROOT)/../../KerberosErrors/Headers/Kerberos $(SRCROOT)/../../CredentialsCache/Headers $(SRCROOT)/../../CredentialsCache/Headers/Kerberos $(SRCROOT)/../../KerberosLogin/Headers $(SRCROOT)/../../KerberosLogin/Headers/Kerberos"; LIBRARY_STYLE = STATIC; PRODUCT_NAME = Kerberos5; REZ_EXECUTABLE = YES; @@ -6138,7 +6145,7 @@ DYLIB_CURRENT_VERSION = 1; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = ../Sources/mac/MacOSX/Headers/Kerberos5Prefix.h; - HEADER_SEARCH_PATHS = "$(BUILT_PRODUCTS_DIR)/Kerberos5.intermediates/include $(SRCROOT)/../../KerberosErrors/Headers $(SRCROOT)/../../KerberosErrors/Headers/Kerberos"; + HEADER_SEARCH_PATHS = "$(SRCROOT)/../Sources/include $(SRCROOT)/../Sources/include/krb5 $(SRCROOT)/../Sources/lib/gssapi $(SRCROOT)/../Sources/lib/gssapi/krb5 $(SRCROOT)/../Sources/lib/gssapi/generic $(BUILT_PRODUCTS_DIR)/Kerberos5.intermediates/ErrorTables $(BUILT_PRODUCTS_DIR)/Kerberos5.intermediates/include $(BUILT_PRODUCTS_DIR)/Kerberos5.intermediates/include/krb5 $(BUILT_PRODUCTS_DIR)/Kerberos5.intermediates/include/gssapi $(SRCROOT)/../../KerberosErrors/Headers $(SRCROOT)/../../KerberosErrors/Headers/Kerberos"; LIBRARY_STYLE = STATIC; PRODUCT_NAME = GSS; REZ_EXECUTABLE = YES; diff --git a/src/mac/MacOSX/Projects/KerberosProfile.pbexp b/src/mac/MacOSX/Projects/KerberosProfile.pbexp index 9033b54..d6fc152 100644 --- a/src/mac/MacOSX/Projects/KerberosProfile.pbexp +++ b/src/mac/MacOSX/Projects/KerberosProfile.pbexp @@ -7,7 +7,12 @@ _profile_init _profile_init_path _FSp_profile_init _FSp_profile_init_path +_profile_is_writable +_profile_is_modified _profile_flush +_profile_flush_to_file +_profile_flush_to_buffer +_profile_free_buffer _profile_abandon _profile_release _profile_get_values diff --git a/src/mac/MacOSX/Scripts/Kerberos5BuildSystem.jam b/src/mac/MacOSX/Scripts/Kerberos5BuildSystem.jam index 3f39118..de3f1ba 100644 --- a/src/mac/MacOSX/Scripts/Kerberos5BuildSystem.jam +++ b/src/mac/MacOSX/Scripts/Kerberos5BuildSystem.jam @@ -28,21 +28,10 @@ CONFIGURE_LDFLAGS = "LDFLAGS=$(CONFIGURE_LDFLAGS:)" ; # script doesn't need to know how the reconf and configure scripts work. # -# Reconf <configure> : <configure.in> -rule Reconf -{ - DEPENDS "$(1)" : "$(1).in" "$(Reconf)" ; -} -actions Reconf -{ - cd "$(Sources)" && /bin/sh "$(Reconf)" -f -} - # Configure <makefile> : <configure> rule Configure { DEPENDS "$(1)" : "$(2)" ; - Reconf "$(2)" : "$(2).in" ; Clean.Remove clean "$(1:D)" ; } actions Configure diff --git a/src/patchlevel.h b/src/patchlevel.h index a520628..1e69012 100644 --- a/src/patchlevel.h +++ b/src/patchlevel.h @@ -52,7 +52,7 @@ */ #define KRB5_MAJOR_RELEASE 1 #define KRB5_MINOR_RELEASE 4 -#define KRB5_PATCHLEVEL 0 -#define KRB5_RELTAIL "prerelease" +#define KRB5_PATCHLEVEL 1 +/* #undef KRB5_RELTAIL */ /* #undef KRB5_RELDATE */ -/* #undef KRB5_RELTAG */ +#define KRB5_RELTAG "krb5-1-4-final" diff --git a/src/tests/dejagnu/krb-root/ChangeLog b/src/tests/dejagnu/krb-root/ChangeLog index df56505..328a26c 100644 --- a/src/tests/dejagnu/krb-root/ChangeLog +++ b/src/tests/dejagnu/krb-root/ChangeLog @@ -1,3 +1,10 @@ +2004-11-15 Tom Yu <tlyu@mit.edu> + + * telnet.exp (telnet_test): Work around possible race condition + with client's resetting of terminal mode when returning from + interactive command mode. Test whether requiring encryption + works. + 2004-03-14 Ken Raeburn <raeburn@mit.edu> * rlogin.exp (start_rlogin_daemon, rlogin_test): Use portbase to diff --git a/src/tests/dejagnu/krb-root/telnet.exp b/src/tests/dejagnu/krb-root/telnet.exp index 17ca35e..03bdb79 100644 --- a/src/tests/dejagnu/krb-root/telnet.exp +++ b/src/tests/dejagnu/krb-root/telnet.exp @@ -50,7 +50,7 @@ if {![get_hostname] \ # A procedure to start up the telnet daemon. -proc start_telnet_daemon { } { +proc start_telnet_daemon { args } { global REALMNAME global TELNETD global LOGINKRB5 @@ -70,7 +70,7 @@ proc start_telnet_daemon { } { # we don't need to use inetd. The portbase+8 is the port to listen at. # Note that tmppwd here is a shell variable, which is set in # setup_root_shell, not a TCL variable. - send -i $rlogin_spawn_id "sh -c \"$TELNETD -debug -t \$tmppwd/srvtab -R $REALMNAME -L $tmppwd/login.wrap -X KERBEROS_V4 [expr 8 + $portbase]\" &\r" + send -i $rlogin_spawn_id "sh -c \"$TELNETD $args -debug -t \$tmppwd/srvtab -R $REALMNAME -L $tmppwd/login.wrap -X KERBEROS_V4 [expr 8 + $portbase]\" &\r" expect { -i $rlogin_spawn_id -re "$ROOT_PROMPT" { } @@ -174,7 +174,7 @@ proc telnet_test { } { set testname "simple telnet" expect { - "ogin:" { + "ogin: " { pass $testname } } @@ -184,7 +184,7 @@ proc telnet_test { } { set testname "telnet command mode" send "\035" expect { - "telnet>" { + "telnet> " { pass $testname } } @@ -200,9 +200,16 @@ proc telnet_test { } { } set testname "back to command mode" + + # For some reason, the telnet client doesn't necessarily reset the + # terminal mode back to raw after exiting command mode. + # Kick it somewhat by sending a CR. + send "\r" + expect "ogin: " + send "\035" expect { - "telnet>" { + "telnet> " { pass $testname } } @@ -299,6 +306,7 @@ proc telnet_test { } { } expect_after + catch "expect eof" # We can't use check_exit_status, because we expect an exit status # of 1. @@ -355,7 +363,7 @@ proc telnet_test { } { # Move back to telnet command mode and check the encryption status. set testname "encryption status" send "\035" - expect "telnet>" + expect "telnet> " send "status\r" expect { -re "Currently encrypting output with DES_CFB64.*Currently decrypting input with DES_CFB64" { @@ -368,6 +376,7 @@ proc telnet_test { } { expect "Connection closed by foreign host.\r" expect_after + catch "expect eof" # We can't use check_exit_status, because we expect an exit status # of 1. @@ -384,6 +393,38 @@ proc telnet_test { } { # The telnet daemon should have stopped, but we have no easy way # of checking whether it actually did. Kill it just in case. stop_telnet_daemon + + set testname "reject unencrypted telnet" + # Check rejection of unencrypted client when encryption is required + start_telnet_daemon -e + + # unencrypted, unauthenticated + spawn $TELNET -- $hostname -[expr 8 + $portbase] + expect_after { + timeout { + fail $testname + catch "expect_after" + return + } + eof { + fail $testname + catch "expect_after" + return + } + } + + expect { + -re "Unencrypted connection refused.*\n" { + pass $testname + } + } + catch "expect_after" + catch "expect eof" + catch wait + + # The telnet daemon should have stopped, but we have no easy way + # of checking whether it actually did. Kill it just in case. + stop_telnet_daemon } # Run the test. Logging in sometimes takes a while, so increase the diff --git a/src/tests/dejagnu/krb-standalone/ChangeLog b/src/tests/dejagnu/krb-standalone/ChangeLog index bba583b..b426a93 100644 --- a/src/tests/dejagnu/krb-standalone/ChangeLog +++ b/src/tests/dejagnu/krb-standalone/ChangeLog @@ -1,3 +1,24 @@ +2005-02-10 Tom Yu <tlyu@mit.edu> + + * kadmin.exp (kadmin_add_rnd): Add "flags" arg, defaulting to + empty string. + (kadmin_test): Add test for fallback to kadmin/admin if + kadmin/fqdn is missing. + +2005-01-14 Tom Yu <tlyu@mit.edu> + + * kadmin.exp (kadmin_list): Check for communication failure. + (kadmin_test): Create a large number of principals, then attempt + to list, in order to check for fixed-size buffer problems in + RPCSEC_GSS. + +2004-12-20 Tom Yu <tlyu@mit.edu> + + * pwhist.exp: New file. Perform some sanity checking on password + history mechanism, including erroneous loss of history when + growing the history array. Also tries to trigger some known + buffer overflows and memory leaks. + 2004-03-14 Ken Raeburn <raeburn@mit.edu> * gssapi.exp (run_client, doit): Use portbase to compute all port diff --git a/src/tests/dejagnu/krb-standalone/kadmin.exp b/src/tests/dejagnu/krb-standalone/kadmin.exp index ded386d..e3e3916 100644 --- a/src/tests/dejagnu/krb-standalone/kadmin.exp +++ b/src/tests/dejagnu/krb-standalone/kadmin.exp @@ -128,7 +128,7 @@ proc kadmin_add { pname password } { # # Adds principal $pname with random key. Returns 1 on success. #-- -proc kadmin_add_rnd { pname } { +proc kadmin_add_rnd { pname { flags "" } } { global REALMNAME global KADMIN global KADMIN_LOCAL @@ -137,7 +137,7 @@ proc kadmin_add_rnd { pname } { global tmppwd set good 0 - spawn $KADMIN -p krbtest/admin@$REALMNAME -q "ank -randkey $pname" + spawn $KADMIN -p krbtest/admin@$REALMNAME -q "ank -randkey $flags $pname" expect_after { "Cannot contact any KDC" { fail "kadmin add rnd $pname lost KDC" @@ -402,6 +402,11 @@ proc kadmin_list { } { catch "expect_after" return 0 } + "Communication failure" { + fail "kadmin ldb got RPC error" + catch "expect_after" + return 0 + } timeout { fail "kadmin ldb" catch "expect_after" @@ -416,7 +421,7 @@ proc kadmin_list { } { expect -re "assword\[^\r\n\]*: *" { send "adminpass$KEY\r" } - expect -re "\(.*@$REALMNAME\r\n\)*" + expect -re "\(.*@$REALMNAME\r\n\)+" expect_after expect eof set k_stat [wait -i $spawn_id] @@ -947,6 +952,7 @@ proc kdestroy { } { # we get some sort of error. proc kadmin_test { } { + global hostname # Start up the kerberos and kadmind daemons if {![start_kerberos_daemons 0] } { @@ -1033,6 +1039,26 @@ proc kadmin_test { } { return } + # test retrieval of large number of principals + # bug [2877] + for { set i 0 } { $i < 200 } { incr i } { + if { ![kadmin_add "foo$i" foopass] } { + return + } + } + + if { ![kadmin_list] } { + return + } + + # test fallback to kadmin/admin + if {![kadmin_delete kadmin/$hostname] \ + || ![kadmin_list] \ + || ![kadmin_add_rnd kadmin/$hostname -allow_tgs_req] \ + || ![kadmin_list]} { + return + } + verbose "kadmin_test succeeded" } diff --git a/src/tests/dejagnu/krb-standalone/pwhist.exp b/src/tests/dejagnu/krb-standalone/pwhist.exp new file mode 100644 index 0000000..f9938e0 --- /dev/null +++ b/src/tests/dejagnu/krb-standalone/pwhist.exp @@ -0,0 +1,215 @@ +# password history tests + +# one *non-interactive* kadmin.local request +proc onerq { rq pname str {flags ""} } { + global REALMNAME + global KADMIN_LOCAL + + spawn $KADMIN_LOCAL -r $REALMNAME -q "$rq $flags $pname" + expect_after { + timeout { + verbose "kadmin.local $rq $flags $pname timed out" + catch expect_after + kill [exp_pid] + close + expect eof + wait + return 0 + } eof { + verbose "kadmin.local $rq $flags $pname got EOF" + catch expect_after + wait + return 0 + } + } + expect $str + expect_after + expect eof + wait + return 1 +} + +proc addprinc { pname pw } { + global REALMNAME + + return [onerq addprinc $pname \ + "Principal \"$pname@$REALMNAME\" created." "-pw $pw"] +} + +proc delprinc { pname } { + global REALMNAME + return [onerq delprinc $pname \ + "Principal \"$pname@$REALMNAME\" deleted." "-force"] +} + +proc cpw { pname pw } { + global REALMNAME + + return [onerq cpw $pname \ + "Password for \"$pname@$REALMNAME\" changed." "-pw $pw"] +} + +proc modprinc { pname flags } { + global REALMNAME + + return [onerq modprinc $pname \ + "Principal \"$pname@$REALMNAME\" modified." $flags] +} + +proc addpol { pname } { + if ![onerq addpol $pname ""] { + return 0 + } + return [onerq getpol $pname "Policy: $pname"] +} + +proc delpol { pname } { + onerq delpol $pname "" -force + return [onerq getpol $pname \ + "Policy does not exist while retrieving policy \"$pname\"."] +} + +proc modpol { pname flags } { + return [onerq modpol $pname "" $flags] +} + +# Mandatory command must return true. +# Issues a break in its parent on failure. +proc mustrun { cmd } { + if ![eval $cmd] { + perror "mandatory command failed: $cmd" + uplevel break + } +} + +# Fail test if command fails. +# Issues a break in its parent on failure. +proc chkpass { cmd } { + upvar test test + if ![eval $cmd] { + verbose "unexpected failure: $cmd" + fail $test + uplevel break + } +} + +# Fail test if command succeeds. +# Issues a break in its parent on failure. +proc chkfail { cmd } { + upvar test test + if [eval $cmd] { + verbose "unexpected success: $cmd" + fail $test + uplevel break + } +} + +# wrapper to run command (actually usually sequence of commands) +# +# If any part of CMD throws an exception, set failall, otherwise pass. +# If failall is already true, report unresolved. +proc wraptest { test cmd } { + upvar failall failall + if $failall { + unresolved $test + return + } + if [catch $cmd] { + set failall 1 + } else { + pass $test + } +} + +# Set up the kerberos database. +if {![get_hostname] \ + || ![setup_kerberos_files] \ + || ![setup_kerberos_env] \ + || ![setup_kerberos_db 0]} { + return +} + +set failall 0 +wraptest "nkeys=1, nhist=3" { + mustrun { addpol crashpol } + mustrun { modpol crashpol "-history 3"} + mustrun { addprinc crash 1111 } + mustrun { modprinc crash "-policy crashpol" } + chkpass { cpw crash 2222 } + chkfail { cpw crash 2222 } + chkfail { cpw crash 1111 } +} +verbose {old_keys [ 1111 ->[] ]} + +# The following will result in reading/writing past array bounds if +# add_to_history() is not patched. +# +# NOTE: A pass from this test does not mean the bug isn't present; +# check with Purify, valgrind, etc. +wraptest "array bounds ok on nkeys=1, nhist 3->2" { + mustrun { modpol crashpol "-history 2" } + chkpass { cpw crash 3333 } +} +verbose {old_keys [ ->2222 ]} + +wraptest "verify nhist=2" { + mustrun { delprinc crash } + mustrun { addprinc crash 1111 } + mustrun { modprinc crash "-policy crashpol" } + chkpass { cpw crash 2222 } + chkfail { cpw crash 2222 } + chkfail { cpw crash 1111 } +} +verbose {old_keys [ ->1111 ]} + +# The following will fail if growing the history array causes an extra +# key to be lost due to failure to shift entries. +wraptest "grow nhist 2->3" { + mustrun { modpol crashpol "-history 3" } + chkpass { cpw crash 3333 } + chkfail { cpw crash 3333 } + chkfail { cpw crash 2222 } + chkfail { cpw crash 1111 } +} +verbose {old_keys [ 2222 ->1111 ]} + +wraptest "grow nhist 3->4" { + mustrun { modpol crashpol "-history 4" } + chkfail { cpw crash 3333 } + chkfail { cpw crash 2222 } + chkfail { cpw crash 1111 } + chkpass { cpw crash 4444 } + chkfail { cpw crash 3333 } + chkfail { cpw crash 2222 } + chkfail { cpw crash 1111 } +} +verbose {old_keys [ 2222 3333 ->1111 ]} +wraptest "shrink nhist 4->3" { + mustrun { modpol crashpol "-history 3" } + chkfail { cpw crash 4444 } + chkfail { cpw crash 3333 } + chkfail { cpw crash 2222 } + chkfail { cpw crash 1111 } + chkpass { cpw crash 5555 } +} +verbose {old_keys [ 4444 ->3333 ]} +wraptest "verify nhist=3" { + chkfail { cpw crash 5555 } + chkfail { cpw crash 4444 } + chkfail { cpw crash 3333 } + chkpass { cpw crash 2222 } +} +verbose {old_keys [ ->4444 5555 ]} +wraptest "shrink nhist 3->2" { + mustrun { modpol crashpol "-history 2" } + chkfail { cpw crash 2222 } + chkfail { cpw crash 5555 } + chkfail { cpw crash 4444 } + chkpass { cpw crash 3333 } +} +verbose {old_keys [ ->2222 ]} + +delprinc crash +delpol crashpol + +stop_kerberos_daemons diff --git a/src/util/ChangeLog b/src/util/ChangeLog index 990ca78..5e792c8 100644 --- a/src/util/ChangeLog +++ b/src/util/ChangeLog @@ -1,3 +1,13 @@ +2004-12-21 Tom Yu <tlyu@mit.edu> + + * def-check.pl: Check for PRIVATE or INTERNAL annotations in defs + file. + +2004-10-31 Tom Yu <tlyu@mit.edu> + + * mkrel: Rework quoting for RELTAIL check. Don't check RELTAIL if + doing a "-current" snapshot. + 2004-09-24 Tom Yu <tlyu@mit.edu> * mkrel: Rework somewhat to handle patchlevel.h being the new diff --git a/src/util/def-check.pl b/src/util/def-check.pl index 9b7aee1..447421e 100644 --- a/src/util/def-check.pl +++ b/src/util/def-check.pl @@ -219,7 +219,9 @@ while (! $d->eof()) { } s/[ \t]*//g; my($xconv); - if (/!CALLCONV/ || /KRB5_CALLCONV_WRONG/) { + if (/PRIVATE/ || /INTERNAL/) { + $xconv = "PRIVATE"; + } elsif (/!CALLCONV/ || /KRB5_CALLCONV_WRONG/) { $xconv = "KRB5_CALLCONV_WRONG"; } elsif ($vararg{$_}) { $xconv = "KRB5_CALLCONV_C"; @@ -227,6 +229,11 @@ while (! $d->eof()) { $xconv = "KRB5_CALLCONV"; } s/;.*$//; + + if ($xconv eq "PRIVATE") { + print "\t private $_\n"; + next LINE2; + } if (!defined($conv{$_})) { print "No calling convention specified for $_!\n"; } elsif (! ($conv{$_} eq $xconv)) { diff --git a/src/util/et/ChangeLog b/src/util/et/ChangeLog index 9349834..bec7407 100644 --- a/src/util/et/ChangeLog +++ b/src/util/et/ChangeLog @@ -1,3 +1,18 @@ +2005-01-17 Jeffrey Altman <jaltman@mit.edu> + + * error_message.c: implement library unload cleanup of mutexes + +2005-01-13 Ken Raeburn <raeburn@mit.edu> + + * error_message.c (com_err_terminate): Lock the list mutex before + walking through it; unlock and destroy it afterwards. + +2004-11-05 Ken Raeburn <raeburn@mit.edu> + + * et_h.awk: Declare initialize_*_error_table as taking no + arguments. + * et_h.pl: Regenerated. + 2004-10-07 Tom Yu <tlyu@mit.edu> * et_c.awk, et_h.awk: Fix off-by-one error. diff --git a/src/util/et/error_message.c b/src/util/et/error_message.c index 42c2300..cb76b2a 100644 --- a/src/util/et/error_message.c +++ b/src/util/et/error_message.c @@ -37,6 +37,7 @@ extern const int sys_nerr; /*@null@*/ static struct et_list * _et_list = (struct et_list *) NULL; /*@null@*//*@only@*/static struct dynamic_et_list * et_list_dynamic; static k5_mutex_t et_list_lock = K5_MUTEX_PARTIAL_INITIALIZER; +static int terminated = 0; /* for debugging shlib fini sequence errors */ MAKE_INIT_FUNCTION(com_err_initialize); MAKE_FINI_FUNCTION(com_err_terminate); @@ -44,6 +45,7 @@ MAKE_FINI_FUNCTION(com_err_terminate); int com_err_initialize(void) { int err; + terminated = 0; err = k5_mutex_finish_init(&et_list_lock); if (err) return err; @@ -56,17 +58,20 @@ int com_err_initialize(void) return 0; } -static int terminated = 0; /* for debugging shlib fini sequence errors */ void com_err_terminate(void) { struct dynamic_et_list *e, *enext; if (! INITIALIZER_RAN(com_err_initialize) || PROGRAM_EXITING()) return; - k5_mutex_destroy(&et_list_lock); + k5_key_delete(K5_KEY_COM_ERR); + k5_mutex_destroy(&com_err_hook_lock); + k5_mutex_lock(&et_list_lock); for (e = et_list_dynamic; e; e = enext) { enext = e->next; free(e); } + k5_mutex_unlock(&et_list_lock); + k5_mutex_destroy(&et_list_lock); terminated = 1; } diff --git a/src/util/et/et_h.awk b/src/util/et/et_h.awk index e3d9fa4..65c6c45 100644 --- a/src/util/et/et_h.awk +++ b/src/util/et/et_h.awk @@ -155,7 +155,7 @@ END { print "" > outfile print "#if !defined(_WIN32)" > outfile print "/* for compatibility with older versions... */" > outfile - print "extern void initialize_" table_name "_error_table () /*@modifies internalState@*/;" > outfile + print "extern void initialize_" table_name "_error_table (void) /*@modifies internalState@*/;" > outfile print "#else" > outfile print "#define initialize_" table_name "_error_table()" > outfile print "#endif" > outfile diff --git a/src/util/et/et_h.pl b/src/util/et/et_h.pl index e0965de..5ab8e8b 100644 --- a/src/util/et/et_h.pl +++ b/src/util/et/et_h.pl @@ -203,7 +203,7 @@ else { &Pick('>', $outfile) && (print $fh 'extern void initialize_' . $table_name . - '_error_table () /*@modifies internalState@*/;'); + '_error_table (void) /*@modifies internalState@*/;'); &Pick('>', $outfile) && (print $fh '#else'); &Pick('>', $outfile) && diff --git a/src/util/mkrel b/src/util/mkrel index 97a08d1..804dd5f 100644 --- a/src/util/mkrel +++ b/src/util/mkrel @@ -120,10 +120,11 @@ if test $newstyle = t; then if test "$KRB5_RELTAG" != $reltag; then echo "WARNING: patchlevel.h '$KRB5_RELTAG' != $reltag" fi - if test "$KRB5_MAJOR_RELEASE" != $relmajor || \ - test "$KRB5_MINOR_RELEASE" != $relminor || \ - test "$KRB5_PATCHLEVEL" != $relpatch || \ - test "$KRB5_RELTAIL" != $reltail; then + if test "$KRB5_MAJOR_RELEASE" != "$relmajor" || \ + test "$KRB5_MINOR_RELEASE" != "$relminor" || \ + test "$KRB5_PATCHLEVEL" != "$relpatch" || \ + ( test -n "$reltail" && \ + test "$KRB5_RELTAIL" != "$reltail" ); then echo "WARNING: patchlevel.h $KRB5_MAJOR_RELEASE.$KRB5_MINOR_RELEASE.$KRB5_PATCHLEVEL${KRB5_RELTAIL+-$KRB5_RELTAIL} != $relmajor.$relminor.$relpatch${reltail+-$reltail}" fi diff --git a/src/util/profile/ChangeLog b/src/util/profile/ChangeLog index 1366bd4..1c9a04f 100644 --- a/src/util/profile/ChangeLog +++ b/src/util/profile/ChangeLog @@ -1,3 +1,63 @@ +2005-03-03 Ken Raeburn <raeburn@mit.edu> + + * prof_tree.c (profile_node_iterator): After checking skip_num + counter, also skip over deleted nodes. + * prof_test1 (test3): New proc. + (top level): Run it. + +2005-02-23 Ken Raeburn <raeburn@mit.edu> + + * prof_tree.c (profile_node_iterator): Check that the root node + pointer is not null; raise assertion failure if it is. + + * prof_int.h: Include k5-platform.h. + (struct _prf_data_t): Reorder fields, and insert some padding. + + * prof_file.c (scan_shared_trees_locked): Check that the "root" + field isn't null. + (profile_open_file): Update the in-memory file contents after + updating the refcount instead of before. + (profile_update_file_data): If the root node in the file data is + null, always do the update. Check that it's not null before + returning a success indication. + (profile_dereference_data_locked): Scan linked list of file data + objects for sanity check, before and after. + (profile_dereference_data_locked): Don't do it here. + +2005-01-13 Ken Raeburn <raeburn@mit.edu> + + * prof_file.c (profile_free_file_data): Destroy mutex before + freeing containing structure. + +2004-12-14 Ken Raeburn <raeburn@mit.edu> + + * prof_tree.c (profile_node_iterator): When the iterator has a + current file, lock it, and unlock it before changing it or + returning. + +2004-11-04 Alexandra Ellwood <lxs@mit.edu> + + * prof_init.c, profile.hin: added profile_is_modified + and profile_is_writable so that callers can check to see + if profile_release() will fail before calling it. + +2004-11-04 Alexandra Ellwood <lxs@mit.edu> + + * prof_set.c: profile calls which set values should not fail + if file is not writable. You can now write to a different + file with profile_flush_to_file() or buffer with + profile_flush_to_buffer(). + +2004-10-30 Ken Raeburn <raeburn@mit.edu> + + * prof_int.h (STAT_ONCE_PER_SECOND): Define. + (struct _prf_data_t) [STAT_ONCE_PER_SECOND]: New field LAST_STAT. + * prof_file.c (scan_shared_trees_locked, + scan_shared_trees_unlocked): Redefine to do nothing for now. + (profile_update_file_data) [STAT_ONCE_PER_SECOND]: If the current + time is the same time as the last stat of the file, just return; + otherwise, save away the current time. + 2004-10-26 Ken Raeburn <raeburn@mit.edu> Permit exporting profile file data into a buffer. diff --git a/src/util/profile/Makefile.in b/src/util/profile/Makefile.in index b768a74..69d5630 100644 --- a/src/util/profile/Makefile.in +++ b/src/util/profile/Makefile.in @@ -157,27 +157,28 @@ check-windows:: $(OUTPRE)test_profile.exe $(OUTPRE)test_parse.exe # prof_tree.so prof_tree.po $(OUTPRE)prof_tree.$(OBJEXT): prof_tree.c prof_int.h \ $(SRCTOP)/include/k5-thread.h $(BUILDTOP)/include/krb5/autoconf.h \ - $(COM_ERR_DEPS) $(BUILDTOP)/include/profile.h + $(SRCTOP)/include/k5-platform.h $(COM_ERR_DEPS) $(BUILDTOP)/include/profile.h prof_file.so prof_file.po $(OUTPRE)prof_file.$(OBJEXT): prof_file.c prof_int.h \ $(SRCTOP)/include/k5-thread.h $(BUILDTOP)/include/krb5/autoconf.h \ - $(COM_ERR_DEPS) $(BUILDTOP)/include/profile.h $(SRCTOP)/include/k5-platform.h + $(SRCTOP)/include/k5-platform.h $(COM_ERR_DEPS) $(BUILDTOP)/include/profile.h prof_parse.so prof_parse.po $(OUTPRE)prof_parse.$(OBJEXT): prof_parse.c prof_int.h \ $(SRCTOP)/include/k5-thread.h $(BUILDTOP)/include/krb5/autoconf.h \ - $(COM_ERR_DEPS) $(BUILDTOP)/include/profile.h + $(SRCTOP)/include/k5-platform.h $(COM_ERR_DEPS) $(BUILDTOP)/include/profile.h prof_get.so prof_get.po $(OUTPRE)prof_get.$(OBJEXT): prof_get.c prof_int.h \ $(SRCTOP)/include/k5-thread.h $(BUILDTOP)/include/krb5/autoconf.h \ - $(COM_ERR_DEPS) $(BUILDTOP)/include/profile.h + $(SRCTOP)/include/k5-platform.h $(COM_ERR_DEPS) $(BUILDTOP)/include/profile.h prof_set.so prof_set.po $(OUTPRE)prof_set.$(OBJEXT): prof_set.c prof_int.h \ $(SRCTOP)/include/k5-thread.h $(BUILDTOP)/include/krb5/autoconf.h \ - $(COM_ERR_DEPS) $(BUILDTOP)/include/profile.h + $(SRCTOP)/include/k5-platform.h $(COM_ERR_DEPS) $(BUILDTOP)/include/profile.h prof_err.so prof_err.po $(OUTPRE)prof_err.$(OBJEXT): prof_err.c $(COM_ERR_DEPS) prof_init.so prof_init.po $(OUTPRE)prof_init.$(OBJEXT): prof_init.c prof_int.h \ $(SRCTOP)/include/k5-thread.h $(BUILDTOP)/include/krb5/autoconf.h \ - $(COM_ERR_DEPS) $(BUILDTOP)/include/profile.h + $(SRCTOP)/include/k5-platform.h $(COM_ERR_DEPS) $(BUILDTOP)/include/profile.h test_parse.so test_parse.po $(OUTPRE)test_parse.$(OBJEXT): test_parse.c prof_int.h \ $(SRCTOP)/include/k5-thread.h $(BUILDTOP)/include/krb5/autoconf.h \ - $(COM_ERR_DEPS) $(BUILDTOP)/include/profile.h + $(SRCTOP)/include/k5-platform.h $(COM_ERR_DEPS) $(BUILDTOP)/include/profile.h test_profile.so test_profile.po $(OUTPRE)test_profile.$(OBJEXT): test_profile.c prof_int.h \ $(SRCTOP)/include/k5-thread.h $(BUILDTOP)/include/krb5/autoconf.h \ - $(COM_ERR_DEPS) $(BUILDTOP)/include/profile.h argv_parse.h + $(SRCTOP)/include/k5-platform.h $(COM_ERR_DEPS) $(BUILDTOP)/include/profile.h \ + argv_parse.h diff --git a/src/util/profile/prof_file.c b/src/util/profile/prof_file.c index f47e540..af29881 100644 --- a/src/util/profile/prof_file.c +++ b/src/util/profile/prof_file.c @@ -66,6 +66,8 @@ void profile_library_finalizer(void) static void profile_free_file_data(prf_data_t); +#if 0 + #define scan_shared_trees_locked() \ { \ prf_data_t d; \ @@ -77,6 +79,7 @@ static void profile_free_file_data(prf_data_t); assert(d->fslen <= 1000); /* XXX */ \ assert(d->filespec[d->fslen] == 0); \ assert(d->fslen = strlen(d->filespec)); \ + assert(d->root != NULL); \ } \ } @@ -89,6 +92,13 @@ static void profile_free_file_data(prf_data_t); k5_mutex_unlock(&g_shared_trees_mutex); \ } +#else + +#define scan_shared_trees_locked() { ; } +#define scan_shared_trees_unlocked() { ; } + +#endif + static int rw_access(const_profile_filespec_t filespec) { #ifdef HAVE_ACCESS @@ -242,9 +252,9 @@ errcode_t profile_open_file(const_profile_filespec_t filespec, break; } if (data) { - retval = profile_update_file_data(data); data->refcount++; (void) k5_mutex_unlock(&g_shared_trees_mutex); + retval = profile_update_file_data(data); free(expanded_filename); prf->data = data; *ret_prof = prf; @@ -263,7 +273,8 @@ errcode_t profile_open_file(const_profile_filespec_t filespec, retval = k5_mutex_init(&data->lock); if (retval) { - profile_close_file(prf); + free(data); + free(prf); return retval; } @@ -295,6 +306,9 @@ errcode_t profile_update_file_data(prf_data_t data) errcode_t retval; #ifdef HAVE_STAT struct stat st; +#ifdef STAT_ONCE_PER_SECOND + time_t now; +#endif #endif FILE *f; @@ -303,12 +317,22 @@ errcode_t profile_update_file_data(prf_data_t data) return retval; #ifdef HAVE_STAT +#ifdef STAT_ONCE_PER_SECOND + now = time(0); + if (now == data->last_stat && data->root != NULL) { + k5_mutex_unlock(&data->lock); + return 0; + } +#endif if (stat(data->filespec, &st)) { retval = errno; k5_mutex_unlock(&data->lock); return retval; } - if (st.st_mtime == data->timestamp) { +#ifdef STAT_ONCE_PER_SECOND + data->last_stat = now; +#endif + if (st.st_mtime == data->timestamp && data->root != NULL) { k5_mutex_unlock(&data->lock); return 0; } @@ -350,6 +374,7 @@ errcode_t profile_update_file_data(prf_data_t data) k5_mutex_unlock(&data->lock); return retval; } + assert(data->root != NULL); #ifdef HAVE_STAT data->timestamp = st.st_mtime; #endif @@ -504,19 +529,19 @@ errcode_t profile_flush_file_data_to_file(prf_data_t data, const char *outfile) void profile_dereference_data(prf_data_t data) { int err; - scan_shared_trees_unlocked(); err = k5_mutex_lock(&g_shared_trees_mutex); if (err) return; profile_dereference_data_locked(data); (void) k5_mutex_unlock(&g_shared_trees_mutex); - scan_shared_trees_unlocked(); } void profile_dereference_data_locked(prf_data_t data) { + scan_shared_trees_locked(); data->refcount--; if (data->refcount == 0) profile_free_file_data(data); + scan_shared_trees_locked(); } int profile_lock_global() @@ -556,12 +581,13 @@ static void profile_free_file_data(prf_data_t data) } } } - if (data->root) - profile_free_node(data->root); - if (data->comment) - free(data->comment); - data->magic = 0; - free(data); + if (data->root) + profile_free_node(data->root); + if (data->comment) + free(data->comment); + data->magic = 0; + k5_mutex_destroy(&data->lock); + free(data); scan_shared_trees_locked(); } diff --git a/src/util/profile/prof_init.c b/src/util/profile/prof_init.c index 02d61ee..0be2a0e 100644 --- a/src/util/profile/prof_init.c +++ b/src/util/profile/prof_init.c @@ -121,6 +121,36 @@ profile_init_path(const_profile_filespec_list_t filepath, } errcode_t KRB5_CALLCONV +profile_is_writable(profile_t profile, int *writable) +{ + if (!profile || profile->magic != PROF_MAGIC_PROFILE) + return PROF_MAGIC_PROFILE; + + if (!writable) + return EINVAL; + + if (profile->first_file) + *writable = (profile->first_file->data->flags & PROFILE_FILE_RW); + + return 0; +} + +errcode_t KRB5_CALLCONV +profile_is_modified(profile_t profile, int *modified) +{ + if (!profile || profile->magic != PROF_MAGIC_PROFILE) + return PROF_MAGIC_PROFILE; + + if (!modified) + return EINVAL; + + if (profile->first_file) + *modified = (profile->first_file->data->flags & PROFILE_FILE_DIRTY); + + return 0; +} + +errcode_t KRB5_CALLCONV profile_flush(profile_t profile) { if (!profile || profile->magic != PROF_MAGIC_PROFILE) diff --git a/src/util/profile/prof_int.h b/src/util/profile/prof_int.h index d276122..43d15b0 100644 --- a/src/util/profile/prof_int.h +++ b/src/util/profile/prof_int.h @@ -11,9 +11,12 @@ #endif #include "k5-thread.h" +#include "k5-platform.h" #include "com_err.h" #include "profile.h" +#define STAT_ONCE_PER_SECOND + #if defined(_WIN32) #define SIZEOF_INT 4 #define SIZEOF_SHORT 2 @@ -27,24 +30,41 @@ typedef long prf_magic_t; * particular configuration file. * * Locking strategy: - * - filespec is fixed after creation + * - filespec, fslen are fixed after creation * - refcount and next should only be tweaked with the global lock held * - other fields can be tweaked after grabbing the in-struct lock */ struct _prf_data_t { prf_magic_t magic; k5_mutex_t lock; - char *comment; struct profile_node *root; +#ifdef STAT_ONCE_PER_SECOND + time_t last_stat; +#endif time_t timestamp; /* time tree was last updated from file */ int flags; /* r/w, dirty */ int upd_serial; /* incremented when data changes */ + char *comment; + + size_t fslen; + + /* Some separation between fields controlled by different + mutexes. Theoretically, both could be accessed at the same + time from different threads on different CPUs with separate + caches. Don't let the threads clobber each other's + changes. One mutex controlling the whole thing would be + better, but sufficient separation might suffice. + + This is icky. I just hope it's adequate. + + For next major release, fix this. */ + union { double d; void *p; UINT64_TYPE ll; k5_mutex_t m; } pad; + int refcount; /* prf_file_t references */ struct _prf_data_t *next; /* Was: "profile_filespec_t filespec". Now: flexible char array ... except, we need to work in C89, so an array length must be specified. */ - size_t fslen; const char filespec[sizeof("/etc/krb5.conf")]; }; diff --git a/src/util/profile/prof_set.c b/src/util/profile/prof_set.c index 67274c2..85f2286 100644 --- a/src/util/profile/prof_set.c +++ b/src/util/profile/prof_set.c @@ -33,9 +33,6 @@ static errcode_t rw_setup(profile_t profile) file = profile->first_file; - if (!(file->data->flags & PROFILE_FILE_RW)) - return PROF_READ_ONLY; - retval = profile_lock_global(); if (retval) return retval; diff --git a/src/util/profile/prof_test1 b/src/util/profile/prof_test1 index 2907f7a..bd49012 100644 --- a/src/util/profile/prof_test1 +++ b/src/util/profile/prof_test1 @@ -1,3 +1,6 @@ +# To do: Should run all tests and return a useful exit status, not +# punt on the first failure. + set wd [pwd] set verbose 0 @@ -107,7 +110,45 @@ proc test2 {} { puts "OK: test2: Modifications don't corrupt existing open handles" } +proc test3 {} { + # lxs said: Start with a relation in the file. Open, delete + # relation, add relation back, list relations. In 1.4 release + # code, got two back. + + global wd verbose + + exec cp $wd/test2.ini $wd/test1c.ini + set p [profile_init_path $wd/test1c.ini] + set sect {{test section 1} quux} + + set v [profile_get_values $p $sect] + set v1 [lindex $v 0] + if $verbose { puts "Old values: $v" } + profile_clear_relation $p $sect + if $verbose { puts "Cleared." } + # profile_get_values raises an exception if no data is there; so if + # it succeeds, the test fails. + catch { + set v [profile_get_values $p $sect] + if $verbose { puts "New values: $v" } + puts stderr "Error: test3: Clearing relation didn't get rid of all values." + exit 1 + } + if $verbose { puts "Adding back $v1 ..." } + profile_add_relation $p $sect $v1 + set v [profile_get_values $p $sect] + if $verbose { puts "New values: $v" } + if [llength $v]!=1 { + puts stderr "Error: test3: Adding one entry after clearing relation leaves [llength $v] entries." + exit 1 + } + profile_abandon $p + file delete $wd/test1c.ini + puts "OK: test3: Clearing relation and adding one entry yields correct count." +} + test1 test2 +test3 exit 0 diff --git a/src/util/profile/prof_tree.c b/src/util/profile/prof_tree.c index 1d96ffb..b014e24 100644 --- a/src/util/profile/prof_tree.c +++ b/src/util/profile/prof_tree.c @@ -466,17 +466,27 @@ errcode_t profile_node_iterator(void **iter_p, struct profile_node **ret_node, * If the file has changed, then the node pointer is invalid, * so we'll have search the file again looking for it. */ + if (iter->file) { + retval = k5_mutex_lock(&iter->file->data->lock); + if (retval) + return retval; + } if (iter->node && (iter->file->data->upd_serial != iter->file_serial)) { iter->flags &= ~PROFILE_ITER_FINAL_SEEN; skip_num = iter->num; iter->node = 0; } - if (iter->node && iter->node->magic != PROF_MAGIC_NODE) + if (iter->node && iter->node->magic != PROF_MAGIC_NODE) { + if (iter->file) + k5_mutex_unlock(&iter->file->data->lock); return PROF_MAGIC_NODE; + } get_new_file: if (iter->node == 0) { if (iter->file == 0 || (iter->flags & PROFILE_ITER_FINAL_SEEN)) { + if (iter->file) + k5_mutex_unlock(&iter->file->data->lock); profile_node_iterator_free(iter_p); if (ret_node) *ret_node = 0; @@ -486,10 +496,18 @@ get_new_file: *ret_value =0; return 0; } + k5_mutex_unlock(&iter->file->data->lock); if ((retval = profile_update_file(iter->file))) { if (retval == ENOENT || retval == EACCES) { /* XXX memory leak? */ iter->file = iter->file->next; + if (iter->file) { + retval = k5_mutex_lock(&iter->file->data->lock); + if (retval) { + profile_node_iterator_free(iter_p); + return retval; + } + } skip_num = 0; retval = 0; goto get_new_file; @@ -498,12 +516,18 @@ get_new_file: return retval; } } + retval = k5_mutex_lock(&iter->file->data->lock); + if (retval) { + profile_node_iterator_free(iter_p); + return retval; + } iter->file_serial = iter->file->data->upd_serial; /* * Find the section to list if we are a LIST_SECTION, * or find the containing section if not. */ section = iter->file->data->root; + assert(section != NULL); for (cpp = iter->names; cpp[iter->done_idx]; cpp++) { for (p=section->first_child; p; p = p->next) { if (!strcmp(p->name, *cpp) && !p->value) @@ -518,7 +542,15 @@ get_new_file: iter->flags |= PROFILE_ITER_FINAL_SEEN; } if (!section) { + k5_mutex_unlock(&iter->file->data->lock); iter->file = iter->file->next; + if (iter->file) { + retval = k5_mutex_lock(&iter->file->data->lock); + if (retval) { + profile_node_iterator_free(iter_p); + return retval; + } + } skip_num = 0; goto get_new_file; } @@ -542,15 +574,26 @@ get_new_file: skip_num--; continue; } + if (p->deleted) + continue; break; } iter->num++; if (!p) { + k5_mutex_unlock(&iter->file->data->lock); iter->file = iter->file->next; + if (iter->file) { + retval = k5_mutex_lock(&iter->file->data->lock); + if (retval) { + profile_node_iterator_free(iter_p); + return retval; + } + } iter->node = 0; skip_num = 0; goto get_new_file; } + k5_mutex_unlock(&iter->file->data->lock); if ((iter->node = p->next) == NULL) iter->file = iter->file->next; if (ret_node) diff --git a/src/util/profile/profile.hin b/src/util/profile/profile.hin index ec822ca..10abe72 100644 --- a/src/util/profile/profile.hin +++ b/src/util/profile/profile.hin @@ -54,6 +54,11 @@ long KRB5_CALLCONV profile_flush_to_buffer void KRB5_CALLCONV profile_free_buffer (profile_t profile, char *buf); +long KRB5_CALLCONV profile_is_writable + (profile_t profile, int *writable); +long KRB5_CALLCONV profile_is_modified + (profile_t profile, int *modified); + void KRB5_CALLCONV profile_abandon (profile_t profile); diff --git a/src/util/ss/ChangeLog b/src/util/ss/ChangeLog index b9b7971..97a99b2 100644 --- a/src/util/ss/ChangeLog +++ b/src/util/ss/ChangeLog @@ -1,3 +1,7 @@ +2005-03-14 Ken Raeburn <raeburn@mit.edu> + + * Makefile.in (EXTRADEPSRCS): Define. + 2004-06-16 Ken Raeburn <raeburn@mit.edu> * Makefile.in (all-mac): Target deleted. diff --git a/src/util/ss/Makefile.in b/src/util/ss/Makefile.in index 07cbab2..20bc8fb 100644 --- a/src/util/ss/Makefile.in +++ b/src/util/ss/Makefile.in @@ -44,6 +44,11 @@ SRCS= $(srcdir)/invocation.c $(srcdir)/help.c \ $(srcdir)/error.c $(srcdir)/prompt.c \ $(srcdir)/request_tbl.c $(srcdir)/list_rqs.c $(srcdir)/pager.c \ $(srcdir)/requests.c $(srcdir)/data.c +EXTRADEPSRCS= \ + $(srcdir)/mk_cmds.c $(srcdir)/utils.c $(srcdir)/options.c \ + cmd_tbl.lex.c ct.tab.c \ + ss_err.c \ + std_rqs.c depend-dependencies: ss_err.h includes std_rqs.o: std_rqs.c ss_err.h @@ -194,4 +199,15 @@ requests.so requests.po $(OUTPRE)requests.$(OBJEXT): requests.c ss_internal.h \ ss.h $(BUILDTOP)/include/ss/ss_err.h $(COM_ERR_DEPS) data.so data.po $(OUTPRE)data.$(OBJEXT): data.c ss_internal.h ss.h \ $(BUILDTOP)/include/ss/ss_err.h $(COM_ERR_DEPS) copyright.h +mk_cmds.so mk_cmds.po $(OUTPRE)mk_cmds.$(OBJEXT): mk_cmds.c copyright.h ss_internal.h \ + ss.h $(BUILDTOP)/include/ss/ss_err.h $(COM_ERR_DEPS) +utils.so utils.po $(OUTPRE)utils.$(OBJEXT): utils.c copyright.h ss_internal.h \ + ss.h $(BUILDTOP)/include/ss/ss_err.h $(COM_ERR_DEPS) +options.so options.po $(OUTPRE)options.$(OBJEXT): options.c copyright.h ss.h \ + $(BUILDTOP)/include/ss/ss_err.h $(COM_ERR_DEPS) +cmd_tbl.lex.o: cmd_tbl.lex.c ct.tab.h +ct.tab.o: ct.tab.c ss.h $(BUILDTOP)/include/ss/ss_err.h \ + $(COM_ERR_DEPS) +ss_err.so ss_err.po $(OUTPRE)ss_err.$(OBJEXT): ss_err.c $(COM_ERR_DEPS) +std_rqs.so std_rqs.po $(OUTPRE)std_rqs.$(OBJEXT): std_rqs.c $(SS_DEPS) $(COM_ERR_DEPS) diff --git a/src/util/support/ChangeLog b/src/util/support/ChangeLog index 2ee4dd9..ecffff7 100644 --- a/src/util/support/ChangeLog +++ b/src/util/support/ChangeLog @@ -1,3 +1,27 @@ +2005-03-20 Alexandra Ellwood <lxs@mit.edu> + + * threads.c (thread_termination): Free array of pointers + to thread-specific data (t) on thread termination. Use + existing mutex to prevent the deletion of the array from + interfering with the global list of thread specific data + (used for library termination). + +2005-02-08 Ken Raeburn <raeburn@mit.edu> + + * threads.c (k5_key_delete) [pthread case]: Reset flags and + destructor function pointer to unset state. + (krb5int_thread_support_init, krb5int_thread_support_fini): If + SHOW_INITFINI_FUNCS is defined, print some tracing messages. + +2005-01-17 Jeffrey Altman <jaltman@mit.edu> + + * threads.c: implement cleanup of static vars on library + unload (for Windows) + +2004-12-15 Jeffrey Altman <jaltman@mit.edu> + + * Makefile.in: rename krb5support_32.dll to k5sprt32.dll + 2004-10-25 Ken Raeburn <raeburn@mit.edu> * libkrb5support.exports: Export krb5int_fac, _lock_fac, diff --git a/src/util/support/Makefile.in b/src/util/support/Makefile.in index 034bade..af3648a 100644 --- a/src/util/support/Makefile.in +++ b/src/util/support/Makefile.in @@ -5,9 +5,9 @@ BUILDTOP=$(REL)..$(S).. RELDIR=../util/support ##DOS##BUILDTOP = ..\.. -##DOS##LIBNAME=$(OUTPRE)krb5support_32.lib +##DOS##LIBNAME=$(OUTPRE)k5sprt32.lib ##DOS##XTRA= -##DOS##OBJFILE=$(OUTPRE)krb5support_32.lst +##DOS##OBJFILE=$(OUTPRE)k5sprt32.lst SED = sed diff --git a/src/util/support/threads.c b/src/util/support/threads.c index eb27f1c..15e991a 100644 --- a/src/util/support/threads.c +++ b/src/util/support/threads.c @@ -117,30 +117,36 @@ static void thread_termination(void *); static void thread_termination (void *tptr) { - int i, pass, none_found; - struct tsd_block *t = tptr; - - /* Make multiple passes in case, for example, a libkrb5 cleanup - function wants to print out an error message, which causes - com_err to allocate a thread-specific buffer, after we just - freed up the old one. - - Shouldn't actually happen, if we're careful, but check just in - case. */ - - pass = 0; - none_found = 0; - while (pass < 4 && !none_found) { - none_found = 1; - for (i = 0; i < K5_KEY_MAX; i++) { - if (destructors_set[i] && destructors[i] && t->values[i]) { - void *v = t->values[i]; - t->values[i] = 0; - (*destructors[i])(v); - none_found = 0; - } - } - } + int err = k5_mutex_lock(&key_lock); + if (err == 0) { + int i, pass, none_found; + struct tsd_block *t = tptr; + + /* Make multiple passes in case, for example, a libkrb5 cleanup + function wants to print out an error message, which causes + com_err to allocate a thread-specific buffer, after we just + freed up the old one. + + Shouldn't actually happen, if we're careful, but check just in + case. */ + + pass = 0; + none_found = 0; + while (pass < 4 && !none_found) { + none_found = 1; + for (i = 0; i < K5_KEY_MAX; i++) { + if (destructors_set[i] && destructors[i] && t->values[i]) { + void *v = t->values[i]; + t->values[i] = 0; + (*destructors[i])(v); + none_found = 0; + } + } + } + free (t); + err = k5_mutex_unlock(&key_lock); + } + /* remove thread from global linked list */ } @@ -305,12 +311,28 @@ int k5_key_delete (k5_key_t keynum) /* XXX Memory leak here! Need to destroy the associated data for all threads. But watch for race conditions in case threads are going away too. */ + assert(destructors_set[keynum] == 1); + destructors_set[keynum] = 0; + destructors[keynum] = 0; LeaveCriticalSection(&key_lock); #else /* POSIX */ - /* Not written yet. */ - abort(); + { + int err; + + /* XXX RESOURCE LEAK: + + Need to destroy the allocated objects first! */ + + err = k5_mutex_lock(&key_lock); + if (err == 0) { + assert(destructors_set[keynum] == 1); + destructors_set[keynum] = 0; + destructors[keynum] = NULL; + k5_mutex_unlock(&key_lock); + } + } #endif @@ -329,6 +351,10 @@ int krb5int_thread_support_init (void) { int err; +#ifdef SHOW_INITFINI_FUNCS + printf("krb5int_thread_support_init\n"); +#endif + #ifndef ENABLE_THREADS /* Nothing to do for TLS initialization. */ @@ -364,6 +390,10 @@ void krb5int_thread_support_fini (void) if (! INITIALIZER_RAN (krb5int_thread_support_init)) return; +#ifdef SHOW_INITFINI_FUNCS + printf("krb5int_thread_support_fini\n"); +#endif + #ifndef ENABLE_THREADS /* Do nothing. */ diff --git a/src/windows/ChangeLog b/src/windows/ChangeLog index e2f888f..c1165b6 100644 --- a/src/windows/ChangeLog +++ b/src/windows/ChangeLog @@ -1,3 +1,7 @@ +2004-12-15 Jeffrey Altman <jaltman@mit.edu> + + * version.rc: rename krb5support.dll to k5sprt32.dll + 2004-09-30 Jeffrey Altman <jaltman@mit.edu> * version.rc: Add pismere condition resource strings diff --git a/src/windows/cns/ChangeLog b/src/windows/cns/ChangeLog index d79cf15..d32fd8a 100644 --- a/src/windows/cns/ChangeLog +++ b/src/windows/cns/ChangeLog @@ -1,3 +1,7 @@ +2005-03-15 Jeffrey Altman <jaltman@mit.edu> + + * tktlist.c: do not mix pointers to long and time_t + 2004-09-30 Jeffrey Altman <jaltman@mit.edu> * Makefile.in: add $(BUILDTOP) to include path for patchlevel.h diff --git a/src/windows/cns/tktlist.c b/src/windows/cns/tktlist.c index 5e15201..68a6f1c 100644 --- a/src/windows/cns/tktlist.c +++ b/src/windows/cns/tktlist.c @@ -56,7 +56,7 @@ typedef struct { * Returns: A pointer to the adjusted time value. */ static char * -short_date (long t) +short_date (time_t t) { static char buf[26 - 4]; char *p; diff --git a/src/windows/installer/nsis/ChangeLog b/src/windows/installer/nsis/ChangeLog index 40d5e1e..12a463e 100644 --- a/src/windows/installer/nsis/ChangeLog +++ b/src/windows/installer/nsis/ChangeLog @@ -1,3 +1,14 @@ +2004-12-18 Jeffrey Altman <jaltman@mit.edu> + +* kfw-fixed.nsi: + Add "Debug Symbols" as a new category. It defaults to on + in debug builds and off in release builds. + +2004-12-15 Jeffrey Altman <jaltman@mit.edu> + +* kfw-fixed.nsi + Add kcpytkt.exe, kdeltkt.exe, k5sprt32.dll, mit2ms.exe + 2004-09-17 Jeffrey Altman <jaltman@mit.edu> * kfw-fixed.nsi: diff --git a/src/windows/installer/nsis/kfw-fixed.nsi b/src/windows/installer/nsis/kfw-fixed.nsi index 6847c82..aacf5b7 100644 --- a/src/windows/installer/nsis/kfw-fixed.nsi +++ b/src/windows/installer/nsis/kfw-fixed.nsi @@ -118,6 +118,8 @@ VIAddVersionKey "PrivateBuild" "Checked/Debug" LangString DESC_secClient ${LANG_ENGLISH} "Client: Allows you to utilize MIT Kerberos from your Windows PC." + LangString DESC_secDebug ${LANG_ENGLISH} "Debug Symbols: Used for debugging problems with MIT Kerberos for Windows" + LangString DESC_secSDK ${LANG_ENGLISH} "SDK: Allows you to build MIT Kerberos aware applications." LangString DESC_secDocs ${LANG_ENGLISH} "Documentation: Release Notes and User Manuals." @@ -197,6 +199,7 @@ Section "KfW Client" secClient !insertmacro ReplaceDLL "${KFW_BIN_DIR}\kpasswd.exe" "$INSTDIR\bin\kpasswd.exe" "$INSTDIR" !insertmacro ReplaceDLL "${KFW_BIN_DIR}\kvno.exe" "$INSTDIR\bin\kvno.exe" "$INSTDIR" !insertmacro ReplaceDLL "${KFW_BIN_DIR}\krb5_32.dll" "$INSTDIR\bin\krb5_32.dll" "$INSTDIR" + !insertmacro ReplaceDLL "${KFW_BIN_DIR}\k5sprt32.dll" "$INSTDIR\bin\k5sprt32.dll" "$INSTDIR" !insertmacro ReplaceDLL "${KFW_BIN_DIR}\krb524.dll" "$INSTDIR\bin\krb524.dll" "$INSTDIR" !insertmacro ReplaceDLL "${KFW_BIN_DIR}\krbcc32.dll" "$INSTDIR\bin\krbcc32.dll" "$INSTDIR" !insertmacro ReplaceDLL "${KFW_BIN_DIR}\krbcc32s.exe" "$INSTDIR\bin\krbcc32s.exe" "$INSTDIR" @@ -209,41 +212,17 @@ Section "KfW Client" secClient !endif !insertmacro ReplaceDLL "${KFW_BIN_DIR}\leashw32.dll" "$INSTDIR\bin\leashw32.dll" "$INSTDIR" !insertmacro ReplaceDLL "${KFW_BIN_DIR}\ms2mit.exe" "$INSTDIR\bin\ms2mit.exe" "$INSTDIR" + !insertmacro ReplaceDLL "${KFW_BIN_DIR}\mit2ms.exe" "$INSTDIR\bin\mit2ms.exe" "$INSTDIR" + !insertmacro ReplaceDLL "${KFW_BIN_DIR}\kcpytkt.exe" "$INSTDIR\bin\kcpytkt.exe" "$INSTDIR" + !insertmacro ReplaceDLL "${KFW_BIN_DIR}\kdeltkt.exe" "$INSTDIR\bin\kdeltkt.exe" "$INSTDIR" !insertmacro ReplaceDLL "${KFW_BIN_DIR}\wshelp32.dll" "$INSTDIR\bin\wshelp32.dll" "$INSTDIR" !insertmacro ReplaceDLL "${KFW_BIN_DIR}\xpprof32.dll" "$INSTDIR\bin\xpprof32.dll" "$INSTDIR" !ifdef DEBUG - File "${KFW_BIN_DIR}\aklog.pdb" - File "${KFW_BIN_DIR}\comerr32.pdb" - File "${KFW_BIN_DIR}\gss.pdb" - File "${KFW_BIN_DIR}\gss-client.pdb" - File "${KFW_BIN_DIR}\gss-server.pdb" - File "${KFW_BIN_DIR}\gssapi32.pdb" - File "${KFW_BIN_DIR}\k524init.pdb" - File "${KFW_BIN_DIR}\kclnt32.pdb" - File "${KFW_BIN_DIR}\kdestroy.pdb" - File "${KFW_BIN_DIR}\kinit.pdb" - File "${KFW_BIN_DIR}\klist.pdb" - File "${KFW_BIN_DIR}\kpasswd.pdb" - File "${KFW_BIN_DIR}\kvno.pdb" - File "${KFW_BIN_DIR}\krb5_32.pdb" - File "${KFW_BIN_DIR}\krb524.pdb" - File "${KFW_BIN_DIR}\krbcc32.pdb" - File "${KFW_BIN_DIR}\krbcc32s.pdb" - File "${KFW_BIN_DIR}\krbv4w32.pdb" - File "${KFW_BIN_DIR}\leashw32.pdb" - File "${KFW_BIN_DIR}\leash32.pdb" - File "${KFW_BIN_DIR}\ms2mit.pdb" - File "${KFW_BIN_DIR}\wshelp32.pdb" - File "${KFW_BIN_DIR}\xpprof32.pdb" - !IFDEF CL_1400 !insertmacro ReplaceDLL "${SYSTEMDIR}\msvcr80d.dll" "$INSTDIR\bin\msvcr80d.dll" "$INSTDIR" - File "${SYSTEMDIR}\msvcr80d.pdb" !insertmacro ReplaceDLL "${SYSTEMDIR}\msvcp80d.dll" "$INSTDIR\bin\msvcp80d.dll" "$INSTDIR" - File "${SYSTEMDIR}\msvcp80d.pdb" !insertmacro ReplaceDLL "${SYSTEMDIR}\mfc80d.dll" "$INSTDIR\bin\mfc80d.dll" "$INSTDIR" - File "${SYSTEMDIR}\mfc80d.pdb" !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC80CHS.DLL" "$INSTDIR\bin\MFC80CHS.DLL" "$INSTDIR" !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC80CHT.DLL" "$INSTDIR\bin\MFC80CHT.DLL" "$INSTDIR" !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC80DEU.DLL" "$INSTDIR\bin\MFC80DEU.DLL" "$INSTDIR" @@ -256,11 +235,8 @@ Section "KfW Client" secClient !ELSE !IFDEF CL_1310 !insertmacro ReplaceDLL "${SYSTEMDIR}\msvcr71d.dll" "$INSTDIR\bin\msvcr71d.dll" "$INSTDIR" - File "${SYSTEMDIR}\msvcr71d.pdb" !insertmacro ReplaceDLL "${SYSTEMDIR}\msvcp71d.dll" "$INSTDIR\bin\msvcp71d.dll" "$INSTDIR" - File "${SYSTEMDIR}\msvcp71d.pdb" !insertmacro ReplaceDLL "${SYSTEMDIR}\mfc71d.dll" "$INSTDIR\bin\mfc71d.dll" "$INSTDIR" - File "${SYSTEMDIR}\mfc71d.pdb" !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC71CHS.DLL" "$INSTDIR\bin\MFC71CHS.DLL" "$INSTDIR" !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC71CHT.DLL" "$INSTDIR\bin\MFC71CHT.DLL" "$INSTDIR" !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC71DEU.DLL" "$INSTDIR\bin\MFC71DEU.DLL" "$INSTDIR" @@ -273,11 +249,8 @@ Section "KfW Client" secClient !ELSE !IFDEF CL_1300 !insertmacro ReplaceDLL "${SYSTEMDIR}\msvcr70d.dll" "$INSTDIR\bin\msvcr70d.dll" "$INSTDIR" - File "${SYSTEMDIR}\msvcr70d.pdb" !insertmacro ReplaceDLL "${SYSTEMDIR}\msvcp70d.dll" "$INSTDIR\bin\msvcp70d.dll" "$INSTDIR" - File "${SYSTEMDIR}\msvcp70d.pdb" !insertmacro ReplaceDLL "${SYSTEMDIR}\mfc70d.dll" "$INSTDIR\bin\mfc70d.dll" "$INSTDIR" - File "${SYSTEMDIR}\mfc70d.pdb" !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC70CHS.DLL" "$INSTDIR\bin\MFC70CHS.DLL" "$INSTDIR" !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC70CHT.DLL" "$INSTDIR\bin\MFC70CHT.DLL" "$INSTDIR" !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC70DEU.DLL" "$INSTDIR\bin\MFC70DEU.DLL" "$INSTDIR" @@ -289,11 +262,8 @@ Section "KfW Client" secClient !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC70KOR.DLL" "$INSTDIR\bin\MFC70KOR.DLL" "$INSTDIR" !ELSE !insertmacro ReplaceDLL "${SYSTEMDIR}\mfc42d.dll" "$INSTDIR\bin\mfc42d.dll" "$INSTDIR" - File "${SYSTEMDIR}\mfc42d.pdb" !insertmacro ReplaceDLL "${SYSTEMDIR}\msvcp60d.dll" "$INSTDIR\bin\msvcp60d.dll" "$INSTDIR" - File "${SYSTEMDIR}\msvcp60d.pdb" !insertmacro ReplaceDLL "${SYSTEMDIR}\msvcrtd.dll" "$INSTDIR\bin\msvcrtd.dll" "$INSTDIR" - File "${SYSTEMDIR}\msvcrtd.pdb" !ENDIF !ENDIF !ENDIF @@ -461,6 +431,7 @@ skipAllowTgtKey: WriteRegDWORD HKLM "Software\Microsoft\Windows NT\CurrentVersion\Terminal Server\Compatibility\Applications\kvno" "Flags" 0x408 WriteRegDWORD HKLM "Software\Microsoft\Windows NT\CurrentVersion\Terminal Server\Compatibility\Applications\ms2mit" "Flags" 0x408 WriteRegDWORD HKLM "Software\Microsoft\Windows NT\CurrentVersion\Terminal Server\Compatibility\Applications\mit2ms" "Flags" 0x408 + WriteRegDWORD HKLM "Software\Microsoft\Windows NT\CurrentVersion\Terminal Server\Compatibility\Applications\mit2ms" "Flags" 0x408 WriteRegDWORD HKLM "Software\Microsoft\Windows NT\CurrentVersion\Terminal Server\Compatibility\Applications\kcpytkt" "Flags" 0x408 WriteRegDWORD HKLM "Software\Microsoft\Windows NT\CurrentVersion\Terminal Server\Compatibility\Applications\kdeltkt" "Flags" 0x408 WriteRegDWORD HKLM "Software\Microsoft\Windows NT\CurrentVersion\Terminal Server\Compatibility\Applications\k95" "Flags" 0x408 @@ -468,6 +439,63 @@ skipAllowTgtKey: SectionEnd +Section "Debug Symbols" secDebug + + SetOutPath "$INSTDIR\bin" + File "${KFW_BIN_DIR}\aklog.pdb" + File "${KFW_BIN_DIR}\comerr32.pdb" + File "${KFW_BIN_DIR}\gss.pdb" + File "${KFW_BIN_DIR}\gss-client.pdb" + File "${KFW_BIN_DIR}\gss-server.pdb" + File "${KFW_BIN_DIR}\gssapi32.pdb" + File "${KFW_BIN_DIR}\k524init.pdb" + File "${KFW_BIN_DIR}\kclnt32.pdb" + File "${KFW_BIN_DIR}\kdestroy.pdb" + File "${KFW_BIN_DIR}\kinit.pdb" + File "${KFW_BIN_DIR}\klist.pdb" + File "${KFW_BIN_DIR}\kpasswd.pdb" + File "${KFW_BIN_DIR}\kvno.pdb" + File "${KFW_BIN_DIR}\krb5_32.pdb" + File "${KFW_BIN_DIR}\k5sprt32.pdb" + File "${KFW_BIN_DIR}\krb524.pdb" + File "${KFW_BIN_DIR}\krbcc32.pdb" + File "${KFW_BIN_DIR}\krbcc32s.pdb" + File "${KFW_BIN_DIR}\krbv4w32.pdb" + File "${KFW_BIN_DIR}\leashw32.pdb" + File "${KFW_BIN_DIR}\leash32.pdb" + File "${KFW_BIN_DIR}\ms2mit.pdb" + File "${KFW_BIN_DIR}\mit2ms.pdb" + File "${KFW_BIN_DIR}\kcpytkt.pdb" + File "${KFW_BIN_DIR}\kdeltkt.pdb" + File "${KFW_BIN_DIR}\wshelp32.pdb" + File "${KFW_BIN_DIR}\xpprof32.pdb" + +!IFDEF DEBUG +!IFDEF CL_1400 + File "${SYSTEMDIR}\msvcr80d.pdb" + File "${SYSTEMDIR}\msvcp80d.pdb" + File "${SYSTEMDIR}\mfc80d.pdb" +!ELSE +!IFDEF CL_1310 + File "${SYSTEMDIR}\msvcr71d.pdb" + File "${SYSTEMDIR}\msvcp71d.pdb" + File "${SYSTEMDIR}\mfc71d.pdb" +!ELSE +!IFDEF CL_1300 + File "${SYSTEMDIR}\msvcr70d.pdb" + File "${SYSTEMDIR}\msvcp70d.pdb" + File "${SYSTEMDIR}\mfc70d.pdb" +!ELSE + File "${SYSTEMDIR}\mfc42d.pdb" + File "${SYSTEMDIR}\msvcp60d.pdb" + File "${SYSTEMDIR}\msvcrtd.pdb" +!ENDIF +!ENDIF +!ENDIF +!ENDIF + +SectionEnd + ;---------------------- ; Kerberos for Windows SDK Section "KfW SDK" secSDK @@ -806,6 +834,17 @@ DoNotRestart: no_remove_uninstaller: contInstall: + ; Never install debug symbols unless explicitly selected, except in DEBUG mode +!IFNDEF DEBUG + SectionGetFlags ${secDebug} $0 + IntOp $0 $0 & ${SECTION_OFF} + SectionSetFlags ${secDebug} $0 +!ELSE + SectionGetFlags ${secDebug} $0 + IntOp $0 $0 | ${SF_SELECTED} + SectionSetFlags ${secDebug} $0 +!ENDIF + ; Our logic should be like this. ; 1) If no KfW components are installed, we do a clean install with default options. (Client/Docs) ; 2) If existing modules are installed, we keep them selected @@ -1019,6 +1058,7 @@ FunctionEnd !insertmacro MUI_DESCRIPTION_TEXT ${secClient} $(DESC_secClient) !insertmacro MUI_DESCRIPTION_TEXT ${secSDK} $(DESC_secSDK) !insertmacro MUI_DESCRIPTION_TEXT ${secDocs} $(DESC_secDocs) + !insertmacro MUI_DESCRIPTION_TEXT ${secDebug} $(DESC_secDebug) !insertmacro MUI_FUNCTION_DESCRIPTION_END ;-------------------------------- @@ -1060,6 +1100,7 @@ StartRemove: Delete /REBOOTOK "$INSTDIR\bin\kpasswd.exe" Delete /REBOOTOK "$INSTDIR\bin\kvno.exe" Delete /REBOOTOK "$INSTDIR\bin\krb5_32.dll" + Delete /REBOOTOK "$INSTDIR\bin\k5sprt32.dll" Delete /REBOOTOK "$INSTDIR\bin\krb524.dll" Delete /REBOOTOK "$INSTDIR\bin\krbcc32.dll" Delete /REBOOTOK "$INSTDIR\bin\krbcc32s.exe" @@ -1072,10 +1113,12 @@ StartRemove: !endif Delete /REBOOTOK "$INSTDIR\bin\leashw32.dll" Delete /REBOOTOK "$INSTDIR\bin\ms2mit.exe" + Delete /REBOOTOK "$INSTDIR\bin\mit2ms.exe" + Delete /REBOOTOK "$INSTDIR\bin\kcpytkt.exe" + Delete /REBOOTOK "$INSTDIR\bin\kdeltkt.exe" Delete /REBOOTOK "$INSTDIR\bin\wshelp32.dll" Delete /REBOOTOK "$INSTDIR\bin\xpprof32.dll" -!IFDEF DEBUG Delete /REBOOTOK "$INSTDIR\bin\aklog.pdb" Delete /REBOOTOK "$INSTDIR\bin\comerr32.pdb" Delete /REBOOTOK "$INSTDIR\bin\gss.pdb" @@ -1090,15 +1133,20 @@ StartRemove: Delete /REBOOTOK "$INSTDIR\bin\kpasswd.pdb" Delete /REBOOTOK "$INSTDIR\bin\kvno.pdb" Delete /REBOOTOK "$INSTDIR\bin\krb5_32.pdb" + Delete /REBOOTOK "$INSTDIR\bin\k5sprt32.pdb" Delete /REBOOTOK "$INSTDIR\bin\krb524.pdb" Delete /REBOOTOK "$INSTDIR\bin\krbcc32.pdb" Delete /REBOOTOK "$INSTDIR\bin\krbcc32s.pdb" Delete /REBOOTOK "$INSTDIR\bin\krbv4w32.pdb" Delete /REBOOTOK "$INSTDIR\bin\leashw32.pdb" Delete /REBOOTOK "$INSTDIR\bin\ms2mit.pdb" + Delete /REBOOTOK "$INSTDIR\bin\mit2ms.pdb" + Delete /REBOOTOK "$INSTDIR\bin\kcpytkt.pdb" + Delete /REBOOTOK "$INSTDIR\bin\kdeltkt.pdb" Delete /REBOOTOK "$INSTDIR\bin\wshelp32.pdb" Delete /REBOOTOK "$INSTDIR\bin\xpprof32.pdb" +!IFDEF DEBUG !IFDEF CL_1400 Delete /REBOOTOK "$INSTDIR\bin\msvcr80d.dll" Delete /REBOOTOK "$INSTDIR\bin\msvcr80d.pdb" diff --git a/src/windows/installer/wix/ChangeLog b/src/windows/installer/wix/ChangeLog index 42b069d..fe818ac 100644 --- a/src/windows/installer/wix/ChangeLog +++ b/src/windows/installer/wix/ChangeLog @@ -1,3 +1,14 @@ +2004-12-18 Jeffrey Altman <jaltman@mit.edu> + + Add Debug Symbols as an optional install feature for + release builds of KFW + +2004-12-15 Jeffrey Altman <jaltman@mit.edu> + + Add kcpytkt.exe, kdeltkt.exe, k5sprt32.dll mit2ms.exe + + Update to Wix 2.1 installer + 2004-09-16 Jeffrey Altman <jaltman@mit.edu> Remove trailing slash from PATH diff --git a/src/windows/installer/wix/config.wxi b/src/windows/installer/wix/config.wxi index f3f5afc..8c361eb 100644 --- a/src/windows/installer/wix/config.wxi +++ b/src/windows/installer/wix/config.wxi @@ -52,6 +52,19 @@ <?include lang\config_$(var.BuildLang).wxi?> + <!-- Parameters for the features containing debug symbols --> + <?ifdef DebugSyms?> + <?ifdef Debug?> + <?define DebugSymInstallDefault="followParent"?> + <?define DebugSymLowLevel="30"?> + <?define DebugSymHighLevel="130"?> + <?else?> + <?define DebugSymInstallDefault="followParent"?> + <?define DebugSymLowLevel="130"?> + <?define DebugSymHighLevel="130"?> + <?endif?> + <?endif?> + <!-- Configuration macros --> <?ifndef LeashAfsStatus?> <?define LeashAfsStatus="1"?> diff --git a/src/windows/installer/wix/features.wxi b/src/windows/installer/wix/features.wxi index e9e3d87..12e25c9 100644 --- a/src/windows/installer/wix/features.wxi +++ b/src/windows/installer/wix/features.wxi @@ -39,9 +39,21 @@ Description="$(loc.KerberosClientDesc)" InstallDefault="local" Title="$(loc.KerberosClientTitle)" - FollowParent="yes" Level="30"> + <?ifdef DebugSyms?> + <Feature + Id="feaKfwClientDebug" + AllowAdvertise="no" + Description="$(loc.StrKerberosClientDebugDesc)" + Display="expand" + InstallDefault="$(var.DebugSymInstallDefault)" + Level="$(var.DebugSymLowLevel)" + Title="$(loc.StrKerberosClientDebugTitle)"> + <ComponentRef Id="cmf_bin_debug"/> + </Feature> + <?endif?> + <ComponentRef Id="cmf_aklog_exe" /> <ComponentRef Id="cmf_comerr32_dll" /> <ComponentRef Id="cmf_gss_exe" /> @@ -51,11 +63,14 @@ <ComponentRef Id="cmf_k524init_exe" /> <ComponentRef Id="cmf_kclnt32_dll" /> <ComponentRef Id="cmf_kdestroy_exe" /> + <ComponentRef Id="cmf_kcpytkt_exe" /> + <ComponentRef Id="cmf_kdeltkt_exe" /> <ComponentRef Id="cmf_kinit_exe" /> <ComponentRef Id="cmf_klist_exe" /> <ComponentRef Id="cmf_kpasswd_exe" /> <ComponentRef Id="cmf_kvno_exe" /> <ComponentRef Id="cmf_krb5_32_dll" /> + <ComponentRef Id="cmf_k5sprt32_dll" /> <ComponentRef Id="cmf_krb524_dll" /> <ComponentRef Id="cmf_krbcc32_dll" /> <ComponentRef Id="cmf_krbcc32s_exe" /> @@ -106,13 +121,10 @@ <ComponentRef Id="rcm_leashdll_17" /> <ComponentRef Id="cmf_ms2mit_exe" /> + <ComponentRef Id="cmf_mit2ms_exe" /> <ComponentRef Id="cmf_wshelp32_dll" /> <ComponentRef Id="cmf_xpprof32_dll" /> - <?ifdef Debug?> - <ComponentRef Id="cmf_bin_debug"/> - <?endif?> - <ComponentRef Id="cmf_psapi_dll" /> <?ifndef Debug?> diff --git a/src/windows/installer/wix/files.wxi b/src/windows/installer/wix/files.wxi index ac581cf..386402c 100644 --- a/src/windows/installer/wix/files.wxi +++ b/src/windows/installer/wix/files.wxi @@ -102,6 +102,16 @@ <Registry Id="reg_ts_kdestroy_0" Root="HKLM" Key="Software\Microsoft\Windows NT\CurrentVersion\Terminal Server\Compatibility\Applications\kdestroy" Action="createKeyAndRemoveKeyOnUninstall" /> <Registry Id="reg_ts_kdestroy_1" Root="HKLM" Key="Software\Microsoft\Windows NT\CurrentVersion\Terminal Server\Compatibility\Applications\kdestroy" Name="Flags" Type="integer" Value="1032" /> </Component> + <Component Id="cmf_kcpytkt_exe" Guid="6B20E57C-0033-4dcf-B3C9-74ED0B2CF46E" DiskId="1"> + <File Id="fil_kcpytkt_exe" LongName="kcpytkt.exe" Name="kcpytkt.exe" KeyPath="yes" /> + <Registry Id="reg_ts_kcpytkt_0" Root="HKLM" Key="Software\Microsoft\Windows NT\CurrentVersion\Terminal Server\Compatibility\Applications\kcpytkt" Action="createKeyAndRemoveKeyOnUninstall" /> + <Registry Id="reg_ts_kcpytkt_1" Root="HKLM" Key="Software\Microsoft\Windows NT\CurrentVersion\Terminal Server\Compatibility\Applications\kcpytkt" Name="Flags" Type="integer" Value="1032" /> + </Component> + <Component Id="cmf_kdeltkt_exe" Guid="C7528C87-9B61-439a-8EA8-AD4BE3D758F9" DiskId="1"> + <File Id="fil_kdeltkt_exe" LongName="kdeltkt.exe" Name="kdeltkt.exe" KeyPath="yes" /> + <Registry Id="reg_ts_kdeltkt_0" Root="HKLM" Key="Software\Microsoft\Windows NT\CurrentVersion\Terminal Server\Compatibility\Applications\kdeltkt" Action="createKeyAndRemoveKeyOnUninstall" /> + <Registry Id="reg_ts_kdeltkt_1" Root="HKLM" Key="Software\Microsoft\Windows NT\CurrentVersion\Terminal Server\Compatibility\Applications\kdeltkt" Name="Flags" Type="integer" Value="1032" /> + </Component> <Component Id="cmf_kinit_exe" Guid="80643A09-EF28-4714-BC62-B64FC5B17CAA" DiskId="1"> <File Id="fil_kinit_exe" LongName="kinit.exe" Name="kinit.exe" KeyPath="yes" /> <Registry Id="reg_ts_kinit_0" Root="HKLM" Key="Software\Microsoft\Windows NT\CurrentVersion\Terminal Server\Compatibility\Applications\kinit" Action="createKeyAndRemoveKeyOnUninstall" /> @@ -126,6 +136,9 @@ <File Id="fil_krb5_32_dll" LongName="krb5_32.dll" Name="krb5_32.dll" KeyPath="yes" /> <Environment Id="env_kclient_path" Action="set" Name="PATH" Part="last" System="yes" Value="[KERBEROSDIR]bin" /> </Component> + <Component Id="cmf_k5sprt32_dll" Guid="F2381331-9201-4c02-866F-2038676771D4" DiskId="1"> + <File Id="fil_k5sprt32_dll" LongName="k5sprt32.dll" Name="k5sprt32.dll" /> + </Component> <Component Id="cmf_krb524_dll" Guid="98685874-A9AA-4BC5-9830-271D9CF52C17" DiskId="1"> <File Id="fil_krb524_dll" LongName="krb524.dll" Name="krb524.dll" KeyPath="yes" /> </Component> @@ -268,6 +281,11 @@ <Registry Id="reg_ts_ms2mit_0" Root="HKLM" Key="Software\Microsoft\Windows NT\CurrentVersion\Terminal Server\Compatibility\Applications\ms2mit" Action="createKeyAndRemoveKeyOnUninstall" /> <Registry Id="reg_ts_ms2mit_1" Root="HKLM" Key="Software\Microsoft\Windows NT\CurrentVersion\Terminal Server\Compatibility\Applications\ms2mit" Name="Flags" Type="integer" Value="1032" /> </Component> + <Component Id="cmf_mit2ms_exe" Guid="4F487781-5B55-48c1-A3FA-8BC6ECA4FEA1" DiskId="1"> + <File Id="fil_mit2ms_exe" LongName="mit2ms.exe" Name="mit2ms.exe" KeyPath="yes" /> + <Registry Id="reg_ts_mit2ms_0" Root="HKLM" Key="Software\Microsoft\Windows NT\CurrentVersion\Terminal Server\Compatibility\Applications\mit2ms" Action="createKeyAndRemoveKeyOnUninstall" /> + <Registry Id="reg_ts_mit2ms_1" Root="HKLM" Key="Software\Microsoft\Windows NT\CurrentVersion\Terminal Server\Compatibility\Applications\mit2ms" Name="Flags" Type="integer" Value="1032" /> + </Component> <Component Id="cmf_wshelp32_dll" Guid="B9D9F5F1-CA93-4F56-B6F8-343F21484CDE" DiskId="1"> <File Id="fil_wshelp32_dll" LongName="wshelp32.dll" Name="wshelp32.dll" KeyPath="yes" /> </Component> @@ -287,11 +305,14 @@ <File Id="fil_k524init_pdb" LongName="k524init.pdb" Name="k524init.pdb" /> <File Id="fil_kclnt32_pdb" LongName="kclnt32.pdb" Name="kclnt32.pdb" /> <File Id="fil_kdestroy_pdb" LongName="kdestroy.pdb" Name="kdestroy.pdb" /> + <File Id="fil_kcpytkt_pdb" LongName="kcpytkt.pdb" Name="kcpytkt.pdb" /> + <File Id="fil_kdeltkt_pdb" LongName="kdeltkt.pdb" Name="kdeltkt.pdb" /> <File Id="fil_kinit_pdb" LongName="kinit.pdb" Name="kinit.pdb" /> <File Id="fil_klist_pdb" LongName="klist.pdb" Name="klist.pdb" /> <File Id="fil_kpasswd_pdb" LongName="kpasswd.pdb" Name="kpasswd.pdb" /> <File Id="fil_kvno_pdb" LongName="kvno.pdb" Name="kvno.pdb" /> <File Id="fil_krb5_32_pdb" LongName="krb5_32.pdb" Name="krb5_32.pdb" KeyPath="yes" /> + <File Id="fil_k5sprt32_pdb" LongName="k5sprt32.pdb" Name="k5sprt32.pdb" /> <File Id="fil_krb524_pdb" LongName="krb524.pdb" Name="krb524.pdb" /> <File Id="fil_krbcc32_pdb" LongName="krbcc32.pdb" Name="krbcc32.pdb" /> <File Id="fil_krbcc32s_pdb" LongName="krbcc32s.pdb" Name="krbcc32s.pdb" /> @@ -299,6 +320,7 @@ <File Id="fil_leash32_pdb" LongName="leash32.pdb" Name="leash32.pdb" /> <File Id="fil_leashw32_pdb" LongName="leashw32.pdb" Name="leashw32.pdb" /> <File Id="fil_ms2mit_pdb" LongName="ms2mit.pdb" Name="ms2mit.pdb" /> + <File Id="fil_mit2ms_pdb" LongName="mit2ms.pdb" Name="mit2ms.pdb" /> <File Id="fil_wshelp32_pdb" LongName="wshelp32.pdb" Name="wshelp32.pdb" /> <File Id="fil_xpprof32_pdb" LongName="xpprof32.pdb" Name="xpprof32.pdb" /> </Component> @@ -696,7 +718,7 @@ </Directory> <Directory Id="ProgramMenuFolder"> - <Directory Id="dirShortcut" LongName="$(loc.ProductName)" Name="$(loc.ProductNameShort)"> + <Directory Id="dirShortcut" LongName="$(loc.ProductName)" Name="KFW"> </Directory> </Directory> <Directory Id="StartupFolder"> diff --git a/src/windows/installer/wix/lang/ChangeLog b/src/windows/installer/wix/lang/ChangeLog index f8aa27c..23a6add 100644 --- a/src/windows/installer/wix/lang/ChangeLog +++ b/src/windows/installer/wix/lang/ChangeLog @@ -1,3 +1,12 @@ +2004-12-18 Jeffrey Altman <jaltman@mit.edu> + + Add Debug Symbols as an optional install feature for + release builds of KFW2004-08-20 Jeffrey Altman <jaltman@mit.edu> + +2004-12-15 Jeffrey Altman <jaltman@mit.edu> + + Update for WiX 2.1 installer + 2004-08-20 Asanka Herath <asanka@mit.edu> New WiX 2.0 MSI for KFW
\ No newline at end of file diff --git a/src/windows/installer/wix/lang/strings_1033.wxl b/src/windows/installer/wix/lang/strings_1033.wxl index 324831d..4106736 100644 --- a/src/windows/installer/wix/lang/strings_1033.wxl +++ b/src/windows/installer/wix/lang/strings_1033.wxl @@ -26,7 +26,7 @@ --> <String Id="ProductName">Kerberos for Windows</String> - <String Id="ProductNameShort">Kerberos</String> + <String Id="ProductNameShort">KFW</String> <String Id="ProductMIT">MIT</String> <String Id="ProductDebug">Debug/Checked</String> <String Id="ProductBeta">Beta</String> @@ -39,6 +39,9 @@ <String Id="KerberosClientTitle">Client</String> <String Id="KerberosClientDesc">Kerberos client utilities, libraries and documentation</String> + <String Id="StrKerberosClientDebugTitle">Debug symbols</String> + <String Id="StrKerberosClientDebugDesc">Debugging symbols for Kerberos for Windows components.</String> + <String Id="KerberosSDKTitle">SDK</String> <String Id="KerberosSDKDesc">Libraries and header files for developing software with Kerberos</String> @@ -51,5 +54,5 @@ <String Id="IE501Required">Kerberos for Windows requires Microsoft Internet Explorer version 5.01 or higher. Please resolve this and run the installer again.</String> <String Id="ARPComments">Build of</String> - + </WixLocalization>
\ No newline at end of file diff --git a/src/windows/installer/wix/site-local.wxi b/src/windows/installer/wix/site-local.wxi index 074492e..e008130 100644 --- a/src/windows/installer/wix/site-local.wxi +++ b/src/windows/installer/wix/site-local.wxi @@ -6,13 +6,13 @@ <!-- TargetDir should point to build target directory and must end with a backslash. If not specified, assume we are in TargetDir\install --> - <?define TargetDir="d:\work\kfwbins\"?> + <?define TargetDir="c:\temp\kfw\kfw-2.6.6-alpha\"?> <!-- ConfigDir should point to directory containing configuration files (krb5.ini, krb.con, krbrealm.con) to be bundled with the installer. The directory name should end with a backslash. --> - <?define ConfigDir="$(env.SystemRoot)\"?> + <?define ConfigDir="c:\temp\kfw\kfw-2.5-extra\sample-config\"?> <!-- VersionMajor, VersionMinor and VersionPatch must all be specified, or none should be specified (in which case, the defaults will be @@ -44,11 +44,14 @@ <!-- At most one of the following could be defined and must correspond to the type of build performed. --> - <!-- <?define Debug?> --> - <?define Release?> - + <?define Debug?> + <!-- <?define Release?> --> + + <!-- We are including debug symbols anyway. Undefine this for a leaner installer without debug syms. --> + <?define DebugSyms?> + <!-- Optional defines --> - <!-- <?define Beta=""?> --> <!-- Numeric Beta identifier --> + <?define Beta="1"?> <!-- Numeric Beta identifier --> <!-- <?define OldHelp?> --> <!-- Specifies the use of the old leash32.hlp file instead of the new leash32.chm file --> @@ -69,7 +72,7 @@ <?ifndef VersionMajor?> <?define VersionMajor="2"?> <?define VersionMinor="6"?> - <?define VersionPatch="0001"?> + <?define VersionPatch="6"?> <?else?> <?if Not ($(var.VersionMinor) And $(var.VersionPatch))?> <?error VersionMajor, VersionMinor and VersionPatch should be specified together?> diff --git a/src/windows/version.rc b/src/windows/version.rc index c1b50f2..05dba75 100644 --- a/src/windows/version.rc +++ b/src/windows/version.rc @@ -59,7 +59,7 @@ #if !defined(_WIN32) #error not win32?? #else -#define K5_ORIGINAL_NAME "krb5support32.dll\0" +#define K5_ORIGINAL_NAME "k5sprt32.dll\0" #endif #endif /* support */ |