From: Miro Jurisic Date: Tue, 14 Jul 1998 15:18:46 +0000 (+0000) Subject: Added new Mac files X-Git-Tag: krb5-1.1-beta1~659 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=388fb30ee9e9ba6d069fe9565baf348321e92512;p=krb5.git Added new Mac files git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@10636 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/mac/GSS.CFM.c b/src/mac/GSS.CFM.c new file mode 100644 index 000000000..686ee20bf --- /dev/null +++ b/src/mac/GSS.CFM.c @@ -0,0 +1,42 @@ +/* + * Copyright (C) 1997 by the Massachusetts Institute of Technology + * All rights reserved. + * + * For copying and distribution information, please see the file + * COPYRIGHT. + */ + + +#include + +#include "gssapi_err_generic.h" +#include "gssapi_err_krb5.h" + + +OSErr __initializeGSS(CFragInitBlockPtr ibp); +void __terminateGSS(void); + +OSErr __initializeGSS(CFragInitBlockPtr ibp) +{ + OSErr err = noErr; + + /* Do normal init of the shared library */ + err = __initialize(); + + /* Initialize the error tables */ + if (err == noErr) { + add_error_table(&et_k5g_error_table); + add_error_table(&et_ggss_error_table); + } + + return err; +} + +void __terminateGSS(void) +{ + + remove_error_table(&et_k5g_error_table); + remove_error_table(&et_ggss_error_table); + + __terminate(); +} diff --git a/src/mac/K5.CFM.c b/src/mac/K5.CFM.c new file mode 100644 index 000000000..a56a8a4a7 --- /dev/null +++ b/src/mac/K5.CFM.c @@ -0,0 +1,59 @@ +/* + * Copyright (C) 1997 by the Massachusetts Institute of Technology + * All rights reserved. + * + * For copying and distribution information, please see the file + * COPYRIGHT. + */ + + +#include + +#include "ShlibTestTrack.h" + +#include "krb5_err.h" +#include "kv5m_err.h" +#include "asn1_err.h" +#include "kdb5_err.h" +#include "profile.h" +#include "adm_err.h" + + +OSErr __initializeK5(CFragInitBlockPtr ibp); +void __terminateGSSK5glue(void); + +OSErr __initializeK5(CFragInitBlockPtr ibp) +{ + OSErr err = noErr; + + /* Do normal init of the shared library */ + err = __initialize(); + + /* Initialize the error tables */ + if (err == noErr) { + add_error_table(&et_krb5_error_table); + add_error_table(&et_kv5m_error_table); + add_error_table(&et_kdb5_error_table); + add_error_table(&et_asn1_error_table); + add_error_table(&et_prof_error_table); + add_error_table(&et_kadm_error_table); + + /* TestTrack the shared library */ + err = ShlibTestTrack(ibp); + } + + return err; +} + +void __terminateK5(void) +{ + + remove_error_table(&et_krb5_error_table); + remove_error_table(&et_kv5m_error_table); + remove_error_table(&et_kdb5_error_table); + remove_error_table(&et_asn1_error_table); + remove_error_table(&et_prof_error_table); + remove_error_table(&et_kadm_error_table); + + __terminate(); +} diff --git a/src/mac/K5Library.exp b/src/mac/K5Library.exp new file mode 100644 index 000000000..716a51958 --- /dev/null +++ b/src/mac/K5Library.exp @@ -0,0 +1,204 @@ +#---------------------------------------------------- +# KRB5.DEF - KRB5.DLL module definition file +#---------------------------------------------------- + +# Kerberos 5 + krb5_build_principal + krb5_build_principal_ext + krb5_copy_addr + krb5_copy_addresses + krb5_copy_authdata + krb5_copy_authenticator + krb5_copy_checksum + krb5_copy_creds + krb5_copy_data + krb5_copy_keyblock + krb5_copy_keyblock_contents + krb5_copy_principal + krb5_copy_ticket + krb5_decrypt_tkt_part + krb5_free_address + krb5_free_addresses + krb5_free_ap_rep + krb5_free_ap_rep_enc_part + krb5_free_ap_req + krb5_free_authdata + krb5_free_authenticator + krb5_free_authenticator_contents + krb5_free_checksum + krb5_free_context + krb5_free_cred + krb5_free_cred_contents + krb5_free_cred_enc_part + krb5_free_creds + krb5_free_data + krb5_free_data_contents + krb5_free_enc_kdc_rep_part + krb5_free_enc_tkt_part + krb5_free_error + krb5_free_host_realm + krb5_free_kdc_rep + krb5_free_kdc_req + krb5_free_keyblock + krb5_free_keyblock_contents + krb5_free_last_req + krb5_free_pa_data + krb5_free_principal + krb5_free_priv + krb5_free_priv_enc_part + krb5_free_pwd_data + krb5_free_pwd_sequences + krb5_free_safe + krb5_free_tgt_creds + krb5_free_ticket + krb5_free_tickets + krb5_free_tkt_authent + krb5_fwd_tgt_creds + krb5_get_credentials + krb5_get_credentials_renew + krb5_get_credentials_validate + krb5_get_default_realm + krb5_get_host_realm + krb5_get_in_tkt + krb5_get_in_tkt_with_keytab + krb5_get_in_tkt_with_password + krb5_get_in_tkt_with_skey + krb5_get_init_creds_opt_init + krb5_get_init_creds_opt_set_tkt_life + krb5_get_init_creds_opt_set_renew_life + krb5_get_init_creds_opt_set_forwardable + krb5_get_init_creds_opt_set_proxiable + krb5_get_init_creds_opt_set_etype_list + krb5_get_init_creds_opt_set_address_list + krb5_get_init_creds_opt_set_preauth_list + krb5_get_init_creds_opt_set_salt + krb5_get_init_creds_password + krb5_get_init_creds_keytab + krb5_get_init_creds_opt_init + krb5_get_notification_message + krb5_init_context + krb5_mk_error + krb5_mk_priv + krb5_mk_rep + krb5_mk_req + krb5_mk_req_extended + krb5_mk_safe + krb5_os_localaddr + krb5_parse_name + krb5_principal_compare + krb5_rd_cred + krb5_rd_error + krb5_rd_priv + krb5_rd_rep + krb5_rd_req + krb5_rd_safe + krb5_read_password + krb5_recvauth + krb5_sendauth + krb5_sname_to_principal + krb5_timeofday + krb5_unparse_name + krb5_unparse_name_ext + krb5_us_timeofday + krb5_get_server_rcache +# + krb5_use_enctype + krb5_checksum_size + krb5_encrypt_size + krb5_calculate_checksum + krb5_verify_checksum + krb5_eblock_enctype +# + krb5_decrypt + krb5_encrypt + krb5_string_to_key + krb5_process_key + krb5_finish_key + krb5_init_random_key + krb5_finish_random_key + krb5_random_key +# + krb5_425_conv_principal + krb5_524_conv_principal +# + krb5_cksumtype_to_string + krb5_deltat_to_string + krb5_enctype_to_string + krb5_salttype_to_string + krb5_string_to_cksumtype + krb5_string_to_deltat + krb5_string_to_enctype + krb5_string_to_salttype + krb5_string_to_timestamp + krb5_timestamp_to_sfstring + krb5_timestamp_to_string +# + krb5_auth_con_free + krb5_auth_con_genaddrs + krb5_auth_con_getflags + krb5_auth_con_getkey + krb5_auth_con_getlocalsubkey + krb5_auth_con_getremotesubkey + krb5_auth_con_init + krb5_auth_con_setflags + krb5_auth_con_getlocalseqnumber + krb5_auth_con_getremoteseqnumber + krb5_auth_con_setuseruserkey + krb5_auth_con_getauthenticator + krb5_auth_con_set_req_cksumtype + krb5_auth_con_setrcache +# + krb5_cc_default + krb5_cc_default_name + krb5_cc_register + krb5_cc_resolve +# + krb5_kt_default + krb5_kt_register + krb5_kt_resolve + krb5_kt_add_entry + krb5_kt_free_entry + krb5_kt_read_service_key + krb5_kt_remove_entry +#Kadm routines +# krb5_adm_connect +# krb5_adm_disconnect +# krb5_free_adm_data +# krb5_read_adm_reply +# krb5_send_adm_cmd +# + krb5_change_password +#Temporary exports (DO NOT USE) + decode_krb5_ticket + profile_get_values + krb5_random_confounder + krb5_size_opaque + krb5_internalize_opaque + krb5_externalize_opaque + krb5_ser_pack_int32 + krb5_ser_unpack_int32 + krb5_ser_pack_bytes + krb5_ser_unpack_bytes + krb5_ser_auth_context_init + krb5_ser_context_init + krb5_ser_ccache_init + krb5_ser_keytab_init + krb5_ser_rcache_init + decode_krb5_ap_req + krb5_mcc_ops + +#com_err -- we should really have this in a separate lib! + add_error_table + remove_error_table + error_message + +# DES exports + mit_des_ecb_encrypt + mit_des_init_random_key + mit_des_key_sched + mit_des_random_key +# mit_des_new_random_key +# mit_des_pcbc_encrypt +# mit_des_quad_cksum +# mit_des_string_to_key +# mit_des_set_random_generator_seed diff --git a/src/mac/macfile_gen.pl b/src/mac/macfile_gen.pl new file mode 100644 index 000000000..d307d9cb7 --- /dev/null +++ b/src/mac/macfile_gen.pl @@ -0,0 +1,372 @@ +#!/usr/athena/bin/perl -w + +if (defined ($ENV{'KERBSRCROOT'})) +{ + $ROOT=$ENV{'KERBSRCROOT'}; +} else { + $ROOT='..'; +} + +print(STDERR "Creating makefile.\n"); + +@MACLIST=&make_macfile_maclist(&make_macfile_list()); +@MACSRCS=grep(/\.c$/, @MACLIST); +@MACSRCSK5=grep($_!~/:gssapi:/, @MACSRCS); +@MACSRCSGSS=grep($_=~/:gssapi:/, @MACSRCS); + +$MAKEFILE=&chew_on_filename("Makefile"); +&delete_file("Makefile") && print(STDERR "Old makefile ($MAKEFILE) deleted.\n"); +open(MF, ">".&chew_on_filename("Makefile")) || die "Can't open Makefile for writing"; +print(MF "SRCS = ", join(" ", @MACSRCS), "\n\n"); +@MFSRCD=grep(s/(.*:)[^:]*\.c$/$1/, ©_array(@MACLIST)); +@MFSRCD=&uniq(sort(@MFSRCD)); +print(MF "SRCDIRS = @MFSRCD\n\n"); + +@MACSRCSGSS=grep(s/.*://, @MACSRCSGSS); +@MACSRCSK5=grep(s/.*://, @MACSRCSK5); + +for $A (0..2) +{ + @ARCH=('68K', '68K', '68K') if $A==0; + @ARCH=('68KCFM', 'CFM68', 'CFM-68K') if $A==1; + @ARCH=('PPC', 'PPC', 'PPC') if $A==2; + + print MF "GSSOBJS$ARCH[0] = "; + for $SRC (@MACSRCSGSS) + { + print(MF ":bin:$ARCH[2]:$SRC.$ARCH[1].o "); + } + print(MF "\n\n"); + + print MF "K5OBJS$ARCH[0] = "; + for $SRC (@MACSRCSK5) + { + print(MF ":bin:$ARCH[2]:$SRC.$ARCH[1].o "); + } + print(MF "\n\n"); +} + +@HEADERS=grep(s/(.*:)[^:]*\.h$/ -i $1/, @MACLIST); +print(MF "AUTOINCLUDES = ", &uniq(sort(@HEADERS)), "\n"); + +print(MF "\n# TEMPLATE BEGINS HERE\n\n"); + +@TEMPLATE=&read_file("mac/Makefile.tmpl"); +$TEMPLATE=join("\n", @TEMPLATE)."\n"; +$TEMPLATE=~tr#\*/:\\#\245:\304\266#; +print MF $TEMPLATE; + +print(STDERR "$MAKEFILE successfully generated.\n"); +exit; + +# Assuming the arguments are sorted, returns a copy with all duppliactes +# removed. +# @SPARSE_LIST = &uniq(@DUP_LIST); +sub uniq +{ + if (@_==0) { return (); } + if (@_==1) { return @_; } + local($N); + for ($N=0; $N<$#_; $N++) + { + $_[$N]=undef if $_[$N] eq $_[$N+1]; + } + return(grep(defined($_), @_)); +} + +# Makes a makefile line-list from a list of sources. +# @MACFILE_MACLIST = &make_macfile_maclist(@SOURCE_FILES); +sub make_macfile_maclist +{ + local(@LINES)=@_; + local($I); + for $I (0..$#LINES) + { + $LINES[$I]=~s|/|:|g; + $LINES[$I]=~s|^|:|g; + if ($LINES[$I]=~/:.:/) { $LINES[$I]=undef; } + elsif ($LINES[$I]=~/:mac:/) { $LINES[$I]=undef; } + } + grep(defined($_), @LINES); +} + +# Returns a list of files needed in the mac build. +# @FILES = &make_macfile_list (); +sub make_macfile_list +{ + local(@MAKEFILE)=&merge_continue_lines(&read_file("Makefile.in")); + local($MACDIRS)=&extract_variable("MAC_SUBDIRS", @MAKEFILE); + local(@RETVAL)=&macfiles_sh(split(/\s+/, $MACDIRS)); + + local(@MACFILES)=split(/\s+/, &extract_variable("MACFILES", @MAKEFILE)); + local(@FOUND)=(); + local($MACFILE); + for $MACFILE (@MACFILES) + { + push(@FOUND, &find_and_glob($MACFILE)); + } + + push(@RETVAL, &sed_exclude("config/winexclude.sed", @FOUND)); + @RETVAL; +} + +# Applies SEDFILE to STREAM. Only deletions are valid. +# This could be expanded if neccessary. +# @OUT = &sed_exclude($SEDFILE, @STREAM); +sub sed_exclude +{ + if ($#_<1) + { + print STDERR "Invalid call to sed_exclude.\n"; + exit(1); + # I have this error because it always indicates + # that something is wrong, not because a one argument + # call doesn't make sense. + } + local ($SEDFILE, @STREAM)=($_[0], @_[1..$#_]); + local (@SEDLINES)=&read_file($SEDFILE); + local (@DELLINES)=grep(s#^/(.*)/d$#$1#, @SEDLINES); + if (@SEDLINES!=@DELLINES) + { + print STDERR "sed script $SEDFILE confused me.\n"; + exit(1); + } + local ($LINE, @RETVALS); + @RETVALS=(); + for $LINE (@STREAM) + { + local($RET)=(1); + for $DEL (@DELLINES) + { + if ($LINE=~/$DEL/) + { + $RET=0; + } + } + $RET && push(@RETVALS, $LINE); + } + @RETVALS; +} + +# Returns a list of files that match a glob. You can only glob in the +# filename part...no directories allowed. Only real files (no dirs, +# block specials, etc.) are returned. An example argument is +# "./vers?filesfoo*.c". ?'s and *'s are valid globbing characters. You +# can push your luck with []'s, but it is untested. Files must be visible. +# @FILES = &find_and_glob("$BASEDIR/$FILEGLOB"); +sub find_and_glob +{ + local($PATTERN)=($_[0]); + local($DIR, $FILE)=($PATTERN=~m|^(.*)/([^/]*)$|)[0,1]; + if (!defined($FILE) || !defined($DIR) || length($DIR)<1 || length($FILE)<1) + { + print STDERR "Invalid call to find_and_glob.\n"; + exit(1); + } + $FILE=~s/\./\\\./g; + $FILE=~s/\*/\.\*/g; + $FILE=~s/\?/./g; + local (@FILES)=&list_in_dir($DIR, $FILE); + local (@RETVAL)=(); + for (@FILES) + { + push(@RETVAL, "$DIR/$_"); + } + @RETVAL; +} + +# Recurses over @DIRS and returns a list of files needed for the mac krb5 +# build. It is similar to the macfiles.sh script. +# @MACFILES = &macfiles_sh(@DIRS); +sub macfiles_sh +{ + local (@RETVAL)=(); + local ($DIR); + for $DIR (@_) + { + local (@MAKEFILE); + @MAKEFILE=&merge_continue_lines(&read_file("$DIR/Makefile.in")); + for $SDIR (split(/\s+/, &extract_variable("MAC_SUBDIRS", @MAKEFILE))) + { + local(@MAKEFILE)=&merge_continue_lines( + &read_file("$DIR/$SDIR/Makefile.in")); + local(@SRCS)=(split(/\s+/, (&extract_variable('MACSRCS', @MAKEFILE) . + &extract_variable('MACSRC', @MAKEFILE) . + &extract_variable('SRCS', @MAKEFILE) . + &extract_variable('SRC', @MAKEFILE)))); + @SRCS=grep(/.*\.c/, @SRCS); + local ($SRC); + for $SRC (@SRCS) + { + $SRC=~s|.*/([^/]+)|$1|; + push(@RETVAL, "$DIR/$SDIR/$SRC"); + } + local(@HEADS)=&list_in_dir("$DIR/$SDIR", '.*\.h$'); + local($HEAD); + for $HEAD (@HEADS) + { + push(@RETVAL, "$DIR/$SDIR/$HEAD"); + } + push(@RETVAL, &macfiles_sh("$DIR/$SDIR")); + } + } + @RETVAL; +} +exit; + +# Given a the contents of a makefile in @_[1,$#_], one line to an element, +# returns the Makefile format variable specified in $_[0]. If the +# $FILE_NAME variable is defined, it is used in error messages. +# @MAKEFILE_CONTENTS should have already been filtered through +# merge_continue_lines(). +# $VARIABLE_VALUE = &extract_variable($VARAIBLE_NAME, @MAKEFILE_CONTENTS); +sub extract_variable +{ + local ($FN, $VARNAME, @LINES, @MATCHES); + $FN=defined($FILE_NAME)?$FILE_NAME:""; + + if ($#_<2) + { + print(STDERR "Invalid call to extract_variable.\n"); + exit(1); + } + $VARNAME=$_[0]; + @LINES=@_[1..$#_]; + @MATCHES=grep(/^$VARNAME\s*=.+/, @LINES); + if (@MATCHES>1) + { + print STDERR "Too many matches for variable $VARNAME in $FN.\n"; + exit(1); + } + if (@MATCHES==0) + { + return ""; + } + return ($MATCHES[0]=~/^$VARNAME\s*=\s*(.*)$/)[0]; +} + +# Print the arguments separated by newlines. +# &print_lines(@LINES); +sub print_lines +{ + print(join("\n", @_), "\n"); +} + +# Given an array of lines, returns the same array transformed to have +# all lines ending in backslashes merged with the following lines. +# @LINES = &merge_continue_lines(@RAWLINES); +sub merge_continue_lines +{ + local ($LONG)=join("\n", @_); + $LONG=~s/\\\n/ /g; + return split('\n', $LONG); +} + +# Returns the contents of the file named $_[0] in an array, one line +# in each element. Newlines are stripped. +# @FILE_CONTENTS = &read_file($FILENAME); +sub read_file +{ + die("Bad call to read_file") unless defined $_[0]; + local($FN) = (&chew_on_filename($_[0])); + local (@LINES, @NLFREE_LINES); + + if (!open(FILE, $FN)) + { + print(STDERR "Can't open $FN.\n"); + exit(1); + } + + @LINES=; + @NLFREE_LINES=grep(s/\n$//, @LINES); + + if (!close(FILE)) + { + print(STDERR "Can't close $FN.\n"); + exit(1); + } + + @NLFREE_LINES; +} + +# lists files that match $PATTERN in $DIR. +# Returned files must be real, visible files. +# @FILES = &list_in_dir($DIR, $PATTERN); +sub list_in_dir +{ + local ($DIR, $PATTERN) = @_[0,1]; + local ($MACDIR)=&chew_on_filename($DIR); + opendir(DIRH, $MACDIR) || die("Can't open $DIR"); + local(@FILES)=readdir(DIRH); + closedir(DIRH); + local (@RET)=(); + for (@FILES) + { + local($FILE)=$_; + if ($FILE=~/^$PATTERN$/ && &is_a_file("$DIR/$_") && $FILE=~/^[^.]/) + { + push(@RET, $FILE); + } + } + @RET; +} + +# Returns whether the argument exists and is a real file. +# $BOOL = &is_a_file($FILENAME); +sub is_a_file +{ + die("Invalid call to is_a_file()") unless defined($_[0]); + local($FILE)=$_[0]; + return -f &chew_on_filename($FILE); +} + +# Returns the argument, interpretted as a filename, munged +# for the local "Operating System", as defined by $^O. +# As of now, fails on full pathnames. +# $LOCALFN = &chew_on_filename($UNIXFN); +sub chew_on_filename +{ + if (@_!=1) + { + print(STDERR "Bad call to chew_on_filename.\n"); + exit(1); + } + $_=$_[0]; + + $_="$ROOT/$_"; + + if ($^O eq 'MacOS') + { + s%/\.\./%:/%g; + s%^\.\./%/%; + s%^\./%%; + s%/\./%/%g; + s%/\.$%%g; + s%/%:%g; + s%^%:%g; + s%^:\.$%:%; + } + + return $_; +} + +# Deletes a file +# &delete_file($FILE); +sub delete_file +{ + die("Illegal call to delete_file()") unless defined $_[0]; + unlink(&chew_on_filename($_[0])); +} + +# Returns a one-level deep copy of an array. +# @B = ©_array(@A); +sub copy_array +{ + local (@A)=(); + for (@_) + { + push(@A, $_); + } + @A; +} +